charva.awt
Class Component

java.lang.Object
  extended bycharva.awt.Component
Direct Known Subclasses:
Container, JComponent, JSeparator, MultiLineLabel, TableHeader

public abstract class Component
extends java.lang.Object

Component is the abstract superclass of all the other CHARVA widgets.


Field Summary
protected  float _alignmentX
          the X-alignment of this component
protected  float _alignmentY
          the Y-alignment of this component
protected  Color _background
          If the background color is null, this component inherits the background color of its parent Container.
protected  int _cursesColor
          The number of this component's color-pair, as computed by the ncurses COLOR_PAIR macro.
protected  boolean _enabled
          This flag is true if this component can react to user input.
protected  java.util.Vector _focusListeners
          A list of FocusListeners registered for this component.
protected  Color _foreground
          If the foreground color is null, this component inherits the foreground color of its parent Container.
protected  java.util.Vector _keyListeners
          A list of KeyListeners registered for this component.
protected  Point _origin
          The coordinates of the top-left corner of the component, relative to its parent container.
protected  java.lang.ref.WeakReference _parent
          A WeakReference to the Container (e.g Window, Panel or Dialog) that contains us.
protected  boolean _visible
          A flag that determines whether this component should be displayed (if its parent is displayed).
static float BOTTOM_ALIGNMENT
           
static float CENTER_ALIGNMENT
           
static float LEFT_ALIGNMENT
           
static float RIGHT_ALIGNMENT
           
static float TOP_ALIGNMENT
           
 
Constructor Summary
Component()
          Constructor
 
Method Summary
 void addFocusListener(FocusListener fl_)
          Register a FocusListener object for this component.
 void addKeyListener(KeyListener kl_)
          Register a KeyListener object for this component.
 boolean contains(int x, int y)
           
 boolean contains(Point p)
          Checks whether this component "contains" the specified point, where the point's x and y coordinates are defined to be relative to the top left corner of the parent Container.
abstract  void debug(int level_)
           
abstract  void draw()
          To be implemented by concrete subclasses.
 float getAlignmentX()
          Returns the alignment along the X axis.
 float getAlignmentY()
          Returns the alignment along the Y axis.
 Window getAncestorWindow()
          Get the Window that contains this component.
 Color getBackground()
          Get the background color of this component.
 Rectangle getBounds()
          Get the bounding rectangle of this component, relative to the origin of its parent Container.
 int getCursesColor()
           
 Color getForeground()
          Get the foreground color of this component.
abstract  int getHeight()
           
 Point getLocation()
           
 Point getLocationOnScreen()
          Return the absolute coordinates of this component's origin.
 java.lang.String getName()
          Returns the name of the component.
 Container getParent()
          Get the parent container of this component.
abstract  Dimension getSize()
           
abstract  int getWidth()
           
 boolean hasFocus()
          Returns true if this Component has the keyboard input focus.
 void hide()
          Deprecated. This method has been replaced by setVisible(boolean).
 void invalidate()
          Marks the component and all parents above it as needing to be laid out again.
 boolean isDisplayed()
          A component is "displayed" if it is contained within a displayed Window.
 boolean isEnabled()
          Determine whether this component can react to user input.
 boolean isFocusTraversable()
          Indicates whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal.
 boolean isTotallyObscured()
          Return true if this component is totally obscured by one or more windows that are stacked above it.
 boolean isValid()
          Determines whether this component has a valid layout.
 boolean isVisible()
          Returns true if this component is displayed when its parent container is displayed.
abstract  Dimension minimumSize()
           
protected  void processEvent(AWTEvent evt_)
          Process events that are implemented by all components.
 void processFocusEvent(FocusEvent fe_)
          Invoke all the FocusListener callbacks that may have been registered for this component.
 void processKeyEvent(KeyEvent ke_)
          Invoke all the KeyListener callbacks that may have been registered for this component.
 void processMouseEvent(MouseEvent e)
          Process a MouseEvent that was generated by clicking the mouse somewhere inside this component.
 void repaint()
          Causes this component to be repainted as soon as possible (this is done by posting a RepaintEvent onto the system queue).
 void requestFocus()
          This method should be invoked by all subclasses of Component which override this method; because this method generates the FOCUS_GAINED event when the component gains the keyboard focus.
 void requestSync()
          Causes a SyncEvent to be posted onto the AWT queue, thus requesting a refresh of the physical screen.
 void setBackground(Color color_)
          Set the background color of this component.
 void setBounds(int top_, int left_, int bottom_, int right_)
           
 void setBounds(Point topleft_, Dimension size_)
           
 void setBounds(Rectangle bounds)
           
 void setEnabled(boolean flag_)
          Enable this component to react to user input.
 void setForeground(Color color_)
          Set the foreground color of this component.
 void setLocation(int x_, int y_)
           
 void setLocation(Point origin_)
           
 void setName(java.lang.String name_)
          Sets the name of the component.
 void setParent(Container container_)
          Set the parent container of this component.
 void setVisible(boolean visible_)
          Shows or hides this component depending on the value of the parameter visible_
 void show()
          Deprecated. This method has been replaced by setVisible(boolean).
 void validate()
          Ensures that this component is laid out correctly.
 void validateCursesColor()
          Compute the component's ncurses color-pair from its foreground and background colors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_origin

protected Point _origin
The coordinates of the top-left corner of the component, relative to its parent container.


_parent

protected java.lang.ref.WeakReference _parent
A WeakReference to the Container (e.g Window, Panel or Dialog) that contains us. The reason that we use a WeakReference is to allow the parent to be garbage-collected when there are no more strong references to it.


_enabled

protected boolean _enabled
This flag is true if this component can react to user input.


_visible

protected boolean _visible
A flag that determines whether this component should be displayed (if its parent is displayed). This flag is set to true by default, except for Window which is initially invisible.

See Also:
setVisible(boolean), isVisible()

_keyListeners

protected java.util.Vector _keyListeners
A list of KeyListeners registered for this component.


_focusListeners

protected java.util.Vector _focusListeners
A list of FocusListeners registered for this component.


_alignmentX

protected float _alignmentX
the X-alignment of this component


_alignmentY

protected float _alignmentY
the Y-alignment of this component


_foreground

protected Color _foreground
If the foreground color is null, this component inherits the foreground color of its parent Container.


_background

protected Color _background
If the background color is null, this component inherits the background color of its parent Container.


_cursesColor

protected int _cursesColor
The number of this component's color-pair, as computed by the ncurses COLOR_PAIR macro. This is set when the component is added to a container and whenever the colors are changed after that, so we don't have to re-determine it every time we draw the component.

A value of -1 indicates that the color-pair number needs to be recomputed.


TOP_ALIGNMENT

public static final float TOP_ALIGNMENT
See Also:
Constant Field Values

CENTER_ALIGNMENT

public static final float CENTER_ALIGNMENT
See Also:
Constant Field Values

BOTTOM_ALIGNMENT

public static final float BOTTOM_ALIGNMENT
See Also:
Constant Field Values

LEFT_ALIGNMENT

public static final float LEFT_ALIGNMENT
See Also:
Constant Field Values

RIGHT_ALIGNMENT

public static final float RIGHT_ALIGNMENT
See Also:
Constant Field Values
Constructor Detail

Component

public Component()
Constructor

Method Detail

setVisible

public void setVisible(boolean visible_)
Shows or hides this component depending on the value of the parameter visible_


show

public void show()
Deprecated. This method has been replaced by setVisible(boolean).


hide

public void hide()
Deprecated. This method has been replaced by setVisible(boolean).


isVisible

public boolean isVisible()
Returns true if this component is displayed when its parent container is displayed.


draw

public abstract void draw()
To be implemented by concrete subclasses.


isDisplayed

public boolean isDisplayed()
A component is "displayed" if it is contained within a displayed Window. Even though it may be "displayed", it may be obscured by other Windows that are on top of it; and it may not be visible to the user because the _visible flag may be false.


getLocation

public Point getLocation()

setLocation

public void setLocation(Point origin_)

setLocation

public void setLocation(int x_,
                        int y_)

getLocationOnScreen

public Point getLocationOnScreen()
Return the absolute coordinates of this component's origin. Note that Window (which is a subclass of Container) has a _parent value of null, but it overrides this method.


getSize

public abstract Dimension getSize()

getWidth

public abstract int getWidth()

getHeight

public abstract int getHeight()

getBounds

public Rectangle getBounds()
Get the bounding rectangle of this component, relative to the origin of its parent Container.


setBounds

public void setBounds(Rectangle bounds)

setBounds

public void setBounds(int top_,
                      int left_,
                      int bottom_,
                      int right_)

setBounds

