net.xoetrope.xui
Class WidgetAdapter

java.lang.Object
  extended by net.xoetrope.xui.WidgetAdapter
Direct Known Subclasses:
AwtWidgetAdapter, SwingWidgetAdapter, SwtWidgetAdapter

public abstract class WidgetAdapter
extends java.lang.Object

    

Adapts the abstract component definition used by the common xui (net.xoetrope.xui) package to the concrete definition of a widget as required by an individual widget set such as AWT, Swing, SWT or HTML components.

The widget adapter generally does little more than casting the abstract widget reference to the appropriate type. The interface specifies only those methods used by XUI to manipulate components, it is not intended for any other use. By the same token it does not prevent access to the methods of the underlying class.

Copyright (c) Xoetrope Ltd., 1998-2005

License: see license.txt

Since:
2.0

Field Summary
protected static WidgetAdapter instance
          Get the instance of the adapter
 
Constructor Summary
WidgetAdapter()
           
 
Method Summary
abstract  void add(java.lang.Object component, java.lang.Object comp)
          Add a component to the container
abstract  void add(java.lang.Object component, java.lang.Object comp, java.lang.Object constraint)
          Add a component to the container using a layout manager constraint
abstract  void doLayout(java.lang.Object component)
          Request that the container updates its layout
abstract  java.lang.Object getComponent(java.lang.Object container, int i)
          Get the child component at a specific index within the container.
abstract  int getComponentCount(java.lang.Object container)
          Get the number of child components owned by this component, assuming that the component is a container.
abstract  java.lang.Object[] getComponents(java.lang.Object container)
          Get the children.
abstract  int getHeight(java.lang.Object component)
          Get the component height
static WidgetAdapter getInstance()
          Get an instance of this adapter.
abstract  java.lang.Object getLayout(java.lang.Object component)
          Get the layout manager used by the container
abstract  java.lang.Object getLocation(java.lang.Object component)
          Get the location of the component
abstract  java.lang.String getName(java.lang.Object component)
          Get the name of the object
abstract  java.lang.Object getParent(java.lang.Object component)
          Get the parent/owner object
abstract  java.lang.Object getSize(java.lang.Object component)
          Get the size of the component
abstract  int getWidth(java.lang.Object component)
          Get the component width
abstract  int getX(java.lang.Object component)
          Get the location of the component's left (X) edge
abstract  int getY(java.lang.Object component)
          Get the location of the component's top (Y) edge
abstract  boolean isContainer(java.lang.Object container)
          Check if the component is a container object, that is that it is capable of containing children
abstract  boolean isVisible(java.lang.Object component)
          Is the component visible?
abstract  void remove(java.lang.Object component, java.lang.Object obj)
          Remove a component from the container
abstract  void repaint(java.lang.Object component)
          Request that the component repaints itself
abstract  void setBackground(java.lang.Object component, java.lang.Object c)
          Set the background color
abstract  void setBounds(java.lang.Object component, int x, int y, int w, int h)
          Set the current bounds for the component
abstract  void setCursor(java.lang.Object component, java.lang.Object cursor)
          Set the current cursor for the component
abstract  void setEnabled(java.lang.Object component, boolean b)
          Set the enabled state of the component
abstract  void setFont(java.lang.Object component, java.lang.Object f)
          Set the font
abstract  void setForeground(java.lang.Object component, java.lang.Object c)
          Set the foreground color
abstract  void setLayout(java.lang.Object component, java.lang.Object lm)
          Set the layout manager for the container
abstract  void setLocation(java.lang.Object component, int x, int y)
          Set the current location of the component
abstract  void setName(java.lang.Object component, java.lang.String name)
          Set the name of the component
abstract  void setSize(java.lang.Object component, int w, int h)
          Set the size of the component
abstract  void setVisible(java.lang.Object component, boolean state)
          Set the component visiblity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static WidgetAdapter instance
Get the instance of the adapter

Constructor Detail

WidgetAdapter

public WidgetAdapter()
Method Detail

getInstance

public static WidgetAdapter getInstance()
Get an instance of this adapter. The adapter is itself stateless so only a single instance of the class is required.

Returns:
The adapter instance

getName

public abstract java.lang.String getName(java.lang.Object component)
Get the name of the object

Parameters:
component - The component instance
Returns:
The name

getComponentCount

public abstract int getComponentCount(java.lang.Object container)
Get the number of child components owned by this component, assuming that the component is a container.

Parameters:
container - the container instance
Returns:
the number of children

getComponents

public abstract java.lang.Object[] getComponents(java.lang.Object container)
Get the children. Assumes that the object is a container

Parameters:
container - the container instance
Returns:
an array of the child components

