A scene is a tree of small building blocks called widgets and represented by this class.
Each widget has a origin location specified relatively to the location its parent widget
and placement is specified be its boundary.
The widget is also responsible for rendering the region. The widget is an abstract implementation
and does not have render anything except borders and background. There are various built-in widget
each for a specific visualization. The widget also holds general properties like foreground, opacity, ...
that could be reused by the high-level widgets.
The widget has a layout assigned. The layout takes care about resolving the placement of children widgets.
For that it can use various properties like preferredLocation, preferredBounds, ...
When the widget is resolved (placed) than the read only location and bounds properties contains
resolved location and boundary of a widget.
Each widget has a chain of actions. Actions defined defines a behaviour of the widget. E.g. MoveAction
makes the widget moveable. Also there is possible to create/assign other chains that will be activated
based on the active tool of a scene.
The widget have its state specified by ObjectState class. When the widget state is change,
notifyStateChanged is called to notify about it. The state is automatically updated by high-level scenes
and actions. Yherefore you can define your own look and feel directly in the that method.
Since version 2.6 Widget class implements Accessible interface.
author: David Kaspar
addDependency(Widget.Dependency dependency) Adds a dependency listener which is notified when the widget placement or boundary is going to be changed or similar thing happens to its parent widget.
isCheckClipping() Returns whether clipping is used in the widget.
final public boolean
isEnabled() Returns whether the widget is enabled.
public boolean
isHitAt(Point localLocation) Called to whether a particular location in local coordination system is controlled (otionally also painted) by the widget.
resolveBounds(Point location, Rectangle bounds) Sets resolved location and bounds of the widget
This method is usually called from implementations of Layout interface.
final public void
revalidate(boolean repaintOnly) Schedules the widget to repaint or revalidation.
final public void
revalidate() Schedules the widget for revalidation.
The Scene.validate method has to be called after all changes to invoke validation.
Adds a child widget as the last one.
Parameters: child - the child widget to be added Parameters: constraint - the constraint assigned to the child widget
addChild
final public void addChild(int index, Widget child)(Code)
Adds a child at a specified index
Parameters: index - the index (the child is added before the one that is not the index place) Parameters: child - the child widget
addChild
final public void addChild(int index, Widget child, Object constraint)(Code)
Adds a child at a specified index
Parameters: index - the index (the child is added before the one that is not the index place) Parameters: child - the child widget Parameters: constraint - the constraint assigned to the child widget
addChildren
final public void addChildren(List<? extends Widget> children)(Code)
Adds all children in a specified list.
Parameters: children - the list of children widgets
Adds a dependency listener which is notified when the widget placement or boundary is going to be changed or similar thing happens to its parent widget.
Parameters: dependency - the dependency listener
Called to calculate the client area required by the widget without the children widgets.
the calculated client area
convertLocalToScene
final publicPoint convertLocalToScene(Point localLocation)(Code)
Converts a location in the local coordination system to the scene coordination system.
Parameters: localLocation - the local location the scene location
Converts a rectangle in the local coordination system to the scene coordination system.
Parameters: localRectangle - the local rectangle the scene rectangle
convertSceneToLocal
final publicPoint convertSceneToLocal(Point sceneLocation)(Code)
Converts a location in the scene coordination system to the local coordination system.
Parameters: sceneLocation - the scene location the local location
Converts a rectangle in the scene coordination system to the local coordination system.
Parameters: sceneRectangle - the scene rectangle the local rectangle
Returns the resolved bounds of the widget. The bounds are specified relatively to the location of the widget.
The location is resolved/set by calling resolveBounds method which should be called from Layout interface implementation only.
Therefore the corrent value is available only after the scene is validated (SceneListener.sceneValidated method).
Before validation a previous/obsolete or null value could be returned.
See Layout section in documentation.
the bounds in local coordination system
Returns a mouse cursor for a specified local location in the widget.
Parameters: localLocation - the local location the mouse cursor; default implementation return value of cursor property. since: 2.3
Returns a Graphics2D instance with is assigned to the scene.
Usually used in the calculatedClientArea and paintWidget method.
the Graphics2D instance; null if the scene view is not created or visible yet
Returns the resolved location of the widget. The location is specified relatively to the location of the parent widget.
The location is resolved/set by calling resolveBounds method which should be called from Layout interface implementation only.
Therefore the corrent value is available only after the scene is validated (SceneListener.sceneValidated method).
Before validation a previous/obsolete or [0,0] value could be returned.
See Layout section in documentation.
the location in the local coordination system of the parent widget
Returns a preferred bounds relatively to the location of the widget. If no preferred bounds are set, then it returns a preferred bounds
that are calculated from the calculateClientArea method of this widget and location and bounds of the children widgets.
This calculated bounds are processed by the minimum and maximum bounds too.
This method can be called after child widgets are layed out which is assured in method calls of the Layout interface implementation.
If preferred bounds are set (check it using isPreferredBoundsSet method), you can call this method at any time.
the preferred bounds
Called to whether a particular location in local coordination system is controlled (otionally also painted) by the widget.
Parameters: localLocation - the local location true, if the location belong to the widget
Returns whether whole area of the widget has to be repainted after the validation of the widget.
Used be LayerWidget for performance optiomalization.
true, if requires; false, if does not require
This method is called to notify that the view is shown.
Note: You must not modify a tree of widgets from within this method.
It means: do not call addChild, removeChild and similar methods.
This method is called to notify that the view is hidden.
Note: You must not modify a tree of widgets from within this method.
It means: do not call addChild, removeChild and similar methods.
Sets resolved location and bounds of the widget
This method is usually called from implementations of Layout interface.
Parameters: location - the resolved location; if null then [0,0] point is used instead Parameters: bounds - the resolved bounds; if null then the preferred bounds are used instead
revalidate
final public void revalidate(boolean repaintOnly)(Code)
Schedules the widget to repaint or revalidation.
Parameters: repaintOnly - if true, then the widget is scheduled for repainting only;if false, then widget is scheduled for revalidation (the Scene.validate method has to be called after all changes to invoke validation)
Schedules the widget for revalidation.
The Scene.validate method has to be called after all changes to invoke validation. In some cases it is invoked automatically.
Sets a cursor for the widget.
Parameters: cursor - the mouse cursor; if null, the cursor is unset
setEnabled
final public void setEnabled(boolean enabled)(Code)
Sets whether the widget is enabled.
If the widget is disabled then any event is processed by assigned actions.
Parameters: enabled - if true, then the widget is enabled
Sets the widget opacity.
Parameters: opaque - if true, then the widget is opaque
setPreferredBounds
final public void setPreferredBounds(Rectangle preferredBounds)(Code)
Sets a preferred bounds that are specified relatively to the location of the widget.
Parameters: preferredBounds - the preferred bounds; if null, then the preferred bounds are unset
setPreferredLocation
final public void setPreferredLocation(Point preferredLocation)(Code)
Sets a preferred location of the widget.
Parameters: preferredLocation - the preferred location; if null, then the preferred location is unset
setPreferredSize
final public void setPreferredSize(Dimension preferredSize)(Code)
Sets a preferred size of the widget
Parameters: preferredSize - the preferred size; if null, then preferred size are unset.