Package ball.util
Class CoordinateMap<V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- ball.util.MapView<Coordinate,V>
-
- ball.util.CoordinateMap<V>
-
- Type Parameters:
V- The value type.
- All Implemented Interfaces:
Serializable,Map<Coordinate,V>,SortedMap<Coordinate,V>,TableModel
public class CoordinateMap<V> extends MapView<Coordinate,V> implements SortedMap<Coordinate,V>, TableModel
CoordinateMapimplementation.- Author:
- Allen D. Ball
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ball.util.MapView
MapView.EntrySet
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description CoordinateMap()Constructor to create an emptyCoordinateMap.CoordinateMap(Number yN, Number xN)Constructor to specify maximumYandX(origin(0, 0)).CoordinateMap(Number y0, Number x0, Number yN, Number xN)Constructor to specify minimum and maximumYandX.
-
Method Summary
-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size
-
-
-
-
Constructor Detail
-
CoordinateMap
public CoordinateMap()
Constructor to create an emptyCoordinateMap.
-
CoordinateMap
public CoordinateMap(Number y0, Number x0, Number yN, Number xN)
Constructor to specify minimum and maximumYandX.- Parameters:
y0-MIN(y)x0-MIN(x)yN-MAX(y) + 1xN-MAX(x) + 1
-
CoordinateMap
public CoordinateMap(Number yN, Number xN)
Constructor to specify maximumYandX(origin(0, 0)).- Parameters:
yN-MAX(y) + 1xN-MAX(x) + 1
-
-
Method Detail
-
map
protected SortedMap<Coordinate,V> map()
- Overrides:
mapin classMapView<Coordinate,V>- Returns:
- The "wrapped"
Map.
-
getType
protected Type getType()
Method to get the value type ofthisCoordinateMap.- Returns:
- The value type
Class.
-
resize
public CoordinateMap<V> resize(Number y0, Number x0, Number yN, Number xN)
Method to specify new limits for theCoordinateMap.- Parameters:
y0-MIN(y)x0-MIN(x)yN-MAX(y) + 1xN-MAX(x) + 1- Returns:
thisCoordinateMap.
-
resize
public CoordinateMap<V> resize(Number yN, Number xN)
Method to specify new limits for theCoordinateMapwith[y0, x0] = [0, 0].- Parameters:
yN-MAX(y) + 1xN-MAX(x) + 1- Returns:
thisCoordinateMap.
-
getMin
public Coordinate getMin()
-
getMax
public Coordinate getMax()
-
getMinY
public int getMinY()
-
getMinX
public int getMinX()
-
getMaxY
public int getMaxY()
-
getMaxX
public int getMaxX()
-
includes
public boolean includes(Coordinate coordinate)
Method to determine if theCoordinateis included inthisCoordinateMap's space. Because the map is sparse, this method may returntruewhenAbstractMap.containsKey(Object)returnsfalse.- Parameters:
coordinate- TheCoordinate.- Returns:
trueif within the space;falseotherwise.
-
columns
public List<CoordinateMap<V>> columns()
Method to get aListof columns (seecolumn(Number)).- Returns:
- The
Listof columns.
-
rows
public List<CoordinateMap<V>> rows()
Method to get aListof rows (seerow(Number)).- Returns:
- The
Listof rows.
-
column
public CoordinateMap<V> column(Number x)
Method to get theListrepresenting the specified column backed by theCoordinateMap.- Parameters:
x- The X-coordinate.- Returns:
- The
CoordinateMaprepresenting the column.
-
row
public CoordinateMap<V> row(Number y)
Method to get theListrepresenting the specified row backed by theCoordinateMap.- Parameters:
y- The Y-coordinate.- Returns:
- The
CoordinateMaprepresenting the row.
-
subMap
public CoordinateMap<V> subMap(Number y0, Number x0, Number yN, Number xN)
- Parameters:
y0-MIN(y)x0-MIN(x)yN-MAX(y) + 1xN-MAX(x) + 1- Returns:
- The sub-
Map(CoordinateMap).
-
asList
public List<V> asList()
Method to getthisCoordinateMapvalues as aList. Updates made throughList.set(int,Object)will be made tothisCoordinateMap.- Returns:
- The
ListofCoordinateMapvalues.
-
containsKey
public boolean containsKey(Number y, Number x)
- Parameters:
y- The Y-coordinate.x- The X-coordinate.- Returns:
trueif theCoordinateMapcontains a key with the specifiedCoordinate;falseotherwise.
-
get
public V get(Number y, Number x)
SeeMapView.get(Object).- Parameters:
y- The Y-coordinate.x- The X-coordinate.- Returns:
- The value at the coordinate (may be
null).
-
put
public V put(Number y, Number x, V value)
- Parameters:
y- The Y-coordinate.x- The X-coordinate.value- The value at the coordinate.- Returns:
- The previous value at the coordinate.
-
put
public V put(Coordinate key, V value)
- Specified by:
putin interfaceMap<Coordinate,V>- Overrides:
putin classMapView<Coordinate,V>
-
remove
public V remove(Object key)
- Specified by:
removein interfaceMap<Coordinate,V>- Overrides:
removein classMapView<Coordinate,V>
-
comparator
public Comparator<? super Coordinate> comparator()
- Specified by:
comparatorin interfaceSortedMap<Coordinate,V>
-
subMap
public CoordinateMap<V> subMap(Coordinate from, Coordinate to)
- Specified by:
subMapin interfaceSortedMap<Coordinate,V>
-
headMap
public CoordinateMap<V> headMap(Coordinate key)
- Specified by:
headMapin interfaceSortedMap<Coordinate,V>
-
tailMap
public CoordinateMap<V> tailMap(Coordinate key)
- Specified by:
tailMapin interfaceSortedMap<Coordinate,V>
-
firstKey
public Coordinate firstKey()
- Specified by:
firstKeyin interfaceSortedMap<Coordinate,V>
-
lastKey
public Coordinate lastKey()
- Specified by:
lastKeyin interfaceSortedMap<Coordinate,V>
-
clear
public void clear()
- Specified by:
clearin interfaceMap<Coordinate,V>- Overrides:
clearin classMapView<Coordinate,V>
-
getRowCount
public int getRowCount()
- Specified by:
getRowCountin interfaceTableModel
-
getColumnCount
public int getColumnCount()
- Specified by:
getColumnCountin interfaceTableModel
-
getColumnName
public String getColumnName(int x)
- Specified by:
getColumnNamein interfaceTableModel
-
getColumnClass
public Class<? extends V> getColumnClass(int x)
- Specified by:
getColumnClassin interfaceTableModel
-
isCellEditable
public boolean isCellEditable(int y, int x)
- Specified by:
isCellEditablein interfaceTableModel
-
getValueAt
public V getValueAt(int y, int x)
- Specified by:
getValueAtin interfaceTableModel
-
setValueAt
public void setValueAt(Object value, int y, int x)
- Specified by:
setValueAtin interfaceTableModel
-
addTableModelListener
public void addTableModelListener(TableModelListener listener)
- Specified by:
addTableModelListenerin interfaceTableModel
-
removeTableModelListener
public void removeTableModelListener(TableModelListener listener)
- Specified by:
removeTableModelListenerin interfaceTableModel
-
getTableModelListeners
protected TableModelListener[] getTableModelListeners()
-
fireTableDataChanged
protected void fireTableDataChanged()
-
fireTableStructureChanged
protected void fireTableStructureChanged()
-
fireTableRowsInserted
protected void fireTableRowsInserted(int start, int end)
-
fireTableRowsUpdated
protected void fireTableRowsUpdated(int start, int end)
-
fireTableRowsDeleted
protected void fireTableRowsDeleted(int start, int end)
-
fireTableCellUpdated
protected void fireTableCellUpdated(int row, int column)
-
fireTableChanged
protected void fireTableChanged(TableModelEvent event)
-
-