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.n52.io.img.LineRenderer.java

private Stroke getSolidLineDefinition(LineStyle style) {
    return new BasicStroke(style.getLineWidth());
}

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

/**
 * Displays a sample chart in its own frame.
 *///  www. j  a v  a  2s  .  com
private void displayChart() {

    if (this.frame == null) {

        // create a default chart based on some sample data...
        final String title = "LCACs in use at given time";
        final String xAxisLabel = "Time";
        final String yAxisLabel = "Number of Transports";

        final XYDataset data = createStepXYDataset();

        final JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, data,
                PlotOrientation.VERTICAL, true, // legend
                true, // tooltips
                false // urls
        );

        // then customise it a little...
        chart.setBackgroundPaint(new Color(216, 216, 216));
        final XYPlot plot = chart.getXYPlot();
        plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));
        plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));

        // and present it in a frame...
        this.frame = new ChartFrame("Plan Comparison", chart);
        this.frame.pack();
        RefineryUtilities.positionFrameRandomly(this.frame);
        this.frame.setVisible(true);

    } else {
        this.frame.setVisible(true);
        this.frame.requestFocus();
    }

}

From source file:org.adempiere.webui.apps.graph.jfreegraph.PerformanceGraphBuilder.java

public JFreeChart createIndicatorChart(IndicatorModel model) {
    JFreeChart chart = null;/*from www.  ja v  a  2 s  .com*/
    DefaultValueDataset data = new DefaultValueDataset((float) model.goalModel.getPercent());
    MeterPlot plot = new MeterPlot(data);

    MColorSchema colorSchema = model.goalModel.getColorSchema();
    int rangeLo = 0;
    int rangeHi = 0;
    Point2D start = new Point2D.Float(0, 0);
    Point2D end = new Point2D.Float(50, 50);
    float[] dist = { 0.0f, 0.2f, 0.45f, 0.75f, 1.0f };
    for (int i = 1; i <= 4; i++) {
        switch (i) {
        case 1:
            rangeHi = colorSchema.getMark1Percent();
            break;
        case 2:
            rangeHi = colorSchema.getMark2Percent();
            break;
        case 3:
            rangeHi = colorSchema.getMark3Percent();
            break;
        case 4:
            rangeHi = colorSchema.getMark4Percent();
            break;
        }
        if (rangeHi == 9999)
            rangeHi = (int) Math.floor(rangeLo * 1.5);
        if (rangeLo < rangeHi) {
            Color[] colors = { colorSchema.getColor(rangeHi).brighter().brighter(),
                    colorSchema.getColor(rangeHi).brighter(), colorSchema.getColor(rangeHi),
                    colorSchema.getColor(rangeHi).darker(), colorSchema.getColor(rangeHi).darker().darker() };
            LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors);

            plot.addInterval(new MeterInterval("Normal", //label
                    new Range(rangeLo, rangeHi), //range
                    p, new BasicStroke(7.0f), model.dialBackground));
            rangeLo = rangeHi;
        }
    }
    plot.setRange(new Range(0, rangeLo));
    plot.setDialBackgroundPaint(model.dialBackground);
    plot.setUnits("");
    plot.setDialShape(DialShape.CHORD);
    plot.setNeedlePaint(model.needleColor);
    plot.setTickSize(2000);
    plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8));
    plot.setValueFont(new Font("SansSerif", Font.BOLD, 8));
    plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8));
    plot.setTickLabelPaint(model.tickColor);
    plot.setValuePaint(new Color(0.0f, 0.0f, 0.0f, 0.0f));
    plot.setTickPaint(model.tickColor);
    //
    chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 9), plot, false);

    return chart;
}

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

/**
 * Draws the circle.//from   ww w .  ja v a2s  . c  o m
 * 
 * @param g2  the graphics device.
 * @param area  the area in which to draw.
 */
