Class XYPolygonAnnotation

All Implemented Interfaces:
Serializable, Cloneable, Annotation, XYAnnotation, PublicCloneable

public class XYPolygonAnnotation extends AbstractXYAnnotation implements Cloneable, PublicCloneable, Serializable
A polygon annotation that can be placed on an XYPlot. The polygon coordinates are specified in data space.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For serialization.
      See Also:
    • polygon

      private double[] polygon
      The polygon.
    • stroke

      private transient Stroke stroke
      The stroke used to draw the box outline.
    • outlinePaint

      private transient Paint outlinePaint
      The paint used to draw the box outline.
    • fillPaint

      private transient Paint fillPaint
      The paint used to fill the box.
  • Constructor Details

    • XYPolygonAnnotation

      public XYPolygonAnnotation(double[] polygon)
      Creates a new annotation (where, by default, the polygon is drawn with a black outline). The array of polygon coordinates must contain an even number of coordinates (each pair is an (x, y) location on the plot) and the last point is automatically joined back to the first point.
      Parameters:
      polygon - the coordinates of the polygon's vertices (null not permitted).
    • XYPolygonAnnotation

      public XYPolygonAnnotation(double[] polygon, Stroke stroke, Paint outlinePaint)
      Creates a new annotation where the box is drawn as an outline using the specified stroke and outlinePaint. The array of polygon coordinates must contain an even number of coordinates (each pair is an (x, y) location on the plot) and the last point is automatically joined back to the first point.
      Parameters:
      polygon - the coordinates of the polygon's vertices (null not permitted).
      stroke - the shape stroke (null permitted).
      outlinePaint - the shape color (null permitted).
    • XYPolygonAnnotation

      public XYPolygonAnnotation(double[] polygon, Stroke stroke, Paint outlinePaint, Paint fillPaint)
      Creates a new annotation. The array of polygon coordinates must contain an even number of coordinates (each pair is an (x, y) location on the plot) and the last point is automatically joined back to the first point.
      Parameters:
      polygon - the coordinates of the polygon's vertices (null not permitted).
      stroke - the shape stroke (null permitted).
      outlinePaint - the shape color (null permitted).
      fillPaint - the paint used to fill the shape (null permitted).
  • Method Details

    • getPolygonCoordinates

      public double[] getPolygonCoordinates()
      Returns the coordinates of the polygon's vertices. The returned array is a copy, so it is safe to modify without altering the annotation's state.
      Returns:
      The coordinates of the polygon's vertices.
    • getFillPaint

      public Paint getFillPaint()
      Returns the fill paint.
      Returns:
      The fill paint (possibly null).
    • getOutlineStroke

      public Stroke getOutlineStroke()
      Returns the outline stroke.
      Returns:
      The outline stroke (possibly null).
    • getOutlinePaint

      public Paint getOutlinePaint()
      Returns the outline paint.
      Returns:
      The outline paint (possibly null).
    • draw

      public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info)
      Draws the annotation. This method is usually called by the XYPlot class, you shouldn't need to call it directly.
      Specified by:
      draw in interface XYAnnotation
      Specified by:
      draw in class AbstractXYAnnotation
      Parameters:
      g2 - the graphics device.
      plot - the plot.
      dataArea - the data area.
      domainAxis - the domain axis.
      rangeAxis - the range axis.
      rendererIndex - the renderer index.
      info - the plot rendering info.
    • equals

      public boolean equals(Object obj)
      Tests this annotation for equality with an arbitrary object.
      Overrides:
      equals in class AbstractXYAnnotation
      Parameters:
      obj - the object (null permitted).
      Returns:
      A boolean.
    • canEqual

      public boolean canEqual(Object other)
      Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.
      Overrides:
      canEqual in class AbstractXYAnnotation
      Parameters:
      other - Object
      Returns:
      true ONLY if the parameter is THIS class type
    • hashCode

      public int hashCode()
      Returns a hash code for this instance.
      Overrides:
      hashCode in class AbstractXYAnnotation
      Returns:
      A hash code.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a clone.
      Specified by:
      clone in interface PublicCloneable
      Overrides:
      clone in class AbstractAnnotation
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - not thrown by this class, but may be by subclasses.
    • writeObject

      private void writeObject(ObjectOutputStream stream) throws IOException
      Provides serialization support.
      Parameters:
      stream - the output stream (null not permitted).
      Throws:
      IOException - if there is an I/O error.
    • readObject

      private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
      Provides serialization support.
      Parameters:
      stream - the input stream (null not permitted).
      Throws:
      IOException - if there is an I/O error.
      ClassNotFoundException - if there is a classpath problem.