Documentation of 'de.erichseifert.gral.plots.legends.AbstractLegend' Java class
AbstractLegend
de.erichseifert.gral.plots.legends

Class AbstractLegend

  • All Implemented Interfaces:
    Container, Drawable, Legend, java.io.Serializable, java.lang.Iterable<Drawable>
    Direct Known Subclasses:
    SeriesLegend, ValueLegend


    public abstract class AbstractLegend
    extends DrawableContainer
    implements Legend

    Abstract class that serves as a base for legends in plots. It stores a list of of items that are used to display a symbol and label for each (visible) data source.

    Like other elements legends can be styled using various settings. The settings are used to control to control how the legend, and its items are displayed. The actual rendering of symbols has to be implemented by derived classes.

    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractLegend

        public AbstractLegend()
        Initializes a new instance with a default background color, a border, vertical orientation and a gap between the items. The default alignment is set to top-left.
    • Method Detail

      • draw

        public void draw(DrawingContext context)
        Draws the Drawable with the specified drawing context.
        Specified by:
        draw in interface Drawable
        Overrides:
        draw in class DrawableContainer
        Parameters:
        context - Environment used for drawing.
      • add

        public void add(DataSource source)
        Adds the specified data source in order to display it.
        Specified by:
        add in interface Legend
        Parameters:
        source - data source to be added.
      • contains

        public boolean contains(DataSource source)
        Returns whether the specified data source was added to the legend.
        Specified by:
        contains in interface Legend
        Parameters:
        source - Data source.
        Returns:
        true if legend contains the data source, otherwise false.
      • remove

        public void remove(DataSource source)
        Removes the specified data source.
        Specified by:
        remove in interface Legend
        Parameters:
        source - Data source to be removed.
      • getSources

        public java.util.Set<DataSource> getSources()
        Returns all data sources displayed in this legend.
        Returns:
        Displayed data sources.
      • clear

        public void clear()
        Removes all data sources from the legend.
        Specified by:
        clear in interface Legend
      • setBounds

        public void setBounds(double x,
                              double y,
                              double width,
                              double height)
        Description copied from class: AbstractDrawable
        Sets the bounds to the specified coordinates, width and height. This method should be used when overriding functionality.
        Specified by:
        setBounds in interface Drawable
        Overrides:
        setBounds in class DrawableContainer
        Parameters:
        x - horizontal position of the upper-left corner
        y - vertical position of the upper-left corner
        width - horizontal extent
        height - vertical extent
      • getBaseFont

        public java.awt.Font getBaseFont()
        Description copied from interface: Legend
        Returns the current font used as a default for sub-components ans for calculation of relative sizes.
        Specified by:
        getBaseFont in interface Legend
        Returns:
        Current base font.
      • setBaseFont

        public void setBaseFont(java.awt.Font baseFont)
        Description copied from interface: Legend
        Sets the new font that will be used as a default for sub-components and for calculation of relative sizes. This method is only used internally to propagate the base font and shouldn't be used manually.
        Specified by:
        setBaseFont in interface Legend
        Parameters:
        baseFont - New base font.
      • getBackground

        public java.awt.Paint getBackground()
        Description copied from interface: Legend
        Returns the paint used to draw the background.
        Specified by:
        getBackground in interface Legend
        Returns:
        Paint used for background drawing.
      • setBackground

        public void setBackground(java.awt.Paint background)
        Description copied from interface: Legend
        Sets the paint used to draw the background.
        Specified by:
        setBackground in interface Legend
        Parameters:
        background - Paint used for background drawing.
      • getBorderStroke

        public java.awt.Stroke getBorderStroke()
        Description copied from interface: Legend
        Returns the stroke used to draw the border of the legend.
        Specified by:
        getBorderStroke in interface Legend
        Returns:
        Stroke used for border drawing.
      • setBorderStroke

        public void setBorderStroke(java.awt.Stroke borderStroke)
        Description copied from interface: Legend
        Sets the stroke used to draw the border of the legend.
        Specified by:
        setBorderStroke in interface Legend
        Parameters:
        borderStroke - Stroke used for border drawing.
      • getFont

        public java.awt.Font getFont()
        Description copied from interface: Legend
        Returns the font used to display the labels.
        Specified by:
        getFont in interface Legend
        Returns:
        Font used for labels.
      • setFont

        public void setFont(java.awt.Font font)
        Description copied from interface: Legend
        Sets the font used to display the labels.
        Specified by:
        setFont in interface Legend
        Parameters:
        font - Font used for labels.
      • getBorderColor

        public java.awt.Paint getBorderColor()
        Description copied from interface: Legend
        Returns the paint used to fill the border of the legend.
        Specified by:
        getBorderColor in interface Legend
        Returns:
        Paint used for border drawing.
      • setBorderColor

        public void setBorderColor(java.awt.Paint borderColor)
        Description copied from interface: Legend
        Sets the paint used to fill the border of the legend.
        Specified by:
        setBorderColor in interface Legend
        Parameters:
        borderColor - Paint used for border drawing.
      • getOrientation

        public Orientation getOrientation()
        Description copied from interface: Legend
        Returns the direction of the legend's items.
        Specified by:
        getOrientation in interface Legend
        Returns:
        Item orientation.
      • setOrientation

        public void setOrientation(Orientation orientation)
        Description copied from interface: Legend
        Sets the direction of the legend's items.
        Specified by:
        setOrientation in interface Legend
        Parameters:
        orientation - Item orientation.
      • getAlignmentX

        public double getAlignmentX()
        Description copied from interface: Legend
        Returns the horizontal alignment of the legend relative to the plot area. 0.0 means left, 0.5 means centered, and 1.0 means right.
        Specified by:
        getAlignmentX in interface Legend
        Returns:
        Relative horizontal alignment.
      • setAlignmentX

        public void setAlignmentX(double alignmentX)
        Description copied from interface: Legend
        Sets the horizontal alignment of the legend relative to the plot area. 0.0 means left, 0.5 means centered, and 1.0 means right.
        Specified by:
        setAlignmentX in interface Legend
        Parameters:
        alignmentX - Relative horizontal alignment.
      • getAlignmentY

        public double getAlignmentY()
        Description copied from interface: Legend
        Returns the vertical alignment of the legend relative to the plot area. 0.0 means top, 0.5 means centered, and 1.0 means bottom.
        Specified by:
        getAlignmentY in interface Legend
        Returns:
        Relative vertical alignment.
      • setAlignmentY

        public void setAlignmentY(double alignmentY)
        Description copied from interface: Legend
        Sets the vertical alignment of the legend relative to the plot area. 0.0 means top, 0.5 means centered, and 1.0 means bottom.
        Specified by:
        setAlignmentY in interface Legend
        Parameters:
        alignmentY - Relative vertical alignment.
      • getGap

        public java.awt.geom.Dimension2D getGap()
        Description copied from interface: Legend
        Returns the horizontal and vertical gap between items.
        Specified by:
        getGap in interface Legend
        Returns:
        Gap size relative to the font height.
      • setGap

        public void setGap(java.awt.geom.Dimension2D gap)
        Description copied from interface: Legend
        Sets the horizontal and vertical gap between items.
        Specified by:
        setGap in interface Legend
        Parameters:
        gap - Gap size relative to the font height.
      • getSymbolSize

        public java.awt.geom.Dimension2D getSymbolSize()
        Description copied from interface: Legend
        Returns the size of the legend's symbols.
        Specified by:
        getSymbolSize in interface Legend
        Returns:
        Symbol size relative to the font height.
      • setSymbolSize

        public void setSymbolSize(java.awt.geom.Dimension2D symbolSize)
        Description copied from interface: Legend
        Sets the size of the legend's symbols.
        Specified by:
        setSymbolSize in interface Legend
        Parameters:
        symbolSize - Symbol size relative to the font height.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.