org.vizzini.ui.graphics
Class AbstractViewerSwing

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 org.vizzini.ui.graphics.AbstractViewerSwing
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, IViewer, IViewerSwing, IJPopupMenuOwner
Direct Known Subclasses:
ObjectViewerJava3D, ObjectViewerSwing

public abstract class AbstractViewerSwing
extends JPanel
implements IViewerSwing

Provides base functionality for Swing 3D viewers.

Since:
v0.2
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Nested Class Summary
(package private)  class AbstractViewerSwing.SelectShapeAction
          Provides an Action for selecting a shape.
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  IShapeCanvas _canvas
          The canvas.
protected  int _xRotation
          The X rotation angle in degrees.
protected  int _yRotation
          The Y rotation angle in degrees.
protected  int _zRotation
          The Z rotation angle in degrees.
 
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 org.vizzini.ui.graphics.IViewer
MAGNIFICATION_FACTOR
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AbstractViewerSwing()
          Construct this object.
 
Method Summary
 void add(IShape shape)
          Add the given shape.
 void addPopupMenu()
          Add a new popup menu to this component.
 void addToPopupMenu(Action action)
          Add the given action into the popup menu.
 void addToPopupMenu(JMenuItem menuItem)
          Add the given menu item into the popup menu.
protected  void configureShapeMenu(JMenu shapeMenu)
          Configure the shape menu.
protected  JPanel createControlPanel()
          Create the control panel.
protected  JPanel createMagnifyPanel()
          Create a panel containing the magnification controls.
 JPopupMenu createPopupMenu()
          Create a new popup menu.
protected abstract  IShapeCanvas createShapeCanvas()
          Create a new shape canvas of the appropriate type.
protected abstract  AdjustmentListener createXAdjustmentListener()
          Create a X adjustment listener.
protected abstract  AdjustmentListener createYAdjustmentListener()
          Create a Y adjustment listener.
protected abstract  AdjustmentListener createZAdjustmentListener()
          Create a Z adjustment listener.
protected  void fillAdditionalPopupMenuItems(JPopupMenu popupMenu)
          Fill in additional popup menu items.
 double getMagnify()
          Return the magnification.
 double getPerspectiveConstant()
          Return the perspective constant.
protected  JPopupMenu getPopupMenu()
          Return the popup menu, creating it if necessary.
protected  IShapeCanvas getShapeCanvas()
          Return the shape canvas.
protected  JMenu getShapeMenu()
           
 Action getZoomInAction()
          Return the zoom in action.
 Action getZoomOutAction()
          Return the zoom out action.
 void insertIntoPopupMenu(Action action, int index)
          Insert the given action into the popup menu at the given index.
 void insertIntoPopupMenu(JMenuItem menuItem, int index)
          Insert the given menu item into the popup menu at the given index.
protected  boolean isMagnifyLayoutHorizontal()
          Return true if the magnify panel layout should be horizontal.
 boolean isShapeMenuUsed()
           
 boolean isViewPointLightUsed()
           
