Example usage for org.jfree.chart.plot XYPlot setOutlineStroke

List of usage examples for org.jfree.chart.plot XYPlot setOutlineStroke

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setOutlineStroke.

Prototype

public void setOutlineStroke(Stroke stroke) 

Source Link

Document

Sets the stroke used to outline the plot area and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.jstockchart.plot.TimeseriesPlot.java

private XYPlot createVolumePlot() {
    Font axisFont = new Font("Arial", 0, 12);
    Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    VolumeArea volumeArea = timeseriesArea.getVolumeArea();
    LogicNumberAxis logicVolumeAxis = volumeArea.getLogicVolumeAxis();
    Color volumeColor = new Color(86, 126, 160);
    volumeArea.setVolumeColor(volumeColor);
    CFXNumberAxis volumeAxis = new CFXNumberAxis(logicVolumeAxis.getLogicTicks());
    volumeAxis.setAxisLineVisible(false);
    volumeAxis.setCustomTickCount(2);//from   www  .  j  a  v a2 s  .  c  o  m
    volumeAxis.setTickLabelPaint(volumeColor);
    volumeAxis.setUpperBound(logicVolumeAxis.getUpperBound());
    volumeAxis.setTickLabelFont(axisFont);
    volumeAxis.setTickMarkStroke(stroke);
    volumeAxis.setLowerBound(logicVolumeAxis.getLowerBound());
    volumeAxis.setAutoRangeIncludesZero(true);
    XYAreaRenderer2 volumeRenderer = new XYAreaRenderer2();
    volumeRenderer.setSeriesPaint(0, volumeArea.getVolumeColor());
    //volumeRenderer.setShadowVisible(false);
    volumeRenderer.setSeriesStroke(0, stroke);
    volumeRenderer.setBaseStroke(stroke);
    XYPlot plot = new XYPlot(new TimeSeriesCollection(dataset.getVolumeTimeSeries()), null, volumeAxis,
            volumeRenderer);
    plot.setBackgroundPaint(volumeArea.getBackgroudColor());
    plot.setOrientation(volumeArea.getOrientation());
    plot.setRangeAxisLocation(volumeArea.getVolumeAxisLocation());
    plot.setRangeMinorGridlinesVisible(false);

    Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f,
            new float[] { 1.0f, 1.0f }, 1.0f);
    Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f,
            new float[] { 2.0f, 2.0f }, 1.0f);
    // plot.setBackgroundPaint(Color.RED);
    plot.setRangeGridlineStroke(gridLineStroke);
    plot.setDomainGridlineStroke(gridLineStroke);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);
    plot.setOutlineVisible(true);
    plot.setOutlineStroke(outLineStroke);
    plot.setOutlinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    return plot;
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Generates a Sparkline Bar Graph./* www  .  j  a v  a  2 s  .com*/
 *
 * @param def the key of the statistic object.
 * @return the generated chart.
 */
public JFreeChart generateSparklineBarGraph(String key, String color, Statistic[] def, long startTime,
        long endTime, int dataPoints) {
    Color backgroundColor = getBackgroundColor();

    IntervalXYDataset dataset = (IntervalXYDataset) populateData(key, def, startTime, endTime, dataPoints);
    JFreeChart chart = ChartFactory.createXYBarChart(null, // chart title
            null, // domain axis label
            true, null, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            false, // tooltips?
            false // URLs?
    );

    chart.setBackgroundPaint(backgroundColor);
    chart.setBorderVisible(false);
    chart.setBorderPaint(null);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setBackgroundPaint(backgroundColor);
    plot.setRangeGridlinesVisible(false);

    GraphDefinition graphDef = GraphDefinition.getDefinition(color);
    Color plotColor = graphDef.getInlineColor(0);
    plot.getRenderer().setSeriesPaint(0, plotColor);
    plot.getRenderer().setBaseItemLabelsVisible(false);
    plot.getRenderer().setBaseOutlinePaint(backgroundColor);
    plot.setOutlineStroke(null);
    plot.setDomainGridlinePaint(null);

    ValueAxis xAxis = chart.getXYPlot().getDomainAxis();

    xAxis.setLabel(null);
    xAxis.setTickLabelsVisible(true);
    xAxis.setTickMarksVisible(true);
    xAxis.setAxisLineVisible(false);
    xAxis.setNegativeArrowVisible(false);
    xAxis.setPositiveArrowVisible(false);
    xAxis.setVisible(false);

    ValueAxis yAxis = chart.getXYPlot().getRangeAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    yAxis.setAxisLineVisible(false);
    yAxis.setNegativeArrowVisible(false);
    yAxis.setPositiveArrowVisible(false);
    yAxis.setVisible(false);

    return chart;
}

From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java

/**
 * Generates a SparkLine Time Area Chart.
 * @param key/*from  w w w  . ja  v  a2s.  c  om*/
 * @param stats
 * @param startTime
 * @param endTime
 * @return chart
 */
