java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
de.uni_trier.wi2.procake.gui.objecteditor.nestworkfloweditor.editor.EditorRuler
All Implemented Interfaces:
DropTargetListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener

public class EditorRuler extends JComponent implements MouseMotionListener, DropTargetListener
Component that displays a ruler for a JGraph component.
See Also:
  • Field Details

    • numberFormat

      public static final NumberFormat numberFormat
      Holds the shared number formatter.
      See Also:
    • 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.
    • DEFAULT_PAGESCALE

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

      protected static boolean DEFAULT_ISMETRIC
      Internal constant used to describe the screen resolution (DPI). Default is 72.
    • 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 DEFAULT_PAGESCALE.
    • metric

      protected boolean metric
      Specifies the unit system. Default is DEFAULT_ISMETRIC.
    • labelFont

      protected Font labelFont
    • rulerSize

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

      protected int tickDistance
      Specifies the minimum distance between two major ticks. Default is 30.
    • graphComponent

      protected com.mxgraph.swing.mxGraphComponent graphComponent
      Reference to the attached graph.
    • 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.
    • repaintHandler

      protected transient com.mxgraph.util.mxEventSource.mxIEventListener repaintHandler
  • Constructor Details

    • EditorRuler

      public EditorRuler(com.mxgraph.swing.mxGraphComponent graphComponent, int orientation)
      Constructs a new ruler for the specified graph and orientation.
      Parameters:
      graphComponent - The graph to create the ruler for.
      orientation - The orientation to use for the ruler.
  • Method Details

    • 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.
    • getTickDistance

      public int getTickDistance()
    • setTickDistance

      public void setTickDistance(int tickDistance)
    • getPreferredSize

      public Dimension getPreferredSize()
      Returns the preferred size by replacing the respective component of the graph's preferred size with rulerSize.
      Overrides:
      getPreferredSize in class JComponent
      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
    • updateMousePosition

      protected void updateMousePosition(Point pt)
      Repaints the mouse position.
    • 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.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - The graphics to paint the ruler to.