gizmoball.gui
Class PaletteModel

java.lang.Object
  extended by java.util.Observable
      extended by gizmoball.gui.PaletteModel
All Implemented Interfaces:
java.util.Observer

public class PaletteModel
extends java.util.Observable
implements java.util.Observer

PaletteModel holds the data necessary to make the editing mode function correctly. It stores temporary information such as the current Gizmo that is being changed or added. PaletteModel observes GamePlayModel, while various palette windows will observe PaletteModel.


Method Summary
 boolean allowsOverlap()
          Returns true if and only if Gizmo overlapping is allowed in edit mode.
 void applyGameObject(Properties afterProperties)
          Applies properties to selected GameObject.
 boolean canRedo()
          Returns whether redo is applicable.
 boolean canUndo()
          Returns whether undo is applicable.
 void clearActions()
          Resets user actions.
 void createAndDoKeyMappingEditAction(java.util.List<java.lang.Integer> beforeKeys, java.util.List<java.lang.Integer> afterKeys)
           
 void createGameObject(GameObject go)
           
 void createGizmo(int type, Vect3 location)
          Creates Gizmo with type type at location.
 boolean doAction(EditAction ea)
           
 void doRotate()
          Does rotate.
 boolean editsPosition(EditAction ea)
           
 int getActionCurrent()
          Returns index of current action.
 java.util.List<EditAction> getActions()
          Returns an unmodifiable copy of actions.
 Properties getBeforeProperties()
           
 double getCurrentCoefficient()
           
 java.awt.Color getCurrentColor()
          Returns the original color of the selected GameObject.
 java.util.List<java.lang.Integer> getCurrentDownKeys()
           
 GameObject getCurrentGameObject()
          Returns current object that is being edited.
 Vect3 getCurrentPosition()
           
 java.lang.String getCurrentTexture()
           
 java.util.List<java.lang.Integer> getCurrentUpKeys()
           
 Vect3 getCurrentVelocity()
           
 java.lang.String getGameObjectTexture()
          Returns the original texture of the selected GameObject.
 int getGizmoDown()
           
 int getNumActions()
          Returns the number of actions.
 java.lang.String[] getTextureFiles()
           
 boolean getToggled()
           
 void purgeActions()
          Purges user actions.
 void redo()
           
 void refresh()
          Makes palette screen show current object's properties.
 void removeGameObject()
          Removes selected GameObject from game world.
 void setBeforeProperties()
           
 void setCurrentGameObject(GameObject go)
          Sets current object that is being edited.
 void setCurrentTexture()
          Sets the original texture of the selected GameObject.
 void setGameObjectColor(java.awt.Color c)
          Sets the original color of the selected GameObject.
 void setGizmoDown(int g)
          Sets gizmoDown.
 void setOverlap()
          Sets whether user can overlap GameObjects in edit mode.
 void smartdo(int index)
          Redos/undos up till the index.
 void undo()
           
 void update(java.util.Observable ob, java.lang.Object o)
          Required implementation for the Observer interface.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTextureFiles

public java.lang.String[] getTextureFiles()
Returns:
A copy of textureFiles.

doRotate

public void doRotate()
Does rotate.


setGizmoDown

public void setGizmoDown(int g)
Sets gizmoDown.

Parameters:
g -
Effects:
gizmoDown

getGizmoDown

public int getGizmoDown()
Returns:
gizmoDown

setOverlap

public void setOverlap()
Sets whether user can overlap GameObjects in edit mode.

Parameters:
b -
Effects:
allow

allowsOverlap

public boolean allowsOverlap()
Returns true if and only if Gizmo overlapping is allowed in edit mode.

Returns:
allowOverlap

doAction

public boolean doAction(EditAction ea)
Parameters:
ea -
Returns:
False if and only if action failed.

getActions

public java.util.List<EditAction> getActions()
Returns an unmodifiable copy of actions.

Returns:
unmodifiable copy of actions

editsPosition

public boolean editsPosition(EditAction ea)
Parameters:
ea -
Returns:
true if and only if EditAction ea alters position

smartdo

public void smartdo(int index)
Redos/undos up till the index. Includes redoing/undoing the action at the index.

Parameters:
index -

getActionCurrent

public int getActionCurrent()
Returns index of current action.

Returns:

getNumActions

public int getNumActions()
Returns the number of actions.

Returns:
actions.size()

canRedo

public boolean canRedo()
Returns whether redo is applicable.

Returns:
True if and only if actionCurrent<=actions.size()-2.

redo

public void redo()

canUndo

public boolean canUndo()
Returns whether undo is applicable.

Returns:
True if and only if actionCurrent>=0.

undo

public void undo()

getToggled

public boolean getToggled()
Returns:
toggled

clearActions

public void clearActions()
Resets user actions.


purgeActions

public void purgeActions()
Purges user actions.


setCurrentGameObject

public void setCurrentGameObject(GameObject go)
Sets current object that is being edited.

Parameters:
go -

setBeforeProperties

public void setBeforeProperties()

getCurrentVelocity

public Vect3 getCurrentVelocity()

getBeforeProperties

public Properties getBeforeProperties()

getCurrentUpKeys

public java.util.List<java.lang.Integer> getCurrentUpKeys()
Returns:
Keys that activate currentGameObject

getCurrentDownKeys

public java.util.List<java.lang.Integer> getCurrentDownKeys()
Returns:
Keys that activate currentGameObject

getCurrentGameObject

public GameObject getCurrentGameObject()
Returns current object that is being edited. Caution: The texture for this GameObject will be "selected.bmp", not its original. User must call getGameObjectTexture().

Returns:
currentGameObject

getCurrentCoefficient

public double getCurrentCoefficient()

getCurrentTexture

public java.lang.String getCurrentTexture()

setCurrentTexture

public void setCurrentTexture()
Sets the original texture of the selected GameObject.


createGizmo

public void createGizmo(int type,
                        Vect3 location)
Creates Gizmo with type type at location.

Parameters:
type -

createGameObject

public void createGameObject(GameObject go)

applyGameObject

public void applyGameObject(Properties afterProperties)
Applies properties to selected GameObject.


removeGameObject

public void removeGameObject()
Removes selected GameObject from game world.


createAndDoKeyMappingEditAction

public void createAndDoKeyMappingEditAction(java.util.List<java.lang.Integer> beforeKeys,
                                            java.util.List<java.lang.Integer> afterKeys)

refresh

public void refresh()
Makes palette screen show current object's properties.


getCurrentPosition

public Vect3 getCurrentPosition()
Returns:
Position of currentGameObject

getGameObjectTexture

public java.lang.String getGameObjectTexture()
Returns the original texture of the selected GameObject.

Returns:
previousTexture

getCurrentColor

public java.awt.Color getCurrentColor()
Returns the original color of the selected GameObject.

Returns:
currentColor

setGameObjectColor

public void setGameObjectColor(java.awt.Color c)
Sets the original color of the selected GameObject.


update

public void update(java.util.Observable ob,
                   java.lang.Object o)
Required implementation for the Observer interface.

Specified by:
update in interface java.util.Observer