public class EditorRuler
extends javax.swing.JComponent
implements java.awt.event.MouseMotionListener, java.awt.dnd.DropTargetListener
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
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 static boolean |
DEFAULT_ISMETRIC
Internal constant used to describe the screen resolution (DPI).
|
protected static int |
DEFAULT_PAGESCALE
Internal constant used to describe the screen resolution (DPI).
|
protected mxGraphComponent |
graphComponent
Reference to the attached graph.
|
protected java.awt.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 java.awt.Font |
labelFont |
protected boolean |
metric
Specifies the unit system.
|
protected java.awt.Point |
mouse
Holds the current and first mouse point.
|
static java.text.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 mxEventSource.mxIEventListener |
repaintHandler |
protected int |
rulerSize
Specifies height or width of the ruler.
|
protected double |
scale
Specifies the scale for the metrics.
|
protected int |
tickDistance
Specifies the minimum distance between two major ticks.
|
protected double |
units
Parameters to control the display.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
EditorRuler(mxGraphComponent graphComponent,
int orientation)
Constructs a new ruler for the specified graph and orientation.
|
Modifier and Type | Method and Description |
---|---|
void |
dragEnter(java.awt.dnd.DropTargetDragEvent arg0) |
void |
dragExit(java.awt.dnd.DropTargetEvent arg0) |
void |
dragOver(java.awt.dnd.DropTargetDragEvent arg0) |
void |
drop(java.awt.dnd.DropTargetDropEvent arg0) |
void |
dropActionChanged(java.awt.dnd.DropTargetDragEvent arg0) |
java.awt.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.
|
int |
getTickDistance() |
boolean |
isMetric()
Returns true if the ruler uses metric units.
|
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
paintComponent(java.awt.Graphics g)
Paints the ruler.
|
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.
|
void |
setTickDistance(int tickDistance) |
protected void |
updateIncrementAndUnits()
Updates the local variables used for painting based on the current scale
and unit system.
|
protected void |
updateMousePosition(java.awt.Point pt)
Repaints the mouse position.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static int ORIENTATION_HORIZONTAL
public static int ORIENTATION_VERTICAL
protected static int INCH
protected static int DEFAULT_PAGESCALE
protected static boolean DEFAULT_ISMETRIC
public static final java.text.NumberFormat numberFormat
NumberFormat.getInstance()
protected java.awt.Color inactiveBackground
protected int orientation
protected int activeoffset
protected int activelength
protected double scale
JGraphEditorDiagramPane#DEFAULT_PAGESCALE
.protected boolean metric
JGraphEditorDiagramPane#DEFAULT_ISMETRIC
.protected java.awt.Font labelFont
protected int rulerSize
protected int tickDistance
protected mxGraphComponent graphComponent
protected java.awt.Point mouse
protected double increment
protected double units
protected transient mxEventSource.mxIEventListener repaintHandler
public EditorRuler(mxGraphComponent graphComponent, int orientation)
graph
- The graph to create the ruler for.orientation
- The orientation to use for the ruler.public void setActiveOffset(int offset)
offset
- The start of the active region.public void setActiveLength(int length)
length
- The length of the active region.public boolean isMetric()
public void setMetric(boolean isMetric)
isMetric
- Whether to use metric units.public int getRulerSize()
public void setRulerSize(int rulerSize)
rulerSize
- The rulerSize to set.public void setTickDistance(int tickDistance)
public int getTickDistance()
public java.awt.Dimension getPreferredSize()
rulerSize
.getPreferredSize
in class javax.swing.JComponent
public void dragEnter(java.awt.dnd.DropTargetDragEvent arg0)
dragEnter
in interface java.awt.dnd.DropTargetListener
public void dragExit(java.awt.dnd.DropTargetEvent arg0)
dragExit
in interface java.awt.dnd.DropTargetListener
public void dragOver(java.awt.dnd.DropTargetDragEvent arg0)
dragOver
in interface java.awt.dnd.DropTargetListener
public void drop(java.awt.dnd.DropTargetDropEvent arg0)
drop
in interface java.awt.dnd.DropTargetListener
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent arg0)
dropActionChanged
in interface java.awt.dnd.DropTargetListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
protected void updateMousePosition(java.awt.Point pt)
protected void updateIncrementAndUnits()
public void repaint(int x, int y)
x
- The endpoint for repainting a horizontal ruler.y
- The endpoint for repainting a vertical ruler.public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- The graphics to paint the ruler to.