net.sf.magicproject.clickable.targetable
Class Targetable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by net.sf.magicproject.clickable.Clickable
                  extended by net.sf.magicproject.clickable.targetable.Targetable
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
AbstractCard, Player

public abstract class Targetable
extends Clickable
implements java.awt.event.ActionListener

Represents a target : player or card.

Since:
0.3, 0.90 a map of objects {String, Tragetable} is added., 0.91 removered properties instance variable to CardModel
Version:
0.91
Author:
Fabrice Daugan , Stefano "Kismet" Lenzi
See Also:
Card, Player, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 java.util.List<Ability> cachedAbilities
          The cached abilities of this component.
 ControllerModifier controllerModifier
          The ControllerModifier on this object
 RegisterIndirection[] indirections
          The registerModifiers on this object
 RegisterModifier[] registerModifiers
          The registerModifiers on this object
 int[] registers
          Current regiters of this targetable
 
Fields inherited from class net.sf.magicproject.clickable.Clickable
highLightColor, isHighLighted
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Targetable()
          Creates a new instance of MTargetable
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          An ActionListener that listens to the ability choice
 void addModifier(RegisterIndirection modifier, int index)
          Add a modifier to this object
 void addModifier(RegisterModifier modifier, int index)
          Add a modifier to this object
 void addPrivateNamedObject(java.lang.String objectName, Targetable targetable)
          Add an object to this targetable.
abstract  void addTimestampReference()
          Add a reference to this targetable.
 void clearDamages()
          remove all damages on this card
 void clearPrivateNamedObject()
          Remove all stored objects.
abstract  void decrementTimestampReference(int timestamp)
          Decrement the reference counter for the current timestamp of this card.
 MCard getCreator()
          Return the creator of this targetable component.
 int getId()
          Return the id of this component.
abstract  Targetable getLastKnownTargetable(int timeStamp)
          Return this targetable as it was at the given timestamp.
 Targetable getOriginalTargetable()
          Return the original targetable without looking for the timestamp number.
 Targetable getPrivateNamedObject(java.lang.String objectName)
          Return the named object.
 java.util.Map<java.lang.String,Targetable> getPrivateNamedObjects()
          Return a cloned instance of map of objects of this targetable.
abstract  int getTimestamp()
          Return the timstamp value of this targetable.
abstract  int getValue(int index)
          Return the value corresponding to the true register index.
 int getValueIndirection(int index)
          Return the value corresponding to the true register index.
abstract  boolean isAbility()
          Is this targetable is an abilty or a spell
abstract  boolean isCard()
          indicates if this target is a card
 boolean isPlayer()
          return true if this targetable is a player
abstract  boolean isSpell()
          Is this targetable is an abilty or a spell
abstract  void removeModifier(RegisterIndirection indirection, int index)
          Remove a register-indirection modifier from this component.
abstract  void removeModifier(RegisterModifier modifier, int index)
          Remove a register modifier from this component.
 void removePrivateNamedObject(java.lang.String objectName)
          Remove the named object.
 void setCreator(MCard creator)
          Set the creator of this targetable component.
 void targetize(boolean... highlightedZones)
          The border will be highligthed to a color identifying it easily as a targetable component.
static void targetize(java.util.List<Targetable> list, boolean[] highlightedZones)
          Highlight as "targetable" the list of targetable
 void tokenize()
          The border will be highligthed to a color identifying it easily as a token component.
abstract  java.lang.String toString()
           
 
Methods inherited from class net.sf.magicproject.clickable.Clickable
disHighLight, disHighlight, highLight, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, sendClickToOpponent
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

registers

public int[] registers
Current regiters of this targetable


registerModifiers

public RegisterModifier[] registerModifiers
The registerModifiers on this object


controllerModifier

public ControllerModifier controllerModifier
The ControllerModifier on this object


indirections

public RegisterIndirection[] indirections
The registerModifiers on this object


cachedAbilities

public java.util.List<Ability> cachedAbilities
The cached abilities of this component.

Constructor Detail

Targetable

public Targetable()
Creates a new instance of MTargetable

Method Detail

clearDamages

public void clearDamages()
remove all damages on this card


toString

public abstract java.lang.String toString()
Overrides:
toString in class java.awt.Component

isPlayer

public final boolean isPlayer()
return true if this targetable is a player

