edu.hws.jcm.awt
Class JCMPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--edu.hws.jcm.awt.JCMPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JCMPanel
extends java.awt.Panel

A JCMPanel is a Panel with an associated Controller. When an InputObject or Computable is added to the JCMPanel, it is automatically added to the controller. When a sub-JCMPanel is added, the Controller of the sub-panel is "attatched" to the controller of the main panel so that objects in the sub-panel will also be controlled by the Controller of the main panel. So, if you build an interface entirely from JCMPanels, a lot of the control setup is done automatically. Note that to make this work, you will need a "mainPanel" that fills the entire window or applet (or at least the part that holds JCM components). You should also call the gatherInputs() method of the main JCMPanel after it is completely set up, so that changes in input objects will cause the panel's controller to be notified, or, alternatively, you can register the Controller by hand with InputObjects so that the Controller will be notified when they change.

The disadvantage of this is that all the data used in the interface is recomputed, even if the input objects that they depend on have not changed. For example. if the user changes the value in a VarialbleInput, all the points on a graph will be recomputed even if the function has not changed. The alternative is to use regular Panels for all or part of the interface and configure some Controllers by hand.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
JCMPanel()
          Create a JCMPanel that uses a BorderLayout with horizontal and veritcal gaps of 3 pixels.
JCMPanel(int gap)
          Create a JCMPanel that uses a BorderLayout with horizontal and vertical gaps of "gap" pixels.
JCMPanel(int rows, int columns)
          Create a JCMPanel that uses a GridLayout with the specified number of rows and columns and with horizontal and veritcal gaps of 3 pixels between components.
JCMPanel(int rows, int columns, int gap)
          Create a JCMPanel that uses a GridLayout with the specified number of rows and columns and with horizontal and vertical gaps of "gap" pixels.
JCMPanel(java.awt.LayoutManager layout)
          Create a JCMPanel that uses a given layout manager.
 
Method Summary
 void gatherInputs()
          This method will set all the input objects in this JCMPanel and in sub-JCMPanels, as well as any other input objects that have been added to the panels' Controllers, to notify the Controller of this JCMPanel when they change.
 Controller getController()
          Return the controller associated with this JCMPanel.
 java.awt.Insets getInsets()
          Called by the system to determine how much of a gap to leave on each edge of the panel.
 void processContainerEvent(java.awt.event.ContainerEvent evt)
          Called by the system when a component is added to or removed from this panel.
 void setInsetGap(int x)
          Set the size of the "Insets" for this JCMPanel.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
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, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JCMPanel

public JCMPanel(java.awt.LayoutManager layout)
Create a JCMPanel that uses a given layout manager.
Parameters:
layout - layout manager to use. (This could be null.)

JCMPanel

public JCMPanel()
Create a JCMPanel that uses a BorderLayout with horizontal and veritcal gaps of 3 pixels.

JCMPanel

public JCMPanel(int gap)
Create a JCMPanel that uses a BorderLayout with horizontal and vertical gaps of "gap" pixels.
Parameters:
gap - inset gap to use.

JCMPanel

public JCMPanel(int rows,
                int columns)
Create a JCMPanel that uses a GridLayout with the specified number of rows and columns and with horizontal and veritcal gaps of 3 pixels between components.
Parameters:
rows - number of rows in the GridLayout.
columns - number of columns in the GridLayout.

JCMPanel

public JCMPanel(int rows,
                int columns,
                int gap)
Create a JCMPanel that uses a GridLayout with the specified number of rows and columns and with horizontal and vertical gaps of "gap" pixels.
Parameters:
rows - number of rows in the GridLayout.
columns - number of columns in the GridLayout.
gap - number of pixels between rows and columns
Method Detail

setInsetGap

public void setInsetGap(int x)
Set the size of the "Insets" for this JCMPanel. This is the gap, in pixels, around the edges of the Panel, where the background color shows through.
Parameters:
x - inset gap to use.

getInsets

public java.awt.Insets getInsets()
Called by the system to determine how much of a gap to leave on each edge of the panel. Not meant to be called directly
Overrides:
getInsets in class java.awt.Container

getController

public Controller getController()
Return the controller associated with this JCMPanel.

gatherInputs

public void gatherInputs()
This method will set all the input objects in this JCMPanel and in sub-JCMPanels, as well as any other input objects that have been added to the panels' Controllers, to notify the Controller of this JCMPanel when they change. It does this by calling setOnUserAction(c) -- or a corresponding method -- for each input object c. This is meant to be used, ordinarily, at the end of an applet's init() method, as an alternative to adding each of the input objects to the controller by hand.

processContainerEvent

public void processContainerEvent(java.awt.event.ContainerEvent evt)
Called by the system when a component is added to or removed from this panel. This takes care of automatically adding and removing things from this Panel's Controller. This is not meant to be called directly
Overrides:
processContainerEvent in class java.awt.Container