|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.neu.ccs.gui.DisplayPanel
edu.neu.ccs.gui.TablePanel
edu.neu.ccs.gui.SimpleArrayPanel
Class SimpleArrayPanel provides a panel that can
hold one or more views of a given type with the number of such
views under interactive user control. Although, as of 2.6.0a,
no JPT class directly implements SimpleArrayPanel,
the class PathListView uses this panel as an
internal panel to display an array of PathNodeView
objects. Of course, SimpleArrayPanel may be used
much more generally.
The views are arranged in a 4-column vertical list with the following structure in each row:
TypedView Class object.This 4-column vertical list is placed in a scroll pane. The designer can determine how many rows will be visible at once.
The interactive controls that permit the user to change the total number of views are placed in a panel underneath the scroll pane.
To construct a SimpleArrayPanel, the user must
supply its viewType which is an object of type
Class that defines the view that will be repeated
in the panel.
The following restrictions on the viewType must
hold:
viewType must not be null.viewType must extend JComponent
so a view may be directly inserted into its panel.viewType must implement TypedView
so the model data can be extracted from a view by the standard
methods of the TypedView interface.viewType class must have a default
constructor.If the method createViewForRow is overridden, that
method may use a different constructor for the viewType
class and it is then not necessary to have a default constructor.
The most common way to obtain a viewType is to
take the name of a class, say FooView, that extends
JComponent, implements TypedView, and
has a default constructor, and then to use
FooView.class for the viewType. Later
in this introduction, we will use this notation for examples.
The SimpleArrayPanel class has several constructors
that take optional parameters. We gather here a description of
these optional parameters and their default values.
initialIndex: Internally, rows are numbered from
zero; for the user interface, rows will be labeled with
index + initialIndex;
the default value for initialIndex is 0.visibleViewCount: The visible view count is the
number of views that should be visible in the scroll pane at
one time; the minimum and the default value is 2.gap: The gap is the horizontal and vertical pixel
gap to be used in the TablePanels made internally
in the array panel; the minimum and the default value is 4.autoHalo: If true, then each view will be wrapped
in a new Halo so that error highlighting will be
localized around the view; the default is false since it may
be the case that a view has its own error highlight strategy.By default, the interactive controls that permit the user to change
the number of views show the length of the array, that is,
the total number of views. For some applications, this value may not
be the most meaningful. For example, for a classic polynomial, the
meaningful number is the degree which is the highest coefficient that
is available. In this case, the degree equals length - 1.
To accomodate this, the SimpleArrayPanel class maintains
an internal value lengthOffset that is added to the
length before it is displayed in the user interface. The following 2
calls would tweak the interface to make it suitable for polynomial
coefficients:
setLengthOffset(-1);
setLengthButtonName("Set Degree");
The SimpleArrayPanel class smoothly handles the
transition between the internal length and the number displayed
in the interactive controls.
To obtain an object that collects all views into an array for
internal manipulation, use the method getViews. This
method returns an Object that is actually an array and
that may be cast to an array of viewType.
For example, if viewType is FooView.class,
then the return value of getViews may be cast to an array
type FooView[].
Similarly, to obtain an object that uses the view states of the
various views to create an array of corresponding data model objects,
use either demandObjects or requestObjects.
These methods return an Object that is actually an array
that may be cast to an array of viewDataType.
For example, if viewType is FooView.class
and its corresponding model data type is Foo, then the
return value for either of the methods above may be cast to the array
type Foo[].
Both demandObjects and requestObjects use
any automatic error checking and correction that has been built in to
the corresponding methods in the viewType class.
The class SimpleArrayPanel is similar to the existing
class ArrayPanel but is simpler to use since the most
common defaults are taken as given. More importantly, this class can
be used as is since it is not abstract and sufficient tools are made
available to manage the model-view interaction directly. Finally,
the new interface controls that permit a user to insert or delete an
individual row gives the user much more power than is available with
the older ArrayPanel class.
The class SimpleArrayPanel does not itself implement
the interface TypedView. The critical reason is that
to implement TypedView, it would be necessary to define
the following methods whose definitions cannot be done in a uniform
manner:
public Class getDataType()
public Stringable demandObject()
public Stringable requestObject() throws CancelledException
If the user of this class wishes to build a TypedView,
then it is necessary to create or obtain a view class appropriate for
an overall view and to define a derived class of this class that does
implement the above three methods.
As a convenience, dummy implementations of the following methods of
the interface TypedView have already been provided:
public void setInputProperties(InputProperties properties)
public InputProperties getInputProperties()
For backward compatibility, the older class ArrayPanel
is still part of JPT and has been left basically as is. We recommend
SimpleArrayPanel for all new code.
In 2.6.0a, it was decided that the call setLength(0)
would be valid and that its effect would be to clear the array of all
existing views and then reset the array to MINIMUM_LENGTH
which is 1. The method clear() was defined
to accomplish the same thing.
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
protected int |
arrayLength
The actual length of the array, that is, the current number of input views in the array panel. |
protected boolean |
autoHalo
Determines whether or not to wrap each view of the array panel in a Halo to localize error highlights. |
protected TablePanel |
controls
The interactive controls panel. |
protected SimpleAction |
decrementLength
The action to decrement the number of views. |
static Paintable |
deleteRowPaintable
The Paintable to make the "delete one row icon". |
protected int |
gap
The horizontal and vertical cell gap to be used for all TablePanel objects constructed directly in
this array panel. |
protected SimpleAction |
incrementLength
The action to increment the number of views. |
protected int |
initialIndex
The initial index in the automatic labels of the input views in the array panel. |
protected TablePanel |
innerPanel
The panel that contains the 2-column vertical list with a label in the left column of each row and a view in the right column of each row. |
static Paintable |
insertRowPaintable
The Paintable to make the "insert one row icon". |
protected int |
labelWidth
The preferred width of the labels and text field view. |
protected int |
lengthOffset
The lengthTFV should display the user meaningful length of the array which equals arrayLength + lengthOffset. |
protected TextFieldView |
lengthTFV
The lengthTFV is part of the interactive user controls; this field displays the user meaningful length of the array which equals arrayLength + lengthOffset. |
static int |
MINIMUM_GAP
The minimum horizontal and vertical cell gap to be used for all TablePanel objects constructed directly in
this array panel; the value is 4. |
static int |
MINIMUM_LENGTH
The minimum number of views that must be in the array panel; the value is 1. |
static int |
MINIMUM_VISIBLE
The minimum number of views that should be visible in the scroll pane without needing scrolling; the value is 2. |
protected JPTScrollPane |
scrollPane
The scroll pane that contains the inner panel. |
protected SimpleAction |
setLengthFromGUI
The action to set the array length from the user meaningful length in the lengthTFV; this action takes care of required adjustments. |
protected Class |
viewDataType
The view data type is the data type associated with the view type via the method getDataType() of TypedView. |
protected int |
viewHeight
The preferred height of a default instance of the view type. |
protected Vector |
viewList
The vector to hold references to the views in this panel for ease of access by the methods of this class. |
protected Class |
viewType
The view type is the type of each input view in the array panel; this type must extend the class JComponent,
implement the interface TypedView, and
have a public default constructor. |
protected int |
viewWidth
The preferred width of a default instance of the view type. |
protected int |
visibleViewCount
The number of views that should be visible in the scroll pane without needing scrolling; this number is used to set the minimum size of the scroll pane view port. |
| Fields inherited from class edu.neu.ccs.gui.TablePanel |
DEFAULT_ALIGNMENT, DEFAULT_ORIENTATION, tg |
| Fields inherited from class edu.neu.ccs.gui.DisplayPanel |
background, codec, CODEC |
| Fields inherited from class javax.swing.JPanel |
|
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface edu.neu.ccs.gui.Displayable |
DEFAULT_VIEW_STATE, VIEW_STATE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
SimpleArrayPanel(Class viewType)
The 1-parameter constructor. |
|
SimpleArrayPanel(Class viewType,
int initialIndex)
The 2-parameter constructor. |
|
SimpleArrayPanel(Class viewType,
int initialIndex,
int visibleViewCount)
The 3-parameter constructor. |
|
SimpleArrayPanel(Class viewType,
int initialIndex,
int visibleViewCount,
int gap)
The 4-parameter constructor. |
|
SimpleArrayPanel(Class viewType,
int initialIndex,
int visibleViewCount,
int gap,
boolean autoHalo)
The 5-parameter constructor. |
|
| Method Summary | |
protected void |
buildArrayPanel()
Main method to build the array panel. |
protected void |
buildControls()
Helper method to build the end user controls. |
protected void |
buildInnerPanel()
Helper method to build the inner panel with labels and views. |
protected void |
buildScrollPane()
Helper method to build the scroll pane. |
void |
clear()
Clear the array and reset to its initial size. |
String |
createLabelForRow(int i)
Returns the label String for the i-th row. |
protected TypedView |
createViewForRow(int i)
Returns a new TypedView for the i-th row
whose class is given by the view type. |
void |
decrementLength()
A helper method to decrement the length by 1. |
void |
deleteRowAtIndex(int index)
Delete a row at the given index by moving the contents of each cell at a higher position downward by one cell and then by deleting the the cell at the end of the array. |
Stringable |
demandObject(int i)
Applies demandObject to the i-th view
and returns the resulting Stringable. |
Object |
demandObjects()
Returns an object that is actually an array that is populated by calling demandObject for each
view. |
Stringable[] |
demandStringableArray()
Returns an array of type Stringable[] that
is populated by calling demandObject for each
view. |
String |
getDefaultViewState()
Gets the default view state of the panel as an encoded string. |
String |
getDefaultViewState(int i)
Gets the default view state of the i-th view. |
String[] |
getDefaultViewStates()
Gets the default view states of the views in this panel as items in a string data array. |
Action |
getDeleteRowAction(int index)
Returns an action that deletes a row at the given index. |
JButton |
getDeleteRowButton(int index)
Returns a button that deletes a row at the given index. |
InputProperties |
getInputProperties()
This method returns null since the panel as
a whole does not utilize input properties. |
InputProperties |
getInputProperties(int i)
Gets the input properties of the i-th view. |
InputProperties[] |
getInputPropertiesByView()
Gets the input properties object for each view and then returns this information in an array. |
Action |
getInsertRowAction(int index)
Returns an action that inserts a row at the given index. |
JButton |
getInsertRowButton(int index)
Returns a button that inserts a row at the given index. |
int |
getLength()
Returns the number of views in this panel or, equivalently, the length of the array of views. |
String |
getLengthButtonName()
Returns the text on the GUI button that sets the length of the array using the user meaningful length that is held in the corresponding GUI text field view. |
int |
getLengthOffset()
Returns the constant that should be added to the length to obtain the length measure meaningful to the end user. |
TypedView |
getTypedView(int i)
Returns the i-th view installed in this panel. |
TypedView[] |
getTypedViewArray()
Returns an array of type TypedView[] with
the views in the panel. |
int |
getUserLength()
Returns the measure of the length of the array that is meaningful to the end user. |
Class |
getViewDataType()
Returns the model data type associated with the views repeated in this panel. |
Object |
getViews()
Returns an object that is actually an array with the list of views installed in the panel. |
String |
getViewState()
Gets the view state of the panel as an encoded string. |
String |
getViewState(int i)
Gets the view state of the i-th view. |
String[] |
getViewStates()
Gets the view states of the views in this panel as items in a string data array. |
Class |
getViewType()
Returns the type of the views repeated in this panel. |
void |
incrementLength()
A helper method to increment the length by 1. |
void |
insertRowAtIndex(int index)
Insert a row at the given index by inserting a row at the end of the array panel and then moving the contents of each cell upward by one cell starting at the index position. |
static Paintable |
makeDeleteRowPaintable()
Method to make the Paintable for the "delete row icon". |
static Paintable |
makeInsertRowPaintable()
Method to make the Paintable for the "insert row icon". |
Stringable |
requestObject(int i)
Applies requestObject to the i-th view
and returns the resulting Stringable. |
Object |
requestObjects()
Returns an object that is actually an array that is populated by calling requestObject for each
view. |
Stringable[] |
requestStringableArray()
Returns an array of type Stringable[] that
is populated by calling requestObject for each
view. |
void |
reset()
Resets each view to its default view state. |
void |
reset(int i)
Resets the i-th view state to its default state. |
protected void |
setAutoHalo(boolean autoHalo)
Sets whether or not each view should be wrapped in a Halo object before being inserted into the
panel. |
void |
setCommonInputProperties(InputProperties properties)
Sets the input properties of each view to the same input properties object. |
void |
setDefaultViewState(int i,
String data)
Sets the default view state of the i-th view to the given data. |
void |
setDefaultViewState(String data)
Sets the default view state of the panel using the data encoded in the given string. |
void |
setDefaultViewStates(String[] data)
Sets the default view states of the views in this panel to the corresponding strings in the data array. |
protected void |
setInitialIndex(int initialIndex)
Sets the initial index for the GUI view labels. |
void |
setInputProperties(InputProperties properties)
This method does nothing since the panel as a whole does not utilize input properties. |
void |
setInputProperties(int i,
InputProperties properties)
Applies setInputProperties to the i-th
view. |
void |
setInputPropertiesByView(InputProperties[] properties)
Sets the input properties of each view to the corresponding input properties object in the given array of properties. |
void |
setLength(int length)
Sets the number of views in this panel or, equivalently, the length of the array of views. |
void |
setLengthButtonName(String name)
Sets the text on the GUI button that sets the length of the array using the user meaningful length that is held in the corresponding GUI text field view. |
protected void |
setLengthFromGUI()
Helper method to set the length using the end user length extracted from the GUI. |
void |
setLengthOffset(int offset)
Sets the constant that should be added to the length to obtain the length measure meaningful to the end user. |
protected void |
setTableGap(int gap)
Sets the horizontal and vertical gap for TablePanel objects constructed in this panel. |
void |
setUserLength(int userLength)
Sets the number of views using the measure of length that is meaningful to the end user. |
void |
setViewState(int i,
String data)
Sets the view state of the i-th view to the given data. |
void |
setViewState(String data)
Sets the view state of the panel using the data encoded in the given string. |
void |
setViewStates(String[] data)
Sets the view states of the views in this panel to the corresponding strings in the data array. |
protected void |
setViewType(Class viewType)
Method used in the constructor to set the view type of the views in this panel. |
protected void |
setVisibleViewCount(int visibleViewCount)
Sets the number of views that should be visible in the scroll pane without needing scrolling. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int MINIMUM_LENGTH
public static final int MINIMUM_VISIBLE
public static final int MINIMUM_GAP
TablePanel objects constructed directly in
this array panel; the value is 4.
public static final Paintable insertRowPaintable
Paintable to make the "insert one row icon".
public static final Paintable deleteRowPaintable
Paintable to make the "delete one row icon".
protected Class viewType
JComponent,
implement the interface TypedView, and
have a public default constructor.
protected Class viewDataType
getDataType() of TypedView.
protected int arrayLength
protected int lengthOffset
arrayLength + lengthOffset.
protected int initialIndex
protected int visibleViewCount
protected int gap
TablePanel objects constructed directly in
this array panel.
protected boolean autoHalo
Halo to localize error highlights.
protected int viewWidth
protected int viewHeight
protected int labelWidth
protected TablePanel innerPanel
protected JPTScrollPane scrollPane
protected TablePanel controls
protected TextFieldView lengthTFV
arrayLength + lengthOffset.
protected SimpleAction incrementLength
protected SimpleAction decrementLength
protected SimpleAction setLengthFromGUI
protected Vector viewList
| Constructor Detail |
public SimpleArrayPanel(Class viewType)
The 1-parameter constructor.
For a complete discussion of contructor parameters and defaults, see the introduction to this class.
viewType - the type of view to use in this panel
public SimpleArrayPanel(Class viewType,
int initialIndex)
The 2-parameter constructor.
For a complete discussion of contructor parameters and defaults, see the introduction to this class.
viewType - the type of view to use in this panelinitialIndex - the initial index in the labels
public SimpleArrayPanel(Class viewType,
int initialIndex,
int visibleViewCount)
The 3-parameter constructor.
For a complete discussion of contructor parameters and defaults, see the introduction to this class.
viewType - the type of view to use in this panelinitialIndex - the initial index in the labelsvisibleViewCount - the number of views to show at once
public SimpleArrayPanel(Class viewType,
int initialIndex,
int visibleViewCount,
int gap)
The 4-parameter constructor.
For a complete discussion of contructor parameters and defaults, see the introduction to this class.
viewType - the type of view to use in this panelinitialIndex - the initial index in the labelsvisibleViewCount - the number of views to show at oncegap - the pixel gap between cells
public SimpleArrayPanel(Class viewType,
int initialIndex,
int visibleViewCount,
int gap,
boolean autoHalo)
The 5-parameter constructor.
For a complete discussion of contructor parameters and defaults, see the introduction to this class.
viewType - the type of view to use in this panelinitialIndex - the initial index in the labelsvisibleViewCount - the number of views to show at oncegap - the pixel gap between cellsautoHalo - whether or not to auto-halo the views| Method Detail |
public final Class getViewType()
public final Class getViewDataType()
public final TypedView getTypedView(int i)
Returns the i-th view installed in this panel.
Returns null if i is out of range.
i - the view index
public final void setViewState(int i,
String data)
Sets the view state of the i-th view to the given data.
Does nothing if i is out of range or the given data is
null.
i - the view indexdata - the desired view statepublic final String getViewState(int i)
Gets the view state of the i-th view.
Returns null if i is out of range.
i - the view index
public final void setDefaultViewState(int i,
String data)
Sets the default view state of the i-th view to the given data.
Does nothing if i is out of range or the given data is
null.
i - the view indexdata - the desired default view statepublic final String getDefaultViewState(int i)
Gets the default view state of the i-th view.
Returns null if i is out of range.
i - the view indexpublic final void reset(int i)
Resets the i-th view state to its default state.
Does nothing if i is out of range.
i - the view indexpublic final Stringable demandObject(int i)
Applies demandObject to the i-th view
and returns the resulting Stringable.
Returns null if i is out of range.
i - the view index
public final Stringable requestObject(int i)
throws CancelledException
Applies requestObject to the i-th view
and returns the resulting Stringable.
Returns null if i is out of range.
Throws CancelledException if the user
cancels when an error has been detected.
i - the view index
CancelledException
public final void setInputProperties(int i,
InputProperties properties)
Applies setInputProperties to the i-th
view.
Does nothing if i is out of range.
i - the view indexpublic final InputProperties getInputProperties(int i)
Gets the input properties of the i-th view.
Returns null if i is out of range.
i - the view indexpublic final Object getViews()
Returns an object that is actually an array with the list of views installed in the panel.
Assume, for example,
that viewType is FooView.class
and that number is the number of views in
the panel. Then the return value may be cast to an array
FooView[] and the length of this array will
be number.
The array is constructed by the following Java call that, in effect, uses reflection:
Array.newInstance(viewType, number)
This array is then populated by calls to the method
getTypedView(i).
public final Object demandObjects()
Returns an object that is actually an array that is
populated by calling demandObject for each
view.
Assume, for example,
that viewType is FooView.class,
that viewDataType is Foo.class,
and that number is the number of views in
the panel. Then the return value may be cast to an array
Foo[] and the length of this array will be
number.
The array is constructed by the following Java call that, in effect, uses reflection:
Array.newInstance(viewDataType, number)
This array is then populated by calls to the method
demandObject(i).
public final Object requestObjects()
throws CancelledException
Returns an object that is actually an array that is
populated by calling requestObject for each
view.
Assume, for example,
that viewType is FooView.class,
that viewDataType is Foo.class,
and that number is the number of views in
the panel. Then the return value may be cast to an array
Foo[] and the length of this array will be
number.
The array is constructed by the following Java call that, in effect, uses reflection:
Array.newInstance(viewDataType, number)
This array is then populated by calls to the method
requestObject(i).
Throws CancelledException if the user
cancels when an error has been detected.
CancelledExceptionpublic final TypedView[] getTypedViewArray()
Returns an array of type TypedView[] with
the views in the panel.
This method is less useful than getViews()
since the array returned cannot be directly cast to an
array of the actual viewType due to basic
restrictions on how Java constructs arrays. Therefore,
this method is only useful in so far as you wish to treat
the views simply as TypedView objects.
public final Stringable[] demandStringableArray()
Returns an array of type Stringable[] that
is populated by calling demandObject for each
view.
This method is less useful than
demandObjects()
since the array returned cannot be directly cast to an
array of the actual viewDataType due to basic
restrictions on how Java constructs arrays. Therefore,
this method is only useful in so far as you wish to treat
the objects simply as Stringable objects.
public final Stringable[] requestStringableArray()
throws CancelledException
Returns an array of type Stringable[] that
is populated by calling requestObject for each
view.
This method is less useful than
requestObjects()
since the array returned cannot be directly cast to an
array of the actual viewDataType due to basic
restrictions on how Java constructs arrays. Therefore,
this method is only useful in so far as you wish to treat
the objects simply as Stringable objects.
Throws CancelledException if the user
cancels when an error has been detected.
CancelledExceptionpublic final void setViewStates(String[] data)
Sets the view states of the views in this panel to the corresponding strings in the data array.
setViewStates in class DisplayPaneldata - the desired view state arraypublic final String[] getViewStates()
Gets the view states of the views in this panel as items in a string data array.
getViewStates in class DisplayPanelpublic final void setDefaultViewStates(String[] data)
Sets the default view states of the views in this panel to the corresponding strings in the data array.
setDefaultViewStates in class DisplayPaneldata - the desired default view state arraypublic final String[] getDefaultViewStates()
Gets the default view states of the views in this panel as items in a string data array.
getDefaultViewStates in class DisplayPanelpublic final void setCommonInputProperties(InputProperties properties)
Sets the input properties of each view to the same input properties object.
properties - the common input properties for all viewspublic final void setInputPropertiesByView(InputProperties[] properties)
Sets the input properties of each view to the corresponding input properties object in the given array of properties.
properties - the array of input properties for all viewspublic final InputProperties[] getInputPropertiesByView()
Gets the input properties object for each view and then returns this information in an array.
public final void setViewState(String data)
Sets the view state of the panel using the data encoded in the given string.
Equivalent to:
setViewStates(Strings.decode(data))
setViewState in interface DisplayablesetViewState in class DisplayPaneldata - the encoded view statepublic final String getViewState()
Gets the view state of the panel as an encoded string.
Equivalent to:
return CodecUtilities.encode(getViewStates())
getViewState in interface DisplayablegetViewState in class DisplayPanelpublic final void setDefaultViewState(String data)
Sets the default view state of the panel using the data encoded in the given string.
Equivalent to:
setDefaultViewStates(Strings.decode(data))
setDefaultViewState in interface DisplayablesetDefaultViewState in class DisplayPaneldata - the encoded default view statepublic final String getDefaultViewState()
Gets the default view state of the panel as an encoded string.
Equivalent to:
return CodecUtilities.encode(getDefaultViewStates())
getDefaultViewState in interface DisplayablegetDefaultViewState in class DisplayPanelpublic final void reset()
reset in interface Displayablereset in class DisplayPanelpublic final void setInputProperties(InputProperties properties)
This method does nothing since the panel as a whole does not utilize input properties.
Implemented trivially in case the user wants to create a
derived class that implements TypedView.
properties - ignoredpublic final InputProperties getInputProperties()
This method returns null since the panel as
a whole does not utilize input properties.
Implemented trivially in case the user wants to create a
derived class that implements TypedView.
public final int getLength()
Returns the number of views in this panel or, equivalently, the length of the array of views.
public final int getUserLength()
Returns the measure of the length of the array that is meaningful to the end user.
Equivalent to:
getLength() + getLengthOffest()
public final int getLengthOffset()
Returns the constant that should be added to the length to obtain the length measure meaningful to the end user.
public final String getLengthButtonName()
Returns the text on the GUI button that sets the length of the array using the user meaningful length that is held in the corresponding GUI text field view.
public final void setLength(int length)
Sets the number of views in this panel or, equivalently, the length of the array of views.
The actual length set will be at least 1.
This method is responsible for adding labels, views, and the "insert one row" and "delete one row" buttons if the length will be increased. To do this, this method calls:
String createLabelForRow(int i)
TypedView createViewForRow(int i)
These methods may be overridden in a derived class if the user of this class wants non-default behavior but the constraints discussed in this class must be observed.
This method is responsible for removing labels, views, and buttons if the length will be decreased.
length - the desired number of views in this panelpublic final void setUserLength(int userLength)
Sets the number of views using the measure of length that is meaningful to the end user.
userLength - the user meaningful lengthpublic final void setLengthOffset(int offset)
Sets the constant that should be added to the length to obtain the length measure meaningful to the end user.
offset - the offset used to adjust the lengthpublic final void setLengthButtonName(String name)
Sets the text on the GUI button that sets the length of the array using the user meaningful length that is held in the corresponding GUI text field view.
name - the text for the button that sets the lengthpublic final void incrementLength()
public final void decrementLength()
public final void clear()
Clear the array and reset to its initial size.
Equivalent to setLength(0).
public String createLabelForRow(int i)
Returns the label String for the i-th row.
By default, this method returns:
"" + (i + initialIndex)
May be overridden in a derived class if the designer wants to create a different label String.
i - the row indexprotected TypedView createViewForRow(int i)
Returns a new TypedView for the i-th row
whose class is given by the view type.
By default, this method returns:
(TypedView) viewType.newInstance()
In particular, this implementation does not use the index i.
May be overridden in a derived class if the designer wants to use a non-default constructor for the view.
The view returned must be assignable to the view type used to construct the array panel.
Furthermore, the view returned by this method must have the same preferred size independent of the index i.
i - the row indexprotected final void setViewType(Class viewType)
Method used in the constructor to set the view type of the views in this panel.
Performs error checks to verify the constraints that are discussed in the introduction to this class.
Extracts the model data type corresponding to the view type and determines the dimensions of a typical view.
viewType - the class of the views in this panelprotected final void setInitialIndex(int initialIndex)
Sets the initial index for the GUI view labels.
initialIndex - the initial index for the labelsprotected final void setVisibleViewCount(int visibleViewCount)
Sets the number of views that should be visible in the scroll pane without needing scrolling.
This number is used to set the minimum size of the scroll pane view port.
visibleViewCount - the number of views visible at onceprotected final void setTableGap(int gap)
Sets the horizontal and vertical gap for
TablePanel objects constructed in this panel.
gap - the standard pixel gap in tablesprotected final void setAutoHalo(boolean autoHalo)
Sets whether or not each view should be wrapped in a
Halo object before being inserted into the
panel.
autoHalo - whether or not to automatically haloprotected final void buildArrayPanel()
protected final void buildInnerPanel()
protected final void buildScrollPane()
protected final void buildControls()
protected final void setLengthFromGUI()
public final void insertRowAtIndex(int index)
Insert a row at the given index by inserting a row at the end of the array panel and then moving the contents of each cell upward by one cell starting at the index position.
Changes the contents of the cell at index to its default view state.
Does nothing unless 0 <= index <getLength().
index - the index at which to insert a rowpublic final void deleteRowAtIndex(int index)
Delete a row at the given index by moving the contents of each cell at a higher position downward by one cell and then by deleting the the cell at the end of the array.
Does nothing if the array length is 1.
Does nothing unless 0 <= index <getLength().
index - the index at which to delete a rowpublic Action getInsertRowAction(int index)
Returns an action that inserts a row at the given index.
index - the index at which to insert a rowpublic Action getDeleteRowAction(int index)
Returns an action that deletes a row at the given index.
index - the index at which to delete a rowpublic JButton getInsertRowButton(int index)
Returns a button that inserts a row at the given index.
index - the index at which to insert a rowpublic JButton getDeleteRowButton(int index)
Returns a button that deletes a row at the given index.
index - the index at which to delete a rowpublic static Paintable makeInsertRowPaintable()
Paintable for the "insert row icon".
public static Paintable makeDeleteRowPaintable()
Paintable for the "delete row icon".
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||