public void setBounds(Point topleft_,
                      Dimension size_)

contains

public boolean contains(Point p)
Checks whether this component "contains" the specified point, where the point's x and y coordinates are defined to be relative to the top left corner of the parent Container.


contains

public boolean contains(int x,
                        int y)

minimumSize

public abstract Dimension minimumSize()

setParent

public void setParent(Container container_)
Set the parent container of this component. This is intended to be called by Container objects only. Note that we use a WeakReference so that the parent can be garbage- collected when there are no more strong references to it.


getParent

public Container getParent()
Get the parent container of this component. Can return null if the component has no parent.


addKeyListener

public void addKeyListener(KeyListener kl_)
Register a KeyListener object for this component.


addFocusListener

public void addFocusListener(FocusListener fl_)
Register a FocusListener object for this component.


processEvent

protected void processEvent(AWTEvent evt_)
Process events that are implemented by all components. This can be overridden by subclasses, to handle custom events.


processKeyEvent

public void processKeyEvent(KeyEvent ke_)
Invoke all the KeyListener callbacks that may have been registered for this component. The KeyListener objects may modify the keycodes, and can also set the "consumed" flag.


processMouseEvent

public void processMouseEvent(MouseEvent e)
Process a MouseEvent that was generated by clicking the mouse somewhere inside this component.


processFocusEvent

public void processFocusEvent(FocusEvent fe_)
Invoke all the FocusListener callbacks that may have been registered for this component.


getAncestorWindow

public Window getAncestorWindow()
Get the Window that contains this component.


requestFocus

public void requestFocus()
This method should be invoked by all subclasses of Component which override this method; because this method generates the FOCUS_GAINED event when the component gains the keyboard focus.


hasFocus

public boolean hasFocus()
Returns true if this Component has the keyboard input focus.


isFocusTraversable

public boolean isFocusTraversable()
Indicates whether this component can be traversed using Tab or Shift-Tab keyboard focus traversal. If this method returns "false" it can still request focus using requestFocus(), but it will not automatically be assigned focus during keyboard focus traversal.


isTotallyObscured

public boolean isTotallyObscured()
Return true if this component is totally obscured by one or more windows that are stacked above it.


getAlignmentX

public float getAlignmentX()
Returns the alignment along the X axis. This indicates how the component would like to be aligned relative to ther components. 0 indicates left-aligned, 0.5 indicates centered and 1 indicates right-aligned.


getAlignmentY

public float getAlignmentY()
Returns the alignment along the Y axis. This indicates how the component would like to be aligned relative to ther components. 0 indicates top-aligned, 0.5 indicates centered and 1 indicates bottom-aligned.


getForeground

public Color getForeground()
Get the foreground color of this component. If it is null, the component will inherit the foreground color of its parent container.


getBackground

public Color getBackground()
Get the background color of this component. If it is null, the component will inherit the background color of its parent container.


setForeground

public void setForeground(Color color_)
Set the foreground color of this component.


setBackground

public void setBackground(Color color_)
Set the background color of this component.


setEnabled

public void setEnabled(boolean flag_)
Enable this component to react to user input. Components are enabled by default.


isEnabled

public boolean isEnabled()
Determine whether this component can react to user input.


invalidate

public void invalidate()
Marks the component and all parents above it as needing to be laid out again. This method is overridden by Container.


validate

public void validate()
Ensures that this component is laid out correctly. This method is primarily intended to be used on instances of Container. The default implementation does nothing; it is overridden by Container.


repaint

public void repaint()
Causes this component to be repainted as soon as possible (this is done by posting a RepaintEvent onto the system queue).


requestSync

public void requestSync()
Causes a SyncEvent to be posted onto the AWT queue, thus requesting a refresh of the physical screen.


isValid

public boolean isValid()
Determines whether this component has a valid layout. A component is valid when it is correctly sized and positioned within its parent container and all its children (in the case of a Container) are also valid. The default implementation returns true; this method is overridden by Container.


debug

public abstract void debug(int level_)

setName

public void setName(java.lang.String name_)
Sets the name of the component.


getName

public java.lang.String getName()
Returns the name of the component.


validateCursesColor

public void validateCursesColor()
Compute the component's ncurses color-pair from its foreground and background colors. If either color is null, it means that the component has not been added to a container yet, so don't do anything (the colors will be validated when the component is added to the container).


getCursesColor

public int getCursesColor()