GraphicsBuilder: Balloon shape - No Fluff Just Stuff

GraphicsBuilder: Balloon shape

Posted by: Andres Almiray on February 27, 2008

When I was taking on the challenge of making Groodle #2 look good that I decided to refactor TabRect into a more versatile shape: Balloon. It is still a union of a rounded rectangle and a triangle but has more room for customization. Here is a screenshot to show you what I mean by that



Not only may the tab be placed in any of the four sides of the rectangle, but it may also be displaced along the side it is on. Because GraphicsBuilder supports triangles as base shapes it was also a simple matter to allow right triangles as tabs, the blue/cyan balloons show them in action. So how does the code look? I'm using aliases (I'm finding them very helpful as I keep using them) just in case you were wondering

An explanation of the properties is in order
  • tw - tabWidth: the name should be self explanatory
  • th - tabHeight: controls the height of the tab, it is 1/2 of tabWidth by default (the example doesn't set it so it is computed as 5)
  • tl - tabLocation: defines which side the tab will be attached on, default value is 'bottom'
  • td - tabDisplacement: where in the chosen side the tab will be attached, it must be a value in the range (0f..1f) and it takes into consideration whatever value you set for arc, meaning that the tab will be drawn between (x+arc) and (x+width+arc)
  • ap - anglePosition: defines where is the right angle, default value is 'none'
Needless to say it will be available in the next release :-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 »