GraphicsBuilder: groups and transformations - No Fluff Just Stuff

GraphicsBuilder: groups and transformations

Posted by: Andres Almiray on August 28, 2007

After working on the area operations I made an effort to squeeze in group and transformations. The following code shows how they can be used

So what do we have here...
  1. set the current color to green.
  2. declare a group, all operations that change the graphics context will not have an effect outside the group.
  3. draw a rounded not-filled rectangle, which will serve as a bound delimiter.
  4. draw another rounded rectangle, filled with cyan.
  5. apply a transformation to the last rectangle, it will translate the rectangle by 10 units across the x axis.
  6. draw a third rectangle, filled with red. Note that the 3 rectangles start at the same x position.
  7. set the current color to yellow.
  8. draw a line, it should be stroked with yellow (current color).
  9. draw a second line (oustide the group), it should be stroked with green(current color).
So how does it look?
groups+transformations


Transformations may be applied to any contextual or grouping operation (a contextual operation allows nesting of other operations), and as in JavaFX, there are four of them: translate, scale, rotate and skew. As the builder evolves I see that it's becoming a little bit difficult to keep track of all the samples, so I decided to create a demo app (like the JavaFX tutorial) that will server as a showcase. By the way Danno has been busy adding binding support to SwingBuilder, and its very likely that that binding solution will be used in GraphicsBuilder.

Keep on Groovying!
Andres Almiray

About Andres Almiray

Andres is a Java/Groovy developer and a Java Champion with more than 20 years of experience in software design and development. He has been involved in web and desktop application development since the early days of Java. Andres is a true believer in open source and has participated on popular projects like Groovy, Griffon, and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member of the Griffon framework and Hackergarten community event. https://ch.linkedin.com/in/aalmiray

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 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »