GraphicsBuilder: groups recieve a facelift - No Fluff Just Stuff

GraphicsBuilder: groups recieve a facelift

Posted by: Andres Almiray on March 11, 2008

When I created groups in GraphicsBuilder I was looking for a way to define a set of operations that would be related somehow, perhaps share some properties like borderColor and fill, but most importantly, assert that any nested operation that changed the current graphics context would not affect other operations outside the group. All those features are in place since the first iterations of the code, but as I kept extending shapes with other features I realized groups could do more, like handling mouse events or even having a filter applied, but one thing prevented that: groups do not have a finite boundary.

One approach to create said boundary would create an Area of the additions of all the nested shapes, but it may be costly, specially if you factor in nested groups and proper caching. So to get the ball rolling I have introduced a new child node in group: viewBox, shamelessly borrowed from SVG. It is by default a rectangular based shaped (with properties x,y,width,height, fully bindable/animatable) and I'm looking forward enabling a custom shape in the future (and even perhaps an option to calculate the Area with a config flag).

ViewBox may be transformed on its own (local transformation) without affecting the group itself. If by any chance a transformation is applied to the group it will also be applied to the viewBox unless it has a property pinned=true set, which I'm sure will come in handy when doing animations.

So with viewBox in place you can now apply any filter combination in a group, affecting all nested children at the same time, and you can also register all event handlers available in shapes too. Outlines and images have received the same treatment for filters and events too, which means that all drawing nodes accept the same set of features :-D

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 »