Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Dragging GraphicsAlgorithm inside another GraphicsAlgorithm
Dragging GraphicsAlgorithm inside another GraphicsAlgorithm [message #1297030] Tue, 15 April 2014 11:17 Go to next message
John Cole is currently offline John ColeFriend
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:



  1. When I move the rectangle (which I want to drop inside the rounded rectangle) above the rounded rectangle, it shows me a forbidden icon.
  2. 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

Re: Dragging GraphicsAlgorithm inside another GraphicsAlgorithm [message #1297039 is a reply to message #1297030] Tue, 15 April 2014 11:24 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
John,

the standard way would be to have a ContainerShape for each of the
rectangles and rounded rectangles. Then you would nest the rectangle's shape
into the rounded rectangles shape by adding it to the children relation of
the outer shape. You should do that in the move feature for the inner shape.

It is also possible to nest graphics algorithms into each other but that is
a different story and I would not recommend that for allowing to nest on
move.

Michael
Re: Dragging GraphicsAlgorithm inside another GraphicsAlgorithm [message #1310540 is a reply to message #1297039] Wed, 23 April 2014 08:43 Go to previous message
John Cole is currently offline John ColeFriend
Messages: 66
Registered: June 2013
Member
It worked!
Thank you very much Michael!
Previous Topic:polyline
Next Topic:some Key Bindings not working
Goto Forum:
  


Current Time: Sat Apr 20 00:01:07 GMT 2024

Powered by FUDForum. Page generated in 0.02978 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top