|
||||||||||
| 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.StringViewer
Class StringViewer provides static
tools for viewing a String in a GUI.
As of 2.6.0e, this class can also instantiate
a StringViewer object that may be
embedded in a GUI and manipulated by the caller.
A StringViewer object embeds a
TextAreaView which is placed in a
JPTScrollPane which is placed in
this object viewed as a DisplayPanel.
The caller can control the preferred size of the viewport in the scroll pane via the width and height parameters to the constructor. If these parameters are omitted, the width defaults to 800 and the height to 600. The minimum width and height is forced to be 100.
As of 2.6.0f, this class implements
TypedView by delegating method calls
to an internal TextAreaView. The goal
is to permit this class to integrate with other JPT
tools.
In effect, StringViewer now enables
the creation of a text area in a scroll pane whose
viewport size is controlled. This enables the use
of a TypedView for multi-line text in
a context where the screen real estate in the GUI
will be predictable.
Upon further reflection, we decided that it would
be helpful to implement GeneralView in
addition to TypedView so those methods
were added in 2.6.0g.
This class does not implement action listeners
because they are not supported by the underlying
JTextArea class. This class also
does not implement property change listeners.
| 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 GeneralViewSupport |
delegate
The GeneralViewSupport object. |
static String |
FONTNAME
The default monospaced font name. |
static int |
H_ALWAYS
The horizontal scroll bar policy of ALWAYS. |
static int |
HEIGHT
The default scroll pane viewport height = 600. |
static int |
MINIMUM
The minimum width and height = 100. |
protected JPTScrollPane |
scrollpane
The internal JPTScrollPane. |
private static Font |
staticFont
The display font for the static calls which uses the default font name, the default font size, and BOLD as the style. |
private static int |
staticFontSize
The default font size. |
protected TextAreaView |
textarea
The internal TextAreaView. |
static int |
V_ALWAYS
The vertical scroll bar policy of ALWAYS. |
static int |
WIDTH
The default scroll pane viewport width = 800. |
| 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.TypedView |
DATA_TYPE |
| 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, PROPERTIES, SOMEBITS |
| Constructor Summary | |
StringViewer()
The default constructor that uses empty initial text, a width of 800, a height of 600, and the default static font. |
|
StringViewer(Font font)
The constructor that uses empty initial text, a width of 800, a height of 600, and the given font. |
|
StringViewer(int width,
int height)
The constructor that uses empty initial text, the given width and height, and the default static font. |
|
StringViewer(int width,
int height,
Font font)
The constructor that uses empty initial text, the given width and height, and the given font. |
|
StringViewer(String text)
The default constructor that uses the given initial text, a width of 800, a height of 600, and the default static font. |
|
StringViewer(String text,
Font font)
The constructor that uses the given initial text, a width of 800, a height of 600, and the given font. |
|
StringViewer(String text,
int width,
int height)
The constructor that uses the given initial text, the given width and height, and the default static font. |
|
StringViewer(String text,
int width,
int height,
Font font)
The constructor that uses the given initial text, the given width and height, and the given font. |
|
| Method Summary | |
void |
addActionListener(ActionListener listener)
This method is required by the GeneralView
interface but the implementation does nothing since
the underlying JTextArea does not fire
action events. |
void |
addMalformedDataListener(MalformedDataListener l)
Registers the given MalformedDataListener
to receive MalformedDataEvents
when the view state data is found to be malformed and
when the view state data is returned to a well-formed
value. |
void |
append(String text)
Append the given text in the text area. |
void |
appendWithNewline(String text)
Append the given text in the text area and then append a newline. |
Stringable |
demandObject()
Returns a Stringable object based on the view state
of the view using the mandatory model. |
Stringable |
demandObject(Class dataType,
StringableFilter filter)
Returns a Stringable object based on the view state
of the view, the temporary data type and filter, and the mandatory
model. |
Stringable |
demandObject(StringableFilter filter)
Returns a Stringable object based on the view state
of the view, the temporary filter, and the mandatory model. |
Class |
getDataType()
Returns the current class of objects returned when a model object is demanded or requested. |
static Font |
getDefaultFont()
Returns the current default static font. |
String |
getDefaultViewState()
Returns a String representation of the default view
state for this object. |
StringableFilter |
getFilter()
Returns the current filter used by this view. |
InputProperties |
getInputProperties()
Returns the input properties for this view. |
JPTScrollPane |
getScrollPane()
Returns the internal JPTScrollPane. |
String |
getText()
Returns the text in the text area. |
TextAreaView |
getTextArea()
Returns the internal TextAreaView. |
int |
getTextLength()
Returns the length of the text in the text area. |
String |
getViewState()
Equivalent to getText. |
protected void |
initialize(String text,
int width,
int height,
Font font)
The common constructor initialization code. |
void |
insert(int position,
String text)
Insert the given text in the text area at the given position. |
void |
insert(String text,
int position)
Insert the given text in the text area at the given position. |
GeneralView |
makeCopy()
Returns a copy of this GeneralView. |
static JPTScrollPane |
makeScrollView(String string)
Wraps the given String in a
TextAreaView object; then wraps
the text area in a JPTScrollPane
object whose viewport is bounded by
800-by-600;
this scroll pane is returned. |
static JPTScrollPane |
makeScrollView(String string,
int width,
int height)
Wraps the given String in a
TextAreaView object; then wraps
the text area in a JPTScrollPane
object whose viewport is bounded by
the given width and height;
this scroll pane is returned. |
void |
removeActionListener(ActionListener listener)
This method is required by the GeneralView
interface but the implementation does nothing since
the underlying JTextArea does not fire
action events. |
void |
removeMalformedDataListener(MalformedDataListener l)
De-registers the given MalformedDataListener
from receiving MalformedDataEvents
when the view state data is found to be malformed and
when the view state data is returned to a well-formed
value. |
Stringable |
requestObject()
Returns a Stringable object based on the view state
of the view using the optional model; throws an exception if the
input operation is cancelled by the user. |
Stringable |
requestObject(Class dataType,
StringableFilter filter)
Returns a Stringable object based on the view state
of the view, the temporary data type and filter, and the optional
model. |
Stringable |
requestObject(StringableFilter filter)
Returns a Stringable object based on the view state
of the view, the temporary filter, and the optional model. |
void |
reset()
Resets the view state of this object to the default view state for this object. |
void |
setDataType(Class dataType)
Sets the current class of objects returned when a model object is demanded or requested. |
static void |
setDefaultFont(Font newfont)
Sets the default static font. |
void |
setDefaultViewState(String data)
Sets the default view state for this object to the data state represented by the given String data. |
void |
setErrorPromptTitleSuggestion(String errorPrompt,
String dialogTitle,
String suggestion)
Sets the three input property Strings for an error
dialog in a single method. |
void |
setFilter(StringableFilter filter)
Sets the current filter used by the view to the given StringableFilter. |
void |
setInputProperties(InputProperties properties)
Sets the input properties for this view to the provided input properties. |
void |
setText(String text)
Sets the text in the text area. |
void |
setTextWithNewline(String text)
Sets the text in the text area and adds a newline. |
void |
setViewState(String data)
Equivalent to setText. |
static void |
showStringInDialog(String string)
Shows the given string in an OK dialog that contains a scroll pane bounded by 800-by-600. |
static void |
showStringInDialog(String string,
int width,
int height)
Shows the given string in an OK dialog that contains a scroll pane bounded by the given width and height. |
static void |
showStringInFrame(String string)
Shows the given string in a frame that contains a scroll pane whose viewport is bounded by 800-by-600. |
static void |
showStringInFrame(String string,
int width,
int height)
Shows the given string in a frame that contains a scroll pane whose viewport is bounded by the given width and height. |
| 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 |
| Methods inherited from interface edu.neu.ccs.gui.Displayable |
setEnabled |
| Field Detail |
public static final int WIDTH
public static final int HEIGHT
public static final int MINIMUM
public static final int V_ALWAYS
public static final int H_ALWAYS
public static final String FONTNAME
private static int staticFontSize
The default font size.
14 + (int) LookAndFeelTools.getNetFontSizeAdjustment()
private static Font staticFont
The display font for the static calls which uses the default font name, the default font size, and BOLD as the style.
This data is intentionally not final so it may be
changed by the method setDefaultFont.
As of 2.6.0e, this font is also the default font
for StringViewer objects if no font is
provided in a constructor.
protected TextAreaView textarea
TextAreaView.
protected JPTScrollPane scrollpane
JPTScrollPane.
protected GeneralViewSupport delegate
| Constructor Detail |
public StringViewer()
The default constructor that uses empty initial text, a width of 800, a height of 600, and the default static font.
public StringViewer(int width,
int height)
The constructor that uses empty initial text, the given width and height, and the default static font.
width - the viewport widthheight - the viewport heightpublic StringViewer(Font font)
The constructor that uses empty initial text, a width of 800, a height of 600, and the given font.
font - the font for the text area
public StringViewer(int width,
int height,
Font font)
The constructor that uses empty initial text, the given width and height, and the given font.
width - the viewport widthheight - the viewport heightfont - the font for the text areapublic StringViewer(String text)
The default constructor that uses the given initial text, a width of 800, a height of 600, and the default static font.
text - the initial text
public StringViewer(String text,
int width,
int height)
The constructor that uses the given initial text, the given width and height, and the default static font.
text - the initial textwidth - the viewport widthheight - the viewport height
public StringViewer(String text,
Font font)
The constructor that uses the given initial text, a width of 800, a height of 600, and the given font.
text - the initial textfont - the font for the text area
public StringViewer(String text,
int width,
int height,
Font font)
The constructor that uses the given initial text, the given width and height, and the given font.
text - the initial textwidth - the viewport widthheight - the viewport heightfont - the font for the text area| Method Detail |
protected void initialize(String text,
int width,
int height,
Font font)
public TextAreaView getTextArea()
Returns the internal TextAreaView.
public JPTScrollPane getScrollPane()
Returns the internal JPTScrollPane.
public String getText()
Returns the text in the text area.
public int getTextLength()
Returns the length of the text in the text area.
public void setText(String text)
Sets the text in the text area.
If the given text is null,
clears the text area.
text - the text to setpublic void setTextWithNewline(String text)
Sets the text in the text area and adds a newline.
If the given text is null,
sets the text to a newline.
text - the text to setpublic void append(String text)
Append the given text in the text area.
If the given text is null,
then does nothing.
text - the text to setpublic void appendWithNewline(String text)
Append the given text in the text area and then append a newline.
If the given text is null,
then append a newline.
text - the text to set
public void insert(String text,
int position)
Insert the given text in the text area at the given position.
If the given text is null,
then does nothing.
If the insert position is not between
0 and getTextLength(),
then inserts at the nearest valid position.
text - the text to setposition - the insert position
public void insert(int position,
String text)
Insert the given text in the text area at the given position.
Calls:
insert(text, position)
position - the insert positiontext - the text to setpublic void setViewState(String data)
setText.
setViewState in interface DisplayablesetViewState in class DisplayPaneldata - the encoded String datapublic String getViewState()
getText.
getViewState in interface DisplayablegetViewState in class DisplayPanelpublic void setDefaultViewState(String data)
DisplayableString data.
setDefaultViewState in interface DisplayablesetDefaultViewState in class DisplayPaneldata - the encoded default String datapublic String getDefaultViewState()
DisplayableString representation of the default view
state for this object.
getDefaultViewState in interface DisplayablegetDefaultViewState in class DisplayPanelpublic void reset()
DisplayableResets the view state of this object to the default view state for this object.
Equivalent to: setViewState(getDefaultViewState()).
reset in interface Displayablereset in class DisplayPanelpublic GeneralView makeCopy()
GeneralViewReturns a copy of this GeneralView.
The purpose of this method is to provide a copy of the view
that may be used in error handling dialogs. The copy should,
as far as possible, have the same screen size and internal
settings. Each GeneralView should describe what
its makeCopy method actually does.
The copy should NOT share its internal document model with the original view. This will allow the copy to operate in an independent fashion from the original.
makeCopy in interface GeneralViewpublic void setDataType(Class dataType)
GeneralView
setDataType in interface GeneralViewdataType - the new class of objects for model objectspublic Class getDataType()
TypedView
getDataType in interface TypedViewpublic void setFilter(StringableFilter filter)
GeneralView
setFilter in interface GeneralViewfilter - the filter to be usedpublic StringableFilter getFilter()
GeneralView
getFilter in interface GeneralViewpublic Stringable demandObject()
TypedViewStringable object based on the view state
of the view using the mandatory model.
demandObject in interface TypedViewStringable model objectTypedView.requestObject()
public Stringable requestObject()
throws CancelledException
TypedViewStringable object based on the view state
of the view using the optional model; throws an exception if the
input operation is cancelled by the user.
requestObject in interface TypedViewStringable model object
CancelledExceptionTypedView.demandObject()public Stringable demandObject(StringableFilter filter)
GeneralViewStringable object based on the view state
of the view, the temporary filter, and the mandatory model.
demandObject in interface GeneralViewfilter - the temporary filter to use
Stringable model objectTypedView.demandObject(),
GeneralView.requestObject(Class, StringableFilter)
public Stringable requestObject(StringableFilter filter)
throws CancelledException
GeneralViewStringable object based on the view state
of the view, the temporary filter, and the optional model.
requestObject in interface GeneralViewfilter - the temporary filter to use
Stringable model object
CancelledExceptionTypedView.requestObject(),
GeneralView.demandObject(Class, StringableFilter)
public Stringable demandObject(Class dataType,
StringableFilter filter)
GeneralViewStringable object based on the view state
of the view, the temporary data type and filter, and the mandatory
model.
demandObject in interface GeneralViewStringable model objectTypedView.demandObject(),
GeneralView.requestObject(Class, StringableFilter)
public Stringable requestObject(Class dataType,
StringableFilter filter)
throws CancelledException
GeneralViewStringable object based on the view state
of the view, the temporary data type and filter, and the optional
model.
requestObject in interface GeneralViewStringable model object
CancelledExceptionTypedView.requestObject(),
GeneralView.demandObject(Class, StringableFilter)public void setInputProperties(InputProperties properties)
TypedViewSets the input properties for this view to the provided input properties.
If the given input properties list is null, the
property list for this view is set to the base property list
containing default property values.
setInputProperties in interface TypedViewproperties - the new input properties for the viewTypedView.getInputProperties()public InputProperties getInputProperties()
TypedView
getInputProperties in interface TypedViewTypedView.setInputProperties(InputProperties)
public void setErrorPromptTitleSuggestion(String errorPrompt,
String dialogTitle,
String suggestion)
GeneralViewStrings for an error
dialog in a single method.
setErrorPromptTitleSuggestion in interface GeneralViewerrorPrompt - the error prompt of an error dialogdialogTitle - the dialog title of an error dialogsuggestion - the suggestion for an error dialogpublic void addMalformedDataListener(MalformedDataListener l)
FragileMalformedDataListener
to receive MalformedDataEvents
when the view state data is found to be malformed and
when the view state data is returned to a well-formed
value.
addMalformedDataListener in interface Fragilel - the listener to registerFragile.removeMalformedDataListener(MalformedDataListener)public void removeMalformedDataListener(MalformedDataListener l)
FragileMalformedDataListener
from receiving MalformedDataEvents
when the view state data is found to be malformed and
when the view state data is returned to a well-formed
value.
removeMalformedDataListener in interface Fragilel - the listener to de-registerFragile.addMalformedDataListener(MalformedDataListener)public void addActionListener(ActionListener listener)
GeneralView
interface but the implementation does nothing since
the underlying JTextArea does not fire
action events.
addActionListener in interface GeneralViewlistener - the ActionListener that is to be notifiedGeneralView.removeActionListener(ActionListener)public void removeActionListener(ActionListener listener)
GeneralView
interface but the implementation does nothing since
the underlying JTextArea does not fire
action events.
removeActionListener in interface GeneralViewlistener - the ActionListener to removeGeneralView.addActionListener(ActionListener)
public static JPTScrollPane makeScrollView(String string,
int width,
int height)
Wraps the given String in a
TextAreaView object; then wraps
the text area in a JPTScrollPane
object whose viewport is bounded by
the given width and height;
this scroll pane is returned.
If the given string is null,
the scroll pane will show an error message.
The width and height are forced to be at
least the value of MINIMUM = 100.
string - the string to viewwidth - the viewport width boundheight - the viewport height boundpublic static JPTScrollPane makeScrollView(String string)
Wraps the given String in a
TextAreaView object; then wraps
the text area in a JPTScrollPane
object whose viewport is bounded by
800-by-600;
this scroll pane is returned.
If the given string is null,
the scroll pane will show an error message.
string - the string to view
public static void showStringInFrame(String string,
int width,
int height)
Shows the given string in a frame that contains a scroll pane whose viewport is bounded by the given width and height.
If the given string is null,
the frame will show an error message.
string - the string to viewwidth - the viewport width boundheight - the viewport height boundpublic static void showStringInFrame(String string)
Shows the given string in a frame that contains a scroll pane whose viewport is bounded by 800-by-600.
If the given string is null,
the frame will show an error message.
string - the string to view
public static void showStringInDialog(String string,
int width,
int height)
Shows the given string in an OK dialog that contains a scroll pane bounded by the given width and height.
If the given string is null, the
dialog will show an error message.
string - the string to viewwidth - the viewport width boundheight - the viewport height boundpublic static void showStringInDialog(String string)
Shows the given string in an OK dialog that contains a scroll pane bounded by 800-by-600.
If the given string is null, the
dialog will show an error message.
string - the string to viewpublic static Font getDefaultFont()
public static void setDefaultFont(Font newfont)
Sets the default static font.
Does nothing if newfont is null.
newfont - the new default static font
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||