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

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

Introduction

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

Prototype

public void setAutoPopulateSeriesShape(boolean auto) 

Source Link

Document

Sets the flag that controls whether or not the series shape list is automatically populated when #lookupSeriesShape(int) is called.

Usage

From source file:org.jax.maanova.plot.PlotUtil.java

/**
 * Create a simple XY renderer which can be used for scatter plots
 * @return  the renderer//  w w  w.j  a v  a  2s  .c  o m
 */
public static XYLineAndShapeRenderer createSimpleScatterPlotRenderer() {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);

    renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F,
            -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS,
            PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS));

    renderer.setUseOutlinePaint(true);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setBaseOutlineStroke(new BasicStroke(0.25F));

    renderer.setSeriesPaint(0, new Color(0x55, 0x55, 0xFF)); // blue
    renderer.setSeriesPaint(1, new Color(0xFF, 0x55, 0x55)); // red

    return renderer;
}

From source file:org.jax.maanova.plot.PlotUtil.java

/**
 * Create a simple monochrome XY renderer which can be used for scatter plots
 * @return  the renderer//from w ww  .  java  2s.co m
 */
public static XYLineAndShapeRenderer createMonochromeScatterPlotRenderer() {
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    renderer.setAutoPopulateSeriesShape(false);
    renderer.setAutoPopulateSeriesOutlinePaint(false);
    renderer.setAutoPopulateSeriesOutlineStroke(false);
    renderer.setAutoPopulateSeriesPaint(false);

    renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F,
            -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS,
            PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS));

    renderer.setUseOutlinePaint(true);
    renderer.setBaseOutlinePaint(Color.BLACK);
    renderer.setBaseOutlineStroke(new BasicStroke(0.25F));

    renderer.clearSeriesPaints(false);
    renderer.setBasePaint(new Color(0x55, 0x55, 0xFF)); // blue

    return renderer;
}

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

private static XYPlot createSubplot1(XYDataset xydataset) {
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setBaseFillPaint(Color.white);
    xylineandshaperenderer.setBaseShape(new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D));
    xylineandshaperenderer.setAutoPopulateSeriesShape(false);
    NumberAxis numberaxis = new NumberAxis("Y");
    numberaxis.setLowerMargin(0.10000000000000001D);
    numberaxis.setUpperMargin(0.10000000000000001D);
    XYPlot xyplot = new XYPlot(xydataset, new DateAxis("Time"), numberaxis, xylineandshaperenderer);
    return xyplot;
}

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

