Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesShapesVisible

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesShapesVisible

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesShapesVisible.

Prototype

public void setSeriesShapesVisible(int series, Boolean flag) 

Source Link

Document

Sets the 'shapes visible' flag for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:com.sdk.connector.chart.TimeDomainRenderer.java

public TimeDomainRenderer(final String title, JPanel panel, String side, String type) {
    sdf = protocol.getTimestampFormat();
    this.side = side + type;
    this.type = type;
    serie.setKey(side);//from w w  w  .  j a v  a  2  s .  c o  m
    dataset.addSeries(serie);
    String legendX = "";
    if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("RR"))) {
        legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle")
                .getString("timeRR.ylabel");
    } else {
        legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle")
                .getString("timeBC.ylabel");
    }
    chart = ChartFactory.createTimeSeriesChart(title,
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("time.xlabel"),
            legendX, dataset, true, true, false);

    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS,
            RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
    //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.GREEN));
    // chart.setBackgroundPaint(new Color(220,255,220,0));
    //chart.setBackgroundImage(new javax.swing.ImageIcon(getClass().getResource("/com/sdk/connector/resources/background.png")).getImage());
    chart.addSubtitle(rangeAnnotation);

    plot = (XYPlot) chart.getPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, new DecimalFormat("0.00")));
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    if (side.startsWith(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) {
        renderer.setSeriesPaint(0, Color.BLUE);
    } else {
        renderer.setSeriesPaint(0, Color.RED);
    }

    renderer.setSeriesShape(0, new Ellipse2D.Double(-1.0, -1.0, 3.0, 3.0));
    if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("BC"))) {
        renderer.setSeriesShape(0, new Rectangle2D.Double(-1.0, -1.0, 3.0, 3.0));
    }

    DateTickUnit dtUnit = new DateTickUnit(DateTickUnitType.MINUTE, 1, tickSDF);
    final DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
    domainAxis.setTickUnit(dtUnit);

    //        ValueAxis axis = plot.getDomainAxis();
    //        axis = plot.getRangeAxis();
    //        ((NumberAxis) axis).setTickUnit(new NumberTickUnit(100));

    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    // plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f));
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("CALIBRATING..."));
    plot.setRangePannable(true);
    plot.setDomainPannable(true);
    Color color1 = new Color(0, 0, 0, 24);
    Color color2 = new Color(255, 255, 255, 24);

    GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2);
    plot.setBackgroundPaint(gp);

    chartPanel = new ChartPanel(chart);
    chartPanel.addChartMouseListener(this);
    panel.setLayout(new GridLayout(0, 1));

    panel.add(chartPanel);
    panel.repaint();
    panel.revalidate();

}

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

/**
 * Creates a chart./*from w w  w. j  av  a2  s  . c  o m*/
 *
 * @param dataset  the data for the chart.
 *
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Data vs Data Q-Q plot",      // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

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

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    // renderer.setShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    //  renderer.setLinesVisible(false);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(0, true);

    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0.02);
    rangeAxis.setLowerMargin(0.02);

    // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setUpperMargin(0.02);
    domainAxis.setLowerMargin(0.02);

    // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // OPTIONAL CUSTOMISATION COMPLETED.
    setQQSummary(dataset);
    return chart;

}

From source file:IHM.compargraph.java

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("", "", "", dataset);
    //chart.removeLegend();
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));
    renderer.setSeriesFillPaint(0, Color.WHITE);
    renderer.setUseFillPaint(true);/*from   w  ww.j a  v  a  2 s.c  o  m*/
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

From source file:ui.Graph.java

