Package org.swtchart

Interface ILegend

All Known Implementing Classes:
Legend

public interface ILegend
A legend for chart.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.swt.graphics.Color
    Gets the background color of legend.
    org.eclipse.swt.graphics.Rectangle
    getBounds(String seriesId)
    Gets the rectangle associated with the given series id on legend.
    org.eclipse.swt.graphics.Font
    Gets the font.
    org.eclipse.swt.graphics.Color
    Gets the foreground color of legend.
    int
    Gets the position of legend.
    boolean
    Gets the visibility state.
    void
    setBackground(org.eclipse.swt.graphics.Color color)
    Sets the background color of legend.
    void
    setFont(org.eclipse.swt.graphics.Font font)
    Sets the font.
    void
    setForeground(org.eclipse.swt.graphics.Color color)
    Sets the foreground color of legend.
    void
    setPosition(int position)
    Sets the position of legend.
    void
    setVisible(boolean visible)
    Sets legend visible.
  • Method Details

    • setVisible

      void setVisible(boolean visible)
      Sets legend visible.
      Parameters:
      visible - the visibility state
    • isVisible

      boolean isVisible()
      Gets the visibility state.
      Returns:
      true if legend is visible
    • setBackground

      void setBackground(org.eclipse.swt.graphics.Color color)
      Sets the background color of legend.
      Parameters:
      color - the background color
    • getBackground

      org.eclipse.swt.graphics.Color getBackground()
      Gets the background color of legend.
      Returns:
      background color of legend.
    • setForeground

      void setForeground(org.eclipse.swt.graphics.Color color)
      Sets the foreground color of legend.
      Parameters:
      color - the foreground color
    • getForeground

      org.eclipse.swt.graphics.Color getForeground()
      Gets the foreground color of legend.
      Returns:
      foreground color of legend.
    • getFont

      org.eclipse.swt.graphics.Font getFont()
      Gets the font.
      Returns:
      the font
    • setFont

      void setFont(org.eclipse.swt.graphics.Font font)
      Sets the font.
      Parameters:
      font - the font
    • getPosition

      int getPosition()
      Gets the position of legend.
      Returns:
      the position of legend.
    • setPosition

      void setPosition(int position)
      Sets the position of legend. If the position is SWT.LEFT or SWT.RIGHT, the orientation of series on legend will be vertical. If the position is SWT.TOP or SWT.BOTTOM, the orientation will be horizontal.
      Parameters:
      position - the position of legend that can be SWT.LEFT, SWT.RIGHT, SWT.TOP or SWT.BOTTOM.
    • getBounds

      org.eclipse.swt.graphics.Rectangle getBounds(String seriesId)
      Gets the rectangle associated with the given series id on legend. This method is typically used for mouse listener to check whether mouse cursor is on legend for a certain series.

      Mouse listener can be added by casting ILegend to Control.

       Control legend = (Control) chart.getLegend();
       legend.addMouseListener(...);
       
      Parameters:
      seriesId - the series id
      Returns:
      the rectangle associated with the given series id in pixels.