Archive

Posts Tagged ‘Dojo’

dojo.gfx in detail

March 24th, 2009 No comments

dojogfx

Matthew Russell wrote the most in depth article on dojo.gfx that I have seen. It appeared in Linux Journal and has now been re-printed online.

The article runs the gamut. It starts off discussing the place that dojo.gfx lives in the Dojo world:

architecture

Then we learn about how gfx abstracts on top of the various underlying graphics subsystems that various browsers expose (Canvas, SVG, VML, Flash, Silverlight, …). gfx will choose for you automatically, or you can ask to use a particular rendered:

PLAIN TEXT

HTML:

  1. <script type="text/javascript"

  2.     djConfig="gfxRenderer:’canvas’"

  3. src="http://o.aolcdn.com/dojo/1.2/dojo/dojo.xd.js">

  4. </script>

Then we delve into the drawing API itself:

PLAIN TEXT

JAVASCRIPT:

  1. dojo.addOnLoad(function() {

  2. var node = dojo.byId("surface");

  3. var surface = dojox.gfx.createSurface(node, 600, 600);

  4.     rect1 = surface.createRect({

  5. /* x and y default to (0,0) */

  6.         width : 200,

  7.         height:200

  8. })

  9.     .setFill("red")

  10.     .setTransform([

  11.         dojox.gfx.matrix.translate(200,200),

  12.         dojox.gfx.matrix.rotategAt(45,100,100)

  13. ])

  14.     ;

  15. });

From here Matthew covers topics such as manipulating groups, and how you can make areas moveable, and the 2D charting API.

Categories: Designing Tags: ,

Observe Dojo Events

March 24th, 2009 No comments

Speaking of bookmarklets, in a recent blog post Nathan Kurtyka discusses a scenario familiar to many Ajax developers:

However, I can’t even begin to think about how much time I’ve wasted hunting through source code hoping there might be some event I can subscribe to (e.g. “What event is published when someone clicks on a Tree widget node?”).

So naturally, he created a little something to scratch that itch:

I created a Dojo bookmarklet that can be used to log all events to the console.

So to not only see how rich Dojo is with event publishing (you probably haven’t been leveraging either), but to also see the bookmarklet in action, head on over Dojo Campus. Just enable Firebug, give the bookmarklet a click, browse the demos.. and behold — events everywhere!!

Check out the blog for the bookmarklet.

Categories: Tips and Tutorials Tags: ,