/**
 * Creates a chart.// w  ww . java2 s  . c om
 *
 * @param dataset
 *            the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) {
    trajectory = traj;

    XYSeries posSeries = new XYSeries("Position");
    XYSeries trajSeries = new XYSeries("Trajectory");
    XYSeries velSeries = new XYSeries("Velocity");
    for (int i = 0; i < setpoints.size(); i++) {

        Setpoint p = setpoints.get(i);
        posSeries.add(p.time, p.position);
        velSeries.add(p.time, p.velocity);
    }

    for (int i = 0; i < trajectory.size(); i++) {

        Setpoint p = trajectory.get(i);
        trajSeries.add(p.time, p.position);

    }

    XYSeriesCollection posDataset = new XYSeriesCollection();
    XYSeriesCollection trajDataset = new XYSeriesCollection();
    XYSeriesCollection velDataset = new XYSeriesCollection();

    posDataset.addSeries(posSeries);
    velDataset.addSeries(velSeries);
    trajDataset.addSeries(trajSeries);
    // create the chart...
    final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title
            "X", // x axis label
            "Y", // y axis label
            posDataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

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

    // final StandardLegend legend = (StandardLegend) chart.getLegend();
    // legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    plot.setDataset(0, posDataset);
    plot.setDataset(1, trajDataset);
    plot.setDataset(2, velDataset);
    plot.setBackgroundPaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer();
    // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f,
    // 1.0f));
    posRenderer.setSeriesPaint(0, Color.BLUE);
    posRenderer.setSeriesLinesVisible(0, true);
    posRenderer.setSeriesShapesVisible(0, false);
    XYStepRenderer trajRenderer = new XYStepRenderer();
    trajRenderer.setSeriesPaint(1, Color.RED);
    trajRenderer.setSeriesStroke(1, new BasicStroke(10));
    trajRenderer.setSeriesLinesVisible(1, true);
    trajRenderer.setSeriesShapesVisible(1, false);

    XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer();
    velRenderer.setSeriesPaint(0, Color.MAGENTA);
    velRenderer.setSeriesLinesVisible(0, true);
    velRenderer.setSeriesShapesVisible(0, false);
    // renderer.setSeriesStroke(1, new BasicStroke(0.01f));
    plot.setRenderer(0, posRenderer);
    plot.setRenderer(1, trajRenderer);
    plot.setRenderer(2, velRenderer);

    for (Setpoint s : trajectory) {
        Marker marker = new ValueMarker(s.time);
        marker.setPaint(Color.DARK_GRAY);
        marker.setLabel(Float.toString((float) s.position));
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(marker);
    }

    XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .75);
    p.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(p);
    XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .7);
    i.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(i);
    XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .65);
    d.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(d);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java

/**
 * Helper method for updateModel(). Adds the gray line at x=0.
 *//*from  w  w  w . j a v  a 2 s .c  o  m*/
private void addLineX(XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) {
    XYSeries line = new XYSeries("");
    line.add(0.5, 0.0);
    line.add(project.getPeriods() + 0.5, 0.0);

    int series = dataset.getSeriesCount();
    dataset.addSeries(line);
    renderer.setSeriesPaint(series, Color.GRAY);
    renderer.setSeriesShapesVisible(series, false);
    renderer.setSeriesLinesVisible(series, true);
    renderer.setSeriesVisibleInLegend(series, false);
}

From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.KaplanMeierPlot.java

