com.realtime.crossfire.jxclient.items
Class AbstractItemView

java.lang.Object
  extended by com.realtime.crossfire.jxclient.items.AbstractItemView
All Implemented Interfaces:
ItemView
Direct Known Subclasses:
FloorView, InventoryView

public abstract class AbstractItemView
extends java.lang.Object
implements ItemView

Abstract base class for ItemView implementing classes.


Field Summary
private  java.lang.Runnable fireEventCallback
          The event scheduler callback for delaying event generation.
private  EventScheduler fireEventScheduler
          The EventScheduler for delaying event generation.
private  IndexedEventListenerList locationListeners
          The registered ItemListeners to be notified about changes.
private  javax.swing.event.EventListenerList locationsListeners
          The registered LocationsListeners to be notified about changes.
private  java.util.Collection<java.lang.Integer> modifiedSlots
          The pending modified floor slots to be reported to listeners.
private  java.lang.Object sync
          The synchronization object for accesses to modifiedSlots.
 
Constructor Summary
protected AbstractItemView()
          Creates a new instance.
 
Method Summary
 void addLocationListener(int index, LocationListener locationListener)
          Adds a LocationListener to be notified when the item displayed in a floor slot has changed.
 void addLocationsListener(LocationsListener locationsListener)
          Adds a LocationsListener to be notified when any displayed item has changed.
protected  void addModified(int index)
          Marks a slot as modified.
protected  void addModifiedRange(int firstIndex, int lastIndex)
          Marks a range of slots as modified.
private  void deliverEvents()
          Delivers all pending events.
private  void fireEvents()
          Delivers outstanding change events.
 void removeLocationListener(int index, LocationListener locationListener)
          Removes a LocationListener to be notified when the item displayed in a floor slot has changed.
 void removeLocationsListener(LocationsListener locationsListener)
          Removes a LocationsListener to be notified when any displayed item has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.realtime.crossfire.jxclient.items.ItemView
getItem, getSize
 

Field Detail

fireEventCallback

@NotNull
private final java.lang.Runnable fireEventCallback
The event scheduler callback for delaying event generation. This is needed because the Crossfire server sends multiple item2 commands for one "get all" command.


fireEventScheduler

@NotNull
private final EventScheduler fireEventScheduler
The EventScheduler for delaying event generation.


locationListeners

@NotNull
private final IndexedEventListenerList locationListeners
The registered ItemListeners to be notified about changes.


locationsListeners

@NotNull
private final javax.swing.event.EventListenerList locationsListeners
The registered LocationsListeners to be notified about changes.


modifiedSlots

@NotNull
private final java.util.Collection<java.lang.Integer> modifiedSlots
The pending modified floor slots to be reported to listeners.


sync

@NotNull
private final java.lang.Object sync
The synchronization object for accesses to modifiedSlots.

Constructor Detail

AbstractItemView

protected AbstractItemView()
Creates a new instance.

Method Detail

addLocationListener

public void addLocationListener(int index,
                                @NotNull
                                LocationListener locationListener)
Adds a LocationListener to be notified when the item displayed in a floor slot has changed.

Specified by:
addLocationListener in interface ItemView
Parameters:
index - the floor slot
locationListener - the location listener to add

addLocationsListener

public void addLocationsListener(@NotNull
                                 LocationsListener locationsListener)
Adds a LocationsListener to be notified when any displayed item has changed.

Specified by:
addLocationsListener in interface ItemView
Parameters:
locationsListener - the locations listener to add

addModified

protected void addModified(int index)
Marks a slot as modified.

Parameters:
index - the modified slot index

addModifiedRange

protected void addModifiedRange(int firstIndex,
                                int lastIndex)
Marks a range of slots as modified.

Parameters:
firstIndex - the first modified slot index
lastIndex - the last modified slot index

deliverEvents

private void deliverEvents()
Delivers all pending events.


fireEvents

private void fireEvents()
Delivers outstanding change events.


removeLocationListener

public void removeLocationListener(int index,
                                   @NotNull
                                   LocationListener locationListener)
Removes a LocationListener to be notified when the item displayed in a floor slot has changed.

Specified by:
removeLocationListener in interface ItemView
Parameters:
index - the floor slot
locationListener - the location listener to remove

removeLocationsListener

public void removeLocationsListener(@NotNull
                                    LocationsListener locationsListener)
Removes a LocationsListener to be notified when any displayed item has changed.

Specified by:
removeLocationsListener in interface ItemView
Parameters:
locationsListener - the locations listener to remove