Java 类org.jfree.chart.renderer.xy.XYLineAndShapeRenderer 实例源码

项目:Neural-Network-Programming-with-Java-SecondEdition    文件:Chart.java   
public JFreeChart scatterGridPlot(String xLabel, String yLabel){
    int numDatasets = dataset.size();
    JFreeChart result = ChartFactory.createScatterPlot(chartTitle
            , xLabel
            , yLabel
            , dataset.get(0));
    XYPlot plot = result.getXYPlot();
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));        
    for(int i=1;i<numDatasets;i++){
        plot.setDataset(i,dataset.get(i));
        //XYItemRenderer renderer = plot.getRenderer(i-0);
        plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
        plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
        plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
    }

    return result;
}
项目:iveely.ml    文件:ScatterPlot.java   
private JFreeChart createChart(XYDataset dataset) {

        JFreeChart chart = ChartFactory.createScatterPlot(this.title,
                this.xAxisLabel, this.yAxisLable, dataset, PlotOrientation.VERTICAL, true, true, false);

        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setNoDataMessage("NO DATA");
        XYLineAndShapeRenderer renderer
                = (XYLineAndShapeRenderer) plot.getRenderer();
        renderer.setSeriesOutlinePaint(0, Color.black);
        renderer.setUseOutlinePaint(true);

        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
        domainAxis.setAutoRangeIncludesZero(false);
        return chart;

    }
项目:open-java-trade-manager    文件:ChartJDialog.java   
private void plotSeperate(XYDataset dataset, String p)
  {
    NumberAxis rangeAxis1 = new NumberAxis(p);
rangeAxis1.setAutoRangeIncludesZero(false);     // override default
rangeAxis1.setLowerMargin(0.40);                // to leave room for volume bars
DecimalFormat format = new DecimalFormat("0");
rangeAxis1.setNumberFormatOverride(format);

final ValueAxis timeAxis = new DateAxis("Date");
timeAxis.setLowerMargin(0.02);                  // reduce the default margins
timeAxis.setUpperMargin(0.02);

XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);

XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setBaseToolTipGenerator(
    new StandardXYToolTipGenerator(
        StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
        new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")
    )
);
plot.setRenderer(0, renderer1);

final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot)this.candlestickChart.getPlot();
if (plot != null) cplot1.add(plot, 1);      // weight is 1.
  }
项目:Ordinary-Least-Squares-Demo    文件:ChartOne.java   
private JFreeChart createChart(XYSeriesCollection xySeriesCollection) {
    JFreeChart chart = ChartFactory.createXYLineChart(
            "PlotDemo",
            "X",
            "Y",
            xySeriesCollection,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);
    chart.setBackgroundPaint(Color.white);

    //...Устанавливаем правила для серий
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(2, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesPaint(0, Color.orange);
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesPaint(2, Color.blue);

    XYPlot plot = chart.getXYPlot();
    plot.setOutlinePaint(Color.cyan);
    plot.setRenderer(renderer);

    return chart;
}
项目:parabuild-ci    文件:XYPlotTests.java   
/**
 * Some checks for the getRendererForDataset() method.
 */
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
项目:parabuild-ci    文件:XYPlotTests.java   
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
public void test1654215() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100, 
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Exception e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
项目:ccu-historian    文件:XYPlotTest.java   
/**
 * Some checks for the getRendererForDataset() method.
 */
@Test
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
项目:ccu-historian    文件:XYPlotTest.java   
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
项目:ccu-historian    文件:XYPlotTest.java   
@Test 
public void testRendererIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    assertEquals(renderer, plot.getRenderer(0));

    // we should be able to give a renderer an arbitrary index
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(20, renderer2);
    assertEquals(2, plot.getRendererCount());
    assertEquals(renderer2, plot.getRenderer(20));

    assertEquals(20, plot.getIndexOf(renderer2));
}
项目:ccu-historian    文件:XYPlotTest.java   
@Test 
public void testGetRendererForDataset2() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset2);

    // by default, the renderer with index 0 is used
    assertEquals(renderer, plot.getRendererForDataset(dataset2));

    // add a second renderer with the same index as dataset2, now it will
    // be used
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer);
    assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