protected abstract  void moveViewPointToShape(IShape shape)
          Move the view point to the given shape.
 void remove(IShape shape)
          Remove the given shape.
 void setCanvasBackground(Color color)
          Set the canvas background color.
 void setMagnify(double magnify)
          Set the magnification.
 void setMagnifyPanelVisible(boolean isVisible)
          Set the visibility of the magnification panel.
 void setPerspectiveConstant(double d)
          Set the perspective constant.
 void setShapeMenuUsed(boolean isShapeMenuUsed)
           
 void setViewPointLightUsed(boolean isViewPointLightUsed)
           
 void setXScrollBarBlockIncrement(int increment)
          Set the block increment on the X scroll bar.
 void setXScrollBarUnitIncrement(int increment)
          Set the unit increment on the X scroll bar.
 void setXScrollBarValues(int value, int visible, int minimum, int maximum)
          Set the values on the X scroll bar.
 void setXScrollBarVisible(boolean isVisible)
          Set the visibility of the X scroll bar.
 void setYScrollBarBlockIncrement(int increment)
          Set the block increment on the Y scroll bar.
 void setYScrollBarUnitIncrement(int increment)
          Set the unit increment on the Y scroll bar.
 void setYScrollBarValues(int value, int visible, int minimum, int maximum)
          Set the values on the Y scroll bar.
 void setYScrollBarVisible(boolean isVisible)
          Set the visibility of the Y scroll bar.
 void setZScrollBarBlockIncrement(int increment)
          Set the block increment on the Z scroll bar.
 void setZScrollBarUnitIncrement(int increment)
          Set the unit increment on the Z scroll bar.
 void setZScrollBarValues(int value, int visible, int minimum, int maximum)
          Set the values on the Z scroll bar.
 void setZScrollBarVisible(boolean isVisible)
          Set the visibility of the Z scroll bar.
 void update()
          Update the shapes in this viewer.
 void zoomInActionPerformed(ActionEvent event)
          Callback for the zoom in action.
 void zoomOutActionPerformed(ActionEvent event)
          Callback for the zoom out action.
 
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, 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, 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, setEnabled, 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, isEnabled, 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
 
Methods inherited from interface org.vizzini.ui.graphics.IViewerSwing
addStarfieldBackground
 

Field Detail

_canvas

protected IShapeCanvas _canvas
The canvas.


_xRotation

protected int _xRotation
The X rotation angle in degrees.


_yRotation

protected int _yRotation
The Y rotation angle in degrees.


_zRotation

protected int _zRotation
The Z rotation angle in degrees.

Constructor Detail

AbstractViewerSwing

public AbstractViewerSwing()
Construct this object.

Since:
v0.2
Method Detail

add

public void add(IShape shape)
Add the given shape.

Specified by:
add in interface IViewer
Since:
v0.2

addPopupMenu

public void addPopupMenu()
Add a new popup menu to this component.

Specified by:
addPopupMenu in interface IViewerSwing
Since:
v0.3

addToPopupMenu

public void addToPopupMenu(Action action)
Add the given action into the popup menu.

Specified by:
addToPopupMenu in interface IJPopupMenuOwner
Parameters:
action - The Action object to add.
Since:
v0.3

addToPopupMenu

public void addToPopupMenu(JMenuItem menuItem)
Add the given menu item into the popup menu.

Specified by:
addToPopupMenu in interface IJPopupMenuOwner
Parameters:
menuItem - The JMenuItem object to add.
Since:
v0.3

createPopupMenu

public JPopupMenu createPopupMenu()
Create a new popup menu.

Specified by:
createPopupMenu in interface IViewerSwing
Since:
v0.3

getMagnify

public double getMagnify()
Return the magnification.

Specified by:
getMagnify in interface IViewer
Since:
v0.2

getPerspectiveConstant

public double getPerspectiveConstant()
Return the perspective constant.

Specified by:
getPerspectiveConstant in interface IViewer
Since:
v0.2

getZoomInAction

public Action getZoomInAction()
Return the zoom in action.

Specified by:
getZoomInAction in interface IViewerSwing
Since:
v0.3

getZoomOutAction

public Action getZoomOutAction()
Return the zoom out action.

Specified by:
getZoomOutAction in interface IViewerSwing
Since:
v0.3

insertIntoPopupMenu

public void insertIntoPopupMenu(Action action,
                                int index)
Insert the given action into the popup menu at the given index.

Specified by:
insertIntoPopupMenu in interface IJPopupMenuOwner
Parameters:
action - The Action object to insert.
index - Specifies the position at which to insert the Action, where 0 is the first.
Since:
v0.3

insertIntoPopupMenu

public void insertIntoPopupMenu(JMenuItem menuItem,
                                int index)
Insert the given menu item into the popup menu at the given index.

Specified by:
insertIntoPopupMenu in interface IJPopupMenuOwner
Parameters:
menuItem - The JMenuItem object to insert.
index - Specifies the position at which to insert the menu item, where 0 is the first.
Since:
v0.3

