Class DrawingPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DrawingPanel extends JPanel
Utility class for allowing users to select, resize, and move "Drawables" on a JPanel.
UIChangeEvent is thrown when a Drawable is selected, deselected, resized or moved.
   events can be:  property                   newValue
                  DrawingPanel.SELECT        Boolean   (true: selected, false: deselected)
                  DrawingPanel.RESIZE        Dimension  (new size)
                  DrawingPanel.MOVE          ??         (new position)
 
Version:
$Id: DrawingPanel.java,v 1.9 2007/07/06 20:45:30 jeffmc Exp $
Author:
John Caron
See Also:
  • Field Details

  • Constructor Details

    • DrawingPanel

      public DrawingPanel(boolean changeable)
      constructor
      Parameters:
      changeable - true if the user can edit/change
  • Method Details

    • addUIChangeListener

      public void addUIChangeListener(UIChangeListener l)
      _more_
      Parameters:
      l -
    • removeUIChangeListener

      public void removeUIChangeListener(UIChangeListener l)
      _more_
      Parameters:
      l -
    • getCenterPoint

      public Point2D getCenterPoint()
      Get the center of the DrawingPanel
      Returns:
      the center of the DrawingPanel
    • useCenterPoint

      public void useCenterPoint(boolean use)
      May optionally keep the Drawables reletive to the center of the DrawingPanel
      Parameters:
      use - true if the Drawables should stay centerd in the DrawingPanel
    • addDrawable

      public void addDrawable(Drawable d)
      Add a Drawable to the top. If Drawable bounds overlap, the topmost is found when picking/selecting with the mouse.
      Parameters:
      d -
    • removeAllDrawables

      public void removeAllDrawables()
      remove all Drawables
    • paintComponent

      public void paintComponent(Graphics g)
      paint the DrawingPanel
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g -
    • select

      public void select(String name)
      Select a Drawable by name.
      Parameters:
      name - unique name of Drawable.