|
|||||||||
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
schmitzm.swing.JPanel
schmitzm.swing.CaptionsChangeablePanel
schmitzm.swing.OperationTreePanel
public class OperationTreePanel
Diese Klasse stellt eine Panel zur Vefuegung, mit der eine einfache arithmetische (und boolsche) Berechnungsformel eingegeben werden kann.
OperationTree
,
OperationTreeParser
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected Vector<String> |
avOperators
Enthaelt die in der Operator-Auswahl zur Verfuegung gestellten Operatoren Konstanten |
protected HashMap<String,String> |
avOperatorsDesc
Enthaelt die in der Operator-Auswahl angezeigen Operatoren Konstanten |
protected HashMap<Object,String> |
avOperatorsToolTip
Enthaelt die in der Operator-Auswahl angezeigen Tooltips der Operatoren. |
protected HashMap<String,GridBagConstraints> |
layoutConstraints
Werte fuer die grafische Anordnung der Layout-Komponenten. |
static String |
OPERATOR_COMBOBOX
Konstante fuer das Operatoren-Auswahlfeld. |
static String |
OPERATOR_LABEL
Konstante fuer das Operatoren-Label. |
protected SelectionInputOption.Combo<String> |
operators
Auswahl-Liste der zur Verfuegung stehenden Operatoren und Konstanzen. |
protected ManualInputOption.Text |
rule
Eingabefeld fuer die Formel. |
static String |
RULE_LABEL
Konstante fuer das Regel-Label. |
static String |
RULE_TEXTFIELD
Konstante fuer das Formel-Eingabefeld. |
static String |
RULE_TOOLTIP
Konstante fuer den Tooltip des Regel-Felds. |
static String |
START_BUTTON
Konstante fuer den Start-Button. |
protected JButton |
startButton
Butten zum Starten der Berechnung. |
protected OperationTreePanel |
THIS
Speichert eine Referenz auf das Fenster-Objekt, um aus verschachtelten Klassen einfach darauf zugreifen zu koennen. |
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.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 | |
---|---|
|
OperationTreePanel()
Erzeugt eine neue Eingabe-GUI fuer den OperationTree . |
protected |
OperationTreePanel(boolean initGUI)
Erzeugt eine neue Eingabe-GUI fuer den OperationTree . |
Method Summary | |
---|---|
protected boolean |
acceptOperator(String operator)
Kann von Sub-Klassen ueberschrieben werden, um bestimmte Operatoren in der Auswahl-Liste auszublenden. |
protected void |
checkInputsAndError()
Prueft die eingegebene Formel auf syntaktische Korrektheit. |
protected int |
getParameterCount(String op)
Liefert die Anzahl an geklammerten Parametern, die ein Operator hat. |
protected void |
initGUI()
Initalisiert die GUI des Fensters. |
protected Object |
performCalculation()
Erzeugt einen OperationTree aus der Formel und wertet diese
aus. |
protected void |
performOperatorInsert(String op,
JTextField textField)
Fuegt einen Operator in die aktuelle Formel ein. |
void |
resetCaptions(Map<String,Object> captionMap)
Setzt die Labels des Panels neu. |
Methods inherited from class schmitzm.swing.CaptionsChangeablePanel |
---|
resetCaptions, resetCaptions |
Methods inherited from class schmitzm.swing.JPanel |
---|
setBackground, setEnabled |
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 |
---|
protected final OperationTreePanel THIS
public static final String START_BUTTON
layoutConstraints
,
resetCaptions(Map)
public static final String RULE_LABEL
resetCaptions(Map)
public static final String RULE_TEXTFIELD
layoutConstraints
public static final String RULE_TOOLTIP
resetCaptions(Map)
public static final String OPERATOR_LABEL
resetCaptions(Map)
public static final String OPERATOR_COMBOBOX
layoutConstraints
protected HashMap<String,GridBagConstraints> layoutConstraints
START_BUTTON
, RULE_TEXTFIELD
und OPERATOR_COMBOBOX
koennen die Constraints (am Anfang von initGUI()
)
veraendert oder erweitert werden.
protected ManualInputOption.Text rule
protected JButton startButton
protected SelectionInputOption.Combo<String> operators
protected Vector<String> avOperators
protected HashMap<String,String> avOperatorsDesc
protected HashMap<Object,String> avOperatorsToolTip
Constructor Detail |
---|
public OperationTreePanel()
OperationTree
.
protected OperationTreePanel(boolean initGUI)
OperationTree
.
initGUI
- Flag, ob initGUI()
am Ende des Konstruktor
aufgerufen werden soll (wenn false
muss die explizit
durch die Unterklasse erfolgen!)Method Detail |
---|
protected void initGUI()
protected boolean acceptOperator(String operator)
operator
- ein Operator
true
public void resetCaptions(Map<String,Object> captionMap)
RULE_LABEL
, RULE_TOOLTIP
,
OPERATOR_LABEL
und START_BUTTON
angesprochen.
resetCaptions
in interface CaptionsChangeable
resetCaptions
in class CaptionsChangeablePanel
captionMap
- Mapprotected void checkInputsAndError() throws Exception
Exception
- falls ein Fehler gefunden wirdprotected Object performCalculation() throws Exception
OperationTree
aus der Formel und wertet diese
aus.
double
-Wert
Exception
OperationTreeParser
protected void performOperatorInsert(String op, JTextField textField)
JTextComponent.getSelectionStart()
und JTextComponent.getSelectionEnd()
kann ermittelt werden, an welcher Stelle der aktuelle Cursor steht.
op
- einzufuegender OperatortextField
- Text-Feld in das der Operator eingefuegt werden sollJTextComponent.getSelectedText()
protected int getParameterCount(String op)
op
- Operator
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |