GraphicsBuilder: name that node - No Fluff Just Stuff

GraphicsBuilder: name that node

Posted by: Andres Almiray on March 13, 2008

It all started when my good friend Alex suggested that nodes built with GraphicsBuilder should have a name property as Swing components do (I wonder what he may have in mind ;-)) and it turned out to be a good idea, complementing the recent updates on event and render handlers.

As shown in a previous example, you may navigate a node's children using a ops property, which is actually a List, using array subscript notation, but with names now in place it is also possible to use a map-like notation to get a hold of a nested node. This feature has been extended to transformations, filters, paints and paths as well, so now you are able to get a reference to those nodes using either an index or a name.

Here is a list of the properties you may use in this way
  • ops - returns an OperationGroup representing the nested operations, available in all operations that support nesting.
  • txs - returns a TransformationGroup representing any tranformations to be applied locally to the node, available in all operations that support transformations (clip, viewBox and gradientPaints too).
  • filters - returns a FilterGroup representing any filters to be applied on the node, available in all operations that support filters
  • paints - returns a List of PaintProviders, available in multiPaint only
  • paint - returns a PaintProvider or a MultiPaintProvider if there is any paint defined for the current node, available in shape operations.
  • borderPaint - returns a BorderPaintProvider if there is any defined for the current node, available in shape and outline operations.
  • stroke- returns a StrokeProvider if there is any defined for the current node, available in shape and outline operations.
  • paths - returns a List of PathOperations of a path node (or ExtPathOperations if it is a xpath node).
Assigning a name to a node doesn't create a variable reference, so it is not a replacement for the id attribute, it works in the same way as it does in SwingBuilder, where components may have a name (a regular property for JComponents) and a id property (a synthetic property used by the builder).

I expect to have the next release ready in the following days.

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 »