com.empireclassic.Remote
Class SelectionMap

java.lang.Object
  extended by com.empireclassic.Remote.SelectionMap

public class SelectionMap
extends java.lang.Object

Many commands provide the user a way to restrict the selection of sectors based on various criteria. The SelectionMap is simply a structure that holds a boolean value for each possible sector. On creation all are set to false (thus, none selected).

Usually the user input will be parsed for selection criteria, which will then be used to set only particular values in this map.

The command will then use this map as the basis for selecting which sectors will finally be operated upon.

Author:
chas
See Also:
Criteria

Constructor Summary
SelectionMap(IslandInfo island)
          Initialize a new SelectionMap to all false values.
 
Method Summary
 void clearSelection(IslandCoord coord)
          Clear selection of one sector
 int count()
          Return the number of selected coords
 int count(SelectionCondition condition)
          Return number of selected coords that meet a certain condition and are selected.
 boolean isSelected(IslandCoord coord)
          Check if a specific location has been selected (true/false).
 void setSelection(Criteria criteria)
          Use a Criteria structure to set a bunch of sectors to selected.
 void setSelection(IslandCoord coord)
          Set one sector to be selected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectionMap

public SelectionMap(IslandInfo island)
Initialize a new SelectionMap to all false values.

Parameters:
island - Used to get the necessary size for this map.
Method Detail

isSelected

public boolean isSelected(IslandCoord coord)
Check if a specific location has been selected (true/false).

Parameters:
coord - The location to check
Returns:
true if selected

setSelection

public void setSelection(Criteria criteria)
Use a Criteria structure to set a bunch of sectors to selected.

Parameters:
criteria - A previously filled out Criteria structure.
See Also:
Criteria

setSelection

public void setSelection(IslandCoord coord)
Set one sector to be selected.

Parameters:
coord - The sector to be marked as selected.

clearSelection

public void clearSelection(IslandCoord coord)
Clear selection of one sector

Parameters:
coord - The sector to be marked as unselected

count

public int count()
Return the number of selected coords

Returns:
number of selected coords

count

public int count(SelectionCondition condition)
Return number of selected coords that meet a certain condition and are selected.

Parameters:
condition - The condition to check
Returns:
number of selected coords that meet condition