[Biojava-l] New FeatureRenderers and demo

Keith James kdj@sanger.ac.uk
13 Jun 2001 17:13:57 +0100


>>>>> "David" == David Huen <smh1008@cus.cam.ac.uk> writes:

    David> 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.
    >> 
    David> Ok, I have been attempting to fix the problem that you
    David> observe on the BeadRenderers and I have a fix though not
    David> one I am entirely happy with.

[...]

I'm re-posting this as the first time it didn't seem to make it to the
list:

David,

I came up with the same thing (although I guess it took me rather
longer than you!) I haven't checked out your code yet, but it sounds
similar (transform the transform(!), invert it and apply it to the
visibleRect).

A problem with overriding SequencePanel's JComponent getVisibleRect()
is that then only SequencePanel will work and all other JComponents
will mysteriously fail.

I think a better fix would be to use integer arithmetic in the first
place. After all, we have two perfectly good integers from the
getMin() and getMax() methods of a Feature's Location. Why not do the
arithmetic first, hence no rounding errors, then convert to floats and
apply the result? I haven't looked through all of the affected
renderers to see quite how hard it will be to change for other things
(rulers, symbols etc) but I'm prepared to spend time on it.

There is also a more general problem with the design of the
FeatureRenderer interface in that one can only pass a
SequenceRenderContext to the renderFeature() method. It's only by
chance that the SequencePanel implementation also happens to be a
JComponent, allowing use of getVisibleRect() for optimization (or if
it were an AWT component a home-made equivalent of
getVisibleRect()). Or is there another way to do this?

I think that the rendering method should have a sure-fire way of
getting a reference to the component it's rendering into. The use of
visibleRect (or equivalent) is, in my opinion, essential. Admittedly,
having a Pentium 150 MHz I'm more exposed to performance problems than
most, but with visiblity checks the display is quite snappy, while
without it's a real dog. The SymbolSequenceRenderer seems to suffer
badly from this.

Thanks for taking the time to help fix this.

cheer,

Keith

-- 

-= Keith James - kdj@sanger.ac.uk - http://www.sanger.ac.uk/Users/kdj =-
The Sanger Centre, Wellcome Trust Genome Campus, Hinxton, Cambs CB10 1SA