Class TPoint

All Implemented Interfaces:
Serializable, Cloneable, Drawable, Interactive, Measurable, Trackable
Direct Known Subclasses:
AutoTracker.ATObject, AutoTracker.Target, CalibrationStep.Position, CoordAxes.AnglePoint, CoordAxes.OriginPoint, DataToolTab.DataToolPlotter.XYAxes, OffsetOriginStep.Position, PerspectiveFilter.Corner, PerspectiveStep.Corner, PositionStep.Position, RGBRegion.VertexHandle, RGBStep.Position, TShape

public class TPoint extends Point2D.Double implements Interactive, Trackable
This is a Point2D that implements the Interactive and Trackable interfaces with additional utility methods. Classes that extend TPoint should interpret the stored x and y values as image coordinates. TPoint has an empty draw method.
Version:
1.0
Author:
Douglas Brown
See Also:
  • Field Details

    • coordsVisibleInMouseBox

      protected static boolean coordsVisibleInMouseBox
    • xyStringBuilder

      protected static XYCoordinateStringBuilder xyStringBuilder
    • enabled

      protected boolean enabled
    • trackEditTrigger

      protected boolean trackEditTrigger
    • coordsEditTrigger

      protected boolean coordsEditTrigger
    • stepEditTrigger

      protected boolean stepEditTrigger
    • isAdjusting

      protected boolean isAdjusting
    • screenPt

      protected Point screenPt
    • worldPt

      protected Point2D.Double worldPt
    • support

      protected PropertyChangeSupport support
    • attachedTo

      protected TPoint attachedTo
    • prevX

      protected double prevX
    • prevY

      protected double prevY
    • toScreen

      protected AffineTransform toScreen
  • Constructor Details

    • TPoint

      public TPoint()
      Constructs a TPoint with image coordinates (0, 0).
    • TPoint

      public TPoint(double x, double y)
      Constructs a TPoint with specified image coordinates.
      Parameters:
      x - the x coordinate
      y - the y coordinate
    • TPoint

      public TPoint(Point2D.Double point)
      Constructs a TPoint with image coordinates specified by a Point2D (commonly another TPoint).
      Parameters:
      point - the Point2D
  • Method Details

    • draw

      public void draw(DrawingPanel panel, Graphics _g)
      Empty draw method. This method should be overridden by subclasses.
      Specified by:
      draw in interface Drawable
      Parameters:
      panel - the drawing panel requesting the drawing
      _g - the graphics context on which to draw
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Returns null. This method should be overridden by subclasses.
      Specified by:
      findInteractive in interface Interactive
      Parameters:
      panel - the drawing panel
      xpix - the x pixel position on the panel
      ypix - the y pixel position on the panel
      Returns:
      null
    • setX

      public void setX(double x)
      Sets the x position in imagespace.
      Specified by:
      setX in interface Interactive
      Parameters:
      x - the x position
    • setY

      public void setY(double y)
      Sets the y position in imagespace.
      Specified by:
      setY in interface Interactive
      Parameters:
      y - the y position
    • setXY

      public void setXY(double x, double y)
      Sets the x and y positions in imagespace.
      Specified by:
      setXY in interface Interactive
      Parameters:
      x - the x position
      y - the y position
    • setLocation

      public void setLocation(double x, double y)
      Overrides Point2D.Double setLocation method.
      Overrides:
      setLocation in class Point2D.Double
      Parameters:
      x - the x position
      y - the y position
    • getFrameNumber

      public int getFrameNumber(VideoPanel vidPanel)
      Gets the frame number this TPoint uses for coordinate system transforms and other identification. Step-based subclasses can override this method to report their own frame number.
      Parameters:
      vidPanel - the video panel
      Returns:
      the frame number
    • getScreenPosition

      public Point getScreenPosition(VideoPanel vidPanel)
      Gets the screen position of this TPoint on the specified VideoPanel.
      Parameters:
      vidPanel - the video panel
      Returns:
      the screen point
    • setScreenPosition

      public void setScreenPosition(int x, int y, VideoPanel vidPanel)
      Sets the screen position of this TPoint on the specified VideoPanel.
      Parameters:
      x - the screen x coordinate
      y - the screen y coordinate
      vidPanel - the video panel
    • setScreenPosition

      public void setScreenPosition(int x, int y, VideoPanel vidPanel, InputEvent e)
      Sets the screen position of this TPoint. This can be overridden by subclasses to change the behavior based on input event methods that report the state of keys like shift, control, alt, etc.
      Parameters:
      x - the screen x coordinate
      y - the screen y coordinate
      vidPanel - the video panel
      e - the input event making the request
    • getWorldPosition

      public Point2D getWorldPosition(VideoPanel vidPanel)
      Gets the world position of this TPoint on the specified VideoPanel.
      Parameters:
      vidPanel - the video panel
      Returns:
      the world position
    • setWorldPosition

      public void setWorldPosition(double x, double y, VideoPanel vidPanel)
      Sets the world position of this TPoint on the specified VideoPanel.
      Parameters:
      x - the world x coordinate
      y - the world y coordinate
      vidPanel - the video panel
    • showCoordinates

      public void showCoordinates(VideoPanel vidPanel)
      Shows the world coordinates of this TPoint in the mouse box of the specified VideoPanel.
      Parameters:
      vidPanel - the video panel
    • attachTo

      public boolean attachTo(TPoint p)
      Attaches this TPoint to another so it follows it.
      Parameters:
      p - the point to attach to
      Returns:
      true if a change has occurred
    • detach

      public void detach()
      Detaches this TPoint.
    • isAttached

      public boolean isAttached()
      Determines if this point is attached to another.
      Returns:
      true if attached
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets whether this responds to mouse hits.
      Specified by:
      setEnabled in interface Interactive
      Parameters:
      enabled - true if this responds to mouse hits.
    • isEnabled

      public boolean isEnabled()
      Gets whether this responds to mouse hits.
      Specified by:
      isEnabled in interface Interactive
      Returns:
      true if this responds to mouse hits.
    • setTrackEditTrigger

      public void setTrackEditTrigger(boolean edit)
      Sets the trackEditTrigger property. A trackEditTrigger triggers undoable track edits when moved.
      Parameters:
      edit - true to make this a trackEditTrigger.
    • isTrackEditTrigger

      public boolean isTrackEditTrigger()
      Reports whether this is a trackEditTrigger. A trackEditTrigger triggers undoable track edits when moved.
      Returns:
      true if this is a trackEditTrigger.
    • setCoordsEditTrigger

      public void setCoordsEditTrigger(boolean edit)
      Sets the coordsEditTrigger property. A coordsEditTrigger triggers undoable coords edits when moved.
      Parameters:
      edit - true to make this a coordsEditTrigger.
    • isCoordsEditTrigger

      public boolean isCoordsEditTrigger()
      Reports whether this is a coordsEditTrigger. A coordsEditTrigger triggers undoable coords edits when moved.
      Returns:
      true if this is a coordsEditTrigger.
    • setStepEditTrigger

      public void setStepEditTrigger(boolean stepEditTrigger)
      Sets the stepEditTrigger property. A stepEditTrigger triggers undoable step edits when moved.
      Parameters:
      stepEditTrigger - true to make this a stepEditTrigger.
    • isStepEditTrigger

      public boolean isStepEditTrigger()
      Reports whether this is a stepEditTrigger. A stepEditTrigger triggers undoable step edits when moved.
      Returns:
      true if this is a stepEditTrigger.
    • getBounds

      public Rectangle getBounds(VideoPanel vidPanel)
      Gets the screen bounds of this object.
      Parameters:
      vidPanel - the video panel
      Returns:
      the bounding rectangle
    • isMeasured

      public boolean isMeasured()
      Reports whether information is available to set min/max values.
      Specified by:
      isMeasured in interface Measurable
      Returns:
      false
    • getXMin

      public double getXMin()
      Gets the minimum x needed to draw this object.
      Specified by:
      getXMin in interface Measurable
      Returns:
      minimum x
    • getXMax

      public double getXMax()
      Gets the maximum x needed to draw this object.
      Specified by:
      getXMax in interface Measurable
      Returns:
      maximum x
    • getYMin

      public double getYMin()
      Gets the minimum y needed to draw this object.
      Specified by:
      getYMin in interface Measurable
      Returns:
      minimum y
    • getYMax

      public double getYMax()
      Gets the maximum y needed to draw this object.
      Specified by:
      getYMax in interface Measurable
      Returns:
      maximum y
    • angle

      public double angle(double x, double y)
      Returns the angle measured ccw from the positive x-axis to the line between this TPoint and the specified coordinates.
      Parameters:
      x - the x coordinate
      y - the x coordinate
      Returns:
      the angle in radians
    • angle

      public double angle(Point2D.Double pt)
      Returns the angle measured ccw from the positive x-axis to a line that goes from this TPoint to the specified Point2D.
      Parameters:
      pt - the Point2D
      Returns:
      the angle in radians
    • sin

      public double sin(double x, double y)
      Returns the sine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified coordinates.
      Parameters:
      x - the x coordinate
      y - the x coordinate
      Returns:
      the sine of the angle
    • sin

      public double sin(Point2D.Double pt)
      Returns the sine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified Point2D.
      Parameters:
      pt - the Point2D
      Returns:
      the sine of the angle
    • cos

      public double cos(double x, double y)
      Returns the cosine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified coordinates.
      Parameters:
      x - the x coordinate
      y - the x coordinate
      Returns:
      the cosine of the angle
    • cos

      public double cos(Point2D.Double pt)
      Returns the cosine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified Point2D.
      Parameters:
      pt - the Point2D
      Returns:
      the cosine of the angle
    • center

      public void center(Point2D.Double pt1, Point2D.Double pt2)
      Centers this TPoint between the two specified points. Note that this method does not call setXY.
      Parameters:
      pt1 - the first Point2D
      pt2 - the second Point2D
    • translate

      public void translate(double dx, double dy)
      Translates this TPoint by the specified displacement.
      Parameters:
      dx - the x displacement in imagespace
      dy - the y displacement in imagespace
    • setAdjusting

      public void setAdjusting(boolean adjusting, MouseEvent e)
      Sets the adjusting flag. This is normally set by the mouse handler when this point is dragged or stops being dragged.
      Parameters:
      adjusting - true if being dragged
      e - a MouseEvent, may be null
    • isAdjusting

      public boolean isAdjusting()
      Gets the adjusting flag.
      Returns:
      true if adjusting
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Adds a PropertyChangeListener.
      Parameters:
      listener - the object requesting property change notification
    • addPropertyChangeListener

      public void addPropertyChangeListener(String property, PropertyChangeListener listener)
      Adds a PropertyChangeListener for a specified property.
      Parameters:
      property - the name of the property of interest to the listener
      listener - the object requesting property change notification
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Removes a PropertyChangeListener.
      Parameters:
      listener - the listener requesting removal
    • removePropertyChangeListener

      public void removePropertyChangeListener(String property, PropertyChangeListener listener)
      Removes a PropertyChangeListener for a specified property.
      Parameters:
      property - the name of the property
      listener - the listener to remove
    • toString

      public String toString()
      Returns a String describing this.
      Overrides:
      toString in class Point2D.Double
      Returns:
      a descriptive string
    • equals

      public boolean equals(Object obj)
      Compares this to the specified object.
      Overrides:
      equals in class Point2D
      Parameters:
      object - the object
      Returns:
      true if this equals the specified object
    • setPositionOnLine

      public void setPositionOnLine(int xScreen, int yScreen, VideoPanel vidPanel, TPoint end1, TPoint end2)
      Sets the position of this point on the line between end1 and end2 nearest the specified screen position.
      Parameters:
      xScreen - the x screen position
      yScreen - the y screen position
      vidPanel - the videoPanel drawing this point
      end1 - one end of the line
      end2 - the other end of the line