org.pzgui
Class PZWindow

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.pzgui.PZWindow
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class PZWindow
extends javax.swing.JFrame
implements java.awt.event.ComponentListener

A single pan-zoom GUI window.

Author:
David Underhill
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String BASE_TITLE
          string to prefix to the title in the window bar
 java.lang.String customTitle
          custom string to use for the title (if null, BASE_TITLE will be used)
protected  PZManager manager
          the manager which is managing this window
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PZWindow(PZManager manager, int screenX, int screenY, int width, int height, int drawX, int drawY)
          Creates new form display window
 
Method Summary
 void addEventListener(PZWindowEventListener l)
          Registers the listener for component, key, mouse, and window events.
 void applyPanInProgress()
          apply the pan in progress
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 javax.swing.JLabel getCanvas()
          Returns the canvas on which the scene will be drawn for this window
 java.lang.String getCustomTitle()
          Gets the custom title of this window bar
 java.awt.Graphics2D getDisplayGfx()
           
 DockLocation getDockLocation()
          get the location where the window is docked, if any
 int getDrawOffsetX()
          get the aggregate x-axis pan
 int getDrawOffsetY()
          get the aggregate y-axis pan
 PZManager getManager()
          Gets the manager of this window
 int getMX(java.awt.event.MouseEvent evt)
          get the y position of the mouse relative to the scene's origin (e.g.
 int getMY(java.awt.event.MouseEvent evt)
          get the y position of the mouse relative to the scene's origin (e.g.
 int getPanX()
          get the current x-axis pan
 int getPanY()
          get the current y-axis pan
 int getReservedHeightBottom()
          gets how much of the bottom side of the window is reserved for other content
 int getReservedWidthRight()
          gets how much of the right side of the window is reserved for other content
 java.lang.String getTitle()
          Gets the title of this window bar
 float getZoom()
          get the current zoom
 void panDown()
          pan down by the standard amount
 void panLeft()
          pan left by the standard amount
 void panRight()
          pan right by the standard amount
 void panUp()
          pan up by the standard amount
 void redraw()
           
 void removeEventListener(PZWindowEventListener l)
          Registers the listener for component, key, mouse, and window events.
 void resetView()
          reset the pan to the origin and zoom to 1.0
 void screenshot()
          tells the GUI to save a screenshot when it finishes the next redraw
 void setCustomTitle(java.lang.String title)
          Sets the custom title of this window bar
 void setDockLocation(DockLocation dockLocation)
          set how the window is docked
 void setHeight(int h)
          set the height of this window
 void setMySize(int w, int h)
          set the height and width of this window
 void setMySize(int w, int h, float zoom)
          set the height, width, and zoom of this window
 void setPanInProgress(int x, int y)
          set the pan in progress to the specified amount
 void setPanX(int x)
          set the aggregate x-axis pan
 void setPanY(int y)
          set the aggregate y-axis pan
 void setPos(Vector2i pos)
          set the x and y coordinates of this window
 void setReservedHeightBottom(int reservedHeightBottom)
          sets how much of the bottom side of the window is reserved for other content
 void setReservedWidthRight(int reservedWidthRight)
          sets how much of the right side of the window is reserved for other content
 void setWidth(int w)
          set the width of this window
 void setX(int x)
          set the x-coordinate of this window
 void setY(int y)
          set the y-coordinate of this window
 void setZoom(float z)
          set the current zoom
 void startPanZoomAnimation(int toX, int toY, float zoomTo, long duration_msec)
          Starts a pan-zoom animation with zoomPanAnimationInterpolationPower == 1.0f (a linear interpolation between the endpoints).
 void startPanZoomAnimation(int toX, int toY, float zoomTo, long duration_msec, float zoomPanAnimationInterpolationPower)
          Starts a pan-zoom animation.
 void startPanZoomAnimationToArea(int left, int right, int top, int bottom, long duration_msec, float zoomPanAnimationInterpolationPower)
          Starts a pan-zoom animation to focus on the specified area.
 void startPanZoomAnimationToLayoutables(java.util.Collection<Layoutable> layoutablesToInclude, long duration_msec, float zoomPanAnimationInterpolationPower)
          Starts a pan-zoom animation to focus on a set of layoutables.
 void stopPanZoomAnimation()
          stops any ongoing pan-zoom animation in its tracks
 java.lang.String toString()
          print out a string representation of the window's settings
 void zoomIn()
          zoom in by the standard amount
 void zoomOut()
          zoom out by the standard amount
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

manager

protected final PZManager manager
the manager which is managing this window


BASE_TITLE

public static java.lang.String BASE_TITLE
string to prefix to the title in the window bar


customTitle

public java.lang.String customTitle
custom string to use for the title (if null, BASE_TITLE will be used)

Constructor Detail

PZWindow

public PZWindow(PZManager manager,
                int screenX,
                int screenY,
                int width,
                int height,
                int drawX,
                int drawY)
Creates new form display window

Method Detail

getManager

public PZManager getManager()
Gets the manager of this window


addEventListener

public void addEventListener(PZWindowEventListener l)
Registers the listener for component, key, mouse, and window events.


removeEventListener

public void removeEventListener(PZWindowEventListener l)
Registers the listener for component, key, mouse, and window events.


getTitle

public java.lang.String getTitle()
Gets the title of this window bar