isShapeMenuUsed

public boolean isShapeMenuUsed()
Specified by:
isShapeMenuUsed in interface IViewerSwing
Returns:
Return isShapeMenuUsed.
Since:
v0.3

isViewPointLightUsed

public boolean isViewPointLightUsed()
Specified by:
isViewPointLightUsed in interface IViewer
Returns:
Return isViewPointLightUsed.
Since:
v0.3

remove

public void remove(IShape shape)
Remove the given shape.

Specified by:
remove in interface IViewer
Since:
v0.2

setCanvasBackground

public void setCanvasBackground(Color color)
Set the canvas background color.

Specified by:
setCanvasBackground in interface IViewer
Since:
v0.2

setMagnify

public void setMagnify(double magnify)
Set the magnification.

Specified by:
setMagnify in interface IViewer
Since:
v0.2

setMagnifyPanelVisible

public void setMagnifyPanelVisible(boolean isVisible)
Set the visibility of the magnification panel.

Specified by:
setMagnifyPanelVisible in interface IViewer
Since:
v0.2

setPerspectiveConstant

public void setPerspectiveConstant(double d)
Set the perspective constant.

Specified by:
setPerspectiveConstant in interface IViewer
Since:
v0.2

setShapeMenuUsed

public void setShapeMenuUsed(boolean isShapeMenuUsed)
Specified by:
setShapeMenuUsed in interface IViewerSwing
Parameters:
isShapeMenuUsed - the isShapeMenuUsed to set
Since:
v0.3

setViewPointLightUsed

public void setViewPointLightUsed(boolean isViewPointLightUsed)
Specified by:
setViewPointLightUsed in interface IViewer
Parameters:
isViewPointLightUsed - the isViewPointLightUsed to set
Since:
v0.3

setXScrollBarBlockIncrement

public void setXScrollBarBlockIncrement(int increment)
Set the block increment on the X scroll bar.

Specified by:
setXScrollBarBlockIncrement in interface IViewer
Parameters:
increment - The amount by which to increment or decrement the scroll bar's value.
Since:
v0.2

setXScrollBarUnitIncrement

public void setXScrollBarUnitIncrement(int increment)
Set the unit increment on the X scroll bar.

Specified by:
setXScrollBarUnitIncrement in interface IViewer
Parameters:
increment - The amount by which to increment or decrement the scroll bar's value.
Since:
v0.2

setXScrollBarValues

public void setXScrollBarValues(int value,
                                int visible,
                                int minimum,
                                int maximum)
Set the values on the X scroll bar.

Specified by:
setXScrollBarValues in interface IViewer
Parameters:
value - The position in the current window.
visible - The amount visible per page.
minimum - The minimum value of the scroll bar.
maximum - The maximum value of the scroll bar.
Since:
v0.2

setXScrollBarVisible

public void setXScrollBarVisible(boolean isVisible)
Set the visibility of the X scroll bar.

Specified by:
setXScrollBarVisible in interface IViewer
Parameters:
isVisible - Flag indicating if the scroll bar is visible.
Since:
v0.2

setYScrollBarBlockIncrement

public void setYScrollBarBlockIncrement(int increment)
Set the block increment on the Y scroll bar.

Specified by:
setYScrollBarBlockIncrement in interface IViewer
Parameters:
increment - The amount by which to increment or decrement the scroll bar's value.
Since:
v0.2

setYScrollBarUnitIncrement

public void setYScrollBarUnitIncrement(int increment)
Set the unit increment on the Y scroll bar.

Specified by:
setYScrollBarUnitIncrement in interface IViewer
Parameters:
increment - The amount by which to increment or decrement the scroll bar's value.
Since:
v0.2

setYScrollBarValues

public void setYScrollBarValues(int value,
                                int visible,
                                int minimum,
                                int maximum)
Set the values on the Y scroll bar.

