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,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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected Rectangle2DHolds our last known size, set after each repaint is evaluatedprotected Rectangle2DHolds the bounds of the shape before layout starts messing with it, so we can remember our original bounds relative to our parent.protected Rectangle2DUsed during repaint, and compared to _last to determine the correct repaint window.protected Rectangle2DHolds the last set of relative position values that we knew about, so that property change events can have an accurate last value.protected Point2DThe saved rotation anchor for the shape, specified in relative terms, e.g.static final Stringprotected AffineTransformA 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, cursorCodeFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface com.inductiveautomation.vision.api.client.components.model.ComponentLifecycle
COMPONENT_RUNNINGFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface com.inductiveautomation.ignition.client.model.LocaleListener
LOCAL_CHANGE_EVENTFields inherited from interface com.inductiveautomation.vision.api.client.binding.MutableDynamicPropertyProvider
RESERVED_SET_KEYFields inherited from interface com.inductiveautomation.vision.api.client.components.model.VisionComponent
COMPONENT_LOCKED, COMPONENT_PERMISSIONS, COMPONENT_SECURITY, COMPONENT_TRANSLATIONS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_setAngle(double newAngle) Updates the internal angle property and fires property change events.protected static intceil(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.voidbooleancontains(int x, int y) protected voidFires change events (if necessary) for the relX, relY, relWidth, and relHeight propertiesprotected static intfloor(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.doubledoubleabstract ShapegetArea()Return the area that this shape will paint in.Calculates the smallest rectangle that encloses the entire shape, creating a new rectangle for the return value.final Rectangle2DCalculates the smallest rectangle that encloses the entire shape.protected abstract Point2DdoubledoubledoublegetRelX()doublegetRelY()Gets the shapes saved rotation anchor.abstract Rectangle2Dabstract floatUsed to outset the repaint region so that widely stroked shapes get repainted correctly.protected voidpaintComponent(Graphics graphics) protected abstract voidDraw the shape to the given graphics object.voidrepaint()Repaint overridden for performance.final voidrotate(double angle, double x, double y) This version is for scripting, since Point2D's are awkward to create in Python.final voidManipulate the underlying shape/transform so to rotate it.protected abstract voidrotateImpl(double angle, Point2D center) Actual implementation of rotation logic from sub-class.protected static intround(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.voidsetAngleDegrees(double newAngle) voidsetAngleRadians(double newAngle) Rotates the shape by the difference between the new angle and the existing angle, around the shape's rotation anchor.final voidOverridden to be a no-op.abstract voidsetBoundingRect(Rectangle2D newBounds) Manipulate the underlying shape/transform so that the shape fits within the new bounding rectangle.voidsetOriginalBounds(Rectangle2D rect) voidsetRelHeight(double newHeight) voidsetRelWidth(double newWidth) voidsetRelX(double newX) voidsetRelY(double newY) voidsetRotationAnchor(Point2D rotationCenter) voidsetTempTransform(AffineTransform tempTransform) toString()protected voidupdateRelBounds(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, updateQualityMethods 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, updateUIMethods 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, validateTreeMethods 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 Details
-
SCALE_STROKE_HINT
- See Also:
-
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
Holds the last set of relative position values that we knew about, so that property change events can have an accurate last value. -
rect
Used during repaint, and compared to _last to determine the correct repaint window. -
lastSize
Holds our last known size, set after each repaint is evaluated -
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
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:
containsin classJComponent
-
getOriginalBounds
- Specified by:
getOriginalBoundsin interfaceBounds2DComponent
-
setOriginalBounds
- Specified by:
setOriginalBoundsin interfaceBounds2DComponent
-
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
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
-
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
-
setTempTransform
-
clearTempTransmform
public void clearTempTransmform() -
setBorder
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:
setBorderin classJComponent
-
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. -
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
- Overrides:
paintComponentin classAbstractVisionComponent
-
getBoundingRect
Calculates the smallest rectangle that encloses the entire shape, creating a new rectangle for the return value.- Specified by:
getBoundingRectin interfaceBounds2DComponent
-
getBoundingRect
Calculates the smallest rectangle that encloses the entire shape.- Specified by:
getBoundingRectin 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
-
getStrokeSize
public abstract float getStrokeSize()Used to outset the repaint region so that widely stroked shapes get repainted correctly. -
setBoundingRect
Manipulate the underlying shape/transform so that the shape fits within the new bounding rectangle.- Specified by:
setBoundingRectin interfaceBounds2DComponent
-
rotate
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
Actual implementation of rotation logic from sub-class. -
paintShape
Draw the shape to the given graphics object. -
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
-