JGraphpad Pro
v6.0.5.0


com.jgraph.editor.factory
Class JGraphEditorRuler

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.jgraph.editor.factory.JGraphEditorRuler
All Implemented Interfaces:
DropTargetListener, EventListener, ImageObserver, MenuContainer, MouseMotionListener, PropertyChangeListener, Serializable

public class JGraphEditorRuler
extends JComponent
implements MouseMotionListener, DropTargetListener, PropertyChangeListener

Component that displays a ruler for a JGraph component.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  int activelength
          Specified that start and length of the active region, ie the region to paint with the background border.
protected  int activeoffset
          Specified that start and length of the active region, ie the region to paint with the background border.
protected  Point drag
          Holds the current and first mouse point.
protected  org.jgraph.JGraph graph
          Reference to the attached graph.
protected  Color inactiveBackground
          Defines the inactive background border.
protected static int INCH
          Internal constant used to describe the screen resolution (DPI).
protected  double increment
          Parameters to control the display.
protected  boolean isMetric
          Specifies the unit system.
protected  Point mouse
          Holds the current and first mouse point.
static NumberFormat numberFormat
          Holds the shared number formatter.
protected  int orientation
          Specifies the orientation.
static int ORIENTATION_HORIZONTAL
          Defines the constants for horizontal and vertical orientation.
static int ORIENTATION_VERTICAL
          Defines the constants for horizontal and vertical orientation.
protected  int rulerSize
          Specifies height or width of the ruler.
protected  double scale
          Specifies the scale for the metrics.
protected  double units
          Parameters to control the display.
 
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.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
JGraphEditorRuler(org.jgraph.JGraph graph, int orientation)
          Constructs a new ruler for the specified graph and orientation.
 
Method Summary
 void dragEnter(DropTargetDragEvent arg0)
           
 void dragExit(DropTargetEvent arg0)
           
 void dragOver(DropTargetDragEvent arg0)
           
 void drop(DropTargetDropEvent arg0)
           
 void dropActionChanged(DropTargetDragEvent arg0)
           
 Dimension getPreferredSize()
          Returns the preferred size by replacing the respective component of the graph's preferred size with rulerSize.
 int getRulerSize()
          Returns the ruler's horizontal or vertical size.
 boolean isMetric()
          Returns true if the ruler uses metric units.
 void mouseDragged(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void paintComponent(Graphics g)
          Paints the ruler.
 void propertyChange(PropertyChangeEvent event)
           
 void repaint(int x, int y)
          Repaints the ruler between the specified 0 and x or y depending on the orientation.
 void setActiveLength(int length)
          Sets the length of the active region in pixels.
 void setActiveOffset(int offset)
          Sets the start of the active region in pixels.
 void setMetric(boolean isMetric)
          Sets if the ruler uses metric units.
 void setRulerSize(int rulerSize)
          Sets the ruler's horizontal or vertical size.
protected  void updateDragPosition(Point pt)
          Repaints the mouse position.
protected  void updateIncrementAndUnits()
          Updates the local variables used for painting based on the current scale and unit system.
protected  void updateMousePosition(Point pt)
          Repaints the mouse position.
 
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, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, 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, 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

ORIENTATION_HORIZONTAL

public static int ORIENTATION_HORIZONTAL
Defines the constants for horizontal and vertical orientation.


ORIENTATION_VERTICAL

public static int ORIENTATION_VERTICAL
Defines the constants for horizontal and vertical orientation.


INCH

protected static int INCH
Internal constant used to describe the screen resolution (DPI). Default is 72.


numberFormat

public static final NumberFormat numberFormat
Holds the shared number formatter.

See Also:
NumberFormat.getInstance()

inactiveBackground

protected Color inactiveBackground
Defines the inactive background border. Default is a not-so-dark gray.


orientation

protected int orientation
Specifies the orientation.


activeoffset

protected int activeoffset
Specified that start and length of the active region, ie the region to paint with the background border. This is used for example to indicate the printable region of a graph.


activelength

protected int activelength
Specified that start and length of the active region, ie the region to paint with the background border. This is used for example to indicate the printable region of a graph.


scale

protected double scale
Specifies the scale for the metrics. Default is JGraphEditorDiagramPane.DEFAULT_PAGESCALE.


isMetric

protected boolean isMetric
Specifies the unit system. Default is JGraphEditorDiagramPane.DEFAULT_ISMETRIC.


rulerSize

protected int rulerSize
Specifies height or width of the ruler. Default is 15 pixels.


graph

protected org.jgraph.JGraph graph
Reference to the attached graph.


drag

protected Point drag
Holds the current and first mouse point.


mouse

protected Point mouse
Holds the current and first mouse point.


increment

protected double increment
Parameters to control the display.


units

protected double units
Parameters to control the display.

Constructor Detail

JGraphEditorRuler

public JGraphEditorRuler(org.jgraph.JGraph graph,
                         int orientation)
Constructs a new ruler for the specified graph and orientation.

Parameters:
graph - The graph to create the ruler for.
orientation - The orientation to use for the ruler.
Method Detail

setActiveOffset

public void setActiveOffset(int offset)
Sets the start of the active region in pixels.

Parameters:
offset - The start of the active region.

setActiveLength

public void setActiveLength(int length)
Sets the length of the active region in pixels.

Parameters:
length - The length of the active region.

isMetric

public boolean isMetric()
Returns true if the ruler uses metric units.

Returns:
Returns if the ruler is metric.

setMetric

public void setMetric(boolean isMetric)
Sets if the ruler uses metric units.

Parameters:
isMetric - Whether to use metric units.

getRulerSize

public int getRulerSize()
Returns the ruler's horizontal or vertical size.

Returns:
Returns the rulerSize.

setRulerSize

public void setRulerSize(int rulerSize)
Sets the ruler's horizontal or vertical size.

Parameters:
rulerSize - The rulerSize to set.

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size by replacing the respective component of the graph's preferred size with rulerSize.

Returns:
Returns the preferred size for the ruler.

dragEnter

public void dragEnter(DropTargetDragEvent arg0)
Specified by:
dragEnter in interface DropTargetListener

dragExit

public void dragExit(DropTargetEvent arg0)
Specified by:
dragExit in interface DropTargetListener

dragOver

public void dragOver(DropTargetDragEvent arg0)
Specified by:
dragOver in interface DropTargetListener

drop

public void drop(DropTargetDropEvent arg0)
Specified by:
drop in interface DropTargetListener

dropActionChanged

public void dropActionChanged(DropTargetDragEvent arg0)
Specified by:
dropActionChanged in interface DropTargetListener

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener

updateDragPosition

protected void updateDragPosition(Point pt)
Repaints the mouse position.


updateMousePosition

protected void updateMousePosition(Point pt)
Repaints the mouse position.


propertyChange

public void propertyChange(PropertyChangeEvent event)
Specified by:
propertyChange in interface PropertyChangeListener

updateIncrementAndUnits

protected void updateIncrementAndUnits()
Updates the local variables used for painting based on the current scale and unit system.


repaint

public void repaint(int x,
                    int y)
Repaints the ruler between the specified 0 and x or y depending on the orientation.

Parameters:
x - The endpoint for repainting a horizontal ruler.
y - The endpoint for repainting a vertical ruler.

paintComponent

public void paintComponent(Graphics g)
Paints the ruler.

Parameters:
g - The graphics to paint the ruler to.

JGraphpad Pro
v6.0.5.0


Copyright (C) 2005 JGraph.com. All rights reserved.