Specified by:
setYScrollBarValues in interface IViewer
Parameters:
value - The position in the current window.
visible - The amount visible per page.
minimum - The minimum value of the scroll bar.
maximum - The maximum value of the scroll bar.
Since:
v0.2

setYScrollBarVisible

public void setYScrollBarVisible(boolean isVisible)
Set the visibility of the Y scroll bar.

Specified by:
setYScrollBarVisible in interface IViewer
Parameters:
isVisible - Flag indicating if the scroll bar is visible.
Since:
v0.2

setZScrollBarBlockIncrement

public void setZScrollBarBlockIncrement(int increment)
Set the block increment on the Z scroll bar.

Specified by:
setZScrollBarBlockIncrement in interface IViewer
Parameters:
increment - The amount by which to increment or decrement the scroll bar's value.
Since:
v0.2

setZScrollBarUnitIncrement

public void setZScrollBarUnitIncrement(int increment)
Set the unit increment on the Z scroll bar.

Specified by:
setZScrollBarUnitIncrement in interface IViewer
Parameters:
increment - The amount by which to increment or decrement the scroll bar's value.
Since:
v0.2

setZScrollBarValues

public void setZScrollBarValues(int value,
                                int visible,
                                int minimum,
                                int maximum)
Set the values on the Z scroll bar.

Specified by:
setZScrollBarValues in interface IViewer
Parameters:
value - The position in the current window.
visible - The amount visible per page.
minimum - The minimum value of the scroll bar.
maximum - The maximum value of the scroll bar.
Since:
v0.2

setZScrollBarVisible

public void setZScrollBarVisible(boolean isVisible)
Set the visibility of the Z scroll bar.

Specified by:
setZScrollBarVisible in interface IViewer
Parameters:
isVisible - Flag indicating if the scroll bar is visible.
Since:
v0.2

update

public void update()
Update the shapes in this viewer.

Specified by:
update in interface IViewer
Since:
v0.3

zoomInActionPerformed

public void zoomInActionPerformed(ActionEvent event)
Callback for the zoom in action.

Since:
v0.3

zoomOutActionPerformed

public void zoomOutActionPerformed(ActionEvent event)
Callback for the zoom out action.

Since:
v0.3

createShapeCanvas

protected abstract IShapeCanvas createShapeCanvas()
Create a new shape canvas of the appropriate type.

Since:
v0.3

createXAdjustmentListener

protected abstract AdjustmentListener createXAdjustmentListener()
Create a X adjustment listener.

Since:
v0.2

createYAdjustmentListener

protected abstract AdjustmentListener createYAdjustmentListener()
Create a Y adjustment listener.

Since:
v0.2

createZAdjustmentListener

protected abstract AdjustmentListener createZAdjustmentListener()
Create a Z adjustment listener.

Since:
v0.2

moveViewPointToShape

protected abstract void moveViewPointToShape(IShape shape)
Move the view point to the given shape.

Parameters:
shape - Shape.
Since:
v0.3

configureShapeMenu

protected void configureShapeMenu(JMenu shapeMenu)
Configure the shape menu.

Since:
v0.3

createControlPanel

protected JPanel createControlPanel()
Create the control panel.

Since:
v0.2

createMagnifyPanel

protected JPanel createMagnifyPanel()
Create a panel containing the magnification controls.

Since:
v0.2

fillAdditionalPopupMenuItems

protected void fillAdditionalPopupMenuItems(JPopupMenu popupMenu)
Fill in additional popup menu items. These menu items are placed at the top of the popup menu.

Since:
v0.3

getPopupMenu

protected JPopupMenu getPopupMenu()
Return the popup menu, creating it if necessary.

Since:
v0.3

getShapeCanvas

protected IShapeCanvas getShapeCanvas()
Return the shape canvas.

Since:
v0.2

getShapeMenu

protected JMenu getShapeMenu()
Returns:
Return shapeMenu.

isMagnifyLayoutHorizontal

protected boolean isMagnifyLayoutHorizontal()
Return true if the magnify panel layout should be horizontal.

Since:
v0.2


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02