net.sf.latexdraw.actions
Class ScaleShapes

java.lang.Object
  extended by org.malai.action.Action
      extended by net.sf.latexdraw.actions.DrawingAction
          extended by net.sf.latexdraw.actions.ShapeAction<IGroup>
              extended by net.sf.latexdraw.actions.ScaleShapes
All Implemented Interfaces:
Modifying, Undoable

public class ScaleShapes
extends ShapeAction<IGroup>
implements Undoable, Modifying

This action scales the selected shapes of a drawing.

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.

29/11/2011

Since:
3.0
Author:
Arnaud BLOUIN

Nested Class Summary
 
Nested classes/interfaces inherited from class org.malai.action.Action
Action.ActionStatus
 
Field Summary
private  java.awt.geom.Rectangle2D bound
          The bound of the selected shapes used to perform the scaling.
protected  double newX
          The new X position used to compute the scale factor.
protected  double newY
          The new Y position used to compute the scale factor.
private  double oldHeight
          The old height of the selection.
private  double oldWidth
          The old width of the selection.
protected  IShape.Position refPosition
          The direction of the scaling.
 
Fields inherited from class net.sf.latexdraw.actions.ShapeAction
shape
 
Fields inherited from class net.sf.latexdraw.actions.DrawingAction
drawing
 
Fields inherited from class org.malai.action.Action
status
 
Constructor Summary
ScaleShapes()
          Creates the action.
 
Method Summary
 boolean canDo()
           
protected  void doActionBody()
          This method contains the core code to execute when the action is executed.
 IShape.Position getRefPosition()
           
private  double getScaledHeight()
           
private  double getScaledWidth()
           
 java.lang.String getUndoName()
           
 boolean isRegisterable()
          Specifies if the action must be saved in the action register.
private  boolean isValidScale(double scale)
           
private  boolean isValidScales()
           
 void redo()
          Redoes the cancelled action.
 void setNewX(double newX)
           
 void setNewY(double newY)
           
 void setRefPosition(IShape.Position refPosition)
           
 void setShape(IGroup shape)
          Sets the shape to add.
 void undo()
          Cancels the action.
private  void updateBound(IPoint tl, IPoint br)
           
 
Methods inherited from class net.sf.latexdraw.actions.ShapeAction
flush, getShape
 
Methods inherited from class net.sf.latexdraw.actions.DrawingAction
getDrawing, setDrawing
 
Methods inherited from class org.malai.action.Action
abort, cancelledBy, doIt, done, getStatus, hadEffect, isDone, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

refPosition

protected IShape.Position refPosition
The direction of the scaling.


newX

protected double newX
The new X position used to compute the scale factor.


newY

protected double newY
The new Y position used to compute the scale factor.


bound

private java.awt.geom.Rectangle2D bound
The bound of the selected shapes used to perform the scaling.


oldWidth

private double oldWidth
The old width of the selection.


oldHeight

private double oldHeight
The old height of the selection.

Constructor Detail

ScaleShapes

public ScaleShapes()
Creates the action.

Method Detail

isRegisterable

public boolean isRegisterable()
Description copied from class: Action
Specifies if the action must be saved in the action register. For instance, some actions, such as a scroll of the scroll bars, should not be saved nor put in the undo/redo manager. Thus, they must not be registrable.

Specified by:
isRegisterable in class Action
Returns:
True: the action is registrable.

canDo

public boolean canDo()
Overrides:
canDo in class ShapeAction<IGroup>
Returns:
True if the action can be executed.

isValidScales

private boolean isValidScales()

isValidScale

private boolean isValidScale(double scale)

doActionBody

protected void doActionBody()
Description copied from class: Action
This method contains the core code to execute when the action is executed.

Specified by:
doActionBody in class Action

updateBound

private void updateBound(IPoint tl,
                         IPoint br)

undo

public void undo()
Description copied from interface: Undoable
Cancels the action.

Specified by:
undo in interface Undoable

setShape

public void setShape(IGroup shape)
Description copied from class: ShapeAction
Sets the shape to add.

Overrides:
setShape in class ShapeAction<IGroup>
Parameters:
shape - The shape to add.

getScaledHeight

private double getScaledHeight()

getScaledWidth

private double getScaledWidth()

redo

public void redo()
Description copied from interface: Undoable
Redoes the cancelled action.

Specified by:
redo in interface Undoable

getUndoName

public java.lang.String getUndoName()
Specified by:
getUndoName in interface Undoable
Returns:
The name of the undo action.

getRefPosition

public IShape.Position getRefPosition()
Returns:
The reference position of the scaling.
Since:
3.0

setNewX

public final void setNewX(double newX)
Parameters:
newX - The new X position used to compute the scale factor.
Since:
3.0

setNewY

public final void setNewY(double newY)
Parameters:
newY - The new Y position used to compute the scale factor.
Since:
3.0

setRefPosition

public void setRefPosition(IShape.Position refPosition)
Parameters:
refPosition - The reference position of the scaling.
Since:
3.0