Returns:
true if this targetable is a player

isCard

public abstract boolean isCard()
indicates if this target is a card

Returns:
true if this target is a card

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
An ActionListener that listens to the ability choice

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - the event

tokenize

public final void tokenize()
The border will be highligthed to a color identifying it easily as a token component.


targetize

public void targetize(boolean... highlightedZones)
The border will be highligthed to a color identifying it easily as a targetable component.

Parameters:
highlightedZones - the set of highlighted zone.

targetize

public static void targetize(java.util.List<Targetable> list,
                             boolean[] highlightedZones)
Highlight as "targetable" the list of targetable

Parameters:
list - the list of targetable to highlight.
highlightedZones - the list of highlighted zones

getValue

public abstract int getValue(int index)
Return the value corresponding to the true register index.

Parameters:
index - the register index
Returns:
the value corresponding to the true register index.

getValueIndirection

public int getValueIndirection(int index)
Return the value corresponding to the true register index.

Parameters:
index - the register index
Returns:
the value corresponding to the true register index.

addModifier

public void addModifier(RegisterModifier modifier,
                        int index)
Add a modifier to this object

Parameters:
modifier - the modifier to add to this object
index - is the modifier register index

addModifier

public void addModifier(RegisterIndirection modifier,
                        int index)
Add a modifier to this object

Parameters:
modifier - the indirection modifier to add to this object
index - is the modifier register index

isAbility

public abstract boolean isAbility()
Is this targetable is an abilty or a spell

Returns:
true id this targetable is an ability

isSpell

public abstract boolean isSpell()
Is this targetable is an abilty or a spell

Returns:
true id this targetable is a spell

removeModifier

public abstract void removeModifier(RegisterModifier modifier,
                                    int index)
Remove a register modifier from this component.

Parameters:
modifier - the register modifier to remove.
index - index of register to remove.

removeModifier

public abstract void removeModifier(RegisterIndirection indirection,
                                    int index)
Remove a register-indirection modifier from this component.

Parameters:
indirection - the register-indirection modifier to remove.
index - index of register indirection to remove.

getLastKnownTargetable

public abstract Targetable getLastKnownTargetable(int timeStamp)
Return this targetable as it was at the given timestamp.

Parameters:
timeStamp - the timestamp number.
Returns:
this targetable as it was at the given timestamp.

getOriginalTargetable

public Targetable getOriginalTargetable()
Return the original targetable without looking for the timestamp number.

Returns:
the original targetable without looking for the timestamp number.

getPrivateNamedObject

public Targetable getPrivateNamedObject(java.lang.String objectName)
Return the named object. If the object has not been found, null value is returned.

Parameters:
objectName - the searched object's name
Returns:
the named object.

getCreator

public MCard getCreator()
Return the creator of this targetable component. May be null if has not been set.

Returns:
the creator of this targetable component.

setCreator

public void setCreator(MCard creator)
Set the creator of this targetable component.

Parameters:
creator - the card creating this card. May be null.

removePrivateNamedObject

public void removePrivateNamedObject(java.lang.String objectName)
Remove the named object.

Parameters:
objectName - the searched object's name

addPrivateNamedObject

public void addPrivateNamedObject(java.lang.String objectName,
                                  Targetable targetable)
Add an object to this targetable. This object will be accessible with the specified name.

Parameters:
objectName - the object's name to save.
targetable - the targetable to save.

clearPrivateNamedObject

public void clearPrivateNamedObject()
Remove all stored objects.


getPrivateNamedObjects

public java.util.Map<java.lang.String,Targetable> getPrivateNamedObjects()
Return a cloned instance of map of objects of this targetable.

Returns:
a cloned instance of map of objects of this targetable.

getId

public int getId()
Return the id of this component. For instance, this id is only relevant for players.

Returns:
the id of this component.

getTimestamp

public abstract int getTimestamp()
Return the timstamp value of this targetable.

Returns:
the timstamp value of this targetable.

addTimestampReference

public abstract void addTimestampReference()
Add a reference to this targetable.


decrementTimestampReference

public abstract void decrementTimestampReference(int timestamp)
Decrement the reference counter for the current timestamp of this card.

Parameters:
timestamp - is the reference to decrement.


Copyright © 2003-2007 Magic-Project. All Rights Reserved.