feud.testgame.gui
Class GUIComponent

java.lang.Object
  extended byfeud.testgame.gui.GUIComponent
Direct Known Subclasses:
Button, Label, Table, TextField, Window

public abstract class GUIComponent
extends java.lang.Object

GIOComponent is the abstract base class of a very very simple GUI system. The GUI components can't even paint themselves. They are just click and type sensitive areas of the screen. But it shouldn't be too jard to add functionality that improves the situation if you need that.


Field Summary
protected  boolean visible
           
 
Constructor Summary
GUIComponent()
           
 
Method Summary
 void add(GUIComponent c)
          Adds a child component to this component.
 void draw(com.threed.jpct.FrameBuffer buffer)
          Draws this component and all of its childs.
 boolean evaluateInput(MouseMapper mouse, com.threed.jpct.util.KeyMapper keyMapper)
          Processes key and mouse events in the context of this component.
 GUIComponent getParent()
          Returns the parent of this component.
 int getParentX()
          If this component is the child of another one, this will return the parent's x-position.
 int getParentY()
          If this component is the child of another one, this will return the parent's y-position.
 int getX()
          Returns the x-position of the component in screen coordinates.
 int getY()
          Returns the y-position of the component in screen coordinates.
 boolean isVisible()
          Is this component visible?
 void setVisible(boolean visi)
          Sets if the component is visible or hidden.
 void setX(int x)
          Sets the x-position of the component in screen coordinates.
 void setY(int y)
          Sets the y-position of the component in screen coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

visible

protected boolean visible
Constructor Detail

GUIComponent

public GUIComponent()
Method Detail

setX

public void setX(int x)
Sets the x-position of the component in screen coordinates.

Parameters:
x - the x-position

setY

public void setY(int y)
Sets the y-position of the component in screen coordinates.

Parameters:
y - the y-position

setVisible

public void setVisible(boolean visi)
Sets if the component is visible or hidden. A hidden component must not react on clicks or key press events.

Parameters:
visi - true if visible, false otherwise

isVisible

public boolean isVisible()
Is this component visible?

Returns:
boolean yes or no...

getX

public int getX()
Returns the x-position of the component in screen coordinates.

Returns:
int the x-position

getY

public int getY()
Returns the y-position of the component in screen coordinates.

Returns:
int the y-position

getParentX

public int getParentX()
If this component is the child of another one, this will return the parent's x-position. If it isn't, it will return 0.

Returns:
int the parent's x-position

getParentY

public int getParentY()
If this component is the child of another one, this will return the parent's y-position. If it isn't, it will return 0.

Returns:
int the parent's y-position

getParent

public GUIComponent getParent()
Returns the parent of this component.

Returns:
GUIComponent The parent or null in case that there isn't any

add

public void add(GUIComponent c)
Adds a child component to this component. A child will be rendered/processed in the context of and relative to the parent. An example are buttons (=childs) displayed in a window (=parent).

Parameters:
c - the child component

evaluateInput

public boolean evaluateInput(MouseMapper mouse,
                             com.threed.jpct.util.KeyMapper keyMapper)
Processes key and mouse events in the context of this component. It then continues processing on the child components until the event got comsumed by one or the last child has been processed.

Parameters:
mouse - the MouseMapper used to process mouse events
keyMapper - the KeyMapper used to process key events
Returns:
boolean true, if an event occured in the context of this component or one of its child components.

draw

public void draw(com.threed.jpct.FrameBuffer buffer)
Draws this component and all of its childs. Drawing in this "toolkit" is limited to label and text rendering. Rendering the actual component isn't done by this toolkit, but can be added easily.

Parameters:
buffer - the FrameBuffer on which to draw to