public abstract class ComponentBase
extends java.lang.Object
implements java.io.Externalizable
Modifier and Type | Field and Description |
---|---|
protected javax.swing.event.EventListenerList |
eventListenerList |
Modifier | Constructor and Description |
---|---|
protected |
ComponentBase()
Initializes a new instance of the ComponentBase class.
|
Modifier and Type | Method and Description |
---|---|
void |
addComponentEventListener(ComponentEventListener listener)
Adds the specified component listener to receive events from this component.
|
void |
addComponentMouseEventListener(ComponentMouseEventListener listener)
Adds the specified component listener to receive events from this component.
|
void |
addComponentValidationEventListener(ComponentValidationEventListener listener)
Adds the specified component listener to receive events from this component.
|
void |
arrangeComponents(java.awt.geom.Rectangle2D.Float bounds,
java.awt.Graphics2D g2d)
Recursively arranges the child components, within the specified space and using the specified graphics for measurement purposes.
|
boolean |
confirmValidating()
Confirms validation by raising the Validating event.
|
boolean |
contains(ComponentBase component)
Checks if the specified component is contained in the hierarchy defined by the current component.
|
java.awt.geom.GeneralPath |
createOutlinePath(java.awt.geom.Rectangle2D.Float bounds,
float rotationAngle)
For internal use.
|
void |
draw(java.awt.Graphics2D g2d,
RenderOptions options)
Renders the component in the specified Graphics2D.
|
ComponentBase |
find(java.lang.String name)
Returns the component with the specified name within the hierarchy defined by the current component.
|
java.awt.geom.Rectangle2D.Float |
getBounds()
Gets the calculated bounds of this component relative to its parent.
|
int |
getChildCount()
Gets the number of child components of this component.
|
CursorHint |
getCursor(java.awt.geom.Point2D point)
Gets the cursor to display when the mouse is at the specified position.
|
XDimension2D.Double |
getDesiredSize(XDimension2D.Double availableSize,
java.awt.Graphics2D g2d)
Gets the desired size of this component in case the width and/or height have not been explicitly specified.
|
java.awt.geom.Rectangle2D.Float |
getDocumentBounds()
For internal use.
|
boolean |
getFocusable()
Gets a value indicating whether the component can receive the input focus.
|
int |
getGridColumn()
Gets the index of the grid column this component will be associated with when added to a GridPanel.
|
int |
getGridRow()
Gets the index of the grid row this component will be associated with when added to a GridPanel.
|
float |
getHeight()
Gets the explicit height of this component.
|
int |
getHorizontalAlignment()
Gets the horizontal alignment of this component relative to its parent.
|
boolean |
getIsEnabled()
Gets a value indicating whether the component is enabled.
|
boolean |
getIsFocused()
Gets a value indicating whether this component currently holds the input focus.
|
boolean |
getIsHitTestVisible()
Gets a value indicating whether this component and all its children are subject to hit-testing operations.
|
boolean |
getIsInteractive()
Gets a value indicating whether this component can be interacted with.
|
java.lang.String |
getName()
Gets the name of the component.
|
java.lang.Object |
getParent()
Gets the parent component, if the current component is hosted.
|
ComponentHost |
getParentHost()
For internal use.
|
int |
getVerticalAlignment()
Gets the vertical alignment of this component relative to its parent.
|
boolean |
getVisible()
Gets a value indicating whether the component is visible.
|
float |
getWidth()
Gets the explicit width of this component.
|
void |
invalidate()
Invalidates the visual appearance of the component.
|
void |
invalidateLayout()
Invalidates the layout of this component and all its children.
|
protected void |
loadFromJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
Deserializes the component from a JsonObject.
|
protected void |
loadFromXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
Deserializes the component from an XML element.
|
protected void |
onAddedToParent()
Invoked when the component is added to a parent component.
|
void |
onContextChanged() |
void |
onGotFocus()
Invokes when the component gains the input focus.
|
protected void |
onGotFocus(ComponentEvent e)
Raises the GotFocus event.
|
boolean |
onKeyDown(int keyCode,
int modifiers) |
void |
onKeyPress(char keyChar)
Called when a character key is pressed when this component has the input focus.
|
void |
onKeyUp(int keyCode,
int modifiers) |
void |
onLostFocus()
Invokes when the component loses the input focus.
|
protected void |
onLostFocus(ComponentEvent e)
Raises the LostFocus event.
|
protected void |
onMouseDown(ComponentMouseEvent e) |
void |
onMouseDown(java.awt.geom.Point2D point)
Called when the left mouse button is pressed while the pointer is over this component.
|
protected void |
onMouseMove(ComponentMouseEvent e)
Raises the MouseMove event.
|
void |
onMouseMove(java.awt.geom.Point2D point)
Called when the mouse is moved while this component tracks the mouse events.
|
protected void |
onMouseUp(ComponentMouseEvent e) |
void |
onMouseUp(java.awt.geom.Point2D point)
Called when the left mouse button is released while this component tracks the mouse events.
|
protected void |
onRemovedFromParent()
Invoked when the component is removed from a parent component.
|
void |
onUnitChanged()
Invoked when the measure unit of the document containing the component has changed.
|
protected void |
onValidated(ComponentEvent e)
Raises the Validated event.
|
protected void |
onValidating(ComponentValidationEvent e)
Raises the Validating event.
|
protected void |
onZoomChanged()
Invoked when the zoom factor of the document containing the component has changed.
|
void |
raiseValidated() |
void |
readExternal(java.io.ObjectInput in)
Implements Externalizable
|
void |
removeComponentEventListener(ComponentEventListener listener)
Removes the specified component listener to not receive events from this component.
|
void |
removeComponentMouseEventListener(ComponentMouseEventListener listener)
Removes the specified component listener to not receive events from this component.
|
void |
removeComponentValidationEventListener(ComponentValidationEventListener listener)
Removes the specified component listener to not receive events from this component.
|
protected void |
saveToJson(com.mindfusion.common.JsonObject obj,
JsonPersistContext context)
Serializes the component into a JsonObject.
|
protected void |
saveToXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
Serializes the component into an XML element.
|
protected boolean |
serializeSubcomponents()
Invoked to query whether the underlying component structure should be automatically serialized or serialized by the user.
|
void |
setBounds(java.awt.geom.Rectangle2D.Float value)
Sets the calculated bounds of this component relative to its parent.
|
void |
setFocusable(boolean value)
Sets a value indicating whether the component can receive the input focus.
|
void |
setGridColumn(int value)
Sets the index of the grid row this component will be associated with when added to a GridPanel.
|
void |
setGridRow(int value)
Sets the index of the grid row this component will be associated with when added to a GridPanel.
|
void |
setHeight(float value)
Sets the explicit height of this component.
|
void |
setHorizontalAlignment(int value)
Sets the horizontal alignment of this component relative to its parent.
|
void |
setIsEnabled(boolean value)
Sets a value indicating whether the component is enabled.
|
void |
setIsFocused(boolean value)
Sets a value indicating whether this component currently holds the input focus.
|
void |
setIsHitTestVisible(boolean value)
Sets a value indicating whether this component and all its children are subject to hit-testing operations.
|
void |
setIsInteractive(boolean value)
Sets a value indicating whether this component can be interacted with.
|
void |
setName(java.lang.String value)
Sets the name of the component.
|
void |
setParent(java.lang.Object value)
For internal use.
|
void |
setVerticalAlignment(int value)
Sets the vertical alignment of this component relative to its parent.
|
void |
setVisible(boolean value)
Sets a value indicating whether the component is visible.
|
void |
setWidth(float value)
Sets the explicit width of this component.
|
java.awt.geom.Point2D.Float |
toDocument(java.awt.geom.Point2D.Float point)
Converts a point from local to document coordinates.
|
java.awt.geom.Point2D |
toLocal(java.awt.geom.Point2D point)
Converts a point from document to local coordinates.
|
java.awt.geom.Point2D.Float |
toParent(ComponentBase parent,
java.awt.geom.Point2D.Float point)
Converts a point from local coordinates to the specified parent's coordinates.
|
void |
writeExternal(java.io.ObjectOutput out)
Implements Externalizable
|
protected ComponentBase()
protected boolean serializeSubcomponents()
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
protected void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
xmlElement
- An Element the component's data should be stored into.context
- An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.protected void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context) throws javax.xml.transform.TransformerException
xmlElement
- An Element containing the component's data.context
- An XmlPersistContext object providing contextual information about the serialization process and some helper serialization methods.javax.xml.transform.TransformerException
protected void saveToJson(com.mindfusion.common.JsonObject obj, JsonPersistContext context)
obj
- An JsonObject containing the component's datacontext
- An JsonPersistContext object providing information
about the serialization process and some helper methods.protected void loadFromJson(com.mindfusion.common.JsonObject obj, JsonPersistContext context)
obj
- An JsonObject containing the component's datacontext
- An JsonPersistContext object providing information
about the serialization process and some helper methods.public void draw(java.awt.Graphics2D g2d, RenderOptions options)
g2d
- The drawing target.options
- A RenderOptions object specifying the drawing context.public void arrangeComponents(java.awt.geom.Rectangle2D.Float bounds, java.awt.Graphics2D g2d)
bounds
- The space available for arrangement.g2d
- A relevant Graphics2D object.public ComponentBase find(java.lang.String name)
name
- The name of the component to search for.public boolean contains(ComponentBase component)
component
- The component to search for.public void invalidateLayout()
public void invalidate()
public XDimension2D.Double getDesiredSize(XDimension2D.Double availableSize, java.awt.Graphics2D g2d)
availableSize
- The available size.g2d
- A relevant Graphics2D object.public void onGotFocus()
public void onLostFocus()
public void onMouseDown(java.awt.geom.Point2D point)
point
- A Point2D.Float instance that specifies the current mouse position.public void onMouseMove(java.awt.geom.Point2D point)
point
- A Point2D.Float instance that specifies the current mouse position.public void onMouseUp(java.awt.geom.Point2D point)
point
- A Point2D.Float instance that specifies the current mouse position.public CursorHint getCursor(java.awt.geom.Point2D point)
point
- A Point2D.Float instance that specifies the current mouse position, in document coordinates.public boolean onKeyDown(int keyCode, int modifiers)
public void onKeyPress(char keyChar)
keyChar
- The character representing the pressed key.public void onKeyUp(int keyCode, int modifiers)
protected void onZoomChanged()
public void onUnitChanged()
public void onContextChanged()
public java.awt.geom.Point2D toLocal(java.awt.geom.Point2D point)
point
- The document Point2D.Float to convert.public java.awt.geom.Point2D.Float toParent(ComponentBase parent, java.awt.geom.Point2D.Float point) throws java.lang.Exception
parent
- A ComponentBase representing a direct or indirect parent.point
- The local Point2D.Float to convert.java.lang.Exception
- This method throws an exception if the specified component is null or it does not represent a parent of the current component.public java.awt.geom.Point2D.Float toDocument(java.awt.geom.Point2D.Float point)
point
- The local Point2D.Float to convert.public java.awt.geom.Rectangle2D.Float getDocumentBounds()
protected void onAddedToParent()
protected void onRemovedFromParent()
public java.awt.geom.GeneralPath createOutlinePath(java.awt.geom.Rectangle2D.Float bounds, float rotationAngle)
public boolean confirmValidating()
protected void onValidating(ComponentValidationEvent e)
e
- An object providing the event data.public void raiseValidated()
protected void onValidated(ComponentEvent e)
e
- An object providing the event data.protected void onGotFocus(ComponentEvent e)
e
- An object providing the event data.protected void onLostFocus(ComponentEvent e)
e
- An object providing the event data.protected void onMouseMove(ComponentMouseEvent e)
e
- An object providing the event data.protected void onMouseUp(ComponentMouseEvent e)
protected void onMouseDown(ComponentMouseEvent e)
public java.lang.Object getParent()
public void setParent(java.lang.Object value)
public ComponentHost getParentHost()
public java.awt.geom.Rectangle2D.Float getBounds()
public void setBounds(java.awt.geom.Rectangle2D.Float value)
value
- The bounds of this component relative to its parent.public float getWidth()
public void setWidth(float value)
value
- A floating point value specifying the component's width. The default is NaN.public float getHeight()
public void setHeight(float value)
value
- A floating point value specifying the component's height. The default is NaN.public int getHorizontalAlignment()
public void setHorizontalAlignment(int value)
value
- A member of the HorizontalAlignment enumeration. The default is Stretch.public int getVerticalAlignment()
public void setVerticalAlignment(int value)
value
- A member of the VerticalAlignment enumeration. The default is Stretch.public java.lang.String getName()
public void setName(java.lang.String value)
value
- A String identifying this component within its component tree.public int getChildCount()
public boolean getIsHitTestVisible()
public void setIsHitTestVisible(boolean value)
value
- true if the component can be hit-tested; otherwise, false. The default is true.public boolean getIsFocused()
public void setIsFocused(boolean value)
value
- A boolean value specifying if the component currently holds the input focus.public boolean getIsEnabled()
public void setIsEnabled(boolean value)
value
- A boolean value specifying if the component is enabled and can be interacted with. The default is true.public boolean getIsInteractive()
public void setIsInteractive(boolean value)
value
- true if the component accepts user input, or false otherwise.public boolean getFocusable()
public void setFocusable(boolean value)
value
- A boolean value specifying if the component can receive the input focus. The default is false.public int getGridRow()
public void setGridRow(int value)
value
- An integer value specifying the 0-based index of the grid row in which to place this component. The default is 0.public int getGridColumn()
public void setGridColumn(int value)
value
- An integer value specifying the 0-based index of the grid column in which to place this component. The default is 0.public boolean getVisible()
public void setVisible(boolean value)
value
- true if the component is visible; otherwise, false. The default is true.public void addComponentEventListener(ComponentEventListener listener)
listener
- A ComponentEventListener object.public void addComponentMouseEventListener(ComponentMouseEventListener listener)
listener
- A ComponentMouseEventListener object.public void addComponentValidationEventListener(ComponentValidationEventListener listener)
listener
- A ComponentValidationEventListener object.public void removeComponentEventListener(ComponentEventListener listener)
listener
- ComponentEventListener object to remove.public void removeComponentMouseEventListener(ComponentMouseEventListener listener)
listener
- ComponentMouseEventListener object to remove.public void removeComponentValidationEventListener(ComponentValidationEventListener listener)
listener
- ComponentValidationEventListener object to remove.