com.realtime.crossfire.jxclient.items
Class CfItem

java.lang.Object
  extended by com.realtime.crossfire.jxclient.items.CfItem
Direct Known Subclasses:
CfPlayer

public class CfItem
extends java.lang.Object

The representation of a Crossfire Item, client-side.

Since:
1.0

Field Summary
private  int anim
          The animation.
private  int animSpeed
          The animation speed.
static int F_APPLIED
          The flags mask for applied states.
static int F_BLESSED
          The flags value for blessed items.
static int F_CURSED
          The flags value for cursed items.
static int F_DAMNED
          The flags value for damned items.
static int F_LOCKED
          The flags value for locked items.
static int F_MAGIC
          The flags value for magical items.
static int F_NOPICK
          The flags value for non-pickable items.
static int F_OPEN
          The flags value for opened items.
static int F_UNIDENTIFIED
          The flags value for unidentified items.
static int F_UNPAID
          The flags value for unpaid items.
private  Face face
          The face.
private  int flags
          The flags.
private  javax.swing.event.EventListenerList listeners
          The listeners to be notified.
private  int location
          The location.
private  boolean modified
          Set if any attribute has changed since the last time listeners were notified.
private  java.lang.String name
          The singular name.
private  java.lang.String namePl
          The plural name.
private  int nrof
          The number of objects in the stack.
private  int tag
          The tag.
private  int type
          The type.
private  int weight
          The weight.
 
Constructor Summary
CfItem(int location, int tag, int flags, int weight, Face face, java.lang.String name, java.lang.String namePl, int anim, int animSpeed, int nrof, int type)
          Creates a new instance.
 
Method Summary
 void addCfItemModifiedListener(CfItemListener listener)
          Add a CfItemModifiedListener.
private  void appendFlag(java.lang.StringBuilder sb, int flag, java.lang.String ident)
          Appends "(<ident>)" if this item has the flag flag set.
private  void fireModified()
          Notify all listener.
 Face getFace()
          Returns the face.
 int getLocation()
          Returns the location.
 java.lang.String getName()
          Returns the name.
 int getNrOf()
          Returns the number of objects in this item stack.
 int getTag()
          Returns the tag.
 java.lang.String getTooltipText()
          Returns a description suitable for a tooltip text.
 java.lang.String getTooltipText1()
          Returns the first line of the tooltip text.
 java.lang.String getTooltipText2()
          Returns the second line of the tooltip text.
 java.lang.String getTooltipText3()
          Returns the third line of the tooltip text.
 int getType()
          Returns the type.
 int getWeight()
          Returns the weight.
 boolean isApplied()
          Returns whether this item is applied.
 boolean isBlessed()
          Returns whether this item is blessed.
 boolean isCursed()
          Returns whether this item is cursed.
 boolean isDamned()
          Returns whether this item is damned.
 boolean isItemGroupButton()
          Returns whether this object is a fake object for selecting object groups in the ground view.
 boolean isLocked()
          Returns whether this item is locked.
 boolean isMagic()
          Returns whether this item is magical.
 boolean isNoPick()
          Returns whether this item cannot be picked up.
 boolean isOpen()
          Returns whether this item is an opened container.
 boolean isUnidentified()
          Returns whether this item is unidentified.
 boolean isUnpaid()
          Returns whether this item is unpaid.
 void removeCfItemModifiedListener(CfItemListener listener)
          Remove a CfItemModifiedListener.
private  void setAnim(int anim)
          Updates the animation.
private  void setAnimSpeed(int animSpeed)
          Updates the animation speed.
private  void setFace(Face face)
          Updates the face.
private  void setFlags(int flags)
          Updates the flags.
 void setLocation(int location)
          Updates the location.
private  void setName(java.lang.String name, java.lang.String namePl)
          Updates the name.
private  void setNrOf(int nrof)
          Updates the number of objects in the stack.
private  void setWeight(int weight)
          Updates the weight.
 void update(int updateFlags, int flags, int weight, Face face, java.lang.String name, java.lang.String namePl, int anim, int animSpeed, int nrof)
          Processes an "upditem" command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

anim

private int anim
The animation.


animSpeed

private int animSpeed
The animation speed.


F_APPLIED

public static final int F_APPLIED
The flags mask for applied states.

See Also:
Constant Field Values

F_BLESSED

public static final int F_BLESSED
The flags value for blessed items.

See Also:
Constant Field Values

F_CURSED

public static final int F_CURSED
The flags value for cursed items.

See Also:
Constant Field Values

F_DAMNED

public static final int F_DAMNED
The flags value for damned items.

See Also:
Constant Field Values

F_LOCKED

public static final int F_LOCKED
The flags value for locked items.

See Also:
Constant Field Values

F_MAGIC

public static final int F_MAGIC
The flags value for magical items.

See Also:
Constant Field Values

F_NOPICK

public static final int F_NOPICK
The flags value for non-pickable items.

See Also:
Constant Field Values

F_OPEN

public static final int F_OPEN
The flags value for opened items.

See Also:
Constant Field Values

F_UNIDENTIFIED

public static final int F_UNIDENTIFIED
The flags value for unidentified items.

See Also:
Constant Field Values

F_UNPAID

public static final int F_UNPAID
The flags value for unpaid items.

See Also:
Constant Field Values

face

@NotNull
private Face face
The face.


flags

private int flags
The flags.


listeners

private final javax.swing.event.EventListenerList listeners
The listeners to be notified.


location

private int location
The location.


modified

private boolean modified
Set if any attribute has changed since the last time listeners were notified.


