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

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

Introduction

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

Prototype

public void setSeriesLinesVisible(int series, boolean visible) 

Source Link

Document

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

Usage

From source file:com.mugarov.neview.view.GraphPanel.java

public void setValues(ArrayList<DotBag> dotBags, ArrayList<Median> lines, String name) {

    CoordinateSeries ser;/*from  w ww . j  a va  2  s. c  om*/
    for (DotBag db : dotBags) {

        ser = new CoordinateSeries(db.getName());
        for (Dot d : db) {

            ser.add(d.getCoordinates(), d.getName(), d.getScaffoldName());
            //                System.out.println("New dot:"+d.getLogX()+", "+d.getLogY());
        }

        this.dotSeries.add(ser);
    }

    for (Median med : lines) {
        ser = new CoordinateSeries(med.getName());

        ser.add(med.getStart(), med.getName(), null);
        ser.add(med.getEnd(), med.getName(), null);
        //            System.out.println("New line from " + med.getStart().getX()+","+ med.getStart().getY()+" to "+med.getEnd().getX()+","+ med.getEnd().getY());
        this.lineSeries.add(ser);
    }

    this.seriesCollection = new CoordinateSeriesCollection();

    for (CoordinateSeries dotSeries : this.dotSeries) {
        this.seriesCollection.addSeries(dotSeries);
    }
    for (CoordinateSeries line : this.lineSeries) {
        this.seriesCollection.addSeries(line);
    }

    this.chart = ChartFactory.createXYLineChart(name, GraphPanel.XAxis, GraphPanel.YAxis, this.seriesCollection,
            PlotOrientation.VERTICAL, true, true, false);
    this.chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();

    ExpAxis x1Axis = new ExpAxis(GraphPanel.XAxis);
    ExpAxis y1Axis = new ExpAxis(GraphPanel.YAxis);

    NumberAxis x2Axis = new NumberAxis("Proportion to max of " + GraphPanel.XAxis);
    NumberAxis y2Axis = new NumberAxis("Proportion to max of " + GraphPanel.YAxis);

    plot.setDomainAxis(0, x1Axis);
    plot.setDomainAxis(1, x2Axis);
    plot.setRangeAxis(0, y1Axis);
    plot.setRangeAxis(1, y2Axis);
    //        plot.setDomainAxis(1, yAxis);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    for (int i = 0; i < this.dotSeries.size(); i++) {
        renderer.setSeriesLinesVisible(i, false);
        renderer.setSeriesPaint(i, this.colorGen.get(i));
    }

    for (int i = this.dotSeries.size(); i < this.lineSeries.size() + this.dotSeries.size(); i++) {
        renderer.setSeriesShapesVisible(i, false);
        //             renderer.setSeriesPaint(i, Color.black);
        renderer.setSeriesPaint(i, this.colorGen.get(i - this.dotSeries.size()));
    }

    renderer.setBaseToolTipGenerator(new ItemGenerator());

    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);

    plot.setDomainGridlinePaint(Color.MAGENTA);
    plot.setRangeGridlinePaint(Color.MAGENTA);

    boolean add = (this.chartPanel == null);
    this.chartPanel = new ChartPanel(chart);

    if (add) {
        this.content.add(this.chartPanel, BorderLayout.CENTER);
        this.scroll.setViewportView(this.chartPanel);
    }

    this.setBackground(Color.green);
    this.chartPanel.setBackground(Color.MAGENTA);
    this.updateUI();
}

From source file:loldmg.GUI.MainFrame.java

private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart newchart = ChartFactory.createXYLineChart("Auto Attack DPS", // chart title
            "Level", // x axis label
            "Damage", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//  w  ww  .j  a v a2  s .c om

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    newchart.setBackgroundPaint(Color.GRAY);

    // get a reference to the plot for further customisation...
    final XYPlot plot = newchart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

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

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

    return newchart;

}

From source file:com.naval.gui.Gui.java

private void update() {
    Coordonnees coords = partie.coords;//from   ww  w  .ja  v  a2s  .  c  o m

    XYSeriesCollection dataset = new XYSeriesCollection();

    for (Navire n : partie.navires) {
        XYSeries series = new XYSeries(n.nom);

        for (int m = 0; m < partie.minute; m++) {
            Donnees d = coords.donneesPour(m);
            series.add(d.xs[n.id], d.ys[n.id]);
        }

        if (series.isEmpty() && partie.minute == 0) {
            series.add(n.x, n.y);
        }

        dataset.addSeries(series);
    }

    JFreeChart chart = ChartFactory.createXYLineChart(
            "Map turn " + partie.getHeureMinute() + " visibilite:" + partie.visibilite + "%", // Title
            "x-axis", // x-axis Label
            "y-axis", // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            true, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );

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

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);

    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);

    plot.setRenderer(renderer);

    if (cPanel != null) {
        remove(cPanel);
        cPanel = new ChartPanel(chart);
        add(cPanel, BorderLayout.CENTER);
    } else {
        cPanel = new ChartPanel(chart);
        add(cPanel, BorderLayout.CENTER);
    }

    frame.validate();
}

From source file:networkmonitor.MainIBMApplicationForm.java

