[Biojava-l] New FeatureRenderers and demo

David Huen smh1008@cus.cam.ac.uk
Wed, 13 Jun 2001 00:02:03 +0100 (BST)


On Tue, 12 Jun 2001, David Huen wrote:

> On Mon, 11 Jun 2001, David Huen wrote:
> 
> > 
> > I think you will need to either transform your Visible Rectangle to the
> > renderer coordinate space or alternatively, transform your objects
> > coordinates to component space so your test uses the same coordinate space
> > for the visibility test.  The former is easier and can be performed with
> > the methods in AffineTransform.  You can recover the current transform
> > from the Graphics2D object by getTransform().
> > 
> Something else appears to be happening here too - I'll work on fixing it
> tonight and get back to you.
> 
Ok, I have been attempting to fix the problem that you observe on the
BeadRenderers and I have a fix though not one I am entirely happy with.

It turns out that my earlier diagnosis was almost correct except I did not
account for the effect of the ScrollPane. It appears that on a ScrollPane,
the visibleRect tracks the current ViewPort position in component space.
The extra transform applied in in paintComponent introduces an offset
which because of the way the setGraphicsOrigin works, results in a
mismatch between the two.  Because the floating point hack endeavours to
keep the context origin at a fixed value (50 currently), the delta between
the visibleRect and the drawing coordinate space remains constant.

I attempted to solve it by recovering the transform and applying the
inverse to set the visibleRect into drawing space.  This does not work
because the transform recovered in a product of the scroll transform
(which paintComponent receives from its caller) and the corrective
transform.  The net result of using this correction is that visibleRect
sweeps thru the view (at twice scroll rate!).

The horrible hack that does work now is to change the setgraphicsOrigin
value of 50.0 to 0.00.  This matches both visibleRect space and drawing
space and so the mismatch doesn't show.  I have tested this and it
seems to obviate the problem.  SequenceLister seems to work fine with
it too. This hack will break when a border is set. I think this may have
to be a temporary fix till I figure out a better fix.

Would a better fix be to override the SequencePanel JComponent
getVisibleRect() method to return a drawing space visibleRect?  Are we
agreeable to this?

Regards,
David Huen