|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
hades.gui.CanvasScroller
CanvasScroller - an AWT component to manage a JavaFIG/HADES editor canvas with rulers at the top and left sides, and additional standard right and bottom scrollbars. Also, a simple Label field is provided to display the current mouse coordinates and zoom factor.
This class needs to be provided with the (real or approximate) bounding
box of all visible objects, in order to calculate and set the size and
position of the scrollbar thumbs.
The thumbs are sized to match the ratio of the visible region to
the union of the visible region plus the bounding box of all displayed
objects.
Remember to call 'setObjectBoundingBox( xl, yt, xr, yb )' after any editing
operation in your application which changes this bounding box - otherwise
the visible objects will not match the user expectations built from the
scrollbar sizes.
Usually, you may want to initialize the bounding box with a suitable
default value. For example, call setObjectBoundingBox( 0, 0, 28000, 18600 )
to initialize the CanvasScroller to (approximate) "A4 paper size"
in landscape orientation. This is also the default object bounding box used.
See class jfig.canvas.FigTrafo2D for documentation about the coordinate
system used in JavaFIG/HADES (2400 dpi world coords, origin at top left).
Usually, the default behaviour of scrollbars is to clip all scrolling to the limit of the underlying data model: Once you arrive at the end of your document, you cannot scroll further. This is the default behaviour of CanvasScroller, where the limit of the 'allowed' region is set by calling setObjectBoundingBox.
However, in order to get the xfig/JavaFIG/HADES behaviour of enlarging the current object region as needed, CanvasScroller also implements a variant of the above strategy, where the scrollbars are not clipped to the visible region or any other predefined values. Instead, the scrollbar thumbs are clipped after each event, to allow one more click in the respective direction. For simplicity, scrollbar values are used in the range 0 ... 99. Therefore, we clip the scrollbar thumb position to the range 1 .. 98. Call setClipToBoudingBox( boolean ) to switch the scrollbar clipping on or off.
Nested Class Summary | |
(package private) class |
CanvasScroller.DummyObjectEnumerator
|
(package private) class |
CanvasScroller.Filler
inner class Filler: used to fill the bottom right corner in a BorderLayout with two Scrollbars |
(package private) class |
CanvasScroller.InfoLabel
|
Nested classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
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.Panel |
bottomPanel
|
protected boolean |
clipToObjectBoundingBox
|
protected java.awt.Label |
coordLabel
|
protected FigCanvas |
editorCanvas
|
protected CanvasScroller.Filler |
filler
|
protected CanvasScroller.InfoLabel |
infoLabel
|
protected java.awt.Panel |
labelPanel
|
protected FigBbox |
objectBBox
|
protected java.awt.Scrollbar |
scrollbarX
|
protected java.awt.Scrollbar |
scrollbarY
|
protected FigBbox |
totalBBox
|
protected FigBbox |
visibleRegionBBox
|
protected java.awt.Label |
zoomLabel
|
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 java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
CanvasScroller(FigCanvas _canvas)
|
Method Summary | |
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
|
(package private) void |
buildGUI()
|
int |
clip(int value,
int min_value,
int max_value)
|
void |
componentHidden(java.awt.event.ComponentEvent evt)
|
void |
componentMoved(java.awt.event.ComponentEvent evt)
|
void |
componentResized(java.awt.event.ComponentEvent evt)
|
void |
componentShown(java.awt.event.ComponentEvent evt)
|
void |
doLayout()
|
int |
getScrollbarWidth()
|
static void |
main(java.lang.String[] argv)
|
void |
mouseDragged(java.awt.event.MouseEvent evt)
|
void |
mouseMoved(java.awt.event.MouseEvent evt)
|
static void |
msg(java.lang.String s)
|
void |
rebuildBoundingBoxes()
|
void |
rebuildScrollbars()
rebuild the scrollbar thumbs, assuming that the visible region and object bounding boxes are set correctly (by a previous call to rebuildBoundingBoxes). |
void |
setCanvas(FigCanvas _canvas)
|
void |
setClipToObjectBoundingBox(boolean b)
|
void |
setObjectBoundingBox(int xl,
int yt,
int xr,
int yb)
|
void |
trackScrollbarX()
|
void |
trackScrollbarY()
|
void |
zoomChanged(java.lang.Object arg)
|
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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 |
protected FigCanvas editorCanvas
protected java.awt.Panel bottomPanel
protected java.awt.Panel labelPanel
protected java.awt.Scrollbar scrollbarX
protected java.awt.Scrollbar scrollbarY
protected java.awt.Label coordLabel
protected java.awt.Label zoomLabel
protected CanvasScroller.Filler filler
protected CanvasScroller.InfoLabel infoLabel
protected FigBbox objectBBox
protected FigBbox visibleRegionBBox
protected FigBbox totalBBox
protected boolean clipToObjectBoundingBox
Constructor Detail |
public CanvasScroller(FigCanvas _canvas)
Method Detail |
public void setCanvas(FigCanvas _canvas)
void buildGUI()
public int getScrollbarWidth()
public void doLayout()
public void rebuildBoundingBoxes()
public void setObjectBoundingBox(int xl, int yt, int xr, int yb)
public void setClipToObjectBoundingBox(boolean b)
public void rebuildScrollbars()
public int clip(int value, int min_value, int max_value)
public void componentHidden(java.awt.event.ComponentEvent evt)
componentHidden
in interface java.awt.event.ComponentListener
public void componentMoved(java.awt.event.ComponentEvent evt)
componentMoved
in interface java.awt.event.ComponentListener
public void componentShown(java.awt.event.ComponentEvent evt)
componentShown
in interface java.awt.event.ComponentListener
public void componentResized(java.awt.event.ComponentEvent evt)
componentResized
in interface java.awt.event.ComponentListener
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
adjustmentValueChanged
in interface java.awt.event.AdjustmentListener
public void trackScrollbarX()
public void trackScrollbarY()
public void mouseMoved(java.awt.event.MouseEvent evt)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent evt)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void zoomChanged(java.lang.Object arg)
zoomChanged
in interface ZoomListener
public static void msg(java.lang.String s)
public static void main(java.lang.String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |