/** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the rectangle surrounding the marker area. * @param markerOffset the marker label offset. * @param labelOffsetType the label offset type. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetType); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetType, LengthAdjustmentType.CONTRACT); } return RectangleAnchor.coordinates(anchorRect, anchor); }
/** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the marker area. * @param markerOffset the marker offset. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ private Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetForRange, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetForRange, LengthAdjustmentType.CONTRACT); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetForRange); } return RectangleAnchor.coordinates(anchorRect, anchor); }
/** * Calculates the (x, y) coordinates for drawing the label for a marker on * the range axis. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the rectangle surrounding the marker. * @param markerOffset the marker offset. * @param labelOffsetType the label offset type. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetType); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetType, LengthAdjustmentType.CONTRACT); } return RectangleAnchor.coordinates(anchorRect, anchor); }
/** * Some checks for the getLabelOffsetType() and setLabelOffsetType() * methods. */ public void testGetSetLabelOffsetType() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType()); m.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelOffsetType(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } }
/** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the rectangle surrounding the marker. * @param markerOffset the marker offset. * @param labelOffsetType the label offset type. * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetType, LengthAdjustmentType.CONTRACT); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetType); } return RectangleAnchor.coordinates(anchorRect, anchor); }
/** * Some checks for the getLabelOffsetType() and setLabelOffsetType() * methods. */ @Test public void testGetSetLabelOffsetType() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType()); m.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelOffsetType(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } }
/** * Calculates the (x, y) coordinates for drawing a marker label. * * @param g2 the graphics device. * @param orientation the plot orientation. * @param dataArea the data area. * @param markerArea the marker area. * @param markerOffset the marker offset. * @param labelOffsetForRange ?? * @param anchor the label anchor. * * @return The coordinates for drawing the marker label. */ private Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, PlotOrientation orientation, Rectangle2D dataArea, Rectangle2D markerArea, RectangleInsets markerOffset, LengthAdjustmentType labelOffsetForRange, RectangleAnchor anchor) { Rectangle2D anchorRect = null; if (orientation == PlotOrientation.HORIZONTAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, labelOffsetForRange, LengthAdjustmentType.CONTRACT); } else if (orientation == PlotOrientation.VERTICAL) { anchorRect = markerOffset.createAdjustedRectangle(markerArea, LengthAdjustmentType.CONTRACT, labelOffsetForRange); } return RectangleAnchor.coordinates(anchorRect, anchor); }
/** * @param plot plot for the marker * @param startVal start postion * @param endVal end position */ protected void addMarker(XYPlot plot, int startVal, int endVal) { IntervalMarker marker = new IntervalMarker(startVal, endVal); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setPaint(new Color(134, 254, 225)); marker.setAlpha((float) 0.60); marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); marker.setLabelPaint(Color.green); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addDomainMarker(marker, Layer.BACKGROUND); ValueMarker markStart = new ValueMarker(startVal, new Color(31, 254, 225), new BasicStroke(2.0f)); ValueMarker markEnd = new ValueMarker(endVal, new Color(31, 254, 225), new BasicStroke(2.0f)); plot.addDomainMarker(markStart, Layer.BACKGROUND); plot.addDomainMarker(markEnd, Layer.BACKGROUND); }
/** * Adds a periodicity marker. * * @param plot plot for the marker * @param startVal start postion * @param endVal end position */ protected void addPeriodMarker(XYPlot plot, int startVal, int endVal) { IntervalMarker marker = new IntervalMarker(startVal, endVal); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setPaint(new Color(134, 254, 225)); marker.setAlpha((float) 0.60); marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); marker.setLabelPaint(Color.blue); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setPaint(Color.blue); plot.addDomainMarker(marker, Layer.BACKGROUND); }
/** * Adds an anomaly marker. * * @param plot plot for the marker * @param startVal start postion * @param endVal end position */ protected void addAnomalyMarker(XYPlot plot, int startVal, int endVal) { IntervalMarker marker = new IntervalMarker(startVal, endVal); marker.setLabelOffsetType(LengthAdjustmentType.EXPAND); marker.setPaint(new Color(134, 254, 225)); marker.setAlpha((float) 0.60); marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); marker.setLabelPaint(Color.pink); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setPaint(Color.pink); plot.addDomainMarker(marker, Layer.BACKGROUND); }