public void draw(final Graphics2D g2, final Rectangle2D area) {
    final Ellipse2D ellipse = new Ellipse2D.Double(area.getX(), area.getY(), area.getWidth(), area.getHeight());
    if (this.fillPaint != null) {
        g2.setPaint(this.fillPaint);
        g2.fill(ellipse);
    }
    if (this.outlinePaint != null && this.outlineStroke != null) {
        g2.setPaint(this.outlinePaint);
        g2.setStroke(this.outlineStroke);
        g2.draw(ellipse);
    }

    g2.setPaint(Color.black);
    g2.setStroke(new BasicStroke(1.0f));
    final Line2D line1 = new Line2D.Double(area.getCenterX(), area.getMinY(), area.getCenterX(),
            area.getMaxY());
    final Line2D line2 = new Line2D.Double(area.getMinX(), area.getCenterY(), area.getMaxX(),
            area.getCenterY());
    g2.draw(line1);
    g2.draw(line2);
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java

public void createChart() {

    XYPlot xyplot = (XYPlot) report.getPlot();
    // if (this.decoratedChart instanceof TimeChartRenderer ) {

    if (this.results != null && !this.results.isEmpty()) {
        Iterator iter1 = this.results.iterator();
        ValueMarker valuemarker = null;//from  www  .j a  v a  2 s .  c o m
        BlockContainer blockcontainerLabel = new BlockContainer(new ColumnArrangement());
        // blockcontainerLabel.setFrame( new LineBorder() );
        int i = 0;
        while (iter1.hasNext()) {
            Object[] item = (Object[]) iter1.next();
            Date date = (Date) item[1];
            Calendar cal = Calendar.getInstance();
            cal.setTime(date);
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            valuemarker = new ValueMarker(cal.getTimeInMillis(), ChartColor.createDefaultPaintArray()[i],
                    new BasicStroke(2.0F));

            xyplot.addDomainMarker(valuemarker);
            LegendItem legendLabel = new LegendItem((String) item[0], null, null, null,
                    new Line2D.Double(-7.0, 0.0, 7.0, 0.0), valuemarker.getPaint(), valuemarker.getStroke(),
                    valuemarker.getPaint());

            blockcontainerLabel.add(createLegendItemBlock(legendLabel, i));
            i++;
        }
        createLegendBlock(blockcontainerLabel);
    }
    // }
}

From source file:com.okmich.twitanalysis.gui.ApplicationFrame.java

private void setChartPanel(JPanel jpanel) {
    this.negativeSeries = new TimeSeries("Negative", Millisecond.class);
    this.postiveSeries = new TimeSeries("Positive", Millisecond.class);
    this.neutralSeries = new TimeSeries("Neutral", Millisecond.class);
    final TimeSeriesCollection dataset = new TimeSeriesCollection(this.negativeSeries);
    dataset.addSeries(this.postiveSeries);
    dataset.addSeries(this.neutralSeries);
    final JFreeChart chart = createChart(dataset);
    chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.RED);
    chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(2.0f));
    chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GREEN);
    chart.getXYPlot().getRenderer(0).setSeriesStroke(1, new BasicStroke(2.0f));
    chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GRAY);
    chart.getXYPlot().getRenderer(0).setSeriesStroke(2, new BasicStroke(2.0f));
    chart.getPlot().setBackgroundPaint(Color.BLACK);

    final ChartPanel chartPanel = new ChartPanel(chart);

    final JPanel tweetCountPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    tweetCountLabel = new JLabel();
    setTweetCountLabel();/*from www  .  j a  v  a  2 s . c  o m*/
    tweetCountPanel.add(tweetCountLabel);

    jpanel.setLayout(new BorderLayout(10, 10));
    jpanel.add(chartPanel, BorderLayout.CENTER);
    jpanel.add(tweetCountPanel, BorderLayout.SOUTH);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(jpanel);
}

From source file:org.jreserve.gui.plot.charts.AbstractLineChart.java

protected void formatSeries(LineAndShapeRenderer renderer) {
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);/*  w ww.j a v a 2 s.c o  m*/
    renderer.setUseFillPaint(true);
    renderer.setBaseStroke(new BasicStroke(2));

    int count = ((CategoryDataset) dataset).getRowCount();
    ColorGenerator colors = format.getColors();
    for (int i = 0; i < count; i++) {
        Paint color = colors.nextColor();
        renderer.setSeriesPaint(i, color);
        renderer.setSeriesFillPaint(i, color);
    }
}

From source file:de.atomfrede.tools.evalutation.tools.plot.custom.CustomSimplePlot.java

