net.sf.latexdraw.instruments
Class Border

java.lang.Object
  extended by org.malai.instrument.Instrument
      extended by net.sf.latexdraw.instruments.Border
All Implemented Interfaces:
ActionHandler, Picker, Preferenciable, Modifiable, Reinitialisable, UndoHandler

public class Border
extends Instrument
implements Picker

This instrument manages the selected views.

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.

10/27/10

Version:
3.0
Author:
Arnaud BLOUIN

Nested Class Summary
private static class Border.DnD2MoveCtrlPoint
          This link maps a DnD interaction on a move control point handler to an action that moves the selected control point.
private static class Border.DnD2MovePoint
          This link maps a DnD interaction on a move point handler to an action that moves the selected point.
private static class Border.DnD2Rotate
          This link maps a DnD interaction on a rotation handler to an action that rotates the selected shapes.
private static class Border.DnD2Scale
          This link maps a DnD interaction on a scale handler to an action that scales the selection.
 
Field Summary
protected  ArcAngleHandler arcHandlerEnd
          The handler that sets the end angle of an arc.
protected  ArcAngleHandler arcHandlerStart
          The handler that sets the start angle of an arc.
protected  java.awt.geom.Rectangle2D border
          The rectangle uses to show the selection.
protected  ICanvas canvas
          The canvas that contains the border.
protected  java.util.List<IHandler> ctrlPt1Handlers
          The handlers that move first control points.
protected  java.util.List<IHandler> ctrlPt2Handlers
          The handlers that move second control points.
protected  java.util.List<IHandler> mvPtHandlers
          The handlers that move points.
protected  IHandler rotHandler
          The handler that rotates shapes.
protected  java.util.List<IHandler> scaleHandlers
          The handlers that scale shapes.
protected  java.util.List<IViewShape> selection
          The selected views.
static java.awt.BasicStroke STROKE
          The stroke uses by the border to display its bounding rectangle.
 
Fields inherited from class org.malai.instrument.Instrument
activated, eventables, links, modified
 
Constructor Summary
Border(ICanvas canvas)
          Creates and initialises the border.
 
Method Summary
 void add(IViewShape view)
          Adds the given shape to the selection.
 void clear()
          Removes all the selected views.
 boolean contains(java.lang.Object obj)
          Tests if the given object is contained by the calling picker.
private  IHandler getHandlerAt(double x, double y, java.util.List<IHandler> handlers)
           
 Pickable getPickableAt(double x, double y)
           
 Picker getPickerAt(double x, double y)
           
 java.awt.geom.Point2D getRelativePoint(double x, double y, java.lang.Object o)
           
 java.util.List<IViewShape> getSelection()
           
private  void initialiseCtrlMvHandlers(IControlPointShape cps)
           
protected  void initialiseLinks()
          Initialises the links of the instrument.
 void interimFeedback()
          Reinitialises the interim feedback of the instrument.
protected  boolean isArcHandlerShowable()
           
protected  boolean isCtrlPtMvHandlersShowable()
           
protected  boolean isPtMvHandlersShowable()
           
 void paint(java.awt.Graphics2D g)
          Paints the border if activated.
private  void paintHandlers(java.awt.Graphics2D g)
          Paints the required handlers.
 void reinit()
          Reinitialises the object.
 void remove(IViewShape view)
          Removes the given view from the selection.
 void update()
          Updates the bounding rectangle using the selected views.
private  void updateArcHandlers()
          Updates the arc handlers.
private  void updateCtrlMvHandlers()
          Updates the handlers that move control points.
private  void updateHandlersPosition()
          Updates the position of the handlers.
private  void updateMvHandlers()
          Updates the handlers that move points.
 
Methods inherited from class org.malai.instrument.Instrument
addEventable, addLink, clearEvents, getLinks, getSizeLinks, hasLinks, isActivated, isModified, load, onActionAborted, onActionAdded, onActionCancelled, onActionDone, onActionExecuted, onUndoableAdded, onUndoableRedo, onUndoableUndo, removeLink, save, setActivated, setModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STROKE

public static final java.awt.BasicStroke STROKE
The stroke uses by the border to display its bounding rectangle.


selection

protected java.util.List<IViewShape> selection
The selected views.


border

protected java.awt.geom.Rectangle2D border
The rectangle uses to show the selection.


scaleHandlers

protected java.util.List<IHandler> scaleHandlers
The handlers that scale shapes.


mvPtHandlers

protected java.util.List<IHandler> mvPtHandlers
The handlers that move points.


ctrlPt1Handlers

protected java.util.List<IHandler> ctrlPt1Handlers
The handlers that move first control points.


