Class TVector

All Implemented Interfaces:
Serializable, Cloneable, Drawable, Interactive, Measurable, Trackable

public class TVector extends TShape
This is a TShape that draws a vector.
Version:
1.0
Author:
Douglas Brown
See Also:
  • Field Details

    • path

      protected GeneralPath path
    • line

      protected Line2D line
    • shaft

      protected Shape shaft
    • length

      protected int length
    • width

      protected int width
    • rotation

      protected AffineTransform rotation
    • tail

      protected TPoint tail
    • tip

      protected TPoint tip
    • tipRect

      protected Rectangle tipRect
    • tipEnabled

      protected boolean tipEnabled
  • Constructor Details

    • TVector

      public TVector()
      Constructs a default TVector with tail position (0, 0) and components (0, 0).
    • TVector

      public TVector(double xt, double yt, double xc, double yc)
      Constructs a TVector with specified tail and components.
      Parameters:
      xt - x position of tail
      yt - y position of tail
      xc - x component
      yc - y component
  • Method Details

    • getTip

      public TPoint getTip()
      Gets the tip.
      Returns:
      the tip
    • getTail

      public TPoint getTail()
      Gets the tail.
      Returns:
      the tail
    • setXComponent

      public void setXComponent(double x)
      Sets the x component.
      Parameters:
      x - the x component
    • setYComponent

      public void setYComponent(double y)
      Sets the y component.
      Parameters:
      y - the y component
    • setXYComponents

      public void setXYComponents(double x, double y)
      Sets the x and y components.
      Parameters:
      x - the x component
      y - the y component
    • getXComponent

      public double getXComponent()
      Gets the x component.
      Returns:
      the x component
    • getYComponent

      public double getYComponent()
      Gets the y component.
      Returns:
      the y component
    • setXY

      public void setXY(double x, double y)
      Overrides TPoint setXY method to move both tip and tail.
      Specified by:
      setXY in interface Interactive
      Overrides:
      setXY in class TPoint
      Parameters:
      x - the x position
      y - the y position
    • setTipEnabled

      public void setTipEnabled(boolean enabled)
      Enables and disables the interactivity of the tip.
      Parameters:
      enabled - true to enable the tip
    • isTipEnabled

      public boolean isTipEnabled()
      Gets whether the tip is enabled.
      Returns:
      true if the tip is enabled
    • setTipLength

      public void setTipLength(int tipLength)
      Sets the length of the arrow tip.
      Parameters:
      tipLength - the tip length in pixels
    • setStroke

      public void setStroke(BasicStroke stroke)
      Overrides TPoint setStroke method.
      Overrides:
      setStroke in class TShape
      Parameters:
      stroke - the desired stroke
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Returns the interactive drawable object at the specified pixel position.
      Specified by:
      findInteractive in interface Interactive
      Overrides:
      findInteractive in class TShape
      Parameters:
      panel - the drawing panel
      xpix - the x pixel position on the panel
      ypix - the y pixel position on the panel
      Returns:
      the interactive drawable object
    • getShape

      protected Shape getShape(VideoPanel vidPanel)
      Gets the shape to be filled in the draw method.
      Overrides:
      getShape in class TShape
      Parameters:
      vidPanel - the video panel
      Returns:
      the line shape