jfig.canvas
Class TopLeftRulerCanvas

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

public class TopLeftRulerCanvas
extends FigBasicCanvas

object canvas with rulers on the top and left sides.

See Also:
FigCanvas, 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
 
Fields inherited from class jfig.canvas.FigBasicCanvas
backgroundColor, BASE_ANCHOR_X, BASE_ANCHOR_Y, canvasListener, cur_height, cur_width, cur_x, cur_y, debug, defaultColor, defaultCursor, enableRulerDragging, enableTimingInfo, gridColor, gridGR, gridMode, gridVisible, hasRulers, helper, mouse_drag_x, mouse_drag_y, n_grid, n_redraws, n_trials_to_create_offscreenImage, n_updates, objectEnumerator, objectGR, offscreenGR, offscreenImage, old_x, old_y, pdbg, printer, ptmp, redrawMode, rubberband, RULER_XL_OFFSET, RULER_XR_OFFSET, RULER_YB_OFFSET, RULER_YT_OFFSET, rulerFont, t_delay, t_grid, t_grid_mean, t_redraw, t_redraw_mean, theObserver, tmp_sc, tmp_wc, trafo, waitCursor, zoomListenerVector
 
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
TopLeftRulerCanvas()
          TopLeftRulerCanvas
 
Method Summary
 void drawGrid(java.awt.Graphics gridGR)
          Actually draw the grid, assuming that the offscreenBuffers are already created and of the right size.
 void drawRulers(java.awt.Graphics g)
          drawRulers: draw the scale rulers on top and the right side of the canvas.
 void drawSlidersOnce(java.awt.Graphics g, int x, int y)
          drawSlidersOnce: internal helper function to draw the sliders/cross-hatch at position (x,y).
static void main(java.lang.String[] argv)
          main(): simple self test of FigBasicCanvas inside a Frame.
 void mousePressed(java.awt.event.MouseEvent evt)
          Handle mouseDown events: snap to the currently active grid, then call the parent mouseDown action function.
 void mouseReleased(java.awt.event.MouseEvent evt)
          mouseReleased() is used to detect mouseDrag() events.
 void setRulerOffsets()
          calculate the offsets required when using rulers on this canvas.
 
Methods inherited from class jfig.canvas.FigBasicCanvas
addCanvasListener, addZoomListener, blitOffscreenBuffer, blitOffscreenBufferClipped, canvasSizeChanged, changeRubberbandMode, changeRubberbandMode, changeRubberbandMode, clearBuffer, clippedDrawTmpObject, doFullRedraw_deadlocks, doFullRedraw, doFullRedraw, doMotionRedraw, doObjectRedraw, doPanning, doSimpleRedraw, doSyncRedraw, 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, mouseMoved, msg, notifyZoomListeners, paint, paint, 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
getCursor, getSize, setCursor
 

Constructor Detail

TopLeftRulerCanvas

public TopLeftRulerCanvas()
TopLeftRulerCanvas

The default viewer canvas doesn't use neither a grid nor snapping.

Method Detail

setRulerOffsets

public void setRulerOffsets()
Description copied from interface: FigCanvas
calculate the offsets required when using rulers on this canvas. For example, the basic xfig-compatibly canvas uses rulers on the top and right sides of the canvas, and Graphics operations might want to clip drawing operations only to the central part of the canvas.

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

drawGrid

public void drawGrid(java.awt.Graphics gridGR)
Actually draw the grid, assuming that the offscreenBuffers are already created and of the right size. This function blocks the editor for a possibly long time. The gridMode is taken from trafo.gridMode. The typical grid spacing is one point every 1cm of screen spacing.

Overrides:
drawGrid in class FigBasicCanvas
Parameters:
gridGR - the Graphics for drawing.

drawRulers

public void drawRulers(java.awt.Graphics g)
drawRulers: draw the scale rulers on top and the right side of the canvas. Both rules are labelled every 2cm (approx), and 10 ticks are drawn between two labels. The labels drawn are either in mm or in inches spacing, depending on the value of FigTrafo2D.units.

Overrides:
drawRulers in class FigBasicCanvas

drawSlidersOnce

public void drawSlidersOnce(java.awt.Graphics g,
                            int x,
                            int y)
drawSlidersOnce: internal helper function to draw the sliders/cross-hatch at position (x,y).

Overrides:
drawSlidersOnce in class FigBasicCanvas

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Description copied from class: FigBasicCanvas
Handle mouseDown events: snap to the currently active grid, then call the parent mouseDown action function.

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

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Description copied from class: FigBasicCanvas
mouseReleased() is used to detect mouseDrag() events. On each mouseDown() and at the end of a mouseUp() we reset the values of the mouse_drag_(x,y) variables.

If both the current and the previous mouse_drag_(x,y) position lie in the rulers and differ by more than 5 pixels (to suppress small 'jitter'), we calculate the corresponding viewport panning.

In the future, we should probably provide some kind of visual feedback about the current drag amout by using mouseDrag() to update the rulers correspondingly.

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

main

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