private JFreeChart generateSparklineAreaChart(String key, String color, Statistic[] stats, long startTime,
        long endTime, int dataPoints) {
    Color backgroundColor = getBackgroundColor();

    XYDataset dataset = populateData(key, stats, startTime, endTime, dataPoints);

    JFreeChart chart = ChartFactory.createXYAreaChart(null, // chart title
            null, // xaxis label
            null, // yaxis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            false, // tooltips?
            false // URLs?
    );

    chart.setBackgroundPaint(backgroundColor);
    chart.setBorderVisible(false);
    chart.setBorderPaint(null);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setForegroundAlpha(1.0f);
    plot.setDomainGridlinesVisible(false);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setBackgroundPaint(backgroundColor);
    plot.setRangeGridlinesVisible(false);

    GraphDefinition graphDef = GraphDefinition.getDefinition(color);
    Color plotColor = graphDef.getInlineColor(0);
    plot.getRenderer().setSeriesPaint(0, plotColor);
    plot.getRenderer().setBaseItemLabelsVisible(false);
    plot.getRenderer().setBaseOutlinePaint(backgroundColor);
    plot.setOutlineStroke(null);
    plot.setDomainGridlinePaint(null);

    NumberAxis xAxis = (NumberAxis) chart.getXYPlot().getDomainAxis();

    xAxis.setLabel(null);
    xAxis.setTickLabelsVisible(true);
    xAxis.setTickMarksVisible(true);
    xAxis.setAxisLineVisible(false);
    xAxis.setNegativeArrowVisible(false);
    xAxis.setPositiveArrowVisible(false);
    xAxis.setVisible(false);

    NumberAxis yAxis = (NumberAxis) chart.getXYPlot().getRangeAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    yAxis.setAxisLineVisible(false);
    yAxis.setNegativeArrowVisible(false);
    yAxis.setPositiveArrowVisible(false);
    yAxis.setVisible(false);

    return chart;
}

From source file:my.electrochem.ElectrochemUI.java

private ChartPanel createChartPanel() {
    //creates a line chart object
    //returns the chart panel
    String chartTitle = "i-E curve";
    String xAxisLabel = "E (V)";
    String yAxisLabel = "i (A)";

    dataset1 = createEmptyDataset();//from   w w  w  .j a v a 2  s.c  o  m

    JFreeChart chart = ChartFactory.createScatterPlot(chartTitle, xAxisLabel, yAxisLabel, dataset1);

    XYPlot plot = chart.getXYPlot();

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setDomainCrosshairLockedOnData(false);
    plot.setRangeCrosshairLockedOnData(false);

    /*chart.addProgressListener(new ChartProgressListener() {
    @Override
    public void chartProgress(ChartProgressEvent cpe) {
        if (cpe.getType() == ChartProgressEvent.DRAWING_FINISHED) {
            //System.out.println("Click event!!");
            XYPlot xyPlot2 = cpe.getChart().getXYPlot();
            System.out.println("drawing finished");
            System.out.println("Xreal:"+xyPlot2.getDomainCrosshairValue()
                   +"Yreal:"+xyPlot2.getRangeCrosshairValue());
            if (click) {
                System.out.println("click true");
                if (x1 == -423.0) {
                    x1 = 0.0;
                    y1 = 0.0;
                            
                }
            
                if (x1 == 0.0 && y1 == 0.0) {
                    System.out.println("print 0,0");
                    click = true;
                    x1 = xyPlot2.getDomainCrosshairValue();
                    y1 = xyPlot2.getRangeCrosshairValue();
                    //xyPlot2.clearAnnotations();
                } else {
                    xyPlot2.clearAnnotations();
                    System.out.println("true-false");
                    click = false;
                    x1 = xyPlot2.getDomainCrosshairValue();
                    y1 = xyPlot2.getRangeCrosshairValue();
                }
                      
                             
            } else {
                System.out.println("click false");
               x2 = xyPlot2.getDomainCrosshairValue();
               y2 = xyPlot2.getRangeCrosshairValue();
               createLineAnn(xyPlot2, x1, y1, x2, y2);
               click = true;
           }
       }
       }
    });*/

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    // sets paint color for each series
    //renderer.setSeriesPaint(0, Color.RED);

    // sets thickness for series (using strokes)
    //renderer.setSeriesStroke(0, new BasicStroke(5.0f));
    renderer.setBaseLinesVisible(true);
    //renderer.setSeriesLinesVisible(0, true);

    //renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(false);
    //srenderer.setDrawSeriesLineAsPath(false);

    plot.setOutlinePaint(Color.BLUE);
    plot.setOutlineStroke(new BasicStroke(2.0f));
    plot.setBackgroundPaint(Color.DARK_GRAY);

    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);

    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.BLACK);

    plot.setRenderer(renderer);

    return new ChartPanel(chart);
}