项目:ccu-historian    文件:XYPlotTest.java   
@Test
public void testDomainMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset, plotted against a second x axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);

    ValueMarker xMarker1 = new ValueMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
项目:ccu-historian    文件:XYPlotTest.java   
@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);

    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
项目:ccu-historian    文件:ChartFactory.java   
/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return The chart.
 */
public static JFreeChart createXYLineChart(String title, String xAxisLabel,
        String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:jfreechart    文件:ChartFactory.java   
/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings.
 *
 * @param title  the chart title ({@code null} permitted).
 * @param xAxisLabel  a label for the X-axis ({@code null} permitted).
 * @param yAxisLabel  a label for the Y-axis ({@code null} permitted).
 * @param dataset  the dataset for the chart ({@code null} permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     ({@code null} NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return The chart.
 */
public static JFreeChart createXYLineChart(String title, String xAxisLabel,
        String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    Args.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:jfreechart    文件:XYPlotTest.java   
/**
 * Some checks for the getRendererForDataset() method.
 */
@Test
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
项目:jfreechart    文件:XYPlotTest.java   
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
项目:jfreechart    文件:XYPlotTest.java   
@Test 
public void testRendererIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    assertEquals(renderer, plot.getRenderer(0));

    // we should be able to give a renderer an arbitrary index
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(20, renderer2);
    assertEquals(2, plot.getRendererCount());
    assertEquals(renderer2, plot.getRenderer(20));

    assertEquals(20, plot.getIndexOf(renderer2));
}
项目:jfreechart    文件:XYPlotTest.java   
@Test 
public void testGetRendererForDataset2() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset2);

    // by default, the renderer with index 0 is used
    assertEquals(renderer, plot.getRendererForDataset(dataset2));

    // add a second renderer with the same index as dataset2, now it will
    // be used
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer);
    assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
项目:jfreechart    文件:XYPlotTest.java   
@Test
public void testDomainMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset, plotted against a second x axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);

    ValueMarker xMarker1 = new ValueMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
项目:jfreechart    文件:XYPlotTest.java   
@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);

    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