/**
 * Creates a chart./*  ww w.  j  a v a2 s . c o m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(

            // put a big space or it'll overlap with the statistics of data...  :) 
            "B/W Usage in KBps:                                                                    ", // chart title
            "Seconds                    ", // x axis label
            "  Usage", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, // Plot Orientation.. it means grap will show you statistics vertically 
            true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // Background color of chart/outside plot........
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    //plot background color inside the graph....
    plot.setBackgroundPaint(Color.orange); //org.jfree.chart.plot.XYPlot;
    //Plot vertical inner graph line.....
    plot.setDomainGridlinePaint(Color.red);
    //plot horizontal inner graph line.....
    plot.setRangeGridlinePaint(Color.blue);

    //Sets the renderer for the PGraphics object that is used for drawing to...
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    // it used to show the up and down connecting line will show or not(RED LINE of graph)
    renderer.setSeriesLinesVisible(1, true);
    //renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);//it used to show the up and down block of data(RED Block Of GRAPH)

    //......................................... 

    //..... change the auto tick unit selection to integer units only
    //LIMIT OF X and Y axis GRAPH SIDE DATA (usages/second)
    //.....if I unhide these then only integer number show in X axis,it avoid floating point

    /*final NumberAxis domainAxis = new NumberAxis("X-Axis");
    domainAxis.setRange(0.00,1.00);
     domainAxis.setTickUnit(new NumberTickUnit(0.1));
     final NumberAxis rangeAxis = new NumberAxis("Y-Axis");
      rangeAxis.setRange(0.0,1.0);
     rangeAxis.setTickUnit(new NumberTickUnit(0.0));*/

    //usases(X axis) integer data counting
    //final NumberAxis rangeAxis = (NumberAxis) 
    //plot.getRangeAxis();
    //  rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.
    //..............................................

    return chart;
}

From source file:de.perdian.apps.dashboard.support.chart.ChartStrokeDefinition.java

public void applyTo(XYLineAndShapeRenderer renderer, int index) {
    if (this.getStroke() != null) {
        renderer.setSeriesStroke(index, this.getStroke());
    }/*from   ww  w  .  j  av a 2 s. c o m*/
    if (this.getColor() != null) {
        renderer.setSeriesPaint(index, this.getColor());
    }
    if (this.getSeriesLinesVisible() != null) {
        renderer.setSeriesLinesVisible(index, this.getSeriesLinesVisible().booleanValue());
    }
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartPanelEditor.java

private void showWarningCollection(XYSeriesCollection xyCollection, int shape, Color color) {
    if (null == indexMap.get(xyCollection)) {
        int index = plot.getDatasetCount();
        indexMap.put(xyCollection, index);
        XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
        renderer2.setSeriesLinesVisible(0, false);
        renderer2.setAutoPopulateSeriesShape(false);
        renderer2.setSeriesPaint(0, color);
        renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[shape]);
        plot.setDataset(index, xyCollection);
        plot.setRenderer(index, renderer2);
    }/*from ww  w. j  av a 2  s.c om*/
}

From source file:GUI.PlotCreator.java

private ChartPanel createSeaCurrentSpeedByHPanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "H", "Sea Current Speed",
            createSeaCurrentSpeedDataByH(), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    //XYItemRenderer renderer = xyPlot.getRenderer();
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);//from ww w.  j  a  va 2  s  .co  m
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    xyPlot.setRenderer(renderer);
    return new ChartPanel(jfreechart);
}

From source file:GUI.PlotCreator.java

private ChartPanel createSeaCurrentDirectionByHPanel() {
    JFreeChart jfreechart = ChartFactory.createScatterPlot("Sea Current Direction Plot", "H",
            "Sea Current Direction", createSeaCurrentDirectionDataByH(), PlotOrientation.VERTICAL, true, true,
            false);/* w w w .  j  ava 2  s .c om*/
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    //XYItemRenderer renderer = xyPlot.getRenderer();
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    xyPlot.setRenderer(renderer);
    return new ChartPanel(jfreechart);
}

From source file:GUI.PlotCreator.java

private ChartPanel createEquirectangularErrorPanel(ArrayList<double[]> dataToDisplay) {
    title = "Equirectangular vs Haversine - Error Plot";
    JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Distance Between Points (meters)", "Error",
            createEquirectangularErrorData(dataToDisplay), PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) jfreechart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);
    //XYItemRenderer renderer = xyPlot.getRenderer();
    NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis();
    domain.setVerticalTickLabels(true);/*from w w  w  .j  a  v  a2s  . c o m*/
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesPaint(1, Color.red);
    xyPlot.setRenderer(renderer);
    return new ChartPanel(jfreechart);
}

From source file:org.operamasks.faces.render.graph.LineChartRenderer.java

private void setSeriesLineStyles(XYLineAndShapeRenderer renderer, UIChart comp, int index, UIDataItem item) {
    Boolean drawLines = item.getDrawLines();
    if (drawLines != null) {
        renderer.setSeriesLinesVisible(index, drawLines);
    }/*from  w w  w  .  jav a  2 s . co  m*/

    Float lineWidth = item.getLineWidth();
    LineStyleType lineStyle = item.getLineStyle();
    if (lineWidth == null)
        lineWidth = comp.getLineWidth();
    if (lineStyle == null)
        lineStyle = comp.getLineStyle();
    if (lineWidth != null || lineStyle != null) {
        if (lineWidth == null)
            lineWidth = 1.0f;
        renderer.setSeriesStroke(index, createLineStroke(lineWidth, lineStyle));
    }

    Boolean drawMarkers = item.getDrawMarkers();
    if (drawMarkers != null) {
        renderer.setSeriesShapesVisible(index, drawMarkers);
    }

    Boolean fillMarkers = item.getFillMarkers();
    if (fillMarkers != null) {
        renderer.setSeriesShapesFilled(index, fillMarkers);
    }

    Paint markerFillColor = item.getMarkerFillColor();
    if (markerFillColor == null) {
        markerFillColor = comp.getMarkerFillColor();
        if (markerFillColor == null)
            markerFillColor = renderer.getSeriesPaint(index);
    }
    renderer.setSeriesFillPaint(index, markerFillColor);
}