aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problems moving shapes when set up own Shapes class extending Path2D.Double Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problems moving shapes when set up own Shapes class extending Path2D.Double" Watch "Problems moving shapes when set up own Shapes class extending Path2D.Double" New topic
Author

Problems moving shapes when set up own Shapes class extending Path2D.Double

Kieran Murray
Ranch Hand

Joined: May 18, 2008
Posts: 47
Dear Guys,

Thank you for your help already.
I have now used your previous code and enlarged it so that I can use my own shapes rather than the ones provided. I need to do this as I will be querying number of the shapes when I link them to a JTable and then pass on information from this table. I need to be able to query the name of the shape and the number so that I can retrieve information from the JTable.

The problem is that to do this I have had to create a drawing method in the Shape class in this case "Generator" and have to pass the AffineTransform into the Generator's constructor.

This is causing problems when I try to move the object - it will not move.

The key issue seems to be the following line under the transformPath method in the ShapeDrawZoomPanel class.

path.transform(at);

I am using the containsPoint method in Shapes to check whether I have hit the object. I have set this very high as I just want to check the functionality of moving the object.

Any help would be much appreciated.



The Shapes class



The PathWrangler2 class


The ShapeDrawZoomPanel class



The main class ShapeDraw



Thanks.

The Apprentice
Kieran Murray
Ranch Hand

Joined: May 18, 2008
Posts: 47
Dear Guys and Galls,

I post the code below as hopefully the end to this particular post.

The code works in the way that I had hoped it would given where I was a few weeks ago. I want to thank you for your help. I add it here, not as self-congratulations but just in case someone needs it.

However, there are a few things that are bugging me.

This line of code in MyInterp method transformPath

path.transform(at) why like this. I am not sure I understand - I was expecting something more like moveTo. Also, what is this method getTransform.

Why do you need inverse Transforms to decide on the location of objects???

Anyway thanks a lot for your help and I am sure I will need somemore.

The code contains two classes, Busbar and Generator which extend Shapes.
I use these classes because I need to be able to inquire of the classes using methods.

The code for the Generator class.



The Busbar class


The Shapes class


The PathWrangler2 class


The MyInterp class


The main class Shaping


Thank you again for you help and you can close this post if you wish.

Kind regards,

The Apprentice
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems moving shapes when set up own Shapes class extending Path2D.Double
 
Similar Threads
Zooming in and out - cursor not in the right place
Is there anyway of overriding the default signal for PopupMenus
Moving clickedShapes and only clickedShapes on a panel
A question that is not final but is my final question about AffineTransforms - hopefu
Can move shapes individually but not as a group