项目:PhET    文件:OrderParameterVsTimeChart.java   
public OrderParameterVsTimeChart( int maxItemCount ) {
    this.maxItemCount = maxItemCount;

    meanSeries = new XYSeries( "Order Parameter vs Time" );
    xySeriesCollection = new XYSeriesCollection( meanSeries );
    domainAxis = new NumberAxis( "Time" );
    rangeAxis = new NumberAxis( "Order Parameter" );
    renderer = new XYLineAndShapeRenderer();

    int MEAN_SERIES = 0;
    renderer.setSeriesStroke( MEAN_SERIES, new BasicStroke( 2 ) );
    renderer.setSeriesLinesVisible( MEAN_SERIES, true );
    renderer.setSeriesShapesVisible( MEAN_SERIES, false );

    xyPlot = new XYPlot( xySeriesCollection,
                         domainAxis,
                         rangeAxis, renderer );
    chart = new JFreeChart( "Order Parameter vs. Time", xyPlot );
    rangeAxis.setRange( -0.01, 1.01 );
    domainAxis.setAutoRange( false );
    domainAxis.setRange( 0, maxItemCount * PlotOrderParameterVsTime.MOD );
}
项目:PhET    文件:StripChartJFCNode.java   
public static JFreeChart createChart( XYDataset dataset, String xaxis, String yaxis ) {
    JFreeChart chart = ChartFactory.createScatterPlot(
            "",  // title
            xaxis,             // x-axis label
            yaxis,   // y-axis label
            dataset,            // data
            PlotOrientation.VERTICAL,
            false,               // create legend?
            false,               // generate tooltips?
            false               // generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRangeAxis().setAutoRange( false );
    plot.getRangeAxis().setRange( -3, 3 );
    plot.getDomainAxis().setRange( 0, 100 );
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( true, false );
    renderer.setStroke( new BasicStroke( 2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1 ) );
    renderer.setPaint( Color.blue );
    plot.setRenderer( renderer );
    return chart;
}
项目:PhET    文件:XYLineAndShapeRendererDemo1.java   
/**
 * Creates a sample chart.
 *
 * @param dataset a dataset for the chart.
 * @return A sample chart.
 */
private static JFreeChart createChart( XYDataset dataset ) {
    JFreeChart chart = ChartFactory.createXYLineChart(
            "XYLineAndShapeRenderer Demo 1",
            "X",
            "Y",
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false
    );
    XYPlot plot = (XYPlot)chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible( 0, true );
    renderer.setSeriesShapesVisible( 0, false );
    renderer.setSeriesLinesVisible( 1, true );
    renderer.setSeriesShapesVisible( 1, false );
    renderer.setToolTipGenerator( new StandardXYToolTipGenerator() );
    renderer.setDefaultEntityRadius( 6 );
    plot.setRenderer( renderer );
    return chart;
}
项目:PhET    文件:JFreeChartIcon.java   
public JFreeChartIcon() {
        XYSeries series = new XYSeries( "" );
        for ( int i = 0; i < 100; i++ ) {
            series.add( i, Math.sin( i / 10.0 ) );
        }
        dataset = new XYSeriesCollection( series );
        JFreeChart jFreeChart = ChartFactory.createXYLineChart( WIStrings.getString( "chart.chart" ), "", "", dataset, PlotOrientation.VERTICAL, false, false, false );
//        jFreeChart.getXYPlot().getRangeAxis().setTickLabelsVisible( false );
//        jFreeChart.getXYPlot().getDomainAxis().setTickLabelsVisible( false );
        BasicStroke stroke = new BasicStroke( 4, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[] { 5, 1 }, 0 );
//        BasicStroke stroke = new BasicStroke( 5 );
        jFreeChart.getXYPlot().setRangeGridlineStroke( stroke );
        jFreeChart.getXYPlot().setRangeGridlinePaint( Color.black );
        jFreeChart.getXYPlot().setDomainGridlineStroke( stroke );
        jFreeChart.getXYPlot().setDomainGridlinePaint( Color.black );
        jFreeChart.setAntiAlias( true );
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( true, false );
        renderer.setPaint( Color.blue );
        renderer.setStroke( new BasicStroke( 10 ) );
//        renderer.set
        jFreeChart.getXYPlot().setRenderer( renderer );
        ChartFrame chartFrame = new ChartFrame( "", jFreeChart );
        chartFrame.setSize( 200, 200 );
        chartFrame.setVisible( true );
        chartFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    }
项目:PhET    文件:StripChartJFCNode.java   
public static JFreeChart createChart( XYDataset dataset, String xaxis, String yaxis ) {
    JFreeChart chart = ChartFactory.createScatterPlot(
            "",  // title
            xaxis,             // x-axis label
            yaxis,   // y-axis label
            dataset,            // data
            PlotOrientation.VERTICAL,
            false,               // create legend?
            false,               // generate tooltips?
            false               // generate URLs?
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRangeAxis().setTickLabelsVisible( false );
    plot.getRangeAxis().setAutoRange( false );
    plot.getRangeAxis().setRange( -1, 1 );
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( true, false );
    renderer.setStroke( new BasicStroke( 2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1 ) );
    renderer.setPaint( Color.blue );
    plot.setRenderer( renderer );
    return chart;
}
项目:aya-lang    文件:XYPlotTest.java   
/**
 * Some checks for the getRendererForDataset() method.
 */
@Test
public void testGetRendererForDataset() {
    XYDataset d0 = new XYSeriesCollection();
    XYDataset d1 = new XYSeriesCollection();
    XYDataset d2 = new XYSeriesCollection();
    XYDataset d3 = new XYSeriesCollection();  // not used by plot
    XYItemRenderer r0 = new XYLineAndShapeRenderer();
    XYItemRenderer r2 = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot();
    plot.setDataset(0, d0);
    plot.setDataset(1, d1);
    plot.setDataset(2, d2);
    plot.setRenderer(0, r0);
    // no renderer 1
    plot.setRenderer(2, r2);
    assertEquals(r0, plot.getRendererForDataset(d0));
    assertEquals(r0, plot.getRendererForDataset(d1));
    assertEquals(r2, plot.getRendererForDataset(d2));
    assertEquals(null, plot.getRendererForDataset(d3));
    assertEquals(null, plot.getRendererForDataset(null));
}
项目:aya-lang    文件:XYPlotTest.java   
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
@Test
public void test1654215() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(1, new XYLineAndShapeRenderer());
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
    }
    catch (Exception e) {
        fail("No exception should be thrown.");
    }
}
项目:aya-lang    文件:XYPlotTest.java   
@Test 
public void testRendererIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    assertEquals(renderer, plot.getRenderer(0));

    // we should be able to give a renderer an arbitrary index
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(20, renderer2);
    assertEquals(2, plot.getRendererCount());
    assertEquals(renderer2, plot.getRenderer(20));

    assertEquals(20, plot.getIndexOf(renderer2));
}
项目:aya-lang    文件:XYPlotTest.java   
@Test 
public void testGetRendererForDataset2() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset2);

    // by default, the renderer with index 0 is used
    assertEquals(renderer, plot.getRendererForDataset(dataset2));

    // add a second renderer with the same index as dataset2, now it will
    // be used
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer);
    assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
