|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpivot.wtk.Component
public abstract class Component
Top level abstract base class for all components. In MVC terminology, a
component represents the "controller". It has no inherent visual
representation and acts as an intermediary between the component's data (the
"model") and the skin, an implementation of Skin
which serves as
the "view".
TODO Add a contains() method or some equivalent that will support mouse interaction with non-rectangular components.
Nested Class Summary | |
---|---|
static class |
Component.Attributes
Abstract base class for component "attributes". |
static class |
Component.ComponentDictionary
Provides dictionary access to all components by handle. |
class |
Component.DecoratorSequence
Decorator sequence implementation. |
class |
Component.StyleDictionary
Style dictionary implementation. |
class |
Component.UserDataDictionary
User data dictionary implementation. |
Constructor Summary | |
---|---|
Component()
Creates a new component. |
Method Summary | |
---|---|
static void |
clearFocus()
Clears the focus. |
protected static void |
clearFocus(boolean temporary)
Clears the focus. |
protected void |
finalize()
|
Component.Attributes |
getAttributes()
Returns the currently installed attributes. |
Bounds |
getBounds()
Returns the component's bounding area. |
static ListenerList<ComponentClassListener> |
getComponentClassListeners()
|
ListenerList<ComponentDataListener> |
getComponentDataListeners()
|
ListenerList<ComponentDecoratorListener> |
getComponentDecoratorListeners()
|
ListenerList<ComponentDragDropListener> |
getComponentDragDropListeners()
|
ListenerList<ComponentKeyListener> |
getComponentKeyListeners()
|
ListenerList<ComponentLayoutListener> |
getComponentLayoutListeners()
|
ListenerList<ComponentListener> |
getComponentListeners()
|
ListenerList<ComponentMouseButtonListener> |
getComponentMouseButtonListeners()
|
ListenerList<ComponentMouseListener> |
getComponentMouseListeners()
|
ListenerList<ComponentMouseWheelListener> |
getComponentMouseWheelListeners()
|
static Component.ComponentDictionary |
getComponents()
Returns the component dictionary. |
ListenerList<ComponentStateListener> |
getComponentStateListeners()
|
Cursor |
getCursor()
Returns the cursor that is displayed when the mouse pointer is over this component. |
Bounds |
getDecoratedBounds()
Returns the component's bounding area including decorators. |
Component.DecoratorSequence |
getDecorators()
Returns the component's decorator sequence. |
Display |
getDisplay()
|
DragSource |
getDragSource()
|
DropTarget |
getDropTarget()
|
static Component |
getFocusedComponent()
Returns the currently focused component. |
Graphics2D |
getGraphics()
Creates a graphics context for this component. |
Integer |
getHandle()
Return's the component's handle. |
int |
getHeight()
Returns the visual's height. |
Point |
getLocation()
Returns the component's location. |
Container |
getParent()
|
int |
getPreferredHeight()
Returns the component's unconstrained preferred height. |
int |
getPreferredHeight(int width)
Returns the component's constrained preferred height. |
Dimensions |
getPreferredSize()
Gets the component's unconstrained preferred size. |
int |
getPreferredWidth()
Returns the component's unconstrained preferred width. |
int |
getPreferredWidth(int height)
Returns the component's constrained preferred width. |
Dimensions |
getSize()
|
protected Skin |
getSkin()
Returns the currently installed skin. |
Component.StyleDictionary |
getStyles()
Returns a dictionary instance representing the component's style properties. |
String |
getTooltipText()
Returns the component's tooltip text. |
Component.UserDataDictionary |
getUserData()
Returns the user data dictionary. |
Bounds |
getVisibleArea()
Determines the visible area of a component. |
Bounds |
getVisibleArea(Bounds area)
Determines the visible area of a component. |
Bounds |
getVisibleArea(int x,
int y,
int width,
int height)
Determines the visible area of a component. |
int |
getWidth()
Returns the visual's width. |
Window |
getWindow()
|
int |
getX()
Returns the component's x-coordinate. |
int |
getY()
Returns the component's y-coordinate. |
protected void |
installSkin(Class<? extends Component> componentClass)
Installs the skin for the given component class, unless a subclass has defined a more specific skin. |
void |
invalidate()
Flags the component's hierarchy as invalid, and clears any cached preferred size. |
boolean |
isBlocked()
Determines if this component is blocked. |
boolean |
isDisplayable()
Returns the component's displayability. |
boolean |
isEnabled()
Returns the component's enabled state. |
boolean |
isFocusable()
Returns this component's focusability. |
boolean |
isFocused()
Returns the component's focused state. |
boolean |
isMouseOver()
Determines if the mouse is positioned over this component. |
boolean |
isOpaque()
Tells whether or not this component is fully opaque when painted. |
boolean |
isPreferredHeightSet()
Returns a flag indicating whether the preferred height was explicitly set by the caller or is the default value determined by the skin. |
boolean |
isPreferredSizeSet()
Returns a flag indicating whether the preferred size was explicitly set by the caller or is the default value determined by the skin. |
boolean |
isPreferredWidthSet()
Returns a flag indicating whether the preferred width was explicitly set by the caller or is the default value determined by the skin. |
boolean |
isShowing()
Determines if this component is showing. |
boolean |
isValid()
Returns the component's valid state. |
boolean |
isVisible()
Returns the component's visibility. |
protected boolean |
keyPressed(int keyCode,
Keyboard.KeyLocation keyLocation)
|
protected boolean |
keyReleased(int keyCode,
Keyboard.KeyLocation keyLocation)
|
protected boolean |
keyTyped(char character)
|
void |
load(Dictionary<String,?> context)
Copies bound values from the bind context to the component. |
void |
load(Object context)
Copies bound values from the bind context to the component by converting the given context to a bean dictionary. |
Point |
mapPointFromAncestor(Container ancestor,
int x,
int y)
Maps a point in the specified ancestor's coordinate space to this component's coordinate system. |
Point |
mapPointToAncestor(Container ancestor,
int x,
int y)
Maps a point in this component's coordinate system to the specified ancestor's coordinate space. |
protected boolean |
mouseClick(Mouse.Button button,
int x,
int y,
int count)
|
protected boolean |
mouseDown(Mouse.Button button,
int x,
int y)
|
protected boolean |
mouseMove(int x,
int y)
|
protected void |
mouseOut()
|
protected void |
mouseOver()
|
protected boolean |
mouseUp(Mouse.Button button,
int x,
int y)
|
protected boolean |
mouseWheel(Mouse.ScrollType scrollType,
int scrollAmount,
int wheelRotation,
int x,
int y)
|
void |
paint(Graphics2D graphics)
Paints the component. |
void |
repaint()
Flags the entire component as needing to be repainted. |
void |
repaint(boolean immediate)
Flags the entire component as needing to be repainted. |
void |
repaint(Bounds area)
Flags an area as needing to be repainted. |
void |
repaint(Bounds area,
boolean immediate)
Flags an area as needing to be repainted or repaints the rectangle immediately. |
void |
repaint(int x,
int y,
int width,
int height)
Flags an area as needing to be repainted. |
void |
repaint(int x,
int y,
int width,
int height,
boolean immediate)
Flags an area as needing to be repainted. |
void |
requestFocus()
Requests that focus be given to this component. |
protected void |
requestFocus(boolean temporary)
Requests that focus be given to this component. |
void |
scrollAreaToVisible(Bounds area)
Ensures that the given area of a component is visible within the viewports of all applicable ancestors. |
void |
scrollAreaToVisible(int x,
int y,
int width,
int height)
Ensures that the given area of a component is visible within the viewports of all applicable ancestors. |
protected void |
setAttributes(Component.Attributes attributes)
Sets the attributes. |
void |
setCursor(Cursor cursor)
Sets the cursor that is displayed when the mouse pointer is over this component. |
void |
setCursor(String cursor)
|
void |
setDisplayable(boolean displayable)
Sets the component's displayability. |
void |
setDragSource(DragSource dragSource)
|
void |
setDropTarget(DropTarget dropTarget)
|
void |
setEnabled(boolean enabled)
Sets the component's enabled state. |
protected void |
setFocused(boolean focused,
boolean temporary)
Called to notify a component that its focus state has changed. |
void |
setHeight(int height)
|
void |
setLocation(int x,
int y)
Sets the component's location. |
void |
setLocation(Point location)
Sets the component's location. |
protected void |
setParent(Container parent)
|
void |
setPreferredHeight(int preferredHeight)
Sets the component's preferred height. |
void |
setPreferredSize(Dimensions preferredSize)
|
void |
setPreferredSize(int preferredWidth,
int preferredHeight)
Sets the component's preferred size. |
void |
setPreferredWidth(int preferredWidth)
Sets the component's preferred width. |
void |
setSize(Dimensions size)
|
void |
setSize(int width,
int height)
NOTE This method should only be called during layout. |
protected void |
setSkin(Skin skin)
Sets the skin, replacing any previous skin. |
void |
setStyles(Map<String,?> styles)
Applies a set of styles. |
void |
setStyles(String styles)
Applies a set of styles encoded as a JSON string. |
void |
setStyles(URL styles)
Applies a set of styles. |
void |
setTooltipText(String tooltipText)
Sets the component's tooltip text. |
void |
setVisible(boolean visible)
Sets the component's visibility. |
void |
setWidth(int width)
|
void |
setX(int x)
Sets the component's x-coordinate. |
void |
setY(int y)
Sets the component's y-coordinate. |
void |
store(Dictionary<String,?> context)
Copies bound values from the component to the bind context. |
void |
store(Object context)
Copies bound values from the component to the bind context by converting the given context to a bean dictionary. |
String |
toString()
|
void |
transferFocus(Direction direction)
Transfers focus to the next focusable component. |
void |
validate()
Lays out the component by calling Skin.layout() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Component()
Method Detail |
---|
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public Integer getHandle()
protected Skin getSkin()
protected void setSkin(Skin skin)
skin
- The new skin.protected final void installSkin(Class<? extends Component> componentClass)
componentClass
- public Container getParent()
protected void setParent(Container parent)
public Window getWindow()
public Display getDisplay()
public int getWidth()
Visual
getWidth
in interface Visual
public void setWidth(int width)
public int getHeight()
Visual
getHeight
in interface Visual
public void setHeight(int height)
public Dimensions getSize()
public final void setSize(Dimensions size)
public void setSize(int width, int height)
setPreferredSize(int, int)
.
setSize
in interface ConstrainedVisual
width
- height
- public int getPreferredWidth()
public int getPreferredWidth(int height)
getPreferredWidth
in interface ConstrainedVisual
height
- The height value by which the preferred width should be constrained, or
-1 for no constraint.
public void setPreferredWidth(int preferredWidth)
preferredWidth
- The preferred width value, or -1 to use the default
value determined by the skin.public boolean isPreferredWidthSet()
public int getPreferredHeight()
public int getPreferredHeight(int width)
getPreferredHeight
in interface ConstrainedVisual
width
- The width value by which the preferred height should be constrained, or
-1 for no constraint.
public void setPreferredHeight(int preferredHeight)
preferredHeight
- The preferred height value, or -1 to use the default
value determined by the skin.public boolean isPreferredHeightSet()
public Dimensions getPreferredSize()
getPreferredSize
in interface ConstrainedVisual
public final void setPreferredSize(Dimensions preferredSize)
public void setPreferredSize(int preferredWidth, int preferredHeight)
preferredWidth
- The preferred width value, or -1 to use the default
value determined by the skin.preferredHeight
- The preferred height value, or -1 to use the default
value determined by the skin.public boolean isPreferredSizeSet()
public int getX()
public void setX(int x)
x
- The component's horizontal position relative to the origin of the
parent container.public int getY()
public void setY(int y)
y
- The component's vertical position relative to the origin of the
parent container.public Point getLocation()
public void setLocation(int x, int y)
x
- The component's horizontal position relative to the origin of the
parent container.y
- The component's vertical position relative to the origin of the
parent container.public final void setLocation(Point location)
location
- A point value containing the component's horizontal and vertical
position relative to the origin of the parent container.setLocation(int, int)
public Bounds getBounds()
public Bounds getDecoratedBounds()
public boolean isVisible()
public void setVisible(boolean visible)
NOTE This method should only be called during layout. Callers should
use setDisplayable(boolean)
.
visible
- true if the component should be painted; false,
otherwise.public boolean isDisplayable()
public void setDisplayable(boolean displayable)
displayable
- true if the component will participate in layout;
false, otherwise.public Component.DecoratorSequence getDecorators()
public Point mapPointToAncestor(Container ancestor, int x, int y)
x
- The x-coordinate in this component's coordinate spacey
- The y-coordinate in this component's coordinate space
public Point mapPointFromAncestor(Container ancestor, int x, int y)
x
- The x-coordinate in the ancestors's coordinate space.y
- The y-coordinate in the ancestor's coordinate space.
public boolean isShowing()
public Bounds getVisibleArea()
public Bounds getVisibleArea(Bounds area)
area
-
public Bounds getVisibleArea(int x, int y, int width, int height)
x
- y
- width
- height
-
public void scrollAreaToVisible(Bounds area)
area
- public void scrollAreaToVisible(int x, int y, int width, int height)
x
- y
- width
- height
- public boolean isValid()
public void invalidate()
public void validate()
Skin.layout()
.
public final void repaint()
public final void repaint(boolean immediate)
immediate
- public final void repaint(Bounds area)
area
- public final void repaint(Bounds area, boolean immediate)
area
- immediate
- public final void repaint(int x, int y, int width, int height)
x
- y
- width
- height
- public void repaint(int x, int y, int width, int height, boolean immediate)
x
- y
- width
- height
- immediate
- public void paint(Graphics2D graphics)
paint
in interface Visual
graphics
- The graphics context in which to paint the visual.public Graphics2D getGraphics()
isShowing()
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- true if the component is enabled; false, otherwise.public boolean isBlocked()
public boolean isMouseOver()
public Cursor getCursor()
public void setCursor(Cursor cursor)
cursor
- The cursor to display over the component, or null to inherit
the cursor of the parent container.public final void setCursor(String cursor)
public String getTooltipText()
public void setTooltipText(String tooltipText)
tooltipText
- The component's tooltip text, or null for no tooltip.public boolean isOpaque()
public boolean isFocusable()
public boolean isFocused()
protected void setFocused(boolean focused, boolean temporary)
focused
- true if the component has received the input focus;
false if the component has lost the focus.temporary
- true if this focus change is temporary; false,
otherwise.public void requestFocus()
protected void requestFocus(boolean temporary)
temporary
- If true, indicates that focus is being restored from a
temporary loss.public void transferFocus(Direction direction)
direction
- The direction in which to transfer focus.public static Component getFocusedComponent()
public static void clearFocus()
public static Component.ComponentDictionary getComponents()
protected static void clearFocus(boolean temporary)
temporary
- If true, the focus is being cleared temporarily.public void load(Dictionary<String,?> context)
context
- public final void load(Object context)
context
- public void store(Dictionary<String,?> context)
context
- public final void store(Object context)
context
- public DragSource getDragSource()
public void setDragSource(DragSource dragSource)
public DropTarget getDropTarget()
public void setDropTarget(DropTarget dropTarget)
public Component.UserDataDictionary getUserData()
public final Component.StyleDictionary getStyles()
public void setStyles(Map<String,?> styles)
styles
- public void setStyles(URL styles) throws IOException, SerializationException
styles
- The location of the styles to apply. If the styles have been previously
applied, they will be retrieved from the resource cache in the
application context. Otherwise, they will be loaded from the given
location and added to the cache before being applied.
IOException
SerializationException
public void setStyles(String styles)
styles
- public Component.Attributes getAttributes()
protected void setAttributes(Component.Attributes attributes)
attributes
- protected boolean mouseMove(int x, int y)
protected void mouseOver()
protected void mouseOut()
protected boolean mouseDown(Mouse.Button button, int x, int y)
protected boolean mouseUp(Mouse.Button button, int x, int y)
protected boolean mouseClick(Mouse.Button button, int x, int y, int count)
protected boolean mouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int x, int y)
protected boolean keyTyped(char character)
protected boolean keyPressed(int keyCode, Keyboard.KeyLocation keyLocation)
protected boolean keyReleased(int keyCode, Keyboard.KeyLocation keyLocation)
public String toString()
toString
in class Object
public ListenerList<ComponentListener> getComponentListeners()
public ListenerList<ComponentLayoutListener> getComponentLayoutListeners()
public ListenerList<ComponentStateListener> getComponentStateListeners()
public ListenerList<ComponentDecoratorListener> getComponentDecoratorListeners()
public ListenerList<ComponentMouseListener> getComponentMouseListeners()
public ListenerList<ComponentMouseButtonListener> getComponentMouseButtonListeners()
public ListenerList<ComponentMouseWheelListener> getComponentMouseWheelListeners()
public ListenerList<ComponentKeyListener> getComponentKeyListeners()
public ListenerList<ComponentDragDropListener> getComponentDragDropListeners()
public ListenerList<ComponentDataListener> getComponentDataListeners()
public static ListenerList<ComponentClassListener> getComponentClassListeners()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |