All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class macrolanguage.MouseManager

java.lang.Object
   |
   +----macrolanguage.MouseManager

public class MouseManager
extends Object
implements MouseListener, MouseMotionListener
this class is a part of FreeFormEdit torn out to allow a more dynamic design, rather than concentrating all the events into one class I removed all the mouse events to a separate class. ATTENTION: most of the method in this class are deprecated. They were used in the previos article but are no longer in use in this article.


Variable Index

 o client
 o lastMousePosition

Constructor Index

 o MouseManager(FreeFormEdit)
The constructor needs a pointer to it's FreeFormEdit owner so it will be able to respond to it's events with callback for methods.

Method Index

 o calculateParentContainerXY(Component, Container, int, int)
this method recives a component ,a container and an x,y coordinate.
 o calculateRelativePosition(Point, Component)
this method recives a point and a component to which the point is relative and calculates the same point relative to this Component.
 o componentDragged(MouseEvent)
Called whenever a mouse gets dragged.
 o componentResized(MouseEvent)
gets called when a resize operation occurs on a component.
 o mouseClicked(MouseEvent)
required by the MouseListener interface.
 o mouseDragged(MouseEvent)
This method is a part of the MouseMotionListener interface and is called whenever a mouse is dragged.
 o mouseEntered(MouseEvent)
required by the MouseMotionListener interface.
 o mouseExited(MouseEvent)
required by the MouseMotionListener interface.
 o mouseMoved(MouseEvent)
required by the MouseMotionListener interface.
 o mousePressed(MouseEvent)
required by the MouseListener interface.
 o mouseReleased(MouseEvent)
required by the MouseListener interface.
 o placeComponentOnNextClick(Component)
places the component comp on the next click on the free form edit surface.

Variables

 o lastMousePosition
 private Point lastMousePosition
 o client
 private FreeFormEdit client

Constructors

 o MouseManager
 MouseManager(FreeFormEdit client)
The constructor needs a pointer to it's FreeFormEdit owner so it will be able to respond to it's events with callback for methods.

Methods

 o calculateParentContainerXY
 private Point calculateParentContainerXY(Component relativeComponent,
                                          Container owningContainer,
                                          int x,
                                          int y)
this method recives a component ,a container and an x,y coordinate. When a mouse event is recived we get a relative x,y coordinate to the owning component and not the container, if we need an absolute position relative to the owning container we need to use this method.

 o calculateRelativePosition
 private Point calculateRelativePosition(Point pos,
                                         Component c)
this method recives a point and a component to which the point is relative and calculates the same point relative to this Component.

 o componentDragged
 private void componentDragged(MouseEvent ev)
Called whenever a mouse gets dragged.

 o componentResized
 private void componentResized(MouseEvent ev)
gets called when a resize operation occurs on a component.

 o mouseClicked
 public void mouseClicked(MouseEvent ev)
required by the MouseListener interface. When a mouse is clicked that could mean 2 things: 1. Selection of a component on the surface. 2. Dropping a new component onto the surface.

 o mouseDragged
 public void mouseDragged(MouseEvent ev)
This method is a part of the MouseMotionListener interface and is called whenever a mouse is dragged. This method abstracts the dragging and dropping of components on the free form surface.

 o mouseEntered
 public void mouseEntered(MouseEvent ev)
required by the MouseMotionListener interface.

 o mouseExited
 public void mouseExited(MouseEvent ev)
required by the MouseMotionListener interface.

 o mouseMoved
 public void mouseMoved(MouseEvent ev)
required by the MouseMotionListener interface. used to determin when to diplay the resize mouse pointer on the components.

 o mousePressed
 public void mousePressed(MouseEvent ev)
required by the MouseListener interface.

 o mouseReleased
 public void mouseReleased(MouseEvent ev)
required by the MouseListener interface. The drop operation when dragging is implemented here.

 o placeComponentOnNextClick
 public void placeComponentOnNextClick(Component comp)
places the component comp on the next click on the free form edit surface.


All Packages  Class Hierarchy  This Package  Previous  Next  Index