hades.gui
Class AWTObjectCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended byjfig.canvas.FigBasicCanvas
              extended byjfig.canvas.TopLeftRulerCanvas
                  extended byhades.gui.AWTObjectCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, FigCanvas, FullRedraw, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, ObjectCanvas, ObjectPainter, java.io.Serializable, SyncPainter

public class AWTObjectCanvas
extends TopLeftRulerCanvas
implements ObjectCanvas, java.awt.event.ActionListener

AWTObjectCanvas - the main display/edit canvas for the HADS schematic editor, constructed from an JavaFIG drawing canvas with additional popup-menu and redraw functions.

AWTObjectCanvas also provides a mechanism for synchronous repaints of all objects that have registered themselves by calling the paint( FigObject) method.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class jfig.canvas.FigBasicCanvas
FigBasicCanvas.Options2D
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int MAX_REPAINT_INDEX
           
protected  int n_repaintOverflows
           
protected  int n_repaintTableEntries
           
protected  int n_repaintTables
           
(package private) static java.lang.String versionString
           
 
Fields inherited from class jfig.canvas.FigBasicCanvas
backgroundColor, BASE_ANCHOR_X, BASE_ANCHOR_Y, cur_height, cur_width, cur_x, cur_y, debug, defaultColor, defaultCursor, enableRulerDragging, enableTimingInfo, gridColor, gridGR, hasRulers, objectEnumerator, objectGR, offscreenGR, old_x, old_y, redrawMode, RULER_XL_OFFSET, RULER_XR_OFFSET, RULER_YB_OFFSET, RULER_YT_OFFSET, trafo, waitCursor
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface jfig.canvas.FigCanvas
FullRedraw, MouseMotionRedraw, NoChanges, ObjectRedraw, panDOWN, panHOME, panLEFT, panRIGHT, panUP, SyncRedraw, SystemRedraw, TmpObjectRedraw, TmpTextRedraw
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AWTObjectCanvas(Editor _editor)
          create an empty AWTObjectCanvas, that is without objects so far.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void bufferedSyncRedraw()
           
 void clearRepaintArray()
           
 int countExecutedSyncRepaints()
           
 int countPendingRepaints()
           
 int countRepaintTableEntries()
           
 int countSyncRepaintOverflows()
           
 void createMenuShortcuts()
           
 void doPanning(int direction, boolean shift)
          automatic panning of the visible viewport on the world-coordinate system.
 void doSyncRedraw()
          method stub for synchronous repaints: FigCanvas itself just provides a doSimpleRedraw().
 void doZoomIn14()
          zoom in by a factor of two.
 void doZoomLandscapeA4(FigBbox bbox)
          fit all objects to "Landscape A4 paper".
 void doZoomOut07()
           
 void doZoomRegion(FigBbox bbox)
          fit objects to this AWTObjectCanvas.
 void doZoomRegionBroken(FigBbox bbox)
           
 java.awt.Menu findMenu(java.awt.Menu parent, java.lang.String menuname)
           
 java.awt.Menu findMenuSlow(java.awt.Menu parent, java.lang.String menuname)
          find a top-level submenu of our popup menu
 boolean getEnablePopup()
           
 java.awt.Point getPopupPosition()
          return the screen-coordinate position of the last popup-menus invocation
 java.awt.Point getPopupPositionWC()
          return the world-coordinate position corresponding to the last popup-menus invocation
 java.awt.Point getPopupPositionWCsnapped()
           
 SyncRedrawTimer getSyncRedrawTimer()
           
 java.lang.String getToken(java.util.StringTokenizer st)
           
 boolean isPopupShowing()
           
 boolean isToolTipsEnabled()
           