public static JFreeChart createDiveProfileChartPanel(DiveProfile diveProfile, Locale locale,
        LengthUnit lengthUnit) {//from   w ww  .  j  a  v  a  2 s.com
    XYSeries depthSerie = new XYSeries(SERIE_DEPTH);
    XYSeriesCollection depthCollection = new XYSeriesCollection();
    depthCollection.addSeries(depthSerie);

    JFreeChart chart = ChartFactory.createXYAreaChart(null, getDomainLegend(locale),
            getRangeLegend(locale, lengthUnit), depthCollection, PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyp = chart.getXYPlot();

    Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f,
            UIAgent.getInstance().getColorWaterSurface(), false);
    xyp.setBackgroundPaint(p);
    xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid());
    ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat());

    XYAreaRenderer renderer0 = new XYAreaRenderer();
    renderer0.setOutline(true);
    renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom());

    Color baseColor = UIAgent.getInstance().getColorBaseBackground();
    renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50));
    xyp.setRenderer(0, renderer0);

    int i = 1;

    XYSeriesCollection decoEntriesCollection = new XYSeriesCollection();
    XYSeries decoEntriesSerie = new XYSeries(SERIE_DECO_ENTRY);
    decoEntriesCollection.addSeries(decoEntriesSerie);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorDecoEntries());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_ENTRY]);
    xyp.setDataset(i, decoEntriesCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection ascentTooFastCollection = new XYSeriesCollection();
    XYSeries ascentTooFastSerie = new XYSeries(SERIE_WARNING_ASCENT_TOO_FAST);
    ascentTooFastCollection.addSeries(ascentTooFastSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningAscentTooFast());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_ASCENT_TOO_FAST_WARNING]);
    xyp.setDataset(i, ascentTooFastCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection decoWarningCollection = new XYSeriesCollection();
    XYSeries decoWarningSerie = new XYSeries(SERIE_DECO_STOP);
    decoWarningCollection.addSeries(decoWarningSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningDecoCeiling());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_WARNING]);
    xyp.setDataset(i, decoWarningCollection);
    xyp.setRenderer(i, renderer2);

    i++;
    XYSeriesCollection remainBottomTimeCollection = new XYSeriesCollection();
    XYSeries remainBottomTimeSerie = new XYSeries(SERIE_REMAINING_BOTTOM_TIME);
    remainBottomTimeCollection.addSeries(remainBottomTimeSerie);
    renderer2 = new XYLineAndShapeRenderer();
    renderer2.setSeriesLinesVisible(0, false);
    renderer2.setAutoPopulateSeriesShape(false);
    renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningRemainingBottomTime());
    renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_REMAINING_BOTTOM_TIME_WARNING]);
    xyp.setDataset(i, remainBottomTimeCollection);
    xyp.setRenderer(i, renderer2);

    Map<Double, Double> depthEntries = diveProfile.getDepthEntries();
    Set<Double> ascentWarning = diveProfile.getAscentWarnings();
    Set<Double> decoWarnings = diveProfile.getDecoCeilingWarnings();
    Set<Double> remainBottomTime = diveProfile.getRemainingBottomTimeWarnings();
    Set<Double> decoEntryTime = diveProfile.getDecoEntries();

    if (depthEntries.size() > 0 && depthEntries.get(0d) == null) {
        depthEntries.put(0d, 0d);
    }

    for (Double seconds : depthEntries.keySet()) {
        double d = UnitsAgent.getInstance().convertLengthFromModel(depthEntries.get(seconds), lengthUnit);
        depthSerie.add(seconds, Double.valueOf(d));
    }

    if (null != ascentWarning) {
        for (Double seconds : ascentWarning) {
            ascentTooFastSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != decoWarnings) {
        for (Double seconds : decoWarnings) {
            decoWarningSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != remainBottomTime) {
        for (Double seconds : remainBottomTime) {
            remainBottomTimeSerie.add(seconds, depthEntries.get(seconds));
        }
    }

    if (null != decoEntryTime) {
        for (Double seconds : decoEntryTime) {
            decoEntriesSerie.add(seconds, depthEntries.get(seconds));
        }
    }
    return chart;
}

From source file:sim.util.media.chart.ScatterPlotSeriesAttributes.java

/** Produces a ScatterPlotSeriesAttributes object with the given generator, series name, series index,
and desire to display margin options. */
public ScatterPlotSeriesAttributes(ChartGenerator generator, String name, int index, double[][] values,
        SeriesChangeListener stoppable) {
    super(generator, name, index, stoppable);

    setValues(values);/* w w  w . ja va  2 s . co m*/
    super.setSeriesName(name); // just set the name, don't update.  Bypasses standard method below.

    // increment shape counter
    ((ScatterPlotGenerator) generator).shapeCounter++;
    if (((ScatterPlotGenerator) generator).shapeCounter >= shapes.length)
        ((ScatterPlotGenerator) generator).shapeCounter = 0;

    // set the shape
    shapeNum = ((ScatterPlotGenerator) generator).shapeCounter;
    shape = shapes[shapeNum];
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) (((XYPlot) getPlot()).getRenderer());
    renderer.setSeriesShape(getSeriesIndex(), shape);
    renderer.setAutoPopulateSeriesShape(false);
}

From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotSeriesAttributes.java

/** Produces a ScatterPlotSeriesAttributes object with the given generator, series name, series index,
 and desire to display margin options. */
