|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pivot.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.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 Object |
getAttributes()
Returns the component's attributes. |
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()
|
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. |
int |
getMaximumPreferredHeight()
Gets the maximum preferred height of this component. |
int |
getMaximumPreferredWidth()
Gets the maximum preferred width of this component. |
MenuHandler |
getMenuHandler()
|
int |
getMinimumPreferredHeight()
Gets the minimum preferred height of this component. |
int |
getMinimumPreferredWidth()
Gets the minimum preferred width of this component. |
Container |
getParent()
|
int |
getPreferredHeight()
Returns the component's unconstrained preferred height. |
int |
getPreferredHeight(int width)
Returns the component's constrained preferred height. |
Limits |
getPreferredHeightLimits()
Gets the preferred height limits for this component. |
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. |
Limits |
getPreferredWidthLimits()
Gets the preferred width limits for this component. |
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 |
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. |
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 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(Object attributes)
Sets the component's attributes. |
void |
setCursor(Cursor cursor)
Sets the cursor that is displayed when the mouse pointer is over this component. |
void |
setCursor(String cursor)
|
void |
setDragSource(DragSource dragSource)
|
void |
setDropTarget(DropTarget dropTarget)
|
void |
setEnabled(boolean enabled)
Sets the component's enabled state. |
void |
setHeight(int height)
|
void |
setLocation(int x,
int y)
Sets the component's location. |
void |
setLocation(Point location)
Sets the component's location. |
void |
setMaximumPreferredHeight(int maximumPreferredHeight)
Sets the maximum preferred height of this component. |
void |
setMaximumPreferredWidth(int maximumPreferredWidth)
Sets the maximum preferred width of this component. |
void |
setMenuHandler(MenuHandler menuHandler)
|
void |
setMinimumPreferredHeight(int minimumPreferredHeight)
Sets the minimum preferred height of this component. |
void |
setMinimumPreferredWidth(int minimumPreferredWidth)
Sets the minimum preferred width of this component. |
protected void |
setParent(Container parent)
|
void |
setPreferredHeight(int preferredHeight)
Sets the component's preferred height. |
void |
setPreferredHeightLimits(int minimumPreferredHeight,
int maximumPreferredHeight)
Sets the preferred height limits for this component. |
void |
setPreferredHeightLimits(Limits preferredHeightLimits)
Sets the preferred height limits for this component. |
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 |
setPreferredWidthLimits(int minimumPreferredWidth,
int maximumPreferredWidth)
Sets the preferred width limits for this component. |
void |
setPreferredWidthLimits(Limits preferredWidthLimits)
Sets the preferred width limits for this component. |
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()
|
Component |
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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Component()
Method Detail |
---|
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 getMinimumPreferredWidth()
public void setMinimumPreferredWidth(int minimumPreferredWidth)
minimumPreferredWidth
- The minimum preferred width, or -1 to specify no minimum
preferred widthpublic int getMaximumPreferredWidth()
public void setMaximumPreferredWidth(int maximumPreferredWidth)
maximumPreferredWidth
- The maximum preferred widthpublic Limits getPreferredWidthLimits()
public void setPreferredWidthLimits(int minimumPreferredWidth, int maximumPreferredWidth)
minimumPreferredWidth
- The minimum preferred width for the componentmaximumPreferredWidth
- The maximum preferred width for the componentpublic final void setPreferredWidthLimits(Limits preferredWidthLimits)
preferredWidthLimits
- The preferred width limits for the componentpublic int getMinimumPreferredHeight()
public void setMinimumPreferredHeight(int minimumPreferredHeight)
minimumPreferredHeight
- The minimum preferred heightpublic int getMaximumPreferredHeight()
public void setMaximumPreferredHeight(int maximumPreferredHeight)
maximumPreferredHeight
- The maximum preferred heightpublic Limits getPreferredHeightLimits()
public void setPreferredHeightLimits(int minimumPreferredHeight, int maximumPreferredHeight)
minimumPreferredHeight
- The minimum preferred height for the componentmaximumPreferredHeight
- The maximum preferred height for the componentpublic final void setPreferredHeightLimits(Limits preferredHeightLimits)
preferredHeightLimits
- The preferred height limits for the componentpublic 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)
visible
- true if the component should be painted; 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()
public boolean requestFocus()
public Component transferFocus(Direction direction)
direction
- The direction in which to transfer focus.public static Component getFocusedComponent()
public static void clearFocus()
public static Component.ComponentDictionary getComponents()
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 MenuHandler getMenuHandler()
public void setMenuHandler(MenuHandler menuHandler)
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
- protected Object getAttributes()
protected void setAttributes(Object 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<ComponentStateListener> getComponentStateListeners()
public ListenerList<ComponentDecoratorListener> getComponentDecoratorListeners()
public ListenerList<ComponentMouseListener> getComponentMouseListeners()
public ListenerList<ComponentMouseButtonListener> getComponentMouseButtonListeners()
public ListenerList<ComponentMouseWheelListener> getComponentMouseWheelListeners()
public ListenerList<ComponentKeyListener> getComponentKeyListeners()
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 |