X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FAnnotationColourChooser.java;h=d26680d0e4c5daf43c84f2c3b65e12ff18216361;hb=ad20cd92225f2ee8c251d39b00b90555d382a616;hp=a3f9fa607927d577a1281ecfb355afb6f47b3e3c;hpb=d053a3c980cf4318b9a19a255f9fc870e74de989;p=jalview.git diff --git a/src/jalview/appletgui/AnnotationColourChooser.java b/src/jalview/appletgui/AnnotationColourChooser.java index a3f9fa6..d26680d 100755 --- a/src/jalview/appletgui/AnnotationColourChooser.java +++ b/src/jalview/appletgui/AnnotationColourChooser.java @@ -1,13 +1,13 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) - * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) + * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR @@ -24,9 +24,6 @@ import java.awt.event.*; import jalview.datamodel.*; import jalview.schemes.*; -import java.awt.Rectangle; - -import javax.swing.BoxLayout; public class AnnotationColourChooser extends Panel implements ActionListener, AdjustmentListener, ItemListener, MouseListener @@ -58,11 +55,8 @@ public class AnnotationColourChooser extends Panel implements if (av.getAlignment().getGroups() != null) { oldgroupColours = new Hashtable(); - Vector allGroups = ap.av.getAlignment().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); @@ -85,12 +79,13 @@ public class AnnotationColourChooser extends Panel implements } 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()); } @@ -122,21 +117,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 +149,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 +186,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 +204,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 +216,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 +251,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 +297,7 @@ public class AnnotationColourChooser extends Panel implements } else if (evt.getSource() == defColours) { - defColour_actionPerformed(); + defColour_actionPerformed(); } else if (evt.getSource() == ok) { @@ -380,6 +378,7 @@ public class AnnotationColourChooser extends Panel implements new UserDefinedColours(this, "Max Colour", maxColour.getBackground()); } } + public void defColour_actionPerformed() { setDefaultMinMax(); @@ -387,6 +386,7 @@ public class AnnotationColourChooser extends Panel implements maxColour.repaint(); changeColour(); } + void changeColour() { // Check if combobox is still adjusting @@ -466,11 +466,8 @@ public class AnnotationColourChooser extends Panel implements if (av.getAlignment().getGroups() != null) { - Vector allGroups = ap.av.getAlignment().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) { @@ -501,11 +498,8 @@ public class AnnotationColourChooser extends Panel implements av.setGlobalColourScheme(oldcs); if (av.getAlignment().getGroups() != null) { - Vector allGroups = ap.av.getAlignment().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) {