Getting 3d effect from draw 2d

Last three months have been like a roller-coaster to say the least, to learn lot new things, mastering the existing and come up renovating yourself. The time we developed FID 1.2 which is open source and available for free download.

The key feature shipped with FID1.2 is EIP Editor (to know about FID and EIP editor go to FUSE Team blogs) and i got a chance to work on it to enhance the look and feel of the editor.

The task was to make the shadowed figures of shapes likes Rectangle, circle, diamond etc using draw2d API. And since designing and development was proceeding hand-to-hand, their were lot of changes in colors and sizes so effectively we needed to design a system or framework which reflect requirement changes in no time. Following are some frequent requirement changes:
  1. Change the gradient colors (which includes start color and end color)
  2. New shapes diamonds, rounded rectangle etc.
  3. Change in sizes of the figures both width, height, insets etc.
Clearly you can't just keep on changing the java code for these changes, so something with combination of java along with properties files is the solution.

The next thing is how to use properties files keeping in mind the enhancements, changes, and also to make it so trivial that anybody (even designers) can change and check.

Designing should be based on figure type, size and color, clearly number of combination will keep on increasing based on the above three parameters. The option of maintaining single cumbersome property file was ruled out because of risk involved in modifying it and time in identifying the right place to do it.

We created property files based on color and sizes e.g. bluefigure, grayfigure, greenfigure property files these files contain the information about the gradiant, shadow color combinations etc. Size properties contains the sizes according to figure type e.g. if you have figure of type A then the A.properties will contain all the size related properties.

The parameter we missed out in property file is shape that we covered in java utility class via having method like getBlueRectangle(Properties propertiedOfA) this method will create and return you the figure which is blue in color and having rectangle shape and sizes are taken from A.properties file which is passed as an argument.

The final output looks like this:

Also we added the custom decorators like error markers, breakpoint markers etc. which can be seen in the pic above

Some points to remember:

  1. Do not set background color inside paint method
  2. Always cache your color and font objects else destroy them when not in use

Comments

Popular posts from this blog

java.net.SocketException: Connection reset

Hide empty last column from Table/Tree Viewer

Spring: implements interface not working in @Controller