X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FRotatableCanvas.java;h=a2463e87d7a44c80e61fb26a8f884c5f8c3cc2d1;hb=10c2447aefb29bddf48799fb5a1631932a5940a8;hp=370de5f9cdbc95c8fb2b7021fa67e671520cfa1e;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index 370de5f..a2463e8 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -99,7 +99,7 @@ public class RotatableCanvas { this.points = points; this.npoint = npoint; - PaintRefresher.Register(this, av.alignment); + PaintRefresher.Register(this, av.getSequenceSetId()); prefsize = getPreferredSize(); orig = new float[npoint][3]; @@ -297,6 +297,7 @@ public class RotatableCanvas { paint(g); } + public void paint(Graphics g) { if (points == null) @@ -329,7 +330,7 @@ public class RotatableCanvas drawAxes(ig); } - if(tooltip!=null) + if (tooltip != null) { ig.setColor(Color.red); ig.drawString(tooltip, toolx, tooly); @@ -371,18 +372,19 @@ public class RotatableCanvas int y = (int) ( (float) (sp.coord[1] - centre[1]) * scale) + halfheight; float z = sp.coord[1] - centre[2]; - if (sp.sequence.getColor() == Color.black) + if (av.getSequenceColour(sp.sequence) == Color.black) { g.setColor(Color.white); } else { - g.setColor(sp.sequence.getColor()); + g.setColor(av.getSequenceColour(sp.sequence)); } if (av.getSelectionGroup() != null) { - if (av.getSelectionGroup().sequences.contains( ( (SequencePoint) points. + if (av.getSelectionGroup().getSequences(null).contains( ( ( + SequencePoint) points. elementAt(i)).sequence)) { g.setColor(Color.gray); @@ -497,33 +499,34 @@ public class RotatableCanvas if (av.getSelectionGroup() != null) { av.getSelectionGroup().addOrRemove(found, true); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()-1); - PaintRefresher.Refresh(this, av.alignment); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); + PaintRefresher.Refresh(this, av.getSequenceSetId()); } else { av.setSelectionGroup(new SequenceGroup()); av.getSelectionGroup().addOrRemove(found, true); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()-1); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); } } repaint(); } - public void mouseMoved(MouseEvent evt) { - SequenceI found = findPoint(evt.getX(), evt.getY()); - if(found==null) - tooltip = null; - else - { - tooltip = found.getName(); - toolx = evt.getX(); - tooly = evt.getY(); - } - repaint(); + SequenceI found = findPoint(evt.getX(), evt.getY()); + if (found == null) + { + tooltip = null; + } + else + { + tooltip = found.getName(); + toolx = evt.getX(); + tooly = evt.getY(); + } + repaint(); } public void mouseDragged(MouseEvent evt) @@ -531,35 +534,35 @@ public class RotatableCanvas mx = evt.getX(); my = evt.getY(); - rotmat.setIdentity(); + rotmat.setIdentity(); - rotmat.rotate( (float) (my - omy), 'x'); - rotmat.rotate( (float) (mx - omx), 'y'); + rotmat.rotate( (float) (my - omy), 'x'); + rotmat.rotate( (float) (mx - omx), 'y'); - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - sp.coord[0] -= centre[0]; - sp.coord[1] -= centre[1]; - sp.coord[2] -= centre[2]; - - //Now apply the rotation matrix - sp.coord = rotmat.vectorMultiply(sp.coord); - - //Now translate back again - sp.coord[0] += centre[0]; - sp.coord[1] += centre[1]; - sp.coord[2] += centre[2]; - } + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + sp.coord[0] -= centre[0]; + sp.coord[1] -= centre[1]; + sp.coord[2] -= centre[2]; - for (int i = 0; i < 3; i++) - { - axes[i] = rotmat.vectorMultiply(axes[i]); - } - omx = mx; - omy = my; + //Now apply the rotation matrix + sp.coord = rotmat.vectorMultiply(sp.coord); + + //Now translate back again + sp.coord[0] += centre[0]; + sp.coord[1] += centre[1]; + sp.coord[2] += centre[2]; + } + + for (int i = 0; i < 3; i++) + { + axes[i] = rotmat.vectorMultiply(axes[i]); + } + omx = mx; + omy = my; - paint(this.getGraphics()); + paint(this.getGraphics()); } public void rectSelect(int x1, int y1, int x2, int y2) @@ -577,7 +580,7 @@ public class RotatableCanvas { if (av != null) { - if (!av.getSelectionGroup().sequences.contains(sp.sequence)) + if (!av.getSelectionGroup().getSequences(null).contains(sp.sequence)) { av.getSelectionGroup().addSequence(sp.sequence, true); }