guk.editIM
Class GlyphTable

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--guk.editIM.MapTable
              |
              +--guk.editIM.GlyphTable
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableCellRenderer, javax.swing.table.TableModel

public class GlyphTable
extends MapTable
implements javax.swing.table.TableCellRenderer

A class to represent a table of all unicode glyphs, where the user can control which lines are visible. Only for glyphs where a key sequence exists, an AssignObject is stored. The lines for un-assigned glyphs are not stored but calculated.

See Also:
Serialized Form

Field Summary
(package private)  javax.swing.JTable myTable
          For some geometry manipulations, we can make use of an object that holds our host JTable (or null).
(package private)  GTRenderer renderman
          The renderman object provides us with a TableCellRenderer implementation and some scrollTo(row) method, which can be controlled by the processCommand() inside.
(package private)  java.util.Hashtable usedSlots
          the glyph value is simply (char) for any internal row i, but externally, not every row is visible all the time...
(package private)  GTVisibility visor
          The visor objects keeps track of which internal rows are externally visible and how row numbers are mapped.
 
Fields inherited from class guk.editIM.MapTable
assignments, changedFlag, tcRenderer, transferFormat
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
GlyphTable()
          The constructor is quite simple now, as the GTVisibility and GTRenderer classes are doing the more specialized tasks.
 
Method Summary
 boolean addEntry(AssignObject ao)
          Overridden because we use a Hashtable, no Vector.
 boolean flushTable()
          Overridden because we use a Hashtable, no Vector.
 java.lang.String getColumnName(int col)
          Overridden for dynamic title depending on the visor hideUnmapped status.
 int getRowCount()
          Overridden as it differs from normal MapTable.
 java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
          The renderer: Use superclass method and improve.
 java.lang.Object getValueAt(int row, int col)
          Finds and returns an appropriate keys / glyphs assignment, or to be more exact, the requested field of it.
 boolean isCellEditable(int row, int col)
          Overridden to disallow editing of the glyph column.
 void processCommand(java.lang.String command, int modifiers, boolean checked)
          Process command strings.
 java.util.Collection readTable()
          Overridden because we use a Hashtable, no Vector.
 boolean removeEntry(AssignObject ao)
          Overridden because we use a Hashtable, no Vector.
 void setScroller(javax.swing.JViewport vp, javax.swing.JTable tab, MenuHelpers menu)
          Know which table we belong to and which viewport, so that we can remote control them.
 void setValueAt(java.lang.Object val, int row, int col)
          Update the stored Hashtable of AssignObjects.
 
Methods inherited from class guk.editIM.MapTable
addRow, clearChanged, getColumnClass, getColumnCount, isChanged
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

usedSlots

java.util.Hashtable usedSlots
the glyph value is simply (char) for any internal row i, but externally, not every row is visible all the time... When key sequences get assigned to glyphs, we use AssignObjects. Because an array for those would be sparse, we use an Hashtable.

myTable

javax.swing.JTable myTable
For some geometry manipulations, we can make use of an object that holds our host JTable (or null).

visor

GTVisibility visor
The visor objects keeps track of which internal rows are externally visible and how row numbers are mapped. Can be controlled by the processCommand() inside.

renderman

GTRenderer renderman
The renderman object provides us with a TableCellRenderer implementation and some scrollTo(row) method, which can be controlled by the processCommand() inside.
Constructor Detail

GlyphTable

public GlyphTable()
The constructor is quite simple now, as the GTVisibility and GTRenderer classes are doing the more specialized tasks. Those also cause some number crunching when their objects are instantiated.
Method Detail

setScroller

public void setScroller(javax.swing.JViewport vp,
                        javax.swing.JTable tab,
                        MenuHelpers menu)
Know which table we belong to and which viewport, so that we can remote control them. Just passed on to the renderman. Obviously breaks some abstraction barriers.
See Also:
GTRenderer

flushTable

public boolean flushTable()
Overridden because we use a Hashtable, no Vector. removes all mappings, Does update visibility.
Overrides:
flushTable in class MapTable
Returns:
returns false on failure.

