|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.wtk.Component
@IDProperty(value="name") 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".
Nested Class Summary | |
---|---|
class |
Component.DecoratorSequence
Decorator sequence implementation. |
class |
Component.StyleDictionary
Style dictionary implementation. |
class |
Component.UserDataDictionary
User data dictionary implementation. |
Constructor Summary | |
---|---|
Component()
|
Method Summary | ||
---|---|---|
void |
clear()
Clears any bound values in the component. |
|
static void |
clearFocus()
Clears the focus. |
|
boolean |
contains(int xArgument,
int yArgument)
Determines if the component contains a given location. |
|
Container |
getAncestor(Class<? extends Container> ancestorType)
|
|
Container |
getAncestor(String ancestorTypeName)
|
|
|
getAttribute(T key)
Gets the specified component attribute. |
|
String |
getAutomationID()
Returns the component's automation ID. |
|
int |
getBaseline()
Returns the component's baseline. |
|
int |
getBaseline(int width,
int height)
Returns the component's baseline for a given width and height. |
|
Bounds |
getBounds()
Returns the component's bounding area. |
|
static ListenerList<ComponentClassListener> |
getComponentClassListeners()
|
|
ListenerList<ComponentDataListener> |
getComponentDataListeners()
|
|
ListenerList<ComponentDecoratorListener> |
getComponentDecoratorListeners()
|
|
ListenerList<ComponentKeyListener> |
getComponentKeyListeners()
|
|
ListenerList<ComponentListener> |
getComponentListeners()
|
|
ListenerList<ComponentMouseButtonListener> |
getComponentMouseButtonListeners()
|
|
ListenerList<ComponentMouseListener> |
getComponentMouseListeners()
|
|
ListenerList<ComponentMouseWheelListener> |
getComponentMouseWheelListeners()
|
|
ListenerList<ComponentStateListener> |
getComponentStateListeners()
|
|
ListenerList<ComponentStyleListener> |
getComponentStyleListeners()
|
|
ListenerList<ComponentTooltipListener> |
getComponentTooltipListeners()
|
|
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. |
|
int |
getHeight()
Returns the visual's height. |
|
Limits |
getHeightLimits()
Returns the height limits for this component. |
|
Point |
getLocation()
Returns the component's location. |
|
int |
getMaximumHeight()
Returns the maximum height of this component. |
|
int |
getMaximumWidth()
Returns the maximum width of this component. |
|
MenuHandler |
getMenuHandler()
|
|
int |
getMinimumHeight()
Returns the minimum height of this component. |
|
int |
getMinimumWidth()
Returns the minimum width of this component. |
|
Point |
getMouseLocation()
Returns the current mouse location in the component's coordinate space. |
|
String |
getName()
Returns the component's name. |
|
static Map<String,Map<String,?>> |
getNamedStyles()
Returns the named style dictionary. |
|
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 the component's style dictionary. |
|
int |
getTooltipDelay()
Returns the component's tooltip delay. |
|
String |
getTooltipText()
Returns the component's tooltip text. |
|
boolean |
getTooltipWrapText()
Returns the tooltip's mode for wrapping its text. |
|
static Map<Class<? extends Component>,Map<String,?>> |
getTypedStyles()
Returns the typed style dictionary. |
|
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 xArgument,
int yArgument,
int width,
int height)
Determines the visible area of a component. |
|
int |
getWidth()
Returns the visual's width. |
|
Limits |
getWidthLimits()
Returns the width limits for this component. |
|
Window |
getWindow()
|
|
int |
getX()
Returns the component's x-coordinate. |
|
int |
getY()
Returns the component's y-coordinate. |
|
protected static void |
indexBoundsCheck(String indexName,
int index,
int min,
int max)
Provide a nice exception message for out of range values. |
|
protected void |
installSkin(Class<? extends Component> componentClass)
Installs the skin for the given component class, as defined by the current theme. |
|
void |
invalidate()
Flags the component's hierarchy as invalid, and clears any cached preferred size. |
|
boolean |
isBlocked()
Determines if this component is blocked. |
|
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)
|
|
protected void |
layout()
Called to lay out the component. |
|
void |
load(Object context)
Copies bound values from the bind context to the component. |
|
Point |
mapPointFromAncestor(Container ancestor,
int xArgument,
int yArgument)
Maps a point in the specified ancestor's coordinate space to this component's coordinate system. |
|
Point |
mapPointFromAncestor(Container ancestor,
Point location)
|
|
Point |
mapPointToAncestor(Container ancestor,
int xArgument,
int yArgument)
Maps a point in this component's coordinate system to the specified ancestor's coordinate space. |
|
Point |
mapPointToAncestor(Container ancestor,
Point location)
Maps a point in this component's coordinate system to the specified ancestor's coordinate space. |
|
protected boolean |
mouseClick(Mouse.Button button,
int xArgument,
int yArgument,
int count)
|
|
protected boolean |
mouseDown(Mouse.Button button,
int xArgument,
int yArgument)
|
|
protected boolean |
mouseMove(int xArgument,
int yArgument)
|
|
protected void |
mouseOut()
|
|
protected void |
mouseOver()
|
|
protected boolean |
mouseUp(Mouse.Button button,
int xArgument,
int yArgument)
|
|
protected boolean |
mouseWheel(Mouse.ScrollType scrollType,
int scrollAmount,
int wheelRotation,
int xArgument,
int yArgument)
|
|
void |
paint(Graphics2D graphics)
Paints the component. |
|
void |
reenterMouse()
If the mouse is currently over the component, causes the component to fire mouseOut() and a mouseMove() at the current mouse location. |
|
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 xArgument,
int yArgument,
int width,
int height)
Flags an area as needing to be repainted. |
|
void |
repaint(int xArgument,
int yArgument,
int width,
int height,
boolean immediate)
Flags an area as needing to be repainted. |
|
boolean |
requestFocus()
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 xArgument,
int yArgument,
int width,
int height)
Ensures that the given area of a component is visible within the viewports of all applicable ancestors. |
|
|
setAttribute(T key,
Object value)
Sets the specified component attribute. |
|
void |
setAutomationID(String automationID)
Sets the component's automation ID. |
|
void |
setCursor(Cursor cursor)
Sets the cursor that is displayed when the mouse pointer is over this component. |
|
void |
setDragSource(DragSource dragSource)
|
|
void |
setDropTarget(DropTarget dropTarget)
|
|
void |
setEnabled(boolean enabled)
Sets the component's enabled state. |
|
protected void |
setFocused(boolean focused,
Component obverseComponent)
Called to notify a component that its focus state has changed. |
|
void |
setHeight(int height)
|
|
void |
setHeightLimits(int minimumHeight,
int maximumHeight)
Sets the height limits for this component. |
|
void |
setHeightLimits(Limits heightLimits)
Sets the height limits for this component. |
|
void |
setLocation(int x,
int y)
Sets the component's location. |
|
void |
setLocation(Point location)
Sets the component's location. |
|
void |
setMaximumHeight(int maximumHeight)
Sets the maximum height of this component. |
|
void |
setMaximumWidth(int maximumWidth)
Sets the maximum width of this component. |
|
void |
setMenuHandler(MenuHandler menuHandler)
|
|
void |
setMinimumHeight(int minimumHeight)
Sets the minimum height of this component. |
|
void |
setMinimumWidth(int minimumWidth)
Sets the minimum width of this component. |
|
void |
setName(String name)
Sets the component's name. |
|
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 |
setStyleName(String styleName)
Applies a set of named styles. |
|
void |
setStyleNames(Sequence<String> styleNames)
Applies a set of named styles. |
|
void |
setStyleNames(String styleNames)
Applies a set of named styles. |
|
void |
setStyles(Map<String,?> styles)
Applies a set of styles. |
|
void |
setStyles(String styles)
Applies a set of styles. |
|
void |
setTooltipDelay(int tooltipDelay)
Sets the component's tooltip delay. |
|
void |
setTooltipText(String tooltipText)
Sets the component's tooltip text. |
|
void |
setTooltipWrapText(boolean tooltipWrapText)
Sets the tooltip's text wrapping mode. |
|
void |
setVisible(boolean visible)
Sets the component's visibility. |
|
void |
setWidth(int width)
|
|
void |
setWidthLimits(int minimumWidth,
int maximumWidth)
Sets the width limits for this component. |
|
void |
setWidthLimits(Limits widthLimits)
Sets the width limits for this component. |
|
void |
setX(int x)
Sets the component's x-coordinate. |
|
void |
setY(int y)
Sets the component's y-coordinate. |
|
void |
store(Object context)
Copies bound values from the component to the bind context. |
|
String |
toString()
|
|
Component |
transferFocus(FocusTraversalDirection 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Component()
Method Detail |
---|
public String getAutomationID()
public void setAutomationID(String automationID)
Automation.get(String)
when the
component is attached to a component hierarchy.
automationID
- The automation ID to use for the component, or null to clear the
automation ID.protected Skin getSkin()
protected void setSkin(Skin skin)
skin
- The new skin.protected void installSkin(Class<? extends Component> componentClass)
componentClass
- public Container getParent()
protected void setParent(Container parent)
public Window getWindow()
public Display getDisplay()
public Container getAncestor(Class<? extends Container> ancestorType)
public Container getAncestor(String ancestorTypeName) throws ClassNotFoundException
ClassNotFoundException
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 getMinimumWidth()
public void setMinimumWidth(int minimumWidth)
minimumWidth
- public int getMaximumWidth()
public void setMaximumWidth(int maximumWidth)
maximumWidth
- public Limits getWidthLimits()
public void setWidthLimits(int minimumWidth, int maximumWidth)
minimumWidth
- maximumWidth
- public final void setWidthLimits(Limits widthLimits)
widthLimits
- public int getMinimumHeight()
public void setMinimumHeight(int minimumHeight)
minimumHeight
- public int getMaximumHeight()
public void setMaximumHeight(int maximumHeight)
maximumHeight
- public Limits getHeightLimits()
public void setHeightLimits(int minimumHeight, int maximumHeight)
minimumHeight
- maximumHeight
- public final void setHeightLimits(Limits heightLimits)
heightLimits
- 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 int getBaseline()
getBaseline
in interface Visual
public int getBaseline(int width, int height)
getBaseline
in interface ConstrainedVisual
public Bounds getBounds()
public Bounds getDecoratedBounds()
public boolean contains(int xArgument, int yArgument)
xArgument
- yArgument
-
UnsupportedOperationException
- This method is not currently implemented.public boolean isVisible()
public void setVisible(boolean visible)
visible
- true if the component should be painted; false,
otherwise.public Component.DecoratorSequence getDecorators()
public Point mapPointToAncestor(Container ancestor, int xArgument, int yArgument)
xArgument
- The x-coordinate in this component's coordinate spaceyArgument
- The y-coordinate in this component's coordinate space
public Point mapPointToAncestor(Container ancestor, Point location)
location
- The coordinates in this component's coordinate space
public Point mapPointFromAncestor(Container ancestor, int xArgument, int yArgument)
xArgument
- The x-coordinate in the ancestors's coordinate space.yArgument
- The y-coordinate in the ancestor's coordinate space.
public Point mapPointFromAncestor(Container ancestor, Point location)
public boolean isShowing()
public Bounds getVisibleArea()
public Bounds getVisibleArea(Bounds area)
area
-
public Bounds getVisibleArea(int xArgument, int yArgument, int width, int height)
xArgument
- yArgument
- width
- height
-
public void scrollAreaToVisible(Bounds area)
area
- public void scrollAreaToVisible(int xArgument, int yArgument, int width, int height)
xArgument
- yArgument
- width
- height
- public boolean isValid()
public void invalidate()
public void validate()
Skin.layout()
.
protected void 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 xArgument, int yArgument, int width, int height)
xArgument
- yArgument
- width
- height
- public void repaint(int xArgument, int yArgument, int width, int height, boolean immediate)
xArgument
- yArgument
- 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 Point getMouseLocation()
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 String getTooltipText()
public void setTooltipText(String tooltipText)
tooltipText
- The component's tooltip text, or null for no tooltip.public int getTooltipDelay()
public void setTooltipDelay(int tooltipDelay)
tooltipDelay
- The tooltip delay, in milliseconds.public boolean getTooltipWrapText()
public void setTooltipWrapText(boolean tooltipWrapText)
tooltipWrapText
- The component's tooltip text wrap mode.public boolean isOpaque()
public boolean isFocusable()
public boolean isFocused()
protected void setFocused(boolean focused, Component obverseComponent)
focused
- true if the component has received the input focus;
false if the component has lost the focus.obverseComponent
- If focused is true, the component that has lost the focus;
otherwise, the component that has gained the focus.public boolean requestFocus()
public Component transferFocus(FocusTraversalDirection direction)
direction
- The direction in which to transfer focus.public static Component getFocusedComponent()
public static void clearFocus()
public void load(Object context)
context
- public void store(Object context)
context
- public void clear()
public DragSource getDragSource()
public void setDragSource(DragSource dragSource)
public DropTarget getDropTarget()
public void setDropTarget(DropTarget dropTarget)
public MenuHandler getMenuHandler()
public void setMenuHandler(MenuHandler menuHandler)
public String getName()
public void setName(String name)
name
- public final Component.StyleDictionary getStyles()
public void setStyles(Map<String,?> styles)
styles
- A map containing the styles to apply.public void setStyles(String styles) throws SerializationException
styles
- The styles encoded as a JSON map.
SerializationException
public static Map<Class<? extends Component>,Map<String,?>> getTypedStyles()
public static Map<String,Map<String,?>> getNamedStyles()
public void setStyleName(String styleName)
styleName
- public void setStyleNames(Sequence<String> styleNames)
styleNames
- public void setStyleNames(String styleNames)
styleNames
- public Component.UserDataDictionary getUserData()
public <T extends Enum<T>> Object getAttribute(T key)
key
- The attribute key
public <T extends Enum<T>> Object setAttribute(T key, Object value)
key
- The attribute keyvalue
- The attribute value, or null to clear the attribute
public void reenterMouse()
This method is primarily useful when consuming container mouse motion events, since it allows a caller to reset the mouse state based on the event consumption logic.
protected boolean mouseMove(int xArgument, int yArgument)
protected void mouseOver()
protected void mouseOut()
protected boolean mouseDown(Mouse.Button button, int xArgument, int yArgument)
protected boolean mouseUp(Mouse.Button button, int xArgument, int yArgument)
protected boolean mouseClick(Mouse.Button button, int xArgument, int yArgument, int count)
protected boolean mouseWheel(Mouse.ScrollType scrollType, int scrollAmount, int wheelRotation, int xArgument, int yArgument)
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<ComponentStateListener> getComponentStateListeners()
public ListenerList<ComponentDecoratorListener> getComponentDecoratorListeners()
public ListenerList<ComponentStyleListener> getComponentStyleListeners()
public ListenerList<ComponentMouseListener> getComponentMouseListeners()
public ListenerList<ComponentMouseButtonListener> getComponentMouseButtonListeners()
public ListenerList<ComponentMouseWheelListener> getComponentMouseWheelListeners()
public ListenerList<ComponentKeyListener> getComponentKeyListeners()
public ListenerList<ComponentTooltipListener> getComponentTooltipListeners()
public ListenerList<ComponentDataListener> getComponentDataListeners()
public static ListenerList<ComponentClassListener> getComponentClassListeners()
protected static final void indexBoundsCheck(String indexName, int index, int min, int max) throws IndexOutOfBoundsException
IndexOutOfBoundsException
- if index is out of range.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |