List of usage examples for org.jfree.chart.plot XYPlot addDomainMarker
public void addDomainMarker(Marker marker, Layer layer)
From source file:bicat.gui.GraphicPane.java
/** * Creates a line chart with//from w ww . j av a2s . c o m * 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 myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel, org.jfree.data.xy.XYDataset dataset, double marker, org.jfree.chart.plot.PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); ValueMarker vm = new ValueMarker(marker); vm.setPaint(Color.GRAY); // plot.addRangeMarker(vm, Layer.FOREGROUND); //.setPaint(Color.PINK)); plot.addDomainMarker(vm, Layer.FOREGROUND); plot.setOrientation(orientation); if (tooltips) { renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
From source file:bicat.gui.GraphicPane.java
public static JFreeChart myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel, org.jfree.data.xy.XYDataset dataset, double[] marker, org.jfree.chart.plot.PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); }/*from w w w . j av a 2s. c o m*/ NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); for (int i = 0; i < marker.length; i++) { ValueMarker vm = new ValueMarker(marker[i]); vm.setPaint(Color.GRAY.brighter()); // plot.addRangeMarker(vm, Layer.FOREGROUND); // //.setPaint(Color.PINK)); plot.addDomainMarker(vm, Layer.FOREGROUND); } plot.setOrientation(orientation); if (tooltips) { renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
From source file:org.jfree.chart.demo.PlotOrientationDemo2.java
/** * Creates a new demo instance./* w w w. j a v a2 s . c om*/ * * @param title the frame title. */ public PlotOrientationDemo2(String title) { super(title); JPanel panel = new JPanel(new GridLayout(2, 4)); for (int i = 0; i < CHART_COUNT; i++) { this.datasets[i] = createDataset(i); this.charts[i] = createChart(i, this.datasets[i]); XYPlot plot = this.charts[i].getXYPlot(); XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 2.0, 3.0), new BasicStroke(1.0f), Color.blue); XYLineAnnotation a2 = new XYLineAnnotation(0.0, -5.0, 10.0, -5.0); plot.addAnnotation(a1); plot.addAnnotation(a2); plot.addDomainMarker(new IntervalMarker(5.0, 10.0), Layer.BACKGROUND); plot.addRangeMarker(new IntervalMarker(-2.0, 0.0), Layer.BACKGROUND); this.panels[i] = new ChartPanel(this.charts[i]); } this.charts[1].getXYPlot().getDomainAxis().setInverted(true); this.charts[2].getXYPlot().getRangeAxis().setInverted(true); this.charts[3].getXYPlot().getDomainAxis().setInverted(true); this.charts[3].getXYPlot().getRangeAxis().setInverted(true); this.charts[5].getXYPlot().getDomainAxis().setInverted(true); this.charts[6].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().getDomainAxis().setInverted(true); this.charts[4].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[5].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[6].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[7].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); panel.add(this.panels[0]); panel.add(this.panels[1]); panel.add(this.panels[4]); panel.add(this.panels[5]); panel.add(this.panels[2]); panel.add(this.panels[3]); panel.add(this.panels[6]); panel.add(this.panels[7]); panel.setPreferredSize(new Dimension(800, 600)); setContentPane(panel); }
From source file:org.openfaces.component.chart.impl.configuration.charts.GridChartConfigurator.java
protected void initMarkers(Chart chart, XYPlot xyPlot) { final GridChartView chartView = (GridChartView) chart.getChartView(); final List<Marker> domainMarkers = collectMarkers(chartView, DomainMarkers.class); final List<Marker> rangeMarkers = collectMarkers(chartView, RangeMarkers.class); for (Marker marker : domainMarkers) { org.jfree.chart.plot.Marker domainMarker = initMarker(marker); if (domainMarker != null) { xyPlot.addDomainMarker(domainMarker, getMarkerLayer(marker)); }/*from w w w . j av a 2 s .c o m*/ } for (Marker marker : rangeMarkers) { org.jfree.chart.plot.Marker rangeMarker = initMarker(marker); if (rangeMarker != null) { xyPlot.addRangeMarker(rangeMarker, getMarkerLayer(marker)); } } }
From source file:ec.ui.view.MarginView.java
private void addDateMarkers() { XYPlot plot = chartPanel.getChart().getXYPlot(); if (data.markers != null) { for (Date o : data.markers) { ValueMarker marker = new ValueMarker(new Day(o).getFirstMillisecond()); marker.setStroke(DATE_MARKER_STROKE); marker.setAlpha(DATE_MARKER_ALPHA); plot.addDomainMarker(marker, Layer.FOREGROUND); }// w ww . jav a2 s . c o m } }
From source file:ec.ui.view.MarginView.java
private void addPrecisionMarkers() { TsData tmp = data.series.fittoDomain(data.upper.getDomain()); TsData values = data.multiplicative ? tmp.div(data.upper) : tmp.minus(data.upper); DescriptiveStatistics stats = new DescriptiveStatistics(values); double min = stats.getMin(); double max = stats.getMax(); if (max - min > 0) { XYPlot plot = chartPanel.getChart().getXYPlot(); TsDomain domain = values.getDomain().extend(0, 1); for (int i = 0; i < domain.getLength() - 1; i++) { float val = (float) ((values.get(i) - min) / (max - min)); IntervalMarker marker = new IntervalMarker(domain.get(i).firstday().getTime().getTime(), domain.get(i + 1).firstday().getTime().getTime()); marker.setOutlineStroke(null); marker.setAlpha(1f - val); plot.addDomainMarker(marker, Layer.BACKGROUND); }/*from w w w . j a v a 2 s .c o m*/ } }
From source file:daylightchart.daylightchart.chart.DaylightChart.java
private void createDSTMarker(final XYPlot plot) { if (!riseSetData.usesDaylightTime()) { return;//from w w w.j a v a2s. c om } final long intervalStart = riseSetData.getDstStartDate().atStartOfDay().atZone(ZoneId.systemDefault()) .toInstant().toEpochMilli(); final long intervalEnd = riseSetData.getDstEndDate().atStartOfDay().atZone(ZoneId.systemDefault()) .toInstant().toEpochMilli(); final IntervalMarker dstMarker = new IntervalMarker(intervalStart, intervalEnd, ChartConfiguration.nightColor, new BasicStroke(0.0f), null, null, 0.4f); dstMarker.setLabelPaint(Color.WHITE); dstMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); dstMarker.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); // plot.addDomainMarker(dstMarker, Layer.BACKGROUND); }
From source file:no.met.jtimeseries.chart.ChartPlotter.java
private void paintDomainGridLine(Calendar date, XYPlot plot) { long millis = date.getTimeInMillis(); final Marker originalEnd = new ValueMarker(millis); originalEnd.setPaint(DOMAIN_GRID_LINE_COLOR); originalEnd.setStroke(new BasicStroke(1)); plot.addDomainMarker(originalEnd, Layer.BACKGROUND); }
From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java
/** * Update of animation type StatisticGrafic.ANIMATION_Histogram * @throws ModelException// www.j av a 2 s . c o m */ private void updateHistogram() throws ModelException { Marker meanMarker, minMarker, maxMarker; double mean, min0, max0; XYPlot plot = this.chart.getXYPlot(); String domainAxisLabel = "Observations "; switch (this.statistic.getTypeIndex()) { case Statistic.INDEX_None: break; case Statistic.INDEX_Min_Max: plot.clearDomainMarkers(); min0 = statistic.getMin(); max0 = statistic.getMax(); if (!Double.isNaN(min0)) { minMarker = new ValueMarker(min0); minMarker.setPaint(StatisticGrafic.DIAGRAM_MARKER_MIN_MAX); minMarker.setStroke(new BasicStroke(2.0f)); plot.addDomainMarker(minMarker, Layer.FOREGROUND); } if (!Double.isNaN(max0)) { maxMarker = new ValueMarker(max0); maxMarker.setPaint(StatisticGrafic.DIAGRAM_MARKER_MIN_MAX); maxMarker.setStroke(new BasicStroke(2.0f)); plot.addDomainMarker(maxMarker, Layer.FOREGROUND); } domainAxisLabel += "(min - max)"; break; case Statistic.INDEX_Mean_StdDev: plot.clearDomainMarkers(); min0 = statistic.getMean() - statistic.getStdDev(); max0 = statistic.getMean() + statistic.getStdDev(); mean = statistic.getMean(); if (!Double.isNaN(mean)) { meanMarker = new ValueMarker(mean); meanMarker.setPaint(StatisticGrafic.DIAGRAM_MARKER_MEAN); meanMarker.setStroke(new BasicStroke(2.0f)); plot.addDomainMarker(meanMarker, Layer.FOREGROUND); } if (!Double.isNaN(min0)) { minMarker = new ValueMarker(min0); minMarker.setPaint(StatisticGrafic.DIAGRAM_MARKER_STD_DEV); minMarker.setStroke(new BasicStroke(2.0f)); plot.addDomainMarker(minMarker, Layer.FOREGROUND); } if (!Double.isNaN(max0)) { maxMarker = new ValueMarker(max0); maxMarker.setPaint(StatisticGrafic.DIAGRAM_MARKER_STD_DEV); maxMarker.setStroke(new BasicStroke(2.0f)); plot.addDomainMarker(maxMarker, Layer.FOREGROUND); } domainAxisLabel += "(\u03BC-\u03C3 - mean - \u03BC+\u03C3)"; break; } this.buildHistogramAxisFormat(plot, domainAxisLabel); }
From source file:gda.gui.mca.McaGUI.java
protected void addRegionMarkers(int region, double d, double e) { if (regionMap.containsKey(region)) { double f[] = regionMap.get(region); if (d == f[0] && e == f[1]) return; removeRegionMarkers(region, f[0], f[1]); }//from w w w .ja v a 2 s . c o m XYPlot xy = simplePlot.getChart().getXYPlot(); xy.addDomainMarker(new ValueMarker(d, color[region], new BasicStroke(1), color[region], null, 180), Layer.FOREGROUND); xy.addDomainMarker(new ValueMarker(e, color[region], new BasicStroke(1), color[region], null, 180), Layer.FOREGROUND); regionMap.put(region, new double[] { d, e }); }