net.sf.latexdraw.instruments
Class Pencil

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

public class Pencil
extends Instrument

This instrument allows to draw shapes.

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.

05/13/10

Version:
3.0
Author:
Arnaud BLOUIN

Field Summary
protected  EditionChoice currentChoice
          The current editing choice (rectangle, ellipse, etc.) of the instrument.
protected  IDrawing drawing
          The drawing that contains the shapes.
protected  LMagneticGrid grid
          The magnetic grid used to create shapes.
protected  IGroup groupParams
           
protected  javax.swing.JFileChooser pictureFileChooser
          The file chooser used to select pictures.
protected  TextSetter textSetter
          The instrument used to add and modify texts.
protected  Zoomer zoomer
          The zoomer that is used to give the zoom level to compute coordinates of the created shapes.
 
Fields inherited from class org.malai.instrument.Instrument
activated, eventables, links, modified
 
Constructor Summary
Pencil(IDrawing drawing, Zoomer zoomer, LMagneticGrid grid, TextSetter textSetter)
          Creates a pencil.
 
Method Summary
 IShape createShapeInstance()
           
 IPoint getAdaptedPoint(java.awt.Point point)
          Computes the point depending on the the zoom level and the magnetic grid.
 EditionChoice getCurrentChoice()
           
 IGroup getGroupParams()
           
 javax.swing.JFileChooser getPictureFileChooser()
           
protected  void initialiseLinks()
          Initialises the links of the instrument.
 void interimFeedback()
          Reinitialises the interim feedback of the instrument.
 void setActivated(boolean activated)
          Activates or deactivates the instrument.
 void setCurrentChoice(EditionChoice currentChoice)
          Sets the current editing choice.
 void setShapeParameters(IShape shape)
          Configures the given shape with the parameters (e.g. thickness, colours, etc.) of the pencil.
 
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, reinit, removeLink, save, setModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grid

protected LMagneticGrid grid
The magnetic grid used to create shapes.


textSetter

protected TextSetter textSetter
The instrument used to add and modify texts.


currentChoice

protected EditionChoice currentChoice
The current editing choice (rectangle, ellipse, etc.) of the instrument.


drawing

protected IDrawing drawing
The drawing that contains the shapes.


zoomer

protected Zoomer zoomer
The zoomer that is used to give the zoom level to compute coordinates of the created shapes.


pictureFileChooser

protected javax.swing.JFileChooser pictureFileChooser
The file chooser used to select pictures.


groupParams

protected IGroup groupParams
Constructor Detail

Pencil

public Pencil(IDrawing drawing,
              Zoomer zoomer,
              LMagneticGrid grid,
              TextSetter textSetter)
Creates a pencil.

Parameters:
drawing - The drawing where the shapes are drawn.
zoomer - The instrument zoomer used to create shapes.
grid - The magnetic grid used to create shapes.
textSetter - The instrument used to add and modify texts.
Throws:
java.lang.IllegalArgumentException - If one of the given argument is null.
Since:
3.0
Method Detail

setActivated

public void setActivated(boolean activated)
Description copied from class: Instrument
Activates or deactivates the instrument.

Overrides:
setActivated in class Instrument
Parameters:
activated - True = activation.

interimFeedback

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

Overrides:
interimFeedback in class Instrument

initialiseLinks

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

Specified by:
initialiseLinks in class Instrument

getGroupParams

public IGroup getGroupParams()
Returns:
The shape that contains the parameters of the pencil. These parameters will be used for the creation of new shapes.
Since:
3.0

createShapeInstance

public IShape createShapeInstance()
Returns:
An instance of a shape configured (thickness, colours, etc.) with the parameters of the pencil.
Since:
3.0

setShapeParameters

public void setShapeParameters(IShape shape)
Configures the given shape with the parameters (e.g. thickness, colours, etc.) of the pencil.

Parameters:
shape - The shape to configure.
Since:
3.0

getPictureFileChooser

public javax.swing.JFileChooser getPictureFileChooser()
Returns:
The file chooser used to select pictures.
Since:
3.0

getCurrentChoice

public EditionChoice getCurrentChoice()
Returns:
The current editing choice.
Since:
3.0

setCurrentChoice

public void setCurrentChoice(EditionChoice currentChoice)
Sets the current editing choice.

Parameters:
currentChoice - The new editing choice to set.
Since:
3.0

getAdaptedPoint

public IPoint getAdaptedPoint(java.awt.Point point)
Computes the point depending on the the zoom level and the magnetic grid.

Parameters:
point - The point to adapted.
Returns:
The computed point.
Since:
3.0