|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Label | +--edu.hws.jcm.awt.DisplayLabel
A DisplayLabel is a label that can display numbers embedded in strings. The text for the label can include '#' characters, which are substituted by values of specified Value objects. (A doubled ## is interpreted as a single literal # to be displayed rather than substituted.) You should provide as many Values as there are #'s in the text. However, no errors are generated if this is not the case. Extra expressions are ignored; extra #'s are shown as "undefined" in the display. In fact, DisplayLabels do not ever generat JCMErrors. Note that Value objects include objects of type Constant, Variable, and Expression, for example. Value is just an interface defined in package edu.hws.jcm.data.
The values displayed in a DisplayLabel are recomputed when the Label's compute() method is called. Usually, this is done by a Controller that the DisplayLabel is registered with. See the Controller class for more information.
Inner classes inherited from class java.awt.Label |
java.awt.Label.AccessibleAWTLabel |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
protected int |
numSize
Desired maximum number of characters in displayed numbers. |
protected java.lang.String |
text
Unsubstituted text for display. |
protected Value[] |
values
Value objects whose values will be substituted for #'s in text. |
Fields inherited from class java.awt.Label |
CENTER, LEFT, RIGHT |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
DisplayLabel()
Create a label with no expressions set up to display a single number. |
|
DisplayLabel(java.lang.String text,
Value val)
Convenience method for making a DisplayLabel with just one value to display. |
|
DisplayLabel(java.lang.String text,
Value[] vals)
Create a DisplayLabel to display one or more values. |
Method Summary | |
void |
compute()
The compute method recalculates the displayed Values and changes the text of the label to show the new values. |
java.lang.String |
getBaseText()
Return the basic text, including the #'s where Values are inserted in the displayed text. |
int |
getNumSize()
Return the desired maximum number of characters in displayed numbers. |
java.awt.Dimension |
getPreferredSize()
Return the preferred size of this DisplayLabel. |
Value[] |
getValues()
Get the array of Value objects whose values are displayed in this DisplayLabel. |
void |
setNumSize(int size)
Set the desired maximum number of characters in displayed numbers. |
void |
setText(java.lang.String text)
Set text for display -- text should include as many (single) #'s as there are values to display. |
void |
setValue(Value val)
A convenience method that can be used when the display string contains just a single #. |
void |
setValues(Value[] vals)
Set the array of Value objects whose values are displayed in this DisplayLabel, and change the display to show the new values. |
Methods inherited from class java.awt.Label |
addNotify, getAccessibleContext, getAlignment, getText, paramString, setAlignment |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String text
protected int numSize
protected Value[] values
Constructor Detail |
public DisplayLabel()
public DisplayLabel(java.lang.String text, Value val)
text
- Text to display. It shoud contain a single '#', which will be substituted by the value.val
- a Value object whose value is substituted for the # in the text.public DisplayLabel(java.lang.String text, Value[] vals)
text
- The text to display. If this is null, it is set to "#".vals
- The Value object(s) whose values are substituted for #'s in the text. If this is null,
the values shoud be set later by calling the setValues() method.Method Detail |
public void compute()
compute
in interface Computable
public Value[] getValues()
public void setValue(Value val)
public void setValues(Value[] vals)
public void setNumSize(int size)
public int getNumSize()
public java.lang.String getBaseText()
public void setText(java.lang.String text)
setText
in class java.awt.Label
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class java.awt.Component
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |