|
Side of Software Marker Bar Library 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sos.marker.Utility
public final class Utility
A collection of utility methods that aid in converting Swing component locations to marker locations.
Method Summary | |
---|---|
static double[] |
listIndexToMarkerRange(javax.swing.JList list,
int row)
Converts a list row index to a range appropriate for a vertical marker bar. |
static double[] |
listRangeToMarkerRange(javax.swing.JList list,
int startIndex,
int endIndex)
Converts a list range to a range appropriate for a vertical marker bar. |
static void |
scrollHorizontallyToMarker(javax.swing.JComponent componentToScroll,
Marker marker)
Scrolls the specific component horizontally to the relative location given by the specified marker. |
static void |
scrollToMarker(javax.swing.JComponent componentToScroll,
JMarkerBar markerBar,
int markerIndex)
Scrolls a component to the relative location given by the marker bar's marker. |
static void |
scrollVerticallyToMarker(javax.swing.JComponent componentToScroll,
Marker marker)
Scrolls the specific component vertically to the relative location given by the specified marker. |
static double[] |
tableIndexToMarkerRange(javax.swing.JTable table,
int row,
int column)
Converts a table cell location to a range appropriate for a vertical marker bar. |
static double[] |
tableRangeToMarkerRange(javax.swing.JTable table,
int startRow,
int startColumn,
int endRow,
int endColumn)
Converts a table range to a range appropriate for a vertical marker bar. |
static double[] |
textIndexToMarkerRange(javax.swing.text.JTextComponent textComponent,
int index)
Converts a text index to a range appropriate for a vertical marker bar. |
static double[] |
textRangeToMarkerRange(javax.swing.text.JTextComponent textComponent,
int startIndex,
int endIndex)
Converts text indices to a range appropriate for a vertical marker bar. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static double[] listIndexToMarkerRange(javax.swing.JList list, int row)
double[] markerRange = Utility.listIndexToMarkerRange( list, row ); Marker marker = new DefaultMarker( markerRange[0], markerRange[1], "Description here" );
list
- the Swing JList
for which the row position is requestedrow
- index of the row in the JList
java.lang.NullPointerException
- if list
is null
public static double[] listRangeToMarkerRange(javax.swing.JList list, int startIndex, int endIndex)
double[] markerRange = Utility.listRangeToMarkerRange( list, fromRow, toRow ); Marker marker = new DefaultMarker( markerRange[0], markerRange[1], "Description here" );
list
- the Swing JList for which the row position is requestedstartIndex
- index of the row in the JListendIndex
- index of the row in the JList
java.lang.NullPointerException
- if list
is null
public static void scrollHorizontallyToMarker(javax.swing.JComponent componentToScroll, Marker marker)
componentToScroll
- component to scroll horizontallymarker
- marker that provides the relative locations of where to scroll
java.lang.NullPointerException
- if componentToScroll
or
marker
is null
scrollVerticallyToMarker(javax.swing.JComponent, sos.marker.Marker)
,
scrollToMarker(javax.swing.JComponent, sos.marker.JMarkerBar, int)
public static void scrollVerticallyToMarker(javax.swing.JComponent componentToScroll, Marker marker)
componentToScroll
- component to scroll verticallymarker
- marker that provides the relative locations of where to scroll
java.lang.NullPointerException
- if componentToScroll
or
marker
is null
scrollHorizontallyToMarker(javax.swing.JComponent, sos.marker.Marker)
,
scrollToMarker(javax.swing.JComponent, sos.marker.JMarkerBar, int)
public static void scrollToMarker(javax.swing.JComponent componentToScroll, JMarkerBar markerBar, int markerIndex)
Clients often invoke this method in response to the click of a marker, as follows:
markerBar.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent event ) { int clickedMarkerIndex = markerBar.getClickedIndex(); Utility.scrollToMarker( componentToScroll, markerBar, clickedMarkerIndex ); } } );
componentToScroll
- component to scroll either horizontally or verticallymarkerBar
- marker bar containing the markermarkerIndex
- index of the marker that gives the relative location of where to scroll
java.lang.NullPointerException
- if componentToScroll
or markerBar
is null
scrollHorizontallyToMarker(javax.swing.JComponent, sos.marker.Marker)
,
scrollVerticallyToMarker(javax.swing.JComponent, sos.marker.Marker)
public static double[] textIndexToMarkerRange(javax.swing.text.JTextComponent textComponent, int index) throws javax.swing.text.BadLocationException
double[] markerRange = Utility.textIndexToMarkerRange( textComponent, index ); Marker marker = new DefaultMarker( markerRange[0], markerRange[1], "Description here" );
textComponent
- Swing component containing the text to convertindex
- index of the character for which the bounds should be fetched
javax.swing.text.BadLocationException
- if index
falls outside the bounds of the text
java.lang.NullPointerException
- if textComponent
is null
public static double[] textRangeToMarkerRange(javax.swing.text.JTextComponent textComponent, int startIndex, int endIndex) throws javax.swing.text.BadLocationException
double[] markerRange = Utility.textRangeToMarkerRange( textComponent, startIndex, endIndex ); Marker marker = new DefaultMarker( markerRange[0], markerRange[1], "Description here" );
textComponent
- Swing component containing the text to convertstartIndex
- index of the first character for which the bounds should be fetchedendIndex
- index of the last character for which the bounds should be fetched
javax.swing.text.BadLocationException
- if startIndex
or endIndex
falls outside
the bounds of the text
java.lang.IllegalArgumentException
- if endIndex
precedes startIndex
java.lang.NullPointerException
- if textComponent
is null
public static double[] tableIndexToMarkerRange(javax.swing.JTable table, int row, int column)
double[] markerRange = Utility.tableIndexToMarkerRange( textComponent, row, column ); Marker marker = new DefaultMarker( markerRange[0], markerRange[1], "Description here" );
table
- Swing JTable
containing the cell to convertrow
- row index of the cell in the JTable
column
- column index of the cell in the JTable
java.lang.NullPointerException
- if table
is null
public static double[] tableRangeToMarkerRange(javax.swing.JTable table, int startRow, int startColumn, int endRow, int endColumn)
double[] markerRange = Utility.textRangeToMarkerRange( textComponent, startRow, startColumn, endRow, endColumn ); Marker marker = new DefaultMarker( markerRange[0], markerRange[1], "Description here" );
table
- Swing JTable
containing the range of cells to convertstartRow
- row index of the starting cell in the rangestartColumn
- column index of the starting cell in the rangeendRow
- row index of the ending cell in the rangeendColumn
- column index of the ending cell in the range
java.lang.NullPointerException
- if table
is null
|
Side of Software Marker Bar Library 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |