Example usage for java.awt BasicStroke BasicStroke

List of usage examples for java.awt BasicStroke BasicStroke

Introduction

In this page you can find the example usage for java.awt BasicStroke BasicStroke.

Prototype

public BasicStroke(float width) 

Source Link

Document

Constructs a solid BasicStroke with the specified line width and with default values for the cap and join styles.

Usage

From source file:org.tsho.dmc2.core.chart.TrajectoryRenderer.java

public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) {
    ValueAxis domainAxis = plot.getDomainAxis();
    ValueAxis rangeAxis = plot.getRangeAxis();

    Stroke stroke = new BasicStroke(7f);
    Stroke origStroke = g2.getStroke();
    Color color = Color.BLACK;

    /* transients */
    if (!continua) {
        stepper.initialize();/*ww  w.j  a  v a 2s . c  o m*/

        state = STATE_TRANSIENTS;

        try {
            for (index = 0; index < transients; index++) {
                stepper.step();
                if (stopped) {
                    state = STATE_STOPPED;
                    return;
                }
            }
        } catch (RuntimeException re) {
            throw new RuntimeException(re);
        }

        index = 0;
        prevX = 0;
        prevY = 0;
    }

    state = STATE_POINTS;

    Stepper.Point2D point;
    double[] fullPoint = new double[dataset.getNcol()];
    dataset.clearRows();
    int x, y;
    int start = index;
    int end = 0;
    if (index == 0) {
        end = start + iterations + 1;
    } else {
        end = start + iterations;
    }

    for (; index < end; index++) {
        point = stepper.getCurrentPoint2D();
        stepper.getCurrentValue(fullPoint);
        try {
            dataset.addRow((double[]) fullPoint.clone());
        } catch (DatasetException e) {
            System.err.println(e);
        }

        if (!timePlot) {
            x = (int) domainAxis.valueToJava2D(point.getX(), dataArea, RectangleEdge.BOTTOM);
        } else {
            x = (int) domainAxis.valueToJava2D(index + transients, dataArea, RectangleEdge.BOTTOM);
        }

        y = (int) rangeAxis.valueToJava2D(point.getY(), dataArea, RectangleEdge.LEFT);

        if (Double.isNaN(point.getX()) || Double.isNaN(point.getY())) {
            System.err.println("NaN values at iteration " + index);
            //FIXME
            //Don't simply throw exception: that would mess up the state machine!
            //throw new RuntimeException("NaN values at iteration " + index);
        }

        if (delay > 0) {
            boolean flag = false;

            try {
                Thread.sleep(delay * 5);

                drawItem(g2, index, x, y);

                g2.setXORMode(color);
                g2.setStroke(stroke);
                g2.drawRect(x - 1, y - 1, 3, 3);

                flag = true;

                Thread.sleep(delay * 5);
            } catch (final InterruptedException e) {
            }

            if (flag) {
                g2.drawRect(x - 1, y - 1, 3, 3);
                g2.setPaintMode();
                g2.setStroke(origStroke);
            } else {
                drawItem(g2, index, x, y);
            }
        } else {
            drawItem(g2, index, x, y);
        }

        try {
            stepper.step();
        } catch (RuntimeException re) {
            throw new RuntimeException(re);
        }

        if (stopped) {
            state = STATE_STOPPED;
            return;
        }
    }

    state = STATE_FINISHED;
}

From source file:playground.artemc.calibration.charts.AddSecondChart.java

public void addChartAndAxis() {

    //this.plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF));       
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    //final CategoryAxis domainAxis = plot.getDomainAxis();
    //domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);

    final ValueAxis axis2 = new NumberAxis(yAxisLabel);
    axis2.setRange(lowerLimit, upperLimit);
    plot.setRangeAxis(1, axis2);/*from   w  w  w.  ja va2 s. c  o m*/
    plot.setDataset(1, dataset);
    plot.mapDatasetToRangeAxis(1, 1);

    final LineAndShapeRenderer renderer = new LineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    plot.setRenderer(1, renderer);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setDomainGridlinesVisible(true);

}

From source file:mls.FramePlot.java

public void addMarker(double val, Color colore) {
    ValueMarker mark = new ValueMarker(val, colore, new BasicStroke(1));
    plotMedia.addRangeMarker(mark);/*from   w  w w  . j av  a 2  s  .  c  om*/
}

