From 3971af0ab85bfd7a999415893c505eeae037b98e Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 3 Jun 2010 15:14:15 +0000 Subject: [PATCH] patch re JAL-554 --- src/jalview/appletgui/AnnotationLabels.java | 7 ++ src/jalview/appletgui/AnnotationPanel.java | 4 + src/jalview/gui/AnnotationPanel.java | 4 + src/jalview/gui/Jalview2XML.java | 138 ++++++++++++++------------- 4 files changed, 87 insertions(+), 66 deletions(-) diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 54b8a84..62ed93c 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -248,6 +248,13 @@ public class AnnotationLabels extends Panel implements ActionListener, MenuItem item = new MenuItem(ADDNEW); item.addActionListener(this); popup.add(item); + if (aa == null) + { + + popup.show(this, evt.getX(), evt.getY()); + return; + } + // add the rest if there are actually rows to show item = new MenuItem(EDITNAME); item.addActionListener(this); popup.add(item); diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index 15b590e..e3ba18b 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -104,6 +104,10 @@ public class AnnotationPanel extends Panel implements AdjustmentListener, public void actionPerformed(ActionEvent evt) { AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if (aa==null) + { + return; + } Annotation[] anot = aa[activeRow].annotations; if (anot.length < av.getColumnSelection().getMax()) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 755b85a..f408400 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -199,6 +199,10 @@ public class AnnotationPanel extends JPanel implements MouseListener, public void actionPerformed(ActionEvent evt) { AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if (aa==null) + { + return; + } Annotation[] anot = aa[activeRow].annotations; if (anot.length < av.getColumnSelection().getMax()) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 7a403a0..260f603 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -2169,7 +2169,7 @@ public class Jalview2XML // newer files have an 'autoCalculated' flag and store calculation // state in viewport properties jaa.autoCalculated = true; // means annotation will be marked for - // update at end of load. + // update at end of load. } al.addAnnotation(jaa); } @@ -2698,85 +2698,91 @@ public class Jalview2XML else if (view.getBgColour().startsWith("Annotation")) { // int find annotation - for (int i = 0; i < af.viewport.alignment.getAlignmentAnnotation().length; i++) + if (af.viewport.alignment.getAlignmentAnnotation() != null) { - if (af.viewport.alignment.getAlignmentAnnotation()[i].label - .equals(view.getAnnotationColours().getAnnotation())) + for (int i = 0; i < af.viewport.alignment + .getAlignmentAnnotation().length; i++) { - if (af.viewport.alignment.getAlignmentAnnotation()[i] - .getThreshold() == null) + if (af.viewport.alignment.getAlignmentAnnotation()[i].label + .equals(view.getAnnotationColours().getAnnotation())) { - af.viewport.alignment.getAlignmentAnnotation()[i] - .setThreshold(new jalview.datamodel.GraphLine(view - .getAnnotationColours().getThreshold(), - "Threshold", java.awt.Color.black) - - ); - } + if (af.viewport.alignment.getAlignmentAnnotation()[i] + .getThreshold() == null) + { + af.viewport.alignment.getAlignmentAnnotation()[i] + .setThreshold(new jalview.datamodel.GraphLine(view + .getAnnotationColours().getThreshold(), + "Threshold", java.awt.Color.black) - if (view.getAnnotationColours().getColourScheme() - .equals("None")) - { - cs = new AnnotationColourGradient(af.viewport.alignment - .getAlignmentAnnotation()[i], new java.awt.Color(view - .getAnnotationColours().getMinColour()), - new java.awt.Color(view.getAnnotationColours() - .getMaxColour()), view.getAnnotationColours() - .getAboveThreshold()); - } - else if (view.getAnnotationColours().getColourScheme() - .startsWith("ucs")) - { - cs = new AnnotationColourGradient(af.viewport.alignment - .getAlignmentAnnotation()[i], GetUserColourScheme( - jms, view.getAnnotationColours().getColourScheme()), - view.getAnnotationColours().getAboveThreshold()); - } - else - { - cs = new AnnotationColourGradient(af.viewport.alignment - .getAlignmentAnnotation()[i], ColourSchemeProperty - .getColour(al, view.getAnnotationColours() - .getColourScheme()), view - .getAnnotationColours().getAboveThreshold()); - } + ); + } - // Also use these settings for all the groups - if (al.getGroups() != null) - { - for (int g = 0; g < al.getGroups().size(); g++) + if (view.getAnnotationColours().getColourScheme().equals( + "None")) + { + cs = new AnnotationColourGradient(af.viewport.alignment + .getAlignmentAnnotation()[i], new java.awt.Color( + view.getAnnotationColours().getMinColour()), + new java.awt.Color(view.getAnnotationColours() + .getMaxColour()), view + .getAnnotationColours().getAboveThreshold()); + } + else if (view.getAnnotationColours().getColourScheme() + .startsWith("ucs")) + { + cs = new AnnotationColourGradient(af.viewport.alignment + .getAlignmentAnnotation()[i], + GetUserColourScheme(jms, view + .getAnnotationColours().getColourScheme()), + view.getAnnotationColours().getAboveThreshold()); + } + else { - jalview.datamodel.SequenceGroup sg = (jalview.datamodel.SequenceGroup) al - .getGroups().elementAt(g); + cs = new AnnotationColourGradient(af.viewport.alignment + .getAlignmentAnnotation()[i], ColourSchemeProperty + .getColour(al, view.getAnnotationColours() + .getColourScheme()), view + .getAnnotationColours().getAboveThreshold()); + } - if (sg.cs == null) + // Also use these settings for all the groups + if (al.getGroups() != null) + { + for (int g = 0; g < al.getGroups().size(); g++) { - continue; - } + jalview.datamodel.SequenceGroup sg = (jalview.datamodel.SequenceGroup) al + .getGroups().elementAt(g); - /* - * if - * (view.getAnnotationColours().getColourScheme().equals("None" - * )) { sg.cs = new AnnotationColourGradient( - * af.viewport.alignment.getAlignmentAnnotation()[i], new - * java.awt.Color(view.getAnnotationColours(). getMinColour()), - * new java.awt.Color(view.getAnnotationColours(). - * getMaxColour()), - * view.getAnnotationColours().getAboveThreshold()); } else - */ - { - sg.cs = new AnnotationColourGradient( - af.viewport.alignment.getAlignmentAnnotation()[i], - sg.cs, view.getAnnotationColours() - .getAboveThreshold()); - } + if (sg.cs == null) + { + continue; + } + + /* + * if + * (view.getAnnotationColours().getColourScheme().equals("None" + * )) { sg.cs = new AnnotationColourGradient( + * af.viewport.alignment.getAlignmentAnnotation()[i], new + * java.awt.Color(view.getAnnotationColours(). + * getMinColour()), new + * java.awt.Color(view.getAnnotationColours(). + * getMaxColour()), + * view.getAnnotationColours().getAboveThreshold()); } else + */ + { + sg.cs = new AnnotationColourGradient( + af.viewport.alignment.getAlignmentAnnotation()[i], + sg.cs, view.getAnnotationColours() + .getAboveThreshold()); + } + } } + + break; } - break; } - } } else -- 1.7.10.2