Overrides:
getTitle in class java.awt.Frame

getCustomTitle

public java.lang.String getCustomTitle()
Gets the custom title of this window bar


setCustomTitle

public void setCustomTitle(java.lang.String title)
Sets the custom title of this window bar


getCanvas

public javax.swing.JLabel getCanvas()
Returns the canvas on which the scene will be drawn for this window


getDisplayGfx

public java.awt.Graphics2D getDisplayGfx()

redraw

public void redraw()

screenshot

public void screenshot()
tells the GUI to save a screenshot when it finishes the next redraw


getReservedWidthRight

public int getReservedWidthRight()
gets how much of the right side of the window is reserved for other content


setReservedWidthRight

public void setReservedWidthRight(int reservedWidthRight)
sets how much of the right side of the window is reserved for other content


getReservedHeightBottom

public int getReservedHeightBottom()
gets how much of the bottom side of the window is reserved for other content


setReservedHeightBottom

public void setReservedHeightBottom(int reservedHeightBottom)
sets how much of the bottom side of the window is reserved for other content


setX

public void setX(int x)
set the x-coordinate of this window


setY

public void setY(int y)
set the y-coordinate of this window


setPos

public void setPos(Vector2i pos)
set the x and y coordinates of this window


getDockLocation

public DockLocation getDockLocation()
get the location where the window is docked, if any


setDockLocation

public void setDockLocation(DockLocation dockLocation)
set how the window is docked


setWidth

public void setWidth(int w)
set the width of this window


setHeight

public void setHeight(int h)
set the height of this window


setMySize

public void setMySize(int w,
                      int h)
set the height and width of this window


setMySize

public void setMySize(int w,
                      int h,
                      float zoom)
set the height, width, and zoom of this window


componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

getDrawOffsetX

public int getDrawOffsetX()
get the aggregate x-axis pan


getDrawOffsetY

public int getDrawOffsetY()
get the aggregate y-axis pan


getPanX

public int getPanX()
get the current x-axis pan


setPanX

public void setPanX(int x)
set the aggregate x-axis pan


getPanY

public int getPanY()
get the current y-axis pan


setPanY

public void setPanY(int y)
set the aggregate y-axis pan


panLeft

public void panLeft()
pan left by the standard amount


panRight

public void panRight()
pan right by the standard amount


panDown

public void panDown()
pan down by the standard amount


panUp

public void panUp()
pan up by the standard amount


applyPanInProgress

public void applyPanInProgress()
apply the pan in progress


setPanInProgress

public void setPanInProgress(int x,
                             int y)
set the pan in progress to the specified amount


getMX

public int getMX(java.awt.event.MouseEvent evt)
get the y position of the mouse relative to the scene's origin (e.g. account for pan and zoom)


getMY

public int getMY(java.awt.event.MouseEvent evt)
get the y position of the mouse relative to the scene's origin (e.g. account for pan and zoom)


getZoom

public float getZoom()
get the current zoom


setZoom

public void setZoom(float z)
set the current zoom


zoomIn

public void zoomIn()
zoom in by the standard amount


zoomOut

public void zoomOut()
zoom out by the standard amount


resetView

public void resetView()
reset the pan to the origin and zoom to 1.0


startPanZoomAnimation

public void startPanZoomAnimation(int toX,
                                  int toY,
                                  float zoomTo,
                                  long duration_msec)
Starts a pan-zoom animation with zoomPanAnimationInterpolationPower == 1.0f (a linear interpolation between the endpoints).


startPanZoomAnimation

public void startPanZoomAnimation(int toX,
                                  int toY,
                                  float zoomTo,
                                  long duration_msec,
                                  float zoomPanAnimationInterpolationPower)
Starts a pan-zoom animation.

Parameters:
toX - what x coordinate to zoom to
toY - what y coordinate to zoom to
zoomTo - the new zoom factor
duration_msec - how long to animate
zoomPanAnimationInterpolationPower - 1 means a linear interpolation will be done between the two animation endpoints. 2 would be quadratic, etc. A higher the number causes a faster beginning and a slower and smoother the ending.

startPanZoomAnimationToLayoutables

public void startPanZoomAnimationToLayoutables(java.util.Collection<Layoutable> layoutablesToInclude,
                                               long duration_msec,
                                               float zoomPanAnimationInterpolationPower)
Starts a pan-zoom animation to focus on a set of layoutables.

Parameters:
layoutablesToInclude - the layoutables to zoom in on
duration_msec - how long to animate
zoomPanAnimationInterpolationPower - see startPanZoomAnimation()

startPanZoomAnimationToArea

public void startPanZoomAnimationToArea(int left,
                                        int right,
                                        int top,
                                        int bottom,
                                        long duration_msec,
                                        float zoomPanAnimationInterpolationPower)
Starts a pan-zoom animation to focus on the specified area.

Parameters:
left - the leftmost coordinate to include
right - the rightmost coordinate to include
top - the uppermost coordinate to include
bottom - the bottom-most coordinate to include
duration_msec - how long to animate
zoomPanAnimationInterpolationPower - see startPanZoomAnimation()

stopPanZoomAnimation

public void stopPanZoomAnimation()
stops any ongoing pan-zoom animation in its tracks


toString

public java.lang.String toString()
print out a string representation of the window's settings

Overrides:
toString in class java.awt.Component