static void main(java.lang.String[] argv)
          main(): simple self test of FigBasicCanvas inside a Frame.
 void mouseMoved(java.awt.event.MouseEvent mme)
          Handle mouseMove events: update sliders/cross hatch, provide rubberbanding
 void mousePressed(java.awt.event.MouseEvent e)
          mousePressed(): intercept mouse clicks and show the context-Popup Menu, if triggered.
 void mouseReleased(java.awt.event.MouseEvent e)
          mouseReleased(): intercept mouse release events.
 void paint(FigDrawable obj)
          add a paint-request from an animated object the the repaintStack.
 void paint(FigDrawable obj, int millis)
          repaint an (animated) object within millis milliseconds.
 java.lang.String printRepaintStatus()
           
 void setEnablePopup(boolean b)
           
 void setEnablePopupOnNextMouseRelease()
          re-enable the popup-menu on the next mouseReleased() event.
 void setPopupPosition(java.awt.Point sp, java.awt.Point wp)
          NOTE: do not call this method.
 void setToolTipsEnabled(boolean b)
           
 void sleep(int millis)
           
 
Methods inherited from class jfig.canvas.TopLeftRulerCanvas
drawGrid, drawRulers, drawSlidersOnce, setRulerOffsets
 
Methods inherited from class jfig.canvas.FigBasicCanvas
addCanvasListener, addZoomListener, blitOffscreenBuffer, blitOffscreenBufferClipped, canvasSizeChanged, changeRubberbandMode, changeRubberbandMode, changeRubberbandMode, clearBuffer, clippedDrawTmpObject, doFullRedraw_deadlocks, doFullRedraw, doFullRedraw, doMotionRedraw, doObjectRedraw, doSimpleRedraw, doSystemRedraw, doTextRedraw, doToggleRubberbandDebug, doZoom11, doZoomFit, doZoomFull, doZoomIn, doZoomOut, doZoomRegion, drawAllObjects, drawGridByHand, drawGridViaCopyArea, drawObject, drawSliders, drawSlidersAndCursor, drawTmpObjects, drawTriangles, eraseObject, err, flush, get_current_canvas_size, getBackground, getComponent, getCurrentCanvasSize, getDebug, getGridColor, getMousePosition, getObjectEnumerator, getOffscreenGraphics, getOptions2D, getRedrawMode, getTrafo, getViewportWCmax, getVisibleRegionBoundingBox_OLD, getVisibleRegionBoundingBox, gotFocus, handleRedraw, initializeOffscreenBuffers, isDoubleBuffered, mouseClicked, mouseDragged, mouseEntered, mouseExited, msg, notifyZoomListeners, paint, print, printAll, printTimingStats, removeZoomListener, repaint, repaint, repaint, repaint, requestAntiAliasing, requestRenderQuality, setBackground, setConsole, setDebug, setDefaultCursor, setEnableRulerDragging, setGrid, setGridColor, setObjectEnumerator, setRubberbandAspect, setRubberbandBasePoint, setRubberbandBasePoint, setRubberbandBasePoint2, setRubberbandBasePoint2, setRubberbandShowLineLengths, setStatusMessage, setTrafo, showRulers, statusMessage, synchronousRepaint, update
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jfig.canvas.FigCanvas
addCanvasListener, addZoomListener, blitOffscreenBuffer, blitOffscreenBufferClipped, changeRubberbandMode, changeRubberbandMode, changeRubberbandMode, clippedDrawTmpObject, doFullRedraw, doFullRedraw, doMotionRedraw, doObjectRedraw, doSimpleRedraw, doSystemRedraw, doTextRedraw, doToggleRubberbandDebug, doZoom11, doZoomFit, doZoomFull, doZoomIn, doZoomOut, doZoomRegion, drawAllObjects, drawObject, drawSlidersAndCursor, drawTmpObjects, eraseObject, flush, getBackground, getComponent, getCursor, getDebug, getGridColor, getMousePosition, getObjectEnumerator, getOffscreenGraphics, getSize, getTrafo, getViewportWCmax, getVisibleRegionBoundingBox, gotFocus, handleRedraw, mouseClicked, mouseDragged, mouseEntered, mouseExited, msg, notifyZoomListeners, paint, printTimingStats, removeZoomListener, repaint, requestAntiAliasing, requestRenderQuality, setBackground, setConsole, setCursor, setDebug, setDefaultCursor, setEnableRulerDragging, setGrid, setGridColor, setObjectEnumerator, setRubberbandAspect, setRubberbandBasePoint, setRubberbandBasePoint, setRubberbandBasePoint2, setRubberbandBasePoint2, setRubberbandShowLineLengths, setRulerOffsets, setStatusMessage, setTrafo, showRulers, statusMessage, synchronousRepaint, update
 

