net.sf.latexdraw.glib.handlers
Class Handler<T extends java.awt.Shape>

java.lang.Object
  extended by net.sf.latexdraw.glib.handlers.Handler<T>
All Implemented Interfaces:
IHandler, Pickable
Direct Known Subclasses:
ArcAngleHandler, CtrlPointHandler, MovePtHandler, RotationHandler, ScaleHandler

abstract class Handler<T extends java.awt.Shape>
extends java.lang.Object
implements IHandler

A handler helps to manipulate and to delimit a shape view.

This file is part of LaTeXDraw
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

08/28/11

Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
protected  java.awt.Color colour
          The colour of the handler.
protected  int opacity
          The opacity of the delimiters.
protected  IPoint point
          The coordinates of the centre of the delimiter.
protected  T shape
          The shape of the handler.
protected  double size
          The size of the handler.
 
Fields inherited from interface net.sf.latexdraw.glib.handlers.IHandler
DEFAULT_SIZE
 
Constructor Summary
Handler()
          Creates the handler.
 
Method Summary
 boolean contains(double x, double y)
          Tests if the given point is into the pickable object.
 IPoint getCentre()
           
 java.awt.Color getColour()
           
 int getOpacity()
           
 Picker getPicker()
           
 double getSize()
           
 double getX()
           
 double getY()
           
 void paint(java.awt.Graphics2D g)
          paint the handler.
 void setOpacity(int opacity)
           
 void setPoint(double x, double y)
          Changes the centre of the handler and updates the shape.
 void setSize(double size)
          Sets the width of the handler and updates the shape.
 java.lang.String toString()
           
 void update()
          Updates the handler.
 void updateFromShape(java.awt.Shape sh)
          Updates the handler using the given shape.
protected abstract  void updateShape()
          Updates the Java2D shape of the handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

point

protected IPoint point
The coordinates of the centre of the delimiter.


size

protected double size
The size of the handler.


opacity

protected int opacity
The opacity of the delimiters. Can be changed.


colour

protected java.awt.Color colour
The colour of the handler.


shape

protected T extends java.awt.Shape shape
The shape of the handler.

Constructor Detail

Handler

public Handler()
Creates the handler.

Method Detail

setPoint

public void setPoint(double x,
                     double y)
Changes the centre of the handler and updates the shape.

Specified by:
setPoint in interface IHandler
Parameters:
x - The new X coordinate.
y - The new Y coordinate.

setSize

public void setSize(double size)
Sets the width of the handler and updates the shape.

Specified by:
setSize in interface IHandler
Parameters:
size - Its new width. Must be greater than 0.

getX

public double getX()
Specified by:
getX in interface IHandler
Returns:
The X-coordinate of the handler.

getCentre

public IPoint getCentre()
Specified by:
getCentre in interface IHandler
Returns:
The centre of the handler.

getY

public double getY()
Specified by:
getY in interface IHandler
Returns:
The Y-coordinate of the handler.

paint

public void paint(java.awt.Graphics2D g)
paint the handler.

Specified by:
paint in interface IHandler
Parameters:
g - The object into which objects are painted.

update

public void update()
Updates the handler.

Specified by:
update in interface IHandler

updateShape

protected abstract void updateShape()
Updates the Java2D shape of the handler.

Since:
3.0

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSize

public double getSize()
Specified by:
getSize in interface IHandler
Returns:
the size of the handler.

getOpacity

public int getOpacity()
Specified by:
getOpacity in interface IHandler
Returns:
The opacity of the handler.

setOpacity

public void setOpacity(int opacity)
Specified by:
setOpacity in interface IHandler
Parameters:
opacity - the opacity to set.

getColour

public java.awt.Color getColour()
Specified by:
getColour in interface IHandler
Returns:
The colour of the handler.

updateFromShape

public void updateFromShape(java.awt.Shape sh)
Description copied from interface: IHandler
Updates the handler using the given shape.

Specified by:
updateFromShape in interface IHandler
Parameters:
sh - The shape used to updated the handler.

contains

public boolean contains(double x,
                        double y)
Description copied from interface: Pickable
Tests if the given point is into the pickable object.

Specified by:
contains in interface Pickable
Parameters:
x - The x-coordinate of the point to test.
y - The y-coordinate of the point to test.
Returns:
True if the given point is into the pickable object.

getPicker

public Picker getPicker()
Specified by:
getPicker in interface Pickable
Returns:
The picker object that contains the pickable object.