scphEditor
Class ExpressionView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by scphEditor.ExpressionView
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.Observer, OperandVectorView, OperandView
Direct Known Subclasses:
ExpressionNaryView

public class ExpressionView
extends java.awt.Container
implements java.util.Observer, OperandView

This AWT component is the view class for Expression objects. It displays the expression recursively. It automatically updates itself whenever the expression changes (child manipulations), by way of the Observable-Observer mechanism.

See Also:
Expression, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  Expression myClient
          The expression viewed by me.
protected  OperandControl myControl
          Remembers my control object (event listener), so I can pass it on to children.
protected  IEmbedding myEmbedding
          The Embedding for the Operator of my expression.
protected  boolean paren
          True iff I am showing parentheses.
 
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
ExpressionView(Expression exOf, OperandControl c)
          Constructor.
 
Method Summary
 void addNotify()
           
 IEmbedding getEmbedding()
          Returns the Embedding for the Operator of my Expression.
 Operand getOperand()
           
 OperandVector getOperandVector()
           
 java.awt.Component getOperandView(int opindex)
           
protected  void makeComponents()
          Creates my components - views for child operands as well as operator symbols and parentheses.
 int operandIndex(java.awt.Component child)
           
 void paint(java.awt.Graphics g)
           
protected  void parenthesize()
          Helper function.
 void removeNotify()
           
protected  java.awt.Component setOperandView(int opindex, java.awt.Component view)
          Helper function.
 void update(java.util.Observable o, java.lang.Object arg)
           
 int viewIndex(java.awt.Component child)
          Given a child view object, looks up the Component index it belongs to in me.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myClient

protected Expression myClient
The expression viewed by me.


myEmbedding

protected IEmbedding myEmbedding
The Embedding for the Operator of my expression.


paren

protected boolean paren
True iff I am showing parentheses.


myControl

protected OperandControl myControl
Remembers my control object (event listener), so I can pass it on to children.

Constructor Detail

ExpressionView

public ExpressionView(Expression exOf,
                      OperandControl c)
Constructor.

Parameters:
exOf - the Expression object to view.
c - the control object (event listener) for me.
Method Detail

makeComponents

protected void makeComponents()
Creates my components - views for child operands as well as operator symbols and parentheses. This implementation works correctly for n-ary operators and expressions, by calling the most abstract methods possible.


parenthesize

protected void parenthesize()
Helper function. Modifies my parenthesization according to my Expression object.


addNotify

public void addNotify()
Overrides:
addNotify in class java.awt.Container

removeNotify

public void removeNotify()
Overrides:
removeNotify in class java.awt.Container

getEmbedding

public IEmbedding getEmbedding()
Returns the Embedding for the Operator of my Expression.


getOperand

public Operand getOperand()
Specified by:
getOperand in interface OperandView

getOperandVector

public OperandVector getOperandVector()
Specified by:
getOperandVector in interface OperandVectorView

operandIndex

public int operandIndex(java.awt.Component child)
Specified by:
operandIndex in interface OperandVectorView

getOperandView

public java.awt.Component getOperandView(int opindex)
Specified by:
getOperandView in interface OperandVectorView

setOperandView

protected java.awt.Component setOperandView(int opindex,
                                            java.awt.Component view)
Helper function. Replaces the child view object at the given index.

Parameters:
opindex - the index.
view - the new view object.
Returns:
the replaced, old view object.

viewIndex

public int viewIndex(java.awt.Component child)
Given a child view object, looks up the Component index it belongs to in me.

Parameters:
child - the child view object.
Returns:
its Component index in me.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Container