|
||||||||||
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
javax.swing.JPanel
hades.gui.JCanvasScroller
provide and manage standard scrollbars for a jfig/Hades FigCanvas. JCanvasScroller is a Swing GUI component that provides a panel with a central FigCanvas (with its own internal rulers, if enabled), bottom and right scrollbars for the FigCanvas, and a simple panel 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 JCanvasScroller 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 JCanvasScroller, 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, JCanvasScroller 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 |
JCanvasScroller.DummyObjectEnumerator
|
(package private) class |
JCanvasScroller.Filler
inner class Filler: used to fill the bottom right corner in a BorderLayout with two Scrollbars |
(package private) class |
JCanvasScroller.InfoLabel
inner class |
Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
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 javax.swing.JPanel |
bottomPanel
|
protected boolean |
clipToObjectBoundingBox
|
protected javax.swing.JLabel |
coordLabel
|
protected FigCanvas |
editorCanvas
|
protected JCanvasScroller.Filler |
filler
|
protected static boolean |
funny_swing_first_time
|
protected boolean |
funny_swing_ignore_track_event
|
protected JCanvasScroller.InfoLabel |
infoLabel
|
protected javax.swing.JPanel |
labelPanel
|
protected FigBbox |
objectBBox
|
protected javax.swing.JScrollBar |
scrollbarX
|
protected javax.swing.JScrollBar |
scrollbarY
|
protected FigBbox |
totalBBox
|
protected FigBbox |
visibleRegionBBox
|
protected javax.swing.JLabel |
zoomLabel
|
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 java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
JCanvasScroller(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 javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
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, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, getBackground, 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 |
Field Detail |
protected FigCanvas editorCanvas
protected javax.swing.JPanel bottomPanel
protected javax.swing.JPanel labelPanel
protected javax.swing.JScrollBar scrollbarX
protected javax.swing.JScrollBar scrollbarY
protected javax.swing.JLabel coordLabel
protected javax.swing.JLabel zoomLabel
protected JCanvasScroller.Filler filler
protected JCanvasScroller.InfoLabel infoLabel
protected FigBbox objectBBox
protected FigBbox visibleRegionBBox
protected FigBbox totalBBox
protected boolean clipToObjectBoundingBox
protected boolean funny_swing_ignore_track_event
protected static boolean funny_swing_first_time
Constructor Detail |
public JCanvasScroller(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 |