Skip to content

Commit

Permalink
Scaling shapes does not work outside the page
Browse files Browse the repository at this point in the history
Scaling shapes does not work outside the page
https://bugs.launchpad.net/latexdraw/+bug/1583116
  • Loading branch information
arnobl committed May 18, 2016
1 parent c2a60b2 commit 0f973da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 2 additions & 0 deletions latexdraw-core/net.sf.latexdraw/release_note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Version 3.3.4

Bugs fixed:
- Scaling shapes does not work outside the page
https://bugs.launchpad.net/latexdraw/+bug/1583116
- Copy/paste a plotted shape does not work as expected
https://bugs.launchpad.net/latexdraw/+bug/1580483
- Boundaries of a group of shapes not correctly computed when moved outside the page
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package net.sf.latexdraw.actions.shape

import java.awt.geom.Rectangle2D
import org.malai.action.Action
import org.malai.undo.Undoable
import net.sf.latexdraw.actions.DrawingAction
import net.sf.latexdraw.actions.Modifying
import net.sf.latexdraw.actions.ShapeAction
import net.sf.latexdraw.glib.models.interfaces.shape.IShape.Position
import net.sf.latexdraw.glib.models.GLibUtilities
import net.sf.latexdraw.glib.models.interfaces.shape.IGroup
import net.sf.latexdraw.glib.models.interfaces.shape.IPoint
import net.sf.latexdraw.util.LNumber

import net.sf.latexdraw.actions.{DrawingAction, Modifying, ShapeAction}
import net.sf.latexdraw.glib.models.GLibUtilities
import net.sf.latexdraw.glib.models.interfaces.shape.IShape.Position
import net.sf.latexdraw.glib.models.interfaces.shape.{IGroup, IPoint}
import net.sf.latexdraw.lang.LangTool
import net.sf.latexdraw.util.LNumber
import org.malai.action.Action
import org.malai.undo.Undoable

/**
* This action scales a shape.<br>
Expand Down Expand Up @@ -64,18 +61,16 @@ class ScaleShapes extends Action with ShapeAction[IGroup] with DrawingAction wit

private def isValidScales = {
_refPosition.get match {
case Position.EAST => isValidScale(_newX) && scaledWidth(_newX)>1.0
case Position.WEST => isValidScale(_newX) && scaledWidth(_newX)>1.0
case Position.NORTH => isValidScale(_newY) && scaledHeight(_newY)>1.0
case Position.SOUTH => isValidScale(_newY) && scaledHeight(_newY)>1.0
case _ => isValidScale(_newX) && isValidScale(_newY) && scaledHeight(_newY)>1.0 && scaledWidth(_newX)>1.0
case Position.EAST => GLibUtilities.isValidCoordinate(_newX) && scaledWidth(_newX)>1.0
case Position.WEST => GLibUtilities.isValidCoordinate(_newX) && scaledWidth(_newX)>1.0
case Position.NORTH => GLibUtilities.isValidCoordinate(_newY) && scaledHeight(_newY)>1.0
case Position.SOUTH => GLibUtilities.isValidCoordinate(_newY) && scaledHeight(_newY)>1.0
case _ => GLibUtilities.isValidCoordinate(_newX) && GLibUtilities.isValidCoordinate(_newY) &&
scaledHeight(_newY)>1.0 && scaledWidth(_newX)>1.0
}
}


private def isValidScale(scale : Double) = GLibUtilities.isValidCoordinate(scale) && scale>0


protected def doActionBody() {
if(oldWidth.isNaN) {
val br = _shape.get.getBottomRightPoint
Expand All @@ -84,7 +79,7 @@ class ScaleShapes extends Action with ShapeAction[IGroup] with DrawingAction wit
oldHeight = br.getY - tl.getY
updateBound(tl, br)
}
redo
redo()
}


Expand Down

0 comments on commit 0f973da

Please sign in to comment.