|
||||||||||
| 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.Annotation
A component
representing an annotation in a GUI, such as the prompt for an
input object or the caption for an image.Displayable
The functionality of this class is based on the functionality
of the class provided in the
JLabeljavax.swing package, with the following additional
functionality:
As of 2.5.0, added constructors that permit the font to be specified.
| 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 Icon |
alertIcon
Icon to be displayed when this annotation is in alert status. |
protected int |
align
Alignment of the icon relative to the text. |
static int |
DEFAULT_ALIGNMENT
Default alignment of the icon relative to the text for an annotation (icon is ABOVE the text). |
protected JLabel |
iconLabel
JLabel used to render the icon. |
protected Color |
oldBackground
Background color of this annotation before alert status was entered. |
protected Color |
oldForeground
Text foreground color of this annotation before alert status was entered. |
static String |
SET_ALERT_ICON
Bound property name for the set alert icon property. |
static String |
SET_BACKGROUND
Bound property name for the set background property. |
static String |
SET_DISABLED_ICON
Bound property name for the set disabled icon property. |
static String |
SET_FONT
Bound property name for the set font property. |
static String |
SET_FOREGROUND
Bound property name for the set foreground property. |
static String |
SET_ICON
Bound property name for the set icon property. |
static String |
SET_OPAQUE
Bound property name for the set opaque property. |
static String |
SET_TEXT
Bound property name for the set text property. |
protected JTextArea |
textLabel
JTextArea used to render the text. |
| 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 | |
Annotation()
Constructs an annotation with no icon or text. |
|
Annotation(Icon icon)
Constructs an annotation displaying the given icon. |
|
Annotation(String text)
Constructs an annotation displaying the given text. |
|
Annotation(String text,
Font font)
Constructs an annotation displaying the given text using the given font. |
|
Annotation(String text,
Icon icon,
int alignment)
Constructor for an annotation displaying the given text and icon. |
|
Annotation(String text,
Icon icon,
int alignment,
Font font)
Constructor for an annotation displaying the given text and icon using the given font. |
|
| Method Summary | |
void |
dataMalformed(MalformedDataEvent evt)
Handles a malformed data event generated by a fragile input component by alerting the user through changes to the background and foreground colors of the annotation. |
void |
endAlert(AlertEvent evt)
Turns off alert status for this component. |
Icon |
getAlertIcon()
Returns the icon to be displayed when this annotation is put in an alert state, or null if it has not been set. |
int |
getAlignment()
Returns the alignment of the icon relative to the text. |
static Font |
getDefaultFont()
Returns the default font for a JLabel. |
Icon |
getDisabledIcon()
Returns the icon to be displayed when this annotation is disabled, if it has been set through use of the
method, or null if it has not been set. |
Icon |
getIcon()
Returns the icon displayed by this annotation, or null if it has not been set. |
String |
getText()
Returns the text displayed by this annotation. |
static Annotation |
makeAnnotation(String text,
Object object,
int alignment)
Returns an Annotation using the given
string, object, and alignment;
the object is converted to an Icon using
ComponentFactory.makeIcon. |
static Annotation |
makeAnnotation(String text,
Object object,
int alignment,
Font font)
Returns an Annotation using the given
string, object, alignment, and font;
the object is converted to an Icon using
ComponentFactory.makeIcon. |
void |
setAlertIcon(Icon icon)
Sets the icon to be displayed when this annotation is in an alert state. |
void |
setAlignment(int alignment)
Sets the alignment of the icon relative to the text using one of the constants ABOVE, BELOW, LEFT, RIGHT, or DEFAULT. |
void |
setBackground(Color background)
Sets the background color for the annotation to the given color. |
void |
setDisabledIcon(Icon icon)
Sets the icon to be displayed when this annotation is disabled. |
void |
setFont(Font font)
Sets the font used to render the text to the given font. |
void |
setForeground(Color foreground)
Sets the foreground color for the annotation to the given color. |
void |
setIcon(Icon icon)
Sets the icon displayed by this annotation to the given icon. |
void |
setOpaque(boolean opaque)
Sets the opaque state for the annotation. |
void |
setText(String text)
Sets the text displayed by this annotation to the given text. |
void |
startAlert(AlertEvent evt)
Turns on alert status for this component. |
| 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 String SET_TEXT
public static final String SET_ICON
public static final String SET_DISABLED_ICON
public static final String SET_ALERT_ICON
public static final String SET_FONT
public static final String SET_FOREGROUND
public static final String SET_BACKGROUND
public static final String SET_OPAQUE
public static final int DEFAULT_ALIGNMENT
protected Color oldForeground
protected Color oldBackground
protected JLabel iconLabel
JLabel used to render the icon.
protected JTextArea textLabel
JTextArea used to render the text.
protected int align
protected Icon alertIcon
null,
when this annotation is in alert status,
the currently displayed icon is not changed.
| Constructor Detail |
public Annotation()
public Annotation(String text)
text - the text to be displayed
public Annotation(String text,
Font font)
text - the text to be displayedfont - the font to use throughout the annotationpublic Annotation(Icon icon)
icon - the icon to be displayed
public Annotation(String text,
Icon icon,
int alignment)
text - the text to be displayedicon - the icon to be displayedalignment - the alignment of the icon relative to text
public Annotation(String text,
Icon icon,
int alignment,
Font font)
text - the text to be displayedicon - the icon to be displayedalignment - the alignment of the icon relative to textfont - the font to use throughout the annotation| Method Detail |
public static Annotation makeAnnotation(String text,
Object object,
int alignment)
Returns an Annotation using the given
string, object, and alignment;
the object is converted to an Icon using
ComponentFactory.makeIcon.
text - the text to be displayedobject - the object to convert into an iconalignment - the alignment of the icon relative to text
public static Annotation makeAnnotation(String text,
Object object,
int alignment,
Font font)
Returns an Annotation using the given
string, object, alignment, and font;
the object is converted to an Icon using
ComponentFactory.makeIcon.
text - the text to be displayedobject - the object to convert into an iconalignment - the alignment of the icon relative to textfont - the font to use throughout the annotationpublic void dataMalformed(MalformedDataEvent evt)
dataMalformed in interface MalformedDataListenerdataMalformed in class DisplayPanelevt - the malformed data eventMalformedDataListenerpublic void startAlert(AlertEvent evt)
startAlert in interface AlertListenerstartAlert in class DisplayPanelevt - the alert eventAlertListenerpublic void endAlert(AlertEvent evt)
endAlert in interface AlertListenerendAlert in class DisplayPanelevt - the alert eventAlertListenerpublic void setAlignment(int alignment)
Sets the alignment of the icon relative to the text using one of the constants ABOVE, BELOW, LEFT, RIGHT, or DEFAULT.
If the alignment value is not valid, the alignment is not changed.
Fires property change: ALIGNMENT.
alignment - the new alignment of the icon relative
to the textJPTConstants.ABOVE,
JPTConstants.BELOW,
SwingConstants.LEFT,
SwingConstants.RIGHT,
JPTConstants.DEFAULTpublic int getAlignment()
JPTConstants.ABOVE,
JPTConstants.BELOW,
SwingConstants.LEFT,
SwingConstants.RIGHTpublic void setOpaque(boolean opaque)
Sets the opaque state for the annotation.
The default opaque state is false which is
the default for a JLabel.
Fires property change: SET_OPAQUE.
opaque - the opaque state (true or false)public void setForeground(Color foreground)
Sets the foreground color for the annotation to the given color.
If the given color is null,
the foreground color is not changed.
Fires property change: SET_FOREGROUND.
foreground - the desired foreground colorpublic void setBackground(Color background)
Sets the background color for the annotation to the given color.
If the given color is null,
the background color is not changed.
Fires property change: SET_BACKGROUND.
background - the desired background colorpublic void setFont(Font font)
Sets the font used to render the text to the given font.
If the given font is null then it is set to
getDefaultFont().
Fires property change: SET_FONT.
font - the font for this componentpublic static Font getDefaultFont()
public void setText(String text)
Sets the text displayed by this annotation to the given text.
If the given text is null,
no text will be displayed by this annotation.
Fires property change: SET_TEXT.
text - the text to be displayedpublic String getText()
Returns the text displayed by this annotation.
public void setIcon(Icon icon)
Sets the icon displayed by this annotation to the given icon.
If the given icon is null,
no icon will be displayed by this annotation.
Fires property change: SET_ICON.
icon - the icon to be displayedpublic Icon getIcon()
null if it has not been set.
public void setDisabledIcon(Icon icon)
Sets the icon to be displayed when this annotation is disabled.
If the disabled icon is null,
and the value of the icon property is an ImageIcon,
a "grayed out" version of the icon is computed and displayed
when the annotation is disabled.
The default value of this property is null.
Fires property change: SET_DISABLED_ICON.
icon - the icon to be displayed
when this component is disabledpublic Icon getDisabledIcon()
Returns the icon to be displayed
when this annotation is disabled,
if it has been set through use of the
method, or setDisabledIconnull if it has not been set.
If the disabled icon is null,
and the value of the icon property is an ImageIcon,
a "grayed out" version of the icon is computed and displayed
when the annotation is disabled.
public void setAlertIcon(Icon icon)
Sets the icon to be displayed when this annotation is in an alert state.
If the given icon is null,
the currently displayed icon will not be changed
when the annotation is in an alert state.
The default value of this property is null.
Fires property change: SET_ALERT_ICON.
icon - the icon to be displayed
when this annotation is in alert statuspublic Icon getAlertIcon()
Returns the icon to be displayed
when this annotation is put in an alert state,
or null if it has not been set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||