Wow, I like the discussion here about SVG vs. Canvas, but it is a bit far afield from my question. However I will make one comment about why I am using SVG instead of Canvas.
My development framework is that I compose highly realistic looking pictures of equipment that are going to be controlled by the application. The images are edited in Inkscape and other tools (such as Adobe Illustrator) that let me work in SVG. The equipment has buttons, connectors, and LEDs that can be clicked by the mouse or change color depending on status.
The easiest way to do this is to make those graphic artifacts SVG elements in the picture, and find them by well-formed IDs using JQuery or just window.getElementById(). Prior to HTML 5 that supports the SVG element, this didn't work because embedded SVG objects were not part of the document DOM. Now when I can find them, I can then do things to them like catch their DOM events, move them, animate them, change their style attributes with just the usual javascript DOM method calls.
I am not sure how this is done with a canvas element without a LOT more javascript code. Maybe there is a way, and maybe we will see a real cool p:canvas element in Primefaces in the future. If someone would like to comment on it I would like to know.
Anyway, my question was this. When I put up an svg element, it gets rendered in-line with a size that is specified by the width and height attributes of the svg element. I wanted the user to be able to click and drag the corner to adjust the size, and it looked like p:resizable was close to what I wanted.
Maybe my example obscured my question -- here it is refactored:
Code: Select all
<p:panel id="panelGraphic">
<svg width="300" height="400" ,,, > some svg stuff </svg>
</p:panel>
<p:resizable for="panelGraphic" aspectRatio="true" />
What I think needs to happen is that the click and drag action needs to be able to adjust the width/height attributes of the svg element as well as the p:panel element. Also the initial size of the p:panel needs to be adjusted to the size of the svg element. I think this could be done with a bit of javascript. Am I on the right track?