net.sf.rej.gui.hexeditor
Class SelectionModel

java.lang.Object
  extended by net.sf.rej.gui.hexeditor.SelectionModel

public class SelectionModel
extends java.lang.Object

A class that maintains the state of the selected indices in the Hex Editor component. The state can be queried and set.

Author:
Sami Koivu

Constructor Summary
SelectionModel()
          Initializes this selection model.
 
Method Summary
 void clearSelection()
          Clears the selection.
 boolean getHexSelection()
          Returns the hex-selection mode of this model.
 int getMaximumIndex()
          Returns the first selected index or -1 if there is no selection.
 int getMinimumIndex()
          Returns the first selected index or -1 if there is no selection.
 int getSize()
          Returns the size of the data with which this selection model is associated.
 int getSubPosition()
          Returns the sub-position value.
 boolean isSelected(int index)
          Returns true if the given index is currently selected, false otherwise.
 void setHexSelection(boolean hexSelection)
          Sets the hex-selection mode of this model.
 void setSelectedIndex(int index)
          Sets the selected index to the given value.
 void setSelectedInverval(int begin, int end)
          Sets the selected indices to the given interval.
 void setSize(int size)
          Sets the size of the data with which this selection model is associated.
 void setSubPosition(int subPosition)
          Sets the sub-position value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectionModel

public SelectionModel()
Initializes this selection model.

Method Detail

setSelectedIndex

public void setSelectedIndex(int index)
Sets the selected index to the given value. Sub-position will be set to 0 and any old selection will be discarded.

Parameters:
index - new selected index.

isSelected

public boolean isSelected(int index)
Returns true if the given index is currently selected, false otherwise.

Parameters:
index - the index to test for being selected.
Returns:
a boolean value indicating whether the the given index is selected.

setSelectedInverval

public void setSelectedInverval(int begin,
                                int end)
Sets the selected indices to the given interval. Sub-position will be set to 0 and any old selection will be discarded. Defining the interval begin=0, end=3 will select the 3 first bytes.

Parameters:
begin - the index of the beginning of the new selection.
end - the index of the end of the new selection.

clearSelection

public void clearSelection()
Clears the selection.


getMinimumIndex

public int getMinimumIndex()
Returns the first selected index or -1 if there is no selection.

Returns:
the smallest index that is currently selected.

getMaximumIndex

public int getMaximumIndex()
Returns the first selected index or -1 if there is no selection.

Returns:
the smallest index that is currently selected.

setSize

public void setSize(int size)
Sets the size of the data with which this selection model is associated.

Parameters:
size - the size of the data in bytes.

getSize

public int getSize()
Returns the size of the data with which this selection model is associated.

Returns:
size of the data in bytes.

getSubPosition

public int getSubPosition()
Returns the sub-position value.

Returns:
sub-position.

setSubPosition

public void setSubPosition(int subPosition)
Sets the sub-position value.

Parameters:
subPosition - new sub-position.

getHexSelection

public boolean getHexSelection()
Returns the hex-selection mode of this model. That is, true if the current editing should affect the hexadecimal values, false if the editing should be targeted at the ascii values.

Returns:
true if the editing is to be done on the hexadecimal values.

setHexSelection

public void setHexSelection(boolean hexSelection)
Sets the hex-selection mode of this model. That is, true if the current editing should affect the hexadecimal values, false if the editing should be targeted at the ascii values.

Parameters:
hexSelection - true if the editing should be done on the hexadecimal values.