Class LegendGraphic

java.lang.Object
org.jfree.chart.block.AbstractBlock
org.jfree.chart.title.LegendGraphic
All Implemented Interfaces:
Serializable, Cloneable, Block, Drawable, PublicCloneable

public class LegendGraphic extends AbstractBlock implements Block, PublicCloneable
The graphical item within a legend item.
See Also:
  • Field Details

    • serialVersionUID

      static final long serialVersionUID
      For serialization.
      See Also:
    • shapeVisible

      private boolean shapeVisible
      A flag that controls whether or not the shape is visible - see also lineVisible.
    • shape

      private transient Shape shape
      The shape to display. To allow for accurate positioning, the center of the shape should be at (0, 0).
    • shapeLocation

      private RectangleAnchor shapeLocation
      Defines the location within the block to which the shape will be aligned.
    • shapeAnchor

      private RectangleAnchor shapeAnchor
      Defines the point on the shape's bounding rectangle that will be aligned to the drawing location when the shape is rendered.
    • shapeFilled

      private boolean shapeFilled
      A flag that controls whether or not the shape is filled.
    • fillPaint

      private transient Paint fillPaint
      The fill paint for the shape.
    • fillPaintTransformer

      private GradientPaintTransformer fillPaintTransformer
      The fill paint transformer (used if the fillPaint is an instance of GradientPaint).
    • shapeOutlineVisible

      private boolean shapeOutlineVisible
      A flag that controls whether or not the shape outline is visible.
    • outlinePaint

      private transient Paint outlinePaint
      The outline paint for the shape.
    • outlineStroke

      private transient Stroke outlineStroke
      The outline stroke for the shape.
    • lineVisible

      private boolean lineVisible
      A flag that controls whether or not the line is visible - see also shapeVisible.
    • line

      private transient Shape line
      The line.
    • lineStroke

      private transient Stroke lineStroke
      The line stroke.
    • linePaint

      private transient Paint linePaint
      The line paint.
  • Constructor Details

    • LegendGraphic

      public LegendGraphic(Shape shape, Paint fillPaint)
      Creates a new legend graphic.
      Parameters:
      shape - the shape (null not permitted).
      fillPaint - the fill paint (null not permitted).
  • Method Details

    • isShapeVisible

      public boolean isShapeVisible()
      Returns a flag that controls whether or not the shape is visible.
      Returns:
      A boolean.
      See Also:
    • setShapeVisible

      public void setShapeVisible(boolean visible)
      Sets a flag that controls whether or not the shape is visible.
      Parameters:
      visible - the flag.
      See Also:
    • getShape

      public Shape getShape()
      Returns the shape.
      Returns:
      The shape.
      See Also:
    • setShape

      public void setShape(Shape shape)
      Sets the shape.
      Parameters:
      shape - the shape.
      See Also:
    • isShapeFilled

      public boolean isShapeFilled()
      Returns a flag that controls whether or not the shapes are filled.
      Returns:
      A boolean.
      See Also:
    • setShapeFilled

      public void setShapeFilled(boolean filled)
      Sets a flag that controls whether or not the shape is filled.
      Parameters:
      filled - the flag.
      See Also:
    • getFillPaint

      public Paint getFillPaint()
      Returns the paint used to fill the shape.
      Returns:
      The fill paint.
      See Also:
    • setFillPaint

      public void setFillPaint(Paint paint)
      Sets the paint used to fill the shape.
      Parameters:
      paint - the paint.
      See Also:
    • getFillPaintTransformer

      public GradientPaintTransformer getFillPaintTransformer()
      Returns the transformer used when the fill paint is an instance of GradientPaint.
      Returns:
      The transformer (never null).
      See Also:
    • setFillPaintTransformer

      public void setFillPaintTransformer(GradientPaintTransformer transformer)
      Sets the transformer used when the fill paint is an instance of GradientPaint.
      Parameters:
      transformer - the transformer (null not permitted).
      See Also:
    • isShapeOutlineVisible

      public boolean isShapeOutlineVisible()
      Returns a flag that controls whether the shape outline is visible.
      Returns:
      A boolean.
      See Also:
    • setShapeOutlineVisible

      public void setShapeOutlineVisible(boolean visible)
      Sets a flag that controls whether or not the shape outline is visible.
      Parameters:
      visible - the flag.
      See Also:
    • getOutlinePaint

      public Paint getOutlinePaint()
      Returns the outline paint.
      Returns:
      The paint.
      See Also:
    • setOutlinePaint

      public void setOutlinePaint(Paint paint)
      Sets the outline paint.
      Parameters:
      paint - the paint.
      See Also:
    • getOutlineStroke

      public Stroke getOutlineStroke()
      Returns the outline stroke.
      Returns:
      The stroke.
      See Also:
    • setOutlineStroke

      public void setOutlineStroke(Stroke stroke)
      Sets the outline stroke.
      Parameters:
      stroke - the stroke.
      See Also:
    • getShapeAnchor

      public RectangleAnchor getShapeAnchor()
      Returns the shape anchor.
      Returns:
      The shape anchor.
      See Also:
    • setShapeAnchor

      public void setShapeAnchor(RectangleAnchor anchor)
      Sets the shape anchor. This defines a point on the shapes bounding rectangle that will be used to align the shape to a location.
      Parameters:
      anchor - the anchor (null not permitted).
      See Also:
    • getShapeLocation

      public RectangleAnchor getShapeLocation()
      Returns the shape location.
      Returns:
      The shape location.
      See Also:
    • setShapeLocation

      public void setShapeLocation(RectangleAnchor location)
      Sets the shape location. This defines a point within the drawing area that will be used to align the shape to.
      Parameters:
      location - the location (null not permitted).
      See Also:
    • isLineVisible

      public boolean isLineVisible()
      Returns the flag that controls whether or not the line is visible.
      Returns:
      A boolean.
      See Also:
    • setLineVisible

      public void setLineVisible(boolean visible)
      Sets the flag that controls whether or not the line is visible.
      Parameters:
      visible - the flag.
      See Also:
    • getLine

      public Shape getLine()
      Returns the line centered about (0, 0).
      Returns:
      The line.
      See Also:
    • setLine

      public void setLine(Shape line)
      Sets the line. A Shape is used here, because then you can use Line2D, GeneralPath or any other Shape to represent the line.
      Parameters:
      line - the line.
      See Also:
    • getLinePaint

      public Paint getLinePaint()
      Returns the line paint.
      Returns:
      The paint.
      See Also:
    • setLinePaint

      public void setLinePaint(Paint paint)
      Sets the line paint.
      Parameters:
      paint - the paint.
      See Also:
    • getLineStroke

      public Stroke getLineStroke()
      Returns the line stroke.
      Returns:
      The stroke.
      See Also:
    • setLineStroke

      public void setLineStroke(Stroke stroke)
      Sets the line stroke.
      Parameters:
      stroke - the stroke.
      See Also:
    • arrange

      public Size2D arrange(Graphics2D g2, RectangleConstraint constraint)
      Arranges the contents of the block, within the given constraints, and returns the block size.
      Specified by:
      arrange in interface Block
      Overrides:
      arrange in class AbstractBlock
      Parameters:
      g2 - the graphics device.
      constraint - the constraint (null not permitted).
      Returns:
      The block size (in Java2D units, never null).
    • arrangeNN

      protected Size2D arrangeNN(Graphics2D g2)
      Performs the layout with no constraint, so the content size is determined by the bounds of the shape and/or line drawn to represent the series.
      Parameters:
      g2 - the graphics device.
      Returns:
      The content size.
    • draw

      public void draw(Graphics2D g2, Rectangle2D area)
      Draws the graphic item within the specified area.
      Specified by:
      draw in interface Drawable
      Parameters:
      g2 - the graphics device.
      area - the area.
    • draw

      public Object draw(Graphics2D g2, Rectangle2D area, Object params)
      Draws the block within the specified area.
      Specified by:
      draw in interface Block
      Parameters:
      g2 - the graphics device.
      area - the area.
      params - ignored (null permitted).
      Returns:
      Always null.
    • equals

      public boolean equals(Object obj)
      Tests this LegendGraphic instance for equality with an arbitrary object.
      Overrides:
      equals in class AbstractBlock
      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 AbstractBlock
      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 AbstractBlock
      Returns:
      A hash code.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a clone of this LegendGraphic instance.
      Specified by:
      clone in interface PublicCloneable
      Overrides:
      clone in class AbstractBlock
      Returns:
      A clone of this LegendGraphic instance.
      Throws:
      CloneNotSupportedException - if there is a problem cloning.
    • writeObject

      private void writeObject(ObjectOutputStream stream) throws IOException
      Provides serialization support.
      Parameters:
      stream - the output stream.
      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.
      Throws:
      IOException - if there is an I/O error.
      ClassNotFoundException - if there is a classpath problem.