Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  AffineTransform#createTransformedShape(GeneralPath)  (Read 2246 times)
0 Members and 1 Guest are viewing this topic.
Offline NVaidya

Junior Devvie

Java games rock!

« Posted 2006-05-31 18:31:25 »

Would appreciate some help with the following please:

My application which works correctly with jdk1.5.0_06 fails with the following ClassCastException with Mustang b85 (-source 1.5):
java.lang.ClassCastException: java.awt.geom.Path2D$Double cannot be cast to java.awt.geom.GeneralPath

when I try to retrieve a transformed GeneralPath as follows:
GeneralPath outputGeneralPath  = (GeneralPath)affineTransform.createTransformedShape( inputGeneralPath );

From a quick look at the source code for 1.5 and 1.6 for the method createTransformedShape(...), it appears that 1.5 can conditionally return a GeneralPath, while 1.6 unconditionally returns a Path2D.Double, and the exception occurs because GeneralPath extends Path2D.Float.

Am I missing anythin' obvious ?

Thanks in advance

Gravity Sucks !
Offline ryanm

Senior Devvie

Projects: 1
Exp: 15 years

Used to be bleb

« Reply #1 - Posted 2006-05-31 18:41:46 »

In trying to make the cast to a GeneralPath, you're making an unsafe assumption about the implementation of createTransformedShape(), which is liable to change at any time.

Hows about coding to the API -rather than the implementation- like so:
GeneralPath outputGeneralPath = new GeneralPath( affineTransform.createTransformedShape( inputGeneralPath ) );
Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #2 - Posted 2006-05-31 20:01:21 »

Bleb is correct - you shouldn't cast the return of createTransformedShape().

Here's the fix which caused the change:
   4172661: GeneralPath needs double version

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline NVaidya

Junior Devvie

Java games rock!

« Reply #3 - Posted 2006-06-01 22:20:47 »

Thanks for the quick help guys ! alright, I get the big picture now after reading  that Bug Fix.   
After looking at the 1.5 docs again, I think I could actually get away with clobbering the input data with an in-place transform by doing inputGeneralPath.transform( affineTransform ) since I really didn't need to keep the original data around. I'm using the GeneralPath to build a couple of hand-crafted icons to display in the ToolBar, and the application was crashing right at the start-up.

Thanks again !

Gravity Sucks !
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Archive (87 views)
2017-02-27 19:41:49

Riven (80 views)
2017-02-27 17:26:59

numerical (447 views)
2017-02-21 07:32:16

numerical (451 views)
2017-02-21 07:31:46

theagentd (561 views)
2017-02-18 13:42:33

theagentd (557 views)
2017-02-18 13:35:16

h.pernpeintner (1732 views)
2017-01-24 22:39:11

h.pernpeintner (1688 views)
2017-01-24 22:38:32

Galdo (2270 views)
2017-01-12 13:44:09

Archive (2183 views)
2017-01-02 05:31:41
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!