Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.items.AbstractItemView Class Referenceabstract

Abstract base class for ItemView implementing classes. More...

+ Inheritance diagram for com.realtime.crossfire.jxclient.items.AbstractItemView:
+ Collaboration diagram for com.realtime.crossfire.jxclient.items.AbstractItemView:

Public Member Functions

void addLocationListener (final int index, @NotNull final LocationListener locationListener)
 Adds a LocationListener to be notified when the item displayed in a floor slot has changed.
Parameters
indexthe floor slot
locationListenerthe location listener to add
More...
 
void addLocationsListener (@NotNull final LocationsListener locationsListener)
 Adds a LocationsListener to be notified when any displayed item has changed.
Parameters
locationsListenerthe locations listener to add
More...
 
void removeLocationListener (final int index, @NotNull final LocationListener locationListener)
 Removes a LocationListener to be notified when the item displayed in a floor slot has changed.
Parameters
indexthe floor slot
locationListenerthe location listener to remove
More...
 
void removeLocationsListener (@NotNull final LocationsListener locationsListener)
 Removes a LocationsListener to be notified when any displayed item has changed.
Parameters
locationsListenerthe locations listener to remove
More...
 
- Public Member Functions inherited from com.realtime.crossfire.jxclient.items.ItemView
CfItem getItem (int index)
 Returns the CfItem in a given slot. More...
 
int getSize ()
 Returns the number of items. More...
 

Protected Member Functions

 AbstractItemView ()
 Creates a new instance. More...
 
void addModified (final int index)
 Marks a slot as modified. More...
 
void addModifiedRange (final int firstIndex, final int lastIndex)
 Marks a range of slots as modified. More...
 

Private Member Functions

void deliverEvents ()
 Delivers all pending events. More...
 
void fireEvents ()
 Delivers outstanding change events. More...
 

Private Attributes

final Runnable fireEventCallback = this::deliverEvents
 The event scheduler callback for delaying event generation. More...
 
final EventScheduler fireEventScheduler = new EventScheduler(100, 1, fireEventCallback)
 The EventScheduler for delaying event generation. More...
 
final IndexedEventListenerList< LocationListenerlocationListeners = new IndexedEventListenerList<>()
 The registered ItemListeners to be notified about changes. More...
 
final EventListenerList2< LocationsListenerlocationsListeners = new EventListenerList2<>()
 The registered LocationsListeners to be notified about changes. More...
 
final Collection< Integer > modifiedSlots = new HashSet<>()
 The pending modified floor slots to be reported to listeners. More...
 
final Object sync = new Object()
 The synchronization object for accesses to modifiedSlots. More...
 

Detailed Description

Abstract base class for ItemView implementing classes.

Author
Andreas Kirschbaum

Definition at line 34 of file AbstractItemView.java.

Constructor & Destructor Documentation

◆ AbstractItemView()

com.realtime.crossfire.jxclient.items.AbstractItemView.AbstractItemView ( )
protected

Creates a new instance.

Definition at line 73 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.items.AbstractItemView.fireEventScheduler, and com.realtime.crossfire.jxclient.items.EventScheduler.start().

+ Here is the call graph for this function:

Member Function Documentation

◆ addLocationListener()

void com.realtime.crossfire.jxclient.items.AbstractItemView.addLocationListener ( final int  index,
@NotNull final LocationListener  locationListener 
)

Adds a LocationListener to be notified when the item displayed in a floor slot has changed.

Parameters
indexthe floor slot
locationListenerthe location listener to add

Implements com.realtime.crossfire.jxclient.items.ItemView.

Definition at line 103 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.util.IndexedEventListenerList< T extends EventListener >.add().

+ Here is the call graph for this function:

◆ addLocationsListener()

void com.realtime.crossfire.jxclient.items.AbstractItemView.addLocationsListener ( @NotNull final LocationsListener  locationsListener)

Adds a LocationsListener to be notified when any displayed item has changed.

