• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic