Hi *,
Firstly I posted this topic in the wrong section (SmartClient) but I couldn't delete it anymore. Sorry for that.
SmartGWT - v9.1p_2014-03-23/LGPL Development Only (built 2014-03-23)
Not sure what I'm doing wrong here:
...all I'm trying to do is to group a set of DrawItems and then drag them all over the pane as a group (together).
The way it works in my implementation:
- if setUseGroupRect is true the group box itself is moved on the screen but the contained shapes remain in the same position
- if setUseGroupRect is false I can move the shapes individually, but the group box remains still.
Is it something I'm missing? Can anyone shed some light on this problem of mine?
Firstly I posted this topic in the wrong section (SmartClient) but I couldn't delete it anymore. Sorry for that.
SmartGWT - v9.1p_2014-03-23/LGPL Development Only (built 2014-03-23)
Not sure what I'm doing wrong here:
Code:
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.types.Cursor;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.drawing.DrawGroup;
import com.smartgwt.client.widgets.drawing.DrawOval;
import com.smartgwt.client.widgets.drawing.DrawPane;
import com.smartgwt.client.widgets.drawing.DrawRect;
import com.smartgwt.client.widgets.drawing.events.DragMove;
import com.smartgwt.client.widgets.drawing.events.DragMoveHandler;
public class MyTestSmartGWT implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final DrawGroup groupOvalRectangle = new DrawGroup();
final DrawPane drawingArea = new DrawPane();
drawingArea.setWidth(1000);
drawingArea.setHeight(600);
drawingArea.setBackgroundColor("#CCCCCC");
drawingArea.setCanDrag(true);
drawingArea.setCursor(Cursor.AUTO);
final DrawRect rectangle = new DrawRect();
final DrawOval oval = new DrawOval();
rectangle.setWidth(200);
rectangle.setHeight(100);
rectangle.setTop(50);
rectangle.setLeft(50);
rectangle.setCursor(Cursor.MOVE);
rectangle.setLineWidth(3);
rectangle.setFillColor("red");
rectangle.setCanDrag(true);
oval.setWidth(100);
oval.setHeight(50);
oval.setTop(200);
oval.setLeft(100);
oval.setCursor(Cursor.MOVE);
oval.setLineWidth(3);
oval.setFillColor("green");
oval.setCanDrag(true);
groupOvalRectangle.setCanDrag(true);
groupOvalRectangle.setDrawItems(rectangle,oval);
// set properties of group box
int [] boxOval = oval.getBoundingBox();
int [] boxRect = rectangle.getBoundingBox();
groupOvalRectangle.setTop(boxRect[1]);
groupOvalRectangle.setLeft(boxRect[0]);
groupOvalRectangle.setWidth(boxRect[2]-boxRect[0]);
groupOvalRectangle.setHeight(boxOval[3]-boxRect[1]);
SC.logInfo("Box surrounding Group >>> X1-" + groupOvalRectangle.getLeft()
+ " Y1-" + groupOvalRectangle.getTop()
+ " Width-" + groupOvalRectangle.getWidth()
+ " Height-" + groupOvalRectangle.getHeight());
//events on Group Rectangle
groupOvalRectangle.addDragMoveHandler(new DragMoveHandler() {
@Override
public void onDragMove(DragMove event) {
SC.logInfo("===> Group Box moved to - " + groupOvalRectangle.getLeft()
+ "," + groupOvalRectangle.getTop());
SC.logInfo("======> Rectangle's top-left corner - " + rectangle.getLeft()
+ "," + rectangle.getTop());
SC.logInfo("======> Oval's top-left corner - " + oval.getLeft()
+ "," + oval.getTop());
}
});
groupOvalRectangle.setUseGroupRect(true);
drawingArea.addDrawItem(groupOvalRectangle, true);
drawingArea.draw();
}
}The way it works in my implementation:
- if setUseGroupRect is true the group box itself is moved on the screen but the contained shapes remain in the same position
- if setUseGroupRect is false I can move the shapes individually, but the group box remains still.
Is it something I'm missing? Can anyone shed some light on this problem of mine?