|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
jfig.canvas.FigSwingCanvas
hades.gui.JObjectCanvas
JObjectCanvas provides a canvas to display and edit HADES schematics. As a subclass of jfig.canvas.FigSwingCanvas, this class can display arbitrary jfig FIG objects and subclasses like hades.symbols.Symbol. Additionally, JObjectCanvas provides animation support via synchronous repaints and a popup-menu created dynamically from text descriptions.
Nested Class Summary |
Nested classes inherited from class jfig.canvas.FigSwingCanvas |
FigSwingCanvas.Options2D |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
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
specify the size of the tables used to manage animation. |
protected int |
n_repaintOverflows
|
protected int |
n_repaintTableEntries
|
protected int |
n_repaintTables
|
(package private) static java.lang.String |
versionString
|
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.Container |
|
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 | |
JObjectCanvas(Editor _editor)
create an empty JObjectCanvas for the specified editor. |
Method Summary | |
void |
clearRepaintArray()
|
int |
countExecutedSyncRepaints()
|
int |
countPendingRepaints()
|
int |
countRepaintTableEntries()
|
int |
countSyncRepaintOverflows()
|
void |
createCustomNullCursor()
|
void |
createMenuShortcuts()
|
javax.swing.JToolTip |
createToolTip()
create a JMultiLineToolTip with context sensitive information text |
void |
doPanning(int direction,
boolean shift)
automatic panning of the visible viewport on the world-coordinate system. |
void |
doSyncRedraw()
perform a synchronous redrawing of all 'dirty' objects contained in our 'repaintArray' object buffer. |
void |
doZoomFit()
doZoomFit(): calculate the bounding box of all objects from our FigDrawableEnumerator, then set the zoom and panning so that all objects are visible. |
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 JObjectCanvas. |
void |
doZoomRegionBroken(FigBbox bbox)
|
void |
drawRulers(java.awt.Graphics g)
drawRulers: draw the scale rulers on top and the right side of the canvas. |
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)
|
java.awt.Point |
getToolTipLocation(java.awt.event.MouseEvent evt)
calculate a good location for our context sensitive tool tips |
java.lang.String |
getToolTipText(java.awt.event.MouseEvent evt)
create a context sensitive tool tip help text, depending on the current mouse position. |
boolean |
isPopupShowing()
|
boolean |
isRightYRuler()
returns false: we want our Y ruler on the left side of the canvas. |
boolean |
isToolTipsEnabled()
|
static void |
main(java.lang.String[] argv)
main(): simple self test of FigSwingCanvas inside a Frame. |
void |
mouseDragged(java.awt.event.MouseEvent mme)
Handle MouseDrag events: Currently, mouseDrag events are used for canvas panning. |
void |
mouseMoved(java.awt.event.MouseEvent mme)
Handle mouseMove events: update sliders/cross hatch, provide rubberbanding Note that we don't need to synchronize in the Swing world: everything is executed in the event dispatcher thread Also note that we have to correct the clip rectangle for the cursor extension (currently three pixels...) |
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. |
void |
paintNoChanges(java.awt.Graphics g)
repaint the canvas under the assumption that the visible FIG objects have not changed. |
java.lang.String |
printRepaintStatus()
|
void |
setContextToolTipProvider(ContextToolTip provider)
|
void |
setCursor(java.awt.Cursor c)
|
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 |
setRulerOffsets()
update our parent's ruler offset variables, assuming either no rulers, or rulers on the top and left border of the canvas. |
void |
setToolTipsEnabled(boolean b)
|
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintChildren, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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 |
static final java.lang.String versionString
public static final int MAX_REPAINT_INDEX
protected int n_repaintTables
protected int n_repaintTableEntries
protected int n_repaintOverflows
Constructor Detail |
public JObjectCanvas(Editor _editor)
Method Detail |
public void createCustomNullCursor()
public void setCursor(java.awt.Cursor c)
setCursor
in interface FigCanvas
public SyncRedrawTimer getSyncRedrawTimer()
getSyncRedrawTimer
in interface ObjectCanvas
public javax.swing.JToolTip createToolTip()
public java.awt.Point getToolTipLocation(java.awt.event.MouseEvent evt)
public java.lang.String getToolTipText(java.awt.event.MouseEvent evt)
public void setContextToolTipProvider(ContextToolTip provider)
public boolean isToolTipsEnabled()
isToolTipsEnabled
in interface ObjectCanvas
public void setToolTipsEnabled(boolean b)
setToolTipsEnabled
in interface ObjectCanvas
public void setRulerOffsets()
setRulerOffsets
in interface FigCanvas
setRulerOffsets
in class FigSwingCanvas
public boolean isRightYRuler()
isRightYRuler
in class FigSwingCanvas
public void drawRulers(java.awt.Graphics g)
drawRulers
in class FigSwingCanvas
public void paintNoChanges(java.awt.Graphics g)
FigSwingCanvas
paintNoChanges
in class FigSwingCanvas
public java.lang.String getToken(java.util.StringTokenizer st) throws java.lang.Exception
java.lang.Exception
public void createMenuShortcuts()
public boolean isPopupShowing()
isPopupShowing
in interface ObjectCanvas
public java.awt.Point getPopupPosition()
getPopupPosition
in interface ObjectCanvas
public java.awt.Point getPopupPositionWC()
getPopupPositionWC
in interface ObjectCanvas
public java.awt.Point getPopupPositionWCsnapped()
getPopupPositionWCsnapped
in interface ObjectCanvas
public void setPopupPosition(java.awt.Point sp, java.awt.Point wp)
setPopupPosition
in interface ObjectCanvas
public void setEnablePopup(boolean b)
setEnablePopup
in interface ObjectCanvas
public boolean getEnablePopup()
getEnablePopup
in interface ObjectCanvas
public void setEnablePopupOnNextMouseRelease()
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.
setEnablePopupOnNextMouseRelease
in interface ObjectCanvas
public void mouseMoved(java.awt.event.MouseEvent mme)
FigSwingCanvas
mouseMoved
in interface FigCanvas
mouseMoved
in class FigSwingCanvas
public void mouseDragged(java.awt.event.MouseEvent mme)
FigSwingCanvas
However, mouseDrag() at the moment is not used: The actual panning calculations are done in mouseUp(). We should probably provide visual feedback about the drag amout by redrawing the rulers in this function.
mouseDragged
in interface FigCanvas
mouseDragged
in class FigSwingCanvas
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface FigCanvas
mousePressed
in class FigSwingCanvas
public void mouseReleased(java.awt.event.MouseEvent e)
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 do nothing here. Note that dispatching to FigSwingCanvas.mouseRelease() would mean to implement the mouse dragging behaviour that we don't want for the Hades editor.
mouseReleased
in interface FigCanvas
mouseReleased
in class FigSwingCanvas
public void doPanning(int direction, boolean shift)
doPanning
in interface FigCanvas
doPanning
in class FigSwingCanvas
public void doZoomFit()
FigCanvas
doZoomFit
in interface FigCanvas
doZoomFit
in class FigSwingCanvas
public void doZoomIn14()
doZoomIn14
in class FigSwingCanvas
public void doZoomOut07()
doZoomOut07
in class FigSwingCanvas
public void doZoomRegionBroken(FigBbox bbox)
public void doZoomRegion(FigBbox bbox)
public void doZoomLandscapeA4(FigBbox bbox)
doZoomLandscapeA4
in interface ObjectCanvas
public void paint(FigDrawable obj)
paint
in interface FigCanvas
paint
in class FigSwingCanvas
public void paint(FigDrawable obj, int millis)
paint
in interface FigCanvas
paint
in class FigSwingCanvas
public void clearRepaintArray()
clearRepaintArray
in interface ObjectCanvas
public java.lang.String printRepaintStatus()
public int countPendingRepaints()
countPendingRepaints
in interface ObjectCanvas
public int countRepaintTableEntries()
public int countSyncRepaintOverflows()
countSyncRepaintOverflows
in interface ObjectCanvas
public int countExecutedSyncRepaints()
countExecutedSyncRepaints
in interface ObjectCanvas
public void doSyncRedraw()
for debugging purposes, if (debug) is on this method will print a dot '.' when the redraw uses the painting of a few objects, and an asterisk '*' when performing a full redraw due to a repaint buffer overflow.
doSyncRedraw
in interface FigCanvas
doSyncRedraw
in class FigSwingCanvas
public static void main(java.lang.String[] argv)
FigSwingCanvas
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |