Java Code Examples for org.jfree.chart.plot.XYPlot#addRangeMarker()
The following examples show how to use
org.jfree.chart.plot.XYPlot#addRangeMarker() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarkerTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks that an XYPlot deregisters listeners when clearing markers. */ public void testListenersWithXYPlot() { XYPlot plot = new XYPlot(); ValueMarker marker1 = new ValueMarker(1.0); ValueMarker marker2 = new ValueMarker(2.0); plot.addDomainMarker(marker1); plot.addRangeMarker(marker2); EventListener[] listeners1 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners1).contains(plot)); EventListener[] listeners2 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners2).contains(plot)); plot.clearDomainMarkers(); plot.clearRangeMarkers(); listeners1 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners1).contains(plot)); listeners2 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners2).contains(plot)); }
Example 2
Source File: MarkerTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks that an XYPlot deregisters listeners when clearing markers. */ public void testListenersWithXYPlot() { XYPlot plot = new XYPlot(); ValueMarker marker1 = new ValueMarker(1.0); ValueMarker marker2 = new ValueMarker(2.0); plot.addDomainMarker(marker1); plot.addRangeMarker(marker2); EventListener[] listeners1 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners1).contains(plot)); EventListener[] listeners2 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners2).contains(plot)); plot.clearDomainMarkers(); plot.clearRangeMarkers(); listeners1 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners1).contains(plot)); listeners2 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners2).contains(plot)); }
Example 3
Source File: LineChartPanel.java From nmonvisualizer with Apache License 2.0 | 6 votes |
@Override public void addMarkers(List<Marker> markers) { if (getChart() != null) { XYPlot plot = getChart().getXYPlot(); plot.clearDomainMarkers(); plot.clearRangeMarkers(); for (Marker marker : markers) { if (marker instanceof RangeValueMarker) { plot.addRangeMarker(marker); } else if (marker instanceof DomainValueMarker) { plot.addDomainMarker(marker); } firePropertyChange("annotation", null, marker); } } }
Example 4
Source File: GUIUtils.java From egads with GNU General Public License v3.0 | 5 votes |
/** * Compute the time-series of anomalies. */ public void addAnomalyTS(CombinedDomainXYPlot plot, DataSequence observedSeries, DataSequence expectedSeries) { // Compute the time-series of errors. HashMap<String, ArrayList<Float>> allErrors = aes.initAnomalyErrors(observedSeries, expectedSeries); Float sDAutoSensitivity = (float) 0.0; Float amntAutoSensitivity = (float) 0.0; if (config.getProperty("AUTO_SENSITIVITY_ANOMALY_PCNT") != null) { amntAutoSensitivity = new Float(config.getProperty("AUTO_SENSITIVITY_ANOMALY_PCNT")); } if (config.getProperty("AUTO_SENSITIVITY_SD") != null) { sDAutoSensitivity = new Float(config.getProperty("AUTO_SENSITIVITY_SD")); } String errorDebug = ""; for (int i = 0; i < (aes.getIndexToError().keySet()).size(); i++) { Float[] fArray = (allErrors.get(aes.getIndexToError().get(i))).toArray(new Float[(allErrors.get(aes.getIndexToError().get(i))).size()]); XYDataset data1 = createDataset(fArray, aes.getIndexToError().get(i)); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis(aes.getIndexToError().get(i)); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); // Get threshold. Float d = AutoSensitivity.getLowDensitySensitivity(fArray, sDAutoSensitivity, amntAutoSensitivity); subplot1.addRangeMarker(new ValueMarker(d)); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.add(subplot1, 1); errorDebug += aes.getIndexToError().get(i) + ": " + d + " "; } System.out.println(errorDebug); }
Example 5
Source File: cfCHART.java From openbd-core with GNU General Public License v3.0 | 5 votes |
public void addRangeMarker(XYPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException { IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd()); rangeMarker.setPaint(convertStringToColor(rmData.getColor())); if (rmData.getLabel() != null) { rangeMarker.setLabel(rmData.getLabel()); rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor())); String labelPos = rmData.getLabelPosition(); if (labelPos.equals("top_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { rangeMarker.setLabelAnchor(RectangleAnchor.LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { rangeMarker.setLabelAnchor(RectangleAnchor.CENTER); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); rangeMarker.setLabelFont(getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize())); } plot.addRangeMarker(rangeMarker, org.jfree.ui.Layer.BACKGROUND); }
Example 6
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some tests for the addRangeMarker() method(s). */ public void testAddRangeMarker() { XYPlot plot = new XYPlot(); Marker m = new ValueMarker(1.0); plot.addRangeMarker(m); List listeners = Arrays.asList(m.getListeners( MarkerChangeListener.class)); assertTrue(listeners.contains(plot)); plot.clearRangeMarkers(); listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); assertFalse(listeners.contains(plot)); }
Example 7
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some tests for the addRangeMarker() method(s). */ public void testAddRangeMarker() { XYPlot plot = new XYPlot(); Marker m = new ValueMarker(1.0); plot.addRangeMarker(m); List listeners = Arrays.asList(m.getListeners( MarkerChangeListener.class)); assertTrue(listeners.contains(plot)); plot.clearRangeMarkers(); listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); assertFalse(listeners.contains(plot)); }
Example 8
Source File: SWTTimeSeriesDemo.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); //plot.setForegroundAlpha(0.5f); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } // code to test the alpha channel IntervalMarker interv = new IntervalMarker(120, 150, Color.blue, new BasicStroke(5.0f),null,null,0.2f); plot.addRangeMarker(interv); // code to test the alpha channel within awt colors XYDifferenceRenderer differenceRenderer= new XYDifferenceRenderer( new Color(255, 0, 0, 128),new Color(0, 255, 0, 128), false); plot.setRenderer(differenceRenderer); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 9
Source File: SWTTimeSeriesDemo.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); //plot.setForegroundAlpha(0.5f); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } // code to test the alpha channel IntervalMarker interv = new IntervalMarker(120, 150, Color.blue, new BasicStroke(5.0f),null,null,0.2f); plot.addRangeMarker(interv); // code to test the alpha channel within awt colors XYDifferenceRenderer differenceRenderer= new XYDifferenceRenderer(new Color(255,0,0,128),new Color(0,255,0,128),false); plot.setRenderer(differenceRenderer); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }