Class Legend

java.lang.Object
Composite
org.swtchart.internal.Legend
All Implemented Interfaces:
ILegend

public class Legend extends Composite implements ILegend
A legend for chart.
  • Constructor Details

    • Legend

      public Legend(Chart chart, int style)
      Constructor.
      Parameters:
      chart - the chart
      style - the style
  • Method Details

    • setVisible

      public void setVisible(boolean visible)
      Description copied from interface: ILegend
      Sets legend visible.
      Specified by:
      setVisible in interface ILegend
      Parameters:
      visible - the visibility state
    • isVisible

      public boolean isVisible()
      Description copied from interface: ILegend
      Gets the visibility state.
      Specified by:
      isVisible in interface ILegend
      Returns:
      true if legend is visible
    • setFont

      public void setFont(Font font)
      Description copied from interface: ILegend
      Sets the font.
      Specified by:
      setFont in interface ILegend
      Parameters:
      font - the font
    • setForeground

      public void setForeground(Color color)
      Description copied from interface: ILegend
      Sets the foreground color of legend.
      Specified by:
      setForeground in interface ILegend
      Parameters:
      color - the foreground color
    • setBackground

      public void setBackground(Color color)
      Description copied from interface: ILegend
      Sets the background color of legend.
      Specified by:
      setBackground in interface ILegend
      Parameters:
      color - the background color
    • getPosition

      public int getPosition()
      Description copied from interface: ILegend
      Gets the position of legend.
      Specified by:
      getPosition in interface ILegend
      Returns:
      the position of legend.
    • setPosition

      public void setPosition(int value)
      Description copied from interface: ILegend
      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.
      Specified by:
      setPosition in interface ILegend
      Parameters:
      value - the position of legend that can be SWT.LEFT, SWT.RIGHT, SWT.TOP or SWT.BOTTOM.
    • getBounds

      public Rectangle getBounds(String seriesId)
      Description copied from interface: ILegend
      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(...);
       
      Specified by:
      getBounds in interface ILegend
      Parameters:
      seriesId - the series id
      Returns:
      the rectangle associated with the given series id in pixels.
    • dispose

      public void dispose()
    • updateLayoutData

      public void updateLayoutData()
      Update the layout data.
    • drawSymbol

      protected void drawSymbol(GC gc, Series series, Rectangle r)
      Draws the symbol of series.
      Parameters:
      gc - the graphics context
      series - the series
      r - the rectangle to draw the symbol of series
    • paintControl

      public void paintControl(PaintEvent e)