Groovy Coffee Cup

Transforming the JavaFX version into Groovy was, for most of it, pretty straight forward though some issues were found along the way, first let me show you the code as it currently looks
In case you're seeing GraphicsBuilder code for the first time know that I made use of property aliases, which means that fill can be set as f, color as c an so on. Alright, let's visit those gotchas
- line 13: radialGradient requires a radius as it doesn't infer it from its host, it also does not follows the shape of its host (as it is the case on JavaFX), this means that it will always have a circular profile.
- lines 35-44: decided to improve the way the cup shape is created by using an intersect operation, problem is that the resulting shape didn't accept a nested paint node, that is why I had to save it as shape an then draw it again. When a shape is drawn this way it looses all local transformations, that is why a keepTrans property had to be set to true. While powerful the usage of draw is not intuitive.
- line 57-60: this is not exactly a problem but a plus, as the innerRim shape is reused to create a composite shape based on an intersect operation.
- lines 62-66: a local transformation is applied to the cup group, negative translation coordinates had to be specified given the relationship with the scale transformations, in other words, scaling is done at world coordinates, not local coordinates.
Keep on Groovying!
About Andres Almiray
Andres is a Java/Groovy developer and Java Champion, with more than 11 years of experience in software design and development. He has been involved in web and desktop application developments since the early days of Java. He has also been teacher of computer science courses in the most prestigious education institute in Mexico. His current interests include Groovy and Swing. He is a true believer of open source and has participated in popular projects like Groovy, Griffon, JMatter and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member and current project lead of the Griffon framework. He blogs periodically at http://jroller.com/aalmiray. You can find him on twitter too as @aalmiray. He likes to spend time with his beloved wife, Ixchel, when not hacking around.
More About Andres »Why Attend the NFJS Tour?
- » Cutting-Edge Technologies
- » Agile Practices
- » Peer Exchange
Current Topics:
- Languages on the JVM: Scala, Groovy, Clojure
- Enterprise Java
- Core Java, Java 7
- Agility
- Testing: Geb, Spock, Easyb
- REST
- NoSQL: MongoDB, Cassandra
- Hadoop
- Spring 3
- Automation Tools: Git, Hudson, Sonar
- HTML5, Ajax, jQuery, Usability
- Mobile Applications - iPhone and Android
- More...
NFJS, the Magazine
December Issue Now AvailableBDD and REST
by Brian SlettenMocks and Stubs in Groovy Tests
by Kenneth KousenAlgorithms for Better Text Search Results
by John GriffinKnowns and Unknowns of Scrum and Agile
by Brian Tarbox

