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 SummaryNested classes/interfaces inherited from class javax.swing.JComponentJComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.ContainerContainer.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.ComponentComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
Field SummaryFieldsModifier 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.AbstractVisionComponentantialias, context, cursorCodeFields inherited from class javax.swing.JComponentlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.ComponentaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface com.inductiveautomation.vision.api.client.components.model.ComponentLifecycleCOMPONENT_RUNNINGFields inherited from interface java.awt.image.ImageObserverABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface com.inductiveautomation.ignition.client.model.LocaleListenerLOCAL_CHANGE_EVENTFields inherited from interface com.inductiveautomation.vision.api.client.binding.MutableDynamicPropertyProviderRESERVED_SET_KEYFields inherited from interface com.inductiveautomation.vision.api.client.components.model.VisionComponentCOMPONENT_LOCKED, COMPONENT_PERMISSIONS, COMPONENT_SECURITY, COMPONENT_TRANSLATIONS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.AbstractVisionComponentgetAppContext, 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.JComponentaddAncestorListener, 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.Containeradd, 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.Componentaction, 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:
 
- 
origBoundsHolds the bounds of the shape before layout starts messing with it, so we can remember our original bounds relative to our parent.
- 
relPosHolds the last set of relative position values that we knew about, so that property change events can have an accurate last value.
- 
rectUsed during repaint, and compared to _last to determine the correct repaint window.
- 
lastSizeHolds our last known size, set after each repaint is evaluated
- 
tempTransformA 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.
- 
angleprotected double angle
- 
rotationAnchorThe saved rotation anchor for the shape, specified in relative terms, e.g. (pct*X, pct*Y). Serialized.
 
- 
- 
Constructor Details- 
AbstractVisionShapeprotected AbstractVisionShape()
 
- 
- 
Method Details- 
containspublic boolean contains(int x, int y) - Overrides:
- containsin class- JComponent
 
- 
getOriginalBounds- Specified by:
- getOriginalBoundsin interface- Bounds2DComponent
 
- 
setOriginalBounds- Specified by:
- setOriginalBoundsin interface- Bounds2DComponent
 
- 
getCenterpoint
- 
_setAngleprotected 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.
- 
getAngleRadianspublic double getAngleRadians()
- 
setAngleRadianspublic void setAngleRadians(double newAngle) Rotates the shape by the difference between the new angle and the existing angle, around the shape's rotation anchor.
- 
getAngleDegreespublic double getAngleDegrees()
- 
setAngleDegreespublic void setAngleDegrees(double newAngle) 
- 
getRotationAnchorGets 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
- 
firePositionChangeprotected void firePositionChange()Fires change events (if necessary) for the relX, relY, relWidth, and relHeight properties
- 
updateRelBoundsprotected void updateRelBounds(double x, double y, double w, double h) 
- 
getRelXpublic double getRelX()
- 
setRelXpublic void setRelX(double newX) 
- 
getRelYpublic double getRelY()
- 
setRelYpublic void setRelY(double newY) 
- 
getRelWidthpublic double getRelWidth()
- 
setRelWidthpublic void setRelWidth(double newWidth) 
- 
getRelHeightpublic double getRelHeight()
- 
setRelHeightpublic void setRelHeight(double newHeight) 
- 
getTempTransform
- 
setTempTransform
- 
clearTempTransmformpublic void clearTempTransmform()
- 
setBorderOverridden 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 class- JComponent
 
- 
repaintpublic 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.
- 
floorprotected 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.
- 
ceilprotected 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.
- 
roundprotected 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 class- AbstractVisionComponent
 
- 
getBoundingRectCalculates the smallest rectangle that encloses the entire shape, creating a new rectangle for the return value.- Specified by:
- getBoundingRectin interface- Bounds2DComponent
 
- 
getBoundingRectCalculates the smallest rectangle that encloses the entire shape.- Specified by:
- getBoundingRectin 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
- 
getStrokeSizepublic abstract float getStrokeSize()Used to outset the repaint region so that widely stroked shapes get repainted correctly.
- 
setBoundingRectManipulate the underlying shape/transform so that the shape fits within the new bounding rectangle.- Specified by:
- setBoundingRectin interface- Bounds2DComponent
 
- 
rotateManipulate 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.
 
- 
rotatepublic final void rotate(double angle, double x, double y) This version is for scripting, since Point2D's are awkward to create in Python.
- 
rotateImplActual implementation of rotation logic from sub-class.
- 
paintShapeDraw the shape to the given graphics object.
- 
getAreaReturn 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
 
-