From: amwaterhouse Date: Mon, 13 Jun 2005 11:34:15 +0000 (+0000) Subject: PaintRefresh changed X-Git-Tag: Release_2_0~63 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6e71f42b0a3713ddbc3054e7ea9d8f5088130ec9;p=jalview.git PaintRefresh changed --- diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 25b74b6..b314854 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -749,10 +749,6 @@ public class AlignFrame { ( (ResidueColourScheme) cs).setThreshold(threshold); } - else if (cs instanceof ScoreColourScheme) - { - ( (ScoreColourScheme) cs).setThreshold(threshold); - } viewport.setGlobalColourScheme(cs); } @@ -760,10 +756,6 @@ public class AlignFrame { ( (ResidueColourScheme) cs).setThreshold(0); } - else if (cs instanceof ScoreColourScheme) - { - ( (ScoreColourScheme) cs).setThreshold(0); - } if (viewport.getConservationSelected()) { @@ -804,9 +796,16 @@ public class AlignFrame { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); + if(cs==null) + { + sg.cs = null; + continue; + } if (cs instanceof ClustalxColourScheme) { - sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth()); + ClustalxColourScheme cxs = (ClustalxColourScheme) cs; + cxs.resetClustalX(viewport.alignment.getSequences(), viewport.alignment.getWidth()); + sg.cs = cxs; } else { @@ -827,10 +826,6 @@ public class AlignFrame { ( (ResidueColourScheme) sg.cs).setThreshold(threshold); } - else if (sg.cs instanceof ScoreColourScheme) - { - ( (ScoreColourScheme) sg.cs).setThreshold(threshold); - } sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth())); } diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 3c3c52c..8b6939e 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -44,7 +44,7 @@ public class IdCanvas { setLayout(null); this.av = av; - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); } public void drawIdString(Graphics gg, SequenceI s, int i, int starty, diff --git a/src/jalview/appletgui/IdPanel.java b/src/jalview/appletgui/IdPanel.java index 33463d4..d548936 100755 --- a/src/jalview/appletgui/IdPanel.java +++ b/src/jalview/appletgui/IdPanel.java @@ -238,7 +238,7 @@ public class IdPanel av.getSelectionGroup().recalcConservation(); mouseDragging = false; - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(this, av.alignment); } public void highlightSearchResults(java.util.Vector found) diff --git a/src/jalview/appletgui/PaintRefresher.java b/src/jalview/appletgui/PaintRefresher.java index 670af70..2da1db6 100755 --- a/src/jalview/appletgui/PaintRefresher.java +++ b/src/jalview/appletgui/PaintRefresher.java @@ -17,44 +17,51 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -package jalview.appletgui; -import java.util.*; + +package jalview.appletgui; import java.awt.*; +import java.util.*; +import jalview.datamodel.*; public class PaintRefresher { - static Vector components = new Vector(); + static Hashtable components = new Hashtable(); - public static void Register(Component c) + public static void Register(Component comp, AlignmentI al) { - if (!components.contains(c)) + if(components.containsKey(al)) { - components.addElement(c); + Vector comps = (Vector)components.get(al); + comps.addElement(comp); } else { - components.removeElement(c); + Vector vcoms = new Vector(); + vcoms.addElement(comp); + components.put(al, vcoms); } } - public static void Refresh(Component c) + public static void Refresh(AlignmentI al) + { + Refresh(null, al); + } + + public static void Refresh(Component c, AlignmentI al) { Component temp; - Enumeration e = components.elements(); - while (e.hasMoreElements()) + Vector coms = (Vector)components.get(al); + Enumeration e = coms.elements(); + while( e.hasMoreElements() ) { - temp = (Component) e.nextElement(); + temp = (Component)e.nextElement(); - if (!temp.isValid()) - { - components.removeElement(temp); - } - else if (temp == c) - { + if(!temp.isValid()) + coms.removeElement( temp ); + else if( temp == c ) continue; - } temp.repaint(); } @@ -62,3 +69,4 @@ public class PaintRefresher } } + diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index 8d22f37..88b6251 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -91,7 +91,7 @@ public class RotatableCanvas this.points = points; this.npoint = npoint; this.av = av; - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); // prefsize = getPreferredSize(); orig = new float[npoint][3]; @@ -471,7 +471,7 @@ public class RotatableCanvas if (av.getSelectionGroup() != null) { av.getSelectionGroup().addOrRemove(found, true); - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(this, av.alignment); } else { diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 438d7ad..5aa5d66 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -50,7 +50,7 @@ public class SeqCanvas this.av = av; fr = new FeatureRenderer(av); sr = new SequenceRenderer(av); - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 9d14b26..6e2a544 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -593,28 +593,23 @@ public class SeqPanel public void doMouseReleasedDefineMode(MouseEvent evt) { - mouseDragging = false; + if(mouseDragging) + { + stretchGroup.recalcConservation(); + mouseDragging = false; + } if (stretchGroup == null) { return; } - stretchGroup.recalcConservation(); - - if (stretchGroup.cs instanceof ClustalxColourScheme) - { - stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, - av.alignment.getWidth()); - } - - else if (stretchGroup.cs instanceof ConservationColourScheme) + if (stretchGroup.cs instanceof ConservationColourScheme) { ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs; stretchGroup.cs = ccs; SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup.getName()); - } else { diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index b00d6cc..136be52 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -70,7 +70,7 @@ public class TreeCanvas longestName = label; setLayout(null); - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); } public void TreeSelectionChanged(Sequence sequence) @@ -85,7 +85,8 @@ public class TreeCanvas selected.setEndRes(av.alignment.getWidth()); selected.addOrRemove(sequence, true); - PaintRefresher.Refresh(this); +System.out.println("called here"); + PaintRefresher.Refresh(this, av.alignment); repaint(); } @@ -424,7 +425,6 @@ public class TreeCanvas public void mousePressed(MouseEvent e) { - av.setCurrentTree(tree); int x = e.getX(); @@ -472,14 +472,22 @@ public class TreeCanvas Vector l = tree.findLeaves( (SequenceNode) tree.getGroups().elementAt( i), new Vector()); - SequenceGroup sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true, false, - 0, av.alignment.getWidth()); + + Vector sequences = new Vector(); for (int j = 0; j < l.size(); j++) { - SequenceNode sn = (SequenceNode) l.elementAt(j); - sg.addSequence( (Sequence) sn.element(), false); + sequences.addElement( (Sequence) ( (SequenceNode) l.elementAt(j)).element()); } + ColourSchemeI cs = ColourSchemeProperty.getColour(sequences, av.alignment.getWidth(), + ColourSchemeProperty.getColourName(av.getGlobalColourScheme())); + + + SequenceGroup sg = new SequenceGroup(sequences, "TreeGroup", + cs, true, true, + false, 0, av.alignment.getWidth()); + + if (av.getGlobalColourScheme() instanceof ConservationColourScheme) { ConservationColourScheme ccs = (ConservationColourScheme) av. @@ -503,7 +511,7 @@ public class TreeCanvas } } - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(this, av.alignment); repaint(); } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 068d605..1a48af6 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -47,7 +47,7 @@ public class AlignmentPanel AnnotationLabels alabels; // this value is set false when selection area being dragged - boolean fastPaint = false; + boolean fastPaint = true; int hextent = 0; int vextent = 0; diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index c14da85..b38fd21 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -42,7 +42,7 @@ public class IdCanvas { setLayout(new BorderLayout()); this.av = av; - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); } public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, @@ -177,9 +177,6 @@ public class IdCanvas void drawIds(int starty, int endy) { - if(gg==null) - return; - Color currentColor = Color.white; Color currentTextColor = Color.black; diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 00fe35f..db24821 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -247,7 +247,7 @@ public class IdPanel } mouseDragging = false; - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(av.alignment); } public void highlightSearchResults(java.util.Vector found) diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index 6bec8fd..e59ecd9 100755 --- a/src/jalview/gui/PaintRefresher.java +++ b/src/jalview/gui/PaintRefresher.java @@ -16,47 +16,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -package jalview.gui; - -import java.util.*; +package jalview.gui; import java.awt.*; +import java.util.*; +import jalview.datamodel.*; public class PaintRefresher { - static Vector components = new Vector(); + static Hashtable components = new Hashtable(); - public static void Register(Component c) + public static void Register(Component comp, AlignmentI al) { - if (!components.contains(c)) + if(components.containsKey(al)) { - components.add(c); + Vector comps = (Vector)components.get(al); + comps.addElement(comp); } else { - components.remove(c); + Vector vcoms = new Vector(); + vcoms.addElement(comp); + components.put(al, vcoms); } } - public static void Refresh(Component c) + public static void Refresh(AlignmentI al) { - Component temp; - Enumeration e = components.elements(); + Refresh(null, al); + } - while (e.hasMoreElements()) + public static void Refresh(Component c, AlignmentI al) + { + Component temp; + Vector coms = (Vector)components.get(al); + Enumeration e = coms.elements(); + while( e.hasMoreElements() ) { - temp = (Component) e.nextElement(); - - if (!temp.isValid()) - { - components.removeElement(temp); - } - else if (temp == c) - { + temp = (Component)e.nextElement(); + + if(!temp.isValid()) + coms.removeElement( temp ); + else if( temp == c ) continue; - } temp.repaint(); } + } + } diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 7576173..d563e09 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -634,7 +634,7 @@ public class PopupMenu SequenceGroup sg = ap.av.getSelectionGroup(); ap.av.alignment.deleteGroup(sg); ap.av.setSelectionGroup(null); - ap.repaint(); + refresh(); } void pdbMenuItem_actionPerformed(ActionEvent e) @@ -676,7 +676,7 @@ public class PopupMenu sg.setOutlineColour(col); } - ap.repaint(); + refresh(); } public void showBoxes_actionPerformed(ActionEvent e) diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index c89cd59..6ae66a2 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -75,7 +75,7 @@ public class RotatableCanvas this.npoint = npoint; this.av = av; ToolTipManager.sharedInstance().registerComponent(this); - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); // prefsize = getPreferredSize(); @@ -475,7 +475,7 @@ public class RotatableCanvas if (av.getSelectionGroup() != null) { av.getSelectionGroup().addOrRemove(found, true); - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(this, av.alignment); } else { diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 1194d08..789fb3f 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -44,13 +44,15 @@ public class SeqCanvas int LABEL_WEST; int LABEL_EAST; + public SeqCanvas(AlignViewport av) { this.av = av; fr = new FeatureRenderer(av); sr = new SequenceRenderer(av); setLayout(new BorderLayout()); - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); + setBackground(Color.white); } void drawNorthScale(Graphics g, int startx, int endx, int ypos) @@ -212,16 +214,16 @@ public class SeqCanvas * NOTE 1: The av limits are set in setFont in this class and * in the adjustment listener in SeqPanel when the scrollbars move. */ + + + // Set this to false to force a full panel paint public void paintComponent(Graphics g) { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - - if (fastPaint) + if (fastPaint || getWidth() != g.getClipBounds().width + || getHeight() != g.getClipBounds().height) { g.drawImage(img, 0, 0, this); fastPaint = false; - return; } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 52d137b..a643ab8 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -60,6 +60,7 @@ public class SeqPanel public SeqPanel(AlignViewport avp, AlignmentPanel p) { this.av = avp; + setBackground(Color.white); seqCanvas = new SeqCanvas(avp); setLayout(new BorderLayout()); @@ -160,9 +161,9 @@ public class SeqPanel doMouseEnteredDefineMode(evt); } }); - repaint(); } + public void doMouseReleased(MouseEvent evt) { if (seqEditOccurred > -1) @@ -176,7 +177,7 @@ public class SeqPanel editingSeqs = false; groupEditing = false; - ap.repaint(); + seqCanvas.repaint(); } public void doMousePressed(MouseEvent evt) @@ -443,14 +444,14 @@ public class SeqPanel endEdit = res; lastres = res; - repaint(); + seqCanvas.repaint(); } public void drawChars(int seqstart, int seqend, int start) { seqCanvas.drawPanel(seqCanvas.gg, start, av.getEndRes(), seqstart, seqend, av.getStartRes(), av.getStartSeq(), 0); - repaint(); + seqCanvas.repaint(); } public void insertChar(int j, int seq) @@ -465,7 +466,7 @@ public class SeqPanel seqEditOccurred = seq; av.alignment.getWidth(); - repaint(); + seqCanvas.repaint(); } void editOccurred(int i) @@ -608,24 +609,26 @@ public class SeqPanel stretchGroup.getWidth(); - repaint(); + seqCanvas.repaint(); } public void doMouseReleasedDefineMode(MouseEvent evt) { - mouseDragging = false; + if(mouseDragging) + { + stretchGroup.recalcConservation(); + mouseDragging = false; + } if (stretchGroup == null) { return; } - stretchGroup.recalcConservation(); - if (stretchGroup.cs instanceof ClustalxColourScheme) { - stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, - av.alignment.getWidth()); + ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.sequences, + stretchGroup.getWidth()); } else if (stretchGroup.cs instanceof ConservationColourScheme) { @@ -644,7 +647,7 @@ public class SeqPanel changeEndRes = false; changeStartRes = false; stretchGroup = null; - repaint(); + seqCanvas.repaint(); ap.idPanel.repaint(); } @@ -743,7 +746,7 @@ public class SeqPanel scrollThread.setEvent(evt); } - repaint(); + seqCanvas.repaint(); } public void doMouseEnteredDefineMode(MouseEvent e) diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 0f74faf..2864eb4 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -65,7 +65,7 @@ public class TreeCanvas tree.findHeight(tree.getTopNode()); longestName = label; - PaintRefresher.Register(this); + PaintRefresher.Register(this, av.alignment); } public void TreeSelectionChanged(Sequence sequence) @@ -81,7 +81,7 @@ public class TreeCanvas selected.setEndRes(av.alignment.getWidth()); selected.addOrRemove(sequence, true); - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(this, av.alignment); repaint(); } @@ -568,11 +568,19 @@ public class TreeCanvas sequences.add( (Sequence)((SequenceNode) l.elementAt(j)).element()); } + ColourSchemeI cs = ColourSchemeProperty.getColour(sequences, av.alignment.getWidth(), + ColourSchemeProperty.getColourName(av.getGlobalColourScheme())); + SequenceGroup sg = new SequenceGroup(sequences, "TreeGroup", - av.getGlobalColourScheme(), true, true, + cs, true, true, false, 0, av.alignment.getWidth()); + ( (ResidueColourScheme) sg.cs).setThreshold(25); + + + + if (av.getGlobalColourScheme() instanceof ConservationColourScheme) { ConservationColourScheme ccs = (ConservationColourScheme) av. @@ -594,7 +602,7 @@ public class TreeCanvas } } - PaintRefresher.Refresh(this); + PaintRefresher.Refresh(this, av.alignment); repaint(); }