public ScatterPlotSeriesAttributes(ChartGenerator generator, String name, int index, double[][] values,
        SeriesChangeListener stoppable) {
    super(generator, name, index, stoppable);

    setValues(values);//w  w  w  . j av  a2 s .com
    super.setSeriesName(name); // just set the name, don't update.  Bypasses standard method below.

    // increment shape counter
    ((ScatterPlotGenerator) generator).shapeCounter++;
    if (((ScatterPlotGenerator) generator).shapeCounter >= shapes.length) {
        ((ScatterPlotGenerator) generator).shapeCounter = 0;
    }

    // set the shape
    shapeNum = ((ScatterPlotGenerator) generator).shapeCounter;
    shape = shapes[shapeNum];
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) (((XYPlot) getPlot()).getRenderer());
    renderer.setSeriesShape(getSeriesIndex(), shape);
    renderer.setAutoPopulateSeriesShape(false);
}

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 w w  w .j a v a  2 s .c o m
}

From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotSeriesAttributes.java

public void rebuildGraphicsDefinitions() {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) (((XYPlot) getPlot()).getRenderer());
    renderer.setSeriesPaint(getSeriesIndex(), reviseColor(color, opacity));
    // shape may be null at this point, that's fine
    renderer.setSeriesShape(getSeriesIndex(), shape);
    renderer.setAutoPopulateSeriesShape(false);
    repaint();//from ww w  .  j  a  v  a2  s.c  om
}

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

private void showCollection(XYSeriesCollection xyCollection, int shape, Color color) {
    if (null == indexMap.get(xyCollection)) {
        int index = registerCollectionOnPlot(xyCollection);

        XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
        renderer2.setSeriesLinesVisible(0, false);
        renderer2.setAutoPopulateSeriesShape(false);
        renderer2.setSeriesPaint(0, color);
        renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[shape]);
        xyp.setRenderer(index, renderer2);
    }/*from w w w.  jav  a 2s.c o  m*/
}

From source file:userinterface.graph.Graph.java

/**
 * Initialises the GraphModel's series and canvas list. Also starts off the
 * graph update timer (one per chart).//w  w w . j  a v  a  2 s.  c om
 * 
 * @param title
 *            Title of the graph.
 */
public Graph(String title) {
    super(ChartFactory.createXYLineChart(title, "X", "Y", new XYSeriesCollection(), PlotOrientation.VERTICAL,
            true, true, false));

    graphCache = new HashMap<SeriesKey, LinkedList<XYDataItem>>();
    keyToSeries = new HashMap<SeriesKey, XYSeries>();
    keyToGraphSeries = new HashMap<SeriesKey, SeriesSettings>();
    graphTitle = new MultipleLineStringSetting("title", title, "The main title heading for the chart.", this,
            false);
    titleFont = new FontColorSetting("title font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 14), Color.black),
            "The font for the chart's title", this, false);
    legendVisible = new BooleanSetting("legend visible?", new Boolean(true),
            "Should the legend, which displays all of the series headings, be displayed?", this, false);

    String[] choices = { "Left", "Right", "Bottom", "Top" };
    legendPosition = new ChoiceSetting("legend position", choices, choices[RIGHT], "The position of the legend",
            this, false);
    legendFont = new FontColorSetting("legend font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 11), Color.black), "The font for the legend",
            this, false);

    // Some easy references
    chart = super.getChart();
    plot = chart.getXYPlot();
    plot.setBackgroundPaint((Paint) Color.white);
    seriesCollection = (XYSeriesCollection) plot.getDataset();

    xAxisSettings = new AxisSettings("X", true, this);
    yAxisSettings = new AxisSettings("Y", false, this);

    xAxisSettings.addObserver(this);
    yAxisSettings.addObserver(this);

    displaySettings = new DisplaySettings(this);
    displaySettings.addObserver(this);

    seriesList = new SeriesSettingsList(this);

    // create a regular XY line chart
    XYItemRenderer r = plot.getRenderer();
    // if possible, try to match the old grapher
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setAutoPopulateSeriesPaint(true);
        renderer.setAutoPopulateSeriesShape(true);
    }

    plot.setDrawingSupplier(new DefaultDrawingSupplier(SeriesSettings.DEFAULT_PAINTS,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, SeriesSettings.DEFAULT_SHAPES));

    super.setPopupMenu(null);

    /* Make sure the graph resembles its default settings. */
    updateGraph();

    // schedule a periodic timer for graph updates
    new java.util.Timer().scheduleAtFixedRate(new GraphUpdateTask(), 0, // start now
            updateInterval);
}