Class MenuElement

java.lang.Object
  extended by greenfoot.Actor
      extended by MenuElement

public abstract class MenuElement
extends greenfoot.Actor

'MenuElement' is an abstract class which provides a partial implementation of a menu UI element

Since:
2012-05-01
Version:
v0.1
Author:
Felix Mo

Field Summary
protected  boolean active
          The element's state.
protected static java.awt.Font FONT
          Font used by all menu elements
protected  java.awt.Rectangle frame
          The element's frame, which includes its origin (in view) and its dimensions.
protected  greenfoot.GreenfootImage image
          The container for the element's view.
protected  int index
          The element's index; it's position relative to other elements within the same group.
protected  java.lang.String title
          The tile of the menu element.
 
Constructor Summary
MenuElement(java.lang.String title, int index)
          Constructs a MenuElement
 
Method Summary
 boolean active()
          Returns the element's state (wether it is active or not).
 java.awt.Rectangle frame()
          Returns the element's frame.
 int index()
          Returns the element's index; it's position relative to other elements within the same group.
 void setActive(boolean state)
          Sets the element's state.
 void setFrame(java.awt.Rectangle frame)
          Sets the element's frame.
 
Methods inherited from class greenfoot.Actor
act, addedToWorld, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, move, setImage, setImage, setLocation, setRotation, turn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

active

protected boolean active
The element's state.


FONT

protected static final java.awt.Font FONT
Font used by all menu elements


frame

protected java.awt.Rectangle frame
The element's frame, which includes its origin (in view) and its dimensions.


image

protected greenfoot.GreenfootImage image
The container for the element's view.


index

protected int index
The element's index; it's position relative to other elements within the same group.


title

protected java.lang.String title
The tile of the menu element.

Constructor Detail

MenuElement

public MenuElement(java.lang.String title,
                   int index)
Constructs a MenuElement

Parameters:
title - The title of the menu element.
index - The position of the menu element, relative to others within the same group.
Method Detail

active

public boolean active()
Returns the element's state (wether it is active or not).

Returns:
True if the element is active

frame

public java.awt.Rectangle frame()
Returns the element's frame.

Returns:
The element's frame (as a Rectangle), which includes its origin (in view) and its dimensions.
See Also:
Rectangle

index

public int index()
Returns the element's index; it's position relative to other elements within the same group.

Returns:
An integer with the element's index.

setActive

public void setActive(boolean state)
Sets the element's state. The method can be overriden for custom functionality when setting the element's active.

Parameters:
state - The element's new state.

setFrame

public void setFrame(java.awt.Rectangle frame)
Sets the element's frame. By setting the frame, a new container for the menu element's view will be created, thus a re-draw of the element is necessary.

Parameters:
frame - The Rectangle that is to be the new frame to be used by the menu element.