Class Label


public class Label extends SinglePointFigure
Draws a label on the chart with a line connector.
  • Constructor Details

    • Label

      public Label(String text)
      Constructor. Creates a label using the default font and text color.
      Parameters:
      text - text to display on the label
    • Label

      public Label(Coordinate location, String text)
      Constructor. Creates a label using the default font and text color.
      Parameters:
      location - absolute location of the label
      text - text to display on the label
    • Label

      public Label(Coordinate location, Enums.StackPolicy stackPolicy, String text)
      Constructor. Creates a label using the default font and text color.
      Parameters:
      location - absolute location of the label
      stackPolicy - stacking policy for figures that share the same coordinate
      text - text to display on the label
    • Label

      public Label(String text, Font font, Color textColor, Color bgColor)
      Constructor.
      Parameters:
      text - text to display in the label
      font - font to use
      textColor - color of the text
      bgColor - background color of the label
  • Method Details

    • getText

      public Text getText()
      Gets the text displayed on the label.
      Returns:
      text object that contains information for drawing the text for this label.
    • setOffset

      public void setOffset(int offset)
      Sets the offset of the label (in pixels) relative to its location.
      Parameters:
      offset - offset (in pixels) relative to its location.
    • getOffset

      public int getOffset()
      Gets the offset of the label (in pixels) relative to its location.
      Returns:
      the offset (in pixels) relative to its location.
    • setShowLine

      public void setShowLine(boolean showLine)
      Sets the attribute to show the line from the label to the point that it is highlighting.
      Parameters:
      showLine -
    • isShowLine

      public boolean isShowLine()
      Determines if the line is to be shown on the label.
      Returns:
      true if the label line is to be shown
    • getLineColor

      public Color getLineColor()
      Gets the color of the line connector (and label outline).
      Returns:
      the color of the line connector.
    • setLineColor

      public void setLineColor(Color color)
      Sets the color of the line connector (and label outline).
      Parameters:
      color - line color
    • setLineStroke

      public void setLineStroke(Stroke stroke)
      Gets the stroke used for the line and outline.
      Parameters:
      stroke - stroke to be used for the line and outline.
    • getLineStroke

      public Stroke getLineStroke()
      Gets the stroke used for the line and outline.
      Returns:
      stroke used to draw the line and outline.
    • layout

      public void layout(DrawContext ctx)
      This method is called to translate any real values in the figure to the graph (represented by the DrawContext).
      Overrides:
      layout in class Figure
      Parameters:
      ctx - draw context
    • draw

      public void draw(Graphics2D gc, DrawContext ctx)
      This method draws the figure on the graph (using the given Graphics2D). This method is called by the study framework to display the figure on the graph.
      Overrides:
      draw in class Figure
      Parameters:
      gc - graphics context
      ctx - draw context