|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent jfig.canvas.FigSwingCanvas
basic object canvas to draw FIG objects.
FigSwingCanvas provides a canvas for displaying of FIG objects (subclasses of jfig.objects.FigObject) with zoom, several redraw and animation options. Use this class or a subclass of it as the main drawing canvas for a graphics editor like jfig or the corresponding viewer.
FigSwingCanvas handles mouseDown, mouseMove, mouseDrag, and KeyDown events for automatic panning (via cursor-keys or mouseMoves near the border). Other events are passed to the parent applet.
Drawing into the canvas is done in three steps with an offscreen buffer for the grid and the 'objects' respectively:
Additionally, FigSwingCanvas supports the standard zoom functionality.
Nested Class Summary | |
class |
FigSwingCanvas.Options2D
Options2D: inner class to encapsulate access to Java2D rendering hints in a Java 1.1 compatible way. |
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 | |
protected java.awt.Color |
backgroundColor
|
protected int |
BASE_ANCHOR_X
|
protected int |
BASE_ANCHOR_Y
|
protected FigCanvasListener |
canvasListener
|
protected int |
cur_height
|
protected int |
cur_width
|
protected int |
cur_x
|
protected int |
cur_y
|
protected boolean |
debug
|
protected java.awt.Color |
defaultColor
|
java.awt.Cursor |
defaultCursor
|
protected boolean |
enableRulerDragging
|
protected boolean |
enableTimingInfo
|
protected java.awt.Color |
gridColor
|
protected int |
gridMode
|
protected boolean |
gridVisible
|
protected boolean |
hasRulers
|
protected StatusMessage |
helper
|
protected boolean |
Jdebug
|
protected int |
mode
|
(package private) int |
mouse_drag_x
|
(package private) int |
mouse_drag_y
|
(package private) int |
n_grid
|
(package private) int |
n_redraws
|
(package private) int |
n_trials_to_create_offscreenImage
|
(package private) int |
n_updates
|
protected FigDrawableEnumerator |
objectEnumerator
|
protected java.awt.Graphics |
objectGR
|
protected java.awt.Graphics |
offscreenGR
|
protected java.awt.Image |
offscreenImage
|
protected int |
old_x
|
protected int |
old_y
|
static int |
PAINT_ALL
|
static int |
PAINT_CURSOR
|
static int |
PAINT_NO_CHANGES
|
static int |
PAINT_OBJECTS
|
static int |
PAINT_RIGHT_RULER
|
static int |
PAINT_RUBBERBAND
|
static int |
PAINT_TMP_TEXT
|
static int |
PAINT_TOP_RULER
|
protected ConsoleMessage |
printer
|
protected java.awt.Point |
ptmp
|
protected FigCanvasRubberband |
rubberband
|
protected int |
RULER_XL_OFFSET
|
protected int |
RULER_XR_OFFSET
|
protected int |
RULER_YB_OFFSET
|
protected int |
RULER_YT_OFFSET
|
protected static java.awt.Font |
rulerFont
|
(package private) long |
t_delay
|
(package private) long |
t_grid
|
(package private) long |
t_grid_mean
|
(package private) long |
t_redraw
|
(package private) long |
t_redraw_mean
|
protected java.awt.image.ImageObserver |
theObserver
|
protected java.awt.Point |
tmp_sc
|
protected java.awt.Point |
tmp_wc
|
protected FigTrafo2D |
trafo
|
protected java.awt.Image |
tripleBuffer
|
protected java.awt.Graphics |
tripleBufferGR
|
protected Format |
two_decimals
|
protected boolean |
useTripleBuffering
|
java.awt.Cursor |
waitCursor
|
protected java.awt.Dimension |
XXX
|
protected int |
zoomFitBorderWidth
|
protected java.util.Vector |
zoomListenerVector
|
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 | |
FigSwingCanvas()
The FigSwingCanvas public contructor. |
Method Summary | |
void |
addCanvasListener(FigCanvasListener listener)
|
void |
addZoomListener(ZoomListener zl)
|
void |
blitOffscreenBuffer(java.awt.Graphics g)
|
void |
blitOffscreenBufferClipped(java.awt.Graphics g)
|
void |
blitTripleBuffer(java.awt.Graphics g)
|
boolean |
canvasSizeChanged()
|
void |
changeRubberbandMode(int new_mode)
changeRubberbandMode(): change the current mode of our rubberband |
void |
changeRubberbandMode(int mode,
FigTrafo2D t,
java.lang.Object b)
|
void |
changeRubberbandMode(int new_mode,
GeometryManager gm)
|
void |
clearBuffer(java.awt.Graphics g)
clear the Image before drawing the rulers and the grid itself. |
void |
clippedDrawTmpObject(java.awt.Graphics g)
NOTE: this method is currently not used anywhere; and it is possibly broken. |
void |
doFullRedraw()
doFullRedraw(): redraw everything... |
void |
doFullRedraw(long millis)
|
void |
doMotionRedraw()
|
void |
doObjectRedraw()
|
void |
doPanning(int direction,
boolean shift)
automatic panning of the visible viewport on the world-coordinate system. |
void |
doSimpleRedraw()
repaint the canvas under the assumption that at most the temporary FIG objects have changed. |
void |
doSyncRedraw()
method stub for synchronous repaints: FigSwingCanvas itself just provides a doSimpleRedraw(). |
void |
doSystemRedraw()
|
void |
doTextRedraw()
|
void |
doToggleRubberbandDebug()
|
void |
doZoom11()
restore to zoom-factor 1 and origin (0,0) |
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 |
doZoomFull()
restore to zoom factor 1 |
void |
doZoomIn()
zoom in by a factor of two. |
void |
doZoomIn14()
|
void |
doZoomOut()
try to halve the current zoom factor (if possible), then redraw all. |
void |
doZoomOut07()
|
void |
doZoomRegion(int wx,
int wy,
int wx2,
int wy2)
doZoomRegion(): zoom into the world coordinate region given by corners (wx,wy) and (wx2, wy2). |
void |
drawAllObjects(java.awt.Graphics g)
drawAllObjects(): This traverses the parent's object list and draws all objects marked visible. |
void |
drawGrid(java.awt.Graphics gridGR)
Actually draw the grid, assuming that the offscreenBuffers are already created and of the right size. |
void |
drawGridByHand(java.awt.Graphics gridGR)
This is the "naive" implementation of drawGrid, which actually draws all N*N grid points by individual calls to drawRect. |
void |
drawObject(java.awt.Graphics g,
FigObject object)
draw the specified object. |
void |
drawRulers(java.awt.Graphics g)
drawRulers: draw the scale rulers on top and the right side of the canvas. |
void |
drawSliders(java.awt.Graphics g,
boolean erase)
draw the sliders to mark the current position. |
void |
drawSlidersAndCursor(java.awt.Graphics g,
boolean erase)
draw the sliders in the rulers and the cursor. |
void |
drawSlidersOnce(java.awt.Graphics g,
int x,
int y)
drawSlidersOnce: internal helper function to draw the sliders/cross-hatch at position (x,y). |
void |
drawTmpObjects(java.awt.Graphics g)
|
void |
drawTriangles(java.awt.Graphics g,
int xmax,
int ymax)
draw the 'scrollbar triangles' |
void |
eraseObject(java.awt.Graphics g,
FigObject object)
erase the specified object. |
void |
flush()
called to help the AWT to release OS resources; the FigSwingCanvas may NOT be used after this was called. |
java.awt.Color |
getBackground()
|
java.awt.Component |
getComponent()
return the AWT/Swing component that actually implements the canvas |
void |
getCurrentCanvasSize()
get the current FigSwingCanvas dimensions and store in our instance vars cur_width and cur_height. |
boolean |
getDebug()
|
java.awt.Color |
getGridColor()
|
java.awt.Point |
getMousePosition()
|
FigDrawableEnumerator |
getObjectEnumerator()
|
java.awt.Graphics |
getOffscreenGraphics()
return a reference to the offscreen Graphics when double-buffering |
FigSwingCanvas.Options2D |
getOptions2D()
|
java.lang.String |
getSwingRepaintMode()
|
FigTrafo2D |
getTrafo()
return the current coordinate transformation used for this canvas. |
java.awt.Point |
getViewportWCmax()
return the world coordinates of the right-bottom corner of this canvas (depending on it's size and the zoom-factor). |
FigBbox |
getVisibleRegionBoundingBox()
|
int |
getZoomFitBorderWidth()
|
boolean |
gotFocus()
|
void |
handleRedraw(java.awt.Graphics g)
The handleRedraw method is defined in the FigCanvas interface, but is only exposing details of the inner workings of FigBasicCanvas. |
void |
initializeOffscreenBuffers()
update the offscreen buffer images. |
boolean |
isDoubleBuffered()
we do not want that Swing should manage a double buffer for us. |
boolean |
isOpaque()
returns true. |
boolean |
isOptimizedDrawingEnabled()
returns true. |
boolean |
isRightYRuler()
if rulers are enabled, should the Y ruler be drawn on the right side (true) or on the left side (false) of this canvas? Default return value is true (right side). |
static void |
main(java.lang.String[] argv)
main(): simple self test of FigSwingCanvas inside a Frame. |
void |
mouseClicked(java.awt.event.MouseEvent evt)
|
void |
mouseDragged(java.awt.event.MouseEvent evt)
Handle MouseDrag events: Currently, mouseDrag events are used for canvas panning. |
void |
mouseEntered(java.awt.event.MouseEvent evt)
mouseEntered(): request the keyboard focus. |
void |
mouseExited(java.awt.event.MouseEvent evt)
|
void |
mouseMoved(java.awt.event.MouseEvent evt)
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 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 |
msg(java.lang.String msg)
print messages to console window or stdout |
void |
notifyZoomListeners()
|
void |
paint(FigDrawable obj)
a method that allows animated objects to update their current state. |
void |
paint(FigDrawable obj,
int millis)
repaint an (animated) object within millis milliseconds. |
void |
paint(java.awt.Graphics g)
dispatches to paintComponent(). |
void |
paintAllObjects(java.awt.Graphics g)
repaint the canvas after update the offscreen buffer. |
void |
paintBorder(java.awt.Graphics g)
does nothing. |
void |
paintComponent(java.awt.Graphics g)
paint this FigSwingCanvas including grid, rulers, objects, rubberband. |
void |
paintCursor(java.awt.Graphics g)
|
void |
paintImmediately(int x,
int y,
int w,
int h)
dispatches to JComponent.paintImmediately(). |
void |
paintNoChanges(java.awt.Graphics g)
repaint the canvas under the assumption that the visible FIG objects have not changed. |
void |
paintRubberband(java.awt.Graphics g)
|
void |
paintTmpText(java.awt.Graphics g)
|
void |
printTimingStats()
|
void |
processKeyEvent(java.awt.event.KeyEvent ko)
|
void |
removeZoomListener(ZoomListener zl)
|
void |
repaint(int millis)
request a standard repaint after (at most) millis milliseconds. |
void |
requestAntiAliasing(boolean b)
|
void |
requestRenderQuality(boolean b)
|
void |
setBackground(java.awt.Color c)
|
void |
setConsole(ConsoleMessage printer)
set the message console |
void |
setDebug(boolean debug)
|
void |
setDefaultCursor(java.awt.Cursor c)
|
void |
setEnableRulerDragging(boolean b)
|
void |
setGrid(int gridMode)
set a new grid spacing. |
void |
setGridColor(java.awt.Color c)
set new grid color |
void |
setObjectEnumerator(FigDrawableEnumerator enumerator)
specify the object that will provide this canvas with the Enumeration of drawable objects. |
void |
setRubberbandAspect(double d)
|
void |
setRubberbandBasePoint(int sx,
int sy)
|
void |
setRubberbandBasePoint(java.awt.Point sp)
set a new base point for the rubberband |
void |
setRubberbandBasePoint2(int sx,
int sy)
|
void |
setRubberbandBasePoint2(java.awt.Point P)
|
void |
setRubberbandShowLineLengths(boolean b)
|
void |
setRulerOffsets()
calculate the offsets required when using rulers on this canvas. |
void |
setStatusMessage(StatusMessage helper)
|
void |
setTrafo(FigTrafo2D trafo)
set the coordinate transformation for this canvas. |
void |
setTripleBuffering(boolean b)
|
void |
setZoomFitBorderWidth(int pixels)
|
void |
showRulers(boolean b)
|
void |
statusMessage(java.lang.String msg)
show or print status msgs |
void |
synchronousRepaint()
request a synchronous repaint of all pending animation repaints. |
void |
update(java.awt.Graphics g)
|
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, 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, getToolTipLocation, getToolTipText, 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, 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 jfig.canvas.FigCanvas |
getCursor, getSize, setCursor |
Field Detail |
protected FigDrawableEnumerator objectEnumerator
protected FigTrafo2D trafo
protected ConsoleMessage printer
protected StatusMessage helper
protected FigCanvasListener canvasListener
protected java.util.Vector zoomListenerVector
public java.awt.Cursor waitCursor
public java.awt.Cursor defaultCursor
protected FigCanvasRubberband rubberband
protected java.awt.image.ImageObserver theObserver
protected java.awt.Image offscreenImage
protected java.awt.Image tripleBuffer
protected java.awt.Graphics offscreenGR
protected java.awt.Graphics objectGR
protected java.awt.Graphics tripleBufferGR
protected int cur_x
protected int cur_y
protected int old_x
protected int old_y
protected int cur_width
protected int cur_height
protected java.awt.Dimension XXX
protected java.awt.Point ptmp
protected java.awt.Point tmp_sc
protected java.awt.Point tmp_wc
protected java.awt.Color backgroundColor
protected java.awt.Color gridColor
protected java.awt.Color defaultColor
protected static final java.awt.Font rulerFont
protected boolean gridVisible
protected int gridMode
protected int zoomFitBorderWidth
public static final int PAINT_TMP_TEXT
public static final int PAINT_NO_CHANGES
public static final int PAINT_TOP_RULER
public static final int PAINT_RIGHT_RULER
public static final int PAINT_CURSOR
public static final int PAINT_RUBBERBAND
public static final int PAINT_OBJECTS
public static final int PAINT_ALL
protected int mode
protected int BASE_ANCHOR_X
protected int BASE_ANCHOR_Y
protected int RULER_XL_OFFSET
protected int RULER_XR_OFFSET
protected int RULER_YT_OFFSET
protected int RULER_YB_OFFSET
int mouse_drag_x
int mouse_drag_y
protected boolean hasRulers
protected boolean enableRulerDragging
protected boolean debug
protected boolean Jdebug
protected boolean enableTimingInfo
protected boolean useTripleBuffering
int n_updates
int n_redraws
long t_redraw
long t_redraw_mean
int n_grid
long t_grid
long t_grid_mean
long t_delay
protected Format two_decimals
int n_trials_to_create_offscreenImage
Constructor Detail |
public FigSwingCanvas()
Method Detail |
public java.lang.String getSwingRepaintMode()
public void setRulerOffsets()
FigCanvas
setRulerOffsets
in interface FigCanvas
public boolean isRightYRuler()
public void setDebug(boolean debug)
setDebug
in interface FigCanvas
public boolean getDebug()
getDebug
in interface FigCanvas
public FigTrafo2D getTrafo()
FigCanvas
getTrafo
in interface FigCanvas
public void setTrafo(FigTrafo2D trafo)
FigCanvas
setTrafo
in interface FigCanvas
public java.awt.Component getComponent()
FigCanvas
getComponent
in interface FigCanvas
public java.awt.Graphics getOffscreenGraphics()
FigCanvas
getOffscreenGraphics
in interface FigCanvas
public void setDefaultCursor(java.awt.Cursor c)
setDefaultCursor
in interface FigCanvas
public void addCanvasListener(FigCanvasListener listener)
addCanvasListener
in interface FigCanvas
public void setObjectEnumerator(FigDrawableEnumerator enumerator)
setObjectEnumerator
in interface FigCanvas
public FigDrawableEnumerator getObjectEnumerator()
getObjectEnumerator
in interface FigCanvas
public void statusMessage(java.lang.String msg)
statusMessage
in interface FigCanvas
public void setStatusMessage(StatusMessage helper)
setStatusMessage
in interface FigCanvas
public void msg(java.lang.String msg)
msg
in interface FigCanvas
public void setConsole(ConsoleMessage printer)
setConsole
in interface FigCanvas
public void setBackground(java.awt.Color c)
setBackground
in interface FigCanvas
public void setGridColor(java.awt.Color c)
setGridColor
in interface FigCanvas
public java.awt.Color getBackground()
getBackground
in interface FigCanvas
public java.awt.Color getGridColor()
getGridColor
in interface FigCanvas
public java.awt.Point getMousePosition()
getMousePosition
in interface FigCanvas
public void showRulers(boolean b)
showRulers
in interface FigCanvas
public void setEnableRulerDragging(boolean b)
setEnableRulerDragging
in interface FigCanvas
public void setTripleBuffering(boolean b)
public void mousePressed(java.awt.event.MouseEvent evt)
mousePressed
in interface FigCanvas
public void mouseReleased(java.awt.event.MouseEvent evt)
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.
mouseReleased
in interface FigCanvas
public void mouseEntered(java.awt.event.MouseEvent evt)
mouseEntered
in interface FigCanvas
public void mouseExited(java.awt.event.MouseEvent evt)
mouseExited
in interface FigCanvas
public void mouseClicked(java.awt.event.MouseEvent evt)
mouseClicked
in interface FigCanvas
public void mouseMoved(java.awt.event.MouseEvent evt)
mouseMoved
in interface FigCanvas
public void mouseDragged(java.awt.event.MouseEvent evt)
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
public boolean gotFocus()
gotFocus
in interface FigCanvas
public void doPanning(int direction, boolean shift)
doPanning
in interface FigCanvas
public boolean isDoubleBuffered()
public boolean isOptimizedDrawingEnabled()
public boolean isOpaque()
public void processKeyEvent(java.awt.event.KeyEvent ko)
public void paint(java.awt.Graphics g)
paint
in interface FigCanvas
public void paintBorder(java.awt.Graphics g)
public void paintImmediately(int x, int y, int w, int h)
public void paintComponent(java.awt.Graphics g)
The current rendering algorithm is as follows: 1. We first check whether the current canvas size still agrees with our offscreen buffer size. If not, we have to re-create the offscreen buffer and set the PAINT_ALL mode. 2. If the PAINT_ALL mode is set, e.g. as a result of doFullRedraw() or a window resize, we update the offscreen buffer first. This consists of drawing the grid, all FIG objects, and the tmp FIG objects onto the background buffer. 3. We bitblt the offscreen buffer onto the screen. 4. We draw the rulers, rubberband, and cursor on the screen.
Note: Experiments with all current JDKs (1.3+, 1.4+) from Sun, Blackdown, and IBM show that the Graphics XOR-mode rendering does not work reliably, especially for font rendering. (to say the least). Therefore, the redraw cannot use the (potentially) much faster XOR-mode based rubberbanding, but always has to do a bitblt with subsequent overdraw...
public void paintNoChanges(java.awt.Graphics g)
public void paintCursor(java.awt.Graphics g)
public void paintRubberband(java.awt.Graphics g)
public void paintTmpText(java.awt.Graphics g)
public void paintAllObjects(java.awt.Graphics g)
public void paint(FigDrawable obj)
paint
in interface FigCanvas
public void paint(FigDrawable obj, int millis)
paint
in interface FigCanvas
public void repaint(int millis)
repaint
in interface FigCanvas
public void synchronousRepaint()
synchronousRepaint
in interface FigCanvas
public void update(java.awt.Graphics g)
update
in interface FigCanvas
public void drawTmpObjects(java.awt.Graphics g)
drawTmpObjects
in interface FigCanvas
public void clippedDrawTmpObject(java.awt.Graphics g)
clippedDrawTmpObject
in interface FigCanvas
public void blitTripleBuffer(java.awt.Graphics g)
public void blitOffscreenBuffer(java.awt.Graphics g)
blitOffscreenBuffer
in interface FigCanvas
public void blitOffscreenBufferClipped(java.awt.Graphics g)
blitOffscreenBufferClipped
in interface FigCanvas
public void printTimingStats()
printTimingStats
in interface FigCanvas
public void doFullRedraw()
doFullRedraw
in interface FigCanvas
public void doFullRedraw(long millis)
doFullRedraw
in interface FigCanvas
public void doSimpleRedraw()
doSimpleRedraw
in interface FigCanvas
public void doTextRedraw()
doTextRedraw
in interface FigCanvas
public void doObjectRedraw()
doObjectRedraw
in interface FigCanvas
public void doMotionRedraw()
doMotionRedraw
in interface FigCanvas
public void doSystemRedraw()
doSystemRedraw
in interface FigCanvas
public void doSyncRedraw()
This method should be overridden by subclasses as necessary.
doSyncRedraw
in interface FigCanvas
public void handleRedraw(java.awt.Graphics g)
handleRedraw
in interface FigCanvas
public void eraseObject(java.awt.Graphics g, FigObject object)
eraseObject
in interface FigCanvas
public void drawObject(java.awt.Graphics g, FigObject object)
drawObject
in interface FigCanvas
public void drawSlidersAndCursor(java.awt.Graphics g, boolean erase)
drawSlidersAndCursor
in interface FigCanvas
public void drawSlidersOnce(java.awt.Graphics g, int x, int y)
public void drawSliders(java.awt.Graphics g, boolean erase)
public final java.awt.Point getViewportWCmax()
getViewportWCmax
in interface FigCanvas
public FigBbox getVisibleRegionBoundingBox()
getVisibleRegionBoundingBox
in interface FigCanvas
public void drawAllObjects(java.awt.Graphics g)
drawAllObjects
in interface FigCanvas
g
- the graphics-context to draw into (e.g. the FigCanvas
screen or the offscreenImage buffer).public void setGrid(int gridMode)
This function implies a full redraw, in order to generate the new grid.
setGrid
in interface FigCanvas
public void drawRulers(java.awt.Graphics g)
public void drawTriangles(java.awt.Graphics g, int xmax, int ymax)
public void getCurrentCanvasSize()
public void initializeOffscreenBuffers()
In order to run jfig both as an applet or standalone application, we have to be a little cautious here: While the applet's browser will be visible, it will provide us with a working graphics context. The standalone application will only receive a graphics context, when its frame is fully constructed and finally visible. As we need some graphics context, before we can proceed to build the offscreen buffer images, this implies that we have to wait until the editor frame window is already show()ing.
I consider this to be a bad Java JDK-10 bug, but it may be a feature :-)
public boolean canvasSizeChanged()
public void flush()
flush
in interface FigCanvas
public void clearBuffer(java.awt.Graphics g)
public void drawGrid(java.awt.Graphics gridGR)
gridGR
- the Graphics for drawing.public void drawGridByHand(java.awt.Graphics gridGR)
public void setZoomFitBorderWidth(int pixels)
public int getZoomFitBorderWidth()
public void doZoomFit()
FigCanvas
doZoomFit
in interface FigCanvas
public void doZoomOut()
doZoomOut
in interface FigCanvas
public void doZoomIn()
doZoomIn
in interface FigCanvas
public void doZoomFull()
doZoomFull
in interface FigCanvas
public void doZoom11()
doZoom11
in interface FigCanvas
public void doZoomRegion(int wx, int wy, int wx2, int wy2)
doZoomRegion
in interface FigCanvas
public void doZoomIn14()
public void doZoomOut07()
public void addZoomListener(ZoomListener zl)
addZoomListener
in interface FigCanvas
public void removeZoomListener(ZoomListener zl)
removeZoomListener
in interface FigCanvas
public void notifyZoomListeners()
notifyZoomListeners
in interface FigCanvas
public final void changeRubberbandMode(int new_mode)
changeRubberbandMode
in interface FigCanvas
public final void changeRubberbandMode(int new_mode, GeometryManager gm)
changeRubberbandMode
in interface FigCanvas
public final void changeRubberbandMode(int mode, FigTrafo2D t, java.lang.Object b)
changeRubberbandMode
in interface FigCanvas
public final void setRubberbandBasePoint(java.awt.Point sp)
setRubberbandBasePoint
in interface FigCanvas
public final void setRubberbandBasePoint(int sx, int sy)
setRubberbandBasePoint
in interface FigCanvas
public final void setRubberbandBasePoint2(java.awt.Point P)
setRubberbandBasePoint2
in interface FigCanvas
public final void setRubberbandBasePoint2(int sx, int sy)
setRubberbandBasePoint2
in interface FigCanvas
public final void setRubberbandAspect(double d)
setRubberbandAspect
in interface FigCanvas
public void doToggleRubberbandDebug()
doToggleRubberbandDebug
in interface FigCanvas
public void setRubberbandShowLineLengths(boolean b)
setRubberbandShowLineLengths
in interface FigCanvas
public void requestRenderQuality(boolean b)
requestRenderQuality
in interface FigCanvas
public void requestAntiAliasing(boolean b)
requestAntiAliasing
in interface FigCanvas
public FigSwingCanvas.Options2D getOptions2D()
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |