Class Polygon

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

public class Polygon extends Figure
Draws a polygon with the given set of coordinates. A fill color may be used to fill the interior of the shape.
  • Constructor Details

    • Polygon

      public Polygon(Coordinate p1, Coordinate p2, Coordinate... ps)
      Constructor
      Parameters:
      p1 - first point in the polygon
      p2 - second point in the polygon
      ps - remaining points in the polygon
  • Method Details

    • setShowOutline

      public void setShowOutline(boolean b)
      Sets the display of the outline. Set to false to hide the outline.
      Parameters:
      b - true if the outline of the polygon should be displayed
    • isShowOutline

      public boolean isShowOutline()
      Gets the show outline attribute
      Returns:
      true if the outline should be displayed
    • setShowFill

      public void setShowFill(boolean b)
      Sets the display of the fill.
      Parameters:
      b - true if the fill color should be displayed
    • isShowFill

      public boolean isShowFill()
      Gets the show fill attribute
      Returns:
      true if the fill should be displayed
    • getLineColor

      public Color getLineColor()
      Gets the color for drawing the outline.
      Returns:
      the color of the line used to draw the outline.
    • setLineColor

      public void setLineColor(Color color)
      Sets the color of the line used to draw the outline.
      Parameters:
      color - outline color
    • getFillColor

      public Color getFillColor()
      Gets the color for drawing the fill (null for no fill).
      Returns:
      the color used to draw the fill (null for no fill).
    • setFillColor

      public void setFillColor(Color color)
      Sets the color for drawing the fill (null for no fill).
      Parameters:
      color - fill color
    • setStroke

      public void setStroke(Stroke stroke)
      Sets the stroke for displaying the outline. If this value is null, the outline will not be drawn.
      Parameters:
      stroke -
    • getStroke

      public Stroke getStroke()
      Gets the stroke for displaying the outline.
      Returns:
      stroke for displaying the outline
    • isVisible

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

      public boolean contains(double x, double y, DrawContext ctx)
      Returns true if the polygon 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 polygon contains the given x and y coordinates
    • layout

      public void layout(DrawContext ctx)
      Lays out the polygon 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 polygon (this is called by the study framework).
      Overrides:
      draw in class Figure
      Parameters:
      gc - Graphics Context
      ctx - Draw Context