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:net.nosleep.superanalyzer.analysis.views.LikesView.java

private void createChart() {
    _chart = ChartFactory.createScatterPlot(Misc.getString("LIKES_VS_PLAYS"),
            Misc.getString("ALBUM_PLAY_COUNT"), Misc.getString("ALBUM_RATING"), _dataset,
            PlotOrientation.VERTICAL, false, true, false);

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LIKES_VS_PLAYS_SUBTITLE")));

    XYPlot plot = (XYPlot) _chart.getPlot();

    ChartUtilities.applyCurrentTheme(_chart);

    plot.setDomainPannable(true);/*w w w . j  a va 2 s. co  m*/
    plot.setRangePannable(true);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // get rid of the little line above/next to the axis
    plot.setDomainZeroBaselinePaint(Color.white);
    plot.setRangeZeroBaselinePaint(Color.white);

    /*
     * NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
     * domainAxis.setAutoRangeIncludesZero(false);
     * 
     * domainAxis.setTickMarkInsideLength(2.0f);
     * domainAxis.setTickMarkOutsideLength(2.0f);
     * 
     * domainAxis.setMinorTickCount(2);
     * domainAxis.setMinorTickMarksVisible(true);
     */
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    /*
     * rangeAxis.setTickMarkInsideLength(2.0f);
     * rangeAxis.setTickMarkOutsideLength(2.0f);
     * rangeAxis.setMinorTickCount(2);
     * rangeAxis.setMinorTickMarksVisible(true);
     */
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // format the line renderer after applying the theme
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

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

public void chartMouseClicked(ChartMouseEvent chartmouseevent) {
    org.jfree.chart.entity.ChartEntity chartentity = chartmouseevent.getEntity();
    if (chartentity != null && (chartentity instanceof LegendItemEntity)) {
        LegendItemEntity legenditementity = (LegendItemEntity) chartentity;
        @SuppressWarnings("rawtypes")
        Comparable comparable = legenditementity.getSeriesKey();
        XYPlot xyplot = (XYPlot) chart.getPlot();
        XYDataset xydataset = xyplot.getDataset();
        XYItemRenderer xyitemrenderer = xyplot.getRenderer();
        for (int i = 0; i < xydataset.getSeriesCount(); i++) {
            xyitemrenderer.setSeriesStroke(i, new BasicStroke(1.0F));
            if (xydataset.getSeriesKey(i).equals(comparable))
                xyitemrenderer.setSeriesStroke(i, new BasicStroke(2.0F));
        }/*from   w  w w  .ja  v a  2 s. co  m*/

    }
}

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

/**
 * Creates a new demo.//from   w  w w. jav a  2 s  .com
 *
 * @param title  the frame title.
 */
public XYStepAreaChartDemo(final String title) {

    super(title);

    this.xySeries = new XYSeries("Some data");
    for (int i = 0; i < TEST_DATA.length; i++) {
        this.xySeries.add((Integer) TEST_DATA[i][0], (Integer) TEST_DATA[i][1]);
    }

    final XYSeriesCollection dataset = new XYSeriesCollection(this.xySeries);

    final JFreeChart chart = createChart(dataset);

    this.chartPanel = new ChartPanel(chart);

    // allow zooming
    //        this.chartPanel.setHorizontalZoom(true);
    //        this.chartPanel.setVerticalZoom(true);

    // size
    this.chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    // make stroke more striking
    final Plot plot = this.chartPanel.getChart().getPlot();
    plot.setOutlineStroke(new BasicStroke(2));
    plot.setOutlinePaint(Color.magenta);

    // add some components to make options changable
    final JPanel main = new JPanel(new BorderLayout());
    final JPanel optionsPanel = new JPanel();

    final String[] options = { ORIENT_VERT, ORIENT_HORIZ };
    this.orientationComboBox = new JComboBox(options);
    this.orientationComboBox.addActionListener(this);
    optionsPanel.add(this.orientationComboBox);

    this.outlineCheckBox = new JCheckBox("Outline");
    this.outlineCheckBox.addActionListener(this);
    optionsPanel.add(this.outlineCheckBox);

    optionsPanel.add(new JLabel("Base"));
    this.rangeBaseTextField = new JTextField("0", 5);
    this.rangeBaseTextField.addActionListener(this);
    optionsPanel.add(this.rangeBaseTextField);

    this.nullValuesCheckBox = new JCheckBox("NULL values");
    this.nullValuesCheckBox.addActionListener(this);
    optionsPanel.add(this.nullValuesCheckBox);

    main.add(optionsPanel, BorderLayout.SOUTH);
    main.add(this.chartPanel);
    setContentPane(main);
}

From source file:hudson.model.LoadStatistics.java

/**
 * Creates a trend chart./*ww  w .java 2  s  .  c om*/
 */
public JFreeChart createChart(CategoryDataset ds) {
    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            null, // range axis label
            ds, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseStroke(new BasicStroke(3));
    configureRenderer(renderer);

    final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:edu.umd.cfar.lamp.chronicle.ChronicleRuler.java

private void drawHashForFrame(int f, PPaintContext paintContext, int atLeast, int atMost, int myWidth) {
    Color color = width2color(myWidth);

    InstantInterval focus = this.viewer.model.getFocus();
    double frameOffset = f - focus.getStartInstant().doubleValue();
    double frameLocation = (frameOffset * this.viewer.getViewLength()) / focus.width();
    int x = (int) (frameLocation); //- paintContext.getLocalClip().getMinX());
    int y2 = 10000;
    int y1 = getRuleOffset(atMost, myWidth);

    drawLine(x, y1, x, y2, color, new BasicStroke(1), paintContext);
}

From source file:RMOS.PieChart.java

/**
 * Creates a chart./*from  w  ww  .j a  va  2  s  . c o  m*/
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Eco Systems Statistics", // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    plot.setSectionPaint(f1.getStationInGroup().get(1), Color.blue);
    plot.setSectionPaint(f1.getStationInGroup().get(1), Color.GREEN);

    // use gradients and white borders for the section colours
    /*plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));*/
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: Eco Recycle Station", new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:org.limy.eclipse.qalab.task.DistanceGraphTask.java

/**
 * @param dataset /*from  www  .java2 s  . c o  m*/
 * @throws IOException 
 * 
 */
private void drawGraph(XYDataset dataset) throws IOException {

    JFreeChart chart = ChartFactory.createScatterPlot("Distance from the Main Sequence", "Instability",
            "Abstractness", dataset, PlotOrientation.VERTICAL, false, false, false);

    XYPlot plot = chart.getXYPlot();

    plot.getRenderer().addAnnotation(
            new XYLineAnnotation(-0.1, 1.1, 1.1, -0.1, new BasicStroke(2), new Color(50, 220, 50)),
            Layer.BACKGROUND);

    plot.getRenderer().setShape(new Ellipse2D.Double(-4, -4, 8, 8));
    plot.getRenderer().setPaint(new Color(0xec, 0x76, 0x37));

    plot.getDomainAxis().setRangeWithMargins(0, 1);
    plot.getRangeAxis().setRangeWithMargins(0, 1);

    chart.getTitle().setPaint(Color.BLUE);

    plot.setDomainCrosshairVisible(true);
    plot.setDomainCrosshairPaint(Color.GRAY);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairPaint(Color.GRAY);

    LimyGraphUtils.writeImagePng(chart, out, 400, 380);

}

From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java

public static JFreeChart chartRoutesByStatus(List<? extends Vehicle> vehicles) {
    CoordDataset nData = new CoordDataset();

    for (int i = 0; i < vehicles.size(); i++) {
        Schedule<?> schedule = vehicles.get(i).getSchedule();
        Map<TaskStatus, CoordSource> vsByStatus = createLinkSourceByStatus(schedule);
        nData.addSeries(i + "-PR", vsByStatus.get(TaskStatus.PERFORMED));
        nData.addSeries(i + "-ST", vsByStatus.get(TaskStatus.STARTED));
        nData.addSeries(i + "-PL", vsByStatus.get(TaskStatus.PLANNED));
    }//ww w .ja va  2 s.  co  m

    JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", nData, PlotOrientation.VERTICAL,
            false, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);
    plot.setBackgroundPaint(Color.white);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesItemLabelsVisible(0, true);

    renderer.setBaseItemLabelGenerator(new LabelGenerator());

    Paint[] paints = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
    Shape[] shapes = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE;

    for (int i = 0; i < vehicles.size(); i++) {
        int s = 3 * i;

        renderer.setSeriesItemLabelsVisible(s + 1, true);
        renderer.setSeriesItemLabelsVisible(s + 2, true);
        renderer.setSeriesItemLabelsVisible(s + 3, true);

        renderer.setSeriesShapesVisible(s + 1, true);
        renderer.setSeriesShapesVisible(s + 2, true);
        renderer.setSeriesShapesVisible(s + 3, true);

        renderer.setSeriesLinesVisible(s + 1, true);
        renderer.setSeriesLinesVisible(s + 2, true);
        renderer.setSeriesLinesVisible(s + 3, true);

        renderer.setSeriesPaint(s + 1, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 2, paints[(i + 1) % paints.length]);
        renderer.setSeriesPaint(s + 3, paints[(i + 1) % paints.length]);

        renderer.setSeriesShape(s + 1, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 2, shapes[(i + 1) % shapes.length]);
        renderer.setSeriesShape(s + 3, shapes[(i + 1) % shapes.length]);

        renderer.setSeriesStroke(s + 2, new BasicStroke(3));
        renderer.setSeriesStroke(s + 3, new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1,
                new float[] { 5f, 5f }, 0));
    }

    return chart;
}

From source file:no.met.jtimeseries.chart.XYWindArrowRenderer.java

private void drawCircle(Graphics2D g) {
    g.setStroke(new BasicStroke(1));
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.drawOval(-arrowHeight / 2, -arrowHeight / 2, arrowHeight, arrowHeight);
}

From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(TITLE, "mm:ss", "Value", dataset, true, true,
            false);/*from ww w  .  j a v  a 2s  . c om*/
    final XYPlot plot = result.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    ValueAxis domain = plot.getDomainAxis();
    domain.setAutoRange(true);
    ValueAxis range = plot.getRangeAxis();
    range.setRange(0, MINMAX);
    range.setAutoRangeMinimumSize(20);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    for (int i = 0; i < SERIES; i++) {
        renderer.setSeriesStroke(i, new BasicStroke(2.0f));
    }

    return result;
}