From source file:org.jfree.chart.demo.HighLowChartDemo3.java

private static JFreeChart createChart(OHLCDataset ohlcdataset) {
    JFreeChart jfreechart = ChartFactory.createHighLowChart("OHLC Demo 3", "Time", "Price", ohlcdataset, true);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    HighLowRenderer highlowrenderer = (HighLowRenderer) xyplot.getRenderer();
    highlowrenderer.setBaseStroke(new BasicStroke(2.0F));
    highlowrenderer.setSeriesPaint(0, Color.blue);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("Price 2");
    numberaxis1.setAutoRangeIncludesZero(false);
    xyplot.setRangeAxis(1, numberaxis1);
    xyplot.setDataset(1, createDataset2());
    xyplot.setRenderer(1, new CandlestickRenderer(10D));
    xyplot.mapDatasetToRangeAxis(1, 1);//from  www .j a  v a2 s . c  o  m
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

From source file:longMethod.jfreechart.draw.XYPolygonAnnotation.java

/**
 * Creates a new annotation (where, by default, the polygon is drawn
 * with a black outline).  The array of polygon coordinates must contain
 * an even number of coordinates (each pair is an (x, y) location on the
 * plot) and the last point is automatically joined back to the first point.
 *
 * @param polygon  the coordinates of the polygon's vertices
 *     (<code>null</code> not permitted).
 *///  w w w. java  2s .  co  m
public XYPolygonAnnotation(double[] polygon) {
    this(polygon, new BasicStroke(1.0f), Color.black);
}

From source file:grafix.graficos.indices.Indice.java

public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) {
    XYLineAndShapeRenderer indicesRenderer = new XYLineAndShapeRenderer();
    indicesRenderer.setSeriesLinesVisible(0, isTracoContinuo());
    indicesRenderer.setSeriesShapesVisible(0, !isTracoContinuo());
    indicesRenderer.setSeriesShape(0, ShapeUtilities.createDiamond(1.5f));
    indicesRenderer.setStroke(new BasicStroke(getEspessura() * 0.5f));
    indicesRenderer.setToolTipGenerator(new IndiceToolTipGenerator(this));
    indicesRenderer.setPaint(getCor());//from w w  w.j a v  a  2 s.  co m
    plot.setRenderer(contador, indicesRenderer);
    plot.setDataset(contador, getDataSet(janela));
}

From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java

public JFreeChart createXYStepChart(XYDataset dataset) {
    XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator);

    XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null);
    plot.setRenderer(renderer);/*from  ww w  .java 2s .  com*/
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend);
    THEME.apply(chart);
    return chart;
}

From source file:org.pentaho.chart.plugin.jfreechart.dial.JFreeDialChartGeneratorIT.java

public void testPlotStyle() throws Exception {
    JFreeChart chart = getJFreeChart("testchart.xml", new Object[][] { { 8D } }); //$NON-NLS-1$
    DialPlot plot = (DialPlot) chart.getPlot();
    DoubleLineDialFrame frame = (DoubleLineDialFrame) plot.getDialFrame();
    assertEquals(frame.getForegroundPaint(), Color.RED);
    assertEquals(frame.getInnerForegroundPaint(), Color.BLUE);
    assertEquals(frame.getBackgroundPaint(), Color.WHITE);
    assertEquals(// ww  w  .  ja  v a2s  . co  m
            String.format("expected: %s but was: %s", 3D, ((BasicStroke) frame.getStroke()).getLineWidth()), //$NON-NLS-1$
            frame.getStroke(),
            new BasicStroke(3F));
}

From source file:org.jfree.experimental.chart.plot.dial.SimpleDialFrame.java

/**
 * Creates a new instance of <code>SimpleDialFrame</code>.
 */// w  w w  .  j  ava 2  s . c  om
public SimpleDialFrame() {
    this.backgroundPaint = Color.gray;
    this.foregroundPaint = Color.black;
    this.stroke = new BasicStroke(2.0f);
    this.radius = 0.95;
}

From source file:edu.ucla.stat.SOCR.chart.demo.XYStepRendererDemo1.java

protected JFreeChart createLegend(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // url
    );//from  w  w w . j  a  va 2  s  . com

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();

    XYStepRenderer renderer = new XYStepRenderer();
    renderer.setBaseStroke(new BasicStroke(2.0f));
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    plot.setRenderer(renderer);
    return chart;

}