Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (856)
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 2946 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  

hadezbladez (728 views)
2018-11-16 13:46:03

hadezbladez (363 views)
2018-11-16 13:41:33

hadezbladez (715 views)
2018-11-16 13:35:35

hadezbladez (181 views)
2018-11-16 13:32:03

EgonOlsen (2376 views)
2018-06-10 19:43:48

EgonOlsen (2530 views)
2018-06-10 19:43:44

EgonOlsen (1467 views)
2018-06-10 19:43:20

DesertCoockie (2133 views)
2018-05-13 18:23:11

nelsongames (1929 views)
2018-04-24 18:15:36

nelsongames (2611 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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!