guk.editIM
Class GTVisibility

java.lang.Object
  |
  +--guk.editIM.GTVisibility

public class GTVisibility
extends java.lang.Object

Visibility and internal versus user row mapping for the glyph table, including the required command processing.


Field Summary
protected static boolean AUTOMAPPED
          If this is true, mapped glyphs will always be visible when the hideUnmapped state is on.
(package private)  int[] glyphToRow
          like rowToGlyph but for translating internal (glyph) to visible row number.
protected  boolean hideUnmapped
          whether to hide rows where no key sequence is assigned.
(package private)  java.util.Map rowContents
          The contents of the table, so that we can stay up to date about which internal rows are in use, for the hideUnmapped feature.
(package private)  int[] rowToGlyph
          The current assignment between visible rows and internal rows, some rows might be invisible so the values might differ! used at different places, maintained by processCommand.
(package private)  boolean[] showAll
          Describes the visibility status of all lines.
(package private)  boolean[] showPart
          ORed together with showAll to determine visibility.
(package private)  int visibleRows
          current size of the table, number of visible rows.
 
Constructor Summary
GTVisibility(java.util.Map contents)
          The constructor initializes the arrays.
 
Method Summary
 int getVisibleRowCount()
          Figure out how many rows are currently to be shown.
 int internalToRow(int row)
          Translate glyph number / internal row to visible row.
 boolean isHideUnmappedOn()
          Ask if the hideUnmapped feature is on.
 void processCommand(java.lang.String command, int modifiers, boolean checked)
          Process command strings.
 int rowToInternal(int row)
          Translate visible row to glyph number / internal row.
 void updateVisibility()
          Determine which internal rows are visible, based on the internal showAll and showPart arrays and on hideUnmapped.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

AUTOMAPPED

protected static final boolean AUTOMAPPED
If this is true, mapped glyphs will always be visible when the hideUnmapped state is on. Otherwise, they can be hidden even in that state by showall / showpart settings.

rowToGlyph

int[] rowToGlyph
The current assignment between visible rows and internal rows, some rows might be invisible so the values might differ! used at different places, maintained by processCommand. speed does matter here, so we have a lookup array.
  rowToGlyph: know glyph from user row (for table interface)
  glyphToRow: know user row from glyph (for scrolling)
  

glyphToRow

int[] glyphToRow
like rowToGlyph but for translating internal (glyph) to visible row number.

showAll

boolean[] showAll
Describes the visibility status of all lines.
  showAll: which glyphs are certainly visible?
  showPart: which glpyhs are specially visible?
    the idea is that you can toggle showAll without having
    to update showPart. If either is true, the row is visible.
  

showPart

boolean[] showPart
ORed together with showAll to determine visibility.

visibleRows

int visibleRows
current size of the table, number of visible rows.

hideUnmapped

protected boolean hideUnmapped
whether to hide rows where no key sequence is assigned. Useful to get an overview of the current mapping by hiding all unmapped glyphs. (protected to have it javadoc-ed even without -private flag ;-)).

rowContents

java.util.Map rowContents
The contents of the table, so that we can stay up to date about which internal rows are in use, for the hideUnmapped feature.
Constructor Detail

GTVisibility

public GTVisibility(java.util.Map contents)
The constructor initializes the arrays. It also receives a map with contents, to be able to know which rows are used (for the hideUnmapped feature, see processCommand()).
Parameters:
contents - A map where an Integer key retrieves the contents for the internal row selected by the Integer value. The map will be queried from time to time.
Method Detail

getVisibleRowCount

public int getVisibleRowCount()
Figure out how many rows are currently to be shown.
Returns:
The number of rows that are currently visible.

isHideUnmappedOn

public boolean isHideUnmappedOn()
Ask if the hideUnmapped feature is on.
Returns:
Whether unused rows are hidden (even if showall or showpart would enable their visibility).

rowToInternal

public int rowToInternal(int row)
Translate visible row to glyph number / internal row. Helper method to translate from visible to internal row numbers - some rows might be configured as invisible.
Parameters:
row - The number of a visible row (0 is the topmost visible row).
Returns:
The number of an internal row. If all rows were visible, input and output of this function were equal.

internalToRow

public int internalToRow(int row)
Translate glyph number / internal row to visible row.
Parameters:
row - The number of a glyph / internal row.
Returns:
The number of a visible row, possibly approximated, where the requested internal row is visible.

updateVisibility

public void updateVisibility()
Determine which internal rows are visible, based on the internal showAll and showPart arrays and on hideUnmapped. You can modify those arrays and hideUnmapped by using the processCommand() interface. Helper method that updates rowToGlyph and glyphToRow and the looks of the table. not performance critical. uses the showAll and showPart boolean arrays as source.

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),
 hideunmapped glyphs (hide all unmapped glyphs from the table)
 (hideunmapped, showall and showpart also use the checked argument)
 

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