You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by "Schwartz, Cynthia L" <cy...@intel.com> on 2013/04/08 19:59:55 UTC

zooming into a custom component using mouse selection

I have a custom component (currently placed within a TablePane)  and wish to mouse select a region of the component and zoom into that region, redrawing my custom component scaled appropriately.  Can you point me in the right direction to do this in Pivot?
I looked at ScaleDecorator but that doesn't handle mouse events to select the region.  Is there an example of this somewhere?

Thanks,
Cynthia



RE: zooming into a custom component using mouse selection

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Hi Cynthia,

                I'm thinking you would probably need to do most of the
work yourself in your custom component.  The ScaleDecorator can be
applied to a whole component (not just a portion of one, which is what
you are needing to do).  And, and you found out, there is no mouse
interaction for the selection process in the Decorator - it is only
essentially a visual filter on the drawing process.  The other
components that handle mouse selection all do it within their
corresponding Skin classes, so I imagine you would have to add mouse
listeners to your custom component and keep track of the mouse selection
in a similar manner, then adjust your drawing routines to scale just
that portion of the graph (I think that's what you're component draws).
So, once you have established a selected region (rectangle?!) you would
probably have to draw the whole component but with a negative clip
region of the selected area (i.e., draw everything BUT what's in that
region), then apply a scaling transform to the selected area and draw
just that portion.  Just thinking out loud.  You can look at the source
for TextArea (for instance) for clues on how to do selection using the
mouse.

                Alternatively, you could potentially extend
ScaleDecorator to do the scaling I just described, and make the code
somewhat modular.  That way, you would have a "RegionZoomDecorator"
which you would apply to your component, that would take a
rectangle/region and a zoom factor, and do the drawing / scaling as
above.  That way, once you have established a zoom region from your
mouse selection, you configure and apply this decorator to the component
and voila!

                Sounds pretty cool - I'd be interested to see what you
come up with ... J

 

HTH,

~Roger Whitcomb