X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationColourChooser.java;h=04864b14b07c14135511ed9ed3e3a73464d2fd19;hb=b57a02c25e335d033c97f8a6bacd6b54f62bd2b6;hp=4ff027bc2d25527cb36c81c5f3f68e9b3ab18576;hpb=797df64fa2a0a30773d0f48f5494d4155e5a8be3;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationColourChooser.java b/src/jalview/appletgui/AnnotationColourChooser.java index 4ff027b..04864b1 100755 --- a/src/jalview/appletgui/AnnotationColourChooser.java +++ b/src/jalview/appletgui/AnnotationColourChooser.java @@ -55,14 +55,11 @@ public class AnnotationColourChooser extends Panel implements } oldcs = av.getGlobalColourScheme(); - if (av.alignment.getGroups() != null) + if (av.getAlignment().getGroups() != null) { oldgroupColours = new Hashtable(); - Vector allGroups = ap.av.alignment.getGroups(); - SequenceGroup sg; - for (int g = 0; g < allGroups.size(); g++) + for (SequenceGroup sg : ap.av.getAlignment().getGroups()) { - sg = (SequenceGroup) allGroups.elementAt(g); if (sg.cs != null) { oldgroupColours.put(sg, sg.cs); @@ -79,18 +76,19 @@ public class AnnotationColourChooser extends Panel implements slider.addAdjustmentListener(this); slider.addMouseListener(this); - if (av.alignment.getAlignmentAnnotation() == null) + if (av.getAlignment().getAlignmentAnnotation() == null) { return; } setDefaultMinMax(); - + if (oldcs instanceof AnnotationColourGradient) { AnnotationColourGradient acg = (AnnotationColourGradient) oldcs; currentColours.setState(acg.predefinedColours); - if (!acg.predefinedColours) { + if (!acg.predefinedColours) + { minColour.setBackground(acg.getMinColour()); maxColour.setBackground(acg.getMaxColour()); } @@ -100,9 +98,9 @@ public class AnnotationColourChooser extends Panel implements Vector list = new Vector(); int index = 1; - for (int i = 0; i < av.alignment.getAlignmentAnnotation().length; i++) + for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++) { - String label = av.alignment.getAlignmentAnnotation()[i].label; + String label = av.getAlignment().getAlignmentAnnotation()[i].label; if (!list.contains(label)) list.addElement(label); else @@ -122,21 +120,23 @@ public class AnnotationColourChooser extends Panel implements { AnnotationColourGradient acg = (AnnotationColourGradient) oldcs; annotations.select(acg.getAnnotation()); - switch (acg.getAboveThreshold()) { + switch (acg.getAboveThreshold()) + { case AnnotationColourGradient.NO_THRESHOLD: - threshold.select("No Threshold"); + threshold.select("No Threshold"); break; case AnnotationColourGradient.ABOVE_THRESHOLD: - threshold.select("Above Threshold"); + threshold.select("Above Threshold"); break; case AnnotationColourGradient.BELOW_THRESHOLD: threshold.select("Below Threshold"); break; - default: - throw new Error("Implementation error: don't know about threshold setting for current AnnotationColourGradient."); + default: + throw new Error( + "Implementation error: don't know about threshold setting for current AnnotationColourGradient."); } thresholdIsMin.setState(acg.thresholdIsMinMax); - thresholdValue.setText(""+acg.getAnnotationThreshold()); + thresholdValue.setText("" + acg.getAnnotationThreshold()); } adjusting = false; @@ -152,10 +152,13 @@ public class AnnotationColourChooser extends Panel implements private void setDefaultMinMax() { - minColour.setBackground(av.applet.getDefaultColourParameter("ANNOTATIONCOLOUR_MIN",Color.orange)); - maxColour.setBackground(av.applet.getDefaultColourParameter("ANNOTATIONCOLOUR_MAX",Color.red)); + minColour.setBackground(av.applet.getDefaultColourParameter( + "ANNOTATIONCOLOUR_MIN", Color.orange)); + maxColour.setBackground(av.applet.getDefaultColourParameter( + "ANNOTATIONCOLOUR_MAX", Color.red)); } + public AnnotationColourChooser() { try @@ -186,14 +189,14 @@ public class AnnotationColourChooser extends Panel implements defColours.setLabel("Defaults"); defColours.addActionListener(this); - + annotations.addItemListener(this); thresholdValue.addActionListener(this); slider.setBackground(Color.white); - slider.setPreferredSize(new Dimension(193,21)); + slider.setPreferredSize(new Dimension(193, 21)); slider.setEnabled(false); - thresholdValue.setPreferredSize(new Dimension(79,22)); + thresholdValue.setPreferredSize(new Dimension(79, 22)); thresholdValue.setEnabled(false); thresholdValue.setColumns(5); currentColours.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); @@ -204,9 +207,9 @@ public class AnnotationColourChooser extends Panel implements thresholdIsMin.setLabel("Threshold is min/max"); this.setLayout(borderLayout1); - + jPanel1.setBackground(Color.white); - + jPanel2.setLayout(new FlowLayout()); jPanel2.setBackground(Color.white); threshold.addItemListener(this); @@ -216,32 +219,30 @@ public class AnnotationColourChooser extends Panel implements jPanel4.setLayout(new BorderLayout()); jPanel4.setBackground(Color.white); - jPanel1.add(ok); jPanel1.add(cancel); - + jPanel2.add(annotations); jPanel2.add(currentColours); jPanel2.add(minColour); jPanel2.add(maxColour); - - + jPanel4.add(thresholdIsMin, BorderLayout.WEST); jPanel4.add(slider, BorderLayout.CENTER); jPanel4.add(thresholdValue, BorderLayout.EAST); - + Panel jPanel34 = new Panel(); jPanel34.setLayout(new BorderLayout()); jPanel34.setBackground(Color.white); jPanel34.add(jPanel2, BorderLayout.NORTH); jPanel34.add(threshold, BorderLayout.WEST); jPanel3.add(defColours); - jPanel34.add(jPanel3, BorderLayout.EAST); + jPanel34.add(jPanel3, BorderLayout.EAST); jPanel34.add(jPanel4, BorderLayout.SOUTH); - + this.add(jPanel34, java.awt.BorderLayout.CENTER); this.add(jPanel1, java.awt.BorderLayout.SOUTH); - + } Choice annotations = new Choice(); @@ -253,7 +254,7 @@ public class AnnotationColourChooser extends Panel implements Button ok = new Button(); Button cancel = new Button(); - + Button defColours = new Button(); Panel jPanel1 = new Panel(); @@ -299,7 +300,7 @@ public class AnnotationColourChooser extends Panel implements } else if (evt.getSource() == defColours) { - defColour_actionPerformed(); + defColour_actionPerformed(); } else if (evt.getSource() == ok) { @@ -380,6 +381,7 @@ public class AnnotationColourChooser extends Panel implements new UserDefinedColours(this, "Max Colour", maxColour.getBackground()); } } + public void defColour_actionPerformed() { setDefaultMinMax(); @@ -387,6 +389,7 @@ public class AnnotationColourChooser extends Panel implements maxColour.repaint(); changeColour(); } + void changeColour() { // Check if combobox is still adjusting @@ -395,7 +398,7 @@ public class AnnotationColourChooser extends Panel implements return; } - currentAnnotation = av.alignment.getAlignmentAnnotation()[annotations + currentAnnotation = av.getAlignment().getAlignmentAnnotation()[annotations .getSelectedIndex()]; int aboveThreshold = -1; @@ -464,13 +467,10 @@ public class AnnotationColourChooser extends Panel implements av.setGlobalColourScheme(acg); - if (av.alignment.getGroups() != null) + if (av.getAlignment().getGroups() != null) { - Vector allGroups = ap.av.alignment.getGroups(); - SequenceGroup sg; - for (int g = 0; g < allGroups.size(); g++) + for (SequenceGroup sg : ap.av.getAlignment().getGroups()) { - sg = (SequenceGroup) allGroups.elementAt(g); if (sg.cs == null) { @@ -499,13 +499,10 @@ public class AnnotationColourChooser extends Panel implements void reset() { av.setGlobalColourScheme(oldcs); - if (av.alignment.getGroups() != null) + if (av.getAlignment().getGroups() != null) { - Vector allGroups = ap.av.alignment.getGroups(); - SequenceGroup sg; - for (int g = 0; g < allGroups.size(); g++) + for (SequenceGroup sg : ap.av.getAlignment().getGroups()) { - sg = (SequenceGroup) allGroups.elementAt(g); Object cs = oldgroupColours.get(sg); if (cs instanceof ColourSchemeI) {