Field Detail

versionString

static final java.lang.String versionString
See Also:
Constant Field Values

MAX_REPAINT_INDEX

public static final int MAX_REPAINT_INDEX
See Also:
Constant Field Values

n_repaintTables

protected int n_repaintTables

n_repaintTableEntries

protected int n_repaintTableEntries

n_repaintOverflows

protected int n_repaintOverflows
Constructor Detail

AWTObjectCanvas

public AWTObjectCanvas(Editor _editor)
create an empty AWTObjectCanvas, that is without objects so far. In order to actually display objects on this AWTObjectCanvas, you have to set the object 'enumerator' via calling setObjectEnumerator().

The popup menu is created dynamically from an external text file, whose location is taken from the SetupManager property "Hades.Editor.PopupMenuResource". The default location is "/hades/gui/PopupMenu.txt".

Method Detail

getSyncRedrawTimer

public SyncRedrawTimer getSyncRedrawTimer()
Specified by:
getSyncRedrawTimer in interface ObjectCanvas

getToken

public java.lang.String getToken(java.util.StringTokenizer st)
                          throws java.lang.Exception
Throws:
java.lang.Exception

findMenu

public java.awt.Menu findMenu(java.awt.Menu parent,
                              java.lang.String menuname)

findMenuSlow

public java.awt.Menu findMenuSlow(java.awt.Menu parent,
                                  java.lang.String menuname)
find a top-level submenu of our popup menu


createMenuShortcuts

public void createMenuShortcuts()

isPopupShowing

public boolean isPopupShowing()
Specified by:
isPopupShowing in interface ObjectCanvas

getPopupPosition

public java.awt.Point getPopupPosition()
return the screen-coordinate position of the last popup-menus invocation

Specified by:
getPopupPosition in interface ObjectCanvas

getPopupPositionWC

public java.awt.Point getPopupPositionWC()
return the world-coordinate position corresponding to the last popup-menus invocation

Specified by:
getPopupPositionWC in interface ObjectCanvas

getPopupPositionWCsnapped

public java.awt.Point getPopupPositionWCsnapped()
Specified by:
getPopupPositionWCsnapped in interface ObjectCanvas

setPopupPosition

public void setPopupPosition(java.awt.Point sp,
                             java.awt.Point wp)
NOTE: do not call this method. It is only provided as a hook to allow LogPlaybackManager to modify the 'virtual'popup menu position during a log playback. It has no effect whatsoever on the 'real' popup menu coordinates, which are always overridden by the actual mouseclicks.

Specified by:
setPopupPosition in interface ObjectCanvas

setEnablePopup

public void setEnablePopup(boolean b)
Specified by:
setEnablePopup in interface ObjectCanvas

getEnablePopup

public boolean getEnablePopup()
Specified by:
getEnablePopup in interface ObjectCanvas

setEnablePopupOnNextMouseRelease

public void setEnablePopupOnNextMouseRelease()
re-enable the popup-menu on the next mouseReleased() event.

This method is a quick fix and workaround for the different popup-menu trigger semantics on X11/Unix and Windows platforms. In a few Hades editor commands (like create object or move object), a right mouse button is used to cancel the command - on the mousePressed event. After canceling the command, we have to re-enable the popup menu. However, doing this right away from the mousePressed callback would instantly display the popup menu on the next mouseReleased event, which is annoying on Windows.

The workaround is to call this method instead of setEnablePopup(true) from the mousePressed callback. We just set our internal enablePopupOnNextMouseRelease flag and check for it in our own mouseRelease handler.

Specified by:
setEnablePopupOnNextMouseRelease in interface ObjectCanvas

isToolTipsEnabled

public boolean isToolTipsEnabled()
Specified by:
isToolTipsEnabled in interface ObjectCanvas

setToolTipsEnabled

public void setToolTipsEnabled(boolean b)
Specified by:
setToolTipsEnabled in interface ObjectCanvas

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent mme)
Description copied from class: FigBasicCanvas
Handle mouseMove events: update sliders/cross hatch, provide rubberbanding

Specified by:
mouseMoved in interface FigCanvas
Overrides:
mouseMoved in class FigBasicCanvas

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
mousePressed(): intercept mouse clicks and show the context-Popup Menu, if triggered. Forward other mouseEvents to our parent class.