Parameters
locationsListenerthe locations listener to add

Implements com.realtime.crossfire.jxclient.items.ItemView.

Definition at line 87 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

+ Here is the call graph for this function:

◆ addModified()

void com.realtime.crossfire.jxclient.items.AbstractItemView.addModified ( final int  index)
protected

Marks a slot as modified.

Parameters
indexthe modified slot index

Definition at line 133 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.items.AbstractItemView.fireEvents(), and com.realtime.crossfire.jxclient.items.AbstractItemView.sync.

+ Here is the call graph for this function:

◆ addModifiedRange()

void com.realtime.crossfire.jxclient.items.AbstractItemView.addModifiedRange ( final int  firstIndex,
final int  lastIndex 
)
protected

◆ deliverEvents()

void com.realtime.crossfire.jxclient.items.AbstractItemView.deliverEvents ( )
private

◆ fireEvents()

void com.realtime.crossfire.jxclient.items.AbstractItemView.fireEvents ( )
private

Delivers outstanding change events.

Definition at line 164 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.items.EventScheduler.trigger().

Referenced by com.realtime.crossfire.jxclient.items.AbstractItemView.addModified(), and com.realtime.crossfire.jxclient.items.AbstractItemView.addModifiedRange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeLocationListener()

void com.realtime.crossfire.jxclient.items.AbstractItemView.removeLocationListener ( final int  index,
@NotNull final LocationListener  locationListener 
)

Removes a LocationListener to be notified when the item displayed in a floor slot has changed.

Parameters
indexthe floor slot
locationListenerthe location listener to remove

Implements com.realtime.crossfire.jxclient.items.ItemView.

Definition at line 111 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.util.IndexedEventListenerList< T extends EventListener >.remove().

+ Here is the call graph for this function:

◆ removeLocationsListener()

void com.realtime.crossfire.jxclient.items.AbstractItemView.removeLocationsListener ( @NotNull final LocationsListener  locationsListener)

Removes a LocationsListener to be notified when any displayed item has changed.

Parameters
locationsListenerthe locations listener to remove

Implements com.realtime.crossfire.jxclient.items.ItemView.

Definition at line 95 of file AbstractItemView.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.remove().

+ Here is the call graph for this function:

Member Data Documentation

◆ fireEventCallback

final Runnable com.realtime.crossfire.jxclient.items.AbstractItemView.fireEventCallback = this::deliverEvents
private

The event scheduler callback for delaying event generation.

This is needed because the Crossfire server sends multiple item2 commands for one "get all" command.

Definition at line 68 of file AbstractItemView.java.

◆ fireEventScheduler

final EventScheduler com.realtime.crossfire.jxclient.items.AbstractItemView.fireEventScheduler = new EventScheduler(100, 1, fireEventCallback)
private

The EventScheduler for delaying event generation.

Definition at line 81 of file AbstractItemView.java.

Referenced by com.realtime.crossfire.jxclient.items.AbstractItemView.AbstractItemView().

◆ locationListeners

final IndexedEventListenerList<LocationListener> com.realtime.crossfire.jxclient.items.AbstractItemView.locationListeners = new IndexedEventListenerList<>()
private

The registered ItemListeners to be notified about changes.

Definition at line 48 of file AbstractItemView.java.

◆ locationsListeners

final EventListenerList2<LocationsListener> com.realtime.crossfire.jxclient.items.AbstractItemView.locationsListeners = new EventListenerList2<>()
private

The registered LocationsListeners to be notified about changes.

Definition at line 41 of file AbstractItemView.java.

◆ modifiedSlots

final Collection<Integer> com.realtime.crossfire.jxclient.items.AbstractItemView.modifiedSlots = new HashSet<>()
private

The pending modified floor slots to be reported to listeners.

Definition at line 54 of file AbstractItemView.java.

◆ sync

final Object com.realtime.crossfire.jxclient.items.AbstractItemView.sync = new Object()
private

The documentation for this class was generated from the following file: