Class Legend

  • All Implemented Interfaces:
    java.io.Serializable

    public class Legend
    extends java.lang.Object
    implements java.io.Serializable
    The class responsible for the settings of the charts legend.
    Since:
    8.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Legend()
      Creates a legend with default properties.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getBackColor()
      Returns the ABGR value representing the background color.
      int getLegendColor()
      Returns the ABGR value representing the legend color.
      java.awt.Font getLegendFont()
      Returns the font for all labels in this legend.
      LegendPlacement getLegendPlacement()
      Returns the placement of the legend in the chart.
      int getOutlineColor()
      Returns the ABGR value representing the legend's outline's color.
      int getOutlineStyle()
      Returns the legend's outline's style.
      int getOutlineWidth()
      Returns the width of the legend's outline in twips.
      boolean isDrawOutline()
      Returns whether or not to draw the outline of legend.
      void readProperties​(org.w3c.dom.Element element)
      Loads the properties of a chart legend from an XML element.
      void saveProperties​(java.io.PrintWriter out, int depth)
      Writes the properties of this legend to PrintWriter as XML.
      void setBackColor​(int backgroundColor)
      Sets the ABGR value representing the legend's background color.
      void setDrawOutline​(boolean drawOutline)
      Sets whether or not to draw the outline of legend.
      void setLegendColor​(int legendColor)
      Sets the ABGR value representing the legend color.
      void setLegendFont​(java.awt.Font legendFont)
      Sets the font for all labels in this legend.
      void setLegendPlacement​(LegendPlacement legendPlacement)
      Sets a placement of the legend in the chart.
      void setOutlineColor​(int outlineColor)
      Sets the ABGR components of the legend's outline's color.
      void setOutlineStyle​(int outlineStyle)
      Sets the style of the legend's outline.
      void setOutlineWidth​(int outlineWidth)
      Sets the width of the legend's outline in twips.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_FONT

        public static final java.awt.Font DEFAULT_FONT
        Default legend font.
      • DEFAULT_LABEL_COLOR

        public static final int DEFAULT_LABEL_COLOR
        Default legend color.
        See Also:
        Constant Field Values
      • DEFAULT_LEGEND_OUTLINE_COLOR

        public static final int DEFAULT_LEGEND_OUTLINE_COLOR
        Default legend outline color.
        See Also:
        Constant Field Values
      • TOKEN_LEGEND

        public static final java.lang.String TOKEN_LEGEND
        XML token for legend element.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Legend

        public Legend()
        Creates a legend with default properties.
        Since:
        8.0
    • Method Detail

      • isDrawOutline

        public boolean isDrawOutline()
        Returns whether or not to draw the outline of legend.
        Returns:
        true the outline is to be drawn.
        Since:
        8.0
      • setDrawOutline

        public void setDrawOutline​(boolean drawOutline)
        Sets whether or not to draw the outline of legend.
        Parameters:
        drawOutline - true if outline is to be drawn.
        Since:
        8.0
      • setLegendPlacement

        public void setLegendPlacement​(LegendPlacement legendPlacement)
        Sets a placement of the legend in the chart. To hide the legend, use LegendPlacement.NONE.
        Parameters:
        legendPlacement - the placement object (null not permitted)
        Throws:
        java.lang.IllegalArgumentException - if the legend placement is null.
        Since:
        8.0
      • getLegendFont

        public java.awt.Font getLegendFont()
        Returns the font for all labels in this legend.
        Returns:
        the legend font.
        Since:
        8.0
        See Also:
        setLegendFont(Font)
      • setLegendFont

        public void setLegendFont​(java.awt.Font legendFont)
        Sets the font for all labels in this legend.
        Parameters:
        legendFont - the legend font (null not permitted)
        Since:
        8.0
        See Also:
        getLegendFont()
      • getLegendColor

        public int getLegendColor()
        Returns the ABGR value representing the legend color.
        Returns:
        the ABGR value representing the legend color.
        Since:
        8.0
        See Also:
        ColorUtils.toJavaColor(int), setLegendColor(int)
      • setLegendColor

        public void setLegendColor​(int legendColor)
        Sets the ABGR value representing the legend color.
        Parameters:
        legendColor - ABGR components of the legend color - may not be RDC.COLOR_NO_COLOR
        Throws:
        java.lang.IllegalArgumentException - if the color is RDC.COLOR_NO_COLOR.
        Since:
        8.0
        See Also:
        ColorUtils.toCcColor(Color), getLegendColor()
      • getBackColor

        public int getBackColor()
        Returns the ABGR value representing the background color.
        Returns:
        the background color
        Since:
        8.0
        See Also:
        setBackColor(int), ColorUtils.toJavaColor(int)
      • setBackColor

        public void setBackColor​(int backgroundColor)
        Sets the ABGR value representing the legend's background color.
        Parameters:
        backgroundColor - a background color
        Since:
        8.0
        See Also:
        getBackColor(), ColorUtils.toCcColor(Color)
      • getOutlineColor

        public int getOutlineColor()
        Returns the ABGR value representing the legend's outline's color.
        Returns:
        the legend's outline's color
        Since:
        8.0
        See Also:
        setOutlineColor(int), ColorUtils.toJavaColor(int)
      • getOutlineStyle

        public int getOutlineStyle()
        Returns the legend's outline's style.
        Returns:
        the style of the legend's outline
        Since:
        8.0
        See Also:
        setOutlineStyle(int), BorderPropertiesConstants.NO_LINE, BorderPropertiesConstants.LINE_STYLE_SINGLE, BorderPropertiesConstants.LINE_STYLE_DASHED, BorderPropertiesConstants.LINE_STYLE_DOTTED
      • setOutlineStyle

        public void setOutlineStyle​(int outlineStyle)
        Sets the style of the legend's outline.
        Parameters:
        outlineStyle - the legend's outline's style
        Throws:
        java.lang.IllegalArgumentException - if an unsupported line style is passed.
        Since:
        8.0
        See Also:
        getOutlineStyle(), BorderPropertiesConstants.NO_LINE, BorderPropertiesConstants.LINE_STYLE_SINGLE, BorderPropertiesConstants.LINE_STYLE_DASHED, BorderPropertiesConstants.LINE_STYLE_DOTTED
      • getOutlineWidth

        public int getOutlineWidth()
        Returns the width of the legend's outline in twips.
        Returns:
        the width
        Since:
        8.0
        See Also:
        setOutlineWidth(int)
      • setOutlineWidth

        public void setOutlineWidth​(int outlineWidth)
        Sets the width of the legend's outline in twips.
        Parameters:
        outlineWidth - the width of the legend's outline
        Throws:
        java.lang.IllegalArgumentException - if the width is less than 1.
        Since:
        8.0
        See Also:
        getOutlineWidth()
      • saveProperties

        public void saveProperties​(java.io.PrintWriter out,
                                   int depth)
        Writes the properties of this legend to PrintWriter as XML.
        Parameters:
        out - the output stream to write to
        depth - the depth of XML indent to prefix each line with
        Since:
        8.0
      • readProperties

        public void readProperties​(org.w3c.dom.Element element)
        Loads the properties of a chart legend from an XML element.
        Parameters:
        element - DOM element
        Since:
        8.0