name

@NotNull
private java.lang.String name
The singular name.


namePl

@NotNull
private java.lang.String namePl
The plural name.


nrof

private int nrof
The number of objects in the stack.


tag

private final int tag
The tag.


type

private final int type
The type.


weight

private int weight
The weight.

Constructor Detail

CfItem

public CfItem(int location,
              int tag,
              int flags,
              int weight,
              @NotNull
              Face face,
              @NotNull
              java.lang.String name,
              @NotNull
              java.lang.String namePl,
              int anim,
              int animSpeed,
              int nrof,
              int type)
Creates a new instance.

Parameters:
location - the location
tag - the tag
flags - the flags
weight - the weight
face - the face
name - the singular name
namePl - the plural name
anim - the animation
animSpeed - the animation speed
nrof - the number of objects in the stack
type - the type
Method Detail

addCfItemModifiedListener

public void addCfItemModifiedListener(@NotNull
                                      CfItemListener listener)
Add a CfItemModifiedListener. The listener will be notified about attribute changes of this item.

Parameters:
listener - the listener to remove

appendFlag

private void appendFlag(@NotNull
                        java.lang.StringBuilder sb,
                        int flag,
                        @NotNull
                        java.lang.String ident)
Appends "(<ident>)" if this item has the flag flag set.

Parameters:
sb - the string builder to append to
flag - the flag to check
ident - the ident string to append

fireModified

private void fireModified()
Notify all listener.


getFace

@NotNull
public Face getFace()
Returns the face.

Returns:
the face

getLocation

public int getLocation()
Returns the location.

Returns:
the location

getName

@NotNull
public java.lang.String getName()
Returns the name.

Returns:
the name

getNrOf

public int getNrOf()
Returns the number of objects in this item stack.

Returns:
whether the number of objects

getTag

public int getTag()
Returns the tag.

Returns:
the tag

getTooltipText

@NotNull
public java.lang.String getTooltipText()
Returns a description suitable for a tooltip text.

Returns:
the tooltip text

getTooltipText1

@NotNull
public java.lang.String getTooltipText1()
Returns the first line of the tooltip text.

Returns:
the tooltip text

getTooltipText2

@NotNull
public java.lang.String getTooltipText2()
Returns the second line of the tooltip text.

Returns:
the tooltip text

getTooltipText3

@NotNull
public java.lang.String getTooltipText3()
Returns the third line of the tooltip text.

Returns:
the tooltip text

getType

public int getType()
Returns the type.

Returns:
the type

getWeight

public int getWeight()
Returns the weight.

Returns:
the weight

isApplied

public boolean isApplied()
Returns whether this item is applied.

Returns:
whether this item is applied

isBlessed

public boolean isBlessed()
Returns whether this item is blessed.

Returns:
whether this item is blessed

isCursed

public boolean isCursed()
Returns whether this item is cursed.

Returns:
whether this item is cursed

isDamned

public boolean isDamned()
Returns whether this item is damned.

Returns:
whether this item is damned

isItemGroupButton

public boolean isItemGroupButton()
Returns whether this object is a fake object for selecting object groups in the ground view.

Returns:
whether this object is a group button

isLocked

public boolean isLocked()
Returns whether this item is locked.

Returns:
whether this item is locked

isMagic

public boolean isMagic()
Returns whether this item is magical.

Returns:
whether this item is magical

isNoPick

public boolean isNoPick()
Returns whether this item cannot be picked up.

Returns:
whether this item cannot be picked up

isOpen

public boolean isOpen()
Returns whether this item is an opened container.

Returns:
whether this item is an opened container

isUnidentified

public boolean isUnidentified()
Returns whether this item is unidentified.

Returns:
whether this item is unidentified

isUnpaid

public boolean isUnpaid()
Returns whether this item is unpaid.

Returns:
whether this item is unpaid

removeCfItemModifiedListener

public void removeCfItemModifiedListener(@NotNull
                                         CfItemListener listener)
Remove a CfItemModifiedListener.

Parameters:
listener - the listener to remove

setAnim

private void setAnim(int anim)
Updates the animation.

Parameters:
anim - the new animation

setAnimSpeed

private void setAnimSpeed(int animSpeed)
Updates the animation speed.

Parameters:
animSpeed - the new animation speed

setFace

private void setFace(@NotNull
                     Face face)
Updates the face.

Parameters:
face - the new face

setFlags

private void setFlags(int flags)
Updates the flags.

Parameters:
flags - the new flags

setLocation

public void setLocation(int location)
Updates the location.

Parameters:
location - the new location

setName

private void setName(@NotNull
                     java.lang.String name,
                     @NotNull
                     java.lang.String namePl)
Updates the name.

Parameters:
name - the new singular name
namePl - the new plural name

setNrOf

private void setNrOf(int nrof)
Updates the number of objects in the stack.

Parameters:
nrof - the new number of objects

setWeight

private void setWeight(int weight)
Updates the weight.

Parameters:
weight - the new weight

update

public void update(int updateFlags,
                   int flags,
                   int weight,
                   @NotNull
                   Face face,
                   @NotNull
                   java.lang.String name,
                   @NotNull
                   java.lang.String namePl,
                   int anim,
                   int animSpeed,
                   int nrof)
Processes an "upditem" command.

Parameters:
updateFlags - the changed values
flags - the new flags
weight - the new weight
face - the new face
name - the new singular name
namePl - the new plural name
anim - the new animation ID
animSpeed - the new animation speed
nrof - the new number of items