

Public Member Functions | |
| DisplayPanel (final ReadOnlyCalculatorApplet applet) | |
| The constructor takes a ReadOnlyCalculatorApplet so that it has an interface to the CalculatorApplet object. | |
| void | setUp () |
| Set up the panel. | |
| void | paintComponent (java.awt.Graphics graphics) |
| This probably does nothing. | |
| void | left () |
| Used by CalculatorApplet in response to a LeftButton Action to ask the EntryLabel to move the caret on place left. | |
| void | right () |
| Used by CalculatorApplet in response to a RightButton Action to ask the EntryLabel to move the caret on place right. | |
| void | update (boolean entry, boolean extra) |
| Updates the panel. | |
| javax.swing.Action | backward () |
| This was designed to collect an Action so we could move the Caret from within the CalculatorApplet, but I couldn’t get it to work so used left() instead. | |
| void | setExpression (Parser parser) |
| Set the current expression. | |
| void | newExpression () |
| Sets a new expression in EntryLabel. | |
| void | clear (Parser parser) |
| Clears the current expression and the Parser. | |
| void | delete (Parser parser) |
| Deletes the PObject at the current Caret position. | |
| void | insert (PObject p, Parser parser) |
| Inserts a PObject at the current Caret position. | |
| void | setOn (boolean value) |
| Set state (on/off). | |
| boolean | getOn () |
| Get state (on/off). | |
| void | setValue () |
| Set the diplayLabel value to match the OObject in the applet. | |
| ReadOnlyCalculatorApplet | getApplet () |
| Get an interface for the CalculatorApplet object. | |
| final DisplayLabel | getDisplayLabel () |
| Udes by CalculatorApplet to get DisplayLabel. | |
| void | setCaretToEntry () |
| Set Caret to entry. | |
| void | setCaretToDisplay () |
| Set Caret to display. | |
| boolean | hasCaret (final ScrollableLabel scrollableLabel) |
| Find if scrollableLabel has the Caret. | |
| boolean | displayLabelHasCaret () |
| Find if displayLabel has the Caret. | |
Package Functions | |
| final boolean | displayLabelScrollable () |
| Find if it is possible to scroll within the display label. | |
Private Attributes | |
| ScrollableLabel | labelWithCaret |
| EntryLabel | entryLabel |
| The entry label: shows what you’ve typed. | |
| DisplayLabel | displayLabel |
| The display label: shows results of calculations. | |
| ExtraPanel | extraPanel |
| The panel that shows calculator state: shift, Stat mode, degrees or radians, Base and the like. | |
| MiniPanel | leftPanel |
| Panel to show left movement of display is possible. | |
| MiniPanel | rightPanel |
| Panel to show right movement of display is possible. | |
| final ReadOnlyCalculatorApplet | applet |
| Interface to the CalculatorApplet object that allows us to read values but not to change their state. | |
| boolean | on |
| State of calculator on or off. | |
Static Private Attributes | |
| static final long | serialVersionUID = 1L |
When a particular CalculatorPanel is made current by CalculatorApplet.setDisplayPanel() through CalculatorPanel.setDisplayPanel() the instance of this class is attached to the the CalculatorPanel. I’m not sure if this is handled entirely correctly yet because the DisplayPanel has actually been added to more than one CalculatorPanel, which I think swing doesn’t permit. However, it works provided we reattach it.
| jscicalc.DisplayPanel.DisplayPanel | ( | final ReadOnlyCalculatorApplet | applet | ) |
The constructor takes a ReadOnlyCalculatorApplet so that it has an interface to the CalculatorApplet object.
It doesn’t need to can modify the CalculatorApplet object and so it doesn’t need access to all members. Forby, despite its general moralistic tendencies, Java doesn’t let you specify that an object is const.
| applet | The CalculatorApplet object (accessed through a read-only interface) |
References jscicalc.DisplayPanel.displayLabel, jscicalc.DisplayPanel.entryLabel, jscicalc.DisplayPanel.extraPanel, jscicalc.DisplayPanel.leftPanel, jscicalc.DisplayPanel.rightPanel, and jscicalc.DisplayPanel.setCaretToEntry().
| void jscicalc.DisplayPanel.setUp | ( | ) |
Set up the panel.
Everything is kept in place by a SpringLayout.
References jscicalc.ReadOnlyCalculatorApplet.buttonWidth(), jscicalc.ReadOnlyCalculatorApplet.displayHeight(), jscicalc.DisplayPanel.displayLabel, jscicalc.DisplayPanel.entryLabel, jscicalc.DisplayPanel.extraPanel, jscicalc.ReadOnlyCalculatorApplet.extraTextSize(), jscicalc.DisplayPanel.getApplet(), jscicalc.DisplayPanel.leftPanel, jscicalc.ReadOnlyCalculatorApplet.minSize(), jscicalc.DisplayPanel.rightPanel, and jscicalc.ReadOnlyCalculatorApplet.strutSize().
Referenced by jscicalc.CalculatorApplet.setPanels().
| void jscicalc.DisplayPanel.paintComponent | ( | java.awt.Graphics | graphics | ) |
This probably does nothing.
I’m not quite sure I've got this right. I'm trying to make sure the background is always white: probably even that should be replaced by a specified colour stored in CalculatorApplet.
| graphics | The graphics context required. |
| void jscicalc.DisplayPanel.left | ( | ) |
Used by CalculatorApplet in response to a LeftButton Action to ask the EntryLabel to move the caret on place left.
It’s important CalculatorApplet controls this as it’s the only thing that can read the Parser and so know whether the caret can move left.
References jscicalc.DisplayPanel.labelWithCaret, and jscicalc.ScrollableLabel.left().
Referenced by jscicalc.CalculatorApplet.left().
| void jscicalc.DisplayPanel.right | ( | ) |
Used by CalculatorApplet in response to a RightButton Action to ask the EntryLabel to move the caret on place right.
It’s important CalculatorApplet controls this as it’s the only thing that can read the Parser and so know whether the caret can move right.
References jscicalc.DisplayPanel.labelWithCaret, and jscicalc.ScrollableLabel.right().
Referenced by jscicalc.CalculatorApplet.right().
| void jscicalc.DisplayPanel.update | ( | boolean | entry, | |
| boolean | extra | |||
| ) |
Updates the panel.
The second parameter is not used but in principle could let us update only the EntryPanel and not the ExtraPanel. We sometimes don’t want to update the EntryPanel immediately. For example, when we evaluate an expression, we clear the expression in the parser but wait until we start typing a new expression before updating the EntryPanel.
| entry | Should we update EntryPanel? | |
| extra | Should we update ExtraPanel? (ignored anyway) |
References jscicalc.BOTH, jscicalc.DisplayPanel.displayLabel, jscicalc.DisplayPanel.displayLabelHasCaret(), jscicalc.DisplayPanel.entryLabel, jscicalc.DisplayPanel.extraPanel, jscicalc.DisplayLabel.getScrollDirections(), jscicalc.LEFT, jscicalc.DisplayPanel.leftPanel, jscicalc.NEITHER, jscicalc.DisplayPanel.on, jscicalc.RIGHT, jscicalc.DisplayPanel.rightPanel, jscicalc.MiniPanel.setIlluminated(), jscicalc.DisplayLabel.update(), and jscicalc.EntryLabel.update().
Referenced by jscicalc.CalculatorApplet.updateDisplay().
| final boolean jscicalc.DisplayPanel.displayLabelScrollable | ( | ) | [package] |
Find if it is possible to scroll within the display label.
References jscicalc.DisplayPanel.displayLabel, and jscicalc.DisplayLabel.getScrollDirections().
Referenced by jscicalc.CalculatorApplet.downHistory().
| javax.swing.Action jscicalc.DisplayPanel.backward | ( | ) |
This was designed to collect an Action so we could move the Caret from within the CalculatorApplet, but I couldn’t get it to work so used left() instead.
References jscicalc.EntryLabel.backward(), and jscicalc.DisplayPanel.entryLabel.
Referenced by jscicalc.CalculatorApplet.backward().
| void jscicalc.DisplayPanel.setExpression | ( | Parser | parser | ) |
Set the current expression.
We pass a Parser because this class shouldn’t access the Parser object directly.
| parser | The Parser, which contains the expression |
References jscicalc.DisplayPanel.entryLabel, and jscicalc.EntryLabel.setExpression().
Referenced by jscicalc.CalculatorApplet.clear(), jscicalc.CalculatorApplet.downHistory(), and jscicalc.CalculatorApplet.upHistory().
| void jscicalc.DisplayPanel.newExpression | ( | ) |
Sets a new expression in EntryLabel.
This doesn’t immediately clear the old expression but does disable Caret movements.
References jscicalc.DisplayPanel.entryLabel, and jscicalc.ScrollableLabel.newExpression.
Referenced by jscicalc.CalculatorApplet.newExpression().
| void jscicalc.DisplayPanel.clear | ( | Parser | parser | ) |
Clears the current expression and the Parser.
Probably it should only clear the expression because CalculatorApplet should be the only object changing the state of the parser.
| parser | The Parser, which contains the expression |
References jscicalc.EntryLabel.clear(), and jscicalc.DisplayPanel.entryLabel.
Referenced by jscicalc.CalculatorApplet.clear().
| void jscicalc.DisplayPanel.delete | ( | Parser | parser | ) |
Deletes the PObject at the current Caret position.
Probably it should only change the expression because CalculatorApplet should be the only object changing the state of the parser.
| parser | The Parser, which contains the expression |
References jscicalc.EntryLabel.delete(), and jscicalc.DisplayPanel.entryLabel.
Referenced by jscicalc.CalculatorApplet.delete().
Inserts a PObject at the current Caret position.
Probably it should only change the expression because CalculatorApplet should be the only object changing the state of the parser.
| p | The PObject: typically generated by a CalculatorButton | |
| parser | The Parser, which contains the expression |
References jscicalc.DisplayPanel.entryLabel, and jscicalc.EntryLabel.insert().
Referenced by jscicalc.CalculatorApplet.insert().
| void jscicalc.DisplayPanel.setOn | ( | boolean | value | ) |
Set state (on/off).
Probably should always get this state from CalculatorApplet because the states should match.
| value | true for on, false for off. |
References jscicalc.DisplayPanel.on.
Referenced by jscicalc.CalculatorApplet.setOn().
| boolean jscicalc.DisplayPanel.getOn | ( | ) |
Get state (on/off).
Probably should always get this state from CalculatorApplet because the states should match.
Implements jscicalc.ReadOnlyDisplayPanel.
References jscicalc.DisplayPanel.on.
Referenced by jscicalc.CalculatorApplet.getOn().
| void jscicalc.DisplayPanel.setValue | ( | ) |
Set the diplayLabel value to match the OObject in the applet.
References jscicalc.DisplayPanel.displayLabel, and jscicalc.DisplayLabel.setNewExpression().
Referenced by jscicalc.CalculatorApplet.setValue().
| ReadOnlyCalculatorApplet jscicalc.DisplayPanel.getApplet | ( | ) |
Get an interface for the CalculatorApplet object.
Implements jscicalc.ReadOnlyDisplayPanel.
References jscicalc.DisplayPanel.applet.
Referenced by jscicalc.DisplayPanel.setUp().
| final DisplayLabel jscicalc.DisplayPanel.getDisplayLabel | ( | ) |
| void jscicalc.DisplayPanel.setCaretToEntry | ( | ) |
Set Caret to entry.
References jscicalc.DisplayPanel.displayLabel, jscicalc.DisplayPanel.entryLabel, jscicalc.DisplayPanel.labelWithCaret, and jscicalc.ScrollableLabel.updateCaretVisibility().
Referenced by jscicalc.DisplayPanel.DisplayPanel(), and jscicalc.CalculatorApplet.setCaretToEntry().
| void jscicalc.DisplayPanel.setCaretToDisplay | ( | ) |
Set Caret to display.
References jscicalc.DisplayPanel.displayLabel, jscicalc.DisplayPanel.entryLabel, jscicalc.DisplayPanel.labelWithCaret, and jscicalc.ScrollableLabel.updateCaretVisibility().
Referenced by jscicalc.CalculatorApplet.setCaretToDisplay().
| boolean jscicalc.DisplayPanel.hasCaret | ( | final ScrollableLabel | scrollableLabel | ) |
Find if scrollableLabel has the Caret.
This allows us to query the interface and find whether EntryPanel or DisplayPanel has permission to display a Caret
| scrollableLabel | The Scrollable label we wish to know about |
Implements jscicalc.ReadOnlyDisplayPanel.
References jscicalc.DisplayPanel.labelWithCaret.
Referenced by jscicalc.DisplayPanel.displayLabelHasCaret().
| boolean jscicalc.DisplayPanel.displayLabelHasCaret | ( | ) |
Find if displayLabel has the Caret.
This allows us to query the interface and find whether EntryPanel or DisplayPanel has permission to display a Caret
References jscicalc.DisplayPanel.displayLabel, and jscicalc.DisplayPanel.hasCaret().
Referenced by jscicalc.DisplayPanel.update(), and jscicalc.CalculatorApplet.upHistory().
EntryLabel jscicalc.DisplayPanel.entryLabel [private] |
The entry label: shows what you’ve typed.
Referenced by jscicalc.DisplayPanel.backward(), jscicalc.DisplayPanel.clear(), jscicalc.DisplayPanel.delete(), jscicalc.DisplayPanel.DisplayPanel(), jscicalc.DisplayPanel.insert(), jscicalc.DisplayPanel.newExpression(), jscicalc.DisplayPanel.setCaretToDisplay(), jscicalc.DisplayPanel.setCaretToEntry(), jscicalc.DisplayPanel.setExpression(), jscicalc.DisplayPanel.setUp(), and jscicalc.DisplayPanel.update().
The display label: shows results of calculations.
Referenced by jscicalc.DisplayPanel.displayLabelHasCaret(), jscicalc.DisplayPanel.displayLabelScrollable(), jscicalc.DisplayPanel.DisplayPanel(), jscicalc.DisplayPanel.getDisplayLabel(), jscicalc.DisplayPanel.setCaretToDisplay(), jscicalc.DisplayPanel.setCaretToEntry(), jscicalc.DisplayPanel.setUp(), jscicalc.DisplayPanel.setValue(), and jscicalc.DisplayPanel.update().
ExtraPanel jscicalc.DisplayPanel.extraPanel [private] |
The panel that shows calculator state: shift, Stat mode, degrees or radians, Base and the like.
Referenced by jscicalc.DisplayPanel.DisplayPanel(), jscicalc.DisplayPanel.setUp(), and jscicalc.DisplayPanel.update().
MiniPanel jscicalc.DisplayPanel.leftPanel [private] |
Panel to show left movement of display is possible.
Referenced by jscicalc.DisplayPanel.DisplayPanel(), jscicalc.DisplayPanel.setUp(), and jscicalc.DisplayPanel.update().
MiniPanel jscicalc.DisplayPanel.rightPanel [private] |
Panel to show right movement of display is possible.
Referenced by jscicalc.DisplayPanel.DisplayPanel(), jscicalc.DisplayPanel.setUp(), and jscicalc.DisplayPanel.update().
final ReadOnlyCalculatorApplet jscicalc.DisplayPanel.applet [private] |
Interface to the CalculatorApplet object that allows us to read values but not to change their state.
Referenced by jscicalc.DisplayPanel.getApplet().
boolean jscicalc.DisplayPanel.on [private] |
State of calculator on or off.
This should be removed because only the CalculatorApplet should have this information.
Referenced by jscicalc.DisplayPanel.getOn(), jscicalc.DisplayPanel.setOn(), and jscicalc.DisplayPanel.update().
final long jscicalc.DisplayPanel.serialVersionUID = 1L [static, private] |
1.5.5