Class AbstractVisionShape
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- com.inductiveautomation.vision.api.client.components.model.AbstractVisionComponent
-
- com.inductiveautomation.vision.api.client.components.shapes.AbstractVisionShape
-
- All Implemented Interfaces:
DynamicPropertyProvider
,LocaleListener
,MutableDynamicPropertyProvider
,StyleProvider
,Bounds2DComponent
,ComponentLifecycle
,QualityMonitor
,VisionComponent
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double
angle
protected java.awt.geom.Rectangle2D
lastSize
Holds our last known size, set after each repaint is evaluatedprotected java.awt.geom.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.protected java.awt.geom.Rectangle2D
rect
Used during repaint, and compared to _last to determine the correct repaint window.protected java.awt.geom.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.protected java.awt.geom.Point2D
rotationAnchor
The saved rotation anchor for the shape, specified in relative terms, e.g.static java.lang.String
SCALE_STROKE_HINT
protected java.awt.geom.AffineTransform
tempTransform
A temporary transform that may be set to perform a blanket transform op on the shape.-
Fields inherited from class com.inductiveautomation.vision.api.client.components.model.AbstractVisionComponent
antialias, context, cursorCode
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface com.inductiveautomation.vision.api.client.components.model.ComponentLifecycle
COMPONENT_RUNNING
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface com.inductiveautomation.ignition.client.model.LocaleListener
LOCAL_CHANGE_EVENT
-
Fields inherited from interface com.inductiveautomation.vision.api.client.binding.MutableDynamicPropertyProvider
RESERVED_SET_KEY
-
Fields inherited from interface com.inductiveautomation.vision.api.client.components.model.VisionComponent
COMPONENT_LOCKED, COMPONENT_PERMISSIONS, COMPONENT_SECURITY, COMPONENT_TRANSLATIONS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractVisionShape()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
_setAngle(double newAngle)
Updates the internal angle property and fires property change events.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.void
clearTempTransmform()
boolean
contains(int x, int y)
protected void
firePositionChange()
Fires change events (if necessary) for the relX, relY, relWidth, and relHeight propertiesprotected 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.double
getAngleDegrees()
double
getAngleRadians()
abstract java.awt.Shape
getArea()
Return the area that this shape will paint in.java.awt.geom.Rectangle2D
getBoundingRect()
Calculates the smallest rectangle that encloses the entire shape, creating a new rectangle for the return value.java.awt.geom.Rectangle2D
getBoundingRect(java.awt.geom.Rectangle2D rv)
Calculates the smallest rectangle that encloses the entire shape.protected abstract java.awt.geom.Point2D
getCenterpoint()
java.awt.geom.Rectangle2D
getOriginalBounds()
double
getRelHeight()
double
getRelWidth()
double
getRelX()
double
getRelY()
java.awt.geom.Point2D
getRotationAnchor()
Gets the shapes saved rotation anchor.abstract java.awt.geom.Rectangle2D
getShapeBounds(java.awt.geom.Rectangle2D rv)
abstract float
getStrokeSize()
Used to outset the repaint region so that widely stroked shapes get repainted correctly.java.awt.geom.AffineTransform
getTempTransform()
protected void
paintComponent(java.awt.Graphics graphics)
protected abstract void
paintShape(java.awt.Graphics2D g)
Draw the shape to the given graphics object.void
repaint()
Repaint overridden for performance.void
rotate(double angle, double x, double y)
This version is for scripting, since Point2D's are awkward to create in Python.void
rotate(double angle, java.awt.geom.Point2D center)
Manipulate the underlying shape/transform so to rotate it.protected abstract void
rotateImpl(double angle, java.awt.geom.Point2D center)
Actual implementation of rotation logic from sub-class.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.void
setAngleDegrees(double newAngle)
void
setAngleRadians(double newAngle)
Rotates the shape by the difference between the new angle and the existing angle, around the shape's rotation anchor.void
setBorder(javax.swing.border.Border b)
Overridden to be a no-op.abstract void
setBoundingRect(java.awt.geom.Rectangle2D newBounds)
Manipulate the underlying shape/transform so that the shape fits within the new bounding rectangle.void
setOriginalBounds(java.awt.geom.Rectangle2D rect)
void
setRelHeight(double newHeight)
void
setRelWidth(double newWidth)
void
setRelX(double newX)
void
setRelY(double newY)
void
setRotationAnchor(java.awt.geom.Point2D rotationCenter)
void
setTempTransform(java.awt.geom.AffineTransform tempTransform)
java.lang.String
toString()
protected void
updateRelBounds(double x, double y, double w, double h)
-
Methods inherited from class com.inductiveautomation.vision.api.client.components.model.AbstractVisionComponent
getAppContext, getCursorCode, getDataQuality, getDynamicProps, getProperties, getPropertyValue, getQuality, getStyles, getToolTipText, isAntialias, isPropertyDefined, localeChanged, onShutdown, onStartup, paintChildren, setAntialias, setCursorCode, setDataQuality, setDynamicProps, setName, setPropertyValue, setQuality, setStyles, setToolTipText, setVisible, shutdownComponent, startupComponent, updateQuality
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update, updateUI
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
SCALE_STROKE_HINT
public static final java.lang.String SCALE_STROKE_HINT
- See Also:
- Constant Field Values
-
origBounds
protected java.awt.geom.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 java.awt.geom.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 java.awt.geom.Rectangle2D rect
Used during repaint, and compared to _last to determine the correct repaint window.
-
lastSize
protected java.awt.geom.Rectangle2D lastSize
Holds our last known size, set after each repaint is evaluated
-
tempTransform
protected java.awt.geom.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 java.awt.geom.Point2D rotationAnchor
The saved rotation anchor for the shape, specified in relative terms, e.g. (pct*X, pct*Y). Serialized.
-
-
Method Detail
-
contains
public boolean contains(int x, int y)
- Overrides:
contains
in classjavax.swing.JComponent
-
getOriginalBounds
public java.awt.geom.Rectangle2D getOriginalBounds()
- Specified by:
getOriginalBounds
in interfaceBounds2DComponent
-
setOriginalBounds
public void setOriginalBounds(java.awt.geom.Rectangle2D rect)
- Specified by:
setOriginalBounds
in interfaceBounds2DComponent
-
getCenterpoint
protected abstract java.awt.geom.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 java.awt.geom.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(java.awt.geom.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 java.awt.geom.AffineTransform getTempTransform()
-
setTempTransform
public void setTempTransform(java.awt.geom.AffineTransform tempTransform)
-
clearTempTransmform
public void clearTempTransmform()
-
setBorder
public final void setBorder(javax.swing.border.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 classjavax.swing.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 togetBoundingRect()
to get the shape's true bounds, and repaints only that region.- Overrides:
repaint
in classjava.awt.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(java.awt.Graphics graphics)
- Overrides:
paintComponent
in classAbstractVisionComponent
-
getBoundingRect
public java.awt.geom.Rectangle2D getBoundingRect()
Calculates the smallest rectangle that encloses the entire shape, creating a new rectangle for the return value.- Specified by:
getBoundingRect
in interfaceBounds2DComponent
-
getBoundingRect
public final java.awt.geom.Rectangle2D getBoundingRect(java.awt.geom.Rectangle2D rv)
Calculates the smallest rectangle that encloses the entire shape.- Specified by:
getBoundingRect
in interfaceBounds2DComponent
- 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 java.awt.geom.Rectangle2D getShapeBounds(java.awt.geom.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(java.awt.geom.Rectangle2D newBounds)
Manipulate the underlying shape/transform so that the shape fits within the new bounding rectangle.- Specified by:
setBoundingRect
in interfaceBounds2DComponent
-
rotate
public final void rotate(double angle, java.awt.geom.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, java.awt.geom.Point2D center)
Actual implementation of rotation logic from sub-class.
-
paintShape
protected abstract void paintShape(java.awt.Graphics2D g)
Draw the shape to the given graphics object.
-
getArea
public abstract java.awt.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 java.lang.String toString()
- Overrides:
toString
in classjava.awt.Component
-
-