All Implemented Interfaces:
DynamicPropertyProvider, LocaleListener, MutableDynamicPropertyProvider, StyleProvider, Bounds2DComponent, ComponentLifecycle, QualityMonitor, VisionComponent, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
PathBasedVisionShape, ShapeGroup

public abstract class AbstractVisionShape extends AbstractVisionComponent implements Bounds2DComponent

The superclass for all "shape" components used in the Ignition Vision module. This a special class of components that gets special treatment from the layout and designer system. These shapes paint themselves anywhere within their parent containers, and don't participate in certain Swing features such as border.

These shapes need not be rectangular, and the getArea() call will be used for mouse hit-testing and selection hit-testing.

See Also:
  • Field Details

    • SCALE_STROKE_HINT

      public static final String SCALE_STROKE_HINT
      See Also:
    • origBounds

      protected Rectangle2D origBounds
      Holds the bounds of the shape before layout starts messing with it, so we can remember our original bounds relative to our parent.
    • relPos

      protected Rectangle2D relPos
      Holds the last set of relative position values that we knew about, so that property change events can have an accurate last value.
    • rect

      protected Rectangle2D rect
      Used during repaint, and compared to _last to determine the correct repaint window.
    • lastSize

      protected Rectangle2D lastSize
      Holds our last known size, set after each repaint is evaluated
    • tempTransform

      protected AffineTransform tempTransform
      A temporary transform that may be set to perform a blanket transform op on the shape. Applied extremely late, during painting, and does not alter any underlying shape information.
    • angle

      protected double angle
    • rotationAnchor

      protected Point2D rotationAnchor
      The saved rotation anchor for the shape, specified in relative terms, e.g. (pct*X, pct*Y). Serialized.
  • Constructor Details

    • AbstractVisionShape

      protected AbstractVisionShape()
  • Method Details

    • contains

      public boolean contains(int x, int y)
      Overrides:
      contains in class JComponent
    • getOriginalBounds

      public Rectangle2D getOriginalBounds()
      Specified by:
      getOriginalBounds in interface Bounds2DComponent
    • setOriginalBounds

      public void setOriginalBounds(Rectangle2D rect)
      Specified by:
      setOriginalBounds in interface Bounds2DComponent
    • getCenterpoint

      protected abstract Point2D getCenterpoint()
    • _setAngle

      protected void _setAngle(double newAngle)
      Updates the internal angle property and fires property change events. Note that calling this method does not actually rotate the object, that should already be done.
    • getAngleRadians

      public double getAngleRadians()
    • setAngleRadians

      public void setAngleRadians(double newAngle)
      Rotates the shape by the difference between the new angle and the existing angle, around the shape's rotation anchor.
    • getAngleDegrees

      public double getAngleDegrees()
    • setAngleDegrees

      public void setAngleDegrees(double newAngle)
    • getRotationAnchor

      public Point2D getRotationAnchor()
      Gets the shapes saved rotation anchor. Specified in relative terms, e.g. (pct*X, pct%Y). Defaults to the center of the component, or (0.5, 0.5)
    • setRotationAnchor

      public void setRotationAnchor(Point2D rotationCenter)
    • firePositionChange

      protected void firePositionChange()
      Fires change events (if necessary) for the relX, relY, relWidth, and relHeight properties
    • updateRelBounds

      protected void updateRelBounds(double x, double y, double w, double h)
    • getRelX

      public double getRelX()
    • setRelX

      public void setRelX(double newX)
    • getRelY

      public double getRelY()
    • setRelY

      public void setRelY(double newY)
    • getRelWidth

      public double getRelWidth()
    • setRelWidth

      public void setRelWidth(double newWidth)
    • getRelHeight

      public double getRelHeight()
    • setRelHeight

      public void setRelHeight(double newHeight)
    • getTempTransform

      public AffineTransform getTempTransform()
    • setTempTransform

      public void setTempTransform(AffineTransform tempTransform)
    • clearTempTransmform

      public void clearTempTransmform()
    • setBorder

      public final void setBorder(Border b)
      Overridden to be a no-op. Because Swing thinks that the component has the same bounds as the parent, borders would be in the wrong spot.
      Overrides:
      setBorder in class JComponent
    • repaint

      public void repaint()
      Repaint overridden for performance. Because all shapes take the entire bounds of their parents, we don't want to repaint what Swing considers to be the bounds. This function defers to getBoundingRect() to get the shape's true bounds, and repaints only that region.
      Overrides:
      repaint in class Component
    • floor

      protected static int floor(double d)
      Special implementation of floor to help with the fact that vision shapes use double-precision 2d graphics, but in reality drawing often uses integer-precision space.
    • ceil

      protected static int ceil(double d)
      Special implementation of ceil to help with the fact that vision shapes use double-precision 2d graphics, but in reality drawing often uses integer-precision space.
    • round

      protected static int round(double d)
      Special implementation of round to help with the fact that vision shapes use double-precision 2d graphics, but in reality drawing often uses integer-precision space.
    • paintComponent

      protected void paintComponent(Graphics graphics)
      Overrides:
      paintComponent in class AbstractVisionComponent
    • getBoundingRect

      public Rectangle2D getBoundingRect()
      Calculates the smallest rectangle that encloses the entire shape, creating a new rectangle for the return value.
      Specified by:
      getBoundingRect in interface Bounds2DComponent
    • getBoundingRect

      public final Rectangle2D getBoundingRect(Rectangle2D rv)
      Calculates the smallest rectangle that encloses the entire shape.
      Specified by:
      getBoundingRect in interface Bounds2DComponent
      Parameters:
      rv - The "return value" rectangle. May be null, in which case a new rectangle will be returned.
      Returns:
      A rectangle (rv if it was not null) containing the current bounds, relative to the shape's nearest non-group parent.
    • getShapeBounds

      public abstract Rectangle2D getShapeBounds(Rectangle2D rv)
    • getStrokeSize

      public abstract float getStrokeSize()
      Used to outset the repaint region so that widely stroked shapes get repainted correctly.
    • setBoundingRect

      public abstract void setBoundingRect(Rectangle2D newBounds)
      Manipulate the underlying shape/transform so that the shape fits within the new bounding rectangle.
      Specified by:
      setBoundingRect in interface Bounds2DComponent
    • rotate

      public final void rotate(double angle, Point2D center)
      Manipulate the underlying shape/transform so to rotate it.
      Parameters:
      angle - The angle to rotate the shape, specified in radians.
      center - The point around which to rotate.
    • rotate

      public final void rotate(double angle, double x, double y)
      This version is for scripting, since Point2D's are awkward to create in Python.
    • rotateImpl

      protected abstract void rotateImpl(double angle, Point2D center)
      Actual implementation of rotation logic from sub-class.
    • paintShape

      protected abstract void paintShape(Graphics2D g)
      Draw the shape to the given graphics object.
    • getArea

      public abstract Shape getArea()
      Return the area that this shape will paint in. The area should be enclosed within the bounding rectangle, but may cover less area than the entire bounding rectangle. Used for mouse hit-testing.
    • toString

      public String toString()
      Overrides:
      toString in class Component