ctrlPt2Handlers

protected java.util.List<IHandler> ctrlPt2Handlers
The handlers that move second control points.


arcHandlerStart

protected ArcAngleHandler arcHandlerStart
The handler that sets the start angle of an arc.


arcHandlerEnd

protected ArcAngleHandler arcHandlerEnd
The handler that sets the end angle of an arc.


rotHandler

protected IHandler rotHandler
The handler that rotates shapes.


canvas

protected ICanvas canvas
The canvas that contains the border.

Constructor Detail

Border

public Border(ICanvas canvas)
Creates and initialises the border.

Parameters:
canvas - The canvas that contains the border.
Since:
3.0
Method Detail

reinit

public void reinit()
Description copied from interface: Reinitialisable
Reinitialises the object.

Specified by:
reinit in interface Reinitialisable
Overrides:
reinit in class Instrument

interimFeedback

public void interimFeedback()
Description copied from class: Instrument
Reinitialises the interim feedback of the instrument. Must be overridden.

Overrides:
interimFeedback in class Instrument

update

public void update()
Updates the bounding rectangle using the selected views.

Since:
3.0

updateHandlersPosition

private void updateHandlersPosition()
Updates the position of the handlers.

Since:
3.0

updateArcHandlers

private void updateArcHandlers()
Updates the arc handlers.

Since:
3.0

updateCtrlMvHandlers

private void updateCtrlMvHandlers()
Updates the handlers that move control points.

Since:
3.0

initialiseCtrlMvHandlers

private void initialiseCtrlMvHandlers(IControlPointShape cps)

updateMvHandlers

private void updateMvHandlers()
Updates the handlers that move points.

Since:
3.0

paint

public void paint(java.awt.Graphics2D g)
Paints the border if activated.

Parameters:
g - The graphics in which the border is painted.
Since:
3.0

paintHandlers

private void paintHandlers(java.awt.Graphics2D g)
Paints the required handlers.


isCtrlPtMvHandlersShowable

protected boolean isCtrlPtMvHandlersShowable()
Returns:
True if the control move point handlers can be painted.

isPtMvHandlersShowable

protected boolean isPtMvHandlersShowable()
Returns:
True if the move point handlers can be painted.

isArcHandlerShowable

protected boolean isArcHandlerShowable()
Returns:
True if the arc handlers can be painted.

add

public void add(IViewShape view)
Adds the given shape to the selection. If the instrument is activated and the addition is performed, the instrument is updated.

Parameters:
view - The view to add. If null, nothing is done.
Since:
3.0

remove

public void remove(IViewShape view)
Removes the given view from the selection. If the instrument is activated and the removal is performed, the instrument is updated.

Parameters:
view - The view to remove. If null or it is not already in the selection, nothing is performed.
Since:
3.0

getSelection

public java.util.List<IViewShape> getSelection()
Returns:
the selected views. Cannot be null.
Since:
3.0

initialiseLinks

protected void initialiseLinks()
Description copied from class: Instrument
Initialises the links of the instrument.

Specified by:
initialiseLinks in class Instrument

clear

public void clear()
Removes all the selected views.

Since:
3.0

getPickableAt

public Pickable getPickableAt(double x,
                              double y)
Specified by:
getPickableAt in interface Picker
Parameters:
x - The x-coordinate of the position used to get the pickable object.
y - The y-coordinate of the position used to get the pickable object.
Returns:
The pickable object at the given position.

getHandlerAt

private IHandler getHandlerAt(double x,
                              double y,
                              java.util.List<IHandler> handlers)

getPickerAt

public Picker getPickerAt(double x,
                          double y)
Specified by:
getPickerAt in interface Picker
Parameters:
x - The x-coordinate of the position used to get the picker object.
y - The y-coordinate of the position used to get the picker object.
Returns:
The pickable object at the given position.

getRelativePoint

public java.awt.geom.Point2D getRelativePoint(double x,
                                              double y,
                                              java.lang.Object o)
Specified by:
getRelativePoint in interface Picker
Parameters:
x - The x-coordinate of the position to convert.
y - The y-coordinate of the position to convert.
o - An object contained by the calling picker. This function will computed the real position of the given point in o.
Returns:
Converts the given point in to fit the coordinates of the given object contained by the picker. For instance, given an object o1 that contains an other object o2 at position (10, 10). o1.getRelativePoint(30, 30, o2) will return (20, 20).

contains

public boolean contains(java.lang.Object obj)
Description copied from interface: Picker
Tests if the given object is contained by the calling picker.

Specified by:
contains in interface Picker
Parameters:
obj - The object to test.
Returns:
True: the given object is contained by the calling picker.