getComponent

public abstract java.lang.Object getComponent(java.lang.Object container,
                                              int i)
Get the child component at a specific index within the container. Assumes that the object is a container

Parameters:
container - the container instance
i - the component index
Returns:
an array of the child components

isVisible

public abstract boolean isVisible(java.lang.Object component)
Is the component visible?

Parameters:
component - the component instance
Returns:
true if the component is visible

setVisible

public abstract void setVisible(java.lang.Object component,
                                boolean state)
Set the component visiblity

Parameters:
component - the component instance
state - true if the component is to be made visible

remove

public abstract void remove(java.lang.Object component,
                            java.lang.Object obj)
Remove a component from the container

Parameters:
component - the container instance
obj - the component to remove

add

public abstract void add(java.lang.Object component,
                         java.lang.Object comp)
Add a component to the container

Parameters:
component - the container instance
comp - the component to add

add

public abstract void add(java.lang.Object component,
                         java.lang.Object comp,
                         java.lang.Object constraint)
Add a component to the container using a layout manager constraint

Parameters:
component - the container instance
comp - the component to add
constraint - the layout constraint

setLayout

public abstract void setLayout(java.lang.Object component,
                               java.lang.Object lm)
Set the layout manager for the container

Parameters:
component - the container instance
lm - the LayoutManager instance

getLayout

public abstract java.lang.Object getLayout(java.lang.Object component)
Get the layout manager used by the container

Parameters:
component - the container instance
Returns:
the LayoutManager instance

doLayout

public abstract void doLayout(java.lang.Object component)
Request that the container updates its layout

Parameters:
component - the container instance

setForeground

public abstract void setForeground(java.lang.Object component,
                                   java.lang.Object c)
Set the foreground color

Parameters:
component - the container instance
c - the color

setBackground

public abstract void setBackground(java.lang.Object component,
                                   java.lang.Object c)
Set the background color

Parameters:
component - the container instance
c - the color

setFont

public abstract void setFont(java.lang.Object component,
                             java.lang.Object f)
Set the font

Parameters:
component - the container instance
f - the font

getSize

public abstract java.lang.Object getSize(java.lang.Object component)
Get the size of the component

Parameters:
component - the container instance
Returns:
the size of the object

getX

public abstract int getX(java.lang.Object component)
Get the location of the component's left (X) edge

Parameters:
component - the container instance
Returns:
the x coordinate

getY

public abstract int getY(java.lang.Object component)
Get the location of the component's top (Y) edge

Parameters:
component - the container instance
Returns:
the y coordinate

getWidth

public abstract int getWidth(java.lang.Object component)
Get the component width

Parameters:
component - the container instance
Returns:
the width

getHeight

public abstract int getHeight(java.lang.Object component)
Get the component height

Parameters:
component - the container instance
Returns:
the height

getParent

public abstract java.lang.Object getParent(java.lang.Object component)
Get the parent/owner object

Parameters:
component - the container instance
Returns:
the parent

setEnabled

public abstract void setEnabled(java.lang.Object component,
                                boolean b)
Set the enabled state of the component

Parameters:
component - the container instance
b - true to enable

setCursor

public abstract void setCursor(java.lang.Object component,
                               java.lang.Object cursor)
Set the current cursor for the component

Parameters:
component - the container instance
cursor - the cursor object

setBounds

public abstract void setBounds(java.lang.Object component,
                               int x,
                               int y,
                               int w,
                               int h)
Set the current bounds for the component

Parameters:
component - the container instance
x - the left/x edge coordinates
y - the top/y edge coordinates
w - the width dimension
h - the height dimension

setLocation

public abstract void setLocation(java.lang.Object component,
                                 int x,
                                 int y)
Set the current location of the component

Parameters:
component - the container instance
x - the left/x edge coordinates
y - the top/y edge coordinates

setSize

public abstract void setSize(java.lang.Object component,
                             int w,
                             int h)
Set the size of the component

Parameters:
component - the container instance
w - the width dimension
h - the height dimension

getLocation

public abstract java.lang.Object getLocation(java.lang.Object component)
Get the location of the component

Parameters:
component - the container instance
Returns:
the object indicating the location

setName

public abstract void setName(java.lang.Object component,
                             java.lang.String name)
Set the name of the component

Parameters:
component - the container instance
name - the new component name

repaint

public abstract void repaint(java.lang.Object component)
Request that the component repaints itself

Parameters:
component - the container instance

isContainer

public abstract boolean isContainer(java.lang.Object container)
Check if the component is a container object, that is that it is capable of containing children

Parameters:
container - the container instance
Returns:
true if the object is a container