org.geotools.gui.swing.referencing
Class CoordinateTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byorg.geotools.gui.swing.referencing.CoordinateTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class CoordinateTableModel
extends javax.swing.table.AbstractTableModel

A table of direct positions. All coordinates contained in this table have the same coordinate reference system, which is specified at construction time.

This table model provides a way to display invalid coordinates in a different color. Invalide coordinates are defined here as coordinates outside the CRS valid area. This color display can be enabled by the following code:

 CoordinateTableModel model = new CoordinateTableModel(crs);
 JTable               view  = new JTable(model);
 TableCellRenderer renderer = new CoordinateTableModel.CellRenderer();
 view.setDefaultRenderer(Double.class, renderer);
 

Since:
2.3
Version:
$Id: CoordinateTableModel.java 18471 2006-03-06 13:10:10Z desruisseaux $
Author:
C?dric Brian?on, Hoa Nguyen, Martin Desruisseaux
See Also:
Serialized Form

Nested Class Summary
static class CoordinateTableModel.CellRenderer
          A cell renderer for the coordinate table model.
 
Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CoordinateTableModel(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Creates an initially empty table model using the specified coordinate reference system.
 
Method Summary
 void add(java.util.Collection newPositions)
          Adds a collection of direct positions to this table.
 void add(org.opengis.spatialschema.geometry.DirectPosition newPosition)
          Adds a direct position to this table.
 java.lang.Class getColumnClass(int columnIndex)
          Returns tye type of data for the specified column.
 int getColumnCount()
          Returns the number of columns.
 java.lang.String getColumnName(int columnIndex)
          Returns the name for the specified column.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCRS()
          Returns the CRS for this table model
 java.util.List getPositions()
          Returns all direct positions in this table.
 int getRowCount()
          Returns the number of rows in the table.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value in the table at the specified postion.
 boolean isCellEditable(int rowIndex, int colIndex)
          Specifies that the user can fill all rows in the table.
 boolean isValidCoordinate(int rowIndex)
          Returns if the position at the specified row is inside the CRS valid area.
 void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
          Sets the value for the specified cell.
 java.lang.String toString()
          Returns a string representation of this table.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CoordinateTableModel

public CoordinateTableModel(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Creates an initially empty table model using the specified coordinate reference system.

Method Detail

getCRS

public org.opengis.referencing.crs.CoordinateReferenceSystem getCRS()
Returns the CRS for this table model


getPositions

public java.util.List getPositions()
Returns all direct positions in this table.

See Also:
add(DirectPosition), add(Collection)

getRowCount

public int getRowCount()
Returns the number of rows in the table.


getColumnCount

public int getColumnCount()
Returns the number of columns.


getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name for the specified column. The default implementation returns the name of the corresponding axis in the table CRS.


getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns tye type of data for the specified column. For coordinate table, this is always .


add

public void add(org.opengis.spatialschema.geometry.DirectPosition newPosition)
Adds a direct position to this table. The position is not cloned. Any cell edited in this table will write its change directly into the corresponding object.


add

public void add(java.util.Collection newPositions)
Adds a collection of direct positions to this table. The position is not cloned. Any cell edited in this table will write its change directly into the corresponding object.


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns the value in the table at the specified postion.

Parameters:
rowIndex - Cell row number.
columnIndex - Cell column number.
Returns:
The ordinate value, or if no value is available for the specified cell.

setValueAt

public void setValueAt(java.lang.Object value,
                       int rowIndex,
                       int columnIndex)
Sets the value for the specified cell.

Parameters:
value - The new value for the cell.
rowIndex - Row number of the cell modified.
columnIndex - Column number of the cell modified.

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int colIndex)
Specifies that the user can fill all rows in the table.


isValidCoordinate

public boolean isValidCoordinate(int rowIndex)
Returns if the position at the specified row is inside the CRS valid area. This method is invoked by CoordinateTableModel.CellRenderer in order to determine if this row should be colorized.


toString

public java.lang.String toString()
Returns a string representation of this table. The default implementation list all coordinates.



Copyright © GeoTools. All Rights Reserved.