Dragging GraphicsAlgorithm inside another GraphicsAlgorithm [message #1297030] |
Tue, 15 April 2014 11:17 |
John Cole Messages: 66 Registered: June 2013 |
Member |
|
|
Hello everyone,
how can I place a new GraphicsAlgorithm inside another, when only one of them is already on the drawing pane?
For example, I dragged and dropped a rounded rectangle from the palette to the dawing pane. Now I want to drag a rectangle inside that rounded rectangle.
I tried to define a class variable for the ContainerShape and use it for both GraphicsAlgorithms together, but when I try that, there are two problems:
- When I move the rectangle (which I want to drop inside the rounded rectangle) above the rounded rectangle, it shows me a forbidden icon.
- When I drop the rectangle (which I want to drop inside the rounded rectangle) next to the rounded rectangle, the editor throws an IllegalStateException with the message:
"The ContainerShape must have a valid GraphicsAlgorithm"
Dragging the rounded rectangle is realised as follows:
RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(this.containerShape, 5, 5);
gaService.setLocationAndSize(roundedRectangle, context.getX(), context.getY(), 500, 500);
roundedRectangle.setFilled(false);
Shape shape = peCreateService.createShape(containerShape, false);
// ask user for the name of the object
String name = JOptionPane.showInputDialog("Name: ");
Text text = gaService.createText(shape, name);
text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
gaService.setLocationAndSize(text, 0, 0, context.getWidth(),
context.getHeight());
ContainerShape is initialised in the contructor.
Dragging the rectangle inside the rounded rectangle as follows:
Shape shape = peCreateService.createShape(this.containerShape, true);
Rectangle rectangle = gaService.createRectangle(shape);
gaService.setLocationAndSize(rectangle, 10, 10, 20, 20);
How can I realise such a feature?
[Updated on: Tue, 15 April 2014 11:21] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03702 seconds