: Download: FAQ: Licensing: Support: Contact ME
LwVCL Home
Introduction
Overview
On-line Demo
Further Plans
Docs
API
FAQ
Download
Latest version

Home > GDP > API

Overview  Package   Class  Tree  Deprecated  Index  Help 

org.zaval.lw.gdp
Class ShapeController

java.lang.Object
  |
  +--org.zaval.lw.gdp.Controller
        |
        +--org.zaval.lw.gdp.ShapeController
All Implemented Interfaces:
java.util.EventListener, LwMouseMotionListener

public class ShapeController
extends Controller
implements LwMouseMotionListener

This is shape controller class that can be used to control size and location for the specified target component.

The controller registers itself as LwMouseMotionListener listener of the target component and registers a cursor controller for the target component.


Fields inherited from class org.zaval.lw.gdp.Controller
target
 
Constructor Summary
ShapeController(LwComponent target)
          Constructs a new shape controller with the specified target component.
 
Method Summary
 void endDragged(LwMouseEvent e)
          Invoked when mouse drag is stopped.
protected  java.awt.Insets getBoundsMask()
          Gets the insets mask.
 void mouseDragged(LwMouseEvent e)
          Invoked every time when mouse drag event is performed with the source component.
 void mouseMoved(LwMouseEvent e)
           
protected  void moveComponent(int ax, int ay)
          Moves the target component to the new location.
protected  void resizeComponent(java.awt.Rectangle r)
          Shapes the target component with the specified bounds.
 void startDragged(LwMouseEvent e)
          Invoked when first mouse drag events has been performed with the source component.
protected  void targetWasChanged(LwComponent n, LwComponent o)
          The method is called whenever the target component has been changed.
 
Methods inherited from class org.zaval.lw.gdp.Controller
getTarget, setTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeController

public ShapeController(LwComponent target)
Constructs a new shape controller with the specified target component.
Parameters:
target - the specified target component.
Method Detail

mouseMoved

public void mouseMoved(LwMouseEvent e)
Specified by:
mouseMoved in interface LwMouseMotionListener

startDragged

public void startDragged(LwMouseEvent e)
Invoked when first mouse drag events has been performed with the source component.
Specified by:
startDragged in interface LwMouseMotionListener
Parameters:
e - the specified mouse drag event.

mouseDragged

public void mouseDragged(LwMouseEvent e)
Invoked every time when mouse drag event is performed with the source component.
Specified by:
mouseDragged in interface LwMouseMotionListener
Parameters:
e - the specified mouse drag event.

endDragged

public void endDragged(LwMouseEvent e)
Invoked when mouse drag is stopped.
Specified by:
endDragged in interface LwMouseMotionListener
Parameters:
e - the specified mouse drag event.

moveComponent

protected void moveComponent(int ax,
                             int ay)
Moves the target component to the new location.
Parameters:
ax - the specified x coordinate relatively the top-level parent component of the target component.
ay - the specified y coordinate relatively the top-level parent component of the target component.

resizeComponent

protected void resizeComponent(java.awt.Rectangle r)
Shapes the target component with the specified bounds.
Parameters:
r - the new bounds for the target component. The x and y fields of the bounds define a new location of the target relatively the top-level parent component.

getBoundsMask

protected java.awt.Insets getBoundsMask()
Gets the insets mask. The insets indicates what bounds should be changed. It is necessary to use 0 or 1 value as the insets fields values. The insets fileds meaning is described below:
  • left field indicates that x top-left corner coordinate of the target component should be changed according to the current mouse pointer location (a location of the bottom-right corner is not changed).
  • top field indicates that y top-left corner coordinate of the target component should be changed according to the current mouse pointer location (a location of the bottom-right corner is not changed).
  • right field indicates that x bottom-right corner coordinate of the target component should be changed according to the current mouse pointer location (a location of the top-left corner is not changed).
  • bottom field indicates that y bottom-right corner coordinate of the target component should be changed according to the current mouse pointer location (a location of the top-left corner is not changed).
  • If all fields are set to 1 than the component will be moved. In this case the target can get a new parent container.
  • The insets is null if nothing should be changed for the target component.

The implementation defines the insets fields according to the current mouse cursor type (the mouse cursor type is set with the cursor controller). The table below shows the correspondence the cursor type and the insets that will be returned.
Cursor type Returned insets
Cursor.W_RESIZE_CURSOR left=1, top=0, right=0, bottom=0
Cursor.E_RESIZE_CURSOR left=0, top=0, right=1, bottom=0
Cursor.N_RESIZE_CURSOR left=0, top=1, right=0, bottom=0
Cursor.S_RESIZE_CURSOR left=0, top=0, right=0, bottom=1
Cursor.NW_RESIZE_CURSOR left=1, top=1, right=0, bottom=0
Cursor.NE_RESIZE_CURSOR left=0, top=1, right=1, bottom=0
Cursor.SW_RESIZE_CURSOR left=1, top=0, right=0, bottom=1
Cursor.SE_RESIZE_CURSOR left=0, top=0, right=1, bottom=1
Cursor.MOVE_CURSOR left=1, top=1, right=1, bottom=1

Returns:
an insets.

targetWasChanged

protected void targetWasChanged(LwComponent n,
                                LwComponent o)
The method is called whenever the target component has been changed. The controller uses cursor controller and drag controller, so the method implementation synchronizes the new target with the two controllers.
Overrides:
targetWasChanged in class Controller
Parameters:
n - the specified new target component.
o - the specified old target component.


: up