dLife Home Page

dlife.robot.gui
Class DeviceDisplay

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by dlife.gui.GUIPanel
                      extended by dlife.robot.gui.DeviceDisplay
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Observer, Accessible
Direct Known Subclasses:
AiboHeadDisplay, AiboWalkDisplay, ArraySensorDisplay, BlankDeviceDisplay, CodeEditorDisplay, DeadReckoningDisplay, DeltaPositionDisplay, DifferentialDriveDisplay, GripperDisplay, OdometryDisplay, OnOffSetDisplay, PanTiltZoomDisplay, PickListDisplay, RollTiltYawDisplay, TextStreamSensorDisplay, VideoSourceGUI

public abstract class DeviceDisplay
extends GUIPanel
implements Observer

Abstract base class for the GUI's for all Devices. This some of the common functionality of all Devices including:

In addition, each concrete subclass must:

Version:
Nov 8, 2010
Author:
Grant Braught, Dickinson College
See Also:
Serialized Form

Nested 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  Device myDevice
           
 
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
DeviceDisplay(Device myDevice)
          Construct a new DeviceDisplay.
 
Method Summary
protected abstract  void disableGUI()
          Disable the GUI.
protected abstract  void enableGUI()
          Enable the GUI.
 JPanel getContentPanel()
          Get the content panel for this DeviceDisplay.
abstract  String getGUIName()
          Get the name of the Device's GUI.
 boolean isActive()
          Check if this display is active.
 boolean isEnabled()
          Check if this DeviceDisplay is enabled.
 void replaceContentPanel(JPanel newContentPanel)
          Set a new content panel for this DeviceDisplay.
 void setActive(boolean active)
          Set this DeviceDisplay as active.
 void setEnabled(boolean enable)
          Enable or disable this DeviceDisplay.
 void update(Observable arg0, Object arg1)
          Update the GUI in response to notifications from the Device that its state has changed.
protected abstract  void updateGUIFromDevice()
          Update the GUI to reflect the current state of the Device.
 
Methods inherited from class dlife.gui.GUIPanel
buildGUI, invokeBuildGUI
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, 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

myDevice

protected Device myDevice
Constructor Detail

DeviceDisplay

public DeviceDisplay(Device myDevice)
Construct a new DeviceDisplay. This constructor assigns this DeviceDisplay as an observer on the provided Device and adds the content panel so that it will remain centered.

Parameters:
myDevice - the Device whose state this DeviceDisplay is displaying. This value can be null. If it is null then this DeviceDisplay is not assigned as an observer of any Device.
Method Detail

getContentPanel

public JPanel getContentPanel()
Get the content panel for this DeviceDisplay. All GUI components for the device's GUI should be added to the content panel. This method can also be used to get the content panel from one DeviceDisplay to be used as a component in another DeviceDisplay.

Returns:
the content panel for this DeviceDisplay.

replaceContentPanel

public void replaceContentPanel(JPanel newContentPanel)
Set a new content panel for this DeviceDisplay. A common use of this is for a subclass of a DeviceDisplay to get the content panel created by its superclass and use it as part of the content panel for its own GUI.

Parameters:
newContentPanel - the new content panel.

setEnabled

public void setEnabled(boolean enable)
Enable or disable this DeviceDisplay. This method will invoke either enableGUI or disableGUI as appropriate. Those methods are responsible for setting the enabled state of the GUI components. The enableGUI or disableGUI will be invoked on the AWT event thread.

Overrides:
setEnabled in class JComponent
Parameters:
enable - true to enable the GUI, false to disable it.

isEnabled

public boolean isEnabled()
Check if this DeviceDisplay is enabled.

Overrides:
isEnabled in class Component
Returns:
true if the DeviceDisplay is enabled, false if it is not.

update

public void update(Observable arg0,
                   Object arg1)
Update the GUI in response to notifications from the Device that its state has changed. This method invokes the updateGUIFromDevice method asynchronously on the AWT event thread. That method then updates the GUI.

Specified by:
update in interface Observer

setActive

public void setActive(boolean active)
Set this DeviceDisplay as active. An active display will invoke updateGUIFromDevice each time it is notified of a change by the Device. A display that is not active will not invoke updateGUIFromDevice. This method also assigns the GUI as an observer on the device any time the GUI is active and unassigns it when it is not active.

Parameters:
active - true to make the display active, false to make it inactive.

isActive

public boolean isActive()
Check if this display is active. An active display will invoke updateGUIFromDevice each time it is notified of a change by the Device. A display that is not active will not invoke updateGUIFromDevice.

Returns:
true if the display is active, false if it is not.

updateGUIFromDevice

protected abstract void updateGUIFromDevice()
Update the GUI to reflect the current state of the Device. This method should modify the GUI components as necessary to display the current state of the Device. Note that this method will be invoked on the AWT event thread so it is safe to modify the GUI elements.


enableGUI

protected abstract void enableGUI()
Enable the GUI. This method should enable all of the GUI elements in the display in order to allow user interaction. Note that this method will be invoked by setEnabled on the AWT event thread so it is safe to modify the GUI elements. This method should not be invoked directly. Use the setEnabled method instead.


disableGUI

protected abstract void disableGUI()
Disable the GUI. This method should disable all of the GUI elements in the display so that user interaction is not possible. Note that this method will be invoked by setEnabled on the AWT event thread so it is safe to modify the GUI elements. This method should not be invoked directly. Use the setEnabled method instead.


getGUIName

public abstract String getGUIName()
Get the name of the Device's GUI. This is the name that will be displayed in the Device's tab in the ControlCenter.

Returns:
the name of the Device.

dLife Home Page