private void createChart(XYDataset dataset) {
    //Create the chart, dropping in the data set
    JFreeChart chart = ChartFactory.createXYLineChart("", "Days in Study", "Probability of Survival", dataset,
            PlotOrientation.VERTICAL, false, //legend
            true, //tooltips
            false//urls
    );//from ww w .ja v a  2  s.  c  om
    LegendTitle legend = chart.getLegend();
    XYPlot plot = (XYPlot) chart.getPlot();
    /********************************************************
     * IMPORTANT:
     * Ideally I would create the actual Renderer settings for
     * the at the time I start to march through the 
     * KaplanMeierPlotPointSeriesSets, adding them to the actual
     * Data Set that is going to be going into the Chart plotter.
     * But you have no idea how they are going to be sitting in
     * the Plot dataset so there is no guarantee that setting the
     * renderer based on a supposed index will actually work. In fact
     * it didn't work when I wrote this.
     * 
     */
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) {
        KaplanMeierPlotPointSeries kmSeries = (KaplanMeierPlotPointSeries) finalDataCollection.getSeries(i);
        if (kmSeries.getType() == SeriesType.CENSOR) {
            renderer.setSeriesLinesVisible(i, false);
            renderer.setSeriesShapesVisible(i, true);
        } else if (kmSeries.getType() == SeriesType.PROBABILITY) {
            renderer.setSeriesLinesVisible(i, true);
            renderer.setSeriesShapesVisible(i, false);

        } else {
            //don't show this set as it is not a known type
            renderer.setSeriesLinesVisible(i, false);
            renderer.setSeriesShapesVisible(i, false);
        }
        renderer.setSeriesPaint(i, getKMSetColor(kmSeries.getKey(), kmSeries.getType()), true);
    }

    renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    renderer.setDefaultEntityRadius(6);
    plot.setRenderer(renderer);
    //change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.
    rangeAxis.setAutoRange(true);
    rangeAxis.setRange(0.0, 1.0);
    kmChart = chart;
}

From source file:regression.gui.RegressionChart.java

/**
 * Creates a chart.//from www  .  j  av a2s  . co  m
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesLinesVisible(0, false);

    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(2, false);
    plot.setRenderer(renderer);

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

    return chart;

}

From source file:org.agmip.ui.afsirs.frames.GraphOutput.java

public void addRain() {

    XYSeries rainSeries = new XYSeries("RAIN");
    double[][] RAIN = utils.getRain();
    for (int i = 0; i < 10/*RAIN.length*/; i++) {
        for (int j = 0; j < 10/*RAIN[0].length*/; j++) {
            rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]);
        }/*from w w  w  . j av  a  2  s. com*/
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(rainSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Rain", "Days", "Inches",
            dataset/*,
                   PlotOrientation.VERTICAL, true, true, false*/);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

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

    ChartPanel panel = new ChartPanel(chart);
    jTabbedPane1.addTab("Rain", panel);

}

From source file:org.agmip.ui.afsirs.frames.GraphOutput.java

public void addEvaporationAndTranspiration() {

    XYSeries etSeries = new XYSeries("ET");
    double[][] ET = utils.getET();
    for (int i = 0; i < 10/*ET.length*/; i++) {
        for (int j = 0; j < 10/*ET[0].length*/; j++) {
            etSeries.add(i * ET[0].length + j, ET[i][j]);
        }/*from  ww w .jav a 2 s. co m*/
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(etSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Evaporation Transpiration", "Days", "Inches",
            dataset/*,
                   PlotOrientation.VERTICAL, true, true, false*/);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

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

    ChartPanel panel = new ChartPanel(chart);
    jTabbedPane1.addTab("Evaporation Transpiration", panel);

}

From source file:org.agmip.ui.afsirs.frames.GraphOutput.java

public void addWeather() {
    int nyr = utils.getNYR();
    XYSeries etSeries = new XYSeries("ET");
    double[][] ET = utils.getET();
    for (int i = 0; i < 10/*ET.length*/; i++) {
        for (int j = 0; j < 10/*ET[0].length*/; j++) {
            etSeries.add(i * ET[0].length + j, ET[i][j]);
        }/*from  w  w w.j a  v a  2  s.  com*/
    }

    XYSeries rainSeries = new XYSeries("RAIN");
    double[][] RAIN = utils.getRain();
    for (int i = 0; i < 10/*RAIN.length*/; i++) {
        for (int j = 0; j < 10/*RAIN[0].length*/; j++) {
            rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(etSeries);
    dataset.addSeries(rainSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches",
            dataset/*,
                   PlotOrientation.VERTICAL, true, true, false*/);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

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

    ChartPanel panel = new ChartPanel(chart);
    jTabbedPane1.addTab("Weather", panel);

}