readTable

public java.util.Collection readTable()
Overridden because we use a Hashtable, no Vector.
Overrides:
readTable in class MapTable
Returns:
returns the Collection with all entries (for saving them).

addEntry

public boolean addEntry(AssignObject ao)
Overridden because we use a Hashtable, no Vector. merges an entry into the table, Does not update visibility.
Overrides:
addEntry in class MapTable
Returns:
returns false on failure.

removeEntry

public boolean removeEntry(AssignObject ao)
Overridden because we use a Hashtable, no Vector. removes an entry from the table, Does not update visibility.
Overrides:
removeEntry in class MapTable
Returns:
returns false on failure, for example when trying to remove a nonexisting entry.

getRowCount

public int getRowCount()
Overridden as it differs from normal MapTable. All things that are already as wanted in a normal MapTable are not overridden in GlyphTable, e.g. getColumnCount()... The row count depends on which rows are visible. The number of internal rows is always 65536.
Overrides:
getRowCount in class MapTable
Following copied from class: guk.editIM.MapTable
Returns:
The number of rows in the table.

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Finds and returns an appropriate keys / glyphs assignment, or to be more exact, the requested field of it.
Overrides:
getValueAt in class MapTable
Returns:
Returns a calculated value with empty key sequence and only the (char)row glyph for unused rows, and the real keys, glyphs or comments for used rows.

getColumnName

public java.lang.String getColumnName(int col)
Overridden for dynamic title depending on the visor hideUnmapped status. Overridden to give the user some hint about the nature of this kind of table and how it differs from a normal MapTable...
Overrides:
getColumnName in class MapTable
Following copied from class: guk.editIM.MapTable
Parameters:
col - The column for which you want to know the name.
Returns:
"Glyph Strings", "Key Sequences" or "Comments" for columns 0, 1 and 2 respectively.

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Overridden to disallow editing of the glyph column. The glyphs are generated, not stored, so you cannot edit them.
Overrides:
isCellEditable in class MapTable
Following copied from class: guk.editIM.MapTable
Parameters:
row - The affected row (not likely to matter)
col - The affected column: implementing classes may return false for columns where they do not want Java to allow the user to activate the editor component.

setValueAt

public void setValueAt(java.lang.Object val,
                       int row,
                       int col)
Update the stored Hashtable of AssignObjects. Overridden: modifies or creates AssignObject in the Hashtable rather than using a sparse array of Strings. AssignObjects are removed when key sequences go empty, which may cause an update of the visibility status.
Overrides:
setValueAt in class MapTable
Following copied from class: guk.editIM.MapTable
Parameters:
val - Usually a string with the new value for that cell.
row - The row where the value is to be stored.
col - The column where the value is to be stored.

getTableCellRendererComponent

public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table,
                                                        java.lang.Object value,
                                                        boolean isSelected,
                                                        boolean hasFocus,
                                                        int row,
                                                        int column)
The renderer: Use superclass method and improve. This is a very nonstandard place for this method. Most of the work is done by the renderman object.
Specified by:
getTableCellRendererComponent in interface javax.swing.table.TableCellRenderer
Overrides:
getTableCellRendererComponent in class MapTable
See Also:
GTRenderer

processCommand

public void processCommand(java.lang.String command,
                           int modifiers,
                           boolean checked)
Process command strings.

 process a command sent by e.g. the GUI menu system:

 showpart 12-34 (show that glyph range, using PART bitmap).
 showall 12-34 (show that glyph range, using ALL bitmap).
 jumpto 1234 (scrolls to that glyph).
 jumpfield CHAR (scrolls to that glyph - char may be escaped).
 hideunmapped glyphs (hide all unmapped glyphs from the table).
 (hideunmapped, showall and showpart also use the checked argument)
 

Overrides:
processCommand in class MapTable
Parameters:
modifiers - Modifiers use the normal ActionEvent bit masks.
checked - Some commands use this as additional boolean input.