项目:aya-lang    文件:XYPlotTest.java   
@Test
public void testDomainMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset, plotted against a second x axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToDomainAxis(99, 1);

    ValueMarker xMarker1 = new ValueMarker(123);
    plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
    assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
            xMarker1));
}
项目:aya-lang    文件:XYPlotTest.java   
@Test
public void testRangeMarkerIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // add a second dataset, plotted against a second axis
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);    
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer2);
    plot.mapDatasetToRangeAxis(99, 1);

    ValueMarker yMarker1 = new ValueMarker(123);
    plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
    assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
项目:aya-lang    文件:ChartFactory.java   
/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-axis (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> NOT permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return The chart.
 */
public static JFreeChart createXYLineChart(String title, String xAxisLabel,
        String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
项目:maf    文件:DCThreadManagerPlotter.java   
private void createFitJFreeCharts(XYSeriesCollection viSeriesCollection) {
    for (int csvCount = 0; csvCount < csvFiles.length; csvCount++) {
        // create chart
        XYSeriesCollection xysc = new XYSeriesCollection();
        xysc.addSeries(viSeriesCollection.getSeries(bestFittingScenarios[csvCount].getScenarioIndex() + csvFiles.length));
        xysc.addSeries(viSeriesCollection.getSeries(csvCount));
        JFreeChart fcchart = ChartFactory.createXYLineChart("Fitting i(v) curve to csv #" + csvCount, "v (V)", "i (mA)",
                xysc, PlotOrientation.VERTICAL, false, true, true);
        XYLineAndShapeRenderer bfsRenderer = new XYLineAndShapeRenderer();
        bfsRenderer.setSeriesShapesVisible(0, false);
        bfsRenderer.setSeriesLinesVisible(0, true);
        bfsRenderer.setSeriesShapesVisible(1, true);
        bfsRenderer.setSeriesLinesVisible(1, true);
        fcchart.getXYPlot().setRenderer(bfsRenderer);
        applyXYChartTheme(fcchart, logI, minIPlotted);
        allCharts.add(fcchart);
    }
}
项目:cy-dataseries    文件:SmoothingChartContainer.java   
public SmoothingChartContainer()
{
    dataset = new DefaultXYDataset();
    dataset.addSeries(NOISY_SERIES_KEY, new double[][] {{0},{0}});
    dataset.addSeries(SMOOTH_SERIES_KEY, new double[][] {{0},{0}});

    noisySeriesIndex = 0;
    smoothSeriesIndex = 1;

    renderer = new XYLineAndShapeRenderer();
    XYPlot plot = new XYPlot(dataset, new NumberAxis("Time"), new NumberAxis(), renderer);
    chart = new JFreeChart(plot);
    plot.setDrawingSupplier(ChartUtils.createDrawingSupplier());

    renderer.setSeriesLinesVisible(noisySeriesIndex, false);
    renderer.setSeriesShapesVisible(noisySeriesIndex, true);

    renderer.setSeriesLinesVisible(smoothSeriesIndex, true);
    renderer.setSeriesShapesVisible(smoothSeriesIndex, false);
}
项目:solrmeter    文件:CacheHistoryPanel.java   
/**
 * Creates the chart of this statistic
 * @return
 */
private Component createChartPanel() {
    NumberAxis xaxis = new NumberAxis(I18n.get(PREFIX + "time"));
    NumberAxis yaxis = new NumberAxis(I18n.get(PREFIX + "entries"));

    plot = new XYPlot(xyDataset, xaxis, yaxis, new XYLineAndShapeRenderer(true, true));

    chart = new JFreeChart("notitle",
            null, plot, true);
    chart.getLegend().setPosition(RectangleEdge.RIGHT);
    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setBorder(CHART_BORDER);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    return chartPanel;
}
项目:JGrafix    文件:ConstrutorGraficoComparativos.java   
private static JFreeChart criarChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            "Comparativo da Evolu��o de Pap�is", "Per�odo", "Evolu��o (%)", dataset, 
            true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer 
        = (XYLineAndShapeRenderer) plot.getRenderer();
    GeneralPath zigzag = new GeneralPath();
    zigzag.moveTo(-6.0f, 0.0f);
    zigzag.lineTo(-3.0f, 6.0f);
    zigzag.lineTo(3.0f, -6.0f);
    zigzag.lineTo(6.0f, 0.0f);
    renderer.setLegendLine(zigzag);
    return chart;

}
项目:cmoct-sourcecode    文件:AScanViewerTool.java   
public void setMax(float max)
{
    for (int i = 0; i < maxData.length; i++)
    {
        maxData[i] = max;
    }

    XYSeriesCollection maxCol = PlotingToolkit
            .getCollection(xData, maxData, "Max");

    XYLineAndShapeRenderer maxRender = new XYLineAndShapeRenderer(true,
            false);
    maxRender.setSeriesPaint(0, Color.MAGENTA);

    previewPlot.getXYPlot().setRenderer(2, maxRender);
    dataPlot.getXYPlot().setRenderer(2, maxRender);

    dataPlot.getXYPlot().setDataset(2, maxCol);
    previewPlot.getXYPlot().setDataset(2, maxCol);
}
项目:cmoct-sourcecode    文件:AScanViewerTool.java   
public void setMin(float min)
{
    for (int i = 0; i < minData.length; i++)
    {
        minData[i] = min;
    }

    XYSeriesCollection minCol = PlotingToolkit
            .getCollection(xData, minData, "Min");

    XYLineAndShapeRenderer minRender = new XYLineAndShapeRenderer(true,
            false);
    minRender.setSeriesPaint(0, Color.RED);

    previewPlot.getXYPlot().setRenderer(1, minRender);
    dataPlot.getXYPlot().setRenderer(1, minRender);

    dataPlot.getXYPlot().setDataset(1, minCol);
    previewPlot.getXYPlot().setDataset(1, minCol);
}
项目:cmoct-sourcecode    文件:PlotingToolkit.java   
public static JFreeChart getPlot(double[] xData, double[] yData, String title, String xlabel, String ylabel)
{

    XYSeriesCollection datCol = getCollection(xData, yData, "Data");

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
    xlabel, // X-Axis label
    ylabel, // Y-Axis label
    new XYSeriesCollection(), // Dataset
    PlotOrientation.VERTICAL, true, // Show legend
    true, true);

    // Add the series
    chart.getXYPlot().setDataset(0, datCol);

    // Set the rendering
    XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true);
    rend1.setShapesVisible(false);
    chart.getXYPlot().setRenderer(0, rend1);

    return chart;
}
项目:cmoct-sourcecode    文件:PlotingToolkit.java   
public static JFreeChart getPlot(double[] yData, String title, String xlabel, String ylabel)
{
    double[] xData = getXDataDouble(yData.length);
    XYSeriesCollection datCol = getCollection(xData, yData, "Data");

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
    xlabel, // X-Axis label
    ylabel, // Y-Axis label
    new XYSeriesCollection(), // Dataset
    PlotOrientation.VERTICAL, true, // Show legend
    true, true);

    // Add the series
    chart.getXYPlot().setDataset(0, datCol);

    // Set the rendering
    XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true);

    chart.getXYPlot().setRenderer(0, rend1);

    return chart;
}