Specified by:
mousePressed in interface FigCanvas
Overrides:
mousePressed in class TopLeftRulerCanvas

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased(): intercept mouse release events. While the HADES editor does not use mouse release events, this method is required as the popup menu trigger on Windows.

If the enablePopupOnNextMouseRelease flag is set, we just set the enablePopup flag and return right away. This extra complication is necessary to handle the "editor command canceled by right mouse button click" situation on Windows. If the enablePopupOnNextMouseRelease flag is not set, we just check the value of the enablePopup flag and check whether the current MouseEvent is a popup trigger event. If it is not, we dispatch to our superclass mouseReleased handler.

Specified by:
mouseReleased in interface FigCanvas
Overrides:
mouseReleased in class TopLeftRulerCanvas

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

doPanning

public void doPanning(int direction,
                      boolean shift)
automatic panning of the visible viewport on the world-coordinate system. Possible directions are left, right, up, down, and home. The amount of panning is 1/20th of the current viewport, or 1/2 with shift=true.

Specified by:
doPanning in interface FigCanvas
Overrides:
doPanning in class FigBasicCanvas

doZoomIn14

public void doZoomIn14()
zoom in by a factor of two. Fixed point is the viewport center.


doZoomOut07

public void doZoomOut07()

doZoomRegionBroken

public void doZoomRegionBroken(FigBbox bbox)

doZoomRegion

public void doZoomRegion(FigBbox bbox)
fit objects to this AWTObjectCanvas. We calculate our Trafo2D parameters for zoom and offset (anchor) so that all objects within the specified bounding box 'bbox' are visible. This method uses a fixed border of 10 pixels on all sides.


doZoomLandscapeA4

public void doZoomLandscapeA4(FigBbox bbox)
fit all objects to "Landscape A4 paper". This function is useful for Java 1.1 printing, which basically translates AWT drawing commands to printing commands for a 72 dpi printer. To improve object layout on the final page, this function takes the given bounding box and calculates the resulting zoom factor and offset so as to fit all objects into the (840x594) pixel rectangle useful for an A4 paper in landscape orientation. We also use a fixed border of 50 pixels (which should be OK for most printers).

Specified by:
doZoomLandscapeA4 in interface ObjectCanvas

paint

public void paint(FigDrawable obj)
add a paint-request from an animated object the the repaintStack. The repaint is not handled right-away but only later after synchronousRepaint() has been called.

Specified by:
paint in interface FigCanvas
Overrides:
paint in class FigBasicCanvas

paint

public void paint(FigDrawable obj,
                  int millis)
repaint an (animated) object within millis milliseconds. AWTObjectCanvas ignores this direct request, but puts the object into the repaintStack for later redraw after synchronousRepaint() has been called.

Specified by:
paint in interface FigCanvas
Overrides:
paint in class FigBasicCanvas

clearRepaintArray

public void clearRepaintArray()
Specified by:
clearRepaintArray in interface ObjectCanvas

countPendingRepaints

public int countPendingRepaints()
Specified by:
countPendingRepaints in interface ObjectCanvas

countRepaintTableEntries

public int countRepaintTableEntries()

countSyncRepaintOverflows

public int countSyncRepaintOverflows()
Specified by:
countSyncRepaintOverflows in interface ObjectCanvas

countExecutedSyncRepaints

public int countExecutedSyncRepaints()
Specified by:
countExecutedSyncRepaints in interface ObjectCanvas

bufferedSyncRedraw

public void bufferedSyncRedraw()

printRepaintStatus

public java.lang.String printRepaintStatus()

doSyncRedraw

public void doSyncRedraw()
Description copied from interface: FigCanvas
method stub for synchronous repaints: FigCanvas itself just provides a doSimpleRedraw().

This method should be overridden by subclasses as necessary.

Specified by:
doSyncRedraw in interface FigCanvas
Overrides:
doSyncRedraw in class FigBasicCanvas

sleep

public void sleep(int millis)

main

public static void main(java.lang.String[] argv)
Description copied from class: FigBasicCanvas
main(): simple self test of FigBasicCanvas inside a Frame.