Re: translation howto?

Hi Brandon,

> I'm attempting to create a 2D graph display that resizes when it's parent
> window resizes.  I'm using the autoAspect feature and some resizing code
> that I found on a JPython script sheet that resizes the box to some
> percentage of the window via the matrix in ProjectionControl.  The problem
> is that when the graph is resized this way it is centered in the panel using
> only the box coords, not the box plus the axes.  So, when I resize the box
> to say 75% + of the window, the axis labels are out of the canvas.  Anything
> less than 75% leaves alot of whitespace all around the graph (which is what
> I want to avoid).  I figure one way around this problem is to calc the sizes
> of the axes and then translate the box up and left by these amounts.  Then
> do the resize.  This seems like a pretty bad hack, and I'm wondering if
> there is a better way to do this.  If I'm stuck with the hack, is there a
> simple way to do the translation?

I wouldn't call it a hack, since any code that does what you
want will have to make this calculation. The only question is
whether that code is encapsulated behind some simple API.

There is no such method that I know of in VisAD, so you'll
probably have to code one yourself. You can use the make_matrix()
method of MouseBehavior (get the MouseBehavior from the
DisplayRenderer, which you get from the DisplayImpl) to
convert a translation into a matrix, then use MouseBehavior's
multiply_matrix() method to combine it with the matrix you
get from ProjectionControl.getMatrix(), and pass the result
back to ProjectionControl.setMatrix().

Good luck,
Bill


  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: