Skip to content

Commit

Permalink
fixed: turning seperates elements of the figure
Browse files Browse the repository at this point in the history
  • Loading branch information
arnobl committed Apr 20, 2013
1 parent f9fe09a commit 288ea70
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 86 deletions.
Expand Up @@ -19,7 +19,7 @@ Yrecursion=0
Yself-in-annots=false
Ystruct-dispatch=poly-cache
Ywarn-dead-code=false
buildmanager=sbt
buildmanager=refined
compileorder=Mixed
debugIncremental=false
deprecation=true
Expand Down Expand Up @@ -143,3 +143,4 @@ syntaxColouring.xml.tagName.underline=false
target=jvm-1.5
unchecked=true
verbose=false
withVersionClasspathValidator=true
Expand Up @@ -65,8 +65,7 @@ public boolean canDo() {

@Override
protected boolean isPropertySupported() {
return super.isPropertySupported() && property!=ShapeProperties.ROTATION_ANGLE &&
property!=ShapeProperties.TEXT;
return super.isPropertySupported() && property!=ShapeProperties.TEXT;
}


Expand Down Expand Up @@ -175,9 +174,6 @@ protected void applyValue(final Object obj) {
case TEXT_POSITION:
pencil.getGroupParams().setTextPosition((TextPosition)value);
break;
case ROTATION_ANGLE:
// The pencil does not perform rotation.
break;
case ARROW1_STYLE:
pencil.getGroupParams().setArrowStyle((ArrowStyle)value, 0);
break;
Expand Down
Expand Up @@ -170,7 +170,6 @@ protected boolean isPropertySupported() {
case ROUND_CORNER_VALUE:
case DOT_SIZE:
case DOT_STYLE:
case ROTATION_ANGLE:
case TEXT:
case TEXT_POSITION:
case COLOUR_LINE: return true;
Expand Down
Expand Up @@ -71,7 +71,7 @@ class RotateShapes extends Action with ShapeAction[IShape] with Undoable with Mo
}


override def getUndoName() = ShapeProperties.ROTATION_ANGLE.getMessage
override def getUndoName() = "rotation"


/**
Expand Down
Expand Up @@ -1330,36 +1330,6 @@ public void setPropertyValueList(final IGroup group, final List<?> values) {
group.setArrowStyleList((List<ArrowStyle>)values, 0);
}
},
/** Modification of the rotation angle a shape. */
ROTATION_ANGLE {
@Override
public String getMessage() {
return "rotation";
}

@Override
public boolean isValueValid(final Object obj) {
return obj instanceof Double;
}

@Override
public List<Double> getPropertyValues(final IGroup group) {
return group==null ? new ArrayList<Double>() : group.getRotationAngleList();
}

@Override
public void setPropertyValue(final IGroup group, final Object value) {
if(group!=null && isValueValid(value))
group.setRotationAngle((Double)value);
}

@SuppressWarnings("unchecked")
@Override
public void setPropertyValueList(final IGroup group, final List<?> values) {
if(group!=null)
group.setRotationAngleList((List<Double>)values);
}
},
/** Modification of the position of texts. */
TEXT_POSITION {
@Override
Expand Down
Expand Up @@ -4,17 +4,15 @@
import javax.swing.JLabel;
import javax.swing.JSpinner;

import net.sf.latexdraw.actions.shape.ModifyShapeProperty;
import net.sf.latexdraw.actions.shape.RotateShapes;
import net.sf.latexdraw.actions.shape.ShapeProperties;
import net.sf.latexdraw.badaboom.BadaboomCollector;
import net.sf.latexdraw.glib.models.interfaces.IGroup;
import net.sf.latexdraw.glib.models.interfaces.IShape;
import net.sf.latexdraw.lang.LangTool;
import net.sf.latexdraw.util.LResources;

import org.malai.instrument.Link;
import org.malai.swing.interaction.library.ButtonPressed;
import org.malai.swing.interaction.library.SpinnerModified;
import org.malai.swing.ui.UIComposer;
import org.malai.swing.widget.MButton;
import org.malai.swing.widget.MSpinner;
Expand Down Expand Up @@ -152,32 +150,34 @@ public MSpinner getRotationField() {
/**
* This link maps a spinner to an action that rotates the selected shapes.
*/
class Spinner2RotateShape extends SpinnerForCustomiser<ModifyShapeProperty, ShapeRotationCustomiser> {
class Spinner2RotateShape extends Link<RotateShapes, SpinnerModified, ShapeRotationCustomiser> {
/**
* Creates the link.
* @param ins The instrument that contains the link.
* @throws InstantiationException If an error of instantiation (interaction, action) occurs.
* @throws IllegalAccessException If no free-parameter constructor are provided.
*/
public Spinner2RotateShape(final ShapeRotationCustomiser ins) throws InstantiationException, IllegalAccessException {
super(ins, ModifyShapeProperty.class);
super(ins, false, RotateShapes.class, SpinnerModified.class);
}

@Override
public boolean isConditionRespected() {
return instrument.getRotationField()==interaction.getSpinner();
}


@Override
public void updateAction() {
action.setValue(Math.toRadians(Double.valueOf(interaction.getSpinner().getValue().toString())));
Object obj = action.shape().get();
if(obj instanceof IShape)
action.setRotationAngle(Math.toRadians(Double.valueOf(interaction.getSpinner().getValue().toString()))-((IShape)obj).getRotationAngle());
}

@Override
public void initAction() {
action.setGroup((IGroup)instrument.pencil.canvas.getDrawing().getSelection().duplicate());
action.setProperty(ShapeProperties.ROTATION_ANGLE);
IShape sh = instrument.pencil.canvas.getDrawing().getSelection().duplicate();
action.setShape(sh);
action.setGravityCentre(sh.getGravityCentre());
}
}

Expand Down
Expand Up @@ -428,45 +428,6 @@ public void testRedoGridStart() {
}


public void testDoRotationAngle() {
IDot d1 = DrawingTK.getFactory().createDot(DrawingTK.getFactory().createPoint(), false);
IRectangle rec = DrawingTK.getFactory().createRectangle(false);
IDot d2 = DrawingTK.getFactory().createDot(DrawingTK.getFactory().createPoint(), false);
g.addShape(d1);
g.addShape(rec);
g.addShape(d2);
d1.setRotationAngle(11.);
d2.setRotationAngle(22.2);
rec.setRotationAngle(-123.4);
action.setGroup(g);
action.setProperty(ShapeProperties.ROTATION_ANGLE);
action.setValue(33.3);
assertTrue(action.doIt());

assertEquals(33.3, d1.getRotationAngle(), 0.0001);
assertEquals(33.3, d2.getRotationAngle(), 0.0001);
}


public void testUndoRotationAngle() {
testDoRotationAngle();
action.undo();
assertEquals(11., g.getShapeAt(0).getRotationAngle(), 0.0001);
assertEquals(-123.4, g.getShapeAt(1).getRotationAngle(), 0.0001);
assertEquals(22.2, g.getShapeAt(2).getRotationAngle(), 0.0001);
}


public void testRedoRotationAngle() {
testUndoRotationAngle();
action.redo();
assertEquals(33.3, g.getShapeAt(0).getRotationAngle(), 0.0001);
assertEquals(33.3, g.getShapeAt(1).getRotationAngle(), 0.0001);
assertEquals(33.3, g.getShapeAt(2).getRotationAngle(), 0.0001);
}



public void testDoDotSize() {
IDot d1 = DrawingTK.getFactory().createDot(DrawingTK.getFactory().createPoint(), false);
IRectangle rec = DrawingTK.getFactory().createRectangle(false);
Expand Down

0 comments on commit 288ea70

Please sign in to comment.