Class Line

java.lang.Object
com.motivewave.platform.sdk.draw.Figure
com.motivewave.platform.sdk.draw.Line

public class Line extends Figure
Draws a line over the given start and end coordinates.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Line​(long startTime, double startValue, long endTime, double endValue)
    Constructor.
    Line​(long startTime, double startValue, long endTime, double endValue, PathInfo info)
    Constructor.
    Line​(Coordinate start, Coordinate end)
    Constructor
    Line​(Coordinate start, Coordinate end, PathInfo info)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains​(double x, double y, DrawContext ctx)
    Returns true if the line contains the given x and y coordinates within the given draw context.
    void
    Draws the line (this is called by the study framework).
    Gets the color of the line.
    long
    Gets the time of the ending location of the line.
    double
    Gets the value of the ending location of the line.
    int
    Gets the number of bars to extend past the start point.
    int
    Gets the number of bars to extend past the end point.
    long
    Gets the time of the starting location of the line.
    double
    Gets the value of the starting location of the line.
    Gets the stroke for displaying the line.
     
    boolean
    Returns true if the line should be extended to the left bounds of the plot.
    boolean
    Returns true if the line should be extended to the right bounds of the plot.
    boolean
    Returns true if the line is currently visible within the given draw context.
    void
    Lays out the line by converting the start and end coordinates to x,y coordinates on the graph.
    void
    setColor​(Color color)
    Sets the color of the line.
    void
    setColorAbove​(double value, Color color)
    Use this method to change the color of the line when it is above a given value.
    void
    setColorBelow​(double value, Color color)
    Use this method to change the color of the line when it is below a given value.
    void
    setEnd​(long time, double value)
    Sets the location of the end of the line.
    void
    setExtendLeft​(int bars)
    Sets the number of bars to extend past the start point
    void
    setExtendLeftBounds​(boolean b)
    Extends the line to the left bounds of the plot.
    void
    setExtendRight​(int bars)
    Sets the number of bars to extend past the end point.
    void
    setExtendRightBounds​(boolean b)
    Extends the line to the right bounds of the plot.
    void
    setStart​(long time, double value)
    Sets the location of the start of the line.
    void
    setStroke​(Stroke stroke)
    Sets the stroke for displaying the line.
    void
    setText​(String text, Font font)
    Sets the text to be displayed in the center of the line.

    Methods inherited from class com.motivewave.platform.sdk.draw.Figure

    getBounds, getPopupMessage, setBounds, setPopupMessage

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Line

      public Line(Coordinate start, Coordinate end)
      Constructor
      Parameters:
      start - starting location of the line
      end - ending location of the line
    • Line

      public Line(Coordinate start, Coordinate end, PathInfo info)
      Constructor
      Parameters:
      start - starting location of the line
      end - ending location of the line
      info - describes how to display the line.
    • Line

      public Line(long startTime, double startValue, long endTime, double endValue)
      Constructor.
      Parameters:
      startTime -
      startValue -
      endTime -
      endValue -
    • Line

      public Line(long startTime, double startValue, long endTime, double endValue, PathInfo info)
      Constructor.
      Parameters:
      startTime -
      startValue -
      endTime -
      endValue -
      info -
  • Method Details

    • setStart

      public void setStart(long time, double value)
      Sets the location of the start of the line.
      Parameters:
      time - time (as milliseconds since 1970)
      value - (y coordinate)
    • getStartTime

      public long getStartTime()
      Gets the time of the starting location of the line.
      Returns:
      start time for the line (milliseconds since 1970)
    • getStartValue

      public double getStartValue()
      Gets the value of the starting location of the line.
      Returns:
      start value for the line
    • setEnd

      public void setEnd(long time, double value)
      Sets the location of the end of the line.
      Parameters:
      time - time (as milliseconds since 1970)
      value - (y coordinate)
    • getEndTime

      public long getEndTime()
      Gets the time of the ending location of the line.
      Returns:
      end time for the line (milliseconds since 1970)
    • getEndValue

      public double getEndValue()
      Gets the value of the ending location of the line.
      Returns:
      end value for the line
    • getText

      public Text getText()
      Returns:
      the text to be displayed in the center of the line.
    • setText

      public void setText(String text, Font font)
      Sets the text to be displayed in the center of the line.
      Parameters:
      text - text value
      font - display font
    • getColor

      public Color getColor()
      Gets the color of the line.
      Returns:
      the color of the line.
    • setColor

      public void setColor(Color color)
      Sets the color of the line.
      Parameters:
      color - line color
    • setStroke

      public void setStroke(Stroke stroke)
      Sets the stroke for displaying the line.
      Parameters:
      stroke -
    • getStroke

      public Stroke getStroke()
      Gets the stroke for displaying the line.
      Returns:
      stroke used to display the line
    • setExtendLeft

      public void setExtendLeft(int bars)
      Sets the number of bars to extend past the start point
      Parameters:
      bars - number bars to extend to the left
    • getExtendLeft

      public int getExtendLeft()
      Gets the number of bars to extend past the start point.
      Returns:
      number of bars to extend left of the start point.
    • setExtendRight

      public void setExtendRight(int bars)
      Sets the number of bars to extend past the end point.
      Parameters:
      bars - number of bars to extend right
    • getExtendRight

      public int getExtendRight()
      Gets the number of bars to extend past the end point.
      Returns:
      number of bars to extend to the right of the end point.
    • setExtendRightBounds

      public void setExtendRightBounds(boolean b)
      Extends the line to the right bounds of the plot. Note: this overrides the extend right (bars) property.
      Parameters:
      b - true if the line should be extended to the right bounds of the plot.
    • isExtendRightBounds

      public boolean isExtendRightBounds()
      Returns true if the line should be extended to the right bounds of the plot.
      Returns:
      true if the line should be extended to the right bounds of the plot
    • setExtendLeftBounds

      public void setExtendLeftBounds(boolean b)
      Extends the line to the left bounds of the plot. Note: this overrides the extend left (bars) property.
      Parameters:
      b - true if the line should be extended to the left bounds of the plot.
    • isExtendLeftBounds

      public boolean isExtendLeftBounds()
      Returns true if the line should be extended to the left bounds of the plot.
      Returns:
      true if the line should be extended to the left bounds of the plot
    • setColorAbove

      public void setColorAbove(double value, Color color)
      Use this method to change the color of the line when it is above a given value.
      Parameters:
      value - value to color above
      color - color to use
    • setColorBelow

      public void setColorBelow(double value, Color color)
      Use this method to change the color of the line when it is below a given value.
      Parameters:
      value - value to color below
      color - color to use
    • isVisible

      public boolean isVisible(DrawContext ctx)
      Returns true if the line is currently visible within the given draw context.
      Overrides:
      isVisible in class Figure
      Parameters:
      ctx - draw context
      Returns:
      true if the line is visible within the current draw context.
    • contains

      public boolean contains(double x, double y, DrawContext ctx)
      Returns true if the line contains the given x and y coordinates within the given draw context.
      Overrides:
      contains in class Figure
      Parameters:
      x - x coordinate
      y - y coordinate
      ctx - draw context
      Returns:
      true if the line contains the given x and y coordinates
    • layout

      public void layout(DrawContext ctx)
      Lays out the line by converting the start and end coordinates to x,y coordinates on the graph. This is called by the study framework.
      Overrides:
      layout in class Figure
      Parameters:
      ctx - draw context
    • draw

      public void draw(Graphics2D gc, DrawContext ctx)
      Draws the line (this is called by the study framework).
      Overrides:
      draw in class Figure
      Parameters:
      gc - Graphics Context
      ctx - Draw Context