com.realtime.crossfire.jxclient.items
Class InventoryView

java.lang.Object
  extended by com.realtime.crossfire.jxclient.items.AbstractItemView
      extended by com.realtime.crossfire.jxclient.items.InventoryView
All Implemented Interfaces:
ItemView

public class InventoryView
extends AbstractItemView

Provides a view of all items in the current player's inventory.

If no player object is known an empty inventory view is generated.


Field Summary
private  java.util.Comparator<CfItem> comparator
          The Comparator for sorting.
private  int currentPlayerTag
          The tag of the current player object or -1.
private  java.util.List<CfItem> items
          The items in the inventory ordered by comparator.
private  ItemSet itemSet
          The ItemSet to monitor.
private  ItemSetListener itemSetListener
          The ItemSetListener attached to itemSet to track the current player object.
private  DoubleMapping mapping
          Maps external index to original index.
private  ItemListener playerInventoryListener
          The ItemListener attached to the current player object.
 
Constructor Summary
InventoryView(ItemSet itemSet, java.util.Comparator<CfItem> comparator)
          Creates a new instance.
 
Method Summary
private  int findInsertionIndex(CfItem item)
          Returns the insertion index of a CfItem.
 CfItem getItem(int index)
          Returns the CfItem in a given slot.
 int getSize()
          Returns the number of items.
private  void setCurrentPlayerTag(int currentPlayerTag)
          Updates the current player object.
 
Methods inherited from class com.realtime.crossfire.jxclient.items.AbstractItemView
addLocationListener, addLocationsListener, addModified, addModifiedRange, removeLocationListener, removeLocationsListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comparator

@NotNull
private final java.util.Comparator<CfItem> comparator
The Comparator for sorting.


currentPlayerTag

private int currentPlayerTag
The tag of the current player object or -1.


items

@NotNull
private final java.util.List<CfItem> items
The items in the inventory ordered by comparator.


itemSet

@NotNull
private final ItemSet itemSet
The ItemSet to monitor.


itemSetListener

@NotNull
private final ItemSetListener itemSetListener
The ItemSetListener attached to itemSet to track the current player object.


mapping

@NotNull
private final DoubleMapping mapping
Maps external index to original index.


playerInventoryListener

@NotNull
private final ItemListener playerInventoryListener
The ItemListener attached to the current player object.

Constructor Detail

InventoryView

public InventoryView(@NotNull
                     ItemSet itemSet,
                     @NotNull
                     java.util.Comparator<CfItem> comparator)
Creates a new instance.

Parameters:
itemSet - the item set to monitor
comparator - the comparator for sorting
Method Detail

findInsertionIndex

private int findInsertionIndex(@NotNull
                               CfItem item)
Returns the insertion index of a CfItem.

Parameters:
item - the item to insert into the inventory
Returns:
the index to insert at

getItem

@Nullable
public CfItem getItem(int index)
Returns the CfItem in a given slot.

Parameters:
index - the slot index
Returns:
the item or null if the slot is empty

getSize

public int getSize()
Returns the number of items.

Returns:
the number of items

setCurrentPlayerTag

private void setCurrentPlayerTag(int currentPlayerTag)
Updates the current player object.

Parameters:
currentPlayerTag - the tag of the player object or -1