@Override
protected JFreeChart createChart(XYDatasetWrapper... datasetWrappers) {
    XYDatasetWrapper mainDataset = datasetWrappers[0];

    JFreeChart chart = ChartFactory.createXYLineChart(mainDataset.getSeriesName(), "Index",
            mainDataset.getSeriesName(), mainDataset.getDataset(), PlotOrientation.VERTICAL, true, false,
            false);//from  w w w  . j a v a  2 s  . c o  m

    XYPlot plot = (XYPlot) chart.getPlot();
    // all adjustments for first/main dataset
    plot.getRangeAxis(0).setLowerBound(mainDataset.getMinimum());
    plot.getRangeAxis(0).setUpperBound(mainDataset.getMaximum());
    // some additional "design" stuff for the plot
    plot.getRenderer(0).setSeriesPaint(0, mainDataset.getSeriesColor());
    plot.getRenderer(0).setSeriesStroke(0, new BasicStroke(mainDataset.getStroke()));

    for (int i = 1; i < datasetWrappers.length; i++) {
        XYDatasetWrapper wrapper = datasetWrappers[i];
        plot.setDataset(i, wrapper.getDataset());
        chart.setTitle(chart.getTitle().getText() + "/" + wrapper.getSeriesName());

        NumberAxis axis = new NumberAxis(wrapper.getSeriesName());
        plot.setRangeAxis(i, axis);
        plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_RIGHT);

        plot.getRangeAxis(i).setLowerBound(wrapper.getMinimum() - 15.0);
        plot.getRangeAxis(i).setUpperBound(wrapper.getMaximum() + 15.0);
        // map the second dataset to the second axis
        plot.mapDatasetToRangeAxis(i, i);

        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setBaseShapesVisible(false);
        renderer.setSeriesStroke(0, new BasicStroke(wrapper.getStroke()));
        plot.setRenderer(i, renderer);
        plot.getRenderer(i).setSeriesPaint(0, wrapper.getSeriesColor());
    }
    // change the background and gridline colors
    plot.setBackgroundPaint(Color.white);
    plot.setDomainMinorGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    return chart;
}

From source file:playground.dgrether.analysis.charts.DgMixedDeltaUtilsModeGroupChart.java

public JFreeChart createChart() {
    XYPlot plot = new XYPlot();
    ValueAxis xAxis = this.axisBuilder.createValueAxis("% of Population Sorted by Income");
    ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]");
    plot.setDomainAxis(xAxis);//from w w w . j  ava  2  s. co  m
    plot.setRangeAxis(yAxis);
    //RANGE
    xAxis.setRange(0.0, 102.0);
    yAxis.setRange(-0.31, 0.61);

    DgColorScheme colorScheme = new DgColorScheme();

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, colorScheme.COLOR1B);
    renderer1.setSeriesPaint(1, colorScheme.COLOR2B);
    renderer1.setSeriesPaint(2, colorScheme.COLOR3B);
    renderer1.setSeriesPaint(3, colorScheme.COLOR4B);
    plot.setDataset(0, this.inomeModeChoiceDs);
    plot.setRenderer(0, renderer1);

    XYItemRenderer renderer2;
    renderer2 = new XYLineAndShapeRenderer(true, true);
    plot.setDataset(1, this.avgDeltaScoreIncomeDs);
    for (int i = 0; i <= 3; i++) {
        renderer2.setSeriesStroke(i, new BasicStroke(2.0f));
        renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f));
        renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a"));
    }
    plot.setRenderer(1, renderer2);
    JFreeChart chart = new JFreeChart("", plot);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    chart.setTextAntiAlias(true);
    return chart;
}

From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java

private static JFreeChart createChart(final CategoryDataset categorydataset, final String chartTitle) {
    final JFreeChart chart = ChartFactory.createBarChart(chartTitle, "Jobs", "Number of Hits", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");

    chart.setBackgroundPaint(new Color(245, 245, 255));
    chart.setBorderPaint(new Color(204, 204, 204));
    chart.setBorderStroke(new BasicStroke(1f));

    final LegendTitle legend = chart.getLegend();
    legend.setWidth(1000);/*w ww.ja v a 2 s .  c o m*/
    legend.setPosition(RectangleEdge.BOTTOM);

    final BlockBorder border = new BlockBorder(new Color(204, 204, 204));
    legend.setBorder(border);

    final CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot();
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(new Color(204, 204, 204));
    categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    final NumberAxis numberaxis = (NumberAxis) categoryPlot.getRangeAxis();

    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    final BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();
    renderer.setDrawBarOutline(true);

    final ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER);
    renderer.setPositiveItemLabelPosition(itemlabelposition);

    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());

    renderer.setItemLabelsVisible(true);
    return chart;
}