From efc31b4a8d5cee63555586804a2b79c06bdb5a14 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 30 Jun 2005 14:46:58 +0000 Subject: [PATCH] Formatting changes --- src/jalview/analysis/AAFrequency.java | 353 +-- src/jalview/analysis/AlignSeq.java | 456 ++- src/jalview/analysis/AlignmentSorter.java | 293 +- src/jalview/analysis/Conservation.java | 293 +- src/jalview/analysis/NJTree.java | 688 ++++- src/jalview/analysis/PCA.java | 143 +- src/jalview/analysis/SeqsetUtils.java | 264 +- src/jalview/analysis/SequenceIdMatcher.java | 246 +- src/jalview/appletgui/AnnotationPanel.java | 2 +- src/jalview/appletgui/IdCanvas.java | 12 +- src/jalview/appletgui/SeqCanvas.java | 12 +- src/jalview/bin/Cache.java | 139 +- src/jalview/bin/Jalview.java | 360 ++- src/jalview/bin/JalviewLite.java | 129 +- src/jalview/binding/Alignment.java | 145 +- src/jalview/binding/Annotation.java | 724 ++--- src/jalview/binding/AnnotationElement.java | 213 +- src/jalview/binding/Colour.java | 145 +- src/jalview/binding/JGroup.java | 512 ++-- src/jalview/binding/JSeq.java | 237 +- src/jalview/binding/JalviewModel.java | 173 +- src/jalview/binding/JalviewModelSequence.java | 1744 +++++------ src/jalview/binding/JalviewModelSequence2.java | 255 +- src/jalview/binding/JalviewModelSequence2Item.java | 361 +-- src/jalview/binding/JalviewUserColours.java | 236 +- src/jalview/binding/JalviewUserColoursItem.java | 56 +- src/jalview/binding/Residue.java | 361 ++- src/jalview/binding/Sequence.java | 178 +- src/jalview/binding/SequenceSet.java | 393 ++- src/jalview/binding/SequenceType.java | 359 ++- src/jalview/binding/Tree.java | 471 +-- src/jalview/binding/UserColour.java | 362 +-- src/jalview/binding/UserColourScheme.java | 178 +- src/jalview/binding/UserColours.java | 308 +- src/jalview/binding/VAMSAS.java | 1133 ++++---- src/jalview/binding/VamsasModel.java | 113 +- src/jalview/binding/Viewport.java | 2805 +++++++++--------- src/jalview/datamodel/Alignment.java | 573 ++-- src/jalview/datamodel/AlignmentAnnotation.java | 123 +- src/jalview/datamodel/AlignmentI.java | 218 +- src/jalview/datamodel/AlignmentOrder.java | 199 +- src/jalview/datamodel/Annotation.java | 41 +- src/jalview/datamodel/BinaryNode.java | 256 +- src/jalview/datamodel/BinarySequence.java | 102 +- src/jalview/datamodel/HistoryItem.java | 71 +- src/jalview/datamodel/Sequence.java | 332 ++- src/jalview/datamodel/SequenceFeature.java | 173 +- src/jalview/datamodel/SequenceGroup.java | 660 +++-- src/jalview/datamodel/SequenceI.java | 199 +- src/jalview/datamodel/SequenceNode.java | 117 +- src/jalview/datamodel/SequencePoint.java | 55 +- src/jalview/datamodel/SuperGroup.java | 110 +- src/jalview/gui/AlignFrame.java | 3049 ++++++++++++-------- src/jalview/gui/AlignViewport.java | 1503 ++++++---- src/jalview/gui/AlignmentPanel.java | 1498 ++++++---- src/jalview/gui/AnnotationLabels.java | 570 ++-- src/jalview/gui/AnnotationPanel.java | 1282 ++++---- src/jalview/gui/ColumnSelection.java | 187 +- src/jalview/gui/CutAndPasteTransfer.java | 208 +- src/jalview/gui/Desktop.java | 854 +++--- src/jalview/gui/FeatureRenderer.java | 171 +- src/jalview/gui/Finder.java | 560 ++-- src/jalview/gui/FontChooser.java | 237 +- src/jalview/gui/IdCanvas.java | 422 +-- src/jalview/gui/IdPanel.java | 538 ++-- src/jalview/gui/IdwidthAdjuster.java | 188 +- src/jalview/gui/Jalview2XML.java | 1261 ++++---- src/jalview/gui/OverviewPanel.java | 545 ++-- src/jalview/gui/PCAPanel.java | 245 +- src/jalview/gui/PaintRefresher.java | 95 +- src/jalview/gui/PairwiseAlignPanel.java | 171 +- src/jalview/gui/PopupMenu.java | 1387 +++++---- src/jalview/gui/Preferences.java | 524 ++-- src/jalview/gui/RedundancyPanel.java | 253 +- src/jalview/gui/RotatableCanvas.java | 1099 +++---- src/jalview/gui/ScalePanel.java | 431 +-- src/jalview/gui/SeqCanvas.java | 1009 ++++--- src/jalview/gui/SeqPanel.java | 1439 ++++----- src/jalview/gui/SequenceRenderer.java | 464 +-- src/jalview/gui/SliderPanel.java | 492 ++-- src/jalview/gui/SplashScreen.java | 176 +- src/jalview/gui/TreeCanvas.java | 1130 ++++---- src/jalview/gui/TreePanel.java | 643 +++-- src/jalview/gui/UserDefinedColours.java | 624 ++-- src/jalview/gui/WebserviceInfo.java | 409 +-- src/jalview/io/AlignFile.java | 62 +- src/jalview/io/BLCFile.java | 157 +- src/jalview/io/ClustalFile.java | 406 +-- src/jalview/io/EBIFetchClient.java | 140 +- src/jalview/io/FastaFile.java | 186 +- src/jalview/io/FileParse.java | 107 +- src/jalview/io/FormatAdapter.java | 104 +- src/jalview/io/HTMLOutput.java | 587 ++-- src/jalview/io/IdentifyFile.java | 70 +- src/jalview/io/JPredFile.java | 166 +- src/jalview/io/JalviewFileChooser.java | 716 ++--- src/jalview/io/JalviewFileFilter.java | 280 +- src/jalview/io/JalviewFileView.java | 166 +- src/jalview/io/MSFfile.java | 214 +- src/jalview/io/NewickFile.java | 416 ++- src/jalview/io/PIRFile.java | 276 +- src/jalview/io/PfamFile.java | 350 ++- src/jalview/io/PileUpfile.java | 511 ++-- src/jalview/io/SequenceFeatureFetcher.java | 306 +- src/jalview/io/WSWUBlastClient.java | 114 +- src/jalview/jbappletgui/GAlignFrame.java | 12 +- src/jalview/jbgui/GAlignFrame.java | 2183 +++++++------- src/jalview/jbgui/GAlignmentPanel.java | 202 +- src/jalview/jbgui/GCutAndPasteTransfer.java | 126 +- src/jalview/jbgui/GDesktop.java | 170 +- src/jalview/jbgui/GFinder.java | 179 +- src/jalview/jbgui/GFontChooser.java | 114 +- src/jalview/jbgui/GPCAPanel.java | 184 +- src/jalview/jbgui/GPairwiseAlignPanel.java | 44 +- src/jalview/jbgui/GPreferences.java | 104 +- src/jalview/jbgui/GSliderPanel.java | 86 +- src/jalview/jbgui/GTreePanel.java | 356 ++- src/jalview/jbgui/GUserDefinedColours.java | 100 +- src/jalview/jbgui/GWebserviceInfo.java | 44 +- src/jalview/math/Matrix.java | 422 ++- src/jalview/math/RotatableMatrix.java | 120 +- src/jalview/schemes/Blosum62ColourScheme.java | 115 +- src/jalview/schemes/BuriedColourScheme.java | 25 +- src/jalview/schemes/ClustalxColourScheme.java | 511 ++-- src/jalview/schemes/ColourSchemeI.java | 46 +- src/jalview/schemes/ColourSchemeProperty.java | 231 +- src/jalview/schemes/Consensus.java | 114 +- src/jalview/schemes/ConservationColourScheme.java | 93 +- src/jalview/schemes/HelixColourScheme.java | 55 +- src/jalview/schemes/HydrophobicColourScheme.java | 25 +- src/jalview/schemes/NucleotideColourScheme.java | 50 +- src/jalview/schemes/PIDColourScheme.java | 107 +- src/jalview/schemes/ResidueColourScheme.java | 95 +- src/jalview/schemes/ResidueProperties.java | 2294 ++++++++------- src/jalview/schemes/ScoreColourScheme.java | 60 +- src/jalview/schemes/StrandColourScheme.java | 25 +- src/jalview/schemes/TaylorColourScheme.java | 45 +- src/jalview/schemes/TurnColourScheme.java | 25 +- src/jalview/schemes/UserColourScheme.java | 71 +- src/jalview/schemes/ZappoColourScheme.java | 16 +- src/jalview/util/BrowserLauncher.java | 1473 +++++----- src/jalview/util/Comparison.java | 131 +- src/jalview/util/Format.java | 478 ++- src/jalview/util/QuickSort.java | 215 +- src/jalview/ws/JPredClient.java | 779 ++--- src/jalview/ws/MsaWSClient.java | 242 +- src/jalview/ws/MsaWServices.java | 17 +- src/jalview/ws/WSClient.java | 76 +- src/jalview/ws/WSClientI.java | 49 +- 149 files changed, 34382 insertions(+), 24606 deletions(-) diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index 8110c48..4ef250b 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -25,44 +25,68 @@ import jalview.datamodel.*; import java.util.*; -public class AAFrequency { - // Takes in a vector of sequences and column start and column end - // and returns a vector of size (end-start+1). Each element of the - // vector contains a hashtable with the keys being residues and - // the values being the count of each residue in that column. - // This class is used extensively in calculating alignment colourschemes - // that depend on the amount of conservation in each alignment column. - public static Vector calculate(Vector sequences, int start, int end) { +/** + * Takes in a vector of sequences and column start and column end + * and returns a vector of size (end-start+1). Each element of the + * vector contains a hashtable with the keys being residues and + * the values being the count of each residue in that column. + * This class is used extensively in calculating alignment colourschemes + * that depend on the amount of conservation in each alignment column. + * @author $author$ + * @version $Revision$ + */ +public class AAFrequency +{ + /** Takes in a vector of sequences and column start and column end + * and returns a vector of size (end-start+1). Each element of the + * vector contains a hashtable with the keys being residues and + * the values being the count of each residue in that column. + * This class is used extensively in calculating alignment colourschemes + * that depend on the amount of conservation in each alignment column. */ + public static Vector calculate(Vector sequences, int start, int end) + { Vector result = new Vector(); - for (int i = start; i <= end; i++) { + for (int i = start; i <= end; i++) + { Hashtable residueHash = new Hashtable(); int maxCount = 0; String maxResidue = "-"; int nongap = 0; - for (int j = 0; j < sequences.size(); j++) { - if (sequences.elementAt(j) instanceof Sequence) { + for (int j = 0; j < sequences.size(); j++) + { + if (sequences.elementAt(j) instanceof Sequence) + { Sequence s = (Sequence) sequences.elementAt(j); - if (s.getSequence().length() > i) { + if (s.getSequence().length() > i) + { String res = s.getSequence().charAt(i) + ""; - if (!jalview.util.Comparison.isGap(res.charAt(0))) { + if (!jalview.util.Comparison.isGap(res.charAt(0))) + { nongap++; - } else { + } + else + { res = "-"; // we always use this for gaps in the property vectors } - if (residueHash.containsKey(res)) { + if (residueHash.containsKey(res)) + { int count = ((Integer) residueHash.get(res)).intValue(); count++; if (!jalview.util.Comparison.isGap(res.charAt(0)) && - (count >= maxCount)) { - if (count > maxCount) { + (count >= maxCount)) + { + if (count > maxCount) + { maxResidue = res; - } else if (maxResidue.indexOf(res) == -1) { + } + else if (maxResidue.indexOf(res) == -1) + { maxResidue += res; } @@ -70,15 +94,22 @@ public class AAFrequency { } residueHash.put(res, new Integer(count)); - } else { + } + else + { residueHash.put(res, new Integer(1)); } - } else { - if (residueHash.containsKey("-")) { + } + else + { + if (residueHash.containsKey("-")) + { int count = ((Integer) residueHash.get("-")).intValue(); count++; residueHash.put("-", new Integer(count)); - } else { + } + else + { residueHash.put("-", new Integer(1)); } } @@ -87,7 +118,8 @@ public class AAFrequency { residueHash.put("maxCount", new Integer(maxCount)); - if (maxCount < 0) { + if (maxCount < 0) + { System.out.println("asasa " + maxCount); } @@ -99,279 +131,4 @@ public class AAFrequency { return result; } - - public static Vector calculatePID(SequenceI refseq, Vector sequences, - int window, int start, int end) { - Vector result = new Vector(); - - boolean init = true; - - Vector prev = null; - - for (int i = start; i <= end; i++) { - Vector values = new Vector(); - - result.addElement(values); - - // If start < window/2 then set value to zero. - if ((i < (window / 2)) || - (i >= (refseq.getSequence().length() - (window / 2)))) { - for (int j = 0; j < sequences.size(); j++) { - values.addElement(new Integer(0)); - } - } else if (init == true) { - init = false; - - int winstart = i - (window / 2); - int winend = i + (window / 2); - - if ((window % 2) != 0) { - winend++; - } - - for (int j = 0; j < sequences.size(); j++) { - values.addElement(new Integer(0)); - } - - for (int k = winstart; k <= winend; k++) { - String refchar = refseq.getSequence().substring(k, k + 1); - - if (jalview.util.Comparison.isGap(refchar.charAt(0))) { - refchar = "-"; - } else { - for (int j = 0; j < sequences.size(); j++) { - Sequence s = (Sequence) sequences.elementAt(j); - - if (s.getSequence().length() > k) { - String res = s.getSequence().substring(k, k + - 1); // no gapchar test needed - - if (res.equals(refchar)) { - int val = ((Integer) values.elementAt(j)).intValue(); - val++; - values.setElementAt(new Integer(val), j); - } - } - } - } - } - - prev = values; - } else { - int winstart = i - (window / 2); - int winend = i + (window / 2); - - if ((window % 2) != 0) { - winend++; - } - - // We need to take the previous set of values - // subtract the pid at winstart-1 - // and add the pid at winend; - String pre_refchar = refseq.getSequence().substring(winstart - - 1, winstart); - String pos_refchar = "-"; - - if (refseq.getSequence().length() > winend) { - pos_refchar = refseq.getSequence().substring(winend, - winend + 1); - } - - for (int j = 0; j < sequences.size(); j++) { - // First copy the pid value from i-1 - int val = ((Integer) prev.elementAt(j)).intValue(); - - Sequence s = (Sequence) sequences.elementAt(j); - - String pre_char = s.getSequence().substring(winstart - 1, - winstart); - - String pos_char = "-"; - - if (s.getSequence().length() > winend) { - pos_char = s.getSequence().substring(winend, winend + - 1); - } - - // Now substract 1 if the chars at winstart-1 match - if ((jalview.util.Comparison.isGap(pre_refchar.charAt(0)) == false) && - pre_char.equals(pre_refchar)) { - val--; - } - - if ((jalview.util.Comparison.isGap(pos_refchar.charAt(0)) == false) && - pos_char.equals(pos_refchar)) { - val++; - } - - values.addElement(new Integer(val)); - } - - prev = values; - } - } - - return result; - } - - public static Hashtable findBlocks(Vector seqs, int start, int end, - Vector exc) { - // start and end are in real (not relative coords); - // The coords in the hashtable that is returned are in relative coords - // i.e. start from 0 - Hashtable blocks = new Hashtable(); - - boolean prev = false; - int bstart = -1; - - for (int i = start; i <= end; i++) { - SequenceI seq = (SequenceI) seqs.elementAt(0); - - char c = seq.getCharAt(i); - - boolean found = true; - - int j = 1; - - while ((j < seqs.size()) && (found == true)) { - SequenceI jseq = (SequenceI) seqs.elementAt(j); - - if (!exc.contains(jseq)) { - char cc = jseq.getCharAt(i); - - if (cc != c) { - found = false; - } - } - - j++; - } - - if ((prev == false) && (found == true)) { - bstart = i; - } else if ((prev == true) && (found == false) && (bstart != -1)) { - int blockstart = bstart - start; - int blocklen = i - bstart; - - //System.out.println("Start len " + blockstart + " " + blocklen); - for (int jj = blockstart; jj < (blockstart + blocklen); jj++) { - blocks.put(new Integer(jj), new Integer(blocklen)); - } - - bstart = -1; - } - - prev = found; - } - - if (bstart != -1) { - int blockstart = bstart - start; - int blocklen = end - bstart; - - // System.out.println("Start len " + blockstart + " " + blocklen); - for (int jj = blockstart; jj < (blockstart + blocklen); jj++) { - blocks.put(new Integer(blockstart), new Integer(blocklen)); - } - } - - return blocks; - } - - public static Hashtable findKmerCount(SequenceI seq, int start, int end, - int window, int step, Vector kmers) { - int tmpstart = start; - Hashtable vals = new Hashtable(); - - while (tmpstart <= end) { - String tmpstr = seq.getSequence().substring(tmpstart - - (window / 2), tmpstart + (window / 2)); - - int count = 0; - - //System.out.println("Str " + tmpstr); - for (int ii = 0; ii < kmers.size(); ii++) { - String kmer = ((SequenceI) kmers.elementAt(ii)).getSequence(); - - int i = -1; - - while (tmpstr.indexOf(kmer, i) != -1) { - i = tmpstr.indexOf(kmer, i); - - i++; - count++; - } - - ii++; - } - - vals.put(new Integer(tmpstart), new Integer(count)); - tmpstart += step; - } - - return vals; - } - - public static Hashtable findBlockStarts(Vector seqs, int start, int end, - Vector exc) { - // start and end are in real (not relative coords); - // The coords in the hashtable that is returned are in relative coords - // i.e. start from 0 - Hashtable blocks = new Hashtable(); - - boolean prev = false; - int bstart = -1; - - for (int i = start; i <= end; i++) { - SequenceI seq = (SequenceI) seqs.elementAt(0); - - char c = seq.getCharAt(i); - - boolean found = true; - - int j = 1; - - while ((j < seqs.size()) && (found == true)) { - SequenceI jseq = (SequenceI) seqs.elementAt(j); - - if (!exc.contains(jseq)) { - char cc = jseq.getCharAt(i); - - if (cc != c) { - found = false; - } - } - - j++; - } - - if ((prev == false) && (found == true)) { - bstart = i; - } else if ((prev == true) && (found == false) && (bstart != -1)) { - int blockstart = bstart - start; - int blocklen = i - bstart; - - // System.out.println("Start len " + blockstart + " " + blocklen); - //for (int jj = blockstart; jj < blockstart + blocklen;jj++) { - blocks.put(new Integer(blockstart), new Integer(blocklen)); - - // } - bstart = -1; - } - - prev = found; - } - - if (bstart != -1) { - int blockstart = bstart - start; - int blocklen = end - bstart; - - // System.out.println("Start len " + blockstart + " " + blocklen); - //for (int jj = blockstart; jj < blockstart + blocklen;jj++) { - blocks.put(new Integer(blockstart), new Integer(blocklen)); - - // } - } - - return blocks; - } } diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 47c17a3..60ad85c 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -20,23 +20,28 @@ package jalview.analysis; import jalview.datamodel.SequenceI; -import jalview.io.*; - import jalview.schemes.*; import jalview.util.*; import java.awt.*; -import java.io.*; - import java.util.*; -public class AlignSeq { +/** + * + * + * @author $author$ + * @version $Revision$ + */ +public class AlignSeq +{ + /** DOCUMENT ME!! */ public static java.util.Hashtable dnaHash = new java.util.Hashtable(); - static { + static + { dnaHash.put("C", new Integer(0)); dnaHash.put("T", new Integer(1)); dnaHash.put("A", new Integer(2)); @@ -45,7 +50,8 @@ public class AlignSeq { } static String[] dna = { "C", "T", "A", "G", "-" }; - static String[] pep = { + static String[] pep = + { "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "-" }; @@ -65,11 +71,21 @@ public class AlignSeq { int[] aseq2; String astr1 = ""; String astr2 = ""; + + /** DOCUMENT ME!! */ public int seq1start; + + /** DOCUMENT ME!! */ public int seq1end; + + /** DOCUMENT ME!! */ public int seq2start; + + /** DOCUMENT ME!! */ public int seq2end; int count; + + /** DOCUMENT ME!! */ public int maxscore; float pid; int prev = 0; @@ -82,84 +98,171 @@ public class AlignSeq { String type; Runtime rt; - public AlignSeq() { - } - public AlignSeq(SequenceI s1, SequenceI s2, String type) { + /** + * Creates a new AlignSeq object. + * + * @param s1 DOCUMENT ME! + * @param s2 DOCUMENT ME! + * @param type DOCUMENT ME! + */ + public AlignSeq(SequenceI s1, SequenceI s2, String type) + { rt = Runtime.getRuntime(); SeqInit(s1, s2, type); } - public int getMaxScore() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getMaxScore() + { return maxscore; } - public int getSeq2Start() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq2Start() + { return seq2start; } - public int getSeq2End() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq2End() + { return seq2end; } - public int getSeq1Start() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq1Start() + { return seq1start; } - public int getSeq1End() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSeq1End() + { return seq1end; } - public String getOutput() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getOutput() + { return output; } - public String getAStr1() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getAStr1() + { return astr1; } - public String getAStr2() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getAStr2() + { return astr2; } - public int[] getASeq1() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] getASeq1() + { return aseq1; } - public int[] getASeq2() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] getASeq2() + { return aseq2; } - public SequenceI getS1() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI getS1() + { return s1; } - public SequenceI getS2() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI getS2() + { return s2; } - public void SeqInit(SequenceI s1, SequenceI s2, String type) { - s1str = extractGaps(".", s1.getSequence()); - s2str = extractGaps(".", s2.getSequence()); - s1str = extractGaps("-", s1str); - s2str = extractGaps("-", s2str); - s1str = extractGaps(" ", s1str); - s2str = extractGaps(" ", s2str); + /** + * DOCUMENT ME! + * + * @param s1 DOCUMENT ME! + * @param s2 DOCUMENT ME! + * @param type DOCUMENT ME! + */ + public void SeqInit(SequenceI s1, SequenceI s2, String type) + { + s1str = extractGaps(jalview.util.Comparison.GapChars, s1.getSequence()); + s2str = extractGaps(jalview.util.Comparison.GapChars, s2.getSequence()); this.s1 = s1; this.s2 = s2; this.type = type; - if (type.equals("pep")) { + if (type.equals("pep")) + { lookup = ResidueProperties.getBLOSUM62(); intToStr = pep; defInt = 23; - } else if (type.equals("dna")) { + } + else if (type.equals("dna")) + { lookup = ResidueProperties.getDNA(); intToStr = dna; defInt = 4; - } else { + } + else + { output = output + ("Wrong type = dna or pep only"); System.exit(0); } @@ -205,20 +308,28 @@ public class AlignSeq { //System.out.println("Time take to traceback alignment = " + (tend-tstart) + " ms"); } - public void traceAlignment() { + /** + * DOCUMENT ME! + */ + public void traceAlignment() + { // Find the maximum score along the rhs or bottom row int max = -9999; - for (int i = 0; i < seq1.length; i++) { - if (score[i][seq2.length - 1] > max) { + for (int i = 0; i < seq1.length; i++) + { + if (score[i][seq2.length - 1] > max) + { max = score[i][seq2.length - 1]; maxi = i; maxj = seq2.length - 1; } } - for (int j = 0; j < seq2.length; j++) { - if (score[seq1.length - 1][j] > max) { + for (int j = 0; j < seq2.length; j++) + { + if (score[seq1.length - 1][j] > max) + { max = score[seq1.length - 1][j]; maxi = seq1.length - 1; maxj = j; @@ -239,27 +350,35 @@ public class AlignSeq { count = (seq1.length + seq2.length) - 1; - while ((i > 0) && (j > 0)) { - if ((aseq1[count] != defInt) && (i >= 0)) { + while ((i > 0) && (j > 0)) + { + if ((aseq1[count] != defInt) && (i >= 0)) + { aseq1[count] = seq1[i]; astr1 = intToStr[seq1[i]] + astr1; } - if ((aseq2[count] != defInt) && (j > 0)) { + if ((aseq2[count] != defInt) && (j > 0)) + { aseq2[count] = seq2[j]; astr2 = intToStr[seq2[j]] + astr2; } trace = findTrace(i, j); - if (trace == 0) { + if (trace == 0) + { i--; j--; - } else if (trace == 1) { + } + else if (trace == 1) + { j--; aseq1[count] = defInt; astr1 = "-" + astr1.substring(1); - } else if (trace == -1) { + } + else if (trace == -1) + { i--; aseq2[count] = defInt; astr2 = "-" + astr2.substring(1); @@ -271,22 +390,29 @@ public class AlignSeq { seq1start = i + 1; seq2start = j + 1; - if (aseq1[count] != defInt) { + if (aseq1[count] != defInt) + { aseq1[count] = seq1[i]; astr1 = intToStr[seq1[i]] + astr1; } - if (aseq2[count] != defInt) { + if (aseq2[count] != defInt) + { aseq2[count] = seq2[j]; astr2 = intToStr[seq2[j]] + astr2; } } - public void printAlignment() { + /** + * DOCUMENT ME! + */ + public void printAlignment() + { // Find the biggest id length for formatting purposes int maxid = s1.getName().length(); - if (s2.getName().length() > maxid) { + if (s2.getName().length() > maxid) + { maxid = s2.getName().length(); } @@ -294,8 +420,6 @@ public class AlignSeq { int nochunks = ((aseq1.length - count) / len) + 1; pid = 0; - int overlap = 0; - output = output + ("Score = " + score[maxi][maxj] + "\n"); output = output + ("Length of alignment = " + (aseq1.length - count) + "\n"); @@ -310,13 +434,16 @@ public class AlignSeq { (" : " + seq2start + " - " + seq2end + " (Sequence length = " + s2str.length() + ")\n\n"); - for (int j = 0; j < nochunks; j++) { + for (int j = 0; j < nochunks; j++) + { // Print the first aligned sequence output = output + (new Format("%" + (maxid) + "s").form(s1.getName()) + " "); - for (int i = 0; i < len; i++) { - if ((count + i + (j * len)) < aseq1.length) { + for (int i = 0; i < len; i++) + { + if ((count + i + (j * len)) < aseq1.length) + { output = output + (new Format("%s").form(intToStr[aseq1[count + i + (j * len)]])); @@ -328,22 +455,32 @@ public class AlignSeq { (new Format("%" + (maxid) + "s").form(" ") + " "); // Print out the matching chars - for (int i = 0; i < len; i++) { - if ((count + i + (j * len)) < aseq1.length) { + for (int i = 0; i < len; i++) + { + if ((count + i + (j * len)) < aseq1.length) + { if (intToStr[aseq1[count + i + (j * len)]].equals( intToStr[aseq2[count + i + (j * len)]]) && - !intToStr[aseq1[count + i + (j * len)]].equals("-")) { + !intToStr[aseq1[count + i + (j * len)]].equals("-")) + { pid++; output = output + ("|"); - } else if (type.equals("pep")) { + } + else if (type.equals("pep")) + { if (ResidueProperties.getPAM250( intToStr[aseq1[count + i + (j * len)]], - intToStr[aseq2[count + i + (j * len)]]) > 0) { + intToStr[aseq2[count + i + (j * len)]]) > 0) + { output = output + ("."); - } else { + } + else + { output = output + (" "); } - } else { + } + else + { output = output + (" "); } } @@ -354,8 +491,10 @@ public class AlignSeq { output = output + (new Format("%" + (maxid) + "s").form(s2.getName()) + " "); - for (int i = 0; i < len; i++) { - if ((count + i + (j * len)) < aseq1.length) { + for (int i = 0; i < len; i++) + { + if ((count + i + (j * len)) < aseq1.length) + { output = output + (new Format("%s").form(intToStr[aseq2[count + i + (j * len)]])); @@ -369,24 +508,35 @@ public class AlignSeq { output = output + (new Format("Percentage ID = %2.2f\n\n").form(pid)); } - public void printScoreMatrix(int[][] mat) { + /** + * DOCUMENT ME! + * + * @param mat DOCUMENT ME! + */ + public void printScoreMatrix(int[][] mat) + { int n = seq1.length; int m = seq2.length; - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { // Print the top sequence - if (i == 0) { + if (i == 0) + { Format.print(System.out, "%8s", s2str.substring(0, 1)); - for (int jj = 1; jj < m; jj++) { + for (int jj = 1; jj < m; jj++) + { Format.print(System.out, "%5s", s2str.substring(jj, jj + 1)); } System.out.println(); } - for (int j = 0; j < m; j++) { - if (j == 0) { + for (int j = 0; j < m; j++) + { + if (j == 0) + { Format.print(System.out, "%3s", s1str.substring(i, i + 1)); } @@ -397,25 +547,42 @@ public class AlignSeq { } } - public int findTrace(int i, int j) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int findTrace(int i, int j) + { int t = 0; int max = score[i - 1][j - 1] + (lookup[seq1[i]][seq2[j]] * 10); - if (F[i][j] > max) { + if (F[i][j] > max) + { max = F[i][j]; t = -1; - } else if (F[i][j] == max) { - if (prev == -1) { + } + else if (F[i][j] == max) + { + if (prev == -1) + { max = F[i][j]; t = -1; } } - if (E[i][j] >= max) { + if (E[i][j] >= max) + { max = E[i][j]; t = 1; - } else if (E[i][j] == max) { - if (prev == 1) { + } + else if (E[i][j] == max) + { + if (prev == 1) + { max = E[i][j]; t = 1; } @@ -426,7 +593,11 @@ public class AlignSeq { return t; } - public void calcScoreMatrix() { + /** + * DOCUMENT ME! + */ + public void calcScoreMatrix() + { int n = seq1.length; int m = seq2.length; @@ -436,7 +607,8 @@ public class AlignSeq { F[0][0] = 0; // Calculate the top row first - for (int j = 1; j < m; j++) { + for (int j = 1; j < m; j++) + { // What should these values be? 0 maybe E[0][j] = max(score[0][j - 1] - gapOpen, E[0][j - 1] - gapExtend); F[0][j] = -gapExtend; @@ -448,7 +620,8 @@ public class AlignSeq { } // Now do the left hand column - for (int i = 1; i < n; i++) { + for (int i = 1; i < n; i++) + { E[i][0] = -gapOpen; F[i][0] = max(score[i - 1][0] - gapOpen, F[i - 1][0] - gapExtend); @@ -457,8 +630,10 @@ public class AlignSeq { } // Now do all the other rows - for (int i = 1; i < n; i++) { - for (int j = 1; j < m; j++) { + for (int i = 1; i < n; i++) + { + for (int j = 1; j < m; j++) + { E[i][j] = max(score[i][j - 1] - gapOpen, E[i][j - 1] - gapExtend); F[i][j] = max(score[i - 1][j] - gapOpen, F[i - 1][j] - @@ -471,72 +646,115 @@ public class AlignSeq { } } - public static String extractChars(String chars, String seq) { - String out = seq; - for (int i = 0; i < chars.length(); i++) { - String gap = chars.substring(i, i + 1); - out = extractGaps(gap, out); - } - - return out; - } - public static String extractGaps(String gapChar, String seq) { + /** + * DOCUMENT ME! + * + * @param gapChar DOCUMENT ME! + * @param seq DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String extractGaps(String gapChar, String seq) + { StringTokenizer str = new StringTokenizer(seq, gapChar); String newString = ""; - while (str.hasMoreTokens()) { + while (str.hasMoreTokens()) + { newString = newString + str.nextToken(); } return newString; } - public int max(int i1, int i2, int i3) { + /** + * DOCUMENT ME! + * + * @param i1 DOCUMENT ME! + * @param i2 DOCUMENT ME! + * @param i3 DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int max(int i1, int i2, int i3) + { int max = i1; - if (i2 > i1) { + if (i2 > i1) + { max = i2; } - if (i3 > max) { + if (i3 > max) + { max = i3; } return max; } - public int max(int i1, int i2) { + /** + * DOCUMENT ME! + * + * @param i1 DOCUMENT ME! + * @param i2 DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int max(int i1, int i2) + { int max = i1; - if (i2 > i1) { + if (i2 > i1) + { max = i2; } return max; } - public int[] stringToInt(String s, String type) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] stringToInt(String s, String type) + { int[] seq1 = new int[s.length()]; - for (int i = 0; i < s.length(); i++) { + for (int i = 0; i < s.length(); i++) + { String ss = s.substring(i, i + 1).toUpperCase(); - try { - if (type.equals("pep")) { + try + { + if (type.equals("pep")) + { seq1[i] = ((Integer) ResidueProperties.aaHash.get(ss)).intValue(); - } else if (type.equals("dna")) { + } + else if (type.equals("dna")) + { seq1[i] = ((Integer) dnaHash.get(ss)).intValue(); } - if (seq1[i] > 23) { + if (seq1[i] > 23) + { seq1[i] = 23; } - } catch (Exception e) { - if (type.equals("dna")) { + } + catch (Exception e) + { + if (type.equals("dna")) + { seq1[i] = 4; - } else { + } + else + { seq1[i] = 23; } } @@ -545,18 +763,32 @@ public class AlignSeq { return seq1; } + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param mat DOCUMENT ME! + * @param n DOCUMENT ME! + * @param m DOCUMENT ME! + * @param psize DOCUMENT ME! + */ public static void displayMatrix(Graphics g, int[][] mat, int n, int m, - int psize) { + int psize) + { int max = -1000; int min = 1000; - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - if (mat[i][j] >= max) { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < m; j++) + { + if (mat[i][j] >= max) + { max = mat[i][j]; } - if (mat[i][j] <= min) { + if (mat[i][j] <= min) + { min = mat[i][j]; } } @@ -564,8 +796,10 @@ public class AlignSeq { System.out.println(max + " " + min); - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < m; j++) + { int x = psize * i; int y = psize * j; diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index bdd6bce..20101dc 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -20,8 +20,6 @@ package jalview.analysis; import jalview.datamodel.*; -import jalview.io.*; - import jalview.util.*; import java.util.*; @@ -29,8 +27,8 @@ import java.util.*; /** Data structure to hold and manipulate a multiple sequence alignment */ -public class AlignmentSorter { - /** */ +public class AlignmentSorter +{ static boolean sortIdAscending = true; static int lastGroupHash = 0; static boolean sortGroupAscending = true; @@ -45,13 +43,15 @@ public class AlignmentSorter { * @param align AlignmentI * @param s SequenceI */ - public static void sortByPID(AlignmentI align, SequenceI s) { + public static void sortByPID(AlignmentI align, SequenceI s) + { int nSeq = align.getHeight(); float[] scores = new float[nSeq]; SequenceI[] seqs = new SequenceI[nSeq]; - for (int i = 0; i < nSeq; i++) { + for (int i = 0; i < nSeq; i++) + { scores[i] = Comparison.PID(align.getSequenceAt(i), s); seqs[i] = align.getSequenceAt(i); } @@ -61,129 +61,199 @@ public class AlignmentSorter { setReverseOrder(align, seqs); } - private static void setReverseOrder(AlignmentI align, SequenceI[] seqs) { + /** + * Reverse the order of the sort + * + * @param align DOCUMENT ME! + * @param seqs DOCUMENT ME! + */ + private static void setReverseOrder(AlignmentI align, SequenceI[] seqs) + { int nSeq = seqs.length; int len = 0; - if ((nSeq % 2) == 0) { + if ((nSeq % 2) == 0) + { len = nSeq / 2; - } else { + } + else + { len = (nSeq + 1) / 2; } // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work - for (int i = 0; i < len; i++) { + for (int i = 0; i < len; i++) + { //SequenceI tmp = seqs[i]; align.getSequences().setElementAt(seqs[nSeq - i - 1], i); align.getSequences().setElementAt(seqs[i], nSeq - i - 1); } } - private static void setOrder(AlignmentI align, Vector tmp) { + /** + * Sets the Alignment object with the given sequences + * + * @param align Alignment object to be updated + * @param tmp sequences as a vector + */ + private static void setOrder(AlignmentI align, Vector tmp) + { setOrder(align, vectorSubsetToArray(tmp, align.getSequences())); } - private static void setOrder(AlignmentI align, SequenceI[] seqs) { - + /** + * Sets the Alignment object with the given sequences + * + * @param align DOCUMENT ME! + * @param seqs sequences as an array + */ + private static void setOrder(AlignmentI align, SequenceI[] seqs) + { // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work Vector algn = align.getSequences(); + for (int i = 0; i < seqs.length; i++) { - algn.setElementAt(seqs[i], i); + algn.setElementAt(seqs[i], i); } } - public static void sortByID(AlignmentI align) { + /** + * Sorts by ID. Numbers are sorted before letters. + * + * @param align The alignment object to sort + */ + public static void sortByID(AlignmentI align) + { int nSeq = align.getHeight(); String[] ids = new String[nSeq]; SequenceI[] seqs = new SequenceI[nSeq]; - for (int i = 0; i < nSeq; i++) { + for (int i = 0; i < nSeq; i++) + { ids[i] = align.getSequenceAt(i).getName(); seqs[i] = align.getSequenceAt(i); } QuickSort.sort(ids, seqs); - if (sortIdAscending) { + if (sortIdAscending) + { setReverseOrder(align, seqs); - } else { + } + else + { setOrder(align, seqs); } sortIdAscending = !sortIdAscending; } - public static void sortByGroup(AlignmentI align) { - //MAINTAINS ORIGNAL SEQUENCE ORDER, - //ORDERS BY GROUP SIZE - + /** + * Sorts the alignment by size of group. + *
Maintains the order of sequences in each group + * by order in given alignment object. + * + * @param align sorts the given alignment object by group + */ + public static void sortByGroup(AlignmentI align) + { + //MAINTAINS ORIGNAL SEQUENCE ORDER, + //ORDERS BY GROUP SIZE Vector groups = new Vector(); - if (groups.hashCode() != lastGroupHash) { + if (groups.hashCode() != lastGroupHash) + { sortGroupAscending = true; lastGroupHash = groups.hashCode(); - } else { + } + else + { sortGroupAscending = !sortGroupAscending; } //SORTS GROUPS BY SIZE ////////////////////// - for(int i=0; i sg2.getSize()) - { - groups.insertElementAt(sg, j); - break; - } - } - - if (!groups.contains(sg)) - { - groups.addElement(sg); - } + SequenceGroup sg = (SequenceGroup) align.getGroups().elementAt(i); + + for (int j = 0; j < groups.size(); j++) + { + SequenceGroup sg2 = (SequenceGroup) groups.elementAt(j); + + if (sg.getSize() > sg2.getSize()) + { + groups.insertElementAt(sg, j); + + break; + } + } + + if (!groups.contains(sg)) + { + groups.addElement(sg); + } } //NOW ADD SEQUENCES MAINTAINING ALIGNMENT ORDER /////////////////////////////////////////////// Vector seqs = new Vector(); + for (int i = 0; i < groups.size(); i++) { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - SequenceI [] orderedseqs = sg.getSequencesInOrder(align); + SequenceI[] orderedseqs = sg.getSequencesInOrder(align); + for (int j = 0; j < orderedseqs.length; j++) { seqs.addElement(orderedseqs[j]); } } - if (sortGroupAscending) { + if (sortGroupAscending) + { setOrder(align, seqs); - } else { + } + else + { setReverseOrder(align, vectorSubsetToArray(seqs, align.getSequences())); } } - private static SequenceI[] vectorToArray(Vector tmp) { - + /** + * Converts Vector to array. + * java 1.18 does not have Vector.toArray() + * + * @param tmp Vector of SequenceI objects + * + * @return array of Sequence[] + */ + private static SequenceI[] vectorToArray(Vector tmp) + { SequenceI[] seqs = new SequenceI[tmp.size()]; - for (int i = 0; i < tmp.size(); i++) { + for (int i = 0; i < tmp.size(); i++) + { seqs[i] = (SequenceI) tmp.elementAt(i); } return seqs; } - private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask) { + /** + * DOCUMENT ME! + * + * @param tmp DOCUMENT ME! + * @param mask DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask) + { Vector seqs = new Vector(); int i; boolean[] tmask = new boolean[mask.size()]; @@ -191,8 +261,8 @@ public class AlignmentSorter { for (i = 0; i < mask.size(); i++) tmask[i] = true; - for (i = 0; i < tmp.size(); i++) { - + for (i = 0; i < tmp.size(); i++) + { Object sq = tmp.elementAt(i); if (mask.contains(sq) && tmask[mask.indexOf(sq)]) @@ -203,47 +273,73 @@ public class AlignmentSorter { } for (i = 0; i < tmask.length; i++) - if (tmask[i]) { + if (tmask[i]) + { seqs.addElement(mask.elementAt(i)); } return vectorToArray(seqs); } - public static void sortBy(AlignmentI align, AlignmentOrder order) { + /** + * Sorts by a given AlignmentOrder object + * + * @param align Alignment to order + * @param order specified order for alignment + */ + public static void sortBy(AlignmentI align, AlignmentOrder order) + { // Get an ordered vector of sequences which may also be present in align Vector tmp = order.getOrder(); - if (lastOrder == order) { + if (lastOrder == order) + { sortOrderAscending = !sortOrderAscending; - } else { + } + else + { sortOrderAscending = true; } - if (sortOrderAscending) { + if (sortOrderAscending) + { setOrder(align, tmp); - } else { + } + else + { setReverseOrder(align, vectorSubsetToArray(tmp, align.getSequences())); } } - public static Vector getOrderByTree(AlignmentI align, NJTree tree) { + /** + * DOCUMENT ME! + * + * @param align alignment to order + * @param tree tree which has + * + * @return DOCUMENT ME! + */ + private static Vector getOrderByTree(AlignmentI align, NJTree tree) + { int nSeq = align.getHeight(); Vector tmp = new Vector(); tmp = _sortByTree(tree.getTopNode(), tmp, align.getSequences()); - if (tmp.size() != nSeq) { + if (tmp.size() != nSeq) + { // TODO: JBPNote - decide if this is always an error // (eg. not when a tree is associated to another alignment which has more // sequences) - if (tmp.size() < nSeq) { + if (tmp.size() < nSeq) + { addStrays(align, tmp); } - if (tmp.size() != nSeq) { + if (tmp.size() != nSeq) + { System.err.println("ERROR: tmp.size()=" + tmp.size() + " != nseq=" + nSeq + " in getOrderByTree"); } @@ -252,60 +348,100 @@ public class AlignmentSorter { return tmp; } - public static void sortByTree(AlignmentI align, NJTree tree) { + /** + * Sorts the alignment by a given tree + * + * @param align alignment to order + * @param tree tree which has + */ + public static void sortByTree(AlignmentI align, NJTree tree) + { Vector tmp = getOrderByTree(align, tree); // tmp should properly permute align with tree. - if (lastTree != tree) { + if (lastTree != tree) + { sortTreeAscending = true; lastTree = tree; - } else { + } + else + { sortTreeAscending = !sortTreeAscending; } - if (sortTreeAscending) { + if (sortTreeAscending) + { setOrder(align, tmp); - } else { + } + else + { setReverseOrder(align, vectorSubsetToArray(tmp, align.getSequences())); } } - private static void addStrays(AlignmentI align, Vector seqs) { + /** + * DOCUMENT ME! + * + * @param align DOCUMENT ME! + * @param seqs DOCUMENT ME! + */ + private static void addStrays(AlignmentI align, Vector seqs) + { int nSeq = align.getHeight(); - for (int i = 0; i < nSeq; i++) { - if (!seqs.contains(align.getSequenceAt(i))) { + for (int i = 0; i < nSeq; i++) + { + if (!seqs.contains(align.getSequenceAt(i))) + { seqs.addElement(align.getSequenceAt(i)); } } - if (nSeq != seqs.size()) { + if (nSeq != seqs.size()) + { System.err.println( "ERROR: Size still not right even after addStrays"); } } - public static Vector _sortByTree(SequenceNode node, Vector tmp, - Vector seqset) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param tmp DOCUMENT ME! + * @param seqset DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static Vector _sortByTree(SequenceNode node, Vector tmp, + Vector seqset) + { + if (node == null) + { return tmp; } SequenceNode left = (SequenceNode) node.left(); SequenceNode right = (SequenceNode) node.right(); - if ((left == null) && (right == null)) { - if (!node.isPlaceholder() && (node.element() != null)) { - if (node.element() instanceof SequenceI) { - if (!tmp.contains(node.element())) { + if ((left == null) && (right == null)) + { + if (!node.isPlaceholder() && (node.element() != null)) + { + if (node.element() instanceof SequenceI) + { + if (!tmp.contains(node.element())) + { tmp.addElement((SequenceI) node.element()); } } } return tmp; - } else { + } + else + { _sortByTree(left, tmp, seqset); _sortByTree(right, tmp, seqset); } @@ -321,7 +457,8 @@ public class AlignmentSorter { * recover the order of sequences given by the safe numbering scheme introducd * SeqsetUtils.uniquify. */ - public static void recoverOrder(SequenceI[] alignment) { + public static void recoverOrder(SequenceI[] alignment) + { float[] ids = new float[alignment.length]; for (int i = 0; i < alignment.length; i++) diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index bfb2e00..0fe4f5e 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -20,12 +20,17 @@ package jalview.analysis; import jalview.datamodel.*; -import jalview.gui.*; - import java.util.*; -public class Conservation { +/** + * Calculates conservation values for a given set of sequences + * + * @author $author$ + * @version $Revision$ + */ +public class Conservation +{ Vector sequences; int start; int end; @@ -33,7 +38,11 @@ public class Conservation { int maxLength = 0; // used by quality calcs boolean seqNumsChanged = false; // updated after any change via calcSeqNum; Vector total = new Vector(); + + /** Stores calculated quality values */ public Vector quality; + + /** Stores maximum and minimum values of quality values */ public Double[] qualityRange = new Double[2]; String consString = ""; Sequence consSequence; @@ -42,8 +51,19 @@ public class Conservation { String name = ""; int[][] cons2; + /** + * Creates a new Conservation object. + * + * @param name Name of conservation + * @param propHash DOCUMENT ME! + * @param threshold to count the residues in residueHash(). commonly used value is 3 + * @param sequences sequences to be used in calculation + * @param start start residue position + * @param end end residue position + */ public Conservation(String name, Hashtable propHash, int threshold, - Vector sequences, int start, int end) { + Vector sequences, int start, int end) + { this.name = name; this.propHash = propHash; this.threshold = threshold; @@ -54,81 +74,115 @@ public class Conservation { calcSeqNums(); } - private void calcSeqNums() { - for (int i = 0; i < sequences.size(); i++) { + /** + * DOCUMENT ME! + */ + private void calcSeqNums() + { + for (int i = 0; i < sequences.size(); i++) + { calcSeqNum(i); } } - private void calcSeqNum(int i) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + private void calcSeqNum(int i) + { String sq = null; // for dumb jbuilder not-inited exception warning int[] sqnum = null; - if ((i > -1) && (i < sequences.size())) { + if ((i > -1) && (i < sequences.size())) + { sq = ((SequenceI) sequences.elementAt(i)).getSequence(); - if (seqNums.size() <= i) { + if (seqNums.size() <= i) + { seqNums.addElement(new int[sq.length() + 1]); } - if (sq.hashCode() != ((int[]) seqNums.elementAt(i))[0]) { + if (sq.hashCode() != ((int[]) seqNums.elementAt(i))[0]) + { int j; int len; seqNumsChanged = true; sq = ((SequenceI) sequences.elementAt(i)).getSequence(); len = sq.length(); - if (maxLength < len) { + if (maxLength < len) + { maxLength = len; } sqnum = new int[len + 1]; // better to always make a new array - sequence can change its length sqnum[0] = sq.hashCode(); - for (j = 1; j <= len; j++) { + for (j = 1; j <= len; j++) + { sqnum[j] = ((Integer) jalview.schemes.ResidueProperties.aaHash.get(new String( sq.substring(j - 1, j)))).intValue(); // yuk } seqNums.setElementAt(sqnum, i); } - } else { + } + else + { // JBPNote INFO level debug System.err.println( "ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); } } - public void calculate() { - for (int i = start; i <= end; i++) { + /** + * Calculates the conservation values for given set of sequences + */ + public void calculate() + { + for (int i = start; i <= end; i++) + { Hashtable resultHash = null; Hashtable residueHash = null; resultHash = new Hashtable(); residueHash = new Hashtable(); - for (int j = 0; j < sequences.size(); j++) { + for (int j = 0; j < sequences.size(); j++) + { // JBPNote - have to make sure elements of the sequences vector // are tested like this everywhere... - if (sequences.elementAt(j) instanceof Sequence) { + if (sequences.elementAt(j) instanceof Sequence) + { Sequence s = (Sequence) sequences.elementAt(j); - if (s.getLength() > i) { + if (s.getLength() > i) + { String res = s.getSequence().substring(i, i + 1); - if (residueHash.containsKey(res)) { + if (residueHash.containsKey(res)) + { int count = ((Integer) residueHash.get(res)).intValue(); count++; residueHash.put(res, new Integer(count)); - } else { + } + else + { residueHash.put(res, new Integer(1)); } - } else { - if (residueHash.containsKey("-")) { + } + else + { + if (residueHash.containsKey("-")) + { int count = ((Integer) residueHash.get("-")).intValue(); count++; residueHash.put("-", new Integer(count)); - } else { + } + else + { residueHash.put("-", new Integer(1)); } } @@ -141,26 +195,35 @@ public class Conservation { //loop over all the found residues Enumeration e = residueHash.keys(); - while (e.hasMoreElements()) { + while (e.hasMoreElements()) + { String res = (String) e.nextElement(); - if (((Integer) residueHash.get(res)).intValue() > thresh) { + if (((Integer) residueHash.get(res)).intValue() > thresh) + { //Now loop over the properties Enumeration e2 = propHash.keys(); - while (e2.hasMoreElements()) { + while (e2.hasMoreElements()) + { String type = (String) e2.nextElement(); Hashtable ht = (Hashtable) propHash.get(type); //Have we ticked this before? - if (!resultHash.containsKey(type)) { - if (ht.containsKey(res)) { + if (!resultHash.containsKey(type)) + { + if (ht.containsKey(res)) + { resultHash.put(type, ht.get(res)); - } else { + } + else + { resultHash.put(type, ht.get("-")); } - } else if (((Integer) resultHash.get(type)).equals( - (Integer) ht.get(res)) == false) { + } + else if (((Integer) resultHash.get(type)).equals( + (Integer) ht.get(res)) == false) + { resultHash.put(type, new Integer(-1)); } } @@ -171,40 +234,23 @@ public class Conservation { } } - public int countGaps(int j) { - int count = 0; - - for (int i = 0; i < sequences.size(); i++) { - if ((j + 1) > ((Sequence) sequences.elementAt(i)).getSequence() - .length()) { - count++; - - continue; - } - - char c = ((Sequence) sequences.elementAt(i)).getSequence().charAt(j); - - if (jalview.util.Comparison.isGap((c))) { - count++; - } - } - - return count; - } /*** * countConsNGaps * returns gap count in int[0], and conserved residue count in int[1] */ - public int[] countConsNGaps(int j) { + public int[] countConsNGaps(int j) + { int count = 0; int cons = 0; int nres = 0; int[] r = new int[2]; char f = '$'; - for (int i = 0; i < sequences.size(); i++) { - if (j >= ((Sequence) sequences.elementAt(i)).getSequence().length()) { + for (int i = 0; i < sequences.size(); i++) + { + if (j >= ((Sequence) sequences.elementAt(i)).getSequence().length()) + { count++; continue; @@ -212,15 +258,21 @@ public class Conservation { char c = ((Sequence) sequences.elementAt(i)).getSequence().charAt(j); - if (jalview.util.Comparison.isGap((c))) { + if (jalview.util.Comparison.isGap((c))) + { count++; - } else { + } + else + { nres++; - if (nres == 1) { + if (nres == 1) + { f = c; cons++; - } else if (f == c) { + } + else if (f == c) + { cons++; } } @@ -232,45 +284,64 @@ public class Conservation { return r; } - public void verdict(boolean consflag, float percentageGaps) { + /** + * Calculates the conservation sequence + * + * @param consflag if true, poitiveve conservation; false calculates negative conservation + * @param percentageGaps commonly used value is 25 + */ + public void verdict(boolean consflag, float percentageGaps) + { String consString = ""; - for (int i = start; i <= end; i++) { + for (int i = start; i <= end; i++) + { int[] gapcons = countConsNGaps(i); - boolean cons = (gapcons[0] == 1) ? true : false; int totGaps = gapcons[1]; float pgaps = ((float) totGaps * 100) / (float) sequences.size(); // System.out.println("percentage gaps = "+pgaps+"\n"); - if (percentageGaps > pgaps) { + if (percentageGaps > pgaps) + { Hashtable resultHash = (Hashtable) total.elementAt(i - start); //Now find the verdict int count = 0; Enumeration e3 = resultHash.keys(); - while (e3.hasMoreElements()) { + while (e3.hasMoreElements()) + { String type = (String) e3.nextElement(); Integer result = (Integer) resultHash.get(type); //Do we want to count +ve conservation or +ve and -ve cons.? - if (consflag) { - if (result.intValue() == 1) { + if (consflag) + { + if (result.intValue() == 1) + { count++; } - } else { - if (result.intValue() != -1) { + } + else + { + if (result.intValue() != -1) + { count++; } } } - if (count < 10) { + if (count < 10) + { consString = consString + String.valueOf(count); // Conserved props!=Identity - } else { + } + else + { consString = consString + ((gapcons[0] == 1) ? "*" : "+"); } - } else { + } + else + { consString = consString + "-"; } } @@ -278,24 +349,38 @@ public class Conservation { consSequence = new Sequence(name, consString, start, end); } - public Sequence getConsSequence() { + /** + * + * + * @return Conservation sequence + */ + public Sequence getConsSequence() + { return consSequence; } // From Alignment.java in jalview118 - public void findQuality() { + public void findQuality() + { findQuality(0, maxLength - 1); } - private void percentIdentity2() { + /** + * DOCUMENT ME! + */ + private void percentIdentity2() + { calcSeqNums(); // updates maxLength, too. - if ((cons2 == null) || seqNumsChanged) { + if ((cons2 == null) || seqNumsChanged) + { cons2 = new int[maxLength][24]; // Initialize the array - for (int j = 0; j < 24; j++) { - for (int i = 0; i < maxLength; i++) { + for (int j = 0; j < 24; j++) + { + for (int i = 0; i < maxLength; i++) + { cons2[i][j] = 0; } } @@ -303,14 +388,17 @@ public class Conservation { int[] sqnum; int j = 0; - while (j < sequences.size()) { + while (j < sequences.size()) + { sqnum = (int[]) seqNums.elementAt(j); - for (int i = 1; i < sqnum.length; i++) { + for (int i = 1; i < sqnum.length; i++) + { cons2[i - 1][sqnum[i]]++; } - for (int i = sqnum.length - 1; i < maxLength; i++) { + for (int i = sqnum.length - 1; i < maxLength; i++) + { cons2[i][23]++; // gap count } @@ -336,7 +424,14 @@ public class Conservation { } } - public void findQuality(int start, int end) { + /** + * Calculates the quality of the set of sequences + * + * @param start Start residue + * @param end End residue + */ + public void findQuality(int start, int end) + { quality = new Vector(); double max = -10000; @@ -354,21 +449,27 @@ public class Conservation { for (int l = 0; l < size; l++) lengths[l] = ((int[]) seqNums.elementAt(l)).length - 1; - for (int j = start; j <= end; j++) { + for (int j = start; j <= end; j++) + { double bigtot = 0; // First Xr = depends on column only double[] x = new double[24]; - for (int ii = 0; ii < 24; ii++) { + for (int ii = 0; ii < 24; ii++) + { x[ii] = 0; - try { - for (int i2 = 0; i2 < 24; i2++) { + try + { + for (int i2 = 0; i2 < 24; i2++) + { x[ii] += (((double) cons2[j][i2] * BLOSUM62[ii][i2]) + 4); } - } catch (Exception e) { + } + catch (Exception e) + { System.err.println("Exception during quality calculation."); e.printStackTrace(); } @@ -380,19 +481,24 @@ public class Conservation { } // Now calculate D for each position and sum - for (int k = 0; k < size; k++) { + for (int k = 0; k < size; k++) + { double tot = 0; double[] xx = new double[24]; int seqNum = (j < lengths[k]) ? ((int[]) seqNums.elementAt(k))[j + 1] : 23; // Sequence, or gap at the end // This is a loop over r - for (int i = 0; i < 23; i++) { + for (int i = 0; i < 23; i++) + { double sr = 0; - try { + try + { sr = (double) BLOSUM62[i][seqNum] + 4; - } catch (Exception e) { + } + catch (Exception e) + { System.out.println("Exception in sr: " + e); e.printStackTrace(); } @@ -408,7 +514,8 @@ public class Conservation { } // This is the quality for one column - if (max < bigtot) { + if (max < bigtot) + { max = bigtot; } @@ -422,14 +529,16 @@ public class Conservation { double newmax = -10000; - for (int j = start; j <= end; j++) { + for (int j = start; j <= end; j++) + { double tmp = ((Double) quality.elementAt(j)).doubleValue(); tmp = ((max - tmp) * (size - cons2[j][23])) / size; // System.out.println(tmp+ " " + j); quality.setElementAt(new Double(tmp), j); - if (tmp > newmax) { + if (tmp > newmax) + { newmax = tmp; } } diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java index 6daee9b..71d6737 100755 --- a/src/jalview/analysis/NJTree.java +++ b/src/jalview/analysis/NJTree.java @@ -29,7 +29,14 @@ import jalview.util.*; import java.util.*; -public class NJTree { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class NJTree +{ Vector cluster; SequenceI[] sequence; int[] done; @@ -54,12 +61,25 @@ public class NJTree { int start; int end; - public NJTree(SequenceNode node) { + /** + * Creates a new NJTree object. + * + * @param node DOCUMENT ME! + */ + public NJTree(SequenceNode node) + { top = node; maxheight = findHeight(top); } - public NJTree(SequenceI[] seqs, NewickFile treefile) { + /** + * Creates a new NJTree object. + * + * @param seqs DOCUMENT ME! + * @param treefile DOCUMENT ME! + */ + public NJTree(SequenceI[] seqs, NewickFile treefile) + { top = treefile.getTree(); maxheight = findHeight(top); @@ -75,31 +95,54 @@ public class NJTree { SequenceI nam; String realnam; - while (i < leaves.size()) { + while (i < leaves.size()) + { j = (SequenceNode) leaves.elementAt(i++); realnam = j.getName(); nam = null; - if (namesleft > -1) { + if (namesleft > -1) + { nam = algnIds.findIdMatch(realnam); } - if (nam != null) { + if (nam != null) + { j.setElement(nam); namesleft--; - } else { + } + else + { j.setElement(new Sequence(realnam, "THISISAPLACEHLDER")); j.setPlaceholder(true); } } } - public NJTree(SequenceI[] sequence, int start, int end) { + /** + * Creates a new NJTree object. + * + * @param sequence DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + public NJTree(SequenceI[] sequence, int start, int end) + { this(sequence, "NJ", "BL", start, end); } + /** + * Creates a new NJTree object. + * + * @param sequence DOCUMENT ME! + * @param type DOCUMENT ME! + * @param pwtype DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ public NJTree(SequenceI[] sequence, String type, String pwtype, int start, - int end) { + int end) + { this.sequence = sequence; this.node = new Vector(); this.type = type; @@ -107,11 +150,13 @@ public class NJTree { this.start = start; this.end = end; - if (!(type.equals("NJ"))) { + if (!(type.equals("NJ"))) + { type = "AV"; } - if (!(pwtype.equals("PID"))) { + if (!(pwtype.equals("PID"))) + { type = "BL"; } @@ -119,7 +164,8 @@ public class NJTree { done = new int[sequence.length]; - while ((i < sequence.length) && (sequence[i] != null)) { + while ((i < sequence.length) && (sequence[i] != null)) + { done[i] = 0; i++; } @@ -135,7 +181,13 @@ public class NJTree { cluster(); } - public String toString() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String toString() + { jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode()); return fout.print(false, true); // distances only @@ -147,7 +199,8 @@ public class NJTree { * * @param alignment Vector */ - public void UpdatePlaceHolders(Vector alignment) { + public void UpdatePlaceHolders(Vector alignment) + { Vector leaves = new Vector(); findLeaves(top, leaves); @@ -155,13 +208,18 @@ public class NJTree { SequenceIdMatcher seqmatcher = null; int i = 0; - while (i < sz) { + while (i < sz) + { SequenceNode leaf = (SequenceNode) leaves.elementAt(i++); - if (alignment.contains(leaf.element())) { + if (alignment.contains(leaf.element())) + { leaf.setPlaceholder(false); - } else { - if (seqmatcher == null) { + } + else + { + if (seqmatcher == null) + { // Only create this the first time we need it SequenceI[] seqs = new SequenceI[alignment.size()]; @@ -173,21 +231,32 @@ public class NJTree { SequenceI nam = seqmatcher.findIdMatch(leaf.getName()); - if (nam != null) { + if (nam != null) + { leaf.setPlaceholder(false); leaf.setElement(nam); - } else { + } + else + { leaf.setPlaceholder(true); } } } } - public void cluster() { - while (noClus > 2) { - if (type.equals("NJ")) { + /** + * DOCUMENT ME! + */ + public void cluster() + { + while (noClus > 2) + { + if (type.equals("NJ")) + { float mind = findMinNJDistance(); - } else { + } + else + { float mind = findMinDistance(); } @@ -206,12 +275,17 @@ public class NJTree { int one = -1; int two = -1; - for (int i = 0; i < noseqs; i++) { - if (done[i] != 1) { - if (onefound == false) { + for (int i = 0; i < noseqs; i++) + { + if (done[i] != 1) + { + if (onefound == false) + { two = i; onefound = true; - } else { + } + else + { one = i; } } @@ -225,7 +299,16 @@ public class NJTree { findMaxDist(top); } - public Cluster joinClusters(int i, int j) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Cluster joinClusters(int i, int j) + { float dist = distance[i][j]; int noi = ((Cluster) cluster.elementAt(i)).value.length; @@ -233,11 +316,13 @@ public class NJTree { int[] value = new int[noi + noj]; - for (int ii = 0; ii < noi; ii++) { + for (int ii = 0; ii < noi; ii++) + { value[ii] = ((Cluster) cluster.elementAt(i)).value[ii]; } - for (int ii = noi; ii < (noi + noj); ii++) { + for (int ii = noi; ii < (noi + noj); ii++) + { value[ii] = ((Cluster) cluster.elementAt(j)).value[ii - noi]; } @@ -246,9 +331,12 @@ public class NJTree { ri = findr(i, j); rj = findr(j, i); - if (type.equals("NJ")) { + if (type.equals("NJ")) + { findClusterNJDistance(i, j); - } else { + } + else + { findClusterDistance(i, j); } @@ -260,9 +348,12 @@ public class NJTree { SequenceNode tmpi = (SequenceNode) (node.elementAt(i)); SequenceNode tmpj = (SequenceNode) (node.elementAt(j)); - if (type.equals("NJ")) { + if (type.equals("NJ")) + { findNewNJDistances(tmpi, tmpj, dist); - } else { + } + else + { findNewDistances(tmpi, tmpj, dist); } @@ -274,8 +365,16 @@ public class NJTree { return c; } + /** + * DOCUMENT ME! + * + * @param tmpi DOCUMENT ME! + * @param tmpj DOCUMENT ME! + * @param dist DOCUMENT ME! + */ public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj, - float dist) { + float dist) + { float ih = 0; float jh = 0; @@ -285,29 +384,41 @@ public class NJTree { tmpi.dist = ((dist + ri) - rj) / 2; tmpj.dist = (dist - tmpi.dist); - if (tmpi.dist < 0) { + if (tmpi.dist < 0) + { tmpi.dist = 0; } - if (tmpj.dist < 0) { + if (tmpj.dist < 0) + { tmpj.dist = 0; } } + /** + * DOCUMENT ME! + * + * @param tmpi DOCUMENT ME! + * @param tmpj DOCUMENT ME! + * @param dist DOCUMENT ME! + */ public void findNewDistances(SequenceNode tmpi, SequenceNode tmpj, - float dist) { + float dist) + { float ih = 0; float jh = 0; SequenceNode sni = tmpi; SequenceNode snj = tmpj; - while (sni != null) { + while (sni != null) + { ih = ih + sni.dist; sni = (SequenceNode) sni.left(); } - while (snj != null) { + while (snj != null) + { jh = jh + snj.dist; snj = (SequenceNode) snj.left(); } @@ -316,75 +427,121 @@ public class NJTree { tmpj.dist = ((dist / 2) - jh); } - public void findClusterDistance(int i, int j) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + */ + public void findClusterDistance(int i, int j) + { int noi = ((Cluster) cluster.elementAt(i)).value.length; int noj = ((Cluster) cluster.elementAt(j)).value.length; // New distances from cluster to others float[] newdist = new float[noseqs]; - for (int l = 0; l < noseqs; l++) { - if ((l != i) && (l != j)) { + for (int l = 0; l < noseqs; l++) + { + if ((l != i) && (l != j)) + { newdist[l] = ((distance[i][l] * noi) + (distance[j][l] * noj)) / (noi + noj); - } else { + } + else + { newdist[l] = 0; } } - for (int ii = 0; ii < noseqs; ii++) { + for (int ii = 0; ii < noseqs; ii++) + { distance[i][ii] = newdist[ii]; distance[ii][i] = newdist[ii]; } } - public void findClusterNJDistance(int i, int j) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + */ + public void findClusterNJDistance(int i, int j) + { int noi = ((Cluster) cluster.elementAt(i)).value.length; int noj = ((Cluster) cluster.elementAt(j)).value.length; // New distances from cluster to others float[] newdist = new float[noseqs]; - for (int l = 0; l < noseqs; l++) { - if ((l != i) && (l != j)) { + for (int l = 0; l < noseqs; l++) + { + if ((l != i) && (l != j)) + { newdist[l] = ((distance[i][l] + distance[j][l]) - distance[i][j]) / 2; - } else { + } + else + { newdist[l] = 0; } } - for (int ii = 0; ii < noseqs; ii++) { + for (int ii = 0; ii < noseqs; ii++) + { distance[i][ii] = newdist[ii]; distance[ii][i] = newdist[ii]; } } - public float findr(int i, int j) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findr(int i, int j) + { float tmp = 1; - for (int k = 0; k < noseqs; k++) { - if ((k != i) && (k != j) && (done[k] != 1)) { + for (int k = 0; k < noseqs; k++) + { + if ((k != i) && (k != j) && (done[k] != 1)) + { tmp = tmp + distance[i][k]; } } - if (noClus > 2) { + if (noClus > 2) + { tmp = tmp / (noClus - 2); } return tmp; } - public float findMinNJDistance() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findMinNJDistance() + { float min = 100000; - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i + 1; j < noseqs; j++) { - if ((done[i] != 1) && (done[j] != 1)) { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i + 1; j < noseqs; j++) + { + if ((done[i] != 1) && (done[j] != 1)) + { float tmp = distance[i][j] - (findr(i, j) + findr(j, i)); - if (tmp < min) { + if (tmp < min) + { mini = i; minj = j; @@ -397,13 +554,23 @@ public class NJTree { return min; } - public float findMinDistance() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findMinDistance() + { float min = 100000; - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i + 1; j < noseqs; j++) { - if ((done[i] != 1) && (done[j] != 1)) { - if (distance[i][j] < min) { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i + 1; j < noseqs; j++) + { + if ((done[i] != 1) && (done[j] != 1)) + { + if (distance[i][j] < min) + { mini = i; minj = j; @@ -416,34 +583,54 @@ public class NJTree { return min; } - public float[][] findDistances() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float[][] findDistances() + { float[][] distance = new float[noseqs][noseqs]; - if (pwtype.equals("PID")) { - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i; j < noseqs; j++) { - if (j == i) { + if (pwtype.equals("PID")) + { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { + if (j == i) + { distance[i][i] = 0; - } else { + } + else + { distance[i][j] = 100 - Comparison.PID(sequence[i], sequence[j], start, end); distance[j][i] = distance[i][j]; } } } - } else if (pwtype.equals("BL")) { + } + else if (pwtype.equals("BL")) + { int maxscore = 0; - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i; j < noseqs; j++) { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { int score = 0; - for (int k = start; k < end; k++) { - try { + for (int k = start; k < end; k++) + { + try + { score += ResidueProperties.getBLOSUM62(sequence[i].getSequence( k, k + 1), sequence[j].getSequence(k, k + 1)); - } catch (Exception ex) { + } + catch (Exception ex) + { System.err.println("err creating BLOSUM62 tree"); ex.printStackTrace(); } @@ -451,37 +638,47 @@ public class NJTree { distance[i][j] = (float) score; - if (score > maxscore) { + if (score > maxscore) + { maxscore = score; } } } - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i; j < noseqs; j++) { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { distance[i][j] = (float) maxscore - distance[i][j]; distance[j][i] = distance[i][j]; } } - } else if (pwtype.equals("SW")) { + } + else if (pwtype.equals("SW")) + { float max = -1; - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i; j < noseqs; j++) { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { AlignSeq as = new AlignSeq(sequence[i], sequence[j], "pep"); as.calcScoreMatrix(); as.traceAlignment(); as.printAlignment(); distance[i][j] = (float) as.maxscore; - if (max < distance[i][j]) { + if (max < distance[i][j]) + { max = distance[i][j]; } } } - for (int i = 0; i < (noseqs - 1); i++) { - for (int j = i; j < noseqs; j++) { + for (int i = 0; i < (noseqs - 1); i++) + { + for (int j = i; j < noseqs; j++) + { distance[i][j] = max - distance[i][j]; distance[j][i] = distance[i][j]; } @@ -491,10 +688,15 @@ public class NJTree { return distance; } - public void makeLeaves() { + /** + * DOCUMENT ME! + */ + public void makeLeaves() + { cluster = new Vector(); - for (int i = 0; i < noseqs; i++) { + for (int i = 0; i < noseqs; i++) + { SequenceNode sn = new SequenceNode(); sn.setElement(sequence[i]); @@ -509,16 +711,29 @@ public class NJTree { } } - public Vector findLeaves(SequenceNode node, Vector leaves) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param leaves DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector findLeaves(SequenceNode node, Vector leaves) + { + if (node == null) + { return leaves; } - if ((node.left() == null) && (node.right() == null)) { + if ((node.left() == null) && (node.right() == null)) + { leaves.addElement(node); return leaves; - } else { + } + else + { findLeaves((SequenceNode) node.left(), leaves); findLeaves((SequenceNode) node.right(), leaves); } @@ -526,22 +741,44 @@ public class NJTree { return leaves; } - public Object findLeaf(SequenceNode node, int count) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param count DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Object findLeaf(SequenceNode node, int count) + { found = _findLeaf(node, count); return found; } - public Object _findLeaf(SequenceNode node, int count) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param count DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Object _findLeaf(SequenceNode node, int count) + { + if (node == null) + { return null; } - if (node.ycount == count) { + if (node.ycount == count) + { found = node.element(); return found; - } else { + } + else + { _findLeaf((SequenceNode) node.left(), count); _findLeaf((SequenceNode) node.right(), count); } @@ -554,80 +791,137 @@ public class NJTree { * * @param node SequenceNode */ - public void printNode(SequenceNode node) { - if (node == null) { + public void printNode(SequenceNode node) + { + if (node == null) + { return; } - if ((node.left() == null) && (node.right() == null)) { + if ((node.left() == null) && (node.right() == null)) + { System.out.println("Leaf = " + ((SequenceI) node.element()).getName()); System.out.println("Dist " + ((SequenceNode) node).dist); System.out.println("Boot " + node.getBootstrap()); - } else { + } + else + { System.out.println("Dist " + ((SequenceNode) node).dist); printNode((SequenceNode) node.left()); printNode((SequenceNode) node.right()); } } - public void findMaxDist(SequenceNode node) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void findMaxDist(SequenceNode node) + { + if (node == null) + { return; } - if ((node.left() == null) && (node.right() == null)) { + if ((node.left() == null) && (node.right() == null)) + { float dist = ((SequenceNode) node).dist; - if (dist > maxDistValue) { + if (dist > maxDistValue) + { maxdist = (SequenceNode) node; maxDistValue = dist; } - } else { + } + else + { findMaxDist((SequenceNode) node.left()); findMaxDist((SequenceNode) node.right()); } } - public Vector getGroups() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getGroups() + { return groups; } - public float getMaxHeight() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float getMaxHeight() + { return maxheight; } - public void groupNodes(SequenceNode node, float threshold) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param threshold DOCUMENT ME! + */ + public void groupNodes(SequenceNode node, float threshold) + { + if (node == null) + { return; } - if ((node.height / maxheight) > threshold) { + if ((node.height / maxheight) > threshold) + { groups.addElement(node); - } else { + } + else + { groupNodes((SequenceNode) node.left(), threshold); groupNodes((SequenceNode) node.right(), threshold); } } - public float findHeight(SequenceNode node) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findHeight(SequenceNode node) + { + if (node == null) + { return maxheight; } - if ((node.left() == null) && (node.right() == null)) { + if ((node.left() == null) && (node.right() == null)) + { node.height = ((SequenceNode) node.parent()).height + node.dist; - if (node.height > maxheight) { + if (node.height > maxheight) + { return node.height; - } else { + } + else + { return maxheight; } - } else { - if (node.parent() != null) { + } + else + { + if (node.parent() != null) + { node.height = ((SequenceNode) node.parent()).height + node.dist; - } else { + } + else + { maxheight = 0; node.height = (float) 0.0; } @@ -639,8 +933,15 @@ public class NJTree { return maxheight; } - public SequenceNode reRoot() { - if (maxdist != null) { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceNode reRoot() + { + if (maxdist != null) + { ycount = 0; float tmpdist = maxdist.dist; @@ -673,15 +974,25 @@ public class NJTree { return top; } - public static void printN(SequenceNode node) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public static void printN(SequenceNode node) + { + if (node == null) + { return; } - if ((node.left() != null) && (node.right() != null)) { + if ((node.left() != null) && (node.right() != null)) + { printN((SequenceNode) node.left()); printN((SequenceNode) node.right()); - } else { + } + else + { System.out.println(" name = " + ((SequenceI) node.element()).getName()); } @@ -690,17 +1001,31 @@ public class NJTree { ((SequenceNode) node).count + " " + ((SequenceNode) node).height); } - public void reCount(SequenceNode node) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void reCount(SequenceNode node) + { ycount = 0; _reCount(node); } - public void _reCount(SequenceNode node) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void _reCount(SequenceNode node) + { + if (node == null) + { return; } - if ((node.left() != null) && (node.right() != null)) { + if ((node.left() != null) && (node.right() != null)) + { _reCount((SequenceNode) node.left()); _reCount((SequenceNode) node.right()); @@ -709,14 +1034,23 @@ public class NJTree { ((SequenceNode) node).count = l.count + r.count; ((SequenceNode) node).ycount = (l.ycount + r.ycount) / 2; - } else { + } + else + { ((SequenceNode) node).count = 1; ((SequenceNode) node).ycount = ycount++; } } - public void swapNodes(SequenceNode node) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void swapNodes(SequenceNode node) + { + if (node == null) + { return; } @@ -726,62 +1060,116 @@ public class NJTree { node.setRight(tmp); } - public void changeDirection(SequenceNode node, SequenceNode dir) { - if (node == null) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param dir DOCUMENT ME! + */ + public void changeDirection(SequenceNode node, SequenceNode dir) + { + if (node == null) + { return; } - if (node.parent() != top) { + if (node.parent() != top) + { changeDirection((SequenceNode) node.parent(), node); SequenceNode tmp = (SequenceNode) node.parent(); - if (dir == node.left()) { + if (dir == node.left()) + { node.setParent(dir); node.setLeft(tmp); - } else if (dir == node.right()) { + } + else if (dir == node.right()) + { node.setParent(dir); node.setRight(tmp); } - } else { - if (dir == node.left()) { + } + else + { + if (dir == node.left()) + { node.setParent(node.left()); - if (top.left() == node) { + if (top.left() == node) + { node.setRight(top.right()); - } else { + } + else + { node.setRight(top.left()); } - } else { + } + else + { node.setParent(node.right()); - if (top.left() == node) { + if (top.left() == node) + { node.setLeft(top.right()); - } else { + } + else + { node.setLeft(top.left()); } } } } - public void setMaxDist(SequenceNode node) { + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + */ + public void setMaxDist(SequenceNode node) + { this.maxdist = maxdist; } - public SequenceNode getMaxDist() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceNode getMaxDist() + { return maxdist; } - public SequenceNode getTopNode() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceNode getTopNode() + { return top; } } -class Cluster { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +class Cluster +{ int[] value; - public Cluster(int[] value) { + /** + * Creates a new Cluster object. + * + * @param value DOCUMENT ME! + */ + public Cluster(int[] value) + { this.value = value; } } diff --git a/src/jalview/analysis/PCA.java b/src/jalview/analysis/PCA.java index ecbe4ab..2e37e6a 100755 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@ -24,29 +24,37 @@ import jalview.math.*; import jalview.util.*; -import java.awt.*; - import java.io.*; -public class PCA implements Runnable { +/** + * Performs Principal Component Analysis on given sequences + * + * @author $author$ + * @version $Revision$ + */ +public class PCA implements Runnable +{ Matrix m; Matrix symm; Matrix m2; double[] eigenvalue; Matrix eigenvector; - public PCA(Matrix m) { - this.m = m; - } - public PCA(SequenceI[] s) { - Runtime rt = Runtime.getRuntime(); + /** + * Creates a new PCA object. + * + * @param s Set of sequences to perform PCA on + */ + public PCA(SequenceI[] s) + { BinarySequence[] bs = new BinarySequence[s.length]; int ii = 0; - while ((ii < s.length) && (s[ii] != null)) { + while ((ii < s.length) && (s[ii] != null)) + { bs[ii] = new BinarySequence(s[ii]); bs[ii].encode(); ii++; @@ -55,7 +63,8 @@ public class PCA implements Runnable { BinarySequence[] bs2 = new BinarySequence[s.length]; ii = 0; - while ((ii < s.length) && (s[ii] != null)) { + while ((ii < s.length) && (s[ii] != null)) + { bs2[ii] = new BinarySequence(s[ii]); bs2[ii].blosumEncode(); ii++; @@ -65,7 +74,8 @@ public class PCA implements Runnable { //printMemory(rt); int count = 0; - while ((count < bs.length) && (bs[count] != null)) { + while ((count < bs.length) && (bs[count] != null)) + { count++; } @@ -73,7 +83,8 @@ public class PCA implements Runnable { double[][] seqmat2 = new double[count][bs2[0].getDBinary().length]; int i = 0; - while (i < count) { + while (i < count) + { seqmat[i] = bs[i].getDBinary(); seqmat2[i] = bs2[i].getDBinary(); i++; @@ -85,34 +96,47 @@ public class PCA implements Runnable { m = new Matrix(seqmat, count, bs[0].getDBinary().length); m2 = new Matrix(seqmat2, count, bs2[0].getDBinary().length); - //System.out.println("Created matrix"); - printMemory(rt); - } + } - public static void printMemory(Runtime rt) { - System.out.println("PCA:Free memory = " + rt.freeMemory()); - } + /** + * Returns the matrix used in PCA calculation + * + * @return java.math.Matrix object + */ - public Matrix getM() { + public Matrix getM() + { return m; - } - - public double[] getEigenvector(int i) { - return eigenvector.getColumn(i); - } - - public double getEigenvalue(int i) { + } + + /** + * Returns Eigenvalue + * + * @param i Index of diagonal within matrix + * + * @return Returns value of diagonal from matrix + */ + public double getEigenvalue(int i) + { return eigenvector.d[i]; } - public float[][] getComponents(int l, int n, int mm) { - return getComponents(l, n, mm, 1); - } - - public float[][] getComponents(int l, int n, int mm, float factor) { + /** + * DOCUMENT ME! + * + * @param l DOCUMENT ME! + * @param n DOCUMENT ME! + * @param mm DOCUMENT ME! + * @param factor DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float[][] getComponents(int l, int n, int mm, float factor) + { float[][] out = new float[m.rows][3]; - for (int i = 0; i < m.rows; i++) { + for (int i = 0; i < m.rows; i++) + { out[i][0] = (float) component(i, l) * factor; out[i][1] = (float) component(i, n) * factor; out[i][2] = (float) component(i, mm) * factor; @@ -121,51 +145,52 @@ public class PCA implements Runnable { return out; } - public double[] component(int n) { + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public double[] component(int n) + { // n = index of eigenvector double[] out = new double[m.rows]; - for (int i = 0; i < m.rows; i++) { + for (int i = 0; i < m.rows; i++) + { out[i] = component(i, n); } return out; } - public double component(int row, int n) { + /** + * DOCUMENT ME! + * + * @param row DOCUMENT ME! + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + double component(int row, int n) + { double out = 0.0; - for (int i = 0; i < symm.cols; i++) { + for (int i = 0; i < symm.cols; i++) + { out += (symm.value[row][i] * eigenvector.value[i][n]); } return out / eigenvector.d[n]; } - public void checkEigenvector(int n, PrintStream ps) { - ps.println(" --- Eigenvector " + n + " --- "); - - double[] eigenv = eigenvector.getColumn(n); - - for (int i = 0; i < eigenv.length; i++) { - Format.print(ps, "%15.4f", eigenv[i]); - } - - System.out.println(); - - double[] neigenv = symm.vectorPostMultiply(eigenv); - System.out.println(" --- symmat * eigenv / lambda --- "); - - if (eigenvector.d[n] > 1e-4) { - for (int i = 0; i < neigenv.length; i++) { - Format.print(System.out, "%15.4f", neigenv[i] / eigenvector.d[n]); - } - } - - System.out.println(); - } - public void run() { + /** + * DOCUMENT ME! + */ + public void run() + { Matrix mt = m.transpose(); // System.out.println(" --- OrigT * Orig ---- "); diff --git a/src/jalview/analysis/SeqsetUtils.java b/src/jalview/analysis/SeqsetUtils.java index 8a8ae28..78f7278 100755 --- a/src/jalview/analysis/SeqsetUtils.java +++ b/src/jalview/analysis/SeqsetUtils.java @@ -1,138 +1,156 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.analysis; -import jalview.datamodel.SequenceI; - -import java.util.Hashtable; - - -/** - *

Title:

- * - *

Description:

- * - *

Copyright: Copyright (c) 2004

- * - *

Company: Dundee University

- * - * @author not attributable - * @version 1.0 - */ -public class SeqsetUtils { - /** - * Store essential properties of a sequence in a hashtable for later recovery - * Keys are Name, Start, End, SeqFeatures, PdbId - * @param seq SequenceI - * @return Hashtable +import java.util.*; + +import jalview.datamodel.*; + +/** + *

Title:

+ * + *

Description:

+ * + *

Copyright: Copyright (c) 2004

+ * + *

Company: Dundee University

+ * + * @author not attributable + * @version 1.0 */ - public static Hashtable SeqCharacterHash(SequenceI seq) { - Hashtable sqinfo = new Hashtable(); - sqinfo.put("Name", seq.getName()); - sqinfo.put("Start", new Integer(seq.getStart())); - sqinfo.put("End", new Integer(seq.getEnd())); - sqinfo.put("SeqFeatures", seq.getSequenceFeatures()); - sqinfo.put("PdbId", - (seq.getPDBId() != null) ? seq.getPDBId() : new String("")); - - return sqinfo; +public class SeqsetUtils +{ + /** + * Store essential properties of a sequence in a hashtable for later recovery + * Keys are Name, Start, End, SeqFeatures, PdbId + * @param seq SequenceI + * @return Hashtable + */ + public static Hashtable SeqCharacterHash(SequenceI seq) + { + Hashtable sqinfo = new Hashtable(); + sqinfo.put("Name", seq.getName()); + sqinfo.put("Start", new Integer(seq.getStart())); + sqinfo.put("End", new Integer(seq.getEnd())); + sqinfo.put("SeqFeatures", seq.getSequenceFeatures()); + sqinfo.put("PdbId", + (seq.getPDBId() != null) ? seq.getPDBId() : new String("")); + + return sqinfo; + } + + /** + * Recover essential properties of a sequence from a hashtable + * TODO: replace these methods with something more elegant. + * @param sq SequenceI + * @param sqinfo Hashtable + * @return boolean + */ + public static boolean SeqCharacterUnhash(SequenceI sq, Hashtable sqinfo) + { + boolean namePresent = true; + String oldname = (String) sqinfo.get("Name"); + Integer start = (Integer) sqinfo.get("Start"); + Integer end = (Integer) sqinfo.get("End"); + java.util.Vector sfeatures = (java.util.Vector) sqinfo.get( + "SeqFeatures"); + String pdbid = (String) sqinfo.get("PdbId"); + + if (oldname == null) + { + namePresent = false; } - - /** - * Recover essential properties of a sequence from a hashtable - * TODO: replace these methods with something more elegant. - * @param sq SequenceI - * @param sqinfo Hashtable - * @return boolean - */ - public static boolean SeqCharacterUnhash(SequenceI sq, Hashtable sqinfo) { - boolean namePresent = true; - String oldname = (String) sqinfo.get("Name"); - Integer start = (Integer) sqinfo.get("Start"); - Integer end = (Integer) sqinfo.get("End"); - java.util.Vector sfeatures = (java.util.Vector) sqinfo.get( - "SeqFeatures"); - String pdbid = (String) sqinfo.get("PdbId"); - - if (oldname == null) { - namePresent = false; - } else { - sq.setName(oldname); - } - - if (!pdbid.equals("")) { - sq.setPDBId(pdbid); - } - - if ((start != null) && (end != null)) { - sq.setStart(start.intValue()); - sq.setEnd(end.intValue()); - } - - if (sfeatures != null) { - sq.setSequenceFeatures(sfeatures); - } - - return namePresent; + else + { + sq.setName(oldname); } - /** - * Form of the unique name used in uniquify for the i'th sequence in an ordered vector of sequences. - * @param i int - * @return String - */ - public static String unique_name(int i) { - return new String("Sequence" + i); + if (!pdbid.equals("")) + { + sq.setPDBId(pdbid); } - public static Hashtable uniquify(SequenceI[] sequences, boolean write_names) { - // Generate a safely named sequence set and a hash to recover the sequence names - Hashtable map = new Hashtable(); - String[] un_names = new String[sequences.length]; - - if (!write_names) { - for (int i = 0; i < sequences.length; i++) { - String safename = new String("Sequence" + i); - map.put(safename, SeqCharacterHash(sequences[i])); - - if (write_names) { - sequences[i].setName(safename); - } - } - } + if ( (start != null) && (end != null)) + { + sq.setStart(start.intValue()); + sq.setEnd(end.intValue()); + } - return map; + if (sfeatures != null) + { + sq.setSequenceFeatures(sfeatures); } - public static boolean deuniquify(Hashtable map, SequenceI[] sequences) { - // recover unsafe sequence names for a sequence set - boolean allfound = true; - - for (int i = 0; i < sequences.length; i++) { - if (map.containsKey(sequences[i].getName())) { - Hashtable sqinfo = (Hashtable) map.get(sequences[i].getName()); - SeqCharacterUnhash(sequences[i], sqinfo); - } else { - allfound = false; - } + return namePresent; + } + + /** + * Form of the unique name used in uniquify for the i'th sequence in an ordered vector of sequences. + * @param i int + * @return String + */ + public static String unique_name(int i) + { + return new String("Sequence" + i); + } + + public static Hashtable uniquify(SequenceI[] sequences, boolean write_names) + { + // Generate a safely named sequence set and a hash to recover the sequence names + Hashtable map = new Hashtable(); + String[] un_names = new String[sequences.length]; + + if (!write_names) + { + for (int i = 0; i < sequences.length; i++) + { + String safename = new String("Sequence" + i); + map.put(safename, SeqCharacterHash(sequences[i])); + + if (write_names) + { + sequences[i].setName(safename); } + } + } - return allfound; + return map; + } + + public static boolean deuniquify(Hashtable map, SequenceI[] sequences) + { + // recover unsafe sequence names for a sequence set + boolean allfound = true; + + for (int i = 0; i < sequences.length; i++) + { + if (map.containsKey(sequences[i].getName())) + { + Hashtable sqinfo = (Hashtable) map.get(sequences[i].getName()); + SeqCharacterUnhash(sequences[i], sqinfo); + } + else + { + allfound = false; + } } + + return allfound; + } } diff --git a/src/jalview/analysis/SequenceIdMatcher.java b/src/jalview/analysis/SequenceIdMatcher.java index f786243..1efe498 100755 --- a/src/jalview/analysis/SequenceIdMatcher.java +++ b/src/jalview/analysis/SequenceIdMatcher.java @@ -1,139 +1,163 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.analysis; -import jalview.datamodel.SequenceI; - -import java.util.Hashtable; -import java.util.Vector; - - -/** - *

Title:

- * SequenceIdMatcher - *

Description:

- * Routine which does approximate Sequence Id resolution by name using string containment rather than equivalence - *

Copyright: Copyright (c) 2004

- * - *

Company: Dundee University

- * - * @author not attributable - * @version 1.0 +import java.util.*; + +import jalview.datamodel.*; + +/** + *

Title:

+ * SequenceIdMatcher + *

Description:

+ * Routine which does approximate Sequence Id resolution by name using string containment rather than equivalence + *

Copyright: Copyright (c) 2004

+ * + *

Company: Dundee University

+ * + * @author not attributable + * @version 1.0 */ -public class SequenceIdMatcher { - private Hashtable names; +public class SequenceIdMatcher +{ + private Hashtable names; - public SequenceIdMatcher(SequenceI[] seqs) { - names = new Hashtable(); + public SequenceIdMatcher(SequenceI[] seqs) + { + names = new Hashtable(); - for (int i = 0; i < seqs.length; i++) { - names.put(new SeqIdName(seqs[i].getName()), seqs[i]); - } + for (int i = 0; i < seqs.length; i++) + { + names.put(new SeqIdName(seqs[i].getName()), seqs[i]); } + } - SequenceI findIdMatch(SequenceI seq) { - SeqIdName nam = new SeqIdName(seq.getName()); + SequenceI findIdMatch(SequenceI seq) + { + SeqIdName nam = new SeqIdName(seq.getName()); - if (names.containsKey(nam)) { - return (SequenceI) names.get(nam); - } - - return null; + if (names.containsKey(nam)) + { + return (SequenceI) names.get(nam); } - SequenceI findIdMatch(String seqnam) { - SeqIdName nam = new SeqIdName(seqnam); + return null; + } - if (names.containsKey(nam)) { - return (SequenceI) names.get(nam); - } + SequenceI findIdMatch(String seqnam) + { + SeqIdName nam = new SeqIdName(seqnam); - return null; + if (names.containsKey(nam)) + { + return (SequenceI) names.get(nam); } - /** - * findIdMatch - * - * Return pointers to sequences (or sequence object containers) - * which have same Id as a given set of different sequence objects - * - * @param seqs SequenceI[] - * @return SequenceI[] - */ - SequenceI[] findIdMatch(SequenceI[] seqs) { - SequenceI[] namedseqs = new SequenceI[seqs.length]; - - int i = 0; - SeqIdName nam; - - if (seqs.length > 0) { - do { - nam = new SeqIdName(seqs[i].getName()); - - if (names.containsKey(nam)) { - namedseqs[i] = (SequenceI) names.get(nam); - } else { - namedseqs[i] = null; - } - } while (i++ < seqs.length); + return null; + } + + /** + * findIdMatch + * + * Return pointers to sequences (or sequence object containers) + * which have same Id as a given set of different sequence objects + * + * @param seqs SequenceI[] + * @return SequenceI[] + */ + SequenceI[] findIdMatch(SequenceI[] seqs) + { + SequenceI[] namedseqs = new SequenceI[seqs.length]; + + int i = 0; + SeqIdName nam; + + if (seqs.length > 0) + { + do + { + nam = new SeqIdName(seqs[i].getName()); + + if (names.containsKey(nam)) + { + namedseqs[i] = (SequenceI) names.get(nam); } - - return namedseqs; + else + { + namedseqs[i] = null; + } + } + while (i++ < seqs.length); } - private class SeqIdName { - String id; + return namedseqs; + } - SeqIdName(String s) { - id = new String(s); - } + private class SeqIdName + { + String id; - public int hashCode() { - return (id.substring(0, 4).hashCode()); - } + SeqIdName(String s) + { + id = new String(s); + } - public boolean equals(Object s) { - if (s instanceof SeqIdName) { - return this.equals((SeqIdName) s); - } else { - if (s instanceof String) { - return this.equals((String) s); - } - } + public int hashCode() + { + return (id.substring(0, 4).hashCode()); + } - return false; + public boolean equals(Object s) + { + if (s instanceof SeqIdName) + { + return this.equals( (SeqIdName) s); + } + else + { + if (s instanceof String) + { + return this.equals( (String) s); } + } - public boolean equals(SeqIdName s) { - if (id.startsWith(s.id) || s.id.startsWith(id)) { - return true; - } + return false; + } - return false; - } + public boolean equals(SeqIdName s) + { + if (id.startsWith(s.id) || s.id.startsWith(id)) + { + return true; + } - public boolean equals(String s) { - if (id.startsWith(s) || s.startsWith(id)) { - return true; - } + return false; + } - return false; - } + public boolean equals(String s) + { + if (id.startsWith(s) || s.startsWith(id)) + { + return true; + } + + return false; } + } } diff --git a/src/jalview/appletgui/AnnotationPanel.java b/src/jalview/appletgui/AnnotationPanel.java index cd6396f..ad4aeb8 100755 --- a/src/jalview/appletgui/AnnotationPanel.java +++ b/src/jalview/appletgui/AnnotationPanel.java @@ -352,7 +352,7 @@ public class AnnotationPanel row.annotations[j - 1].secondaryStructure)) { - g.drawString(row.annotations[j].displayCharacter, x, + g.drawString(row.annotations[j].displayCharacter, x + charOffset, y + iconOffset + 2); } diff --git a/src/jalview/appletgui/IdCanvas.java b/src/jalview/appletgui/IdCanvas.java index 8b6939e..399506e 100755 --- a/src/jalview/appletgui/IdCanvas.java +++ b/src/jalview/appletgui/IdCanvas.java @@ -55,7 +55,7 @@ public class IdCanvas if (searchResults != null && searchResults.contains(s)) { gg.setColor(Color.black); - gg.fillRect(0, AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos, + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getSize().width, charHeight); gg.setColor(Color.white); } @@ -63,14 +63,14 @@ public class IdCanvas av.getSelectionGroup().sequences.contains(s)) { gg.setColor(Color.lightGray); - gg.fillRect(0, AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos, + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getSize().width, charHeight); gg.setColor(Color.white); } else { gg.setColor(s.getColor()); - gg.fillRect(0, AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos, + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getSize().width, charHeight); gg.setColor(Color.black); } @@ -82,7 +82,7 @@ public class IdCanvas } gg.drawString(string, 0, - AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos + + ((i - starty) * charHeight) + ypos + charHeight - (charHeight / 5)); } @@ -228,7 +228,7 @@ public class IdCanvas gg.setColor(currentColor); gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), + ((i - starty) * av.charHeight), getSize().width, av.charHeight); @@ -239,7 +239,7 @@ public class IdCanvas string = av.alignment.getSequenceAt(i).getDisplayId(); } gg.drawString(string, 0, - AlignmentUtil.getPixelHeight(starty, i, av.charHeight) + + ((i - starty) * av.charHeight) + av.charHeight - (av.charHeight / 5)); } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 5aa5d66..29616ef 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -374,7 +374,7 @@ public class SeqCanvas sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2, (x1 - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), + (i-starty)*av.charHeight, av.charWidth, av.charHeight); if (av.showSequenceFeatures) @@ -382,7 +382,7 @@ public class SeqCanvas fr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), x1, x2, (x1 - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), + (i-starty)*av.charHeight, av.charWidth, av.charHeight); } } @@ -413,7 +413,7 @@ public class SeqCanvas for (i = y1; i < y2; i++) { sx = (group.getStartRes() - startx) * av.charWidth; - sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight); + sy = offset + (i-starty)*av.charHeight; ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth - 1; if (sx < getSize().width @@ -484,7 +484,7 @@ public class SeqCanvas bottom = -1; } - sy = offset + AlignmentUtil.getPixelHeight(starty, i, av.charHeight); + sy = offset + (i-starty)*av.charHeight; g.drawLine(sx, oldY, sx, sy); g.drawLine(sx + ex, oldY, sx + ex, sy); inGroup = false; @@ -531,9 +531,7 @@ public class SeqCanvas searchEnd, (searchStart - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, - searchSeq, - av.charHeight), + (searchSeq-starty)*av.charHeight, av.charWidth, av.charHeight); } diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index e1978fe..57ae4ce 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1,50 +1,71 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.bin; import java.io.*; import java.util.*; -import java.util.jar.*; -public class Cache { - public static String VERSION = "Release 2.0"; +/** + * Stores and retrieves Jalview Application Properties + *

Current properties include: + *
logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services) + *
logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization) + *
jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do. + *
SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_Y=285,SCREEN_X=371,SHOW_FULLSCREEN + * FONT_NAME,FONT_SIZE,FONT_STYLE,GAP_SYMBOL,LAST_DIRECTORY,USER_DEFINED_COLOUR + * SHOW_FULL_ID,SHOW_IDENTITY,SHOW_QUALITY,SHOW_ANNOTATIONS,SHOW_CONSERVATION, + * DEFAULT_COLOUR,DEFAULT_FILE_FORMAT,STARTUP_FILE,SHOW_STARTUP_FILE + + * @author $author$ + * @version $Revision$ + */ +public class Cache +{ + /** Current release tag */ + public static String VERSION = "AW Test"; + + /** Date Jalview was last packaged, else compilation date of Cache.class */ public static String BUILD_DATE = ""; + + /** Jalview Properties */ public static Properties applicationProperties; - // Current properties include: - // - // LAST_DIRECTORY , use this to cache record of where the user looked to find a file - // UNIPROT_CACHE - // USER_DEFINED_COLOUR - file describing last user set colours - // FONT_NAME - // FONT_STYLE - // FONT_SIZE - // logs.Axis.Level - one of the stringified Levels for log4j controlling the logging level for axis (used for web services) - // logs.Castor.Level - one of the stringified Levels for log4j controlling the logging level for castor (used for serialization) - // jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do. - public static void loadProperties() { + /** Default file is ~/.jalview_properties */ + static String propertiesFile; + + /** Called when Jalview is started */ + public static void loadProperties(String propsFile) + { + propertiesFile = propsFile; + if (propsFile == null) + { + propertiesFile = System.getProperty("user.home") + "/.jalview_properties"; + } + + // get last build time. long date = 0; - try { + try + { String localFile = Cache.class.getProtectionDomain().getCodeSource() .getLocation().toString(); localFile = localFile.concat("!/"); @@ -54,11 +75,14 @@ public class Cache { java.net.URL localJarFileURL = new java.net.URL(localJarFileString); java.net.JarURLConnection localJarFile = (java.net.JarURLConnection) localJarFileURL.openConnection(); date = localJarFile.getLastModified(); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } - if (date == 0) { + if (date == 0) + { // this is called for unpackaged class files, ie not in a Jar file // InstallAnywhere version will find build date this way // not entirely accurate as it only tells you when Cache.class was last compiled @@ -67,36 +91,59 @@ public class Cache { date = f.lastModified(); } - if (date != 0) { + if (date != 0) + { BUILD_DATE = new Date(date).toString(); } applicationProperties = new Properties(); - try { - FileInputStream in = new FileInputStream(System.getProperty( - "user.home") + "/.jalview_properties"); + try + { + FileInputStream in = new FileInputStream(propertiesFile); applicationProperties = new Properties(); applicationProperties.load(in); in.close(); - } catch (Exception ex) { + } + catch (Exception ex) + { } } - public static String getProperty(String key) { + /** + * Gets Jalview application property of given key. Returns null + * if key not found + * + * @param key Name of property + * + * @return Property value + */ + public static String getProperty(String key) + { return applicationProperties.getProperty(key); } - public static String setProperty(String key, String obj) { - try { - FileOutputStream out = new FileOutputStream(System.getProperty( - "user.home") + "/.jalview_properties"); + /** + * Stores property in the file "HOME_DIR/.jalview_properties" + * + * @param key Name of object + * @param obj String value of property + * + * @return String value of property + */ + public static String setProperty(String key, String obj) + { + try + { + FileOutputStream out = new FileOutputStream(propertiesFile); applicationProperties.setProperty(key, obj); applicationProperties.store(out, "---JalviewX Properties File---"); out.close(); - } catch (Exception ex) { + } + catch (Exception ex) + { } return obj; diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index c11d051..f05b394 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -1,88 +1,57 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.bin; import jalview.gui.*; -import jalview.io.*; - import org.apache.log4j.*; -import java.awt.event.*; - import javax.swing.*; - -public class Jalview extends JApplet { - public static JApplet applet; - Desktop frame; - - public void init() { - applet = this; - Cache.loadProperties(); - jalview.gui.Preferences.initPreferences(); - - frame = new Desktop(); - frame.setResizable(true); - frame.setVisible(true); - frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - applet.stop(); - applet.destroy(); - } - }); - - String file = getParameter("alignment"); - - if (file != null) { - jalview.bin.Cache.setProperty("LAST_DIRECTORY", file); - - String protocol = "File"; - - if (file.indexOf("http:") > -1) { - protocol = "URL"; - } - - String format = jalview.io.IdentifyFile.Identify(file, protocol); - - frame.LoadFile(file, protocol, format); - } - } - - public void destroy() { - if (applet != null) { - applet.stop(); - } else { - System.exit(0); - } - - frame.setVisible(false); - } - - private static void initLogger() { +import java.util.Vector; + + +/** + * Main class for Jalview Application + *
+ *
start with java -Djava.ext.dirs=$PATH_TO_LIB$ jalview.bin.Jalview + * + * @author $author$ + * @version $Revision$ + */ +public class Jalview +{ + /** + * Initialises the Apache Axis logger + */ + private static void initLogger() + { Logger laxis = Logger.getLogger("org.apache.axis"); Logger lcastor = Logger.getLogger("org.exolab.castor"); - if (Cache.getProperty("logs.Axis.Level") == null) { + + if (Cache.getProperty("logs.Axis.Level") == null) + { Cache.setProperty("logs.Axis.Level", Level.INFO.toString()); } - if (Cache.getProperty("logs.Castor.Level") == null) { + + if (Cache.getProperty("logs.Castor.Level") == null) + { Cache.setProperty("logs.Castor.Level", Level.INFO.toString()); } @@ -96,64 +65,231 @@ public class Jalview extends JApplet { lcastor.addAppender(ap); } - public static void main(String[] args) { - Cache.loadProperties(); - jalview.gui.Preferences.initPreferences(); - - try { - initLogger(); - } catch (Exception e) { - System.err.println("Problems initializing the log4j system\n"); - e.printStackTrace(); - } - - try { + /** + * main class for Jalview application + * + * @param args open filename + */ + public static void main(String[] args) + { + ArgsParser aparser = new ArgsParser(args); + + try + { UIManager.setLookAndFeel( - // "javax.swing.plaf.metal.MetalLookAndFeel" + // "javax.swing.plaf.metal.MetalLookAndFeel" // "javax.swing.plaf.multi.MultiLookAndFeel" UIManager.getSystemLookAndFeelClassName()); - } catch (Exception ex) { + } + catch (Exception ex) + { } - Desktop frame = new Desktop(); - frame.setResizable(true); - frame.setVisible(true); + Cache.loadProperties(aparser.getValue("props")); + jalview.gui.Preferences.initPreferences(); + try + { + initLogger(); + } + catch (Exception e) + { + System.err.println("Problems initializing the log4j system\n"); + } + + + String file = null, protocol = null, format = null, groups=null; + Desktop desktop = new Desktop(); + + + if(args==null || args.length==0) + { + desktop.setVisible(true); + } + else + { + if( aparser.contains("help") || aparser.contains("h") ) + { + System.out.println("Usage: jalview -open [FILE] [OUTPUT_FORMAT] [OUTPUT_FILE]\n\n" + +"-nodisplay\tRun Jalview without User Interface.\n" + +"-props FILE\tUse the given Jalview properties file instead of users default.\n" + +"-groups FILE\tUse the given file to mark groups on the alignment. \nGroups file is in the following tab delimited format\n" + +"TEXTSEQUENCE_IDSEQUENCE_INDEXSTART_RESIDUEEND_RESIDUECOLOUR\n" + +"SequenceID is used in preference to SequenceIndex if both are provided.\n" + +"Enter ID_NOT_SPECIFIED for SEQUENCE_ID or -1 for SEQUENCE_INDEX if unknown.\n" + +"COLOUR can be hexadecimal RGB or 'red', 'blue' etc.\n\n" + +"-fasta FILE\tCreate alignment file FILE in Fasta format.\n" + +"-clustal FILE\tCreate alignment file FILE in Clustal format.\n" + +"-pfam FILE\tCreate alignment file FILE in PFAM format.\n" + +"-msf FILE\tCreate alignment file FILE in MSF format.\n" + +"-pileup FILE\tCreate alignment file FILE in Pileup format\n" + +"-pir FILE\tCreate alignment file FILE in PIR format.\n" + +"-blc FILE\tCreate alignment file FILE in BLC format.\n" + +"-jalview FILE\tCreate alignment file FILE in Jalview format.\n" + +"-png FILE\tCreate PNG image FILE from alignment.\n" + +"-imgMap FILE\tCreate HTML file FILE with image map of PNG image.\n" + +"-eps FILE\tCreate EPS file FILE from alignment."); + System.exit(0); + + } + - if ((args != null) && (args.length > 0)) { - String file = null; + file = aparser.getValue("open"); - if (args[0].equals("-open")) { - file = args[1]; - } else { - file = args[0]; + if (file == null) + { + System.out.println("No files to open!"); + System.exit(1); + } + else if(!file.startsWith("http://")) + { + if (!(new java.io.File(file)).exists()) + { + System.out.println("Can't find " + file); + System.exit(1); } + } + + if (!aparser.contains("nodisplay")) + desktop.setVisible(true); + + protocol = "File"; + + if (file.indexOf("http:") > -1) + { + protocol = "URL"; + } - String protocol = "File"; + if(file.endsWith(".jar")) + format = "Jalview"; + else + format = jalview.io.IdentifyFile.Identify(file, protocol); - if (file.indexOf("http:") > -1) { - protocol = "URL"; + System.out.println("Opening: " + format + " file " + file); + + AlignFrame af = desktop.LoadFileWaitTillLoaded(file, protocol, format); + + groups = aparser.getValue("groups"); + if(groups!=null) + { + af.parseGroupsFile(groups); + } + + String imageName = "unnamed.png"; + while (aparser.getSize() > 1) + { + format = aparser.nextValue(); + file = aparser.nextValue(); + + if (format.equalsIgnoreCase("png")) + { + af.createPNG(new java.io.File(file)); + imageName = (new java.io.File(file)).getName(); + System.out.println("Creating PNG image: " + file); + continue; } + else if (format.equalsIgnoreCase("imgMap")) + { + af.createImageMap(new java.io.File(file), imageName); + System.out.println("Creating image map: " + file); + continue; + } + else if (format.equalsIgnoreCase("eps")) + { + System.out.println("Creating EPS file: " + file); + af.createEPS(new java.io.File(file)); + continue; + } + + if (af.saveAlignment(file, format)) + System.out.println("Written alignment in " + format + + " format to " + file); + else + System.out.println("Error writing file " + file + " in " + format + + " format!!"); - String format = jalview.io.IdentifyFile.Identify(file, protocol); + } - frame.LoadFile(file, protocol, format); + while (aparser.getSize() > 0) + { + System.out.println("Unknown arg: " + aparser.nextValue()); + } } - if (jalview.gui.Preferences.showStartupFile && - (jalview.gui.Preferences.startupFile != null)) { - String file = jalview.gui.Preferences.startupFile; - String protocol = "File"; + if (jalview.gui.Preferences.showStartupFile && + (jalview.gui.Preferences.startupFile != null)) + { - if (file.indexOf("http:") > -1) { - protocol = "URL"; + file = jalview.gui.Preferences.startupFile; + protocol = "File"; + + if (file.indexOf("http:") > -1) + { + protocol = "URL"; } - if (file.endsWith(".jar")) { - Jalview2XML.LoadJalviewAlign(file); - } else { - String format = jalview.io.IdentifyFile.Identify(file, protocol); - frame.LoadFile(file, protocol, format); + if (file.endsWith(".jar")) + { + Jalview2XML.LoadJalviewAlign(file); } - } + else + { + format = jalview.io.IdentifyFile.Identify(file, protocol); + desktop.LoadFile(file, protocol, format); + } + } + + if (!desktop.isVisible()) + System.exit(0); } } + + class ArgsParser + { + Vector vargs = null; + public ArgsParser(String [] args) + { + vargs = new Vector(); + for (int i = 0; i < args.length; i++) + { + String arg = args[i].trim(); + if (arg.charAt(0) == '-') + arg = arg.substring(1); + vargs.addElement(arg); + } + } + + public String getValue(String arg) + { + int index = vargs.indexOf(arg); + String ret = null; + if (index != -1) + { + ret = vargs.elementAt(index + 1).toString(); + vargs.removeElementAt(index); + vargs.removeElementAt(index); + } + return ret; + } + + public boolean contains(String arg) + { + if(vargs.contains(arg)) + { + vargs.removeElement(arg); + return true; + } + else + return false; + } + + public String nextValue() + { + return vargs.remove(0).toString(); + } + + public int getSize() + { + return vargs.size(); + } + + } diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 2a411f7..451c478 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -30,7 +30,14 @@ import java.awt.*; import java.awt.event.*; -public class JalviewLite extends Applet { +/** + * Jalview Applet. Runs in Java 1.18 runtime + * + * @author $author$ + * @version $Revision$ + */ +public class JalviewLite extends Applet +{ static int lastFrameX = 200; static int lastFrameY = 200; static Applet applet; @@ -38,73 +45,127 @@ public class JalviewLite extends Applet { String file = "No file"; Button launcher = new Button("Start Jalview"); - public void init() { + /** + * init method for Jalview Applet + */ + public void init() + { applet = this; - int r=255,g=255,b=255; + int r = 255; + int g = 255; + int b = 255; String param = getParameter("RGB"); - if(param!=null) + + if (param != null) { - try - { - r = Integer.parseInt(param.substring(0,2),16); - g = Integer.parseInt(param.substring(2,4),16); - b = Integer.parseInt(param.substring(4,6),16); - } - catch (Exception ex) - { r=255;g=255;b=255; } + try + { + r = Integer.parseInt(param.substring(0, 2), 16); + g = Integer.parseInt(param.substring(2, 4), 16); + b = Integer.parseInt(param.substring(4, 6), 16); + } + catch (Exception ex) + { + r = 255; + g = 255; + b = 255; + } } - this.setBackground(new Color(r,g,b)); + this.setBackground(new Color(r, g, b)); file = getParameter("file"); - if (file != null) { + if (file != null) + { add(launcher); file = applet.getCodeBase() + file; - launcher.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + launcher.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { String format = jalview.io.IdentifyFile.Identify(file, "URL"); LoadFile(file, "URL", format); } }); - } else { + } + else + { file = "NO FILE"; fileFound = false; } } - public static void showURL(String url) { - try { + /** + * Displays the given URL in a new browser window + * + * @param url URL to display in browser window. + *
New window will be named "HELP_WINDOW" + */ + public static void showURL(String url) + { + try + { applet.getAppletContext().showDocument(new java.net.URL(url), "HELP_WINDOW"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } - public void LoadFile(String file, String protocol, String format) { + /** + * Starts a new LoadingThread for loading an alignment file + * + * @param file file name including full path to file + * @param protocol file or URL or paste + * @param format Fasta, Clustal, PFAM, MSF, PIR, BLC, Jalview + */ + public void LoadFile(String file, String protocol, String format) + { LoadingThread loader = new LoadingThread(file, protocol, format, this); loader.start(); } + /** + * Initialises and displays a new java.awt.Frame + * + * @param frame java.awt.Frame to be displayed + * @param title title of new frame + * @param width width if new frame + * @param height height of new frame + */ public static void addFrame(final Frame frame, String title, int width, - int height) { + int height) + { frame.setLocation(lastFrameX, lastFrameY); lastFrameX += 40; lastFrameY += 40; frame.setSize(width, height); frame.setTitle(title); - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { + frame.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { frame.dispose(); } }); frame.setVisible(true); } - public void paint(Graphics g) { - if (!fileFound) { + /** + * This paints the background surrounding the "Launch Jalview button" + *
+ *
If file given in parameter not found, displays error message + * + * @param g graphics context + */ + public void paint(Graphics g) + { + if (!fileFound) + { g.setColor(new Color(200, 200, 200)); g.setColor(Color.cyan); g.fillRect(0, 0, getSize().width, getSize().height); @@ -114,31 +175,37 @@ public class JalviewLite extends Applet { } } - class LoadingThread extends Thread { + class LoadingThread extends Thread + { String file; String protocol; String format; JalviewLite jlapplet; public LoadingThread(String file, String protocol, String format, - JalviewLite applet) { + JalviewLite applet) + { this.file = file; this.protocol = protocol; this.format = format; this.jlapplet = applet; } - public void run() { + public void run() + { SequenceI[] sequences = null; sequences = FormatAdapter.readFile(file, protocol, format); - if ((sequences != null) && (sequences.length > 0)) { + if ((sequences != null) && (sequences.length > 0)) + { AlignFrame af = new AlignFrame(new Alignment(sequences), jlapplet); addFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); af.statusBar.setText("Successfully loaded file " + file); - } else { + } + else + { fileFound = false; remove(launcher); repaint(); diff --git a/src/jalview/binding/Alignment.java b/src/jalview/binding/Alignment.java index 9a38f10..78fff89 100755 --- a/src/jalview/binding/Alignment.java +++ b/src/jalview/binding/Alignment.java @@ -1,36 +1,36 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; + import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; + + /** * Class Alignment. - * + * * @version $Revision$ $Date$ */ -public class Alignment implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class Alignment implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -43,131 +43,148 @@ public class Alignment implements java.io.Serializable { */ private jalview.binding.SequenceSet _sequenceSet; - - //----------------/ - //- Constructors -/ //----------------/ - - public Alignment() { + //- Constructors -/ + //----------------/ + public Alignment() + { super(); - } //-- jalview.binding.Alignment() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.Alignment() //-----------/ /** - * Returns the value of field 'annotation'. - * - * @return Annotation - * @return the value of field 'annotation'. + * DOCUMENT ME! + * + * @return DOCUMENT ME! */ public jalview.binding.Annotation getAnnotation() { return this._annotation; - } //-- jalview.binding.Annotation getAnnotation() + } + + //-- jalview.binding.Annotation getAnnotation() /** * Returns the value of field 'sequenceSet'. - * + * * @return SequenceSet * @return the value of field 'sequenceSet'. */ public jalview.binding.SequenceSet getSequenceSet() { return this._sequenceSet; - } //-- jalview.binding.SequenceSet getSequenceSet() + } + + //-- jalview.binding.SequenceSet getSequenceSet() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'annotation'. - * + * * @param annotation the value of field 'annotation'. */ public void setAnnotation(jalview.binding.Annotation annotation) { this._annotation = annotation; - } //-- void setAnnotation(jalview.binding.Annotation) + } + + //-- void setAnnotation(jalview.binding.Annotation) /** * Sets the value of field 'sequenceSet'. - * + * * @param sequenceSet the value of field 'sequenceSet'. */ public void setSequenceSet(jalview.binding.SequenceSet sequenceSet) { this._sequenceSet = sequenceSet; - } //-- void setSequenceSet(jalview.binding.SequenceSet) + } + + //-- void setSequenceSet(jalview.binding.SequenceSet) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.Alignment) Unmarshaller.unmarshal(jalview.binding.Alignment.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.Alignment) Unmarshaller.unmarshal(jalview.binding.Alignment.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/Annotation.java b/src/jalview/binding/Annotation.java index fefdd12..14b09c4 100755 --- a/src/jalview/binding/Annotation.java +++ b/src/jalview/binding/Annotation.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,373 +7,385 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ //---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ + +import java.util.*; -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import java.util.Enumeration; -import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class Annotation. - * + * * @version $Revision$ $Date$ */ -public class Annotation implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _graph - */ - private boolean _graph; - - /** - * keeps track of state for field: _graph - */ - private boolean _has_graph; - - /** - * Field _annotationElementList - */ - private java.util.Vector _annotationElementList; - - /** - * Field _label - */ - private java.lang.String _label; - - /** - * Field _description - */ - private java.lang.String _description; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Annotation() { - super(); - _annotationElementList = new Vector(); - } //-- jalview.binding.Annotation() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addAnnotationElement - * - * - * - * @param vAnnotationElement - */ - public void addAnnotationElement(jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException - { - _annotationElementList.addElement(vAnnotationElement); - } //-- void addAnnotationElement(jalview.binding.AnnotationElement) - - /** - * Method addAnnotationElement - * - * - * - * @param index - * @param vAnnotationElement - */ - public void addAnnotationElement(int index, jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException - { - _annotationElementList.insertElementAt(vAnnotationElement, index); - } //-- void addAnnotationElement(int, jalview.binding.AnnotationElement) - - /** - * Method deleteGraph - * - */ - public void deleteGraph() - { - this._has_graph= false; - } //-- void deleteGraph() - - /** - * Method enumerateAnnotationElement - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateAnnotationElement() - { - return _annotationElementList.elements(); - } //-- java.util.Enumeration enumerateAnnotationElement() - - /** - * Method getAnnotationElement - * - * - * - * @param index - * @return AnnotationElement - */ - public jalview.binding.AnnotationElement getAnnotationElement(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _annotationElementList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.AnnotationElement) _annotationElementList.elementAt(index); - } //-- jalview.binding.AnnotationElement getAnnotationElement(int) - - /** - * Method getAnnotationElement - * - * - * - * @return AnnotationElement - */ - public jalview.binding.AnnotationElement[] getAnnotationElement() - { - int size = _annotationElementList.size(); - jalview.binding.AnnotationElement[] mArray = new jalview.binding.AnnotationElement[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.AnnotationElement) _annotationElementList.elementAt(index); - } - return mArray; - } //-- jalview.binding.AnnotationElement[] getAnnotationElement() - - /** - * Method getAnnotationElementCount - * - * - * - * @return int - */ - public int getAnnotationElementCount() - { - return _annotationElementList.size(); - } //-- int getAnnotationElementCount() - - /** - * Returns the value of field 'description'. - * - * @return String - * @return the value of field 'description'. - */ - public java.lang.String getDescription() - { - return this._description; - } //-- java.lang.String getDescription() - - /** - * Returns the value of field 'graph'. - * - * @return boolean - * @return the value of field 'graph'. - */ - public boolean getGraph() - { - return this._graph; - } //-- boolean getGraph() - - /** - * Returns the value of field 'label'. - * - * @return String - * @return the value of field 'label'. - */ - public java.lang.String getLabel() - { - return this._label; - } //-- java.lang.String getLabel() - - /** - * Method hasGraph - * - * - * - * @return boolean - */ - public boolean hasGraph() - { - return this._has_graph; - } //-- boolean hasGraph() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Method removeAllAnnotationElement - * - */ - public void removeAllAnnotationElement() - { - _annotationElementList.removeAllElements(); - } //-- void removeAllAnnotationElement() - - /** - * Method removeAnnotationElement - * - * - * - * @param index - * @return AnnotationElement - */ - public jalview.binding.AnnotationElement removeAnnotationElement(int index) - { - java.lang.Object obj = _annotationElementList.elementAt(index); - _annotationElementList.removeElementAt(index); - return (jalview.binding.AnnotationElement) obj; - } //-- jalview.binding.AnnotationElement removeAnnotationElement(int) - - /** - * Method setAnnotationElement - * - * - * - * @param index - * @param vAnnotationElement - */ - public void setAnnotationElement(int index, jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _annotationElementList.size())) { - throw new IndexOutOfBoundsException(); - } - _annotationElementList.setElementAt(vAnnotationElement, index); - } //-- void setAnnotationElement(int, jalview.binding.AnnotationElement) - - /** - * Method setAnnotationElement - * - * - * - * @param annotationElementArray - */ - public void setAnnotationElement(jalview.binding.AnnotationElement[] annotationElementArray) +public class Annotation + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _graph + */ + private boolean _graph; + + /** + * keeps track of state for field: _graph + */ + private boolean _has_graph; + + /** + * Field _annotationElementList + */ + private java.util.Vector _annotationElementList; + + /** + * Field _label + */ + private java.lang.String _label; + + /** + * Field _description + */ + private java.lang.String _description; + + //----------------/ + //- Constructors -/ + //----------------/ + + public Annotation() + { + super(); + _annotationElementList = new Vector(); + } //-- jalview.binding.Annotation() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addAnnotationElement + * + * + * + * @param vAnnotationElement + */ + public void addAnnotationElement(jalview.binding.AnnotationElement + vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + _annotationElementList.addElement(vAnnotationElement); + } //-- void addAnnotationElement(jalview.binding.AnnotationElement) + + /** + * Method addAnnotationElement + * + * + * + * @param index + * @param vAnnotationElement + */ + public void addAnnotationElement(int index, + jalview.binding.AnnotationElement + vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + _annotationElementList.insertElementAt(vAnnotationElement, index); + } //-- void addAnnotationElement(int, jalview.binding.AnnotationElement) + + /** + * Method deleteGraph + * + */ + public void deleteGraph() + { + this._has_graph = false; + } //-- void deleteGraph() + + /** + * Method enumerateAnnotationElement + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAnnotationElement() + { + return _annotationElementList.elements(); + } //-- java.util.Enumeration enumerateAnnotationElement() + + /** + * Method getAnnotationElement + * + * + * + * @param index + * @return AnnotationElement + */ + public jalview.binding.AnnotationElement getAnnotationElement(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _annotationElementList.size())) { - //-- copy array - _annotationElementList.removeAllElements(); - for (int i = 0; i < annotationElementArray.length; i++) { - _annotationElementList.addElement(annotationElementArray[i]); - } - } //-- void setAnnotationElement(jalview.binding.AnnotationElement) - - /** - * Sets the value of field 'description'. - * - * @param description the value of field 'description'. - */ - public void setDescription(java.lang.String description) + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.AnnotationElement) _annotationElementList.elementAt( + index); + } //-- jalview.binding.AnnotationElement getAnnotationElement(int) + + /** + * Method getAnnotationElement + * + * + * + * @return AnnotationElement + */ + public jalview.binding.AnnotationElement[] getAnnotationElement() + { + int size = _annotationElementList.size(); + jalview.binding.AnnotationElement[] mArray = new jalview.binding. + AnnotationElement[size]; + for (int index = 0; index < size; index++) { - this._description = description; - } //-- void setDescription(java.lang.String) - - /** - * Sets the value of field 'graph'. - * - * @param graph the value of field 'graph'. - */ - public void setGraph(boolean graph) + mArray[index] = (jalview.binding.AnnotationElement) + _annotationElementList.elementAt(index); + } + return mArray; + } //-- jalview.binding.AnnotationElement[] getAnnotationElement() + + /** + * Method getAnnotationElementCount + * + * + * + * @return int + */ + public int getAnnotationElementCount() + { + return _annotationElementList.size(); + } //-- int getAnnotationElementCount() + + /** + * Returns the value of field 'description'. + * + * @return String + * @return the value of field 'description'. + */ + public java.lang.String getDescription() + { + return this._description; + } //-- java.lang.String getDescription() + + /** + * Returns the value of field 'graph'. + * + * @return boolean + * @return the value of field 'graph'. + */ + public boolean getGraph() + { + return this._graph; + } //-- boolean getGraph() + + /** + * Returns the value of field 'label'. + * + * @return String + * @return the value of field 'label'. + */ + public java.lang.String getLabel() + { + return this._label; + } //-- java.lang.String getLabel() + + /** + * Method hasGraph + * + * + * + * @return boolean + */ + public boolean hasGraph() + { + return this._has_graph; + } //-- boolean hasGraph() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { - this._graph = graph; - this._has_graph = true; - } //-- void setGraph(boolean) - - /** - * Sets the value of field 'label'. - * - * @param label the value of field 'label'. - */ - public void setLabel(java.lang.String label) + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { - this._label = label; - } //-- void setLabel(java.lang.String) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllAnnotationElement + * + */ + public void removeAllAnnotationElement() + { + _annotationElementList.removeAllElements(); + } //-- void removeAllAnnotationElement() + + /** + * Method removeAnnotationElement + * + * + * + * @param index + * @return AnnotationElement + */ + public jalview.binding.AnnotationElement removeAnnotationElement(int index) + { + java.lang.Object obj = _annotationElementList.elementAt(index); + _annotationElementList.removeElementAt(index); + return (jalview.binding.AnnotationElement) obj; + } //-- jalview.binding.AnnotationElement removeAnnotationElement(int) + + /** + * Method setAnnotationElement + * + * + * + * @param index + * @param vAnnotationElement + */ + public void setAnnotationElement(int index, + jalview.binding.AnnotationElement + vAnnotationElement) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _annotationElementList.size())) { - return (jalview.binding.Annotation) Unmarshaller.unmarshal(jalview.binding.Annotation.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException + throw new IndexOutOfBoundsException(); + } + _annotationElementList.setElementAt(vAnnotationElement, index); + } //-- void setAnnotationElement(int, jalview.binding.AnnotationElement) + + /** + * Method setAnnotationElement + * + * + * + * @param annotationElementArray + */ + public void setAnnotationElement(jalview.binding.AnnotationElement[] + annotationElementArray) + { + //-- copy array + _annotationElementList.removeAllElements(); + for (int i = 0; i < annotationElementArray.length; i++) { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + _annotationElementList.addElement(annotationElementArray[i]); + } + } //-- void setAnnotationElement(jalview.binding.AnnotationElement) + + /** + * Sets the value of field 'description'. + * + * @param description the value of field 'description'. + */ + public void setDescription(java.lang.String description) + { + this._description = description; + } //-- void setDescription(java.lang.String) + + /** + * Sets the value of field 'graph'. + * + * @param graph the value of field 'graph'. + */ + public void setGraph(boolean graph) + { + this._graph = graph; + this._has_graph = true; + } //-- void setGraph(boolean) + + /** + * Sets the value of field 'label'. + * + * @param label the value of field 'label'. + */ + public void setLabel(java.lang.String label) + { + this._label = label; + } //-- void setLabel(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Annotation) Unmarshaller.unmarshal(jalview.binding. + Annotation.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/AnnotationElement.java b/src/jalview/binding/AnnotationElement.java index e4aec31..16c3dab 100755 --- a/src/jalview/binding/AnnotationElement.java +++ b/src/jalview/binding/AnnotationElement.java @@ -1,36 +1,36 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; + import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; + + /** * Class AnnotationElement. - * + * * @version $Revision$ $Date$ */ -public class AnnotationElement implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class AnnotationElement implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -68,239 +68,276 @@ public class AnnotationElement implements java.io.Serializable { */ private boolean _has_value; - - //----------------/ - //- Constructors -/ //----------------/ - - public AnnotationElement() { + //- Constructors -/ + //----------------/ + public AnnotationElement() + { super(); - } //-- jalview.binding.AnnotationElement() - + } - //-----------/ - //- Methods -/ + //-- jalview.binding.AnnotationElement() //-----------/ /** - * Method deletePosition - * + * DOCUMENT ME! */ public void deletePosition() { - this._has_position= false; - } //-- void deletePosition() + this._has_position = false; + } + + //-- void deletePosition() /** * Method deleteValue - * + * */ public void deleteValue() { - this._has_value= false; - } //-- void deleteValue() + this._has_value = false; + } + + //-- void deleteValue() /** * Returns the value of field 'description'. - * + * * @return String * @return the value of field 'description'. */ public java.lang.String getDescription() { return this._description; - } //-- java.lang.String getDescription() + } + + //-- java.lang.String getDescription() /** * Returns the value of field 'displayCharacter'. - * + * * @return String * @return the value of field 'displayCharacter'. */ public java.lang.String getDisplayCharacter() { return this._displayCharacter; - } //-- java.lang.String getDisplayCharacter() + } + + //-- java.lang.String getDisplayCharacter() /** * Returns the value of field 'position'. - * + * * @return int * @return the value of field 'position'. */ public int getPosition() { return this._position; - } //-- int getPosition() + } + + //-- int getPosition() /** * Returns the value of field 'secondaryStructure'. - * + * * @return String * @return the value of field 'secondaryStructure'. */ public java.lang.String getSecondaryStructure() { return this._secondaryStructure; - } //-- java.lang.String getSecondaryStructure() + } + + //-- java.lang.String getSecondaryStructure() /** * Returns the value of field 'value'. - * + * * @return float * @return the value of field 'value'. */ public float getValue() { return this._value; - } //-- float getValue() + } + + //-- float getValue() /** * Method hasPosition - * - * - * + * + * + * * @return boolean */ public boolean hasPosition() { return this._has_position; - } //-- boolean hasPosition() + } + + //-- boolean hasPosition() /** * Method hasValue - * - * - * + * + * + * * @return boolean */ public boolean hasValue() { return this._has_value; - } //-- boolean hasValue() + } + + //-- boolean hasValue() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'description'. - * + * * @param description the value of field 'description'. */ public void setDescription(java.lang.String description) { this._description = description; - } //-- void setDescription(java.lang.String) + } + + //-- void setDescription(java.lang.String) /** * Sets the value of field 'displayCharacter'. - * + * * @param displayCharacter the value of field 'displayCharacter' */ public void setDisplayCharacter(java.lang.String displayCharacter) { this._displayCharacter = displayCharacter; - } //-- void setDisplayCharacter(java.lang.String) + } + + //-- void setDisplayCharacter(java.lang.String) /** * Sets the value of field 'position'. - * + * * @param position the value of field 'position'. */ public void setPosition(int position) { this._position = position; this._has_position = true; - } //-- void setPosition(int) + } + + //-- void setPosition(int) /** * Sets the value of field 'secondaryStructure'. - * + * * @param secondaryStructure the value of field * 'secondaryStructure'. */ public void setSecondaryStructure(java.lang.String secondaryStructure) { this._secondaryStructure = secondaryStructure; - } //-- void setSecondaryStructure(java.lang.String) + } + + //-- void setSecondaryStructure(java.lang.String) /** * Sets the value of field 'value'. - * + * * @param value the value of field 'value'. */ public void setValue(float value) { this._value = value; this._has_value = true; - } //-- void setValue(float) + } + + //-- void setValue(float) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.AnnotationElement) Unmarshaller.unmarshal(jalview.binding.AnnotationElement.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.AnnotationElement) Unmarshaller.unmarshal(jalview.binding.AnnotationElement.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/Colour.java b/src/jalview/binding/Colour.java index a51102b..4e57c3f 100755 --- a/src/jalview/binding/Colour.java +++ b/src/jalview/binding/Colour.java @@ -1,36 +1,36 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; + import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; + + /** * Class Colour. - * + * * @version $Revision$ $Date$ */ -public class Colour implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class Colour implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -43,131 +43,148 @@ public class Colour implements java.io.Serializable { */ private java.lang.String _RGB; - - //----------------/ - //- Constructors -/ //----------------/ - - public Colour() { + //- Constructors -/ + //----------------/ + public Colour() + { super(); - } //-- jalview.binding.Colour() - + } - //-----------/ - //- Methods -/ + //-- jalview.binding.Colour() //-----------/ /** - * Returns the value of field 'name'. - * - * @return String - * @return the value of field 'name'. + * DOCUMENT ME! + * + * @return DOCUMENT ME! */ public java.lang.String getName() { return this._name; - } //-- java.lang.String getName() + } + + //-- java.lang.String getName() /** * Returns the value of field 'RGB'. - * + * * @return String * @return the value of field 'RGB'. */ public java.lang.String getRGB() { return this._RGB; - } //-- java.lang.String getRGB() + } + + //-- java.lang.String getRGB() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'name'. - * + * * @param name the value of field 'name'. */ public void setName(java.lang.String name) { this._name = name; - } //-- void setName(java.lang.String) + } + + //-- void setName(java.lang.String) /** * Sets the value of field 'RGB'. - * + * * @param RGB the value of field 'RGB'. */ public void setRGB(java.lang.String RGB) { this._RGB = RGB; - } //-- void setRGB(java.lang.String) + } + + //-- void setRGB(java.lang.String) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.Colour) Unmarshaller.unmarshal(jalview.binding.Colour.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.Colour) Unmarshaller.unmarshal(jalview.binding.Colour.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/JGroup.java b/src/jalview/binding/JGroup.java index 6473149..5b6d74e 100755 --- a/src/jalview/binding/JGroup.java +++ b/src/jalview/binding/JGroup.java @@ -1,38 +1,39 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Enumeration; import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class JGroup. - * + * * @version $Revision$ $Date$ */ -public class JGroup implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JGroup implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -130,39 +131,37 @@ public class JGroup implements java.io.Serializable { */ private java.util.Vector _seqList; - - //----------------/ - //- Constructors -/ //----------------/ - - public JGroup() { + //- Constructors -/ + //----------------/ + public JGroup() + { super(); _seqList = new Vector(); - } //-- jalview.binding.JGroup() - + } - //-----------/ - //- Methods -/ + //-- jalview.binding.JGroup() //-----------/ /** - * Method addSeq - * - * - * - * @param vSeq + * DOCUMENT ME! + * + * @param vSeq DOCUMENT ME! + * + * @throws java.lang.IndexOutOfBoundsException DOCUMENT ME! */ - public void addSeq(int vSeq) - throws java.lang.IndexOutOfBoundsException + public void addSeq(int vSeq) throws java.lang.IndexOutOfBoundsException { _seqList.addElement(new java.lang.Integer(vSeq)); - } //-- void addSeq(int) + } + + //-- void addSeq(int) /** * Method addSeq - * - * - * + * + * + * * @param index * @param vSeq */ @@ -170,406 +169,482 @@ public class JGroup implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { _seqList.insertElementAt(new java.lang.Integer(vSeq), index); - } //-- void addSeq(int, int) + } + + //-- void addSeq(int, int) /** * Method deleteColourText - * + * */ public void deleteColourText() { - this._has_colourText= false; - } //-- void deleteColourText() + this._has_colourText = false; + } + + //-- void deleteColourText() /** * Method deleteConsThreshold - * + * */ public void deleteConsThreshold() { - this._has_consThreshold= false; - } //-- void deleteConsThreshold() + this._has_consThreshold = false; + } + + //-- void deleteConsThreshold() /** * Method deleteDisplayBoxes - * + * */ public void deleteDisplayBoxes() { - this._has_displayBoxes= false; - } //-- void deleteDisplayBoxes() + this._has_displayBoxes = false; + } + + //-- void deleteDisplayBoxes() /** * Method deleteDisplayText - * + * */ public void deleteDisplayText() { - this._has_displayText= false; - } //-- void deleteDisplayText() + this._has_displayText = false; + } + + //-- void deleteDisplayText() /** * Method deleteEnd - * + * */ public void deleteEnd() { - this._has_end= false; - } //-- void deleteEnd() + this._has_end = false; + } + + //-- void deleteEnd() /** * Method deleteOutlineColour - * + * */ public void deleteOutlineColour() { - this._has_outlineColour= false; - } //-- void deleteOutlineColour() + this._has_outlineColour = false; + } + + //-- void deleteOutlineColour() /** * Method deletePidThreshold - * + * */ public void deletePidThreshold() { - this._has_pidThreshold= false; - } //-- void deletePidThreshold() + this._has_pidThreshold = false; + } + + //-- void deletePidThreshold() /** * Method deleteStart - * + * */ public void deleteStart() { - this._has_start= false; - } //-- void deleteStart() + this._has_start = false; + } + + //-- void deleteStart() /** * Method enumerateSeq - * - * - * + * + * + * * @return Enumeration */ public java.util.Enumeration enumerateSeq() { return _seqList.elements(); - } //-- java.util.Enumeration enumerateSeq() + } + + //-- java.util.Enumeration enumerateSeq() /** * Returns the value of field 'colour'. - * + * * @return String * @return the value of field 'colour'. */ public java.lang.String getColour() { return this._colour; - } //-- java.lang.String getColour() + } + + //-- java.lang.String getColour() /** * Returns the value of field 'colourText'. - * + * * @return boolean * @return the value of field 'colourText'. */ public boolean getColourText() { return this._colourText; - } //-- boolean getColourText() + } + + //-- boolean getColourText() /** * Returns the value of field 'consThreshold'. - * + * * @return int * @return the value of field 'consThreshold'. */ public int getConsThreshold() { return this._consThreshold; - } //-- int getConsThreshold() + } + + //-- int getConsThreshold() /** * Returns the value of field 'displayBoxes'. - * + * * @return boolean * @return the value of field 'displayBoxes'. */ public boolean getDisplayBoxes() { return this._displayBoxes; - } //-- boolean getDisplayBoxes() + } + + //-- boolean getDisplayBoxes() /** * Returns the value of field 'displayText'. - * + * * @return boolean * @return the value of field 'displayText'. */ public boolean getDisplayText() { return this._displayText; - } //-- boolean getDisplayText() + } + + //-- boolean getDisplayText() /** * Returns the value of field 'end'. - * + * * @return int * @return the value of field 'end'. */ public int getEnd() { return this._end; - } //-- int getEnd() + } + + //-- int getEnd() /** * Returns the value of field 'name'. - * + * * @return String * @return the value of field 'name'. */ public java.lang.String getName() { return this._name; - } //-- java.lang.String getName() + } + + //-- java.lang.String getName() /** * Returns the value of field 'outlineColour'. - * + * * @return int * @return the value of field 'outlineColour'. */ public int getOutlineColour() { return this._outlineColour; - } //-- int getOutlineColour() + } + + //-- int getOutlineColour() /** * Returns the value of field 'pidThreshold'. - * + * * @return int * @return the value of field 'pidThreshold'. */ public int getPidThreshold() { return this._pidThreshold; - } //-- int getPidThreshold() + } + + //-- int getPidThreshold() /** * Method getSeq - * - * - * + * + * + * * @param index * @return int */ - public int getSeq(int index) - throws java.lang.IndexOutOfBoundsException + public int getSeq(int index) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _seqList.size())) { + if ((index < 0) || (index > _seqList.size())) + { throw new IndexOutOfBoundsException(); } - - return ((java.lang.Integer)_seqList.elementAt(index)).intValue(); - } //-- int getSeq(int) + + return ((java.lang.Integer) _seqList.elementAt(index)).intValue(); + } + + //-- int getSeq(int) /** * Method getSeq - * - * - * + * + * + * * @return int */ public int[] getSeq() { int size = _seqList.size(); int[] mArray = new int[size]; - for (int index = 0; index < size; index++) { - mArray[index] = ((java.lang.Integer)_seqList.elementAt(index)).intValue(); + + for (int index = 0; index < size; index++) + { + mArray[index] = ((java.lang.Integer) _seqList.elementAt(index)).intValue(); } + return mArray; - } //-- int[] getSeq() + } + + //-- int[] getSeq() /** * Method getSeqCount - * - * - * + * + * + * * @return int */ public int getSeqCount() { return _seqList.size(); - } //-- int getSeqCount() + } + + //-- int getSeqCount() /** * Returns the value of field 'start'. - * + * * @return int * @return the value of field 'start'. */ public int getStart() { return this._start; - } //-- int getStart() + } + + //-- int getStart() /** * Method hasColourText - * - * - * + * + * + * * @return boolean */ public boolean hasColourText() { return this._has_colourText; - } //-- boolean hasColourText() + } + + //-- boolean hasColourText() /** * Method hasConsThreshold - * - * - * + * + * + * * @return boolean */ public boolean hasConsThreshold() { return this._has_consThreshold; - } //-- boolean hasConsThreshold() + } + + //-- boolean hasConsThreshold() /** * Method hasDisplayBoxes - * - * - * + * + * + * * @return boolean */ public boolean hasDisplayBoxes() { return this._has_displayBoxes; - } //-- boolean hasDisplayBoxes() + } + + //-- boolean hasDisplayBoxes() /** * Method hasDisplayText - * - * - * + * + * + * * @return boolean */ public boolean hasDisplayText() { return this._has_displayText; - } //-- boolean hasDisplayText() + } + + //-- boolean hasDisplayText() /** * Method hasEnd - * - * - * + * + * + * * @return boolean */ public boolean hasEnd() { return this._has_end; - } //-- boolean hasEnd() + } + + //-- boolean hasEnd() /** * Method hasOutlineColour - * - * - * + * + * + * * @return boolean */ public boolean hasOutlineColour() { return this._has_outlineColour; - } //-- boolean hasOutlineColour() + } + + //-- boolean hasOutlineColour() /** * Method hasPidThreshold - * - * - * + * + * + * * @return boolean */ public boolean hasPidThreshold() { return this._has_pidThreshold; - } //-- boolean hasPidThreshold() + } + + //-- boolean hasPidThreshold() /** * Method hasStart - * - * - * + * + * + * * @return boolean */ public boolean hasStart() { return this._has_start; - } //-- boolean hasStart() + } + + //-- boolean hasStart() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllSeq - * + * */ public void removeAllSeq() { _seqList.removeAllElements(); - } //-- void removeAllSeq() + } + + //-- void removeAllSeq() /** * Method removeSeq - * - * - * + * + * + * * @param index * @return int */ @@ -577,111 +652,132 @@ public class JGroup implements java.io.Serializable { { java.lang.Object obj = _seqList.elementAt(index); _seqList.removeElementAt(index); - return ((java.lang.Integer)obj).intValue(); - } //-- int removeSeq(int) + + return ((java.lang.Integer) obj).intValue(); + } + + //-- int removeSeq(int) /** * Sets the value of field 'colour'. - * + * * @param colour the value of field 'colour'. */ public void setColour(java.lang.String colour) { this._colour = colour; - } //-- void setColour(java.lang.String) + } + + //-- void setColour(java.lang.String) /** * Sets the value of field 'colourText'. - * + * * @param colourText the value of field 'colourText'. */ public void setColourText(boolean colourText) { this._colourText = colourText; this._has_colourText = true; - } //-- void setColourText(boolean) + } + + //-- void setColourText(boolean) /** * Sets the value of field 'consThreshold'. - * + * * @param consThreshold the value of field 'consThreshold'. */ public void setConsThreshold(int consThreshold) { this._consThreshold = consThreshold; this._has_consThreshold = true; - } //-- void setConsThreshold(int) + } + + //-- void setConsThreshold(int) /** * Sets the value of field 'displayBoxes'. - * + * * @param displayBoxes the value of field 'displayBoxes'. */ public void setDisplayBoxes(boolean displayBoxes) { this._displayBoxes = displayBoxes; this._has_displayBoxes = true; - } //-- void setDisplayBoxes(boolean) + } + + //-- void setDisplayBoxes(boolean) /** * Sets the value of field 'displayText'. - * + * * @param displayText the value of field 'displayText'. */ public void setDisplayText(boolean displayText) { this._displayText = displayText; this._has_displayText = true; - } //-- void setDisplayText(boolean) + } + + //-- void setDisplayText(boolean) /** * Sets the value of field 'end'. - * + * * @param end the value of field 'end'. */ public void setEnd(int end) { this._end = end; this._has_end = true; - } //-- void setEnd(int) + } + + //-- void setEnd(int) /** * Sets the value of field 'name'. - * + * * @param name the value of field 'name'. */ public void setName(java.lang.String name) { this._name = name; - } //-- void setName(java.lang.String) + } + + //-- void setName(java.lang.String) /** * Sets the value of field 'outlineColour'. - * + * * @param outlineColour the value of field 'outlineColour'. */ public void setOutlineColour(int outlineColour) { this._outlineColour = outlineColour; this._has_outlineColour = true; - } //-- void setOutlineColour(int) + } + + //-- void setOutlineColour(int) /** * Sets the value of field 'pidThreshold'. - * + * * @param pidThreshold the value of field 'pidThreshold'. */ public void setPidThreshold(int pidThreshold) { this._pidThreshold = pidThreshold; this._has_pidThreshold = true; - } //-- void setPidThreshold(int) + } + + //-- void setPidThreshold(int) /** * Method setSeq - * - * - * + * + * + * * @param index * @param vSeq */ @@ -689,62 +785,76 @@ public class JGroup implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _seqList.size())) { + if ((index < 0) || (index > _seqList.size())) + { throw new IndexOutOfBoundsException(); } + _seqList.setElementAt(new java.lang.Integer(vSeq), index); - } //-- void setSeq(int, int) + } + + //-- void setSeq(int, int) /** * Method setSeq - * - * - * + * + * + * * @param seqArray */ public void setSeq(int[] seqArray) { //-- copy array _seqList.removeAllElements(); - for (int i = 0; i < seqArray.length; i++) { + + for (int i = 0; i < seqArray.length; i++) + { _seqList.addElement(new java.lang.Integer(seqArray[i])); } - } //-- void setSeq(int) + } + + //-- void setSeq(int) /** * Sets the value of field 'start'. - * + * * @param start the value of field 'start'. */ public void setStart(int start) { this._start = start; this._has_start = true; - } //-- void setStart(int) + } + + //-- void setStart(int) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.JGroup) Unmarshaller.unmarshal(jalview.binding.JGroup.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.JGroup) Unmarshaller.unmarshal(jalview.binding.JGroup.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/JSeq.java b/src/jalview/binding/JSeq.java index 751409f..9b8ddcb 100755 --- a/src/jalview/binding/JSeq.java +++ b/src/jalview/binding/JSeq.java @@ -1,36 +1,36 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; + import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; + + /** * Class JSeq. - * + * * @version $Revision$ $Date$ */ -public class JSeq implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JSeq implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -73,261 +73,302 @@ public class JSeq implements java.io.Serializable { */ private boolean _has_id; - - //----------------/ - //- Constructors -/ //----------------/ - - public JSeq() { + //- Constructors -/ + //----------------/ + public JSeq() + { super(); - } //-- jalview.binding.JSeq() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.JSeq() //-----------/ /** - * Method deleteColour - * + * DOCUMENT ME! */ public void deleteColour() { - this._has_colour= false; - } //-- void deleteColour() + this._has_colour = false; + } + + //-- void deleteColour() /** * Method deleteEnd - * + * */ public void deleteEnd() { - this._has_end= false; - } //-- void deleteEnd() + this._has_end = false; + } + + //-- void deleteEnd() /** * Method deleteId - * + * */ public void deleteId() { - this._has_id= false; - } //-- void deleteId() + this._has_id = false; + } + + //-- void deleteId() /** * Method deleteStart - * + * */ public void deleteStart() { - this._has_start= false; - } //-- void deleteStart() + this._has_start = false; + } + + //-- void deleteStart() /** * Returns the value of field 'colour'. - * + * * @return int * @return the value of field 'colour'. */ public int getColour() { return this._colour; - } //-- int getColour() + } + + //-- int getColour() /** * Returns the value of field 'end'. - * + * * @return int * @return the value of field 'end'. */ public int getEnd() { return this._end; - } //-- int getEnd() + } + + //-- int getEnd() /** * Returns the value of field 'id'. - * + * * @return int * @return the value of field 'id'. */ public int getId() { return this._id; - } //-- int getId() + } + + //-- int getId() /** * Returns the value of field 'start'. - * + * * @return int * @return the value of field 'start'. */ public int getStart() { return this._start; - } //-- int getStart() + } + + //-- int getStart() /** * Method hasColour - * - * - * + * + * + * * @return boolean */ public boolean hasColour() { return this._has_colour; - } //-- boolean hasColour() + } + + //-- boolean hasColour() /** * Method hasEnd - * - * - * + * + * + * * @return boolean */ public boolean hasEnd() { return this._has_end; - } //-- boolean hasEnd() + } + + //-- boolean hasEnd() /** * Method hasId - * - * - * + * + * + * * @return boolean */ public boolean hasId() { return this._has_id; - } //-- boolean hasId() + } + + //-- boolean hasId() /** * Method hasStart - * - * - * + * + * + * * @return boolean */ public boolean hasStart() { return this._has_start; - } //-- boolean hasStart() + } + + //-- boolean hasStart() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'colour'. - * + * * @param colour the value of field 'colour'. */ public void setColour(int colour) { this._colour = colour; this._has_colour = true; - } //-- void setColour(int) + } + + //-- void setColour(int) /** * Sets the value of field 'end'. - * + * * @param end the value of field 'end'. */ public void setEnd(int end) { this._end = end; this._has_end = true; - } //-- void setEnd(int) + } + + //-- void setEnd(int) /** * Sets the value of field 'id'. - * + * * @param id the value of field 'id'. */ public void setId(int id) { this._id = id; this._has_id = true; - } //-- void setId(int) + } + + //-- void setId(int) /** * Sets the value of field 'start'. - * + * * @param start the value of field 'start'. */ public void setStart(int start) { this._start = start; this._has_start = true; - } //-- void setStart(int) + } + + //-- void setStart(int) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.JSeq) Unmarshaller.unmarshal(jalview.binding.JSeq.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.JSeq) Unmarshaller.unmarshal(jalview.binding.JSeq.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/JalviewModel.java b/src/jalview/binding/JalviewModel.java index 8edd012..bfdbddc 100755 --- a/src/jalview/binding/JalviewModel.java +++ b/src/jalview/binding/JalviewModel.java @@ -1,37 +1,38 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; + +import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Date; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class JalviewModel. - * + * * @version $Revision$ $Date$ */ -public class JalviewModel implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JalviewModel implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -54,174 +55,200 @@ public class JalviewModel implements java.io.Serializable { */ private jalview.binding.JalviewModelSequence _jalviewModelSequence; - - //----------------/ - //- Constructors -/ //----------------/ - - public JalviewModel() { + //- Constructors -/ + //----------------/ + public JalviewModel() + { super(); - } //-- jalview.binding.JalviewModel() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.JalviewModel() //-----------/ /** - * Returns the value of field 'creationDate'. - * - * @return Date - * @return the value of field 'creationDate'. + * DOCUMENT ME! + * + * @return DOCUMENT ME! */ public java.util.Date getCreationDate() { return this._creationDate; - } //-- java.util.Date getCreationDate() + } + + //-- java.util.Date getCreationDate() /** * Returns the value of field 'jalviewModelSequence'. - * + * * @return JalviewModelSequence * @return the value of field 'jalviewModelSequence'. */ public jalview.binding.JalviewModelSequence getJalviewModelSequence() { return this._jalviewModelSequence; - } //-- jalview.binding.JalviewModelSequence getJalviewModelSequence() + } + + //-- jalview.binding.JalviewModelSequence getJalviewModelSequence() /** * Returns the value of field 'vamsasModel'. - * + * * @return VamsasModel * @return the value of field 'vamsasModel'. */ public jalview.binding.VamsasModel getVamsasModel() { return this._vamsasModel; - } //-- jalview.binding.VamsasModel getVamsasModel() + } + + //-- jalview.binding.VamsasModel getVamsasModel() /** * Returns the value of field 'version'. - * + * * @return String * @return the value of field 'version'. */ public java.lang.String getVersion() { return this._version; - } //-- java.lang.String getVersion() + } + + //-- java.lang.String getVersion() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'creationDate'. - * + * * @param creationDate the value of field 'creationDate'. */ public void setCreationDate(java.util.Date creationDate) { this._creationDate = creationDate; - } //-- void setCreationDate(java.util.Date) + } + + //-- void setCreationDate(java.util.Date) /** * Sets the value of field 'jalviewModelSequence'. - * + * * @param jalviewModelSequence the value of field * 'jalviewModelSequence'. */ - public void setJalviewModelSequence(jalview.binding.JalviewModelSequence jalviewModelSequence) + public void setJalviewModelSequence( + jalview.binding.JalviewModelSequence jalviewModelSequence) { this._jalviewModelSequence = jalviewModelSequence; - } //-- void setJalviewModelSequence(jalview.binding.JalviewModelSequence) + } + + //-- void setJalviewModelSequence(jalview.binding.JalviewModelSequence) /** * Sets the value of field 'vamsasModel'. - * + * * @param vamsasModel the value of field 'vamsasModel'. */ public void setVamsasModel(jalview.binding.VamsasModel vamsasModel) { this._vamsasModel = vamsasModel; - } //-- void setVamsasModel(jalview.binding.VamsasModel) + } + + //-- void setVamsasModel(jalview.binding.VamsasModel) /** * Sets the value of field 'version'. - * + * * @param version the value of field 'version'. */ public void setVersion(java.lang.String version) { this._version = version; - } //-- void setVersion(java.lang.String) + } + + //-- void setVersion(java.lang.String) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewModel) Unmarshaller.unmarshal(jalview.binding.JalviewModel.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.JalviewModel) Unmarshaller.unmarshal(jalview.binding.JalviewModel.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/JalviewModelSequence.java b/src/jalview/binding/JalviewModelSequence.java index 4ac40d5..2c2abff 100755 --- a/src/jalview/binding/JalviewModelSequence.java +++ b/src/jalview/binding/JalviewModelSequence.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,872 +7,894 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ //---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ + +import java.util.*; -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import java.util.Enumeration; -import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class JalviewModelSequence. - * + * * @version $Revision$ $Date$ */ -public class JalviewModelSequence implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _JSeqList - */ - private java.util.Vector _JSeqList; - - /** - * Field _JGroupList - */ - private java.util.Vector _JGroupList; - - /** - * Field _viewportList - */ - private java.util.Vector _viewportList; - - /** - * Field _userColoursList - */ - private java.util.Vector _userColoursList; - - /** - * Field _treeList - */ - private java.util.Vector _treeList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JalviewModelSequence() { - super(); - _JSeqList = new Vector(); - _JGroupList = new Vector(); - _viewportList = new Vector(); - _userColoursList = new Vector(); - _treeList = new Vector(); - } //-- jalview.binding.JalviewModelSequence() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addJGroup - * - * - * - * @param vJGroup - */ - public void addJGroup(jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException - { - _JGroupList.addElement(vJGroup); - } //-- void addJGroup(jalview.binding.JGroup) - - /** - * Method addJGroup - * - * - * - * @param index - * @param vJGroup - */ - public void addJGroup(int index, jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException - { - _JGroupList.insertElementAt(vJGroup, index); - } //-- void addJGroup(int, jalview.binding.JGroup) - - /** - * Method addJSeq - * - * - * - * @param vJSeq - */ - public void addJSeq(jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException - { - _JSeqList.addElement(vJSeq); - } //-- void addJSeq(jalview.binding.JSeq) - - /** - * Method addJSeq - * - * - * - * @param index - * @param vJSeq - */ - public void addJSeq(int index, jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException - { - _JSeqList.insertElementAt(vJSeq, index); - } //-- void addJSeq(int, jalview.binding.JSeq) - - /** - * Method addTree - * - * - * - * @param vTree - */ - public void addTree(jalview.binding.Tree vTree) - throws java.lang.IndexOutOfBoundsException - { - _treeList.addElement(vTree); - } //-- void addTree(jalview.binding.Tree) - - /** - * Method addTree - * - * - * - * @param index - * @param vTree - */ - public void addTree(int index, jalview.binding.Tree vTree) - throws java.lang.IndexOutOfBoundsException - { - _treeList.insertElementAt(vTree, index); - } //-- void addTree(int, jalview.binding.Tree) - - /** - * Method addUserColours - * - * - * - * @param vUserColours - */ - public void addUserColours(jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException - { - _userColoursList.addElement(vUserColours); - } //-- void addUserColours(jalview.binding.UserColours) - - /** - * Method addUserColours - * - * - * - * @param index - * @param vUserColours - */ - public void addUserColours(int index, jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException - { - _userColoursList.insertElementAt(vUserColours, index); - } //-- void addUserColours(int, jalview.binding.UserColours) - - /** - * Method addViewport - * - * - * - * @param vViewport - */ - public void addViewport(jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException - { - _viewportList.addElement(vViewport); - } //-- void addViewport(jalview.binding.Viewport) - - /** - * Method addViewport - * - * - * - * @param index - * @param vViewport - */ - public void addViewport(int index, jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException - { - _viewportList.insertElementAt(vViewport, index); - } //-- void addViewport(int, jalview.binding.Viewport) - - /** - * Method enumerateJGroup - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateJGroup() - { - return _JGroupList.elements(); - } //-- java.util.Enumeration enumerateJGroup() - - /** - * Method enumerateJSeq - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateJSeq() - { - return _JSeqList.elements(); - } //-- java.util.Enumeration enumerateJSeq() - - /** - * Method enumerateTree - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateTree() - { - return _treeList.elements(); - } //-- java.util.Enumeration enumerateTree() - - /** - * Method enumerateUserColours - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateUserColours() - { - return _userColoursList.elements(); - } //-- java.util.Enumeration enumerateUserColours() - - /** - * Method enumerateViewport - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateViewport() - { - return _viewportList.elements(); - } //-- java.util.Enumeration enumerateViewport() - - /** - * Method getJGroup - * - * - * - * @param index - * @return JGroup - */ - public jalview.binding.JGroup getJGroup(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _JGroupList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.JGroup) _JGroupList.elementAt(index); - } //-- jalview.binding.JGroup getJGroup(int) - - /** - * Method getJGroup - * - * - * - * @return JGroup - */ - public jalview.binding.JGroup[] getJGroup() - { - int size = _JGroupList.size(); - jalview.binding.JGroup[] mArray = new jalview.binding.JGroup[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.JGroup) _JGroupList.elementAt(index); - } - return mArray; - } //-- jalview.binding.JGroup[] getJGroup() - - /** - * Method getJGroupCount - * - * - * - * @return int - */ - public int getJGroupCount() - { - return _JGroupList.size(); - } //-- int getJGroupCount() - - /** - * Method getJSeq - * - * - * - * @param index - * @return JSeq - */ - public jalview.binding.JSeq getJSeq(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _JSeqList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.JSeq) _JSeqList.elementAt(index); - } //-- jalview.binding.JSeq getJSeq(int) - - /** - * Method getJSeq - * - * - * - * @return JSeq - */ - public jalview.binding.JSeq[] getJSeq() - { - int size = _JSeqList.size(); - jalview.binding.JSeq[] mArray = new jalview.binding.JSeq[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.JSeq) _JSeqList.elementAt(index); - } - return mArray; - } //-- jalview.binding.JSeq[] getJSeq() - - /** - * Method getJSeqCount - * - * - * - * @return int - */ - public int getJSeqCount() - { - return _JSeqList.size(); - } //-- int getJSeqCount() - - /** - * Method getTree - * - * - * - * @param index - * @return Tree - */ - public jalview.binding.Tree getTree(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _treeList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.Tree) _treeList.elementAt(index); - } //-- jalview.binding.Tree getTree(int) - - /** - * Method getTree - * - * - * - * @return Tree - */ - public jalview.binding.Tree[] getTree() - { - int size = _treeList.size(); - jalview.binding.Tree[] mArray = new jalview.binding.Tree[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.Tree) _treeList.elementAt(index); - } - return mArray; - } //-- jalview.binding.Tree[] getTree() - - /** - * Method getTreeCount - * - * - * - * @return int - */ - public int getTreeCount() - { - return _treeList.size(); - } //-- int getTreeCount() - - /** - * Method getUserColours - * - * - * - * @param index - * @return UserColours - */ - public jalview.binding.UserColours getUserColours(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _userColoursList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.UserColours) _userColoursList.elementAt(index); - } //-- jalview.binding.UserColours getUserColours(int) - - /** - * Method getUserColours - * - * - * - * @return UserColours - */ - public jalview.binding.UserColours[] getUserColours() - { - int size = _userColoursList.size(); - jalview.binding.UserColours[] mArray = new jalview.binding.UserColours[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.UserColours) _userColoursList.elementAt(index); - } - return mArray; - } //-- jalview.binding.UserColours[] getUserColours() - - /** - * Method getUserColoursCount - * - * - * - * @return int - */ - public int getUserColoursCount() - { - return _userColoursList.size(); - } //-- int getUserColoursCount() - - /** - * Method getViewport - * - * - * - * @param index - * @return Viewport - */ - public jalview.binding.Viewport getViewport(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _viewportList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.Viewport) _viewportList.elementAt(index); - } //-- jalview.binding.Viewport getViewport(int) - - /** - * Method getViewport - * - * - * - * @return Viewport - */ - public jalview.binding.Viewport[] getViewport() - { - int size = _viewportList.size(); - jalview.binding.Viewport[] mArray = new jalview.binding.Viewport[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.Viewport) _viewportList.elementAt(index); - } - return mArray; - } //-- jalview.binding.Viewport[] getViewport() - - /** - * Method getViewportCount - * - * - * - * @return int - */ - public int getViewportCount() - { - return _viewportList.size(); - } //-- int getViewportCount() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Method removeAllJGroup - * - */ - public void removeAllJGroup() - { - _JGroupList.removeAllElements(); - } //-- void removeAllJGroup() - - /** - * Method removeAllJSeq - * - */ - public void removeAllJSeq() - { - _JSeqList.removeAllElements(); - } //-- void removeAllJSeq() - - /** - * Method removeAllTree - * - */ - public void removeAllTree() - { - _treeList.removeAllElements(); - } //-- void removeAllTree() - - /** - * Method removeAllUserColours - * - */ - public void removeAllUserColours() - { - _userColoursList.removeAllElements(); - } //-- void removeAllUserColours() - - /** - * Method removeAllViewport - * - */ - public void removeAllViewport() - { - _viewportList.removeAllElements(); - } //-- void removeAllViewport() - - /** - * Method removeJGroup - * - * - * - * @param index - * @return JGroup - */ - public jalview.binding.JGroup removeJGroup(int index) - { - java.lang.Object obj = _JGroupList.elementAt(index); - _JGroupList.removeElementAt(index); - return (jalview.binding.JGroup) obj; - } //-- jalview.binding.JGroup removeJGroup(int) - - /** - * Method removeJSeq - * - * - * - * @param index - * @return JSeq - */ - public jalview.binding.JSeq removeJSeq(int index) - { - java.lang.Object obj = _JSeqList.elementAt(index); - _JSeqList.removeElementAt(index); - return (jalview.binding.JSeq) obj; - } //-- jalview.binding.JSeq removeJSeq(int) - - /** - * Method removeTree - * - * - * - * @param index - * @return Tree - */ - public jalview.binding.Tree removeTree(int index) - { - java.lang.Object obj = _treeList.elementAt(index); - _treeList.removeElementAt(index); - return (jalview.binding.Tree) obj; - } //-- jalview.binding.Tree removeTree(int) - - /** - * Method removeUserColours - * - * - * - * @param index - * @return UserColours - */ - public jalview.binding.UserColours removeUserColours(int index) - { - java.lang.Object obj = _userColoursList.elementAt(index); - _userColoursList.removeElementAt(index); - return (jalview.binding.UserColours) obj; - } //-- jalview.binding.UserColours removeUserColours(int) - - /** - * Method removeViewport - * - * - * - * @param index - * @return Viewport - */ - public jalview.binding.Viewport removeViewport(int index) - { - java.lang.Object obj = _viewportList.elementAt(index); - _viewportList.removeElementAt(index); - return (jalview.binding.Viewport) obj; - } //-- jalview.binding.Viewport removeViewport(int) - - /** - * Method setJGroup - * - * - * - * @param index - * @param vJGroup - */ - public void setJGroup(int index, jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _JGroupList.size())) { - throw new IndexOutOfBoundsException(); - } - _JGroupList.setElementAt(vJGroup, index); - } //-- void setJGroup(int, jalview.binding.JGroup) - - /** - * Method setJGroup - * - * - * - * @param JGroupArray - */ - public void setJGroup(jalview.binding.JGroup[] JGroupArray) - { - //-- copy array - _JGroupList.removeAllElements(); - for (int i = 0; i < JGroupArray.length; i++) { - _JGroupList.addElement(JGroupArray[i]); - } - } //-- void setJGroup(jalview.binding.JGroup) - - /** - * Method setJSeq - * - * - * - * @param index - * @param vJSeq - */ - public void setJSeq(int index, jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _JSeqList.size())) { - throw new IndexOutOfBoundsException(); - } - _JSeqList.setElementAt(vJSeq, index); - } //-- void setJSeq(int, jalview.binding.JSeq) - - /** - * Method setJSeq - * - * - * - * @param JSeqArray - */ - public void setJSeq(jalview.binding.JSeq[] JSeqArray) - { - //-- copy array - _JSeqList.removeAllElements(); - for (int i = 0; i < JSeqArray.length; i++) { - _JSeqList.addElement(JSeqArray[i]); - } - } //-- void setJSeq(jalview.binding.JSeq) - - /** - * Method setTree - * - * - * - * @param index - * @param vTree - */ - public void setTree(int index, jalview.binding.Tree vTree) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _treeList.size())) { - throw new IndexOutOfBoundsException(); - } - _treeList.setElementAt(vTree, index); - } //-- void setTree(int, jalview.binding.Tree) - - /** - * Method setTree - * - * - * - * @param treeArray - */ - public void setTree(jalview.binding.Tree[] treeArray) - { - //-- copy array - _treeList.removeAllElements(); - for (int i = 0; i < treeArray.length; i++) { - _treeList.addElement(treeArray[i]); - } - } //-- void setTree(jalview.binding.Tree) - - /** - * Method setUserColours - * - * - * - * @param index - * @param vUserColours - */ - public void setUserColours(int index, jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _userColoursList.size())) { - throw new IndexOutOfBoundsException(); - } - _userColoursList.setElementAt(vUserColours, index); - } //-- void setUserColours(int, jalview.binding.UserColours) - - /** - * Method setUserColours - * - * - * - * @param userColoursArray - */ - public void setUserColours(jalview.binding.UserColours[] userColoursArray) - { - //-- copy array - _userColoursList.removeAllElements(); - for (int i = 0; i < userColoursArray.length; i++) { - _userColoursList.addElement(userColoursArray[i]); - } - } //-- void setUserColours(jalview.binding.UserColours) - - /** - * Method setViewport - * - * - * - * @param index - * @param vViewport - */ - public void setViewport(int index, jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _viewportList.size())) { - throw new IndexOutOfBoundsException(); - } - _viewportList.setElementAt(vViewport, index); - } //-- void setViewport(int, jalview.binding.Viewport) - - /** - * Method setViewport - * - * - * - * @param viewportArray - */ - public void setViewport(jalview.binding.Viewport[] viewportArray) - { - //-- copy array - _viewportList.removeAllElements(); - for (int i = 0; i < viewportArray.length; i++) { - _viewportList.addElement(viewportArray[i]); - } - } //-- void setViewport(jalview.binding.Viewport) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.binding.JalviewModelSequence) Unmarshaller.unmarshal(jalview.binding.JalviewModelSequence.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() +public class JalviewModelSequence + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _JSeqList + */ + private java.util.Vector _JSeqList; + + /** + * Field _JGroupList + */ + private java.util.Vector _JGroupList; + + /** + * Field _viewportList + */ + private java.util.Vector _viewportList; + + /** + * Field _userColoursList + */ + private java.util.Vector _userColoursList; + + /** + * Field _treeList + */ + private java.util.Vector _treeList; + + //----------------/ + //- Constructors -/ + //----------------/ + + public JalviewModelSequence() + { + super(); + _JSeqList = new Vector(); + _JGroupList = new Vector(); + _viewportList = new Vector(); + _userColoursList = new Vector(); + _treeList = new Vector(); + } //-- jalview.binding.JalviewModelSequence() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addJGroup + * + * + * + * @param vJGroup + */ + public void addJGroup(jalview.binding.JGroup vJGroup) + throws java.lang.IndexOutOfBoundsException + { + _JGroupList.addElement(vJGroup); + } //-- void addJGroup(jalview.binding.JGroup) + + /** + * Method addJGroup + * + * + * + * @param index + * @param vJGroup + */ + public void addJGroup(int index, jalview.binding.JGroup vJGroup) + throws java.lang.IndexOutOfBoundsException + { + _JGroupList.insertElementAt(vJGroup, index); + } //-- void addJGroup(int, jalview.binding.JGroup) + + /** + * Method addJSeq + * + * + * + * @param vJSeq + */ + public void addJSeq(jalview.binding.JSeq vJSeq) + throws java.lang.IndexOutOfBoundsException + { + _JSeqList.addElement(vJSeq); + } //-- void addJSeq(jalview.binding.JSeq) + + /** + * Method addJSeq + * + * + * + * @param index + * @param vJSeq + */ + public void addJSeq(int index, jalview.binding.JSeq vJSeq) + throws java.lang.IndexOutOfBoundsException + { + _JSeqList.insertElementAt(vJSeq, index); + } //-- void addJSeq(int, jalview.binding.JSeq) + + /** + * Method addTree + * + * + * + * @param vTree + */ + public void addTree(jalview.binding.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.addElement(vTree); + } //-- void addTree(jalview.binding.Tree) + + /** + * Method addTree + * + * + * + * @param index + * @param vTree + */ + public void addTree(int index, jalview.binding.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.insertElementAt(vTree, index); + } //-- void addTree(int, jalview.binding.Tree) + + /** + * Method addUserColours + * + * + * + * @param vUserColours + */ + public void addUserColours(jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException + { + _userColoursList.addElement(vUserColours); + } //-- void addUserColours(jalview.binding.UserColours) + + /** + * Method addUserColours + * + * + * + * @param index + * @param vUserColours + */ + public void addUserColours(int index, + jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException + { + _userColoursList.insertElementAt(vUserColours, index); + } //-- void addUserColours(int, jalview.binding.UserColours) + + /** + * Method addViewport + * + * + * + * @param vViewport + */ + public void addViewport(jalview.binding.Viewport vViewport) + throws java.lang.IndexOutOfBoundsException + { + _viewportList.addElement(vViewport); + } //-- void addViewport(jalview.binding.Viewport) + + /** + * Method addViewport + * + * + * + * @param index + * @param vViewport + */ + public void addViewport(int index, jalview.binding.Viewport vViewport) + throws java.lang.IndexOutOfBoundsException + { + _viewportList.insertElementAt(vViewport, index); + } //-- void addViewport(int, jalview.binding.Viewport) + + /** + * Method enumerateJGroup + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateJGroup() + { + return _JGroupList.elements(); + } //-- java.util.Enumeration enumerateJGroup() + + /** + * Method enumerateJSeq + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateJSeq() + { + return _JSeqList.elements(); + } //-- java.util.Enumeration enumerateJSeq() + + /** + * Method enumerateTree + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateTree() + { + return _treeList.elements(); + } //-- java.util.Enumeration enumerateTree() + + /** + * Method enumerateUserColours + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateUserColours() + { + return _userColoursList.elements(); + } //-- java.util.Enumeration enumerateUserColours() + + /** + * Method enumerateViewport + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateViewport() + { + return _viewportList.elements(); + } //-- java.util.Enumeration enumerateViewport() + + /** + * Method getJGroup + * + * + * + * @param index + * @return JGroup + */ + public jalview.binding.JGroup getJGroup(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _JGroupList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.JGroup) _JGroupList.elementAt(index); + } //-- jalview.binding.JGroup getJGroup(int) + + /** + * Method getJGroup + * + * + * + * @return JGroup + */ + public jalview.binding.JGroup[] getJGroup() + { + int size = _JGroupList.size(); + jalview.binding.JGroup[] mArray = new jalview.binding.JGroup[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.JGroup) _JGroupList.elementAt(index); + } + return mArray; + } //-- jalview.binding.JGroup[] getJGroup() + + /** + * Method getJGroupCount + * + * + * + * @return int + */ + public int getJGroupCount() + { + return _JGroupList.size(); + } //-- int getJGroupCount() + + /** + * Method getJSeq + * + * + * + * @param index + * @return JSeq + */ + public jalview.binding.JSeq getJSeq(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _JSeqList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.JSeq) _JSeqList.elementAt(index); + } //-- jalview.binding.JSeq getJSeq(int) + + /** + * Method getJSeq + * + * + * + * @return JSeq + */ + public jalview.binding.JSeq[] getJSeq() + { + int size = _JSeqList.size(); + jalview.binding.JSeq[] mArray = new jalview.binding.JSeq[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.JSeq) _JSeqList.elementAt(index); + } + return mArray; + } //-- jalview.binding.JSeq[] getJSeq() + + /** + * Method getJSeqCount + * + * + * + * @return int + */ + public int getJSeqCount() + { + return _JSeqList.size(); + } //-- int getJSeqCount() + + /** + * Method getTree + * + * + * + * @param index + * @return Tree + */ + public jalview.binding.Tree getTree(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _treeList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Tree) _treeList.elementAt(index); + } //-- jalview.binding.Tree getTree(int) + + /** + * Method getTree + * + * + * + * @return Tree + */ + public jalview.binding.Tree[] getTree() + { + int size = _treeList.size(); + jalview.binding.Tree[] mArray = new jalview.binding.Tree[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.Tree) _treeList.elementAt(index); + } + return mArray; + } //-- jalview.binding.Tree[] getTree() + + /** + * Method getTreeCount + * + * + * + * @return int + */ + public int getTreeCount() + { + return _treeList.size(); + } //-- int getTreeCount() + + /** + * Method getUserColours + * + * + * + * @param index + * @return UserColours + */ + public jalview.binding.UserColours getUserColours(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _userColoursList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.UserColours) _userColoursList.elementAt(index); + } //-- jalview.binding.UserColours getUserColours(int) + + /** + * Method getUserColours + * + * + * + * @return UserColours + */ + public jalview.binding.UserColours[] getUserColours() + { + int size = _userColoursList.size(); + jalview.binding.UserColours[] mArray = new jalview.binding.UserColours[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.UserColours) _userColoursList.elementAt( + index); + } + return mArray; + } //-- jalview.binding.UserColours[] getUserColours() + + /** + * Method getUserColoursCount + * + * + * + * @return int + */ + public int getUserColoursCount() + { + return _userColoursList.size(); + } //-- int getUserColoursCount() + + /** + * Method getViewport + * + * + * + * @param index + * @return Viewport + */ + public jalview.binding.Viewport getViewport(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _viewportList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Viewport) _viewportList.elementAt(index); + } //-- jalview.binding.Viewport getViewport(int) + + /** + * Method getViewport + * + * + * + * @return Viewport + */ + public jalview.binding.Viewport[] getViewport() + { + int size = _viewportList.size(); + jalview.binding.Viewport[] mArray = new jalview.binding.Viewport[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.Viewport) _viewportList.elementAt(index); + } + return mArray; + } //-- jalview.binding.Viewport[] getViewport() + + /** + * Method getViewportCount + * + * + * + * @return int + */ + public int getViewportCount() + { + return _viewportList.size(); + } //-- int getViewportCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try + { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAllJGroup + * + */ + public void removeAllJGroup() + { + _JGroupList.removeAllElements(); + } //-- void removeAllJGroup() + + /** + * Method removeAllJSeq + * + */ + public void removeAllJSeq() + { + _JSeqList.removeAllElements(); + } //-- void removeAllJSeq() + + /** + * Method removeAllTree + * + */ + public void removeAllTree() + { + _treeList.removeAllElements(); + } //-- void removeAllTree() + + /** + * Method removeAllUserColours + * + */ + public void removeAllUserColours() + { + _userColoursList.removeAllElements(); + } //-- void removeAllUserColours() + + /** + * Method removeAllViewport + * + */ + public void removeAllViewport() + { + _viewportList.removeAllElements(); + } //-- void removeAllViewport() + + /** + * Method removeJGroup + * + * + * + * @param index + * @return JGroup + */ + public jalview.binding.JGroup removeJGroup(int index) + { + java.lang.Object obj = _JGroupList.elementAt(index); + _JGroupList.removeElementAt(index); + return (jalview.binding.JGroup) obj; + } //-- jalview.binding.JGroup removeJGroup(int) + + /** + * Method removeJSeq + * + * + * + * @param index + * @return JSeq + */ + public jalview.binding.JSeq removeJSeq(int index) + { + java.lang.Object obj = _JSeqList.elementAt(index); + _JSeqList.removeElementAt(index); + return (jalview.binding.JSeq) obj; + } //-- jalview.binding.JSeq removeJSeq(int) + + /** + * Method removeTree + * + * + * + * @param index + * @return Tree + */ + public jalview.binding.Tree removeTree(int index) + { + java.lang.Object obj = _treeList.elementAt(index); + _treeList.removeElementAt(index); + return (jalview.binding.Tree) obj; + } //-- jalview.binding.Tree removeTree(int) + + /** + * Method removeUserColours + * + * + * + * @param index + * @return UserColours + */ + public jalview.binding.UserColours removeUserColours(int index) + { + java.lang.Object obj = _userColoursList.elementAt(index); + _userColoursList.removeElementAt(index); + return (jalview.binding.UserColours) obj; + } //-- jalview.binding.UserColours removeUserColours(int) + + /** + * Method removeViewport + * + * + * + * @param index + * @return Viewport + */ + public jalview.binding.Viewport removeViewport(int index) + { + java.lang.Object obj = _viewportList.elementAt(index); + _viewportList.removeElementAt(index); + return (jalview.binding.Viewport) obj; + } //-- jalview.binding.Viewport removeViewport(int) + + /** + * Method setJGroup + * + * + * + * @param index + * @param vJGroup + */ + public void setJGroup(int index, jalview.binding.JGroup vJGroup) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _JGroupList.size())) + { + throw new IndexOutOfBoundsException(); + } + _JGroupList.setElementAt(vJGroup, index); + } //-- void setJGroup(int, jalview.binding.JGroup) + + /** + * Method setJGroup + * + * + * + * @param JGroupArray + */ + public void setJGroup(jalview.binding.JGroup[] JGroupArray) + { + //-- copy array + _JGroupList.removeAllElements(); + for (int i = 0; i < JGroupArray.length; i++) + { + _JGroupList.addElement(JGroupArray[i]); + } + } //-- void setJGroup(jalview.binding.JGroup) + + /** + * Method setJSeq + * + * + * + * @param index + * @param vJSeq + */ + public void setJSeq(int index, jalview.binding.JSeq vJSeq) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _JSeqList.size())) + { + throw new IndexOutOfBoundsException(); + } + _JSeqList.setElementAt(vJSeq, index); + } //-- void setJSeq(int, jalview.binding.JSeq) + + /** + * Method setJSeq + * + * + * + * @param JSeqArray + */ + public void setJSeq(jalview.binding.JSeq[] JSeqArray) + { + //-- copy array + _JSeqList.removeAllElements(); + for (int i = 0; i < JSeqArray.length; i++) + { + _JSeqList.addElement(JSeqArray[i]); + } + } //-- void setJSeq(jalview.binding.JSeq) + + /** + * Method setTree + * + * + * + * @param index + * @param vTree + */ + public void setTree(int index, jalview.binding.Tree vTree) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _treeList.size())) + { + throw new IndexOutOfBoundsException(); + } + _treeList.setElementAt(vTree, index); + } //-- void setTree(int, jalview.binding.Tree) + + /** + * Method setTree + * + * + * + * @param treeArray + */ + public void setTree(jalview.binding.Tree[] treeArray) + { + //-- copy array + _treeList.removeAllElements(); + for (int i = 0; i < treeArray.length; i++) + { + _treeList.addElement(treeArray[i]); + } + } //-- void setTree(jalview.binding.Tree) + + /** + * Method setUserColours + * + * + * + * @param index + * @param vUserColours + */ + public void setUserColours(int index, + jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _userColoursList.size())) + { + throw new IndexOutOfBoundsException(); + } + _userColoursList.setElementAt(vUserColours, index); + } //-- void setUserColours(int, jalview.binding.UserColours) + + /** + * Method setUserColours + * + * + * + * @param userColoursArray + */ + public void setUserColours(jalview.binding.UserColours[] userColoursArray) + { + //-- copy array + _userColoursList.removeAllElements(); + for (int i = 0; i < userColoursArray.length; i++) + { + _userColoursList.addElement(userColoursArray[i]); + } + } //-- void setUserColours(jalview.binding.UserColours) + + /** + * Method setViewport + * + * + * + * @param index + * @param vViewport + */ + public void setViewport(int index, jalview.binding.Viewport vViewport) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _viewportList.size())) + { + throw new IndexOutOfBoundsException(); + } + _viewportList.setElementAt(vViewport, index); + } //-- void setViewport(int, jalview.binding.Viewport) + + /** + * Method setViewport + * + * + * + * @param viewportArray + */ + public void setViewport(jalview.binding.Viewport[] viewportArray) + { + //-- copy array + _viewportList.removeAllElements(); + for (int i = 0; i < viewportArray.length; i++) + { + _viewportList.addElement(viewportArray[i]); + } + } //-- void setViewport(jalview.binding.Viewport) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.JalviewModelSequence) Unmarshaller.unmarshal( + jalview.binding.JalviewModelSequence.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/JalviewModelSequence2.java b/src/jalview/binding/JalviewModelSequence2.java index 36e5579..2cfd72c 100755 --- a/src/jalview/binding/JalviewModelSequence2.java +++ b/src/jalview/binding/JalviewModelSequence2.java @@ -1,38 +1,39 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Enumeration; import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class JalviewModelSequence2. - * + * * @version $Revision$ $Date$ */ -public class JalviewModelSequence2 implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JalviewModelSequence2 implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -40,235 +41,279 @@ public class JalviewModelSequence2 implements java.io.Serializable { */ private java.util.Vector _items; - - //----------------/ - //- Constructors -/ //----------------/ - - public JalviewModelSequence2() { + //- Constructors -/ + //----------------/ + public JalviewModelSequence2() + { super(); _items = new Vector(); - } //-- jalview.binding.JalviewModelSequence2() - + } - //-----------/ - //- Methods -/ + //-- jalview.binding.JalviewModelSequence2() //-----------/ /** - * Method addJalviewModelSequence2Item - * - * - * - * @param vJalviewModelSequence2Item + * DOCUMENT ME! + * + * @param vJalviewModelSequence2Item DOCUMENT ME! + * + * @throws java.lang.IndexOutOfBoundsException DOCUMENT ME! */ - public void addJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) + public void addJalviewModelSequence2Item( + jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) throws java.lang.IndexOutOfBoundsException { _items.addElement(vJalviewModelSequence2Item); - } //-- void addJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) + } + + //-- void addJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) /** * Method addJalviewModelSequence2Item - * - * - * + * + * + * * @param index * @param vJalviewModelSequence2Item */ - public void addJalviewModelSequence2Item(int index, jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) + public void addJalviewModelSequence2Item(int index, + jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) throws java.lang.IndexOutOfBoundsException { _items.insertElementAt(vJalviewModelSequence2Item, index); - } //-- void addJalviewModelSequence2Item(int, jalview.binding.JalviewModelSequence2Item) + } + + //-- void addJalviewModelSequence2Item(int, jalview.binding.JalviewModelSequence2Item) /** * Method enumerateJalviewModelSequence2Item - * - * - * + * + * + * * @return Enumeration */ public java.util.Enumeration enumerateJalviewModelSequence2Item() { return _items.elements(); - } //-- java.util.Enumeration enumerateJalviewModelSequence2Item() + } + + //-- java.util.Enumeration enumerateJalviewModelSequence2Item() /** * Method getJalviewModelSequence2Item - * - * - * + * + * + * * @param index * @return JalviewModelSequence2Item */ - public jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item(int index) - throws java.lang.IndexOutOfBoundsException + public jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item( + int index) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _items.size())) { + if ((index < 0) || (index > _items.size())) + { throw new IndexOutOfBoundsException(); } - + return (jalview.binding.JalviewModelSequence2Item) _items.elementAt(index); - } //-- jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item(int) + } + + //-- jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item(int) /** * Method getJalviewModelSequence2Item - * - * - * + * + * + * * @return JalviewModelSequence2Item */ public jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() { int size = _items.size(); jalview.binding.JalviewModelSequence2Item[] mArray = new jalview.binding.JalviewModelSequence2Item[size]; - for (int index = 0; index < size; index++) { + + for (int index = 0; index < size; index++) + { mArray[index] = (jalview.binding.JalviewModelSequence2Item) _items.elementAt(index); } + return mArray; - } //-- jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() + } + + //-- jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() /** * Method getJalviewModelSequence2ItemCount - * - * - * + * + * + * * @return int */ public int getJalviewModelSequence2ItemCount() { return _items.size(); - } //-- int getJalviewModelSequence2ItemCount() + } + + //-- int getJalviewModelSequence2ItemCount() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllJalviewModelSequence2Item - * + * */ public void removeAllJalviewModelSequence2Item() { _items.removeAllElements(); - } //-- void removeAllJalviewModelSequence2Item() + } + + //-- void removeAllJalviewModelSequence2Item() /** * Method removeJalviewModelSequence2Item - * - * - * + * + * + * * @param index * @return JalviewModelSequence2Item */ - public jalview.binding.JalviewModelSequence2Item removeJalviewModelSequence2Item(int index) + public jalview.binding.JalviewModelSequence2Item removeJalviewModelSequence2Item( + int index) { java.lang.Object obj = _items.elementAt(index); _items.removeElementAt(index); + return (jalview.binding.JalviewModelSequence2Item) obj; - } //-- jalview.binding.JalviewModelSequence2Item removeJalviewModelSequence2Item(int) + } + + //-- jalview.binding.JalviewModelSequence2Item removeJalviewModelSequence2Item(int) /** * Method setJalviewModelSequence2Item - * - * - * + * + * + * * @param index * @param vJalviewModelSequence2Item */ - public void setJalviewModelSequence2Item(int index, jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) + public void setJalviewModelSequence2Item(int index, + jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _items.size())) { + if ((index < 0) || (index > _items.size())) + { throw new IndexOutOfBoundsException(); } + _items.setElementAt(vJalviewModelSequence2Item, index); - } //-- void setJalviewModelSequence2Item(int, jalview.binding.JalviewModelSequence2Item) + } + + //-- void setJalviewModelSequence2Item(int, jalview.binding.JalviewModelSequence2Item) /** * Method setJalviewModelSequence2Item - * - * - * + * + * + * * @param jalviewModelSequence2ItemArray */ - public void setJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item[] jalviewModelSequence2ItemArray) + public void setJalviewModelSequence2Item( + jalview.binding.JalviewModelSequence2Item[] jalviewModelSequence2ItemArray) { //-- copy array _items.removeAllElements(); - for (int i = 0; i < jalviewModelSequence2ItemArray.length; i++) { + + for (int i = 0; i < jalviewModelSequence2ItemArray.length; i++) + { _items.addElement(jalviewModelSequence2ItemArray[i]); } - } //-- void setJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) + } + + //-- void setJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewModelSequence2) Unmarshaller.unmarshal(jalview.binding.JalviewModelSequence2.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.JalviewModelSequence2) Unmarshaller.unmarshal(jalview.binding.JalviewModelSequence2.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/JalviewModelSequence2Item.java b/src/jalview/binding/JalviewModelSequence2Item.java index 8678b09..6e54565 100755 --- a/src/jalview/binding/JalviewModelSequence2Item.java +++ b/src/jalview/binding/JalviewModelSequence2Item.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,191 +7,200 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.Serializable; -import java.util.Enumeration; -import java.util.Vector; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; +import java.util.*; /** * Class JalviewModelSequence2Item. - * + * * @version $Revision$ $Date$ */ -public class JalviewModelSequence2Item implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _userColourSchemeList - */ - private java.util.Vector _userColourSchemeList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public JalviewModelSequence2Item() { - super(); - _userColourSchemeList = new Vector(); - } //-- jalview.binding.JalviewModelSequence2Item() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addUserColourScheme - * - * - * - * @param vUserColourScheme - */ - public void addUserColourScheme(jalview.binding.UserColourScheme vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { - _userColourSchemeList.addElement(vUserColourScheme); - } //-- void addUserColourScheme(jalview.binding.UserColourScheme) - - /** - * Method addUserColourScheme - * - * - * - * @param index - * @param vUserColourScheme - */ - public void addUserColourScheme(int index, jalview.binding.UserColourScheme vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { - _userColourSchemeList.insertElementAt(vUserColourScheme, index); - } //-- void addUserColourScheme(int, jalview.binding.UserColourScheme) - - /** - * Method enumerateUserColourScheme - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateUserColourScheme() - { - return _userColourSchemeList.elements(); - } //-- java.util.Enumeration enumerateUserColourScheme() - - /** - * Method getUserColourScheme - * - * - * - * @param index - * @return UserColourScheme - */ - public jalview.binding.UserColourScheme getUserColourScheme(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _userColourSchemeList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.UserColourScheme) _userColourSchemeList.elementAt(index); - } //-- jalview.binding.UserColourScheme getUserColourScheme(int) - - /** - * Method getUserColourScheme - * - * - * - * @return UserColourScheme - */ - public jalview.binding.UserColourScheme[] getUserColourScheme() - { - int size = _userColourSchemeList.size(); - jalview.binding.UserColourScheme[] mArray = new jalview.binding.UserColourScheme[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.UserColourScheme) _userColourSchemeList.elementAt(index); - } - return mArray; - } //-- jalview.binding.UserColourScheme[] getUserColourScheme() - - /** - * Method getUserColourSchemeCount - * - * - * - * @return int - */ - public int getUserColourSchemeCount() - { - return _userColourSchemeList.size(); - } //-- int getUserColourSchemeCount() - - /** - * Method removeAllUserColourScheme - * - */ - public void removeAllUserColourScheme() +public class JalviewModelSequence2Item + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _userColourSchemeList + */ + private java.util.Vector _userColourSchemeList; + + //----------------/ + //- Constructors -/ + //----------------/ + + public JalviewModelSequence2Item() + { + super(); + _userColourSchemeList = new Vector(); + } //-- jalview.binding.JalviewModelSequence2Item() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addUserColourScheme + * + * + * + * @param vUserColourScheme + */ + public void addUserColourScheme(jalview.binding.UserColourScheme + vUserColourScheme) + throws java.lang.IndexOutOfBoundsException + { + _userColourSchemeList.addElement(vUserColourScheme); + } //-- void addUserColourScheme(jalview.binding.UserColourScheme) + + /** + * Method addUserColourScheme + * + * + * + * @param index + * @param vUserColourScheme + */ + public void addUserColourScheme(int index, + jalview.binding.UserColourScheme + vUserColourScheme) + throws java.lang.IndexOutOfBoundsException + { + _userColourSchemeList.insertElementAt(vUserColourScheme, index); + } //-- void addUserColourScheme(int, jalview.binding.UserColourScheme) + + /** + * Method enumerateUserColourScheme + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateUserColourScheme() + { + return _userColourSchemeList.elements(); + } //-- java.util.Enumeration enumerateUserColourScheme() + + /** + * Method getUserColourScheme + * + * + * + * @param index + * @return UserColourScheme + */ + public jalview.binding.UserColourScheme getUserColourScheme(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _userColourSchemeList.size())) { - _userColourSchemeList.removeAllElements(); - } //-- void removeAllUserColourScheme() - - /** - * Method removeUserColourScheme - * - * - * - * @param index - * @return UserColourScheme - */ - public jalview.binding.UserColourScheme removeUserColourScheme(int index) + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.UserColourScheme) _userColourSchemeList.elementAt( + index); + } //-- jalview.binding.UserColourScheme getUserColourScheme(int) + + /** + * Method getUserColourScheme + * + * + * + * @return UserColourScheme + */ + public jalview.binding.UserColourScheme[] getUserColourScheme() + { + int size = _userColourSchemeList.size(); + jalview.binding.UserColourScheme[] mArray = new jalview.binding. + UserColourScheme[size]; + for (int index = 0; index < size; index++) { - java.lang.Object obj = _userColourSchemeList.elementAt(index); - _userColourSchemeList.removeElementAt(index); - return (jalview.binding.UserColourScheme) obj; - } //-- jalview.binding.UserColourScheme removeUserColourScheme(int) - - /** - * Method setUserColourScheme - * - * - * - * @param index - * @param vUserColourScheme - */ - public void setUserColourScheme(int index, jalview.binding.UserColourScheme vUserColourScheme) - throws java.lang.IndexOutOfBoundsException + mArray[index] = (jalview.binding.UserColourScheme) _userColourSchemeList. + elementAt(index); + } + return mArray; + } //-- jalview.binding.UserColourScheme[] getUserColourScheme() + + /** + * Method getUserColourSchemeCount + * + * + * + * @return int + */ + public int getUserColourSchemeCount() + { + return _userColourSchemeList.size(); + } //-- int getUserColourSchemeCount() + + /** + * Method removeAllUserColourScheme + * + */ + public void removeAllUserColourScheme() + { + _userColourSchemeList.removeAllElements(); + } //-- void removeAllUserColourScheme() + + /** + * Method removeUserColourScheme + * + * + * + * @param index + * @return UserColourScheme + */ + public jalview.binding.UserColourScheme removeUserColourScheme(int index) + { + java.lang.Object obj = _userColourSchemeList.elementAt(index); + _userColourSchemeList.removeElementAt(index); + return (jalview.binding.UserColourScheme) obj; + } //-- jalview.binding.UserColourScheme removeUserColourScheme(int) + + /** + * Method setUserColourScheme + * + * + * + * @param index + * @param vUserColourScheme + */ + public void setUserColourScheme(int index, + jalview.binding.UserColourScheme + vUserColourScheme) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _userColourSchemeList.size())) { - //-- check bounds for index - if ((index < 0) || (index > _userColourSchemeList.size())) { - throw new IndexOutOfBoundsException(); - } - _userColourSchemeList.setElementAt(vUserColourScheme, index); - } //-- void setUserColourScheme(int, jalview.binding.UserColourScheme) - - /** - * Method setUserColourScheme - * - * - * - * @param userColourSchemeArray - */ - public void setUserColourScheme(jalview.binding.UserColourScheme[] userColourSchemeArray) + throw new IndexOutOfBoundsException(); + } + _userColourSchemeList.setElementAt(vUserColourScheme, index); + } //-- void setUserColourScheme(int, jalview.binding.UserColourScheme) + + /** + * Method setUserColourScheme + * + * + * + * @param userColourSchemeArray + */ + public void setUserColourScheme(jalview.binding.UserColourScheme[] + userColourSchemeArray) + { + //-- copy array + _userColourSchemeList.removeAllElements(); + for (int i = 0; i < userColourSchemeArray.length; i++) { - //-- copy array - _userColourSchemeList.removeAllElements(); - for (int i = 0; i < userColourSchemeArray.length; i++) { - _userColourSchemeList.addElement(userColourSchemeArray[i]); - } - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) + _userColourSchemeList.addElement(userColourSchemeArray[i]); + } + } //-- void setUserColourScheme(jalview.binding.UserColourScheme) } diff --git a/src/jalview/binding/JalviewUserColours.java b/src/jalview/binding/JalviewUserColours.java index 676a623..8df0d44 100755 --- a/src/jalview/binding/JalviewUserColours.java +++ b/src/jalview/binding/JalviewUserColours.java @@ -1,38 +1,39 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; +import org.xml.sax.ContentHandler; + +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Enumeration; import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class JalviewUserColours. - * + * * @version $Revision$ $Date$ */ -public class JalviewUserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JalviewUserColours implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -40,39 +41,38 @@ public class JalviewUserColours implements java.io.Serializable { */ private java.util.Vector _colourList; - - //----------------/ - //- Constructors -/ //----------------/ - - public JalviewUserColours() { + //- Constructors -/ + //----------------/ + public JalviewUserColours() + { super(); _colourList = new Vector(); - } //-- jalview.binding.JalviewUserColours() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.JalviewUserColours() //-----------/ /** - * Method addColour - * - * - * - * @param vColour + * DOCUMENT ME! + * + * @param vColour DOCUMENT ME! + * + * @throws java.lang.IndexOutOfBoundsException DOCUMENT ME! */ public void addColour(jalview.binding.Colour vColour) throws java.lang.IndexOutOfBoundsException { _colourList.addElement(vColour); - } //-- void addColour(jalview.binding.Colour) + } + + //-- void addColour(jalview.binding.Colour) /** * Method addColour - * - * - * + * + * + * * @param index * @param vColour */ @@ -80,25 +80,29 @@ public class JalviewUserColours implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { _colourList.insertElementAt(vColour, index); - } //-- void addColour(int, jalview.binding.Colour) + } + + //-- void addColour(int, jalview.binding.Colour) /** * Method enumerateColour - * - * - * + * + * + * * @return Enumeration */ public java.util.Enumeration enumerateColour() { return _colourList.elements(); - } //-- java.util.Enumeration enumerateColour() + } + + //-- java.util.Enumeration enumerateColour() /** * Method getColour - * - * - * + * + * + * * @param index * @return Colour */ @@ -106,102 +110,123 @@ public class JalviewUserColours implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _colourList.size())) { + if ((index < 0) || (index > _colourList.size())) + { throw new IndexOutOfBoundsException(); } - + return (jalview.binding.Colour) _colourList.elementAt(index); - } //-- jalview.binding.Colour getColour(int) + } + + //-- jalview.binding.Colour getColour(int) /** * Method getColour - * - * - * + * + * + * * @return Colour */ public jalview.binding.Colour[] getColour() { int size = _colourList.size(); jalview.binding.Colour[] mArray = new jalview.binding.Colour[size]; - for (int index = 0; index < size; index++) { + + for (int index = 0; index < size; index++) + { mArray[index] = (jalview.binding.Colour) _colourList.elementAt(index); } + return mArray; - } //-- jalview.binding.Colour[] getColour() + } + + //-- jalview.binding.Colour[] getColour() /** * Method getColourCount - * - * - * + * + * + * * @return int */ public int getColourCount() { return _colourList.size(); - } //-- int getColourCount() + } + + //-- int getColourCount() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllColour - * + * */ public void removeAllColour() { _colourList.removeAllElements(); - } //-- void removeAllColour() + } + + //-- void removeAllColour() /** * Method removeColour - * - * - * + * + * + * * @param index * @return Colour */ @@ -209,14 +234,17 @@ public class JalviewUserColours implements java.io.Serializable { { java.lang.Object obj = _colourList.elementAt(index); _colourList.removeElementAt(index); + return (jalview.binding.Colour) obj; - } //-- jalview.binding.Colour removeColour(int) + } + + //-- jalview.binding.Colour removeColour(int) /** * Method setColour - * - * - * + * + * + * * @param index * @param vColour */ @@ -224,51 +252,63 @@ public class JalviewUserColours implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _colourList.size())) { + if ((index < 0) || (index > _colourList.size())) + { throw new IndexOutOfBoundsException(); } + _colourList.setElementAt(vColour, index); - } //-- void setColour(int, jalview.binding.Colour) + } + + //-- void setColour(int, jalview.binding.Colour) /** * Method setColour - * - * - * + * + * + * * @param colourArray */ public void setColour(jalview.binding.Colour[] colourArray) { //-- copy array _colourList.removeAllElements(); - for (int i = 0; i < colourArray.length; i++) { + + for (int i = 0; i < colourArray.length; i++) + { _colourList.addElement(colourArray[i]); } - } //-- void setColour(jalview.binding.Colour) + } + + //-- void setColour(jalview.binding.Colour) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/JalviewUserColoursItem.java b/src/jalview/binding/JalviewUserColoursItem.java index ce6919c..9c88831 100755 --- a/src/jalview/binding/JalviewUserColoursItem.java +++ b/src/jalview/binding/JalviewUserColoursItem.java @@ -1,30 +1,29 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.Serializable; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.Serializable; + + /** * Class JalviewUserColoursItem. - * + * * @version $Revision$ $Date$ */ -public class JalviewUserColoursItem implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class JalviewUserColoursItem implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -32,39 +31,38 @@ public class JalviewUserColoursItem implements java.io.Serializable { */ private jalview.binding.Colour _colour; - - //----------------/ - //- Constructors -/ //----------------/ - - public JalviewUserColoursItem() { + //- Constructors -/ + //----------------/ + public JalviewUserColoursItem() + { super(); - } //-- jalview.binding.JalviewUserColoursItem() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.JalviewUserColoursItem() //-----------/ /** - * Returns the value of field 'colour'. - * - * @return Colour - * @return the value of field 'colour'. + * DOCUMENT ME! + * + * @return DOCUMENT ME! */ public jalview.binding.Colour getColour() { return this._colour; - } //-- jalview.binding.Colour getColour() + } + + //-- jalview.binding.Colour getColour() /** * Sets the value of field 'colour'. - * + * * @param colour the value of field 'colour'. */ public void setColour(jalview.binding.Colour colour) { this._colour = colour; - } //-- void setColour(jalview.binding.Colour) + } + //-- void setColour(jalview.binding.Colour) } diff --git a/src/jalview/binding/Residue.java b/src/jalview/binding/Residue.java index 69e4312..2588f38 100755 --- a/src/jalview/binding/Residue.java +++ b/src/jalview/binding/Residue.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,194 +7,193 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class Residue. - * + * * @version $Revision$ $Date$ */ -public class Residue implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _name - */ - private java.lang.String _name; - - /** - * Field _RGB - */ - private int _RGB; - - /** - * keeps track of state for field: _RGB - */ - private boolean _has_RGB; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Residue() { - super(); - } //-- jalview.binding.Residue() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method deleteRGB - * - */ - public void deleteRGB() - { - this._has_RGB= false; - } //-- void deleteRGB() - - /** - * Returns the value of field 'name'. - * - * @return String - * @return the value of field 'name'. - */ - public java.lang.String getName() - { - return this._name; - } //-- java.lang.String getName() - - /** - * Returns the value of field 'RGB'. - * - * @return int - * @return the value of field 'RGB'. - */ - public int getRGB() - { - return this._RGB; - } //-- int getRGB() - - /** - * Method hasRGB - * - * - * - * @return boolean - */ - public boolean hasRGB() - { - return this._has_RGB; - } //-- boolean hasRGB() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName(java.lang.String name) - { - this._name = name; - } //-- void setName(java.lang.String) - - /** - * Sets the value of field 'RGB'. - * - * @param RGB the value of field 'RGB'. - */ - public void setRGB(int RGB) - { - this._RGB = RGB; - this._has_RGB = true; - } //-- void setRGB(int) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException +public class Residue + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _name + */ + private java.lang.String _name; + + /** + * Field _RGB + */ + private int _RGB; + + /** + * keeps track of state for field: _RGB + */ + private boolean _has_RGB; + + //----------------/ + //- Constructors -/ + //----------------/ + + public Residue() + { + super(); + } //-- jalview.binding.Residue() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteRGB + * + */ + public void deleteRGB() + { + this._has_RGB = false; + } //-- void deleteRGB() + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Returns the value of field 'RGB'. + * + * @return int + * @return the value of field 'RGB'. + */ + public int getRGB() + { + return this._RGB; + } //-- int getRGB() + + /** + * Method hasRGB + * + * + * + * @return boolean + */ + public boolean hasRGB() + { + return this._has_RGB; + } //-- boolean hasRGB() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { - return (jalview.binding.Residue) Unmarshaller.unmarshal(jalview.binding.Residue.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Sets the value of field 'RGB'. + * + * @param RGB the value of field 'RGB'. + */ + public void setRGB(int RGB) + { + this._RGB = RGB; + this._has_RGB = true; + } //-- void setRGB(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Residue) Unmarshaller.unmarshal(jalview.binding. + Residue.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/Sequence.java b/src/jalview/binding/Sequence.java index f3fd4e4..b583b4e 100755 --- a/src/jalview/binding/Sequence.java +++ b/src/jalview/binding/Sequence.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,112 +7,110 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class Sequence. - * + * * @version $Revision$ $Date$ */ -public class Sequence extends SequenceType -implements java.io.Serializable +public class Sequence + extends SequenceType implements java.io.Serializable { + //----------------/ + //- Constructors -/ + //----------------/ - //----------------/ - //- Constructors -/ - //----------------/ + public Sequence() + { + super(); + } //-- jalview.binding.Sequence() - public Sequence() { - super(); - } //-- jalview.binding.Sequence() + //-----------/ + //- Methods -/ + //-----------/ + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try + { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } //-- boolean isValid() - //-----------/ - //- Methods -/ - //-----------/ + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.binding.Sequence) Unmarshaller.unmarshal(jalview.binding.Sequence.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Sequence) Unmarshaller.unmarshal(jalview.binding. + Sequence.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/SequenceSet.java b/src/jalview/binding/SequenceSet.java index 7ed3b52..a0d116e 100755 --- a/src/jalview/binding/SequenceSet.java +++ b/src/jalview/binding/SequenceSet.java @@ -1,38 +1,39 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; + +import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ import java.io.IOException; import java.io.Reader; import java.io.Serializable; import java.io.Writer; + import java.util.Enumeration; import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; + /** * Class SequenceSet. - * + * * @version $Revision$ $Date$ */ -public class SequenceSet implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class SequenceSet implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -60,40 +61,39 @@ public class SequenceSet implements java.io.Serializable { */ private java.util.Vector _annotationList; - - //----------------/ - //- Constructors -/ //----------------/ - - public SequenceSet() { + //- Constructors -/ + //----------------/ + public SequenceSet() + { super(); _sequenceList = new Vector(); _annotationList = new Vector(); - } //-- jalview.binding.SequenceSet() - + } - //-----------/ - //- Methods -/ + //-- jalview.binding.SequenceSet() //-----------/ /** - * Method addAnnotation - * - * - * - * @param vAnnotation + * DOCUMENT ME! + * + * @param vAnnotation DOCUMENT ME! + * + * @throws java.lang.IndexOutOfBoundsException DOCUMENT ME! */ public void addAnnotation(jalview.binding.Annotation vAnnotation) throws java.lang.IndexOutOfBoundsException { _annotationList.addElement(vAnnotation); - } //-- void addAnnotation(jalview.binding.Annotation) + } + + //-- void addAnnotation(jalview.binding.Annotation) /** * Method addAnnotation - * - * - * + * + * + * * @param index * @param vAnnotation */ @@ -101,26 +101,30 @@ public class SequenceSet implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { _annotationList.insertElementAt(vAnnotation, index); - } //-- void addAnnotation(int, jalview.binding.Annotation) + } + + //-- void addAnnotation(int, jalview.binding.Annotation) /** * Method addSequence - * - * - * + * + * + * * @param vSequence */ public void addSequence(jalview.binding.Sequence vSequence) throws java.lang.IndexOutOfBoundsException { _sequenceList.addElement(vSequence); - } //-- void addSequence(jalview.binding.Sequence) + } + + //-- void addSequence(jalview.binding.Sequence) /** * Method addSequence - * - * - * + * + * + * * @param index * @param vSequence */ @@ -128,57 +132,67 @@ public class SequenceSet implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { _sequenceList.insertElementAt(vSequence, index); - } //-- void addSequence(int, jalview.binding.Sequence) + } + + //-- void addSequence(int, jalview.binding.Sequence) /** * Method deleteAligned - * + * */ public void deleteAligned() { - this._has_aligned= false; - } //-- void deleteAligned() + this._has_aligned = false; + } + + //-- void deleteAligned() /** * Method enumerateAnnotation - * - * - * + * + * + * * @return Enumeration */ public java.util.Enumeration enumerateAnnotation() { return _annotationList.elements(); - } //-- java.util.Enumeration enumerateAnnotation() + } + + //-- java.util.Enumeration enumerateAnnotation() /** * Method enumerateSequence - * - * - * + * + * + * * @return Enumeration */ public java.util.Enumeration enumerateSequence() { return _sequenceList.elements(); - } //-- java.util.Enumeration enumerateSequence() + } + + //-- java.util.Enumeration enumerateSequence() /** * Returns the value of field 'aligned'. - * + * * @return boolean * @return the value of field 'aligned'. */ public boolean getAligned() { return this._aligned; - } //-- boolean getAligned() + } + + //-- boolean getAligned() /** * Method getAnnotation - * - * - * + * + * + * * @param index * @return Annotation */ @@ -186,58 +200,70 @@ public class SequenceSet implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _annotationList.size())) { + if ((index < 0) || (index > _annotationList.size())) + { throw new IndexOutOfBoundsException(); } - + return (jalview.binding.Annotation) _annotationList.elementAt(index); - } //-- jalview.binding.Annotation getAnnotation(int) + } + + //-- jalview.binding.Annotation getAnnotation(int) /** * Method getAnnotation - * - * - * + * + * + * * @return Annotation */ public jalview.binding.Annotation[] getAnnotation() { int size = _annotationList.size(); jalview.binding.Annotation[] mArray = new jalview.binding.Annotation[size]; - for (int index = 0; index < size; index++) { + + for (int index = 0; index < size; index++) + { mArray[index] = (jalview.binding.Annotation) _annotationList.elementAt(index); } + return mArray; - } //-- jalview.binding.Annotation[] getAnnotation() + } + + //-- jalview.binding.Annotation[] getAnnotation() /** * Method getAnnotationCount - * - * - * + * + * + * * @return int */ public int getAnnotationCount() { return _annotationList.size(); - } //-- int getAnnotationCount() + } + + //-- int getAnnotationCount() /** * Returns the value of field 'gapChar'. - * + * * @return String * @return the value of field 'gapChar'. */ public java.lang.String getGapChar() { return this._gapChar; - } //-- java.lang.String getGapChar() + } + + //-- java.lang.String getGapChar() /** * Method getSequence - * - * - * + * + * + * * @param index * @return Sequence */ @@ -245,123 +271,148 @@ public class SequenceSet implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _sequenceList.size())) { + if ((index < 0) || (index > _sequenceList.size())) + { throw new IndexOutOfBoundsException(); } - + return (jalview.binding.Sequence) _sequenceList.elementAt(index); - } //-- jalview.binding.Sequence getSequence(int) + } + + //-- jalview.binding.Sequence getSequence(int) /** * Method getSequence - * - * - * + * + * + * * @return Sequence */ public jalview.binding.Sequence[] getSequence() { int size = _sequenceList.size(); jalview.binding.Sequence[] mArray = new jalview.binding.Sequence[size]; - for (int index = 0; index < size; index++) { + + for (int index = 0; index < size; index++) + { mArray[index] = (jalview.binding.Sequence) _sequenceList.elementAt(index); } + return mArray; - } //-- jalview.binding.Sequence[] getSequence() + } + + //-- jalview.binding.Sequence[] getSequence() /** * Method getSequenceCount - * - * - * + * + * + * * @return int */ public int getSequenceCount() { return _sequenceList.size(); - } //-- int getSequenceCount() + } + + //-- int getSequenceCount() /** * Method hasAligned - * - * - * + * + * + * * @return boolean */ public boolean hasAligned() { return this._has_aligned; - } //-- boolean hasAligned() + } + + //-- boolean hasAligned() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllAnnotation - * + * */ public void removeAllAnnotation() { _annotationList.removeAllElements(); - } //-- void removeAllAnnotation() + } + + //-- void removeAllAnnotation() /** * Method removeAllSequence - * + * */ public void removeAllSequence() { _sequenceList.removeAllElements(); - } //-- void removeAllSequence() + } + + //-- void removeAllSequence() /** * Method removeAnnotation - * - * - * + * + * + * * @param index * @return Annotation */ @@ -369,14 +420,17 @@ public class SequenceSet implements java.io.Serializable { { java.lang.Object obj = _annotationList.elementAt(index); _annotationList.removeElementAt(index); + return (jalview.binding.Annotation) obj; - } //-- jalview.binding.Annotation removeAnnotation(int) + } + + //-- jalview.binding.Annotation removeAnnotation(int) /** * Method removeSequence - * - * - * + * + * + * * @param index * @return Sequence */ @@ -384,25 +438,30 @@ public class SequenceSet implements java.io.Serializable { { java.lang.Object obj = _sequenceList.elementAt(index); _sequenceList.removeElementAt(index); + return (jalview.binding.Sequence) obj; - } //-- jalview.binding.Sequence removeSequence(int) + } + + //-- jalview.binding.Sequence removeSequence(int) /** * Sets the value of field 'aligned'. - * + * * @param aligned the value of field 'aligned'. */ public void setAligned(boolean aligned) { this._aligned = aligned; this._has_aligned = true; - } //-- void setAligned(boolean) + } + + //-- void setAligned(boolean) /** * Method setAnnotation - * - * - * + * + * + * * @param index * @param vAnnotation */ @@ -410,43 +469,53 @@ public class SequenceSet implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _annotationList.size())) { + if ((index < 0) || (index > _annotationList.size())) + { throw new IndexOutOfBoundsException(); } + _annotationList.setElementAt(vAnnotation, index); - } //-- void setAnnotation(int, jalview.binding.Annotation) + } + + //-- void setAnnotation(int, jalview.binding.Annotation) /** * Method setAnnotation - * - * - * + * + * + * * @param annotationArray */ public void setAnnotation(jalview.binding.Annotation[] annotationArray) { //-- copy array _annotationList.removeAllElements(); - for (int i = 0; i < annotationArray.length; i++) { + + for (int i = 0; i < annotationArray.length; i++) + { _annotationList.addElement(annotationArray[i]); } - } //-- void setAnnotation(jalview.binding.Annotation) + } + + //-- void setAnnotation(jalview.binding.Annotation) /** * Sets the value of field 'gapChar'. - * + * * @param gapChar the value of field 'gapChar'. */ public void setGapChar(java.lang.String gapChar) { this._gapChar = gapChar; - } //-- void setGapChar(java.lang.String) + } + + //-- void setGapChar(java.lang.String) /** * Method setSequence - * - * - * + * + * + * * @param index * @param vSequence */ @@ -454,51 +523,63 @@ public class SequenceSet implements java.io.Serializable { throws java.lang.IndexOutOfBoundsException { //-- check bounds for index - if ((index < 0) || (index > _sequenceList.size())) { + if ((index < 0) || (index > _sequenceList.size())) + { throw new IndexOutOfBoundsException(); } + _sequenceList.setElementAt(vSequence, index); - } //-- void setSequence(int, jalview.binding.Sequence) + } + + //-- void setSequence(int, jalview.binding.Sequence) /** * Method setSequence - * - * - * + * + * + * * @param sequenceArray */ public void setSequence(jalview.binding.Sequence[] sequenceArray) { //-- copy array _sequenceList.removeAllElements(); - for (int i = 0; i < sequenceArray.length; i++) { + + for (int i = 0; i < sequenceArray.length; i++) + { _sequenceList.addElement(sequenceArray[i]); } - } //-- void setSequence(jalview.binding.Sequence) + } + + //-- void setSequence(jalview.binding.Sequence) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/SequenceType.java b/src/jalview/binding/SequenceType.java index 3a935e4..780c8ba 100755 --- a/src/jalview/binding/SequenceType.java +++ b/src/jalview/binding/SequenceType.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,193 +7,192 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class SequenceType. - * + * * @version $Revision$ $Date$ */ -public class SequenceType implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id - */ - private java.lang.String _id; - - /** - * Field _sequence - */ - private java.lang.String _sequence; - - /** - * Field _name - */ - private java.lang.String _name; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public SequenceType() { - super(); - } //-- jalview.binding.SequenceType() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'id'. - * - * @return String - * @return the value of field 'id'. - */ - public java.lang.String getId() - { - return this._id; - } //-- java.lang.String getId() - - /** - * Returns the value of field 'name'. - * - * @return String - * @return the value of field 'name'. - */ - public java.lang.String getName() - { - return this._name; - } //-- java.lang.String getName() - - /** - * Returns the value of field 'sequence'. - * - * @return String - * @return the value of field 'sequence'. - */ - public java.lang.String getSequence() - { - return this._sequence; - } //-- java.lang.String getSequence() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId(java.lang.String id) - { - this._id = id; - } //-- void setId(java.lang.String) - - /** - * Sets the value of field 'name'. - * - * @param name the value of field 'name'. - */ - public void setName(java.lang.String name) - { - this._name = name; - } //-- void setName(java.lang.String) - - /** - * Sets the value of field 'sequence'. - * - * @param sequence the value of field 'sequence'. - */ - public void setSequence(java.lang.String sequence) - { - this._sequence = sequence; - } //-- void setSequence(java.lang.String) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException +public class SequenceType + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _id + */ + private java.lang.String _id; + + /** + * Field _sequence + */ + private java.lang.String _sequence; + + /** + * Field _name + */ + private java.lang.String _name; + + //----------------/ + //- Constructors -/ + //----------------/ + + public SequenceType() + { + super(); + } //-- jalview.binding.SequenceType() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Returns the value of field 'id'. + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'name'. + * + * @return String + * @return the value of field 'name'. + */ + public java.lang.String getName() + { + return this._name; + } //-- java.lang.String getName() + + /** + * Returns the value of field 'sequence'. + * + * @return String + * @return the value of field 'sequence'. + */ + public java.lang.String getSequence() + { + return this._sequence; + } //-- java.lang.String getSequence() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { - return (jalview.binding.SequenceType) Unmarshaller.unmarshal(jalview.binding.SequenceType.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'id'. + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'name'. + * + * @param name the value of field 'name'. + */ + public void setName(java.lang.String name) + { + this._name = name; + } //-- void setName(java.lang.String) + + /** + * Sets the value of field 'sequence'. + * + * @param sequence the value of field 'sequence'. + */ + public void setSequence(java.lang.String sequence) + { + this._sequence = sequence; + } //-- void setSequence(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.SequenceType) Unmarshaller.unmarshal(jalview. + binding.SequenceType.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/Tree.java b/src/jalview/binding/Tree.java index 2821029..9fc63d2 100755 --- a/src/jalview/binding/Tree.java +++ b/src/jalview/binding/Tree.java @@ -1,36 +1,36 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; + import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; + + /** * Class Tree. - * + * * @version $Revision$ $Date$ */ -public class Tree implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ +public class Tree implements java.io.Serializable +{ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -153,604 +153,709 @@ public class Tree implements java.io.Serializable { */ private java.lang.String _newick; - - //----------------/ - //- Constructors -/ //----------------/ - - public Tree() { + //- Constructors -/ + //----------------/ + public Tree() + { super(); - } //-- jalview.binding.Tree() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.Tree() //-----------/ /** - * Method deleteCurrentTree - * + * DOCUMENT ME! */ public void deleteCurrentTree() { - this._has_currentTree= false; - } //-- void deleteCurrentTree() + this._has_currentTree = false; + } + + //-- void deleteCurrentTree() /** * Method deleteFitToWindow - * + * */ public void deleteFitToWindow() { - this._has_fitToWindow= false; - } //-- void deleteFitToWindow() + this._has_fitToWindow = false; + } + + //-- void deleteFitToWindow() /** * Method deleteFontSize - * + * */ public void deleteFontSize() { - this._has_fontSize= false; - } //-- void deleteFontSize() + this._has_fontSize = false; + } + + //-- void deleteFontSize() /** * Method deleteHeight - * + * */ public void deleteHeight() { - this._has_height= false; - } //-- void deleteHeight() + this._has_height = false; + } + + //-- void deleteHeight() /** * Method deleteMarkUnlinked - * + * */ public void deleteMarkUnlinked() { - this._has_markUnlinked= false; - } //-- void deleteMarkUnlinked() + this._has_markUnlinked = false; + } + + //-- void deleteMarkUnlinked() /** * Method deleteShowBootstrap - * + * */ public void deleteShowBootstrap() { - this._has_showBootstrap= false; - } //-- void deleteShowBootstrap() + this._has_showBootstrap = false; + } + + //-- void deleteShowBootstrap() /** * Method deleteShowDistances - * + * */ public void deleteShowDistances() { - this._has_showDistances= false; - } //-- void deleteShowDistances() + this._has_showDistances = false; + } + + //-- void deleteShowDistances() /** * Method deleteThreshold - * + * */ public void deleteThreshold() { - this._has_threshold= false; - } //-- void deleteThreshold() + this._has_threshold = false; + } + + //-- void deleteThreshold() /** * Method deleteWidth - * + * */ public void deleteWidth() { - this._has_width= false; - } //-- void deleteWidth() + this._has_width = false; + } + + //-- void deleteWidth() /** * Method deleteXpos - * + * */ public void deleteXpos() { - this._has_xpos= false; - } //-- void deleteXpos() + this._has_xpos = false; + } + + //-- void deleteXpos() /** * Method deleteYpos - * + * */ public void deleteYpos() { - this._has_ypos= false; - } //-- void deleteYpos() + this._has_ypos = false; + } + + //-- void deleteYpos() /** * Returns the value of field 'currentTree'. - * + * * @return boolean * @return the value of field 'currentTree'. */ public boolean getCurrentTree() { return this._currentTree; - } //-- boolean getCurrentTree() + } + + //-- boolean getCurrentTree() /** * Returns the value of field 'fitToWindow'. - * + * * @return boolean * @return the value of field 'fitToWindow'. */ public boolean getFitToWindow() { return this._fitToWindow; - } //-- boolean getFitToWindow() + } + + //-- boolean getFitToWindow() /** * Returns the value of field 'fontSize'. - * + * * @return int * @return the value of field 'fontSize'. */ public int getFontSize() { return this._fontSize; - } //-- int getFontSize() + } + + //-- int getFontSize() /** * Returns the value of field 'height'. - * + * * @return int * @return the value of field 'height'. */ public int getHeight() { return this._height; - } //-- int getHeight() + } + + //-- int getHeight() /** * Returns the value of field 'markUnlinked'. - * + * * @return boolean * @return the value of field 'markUnlinked'. */ public boolean getMarkUnlinked() { return this._markUnlinked; - } //-- boolean getMarkUnlinked() + } + + //-- boolean getMarkUnlinked() /** * Returns the value of field 'newick'. - * + * * @return String * @return the value of field 'newick'. */ public java.lang.String getNewick() { return this._newick; - } //-- java.lang.String getNewick() + } + + //-- java.lang.String getNewick() /** * Returns the value of field 'showBootstrap'. - * + * * @return boolean * @return the value of field 'showBootstrap'. */ public boolean getShowBootstrap() { return this._showBootstrap; - } //-- boolean getShowBootstrap() + } + + //-- boolean getShowBootstrap() /** * Returns the value of field 'showDistances'. - * + * * @return boolean * @return the value of field 'showDistances'. */ public boolean getShowDistances() { return this._showDistances; - } //-- boolean getShowDistances() + } + + //-- boolean getShowDistances() /** * Returns the value of field 'threshold'. - * + * * @return float * @return the value of field 'threshold'. */ public float getThreshold() { return this._threshold; - } //-- float getThreshold() + } + + //-- float getThreshold() /** * Returns the value of field 'title'. - * + * * @return String * @return the value of field 'title'. */ public java.lang.String getTitle() { return this._title; - } //-- java.lang.String getTitle() + } + + //-- java.lang.String getTitle() /** * Returns the value of field 'width'. - * + * * @return int * @return the value of field 'width'. */ public int getWidth() { return this._width; - } //-- int getWidth() + } + + //-- int getWidth() /** * Returns the value of field 'xpos'. - * + * * @return int * @return the value of field 'xpos'. */ public int getXpos() { return this._xpos; - } //-- int getXpos() + } + + //-- int getXpos() /** * Returns the value of field 'ypos'. - * + * * @return int * @return the value of field 'ypos'. */ public int getYpos() { return this._ypos; - } //-- int getYpos() + } + + //-- int getYpos() /** * Method hasCurrentTree - * - * - * + * + * + * * @return boolean */ public boolean hasCurrentTree() { return this._has_currentTree; - } //-- boolean hasCurrentTree() + } + + //-- boolean hasCurrentTree() /** * Method hasFitToWindow - * - * - * + * + * + * * @return boolean */ public boolean hasFitToWindow() { return this._has_fitToWindow; - } //-- boolean hasFitToWindow() + } + + //-- boolean hasFitToWindow() /** * Method hasFontSize - * - * - * + * + * + * * @return boolean */ public boolean hasFontSize() { return this._has_fontSize; - } //-- boolean hasFontSize() + } + + //-- boolean hasFontSize() /** * Method hasHeight - * - * - * + * + * + * * @return boolean */ public boolean hasHeight() { return this._has_height; - } //-- boolean hasHeight() + } + + //-- boolean hasHeight() /** * Method hasMarkUnlinked - * - * - * + * + * + * * @return boolean */ public boolean hasMarkUnlinked() { return this._has_markUnlinked; - } //-- boolean hasMarkUnlinked() + } + + //-- boolean hasMarkUnlinked() /** * Method hasShowBootstrap - * - * - * + * + * + * * @return boolean */ public boolean hasShowBootstrap() { return this._has_showBootstrap; - } //-- boolean hasShowBootstrap() + } + + //-- boolean hasShowBootstrap() /** * Method hasShowDistances - * - * - * + * + * + * * @return boolean */ public boolean hasShowDistances() { return this._has_showDistances; - } //-- boolean hasShowDistances() + } + + //-- boolean hasShowDistances() /** * Method hasThreshold - * - * - * + * + * + * * @return boolean */ public boolean hasThreshold() { return this._has_threshold; - } //-- boolean hasThreshold() + } + + //-- boolean hasThreshold() /** * Method hasWidth - * - * - * + * + * + * * @return boolean */ public boolean hasWidth() { return this._has_width; - } //-- boolean hasWidth() + } + + //-- boolean hasWidth() /** * Method hasXpos - * - * - * + * + * + * * @return boolean */ public boolean hasXpos() { return this._has_xpos; - } //-- boolean hasXpos() + } + + //-- boolean hasXpos() /** * Method hasYpos - * - * - * + * + * + * * @return boolean */ public boolean hasYpos() { return this._has_ypos; - } //-- boolean hasYpos() + } + + //-- boolean hasYpos() /** * Method isValid - * - * - * + * + * + * * @return boolean */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Sets the value of field 'currentTree'. - * + * * @param currentTree the value of field 'currentTree'. */ public void setCurrentTree(boolean currentTree) { this._currentTree = currentTree; this._has_currentTree = true; - } //-- void setCurrentTree(boolean) + } + + //-- void setCurrentTree(boolean) /** * Sets the value of field 'fitToWindow'. - * + * * @param fitToWindow the value of field 'fitToWindow'. */ public void setFitToWindow(boolean fitToWindow) { this._fitToWindow = fitToWindow; this._has_fitToWindow = true; - } //-- void setFitToWindow(boolean) + } + + //-- void setFitToWindow(boolean) /** * Sets the value of field 'fontSize'. - * + * * @param fontSize the value of field 'fontSize'. */ public void setFontSize(int fontSize) { this._fontSize = fontSize; this._has_fontSize = true; - } //-- void setFontSize(int) + } + + //-- void setFontSize(int) /** * Sets the value of field 'height'. - * + * * @param height the value of field 'height'. */ public void setHeight(int height) { this._height = height; this._has_height = true; - } //-- void setHeight(int) + } + + //-- void setHeight(int) /** * Sets the value of field 'markUnlinked'. - * + * * @param markUnlinked the value of field 'markUnlinked'. */ public void setMarkUnlinked(boolean markUnlinked) { this._markUnlinked = markUnlinked; this._has_markUnlinked = true; - } //-- void setMarkUnlinked(boolean) + } + + //-- void setMarkUnlinked(boolean) /** * Sets the value of field 'newick'. - * + * * @param newick the value of field 'newick'. */ public void setNewick(java.lang.String newick) { this._newick = newick; - } //-- void setNewick(java.lang.String) + } + + //-- void setNewick(java.lang.String) /** * Sets the value of field 'showBootstrap'. - * + * * @param showBootstrap the value of field 'showBootstrap'. */ public void setShowBootstrap(boolean showBootstrap) { this._showBootstrap = showBootstrap; this._has_showBootstrap = true; - } //-- void setShowBootstrap(boolean) + } + + //-- void setShowBootstrap(boolean) /** * Sets the value of field 'showDistances'. - * + * * @param showDistances the value of field 'showDistances'. */ public void setShowDistances(boolean showDistances) { this._showDistances = showDistances; this._has_showDistances = true; - } //-- void setShowDistances(boolean) + } + + //-- void setShowDistances(boolean) /** * Sets the value of field 'threshold'. - * + * * @param threshold the value of field 'threshold'. */ public void setThreshold(float threshold) { this._threshold = threshold; this._has_threshold = true; - } //-- void setThreshold(float) + } + + //-- void setThreshold(float) /** * Sets the value of field 'title'. - * + * * @param title the value of field 'title'. */ public void setTitle(java.lang.String title) { this._title = title; - } //-- void setTitle(java.lang.String) + } + + //-- void setTitle(java.lang.String) /** * Sets the value of field 'width'. - * + * * @param width the value of field 'width'. */ public void setWidth(int width) { this._width = width; this._has_width = true; - } //-- void setWidth(int) + } + + //-- void setWidth(int) /** * Sets the value of field 'xpos'. - * + * * @param xpos the value of field 'xpos'. */ public void setXpos(int xpos) { this._xpos = xpos; this._has_xpos = true; - } //-- void setXpos(int) + } + + //-- void setXpos(int) /** * Sets the value of field 'ypos'. - * + * * @param ypos the value of field 'ypos'. */ public void setYpos(int ypos) { this._ypos = ypos; this._has_ypos = true; - } //-- void setYpos(int) + } + + //-- void setYpos(int) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.Tree) Unmarshaller.unmarshal(jalview.binding.Tree.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.Tree) Unmarshaller.unmarshal(jalview.binding.Tree.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/UserColour.java b/src/jalview/binding/UserColour.java index 837d9af..1d27451 100755 --- a/src/jalview/binding/UserColour.java +++ b/src/jalview/binding/UserColour.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,194 +7,194 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class UserColour. - * + * * @version $Revision$ $Date$ */ -public class UserColour implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id - */ - private int _id; - - /** - * keeps track of state for field: _id - */ - private boolean _has_id; - - /** - * Field _userColourScheme - */ - private jalview.binding.UserColourScheme _userColourScheme; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public UserColour() { - super(); - } //-- jalview.binding.UserColour() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method deleteId - * - */ - public void deleteId() - { - this._has_id= false; - } //-- void deleteId() - - /** - * Returns the value of field 'id'. - * - * @return int - * @return the value of field 'id'. - */ - public int getId() - { - return this._id; - } //-- int getId() - - /** - * Returns the value of field 'userColourScheme'. - * - * @return UserColourScheme - * @return the value of field 'userColourScheme'. - */ - public jalview.binding.UserColourScheme getUserColourScheme() - { - return this._userColourScheme; - } //-- jalview.binding.UserColourScheme getUserColourScheme() - - /** - * Method hasId - * - * - * - * @return boolean - */ - public boolean hasId() - { - return this._has_id; - } //-- boolean hasId() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId(int id) - { - this._id = id; - this._has_id = true; - } //-- void setId(int) - - /** - * Sets the value of field 'userColourScheme'. - * - * @param userColourScheme the value of field 'userColourScheme' - */ - public void setUserColourScheme(jalview.binding.UserColourScheme userColourScheme) - { - this._userColourScheme = userColourScheme; - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException +public class UserColour + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _id + */ + private int _id; + + /** + * keeps track of state for field: _id + */ + private boolean _has_id; + + /** + * Field _userColourScheme + */ + private jalview.binding.UserColourScheme _userColourScheme; + + //----------------/ + //- Constructors -/ + //----------------/ + + public UserColour() + { + super(); + } //-- jalview.binding.UserColour() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteId + * + */ + public void deleteId() + { + this._has_id = false; + } //-- void deleteId() + + /** + * Returns the value of field 'id'. + * + * @return int + * @return the value of field 'id'. + */ + public int getId() + { + return this._id; + } //-- int getId() + + /** + * Returns the value of field 'userColourScheme'. + * + * @return UserColourScheme + * @return the value of field 'userColourScheme'. + */ + public jalview.binding.UserColourScheme getUserColourScheme() + { + return this._userColourScheme; + } //-- jalview.binding.UserColourScheme getUserColourScheme() + + /** + * Method hasId + * + * + * + * @return boolean + */ + public boolean hasId() + { + return this._has_id; + } //-- boolean hasId() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { - return (jalview.binding.UserColour) Unmarshaller.unmarshal(jalview.binding.UserColour.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'id'. + * + * @param id the value of field 'id'. + */ + public void setId(int id) + { + this._id = id; + this._has_id = true; + } //-- void setId(int) + + /** + * Sets the value of field 'userColourScheme'. + * + * @param userColourScheme the value of field 'userColourScheme' + */ + public void setUserColourScheme(jalview.binding.UserColourScheme + userColourScheme) + { + this._userColourScheme = userColourScheme; + } //-- void setUserColourScheme(jalview.binding.UserColourScheme) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.UserColour) Unmarshaller.unmarshal(jalview.binding. + UserColour.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/UserColourScheme.java b/src/jalview/binding/UserColourScheme.java index 79ea637..6d6c265 100755 --- a/src/jalview/binding/UserColourScheme.java +++ b/src/jalview/binding/UserColourScheme.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,112 +7,110 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class UserColourScheme. - * + * * @version $Revision$ $Date$ */ -public class UserColourScheme extends JalviewUserColours -implements java.io.Serializable +public class UserColourScheme + extends JalviewUserColours implements java.io.Serializable { + //----------------/ + //- Constructors -/ + //----------------/ - //----------------/ - //- Constructors -/ - //----------------/ + public UserColourScheme() + { + super(); + } //-- jalview.binding.UserColourScheme() - public UserColourScheme() { - super(); - } //-- jalview.binding.UserColourScheme() + //-----------/ + //- Methods -/ + //-----------/ + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try + { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } //-- boolean isValid() - //-----------/ - //- Methods -/ - //-----------/ + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.binding.UserColourScheme) Unmarshaller.unmarshal(jalview.binding.UserColourScheme.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.UserColourScheme) Unmarshaller.unmarshal(jalview. + binding.UserColourScheme.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/UserColours.java b/src/jalview/binding/UserColours.java index 241aaab..f00e341 100755 --- a/src/jalview/binding/UserColours.java +++ b/src/jalview/binding/UserColours.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,167 +7,167 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class UserColours. - * + * * @version $Revision$ $Date$ */ -public class UserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _id - */ - private java.lang.String _id; - - /** - * Field _userColourScheme - */ - private jalview.binding.UserColourScheme _userColourScheme; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public UserColours() { - super(); - } //-- jalview.binding.UserColours() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'id'. - * - * @return String - * @return the value of field 'id'. - */ - public java.lang.String getId() - { - return this._id; - } //-- java.lang.String getId() - - /** - * Returns the value of field 'userColourScheme'. - * - * @return UserColourScheme - * @return the value of field 'userColourScheme'. - */ - public jalview.binding.UserColourScheme getUserColourScheme() - { - return this._userColourScheme; - } //-- jalview.binding.UserColourScheme getUserColourScheme() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Sets the value of field 'id'. - * - * @param id the value of field 'id'. - */ - public void setId(java.lang.String id) - { - this._id = id; - } //-- void setId(java.lang.String) - - /** - * Sets the value of field 'userColourScheme'. - * - * @param userColourScheme the value of field 'userColourScheme' - */ - public void setUserColourScheme(jalview.binding.UserColourScheme userColourScheme) - { - this._userColourScheme = userColourScheme; - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException +public class UserColours + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _id + */ + private java.lang.String _id; + + /** + * Field _userColourScheme + */ + private jalview.binding.UserColourScheme _userColourScheme; + + //----------------/ + //- Constructors -/ + //----------------/ + + public UserColours() + { + super(); + } //-- jalview.binding.UserColours() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Returns the value of field 'id'. + * + * @return String + * @return the value of field 'id'. + */ + public java.lang.String getId() + { + return this._id; + } //-- java.lang.String getId() + + /** + * Returns the value of field 'userColourScheme'. + * + * @return UserColourScheme + * @return the value of field 'userColourScheme'. + */ + public jalview.binding.UserColourScheme getUserColourScheme() + { + return this._userColourScheme; + } //-- jalview.binding.UserColourScheme getUserColourScheme() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { - return (jalview.binding.UserColours) Unmarshaller.unmarshal(jalview.binding.UserColours.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'id'. + * + * @param id the value of field 'id'. + */ + public void setId(java.lang.String id) + { + this._id = id; + } //-- void setId(java.lang.String) + + /** + * Sets the value of field 'userColourScheme'. + * + * @param userColourScheme the value of field 'userColourScheme' + */ + public void setUserColourScheme(jalview.binding.UserColourScheme + userColourScheme) + { + this._userColourScheme = userColourScheme; + } //-- void setUserColourScheme(jalview.binding.UserColourScheme) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.UserColours) Unmarshaller.unmarshal(jalview.binding. + UserColours.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/VAMSAS.java b/src/jalview/binding/VAMSAS.java index b4237b8..037bd3d 100755 --- a/src/jalview/binding/VAMSAS.java +++ b/src/jalview/binding/VAMSAS.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,570 +7,585 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ //---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ + +import java.util.*; -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import java.util.Enumeration; -import java.util.Vector; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class VAMSAS. - * + * * @version $Revision$ $Date$ */ -public class VAMSAS implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _alignmentList - */ - private java.util.Vector _alignmentList; - - /** - * Field _treeList - */ - private java.util.Vector _treeList; - - /** - * Field _sequenceSetList - */ - private java.util.Vector _sequenceSetList; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public VAMSAS() { - super(); - _alignmentList = new Vector(); - _treeList = new Vector(); - _sequenceSetList = new Vector(); - } //-- jalview.binding.VAMSAS() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addAlignment - * - * - * - * @param vAlignment - */ - public void addAlignment(jalview.binding.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException - { - _alignmentList.addElement(vAlignment); - } //-- void addAlignment(jalview.binding.Alignment) - - /** - * Method addAlignment - * - * - * - * @param index - * @param vAlignment - */ - public void addAlignment(int index, jalview.binding.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException - { - _alignmentList.insertElementAt(vAlignment, index); - } //-- void addAlignment(int, jalview.binding.Alignment) - - /** - * Method addSequenceSet - * - * - * - * @param vSequenceSet - */ - public void addSequenceSet(jalview.binding.SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException - { - _sequenceSetList.addElement(vSequenceSet); - } //-- void addSequenceSet(jalview.binding.SequenceSet) - - /** - * Method addSequenceSet - * - * - * - * @param index - * @param vSequenceSet - */ - public void addSequenceSet(int index, jalview.binding.SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException - { - _sequenceSetList.insertElementAt(vSequenceSet, index); - } //-- void addSequenceSet(int, jalview.binding.SequenceSet) - - /** - * Method addTree - * - * - * - * @param vTree - */ - public void addTree(java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException - { - _treeList.addElement(vTree); - } //-- void addTree(java.lang.String) - - /** - * Method addTree - * - * - * - * @param index - * @param vTree - */ - public void addTree(int index, java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException - { - _treeList.insertElementAt(vTree, index); - } //-- void addTree(int, java.lang.String) - - /** - * Method enumerateAlignment - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateAlignment() - { - return _alignmentList.elements(); - } //-- java.util.Enumeration enumerateAlignment() - - /** - * Method enumerateSequenceSet - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateSequenceSet() - { - return _sequenceSetList.elements(); - } //-- java.util.Enumeration enumerateSequenceSet() - - /** - * Method enumerateTree - * - * - * - * @return Enumeration - */ - public java.util.Enumeration enumerateTree() - { - return _treeList.elements(); - } //-- java.util.Enumeration enumerateTree() - - /** - * Method getAlignment - * - * - * - * @param index - * @return Alignment - */ - public jalview.binding.Alignment getAlignment(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _alignmentList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.Alignment) _alignmentList.elementAt(index); - } //-- jalview.binding.Alignment getAlignment(int) - - /** - * Method getAlignment - * - * - * - * @return Alignment - */ - public jalview.binding.Alignment[] getAlignment() - { - int size = _alignmentList.size(); - jalview.binding.Alignment[] mArray = new jalview.binding.Alignment[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.Alignment) _alignmentList.elementAt(index); - } - return mArray; - } //-- jalview.binding.Alignment[] getAlignment() - - /** - * Method getAlignmentCount - * - * - * - * @return int - */ - public int getAlignmentCount() - { - return _alignmentList.size(); - } //-- int getAlignmentCount() - - /** - * Method getSequenceSet - * - * - * - * @param index - * @return SequenceSet - */ - public jalview.binding.SequenceSet getSequenceSet(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _sequenceSetList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (jalview.binding.SequenceSet) _sequenceSetList.elementAt(index); - } //-- jalview.binding.SequenceSet getSequenceSet(int) - - /** - * Method getSequenceSet - * - * - * - * @return SequenceSet - */ - public jalview.binding.SequenceSet[] getSequenceSet() - { - int size = _sequenceSetList.size(); - jalview.binding.SequenceSet[] mArray = new jalview.binding.SequenceSet[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (jalview.binding.SequenceSet) _sequenceSetList.elementAt(index); - } - return mArray; - } //-- jalview.binding.SequenceSet[] getSequenceSet() - - /** - * Method getSequenceSetCount - * - * - * - * @return int - */ - public int getSequenceSetCount() - { - return _sequenceSetList.size(); - } //-- int getSequenceSetCount() - - /** - * Method getTree - * - * - * - * @param index - * @return String - */ - public java.lang.String getTree(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _treeList.size())) { - throw new IndexOutOfBoundsException(); - } - - return (String)_treeList.elementAt(index); - } //-- java.lang.String getTree(int) - - /** - * Method getTree - * - * - * - * @return String - */ - public java.lang.String[] getTree() - { - int size = _treeList.size(); - java.lang.String[] mArray = new java.lang.String[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (String)_treeList.elementAt(index); - } - return mArray; - } //-- java.lang.String[] getTree() - - /** - * Method getTreeCount - * - * - * - * @return int - */ - public int getTreeCount() - { - return _treeList.size(); - } //-- int getTreeCount() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Method removeAlignment - * - * - * - * @param index - * @return Alignment - */ - public jalview.binding.Alignment removeAlignment(int index) - { - java.lang.Object obj = _alignmentList.elementAt(index); - _alignmentList.removeElementAt(index); - return (jalview.binding.Alignment) obj; - } //-- jalview.binding.Alignment removeAlignment(int) - - /** - * Method removeAllAlignment - * - */ - public void removeAllAlignment() - { - _alignmentList.removeAllElements(); - } //-- void removeAllAlignment() - - /** - * Method removeAllSequenceSet - * - */ - public void removeAllSequenceSet() - { - _sequenceSetList.removeAllElements(); - } //-- void removeAllSequenceSet() - - /** - * Method removeAllTree - * - */ - public void removeAllTree() - { - _treeList.removeAllElements(); - } //-- void removeAllTree() - - /** - * Method removeSequenceSet - * - * - * - * @param index - * @return SequenceSet - */ - public jalview.binding.SequenceSet removeSequenceSet(int index) - { - java.lang.Object obj = _sequenceSetList.elementAt(index); - _sequenceSetList.removeElementAt(index); - return (jalview.binding.SequenceSet) obj; - } //-- jalview.binding.SequenceSet removeSequenceSet(int) - - /** - * Method removeTree - * - * - * - * @param index - * @return String - */ - public java.lang.String removeTree(int index) - { - java.lang.Object obj = _treeList.elementAt(index); - _treeList.removeElementAt(index); - return (String)obj; - } //-- java.lang.String removeTree(int) - - /** - * Method setAlignment - * - * - * - * @param index - * @param vAlignment - */ - public void setAlignment(int index, jalview.binding.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _alignmentList.size())) { - throw new IndexOutOfBoundsException(); - } - _alignmentList.setElementAt(vAlignment, index); - } //-- void setAlignment(int, jalview.binding.Alignment) - - /** - * Method setAlignment - * - * - * - * @param alignmentArray - */ - public void setAlignment(jalview.binding.Alignment[] alignmentArray) - { - //-- copy array - _alignmentList.removeAllElements(); - for (int i = 0; i < alignmentArray.length; i++) { - _alignmentList.addElement(alignmentArray[i]); - } - } //-- void setAlignment(jalview.binding.Alignment) - - /** - * Method setSequenceSet - * - * - * - * @param index - * @param vSequenceSet - */ - public void setSequenceSet(int index, jalview.binding.SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _sequenceSetList.size())) { - throw new IndexOutOfBoundsException(); - } - _sequenceSetList.setElementAt(vSequenceSet, index); - } //-- void setSequenceSet(int, jalview.binding.SequenceSet) - - /** - * Method setSequenceSet - * - * - * - * @param sequenceSetArray - */ - public void setSequenceSet(jalview.binding.SequenceSet[] sequenceSetArray) - { - //-- copy array - _sequenceSetList.removeAllElements(); - for (int i = 0; i < sequenceSetArray.length; i++) { - _sequenceSetList.addElement(sequenceSetArray[i]); - } - } //-- void setSequenceSet(jalview.binding.SequenceSet) - - /** - * Method setTree - * - * - * - * @param index - * @param vTree - */ - public void setTree(int index, java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _treeList.size())) { - throw new IndexOutOfBoundsException(); - } - _treeList.setElementAt(vTree, index); - } //-- void setTree(int, java.lang.String) - - /** - * Method setTree - * - * - * - * @param treeArray - */ - public void setTree(java.lang.String[] treeArray) - { - //-- copy array - _treeList.removeAllElements(); - for (int i = 0; i < treeArray.length; i++) { - _treeList.addElement(treeArray[i]); - } - } //-- void setTree(java.lang.String) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(jalview.binding.VAMSAS.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() +public class VAMSAS + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _alignmentList + */ + private java.util.Vector _alignmentList; + + /** + * Field _treeList + */ + private java.util.Vector _treeList; + + /** + * Field _sequenceSetList + */ + private java.util.Vector _sequenceSetList; + + //----------------/ + //- Constructors -/ + //----------------/ + + public VAMSAS() + { + super(); + _alignmentList = new Vector(); + _treeList = new Vector(); + _sequenceSetList = new Vector(); + } //-- jalview.binding.VAMSAS() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method addAlignment + * + * + * + * @param vAlignment + */ + public void addAlignment(jalview.binding.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + _alignmentList.addElement(vAlignment); + } //-- void addAlignment(jalview.binding.Alignment) + + /** + * Method addAlignment + * + * + * + * @param index + * @param vAlignment + */ + public void addAlignment(int index, jalview.binding.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + _alignmentList.insertElementAt(vAlignment, index); + } //-- void addAlignment(int, jalview.binding.Alignment) + + /** + * Method addSequenceSet + * + * + * + * @param vSequenceSet + */ + public void addSequenceSet(jalview.binding.SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException + { + _sequenceSetList.addElement(vSequenceSet); + } //-- void addSequenceSet(jalview.binding.SequenceSet) + + /** + * Method addSequenceSet + * + * + * + * @param index + * @param vSequenceSet + */ + public void addSequenceSet(int index, + jalview.binding.SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException + { + _sequenceSetList.insertElementAt(vSequenceSet, index); + } //-- void addSequenceSet(int, jalview.binding.SequenceSet) + + /** + * Method addTree + * + * + * + * @param vTree + */ + public void addTree(java.lang.String vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.addElement(vTree); + } //-- void addTree(java.lang.String) + + /** + * Method addTree + * + * + * + * @param index + * @param vTree + */ + public void addTree(int index, java.lang.String vTree) + throws java.lang.IndexOutOfBoundsException + { + _treeList.insertElementAt(vTree, index); + } //-- void addTree(int, java.lang.String) + + /** + * Method enumerateAlignment + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateAlignment() + { + return _alignmentList.elements(); + } //-- java.util.Enumeration enumerateAlignment() + + /** + * Method enumerateSequenceSet + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateSequenceSet() + { + return _sequenceSetList.elements(); + } //-- java.util.Enumeration enumerateSequenceSet() + + /** + * Method enumerateTree + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateTree() + { + return _treeList.elements(); + } //-- java.util.Enumeration enumerateTree() + + /** + * Method getAlignment + * + * + * + * @param index + * @return Alignment + */ + public jalview.binding.Alignment getAlignment(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _alignmentList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.Alignment) _alignmentList.elementAt(index); + } //-- jalview.binding.Alignment getAlignment(int) + + /** + * Method getAlignment + * + * + * + * @return Alignment + */ + public jalview.binding.Alignment[] getAlignment() + { + int size = _alignmentList.size(); + jalview.binding.Alignment[] mArray = new jalview.binding.Alignment[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.Alignment) _alignmentList.elementAt( + index); + } + return mArray; + } //-- jalview.binding.Alignment[] getAlignment() + + /** + * Method getAlignmentCount + * + * + * + * @return int + */ + public int getAlignmentCount() + { + return _alignmentList.size(); + } //-- int getAlignmentCount() + + /** + * Method getSequenceSet + * + * + * + * @param index + * @return SequenceSet + */ + public jalview.binding.SequenceSet getSequenceSet(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _sequenceSetList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (jalview.binding.SequenceSet) _sequenceSetList.elementAt(index); + } //-- jalview.binding.SequenceSet getSequenceSet(int) + + /** + * Method getSequenceSet + * + * + * + * @return SequenceSet + */ + public jalview.binding.SequenceSet[] getSequenceSet() + { + int size = _sequenceSetList.size(); + jalview.binding.SequenceSet[] mArray = new jalview.binding.SequenceSet[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (jalview.binding.SequenceSet) _sequenceSetList.elementAt( + index); + } + return mArray; + } //-- jalview.binding.SequenceSet[] getSequenceSet() + + /** + * Method getSequenceSetCount + * + * + * + * @return int + */ + public int getSequenceSetCount() + { + return _sequenceSetList.size(); + } //-- int getSequenceSetCount() + + /** + * Method getTree + * + * + * + * @param index + * @return String + */ + public java.lang.String getTree(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _treeList.size())) + { + throw new IndexOutOfBoundsException(); + } + + return (String) _treeList.elementAt(index); + } //-- java.lang.String getTree(int) + + /** + * Method getTree + * + * + * + * @return String + */ + public java.lang.String[] getTree() + { + int size = _treeList.size(); + java.lang.String[] mArray = new java.lang.String[size]; + for (int index = 0; index < size; index++) + { + mArray[index] = (String) _treeList.elementAt(index); + } + return mArray; + } //-- java.lang.String[] getTree() + + /** + * Method getTreeCount + * + * + * + * @return int + */ + public int getTreeCount() + { + return _treeList.size(); + } //-- int getTreeCount() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try + { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Method removeAlignment + * + * + * + * @param index + * @return Alignment + */ + public jalview.binding.Alignment removeAlignment(int index) + { + java.lang.Object obj = _alignmentList.elementAt(index); + _alignmentList.removeElementAt(index); + return (jalview.binding.Alignment) obj; + } //-- jalview.binding.Alignment removeAlignment(int) + + /** + * Method removeAllAlignment + * + */ + public void removeAllAlignment() + { + _alignmentList.removeAllElements(); + } //-- void removeAllAlignment() + + /** + * Method removeAllSequenceSet + * + */ + public void removeAllSequenceSet() + { + _sequenceSetList.removeAllElements(); + } //-- void removeAllSequenceSet() + + /** + * Method removeAllTree + * + */ + public void removeAllTree() + { + _treeList.removeAllElements(); + } //-- void removeAllTree() + + /** + * Method removeSequenceSet + * + * + * + * @param index + * @return SequenceSet + */ + public jalview.binding.SequenceSet removeSequenceSet(int index) + { + java.lang.Object obj = _sequenceSetList.elementAt(index); + _sequenceSetList.removeElementAt(index); + return (jalview.binding.SequenceSet) obj; + } //-- jalview.binding.SequenceSet removeSequenceSet(int) + + /** + * Method removeTree + * + * + * + * @param index + * @return String + */ + public java.lang.String removeTree(int index) + { + java.lang.Object obj = _treeList.elementAt(index); + _treeList.removeElementAt(index); + return (String) obj; + } //-- java.lang.String removeTree(int) + + /** + * Method setAlignment + * + * + * + * @param index + * @param vAlignment + */ + public void setAlignment(int index, jalview.binding.Alignment vAlignment) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _alignmentList.size())) + { + throw new IndexOutOfBoundsException(); + } + _alignmentList.setElementAt(vAlignment, index); + } //-- void setAlignment(int, jalview.binding.Alignment) + + /** + * Method setAlignment + * + * + * + * @param alignmentArray + */ + public void setAlignment(jalview.binding.Alignment[] alignmentArray) + { + //-- copy array + _alignmentList.removeAllElements(); + for (int i = 0; i < alignmentArray.length; i++) + { + _alignmentList.addElement(alignmentArray[i]); + } + } //-- void setAlignment(jalview.binding.Alignment) + + /** + * Method setSequenceSet + * + * + * + * @param index + * @param vSequenceSet + */ + public void setSequenceSet(int index, + jalview.binding.SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _sequenceSetList.size())) + { + throw new IndexOutOfBoundsException(); + } + _sequenceSetList.setElementAt(vSequenceSet, index); + } //-- void setSequenceSet(int, jalview.binding.SequenceSet) + + /** + * Method setSequenceSet + * + * + * + * @param sequenceSetArray + */ + public void setSequenceSet(jalview.binding.SequenceSet[] sequenceSetArray) + { + //-- copy array + _sequenceSetList.removeAllElements(); + for (int i = 0; i < sequenceSetArray.length; i++) + { + _sequenceSetList.addElement(sequenceSetArray[i]); + } + } //-- void setSequenceSet(jalview.binding.SequenceSet) + + /** + * Method setTree + * + * + * + * @param index + * @param vTree + */ + public void setTree(int index, java.lang.String vTree) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ( (index < 0) || (index > _treeList.size())) + { + throw new IndexOutOfBoundsException(); + } + _treeList.setElementAt(vTree, index); + } //-- void setTree(int, java.lang.String) + + /** + * Method setTree + * + * + * + * @param treeArray + */ + public void setTree(java.lang.String[] treeArray) + { + //-- copy array + _treeList.removeAllElements(); + for (int i = 0; i < treeArray.length; i++) + { + _treeList.addElement(treeArray[i]); + } + } //-- void setTree(java.lang.String) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(jalview.binding. + VAMSAS.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/binding/VamsasModel.java b/src/jalview/binding/VamsasModel.java index a4d4362..74aa86e 100755 --- a/src/jalview/binding/VamsasModel.java +++ b/src/jalview/binding/VamsasModel.java @@ -1,118 +1,125 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ - package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.ValidationException; + import org.xml.sax.ContentHandler; +//---------------------------------/ +//- Imported classes and packages -/ +//---------------------------------/ +import java.io.IOException; +import java.io.Reader; +import java.io.Serializable; +import java.io.Writer; + + /** * Class VamsasModel. - * + * * @version $Revision$ $Date$ */ -public class VamsasModel extends VAMSAS -implements java.io.Serializable +public class VamsasModel extends VAMSAS implements java.io.Serializable { - - - //----------------/ - //- Constructors -/ //----------------/ - - public VamsasModel() { + //- Constructors -/ + //----------------/ + public VamsasModel() + { super(); - } //-- jalview.binding.VamsasModel() + } - - //-----------/ - //- Methods -/ + //-- jalview.binding.VamsasModel() //-----------/ /** - * Method isValid - * - * - * - * @return boolean + * DOCUMENT ME! + * + * @return DOCUMENT ME! */ public boolean isValid() { - try { + try + { validate(); } - catch (org.exolab.castor.xml.ValidationException vex) { + catch (org.exolab.castor.xml.ValidationException vex) + { return false; } + return true; - } //-- boolean isValid() + } + + //-- boolean isValid() /** * Method marshal - * - * - * + * + * + * * @param out */ public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) + } + + //-- void marshal(java.io.Writer) /** * Method marshal - * - * - * + * + * + * * @param handler */ public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) + } + + //-- void marshal(org.xml.sax.ContentHandler) /** * Method unmarshal - * - * - * + * + * + * * @param reader * @return Object */ public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException { - return (jalview.binding.VamsasModel) Unmarshaller.unmarshal(jalview.binding.VamsasModel.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + return (jalview.binding.VamsasModel) Unmarshaller.unmarshal(jalview.binding.VamsasModel.class, + reader); + } + + //-- java.lang.Object unmarshal(java.io.Reader) /** * Method validate - * + * */ - public void validate() - throws org.exolab.castor.xml.ValidationException + public void validate() throws org.exolab.castor.xml.ValidationException { org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); validator.validate(this); - } //-- void validate() + } + //-- void validate() } diff --git a/src/jalview/binding/Viewport.java b/src/jalview/binding/Viewport.java index 911061b..07622b3 100755 --- a/src/jalview/binding/Viewport.java +++ b/src/jalview/binding/Viewport.java @@ -1,5 +1,5 @@ /* - * This class was automatically generated with + * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ @@ -7,1414 +7,1413 @@ package jalview.binding; - //---------------------------------/ - //- Imported classes and packages -/ +//---------------------------------/ +//- Imported classes and packages -/ //---------------------------------/ -import java.io.IOException; -import java.io.Reader; -import java.io.Serializable; -import java.io.Writer; -import org.exolab.castor.xml.MarshalException; -import org.exolab.castor.xml.Marshaller; -import org.exolab.castor.xml.Unmarshaller; -import org.exolab.castor.xml.ValidationException; -import org.xml.sax.ContentHandler; +import org.exolab.castor.xml.*; /** * Class Viewport. - * + * * @version $Revision$ $Date$ */ -public class Viewport implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field _conservationSelected - */ - private boolean _conservationSelected; - - /** - * keeps track of state for field: _conservationSelected - */ - private boolean _has_conservationSelected; - - /** - * Field _pidSelected - */ - private boolean _pidSelected; - - /** - * keeps track of state for field: _pidSelected - */ - private boolean _has_pidSelected; - - /** - * Field _bgColour - */ - private java.lang.String _bgColour; - - /** - * Field _consThreshold - */ - private int _consThreshold; - - /** - * keeps track of state for field: _consThreshold - */ - private boolean _has_consThreshold; - - /** - * Field _pidThreshold - */ - private int _pidThreshold; - - /** - * keeps track of state for field: _pidThreshold - */ - private boolean _has_pidThreshold; - - /** - * Field _title - */ - private java.lang.String _title; - - /** - * Field _showFullId - */ - private boolean _showFullId; - - /** - * keeps track of state for field: _showFullId - */ - private boolean _has_showFullId; - - /** - * Field _showText - */ - private boolean _showText; - - /** - * keeps track of state for field: _showText - */ - private boolean _has_showText; - - /** - * Field _showColourText - */ - private boolean _showColourText; - - /** - * keeps track of state for field: _showColourText - */ - private boolean _has_showColourText; - - /** - * Field _showBoxes - */ - private boolean _showBoxes; - - /** - * keeps track of state for field: _showBoxes - */ - private boolean _has_showBoxes; - - /** - * Field _wrapAlignment - */ - private boolean _wrapAlignment; - - /** - * keeps track of state for field: _wrapAlignment - */ - private boolean _has_wrapAlignment; - - /** - * Field _renderGaps - */ - private boolean _renderGaps; - - /** - * keeps track of state for field: _renderGaps - */ - private boolean _has_renderGaps; - - /** - * Field _showSequenceFeatures - */ - private boolean _showSequenceFeatures; - - /** - * keeps track of state for field: _showSequenceFeatures - */ - private boolean _has_showSequenceFeatures; - - /** - * Field _showAnnotation - */ - private boolean _showAnnotation; - - /** - * keeps track of state for field: _showAnnotation - */ - private boolean _has_showAnnotation; - - /** - * Field _showConservation - */ - private boolean _showConservation; - - /** - * keeps track of state for field: _showConservation - */ - private boolean _has_showConservation; - - /** - * Field _showQuality - */ - private boolean _showQuality; - - /** - * keeps track of state for field: _showQuality - */ - private boolean _has_showQuality; - - /** - * Field _showIdentity - */ - private boolean _showIdentity; - - /** - * keeps track of state for field: _showIdentity - */ - private boolean _has_showIdentity; - - /** - * Field _xpos - */ - private int _xpos; - - /** - * keeps track of state for field: _xpos - */ - private boolean _has_xpos; - - /** - * Field _ypos - */ - private int _ypos; - - /** - * keeps track of state for field: _ypos - */ - private boolean _has_ypos; - - /** - * Field _width - */ - private int _width; - - /** - * keeps track of state for field: _width - */ - private boolean _has_width; - - /** - * Field _height - */ - private int _height; - - /** - * keeps track of state for field: _height - */ - private boolean _has_height; - - /** - * Field _startRes - */ - private int _startRes; - - /** - * keeps track of state for field: _startRes - */ - private boolean _has_startRes; - - /** - * Field _startSeq - */ - private int _startSeq; - - /** - * keeps track of state for field: _startSeq - */ - private boolean _has_startSeq; - - /** - * Field _fontName - */ - private java.lang.String _fontName; - - /** - * Field _fontSize - */ - private int _fontSize; - - /** - * keeps track of state for field: _fontSize - */ - private boolean _has_fontSize; - - /** - * Field _fontStyle - */ - private int _fontStyle; - - /** - * keeps track of state for field: _fontStyle - */ - private boolean _has_fontStyle; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public Viewport() { - super(); - } //-- jalview.binding.Viewport() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method deleteConsThreshold - * - */ - public void deleteConsThreshold() - { - this._has_consThreshold= false; - } //-- void deleteConsThreshold() - - /** - * Method deleteConservationSelected - * - */ - public void deleteConservationSelected() - { - this._has_conservationSelected= false; - } //-- void deleteConservationSelected() - - /** - * Method deleteFontSize - * - */ - public void deleteFontSize() - { - this._has_fontSize= false; - } //-- void deleteFontSize() - - /** - * Method deleteFontStyle - * - */ - public void deleteFontStyle() - { - this._has_fontStyle= false; - } //-- void deleteFontStyle() - - /** - * Method deleteHeight - * - */ - public void deleteHeight() - { - this._has_height= false; - } //-- void deleteHeight() - - /** - * Method deletePidSelected - * - */ - public void deletePidSelected() - { - this._has_pidSelected= false; - } //-- void deletePidSelected() - - /** - * Method deletePidThreshold - * - */ - public void deletePidThreshold() - { - this._has_pidThreshold= false; - } //-- void deletePidThreshold() - - /** - * Method deleteRenderGaps - * - */ - public void deleteRenderGaps() - { - this._has_renderGaps= false; - } //-- void deleteRenderGaps() - - /** - * Method deleteShowAnnotation - * - */ - public void deleteShowAnnotation() - { - this._has_showAnnotation= false; - } //-- void deleteShowAnnotation() - - /** - * Method deleteShowBoxes - * - */ - public void deleteShowBoxes() - { - this._has_showBoxes= false; - } //-- void deleteShowBoxes() - - /** - * Method deleteShowColourText - * - */ - public void deleteShowColourText() - { - this._has_showColourText= false; - } //-- void deleteShowColourText() - - /** - * Method deleteShowConservation - * - */ - public void deleteShowConservation() - { - this._has_showConservation= false; - } //-- void deleteShowConservation() - - /** - * Method deleteShowFullId - * - */ - public void deleteShowFullId() - { - this._has_showFullId= false; - } //-- void deleteShowFullId() - - /** - * Method deleteShowIdentity - * - */ - public void deleteShowIdentity() - { - this._has_showIdentity= false; - } //-- void deleteShowIdentity() - - /** - * Method deleteShowQuality - * - */ - public void deleteShowQuality() - { - this._has_showQuality= false; - } //-- void deleteShowQuality() - - /** - * Method deleteShowSequenceFeatures - * - */ - public void deleteShowSequenceFeatures() - { - this._has_showSequenceFeatures= false; - } //-- void deleteShowSequenceFeatures() - - /** - * Method deleteShowText - * - */ - public void deleteShowText() - { - this._has_showText= false; - } //-- void deleteShowText() - - /** - * Method deleteStartRes - * - */ - public void deleteStartRes() - { - this._has_startRes= false; - } //-- void deleteStartRes() - - /** - * Method deleteStartSeq - * - */ - public void deleteStartSeq() - { - this._has_startSeq= false; - } //-- void deleteStartSeq() - - /** - * Method deleteWidth - * - */ - public void deleteWidth() - { - this._has_width= false; - } //-- void deleteWidth() - - /** - * Method deleteWrapAlignment - * - */ - public void deleteWrapAlignment() - { - this._has_wrapAlignment= false; - } //-- void deleteWrapAlignment() - - /** - * Method deleteXpos - * - */ - public void deleteXpos() - { - this._has_xpos= false; - } //-- void deleteXpos() - - /** - * Method deleteYpos - * - */ - public void deleteYpos() - { - this._has_ypos= false; - } //-- void deleteYpos() - - /** - * Returns the value of field 'bgColour'. - * - * @return String - * @return the value of field 'bgColour'. - */ - public java.lang.String getBgColour() - { - return this._bgColour; - } //-- java.lang.String getBgColour() - - /** - * Returns the value of field 'consThreshold'. - * - * @return int - * @return the value of field 'consThreshold'. - */ - public int getConsThreshold() - { - return this._consThreshold; - } //-- int getConsThreshold() - - /** - * Returns the value of field 'conservationSelected'. - * - * @return boolean - * @return the value of field 'conservationSelected'. - */ - public boolean getConservationSelected() - { - return this._conservationSelected; - } //-- boolean getConservationSelected() - - /** - * Returns the value of field 'fontName'. - * - * @return String - * @return the value of field 'fontName'. - */ - public java.lang.String getFontName() - { - return this._fontName; - } //-- java.lang.String getFontName() - - /** - * Returns the value of field 'fontSize'. - * - * @return int - * @return the value of field 'fontSize'. - */ - public int getFontSize() - { - return this._fontSize; - } //-- int getFontSize() - - /** - * Returns the value of field 'fontStyle'. - * - * @return int - * @return the value of field 'fontStyle'. - */ - public int getFontStyle() - { - return this._fontStyle; - } //-- int getFontStyle() - - /** - * Returns the value of field 'height'. - * - * @return int - * @return the value of field 'height'. - */ - public int getHeight() - { - return this._height; - } //-- int getHeight() - - /** - * Returns the value of field 'pidSelected'. - * - * @return boolean - * @return the value of field 'pidSelected'. - */ - public boolean getPidSelected() - { - return this._pidSelected; - } //-- boolean getPidSelected() - - /** - * Returns the value of field 'pidThreshold'. - * - * @return int - * @return the value of field 'pidThreshold'. - */ - public int getPidThreshold() - { - return this._pidThreshold; - } //-- int getPidThreshold() - - /** - * Returns the value of field 'renderGaps'. - * - * @return boolean - * @return the value of field 'renderGaps'. - */ - public boolean getRenderGaps() - { - return this._renderGaps; - } //-- boolean getRenderGaps() - - /** - * Returns the value of field 'showAnnotation'. - * - * @return boolean - * @return the value of field 'showAnnotation'. - */ - public boolean getShowAnnotation() - { - return this._showAnnotation; - } //-- boolean getShowAnnotation() - - /** - * Returns the value of field 'showBoxes'. - * - * @return boolean - * @return the value of field 'showBoxes'. - */ - public boolean getShowBoxes() - { - return this._showBoxes; - } //-- boolean getShowBoxes() - - /** - * Returns the value of field 'showColourText'. - * - * @return boolean - * @return the value of field 'showColourText'. - */ - public boolean getShowColourText() - { - return this._showColourText; - } //-- boolean getShowColourText() - - /** - * Returns the value of field 'showConservation'. - * - * @return boolean - * @return the value of field 'showConservation'. - */ - public boolean getShowConservation() - { - return this._showConservation; - } //-- boolean getShowConservation() - - /** - * Returns the value of field 'showFullId'. - * - * @return boolean - * @return the value of field 'showFullId'. - */ - public boolean getShowFullId() - { - return this._showFullId; - } //-- boolean getShowFullId() - - /** - * Returns the value of field 'showIdentity'. - * - * @return boolean - * @return the value of field 'showIdentity'. - */ - public boolean getShowIdentity() - { - return this._showIdentity; - } //-- boolean getShowIdentity() - - /** - * Returns the value of field 'showQuality'. - * - * @return boolean - * @return the value of field 'showQuality'. - */ - public boolean getShowQuality() - { - return this._showQuality; - } //-- boolean getShowQuality() - - /** - * Returns the value of field 'showSequenceFeatures'. - * - * @return boolean - * @return the value of field 'showSequenceFeatures'. - */ - public boolean getShowSequenceFeatures() - { - return this._showSequenceFeatures; - } //-- boolean getShowSequenceFeatures() - - /** - * Returns the value of field 'showText'. - * - * @return boolean - * @return the value of field 'showText'. - */ - public boolean getShowText() - { - return this._showText; - } //-- boolean getShowText() - - /** - * Returns the value of field 'startRes'. - * - * @return int - * @return the value of field 'startRes'. - */ - public int getStartRes() - { - return this._startRes; - } //-- int getStartRes() - - /** - * Returns the value of field 'startSeq'. - * - * @return int - * @return the value of field 'startSeq'. - */ - public int getStartSeq() - { - return this._startSeq; - } //-- int getStartSeq() - - /** - * Returns the value of field 'title'. - * - * @return String - * @return the value of field 'title'. - */ - public java.lang.String getTitle() - { - return this._title; - } //-- java.lang.String getTitle() - - /** - * Returns the value of field 'width'. - * - * @return int - * @return the value of field 'width'. - */ - public int getWidth() - { - return this._width; - } //-- int getWidth() - - /** - * Returns the value of field 'wrapAlignment'. - * - * @return boolean - * @return the value of field 'wrapAlignment'. - */ - public boolean getWrapAlignment() - { - return this._wrapAlignment; - } //-- boolean getWrapAlignment() - - /** - * Returns the value of field 'xpos'. - * - * @return int - * @return the value of field 'xpos'. - */ - public int getXpos() - { - return this._xpos; - } //-- int getXpos() - - /** - * Returns the value of field 'ypos'. - * - * @return int - * @return the value of field 'ypos'. - */ - public int getYpos() - { - return this._ypos; - } //-- int getYpos() - - /** - * Method hasConsThreshold - * - * - * - * @return boolean - */ - public boolean hasConsThreshold() - { - return this._has_consThreshold; - } //-- boolean hasConsThreshold() - - /** - * Method hasConservationSelected - * - * - * - * @return boolean - */ - public boolean hasConservationSelected() - { - return this._has_conservationSelected; - } //-- boolean hasConservationSelected() - - /** - * Method hasFontSize - * - * - * - * @return boolean - */ - public boolean hasFontSize() - { - return this._has_fontSize; - } //-- boolean hasFontSize() - - /** - * Method hasFontStyle - * - * - * - * @return boolean - */ - public boolean hasFontStyle() - { - return this._has_fontStyle; - } //-- boolean hasFontStyle() - - /** - * Method hasHeight - * - * - * - * @return boolean - */ - public boolean hasHeight() - { - return this._has_height; - } //-- boolean hasHeight() - - /** - * Method hasPidSelected - * - * - * - * @return boolean - */ - public boolean hasPidSelected() - { - return this._has_pidSelected; - } //-- boolean hasPidSelected() - - /** - * Method hasPidThreshold - * - * - * - * @return boolean - */ - public boolean hasPidThreshold() - { - return this._has_pidThreshold; - } //-- boolean hasPidThreshold() - - /** - * Method hasRenderGaps - * - * - * - * @return boolean - */ - public boolean hasRenderGaps() - { - return this._has_renderGaps; - } //-- boolean hasRenderGaps() - - /** - * Method hasShowAnnotation - * - * - * - * @return boolean - */ - public boolean hasShowAnnotation() - { - return this._has_showAnnotation; - } //-- boolean hasShowAnnotation() - - /** - * Method hasShowBoxes - * - * - * - * @return boolean - */ - public boolean hasShowBoxes() - { - return this._has_showBoxes; - } //-- boolean hasShowBoxes() - - /** - * Method hasShowColourText - * - * - * - * @return boolean - */ - public boolean hasShowColourText() - { - return this._has_showColourText; - } //-- boolean hasShowColourText() - - /** - * Method hasShowConservation - * - * - * - * @return boolean - */ - public boolean hasShowConservation() - { - return this._has_showConservation; - } //-- boolean hasShowConservation() - - /** - * Method hasShowFullId - * - * - * - * @return boolean - */ - public boolean hasShowFullId() - { - return this._has_showFullId; - } //-- boolean hasShowFullId() - - /** - * Method hasShowIdentity - * - * - * - * @return boolean - */ - public boolean hasShowIdentity() - { - return this._has_showIdentity; - } //-- boolean hasShowIdentity() - - /** - * Method hasShowQuality - * - * - * - * @return boolean - */ - public boolean hasShowQuality() - { - return this._has_showQuality; - } //-- boolean hasShowQuality() - - /** - * Method hasShowSequenceFeatures - * - * - * - * @return boolean - */ - public boolean hasShowSequenceFeatures() - { - return this._has_showSequenceFeatures; - } //-- boolean hasShowSequenceFeatures() - - /** - * Method hasShowText - * - * - * - * @return boolean - */ - public boolean hasShowText() - { - return this._has_showText; - } //-- boolean hasShowText() - - /** - * Method hasStartRes - * - * - * - * @return boolean - */ - public boolean hasStartRes() - { - return this._has_startRes; - } //-- boolean hasStartRes() - - /** - * Method hasStartSeq - * - * - * - * @return boolean - */ - public boolean hasStartSeq() - { - return this._has_startSeq; - } //-- boolean hasStartSeq() - - /** - * Method hasWidth - * - * - * - * @return boolean - */ - public boolean hasWidth() - { - return this._has_width; - } //-- boolean hasWidth() - - /** - * Method hasWrapAlignment - * - * - * - * @return boolean - */ - public boolean hasWrapAlignment() - { - return this._has_wrapAlignment; - } //-- boolean hasWrapAlignment() - - /** - * Method hasXpos - * - * - * - * @return boolean - */ - public boolean hasXpos() - { - return this._has_xpos; - } //-- boolean hasXpos() - - /** - * Method hasYpos - * - * - * - * @return boolean - */ - public boolean hasYpos() - { - return this._has_ypos; - } //-- boolean hasYpos() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Sets the value of field 'bgColour'. - * - * @param bgColour the value of field 'bgColour'. - */ - public void setBgColour(java.lang.String bgColour) - { - this._bgColour = bgColour; - } //-- void setBgColour(java.lang.String) - - /** - * Sets the value of field 'consThreshold'. - * - * @param consThreshold the value of field 'consThreshold'. - */ - public void setConsThreshold(int consThreshold) - { - this._consThreshold = consThreshold; - this._has_consThreshold = true; - } //-- void setConsThreshold(int) - - /** - * Sets the value of field 'conservationSelected'. - * - * @param conservationSelected the value of field - * 'conservationSelected'. - */ - public void setConservationSelected(boolean conservationSelected) - { - this._conservationSelected = conservationSelected; - this._has_conservationSelected = true; - } //-- void setConservationSelected(boolean) - - /** - * Sets the value of field 'fontName'. - * - * @param fontName the value of field 'fontName'. - */ - public void setFontName(java.lang.String fontName) - { - this._fontName = fontName; - } //-- void setFontName(java.lang.String) - - /** - * Sets the value of field 'fontSize'. - * - * @param fontSize the value of field 'fontSize'. - */ - public void setFontSize(int fontSize) - { - this._fontSize = fontSize; - this._has_fontSize = true; - } //-- void setFontSize(int) - - /** - * Sets the value of field 'fontStyle'. - * - * @param fontStyle the value of field 'fontStyle'. - */ - public void setFontStyle(int fontStyle) - { - this._fontStyle = fontStyle; - this._has_fontStyle = true; - } //-- void setFontStyle(int) - - /** - * Sets the value of field 'height'. - * - * @param height the value of field 'height'. - */ - public void setHeight(int height) - { - this._height = height; - this._has_height = true; - } //-- void setHeight(int) - - /** - * Sets the value of field 'pidSelected'. - * - * @param pidSelected the value of field 'pidSelected'. - */ - public void setPidSelected(boolean pidSelected) - { - this._pidSelected = pidSelected; - this._has_pidSelected = true; - } //-- void setPidSelected(boolean) - - /** - * Sets the value of field 'pidThreshold'. - * - * @param pidThreshold the value of field 'pidThreshold'. - */ - public void setPidThreshold(int pidThreshold) - { - this._pidThreshold = pidThreshold; - this._has_pidThreshold = true; - } //-- void setPidThreshold(int) - - /** - * Sets the value of field 'renderGaps'. - * - * @param renderGaps the value of field 'renderGaps'. - */ - public void setRenderGaps(boolean renderGaps) - { - this._renderGaps = renderGaps; - this._has_renderGaps = true; - } //-- void setRenderGaps(boolean) - - /** - * Sets the value of field 'showAnnotation'. - * - * @param showAnnotation the value of field 'showAnnotation'. - */ - public void setShowAnnotation(boolean showAnnotation) - { - this._showAnnotation = showAnnotation; - this._has_showAnnotation = true; - } //-- void setShowAnnotation(boolean) - - /** - * Sets the value of field 'showBoxes'. - * - * @param showBoxes the value of field 'showBoxes'. - */ - public void setShowBoxes(boolean showBoxes) - { - this._showBoxes = showBoxes; - this._has_showBoxes = true; - } //-- void setShowBoxes(boolean) - - /** - * Sets the value of field 'showColourText'. - * - * @param showColourText the value of field 'showColourText'. - */ - public void setShowColourText(boolean showColourText) - { - this._showColourText = showColourText; - this._has_showColourText = true; - } //-- void setShowColourText(boolean) - - /** - * Sets the value of field 'showConservation'. - * - * @param showConservation the value of field 'showConservation' - */ - public void setShowConservation(boolean showConservation) - { - this._showConservation = showConservation; - this._has_showConservation = true; - } //-- void setShowConservation(boolean) - - /** - * Sets the value of field 'showFullId'. - * - * @param showFullId the value of field 'showFullId'. - */ - public void setShowFullId(boolean showFullId) - { - this._showFullId = showFullId; - this._has_showFullId = true; - } //-- void setShowFullId(boolean) - - /** - * Sets the value of field 'showIdentity'. - * - * @param showIdentity the value of field 'showIdentity'. - */ - public void setShowIdentity(boolean showIdentity) - { - this._showIdentity = showIdentity; - this._has_showIdentity = true; - } //-- void setShowIdentity(boolean) - - /** - * Sets the value of field 'showQuality'. - * - * @param showQuality the value of field 'showQuality'. - */ - public void setShowQuality(boolean showQuality) - { - this._showQuality = showQuality; - this._has_showQuality = true; - } //-- void setShowQuality(boolean) - - /** - * Sets the value of field 'showSequenceFeatures'. - * - * @param showSequenceFeatures the value of field - * 'showSequenceFeatures'. - */ - public void setShowSequenceFeatures(boolean showSequenceFeatures) - { - this._showSequenceFeatures = showSequenceFeatures; - this._has_showSequenceFeatures = true; - } //-- void setShowSequenceFeatures(boolean) - - /** - * Sets the value of field 'showText'. - * - * @param showText the value of field 'showText'. - */ - public void setShowText(boolean showText) - { - this._showText = showText; - this._has_showText = true; - } //-- void setShowText(boolean) - - /** - * Sets the value of field 'startRes'. - * - * @param startRes the value of field 'startRes'. - */ - public void setStartRes(int startRes) - { - this._startRes = startRes; - this._has_startRes = true; - } //-- void setStartRes(int) - - /** - * Sets the value of field 'startSeq'. - * - * @param startSeq the value of field 'startSeq'. - */ - public void setStartSeq(int startSeq) - { - this._startSeq = startSeq; - this._has_startSeq = true; - } //-- void setStartSeq(int) - - /** - * Sets the value of field 'title'. - * - * @param title the value of field 'title'. - */ - public void setTitle(java.lang.String title) - { - this._title = title; - } //-- void setTitle(java.lang.String) - - /** - * Sets the value of field 'width'. - * - * @param width the value of field 'width'. - */ - public void setWidth(int width) - { - this._width = width; - this._has_width = true; - } //-- void setWidth(int) - - /** - * Sets the value of field 'wrapAlignment'. - * - * @param wrapAlignment the value of field 'wrapAlignment'. - */ - public void setWrapAlignment(boolean wrapAlignment) - { - this._wrapAlignment = wrapAlignment; - this._has_wrapAlignment = true; - } //-- void setWrapAlignment(boolean) - - /** - * Sets the value of field 'xpos'. - * - * @param xpos the value of field 'xpos'. - */ - public void setXpos(int xpos) - { - this._xpos = xpos; - this._has_xpos = true; - } //-- void setXpos(int) - - /** - * Sets the value of field 'ypos'. - * - * @param ypos the value of field 'ypos'. - */ - public void setYpos(int ypos) - { - this._ypos = ypos; - this._has_ypos = true; - } //-- void setYpos(int) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.binding.Viewport) Unmarshaller.unmarshal(jalview.binding.Viewport.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() +public class Viewport + implements java.io.Serializable +{ + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field _conservationSelected + */ + private boolean _conservationSelected; + + /** + * keeps track of state for field: _conservationSelected + */ + private boolean _has_conservationSelected; + + /** + * Field _pidSelected + */ + private boolean _pidSelected; + + /** + * keeps track of state for field: _pidSelected + */ + private boolean _has_pidSelected; + + /** + * Field _bgColour + */ + private java.lang.String _bgColour; + + /** + * Field _consThreshold + */ + private int _consThreshold; + + /** + * keeps track of state for field: _consThreshold + */ + private boolean _has_consThreshold; + + /** + * Field _pidThreshold + */ + private int _pidThreshold; + + /** + * keeps track of state for field: _pidThreshold + */ + private boolean _has_pidThreshold; + + /** + * Field _title + */ + private java.lang.String _title; + + /** + * Field _showFullId + */ + private boolean _showFullId; + + /** + * keeps track of state for field: _showFullId + */ + private boolean _has_showFullId; + + /** + * Field _showText + */ + private boolean _showText; + + /** + * keeps track of state for field: _showText + */ + private boolean _has_showText; + + /** + * Field _showColourText + */ + private boolean _showColourText; + + /** + * keeps track of state for field: _showColourText + */ + private boolean _has_showColourText; + + /** + * Field _showBoxes + */ + private boolean _showBoxes; + + /** + * keeps track of state for field: _showBoxes + */ + private boolean _has_showBoxes; + + /** + * Field _wrapAlignment + */ + private boolean _wrapAlignment; + + /** + * keeps track of state for field: _wrapAlignment + */ + private boolean _has_wrapAlignment; + + /** + * Field _renderGaps + */ + private boolean _renderGaps; + + /** + * keeps track of state for field: _renderGaps + */ + private boolean _has_renderGaps; + + /** + * Field _showSequenceFeatures + */ + private boolean _showSequenceFeatures; + + /** + * keeps track of state for field: _showSequenceFeatures + */ + private boolean _has_showSequenceFeatures; + + /** + * Field _showAnnotation + */ + private boolean _showAnnotation; + + /** + * keeps track of state for field: _showAnnotation + */ + private boolean _has_showAnnotation; + + /** + * Field _showConservation + */ + private boolean _showConservation; + + /** + * keeps track of state for field: _showConservation + */ + private boolean _has_showConservation; + + /** + * Field _showQuality + */ + private boolean _showQuality; + + /** + * keeps track of state for field: _showQuality + */ + private boolean _has_showQuality; + + /** + * Field _showIdentity + */ + private boolean _showIdentity; + + /** + * keeps track of state for field: _showIdentity + */ + private boolean _has_showIdentity; + + /** + * Field _xpos + */ + private int _xpos; + + /** + * keeps track of state for field: _xpos + */ + private boolean _has_xpos; + + /** + * Field _ypos + */ + private int _ypos; + + /** + * keeps track of state for field: _ypos + */ + private boolean _has_ypos; + + /** + * Field _width + */ + private int _width; + + /** + * keeps track of state for field: _width + */ + private boolean _has_width; + + /** + * Field _height + */ + private int _height; + + /** + * keeps track of state for field: _height + */ + private boolean _has_height; + + /** + * Field _startRes + */ + private int _startRes; + + /** + * keeps track of state for field: _startRes + */ + private boolean _has_startRes; + + /** + * Field _startSeq + */ + private int _startSeq; + + /** + * keeps track of state for field: _startSeq + */ + private boolean _has_startSeq; + + /** + * Field _fontName + */ + private java.lang.String _fontName; + + /** + * Field _fontSize + */ + private int _fontSize; + + /** + * keeps track of state for field: _fontSize + */ + private boolean _has_fontSize; + + /** + * Field _fontStyle + */ + private int _fontStyle; + + /** + * keeps track of state for field: _fontStyle + */ + private boolean _has_fontStyle; + + //----------------/ + //- Constructors -/ + //----------------/ + + public Viewport() + { + super(); + } //-- jalview.binding.Viewport() + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteConsThreshold + * + */ + public void deleteConsThreshold() + { + this._has_consThreshold = false; + } //-- void deleteConsThreshold() + + /** + * Method deleteConservationSelected + * + */ + public void deleteConservationSelected() + { + this._has_conservationSelected = false; + } //-- void deleteConservationSelected() + + /** + * Method deleteFontSize + * + */ + public void deleteFontSize() + { + this._has_fontSize = false; + } //-- void deleteFontSize() + + /** + * Method deleteFontStyle + * + */ + public void deleteFontStyle() + { + this._has_fontStyle = false; + } //-- void deleteFontStyle() + + /** + * Method deleteHeight + * + */ + public void deleteHeight() + { + this._has_height = false; + } //-- void deleteHeight() + + /** + * Method deletePidSelected + * + */ + public void deletePidSelected() + { + this._has_pidSelected = false; + } //-- void deletePidSelected() + + /** + * Method deletePidThreshold + * + */ + public void deletePidThreshold() + { + this._has_pidThreshold = false; + } //-- void deletePidThreshold() + + /** + * Method deleteRenderGaps + * + */ + public void deleteRenderGaps() + { + this._has_renderGaps = false; + } //-- void deleteRenderGaps() + + /** + * Method deleteShowAnnotation + * + */ + public void deleteShowAnnotation() + { + this._has_showAnnotation = false; + } //-- void deleteShowAnnotation() + + /** + * Method deleteShowBoxes + * + */ + public void deleteShowBoxes() + { + this._has_showBoxes = false; + } //-- void deleteShowBoxes() + + /** + * Method deleteShowColourText + * + */ + public void deleteShowColourText() + { + this._has_showColourText = false; + } //-- void deleteShowColourText() + + /** + * Method deleteShowConservation + * + */ + public void deleteShowConservation() + { + this._has_showConservation = false; + } //-- void deleteShowConservation() + + /** + * Method deleteShowFullId + * + */ + public void deleteShowFullId() + { + this._has_showFullId = false; + } //-- void deleteShowFullId() + + /** + * Method deleteShowIdentity + * + */ + public void deleteShowIdentity() + { + this._has_showIdentity = false; + } //-- void deleteShowIdentity() + + /** + * Method deleteShowQuality + * + */ + public void deleteShowQuality() + { + this._has_showQuality = false; + } //-- void deleteShowQuality() + + /** + * Method deleteShowSequenceFeatures + * + */ + public void deleteShowSequenceFeatures() + { + this._has_showSequenceFeatures = false; + } //-- void deleteShowSequenceFeatures() + + /** + * Method deleteShowText + * + */ + public void deleteShowText() + { + this._has_showText = false; + } //-- void deleteShowText() + + /** + * Method deleteStartRes + * + */ + public void deleteStartRes() + { + this._has_startRes = false; + } //-- void deleteStartRes() + + /** + * Method deleteStartSeq + * + */ + public void deleteStartSeq() + { + this._has_startSeq = false; + } //-- void deleteStartSeq() + + /** + * Method deleteWidth + * + */ + public void deleteWidth() + { + this._has_width = false; + } //-- void deleteWidth() + + /** + * Method deleteWrapAlignment + * + */ + public void deleteWrapAlignment() + { + this._has_wrapAlignment = false; + } //-- void deleteWrapAlignment() + + /** + * Method deleteXpos + * + */ + public void deleteXpos() + { + this._has_xpos = false; + } //-- void deleteXpos() + + /** + * Method deleteYpos + * + */ + public void deleteYpos() + { + this._has_ypos = false; + } //-- void deleteYpos() + + /** + * Returns the value of field 'bgColour'. + * + * @return String + * @return the value of field 'bgColour'. + */ + public java.lang.String getBgColour() + { + return this._bgColour; + } //-- java.lang.String getBgColour() + + /** + * Returns the value of field 'consThreshold'. + * + * @return int + * @return the value of field 'consThreshold'. + */ + public int getConsThreshold() + { + return this._consThreshold; + } //-- int getConsThreshold() + + /** + * Returns the value of field 'conservationSelected'. + * + * @return boolean + * @return the value of field 'conservationSelected'. + */ + public boolean getConservationSelected() + { + return this._conservationSelected; + } //-- boolean getConservationSelected() + + /** + * Returns the value of field 'fontName'. + * + * @return String + * @return the value of field 'fontName'. + */ + public java.lang.String getFontName() + { + return this._fontName; + } //-- java.lang.String getFontName() + + /** + * Returns the value of field 'fontSize'. + * + * @return int + * @return the value of field 'fontSize'. + */ + public int getFontSize() + { + return this._fontSize; + } //-- int getFontSize() + + /** + * Returns the value of field 'fontStyle'. + * + * @return int + * @return the value of field 'fontStyle'. + */ + public int getFontStyle() + { + return this._fontStyle; + } //-- int getFontStyle() + + /** + * Returns the value of field 'height'. + * + * @return int + * @return the value of field 'height'. + */ + public int getHeight() + { + return this._height; + } //-- int getHeight() + + /** + * Returns the value of field 'pidSelected'. + * + * @return boolean + * @return the value of field 'pidSelected'. + */ + public boolean getPidSelected() + { + return this._pidSelected; + } //-- boolean getPidSelected() + + /** + * Returns the value of field 'pidThreshold'. + * + * @return int + * @return the value of field 'pidThreshold'. + */ + public int getPidThreshold() + { + return this._pidThreshold; + } //-- int getPidThreshold() + + /** + * Returns the value of field 'renderGaps'. + * + * @return boolean + * @return the value of field 'renderGaps'. + */ + public boolean getRenderGaps() + { + return this._renderGaps; + } //-- boolean getRenderGaps() + + /** + * Returns the value of field 'showAnnotation'. + * + * @return boolean + * @return the value of field 'showAnnotation'. + */ + public boolean getShowAnnotation() + { + return this._showAnnotation; + } //-- boolean getShowAnnotation() + + /** + * Returns the value of field 'showBoxes'. + * + * @return boolean + * @return the value of field 'showBoxes'. + */ + public boolean getShowBoxes() + { + return this._showBoxes; + } //-- boolean getShowBoxes() + + /** + * Returns the value of field 'showColourText'. + * + * @return boolean + * @return the value of field 'showColourText'. + */ + public boolean getShowColourText() + { + return this._showColourText; + } //-- boolean getShowColourText() + + /** + * Returns the value of field 'showConservation'. + * + * @return boolean + * @return the value of field 'showConservation'. + */ + public boolean getShowConservation() + { + return this._showConservation; + } //-- boolean getShowConservation() + + /** + * Returns the value of field 'showFullId'. + * + * @return boolean + * @return the value of field 'showFullId'. + */ + public boolean getShowFullId() + { + return this._showFullId; + } //-- boolean getShowFullId() + + /** + * Returns the value of field 'showIdentity'. + * + * @return boolean + * @return the value of field 'showIdentity'. + */ + public boolean getShowIdentity() + { + return this._showIdentity; + } //-- boolean getShowIdentity() + + /** + * Returns the value of field 'showQuality'. + * + * @return boolean + * @return the value of field 'showQuality'. + */ + public boolean getShowQuality() + { + return this._showQuality; + } //-- boolean getShowQuality() + + /** + * Returns the value of field 'showSequenceFeatures'. + * + * @return boolean + * @return the value of field 'showSequenceFeatures'. + */ + public boolean getShowSequenceFeatures() + { + return this._showSequenceFeatures; + } //-- boolean getShowSequenceFeatures() + + /** + * Returns the value of field 'showText'. + * + * @return boolean + * @return the value of field 'showText'. + */ + public boolean getShowText() + { + return this._showText; + } //-- boolean getShowText() + + /** + * Returns the value of field 'startRes'. + * + * @return int + * @return the value of field 'startRes'. + */ + public int getStartRes() + { + return this._startRes; + } //-- int getStartRes() + + /** + * Returns the value of field 'startSeq'. + * + * @return int + * @return the value of field 'startSeq'. + */ + public int getStartSeq() + { + return this._startSeq; + } //-- int getStartSeq() + + /** + * Returns the value of field 'title'. + * + * @return String + * @return the value of field 'title'. + */ + public java.lang.String getTitle() + { + return this._title; + } //-- java.lang.String getTitle() + + /** + * Returns the value of field 'width'. + * + * @return int + * @return the value of field 'width'. + */ + public int getWidth() + { + return this._width; + } //-- int getWidth() + + /** + * Returns the value of field 'wrapAlignment'. + * + * @return boolean + * @return the value of field 'wrapAlignment'. + */ + public boolean getWrapAlignment() + { + return this._wrapAlignment; + } //-- boolean getWrapAlignment() + + /** + * Returns the value of field 'xpos'. + * + * @return int + * @return the value of field 'xpos'. + */ + public int getXpos() + { + return this._xpos; + } //-- int getXpos() + + /** + * Returns the value of field 'ypos'. + * + * @return int + * @return the value of field 'ypos'. + */ + public int getYpos() + { + return this._ypos; + } //-- int getYpos() + + /** + * Method hasConsThreshold + * + * + * + * @return boolean + */ + public boolean hasConsThreshold() + { + return this._has_consThreshold; + } //-- boolean hasConsThreshold() + + /** + * Method hasConservationSelected + * + * + * + * @return boolean + */ + public boolean hasConservationSelected() + { + return this._has_conservationSelected; + } //-- boolean hasConservationSelected() + + /** + * Method hasFontSize + * + * + * + * @return boolean + */ + public boolean hasFontSize() + { + return this._has_fontSize; + } //-- boolean hasFontSize() + + /** + * Method hasFontStyle + * + * + * + * @return boolean + */ + public boolean hasFontStyle() + { + return this._has_fontStyle; + } //-- boolean hasFontStyle() + + /** + * Method hasHeight + * + * + * + * @return boolean + */ + public boolean hasHeight() + { + return this._has_height; + } //-- boolean hasHeight() + + /** + * Method hasPidSelected + * + * + * + * @return boolean + */ + public boolean hasPidSelected() + { + return this._has_pidSelected; + } //-- boolean hasPidSelected() + + /** + * Method hasPidThreshold + * + * + * + * @return boolean + */ + public boolean hasPidThreshold() + { + return this._has_pidThreshold; + } //-- boolean hasPidThreshold() + + /** + * Method hasRenderGaps + * + * + * + * @return boolean + */ + public boolean hasRenderGaps() + { + return this._has_renderGaps; + } //-- boolean hasRenderGaps() + + /** + * Method hasShowAnnotation + * + * + * + * @return boolean + */ + public boolean hasShowAnnotation() + { + return this._has_showAnnotation; + } //-- boolean hasShowAnnotation() + + /** + * Method hasShowBoxes + * + * + * + * @return boolean + */ + public boolean hasShowBoxes() + { + return this._has_showBoxes; + } //-- boolean hasShowBoxes() + + /** + * Method hasShowColourText + * + * + * + * @return boolean + */ + public boolean hasShowColourText() + { + return this._has_showColourText; + } //-- boolean hasShowColourText() + + /** + * Method hasShowConservation + * + * + * + * @return boolean + */ + public boolean hasShowConservation() + { + return this._has_showConservation; + } //-- boolean hasShowConservation() + + /** + * Method hasShowFullId + * + * + * + * @return boolean + */ + public boolean hasShowFullId() + { + return this._has_showFullId; + } //-- boolean hasShowFullId() + + /** + * Method hasShowIdentity + * + * + * + * @return boolean + */ + public boolean hasShowIdentity() + { + return this._has_showIdentity; + } //-- boolean hasShowIdentity() + + /** + * Method hasShowQuality + * + * + * + * @return boolean + */ + public boolean hasShowQuality() + { + return this._has_showQuality; + } //-- boolean hasShowQuality() + + /** + * Method hasShowSequenceFeatures + * + * + * + * @return boolean + */ + public boolean hasShowSequenceFeatures() + { + return this._has_showSequenceFeatures; + } //-- boolean hasShowSequenceFeatures() + + /** + * Method hasShowText + * + * + * + * @return boolean + */ + public boolean hasShowText() + { + return this._has_showText; + } //-- boolean hasShowText() + + /** + * Method hasStartRes + * + * + * + * @return boolean + */ + public boolean hasStartRes() + { + return this._has_startRes; + } //-- boolean hasStartRes() + + /** + * Method hasStartSeq + * + * + * + * @return boolean + */ + public boolean hasStartSeq() + { + return this._has_startSeq; + } //-- boolean hasStartSeq() + + /** + * Method hasWidth + * + * + * + * @return boolean + */ + public boolean hasWidth() + { + return this._has_width; + } //-- boolean hasWidth() + + /** + * Method hasWrapAlignment + * + * + * + * @return boolean + */ + public boolean hasWrapAlignment() + { + return this._has_wrapAlignment; + } //-- boolean hasWrapAlignment() + + /** + * Method hasXpos + * + * + * + * @return boolean + */ + public boolean hasXpos() + { + return this._has_xpos; + } //-- boolean hasXpos() + + /** + * Method hasYpos + * + * + * + * @return boolean + */ + public boolean hasYpos() + { + return this._has_ypos; + } //-- boolean hasYpos() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try + { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) + { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'bgColour'. + * + * @param bgColour the value of field 'bgColour'. + */ + public void setBgColour(java.lang.String bgColour) + { + this._bgColour = bgColour; + } //-- void setBgColour(java.lang.String) + + /** + * Sets the value of field 'consThreshold'. + * + * @param consThreshold the value of field 'consThreshold'. + */ + public void setConsThreshold(int consThreshold) + { + this._consThreshold = consThreshold; + this._has_consThreshold = true; + } //-- void setConsThreshold(int) + + /** + * Sets the value of field 'conservationSelected'. + * + * @param conservationSelected the value of field + * 'conservationSelected'. + */ + public void setConservationSelected(boolean conservationSelected) + { + this._conservationSelected = conservationSelected; + this._has_conservationSelected = true; + } //-- void setConservationSelected(boolean) + + /** + * Sets the value of field 'fontName'. + * + * @param fontName the value of field 'fontName'. + */ + public void setFontName(java.lang.String fontName) + { + this._fontName = fontName; + } //-- void setFontName(java.lang.String) + + /** + * Sets the value of field 'fontSize'. + * + * @param fontSize the value of field 'fontSize'. + */ + public void setFontSize(int fontSize) + { + this._fontSize = fontSize; + this._has_fontSize = true; + } //-- void setFontSize(int) + + /** + * Sets the value of field 'fontStyle'. + * + * @param fontStyle the value of field 'fontStyle'. + */ + public void setFontStyle(int fontStyle) + { + this._fontStyle = fontStyle; + this._has_fontStyle = true; + } //-- void setFontStyle(int) + + /** + * Sets the value of field 'height'. + * + * @param height the value of field 'height'. + */ + public void setHeight(int height) + { + this._height = height; + this._has_height = true; + } //-- void setHeight(int) + + /** + * Sets the value of field 'pidSelected'. + * + * @param pidSelected the value of field 'pidSelected'. + */ + public void setPidSelected(boolean pidSelected) + { + this._pidSelected = pidSelected; + this._has_pidSelected = true; + } //-- void setPidSelected(boolean) + + /** + * Sets the value of field 'pidThreshold'. + * + * @param pidThreshold the value of field 'pidThreshold'. + */ + public void setPidThreshold(int pidThreshold) + { + this._pidThreshold = pidThreshold; + this._has_pidThreshold = true; + } //-- void setPidThreshold(int) + + /** + * Sets the value of field 'renderGaps'. + * + * @param renderGaps the value of field 'renderGaps'. + */ + public void setRenderGaps(boolean renderGaps) + { + this._renderGaps = renderGaps; + this._has_renderGaps = true; + } //-- void setRenderGaps(boolean) + + /** + * Sets the value of field 'showAnnotation'. + * + * @param showAnnotation the value of field 'showAnnotation'. + */ + public void setShowAnnotation(boolean showAnnotation) + { + this._showAnnotation = showAnnotation; + this._has_showAnnotation = true; + } //-- void setShowAnnotation(boolean) + + /** + * Sets the value of field 'showBoxes'. + * + * @param showBoxes the value of field 'showBoxes'. + */ + public void setShowBoxes(boolean showBoxes) + { + this._showBoxes = showBoxes; + this._has_showBoxes = true; + } //-- void setShowBoxes(boolean) + + /** + * Sets the value of field 'showColourText'. + * + * @param showColourText the value of field 'showColourText'. + */ + public void setShowColourText(boolean showColourText) + { + this._showColourText = showColourText; + this._has_showColourText = true; + } //-- void setShowColourText(boolean) + + /** + * Sets the value of field 'showConservation'. + * + * @param showConservation the value of field 'showConservation' + */ + public void setShowConservation(boolean showConservation) + { + this._showConservation = showConservation; + this._has_showConservation = true; + } //-- void setShowConservation(boolean) + + /** + * Sets the value of field 'showFullId'. + * + * @param showFullId the value of field 'showFullId'. + */ + public void setShowFullId(boolean showFullId) + { + this._showFullId = showFullId; + this._has_showFullId = true; + } //-- void setShowFullId(boolean) + + /** + * Sets the value of field 'showIdentity'. + * + * @param showIdentity the value of field 'showIdentity'. + */ + public void setShowIdentity(boolean showIdentity) + { + this._showIdentity = showIdentity; + this._has_showIdentity = true; + } //-- void setShowIdentity(boolean) + + /** + * Sets the value of field 'showQuality'. + * + * @param showQuality the value of field 'showQuality'. + */ + public void setShowQuality(boolean showQuality) + { + this._showQuality = showQuality; + this._has_showQuality = true; + } //-- void setShowQuality(boolean) + + /** + * Sets the value of field 'showSequenceFeatures'. + * + * @param showSequenceFeatures the value of field + * 'showSequenceFeatures'. + */ + public void setShowSequenceFeatures(boolean showSequenceFeatures) + { + this._showSequenceFeatures = showSequenceFeatures; + this._has_showSequenceFeatures = true; + } //-- void setShowSequenceFeatures(boolean) + + /** + * Sets the value of field 'showText'. + * + * @param showText the value of field 'showText'. + */ + public void setShowText(boolean showText) + { + this._showText = showText; + this._has_showText = true; + } //-- void setShowText(boolean) + + /** + * Sets the value of field 'startRes'. + * + * @param startRes the value of field 'startRes'. + */ + public void setStartRes(int startRes) + { + this._startRes = startRes; + this._has_startRes = true; + } //-- void setStartRes(int) + + /** + * Sets the value of field 'startSeq'. + * + * @param startSeq the value of field 'startSeq'. + */ + public void setStartSeq(int startSeq) + { + this._startSeq = startSeq; + this._has_startSeq = true; + } //-- void setStartSeq(int) + + /** + * Sets the value of field 'title'. + * + * @param title the value of field 'title'. + */ + public void setTitle(java.lang.String title) + { + this._title = title; + } //-- void setTitle(java.lang.String) + + /** + * Sets the value of field 'width'. + * + * @param width the value of field 'width'. + */ + public void setWidth(int width) + { + this._width = width; + this._has_width = true; + } //-- void setWidth(int) + + /** + * Sets the value of field 'wrapAlignment'. + * + * @param wrapAlignment the value of field 'wrapAlignment'. + */ + public void setWrapAlignment(boolean wrapAlignment) + { + this._wrapAlignment = wrapAlignment; + this._has_wrapAlignment = true; + } //-- void setWrapAlignment(boolean) + + /** + * Sets the value of field 'xpos'. + * + * @param xpos the value of field 'xpos'. + */ + public void setXpos(int xpos) + { + this._xpos = xpos; + this._has_xpos = true; + } //-- void setXpos(int) + + /** + * Sets the value of field 'ypos'. + * + * @param ypos the value of field 'ypos'. + */ + public void setYpos(int ypos) + { + this._ypos = ypos; + this._has_ypos = true; + } //-- void setYpos(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, + org.exolab.castor.xml.ValidationException + { + return (jalview.binding.Viewport) Unmarshaller.unmarshal(jalview.binding. + Viewport.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml. + Validator(); + validator.validate(this); + } //-- void validate() } diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 817472a..28849b6 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1,21 +1,21 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.datamodel; import jalview.analysis.*; @@ -27,33 +27,56 @@ import java.util.*; /** Data structure to hold and manipulate a multiple sequence alignment */ -public class Alignment implements AlignmentI { +public class Alignment implements AlignmentI +{ protected Vector sequences; protected Vector groups = new Vector(); protected Vector superGroup = new Vector(); protected char gapCharacter = '-'; + + /** DOCUMENT ME!! */ public AlignmentAnnotation[] annotations; + + /** DOCUMENT ME!! */ public boolean featuresAdded = false; /** Make an alignment from an array of Sequences. - * - * @param sequences - */ - public Alignment(SequenceI[] seqs) { + * + * @param sequences + */ + public Alignment(SequenceI[] seqs) + { sequences = new Vector(); for (int i = 0; i < seqs.length; i++) + { sequences.addElement(seqs[i]); + } getWidth(); } - public Vector getSequences() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getSequences() + { return sequences; } - public SequenceI getSequenceAt(int i) { - if (i < sequences.size()) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI getSequenceAt(int i) + { + if (i < sequences.size()) + { return (SequenceI) sequences.elementAt(i); } @@ -64,75 +87,73 @@ public class Alignment implements AlignmentI { * * @param snew */ - public void addSequence(SequenceI snew) { + public void addSequence(SequenceI snew) + { sequences.addElement(snew); } - public void addSequence(SequenceI[] seq) { - for (int i = 0; i < seq.length; i++) { + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + */ + public void addSequence(SequenceI[] seq) + { + for (int i = 0; i < seq.length; i++) + { addSequence(seq[i]); } } /** Adds a sequence to the alignment. Recalculates maxLength and size. - * + * * @param snew */ - public void setSequenceAt(int i, SequenceI snew) { + public void setSequenceAt(int i, SequenceI snew) + { SequenceI oldseq = getSequenceAt(i); deleteSequence(oldseq); sequences.setElementAt(snew, i); } - public Vector getGroups() { - return groups; - } - - /** Sorts the sequences by sequence group size - largest to smallest. - * Uses QuickSort. + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! */ - public void sortGroups() { - float[] arr = new float[groups.size()]; - Object[] s = new Object[groups.size()]; - - for (int i = 0; i < groups.size(); i++) { - arr[i] = ((SequenceGroup) groups.elementAt(i)).sequences.size(); - s[i] = groups.elementAt(i); - } - - QuickSort.sort(arr, s); - - Vector newg = new Vector(groups.size()); - - for (int i = groups.size() - 1; i >= 0; i--) { - newg.addElement(s[i]); - } - - groups = newg; + public Vector getGroups() + { + return groups; } /** Takes out columns consisting entirely of gaps (-,.," ") */ - public void removeGaps() { + public void removeGaps() + { SequenceI current; int iSize = getWidth(); - for (int i = 0; i < iSize; i++) { + for (int i = 0; i < iSize; i++) + { boolean delete = true; - for (int j = 0; j < getHeight(); j++) { + for (int j = 0; j < getHeight(); j++) + { current = getSequenceAt(j); - if (current.getLength() > i) { + if (current.getLength() > i) + { /* MC Should move this to a method somewhere */ - if (!jalview.util.Comparison.isGap(current.getCharAt(i))) { + if (!jalview.util.Comparison.isGap(current.getCharAt(i))) + { delete = false; } } } - if (delete) { + if (delete) + { deleteColumns(i, i); iSize--; i--; @@ -140,59 +161,44 @@ public class Alignment implements AlignmentI { } } - /** Returns an array of Sequences containing columns - * start to end (inclusive) only. - * - * @param start start column to fetch - * @param end end column to fetch - * @return Array of Sequences, ready to put into a new Alignment - */ - public SequenceI[] getColumns(int start, int end) { - return getColumns(0, getHeight() - 1, start, end); - } - /** Removes a range of columns (start to end inclusive). * * @param start Start column in the alignment * @param end End column in the alignment */ - public void deleteColumns(int start, int end) { + public void deleteColumns(int start, int end) + { deleteColumns(0, getHeight() - 1, start, end); } - public void deleteColumns(int seq1, int seq2, int start, int end) { - for (int i = 0; i <= (end - start); i++) { - for (int j = seq1; j <= seq2; j++) { + /** + * DOCUMENT ME! + * + * @param seq1 DOCUMENT ME! + * @param seq2 DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + public void deleteColumns(int seq1, int seq2, int start, int end) + { + for (int i = 0; i <= (end - start); i++) + { + for (int j = seq1; j <= seq2; j++) + { getSequenceAt(j).deleteCharAt(start); } } } - public void insertColumns(SequenceI[] seqs, int pos) { - if (seqs.length == getHeight()) { - for (int i = 0; i < getHeight(); i++) { - String tmp = new String(getSequenceAt(i).getSequence()); - getSequenceAt(i).setSequence(tmp.substring(0, pos) + - seqs[i].getSequence() + tmp.substring(pos)); - } - } - } - - public SequenceI[] getColumns(int seq1, int seq2, int start, int end) { - SequenceI[] seqs = new Sequence[(seq2 - seq1) + 1]; - - for (int i = seq1; i <= seq2; i++) { - seqs[i] = new Sequence(getSequenceAt(i).getName(), - getSequenceAt(i).getSequence().substring(start, end), - getSequenceAt(i).findPosition(start), - getSequenceAt(i).findPosition(end)); - } - - return seqs; - } - - public void trimLeft(int i) { - for (int j = 0; j < getHeight(); j++) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void trimLeft(int i) + { + for (int j = 0; j < getHeight(); j++) + { SequenceI s = getSequenceAt(j); int newstart = s.findPosition(i); @@ -201,8 +207,15 @@ public class Alignment implements AlignmentI { } } - public void trimRight(int i) { - for (int j = 0; j < getHeight(); j++) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void trimRight(int i) + { + for (int j = 0; j < getHeight(); j++) + { SequenceI s = getSequenceAt(j); int newend = s.findPosition(i); @@ -211,36 +224,67 @@ public class Alignment implements AlignmentI { } } - public void deleteSequence(SequenceI s) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + */ + public void deleteSequence(SequenceI s) + { for (int i = 0; i < getHeight(); i++) - if (getSequenceAt(i) == s) { + { + if (getSequenceAt(i) == s) + { deleteSequence(i); } + } } - public void deleteSequence(int i) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void deleteSequence(int i) + { sequences.removeElementAt(i); } - public Vector removeRedundancy(float threshold, Vector sel) { + /** + * DOCUMENT ME! + * + * @param threshold DOCUMENT ME! + * @param sel DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector removeRedundancy(float threshold, Vector sel) + { Vector del = new Vector(); - for (int i = 1; i < sel.size(); i++) { - for (int j = 0; j < i; j++) { + for (int i = 1; i < sel.size(); i++) + { + for (int j = 0; j < i; j++) + { // Only do the comparison if either have not been deleted if (!del.contains((SequenceI) sel.elementAt(i)) || - !del.contains((SequenceI) sel.elementAt(j))) { + !del.contains((SequenceI) sel.elementAt(j))) + { // use PID instead of Comparison (which is really not pleasant) float pid = Comparison.PID((SequenceI) sel.elementAt(j), (SequenceI) sel.elementAt(i)); - if (pid >= threshold) { + if (pid >= threshold) + { // Delete the shortest one if (((SequenceI) sel.elementAt(j)).getSequence().length() > ((SequenceI) sel .elementAt( - i)).getSequence().length()) { + i)).getSequence().length()) + { del.addElement(sel.elementAt(i)); - } else { + } + else + { del.addElement(sel.elementAt(i)); } } @@ -250,78 +294,28 @@ public class Alignment implements AlignmentI { // Now delete the sequences for (int i = 0; i < del.size(); i++) + { deleteSequence((SequenceI) del.elementAt(i)); - - return del; - } - - public void sortByPID(SequenceI s) { - float[] scores = new float[getHeight()]; - SequenceI[] seqs = new SequenceI[getHeight()]; - - for (int i = 0; i < getHeight(); i++) { - scores[i] = Comparison.compare(getSequenceAt(i), s); - seqs[i] = getSequenceAt(i); } - QuickSort.sort(scores, 0, scores.length - 1, seqs); - - int len = 0; - - if ((getHeight() % 2) == 0) { - len = getHeight() / 2; - } else { - len = (getHeight() + 1) / 2; - } - - for (int i = 0; i < len; i++) { - SequenceI tmp = seqs[i]; - sequences.setElementAt(seqs[getHeight() - i - 1], i); - sequences.setElementAt(tmp, getHeight() - i - 1); - } - } - - public void sortByID() { - String[] ids = new String[getHeight()]; - SequenceI[] seqs = new SequenceI[getHeight()]; - - for (int i = 0; i < getHeight(); i++) { - ids[i] = getSequenceAt(i).getName(); - seqs[i] = getSequenceAt(i); - } - - QuickSort.sort(ids, seqs); - - int len = 0; - - if ((getHeight() % 2) == 0) { - len = getHeight() / 2; - } else { - len = (getHeight() + 1) / 2; - System.out.println("DEBUG:Sort len is odd = " + len); // log. - } - - for (int i = 0; i < len; i++) { - System.out.println("DEBUG:Swapping " + seqs[i].getName() + " and " + - seqs[getHeight() - i - 1].getName()); // log. - - SequenceI tmp = seqs[i]; - sequences.setElementAt(seqs[getHeight() - i - 1], i); - sequences.setElementAt(tmp, getHeight() - i - 1); - } + return del; } /** */ - public SequenceGroup findGroup(int i) { + public SequenceGroup findGroup(int i) + { return findGroup(getSequenceAt(i)); } /** */ - public SequenceGroup findGroup(SequenceI s) { - for (int i = 0; i < this.groups.size(); i++) { + public SequenceGroup findGroup(SequenceI s) + { + for (int i = 0; i < this.groups.size(); i++) + { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if (sg.sequences.contains(s)) { + if (sg.sequences.contains(s)) + { return sg; } } @@ -329,13 +323,23 @@ public class Alignment implements AlignmentI { return null; } - public SequenceGroup[] findAllGroups(SequenceI s) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceGroup[] findAllGroups(SequenceI s) + { Vector temp = new Vector(); - for (int i = 0; i < this.groups.size(); i++) { + for (int i = 0; i < this.groups.size(); i++) + { SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - if (sg.sequences.contains(s)) { + if (sg.sequences.contains(s)) + { temp.addElement(sg); } } @@ -343,44 +347,48 @@ public class Alignment implements AlignmentI { SequenceGroup[] ret = new SequenceGroup[temp.size()]; for (int i = 0; i < temp.size(); i++) + { ret[i] = (SequenceGroup) temp.elementAt(i); - - return ret; - } - - /** */ - public void addToGroup(SequenceGroup g, SequenceI s) { - if (!(g.sequences.contains(s))) { - g.sequences.addElement(s); } - } - /** */ - public void removeFromGroup(SequenceGroup g, SequenceI s) { - if ((g != null) && (g.sequences != null)) { - if (g.sequences.contains(s)) { - g.sequences.removeElement(s); - - if (g.sequences.size() == 0) { - groups.removeElement(g); - } - } - } + return ret; } - public void addSuperGroup(SuperGroup sg) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void addSuperGroup(SuperGroup sg) + { superGroup.addElement(sg); } - public void removeSuperGroup(SuperGroup sg) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void removeSuperGroup(SuperGroup sg) + { superGroup.removeElement(sg); } - public SuperGroup getSuperGroup(SequenceGroup sg) { - for (int i = 0; i < this.superGroup.size(); i++) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SuperGroup getSuperGroup(SequenceGroup sg) + { + for (int i = 0; i < this.superGroup.size(); i++) + { SuperGroup temp = (SuperGroup) superGroup.elementAt(i); - if (temp.sequenceGroups.contains(sg)) { + if (temp.sequenceGroups.contains(sg)) + { return temp; } } @@ -389,19 +397,26 @@ public class Alignment implements AlignmentI { } /** */ - public void addGroup(SequenceGroup sg) { - if (!groups.contains(sg)) { + public void addGroup(SequenceGroup sg) + { + if (!groups.contains(sg)) + { groups.addElement(sg); } } - public void deleteAllGroups() { + /** + * DOCUMENT ME! + */ + public void deleteAllGroups() + { groups.removeAllElements(); superGroup.removeAllElements(); int i = 0; - while (i < sequences.size()) { + while (i < sequences.size()) + { SequenceI s = getSequenceAt(i); s.setColor(java.awt.Color.white); i++; @@ -409,20 +424,25 @@ public class Alignment implements AlignmentI { } /** */ - public void deleteGroup(SequenceGroup g) { - if (groups.contains(g)) { + public void deleteGroup(SequenceGroup g) + { + if (groups.contains(g)) + { groups.removeElement(g); } } /** */ - public SequenceI findName(String name) { + public SequenceI findName(String name) + { int i = 0; - while (i < sequences.size()) { + while (i < sequences.size()) + { SequenceI s = getSequenceAt(i); - if (s.getName().equals(name)) { + if (s.getName().equals(name)) + { return s; } @@ -433,13 +453,16 @@ public class Alignment implements AlignmentI { } /** */ - public SequenceI findbyDisplayId(String name) { + public SequenceI findbyDisplayId(String name) + { int i = 0; - while (i < sequences.size()) { + while (i < sequences.size()) + { SequenceI s = getSequenceAt(i); - if (s.getDisplayId().equals(name)) { + if (s.getDisplayId().equals(name)) + { return s; } @@ -450,11 +473,14 @@ public class Alignment implements AlignmentI { } /** */ - public int findIndex(SequenceI s) { + public int findIndex(SequenceI s) + { int i = 0; - while (i < sequences.size()) { - if (s == getSequenceAt(i)) { + while (i < sequences.size()) + { + if (s == getSequenceAt(i)) + { return i; } @@ -464,15 +490,29 @@ public class Alignment implements AlignmentI { return -1; } - public int getHeight() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getHeight() + { return sequences.size(); } - public int getWidth() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getWidth() + { int maxLength = -1; - for (int i = 0; i < sequences.size(); i++) { - if (getSequenceAt(i).getLength() > maxLength) { + for (int i = 0; i < sequences.size(); i++) + { + if (getSequenceAt(i).getLength() > maxLength) + { maxLength = getSequenceAt(i).getLength(); } } @@ -480,16 +520,24 @@ public class Alignment implements AlignmentI { return maxLength; } - public int getMaxIdLength() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getMaxIdLength() + { int max = 0; int i = 0; - while (i < sequences.size()) { + while (i < sequences.size()) + { SequenceI seq = getSequenceAt(i); String tmp = seq.getName() + "/" + seq.getStart() + "-" + seq.getEnd(); - if (tmp.length() > max) { + if (tmp.length() > max) + { max = tmp.length(); } @@ -499,10 +547,17 @@ public class Alignment implements AlignmentI { return max; } - public void setGapCharacter(char gc) { + /** + * DOCUMENT ME! + * + * @param gc DOCUMENT ME! + */ + public void setGapCharacter(char gc) + { gapCharacter = gc; - for (int i = 0; i < sequences.size(); i++) { + for (int i = 0; i < sequences.size(); i++) + { Sequence seq = (Sequence) sequences.elementAt(i); seq.sequence = seq.sequence.replace('.', gc); seq.sequence = seq.sequence.replace('-', gc); @@ -510,29 +565,57 @@ public class Alignment implements AlignmentI { } } - public char getGapCharacter() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public char getGapCharacter() + { return gapCharacter; } - public Vector getAAFrequency() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getAAFrequency() + { return AAFrequency.calculate(sequences, 0, getWidth()); } - public boolean isAligned() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean isAligned() + { int width = getWidth(); for (int i = 0; i < sequences.size(); i++) - if (getSequenceAt(i).getLength() != width) { + { + if (getSequenceAt(i).getLength() != width) + { return false; } + } return true; } - public void deleteAnnotation(AlignmentAnnotation aa) { + /** + * DOCUMENT ME! + * + * @param aa DOCUMENT ME! + */ + public void deleteAnnotation(AlignmentAnnotation aa) + { int aSize = 1; - if (annotations != null) { + if (annotations != null) + { aSize = annotations.length; } @@ -540,8 +623,10 @@ public class Alignment implements AlignmentI { int tIndex = 0; - for (int i = 0; i < aSize; i++) { - if (annotations[i] == aa) { + for (int i = 0; i < aSize; i++) + { + if (annotations[i] == aa) + { continue; } @@ -552,19 +637,29 @@ public class Alignment implements AlignmentI { annotations = temp; } - public void addAnnotation(AlignmentAnnotation aa) { + /** + * DOCUMENT ME! + * + * @param aa DOCUMENT ME! + */ + public void addAnnotation(AlignmentAnnotation aa) + { int aSize = 1; - if (annotations != null) { + if (annotations != null) + { aSize = annotations.length + 1; } AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize]; int i = 0; - if (aSize > 1) { + if (aSize > 1) + { for (i = 0; i < (aSize - 1); i++) + { temp[i] = annotations[i]; + } } temp[i] = aa; @@ -572,7 +667,13 @@ public class Alignment implements AlignmentI { annotations = temp; } - public AlignmentAnnotation[] getAlignmentAnnotation() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public AlignmentAnnotation[] getAlignmentAnnotation() + { return annotations; } } diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 35297b5..9cfdff6 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -18,63 +18,121 @@ */ package jalview.datamodel; -public class AlignmentAnnotation { + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class AlignmentAnnotation +{ + /** DOCUMENT ME!! */ public String label; + + /** DOCUMENT ME!! */ public String description; + + /** DOCUMENT ME!! */ public Annotation[] annotations; + + /** DOCUMENT ME!! */ public boolean isGraph = false; + + /** DOCUMENT ME!! */ public float graphMin; + + /** DOCUMENT ME!! */ public float graphMax; + + /** DOCUMENT ME!! */ public int windowLength; // Graphical hints and tips + + /** DOCUMENT ME!! */ public boolean editable = false; + + /** DOCUMENT ME!! */ public boolean hasIcons; // + + /** DOCUMENT ME!! */ public boolean hasText; + + /** DOCUMENT ME!! */ public boolean visible = true; + + /** DOCUMENT ME!! */ public int height = 0; + /** + * Creates a new AlignmentAnnotation object. + * + * @param label DOCUMENT ME! + * @param description DOCUMENT ME! + * @param annotations DOCUMENT ME! + */ public AlignmentAnnotation(String label, String description, - Annotation[] annotations) { + Annotation[] annotations) + { // always editable? editable = true; this.label = label; this.description = description; this.annotations = annotations; - for (int i = 0; i < annotations.length; i++) { + for (int i = 0; i < annotations.length; i++) + { if ((annotations[i] != null) && ((annotations[i].secondaryStructure == 'H') || - (annotations[i].secondaryStructure == 'E'))) { + (annotations[i].secondaryStructure == 'E'))) + { hasIcons = true; } if ((annotations[i] != null) && - (annotations[i].displayCharacter.length() > 0)) { + (annotations[i].displayCharacter.length() > 0)) + { hasText = true; } } } + /** + * Creates a new AlignmentAnnotation object. + * + * @param label DOCUMENT ME! + * @param description DOCUMENT ME! + * @param annotations DOCUMENT ME! + * @param min DOCUMENT ME! + * @param max DOCUMENT ME! + * @param winLength DOCUMENT ME! + */ public AlignmentAnnotation(String label, String description, - Annotation[] annotations, float min, float max, int winLength) { + Annotation[] annotations, float min, float max, int winLength) + { // graphs are not editable this.label = label; this.description = description; this.annotations = annotations; isGraph = true; - if (min == max) { - for (int i = 0; i < annotations.length; i++) { - if (annotations[i] == null) { + if (min == max) + { + for (int i = 0; i < annotations.length; i++) + { + if (annotations[i] == null) + { continue; } - if (annotations[i].value > max) { + if (annotations[i].value > max) + { max = annotations[i].value; } - if (annotations[i].value < min) { + if (annotations[i].value < min) + { min = annotations[i].value; } } @@ -84,30 +142,46 @@ public class AlignmentAnnotation { graphMax = max; windowLength = winLength; - for (int i = 0; i < annotations.length; i++) { + for (int i = 0; i < annotations.length; i++) + { if ((annotations[i] != null) && ((annotations[i].secondaryStructure == 'H') || - (annotations[i].secondaryStructure == 'E'))) { + (annotations[i].secondaryStructure == 'E'))) + { hasIcons = true; } if ((annotations[i] != null) && - (annotations[i].displayCharacter.length() > 0)) { + (annotations[i].displayCharacter.length() > 0)) + { hasText = true; } } } - public String toString() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String toString() + { StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < annotations.length; i++) { - if (annotations[i] != null) { - if (isGraph) { + for (int i = 0; i < annotations.length; i++) + { + if (annotations[i] != null) + { + if (isGraph) + { buffer.append(annotations[i].value); - } else if (hasIcons) { + } + else if (hasIcons) + { buffer.append(annotations[i].secondaryStructure); - } else { + } + else + { buffer.append(annotations[i].displayCharacter); } } @@ -115,11 +189,14 @@ public class AlignmentAnnotation { buffer.append(", "); } - if (label.equals("Consensus")) { + if (label.equals("Consensus")) + { buffer.append("\n"); - for (int i = 0; i < annotations.length; i++) { - if (annotations[i] != null) { + for (int i = 0; i < annotations.length; i++) + { + if (annotations[i] != null) + { buffer.append(annotations[i].description); } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 8a14a08..416be69 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -23,94 +23,270 @@ import java.util.*; /** Data structure to hold and manipulate a multiple sequence alignment */ -public interface AlignmentI { +public interface AlignmentI +{ + /** + * Calculates the number of sequences in an alignment + * + * @return Number of sequences in alignment + */ public int getHeight(); + /** + * Calculates the maximum width of the alignment, including gaps. + * + * @return Greatest sequence length within alignment. + */ public int getWidth(); + /** + * Calculates the longest sequence Id of the alignment + * + * @return Number of characters in longest sequence Id. + */ public int getMaxIdLength(); + /** + * Calculates if this set of sequences is all the same length + * + * @return true if all sequences in alignment are the same length + */ public boolean isAligned(); + /** + * Gets sequences as a Vector + * + * @return All sequences in alignment. + */ public Vector getSequences(); + /** + * Find a specific sequence in this alignment. + * + * @param i Index of required sequence. + * + * @return SequenceI at given index. + */ public SequenceI getSequenceAt(int i); + /** + * Add a new sequence to this alignment. + * + * @param seq New sequence will be added at end of alignment. + */ public void addSequence(SequenceI seq); + /** + * Used to set a particular index of the alignment with the given sequence. + * + * @param i Index of sequence to be updated. + * @param seq New sequence to be inserted. + */ public void setSequenceAt(int i, SequenceI seq); + /** + * Deletes a sequence from the alignment. + * + * @param s Sequence to be deleted. + */ public void deleteSequence(SequenceI s); + /** + * Deletes a sequence from the alignment. + * + * @param i Index of sequence to be deleted. + */ public void deleteSequence(int i); - public SequenceI[] getColumns(int start, int end); - - public SequenceI[] getColumns(int seq1, int seq2, int start, int end); - + /** + * Deletes all residues in every sequence of alignment within given columns. + * + * @param start Start index of columns to delete. + * @param end End index to columns to delete. + */ public void deleteColumns(int start, int end); + /** + * Deletes all residues in every sequence of alignment within given columns. + * + * @param seq1 Index of first sequence to delete columns from. + * @param seq2 Index of last sequence to delete columns from. + * @param start Start index of columns to delete. + * @param end End index of columns to delete. + */ public void deleteColumns(int seq1, int seq2, int start, int end); - public void insertColumns(SequenceI[] seqs, int pos); - + /** + * Finds sequence in alignment using sequence name as query. + * + * @param name Id of sequence to search for. + * + * @return Sequence matching query, if found. If not found returns null. + */ public SequenceI findName(String name); + /** + * Finds sequence in alignment using full displayId as query. + * + * @param name displayId, ie NAME/25-100 + * + * @return Sequence matching query, if found. If not found returns null. + */ public SequenceI findbyDisplayId(String name); + /** + * Finds index of a given sequence in the alignment. + * + * @param s Sequence to look for. + * + * @return Index of sequence within the alignment. + */ public int findIndex(SequenceI s); - // Modifying + /** + * All sequences will be cut from beginning to given index. + * + * @param i Remove all residues in sequences up to this column. + */ public void trimLeft(int i); + /** + * All sequences will be cut from given index. + * + * @param i Remove all residues in sequences beyond this column. + */ public void trimRight(int i); + /** + * Removes all columns containing entirely gap characters. + */ public void removeGaps(); + /** + * Removes redundant sequences from alignment. + * + * @param threshold Remove all sequences above the given threshold. + * @param sel Set of sequences which will have redundant sequences removed from. + * + * @return All sequences below redundancy threshold. + */ public Vector removeRedundancy(float threshold, Vector sel); - // Grouping methods + /** + * Finds group that sequence at index i in alignment is part of. + * + * @param i Index in alignment. + * + * @return First group found for sequence at position i. WARNING : + * Sequences may be members of several groups. This method is incomplete. + */ public SequenceGroup findGroup(int i); + /** + * Finds group that given sequence is part of. + * + * @param s Sequence in alignment. + * + * @return First group found for sequence. WARNING : + * Sequences may be members of several groups. This method is incomplete. + */ public SequenceGroup findGroup(SequenceI s); + /** + * Finds all groups that a given sequence is part of. + * + * @param s Sequence in alignment. + * + * @return All groups containing given sequence. + */ public SequenceGroup[] findAllGroups(SequenceI s); - public void addToGroup(SequenceGroup g, SequenceI s); - - public void removeFromGroup(SequenceGroup g, SequenceI s); - + /** + * Adds a new SequenceGroup to this alignment. + * + * @param sg New group to be added. + */ public void addGroup(SequenceGroup sg); + /** + * Deletes a specific SequenceGroup + * + * @param g Group will be deleted from alignment. + */ public void deleteGroup(SequenceGroup g); + /** + * Get all the groups associated with this alignment. + * + * @return All groups as a Vector. + */ public Vector getGroups(); + /** + * Deletes all groups from this alignment. + */ public void deleteAllGroups(); + /** + * Adds a super group. A SuperGroup is a group of groups. + * + * @param sg Adds a new SuperGroup to alignment + */ public void addSuperGroup(SuperGroup sg); + /** + * Removes SuperGroup from alignment. + * + * @param sg This SuperGroup will be deleted from alignment. + */ public void removeSuperGroup(SuperGroup sg); + /** + * Finds any SuperGroup that a given SequenceGroup may be part of. + * + * @param sg SequenceGroup to search for. + * + * @return SuperGroup that contains the given SequenceGroup. + */ public SuperGroup getSuperGroup(SequenceGroup sg); - // Sorting - public void sortGroups(); - - public void sortByPID(SequenceI s); - - public void sortByID(); - - //Annotations + /** + * Adds a new AlignmentAnnotation to this alignment + */ public void addAnnotation(AlignmentAnnotation aa); + /** + * Deletes a specific AlignmentAnnotation from the alignment. + * + * @param aa DOCUMENT ME! + */ public void deleteAnnotation(AlignmentAnnotation aa); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public AlignmentAnnotation[] getAlignmentAnnotation(); + /** + * DOCUMENT ME! + * + * @param gc DOCUMENT ME! + */ public void setGapCharacter(char gc); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public char getGapCharacter(); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public Vector getAAFrequency(); } diff --git a/src/jalview/datamodel/AlignmentOrder.java b/src/jalview/datamodel/AlignmentOrder.java index c0da1fc..1fa3b96 100755 --- a/src/jalview/datamodel/AlignmentOrder.java +++ b/src/jalview/datamodel/AlignmentOrder.java @@ -1,125 +1,184 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.datamodel; import java.util.*; -/** - *

Title:

- * - *

Description:

- * - *

Copyright: Copyright (c) 2004

- * - *

Company: Dundee University

- * - * @author not attributable - * @version 1.0 +/** + *

Title:

+ * + *

Description:

+ * + *

Copyright: Copyright (c) 2004

+ * + *

Company: Dundee University

+ * + * @author not attributable + * @version 1.0 */ -public class AlignmentOrder { +public class AlignmentOrder +{ // JBPNote : this method would return a vector containing all sequences in seqset // with those also contained in order at the beginning of the vector in the order // given by order. AlignmentSorter.vectorSubsetToArray already does this, but that method // should be here for completeness. - /* public Vector getOrder(AlignmentI seqset) - { - Vector perm = new Vector(seqset.getHeight()); - for (i=0, o = 0, n=seqset.getHeight(), p = Order.size(); i 20) { + if (aanum > 20) + { aanum = 20; } @@ -70,7 +102,11 @@ public class BinarySequence extends Sequence { } } - public void blosumEncode() { + /** + * DOCUMENT ME! + */ + public void blosumEncode() + { // Set all matrix to 0 dbinary = new double[getSequence().length() * 21]; @@ -79,35 +115,49 @@ public class BinarySequence extends Sequence { //for (int i = 0; i < dbinary.length; i++) { // dbinary[i] = 0.0; //} - for (int i = 0; i < getSequence().length(); i++) { + for (int i = 0; i < getSequence().length(); i++) + { int aanum = 20; - try { + try + { aanum = ((Integer) ResidueProperties.getAAHash().get(getSequence() .substring(i, i + 1))).intValue(); - } catch (NullPointerException e) { + } + catch (NullPointerException e) + { aanum = 20; } - if (aanum > 20) { + if (aanum > 20) + { aanum = 20; } // Do the blosum thing - for (int j = 0; j < 20; j++) { + for (int j = 0; j < 20; j++) + { dbinary[(i * nores) + j] = ResidueProperties.getBLOSUM62()[aanum][j]; } } } - public String toBinaryString() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String toBinaryString() + { String out = ""; - for (int i = 0; i < binary.length; i++) { + for (int i = 0; i < binary.length; i++) + { out += (new Integer(binary[i])).toString(); - if (i < (binary.length - 1)) { + if (i < (binary.length - 1)) + { out += " "; } } @@ -115,11 +165,23 @@ public class BinarySequence extends Sequence { return out; } - public double[] getDBinary() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public double[] getDBinary() + { return dbinary; } - public static void printMemory(Runtime rt) { + /** + * DOCUMENT ME! + * + * @param rt DOCUMENT ME! + */ + public static void printMemory(Runtime rt) + { System.out.println("DEBUG: Free memory = " + rt.freeMemory()); // log. } } diff --git a/src/jalview/datamodel/HistoryItem.java b/src/jalview/datamodel/HistoryItem.java index ed119e8..eb4979d 100755 --- a/src/jalview/datamodel/HistoryItem.java +++ b/src/jalview/datamodel/HistoryItem.java @@ -21,10 +21,24 @@ package jalview.datamodel; import java.util.*; -public class HistoryItem { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class HistoryItem +{ + /** DOCUMENT ME!! */ public static final int EDIT = 0; + + /** DOCUMENT ME!! */ public static final int SORT = 1; + + /** DOCUMENT ME!! */ public static final int HIDE = 2; + + /** DOCUMENT ME!! */ public static final int PASTE = 3; final int type; Vector sequences; @@ -32,14 +46,23 @@ public class HistoryItem { String description; Vector hiddenSeqs; - public HistoryItem(String description, AlignmentI al, int type) { + /** + * Creates a new HistoryItem object. + * + * @param description DOCUMENT ME! + * @param al DOCUMENT ME! + * @param type DOCUMENT ME! + */ + public HistoryItem(String description, AlignmentI al, int type) + { this.type = type; this.description = description; sequences = new Vector(); alignIndex = new Vector(); hiddenSeqs = new Vector(); - for (int i = 0; i < al.getHeight(); i++) { + for (int i = 0; i < al.getHeight(); i++) + { SequenceI seq = al.getSequenceAt(i); sequences.addElement(seq); alignIndex.addElement(i + ""); @@ -47,23 +70,55 @@ public class HistoryItem { } } - public int getType() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getType() + { return type; } - public Vector getSequences() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getSequences() + { return sequences; } - public String getDescription() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getDescription() + { return description; } - public Vector getHidden() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getHidden() + { return hiddenSeqs; } - public int getAlignIndex(int seq) { + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getAlignIndex(int seq) + { return Integer.parseInt(alignIndex.elementAt(seq).toString()); } } diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 3853af9..34c1cd9 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -27,7 +27,14 @@ import java.awt.*; import java.util.*; -public class Sequence implements SequenceI { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Sequence implements SequenceI +{ protected String name; protected String sequence; protected String description; @@ -36,9 +43,20 @@ public class Sequence implements SequenceI { protected String displayId; protected Color color = Color.white; String pdbId; + + /** DOCUMENT ME!! */ public Vector sequenceFeatures = new Vector(); - public Sequence(String name, String sequence, int start, int end) { + /** + * Creates a new Sequence object. + * + * @param name DOCUMENT ME! + * @param sequence DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + public Sequence(String name, String sequence, int start, int end) + { this.name = name; this.sequence = sequence; this.start = start; @@ -47,137 +65,295 @@ public class Sequence implements SequenceI { setDisplayId(); } - public Sequence(String name, String sequence) { + /** + * Creates a new Sequence object. + * + * @param name DOCUMENT ME! + * @param sequence DOCUMENT ME! + */ + public Sequence(String name, String sequence) + { this(name, sequence, 1, sequence.length()); } - public Sequence(SequenceI seq) { + /** + * Creates a new Sequence object. + * + * @param seq DOCUMENT ME! + */ + public Sequence(SequenceI seq) + { this(seq.getName(), seq.getSequence(), seq.getStart(), seq.getEnd()); } - public void setSequenceFeatures(Vector v) { + /** + * DOCUMENT ME! + * + * @param v DOCUMENT ME! + */ + public void setSequenceFeatures(Vector v) + { sequenceFeatures = v; } - public Vector getSequenceFeatures() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector getSequenceFeatures() + { return sequenceFeatures; } - public void setPDBId(String id) { + /** + * DOCUMENT ME! + * + * @param id DOCUMENT ME! + */ + public void setPDBId(String id) + { pdbId = id; } - public String getPDBId() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getPDBId() + { return pdbId; } - public String getDisplayId() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getDisplayId() + { return displayId; } - public void setDisplayId() { + /** + * DOCUMENT ME! + */ + public void setDisplayId() + { displayId = name + "/" + start + "-" + end; } - public void setName(String name) { + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + */ + public void setName(String name) + { this.name = name; setDisplayId(); } - public String getName() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getName() + { return this.name; } - public void setStart(int start) { + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + */ + public void setStart(int start) + { this.start = start; setDisplayId(); } - public int getStart() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getStart() + { return this.start; } - public void setEnd(int end) { + /** + * DOCUMENT ME! + * + * @param end DOCUMENT ME! + */ + public void setEnd(int end) + { this.end = end; setDisplayId(); } - public int getEnd() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getEnd() + { return this.end; } - public int getLength() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getLength() + { return this.sequence.length(); } - public void setSequence(String seq) { + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + */ + public void setSequence(String seq) + { this.sequence = seq; } - public String getSequence() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getSequence() + { return this.sequence; } - public String getSequence(int start, int end) { + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getSequence(int start, int end) + { // JBPNote - left to user to pad the result here (TODO:Decide on this policy) - if (start >= sequence.length()) { + if (start >= sequence.length()) + { return ""; } - if (end >= sequence.length()) { + if (end >= sequence.length()) + { end = sequence.length(); } return this.sequence.substring(start, end); } - public char getCharAt(int i) { - if (i < sequence.length()) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public char getCharAt(int i) + { + if (i < sequence.length()) + { return sequence.charAt(i); - } else { + } + else + { return ' '; } } - public void setDescription(String desc) { + /** + * DOCUMENT ME! + * + * @param desc DOCUMENT ME! + */ + public void setDescription(String desc) + { this.description = desc; } - public String getDescription() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getDescription() + { return this.description; } - public int findIndex(int pos) { + /** + * DOCUMENT ME! + * + * @param pos DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int findIndex(int pos) + { // returns the alignment position for a residue int j = start; int i = 0; - while ((i < sequence.length()) && (j <= end) && (j <= pos)) { + while ((i < sequence.length()) && (j <= end) && (j <= pos)) + { char c = sequence.charAt(i); - if (!jalview.util.Comparison.isGap((c))) { + if (!jalview.util.Comparison.isGap((c))) + { j++; } i++; } - if ((j == end) && (j < pos)) { + if ((j == end) && (j < pos)) + { return end + 1; - } else { + } + else + { return i; } } - public int findPosition(int i) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int findPosition(int i) + { // Returns the sequence position for an alignment position int j = 0; int pos = start; - while ((j < i) && (j < sequence.length())) { + while ((j < i) && (j < sequence.length())) + { char c = sequence.charAt(j); - if (!jalview.util.Comparison.isGap((c))) { + if (!jalview.util.Comparison.isGap((c))) + { pos++; } @@ -187,15 +363,23 @@ public class Sequence implements SequenceI { return pos; } - public int[] gapMap() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int[] gapMap() + { // Returns an int array giving the position of each residue in the sequence in the alignment String seq = jalview.analysis.AlignSeq.extractGaps("-. ", sequence); int[] map = new int[seq.length()]; int j = 0; int p = 0; - while (j < sequence.length()) { - if (!jalview.util.Comparison.isGap(sequence.charAt(j))) { + while (j < sequence.length()) + { + if (!jalview.util.Comparison.isGap(sequence.charAt(j))) + { map[p++] = j; } @@ -205,37 +389,73 @@ public class Sequence implements SequenceI { return map; } - public void deleteCharAt(int i) { - if (i >= sequence.length()) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void deleteCharAt(int i) + { + if (i >= sequence.length()) + { return; } sequence = sequence.substring(0, i) + sequence.substring(i + 1); } - public void deleteChars(int i, int j) { - if (i >= sequence.length()) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + */ + public void deleteChars(int i, int j) + { + if (i >= sequence.length()) + { return; } - if (j >= sequence.length()) { + if (j >= sequence.length()) + { sequence = sequence.substring(0, i); - } else { + } + else + { sequence = sequence.substring(0, i) + sequence.substring(j); } } - public void insertCharAt(int i, char c) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param c DOCUMENT ME! + */ + public void insertCharAt(int i, char c) + { insertCharAt(i, c, true); } - public void insertCharAt(int i, char c, boolean chop) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param c DOCUMENT ME! + * @param chop DOCUMENT ME! + */ + public void insertCharAt(int i, char c, boolean chop) + { String tmp = new String(sequence); - if (i < sequence.length()) { + if (i < sequence.length()) + { sequence = tmp.substring(0, i) + String.valueOf(c) + tmp.substring(i); - } else { + } + else + { // JBPNote : padding char at end of sequence. We'll not get away with this when we insert residues, I bet! char[] ch = new char[(1 + i) - sequence.length()]; @@ -246,11 +466,23 @@ public class Sequence implements SequenceI { } } - public void setColor(Color c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + */ + public void setColor(Color c) + { this.color = c; } - public Color getColor() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color getColor() + { return color; } } diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index 702af73..5bf4e88 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -1,35 +1,56 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.datamodel; -public class SequenceFeature { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SequenceFeature +{ int begin; int end; String type; String description; String status; - public SequenceFeature() { + /** + * Creates a new SequenceFeature object. + */ + public SequenceFeature() + { } + /** + * Creates a new SequenceFeature object. + * + * @param type DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param description DOCUMENT ME! + * @param status DOCUMENT ME! + */ public SequenceFeature(String type, int start, int end, String description, - String status) { + String status) + { this.type = type; this.begin = start; this.end = end; @@ -37,62 +58,92 @@ public class SequenceFeature { this.status = status; } - public int getStart() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getStart() + { return begin; } - public int getEnd() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getEnd() + { return end; } - public String getType() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getType() + { return type; } - public String getDescription() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getDescription() + { return description; } - public String getStatus() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getStatus() + { return status; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ } diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index a262257..054896b 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -20,311 +20,481 @@ package jalview.datamodel; import jalview.analysis.*; -import jalview.datamodel.*; - import jalview.schemes.*; import java.awt.*; -import java.util.Vector; +import java.util.*; + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class SequenceGroup { - String groupName; - Conservation conserve; - Vector aaFrequency; - boolean displayBoxes; - boolean displayText; - boolean colourText; - public Vector sequences = new Vector(); - int width = -1; - public ColourSchemeI cs; - int startRes = 0; - int endRes = 0; - Color outlineColour = Color.black; - - public SequenceGroup() - { - groupName = "Group"; - this.displayBoxes = true; - this.displayText = true; - this.colourText = false; - cs = null; - } - - public SequenceGroup(Vector sequences, String groupName, ColourSchemeI scheme, - boolean displayBoxes, boolean displayText, - boolean colourText, - int start, int end) - { - this.sequences = sequences; - this.groupName = groupName; - this.displayBoxes = displayBoxes; - this.displayText = displayText; - this.colourText = colourText; - this.cs = scheme; - startRes = start; - endRes = end; - recalcConservation(); - } - - public SequenceGroup(String groupName, ColourSchemeI scheme, - boolean displayBoxes, boolean displayText, - boolean colourText, - int start, int end) - { - this.groupName = groupName; - this.displayBoxes = displayBoxes; - this.displayText = displayText; - this.colourText = colourText; - this.cs = scheme; - startRes = start; - endRes = end; - } - - public boolean adjustForRemoveLeft(int col) - { - // return value is true if the group still exists - if (startRes >= col) + String groupName; + Conservation conserve; + Vector aaFrequency; + boolean displayBoxes; + boolean displayText; + boolean colourText; + + /** DOCUMENT ME!! */ + public Vector sequences = new Vector(); + int width = -1; + + /** DOCUMENT ME!! */ + public ColourSchemeI cs; + int startRes = 0; + int endRes = 0; + Color outlineColour = Color.black; + + /** + * Creates a new SequenceGroup object. + */ + public SequenceGroup() { - startRes = startRes - col; + groupName = "Group"; + this.displayBoxes = true; + this.displayText = true; + this.colourText = false; + cs = null; } - if (endRes >= col) + /** + * Creates a new SequenceGroup object. + * + * @param sequences DOCUMENT ME! + * @param groupName DOCUMENT ME! + * @param scheme DOCUMENT ME! + * @param displayBoxes DOCUMENT ME! + * @param displayText DOCUMENT ME! + * @param colourText DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + public SequenceGroup(Vector sequences, String groupName, + ColourSchemeI scheme, boolean displayBoxes, boolean displayText, + boolean colourText, int start, int end) { - endRes = endRes - col; + this.sequences = sequences; + this.groupName = groupName; + this.displayBoxes = displayBoxes; + this.displayText = displayText; + this.colourText = colourText; + this.cs = scheme; + startRes = start; + endRes = end; + recalcConservation(); + } - if (startRes > endRes) - { - startRes = 0; - } + /** + * Creates a new SequenceGroup object. + * + * @param groupName DOCUMENT ME! + * @param scheme DOCUMENT ME! + * @param displayBoxes DOCUMENT ME! + * @param displayText DOCUMENT ME! + * @param colourText DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + public SequenceGroup(String groupName, ColourSchemeI scheme, + boolean displayBoxes, boolean displayText, boolean colourText, + int start, int end) + { + this.groupName = groupName; + this.displayBoxes = displayBoxes; + this.displayText = displayText; + this.colourText = colourText; + this.cs = scheme; + startRes = start; + endRes = end; } - else + + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean adjustForRemoveLeft(int col) { - // must delete this group!! - return false; + // return value is true if the group still exists + if (startRes >= col) + { + startRes = startRes - col; + } + + if (endRes >= col) + { + endRes = endRes - col; + + if (startRes > endRes) + { + startRes = 0; + } + } + else + { + // must delete this group!! + return false; + } + + return true; } - return true; - } + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean adjustForRemoveRight(int col) + { + if (startRes > col) + { + // delete this group + return false; + } + + if (endRes >= col) + { + endRes = col; + } - public boolean adjustForRemoveRight(int col) - { - if (startRes > col) + return true; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getName() { - // delete this group - return false; + return groupName; } - if (endRes >= col) + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + */ + public void setName(String name) { - endRes = col; + groupName = name; } - return true; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Conservation getConservation() + { + return conserve; + } - public String getName() - { - return groupName; - } + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + */ + public void setConservation(Conservation c) + { + conserve = c; + } - public void setName(String name) - { - groupName = name; - } + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param recalc DOCUMENT ME! + */ + public void addSequence(SequenceI s, boolean recalc) + { + if (!sequences.contains(s)) + { + sequences.addElement(s); + } - public Conservation getConservation() - { - return conserve; - } + if (recalc) + { + recalcConservation(); + } + } - public void setConservation(Conservation c) - { - conserve = c; - } + /** + * DOCUMENT ME! + */ + public void recalcConservation() + { + if (cs != null) + { + cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth())); + } - public void addSequence(SequenceI s, boolean recalc) - { - if (!sequences.contains(s)) - sequences.addElement(s); + if (cs instanceof ClustalxColourScheme) + { + ((ClustalxColourScheme) cs).resetClustalX(sequences, getWidth()); + } - if(recalc) - recalcConservation(); - } + if (cs instanceof ConservationColourScheme) + { + Conservation c = new Conservation(groupName, + ResidueProperties.propHash, 3, sequences, 0, getWidth()); + c.calculate(); + c.verdict(false, 25); + + ConservationColourScheme ccs = (ConservationColourScheme) cs; + ccs.conserve = c; + + if (ccs.cs instanceof ClustalxColourScheme) + { + ((ClustalxColourScheme) ccs.cs).resetClustalX(sequences, + getWidth()); + } + } + } + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param recalc DOCUMENT ME! + */ + public void addOrRemove(SequenceI s, boolean recalc) + { + if (sequences.contains(s)) + { + deleteSequence(s, recalc); + } + else + { + addSequence(s, recalc); + } + } - public void recalcConservation() - { - if (cs != null) + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param recalc DOCUMENT ME! + */ + public void deleteSequence(SequenceI s, boolean recalc) { - cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth())); + sequences.removeElement(s); + + if (recalc) + { + recalcConservation(); + } } - if (cs instanceof ClustalxColourScheme) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getStartRes() { - ( (ClustalxColourScheme) cs).resetClustalX(sequences,getWidth()); + return startRes; } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getEndRes() + { + return endRes; + } - if ( cs instanceof ConservationColourScheme) + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void setStartRes(int i) { - Conservation c = new Conservation(groupName, - ResidueProperties.propHash, 3, sequences, - 0, getWidth()); - c.calculate(); - c.verdict(false, 25); - - ConservationColourScheme ccs = (ConservationColourScheme) cs; - ccs.conserve = c; - if (ccs.cs instanceof ClustalxColourScheme) - { - ( (ClustalxColourScheme) ccs.cs).resetClustalX(sequences, getWidth()); - } + startRes = i; + } + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void setEndRes(int i) + { + endRes = i; } - } - public void addOrRemove(SequenceI s, boolean recalc) - { - if (sequences.contains(s)) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSize() { - deleteSequence(s, recalc); + return sequences.size(); } - else + + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI getSequenceAt(int i) + { + return (SequenceI) sequences.elementAt(i); + } + + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setColourText(boolean state) { - addSequence(s, recalc); + colourText = state; } - } - - public void deleteSequence(SequenceI s, boolean recalc) - { - sequences.removeElement(s); - if(recalc) - recalcConservation(); - } - - public int getStartRes() - { - return startRes; - } - - public int getEndRes() - { - return endRes; - } - - public void setStartRes(int i) - { - startRes = i; - } - - public void setEndRes(int i) - { - endRes = i; - } - - public int getSize() - { - return sequences.size(); - } - - public SequenceI getSequenceAt(int i) - { - return (SequenceI) sequences.elementAt(i); - } - - public void setColourText(boolean state) - { - colourText = state; - } - - public boolean getColourText() - { - return colourText; - } - - public void setDisplayText(boolean state) - { - displayText = state; - } - - public boolean getDisplayText() - { - return displayText; - } - - public void setDisplayBoxes(boolean state) - { - displayBoxes = state; - } - - public boolean getDisplayBoxes() - { - return displayBoxes; - } - - public int getWidth() - { - // MC This needs to get reset when characters are inserted and deleted - if (sequences.size() > 0) + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getColourText() { - width = ( (SequenceI) sequences.elementAt(0)).getLength(); + return colourText; } - for (int i = 1; i < sequences.size(); i++) + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setDisplayText(boolean state) { - SequenceI seq = (SequenceI) sequences.elementAt(i); + displayText = state; + } - if (seq.getLength() > width) - { - width = seq.getLength(); - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getDisplayText() + { + return displayText; } - return width; - } - - public void setOutlineColour(Color c) - { - outlineColour = c; - } - - public Color getOutlineColour() - { - return outlineColour; - } - - /** - * - * returns the sequences in the group ordered by the ordering given by al - * - * @param al Alignment - * @return SequenceI[] - */ - public SequenceI[] getSequencesInOrder(AlignmentI al) - { - int sz = sequences.size(); - java.util.Hashtable orderedSeqs = new java.util.Hashtable(); - SequenceI[] seqs = new SequenceI[sz]; - - for (int i = 0; i < sz; i++) + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setDisplayBoxes(boolean state) { - SequenceI seq = (SequenceI) sequences.elementAt(i); - int index = al.findIndex(seq); - orderedSeqs.put(index + "", seq); + displayBoxes = state; } - int index = 0; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getDisplayBoxes() + { + return displayBoxes; + } - for (int i = 0; i < al.getHeight(); i++) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getWidth() { - if (orderedSeqs.containsKey(i + "")) + // MC This needs to get reset when characters are inserted and deleted + if (sequences.size() > 0) { - seqs[index++] = (SequenceI) orderedSeqs.get(i + ""); + width = ((SequenceI) sequences.elementAt(0)).getLength(); } + + for (int i = 1; i < sequences.size(); i++) + { + SequenceI seq = (SequenceI) sequences.elementAt(i); + + if (seq.getLength() > width) + { + width = seq.getLength(); + } + } + + return width; + } + + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + */ + public void setOutlineColour(Color c) + { + outlineColour = c; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color getOutlineColour() + { + return outlineColour; } - return seqs; - } + /** + * + * returns the sequences in the group ordered by the ordering given by al + * + * @param al Alignment + * @return SequenceI[] + */ + public SequenceI[] getSequencesInOrder(AlignmentI al) + { + int sz = sequences.size(); + java.util.Hashtable orderedSeqs = new java.util.Hashtable(); + SequenceI[] seqs = new SequenceI[sz]; + + for (int i = 0; i < sz; i++) + { + SequenceI seq = (SequenceI) sequences.elementAt(i); + int index = al.findIndex(seq); + orderedSeqs.put(index + "", seq); + } + + int index = 0; + + for (int i = 0; i < al.getHeight(); i++) + { + if (orderedSeqs.containsKey(i + "")) + { + seqs[index++] = (SequenceI) orderedSeqs.get(i + ""); + } + } + + return seqs; + } } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index f16c009..b7c9197 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -1,82 +1,235 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.datamodel; -import jalview.jbgui.*; - import java.awt.*; -import java.util.Vector; - - -public interface SequenceI { +import java.util.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public interface SequenceI +{ + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + */ public void setName(String name); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getName(); + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + */ public void setStart(int start); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int getStart(); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getDisplayId(); + /** + * DOCUMENT ME! + * + * @param end DOCUMENT ME! + */ public void setEnd(int end); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int getEnd(); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int getLength(); + /** + * DOCUMENT ME! + * + * @param sequence DOCUMENT ME! + */ public void setSequence(String sequence); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getSequence(); + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getSequence(int start, int end); + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public char getCharAt(int i); + /** + * DOCUMENT ME! + * + * @param desc DOCUMENT ME! + */ public void setDescription(String desc); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getDescription(); + /** + * DOCUMENT ME! + * + * @param pos DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int findIndex(int pos); + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int findPosition(int i); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public int[] gapMap(); + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + */ public void deleteChars(int i, int j); + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ public void deleteCharAt(int i); + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param c DOCUMENT ME! + */ public void insertCharAt(int i, char c); + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param c DOCUMENT ME! + * @param chop DOCUMENT ME! + */ public void insertCharAt(int i, char c, boolean chop); + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + */ public void setColor(Color c); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public Color getColor(); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public Vector getSequenceFeatures(); + /** + * DOCUMENT ME! + * + * @param v DOCUMENT ME! + */ public void setSequenceFeatures(Vector v); + /** + * DOCUMENT ME! + * + * @param id DOCUMENT ME! + */ public void setPDBId(String id); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String getPDBId(); } diff --git a/src/jalview/datamodel/SequenceNode.java b/src/jalview/datamodel/SequenceNode.java index f86c63e..ac2e9e2 100755 --- a/src/jalview/datamodel/SequenceNode.java +++ b/src/jalview/datamodel/SequenceNode.java @@ -1,46 +1,88 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.datamodel; import java.awt.*; -public class SequenceNode extends BinaryNode { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SequenceNode extends BinaryNode +{ + /** DOCUMENT ME!! */ public float dist; + + /** DOCUMENT ME!! */ public int count; + + /** DOCUMENT ME!! */ public float height; + + /** DOCUMENT ME!! */ public float ycount; + + /** DOCUMENT ME!! */ public Color color = Color.black; + + /** DOCUMENT ME!! */ public boolean dummy = false; private boolean placeholder = false; - public SequenceNode() { + /** + * Creates a new SequenceNode object. + */ + public SequenceNode() + { super(); } - public SequenceNode(Object val, SequenceNode parent, float dist, String name) { + /** + * Creates a new SequenceNode object. + * + * @param val DOCUMENT ME! + * @param parent DOCUMENT ME! + * @param dist DOCUMENT ME! + * @param name DOCUMENT ME! + */ + public SequenceNode(Object val, SequenceNode parent, float dist, String name) + { super(val, parent, name); this.dist = dist; } + /** + * Creates a new SequenceNode object. + * + * @param val DOCUMENT ME! + * @param parent DOCUMENT ME! + * @param name DOCUMENT ME! + * @param dist DOCUMENT ME! + * @param bootstrap DOCUMENT ME! + * @param dummy DOCUMENT ME! + */ public SequenceNode(Object val, SequenceNode parent, String name, - float dist, int bootstrap, boolean dummy) { + float dist, int bootstrap, boolean dummy) + { super(val, parent, name); this.dist = dist; this.bootstrap = bootstrap; @@ -50,25 +92,41 @@ public class SequenceNode extends BinaryNode { /** * @param dummy true if node is created for the representation of polytomous trees */ - public boolean isDummy() { + public boolean isDummy() + { return dummy; } /* @param placeholder is true if the sequence refered to in the * element node is not actually present in the associated alignment */ - public boolean isPlaceholder() { + public boolean isPlaceholder() + { return placeholder; } - public boolean setDummy(boolean newstate) { + /** + * DOCUMENT ME! + * + * @param newstate DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean setDummy(boolean newstate) + { boolean oldstate = dummy; dummy = newstate; return oldstate; } - public void setPlaceholder(boolean Placeholder) { + /** + * DOCUMENT ME! + * + * @param Placeholder DOCUMENT ME! + */ + public void setPlaceholder(boolean Placeholder) + { this.placeholder = Placeholder; } @@ -76,12 +134,15 @@ public class SequenceNode extends BinaryNode { * ascends the tree but doesn't stop until a non-dummy node is discovered. * This will probably break if the tree is a mixture of BinaryNodes and SequenceNodes. */ - public SequenceNode AscendTree() { + public SequenceNode AscendTree() + { SequenceNode c = this; - do { + do + { c = (SequenceNode) c.parent(); - } while ((c != null) && c.dummy); + } + while ((c != null) && c.dummy); return c; } diff --git a/src/jalview/datamodel/SequencePoint.java b/src/jalview/datamodel/SequencePoint.java index fa91e59..2c5d2a3 100755 --- a/src/jalview/datamodel/SequencePoint.java +++ b/src/jalview/datamodel/SequencePoint.java @@ -1,35 +1,42 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.datamodel; -import java.awt.*; - -import java.util.*; - - -public class SequencePoint { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SequencePoint +{ // SMJS PUBLIC + + /** DOCUMENT ME!! */ public SequenceI sequence; + + /** DOCUMENT ME!! */ public float[] coord; // SMJS ENDPUBLIC - public SequencePoint(SequenceI sequence, float[] coord) { + public SequencePoint(SequenceI sequence, float[] coord) + { this.sequence = sequence; this.coord = coord; } diff --git a/src/jalview/datamodel/SuperGroup.java b/src/jalview/datamodel/SuperGroup.java index ad6f703..b2993b5 100755 --- a/src/jalview/datamodel/SuperGroup.java +++ b/src/jalview/datamodel/SuperGroup.java @@ -18,8 +18,6 @@ */ package jalview.datamodel; -import jalview.analysis.*; - import jalview.datamodel.*; import jalview.schemes.*; @@ -27,15 +25,28 @@ import jalview.schemes.*; import java.util.*; -public class SuperGroup { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SuperGroup +{ String groupName; boolean displayBoxes; boolean displayText; boolean colourText; + + /** DOCUMENT ME!! */ public ColourSchemeI cs; Vector sequenceGroups = new Vector(); - public SuperGroup() { + /** + * Creates a new SuperGroup object. + */ + public SuperGroup() + { groupName = "Super group"; this.displayBoxes = true; this.displayText = true; @@ -43,8 +54,18 @@ public class SuperGroup { cs = null; } + /** + * Creates a new SuperGroup object. + * + * @param groupName DOCUMENT ME! + * @param scheme DOCUMENT ME! + * @param displayBoxes DOCUMENT ME! + * @param displayText DOCUMENT ME! + * @param colourText DOCUMENT ME! + */ public SuperGroup(String groupName, ColourSchemeI scheme, - boolean displayBoxes, boolean displayText, boolean colourText) { + boolean displayBoxes, boolean displayText, boolean colourText) + { this.groupName = groupName; this.displayBoxes = displayBoxes; this.displayText = displayText; @@ -52,39 +73,80 @@ public class SuperGroup { this.cs = scheme; } - public String getName() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getName() + { return groupName; } - public void setName(String name) { + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + */ + public void setName(String name) + { groupName = name; } - public void addGroup(SequenceGroup sg) { - if (!sequenceGroups.contains(sg)) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void addGroup(SequenceGroup sg) + { + if (!sequenceGroups.contains(sg)) + { sequenceGroups.addElement(sg); } } - public void addOrRemove(SequenceGroup sg) { - if (sequenceGroups.contains(sg)) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void addOrRemove(SequenceGroup sg) + { + if (sequenceGroups.contains(sg)) + { deleteGroup(sg); - } else { + } + else + { addGroup(sg); } } - public void deleteGroup(SequenceGroup sg) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void deleteGroup(SequenceGroup sg) + { sequenceGroups.removeElement(sg); } - public void setSuperGroupProperties(SequenceGroup sg) { + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void setSuperGroupProperties(SequenceGroup sg) + { cs = sg.cs; colourText = sg.colourText; displayText = sg.displayText; displayBoxes = sg.displayBoxes; - for (int i = 0; i < sequenceGroups.size(); i++) { + for (int i = 0; i < sequenceGroups.size(); i++) + { SequenceGroup temp = (SequenceGroup) sequenceGroups.elementAt(i); temp.cs = sg.cs; temp.colourText = sg.colourText; @@ -93,11 +155,25 @@ public class SuperGroup { } } - public int getSize() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getSize() + { return sequenceGroups.size(); } - public SequenceGroup getGroupeAt(int i) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceGroup getGroupeAt(int i) + { return (SequenceGroup) sequenceGroups.elementAt(i); } } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 7499b4e..d154e2e 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -18,93 +18,185 @@ */ package jalview.gui; -import java.beans.*; -import java.util.*; +import jalview.analysis.*; + +import jalview.datamodel.*; + +import jalview.io.*; + +import jalview.jbgui.*; + +import jalview.schemes.*; + +import jalview.ws.*; import java.awt.*; import java.awt.datatransfer.*; import java.awt.event.*; import java.awt.print.*; + +import java.io.*; + +import java.beans.*; + +import java.util.*; + import javax.swing.*; import javax.swing.event.*; -import jalview.analysis.*; -import jalview.datamodel.*; -import jalview.io.*; -import jalview.jbgui.*; -import jalview.schemes.*; -import jalview.ws.*; -public class AlignFrame - extends GAlignFrame +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class AlignFrame extends GAlignFrame { - public static final int NEW_WINDOW_WIDTH = 700; - public static final int NEW_WINDOW_HEIGHT = 500; - final AlignmentPanel alignPanel; - final AlignViewport viewport; - public String currentFileFormat = "Jalview"; - Stack historyList = new Stack(); - Stack redoList = new Stack(); - private int treeCount = 0; - - public AlignFrame(AlignmentI al) - { - viewport = new AlignViewport(al); - - alignPanel = new AlignmentPanel(this, viewport); - alignPanel.annotationPanel.adjustPanelHeight(); - alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel. - annotationPanel.getPreferredSize()); - alignPanel.annotationScroller.setPreferredSize(alignPanel.annotationPanel. - getPreferredSize()); - alignPanel.setAnnotationVisible(viewport.getShowAnnotation()); - - getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER); - - addInternalFrameListener(new InternalFrameAdapter() - { - public void internalFrameActivated(InternalFrameEvent evt) - { - javax.swing.SwingUtilities.invokeLater(new Runnable() + /** DOCUMENT ME!! */ + public static final int NEW_WINDOW_WIDTH = 700; + + /** DOCUMENT ME!! */ + public static final int NEW_WINDOW_HEIGHT = 500; + final AlignmentPanel alignPanel; + final AlignViewport viewport; + + /** DOCUMENT ME!! */ + public String currentFileFormat = null; + Stack historyList = new Stack(); + Stack redoList = new Stack(); + private int treeCount = 0; + + /** + * Creates a new AlignFrame object. + * + * @param al DOCUMENT ME! + */ + public AlignFrame(AlignmentI al) + { + viewport = new AlignViewport(al); + + alignPanel = new AlignmentPanel(this, viewport); + alignPanel.annotationPanel.adjustPanelHeight(); + alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.annotationPanel.getPreferredSize()); + alignPanel.annotationScroller.setPreferredSize(alignPanel.annotationPanel.getPreferredSize()); + alignPanel.setAnnotationVisible(viewport.getShowAnnotation()); + + getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER); + + addInternalFrameListener(new InternalFrameAdapter() + { + public void internalFrameActivated(InternalFrameEvent evt) + { + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + alignPanel.requestFocus(); + } + }); + } + }); + } + + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void parseGroupsFile(String file) + { + try{ + BufferedReader in = new BufferedReader(new FileReader(file)); + SequenceI seq=null; + String line, text, token; + UserColourScheme ucs; + int index, start, end; + StringTokenizer st; + SequenceGroup sg; + while( (line = in.readLine())!=null) { - public void run() + st = new StringTokenizer(line, "\t"); + if(st.countTokens()!=6) { - alignPanel.requestFocus(); + System.out.println("Groups file "+file+" is invalid. Read help file."); + System.exit(1); } - }); - } - }); - } - public void saveAlignmentMenu_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), - new String[] - { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" - }, - new String[] + while(st.hasMoreElements()) + { + text = st.nextToken(); + token = st.nextToken(); + if(!token.equals("ID_NOT_SPECIFIED")) + { + index = viewport.alignment.findIndex(viewport.alignment.findName( + token)); + st.nextToken(); + } + else + index = Integer.parseInt( st.nextToken() ); + + start=Integer.parseInt( st.nextToken() ); + end = Integer.parseInt( st.nextToken() ); + ucs = new UserColourScheme(st.nextToken()); + + seq = viewport.alignment.getSequenceAt(index); + start = seq.findIndex(start)-1; + end = seq.findIndex(end)-1; + + sg = new SequenceGroup(text,ucs,true,true,false,start,end); + sg.addSequence( seq,true); + + viewport.alignment.addGroup(sg); + } + } + + }catch(Exception ex){System.out.println("Error parsing groups file: "+ex);} + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void saveAlignmentMenu_actionPerformed(ActionEvent e) + { + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), + new String[] + { + "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", + "jar" + }, + new String[] + { + "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" + }, currentFileFormat); + + chooser.setAcceptAllFileFilterUsed(false); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save Alignment to file"); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) { - "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" - }, currentFileFormat); + currentFileFormat = chooser.getSelectedFormat(); + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", + currentFileFormat); - chooser.setAcceptAllFileFilterUsed(false); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Save Alignment to file"); - chooser.setToolTipText("Save"); + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - int value = chooser.showSaveDialog(this); + saveAlignment(choice, currentFileFormat); + } + } - if (value == JalviewFileChooser.APPROVE_OPTION) + public boolean saveAlignment(String file, String format) { - currentFileFormat = chooser.getSelectedFormat(); - jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", - currentFileFormat); - - if (currentFileFormat.equals("Jalview")) + if (format.equalsIgnoreCase("Jalview")) { String shortName = title; @@ -114,1536 +206,1931 @@ public class AlignFrame java.io.File.separatorChar) + 1); } - String choice = chooser.getSelectedFile().getPath(); - Jalview2XML.SaveAlignment(this, choice, shortName); + Jalview2XML.SaveAlignment(this, file, shortName); // USE Jalview2XML to save this file - return; - } - - String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); - - String output = FormatAdapter.formatSequences(currentFileFormat, - viewport.getAlignment().getSequences()); - - try - { - java.io.PrintWriter out = new java.io.PrintWriter(new java.io. - FileWriter( - choice)); - out.println(output); - out.close(); + return true; } - catch (Exception ex) + else { + String output = FormatAdapter.formatSequences(format, + viewport.getAlignment(). + getSequences()); + if(output==null) + return false; + + try + { + java.io.PrintWriter out = new java.io.PrintWriter( + new java.io.FileWriter(file)); + out.println(output); + out.close(); + return true; + } + catch (Exception ex) + { + ex.printStackTrace(); + } } + return false; } - } - - protected void outputText_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - Desktop.addInternalFrame(cap, - "Alignment output - " + e.getActionCommand(), 600, - 500); - cap.setText(FormatAdapter.formatSequences(e.getActionCommand(), - viewport.getAlignment(). - getSequences())); - } - protected void htmlMenuItem_actionPerformed(ActionEvent e) - { - new HTMLOutput(viewport); - } - protected void createPNG_actionPerformed(ActionEvent e) - { - alignPanel.makePNG(); - } - - protected void epsFile_actionPerformed(ActionEvent e) - { - alignPanel.makeEPS(); - } - - public void printMenuItem_actionPerformed(ActionEvent e) - { - //Putting in a thread avoids Swing painting problems - PrintThread thread = new PrintThread(); - thread.start(); - } - - public void closeMenuItem_actionPerformed(ActionEvent e) - { - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void outputText_actionPerformed(ActionEvent e) { - this.setClosed(true); + CutAndPasteTransfer cap = new CutAndPasteTransfer(); + Desktop.addInternalFrame(cap, + "Alignment output - " + e.getActionCommand(), 600, 500); + cap.setText(FormatAdapter.formatSequences(e.getActionCommand(), + viewport.getAlignment().getSequences())); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void htmlMenuItem_actionPerformed(ActionEvent e) { + new HTMLOutput(viewport); } - } - void updateEditMenuBar() - { - if (historyList.size() > 0) + public void createImageMap(File file, String image) { - undoMenuItem.setEnabled(true); - - HistoryItem hi = (HistoryItem) historyList.peek(); - undoMenuItem.setText("Undo " + hi.getDescription()); + alignPanel.makePNGImageMap(file, image); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void createPNG(File f) { - undoMenuItem.setEnabled(false); - undoMenuItem.setText("Undo"); + alignPanel.makePNG(f); } - if (redoList.size() > 0) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void createEPS(File f) { - redoMenuItem.setEnabled(true); - - HistoryItem hi = (HistoryItem) redoList.peek(); - redoMenuItem.setText("Redo " + hi.getDescription()); + alignPanel.makeEPS(f); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void printMenuItem_actionPerformed(ActionEvent e) { - redoMenuItem.setEnabled(false); - redoMenuItem.setText("Redo"); + //Putting in a thread avoids Swing painting problems + PrintThread thread = new PrintThread(); + thread.start(); } - } - - public void addHistoryItem(HistoryItem hi) - { - historyList.push(hi); - updateEditMenuBar(); - } - - protected void undoMenuItem_actionPerformed(ActionEvent e) - { - HistoryItem hi = (HistoryItem) historyList.pop(); - redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment, - HistoryItem.HIDE)); - restoreHistoryItem(hi); - } - - protected void redoMenuItem_actionPerformed(ActionEvent e) - { - HistoryItem hi = (HistoryItem) redoList.pop(); - restoreHistoryItem(hi); - updateEditMenuBar(); - viewport.updateConsensus(); - alignPanel.repaint(); - alignPanel.repaint(); - } - // used by undo and redo - void restoreHistoryItem(HistoryItem hi) - { - if (hi.getType() == HistoryItem.SORT) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void closeMenuItem_actionPerformed(ActionEvent e) { - for (int i = 0; i < hi.getSequences().size(); i++) - { - viewport.alignment.getSequences().setElementAt(hi.getSequences() - .elementAt(i), - i); - } + try + { + this.setClosed(true); + } + catch (Exception ex) + { + } } - else - { - for (int i = 0; i < hi.getSequences().size(); i++) - { - SequenceI restore = (SequenceI) hi.getSequences().elementAt(i); - if (restore.getLength() == 0) + /** + * DOCUMENT ME! + */ + void updateEditMenuBar() + { + if (historyList.size() > 0) { - restore.setSequence(hi.getHidden().elementAt(i).toString()); - viewport.alignment.getSequences().insertElementAt(restore, - hi.getAlignIndex(i)); + undoMenuItem.setEnabled(true); + + HistoryItem hi = (HistoryItem) historyList.peek(); + undoMenuItem.setText("Undo " + hi.getDescription()); } else { - restore.setSequence(hi.getHidden().elementAt(i).toString()); + undoMenuItem.setEnabled(false); + undoMenuItem.setText("Undo"); } - } - if (hi.getType() == HistoryItem.PASTE) - { - for (int i = viewport.alignment.getHeight() - 1; - i > (hi.getSequences().size() - 1); i--) + if (redoList.size() > 0) { - viewport.alignment.deleteSequence(i); + redoMenuItem.setEnabled(true); + + HistoryItem hi = (HistoryItem) redoList.peek(); + redoMenuItem.setText("Redo " + hi.getDescription()); + } + else + { + redoMenuItem.setEnabled(false); + redoMenuItem.setText("Redo"); } - } } - updateEditMenuBar(); + /** + * DOCUMENT ME! + * + * @param hi DOCUMENT ME! + */ + public void addHistoryItem(HistoryItem hi) + { + historyList.push(hi); + updateEditMenuBar(); + } - viewport.updateConsensus(); - viewport.updateConservation(); - alignPanel.repaint(); - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void undoMenuItem_actionPerformed(ActionEvent e) + { + HistoryItem hi = (HistoryItem) historyList.pop(); + redoList.push(new HistoryItem(hi.getDescription(), viewport.alignment, + HistoryItem.HIDE)); + restoreHistoryItem(hi); + } - public void moveSelectedSequences(boolean up) - { - SequenceGroup sg = viewport.getSelectionGroup(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void redoMenuItem_actionPerformed(ActionEvent e) + { + HistoryItem hi = (HistoryItem) redoList.pop(); + restoreHistoryItem(hi); + updateEditMenuBar(); + viewport.updateConsensus(); + alignPanel.repaint(); + alignPanel.repaint(); + } - if (sg == null) + // used by undo and redo + void restoreHistoryItem(HistoryItem hi) { - return; + if (hi.getType() == HistoryItem.SORT) + { + for (int i = 0; i < hi.getSequences().size(); i++) + { + viewport.alignment.getSequences().setElementAt(hi.getSequences() + .elementAt(i), + i); + } + } + else + { + for (int i = 0; i < hi.getSequences().size(); i++) + { + SequenceI restore = (SequenceI) hi.getSequences().elementAt(i); + + if (restore.getLength() == 0) + { + restore.setSequence(hi.getHidden().elementAt(i).toString()); + viewport.alignment.getSequences().insertElementAt(restore, + hi.getAlignIndex(i)); + } + else + { + restore.setSequence(hi.getHidden().elementAt(i).toString()); + } + } + + if (hi.getType() == HistoryItem.PASTE) + { + for (int i = viewport.alignment.getHeight() - 1; + i > (hi.getSequences().size() - 1); i--) + { + viewport.alignment.deleteSequence(i); + } + } + } + + updateEditMenuBar(); + + viewport.updateConsensus(); + viewport.updateConservation(); + alignPanel.repaint(); + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); } - if (up) + /** + * DOCUMENT ME! + * + * @param up DOCUMENT ME! + */ + public void moveSelectedSequences(boolean up) { - for (int i = 1; i < viewport.alignment.getHeight(); i++) - { - SequenceI seq = viewport.alignment.getSequenceAt(i); + SequenceGroup sg = viewport.getSelectionGroup(); - if (!sg.sequences.contains(seq)) + if (sg == null) { - continue; + return; } - SequenceI temp = viewport.alignment.getSequenceAt(i - 1); + if (up) + { + for (int i = 1; i < viewport.alignment.getHeight(); i++) + { + SequenceI seq = viewport.alignment.getSequenceAt(i); + + if (!sg.sequences.contains(seq)) + { + continue; + } + + SequenceI temp = viewport.alignment.getSequenceAt(i - 1); - if (sg.sequences.contains(temp)) + if (sg.sequences.contains(temp)) + { + continue; + } + + viewport.alignment.getSequences().setElementAt(temp, i); + viewport.alignment.getSequences().setElementAt(seq, i - 1); + } + } + else { - continue; + for (int i = viewport.alignment.getHeight() - 2; i > -1; i--) + { + SequenceI seq = viewport.alignment.getSequenceAt(i); + + if (!sg.sequences.contains(seq)) + { + continue; + } + + SequenceI temp = viewport.alignment.getSequenceAt(i + 1); + + if (sg.sequences.contains(temp)) + { + continue; + } + + viewport.alignment.getSequences().setElementAt(temp, i); + viewport.alignment.getSequences().setElementAt(seq, i + 1); + } } - viewport.alignment.getSequences().setElementAt(temp, i); - viewport.alignment.getSequences().setElementAt(seq, i - 1); - } + alignPanel.repaint(); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void copy_actionPerformed(ActionEvent e) { - for (int i = viewport.alignment.getHeight() - 2; i > -1; i--) - { - SequenceI seq = viewport.alignment.getSequenceAt(i); + if (viewport.getSelectionGroup() == null) + { + return; + } + + SequenceGroup sg = viewport.getSelectionGroup(); - if (!sg.sequences.contains(seq)) + Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringBuffer buffer = new StringBuffer(); + + Hashtable orderedSeqs = new Hashtable(); + + for (int i = 0; i < sg.getSize(); i++) { - continue; + SequenceI seq = sg.getSequenceAt(i); + int index = viewport.alignment.findIndex(seq); + orderedSeqs.put(index + "", seq); } - SequenceI temp = viewport.alignment.getSequenceAt(i + 1); + int index = 0; - if (sg.sequences.contains(temp)) + for (int i = 0; i < sg.getSize(); i++) { - continue; + SequenceI seq = null; + + while (seq == null) + { + if (orderedSeqs.containsKey(index + "")) + { + seq = (SequenceI) orderedSeqs.get(index + ""); + index++; + + break; + } + else + { + index++; + } + } + + buffer.append(seq.getName() + "\t" + + seq.findPosition(sg.getStartRes()) + "\t" + + seq.findPosition(sg.getEndRes()) + "\t" + + sg.getSequenceAt(i).getSequence(sg.getStartRes(), + sg.getEndRes() + 1) + "\n"); } - viewport.alignment.getSequences().setElementAt(temp, i); - viewport.alignment.getSequences().setElementAt(seq, i + 1); - } + c.setContents(new StringSelection(buffer.toString()), null); } - alignPanel.repaint(); - } - - protected void copy_actionPerformed(ActionEvent e) - { - if (viewport.getSelectionGroup() == null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void pasteNew_actionPerformed(ActionEvent e) { - return; + paste(true); } - SequenceGroup sg = viewport.getSelectionGroup(); - - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuffer buffer = new StringBuffer(); - - Hashtable orderedSeqs = new Hashtable(); - - for (int i = 0; i < sg.getSize(); i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void pasteThis_actionPerformed(ActionEvent e) { - SequenceI seq = sg.getSequenceAt(i); - int index = viewport.alignment.findIndex(seq); - orderedSeqs.put(index + "", seq); + addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment, + HistoryItem.PASTE)); + paste(false); } - int index = 0; - - for (int i = 0; i < sg.getSize(); i++) + /** + * DOCUMENT ME! + * + * @param newAlignment DOCUMENT ME! + */ + void paste(boolean newAlignment) { - SequenceI seq = null; - - while (seq == null) - { - if (orderedSeqs.containsKey(index + "")) + try { - seq = (SequenceI) orderedSeqs.get(index + ""); - index++; - - break; + Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable contents = c.getContents(this); + + if (contents == null) + { + return; + } + + String str = (String) contents.getTransferData(DataFlavor.stringFlavor); + StringTokenizer st = new StringTokenizer(str); + ArrayList seqs = new ArrayList(); + + while (st.hasMoreElements()) + { + String name = st.nextToken(); + int start = Integer.parseInt(st.nextToken()); + int end = Integer.parseInt(st.nextToken()); + Sequence sequence = new Sequence(name, st.nextToken(), start, + end); + + if (!newAlignment) + { + viewport.alignment.addSequence(sequence); + } + else + { + seqs.add(sequence); + } + } + + if (newAlignment) + { + SequenceI[] newSeqs = new SequenceI[seqs.size()]; + seqs.toArray(newSeqs); + + AlignFrame af = new AlignFrame(new Alignment(newSeqs)); + String newtitle = new String("Copied sequences"); + + if (title.startsWith("Copied sequences")) + { + newtitle = title; + } + else + { + newtitle = newtitle.concat("- from " + title); + } + + Desktop.addInternalFrame(af, newtitle, NEW_WINDOW_WIDTH, + NEW_WINDOW_HEIGHT); + } + else + { + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); + viewport.setEndSeq(viewport.alignment.getHeight()); + viewport.alignment.getWidth(); + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); + } } - else + catch (Exception ex) { - index++; } - } - buffer.append(seq.getName() + "\t" + - seq.findPosition(sg.getStartRes()) + "\t" + - seq.findPosition(sg.getEndRes()) + "\t" + - sg.getSequenceAt(i).getSequence(sg.getStartRes(), - sg.getEndRes() + 1) + "\n"); + // could be anything being pasted in here } - c.setContents(new StringSelection(buffer.toString()), null); - } - - protected void pasteNew_actionPerformed(ActionEvent e) - { - paste(true); - } - - protected void pasteThis_actionPerformed(ActionEvent e) - { - addHistoryItem(new HistoryItem("Paste Sequences", viewport.alignment, - HistoryItem.PASTE)); - paste(false); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cut_actionPerformed(ActionEvent e) + { + copy_actionPerformed(null); + delete_actionPerformed(null); + } - void paste(boolean newAlignment) - { - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void delete_actionPerformed(ActionEvent e) { - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - Transferable contents = c.getContents(this); + boolean seqsdeleted = false; - if (contents == null) - { - return; - } + if (viewport.getSelectionGroup() == null) + { + return; + } - String str = (String) contents.getTransferData(DataFlavor.stringFlavor); - StringTokenizer st = new StringTokenizer(str); - ArrayList seqs = new ArrayList(); + addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, + HistoryItem.HIDE)); - while (st.hasMoreElements()) - { - String name = st.nextToken(); - int start = Integer.parseInt(st.nextToken()); - int end = Integer.parseInt(st.nextToken()); - Sequence sequence = new Sequence(name, st.nextToken(), start, - end); + SequenceGroup sg = viewport.getSelectionGroup(); - if (!newAlignment) + for (int i = 0; i < sg.sequences.size(); i++) { - viewport.alignment.addSequence(sequence); + SequenceI seq = sg.getSequenceAt(i); + int index = viewport.getAlignment().findIndex(seq); + seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1); + + if (seq.getSequence().length() < 1) + { + seqsdeleted = true; + viewport.getAlignment().deleteSequence(seq); + } + else + { + viewport.getAlignment().getSequences().setElementAt(seq, index); + } } - else - { - seqs.add(sequence); - } - } - if (newAlignment) - { - SequenceI[] newSeqs = new SequenceI[seqs.size()]; - seqs.toArray(newSeqs); - - AlignFrame af = new AlignFrame(new Alignment(newSeqs)); - String newtitle = new String("Copied sequences"); + viewport.setSelectionGroup(null); + viewport.alignment.deleteGroup(sg); - if (title.startsWith("Copied sequences")) + if (seqsdeleted) { - newtitle = title; + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); } - else + + viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getHeight()); + + if (viewport.getAlignment().getHeight() < 1) { - newtitle = newtitle.concat("- from " + title); + try + { + this.setClosed(true); + } + catch (Exception ex) + { + } } - Desktop.addInternalFrame(af, newtitle, NEW_WINDOW_WIDTH, - NEW_WINDOW_HEIGHT); - } - else - { - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); - viewport.setEndSeq(viewport.alignment.getHeight()); - viewport.alignment.getWidth(); viewport.updateConservation(); viewport.updateConsensus(); alignPanel.repaint(); - } } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void deleteGroups_actionPerformed(ActionEvent e) { + viewport.alignment.deleteAllGroups(); + viewport.setSelectionGroup(null); + alignPanel.repaint(); } - // could be anything being pasted in here - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) + { + SequenceGroup sg = new SequenceGroup(); - protected void cut_actionPerformed(ActionEvent e) - { - copy_actionPerformed(null); - delete_actionPerformed(null); - } + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + sg.addSequence(viewport.getAlignment().getSequenceAt(i), false); + } - protected void delete_actionPerformed(ActionEvent e) - { - boolean seqsdeleted = false; + sg.setEndRes(viewport.alignment.getWidth()); + viewport.setSelectionGroup(sg); + PaintRefresher.Refresh(null, viewport.alignment); + } - if (viewport.getSelectionGroup() == null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) { - return; + viewport.setSelectionGroup(null); + viewport.getColumnSelection().clear(); + viewport.setSelectionGroup(null); + alignPanel.annotationPanel.activeRes = null; + PaintRefresher.Refresh(null, viewport.alignment); } - addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, - HistoryItem.HIDE)); - - SequenceGroup sg = viewport.getSelectionGroup(); - - for (int i = 0; i < sg.sequences.size(); i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void invertSequenceMenuItem_actionPerformed(ActionEvent e) { - SequenceI seq = sg.getSequenceAt(i); - int index = viewport.getAlignment().findIndex(seq); - seq.deleteChars(sg.getStartRes(), sg.getEndRes() + 1); + SequenceGroup sg = viewport.getSelectionGroup(); - if (seq.getSequence().length() < 1) - { - seqsdeleted = true; - viewport.getAlignment().deleteSequence(seq); - } - else - { - viewport.getAlignment().getSequences().setElementAt(seq, index); - } - } + if (sg == null) + { + selectAllSequenceMenuItem_actionPerformed(null); - viewport.setSelectionGroup(null); - viewport.alignment.deleteGroup(sg); + return; + } - if (seqsdeleted) - { - viewport.firePropertyChange("alignment", null, - viewport.getAlignment().getSequences()); - } + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false); + } - viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getHeight()); + PaintRefresher.Refresh(null, viewport.alignment); + } - if (viewport.getAlignment().getHeight() < 1) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void remove2LeftMenuItem_actionPerformed(ActionEvent e) { - try - { - this.setClosed(true); - } - catch (Exception ex) - { - } - } + ColumnSelection colSel = viewport.getColumnSelection(); - viewport.updateConservation(); - viewport.updateConsensus(); - alignPanel.repaint(); - } + if (colSel.size() > 0) + { + addHistoryItem(new HistoryItem("Remove Left", viewport.alignment, + HistoryItem.HIDE)); - protected void deleteGroups_actionPerformed(ActionEvent e) - { - viewport.alignment.deleteAllGroups(); - viewport.setSelectionGroup(null); - alignPanel.repaint(); - } + int min = colSel.getMin(); + viewport.getAlignment().trimLeft(min); + colSel.compensateForEdit(0, min); - public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) - { - SequenceGroup sg = new SequenceGroup(); + if (viewport.getSelectionGroup() != null) + { + viewport.getSelectionGroup().adjustForRemoveLeft(min); + } - for (int i = 0; i < viewport.getAlignment().getSequences().size(); - i++) - { - sg.addSequence(viewport.getAlignment().getSequenceAt(i), false); - } + Vector groups = viewport.alignment.getGroups(); - sg.setEndRes(viewport.alignment.getWidth()); - viewport.setSelectionGroup(sg); - PaintRefresher.Refresh(null, viewport.alignment); - } + for (int i = 0; i < groups.size(); i++) + { + SequenceGroup sg = (SequenceGroup) groups.get(i); - public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) - { - viewport.setSelectionGroup(null); - viewport.getColumnSelection().clear(); - viewport.setSelectionGroup(null); - alignPanel.annotationPanel.activeRes=null; - PaintRefresher.Refresh(null, viewport.alignment); - } + if (!sg.adjustForRemoveLeft(min)) + { + viewport.alignment.deleteGroup(sg); + } + } - public void invertSequenceMenuItem_actionPerformed(ActionEvent e) - { - SequenceGroup sg = viewport.getSelectionGroup(); - if(sg==null) - { - selectAllSequenceMenuItem_actionPerformed(null); - return; + alignPanel.repaint(); + } } - for (int i = 0; i < viewport.getAlignment().getSequences().size(); - i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void remove2RightMenuItem_actionPerformed(ActionEvent e) { - sg.addOrRemove(viewport.getAlignment().getSequenceAt(i), false); - } - - PaintRefresher.Refresh(null, viewport.alignment); - } + ColumnSelection colSel = viewport.getColumnSelection(); - public void remove2LeftMenuItem_actionPerformed(ActionEvent e) - { - ColumnSelection colSel = viewport.getColumnSelection(); + if (colSel.size() > 0) + { + addHistoryItem(new HistoryItem("Remove Right", viewport.alignment, + HistoryItem.HIDE)); - if (colSel.size() > 0) - { - addHistoryItem(new HistoryItem("Remove Left", viewport.alignment, - HistoryItem.HIDE)); + int max = colSel.getMax(); + viewport.getAlignment().trimRight(max); - int min = colSel.getMin(); - viewport.getAlignment().trimLeft(min); - colSel.compensateForEdit(0, min); + if (viewport.getSelectionGroup() != null) + { + viewport.getSelectionGroup().adjustForRemoveRight(max); + } - if (viewport.getSelectionGroup() != null) - { - viewport.getSelectionGroup().adjustForRemoveLeft(min); - } + Vector groups = viewport.alignment.getGroups(); - Vector groups = viewport.alignment.getGroups(); + for (int i = 0; i < groups.size(); i++) + { + SequenceGroup sg = (SequenceGroup) groups.get(i); - for (int i = 0; i < groups.size(); i++) - { - SequenceGroup sg = (SequenceGroup) groups.get(i); + if (!sg.adjustForRemoveRight(max)) + { + viewport.alignment.deleteGroup(sg); + } + } - if (!sg.adjustForRemoveLeft(min)) - { - viewport.alignment.deleteGroup(sg); + alignPanel.repaint(); } - } - - alignPanel.repaint(); } - } - public void remove2RightMenuItem_actionPerformed(ActionEvent e) - { - ColumnSelection colSel = viewport.getColumnSelection(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Remove Gapped Columns", + viewport.alignment, HistoryItem.HIDE)); - if (colSel.size() > 0) + viewport.getAlignment().removeGaps(); + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void removeAllGapsMenuItem_actionPerformed(ActionEvent e) { - addHistoryItem(new HistoryItem("Remove Right", viewport.alignment, - HistoryItem.HIDE)); + addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment, + HistoryItem.HIDE)); - int max = colSel.getMax(); - viewport.getAlignment().trimRight(max); + SequenceI current; + int jSize; - if (viewport.getSelectionGroup() != null) - { - viewport.getSelectionGroup().adjustForRemoveRight(max); - } + Vector seqs = null; - Vector groups = viewport.alignment.getGroups(); + int start = 0; + int end = viewport.alignment.getWidth(); - for (int i = 0; i < groups.size(); i++) - { - SequenceGroup sg = (SequenceGroup) groups.get(i); + if (viewport.getSelectionGroup() != null) + { + seqs = viewport.getSelectionGroup().sequences; + start = viewport.getSelectionGroup().getStartRes(); + end = viewport.getSelectionGroup().getEndRes(); + } + else + { + seqs = viewport.alignment.getSequences(); + } - if (!sg.adjustForRemoveRight(max)) + for (int i = 0; i < seqs.size(); i++) { - viewport.alignment.deleteGroup(sg); + current = (SequenceI) seqs.elementAt(i); + jSize = current.getLength(); + + int j = start; + + do + { + if (jalview.util.Comparison.isGap(current.getCharAt(j))) + { + current.deleteCharAt(j); + j--; + jSize--; + } + + j++; + } + while (j < end); } - } - alignPanel.repaint(); + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); } - } - public void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) - { - addHistoryItem(new HistoryItem("Remove Gapped Columns", - viewport.alignment, HistoryItem.HIDE)); - - viewport.getAlignment().removeGaps(); - viewport.updateConservation(); - viewport.updateConsensus(); - alignPanel.repaint(); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void padGapsMenuitem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Pad Gaps", viewport.alignment, + HistoryItem.HIDE)); - public void removeAllGapsMenuItem_actionPerformed(ActionEvent e) - { - addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment, - HistoryItem.HIDE)); + SequenceI current; + int Width = viewport.getAlignment().getWidth(); - SequenceI current; - int jSize; + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + current = viewport.getAlignment().getSequenceAt(i); - Vector seqs=null; + if (current.getLength() < Width) + { + current.insertCharAt(Width - 1, viewport.getGapCharacter()); + } + } - int start=0, end = viewport.alignment.getWidth(); + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); + } - if(viewport.getSelectionGroup()!=null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void findMenuItem_actionPerformed(ActionEvent e) { - seqs = viewport.getSelectionGroup().sequences; - start = viewport.getSelectionGroup().getStartRes(); - end = viewport.getSelectionGroup().getEndRes(); + JInternalFrame frame = new JInternalFrame(); + Finder finder = new Finder(viewport, alignPanel, frame); + frame.setContentPane(finder); + Desktop.addInternalFrame(frame, "Find", 340, 110); + frame.setLayer(JLayeredPane.PALETTE_LAYER); } - else - seqs = viewport.alignment.getSequences(); - for (int i = 0; i 0)) || - (viewport.getAlignment().getHeight() < 4)) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void modifyConservation_actionPerformed(ActionEvent e) { - JOptionPane.showInternalMessageDialog(this, - "Principal component analysis must take\n" + - "at least 4 input sequences.", - "Sequence selection insufficient", - JOptionPane.WARNING_MESSAGE); - - return; + if (viewport.getConservationSelected()) + { + SliderPanel.setConservationSlider(alignPanel, + viewport.globalColourScheme, "Background"); + SliderPanel.showConservationSlider(); + } } - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void conservationMenuItem_actionPerformed(ActionEvent e) { - PCAPanel pcaPanel = new PCAPanel(viewport, null); - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(pcaPanel); - Desktop.addInternalFrame(frame, "Principal component analysis", - 400, 400); - } - catch (java.lang.OutOfMemoryError ex) - { - JOptionPane.showInternalMessageDialog(this, - "Too many sequences selected\nfor Principal Component Analysis!!", - "Out of memory", - JOptionPane.WARNING_MESSAGE); - } - } - - public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) - { - NewTreePanel("AV", "PID", "Average distance tree using PID"); - } - - public void neighbourTreeMenuItem_actionPerformed(ActionEvent e) - { - NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); - } - - protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) - { - NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); - } - - protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) - { - NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62"); - } - - void NewTreePanel(String type, String pwType, String title) - { - final TreePanel tp; - - if ( (viewport.getSelectionGroup() != null) && - (viewport.getSelectionGroup().getSize() > 3)) - { - int s = 0; - SequenceGroup sg = viewport.getSelectionGroup(); + viewport.setConservationSelected(conservationMenuItem.isSelected()); - /* Decide if the selection is a column region */ - while (s < sg.sequences.size()) - { - if ( ( (SequenceI) sg.sequences.elementAt(s++)).getLength() < - sg.getEndRes()) - { - JOptionPane.showMessageDialog(Desktop.desktop, - "The selected region to create a tree may\nonly contain residues or gaps.\n" + - "Try using the Pad function in the edit menu,\n" + - "or one of the multiple sequence alignment web services.", - "Sequences in selection are not aligned", - JOptionPane.WARNING_MESSAGE); + viewport.setAbovePIDThreshold(false); + abovePIDThreshold.setSelected(false); + + ColourSchemeI cs = viewport.getGlobalColourScheme(); - return; + if (cs instanceof ConservationColourScheme) + { + changeColour(((ConservationColourScheme) cs).cs); + } + else + { + changeColour(cs); } - } - title = title + " on region"; - tp = new TreePanel(viewport, - viewport.getSelectionGroup().sequences, type, pwType, - sg.getStartRes(), sg.getEndRes()); + modifyConservation_actionPerformed(null); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void abovePIDThreshold_actionPerformed(ActionEvent e) { - //are the sequences aligned? - if (!viewport.alignment.isAligned()) - { - JOptionPane.showMessageDialog(Desktop.desktop, - "The sequences must be aligned before creating a tree.\n" + - "Try using the Pad function in the edit menu,\n" + - "or one of the multiple sequence alignment web services.", - "Sequences not aligned", - JOptionPane.WARNING_MESSAGE); - - return; - } + viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected()); - tp = new TreePanel(viewport, - viewport.getAlignment().getSequences(), type, pwType, - 0, - viewport.alignment.getWidth()); - } + conservationMenuItem.setSelected(false); + viewport.setConservationSelected(false); - addTreeMenuItem(tp, title); - viewport.setCurrentTree(tp.getTree()); + ColourSchemeI cs = viewport.getGlobalColourScheme(); - Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500); - } + if (cs instanceof ConservationColourScheme) + { + changeColour(((ConservationColourScheme) cs).cs); + } + else + { + changeColour(cs); + } - public void addSortByOrderMenuItem(String title, final AlignmentOrder order) - { - final JMenuItem item = new JMenuItem("by " + title); - sort.add(item); - item.addActionListener(new java.awt.event.ActionListener() + modifyPID_actionPerformed(null); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void userDefinedColour_actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - addHistoryItem(new HistoryItem("Sort", viewport.alignment, - HistoryItem.SORT)); + new UserDefinedColours(alignPanel, null); + } - // TODO: JBPNote - have to map order entries to curent SequenceI pointers - AlignmentSorter.sortBy(viewport.getAlignment(), order); - alignPanel.repaint(); - } - }); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void PIDColour_actionPerformed(ActionEvent e) + { + changeColour(new PIDColourScheme()); + } - void addTreeMenuItem(final TreePanel treePanel, String title) - { - final JMenuItem item = new JMenuItem(title); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void BLOSUM62Colour_actionPerformed(ActionEvent e) + { + changeColour(new Blosum62ColourScheme()); + } - treeCount++; + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void sortPairwiseMenuItem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Pairwise Sort", viewport.alignment, + HistoryItem.SORT)); + AlignmentSorter.sortByPID(viewport.getAlignment(), + viewport.getAlignment().getSequenceAt(0)); + alignPanel.repaint(); + } - if (treeCount == 1) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void sortIDMenuItem_actionPerformed(ActionEvent e) { - sort.add(sortByTreeMenu); + addHistoryItem(new HistoryItem("ID Sort", viewport.alignment, + HistoryItem.SORT)); + AlignmentSorter.sortByID(viewport.getAlignment()); + alignPanel.repaint(); } - sortByTreeMenu.add(item); - item.addActionListener(new java.awt.event.ActionListener() + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void sortGroupMenuItem_actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - addHistoryItem(new HistoryItem("Tree Sort", - viewport.alignment, HistoryItem.SORT)); - AlignmentSorter.sortByTree(viewport.getAlignment(), - treePanel.getTree()); + addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, + HistoryItem.SORT)); + + AlignmentSorter.sortByGroup(viewport.getAlignment()); alignPanel.repaint(); - } - }); + } - treePanel.addInternalFrameListener(new javax.swing.event. - InternalFrameAdapter() + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void removeRedundancyMenuItem_actionPerformed(ActionEvent e) { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent evt) - { - treeCount--; - sortByTreeMenu.remove(item); + RedundancyPanel sp = new RedundancyPanel(alignPanel, this); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(sp); + Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, + 100, false); + } - if (treeCount == 0) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) + { + if ((viewport.getSelectionGroup() == null) || + (viewport.getSelectionGroup().getSize() < 2)) { - sort.remove(sortByTreeMenu); + JOptionPane.showInternalMessageDialog(this, + "You must select at least 2 sequences.", "Invalid Selection", + JOptionPane.WARNING_MESSAGE); } - } - ; - }); - viewport.addPropertyChangeListener(new java.beans.PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - if (evt.getPropertyName().equals("alignment")) + else { - treePanel.getTree().UpdatePlaceHolders( (Vector) evt.getNewValue()); - treePanel.repaint(); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(new PairwiseAlignPanel(viewport)); + Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500); } - } - }); - } - - public void clustalAlignMenuItem_actionPerformed(ActionEvent e) - { - // TODO:resolve which menu item was actually selected - // Now, check we have enough sequences - SequenceI[] msa = null; - - if ( (viewport.getSelectionGroup() != null) && - (viewport.getSelectionGroup().getSize() > 1)) - { - // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! - SequenceGroup seqs = viewport.getSelectionGroup(); - int sz; - msa = new SequenceI[sz = seqs.getSize()]; - - for (int i = 0; i < sz; i++) - { - msa[i] = (SequenceI) seqs.getSequenceAt(i); - } } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void PCAMenuItem_actionPerformed(ActionEvent e) { - Vector seqs = viewport.getAlignment().getSequences(); + if (((viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() < 4) && + (viewport.getSelectionGroup().getSize() > 0)) || + (viewport.getAlignment().getHeight() < 4)) + { + JOptionPane.showInternalMessageDialog(this, + "Principal component analysis must take\n" + + "at least 4 input sequences.", + "Sequence selection insufficient", JOptionPane.WARNING_MESSAGE); - if (seqs.size() > 1) - { - msa = new SequenceI[seqs.size()]; + return; + } - for (int i = 0; i < seqs.size(); i++) + try { - msa[i] = (SequenceI) seqs.elementAt(i); + PCAPanel pcaPanel = new PCAPanel(viewport, null); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(pcaPanel); + Desktop.addInternalFrame(frame, "Principal component analysis", + 400, 400); + } + catch (java.lang.OutOfMemoryError ex) + { + JOptionPane.showInternalMessageDialog(this, + "Too many sequences selected\nfor Principal Component Analysis!!", + "Out of memory", JOptionPane.WARNING_MESSAGE); } - } } - if (msa != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) { - jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", - title, msa, false, true); + NewTreePanel("AV", "PID", "Average distance tree using PID"); } - } - public void ClustalRealign_actionPerformed(ActionEvent e) - { - // TODO:resolve which menu item was actually selected - // Now, check we have enough sequences - SequenceI[] msa = null; - - if ( (viewport.getSelectionGroup() != null) && - (viewport.getSelectionGroup().getSize() > 1)) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void neighbourTreeMenuItem_actionPerformed(ActionEvent e) { - // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! - SequenceGroup seqs = viewport.getSelectionGroup(); - int sz; - msa = new SequenceI[sz = seqs.getSize()]; + NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); + } - for (int i = 0; i < sz; i++) - { - msa[i] = (SequenceI) seqs.getSequenceAt(i); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) + { + NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) { - Vector seqs = viewport.getAlignment().getSequences(); + NewTreePanel("AV", "BL", "Average distance tree using BLOSUM62"); + } - if (seqs.size() > 1) - { - msa = new SequenceI[seqs.size()]; + /** + * DOCUMENT ME! + * + * @param type DOCUMENT ME! + * @param pwType DOCUMENT ME! + * @param title DOCUMENT ME! + */ + void NewTreePanel(String type, String pwType, String title) + { + final TreePanel tp; - for (int i = 0; i < seqs.size(); i++) + if ((viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() > 3)) { - msa[i] = (SequenceI) seqs.elementAt(i); + int s = 0; + SequenceGroup sg = viewport.getSelectionGroup(); + + /* Decide if the selection is a column region */ + while (s < sg.sequences.size()) + { + if (((SequenceI) sg.sequences.elementAt(s++)).getLength() < sg.getEndRes()) + { + JOptionPane.showMessageDialog(Desktop.desktop, + "The selected region to create a tree may\nonly contain residues or gaps.\n" + + "Try using the Pad function in the edit menu,\n" + + "or one of the multiple sequence alignment web services.", + "Sequences in selection are not aligned", + JOptionPane.WARNING_MESSAGE); + + return; + } + } + + title = title + " on region"; + tp = new TreePanel(viewport, + viewport.getSelectionGroup().sequences, type, pwType, + sg.getStartRes(), sg.getEndRes()); } - } + else + { + //are the sequences aligned? + if (!viewport.alignment.isAligned()) + { + JOptionPane.showMessageDialog(Desktop.desktop, + "The sequences must be aligned before creating a tree.\n" + + "Try using the Pad function in the edit menu,\n" + + "or one of the multiple sequence alignment web services.", + "Sequences not aligned", JOptionPane.WARNING_MESSAGE); + + return; + } + + tp = new TreePanel(viewport, + viewport.getAlignment().getSequences(), type, pwType, 0, + viewport.alignment.getWidth()); + } + + addTreeMenuItem(tp, title); + viewport.setCurrentTree(tp.getTree()); + + Desktop.addInternalFrame(tp, title + " from " + this.title, 600, 500); } - if (msa != null) + /** + * DOCUMENT ME! + * + * @param title DOCUMENT ME! + * @param order DOCUMENT ME! + */ + public void addSortByOrderMenuItem(String title, final AlignmentOrder order) { - jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", - title, msa, true, true); - } - } + final JMenuItem item = new JMenuItem("by " + title); + sort.add(item); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Sort", viewport.alignment, + HistoryItem.SORT)); - protected void jpred_actionPerformed(ActionEvent e) - { - SequenceI seq = null; - SequenceI[] msa = null; + // TODO: JBPNote - have to map order entries to curent SequenceI pointers + AlignmentSorter.sortBy(viewport.getAlignment(), order); + alignPanel.repaint(); + } + }); + } - if ( (viewport.getSelectionGroup() != null) && - (viewport.getSelectionGroup().getSize() > 0)) + /** + * DOCUMENT ME! + * + * @param treePanel DOCUMENT ME! + * @param title DOCUMENT ME! + */ + void addTreeMenuItem(final TreePanel treePanel, String title) { - // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! - SequenceGroup seqs = viewport.getSelectionGroup(); + final JMenuItem item = new JMenuItem(title); - if ( (seqs.getSize() == 1) || !viewport.alignment.isAligned()) - { - seq = (SequenceI) seqs.getSequenceAt(0); - } - else - { - int sz; - msa = new SequenceI[sz = seqs.getSize()]; + treeCount++; - for (int i = 0; i < sz; i++) + if (treeCount == 1) { - msa[i] = (SequenceI) seqs.getSequenceAt(i); + sort.add(sortByTreeMenu); } - } - } - else - { - Vector seqs = viewport.getAlignment().getSequences(); - if ( (seqs.size() == 1) || !viewport.alignment.isAligned()) - { - seq = (SequenceI) seqs.elementAt(0); - } - else - { - msa = new SequenceI[seqs.size()]; + sortByTreeMenu.add(item); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Tree Sort", + viewport.alignment, HistoryItem.SORT)); + AlignmentSorter.sortByTree(viewport.getAlignment(), + treePanel.getTree()); + alignPanel.repaint(); + } + }); + + treePanel.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent evt) + { + treeCount--; + sortByTreeMenu.remove(item); + + if (treeCount == 0) + { + sort.remove(sortByTreeMenu); + } + } + ; + }); + viewport.addPropertyChangeListener(new java.beans.PropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent evt) + { + if (evt.getPropertyName().equals("alignment")) + { + treePanel.getTree().UpdatePlaceHolders((Vector) evt.getNewValue()); + treePanel.repaint(); + } + } + }); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void clustalAlignMenuItem_actionPerformed(ActionEvent e) + { + // TODO:resolve which menu item was actually selected + // Now, check we have enough sequences + SequenceI[] msa = null; + + if ((viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() > 1)) + { + // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! + SequenceGroup seqs = viewport.getSelectionGroup(); + int sz; + msa = new SequenceI[sz = seqs.getSize()]; + + for (int i = 0; i < sz; i++) + { + msa[i] = (SequenceI) seqs.getSequenceAt(i); + } + } + else + { + Vector seqs = viewport.getAlignment().getSequences(); - for (int i = 0; i < seqs.size(); i++) + if (seqs.size() > 1) + { + msa = new SequenceI[seqs.size()]; + + for (int i = 0; i < seqs.size(); i++) + { + msa[i] = (SequenceI) seqs.elementAt(i); + } + } + } + + if (msa != null) { - msa[i] = (SequenceI) seqs.elementAt(i); + jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", + title, msa, false, true); } - } } - if (msa != null) - { - JPredClient ct = new JPredClient(title, msa); - } - else if (seq != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void ClustalRealign_actionPerformed(ActionEvent e) { - JPredClient ct = new JPredClient(title, seq); - } - else - { - System.err.print( - "JALVIEW ERROR! - Unexpected JPred selection state!\n"); - } - } + // TODO:resolve which menu item was actually selected + // Now, check we have enough sequences + SequenceI[] msa = null; + + if ((viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() > 1)) + { + // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! + SequenceGroup seqs = viewport.getSelectionGroup(); + int sz; + msa = new SequenceI[sz = seqs.getSize()]; + + for (int i = 0; i < sz; i++) + { + msa[i] = (SequenceI) seqs.getSequenceAt(i); + } + } + else + { + Vector seqs = viewport.getAlignment().getSequences(); - protected void msaAlignMenuItem_actionPerformed(ActionEvent e) - { - // TODO:resolve which menu item was actually selected - // Now, check we have enough sequences - SequenceI[] msa = null; + if (seqs.size() > 1) + { + msa = new SequenceI[seqs.size()]; - if ( (viewport.getSelectionGroup() != null) && - (viewport.getSelectionGroup().getSize() > 1)) - { - // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! - SequenceGroup seqs = viewport.getSelectionGroup(); - int sz; - msa = new SequenceI[sz = seqs.getSize()]; + for (int i = 0; i < seqs.size(); i++) + { + msa[i] = (SequenceI) seqs.elementAt(i); + } + } + } - for (int i = 0; i < sz; i++) - { - msa[i] = (SequenceI) seqs.getSequenceAt(i); - } + if (msa != null) + { + jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", + title, msa, true, true); + } } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void jpred_actionPerformed(ActionEvent e) { - Vector seqs = viewport.getAlignment().getSequences(); + SequenceI seq = null; + SequenceI[] msa = null; - if (seqs.size() > 1) - { - msa = new SequenceI[seqs.size()]; + if ((viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() > 0)) + { + // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! + SequenceGroup seqs = viewport.getSelectionGroup(); + + if ((seqs.getSize() == 1) || !viewport.alignment.isAligned()) + { + seq = (SequenceI) seqs.getSequenceAt(0); + } + else + { + int sz; + msa = new SequenceI[sz = seqs.getSize()]; + + for (int i = 0; i < sz; i++) + { + msa[i] = (SequenceI) seqs.getSequenceAt(i); + } + } + } + else + { + Vector seqs = viewport.getAlignment().getSequences(); + + if ((seqs.size() == 1) || !viewport.alignment.isAligned()) + { + seq = (SequenceI) seqs.elementAt(0); + } + else + { + msa = new SequenceI[seqs.size()]; + + for (int i = 0; i < seqs.size(); i++) + { + msa[i] = (SequenceI) seqs.elementAt(i); + } + } + } - for (int i = 0; i < seqs.size(); i++) + if (msa != null) { - msa[i] = (SequenceI) seqs.elementAt(i); + JPredClient ct = new JPredClient(title, msa); + } + else if (seq != null) + { + JPredClient ct = new JPredClient(title, seq); + } + else + { + System.err.print( + "JALVIEW ERROR! - Unexpected JPred selection state!\n"); } - } } - if (msa != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void msaAlignMenuItem_actionPerformed(ActionEvent e) { - MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS", title, msa, - false, true); - } - } + // TODO:resolve which menu item was actually selected + // Now, check we have enough sequences + SequenceI[] msa = null; - protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) - { - // Pick the tree file - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY")); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Select a newick-like tree file"); - chooser.setToolTipText("Load a tree file"); + if ((viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() > 1)) + { + // JBPNote UGLY! To prettify, make SequenceGroup and Alignment conform to some common interface! + SequenceGroup seqs = viewport.getSelectionGroup(); + int sz; + msa = new SequenceI[sz = seqs.getSize()]; + + for (int i = 0; i < sz; i++) + { + msa[i] = (SequenceI) seqs.getSequenceAt(i); + } + } + else + { + Vector seqs = viewport.getAlignment().getSequences(); - int value = chooser.showOpenDialog(null); + if (seqs.size() > 1) + { + msa = new SequenceI[seqs.size()]; - if (value == JalviewFileChooser.APPROVE_OPTION) - { - String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); + for (int i = 0; i < seqs.size(); i++) + { + msa[i] = (SequenceI) seqs.elementAt(i); + } + } + } - try - { - jalview.io.NewickFile fin = new jalview.io.NewickFile(choice, - "File"); - viewport.setCurrentTree( ShowNewickTree(fin, choice).getTree() ); - } - catch (Exception ex) - { - JOptionPane.showMessageDialog(Desktop.desktop, - "Problem reading tree file", - ex.getMessage(), - JOptionPane.WARNING_MESSAGE); - ex.printStackTrace(); - } + if (msa != null) + { + MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS", title, msa, + false, true); + } } - } - public TreePanel ShowNewickTree(NewickFile nf, String title) - { - TreePanel tp = null; - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { - nf.parse(); - if (nf.getTree() != null) - { - tp = new TreePanel(viewport, - viewport.getAlignment().getSequences(), nf, - "FromFile", - title); - Desktop.addInternalFrame(tp, title, 600, 500); - addTreeMenuItem(tp, title); - } - } - catch (Exception ex) - { - ex.printStackTrace(); + // Pick the tree file + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Select a newick-like tree file"); + chooser.setToolTipText("Load a tree file"); + + int value = chooser.showOpenDialog(null); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); + + try + { + jalview.io.NewickFile fin = new jalview.io.NewickFile(choice, + "File"); + viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree()); + } + catch (Exception ex) + { + JOptionPane.showMessageDialog(Desktop.desktop, + "Problem reading tree file", ex.getMessage(), + JOptionPane.WARNING_MESSAGE); + ex.printStackTrace(); + } + } } - return tp; - } - class PrintThread - extends Thread - { - public void run() + /** + * DOCUMENT ME! + * + * @param nf DOCUMENT ME! + * @param title DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public TreePanel ShowNewickTree(NewickFile nf, String title) { - PrinterJob printJob = PrinterJob.getPrinterJob(); - PageFormat pf = printJob.pageDialog(printJob.defaultPage()); - printJob.setPrintable(alignPanel, pf); + TreePanel tp = null; - if (printJob.printDialog()) - { try { - printJob.print(); + nf.parse(); + + if (nf.getTree() != null) + { + tp = new TreePanel(viewport, + viewport.getAlignment().getSequences(), nf, "FromFile", + title); + Desktop.addInternalFrame(tp, title, 600, 500); + addTreeMenuItem(tp, title); + } } - catch (Exception PrintException) + catch (Exception ex) { - PrintException.printStackTrace(); + ex.printStackTrace(); + } + + return tp; + } + + class PrintThread extends Thread + { + public void run() + { + PrinterJob printJob = PrinterJob.getPrinterJob(); + PageFormat pf = printJob.pageDialog(printJob.defaultPage()); + printJob.setPrintable(alignPanel, pf); + + if (printJob.printDialog()) + { + try + { + printJob.print(); + } + catch (Exception PrintException) + { + PrintException.printStackTrace(); + } + } } - } } - } } diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 44b7432..e8f34d8 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -18,670 +18,1017 @@ */ package jalview.gui; -import java.util.*; - -import java.awt.*; - import jalview.analysis.*; + import jalview.bin.*; + import jalview.datamodel.*; + import jalview.schemes.*; +import java.awt.*; + +import java.util.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class AlignViewport { - int startRes; - int endRes; - int startSeq; - int endSeq; - boolean showFullId = false; - boolean showText = true; - boolean showColourText = false; - boolean showBoxes = true; - boolean wrapAlignment = false; - boolean renderGaps = true; - boolean showSequenceFeatures = false; - boolean showAnnotation = true; - boolean showConservation = true; - boolean showQuality = true; - boolean showIdentity = true; - boolean colourAppliesToAllGroups = true; - ColourSchemeI globalColourScheme = null; - boolean conservationColourSelected = false; - boolean abovePIDThreshold = false; - SequenceGroup selectionGroup = new SequenceGroup(); - int charHeight; - int charWidth; - int chunkWidth; - int chunkHeight; - Font font = new Font("SansSerif", Font.PLAIN, 10); - AlignmentI alignment; - ColumnSelection colSel = new ColumnSelection(); - int threshold; - int increment; - NJTree currentTree = null; - boolean scaleAboveWrapped = false; - boolean scaleLeftWrapped = true; - boolean scaleRightWrapped = true; - public Vector vconsensus; - AlignmentAnnotation consensus; - AlignmentAnnotation conservation; - AlignmentAnnotation quality; - public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! - - // JBPNote Prolly only need this in the applet version. - private java.beans.PropertyChangeSupport changeSupport = new java.beans. - PropertyChangeSupport(this); - - public AlignViewport(AlignmentI al) - { - setAlignment(al); - this.startRes = 0; - this.endRes = al.getWidth() - 1; - this.startSeq = 0; - this.endSeq = al.getHeight() - 1; - - updateFromPreferences(); - } - - public void updateFromPreferences() - { - showFullId = Preferences.showFullId; - showAnnotation = Preferences.showAnnotation; - showConservation = Preferences.showConservation; - showQuality = Preferences.showQuality; - showIdentity = Preferences.showIdentity; - showFullId = Preferences.showFullId; - - String fontName = Preferences.fontName; - String fontStyle = Preferences.fontStyle; - String fontSize = Cache.getProperty("FONT_SIZE"); - - if ( (fontName != null) && (fontStyle != null) && (fontSize != null)) - { - int style = 0; - - if (fontStyle.equals("bold")) - { - style = 1; - } - else if (fontStyle.equals("italic")) - { - style = 2; - } - - setFont(new Font(fontName, style, Integer.parseInt(fontSize))); - } - else - { - setFont(font); - } - - alignment.setGapCharacter(Preferences.gapSymbol); - - // We must set conservation and consensus before setting colour, - // as Blosum and Clustal require this to be done - updateConservation(); - updateConsensus(); - - if (Preferences.defaultColour != null) - { - globalColourScheme = ColourSchemeProperty.getColour(alignment, - Preferences.defaultColour); - - if (globalColourScheme instanceof UserColourScheme) - { - globalColourScheme = UserDefinedColours.loadDefaultColours(); - } - - if (globalColourScheme != null) - { - globalColourScheme.setConsensus(vconsensus); - } - } - } - - public void showSequenceFeatures(boolean b) - { - showSequenceFeatures = b; - } - - public void updateConservation() - { - Conservation cons = new jalview.analysis.Conservation("All", - jalview.schemes.ResidueProperties.propHash, 3, - alignment.getSequences(), 0, alignment.getWidth() - 1); - cons.calculate(); - cons.verdict(false, ConsPercGaps); - cons.findQuality(); - - int alWidth = alignment.getWidth(); - Annotation[] annotations = new Annotation[alWidth]; - Annotation[] qannotations = new Annotation[alWidth]; - String sequence = cons.getConsSequence().getSequence(); - float minR; - float minG; - float minB; - float maxR; - float maxG; - float maxB; - minR = 0.3f; - minG = 0.0f; - minB = 0f; - maxR = 1.0f - minR; - maxG = 0.9f - minG; - maxB = 0f - minB; // scalable range for colouring both Conservation and Quality - - float min = 0f; - float max = 11f; - float qmin = cons.qualityRange[0].floatValue(); - float qmax = cons.qualityRange[1].floatValue(); - - for (int i = 0; i < alWidth; i++) - { - float value = 0; - - try - { - value = Integer.parseInt(sequence.charAt(i) + ""); - } - catch (Exception ex) - { - if (sequence.charAt(i) == '*') + int startRes; + int endRes; + int startSeq; + int endSeq; + boolean showFullId = false; + boolean showText = true; + boolean showColourText = false; + boolean showBoxes = true; + boolean wrapAlignment = false; + boolean renderGaps = true; + boolean showSequenceFeatures = false; + boolean showAnnotation = true; + boolean showConservation = true; + boolean showQuality = true; + boolean showIdentity = true; + boolean colourAppliesToAllGroups = true; + ColourSchemeI globalColourScheme = null; + boolean conservationColourSelected = false; + boolean abovePIDThreshold = false; + SequenceGroup selectionGroup = new SequenceGroup(); + int charHeight; + int charWidth; + int chunkWidth; + int chunkHeight; + Font font = new Font("SansSerif", Font.PLAIN, 10); + AlignmentI alignment; + ColumnSelection colSel = new ColumnSelection(); + int threshold; + int increment; + NJTree currentTree = null; + boolean scaleAboveWrapped = false; + boolean scaleLeftWrapped = true; + boolean scaleRightWrapped = true; + + /** DOCUMENT ME!! */ + public Vector vconsensus; + AlignmentAnnotation consensus; + AlignmentAnnotation conservation; + AlignmentAnnotation quality; + + /** DOCUMENT ME!! */ + public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! + + // JBPNote Prolly only need this in the applet version. + private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); + + /** + * Creates a new AlignViewport object. + * + * @param al DOCUMENT ME! + */ + public AlignViewport(AlignmentI al) + { + setAlignment(al); + this.startRes = 0; + this.endRes = al.getWidth() - 1; + this.startSeq = 0; + this.endSeq = al.getHeight() - 1; + + updateFromPreferences(); + } + + /** + * DOCUMENT ME! + */ + public void updateFromPreferences() + { + showFullId = Preferences.showFullId; + showAnnotation = Preferences.showAnnotation; + showConservation = Preferences.showConservation; + showQuality = Preferences.showQuality; + showIdentity = Preferences.showIdentity; + showFullId = Preferences.showFullId; + + String fontName = Preferences.fontName; + String fontStyle = Preferences.fontStyle; + String fontSize = Cache.getProperty("FONT_SIZE"); + + if ((fontName != null) && (fontStyle != null) && (fontSize != null)) { - value = 11; + int style = 0; + + if (fontStyle.equals("bold")) + { + style = 1; + } + else if (fontStyle.equals("italic")) + { + style = 2; + } + + setFont(new Font(fontName, style, Integer.parseInt(fontSize))); } + else + { + setFont(font); + } + + alignment.setGapCharacter(Preferences.gapSymbol); - if (sequence.charAt(i) == '+') + // We must set conservation and consensus before setting colour, + // as Blosum and Clustal require this to be done + updateConservation(); + updateConsensus(); + + if (Preferences.defaultColour != null) { - value = 10; + globalColourScheme = ColourSchemeProperty.getColour(alignment, + Preferences.defaultColour); + + if (globalColourScheme instanceof UserColourScheme) + { + globalColourScheme = UserDefinedColours.loadDefaultColours(); + } + + if (globalColourScheme != null) + { + globalColourScheme.setConsensus(vconsensus); + } } - } + } - float vprop = value - min; - vprop /= max; - annotations[i] = new Annotation(sequence.charAt(i) + "", String.valueOf(value), ' ', - value, - new Color(minR + (maxR * vprop), - minG + (maxG * vprop), - minB + (maxB * vprop))); + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void showSequenceFeatures(boolean b) + { + showSequenceFeatures = b; + } + + /** + * DOCUMENT ME! + */ + public void updateConservation() + { + Conservation cons = new jalview.analysis.Conservation("All", + jalview.schemes.ResidueProperties.propHash, 3, + alignment.getSequences(), 0, alignment.getWidth() - 1); + cons.calculate(); + cons.verdict(false, ConsPercGaps); + cons.findQuality(); + + int alWidth = alignment.getWidth(); + Annotation[] annotations = new Annotation[alWidth]; + Annotation[] qannotations = new Annotation[alWidth]; + String sequence = cons.getConsSequence().getSequence(); + float minR; + float minG; + float minB; + float maxR; + float maxG; + float maxB; + minR = 0.3f; + minG = 0.0f; + minB = 0f; + maxR = 1.0f - minR; + maxG = 0.9f - minG; + maxB = 0f - minB; // scalable range for colouring both Conservation and Quality + + float min = 0f; + float max = 11f; + float qmin = cons.qualityRange[0].floatValue(); + float qmax = cons.qualityRange[1].floatValue(); + + for (int i = 0; i < alWidth; i++) + { + float value = 0; + + try + { + value = Integer.parseInt(sequence.charAt(i) + ""); + } + catch (Exception ex) + { + if (sequence.charAt(i) == '*') + { + value = 11; + } + + if (sequence.charAt(i) == '+') + { + value = 10; + } + } + + float vprop = value - min; + vprop /= max; + annotations[i] = new Annotation(sequence.charAt(i) + "", + String.valueOf(value), ' ', value, + new Color(minR + (maxR * vprop), minG + (maxG * vprop), + minB + (maxB * vprop))); + + // Quality calc + value = ((Double) cons.quality.get(i)).floatValue(); + vprop = value - qmin; + vprop /= qmax; + qannotations[i] = new Annotation(" ", String.valueOf(value), ' ', + value, + new Color(minR + (maxR * vprop), minG + (maxG * vprop), + minB + (maxB * vprop))); + } - // Quality calc - value = ( (Double) cons.quality.get(i)).floatValue(); - vprop = value - qmin; - vprop /= qmax; - qannotations[i] = new Annotation(" ", String.valueOf(value), ' ', - value, - new Color(minR + (maxR * vprop), - minG + (maxG * vprop), - minB + (maxB * vprop))); + if (conservation == null) + { + conservation = new AlignmentAnnotation("Conservation", + "Conservation of total alignment less than " + + ConsPercGaps + "% gaps", annotations, 0f, // cons.qualityRange[0].floatValue(), + 11f, // cons.qualityRange[1].floatValue() + 1); + + if (showConservation) + { + alignment.addAnnotation(conservation); + } + + quality = new AlignmentAnnotation("Quality", + "Alignment Quality based on Blosum62 scores", qannotations, + cons.qualityRange[0].floatValue(), + cons.qualityRange[1].floatValue(), 1); + + if (showQuality) + { + alignment.addAnnotation(quality); + } + } + else + { + conservation.annotations = annotations; + quality.annotations = qannotations; + quality.graphMax = cons.qualityRange[1].floatValue(); + } } - if (conservation == null) + /** + * DOCUMENT ME! + */ + public void updateConsensus() { - conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment less than " + - ConsPercGaps + "% gaps", - annotations, 0f, // cons.qualityRange[0].floatValue(), - 11f, // cons.qualityRange[1].floatValue() - 1); + Annotation[] annotations = new Annotation[alignment.getWidth()]; + + // this routine prevents vconsensus becoming a new object each time + // consenus is calculated. Important for speed of Blosum62 + // and PID colouring of alignment + if (vconsensus == null) + { + vconsensus = alignment.getAAFrequency(); + } + else + { + Vector temp = alignment.getAAFrequency(); + vconsensus.clear(); + + Enumeration e = temp.elements(); + + while (e.hasMoreElements()) + { + vconsensus.add(e.nextElement()); + } + } + + Hashtable hash = null; + + for (int i = 0; i < alignment.getWidth(); i++) + { + hash = (Hashtable) vconsensus.elementAt(i); + + float value = Float.parseFloat(hash.get("maxCount").toString()); + value /= Float.parseFloat(hash.get("size").toString()); + + value *= 100; + + String maxRes = hash.get("maxResidue") + " "; + String mouseOver = hash.get("maxResidue") + " "; + + if (maxRes.length() > 2) + { + mouseOver = "[" + maxRes + "] "; + maxRes = "+ "; + } + + mouseOver += ((int) value + "%"); + annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); + } - if (showConservation) - { - alignment.addAnnotation(conservation); - } + if (consensus == null) + { + consensus = new AlignmentAnnotation("Consensus", "PID", + annotations, 0f, 100f, 1); - quality = new AlignmentAnnotation("Quality", - "Alignment Quality based on Blosum62 scores", - qannotations, - cons.qualityRange[0].floatValue(), - cons.qualityRange[1].floatValue(), 1); + if (showIdentity) + { + alignment.addAnnotation(consensus); + } + } + else + { + consensus.annotations = annotations; + } + } - if (showQuality) - { - alignment.addAnnotation(quality); - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceGroup getSelectionGroup() + { + return selectionGroup; } - else + + /** + * DOCUMENT ME! + * + * @param sg DOCUMENT ME! + */ + public void setSelectionGroup(SequenceGroup sg) { - conservation.annotations = annotations; - quality.annotations = qannotations; - quality.graphMax = cons.qualityRange[1].floatValue(); + selectionGroup = sg; } - } - public void updateConsensus() - { - Annotation[] annotations = new Annotation[alignment.getWidth()]; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getConservationSelected() + { + return conservationColourSelected; + } - // this routine prevents vconsensus becoming a new object each time - // consenus is calculated. Important for speed of Blosum62 - // and PID colouring of alignment - if (vconsensus == null) + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setConservationSelected(boolean b) { - vconsensus = alignment.getAAFrequency(); + conservationColourSelected = b; } - else + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getAbovePIDThreshold() { - Vector temp = alignment.getAAFrequency(); - vconsensus.clear(); + return abovePIDThreshold; + } - Enumeration e = temp.elements(); + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setAbovePIDThreshold(boolean b) + { + abovePIDThreshold = b; + } - while (e.hasMoreElements()) - { - vconsensus.add(e.nextElement()); - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getStartRes() + { + return startRes; } - Hashtable hash = null; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getEndRes() + { + return endRes; + } - for (int i = 0; i < alignment.getWidth(); i++) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getStartSeq() { - hash = (Hashtable) vconsensus.elementAt(i); + return startSeq; + } - float value = Float.parseFloat(hash.get("maxCount").toString()); - value /= Float.parseFloat(hash.get("size").toString()); + /** + * DOCUMENT ME! + * + * @param cs DOCUMENT ME! + */ + public void setGlobalColourScheme(ColourSchemeI cs) + { + globalColourScheme = cs; + } - value *= 100; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public ColourSchemeI getGlobalColourScheme() + { + return globalColourScheme; + } - String maxRes = hash.get("maxResidue") + " "; - String mouseOver = hash.get("maxResidue") + " "; + /** + * DOCUMENT ME! + * + * @param res DOCUMENT ME! + */ + public void setStartRes(int res) + { + this.startRes = res; + } - if (maxRes.length() > 2) - { - mouseOver = "[" + maxRes + "] "; - maxRes = "+ "; - } + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + */ + public void setStartSeq(int seq) + { + this.startSeq = seq; + } + + /** + * DOCUMENT ME! + * + * @param res DOCUMENT ME! + */ + public void setEndRes(int res) + { + if (res > (alignment.getWidth() - 1)) + { + // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1)); + res = alignment.getWidth() - 1; + } + + if (res < 0) + { + res = 0; + } - mouseOver += ( (int) value + "%"); - annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); + this.endRes = res; } - if (consensus == null) + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + */ + public void setEndSeq(int seq) { - consensus = new AlignmentAnnotation("Consensus", "PID", - annotations, 0f, 100f, 1); + if (seq > alignment.getHeight()) + { + seq = alignment.getHeight(); + } + + if (seq < 0) + { + seq = 0; + } - if (showIdentity) - { - alignment.addAnnotation(consensus); - } + this.endSeq = seq; } - else + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getEndSeq() { - consensus.annotations = annotations; + return endSeq; } - } - public SequenceGroup getSelectionGroup() - { - return selectionGroup; - } + /** + * DOCUMENT ME! + * + * @param f DOCUMENT ME! + */ + public void setFont(Font f) + { + font = f; + + javax.swing.JFrame temp = new javax.swing.JFrame(); + temp.addNotify(); - public void setSelectionGroup(SequenceGroup sg) - { - selectionGroup = sg; - } + java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font); + setCharHeight(fm.getHeight()); + setCharWidth(fm.charWidth('M')); + } - public boolean getConservationSelected() - { - return conservationColourSelected; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Font getFont() + { + return font; + } - public void setConservationSelected(boolean b) - { - conservationColourSelected = b; - } + /** + * DOCUMENT ME! + * + * @param w DOCUMENT ME! + */ + public void setCharWidth(int w) + { + this.charWidth = w; + } - public boolean getAbovePIDThreshold() - { - return abovePIDThreshold; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getCharWidth() + { + return charWidth; + } - public void setAbovePIDThreshold(boolean b) - { - abovePIDThreshold = b; - } + /** + * DOCUMENT ME! + * + * @param h DOCUMENT ME! + */ + public void setCharHeight(int h) + { + this.charHeight = h; + } - public int getStartRes() - { - return startRes; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getCharHeight() + { + return charHeight; + } - public int getEndRes() - { - return endRes; - } + /** + * DOCUMENT ME! + * + * @param w DOCUMENT ME! + */ + public void setChunkWidth(int w) + { + this.chunkWidth = w; + } - public int getStartSeq() - { - return startSeq; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getChunkWidth() + { + return chunkWidth; + } - public void setGlobalColourScheme(ColourSchemeI cs) - { - globalColourScheme = cs; - } + /** + * DOCUMENT ME! + * + * @param h DOCUMENT ME! + */ + public void setChunkHeight(int h) + { + this.chunkHeight = h; + } - public ColourSchemeI getGlobalColourScheme() - { - return globalColourScheme; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getChunkHeight() + { + return chunkHeight; + } - public void setStartRes(int res) - { - this.startRes = res; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public AlignmentI getAlignment() + { + return alignment; + } - public void setStartSeq(int seq) - { - this.startSeq = seq; - } + /** + * DOCUMENT ME! + * + * @param align DOCUMENT ME! + */ + public void setAlignment(AlignmentI align) + { + this.alignment = align; + } - public void setEndRes(int res) - { - if (res > (alignment.getWidth() - 1)) + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setWrapAlignment(boolean state) { - // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1)); - res = alignment.getWidth() - 1; + wrapAlignment = state; } - if (res < 0) + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setShowText(boolean state) { - res = 0; + showText = state; } - this.endRes = res; - } + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setRenderGaps(boolean state) + { + renderGaps = state; + } - public void setEndSeq(int seq) - { - if (seq > alignment.getHeight()) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getColourText() { - seq = alignment.getHeight(); + return showColourText; } - if (seq < 0) + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setColourText(boolean state) { - seq = 0; + showColourText = state; } - this.endSeq = seq; - } + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setShowBoxes(boolean state) + { + showBoxes = state; + } - public int getEndSeq() - { - return endSeq; - } - - public void setFont(Font f) - { - font = f; - - javax.swing.JFrame temp = new javax.swing.JFrame(); - temp.addNotify(); - - java.awt.FontMetrics fm = temp.getGraphics().getFontMetrics(font); - setCharHeight(fm.getHeight()); - setCharWidth(fm.charWidth('M')); - } - - public Font getFont() - { - return font; - } - - public void setCharWidth(int w) - { - this.charWidth = w; - } - - public int getCharWidth() - { - return charWidth; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getWrapAlignment() + { + return wrapAlignment; + } - public void setCharHeight(int h) - { - this.charHeight = h; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getShowText() + { + return showText; + } - public int getCharHeight() - { - return charHeight; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getShowBoxes() + { + return showBoxes; + } - public void setChunkWidth(int w) - { - this.chunkWidth = w; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public char getGapCharacter() + { + return getAlignment().getGapCharacter(); + } - public int getChunkWidth() - { - return chunkWidth; - } + /** + * DOCUMENT ME! + * + * @param gap DOCUMENT ME! + */ + public void setGapCharacter(char gap) + { + if (getAlignment() != null) + { + getAlignment().setGapCharacter(gap); + } + } - public void setChunkHeight(int h) - { - this.chunkHeight = h; - } + /** + * DOCUMENT ME! + * + * @param thresh DOCUMENT ME! + */ + public void setThreshold(int thresh) + { + threshold = thresh; + } - public int getChunkHeight() - { - return chunkHeight; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getThreshold() + { + return threshold; + } - public AlignmentI getAlignment() - { - return alignment; - } + /** + * DOCUMENT ME! + * + * @param inc DOCUMENT ME! + */ + public void setIncrement(int inc) + { + increment = inc; + } - public void setAlignment(AlignmentI align) - { - this.alignment = align; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getIncrement() + { + return increment; + } - public void setWrapAlignment(boolean state) - { - wrapAlignment = state; - } + /** + * DOCUMENT ME! + * + * @param y DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getIndex(int y) + { + int y1 = 0; + int starty = getStartSeq(); + int endy = getEndSeq(); - public void setShowText(boolean state) - { - showText = state; - } - - public void setRenderGaps(boolean state) - { - renderGaps = state; - } - - public boolean getColourText() - { - return showColourText; - } - - public void setColourText(boolean state) - { - showColourText = state; - } - - public void setShowBoxes(boolean state) - { - showBoxes = state; - } - - public boolean getWrapAlignment() - { - return wrapAlignment; - } - - public boolean getShowText() - { - return showText; - } - - public boolean getShowBoxes() - { - return showBoxes; - } - - public char getGapCharacter() - { - return getAlignment().getGapCharacter(); - } - - public void setGapCharacter(char gap) - { - if (getAlignment() != null) - { - getAlignment().setGapCharacter(gap); - } - } - - public void setThreshold(int thresh) - { - threshold = thresh; - } - - public int getThreshold() - { - return threshold; - } - - public void setIncrement(int inc) - { - increment = inc; - } - - public int getIncrement() - { - return increment; - } - - public int getIndex(int y) - { - int y1 = 0; - int starty = getStartSeq(); - int endy = getEndSeq(); - - for (int i = starty; i <= endy; i++) - { - if ( (i < alignment.getHeight()) && - (alignment.getSequenceAt(i) != null)) - { - int y2 = y1 + getCharHeight(); - - if ( (y >= y1) && (y <= y2)) + for (int i = starty; i <= endy; i++) { - return i; + if ((i < alignment.getHeight()) && + (alignment.getSequenceAt(i) != null)) + { + int y2 = y1 + getCharHeight(); + + if ((y >= y1) && (y <= y2)) + { + return i; + } + + y1 = y2; + } + else + { + return -1; + } } - y1 = y2; - } - else - { return -1; - } - } - - return -1; - } - - public ColumnSelection getColumnSelection() - { - return colSel; - } - - public void resetSeqLimits(int height) - { - setEndSeq(height / getCharHeight()); - } - - public void setCurrentTree(NJTree tree) - { - currentTree = tree; - } - - public NJTree getCurrentTree() - { - return currentTree; - } - - public void setColourAppliesToAllGroups(boolean b) - { - colourAppliesToAllGroups = b; - } - - public boolean getColourAppliesToAllGroups() - { - return colourAppliesToAllGroups; - } - - public boolean getShowFullId() - { - return showFullId; - } - - public void setShowFullId(boolean b) - { - showFullId = b; - } - - public boolean getShowAnnotation() - { - return showAnnotation; - } - - public void setShowAnnotation(boolean b) - { - showAnnotation = b; - } - - public boolean getScaleAboveWrapped() - { - return scaleAboveWrapped; - } - - public boolean getScaleLeftWrapped() - { - return scaleLeftWrapped; - } - - public boolean getScaleRightWrapped() - { - return scaleRightWrapped; - } - - public void setScaleAboveWrapped(boolean b) - { - scaleAboveWrapped = b; - } - - public void setScaleLeftWrapped(boolean b) - { - scaleLeftWrapped = b; - } - - public void setScaleRightWrapped(boolean b) - { - scaleRightWrapped = b; - } - - public void addPropertyChangeListener( - java.beans.PropertyChangeListener listener) - { - changeSupport.addPropertyChangeListener(listener); - } - - public void removePropertyChangeListener( - java.beans.PropertyChangeListener listener) - { - changeSupport.removePropertyChangeListener(listener); - } - - public void firePropertyChange(String prop, Object oldvalue, Object newvalue) - { - changeSupport.firePropertyChange(prop, oldvalue, newvalue); - } + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public ColumnSelection getColumnSelection() + { + return colSel; + } + + /** + * DOCUMENT ME! + * + * @param height DOCUMENT ME! + */ + public void resetSeqLimits(int height) + { + setEndSeq(height / getCharHeight()); + } + + /** + * DOCUMENT ME! + * + * @param tree DOCUMENT ME! + */ + public void setCurrentTree(NJTree tree) + { + currentTree = tree; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public NJTree getCurrentTree() + { + return currentTree; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setColourAppliesToAllGroups(boolean b) + { + colourAppliesToAllGroups = b; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getColourAppliesToAllGroups() + { + return colourAppliesToAllGroups; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getShowFullId() + { + return showFullId; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setShowFullId(boolean b) + { + showFullId = b; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getShowAnnotation() + { + return showAnnotation; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setShowAnnotation(boolean b) + { + showAnnotation = b; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getScaleAboveWrapped() + { + return scaleAboveWrapped; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getScaleLeftWrapped() + { + return scaleLeftWrapped; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getScaleRightWrapped() + { + return scaleRightWrapped; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setScaleAboveWrapped(boolean b) + { + scaleAboveWrapped = b; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setScaleLeftWrapped(boolean b) + { + scaleLeftWrapped = b; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setScaleRightWrapped(boolean b) + { + scaleRightWrapped = b; + } + + /** + * DOCUMENT ME! + * + * @param listener DOCUMENT ME! + */ + public void addPropertyChangeListener( + java.beans.PropertyChangeListener listener) + { + changeSupport.addPropertyChangeListener(listener); + } + + /** + * DOCUMENT ME! + * + * @param listener DOCUMENT ME! + */ + public void removePropertyChangeListener( + java.beans.PropertyChangeListener listener) + { + changeSupport.removePropertyChangeListener(listener); + } + + /** + * DOCUMENT ME! + * + * @param prop DOCUMENT ME! + * @param oldvalue DOCUMENT ME! + * @param newvalue DOCUMENT ME! + */ + public void firePropertyChange(String prop, Object oldvalue, Object newvalue) + { + changeSupport.firePropertyChange(prop, oldvalue, newvalue); + } } diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index 1a48af6..e312510 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -18,804 +18,1040 @@ */ package jalview.gui; -import java.io.*; -import javax.imageio.*; +import jalview.analysis.*; + +import jalview.datamodel.*; + +import jalview.jbgui.*; + +import jalview.schemes.*; + +import org.jibble.epsgraphics.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.awt.print.*; + +import java.io.*; + +import javax.imageio.*; + import javax.swing.*; -import org.jibble.epsgraphics.*; -import jalview.analysis.*; -import jalview.datamodel.*; -import jalview.jbgui.*; -import jalview.schemes.*; -public class AlignmentPanel - extends GAlignmentPanel implements AdjustmentListener, Printable +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class AlignmentPanel extends GAlignmentPanel + implements AdjustmentListener, Printable { - AlignViewport av; - OverviewPanel overviewPanel; - SeqPanel seqPanel; - IdPanel idPanel; - IdwidthAdjuster idwidthAdjuster; - public AlignFrame alignFrame; - ScalePanel scalePanel; - AnnotationPanel annotationPanel; - AnnotationLabels alabels; - - // this value is set false when selection area being dragged - boolean fastPaint = true; - int hextent = 0; - int vextent = 0; - - public AlignmentPanel(AlignFrame af, final AlignViewport av) - { - alignFrame = af; - this.av = av; - seqPanel = new SeqPanel(av, this); - idPanel = new IdPanel(av, this); - - scalePanel = new ScalePanel(av, this); - - idPanelHolder.add(idPanel, BorderLayout.CENTER); - idwidthAdjuster = new IdwidthAdjuster(this); - idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); - - annotationPanel = new AnnotationPanel(this); - alabels = new AnnotationLabels(this); - - annotationSpaceFillerHolder.setPreferredSize(annotationPanel. - getPreferredSize()); - annotationScroller.setPreferredSize(annotationPanel.getPreferredSize()); - annotationScroller.setViewportView(annotationPanel); - annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); - - fontChanged(); - - scalePanelHolder.add(scalePanel, BorderLayout.CENTER); - seqPanelHolder.add(seqPanel, BorderLayout.CENTER); - - setScrollValues(0, 0); - - hscroll.addAdjustmentListener(this); - vscroll.addAdjustmentListener(this); - - setFocusable(true); - addKeyListener(new KeyAdapter() + AlignViewport av; + OverviewPanel overviewPanel; + SeqPanel seqPanel; + IdPanel idPanel; + IdwidthAdjuster idwidthAdjuster; + + /** DOCUMENT ME!! */ + public AlignFrame alignFrame; + ScalePanel scalePanel; + AnnotationPanel annotationPanel; + AnnotationLabels alabels; + + // this value is set false when selection area being dragged + boolean fastPaint = true; + int hextent = 0; + int vextent = 0; + + /** + * Creates a new AlignmentPanel object. + * + * @param af DOCUMENT ME! + * @param av DOCUMENT ME! + */ + public AlignmentPanel(AlignFrame af, final AlignViewport av) { - public void keyPressed(KeyEvent evt) - { - switch (evt.getKeyCode()) - { - case 27: // escape key - av.setSelectionGroup(null); - repaint(); + alignFrame = af; + this.av = av; + seqPanel = new SeqPanel(av, this); + idPanel = new IdPanel(av, this); - break; + scalePanel = new ScalePanel(av, this); - case KeyEvent.VK_DOWN: - alignFrame.moveSelectedSequences(false); + idPanelHolder.add(idPanel, BorderLayout.CENTER); + idwidthAdjuster = new IdwidthAdjuster(this); + idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); - break; + annotationPanel = new AnnotationPanel(this); + alabels = new AnnotationLabels(this); - case KeyEvent.VK_UP: - alignFrame.moveSelectedSequences(true); + annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize()); + annotationScroller.setPreferredSize(annotationPanel.getPreferredSize()); + annotationScroller.setViewportView(annotationPanel); + annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); - break; - } - } - }); - } - - public void fontChanged() - { - // set idCanvas bufferedImage to null - // to prevent drawing old image - FontMetrics fm = getFontMetrics(av.getFont()); - - scalePanelHolder.setPreferredSize(new Dimension(10, - av.charHeight + fm.getDescent())); - idSpaceFillerPanel1.setPreferredSize(new Dimension(10, - av.charHeight + fm.getDescent())); - - idPanel.idCanvas.gg = null; - annotationPanel.adjustPanelHeight(); - - Dimension d = calculateIdWidth(); - d.setSize(d.width + 4, d.height); - idPanel.idCanvas.setPreferredSize(d); - hscrollFillerPanel.setPreferredSize(d); - repaint(); - } - - Dimension calculateIdWidth() - { - Graphics g = this.getGraphics(); - - if (g == null) - { - javax.swing.JFrame f = new javax.swing.JFrame(); - f.addNotify(); - g = f.getGraphics(); - } + fontChanged(); - FontMetrics fm = g.getFontMetrics(av.font); - AlignmentI al = av.getAlignment(); + scalePanelHolder.add(scalePanel, BorderLayout.CENTER); + seqPanelHolder.add(seqPanel, BorderLayout.CENTER); - int i = 0; - int idWidth = 0; - String id; + setScrollValues(0, 0); - while ( (i < al.getHeight()) && (al.getSequenceAt(i) != null)) - { - SequenceI s = al.getSequenceAt(i); + hscroll.addAdjustmentListener(this); + vscroll.addAdjustmentListener(this); - if (av.getShowFullId()) - { - id = s.getDisplayId(); - } - else - { - id = s.getName(); - } + setFocusable(true); + addKeyListener(new KeyAdapter() + { + public void keyPressed(KeyEvent evt) + { + switch (evt.getKeyCode()) + { + case 27: // escape key + av.setSelectionGroup(null); + repaint(); - if (fm.stringWidth(id) > idWidth) - { - idWidth = fm.stringWidth(id); - } + break; + + case KeyEvent.VK_DOWN: + alignFrame.moveSelectedSequences(false); - i++; + break; + + case KeyEvent.VK_UP: + alignFrame.moveSelectedSequences(true); + + break; + } + } + }); } - // Also check annotation label widths - i = 0; + /** + * DOCUMENT ME! + */ + public void fontChanged() + { + // set idCanvas bufferedImage to null + // to prevent drawing old image + FontMetrics fm = getFontMetrics(av.getFont()); + + scalePanelHolder.setPreferredSize(new Dimension(10, + av.charHeight + fm.getDescent())); + idSpaceFillerPanel1.setPreferredSize(new Dimension(10, + av.charHeight + fm.getDescent())); + + idPanel.idCanvas.gg = null; + annotationPanel.adjustPanelHeight(); + + Dimension d = calculateIdWidth(); + d.setSize(d.width + 4, d.height); + idPanel.idCanvas.setPreferredSize(d); + hscrollFillerPanel.setPreferredSize(d); + repaint(); + } - if (al.getAlignmentAnnotation() != null) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Dimension calculateIdWidth() { - fm = g.getFontMetrics(alabels.getFont()); + Graphics g = this.getGraphics(); - while (i < al.getAlignmentAnnotation().length) - { - String label = al.getAlignmentAnnotation()[i].label; + if (g == null) + { + javax.swing.JFrame f = new javax.swing.JFrame(); + f.addNotify(); + g = f.getGraphics(); + } + + FontMetrics fm = g.getFontMetrics(av.font); + AlignmentI al = av.getAlignment(); - if (fm.stringWidth(label) > idWidth) + int i = 0; + int idWidth = 0; + String id; + + while ((i < al.getHeight()) && (al.getSequenceAt(i) != null)) { - idWidth = fm.stringWidth(label); + SequenceI s = al.getSequenceAt(i); + + if (av.getShowFullId()) + { + id = s.getDisplayId(); + } + else + { + id = s.getName(); + } + + if (fm.stringWidth(id) > idWidth) + { + idWidth = fm.stringWidth(id); + } + + i++; } - i++; - } - } + // Also check annotation label widths + i = 0; - return new Dimension(idWidth, 12); - } + if (al.getAlignmentAnnotation() != null) + { + fm = g.getFontMetrics(alabels.getFont()); - public void highlightSearchResults(int[] results) - { - seqPanel.seqCanvas.highlightSearchResults(results); + while (i < al.getAlignmentAnnotation().length) + { + String label = al.getAlignmentAnnotation()[i].label; - // do we need to scroll the panel? - if (results != null) - { - SequenceI seq = av.alignment.getSequenceAt(results[0]); - int start = seq.findIndex(results[1]) - 1; - int end = seq.findIndex(results[2]) - 1; + if (fm.stringWidth(label) > idWidth) + { + idWidth = fm.stringWidth(label); + } - if ( (av.getStartRes() > start) || (av.getEndRes() < end) || - ( (av.getStartSeq() > results[0]) || - (av.getEndSeq() < results[0]))) - { - setScrollValues(start, results[0]); - } + i++; + } + } + + return new Dimension(idWidth, 12); } - } - - public OverviewPanel getOverviewPanel() - { - return overviewPanel; - } - - public void setOverviewPanel(OverviewPanel op) - { - overviewPanel = op; - } - - public void setAnnotationVisible(boolean b) - { - annotationSpaceFillerHolder.setVisible(b); - annotationScroller.setVisible(b); - } - - public void setWrapAlignment(boolean wrap) - { - scalePanelHolder.setVisible(!wrap); - hscroll.setVisible(!wrap); - idwidthAdjuster.setVisible(!wrap); - - av.setShowAnnotation(!wrap); - annotationScroller.setVisible(!wrap); - annotationSpaceFillerHolder.setVisible(!wrap); - idSpaceFillerPanel1.setVisible(!wrap); - - repaint(); - } - - public void setColourScheme() - { - ColourSchemeI cs = av.getGlobalColourScheme(); - - if (av.getConservationSelected()) + + /** + * DOCUMENT ME! + * + * @param results DOCUMENT ME! + */ + public void highlightSearchResults(int[] results) { - Alignment al = (Alignment) av.getAlignment(); - Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, - al.getSequences(), 0, - al.getWidth()); + seqPanel.seqCanvas.highlightSearchResults(results); - c.calculate(); - c.verdict(false, av.ConsPercGaps); + // do we need to scroll the panel? + if (results != null) + { + SequenceI seq = av.alignment.getSequenceAt(results[0]); + int start = seq.findIndex(results[1]) - 1; + int end = seq.findIndex(results[2]) - 1; + + if ((av.getStartRes() > start) || (av.getEndRes() < end) || + ((av.getStartSeq() > results[0]) || + (av.getEndSeq() < results[0]))) + { + setScrollValues(start, results[0]); + } + } + } - ConservationColourScheme ccs = new ConservationColourScheme(c, cs); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public OverviewPanel getOverviewPanel() + { + return overviewPanel; + } - av.setGlobalColourScheme(ccs); + /** + * DOCUMENT ME! + * + * @param op DOCUMENT ME! + */ + public void setOverviewPanel(OverviewPanel op) + { + overviewPanel = op; } - repaint(); - } + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setAnnotationVisible(boolean b) + { + annotationSpaceFillerHolder.setVisible(b); + annotationScroller.setVisible(b); + } - // return value is true if the scroll is valid - public boolean scrollUp(boolean up) - { - if (up) + /** + * DOCUMENT ME! + * + * @param wrap DOCUMENT ME! + */ + public void setWrapAlignment(boolean wrap) { - if (vscroll.getValue() < 1) - { - return false; - } + scalePanelHolder.setVisible(!wrap); + hscroll.setVisible(!wrap); + idwidthAdjuster.setVisible(!wrap); - fastPaint = false; - vscroll.setValue(vscroll.getValue() - 1); + av.setShowAnnotation(!wrap); + annotationScroller.setVisible(!wrap); + annotationSpaceFillerHolder.setVisible(!wrap); + idSpaceFillerPanel1.setVisible(!wrap); + + repaint(); } - else + + /** + * DOCUMENT ME! + */ + public void setColourScheme() { - if ( (vextent + vscroll.getValue()) >= av.getAlignment().getHeight()) - { - return false; - } + ColourSchemeI cs = av.getGlobalColourScheme(); - fastPaint = false; - vscroll.setValue(vscroll.getValue() + 1); - } + if (av.getConservationSelected()) + { + Alignment al = (Alignment) av.getAlignment(); + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, al.getSequences(), 0, + al.getWidth()); - fastPaint = true; + c.calculate(); + c.verdict(false, av.ConsPercGaps); - return true; - } + ConservationColourScheme ccs = new ConservationColourScheme(c, cs); - public boolean scrollRight(boolean right) - { - if (right) - { - if (hscroll.getValue() < 1) - { - return false; - } + av.setGlobalColourScheme(ccs); + } - fastPaint = false; - hscroll.setValue(hscroll.getValue() - 1); + repaint(); } - else + + // return value is true if the scroll is valid + public boolean scrollUp(boolean up) { - if ( (hextent + hscroll.getValue()) >= av.getAlignment().getWidth()) - { - return false; - } + if (up) + { + if (vscroll.getValue() < 1) + { + return false; + } + + fastPaint = false; + vscroll.setValue(vscroll.getValue() - 1); + } + else + { + if ((vextent + vscroll.getValue()) >= av.getAlignment().getHeight()) + { + return false; + } - fastPaint = false; - hscroll.setValue(hscroll.getValue() + 1); + fastPaint = false; + vscroll.setValue(vscroll.getValue() + 1); + } + + fastPaint = true; + + return true; } - fastPaint = true; + /** + * DOCUMENT ME! + * + * @param right DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean scrollRight(boolean right) + { + if (right) + { + if (hscroll.getValue() < 1) + { + return false; + } - return true; - } + fastPaint = false; + hscroll.setValue(hscroll.getValue() - 1); + } + else + { + if ((hextent + hscroll.getValue()) >= av.getAlignment().getWidth()) + { + return false; + } - public void setScrollValues(int x, int y) - { - av.setEndRes( (x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - - 1); + fastPaint = false; + hscroll.setValue(hscroll.getValue() + 1); + } - hextent = seqPanel.seqCanvas.getWidth() / av.charWidth; - vextent = seqPanel.seqCanvas.getHeight() / av.charHeight; + fastPaint = true; - if (hextent > av.alignment.getWidth()) - { - hextent = av.alignment.getWidth(); + return true; } - if (vextent > av.alignment.getHeight()) + /** + * DOCUMENT ME! + * + * @param x DOCUMENT ME! + * @param y DOCUMENT ME! + */ + public void setScrollValues(int x, int y) { - vextent = av.alignment.getHeight(); - } + av.setEndRes((x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - + 1); - if ( (hextent + x) > av.getAlignment().getWidth()) - { - x = av.getAlignment().getWidth() - hextent; - } + hextent = seqPanel.seqCanvas.getWidth() / av.charWidth; + vextent = seqPanel.seqCanvas.getHeight() / av.charHeight; - if ( (vextent + y) > av.getAlignment().getHeight()) - { - y = av.getAlignment().getHeight() - vextent; - } + if (hextent > av.alignment.getWidth()) + { + hextent = av.alignment.getWidth(); + } - if (y < 0) - { - y = 0; - } + if (vextent > av.alignment.getHeight()) + { + vextent = av.alignment.getHeight(); + } - if (x < 0) - { - x = 0; - } + if ((hextent + x) > av.getAlignment().getWidth()) + { + x = av.getAlignment().getWidth() - hextent; + } - hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth()); - vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight()); - } + if ((vextent + y) > av.getAlignment().getHeight()) + { + y = av.getAlignment().getHeight() - vextent; + } - public void adjustmentValueChanged(AdjustmentEvent evt) - { - int oldX = av.getStartRes(); - int oldY = av.getStartSeq(); + if (y < 0) + { + y = 0; + } - if (evt.getSource() == hscroll) - { - int x = hscroll.getValue(); - av.setStartRes(x); - av.setEndRes( (x + - (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1); + if (x < 0) + { + x = 0; + } + + hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth()); + vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight()); } - if (evt.getSource() == vscroll) + public void this_mouseWheelMoved(MouseWheelEvent e) { - int offy = vscroll.getValue(); - - if (av.getWrapAlignment()) - { - int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel. - seqCanvas.getWidth()); - av.setStartRes(vscroll.getValue() * rowSize); - av.setEndRes( (vscroll.getValue() + 1) * rowSize); - } + if(e.getWheelRotation()>0) + scrollUp(false); else - { - av.setStartSeq(offy); - av.setEndSeq(offy + - (seqPanel.seqCanvas.getHeight() / av.getCharHeight())); - } + scrollUp(true); } - if (overviewPanel != null) - { - overviewPanel.setBoxPosition(); - } - if (av.getWrapAlignment() || !fastPaint) - { - repaint(); - } - else + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void adjustmentValueChanged(AdjustmentEvent evt) { - idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY); - seqPanel.seqCanvas.fastPaint(av.getStartRes() - oldX, - av.getStartSeq() - oldY); + int oldX = av.getStartRes(); + int oldY = av.getStartSeq(); - scalePanel.repaint(); + if (evt.getSource() == hscroll) + { + int x = hscroll.getValue(); + av.setStartRes(x); + av.setEndRes((x + + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1); + } - if (av.getShowAnnotation()) - { - annotationPanel.fastPaint(av.getStartRes() - oldX); - } - } - } + if (evt.getSource() == vscroll) + { + int offy = vscroll.getValue(); + + if (av.getWrapAlignment()) + { + int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); + av.setStartRes(vscroll.getValue() * rowSize); + av.setEndRes((vscroll.getValue() + 1) * rowSize); + } + else + { + av.setStartSeq(offy); + av.setEndSeq(offy + + (seqPanel.seqCanvas.getHeight() / av.getCharHeight())); + } + } - public void paintComponent(Graphics g) - { - invalidate(); + if (overviewPanel != null) + { + overviewPanel.setBoxPosition(); + } - Dimension d = idPanel.idCanvas.getPreferredSize(); - idPanelHolder.setPreferredSize(d); - hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12)); - validate(); + if (av.getWrapAlignment() || !fastPaint) + { + repaint(); + } + else + { + idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY); + seqPanel.seqCanvas.fastPaint(av.getStartRes() - oldX, + av.getStartSeq() - oldY); - if (av.getWrapAlignment()) - { - int max = av.alignment.getWidth() / - seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); - vscroll.setMaximum(max); - vscroll.setUnitIncrement(1); - vscroll.setVisibleAmount(1); - } - else - { - setScrollValues(av.getStartRes(), av.getStartSeq()); + scalePanel.repaint(); + + if (av.getShowAnnotation()) + { + annotationPanel.fastPaint(av.getStartRes() - oldX); + } + } } - } - public int print(Graphics pg, PageFormat pf, int pi) - throws PrinterException - { - pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY()); + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) + { + invalidate(); - int pwidth = (int) pf.getImageableWidth(); - int pheight = (int) pf.getImageableHeight(); + Dimension d = idPanel.idCanvas.getPreferredSize(); + idPanelHolder.setPreferredSize(d); + hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12)); + validate(); - if (av.getWrapAlignment()) - { - return printWrappedAlignment(pg, pwidth, pheight, pi); + if (av.getWrapAlignment()) + { + int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); + vscroll.setMaximum(max); + vscroll.setUnitIncrement(1); + vscroll.setVisibleAmount(1); + } + else + { + setScrollValues(av.getStartRes(), av.getStartSeq()); + } } - else + + /** + * DOCUMENT ME! + * + * @param pg DOCUMENT ME! + * @param pf DOCUMENT ME! + * @param pi DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws PrinterException DOCUMENT ME! + */ + public int print(Graphics pg, PageFormat pf, int pi) + throws PrinterException { - return printUnwrapped(pg, pwidth, pheight, pi); - } - } + pg.translate((int) pf.getImageableX(), (int) pf.getImageableY()); - public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi) - throws PrinterException - { - int idWidth = calculateIdWidth().width + 4; - FontMetrics fm = getFontMetrics(av.getFont()); - int scaleHeight = av.charHeight + fm.getDescent(); + int pwidth = (int) pf.getImageableWidth(); + int pheight = (int) pf.getImageableHeight(); - pg.setColor(Color.white); - pg.fillRect(0, 0, pwidth, pheight); - pg.setFont(av.getFont()); + if (av.getWrapAlignment()) + { + return printWrappedAlignment(pg, pwidth, pheight, pi); + } + else + { + return printUnwrapped(pg, pwidth, pheight, pi); + } + } - //////////////////////////////////// - /// How many sequences and residues can we fit on a printable page? - int totalRes = (pwidth - idWidth) / av.getCharWidth(); + /** + * DOCUMENT ME! + * + * @param pg DOCUMENT ME! + * @param pwidth DOCUMENT ME! + * @param pheight DOCUMENT ME! + * @param pi DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws PrinterException DOCUMENT ME! + */ + public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi) + throws PrinterException + { + int idWidth = calculateIdWidth().width + 4; + FontMetrics fm = getFontMetrics(av.getFont()); + int scaleHeight = av.charHeight + fm.getDescent(); - int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) - - 1; + pg.setColor(Color.white); + pg.fillRect(0, 0, pwidth, pheight); + pg.setFont(av.getFont()); - int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1; + //////////////////////////////////// + /// How many sequences and residues can we fit on a printable page? + int totalRes = (pwidth - idWidth) / av.getCharWidth(); - ///////////////////////////// - /// Only print these sequences and residues on this page - int startRes; + int totalSeq = (int) ((pheight - scaleHeight) / av.getCharHeight()) - + 1; - ///////////////////////////// - /// Only print these sequences and residues on this page - int endRes; + int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1; - ///////////////////////////// - /// Only print these sequences and residues on this page - int startSeq; + ///////////////////////////// + /// Only print these sequences and residues on this page + int startRes; - ///////////////////////////// - /// Only print these sequences and residues on this page - int endSeq; - startRes = (pi % pagesWide) * totalRes; - endRes = (startRes + totalRes) - 1; + ///////////////////////////// + /// Only print these sequences and residues on this page + int endRes; - if (endRes > (av.getAlignment().getWidth() - 1)) - { - endRes = av.getAlignment().getWidth() - 1; - } + ///////////////////////////// + /// Only print these sequences and residues on this page + int startSeq; - startSeq = (pi / pagesWide) * totalSeq; - endSeq = startSeq + totalSeq; + ///////////////////////////// + /// Only print these sequences and residues on this page + int endSeq; + startRes = (pi % pagesWide) * totalRes; + endRes = (startRes + totalRes) - 1; - if (endSeq > av.getAlignment().getHeight()) - { - endSeq = av.getAlignment().getHeight(); - } + if (endRes > (av.getAlignment().getWidth() - 1)) + { + endRes = av.getAlignment().getWidth() - 1; + } - int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight; + startSeq = (pi / pagesWide) * totalSeq; + endSeq = startSeq + totalSeq; - if (av.showAnnotation) - { - pagesHigh += annotationPanel.getHeight(); - } + if (endSeq > av.getAlignment().getHeight()) + { + endSeq = av.getAlignment().getHeight(); + } - pagesHigh /= pheight; + int pagesHigh = ((av.alignment.getHeight() / totalSeq) + 1) * pheight; - if (pi >= (pagesWide * pagesHigh)) - { - return Printable.NO_SUCH_PAGE; - } + if (av.showAnnotation) + { + pagesHigh += annotationPanel.getHeight(); + } - //draw Scale - pg.translate(idWidth, 0); - scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight); - pg.translate( -idWidth, scaleHeight); + pagesHigh /= pheight; - //////////////// - // Draw the ids - Color currentColor = null; - Color currentTextColor = null; + if (pi >= (pagesWide * pagesHigh)) + { + return Printable.NO_SUCH_PAGE; + } - for (int i = startSeq; i < endSeq; i++) - { - if ( (av.getSelectionGroup() != null) && - av.getSelectionGroup().sequences.contains( - av.getAlignment().getSequenceAt(i))) - { - currentColor = Color.gray; - currentTextColor = Color.black; - } - else - { - currentColor = av.getAlignment().getSequenceAt(i).getColor(); - currentTextColor = Color.black; - } + //draw Scale + pg.translate(idWidth, 0); + scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight); + pg.translate(-idWidth, scaleHeight); - pg.setColor(currentColor); - pg.fillRect(0, - jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, - av.getCharHeight()), idWidth, av.getCharHeight()); + //////////////// + // Draw the ids + Color currentColor = null; + Color currentTextColor = null; - pg.setColor(currentTextColor); + for (int i = startSeq; i < endSeq; i++) + { + if ((av.getSelectionGroup() != null) && + av.getSelectionGroup().sequences.contains( + av.getAlignment().getSequenceAt(i))) + { + currentColor = Color.gray; + currentTextColor = Color.black; + } + else + { + currentColor = av.getAlignment().getSequenceAt(i).getColor(); + currentTextColor = Color.black; + } + + pg.setColor(currentColor); + pg.fillRect(0, (i-startSeq) * av.charHeight, idWidth, + av.getCharHeight()); + + pg.setColor(currentTextColor); + + String string = av.getAlignment().getSequenceAt(i).getName(); + + if (av.getShowFullId()) + { + string = av.getAlignment().getSequenceAt(i).getDisplayId(); + } + + pg.drawString(string, 0, + (((i-startSeq) * av.charHeight) + av.getCharHeight()) - + (av.getCharHeight() / 5)); + } - String string = av.getAlignment().getSequenceAt(i).getName(); + // draw main sequence panel + pg.translate(idWidth, 0); + seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, + startRes, startSeq, 0); - if (av.getShowFullId()) - { - string = av.getAlignment().getSequenceAt(i).getDisplayId(); - } + if (av.showAnnotation && (endSeq == av.alignment.getHeight())) + { + pg.translate(-idWidth, (endSeq - startSeq) * av.charHeight); + alabels.drawComponent((Graphics2D) pg); + pg.translate(idWidth, 0); + annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes + + 1); + } - pg.drawString(string, 0, - (jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, - av.getCharHeight()) + av.getCharHeight()) - - (av.getCharHeight() / 5)); + return Printable.PAGE_EXISTS; } - // draw main sequence panel - pg.translate(idWidth, 0); - seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, - startRes, startSeq, 0); - - if (av.showAnnotation && (endSeq == av.alignment.getHeight())) + /** + * DOCUMENT ME! + * + * @param pg DOCUMENT ME! + * @param pwidth DOCUMENT ME! + * @param pheight DOCUMENT ME! + * @param pi DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws PrinterException DOCUMENT ME! + */ + public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, + int pi) throws PrinterException { - pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight); - alabels.drawComponent( (Graphics2D) pg); - pg.translate(idWidth, 0); - annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes + - 1); - } + int idWidth = calculateIdWidth().width + 4; - return Printable.PAGE_EXISTS; - } + int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth - + idWidth); + int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * ((av.alignment.getWidth() / resWidth) + + 1) * av.charHeight; - public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, - int pi) - throws PrinterException - { - int idWidth = calculateIdWidth().width + 4; + pg.setColor(Color.white); + pg.fillRect(0, 0, pwidth, pheight); + pg.setFont(av.getFont()); - int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth - - idWidth); - int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * - ( (av.alignment.getWidth() / resWidth) + - 1) * av.charHeight; + //////////////// + // Draw the ids + pg.setColor(Color.black); - pg.setColor(Color.white); - pg.fillRect(0, 0, pwidth, pheight); - pg.setFont(av.getFont()); + pg.translate(0, -pi * pheight); - //////////////// - // Draw the ids - pg.setColor(Color.black); + pg.setClip(0, pi * pheight, pwidth, pheight); - pg.translate(0, -pi * pheight); + int ypos = 2 * av.charHeight; - pg.setClip(0, pi * pheight, pwidth, pheight); + do + { + for (int i = 0; i < av.alignment.getHeight(); i++) + { + SequenceI s = av.alignment.getSequenceAt(i); + String string = s.getName(); + + if (av.getShowFullId()) + { + string = s.getDisplayId(); + } + + pg.drawString(string, 0, + ((i * av.charHeight) + ypos + av.charHeight) - + (av.charHeight / 5)); + } + + ypos += ((av.alignment.getHeight() + 2) * av.charHeight); + } + while (ypos < totalHeight); - int ypos = 2 * av.charHeight; + pg.translate(idWidth, 0); - do - { - for (int i = 0; i < av.alignment.getHeight(); i++) - { - SequenceI s = av.alignment.getSequenceAt(i); - String string = s.getName(); + seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0); - if (av.getShowFullId()) + if ((pi * pheight) < totalHeight) + { + return Printable.PAGE_EXISTS; + } + else { - string = s.getDisplayId(); + return Printable.NO_SUCH_PAGE; } + } - pg.drawString(string, 0, - (AlignmentUtil.getPixelHeight(0, i, av.charHeight) + ypos + - av.charHeight) - (av.charHeight / 5)); - } + /** + * DOCUMENT ME! + */ + public void makeEPS(File epsFile) + { + if(epsFile == null) + { + jalview.io.JalviewFileChooser chooser = new jalview.io. + JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] + {"eps"}, + new String[] + {"Encapsulated Postscript"}, + "Encapsulated Postscript"); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Create EPS file from alignment"); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(this); + + if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) + { + return; + } + + epsFile = chooser.getSelectedFile(); + + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + } - ypos += ( (av.alignment.getHeight() + 2) * av.charHeight); - } - while (ypos < totalHeight); + int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30; + int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth); - pg.translate(idWidth, 0); + if (av.getWrapAlignment()) + { + height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) * + av.chunkHeight; + width = seqPanel.getWidth() + idPanel.getWidth(); - seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0); + } - if ( (pi * pheight) < totalHeight) - { - return Printable.PAGE_EXISTS; - } - else - { - return Printable.NO_SUCH_PAGE; - } - } - public void makeEPS() - { - int height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) * - av.chunkHeight; - int width = seqPanel.getWidth() + idPanel.getWidth(); + if (av.getShowAnnotation()) + { + height += annotationPanel.getPreferredSize().height; + } - if (!av.getWrapAlignment()) - { - height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30; - width = idPanel.getWidth() + - (av.alignment.getWidth() * av.charWidth); + try + { + FileOutputStream out = new FileOutputStream(epsFile); + EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width, + height); + + if (av.getWrapAlignment()) + { + printWrappedAlignment(pg, width, height, 0); + } + else + { + printUnwrapped(pg, width, height, 0); + } + + pg.flush(); + pg.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - if (av.getShowAnnotation()) + + public void makePNGImageMap(File imgMapFile, String imageName) { - height += annotationPanel.getPreferredSize().height; + ///////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS + ////////////////////////////////////////////// + int idWidth = calculateIdWidth().width + 4; + FontMetrics fm = getFontMetrics(av.getFont()); + int scaleHeight = av.charHeight + fm.getDescent(); + + // Gen image map + ////////////////////////////////// + if(imgMapFile!=null) + { + try + { + PrintWriter out = new PrintWriter(new FileWriter(imgMapFile)); + out.println(jalview.io.HTMLOutput.getImageMapHTML()); + out.println("" + +""); + + for (int s = 0; s < av.alignment.getHeight(); s++) + { + SequenceI seq = av.alignment.getSequenceAt(s); + SequenceGroup[] groups = av.alignment.findAllGroups(seq); + for (int i = 0; i < groups.length; i++) + { + int sy = s * av.charHeight + scaleHeight; + for (int res = groups[i].getStartRes(); + res < groups[i].getEndRes() + 1; res++) + { + int alIndex = seq.findPosition(res); + Object obj = ResidueProperties.aa2Triplet.get( + seq.getCharAt(res) + ""); + if (obj == null) + continue; + + String triplet = obj.toString(); + + out.println( + "" + groups[i].getName() + + "')\"; onMouseOut=\"toolTip()\"; " + + " href=\"#\">"); + } + } + } + + out.println(""); + out.close(); + + } + catch (Exception ex) + { + ex.printStackTrace(); + } + }///////////END OF IMAGE MAP + } - try + /** + * DOCUMENT ME! + */ + public void makePNG(File pngFile) { - jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), new String[] - {"eps"}, - new String[] - {"Encapsulated Postscript"}, - "Encapsulated Postscript"); - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Create EPS file from alignment"); - chooser.setToolTipText("Save"); - - int value = chooser.showSaveDialog(this); - - if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) + if(pngFile==null) { - return; + jalview.io.JalviewFileChooser chooser = new jalview.io. + JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] + {"png"}, + new String[] + {"Portable network graphics"}, + "Portable network graphics"); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Create EPS file from alignment"); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(this); + + if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) + { + return; + } + + pngFile = chooser.getSelectedFile(); + + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); } - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); - FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); - EpsGraphics2D pg = new EpsGraphics2D("Example", out, 0, 0, width, - height); + + int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30; + int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth); if (av.getWrapAlignment()) { - printWrappedAlignment(pg, width, height, 0); - } - else - { - printUnwrapped(pg, width, height, 0); - } + height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) * + av.chunkHeight; + width = seqPanel.getWidth() + idPanel.getWidth(); - pg.flush(); - pg.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } + } - public void makePNG() - { - int height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) * - av.chunkHeight; - int width = seqPanel.getWidth() + idPanel.getWidth(); - if (!av.getWrapAlignment()) - { - height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30; - width = idPanel.getWidth() + - (av.alignment.getWidth() * av.charWidth); - } + if (av.getShowAnnotation()) + { + height += annotationPanel.getPreferredSize().height; + } - if (av.getShowAnnotation()) - { - height += annotationPanel.getPreferredSize().height; - } + try + { - try - { - jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), new String[] - {"png"}, - new String[] - {"Portable network graphics"}, - "Portable network graphics"); - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Create EPS file from alignment"); - chooser.setToolTipText("Save"); - - int value = chooser.showSaveDialog(this); - - if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) - { - return; - } + FileOutputStream out = new FileOutputStream(pngFile); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); + BufferedImage bi = new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + Graphics2D png = (Graphics2D) bi.getGraphics(); - FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); + png.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - BufferedImage bi = new BufferedImage(width, height, - BufferedImage.TYPE_INT_RGB); - Graphics2D png = (Graphics2D) bi.getGraphics(); + if (av.getWrapAlignment()) + { + printWrappedAlignment(png, width, height, 0); + } + else + { + printUnwrapped(png, width, height, 0); + } - png.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + ImageIO.write(bi, "png", out); + out.close(); + } + catch(OutOfMemoryError err) + { + System.out.println("########################\n" + +"OUT OF MEMORY "+pngFile+"\n" + +"########################"); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } +} - if (av.getWrapAlignment()) - { - printWrappedAlignment(png, width, height, 0); - } - else - { - printUnwrapped(png, width, height, 0); - } - ImageIO.write(bi, "png", out); - out.close(); - } - catch (Exception ex) +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +class Preview extends JFrame +{ + /** + * Creates a new Preview object. + * + * @param image DOCUMENT ME! + */ + public Preview(Image image) { - ex.printStackTrace(); + setResizable(true); + setSize(image.getWidth(this), image.getHeight(this)); + setVisible(true); + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER); + validate(); + repaint(); } - } } -class Preview - extends JFrame -{ - public Preview(Image image) - { - setResizable(true); - setSize(image.getWidth(this), image.getHeight(this)); - setVisible(true); - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(new PreviewPanel(image), BorderLayout.CENTER); - validate(); - repaint(); - } -} -class PreviewPanel - extends JPanel +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +class PreviewPanel extends JPanel { - Image image; - - public PreviewPanel(Image image) - { - this.image = image; - } - - public void paintComponent(Graphics g) - { - if (image != null) + Image image; + + /** + * Creates a new PreviewPanel object. + * + * @param image DOCUMENT ME! + */ + public PreviewPanel(Image image) { - g.drawImage(image, 0, 0, this); + this.image = image; } - else + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - System.out.println("DEBUG:image is null"); + if (image != null) + { + g.drawImage(image, 0, 0, this); + } + else + { + System.out.println("DEBUG:image is null"); + } } - } } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 9b9e2db..2a972ea 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -18,316 +18,386 @@ */ package jalview.gui; +import jalview.datamodel.*; + import java.awt.*; import java.awt.event.*; import java.awt.image.*; + import javax.swing.*; -import jalview.datamodel.*; -public class AnnotationLabels - extends JPanel implements MouseListener, +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class AnnotationLabels extends JPanel implements MouseListener, MouseMotionListener, ActionListener { - static String ADDNEW = "Add New Row"; - static String HIDE = "Hide This Row"; - static String DELETE = "Delete This Row"; - static String SHOWALL = "Show All Hidden Rows"; - static String OUTPUT_TEXT = "Show Values In Textbox"; - boolean active = false; - Image image; - AlignmentPanel ap; - boolean resizing = false; - int oldY; - int mouseX; - int selectedRow = 0; - int scrollOffset = 0; - - public AnnotationLabels(AlignmentPanel ap) - { - this.ap = ap; - - java.net.URL url = getClass().getResource("/images/idwidth.gif"); - Image temp = null; - - if (url != null) + static String ADDNEW = "Add New Row"; + static String HIDE = "Hide This Row"; + static String DELETE = "Delete This Row"; + static String SHOWALL = "Show All Hidden Rows"; + static String OUTPUT_TEXT = "Show Values In Textbox"; + boolean active = false; + Image image; + AlignmentPanel ap; + boolean resizing = false; + int oldY; + int mouseX; + int selectedRow = 0; + int scrollOffset = 0; + + /** + * Creates a new AnnotationLabels object. + * + * @param ap DOCUMENT ME! + */ + public AnnotationLabels(AlignmentPanel ap) { - temp = java.awt.Toolkit.getDefaultToolkit().createImage(url); - } + this.ap = ap; - try - { - MediaTracker mt = new MediaTracker(this); - mt.addImage(temp, 0); - mt.waitForID(0); + java.net.URL url = getClass().getResource("/images/idwidth.gif"); + Image temp = null; + + if (url != null) + { + temp = java.awt.Toolkit.getDefaultToolkit().createImage(url); + } + + try + { + MediaTracker mt = new MediaTracker(this); + mt.addImage(temp, 0); + mt.waitForID(0); + } + catch (Exception ex) + { + } + + BufferedImage bi = new BufferedImage(temp.getHeight(this), + temp.getWidth(this), BufferedImage.TYPE_INT_RGB); + Graphics2D g = (Graphics2D) bi.getGraphics(); + g.rotate(Math.toRadians(90)); + g.drawImage(temp, 0, -bi.getWidth(this), this); + image = (Image) bi; + + addMouseListener(this); + addMouseMotionListener(this); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param y DOCUMENT ME! + */ + public void setScrollOffset(int y) { + scrollOffset = y; + repaint(); } - BufferedImage bi = new BufferedImage(temp.getHeight(this), - temp.getWidth(this), - BufferedImage.TYPE_INT_RGB); - Graphics2D g = (Graphics2D) bi.getGraphics(); - g.rotate(Math.toRadians(90)); - g.drawImage(temp, 0, -bi.getWidth(this), this); - image = (Image) bi; - - addMouseListener(this); - addMouseMotionListener(this); - } - - public void setScrollOffset(int y) - { - scrollOffset = y; - repaint(); - } - - public void actionPerformed(ActionEvent evt) - { - int dif = 0; - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - - if (evt.getActionCommand().equals(ADDNEW)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void actionPerformed(ActionEvent evt) { - String label = JOptionPane.showInputDialog(this, - "Label for annotation"); - if (label == null) - label = ""; + int dif = 0; + AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - ap.av.alignment.addAnnotation(new AlignmentAnnotation(label, - "New description", - new Annotation[ap.av.alignment.getWidth()])); + if (evt.getActionCommand().equals(ADDNEW)) + { + String label = JOptionPane.showInputDialog(this, + "Label for annotation"); - dif = aa[aa.length-1].height; - } - else if (evt.getActionCommand().equals(HIDE)) - { - aa[selectedRow].visible = false; + if (label == null) + { + label = ""; + } + + ap.av.alignment.addAnnotation(new AlignmentAnnotation(label, + "New description", + new Annotation[ap.av.alignment.getWidth()])); + + dif = aa[aa.length - 1].height; + } + else if (evt.getActionCommand().equals(HIDE)) + { + aa[selectedRow].visible = false; + + if (aa[selectedRow].label.equals("Conservation")) + { + ap.av.showConservation = false; + } - if (aa[selectedRow].label.equals("Conservation")) - { - ap.av.showConservation = false; - } + if (aa[selectedRow].label.equals("Quality")) + { + ap.av.showQuality = false; + } - if (aa[selectedRow].label.equals("Quality")) - { - ap.av.showQuality = false; - } + if (aa[selectedRow].label.equals("Consensus")) + { + ap.av.showIdentity = false; + } + + dif = aa[selectedRow].height * -1; + } + else if (evt.getActionCommand().equals(DELETE)) + { + ap.av.alignment.deleteAnnotation(aa[selectedRow]); + dif = aa[selectedRow].height * -1; + } + else if (evt.getActionCommand().equals(SHOWALL)) + { + for (int i = 0; i < aa.length; i++) + { + if (!aa[i].visible) + { + dif += aa[i].height; + aa[i].visible = true; + } + } + } + else if (evt.getActionCommand().equals(OUTPUT_TEXT)) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(); + Desktop.addInternalFrame(cap, + ap.alignFrame.getTitle() + " - " + aa[selectedRow].label, 500, + 100); + cap.setText(aa[selectedRow].toString()); + } - if (aa[selectedRow].label.equals("Consensus")) - { - ap.av.showIdentity = false; - } + ap.annotationPanel.adjustPanelHeight(); - dif = aa[selectedRow].height*-1; + Dimension d = ap.annotationScroller.getPreferredSize(); + ap.annotationScroller.setPreferredSize(new Dimension(d.width, + d.height + dif)); + d = ap.annotationSpaceFillerHolder.getPreferredSize(); + ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension(d.width, + d.height + dif)); + + ap.addNotify(); } - else if (evt.getActionCommand().equals(DELETE)) + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mousePressed(MouseEvent evt) { - ap.av.alignment.deleteAnnotation(aa[selectedRow]); - dif = aa[selectedRow].height*-1; + oldY = evt.getY(); } - else if (evt.getActionCommand().equals(SHOWALL)) + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseReleased(MouseEvent evt) { - for (int i = 0; i < aa.length; i++) - { - if(!aa[i].visible) - { - dif+=aa[i].height; - aa[i].visible = true; - } - } + active = false; + repaint(); } - else if (evt.getActionCommand().equals(OUTPUT_TEXT)) + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseEntered(MouseEvent evt) { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - Desktop.addInternalFrame(cap, - ap.alignFrame.getTitle() + " - " + - aa[selectedRow].label, 500, - 100); - cap.setText(aa[selectedRow].toString()); + active = true; + repaint(); } - ap.annotationPanel.adjustPanelHeight(); + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseExited(MouseEvent evt) + { + active = false; + repaint(); + } - Dimension d = ap.annotationScroller.getPreferredSize(); - ap.annotationScroller.setPreferredSize(new Dimension(d.width, d.height+dif)); - d = ap.annotationSpaceFillerHolder.getPreferredSize(); - ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension( - d.width, d.height+dif)); + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseDragged(MouseEvent evt) + { + active = true; - ap.addNotify(); + Dimension d = ap.annotationScroller.getPreferredSize(); + int dif = evt.getY() - oldY; + dif /= ap.av.charHeight; + dif *= ap.av.charHeight; - } + if ((d.height - dif) > 20) + { + ap.annotationScroller.setPreferredSize(new Dimension(d.width, + d.height - dif)); + d = ap.annotationSpaceFillerHolder.getPreferredSize(); + ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension( + d.width, d.height - dif)); + ap.repaint(); + } - public void mousePressed(MouseEvent evt) - { - oldY = evt.getY(); - } + ap.addNotify(); + } - public void mouseReleased(MouseEvent evt) - { - active = false; - repaint(); - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseMoved(MouseEvent evt) + { + } - public void mouseEntered(MouseEvent evt) - { - active = true; - repaint(); - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseClicked(MouseEvent evt) + { + int y = evt.getY() - scrollOffset; + AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - public void mouseExited(MouseEvent evt) - { - active = false; - repaint(); - } + if ((aa == null) || (aa.length == 0)) + { + JPopupMenu pop = new JPopupMenu("Annotations"); + JMenuItem item = new JMenuItem(ADDNEW); + item.addActionListener(this); + pop.add(item); + pop.show(this, evt.getX(), evt.getY()); - public void mouseDragged(MouseEvent evt) - { - active = true; + return; + } - Dimension d = ap.annotationScroller.getPreferredSize(); - int dif = evt.getY() - oldY; + int height = 0; - dif /= ap.av.charHeight; - dif *= ap.av.charHeight; + for (int i = 0; i < aa.length; i++) + { + if (!aa[i].visible) + { + continue; + } - if ( (d.height - dif) > 20) - { - ap.annotationScroller.setPreferredSize(new Dimension(d.width, - d.height - dif)); - d = ap.annotationSpaceFillerHolder.getPreferredSize(); - ap.annotationSpaceFillerHolder.setPreferredSize(new Dimension( - d.width, d.height - dif)); - ap.repaint(); - } + height += aa[i].height; - ap.addNotify(); - } + if (y < height) + { + selectedRow = i; - public void mouseMoved(MouseEvent evt) - { - } + break; + } + } - public void mouseClicked(MouseEvent evt) - { - int y = evt.getY() - scrollOffset; - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); + JPopupMenu pop = new JPopupMenu("Annotations"); + JMenuItem item = new JMenuItem(ADDNEW); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(HIDE); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(DELETE); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(SHOWALL); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(OUTPUT_TEXT); + item.addActionListener(this); + pop.add(item); + pop.show(this, evt.getX(), evt.getY()); + } - if ( (aa == null) || (aa.length == 0)) + /** + * DOCUMENT ME! + * + * @param g1 DOCUMENT ME! + */ + public void paintComponent(Graphics g1) { - JPopupMenu pop = new JPopupMenu("Annotations"); - JMenuItem item = new JMenuItem(ADDNEW); - item.addActionListener(this); - pop.add(item); - pop.show(this, evt.getX(), evt.getY()); + Graphics2D g = (Graphics2D) g1; + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - return; + drawComponent(g); } - int height = 0; - - for (int i = 0; i < aa.length; i++) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void drawComponent(Graphics2D g) { - if (!aa[i].visible) - { - continue; - } + FontMetrics fm = g.getFontMetrics(g.getFont()); + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); - height += aa[i].height; + g.translate(0, scrollOffset); + g.setColor(Color.black); - if (y < height) - { - selectedRow = i; + AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); + int y = g.getFont().getSize(); + int x = 0; + int width = getWidth(); + if(width==0) + width = ap.calculateIdWidth().width + 4; - break; - } - } - - JPopupMenu pop = new JPopupMenu("Annotations"); - JMenuItem item = new JMenuItem(ADDNEW); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(HIDE); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(DELETE); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(SHOWALL); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(OUTPUT_TEXT); - item.addActionListener(this); - pop.add(item); - pop.show(this, evt.getX(), evt.getY()); - } - - public void paintComponent(Graphics g1) - { - Graphics2D g = (Graphics2D) g1; - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - drawComponent(g); - } - - public void drawComponent(Graphics2D g) - { - FontMetrics fm = g.getFontMetrics(g.getFont()); - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - - g.translate(0, scrollOffset); - g.setColor(Color.black); - - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - int y = g.getFont().getSize(); - int x = 0; - - if (aa != null) - { - for (int i = 0; i < aa.length; i++) - { - if (!aa[i].visible) + if (aa != null) { - continue; + for (int i = 0; i < aa.length; i++) + { + if (!aa[i].visible) + { + continue; + } + + x = width - fm.stringWidth(aa[i].label) - 3; + + if (aa[i].isGraph) + { + y += (aa[i].height / 3); + } + + g.drawString(aa[i].label, x, y); + + if (aa[i].isGraph) + { + y += ((2 * aa[i].height) / 3); + } + else + { + y += aa[i].height; + } + } } - x = getWidth() - fm.stringWidth(aa[i].label) - 3; - - if (aa[i].isGraph) + if (active) { - y += (aa[i].height / 3); + if (image != null) + { + g.drawImage(image, 2, 0, this); + } } - g.drawString(aa[i].label, x, y); - - if (aa[i].isGraph) + if ((aa == null) || (aa.length < 1)) { - y += ( (2 * aa[i].height) / 3); + g.drawString("Right click", 2, 8); + g.drawString("to add annotation", 2, 18); } - else - { - y += aa[i].height; - } - } - } - - if (active) - { - if (image != null) - { - g.drawImage(image, 2, 0, this); - } - } - - if ( (aa == null) || (aa.length < 1)) - { - g.drawString("Right click", 2, 8); - g.drawString("to add annotation", 2, 18); } - } } diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index a6c2055..9ae103e 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -18,751 +18,841 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; + +import java.util.*; + import javax.swing.*; -import jalview.datamodel.*; -public class AnnotationPanel - extends JPanel implements MouseListener, +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class AnnotationPanel extends JPanel implements MouseListener, MouseMotionListener, ActionListener, AdjustmentListener { - static String HELIX = "Helix"; - static String SHEET = "Sheet"; - static String LABEL = "Label"; - static String REMOVE = "Remove Annotation"; - static String COLOUR = "Colour"; - static Color HELIX_COLOUR = Color.red.darker(); - static Color SHEET_COLOUR = Color.green.darker().darker(); - - public static int GRAPH_HEIGHT = 40; - AlignViewport av; - AlignmentPanel ap; - int activeRow = -1; - Vector activeRes; - BufferedImage image; - Graphics2D gg; - FontMetrics fm; - int imgWidth = 0; - boolean fastPaint = false; - - public AnnotationPanel(AlignmentPanel ap) - { - ToolTipManager.sharedInstance().registerComponent(this); - ToolTipManager.sharedInstance().setInitialDelay(0); - ToolTipManager.sharedInstance().setDismissDelay(10000); - this.ap = ap; - av = ap.av; - this.setLayout(null); - addMouseListener(this); - addMouseMotionListener(this); - ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this); - } - - public void adjustmentValueChanged(AdjustmentEvent evt) - { - ap.alabels.setScrollOffset( -evt.getValue()); - } - - public void adjustPanelHeight() - { - // setHeight of panels - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int height = 0; - - if (aa != null) + static String HELIX = "Helix"; + static String SHEET = "Sheet"; + static String LABEL = "Label"; + static String REMOVE = "Remove Annotation"; + static String COLOUR = "Colour"; + static Color HELIX_COLOUR = Color.red.darker(); + static Color SHEET_COLOUR = Color.green.darker().darker(); + + /** DOCUMENT ME!! */ + public static int GRAPH_HEIGHT = 40; + AlignViewport av; + AlignmentPanel ap; + int activeRow = -1; + Vector activeRes; + BufferedImage image; + Graphics2D gg; + FontMetrics fm; + int imgWidth = 0; + boolean fastPaint = false; + + /** + * Creates a new AnnotationPanel object. + * + * @param ap DOCUMENT ME! + */ + public AnnotationPanel(AlignmentPanel ap) { - for (int i = 0; i < aa.length; i++) - { - if (!aa[i].visible) - { - continue; - } + ToolTipManager.sharedInstance().registerComponent(this); + ToolTipManager.sharedInstance().setInitialDelay(0); + ToolTipManager.sharedInstance().setDismissDelay(10000); + this.ap = ap; + av = ap.av; + this.setLayout(null); + addMouseListener(this); + addMouseMotionListener(this); + ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this); + } - aa[i].height = 0; + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void adjustmentValueChanged(AdjustmentEvent evt) + { + ap.alabels.setScrollOffset(-evt.getValue()); + } - if (aa[i].hasText) + /** + * DOCUMENT ME! + */ + public void adjustPanelHeight() + { + // setHeight of panels + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + int height = 0; + + if (aa != null) { - aa[i].height += av.charHeight; + for (int i = 0; i < aa.length; i++) + { + if (!aa[i].visible) + { + continue; + } + + aa[i].height = 0; + + if (aa[i].hasText) + { + aa[i].height += av.charHeight; + } + + if (aa[i].hasIcons) + { + aa[i].height += 16; + } + + if (aa[i].isGraph) + { + aa[i].height += GRAPH_HEIGHT; + } + + if (aa[i].height == 0) + { + aa[i].height = 20; + } + + height += aa[i].height; + } } - - if (aa[i].hasIcons) + else { - aa[i].height += 16; + height = 20; } - if (aa[i].isGraph) + this.setPreferredSize(new Dimension(1, height)); + } + + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + */ + public void removeEditableColumn(int col) + { + if (activeRow == -1) { - aa[i].height += GRAPH_HEIGHT; + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + + for (int j = 0; j < aa.length; j++) + { + if (aa[j].editable) + { + activeRow = j; + + break; + } + } } - if (aa[i].height == 0) + if ((activeRes != null) && activeRes.contains(String.valueOf(col))) { - aa[i].height = 20; + activeRes.removeElement(String.valueOf(col)); } - height += aa[i].height; - } + repaint(); } - else + + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + */ + public void addEditableColumn(int col) { - height = 20; - } + if (activeRow == -1) + { + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - this.setPreferredSize(new Dimension(1, height)); - } + for (int j = 0; j < aa.length; j++) + { + if (aa[j].editable) + { + activeRow = j; + break; + } + } + } - public void removeEditableColumn(int col) - { - if (activeRow == -1) - { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if (activeRes == null) + { + activeRes = new Vector(); + } - for (int j = 0; j < aa.length; j++) - { - if (aa[j].editable) + if (!activeRes.contains(String.valueOf(col))) { - activeRow = j; - break; + activeRes.addElement(String.valueOf(col)); } - } - } - if (activeRes != null && activeRes.contains(String.valueOf(col))) - { - activeRes.removeElement(String.valueOf(col)); + repaint(); } - repaint(); - } - - public void addEditableColumn(int col) - { - if (activeRow == -1) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void actionPerformed(ActionEvent evt) { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + Annotation[] anot = aa[activeRow].annotations; - for (int j = 0; j < aa.length; j++) - { - if (aa[j].editable) + if (evt.getActionCommand().equals(REMOVE)) { - activeRow = j; - break; + for (int i = 0; i < activeRes.size(); i++) + { + anot[Integer.parseInt(activeRes.get(i).toString())] = null; + anot[Integer.parseInt(activeRes.get(i).toString())] = null; + } } - } - } - - if (activeRes == null) - activeRes = new Vector(); + else if (evt.getActionCommand().equals(LABEL)) + { + String label = JOptionPane.showInputDialog(this, "Enter Label ", + "Enter label", JOptionPane.QUESTION_MESSAGE); - if (!activeRes.contains(String.valueOf(col))) - activeRes.addElement(String.valueOf(col)); + if (label == null) + { + return; + } - repaint(); - } + if ((label.length() > 0) && !aa[activeRow].hasText) + { + aa[activeRow].hasText = true; + } - public void actionPerformed(ActionEvent evt) - { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - Annotation[] anot = aa[activeRow].annotations; + for (int i = 0; i < activeRes.size(); i++) + { + int index = Integer.parseInt(activeRes.get(i).toString()); - if (evt.getActionCommand().equals(REMOVE)) - { - for (int i = 0; i < activeRes.size(); i++) - { - anot[Integer.parseInt(activeRes.get(i).toString())] = null; - anot[Integer.parseInt(activeRes.get(i).toString())] = null; - } - } - else if (evt.getActionCommand().equals(LABEL)) - { - String label = JOptionPane.showInputDialog(this, "Enter Label ", - "Enter label", - JOptionPane.QUESTION_MESSAGE); + if (anot[index] == null) + { + anot[index] = new Annotation(label, "", ' ', 0); + } - if (label == null) - return; + anot[index].displayCharacter = label; + } + } + else if (evt.getActionCommand().equals(COLOUR)) + { + Color col = JColorChooser.showDialog(this, + "Choose foreground colour", Color.black); - if ( (label.length() > 0) && !aa[activeRow].hasText) - { - aa[activeRow].hasText = true; - } + for (int i = 0; i < activeRes.size(); i++) + { + int index = Integer.parseInt(activeRes.get(i).toString()); - for (int i = 0; i < activeRes.size(); i++) - { - int index = Integer.parseInt(activeRes.get(i).toString()); + if (anot[index] == null) + { + anot[index] = new Annotation("", "", ' ', 0); + } - if (anot[index] == null) - { - anot[index] = new Annotation(label, "", ' ', 0); + anot[index].colour = col; + } } - anot[index].displayCharacter = label; - } - } - else if (evt.getActionCommand().equals(COLOUR)) - { - Color col = JColorChooser.showDialog(this, - "Choose foreground colour", - Color.black); - - for (int i = 0; i < activeRes.size(); i++) - { - int index = Integer.parseInt(activeRes.get(i).toString()); - - if (anot[index] == null) + else // HELIX OR SHEET { - anot[index] = new Annotation("", "", ' ', 0); - } + char type = 0; + String symbol = "\u03B1"; - anot[index].colour = col; - } - } - else // HELIX OR SHEET - { - char type = 0; - String symbol = "\u03B1"; - - if (evt.getActionCommand().equals(HELIX)) - { - type = 'H'; - } - else if (evt.getActionCommand().equals(SHEET)) - { - type = 'E'; - symbol = "\u03B2"; - } - - if (!aa[activeRow].hasIcons) - { - aa[activeRow].hasIcons = true; - } - - String label = JOptionPane.showInputDialog( - "Enter a label for the structure?", - symbol); - - if (label == null) - return; - - if ( (label.length() > 0) && !aa[activeRow].hasText) - { - aa[activeRow].hasText = true; - } + if (evt.getActionCommand().equals(HELIX)) + { + type = 'H'; + } + else if (evt.getActionCommand().equals(SHEET)) + { + type = 'E'; + symbol = "\u03B2"; + } - for (int i = 0; i < activeRes.size(); i++) - { - int index = Integer.parseInt(activeRes.get(i).toString()); + if (!aa[activeRow].hasIcons) + { + aa[activeRow].hasIcons = true; + } - if (anot[index] == null) - { - anot[index] = new Annotation(label, "", type, 0); - } + String label = JOptionPane.showInputDialog("Enter a label for the structure?", + symbol); - anot[index].secondaryStructure = type; - anot[index].displayCharacter = label; - } - } + if (label == null) + { + return; + } - adjustPanelHeight(); - activeRes = null; - repaint(); + if ((label.length() > 0) && !aa[activeRow].hasText) + { + aa[activeRow].hasText = true; + } - return; - } + for (int i = 0; i < activeRes.size(); i++) + { + int index = Integer.parseInt(activeRes.get(i).toString()); - public void mousePressed(MouseEvent evt) - { - int height = 0; - activeRow = -1; - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + if (anot[index] == null) + { + anot[index] = new Annotation(label, "", type, 0); + } - for (int i = 0; i < aa.length; i++) - { - height += aa[i].height; + anot[index].secondaryStructure = type; + anot[index].displayCharacter = label; + } + } - if (evt.getY() < height) - { - if (aa[i].editable) - activeRow = i; - else - activeRes = null; + adjustPanelHeight(); + activeRes = null; + repaint(); - break; - } + return; } - - if (SwingUtilities.isRightMouseButton(evt)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mousePressed(MouseEvent evt) { - if (activeRes == null) - { - return; - } - - - JPopupMenu pop = new JPopupMenu("Structure type"); - JMenuItem item = new JMenuItem(HELIX); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(SHEET); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(LABEL); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(COLOUR); - item.addActionListener(this); - pop.add(item); - item = new JMenuItem(REMOVE); - item.addActionListener(this); - pop.add(item); - pop.show(this, evt.getX(), evt.getY()); - - return; - } + int height = 0; + activeRow = -1; + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - if (aa == null) - { - return; - } + for (int i = 0; i < aa.length; i++) + { + height += aa[i].height; + if (evt.getY() < height) + { + if (aa[i].editable) + { + activeRow = i; + } + else + { + activeRes = null; + } - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + break; + } + } - if (evt.isControlDown() || evt.isAltDown()) - { - addEditableColumn(res); - } - else if (evt.isShiftDown()) - { - if (activeRes == null) - { - activeRes = new Vector(); - } - else - { - int start = Integer.parseInt(activeRes.get(activeRes.size() - - 1).toString()); - int end = res; - - if (end < start) + if (SwingUtilities.isRightMouseButton(evt)) { - int temp = end; - end = start; - start = temp; + if (activeRes == null) + { + return; + } + + JPopupMenu pop = new JPopupMenu("Structure type"); + JMenuItem item = new JMenuItem(HELIX); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(SHEET); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(LABEL); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(COLOUR); + item.addActionListener(this); + pop.add(item); + item = new JMenuItem(REMOVE); + item.addActionListener(this); + pop.add(item); + pop.show(this, evt.getX(), evt.getY()); + + return; } - for (int n = start; n <= end; n++) + if (aa == null) { - addEditableColumn(n); + return; } - } - } - else - { - activeRes = new Vector(); - activeRes.addElement(String.valueOf(res)); - } - - repaint(); - } - - public void mouseReleased(MouseEvent evt) - { - } - - public void mouseEntered(MouseEvent evt) - { - } - public void mouseExited(MouseEvent evt) - { - } + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - public void mouseDragged(MouseEvent evt) - { - } + if (evt.isControlDown() || evt.isAltDown()) + { + addEditableColumn(res); + } + else if (evt.isShiftDown()) + { + if (activeRes == null) + { + activeRes = new Vector(); + } + else + { + int start = Integer.parseInt(activeRes.get(activeRes.size() - + 1).toString()); + int end = res; + + if (end < start) + { + int temp = end; + end = start; + start = temp; + } + + for (int n = start; n <= end; n++) + { + addEditableColumn(n); + } + } + } + else + { + activeRes = new Vector(); + activeRes.addElement(String.valueOf(res)); + } - public void mouseMoved(MouseEvent evt) - { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + repaint(); + } - if (aa == null) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseReleased(MouseEvent evt) { - return; } - int row = -1; - int height = 0; - - for (int i = 0; i < aa.length; i++) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseEntered(MouseEvent evt) { - if (aa[i].visible) - { - height += aa[i].height; - } - - if (evt.getY() < height) - { - row = i; - - break; - } } - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - - if ( (row > -1) && (res < aa[row].annotations.length) && - (aa[row].annotations[res] != null)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseExited(MouseEvent evt) { - this.setToolTipText(aa[row].annotations[res].description); - - StringBuffer text = new StringBuffer("Sequence position " + - (res + 1) + " " + - aa[row].annotations[res].description); - ap.alignFrame.statusBar.setText(text.toString()); } - } - public void mouseClicked(MouseEvent evt) - { - } - - public void paintComponent(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - - if (fastPaint) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseDragged(MouseEvent evt) { - g.drawImage(image, 0, 0, this); - fastPaint = false; - - return; } - imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseMoved(MouseEvent evt) + { + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), - BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) image.getGraphics(); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + if (aa == null) + { + return; + } - gg.setFont(av.getFont()); - fm = gg.getFontMetrics(); + int row = -1; + int height = 0; - drawComponent(gg, av.startRes, av.endRes + 1); - g.drawImage(image, 0, 0, this); - } + for (int i = 0; i < aa.length; i++) + { + if (aa[i].visible) + { + height += aa[i].height; + } - public void fastPaint(int horizontal) - { - if ( (horizontal == 0) || - (av.alignment.getAlignmentAnnotation() == null) || - (av.alignment.getAlignmentAnnotation().length < 1)) - { - repaint(); + if (evt.getY() < height) + { + row = i; - return; - } + break; + } + } - gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0); + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - int sr = av.startRes; - int er = av.endRes + 1; - int transX = 0; + if ((row > -1) && (res < aa[row].annotations.length) && + (aa[row].annotations[res] != null)) + { + this.setToolTipText(aa[row].annotations[res].description); - if (horizontal > 0) // scrollbar pulled right, image to the left - { - transX = (er - sr - horizontal) * av.charWidth; - sr = er - horizontal; + StringBuffer text = new StringBuffer("Sequence position " + + (res + 1) + " " + aa[row].annotations[res].description); + ap.alignFrame.statusBar.setText(text.toString()); + } } - else if (horizontal < 0) + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseClicked(MouseEvent evt) { - er = sr - horizontal; } - gg.translate(transX, 0); + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) + { + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); - drawComponent(gg, sr, er); + if (fastPaint) + { + g.drawImage(image, 0, 0, this); + fastPaint = false; - gg.translate( -transX, 0); + return; + } - fastPaint = true; - repaint(); - } + imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; - public void drawComponent(Graphics2D g, int startRes, int endRes) - { - g.setColor(Color.white); - g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); + image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), + BufferedImage.TYPE_INT_RGB); + gg = (Graphics2D) image.getGraphics(); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - if ( (av.alignment.getAlignmentAnnotation() == null) || - (av.alignment.getAlignmentAnnotation().length < 1)) - { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - g.setColor(Color.black); - g.drawString("Alignment has no annotations", 20, 15); + gg.setFont(av.getFont()); - return; + drawComponent(gg, av.startRes, av.endRes + 1); + g.drawImage(image, 0, 0, this); } - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - - int j; - int x = 0; - int y = 0; - char[] lastSS = new char[aa.length]; - int[] lastSSX = new int[aa.length]; - int iconOffset = av.charHeight / 2; - boolean validRes = false; - - //\u03B2 \u03B1 - for (int i = 0; i < aa.length; i++) + /** + * DOCUMENT ME! + * + * @param horizontal DOCUMENT ME! + */ + public void fastPaint(int horizontal) { - AlignmentAnnotation row = aa[i]; + if ((horizontal == 0) || + (av.alignment.getAlignmentAnnotation() == null) || + (av.alignment.getAlignmentAnnotation().length < 1)) + { + repaint(); - if (!row.visible) - { - continue; - } + return; + } - if (row.isGraph) - { - // this is so that we draw the characters below the graph - y += row.height; + gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0); - if (row.hasText) - { - y -= av.charHeight; - } - } - - if (row.hasText) - { - iconOffset = av.charHeight / 2; - } - else - { - iconOffset = 0; - } - - for (j = startRes; j < endRes; j++) - { - if ( (row.annotations.length <= j) || - (row.annotations[j] == null)) + int sr = av.startRes; + int er = av.endRes + 1; + int transX = 0; + + if (horizontal > 0) // scrollbar pulled right, image to the left { - validRes = false; + transX = (er - sr - horizontal) * av.charWidth; + sr = er - horizontal; } - else + else if (horizontal < 0) { - validRes = true; + er = sr - horizontal; } - x = (j - startRes) * av.charWidth; + gg.translate(transX, 0); - if (activeRow == i) - { - g.setColor(Color.red); + drawComponent(gg, sr, er); - if (activeRes != null) - { - for (int n = 0; n < activeRes.size(); n++) - { - int v = Integer.parseInt(activeRes.get(n).toString()); + gg.translate(-transX, 0); - if (v == j) - { - g.fillRect( (j - startRes) * av.charWidth, y, - av.charWidth, row.height); - } - } - } - } + fastPaint = true; + repaint(); + } - if (validRes && - (row.annotations[j].displayCharacter.length() > 0)) - { - int charOffset = (av.charWidth - - fm.charWidth(row.annotations[j].displayCharacter. - charAt( - 0))) / 2; - g.setColor(row.annotations[j].colour); - - if (j == 0) - { - g.drawString(row.annotations[j].displayCharacter, - x, y + iconOffset + 2); - } - else if ( - ( (row.annotations[j - 1] == null) || - (row.annotations[j].displayCharacter != row.annotations[j - - 1].displayCharacter))) - { - g.drawString(row.annotations[j].displayCharacter, x, - y + iconOffset + 2); - } + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param startRes DOCUMENT ME! + * @param endRes DOCUMENT ME! + */ + public void drawComponent(Graphics2D g, int startRes, int endRes) + { + if(fm==null) + fm = g.getFontMetrics(); - } + g.setColor(Color.white); + g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); - if (row.hasIcons) + if ((av.alignment.getAlignmentAnnotation() == null) || + (av.alignment.getAlignmentAnnotation().length < 1)) { - if (!validRes || - (row.annotations[j].secondaryStructure != lastSS[i])) - { - switch (lastSS[i]) - { - case 'H': - g.setColor(HELIX_COLOUR); - g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i], 7, 8, 8); + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.black); + g.drawString("Alignment has no annotations", 20, 15); - break; + return; + } - case 'E': - g.setColor(SHEET_COLOUR); - g.fillRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i] - 4, 7); - g.fillPolygon(new int[] - {x - 4, x - 4, x}, - new int[] - { - y + iconOffset, y + 14 + iconOffset, - y + 8 + iconOffset - }, 3); + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - break; + int j; + int x = 0; + int y = 0; + char[] lastSS = new char[aa.length]; + int[] lastSSX = new int[aa.length]; + int iconOffset = av.charHeight / 2; + boolean validRes = false; - case 'C': - break; + //\u03B2 \u03B1 + for (int i = 0; i < aa.length; i++) + { + AlignmentAnnotation row = aa[i]; - default: - g.setColor(Color.gray); - g.fillRect(lastSSX[i], y + 6 + iconOffset, - x - lastSSX[i], 2); + if (!row.visible) + { + continue; + } - break; + if (row.isGraph) + { + // this is so that we draw the characters below the graph + y += row.height; + + if (row.hasText) + { + y -= av.charHeight; + } } - if (validRes) + if (row.hasText) { - lastSS[i] = row.annotations[j].secondaryStructure; + iconOffset = av.charHeight / 2; } else { - lastSS[i] = ' '; + iconOffset = 0; } - lastSSX[i] = x; - } - } - - if (validRes && row.isGraph) - { - g.setColor(new Color(0, 0, 180)); - - int height = (int) ( (row.annotations[j].value / row.graphMax) * - GRAPH_HEIGHT); - - if (row.windowLength > 1) - { - int total = 0; - - for (int i2 = j - (row.windowLength / 2); - i2 < (j + (row.windowLength / 2)); i2++) + for (j = startRes; j < endRes; j++) { - if ( (i2 < 0) || (i2 >= av.alignment.getWidth())) - { - continue; - } + if ((row.annotations.length <= j) || + (row.annotations[j] == null)) + { + validRes = false; + } + else + { + validRes = true; + } + + x = (j - startRes) * av.charWidth; + + if (activeRow == i) + { + g.setColor(Color.red); + + if (activeRes != null) + { + for (int n = 0; n < activeRes.size(); n++) + { + int v = Integer.parseInt(activeRes.get(n).toString()); + + if (v == j) + { + g.fillRect((j - startRes) * av.charWidth, y, + av.charWidth, row.height); + } + } + } + } + + if (validRes && + (row.annotations[j].displayCharacter.length() > 0)) + { + int charOffset = (av.charWidth - + fm.charWidth(row.annotations[j].displayCharacter.charAt( + 0))) / 2; + g.setColor(row.annotations[j].colour); + + if (j == 0) + { + g.drawString(row.annotations[j].displayCharacter, x+charOffset, + y + iconOffset + 2); + } + else if (((row.annotations[j - 1] == null) || + (row.annotations[j].displayCharacter != row.annotations[j - + 1].displayCharacter))) + { + g.drawString(row.annotations[j].displayCharacter, x+charOffset, + y + iconOffset + 2); + } + } + + if (row.hasIcons) + { + if (!validRes || + (row.annotations[j].secondaryStructure != lastSS[i])) + { + switch (lastSS[i]) + { + case 'H': + g.setColor(HELIX_COLOUR); + g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, + x - lastSSX[i], 7, 8, 8); - total += row.annotations[i2].value; + break; + + case 'E': + g.setColor(SHEET_COLOUR); + g.fillRect(lastSSX[i], y + 4 + iconOffset, + x - lastSSX[i] - 4, 7); + g.fillPolygon(new int[] { x - 4, x - 4, x }, + new int[] + { + y + iconOffset, y + 14 + iconOffset, + y + 8 + iconOffset + }, 3); + + break; + + case 'C': + break; + + default: + g.setColor(Color.gray); + g.fillRect(lastSSX[i], y + 6 + iconOffset, + x - lastSSX[i], 2); + + break; + } + + if (validRes) + { + lastSS[i] = row.annotations[j].secondaryStructure; + } + else + { + lastSS[i] = ' '; + } + + lastSSX[i] = x; + } + } + + if (validRes && row.isGraph) + { + g.setColor(new Color(0, 0, 180)); + + int height = (int) ((row.annotations[j].value / row.graphMax) * GRAPH_HEIGHT); + + if (row.windowLength > 1) + { + int total = 0; + + for (int i2 = j - (row.windowLength / 2); + i2 < (j + (row.windowLength / 2)); i2++) + { + if ((i2 < 0) || (i2 >= av.alignment.getWidth())) + { + continue; + } + + total += row.annotations[i2].value; + } + + total /= row.windowLength; + height = (int) ((total / row.graphMax) * GRAPH_HEIGHT); + } + + g.setColor(row.annotations[j].colour); + g.fillRect(x, y - height, av.charWidth, height); + } } - total /= row.windowLength; - height = (int) ( (total / row.graphMax) * GRAPH_HEIGHT); - } + x += av.charWidth; - g.setColor(row.annotations[j].colour); - g.fillRect(x, y - height, av.charWidth, height); - } - } + if (row.hasIcons) + { + switch (lastSS[i]) + { + case 'H': + g.setColor(HELIX_COLOUR); + g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, + x - lastSSX[i], 7, 8, 8); + + break; + + case 'E': + g.setColor(SHEET_COLOUR); + g.fillRect(lastSSX[i], y + 4 + iconOffset, + x - lastSSX[i] - 4, 7); + g.fillPolygon(new int[] { x - 4, x - 4, x }, + new int[] + { + y + iconOffset, y + 14 + iconOffset, + y + 7 + iconOffset + }, 3); + + break; + + case 'C': + break; + + default: + g.setColor(Color.gray); + g.fillRect(lastSSX[i], y + 6 + iconOffset, x - lastSSX[i], 2); + + break; + } + } - x += av.charWidth; + if (row.isGraph && row.hasText) + { + y += av.charHeight; + } - if (row.hasIcons) - { - switch (lastSS[i]) - { - case 'H': - g.setColor(HELIX_COLOUR); - g.fillRoundRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i], 7, 8, 8); - - break; - - case 'E': - g.setColor(SHEET_COLOUR); - g.fillRect(lastSSX[i], y + 4 + iconOffset, - x - lastSSX[i] - 4, 7); - g.fillPolygon(new int[] - {x - 4, x - 4, x}, - new int[] - { - y + iconOffset, y + 14 + iconOffset, - y + 7 + iconOffset - }, 3); - - break; - - case 'C': - break; - - default: - g.setColor(Color.gray); - g.fillRect(lastSSX[i], y + 6 + iconOffset, x - lastSSX[i], 2); - - break; + if (!row.isGraph) + { + y += aa[i].height; + } } - } - - if (row.isGraph && row.hasText) - { - y += av.charHeight; - } - - if (!row.isGraph) - { - y += aa[i].height; - } } - } - // used by overview window - public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y) - { - g.setColor(Color.white); - g.fillRect(0, 0, width, y); - g.setColor(new Color(0, 0, 180)); + // used by overview window + public void drawGraph(Graphics g, AlignmentAnnotation aa, int width, int y) + { + g.setColor(Color.white); + g.fillRect(0, 0, width, y); + g.setColor(new Color(0, 0, 180)); - int x = 0; + int x = 0; - for (int j = 0; j < aa.annotations.length; j++) - { - g.setColor(new Color(0, 0, 180)); + for (int j = 0; j < aa.annotations.length; j++) + { + g.setColor(new Color(0, 0, 180)); - int height = (int) ( (aa.annotations[j].value / aa.graphMax) * - GRAPH_HEIGHT); - g.fillRect(x, y - height, av.charWidth, height); - x += av.charWidth; + int height = (int) ((aa.annotations[j].value / aa.graphMax) * GRAPH_HEIGHT); + g.fillRect(x, y - height, av.charWidth, height); + x += av.charWidth; + } } - } } diff --git a/src/jalview/gui/ColumnSelection.java b/src/jalview/gui/ColumnSelection.java index 2116d50..356dd1c 100755 --- a/src/jalview/gui/ColumnSelection.java +++ b/src/jalview/gui/ColumnSelection.java @@ -20,93 +20,150 @@ package jalview.gui; import java.util.*; + /** * NOTE: Columns are zero based. */ public class ColumnSelection { - Vector selected = new Vector(); - - public void addElement(int col) - { - if(!selected.contains(new Integer(col))) - selected.addElement(new Integer(col)); - } - - public void clear() - { - selected.removeAllElements(); - } - - public void removeElement(int col) - { - Integer colInt = new Integer(col); - if (selected.contains(colInt)) + Vector selected = new Vector(); + + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + */ + public void addElement(int col) { - selected.removeElement(colInt); + if (!selected.contains(new Integer(col))) + { + selected.addElement(new Integer(col)); + } } - } - - public boolean contains(int col) - { - return selected.contains(new Integer(col)); - } - public int columnAt(int i) - { - return ( (Integer) selected.elementAt(i)).intValue(); - } + /** + * DOCUMENT ME! + */ + public void clear() + { + selected.removeAllElements(); + } - public int size() - { - return selected.size(); - } + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + */ + public void removeElement(int col) + { + Integer colInt = new Integer(col); - public int getMax() - { - int max = -1; + if (selected.contains(colInt)) + { + selected.removeElement(colInt); + } + } - for (int i = 0; i < selected.size(); i++) + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean contains(int col) { - if (columnAt(i) > max) - { - max = columnAt(i); - } + return selected.contains(new Integer(col)); } - return max; - } + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int columnAt(int i) + { + return ((Integer) selected.elementAt(i)).intValue(); + } - public int getMin() - { - int min = 1000000000; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int size() + { + return selected.size(); + } - for (int i = 0; i < selected.size(); i++) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getMax() { - if (columnAt(i) < min) - { - min = columnAt(i); - } + int max = -1; + + for (int i = 0; i < selected.size(); i++) + { + if (columnAt(i) > max) + { + max = columnAt(i); + } + } + + return max; } - return min; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getMin() + { + int min = 1000000000; + + for (int i = 0; i < selected.size(); i++) + { + if (columnAt(i) < min) + { + min = columnAt(i); + } + } - public Vector asVector() - { - return selected; - } + return min; + } - public void compensateForEdit(int start, int change) - { - for (int i = 0; i < size(); i++) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector asVector() { - int temp = columnAt(i); + return selected; + } - if (temp >= start) - { - selected.setElementAt(new Integer(temp - change), i); - } + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + * @param change DOCUMENT ME! + */ + public void compensateForEdit(int start, int change) + { + for (int i = 0; i < size(); i++) + { + int temp = columnAt(i); + + if (temp >= start) + { + selected.setElementAt(new Integer(temp - change), i); + } + } } - } } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 175a609..9e0dca4 100755 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -18,113 +18,153 @@ */ package jalview.gui; +import jalview.datamodel.*; + +import jalview.io.*; + +import jalview.jbgui.*; + import java.awt.*; import java.awt.datatransfer.*; import java.awt.event.*; + import javax.swing.*; -import jalview.datamodel.*; -import jalview.io.*; -import jalview.jbgui.*; -public class CutAndPasteTransfer - extends GCutAndPasteTransfer +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class CutAndPasteTransfer extends GCutAndPasteTransfer { - public void setForInput() - { - getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH); - } - - public String getText() - { - return textarea.getText(); - } - - public void setText(String text) - { - textarea.setText(text); - } - - public void copyItem_actionPerformed(ActionEvent e) - { - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - c.setContents(new StringSelection(textarea.getText()), null); - } - - public void pasteMenu_actionPerformed(ActionEvent e) - { - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - Transferable contents = c.getContents(this); - - if (contents == null) + /** + * DOCUMENT ME! + */ + public void setForInput() { - return; + getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH); } - try + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getText() { - textarea.setText( (String) contents.getTransferData( - DataFlavor.stringFlavor)); + return textarea.getText(); } - catch (Exception ex) - { - } - } - - public void ok_actionPerformed(ActionEvent e) - { - String format = IdentifyFile.Identify(getText(), "Paste"); - SequenceI[] sequences = null; - if (FormatAdapter.formats.contains(format)) + /** + * DOCUMENT ME! + * + * @param text DOCUMENT ME! + */ + public void setText(String text) { - sequences = FormatAdapter.readFile(getText(), "Paste", format); + textarea.setText(text); } - if (sequences != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void copyItem_actionPerformed(ActionEvent e) { - AlignFrame af = new AlignFrame(new Alignment(sequences)); - af.currentFileFormat = format; - Desktop.addInternalFrame(af, "Cut & Paste input - " + format, - AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - af.statusBar.setText("Successfully pasted alignment file"); - - try - { - af.setMaximum(Preferences.showFullscreen); - } - catch (Exception ex) - { - } - - try - { - this.setClosed(true); - } - catch (Exception ex) - { - } + Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); + c.setContents(new StringSelection(textarea.getText()), null); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void pasteMenu_actionPerformed(ActionEvent e) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Couldn't read the pasted text.\n" + - "Formats currently supported are\n" + - "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM", - "Error parsing text", - JOptionPane.WARNING_MESSAGE); + Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable contents = c.getContents(this); + + if (contents == null) + { + return; + } + + try + { + textarea.setText((String) contents.getTransferData( + DataFlavor.stringFlavor)); + } + catch (Exception ex) + { + } } - } - public void cancel_actionPerformed(ActionEvent e) - { - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void ok_actionPerformed(ActionEvent e) { - this.setClosed(true); + String format = IdentifyFile.Identify(getText(), "Paste"); + SequenceI[] sequences = null; + + if (FormatAdapter.formats.contains(format)) + { + sequences = FormatAdapter.readFile(getText(), "Paste", format); + } + + if (sequences != null) + { + AlignFrame af = new AlignFrame(new Alignment(sequences)); + af.currentFileFormat = format; + Desktop.addInternalFrame(af, "Cut & Paste input - " + format, + AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); + af.statusBar.setText("Successfully pasted alignment file"); + + try + { + af.setMaximum(Preferences.showFullscreen); + } + catch (Exception ex) + { + } + + try + { + this.setClosed(true); + } + catch (Exception ex) + { + } + } + else + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Couldn't read the pasted text.\n" + + "Formats currently supported are\n" + + "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM", + "Error parsing text", JOptionPane.WARNING_MESSAGE); + } } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void cancel_actionPerformed(ActionEvent e) { + try + { + this.setClosed(true); + } + catch (Exception ex) + { + } } - } } diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 2a1979e..6a6ba2f 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -18,453 +18,573 @@ */ package jalview.gui; +import jalview.datamodel.*; + +import jalview.io.*; + import java.awt.*; import java.awt.datatransfer.*; import java.awt.dnd.*; import java.awt.event.*; + import javax.swing.*; -import jalview.datamodel.*; -import jalview.io.*; -public class Desktop - extends jalview.jbgui.GDesktop implements DropTargetListener +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Desktop extends jalview.jbgui.GDesktop + implements DropTargetListener { - public static JDesktopPane desktop; - static int openFrameCount = 0; - static final int xOffset = 30; - static final int yOffset = 30; - - public Desktop() - { - Image image = null; - - try + /** DOCUMENT ME!! */ + public static JDesktopPane desktop; + static int openFrameCount = 0; + static final int xOffset = 30; + static final int yOffset = 30; + + /** + * Creates a new Desktop object. + */ + public Desktop() { - java.net.URL url = getClass().getResource("/images/logo.gif"); + Image image = null; + + try + { + java.net.URL url = getClass().getResource("/images/logo.gif"); - if (url != null) - { - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - MediaTracker mt = new MediaTracker(this); - mt.addImage(image, 0); - mt.waitForID(0); - setIconImage(image); - } - } - catch (Exception ex) - { - } + MediaTracker mt = new MediaTracker(this); + mt.addImage(image, 0); + mt.waitForID(0); + // setIconImage(image); + } + } + catch (Exception ex) + { + } - setTitle("Jalview 2005"); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - desktop = new JDesktopPane(); - desktop.setBackground(Color.white); - setContentPane(desktop); - desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); + setTitle("Jalview 2005"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + desktop = new JDesktopPane(); + desktop.setBackground(Color.white); + setContentPane(desktop); + desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); - // This line prevents Windows Look&Feel resizing all new windows to maximum - // if previous window was maximised - desktop.setDesktopManager(new DefaultDesktopManager()); + // This line prevents Windows Look&Feel resizing all new windows to maximum + // if previous window was maximised + desktop.setDesktopManager(new DefaultDesktopManager()); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - String x = jalview.bin.Cache.getProperty("SCREEN_X"); - String y = jalview.bin.Cache.getProperty("SCREEN_Y"); - String width = jalview.bin.Cache.getProperty("SCREEN_WIDTH"); - String height = jalview.bin.Cache.getProperty("SCREEN_HEIGHT"); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + String x = jalview.bin.Cache.getProperty("SCREEN_X"); + String y = jalview.bin.Cache.getProperty("SCREEN_Y"); + String width = jalview.bin.Cache.getProperty("SCREEN_WIDTH"); + String height = jalview.bin.Cache.getProperty("SCREEN_HEIGHT"); - if ( (x != null) && (y != null) && (width != null) && (height != null)) - { - setBounds(Integer.parseInt(x), Integer.parseInt(y), + if ((x != null) && (y != null) && (width != null) && (height != null)) + { + setBounds(Integer.parseInt(x), Integer.parseInt(y), Integer.parseInt(width), Integer.parseInt(height)); - } - else - { - setBounds( (int) (screenSize.width - 900) / 2, + } + else + { + setBounds((int) (screenSize.width - 900) / 2, (int) (screenSize.height - 650) / 2, 900, 650); - } + } - this.addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent evt) - { - quit(); - } - }); - setVisible(true); - - this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); - - /////////Add a splashscreen on startup - /////////Add a splashscreen on startup - JInternalFrame frame = new JInternalFrame(); - - SplashScreen splash = new SplashScreen(frame, image); - frame.setContentPane(splash); - frame.setLayer(JLayeredPane.PALETTE_LAYER); - addInternalFrame(frame, "", 750, 160, false); - frame.setLocation( (int) ( (getWidth() - 750) / 2), - (int) ( (getHeight() - 160) / 2)); - } - - public static void addInternalFrame(final JInternalFrame frame, - String title, int w, int h) - { - addInternalFrame(frame, title, w, h, true); - } - - public static void addInternalFrame(final JInternalFrame frame, - String title, int w, int h, - boolean resizable) - { - desktop.add(frame); - openFrameCount++; - - try - { - frame.setSelected(true); + this.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent evt) + { + quit(); + } + }); + + this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); + + /////////Add a splashscreen on startup + /////////Add a splashscreen on startup + JInternalFrame frame = new JInternalFrame(); + + SplashScreen splash = new SplashScreen(frame, image); + frame.setContentPane(splash); + frame.setLayer(JLayeredPane.PALETTE_LAYER); + addInternalFrame(frame, "", 750, 160, false); + frame.setLocation((int) ((getWidth() - 750) / 2), + (int) ((getHeight() - 160) / 2)); } - catch (java.beans.PropertyVetoException e) + + /** + * DOCUMENT ME! + * + * @param frame DOCUMENT ME! + * @param title DOCUMENT ME! + * @param w DOCUMENT ME! + * @param h DOCUMENT ME! + */ + public static void addInternalFrame(final JInternalFrame frame, + String title, int w, int h) { + addInternalFrame(frame, title, w, h, true); } - frame.setTitle(title); - frame.setSize(w, h); - frame.setClosable(true); - frame.setResizable(resizable); - frame.setMaximizable(resizable); - frame.setIconifiable(resizable); - frame.setFrameIcon(null); - frame.setLocation(xOffset * openFrameCount, yOffset * openFrameCount); - frame.toFront(); - - final JMenuItem menuItem = new JMenuItem(title); - frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + /** + * DOCUMENT ME! + * + * @param frame DOCUMENT ME! + * @param title DOCUMENT ME! + * @param w DOCUMENT ME! + * @param h DOCUMENT ME! + * @param resizable DOCUMENT ME! + */ + public static void addInternalFrame(final JInternalFrame frame, + String title, int w, int h, boolean resizable) { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent evt) - { - openFrameCount--; - windowMenu.remove(menuItem); - } - ; - }); - - menuItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { + desktop.add(frame); + openFrameCount++; + try { - frame.setSelected(true); - frame.setIcon(false); + frame.setSelected(true); } - catch (java.beans.PropertyVetoException ex) + catch (java.beans.PropertyVetoException e) { } - ; - } - }); - - frame.setVisible(true); - windowMenu.add(menuItem); - } - - public void dragEnter(DropTargetDragEvent evt) - { - } - - public void dragExit(DropTargetEvent evt) - { - } - - public void dragOver(DropTargetDragEvent evt) - { - } + frame.setTitle(title); + frame.setSize(w, h); + frame.setClosable(true); + frame.setResizable(resizable); + frame.setMaximizable(resizable); + frame.setIconifiable(resizable); + frame.setFrameIcon(null); + frame.setLocation(xOffset * openFrameCount, yOffset * openFrameCount); + frame.toFront(); + + final JMenuItem menuItem = new JMenuItem(title); + frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent evt) + { + openFrameCount--; + windowMenu.remove(menuItem); + } + ; + }); + + menuItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + try + { + frame.setSelected(true); + frame.setIcon(false); + } + catch (java.beans.PropertyVetoException ex) + { + } + + ; + } + }); + + frame.setVisible(true); + windowMenu.add(menuItem); + } - public void dropActionChanged(DropTargetDragEvent evt) - { - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void dragEnter(DropTargetDragEvent evt) + { + } - public void drop(DropTargetDropEvent evt) - { - Transferable t = evt.getTransferable(); + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void dragExit(DropTargetEvent evt) + { + } - if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void dragOver(DropTargetDragEvent evt) { - return; } - evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void dropActionChanged(DropTargetDragEvent evt) + { + } - try + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void drop(DropTargetDropEvent evt) { - java.util.List files = (java.util.List) t.getTransferData(DataFlavor. - javaFileListFlavor); + Transferable t = evt.getTransferable(); - for (int i = 0; i < files.size(); i++) - { - String file = files.get(i).toString(); - String protocol = "File"; + if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) + { + return; + } + + evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); - if (file.endsWith(".jar")) + try { - Jalview2XML.LoadJalviewAlign(file); + java.util.List files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor); + + for (int i = 0; i < files.size(); i++) + { + String file = files.get(i).toString(); + String protocol = "File"; + String format = null; + + if (file.endsWith(".jar")) + { + format = "Jalview"; + + } + else + { + format = jalview.io.IdentifyFile.Identify(file, + protocol); + } + LoadFile(file, protocol, format); + } } - else + catch (Exception ex) { - String format = jalview.io.IdentifyFile.Identify(file, - protocol); - LoadFile(file, protocol, format); + ex.printStackTrace(); } - } } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void inputLocalFileMenuItem_actionPerformed(ActionEvent e) { - ex.printStackTrace(); - } - } - - public void inputLocalFileMenuItem_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), - new String[] + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), + new String[] + { + "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", + "jar" + }, + new String[] + { + "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" + }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Open local file"); + chooser.setToolTipText("Open"); + + int value = chooser.showOpenDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" - }, - new String[] - { - "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" - }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); - - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Open local file"); - chooser.setToolTipText("Open"); - - int value = chooser.showOpenDialog(this); + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + + String format = null; + if (chooser.getSelectedFormat().equals("Jalview")) + { + format = "Jalview"; + } + else + { + format = IdentifyFile.Identify(choice, "File"); + } + + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", format); + LoadFile(choice, "File", format); + } + } - if (value == JalviewFileChooser.APPROVE_OPTION) + /** + * DOCUMENT ME! + * + * @param file DOCUMENT ME! + * @param protocol DOCUMENT ME! + * @param format DOCUMENT ME! + */ + public void LoadFile(String file, String protocol, String format) { - String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); - - if (chooser.getSelectedFormat().equals("Jalview")) - { - jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", "Jalivew"); - Jalview2XML.LoadJalviewAlign(choice); - } - else - { - String format = IdentifyFile.Identify(choice, "File"); - jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", format); - LoadFile(choice, "File", format); - } + LoadingThread loader = new LoadingThread(file, protocol, format); + loader.start(); } - } - - public void LoadFile(String file, String protocol, String format) - { - LoadingThread loader = new LoadingThread(file, protocol, format); - loader.start(); - } - - public void inputURLMenuItem_actionPerformed(ActionEvent e) - { - String url = JOptionPane.showInternalInputDialog(Desktop.desktop, - "Enter url of input file", "Input alignment from URL", - JOptionPane.QUESTION_MESSAGE, null, null, "http://www.") - .toString(); - - if (url == null) + /** + * DOCUMENT ME! + * + * @param file DOCUMENT ME! + * @param protocol DOCUMENT ME! + * @param format DOCUMENT ME! + */ + public AlignFrame LoadFileWaitTillLoaded(String file, String protocol, String format) { - return; - } + LoadingThread loader = new LoadingThread(file, protocol, format); + loader.start(); + + while (loader.isAlive()) + { + try + { + Thread.sleep(50); + } + catch (Exception ex) + {} + } - String format = IdentifyFile.Identify(url, "URL"); + return loader.af; + } - if (format.equals("URL NOT FOUND")) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void inputURLMenuItem_actionPerformed(ActionEvent e) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Couldn't locate " + url, - "URL not found", - JOptionPane.WARNING_MESSAGE); + String url = JOptionPane.showInternalInputDialog(Desktop.desktop, + "Enter url of input file", "Input alignment from URL", + JOptionPane.QUESTION_MESSAGE, null, null, "http://www.") + .toString(); + + if (url == null) + { + return; + } + + if (url.trim().toLowerCase().endsWith(".jar")) + { + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", "Jalview"); + Jalview2XML.LoadJalviewAlign(url); + } + else + { - return; + String format = IdentifyFile.Identify(url, "URL"); + + if (format.equals("URL NOT FOUND")) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Couldn't locate " + url, + "URL not found", + JOptionPane.WARNING_MESSAGE); + + return; + } + + LoadFile(url, "URL", format); + } } - LoadFile(url, "URL", format); - } - - public void inputTextboxMenuItem_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - cap.setForInput(); - Desktop.addInternalFrame(cap, "Cut & Paste Alignment File", 600, 500); - } - - /* - * Exit the program - */ - public void quit() - { - if (jalview.bin.Jalview.applet != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void inputTextboxMenuItem_actionPerformed(ActionEvent e) { - jalview.bin.Jalview.applet.destroy(); + CutAndPasteTransfer cap = new CutAndPasteTransfer(); + cap.setForInput(); + Desktop.addInternalFrame(cap, "Cut & Paste Alignment File", 600, 500); } - else + + /* + * Exit the program + */ + public void quit() { - jalview.bin.Cache.setProperty("SCREEN_X", getBounds().x + - ""); - jalview.bin.Cache.setProperty("SCREEN_Y", getBounds().y + - ""); - jalview.bin.Cache.setProperty("SCREEN_WIDTH", - getWidth() + ""); - jalview.bin.Cache.setProperty("SCREEN_HEIGHT", - getHeight() + ""); - System.exit(0); + jalview.bin.Cache.setProperty("SCREEN_X", getBounds().x + ""); + jalview.bin.Cache.setProperty("SCREEN_Y", getBounds().y + ""); + jalview.bin.Cache.setProperty("SCREEN_WIDTH", getWidth() + ""); + jalview.bin.Cache.setProperty("SCREEN_HEIGHT", getHeight() + ""); + System.exit(0); } - } - - public void aboutMenuItem_actionPerformed(ActionEvent e) - { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "JalView 2005 version " + - jalview.bin.Cache.VERSION + - "; last updated: " + - jalview.bin.Cache.BUILD_DATE + - "\nAuthors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton." + - "\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee." + - "\nFor all issues relating to Jalview, email help@jalview.org" + - "\n\nIf you use JalView, please cite:" + - "\n\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"" + - "\nBioinformatics, 2004 12;426-7.", - "About Jalview", - JOptionPane.INFORMATION_MESSAGE); - } - - public void documentationMenuItem_actionPerformed(ActionEvent e) - { - try + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void aboutMenuItem_actionPerformed(ActionEvent e) { - ClassLoader cl = jalview.gui.Desktop.class.getClassLoader(); - java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help"); - javax.help.HelpSet hs = new javax.help.HelpSet(cl, url); - - javax.help.HelpBroker hb = hs.createHelpBroker(); - hb.setLocation(new Point(200, 50)); - hb.setSize(new Dimension(800, 700)); - hb.setCurrentID("home"); - hb.setDisplayed(true); + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "JalView 2005 version " + jalview.bin.Cache.VERSION + + "; last updated: " + jalview.bin.Cache.BUILD_DATE + + "\nAuthors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton." + + "\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee." + + "\nFor all issues relating to Jalview, email help@jalview.org" + + "\n\nIf you use JalView, please cite:" + + "\n\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"" + + "\nBioinformatics, 2004 12;426-7.", "About Jalview", + JOptionPane.INFORMATION_MESSAGE); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void documentationMenuItem_actionPerformed(ActionEvent e) { - ex.printStackTrace(); + try + { + ClassLoader cl = jalview.gui.Desktop.class.getClassLoader(); + java.net.URL url = javax.help.HelpSet.findHelpSet(cl, "help/help"); + javax.help.HelpSet hs = new javax.help.HelpSet(cl, url); + + javax.help.HelpBroker hb = hs.createHelpBroker(); + hb.setLocation(new Point(200, 50)); + hb.setSize(new Dimension(800, 700)); + hb.setCurrentID("home"); + hb.setDisplayed(true); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - } - protected void preferences_actionPerformed(ActionEvent e) - { - Preferences pref = new Preferences(); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void preferences_actionPerformed(ActionEvent e) + { + new Preferences(); + } - public void saveState_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), new String[] - {"jar"}, - new String[] - {"Jalview Project"}, "Jalview Project"); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void saveState_actionPerformed(ActionEvent e) + { + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "jar" }, + new String[] { "Jalview Project" }, "Jalview Project"); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Save State"); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save State"); - int value = chooser.showSaveDialog(this); + int value = chooser.showSaveDialog(this); - if (value == JalviewFileChooser.APPROVE_OPTION) - { - java.io.File choice = chooser.getSelectedFile(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); - Jalview2XML.SaveState(choice); + if (value == JalviewFileChooser.APPROVE_OPTION) + { + java.io.File choice = chooser.getSelectedFile(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); + Jalview2XML.SaveState(choice); + } } - } - - public void loadState_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), new String[] - {"jar"}, - new String[] - {"Jalview Project"}, "Jalview Project"); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Restore state"); - - int value = chooser.showOpenDialog(this); - - if (value == JalviewFileChooser.APPROVE_OPTION) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void loadState_actionPerformed(ActionEvent e) { - String choice = chooser.getSelectedFile().getAbsolutePath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); - Jalview2XML.LoadJalviewAlign(choice); - } - } + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "jar" }, + new String[] { "Jalview Project" }, "Jalview Project"); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Restore state"); - class LoadingThread - extends Thread - { - String file; - String protocol; - String format; + int value = chooser.showOpenDialog(this); - public LoadingThread(String file, String protocol, String format) - { - this.file = file; - this.protocol = protocol; - this.format = format; + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String choice = chooser.getSelectedFile().getAbsolutePath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + Jalview2XML.LoadJalviewAlign(choice); + } } - public void run() + class LoadingThread extends Thread { - SequenceI[] sequences = null; + String file; + String protocol; + String format; + AlignFrame af; - if (FormatAdapter.formats.contains(format)) - { - sequences = FormatAdapter.readFile(file, protocol, format); - } - - if ( (sequences != null) && (sequences.length > 0)) - { - AlignFrame af = new AlignFrame(new Alignment(sequences)); - addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - af.currentFileFormat = format; - af.statusBar.setText("Successfully loaded file " + file); - - try + public LoadingThread(String file, String protocol, String format) { - af.setMaximum(Preferences.showFullscreen); + this.file = file; + this.protocol = protocol; + this.format = format; } - catch (Exception ex) + + public void run() { + SequenceI[] sequences = null; + + if(format.equalsIgnoreCase("Jalview")) + { + Jalview2XML.LoadJalviewAlign(file); + } + else + { + if (FormatAdapter.formats.contains(format)) + { + sequences = FormatAdapter.readFile(file, protocol, format); + } + + if ( (sequences != null) && (sequences.length > 0)) + { + af = new AlignFrame(new Alignment(sequences)); + addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, + AlignFrame.NEW_WINDOW_HEIGHT); + af.currentFileFormat = format; + af.statusBar.setText("Successfully loaded file " + file); + + try + { + af.setMaximum(Preferences.showFullscreen); + } + catch (Exception ex) + { + } + } + else + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "Couldn't open file.\n" + + "Formats currently supported are\n" + + "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter! + , "Error loading file", JOptionPane.WARNING_MESSAGE); + } + } } - } - else - { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "Couldn't open file.\n" + - "Formats currently supported are\n" + - "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM" // JBPNote - message should be generated through FormatAdapter! - , "Error loading file", - JOptionPane.WARNING_MESSAGE); - } } - } } diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 1de32a5..8a94a89 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -18,93 +18,120 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; import java.awt.*; -import jalview.datamodel.*; +import java.util.*; + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class FeatureRenderer { - AlignViewport av; - SequenceGroup currentSequenceGroup = null; - SequenceGroup[] allGroups = null; - Color resBoxColour; - Graphics graphics; - - public FeatureRenderer(AlignViewport av) - { - this.av = av; - } - - public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, - int start, int end, int x1, int y1, int width, - int height) - { - Vector features = seq.getSequenceFeatures(); - Enumeration e = features.elements(); - - while (e.hasMoreElements()) + AlignViewport av; + SequenceGroup currentSequenceGroup = null; + SequenceGroup[] allGroups = null; + Color resBoxColour; + Graphics graphics; + + /** + * Creates a new FeatureRenderer object. + * + * @param av DOCUMENT ME! + */ + public FeatureRenderer(AlignViewport av) { - SequenceFeature sf = (SequenceFeature) e.nextElement(); - - if (sf.getStart() > seq.getEnd()) - { - continue; - } - - int fstart = seq.findIndex(sf.getStart()) - 1; - int fend = seq.findIndex(sf.getEnd()) - 1; + this.av = av; + } - if ( ( (fstart <= end) && (fend >= start))) - { - if (fstart < start) - { // fix for if the feature we have starts before the sequence start, - fstart = start; // but the feature end is still valid!! - } - if(fend >=end) - fend = end; + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param seq DOCUMENT ME! + * @param sg DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, + int start, int end, int x1, int y1, int width, int height) + { + Vector features = seq.getSequenceFeatures(); + Enumeration e = features.elements(); - if (fstart == fend) - { - g.setColor(Color.red); - g.fillRoundRect( (fstart - start) * width, y1, width, - height, 4, 4); - g.setColor(Color.white); - - char s = seq.getSequence().charAt(fstart); - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (fstart - start)), - (y1 + height) - pady); - } - else + while (e.hasMoreElements()) { - for (int i = fstart; i <= fend; i++) - { - char s = seq.getSequence().charAt(i); + SequenceFeature sf = (SequenceFeature) e.nextElement(); - if (jalview.util.Comparison.isGap(s)) + if (sf.getStart() > seq.getEnd()) { - continue; + continue; } - g.setColor(Color.blue); - g.fillRect( (i - start) * width, y1, width, height); - - g.setColor(Color.white); + int fstart = seq.findIndex(sf.getStart()) - 1; + int fend = seq.findIndex(sf.getEnd()) - 1; - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), - (y1 + height) - pady); - } + if (((fstart <= end) && (fend >= start))) + { + if (fstart < start) + { // fix for if the feature we have starts before the sequence start, + fstart = start; // but the feature end is still valid!! + } + + if (fend >= end) + { + fend = end; + } + + if (fstart == fend) + { + g.setColor(Color.red); + g.fillRoundRect((fstart - start) * width, y1, width, + height, 4, 4); + g.setColor(Color.white); + + char s = seq.getSequence().charAt(fstart); + FontMetrics fm = g.getFontMetrics(); + int charOffset = (width - fm.charWidth(s)) / 2; + int pady = height / 5; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (fstart - start)), + (y1 + height) - pady); + } + else + { + for (int i = fstart; i <= fend; i++) + { + char s = seq.getSequence().charAt(i); + + if (jalview.util.Comparison.isGap(s)) + { + continue; + } + + g.setColor(Color.blue); + g.fillRect((i - start) * width, y1, width, height); + + g.setColor(Color.white); + + FontMetrics fm = g.getFontMetrics(); + int charOffset = (width - fm.charWidth(s)) / 2; + int pady = height / 5; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), + (y1 + height) - pady); + } + } + } } - } } - } } diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 71a52e9..1aceb80 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -18,318 +18,362 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; + +import jalview.jbgui.*; import java.awt.*; import java.awt.event.*; + +import java.util.*; + import javax.swing.*; import javax.swing.event.*; -import jalview.datamodel.*; -import jalview.jbgui.*; -public class Finder - extends GFinder +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Finder extends GFinder { - AlignViewport av; - AlignmentPanel ap; - JInternalFrame frame; - SuperGroup searchGroup; - Vector searchResults; - int seqIndex = 0; - int resIndex = 0; - - public Finder(AlignViewport av, AlignmentPanel ap, JInternalFrame f) - { - this.av = av; - this.ap = ap; - frame = f; - - // all a big pain, but we need to wait until the frame is visible before the textfield can - // obtain the focus///////////////////////// - frame.addInternalFrameListener(new InternalFrameAdapter() - { - public void internalFrameOpened(InternalFrameEvent evt) - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - textfield.requestFocus(); - } - }); - } - - public void internalFrameClosing(InternalFrameEvent evt) - { - cancel_actionPerformed(null); - } - }); - } - - public void textfield_actionPerformed(ActionEvent e) - { - doSearch(false); - } - - public void findNext_actionPerformed(ActionEvent e) - { - doSearch(false); - } - - public void findAll_actionPerformed(ActionEvent e) - { - resIndex = 0; - seqIndex = 0; - doSearch(true); - } - - public void cancel_actionPerformed(ActionEvent e) - { - try + AlignViewport av; + AlignmentPanel ap; + JInternalFrame frame; + SuperGroup searchGroup; + Vector searchResults; + int seqIndex = 0; + int resIndex = 0; + + /** + * Creates a new Finder object. + * + * @param av DOCUMENT ME! + * @param ap DOCUMENT ME! + * @param f DOCUMENT ME! + */ + public Finder(AlignViewport av, AlignmentPanel ap, JInternalFrame f) { - // if allResults is null, this effectively switches displaySearch flag in seqCanvas - ap.highlightSearchResults(null); - ap.idPanel.highlightSearchResults(null); - - // frame.setClosed(true); + this.av = av; + this.ap = ap; + frame = f; + + // all a big pain, but we need to wait until the frame is visible before the textfield can + // obtain the focus///////////////////////// + frame.addInternalFrameListener(new InternalFrameAdapter() + { + public void internalFrameOpened(InternalFrameEvent evt) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + textfield.requestFocus(); + } + }); + } + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void internalFrameClosing(InternalFrameEvent evt) + { + cancel_actionPerformed(null); + } + }); } - catch (Exception ex) - { - } - } - - public void createNewGroup_actionPerformed(ActionEvent e) - { - Color[] newColors = new Color[24]; - for (int i = 0; i < 24; i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void textfield_actionPerformed(ActionEvent e) { - newColors[i] = new Color(60, 160, 115); + doSearch(false); } - jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme( - newColors); - String searchString = textfield.getText(); - - searchGroup = new SuperGroup(searchString, ucs, true, true, false); - - for (int i = 0; i < searchResults.size(); i += 3) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void findNext_actionPerformed(ActionEvent e) { - // its possible edits may have occurred since search was performed - // account for this here - SequenceI seq = av.alignment.getSequenceAt(Integer.parseInt( - searchResults.elementAt(i).toString())); - int startRes = seq.findIndex(Integer.parseInt( - searchResults.elementAt(i + 1).toString())) - 1; - int endRes = seq.findIndex(Integer.parseInt( - searchResults.elementAt(i + 2).toString())) - 1; - - SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, - false, startRes, endRes); - sg.addSequence(seq, false); - av.alignment.addGroup(sg); - searchGroup.addGroup(sg); + doSearch(false); } - ap.av.alignment.addSuperGroup(searchGroup); - ap.highlightSearchResults(null); - } - - void doSearch(boolean findAll) - { - createNewGroup.setEnabled(false); - - String searchString = textfield.getText().toUpperCase(); - - com.stevesoft.pat.Regex regex = new com.stevesoft.pat.Regex(searchString); - - searchResults = new Vector(); - - int[] allResults = null; - - Sequence seq; - String item = null; - boolean found = false; - - ////// is the searchString a residue number? - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void findAll_actionPerformed(ActionEvent e) { - int res = Integer.parseInt(searchString); - found = true; - - if (av.getSelectionGroup().getSize() > 0) - { - seq = (Sequence) (av.getSelectionGroup().getSequenceAt(0)); - } - else - { - seq = (Sequence) av.getAlignment().getSequenceAt(0); - } - - searchResults.add(Integer.toString(av.getAlignment().findIndex(seq))); - searchResults.add(Integer.toString(seq.findIndex(res) - 1)); - searchResults.add(Integer.toString(seq.findIndex(res) - 1)); + resIndex = 0; + seqIndex = 0; + doSearch(true); } - catch (NumberFormatException ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void cancel_actionPerformed(ActionEvent e) { - } + try + { + // if allResults is null, this effectively switches displaySearch flag in seqCanvas + ap.highlightSearchResults(null); + ap.idPanel.highlightSearchResults(null); - /////////////////////////////////////////////// - Color[] newColors = new Color[24]; + // frame.setClosed(true); + } + catch (Exception ex) + { + } + } - for (int i = 0; i < 24; i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void createNewGroup_actionPerformed(ActionEvent e) { - newColors[i] = new Color(60, 160, 115); - } + Color[] newColors = new Color[24]; - jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme( - newColors); + for (int i = 0; i < 24; i++) + { + newColors[i] = new Color(60, 160, 115); + } - searchGroup = new SuperGroup(searchString, ucs, true, true, false); + jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(newColors); + String searchString = textfield.getText(); - int end = av.alignment.getHeight(); + searchGroup = new SuperGroup(searchString, ucs, true, true, false); - SequenceGroup selection = av.getSelectionGroup(); + for (int i = 0; i < searchResults.size(); i += 3) + { + // its possible edits may have occurred since search was performed + // account for this here + SequenceI seq = av.alignment.getSequenceAt(Integer.parseInt( + searchResults.elementAt(i).toString())); + int startRes = seq.findIndex(Integer.parseInt( + searchResults.elementAt(i + 1).toString())) - 1; + int endRes = seq.findIndex(Integer.parseInt( + searchResults.elementAt(i + 2).toString())) - 1; + + SequenceGroup sg = new SequenceGroup(searchString, ucs, true, true, + false, startRes, endRes); + sg.addSequence(seq, false); + av.alignment.addGroup(sg); + searchGroup.addGroup(sg); + } - if (selection != null) - { - if ( (selection.getSize() < 1) || - ( (selection.getEndRes() - selection.getStartRes()) < 2)) - { - selection = null; - } + ap.av.alignment.addSuperGroup(searchGroup); + ap.highlightSearchResults(null); } - while (!found && (seqIndex < end)) + /** + * DOCUMENT ME! + * + * @param findAll DOCUMENT ME! + */ + void doSearch(boolean findAll) { - seq = (Sequence) av.alignment.getSequenceAt(seqIndex); + createNewGroup.setEnabled(false); - if ( (selection != null) && !selection.sequences.contains(seq)) - { - seqIndex++; - resIndex = 0; + String searchString = textfield.getText().toUpperCase(); - continue; - } + com.stevesoft.pat.Regex regex = new com.stevesoft.pat.Regex(searchString); - item = seq.getSequence().toUpperCase(); + searchResults = new Vector(); - if ( (selection != null) && - (selection.getEndRes() < av.alignment.getWidth())) - { - item = item.substring(0, selection.getEndRes() + 1); - } + int[] allResults = null; - ///Shall we ignore gaps???? - StringBuffer noGaps = new StringBuffer(); - int insertCount = 0; - Vector spaces = new Vector(); + Sequence seq; + String item = null; + boolean found = false; - for (int j = 0; j < item.length(); j++) - { - if (!jalview.util.Comparison.isGap(item.charAt(j))) + ////// is the searchString a residue number? + try { - noGaps.append(item.charAt(j)); - spaces.add(new Integer(insertCount)); + int res = Integer.parseInt(searchString); + found = true; + + if (av.getSelectionGroup().getSize() > 0) + { + seq = (Sequence) (av.getSelectionGroup().getSequenceAt(0)); + } + else + { + seq = (Sequence) av.getAlignment().getSequenceAt(0); + } + + searchResults.add(Integer.toString(av.getAlignment().findIndex(seq))); + searchResults.add(Integer.toString(seq.findIndex(res) - 1)); + searchResults.add(Integer.toString(seq.findIndex(res) - 1)); } - else + catch (NumberFormatException ex) { - insertCount++; } - } - for (int r = resIndex; r < noGaps.length(); r++) - { - if (regex.searchFrom(noGaps.toString(), r)) + /////////////////////////////////////////////// + Color[] newColors = new Color[24]; + + for (int i = 0; i < 24; i++) { - resIndex = regex.matchedFrom(); - - if ( (selection != null) && - ( (resIndex + - Integer.parseInt(spaces.get(resIndex).toString())) < - selection.getStartRes())) - { - continue; - } - - searchResults.add(Integer.toString(seqIndex)); - - int sres = seq.findPosition(resIndex + - Integer.parseInt(spaces.elementAt( - resIndex) - .toString())); - int eres = seq.findPosition(regex.matchedTo() - 1 + - Integer.parseInt(spaces.elementAt(regex. - matchedTo() - - 1).toString())); - - searchResults.addElement(sres + ""); - searchResults.addElement(eres + ""); - - if (!findAll) - { - // thats enough, break and display the result - found = true; - resIndex++; + newColors[i] = new Color(60, 160, 115); + } + + jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(newColors); - break; - } + searchGroup = new SuperGroup(searchString, ucs, true, true, false); - r = resIndex; + int end = av.alignment.getHeight(); + + SequenceGroup selection = av.getSelectionGroup(); + + if (selection != null) + { + if ((selection.getSize() < 1) || + ((selection.getEndRes() - selection.getStartRes()) < 2)) + { + selection = null; + } } - } - if (!found) - { - seqIndex++; - resIndex = 0; - } - } + while (!found && (seqIndex < end)) + { + seq = (Sequence) av.alignment.getSequenceAt(seqIndex); + + if ((selection != null) && !selection.sequences.contains(seq)) + { + seqIndex++; + resIndex = 0; + + continue; + } + + item = seq.getSequence().toUpperCase(); + + if ((selection != null) && + (selection.getEndRes() < av.alignment.getWidth())) + { + item = item.substring(0, selection.getEndRes() + 1); + } + + ///Shall we ignore gaps???? + StringBuffer noGaps = new StringBuffer(); + int insertCount = 0; + Vector spaces = new Vector(); + + for (int j = 0; j < item.length(); j++) + { + if (!jalview.util.Comparison.isGap(item.charAt(j))) + { + noGaps.append(item.charAt(j)); + spaces.add(new Integer(insertCount)); + } + else + { + insertCount++; + } + } + + for (int r = resIndex; r < noGaps.length(); r++) + { + if (regex.searchFrom(noGaps.toString(), r)) + { + resIndex = regex.matchedFrom(); + + if ((selection != null) && + ((resIndex + + Integer.parseInt(spaces.get(resIndex).toString())) < selection.getStartRes())) + { + continue; + } + + searchResults.add(Integer.toString(seqIndex)); + + int sres = seq.findPosition(resIndex + + Integer.parseInt(spaces.elementAt(resIndex) + .toString())); + int eres = seq.findPosition(regex.matchedTo() - 1 + + Integer.parseInt(spaces.elementAt(regex.matchedTo() - + 1).toString())); + + searchResults.addElement(sres + ""); + searchResults.addElement(eres + ""); + + if (!findAll) + { + // thats enough, break and display the result + found = true; + resIndex++; + + break; + } + + r = resIndex; + } + } + + if (!found) + { + seqIndex++; + resIndex = 0; + } + } - Vector idMatch = new Vector(); + Vector idMatch = new Vector(); - for (int id = 0; id < av.alignment.getHeight(); id++) - { - if (regex.search(av.alignment.getSequenceAt(id).getName())) - { - idMatch.add(av.alignment.getSequenceAt(id)); - } - } + for (int id = 0; id < av.alignment.getHeight(); id++) + { + if (regex.search(av.alignment.getSequenceAt(id).getName())) + { + idMatch.add(av.alignment.getSequenceAt(id)); + } + } - if ( (searchResults.size() == 0) && (idMatch.size() > 0)) - { - ap.idPanel.highlightSearchResults(idMatch); - } + if ((searchResults.size() == 0) && (idMatch.size() > 0)) + { + ap.idPanel.highlightSearchResults(idMatch); + } - if (searchResults.size() > 0) - { - allResults = new int[searchResults.size()]; + if (searchResults.size() > 0) + { + allResults = new int[searchResults.size()]; - for (int i = 0; i < searchResults.size(); i++) - { - allResults[i] = Integer.parseInt(searchResults.get(i).toString()); - } + for (int i = 0; i < searchResults.size(); i++) + { + allResults[i] = Integer.parseInt(searchResults.get(i).toString()); + } - createNewGroup.setEnabled(true); - } - else - { - JOptionPane.showInternalMessageDialog(this, "Finished searching", - null, - JOptionPane.INFORMATION_MESSAGE); - resIndex = 0; - seqIndex = 0; - } + createNewGroup.setEnabled(true); + } + else + { + JOptionPane.showInternalMessageDialog(this, "Finished searching", + null, JOptionPane.INFORMATION_MESSAGE); + resIndex = 0; + seqIndex = 0; + } - // if allResults is null, this effectively switches displaySearch flag in seqCanvas - ap.highlightSearchResults(allResults); + // if allResults is null, this effectively switches displaySearch flag in seqCanvas + ap.highlightSearchResults(allResults); - if (findAll) - { - String message = (searchResults.size() / 3) + " matches found."; - JOptionPane.showInternalMessageDialog(this, message, null, - JOptionPane.INFORMATION_MESSAGE); + if (findAll) + { + String message = (searchResults.size() / 3) + " matches found."; + JOptionPane.showInternalMessageDialog(this, message, null, + JOptionPane.INFORMATION_MESSAGE); + } } - } } diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index b911d7d..527bf5d 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -18,132 +18,177 @@ */ package jalview.gui; +import jalview.bin.*; + +import jalview.jbgui.*; + import java.awt.*; import java.awt.event.*; + import javax.swing.*; -import jalview.bin.*; -import jalview.jbgui.*; -public class FontChooser - extends GFontChooser +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class FontChooser extends GFontChooser { - AlignmentPanel ap; - Font oldFont; - boolean init = true; - JInternalFrame frame; - - public FontChooser(AlignmentPanel ap) - { - frame = new JInternalFrame(); - frame.setContentPane(this); - Desktop.addInternalFrame(frame, "Change Font", 480, 100, false); - frame.setLayer(JLayeredPane.PALETTE_LAYER); - - this.ap = ap; + AlignmentPanel ap; + Font oldFont; + boolean init = true; + JInternalFrame frame; + + /** + * Creates a new FontChooser object. + * + * @param ap DOCUMENT ME! + */ + public FontChooser(AlignmentPanel ap) + { + frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, "Change Font", 480, 100, false); + frame.setLayer(JLayeredPane.PALETTE_LAYER); - String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() - .getAvailableFontFamilyNames(); + this.ap = ap; - for (int i = 0; i < fonts.length; i++) - { - fontName.addItem(fonts[i]); - } + String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() + .getAvailableFontFamilyNames(); - for (int i = 1; i < 31; i++) - { - fontSize.addItem(i + ""); - } + for (int i = 0; i < fonts.length; i++) + { + fontName.addItem(fonts[i]); + } - fontStyle.addItem("plain"); - fontStyle.addItem("bold"); - fontStyle.addItem("italic"); + for (int i = 1; i < 31; i++) + { + fontSize.addItem(i + ""); + } - oldFont = ap.av.getFont(); - fontName.setSelectedItem(oldFont.getName()); - fontSize.setSelectedItem(oldFont.getSize() + ""); - fontStyle.setSelectedIndex(oldFont.getStyle()); + fontStyle.addItem("plain"); + fontStyle.addItem("bold"); + fontStyle.addItem("italic"); - init = false; - } + oldFont = ap.av.getFont(); + fontName.setSelectedItem(oldFont.getName()); + fontSize.setSelectedItem(oldFont.getSize() + ""); + fontStyle.setSelectedIndex(oldFont.getStyle()); - protected void ok_actionPerformed(ActionEvent e) - { - try - { - frame.setClosed(true); + init = false; } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void ok_actionPerformed(ActionEvent e) { + try + { + frame.setClosed(true); + } + catch (Exception ex) + { + } + + if (ap.getOverviewPanel() != null) + { + ap.getOverviewPanel().updateOverviewImage(); + } } - if (ap.getOverviewPanel() != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cancel_actionPerformed(ActionEvent e) { - ap.getOverviewPanel().updateOverviewImage(); + ap.av.setFont(oldFont); + ap.repaint(); + fontName.setSelectedItem(oldFont.getName()); + fontSize.setSelectedItem(oldFont.getSize() + ""); + fontStyle.setSelectedIndex(oldFont.getStyle()); + + try + { + frame.setClosed(true); + } + catch (Exception ex) + { + } } - } - protected void cancel_actionPerformed(ActionEvent e) - { - ap.av.setFont(oldFont); - ap.repaint(); - fontName.setSelectedItem(oldFont.getName()); - fontSize.setSelectedItem(oldFont.getSize() + ""); - fontStyle.setSelectedIndex(oldFont.getStyle()); - - try + /** + * DOCUMENT ME! + */ + void changeFont() { - frame.setClosed(true); + Font newFont = new Font(fontName.getSelectedItem().toString(), + fontStyle.getSelectedIndex(), + Integer.parseInt(fontSize.getSelectedItem().toString())); + ap.av.setFont(newFont); + ap.fontChanged(); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void fontName_actionPerformed(ActionEvent e) { + if (init) + { + return; + } + + changeFont(); } - } - - void changeFont() - { - Font newFont = new Font(fontName.getSelectedItem().toString(), - fontStyle.getSelectedIndex(), - Integer.parseInt(fontSize.getSelectedItem(). - toString())); - ap.av.setFont(newFont); - ap.fontChanged(); - } - - protected void fontName_actionPerformed(ActionEvent e) - { - if (init) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void fontSize_actionPerformed(ActionEvent e) { - return; - } + if (init) + { + return; + } - changeFont(); - } + changeFont(); + } - protected void fontSize_actionPerformed(ActionEvent e) - { - if (init) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void fontStyle_actionPerformed(ActionEvent e) { - return; - } + if (init) + { + return; + } - changeFont(); - } + changeFont(); + } - protected void fontStyle_actionPerformed(ActionEvent e) - { - if (init) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void defaultButton_actionPerformed(ActionEvent e) { - return; + Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString()); + Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + ""); + Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString()); } - - changeFont(); - } - - public void defaultButton_actionPerformed(ActionEvent e) - { - Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString()); - Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex() + ""); - Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString()); - } } diff --git a/src/jalview/gui/IdCanvas.java b/src/jalview/gui/IdCanvas.java index b38fd21..9581ccc 100755 --- a/src/jalview/gui/IdCanvas.java +++ b/src/jalview/gui/IdCanvas.java @@ -18,240 +18,278 @@ */ package jalview.gui; +import jalview.analysis.*; + +import jalview.datamodel.*; + import java.awt.*; import java.awt.image.*; + import javax.swing.*; -import jalview.analysis.*; -import jalview.datamodel.*; -public class IdCanvas - extends JPanel +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class IdCanvas extends JPanel { - protected AlignViewport av; - protected boolean showScores = true; - protected int maxIdLength = -1; - protected String maxIdStr = null; - BufferedImage image; - Graphics2D gg; - int imgHeight = 0; - boolean fastPaint = false; - java.util.Vector searchResults; - - public IdCanvas(AlignViewport av) - { - setLayout(new BorderLayout()); - this.av = av; - PaintRefresher.Register(this, av.alignment); - } - - public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, - int ypos) - { - int charHeight = av.getCharHeight(); - - if ( (searchResults != null) && searchResults.contains(s)) + protected AlignViewport av; + protected boolean showScores = true; + protected int maxIdLength = -1; + protected String maxIdStr = null; + BufferedImage image; + Graphics2D gg; + int imgHeight = 0; + boolean fastPaint = false; + java.util.Vector searchResults; + + /** + * Creates a new IdCanvas object. + * + * @param av DOCUMENT ME! + */ + public IdCanvas(AlignViewport av) { - gg.setColor(Color.black); - gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos, - getWidth(), charHeight); - gg.setColor(Color.white); - } - else if ( (av.getSelectionGroup() != null) && - av.getSelectionGroup().sequences.contains(s)) - { - gg.setColor(Color.lightGray); - gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos, - getWidth(), charHeight); - gg.setColor(Color.white); - } - else - { - gg.setColor(s.getColor()); - gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos, - getWidth(), charHeight); - gg.setColor(Color.black); + setLayout(new BorderLayout()); + this.av = av; + PaintRefresher.Register(this, av.alignment); } - String string = s.getName(); - - if (av.getShowFullId()) + /** + * DOCUMENT ME! + * + * @param gg DOCUMENT ME! + * @param s DOCUMENT ME! + * @param i DOCUMENT ME! + * @param starty DOCUMENT ME! + * @param ypos DOCUMENT ME! + */ + public void drawIdString(Graphics2D gg, SequenceI s, int i, int starty, + int ypos) { - string = s.getDisplayId(); - } + int charHeight = av.charHeight; - gg.drawString(string, 0, - (AlignmentUtil.getPixelHeight(starty, i, charHeight) + ypos + - charHeight) - (charHeight / 5)); - } - - public void fastPaint(int vertical) - { - if (gg == null) - { - repaint(); - return; - } + if ((searchResults != null) && searchResults.contains(s)) + { + gg.setColor(Color.black); + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getWidth(), + charHeight); + gg.setColor(Color.white); + } + else if ((av.getSelectionGroup() != null) && + av.getSelectionGroup().sequences.contains(s)) + { + gg.setColor(Color.lightGray); + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getWidth(), + charHeight); + gg.setColor(Color.white); + } + else + { + gg.setColor(s.getColor()); + gg.fillRect(0, ((i - starty) * charHeight) + ypos, getWidth(), + charHeight); + gg.setColor(Color.black); + } - gg.copyArea(0, 0, getWidth(), imgHeight, 0, -vertical * av.charHeight); + String string = s.getName(); - int ss = av.startSeq; - int es = av.endSeq; - int transY = 0; + if (av.getShowFullId()) + { + string = s.getDisplayId(); + } - if (vertical > 0) // scroll down - { - ss = es - vertical; - - if (ss < av.startSeq) - { // ie scrolling too fast, more than a page at a time - ss = av.startSeq; - } - else - { - transY = imgHeight - (vertical * av.charHeight); - } + gg.drawString(string, 0, + (((i - starty + 1) * charHeight) + ypos) - (charHeight / 5)); } - else if (vertical < 0) + + /** + * DOCUMENT ME! + * + * @param vertical DOCUMENT ME! + */ + public void fastPaint(int vertical) { - es = ss - vertical; + if (gg == null) + { + repaint(); - if (es > av.endSeq) - { - es = av.endSeq; - } - } + return; + } - gg.translate(0, transY); + gg.copyArea(0, 0, getWidth(), imgHeight, 0, -vertical * av.charHeight); - drawIds(ss, es); + int ss = av.startSeq; + int es = av.endSeq; + int transY = 0; - gg.translate(0, -transY); + if (vertical > 0) // scroll down + { + ss = es - vertical; + + if (ss < av.startSeq) + { // ie scrolling too fast, more than a page at a time + ss = av.startSeq; + } + else + { + transY = imgHeight - (vertical * av.charHeight); + } + } + else if (vertical < 0) + { + es = ss - vertical; - fastPaint = true; - repaint(); - } + if (es > av.endSeq) + { + es = av.endSeq; + } + } - public void paintComponent(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); + gg.translate(0, transY); - if (fastPaint) - { - fastPaint = false; - g.drawImage(image, 0, 0, this); + drawIds(ss, es); - return; - } + gg.translate(0, -transY); - imgHeight = getHeight(); - imgHeight -= (imgHeight % av.charHeight); + fastPaint = true; + repaint(); + } - if (imgHeight < 1) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - return; - } + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); - image = new BufferedImage(getWidth(), imgHeight, - BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) image.getGraphics(); + if (fastPaint) + { + fastPaint = false; + g.drawImage(image, 0, 0, this); - //Fill in the background - gg.setColor(Color.white); - gg.fillRect(0, 0, getWidth(), imgHeight); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + return; + } - Font italic = new Font(av.getFont().getName(), Font.ITALIC, - av.getFont().getSize()); - gg.setFont(italic); + imgHeight = getHeight(); + imgHeight -= (imgHeight % av.charHeight); - drawIds(av.getStartSeq(), av.endSeq); + if (imgHeight < 1) + { + return; + } - g.drawImage(image, 0, 0, this); - } + image = new BufferedImage(getWidth(), imgHeight, + BufferedImage.TYPE_INT_RGB); + gg = (Graphics2D) image.getGraphics(); - void drawIds(int starty, int endy) - { + //Fill in the background + gg.setColor(Color.white); + gg.fillRect(0, 0, getWidth(), imgHeight); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - Color currentColor = Color.white; - Color currentTextColor = Color.black; + Font italic = new Font(av.getFont().getName(), Font.ITALIC, + av.getFont().getSize()); + gg.setFont(italic); - if (av.getWrapAlignment()) - { - int rowSize = av.getEndRes() - av.getStartRes(); - - // Draw the rest of the panels - for (int ypos = 2 * av.charHeight, row = av.startRes; - (ypos <= getHeight()) && (row < av.alignment.getWidth()); - ypos += av.chunkHeight, row += rowSize) - { - for (int i = starty; i < av.alignment.getHeight(); i++) - { - SequenceI s = av.alignment.getSequenceAt(i); - drawIdString(gg, s, i, 0, ypos); - } - } + drawIds(av.getStartSeq(), av.endSeq); + + g.drawImage(image, 0, 0, this); } - else + + /** + * DOCUMENT ME! + * + * @param starty DOCUMENT ME! + * @param endy DOCUMENT ME! + */ + void drawIds(int starty, int endy) { - //Now draw the id strings - for (int i = starty; i < endy; i++) - { - // Selected sequence colours - if ( (searchResults != null) && - searchResults.contains(av.alignment.getSequenceAt(i))) - { - gg.setColor(Color.black); - currentColor = Color.black; - currentTextColor = Color.white; - } - else if ( (av.getSelectionGroup() != null) && - av.getSelectionGroup().sequences.contains( - av.alignment.getSequenceAt(i))) + Color currentColor = Color.white; + Color currentTextColor = Color.black; + + if (av.getWrapAlignment()) { - currentColor = Color.lightGray; - currentTextColor = Color.black; + int rowSize = av.getEndRes() - av.getStartRes(); + + // Draw the rest of the panels + for (int ypos = 2 * av.charHeight, row = av.startRes; + (ypos <= getHeight()) && (row < av.alignment.getWidth()); + ypos += av.chunkHeight, row += rowSize) + { + for (int i = starty; i < av.alignment.getHeight(); i++) + { + SequenceI s = av.alignment.getSequenceAt(i); + drawIdString(gg, s, i, 0, ypos); + } + } } else { - currentColor = av.alignment.getSequenceAt(i).getColor(); - currentTextColor = Color.black; - } - - gg.setColor(currentColor); - - gg.fillRect(0, - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), - getWidth(), av.charHeight); - - gg.setColor(currentTextColor); - - String string = av.alignment.getSequenceAt(i).getName(); - - if (av.getShowFullId()) - { - string = av.alignment.getSequenceAt(i).getDisplayId(); + //Now draw the id strings + for (int i = starty; i < endy; i++) + { + // Selected sequence colours + if ((searchResults != null) && + searchResults.contains(av.alignment.getSequenceAt(i))) + { + gg.setColor(Color.black); + currentColor = Color.black; + currentTextColor = Color.white; + } + else if ((av.getSelectionGroup() != null) && + av.getSelectionGroup().sequences.contains( + av.alignment.getSequenceAt(i))) + { + currentColor = Color.lightGray; + currentTextColor = Color.black; + } + else + { + currentColor = av.alignment.getSequenceAt(i).getColor(); + currentTextColor = Color.black; + } + + gg.setColor(currentColor); + + gg.fillRect(0, (i - starty) * av.charHeight, getWidth(), + av.charHeight); + + gg.setColor(currentTextColor); + + String string = av.alignment.getSequenceAt(i).getName(); + + if (av.getShowFullId()) + { + string = av.alignment.getSequenceAt(i).getDisplayId(); + } + + gg.drawString(string, 0, + (((i - starty) * av.charHeight) + av.charHeight) - + (av.charHeight / 5)); + } + + // add a border + gg.setColor(Color.white); + gg.fillRect(getWidth() - 4, 0, 4, getHeight()); } - - gg.drawString(string, 0, - (AlignmentUtil.getPixelHeight(starty, i, av.charHeight) + - av.charHeight) - (av.charHeight / 5)); - } - - // add a border - gg.setColor(Color.white); - gg.fillRect(getWidth() - 4, 0, 4, getHeight()); } - } - public void setHighlighted(java.util.Vector found) - { - searchResults = found; - repaint(); - } + /** + * DOCUMENT ME! + * + * @param found DOCUMENT ME! + */ + public void setHighlighted(java.util.Vector found) + { + searchResults = found; + repaint(); + } } diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 3dd7b5b..310276c 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -18,316 +18,380 @@ */ package jalview.gui; +import jalview.datamodel.*; + import java.awt.*; import java.awt.event.*; + import javax.swing.*; -import jalview.datamodel.*; -public class IdPanel - extends JPanel implements MouseListener, +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class IdPanel extends JPanel implements MouseListener, MouseMotionListener { - protected IdCanvas idCanvas; - protected AlignViewport av; - protected AlignmentPanel alignPanel; - ScrollThread scrollThread = null; - int offy; - int width; - int lastid = -1; - boolean mouseDragging = false; - - public IdPanel(AlignViewport av, AlignmentPanel parent) - { - this.av = av; - alignPanel = parent; - idCanvas = new IdCanvas(av); - setLayout(new BorderLayout()); - add(idCanvas, BorderLayout.CENTER); - addMouseListener(this); - addMouseMotionListener(this); - } - - public void mouseMoved(MouseEvent e) - { - } - - public void mouseDragged(MouseEvent e) - { - mouseDragging = true; - - int y = e.getY(); - - if (av.getWrapAlignment()) + protected IdCanvas idCanvas; + protected AlignViewport av; + protected AlignmentPanel alignPanel; + ScrollThread scrollThread = null; + int offy; + int width; + int lastid = -1; + boolean mouseDragging = false; + + /** + * Creates a new IdPanel object. + * + * @param av DOCUMENT ME! + * @param parent DOCUMENT ME! + */ + public IdPanel(AlignViewport av, AlignmentPanel parent) { - y -= (2 * av.charHeight); + this.av = av; + alignPanel = parent; + idCanvas = new IdCanvas(av); + setLayout(new BorderLayout()); + add(idCanvas, BorderLayout.CENTER); + addMouseListener(this); + addMouseMotionListener(this); } - int seq = av.getIndex(y); - - if (seq < 0) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseMoved(MouseEvent e) { - return; } - if (seq < lastid) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseDragged(MouseEvent e) { - selectSeqs(lastid - 1, seq); - } - else if (seq > lastid) - { - selectSeqs(lastid + 1, seq); - } + mouseDragging = true; - lastid = seq; - alignPanel.repaint(); - } + int y = e.getY(); - public void mouseClicked(MouseEvent e) - { - if (e.getClickCount() == 2) - { - int y = e.getY(); - - if (av.getWrapAlignment()) - { - y -= (2 * av.charHeight); - } - - int seq = av.getIndex(y); - String id = av.getAlignment().getSequenceAt(seq).getName(); - - try - { - jalview.util.BrowserLauncher.openURL( - "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:" + - id + "]+-vn+2"); - } - catch (Exception ex) - { - // TODO: JBPNote : state dependent error message for real browserLaunch problems rather than unix misconfiguration. - System.err.println(ex.getMessage() + - "\nUnixers: Try adding this jalview.browser property line \n" + - "in your jalview.properties file (/usr/local/bin/firefox is an exanmple browser path):\n" + - "jalview.browser=/usr/local/bin/firefox\n"); - - //ex.printStackTrace(); - } - } - } + if (av.getWrapAlignment()) + { + y -= (2 * av.charHeight); + } - public void mouseEntered(MouseEvent e) - { - if (scrollThread != null) - { - scrollThread.running = false; - } - } + int seq = av.getIndex(y); - public void mouseExited(MouseEvent e) - { - if (av.getWrapAlignment()) - { - return; - } + if (seq < 0) + { + return; + } - if (mouseDragging && (e.getY() < 0) && (av.getStartSeq() > 0)) - { - scrollThread = new ScrollThread(true); + if (seq < lastid) + { + selectSeqs(lastid - 1, seq); + } + else if (seq > lastid) + { + selectSeqs(lastid + 1, seq); + } + + lastid = seq; + alignPanel.repaint(); } - if (mouseDragging && (e.getY() >= getHeight()) && - (av.alignment.getHeight() > av.getEndSeq())) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseClicked(MouseEvent e) { - scrollThread = new ScrollThread(false); + if (e.getClickCount() == 2) + { + int y = e.getY(); + + if (av.getWrapAlignment()) + { + y -= (2 * av.charHeight); + } + + int seq = av.getIndex(y); + String id = av.getAlignment().getSequenceAt(seq).getName(); + + try + { + jalview.util.BrowserLauncher.openURL( + "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:" + + id + "]+-vn+2"); + } + catch (Exception ex) + { + // TODO: JBPNote : state dependent error message for real browserLaunch problems rather than unix misconfiguration. + System.err.println(ex.getMessage() + + "\nUnixers: Try adding this jalview.browser property line \n" + + "in your jalview.properties file (/usr/local/bin/firefox is an exanmple browser path):\n" + + "jalview.browser=/usr/local/bin/firefox\n"); + + //ex.printStackTrace(); + } + } } - } - public void mousePressed(MouseEvent e) - { - if (e.getClickCount() == 2) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseEntered(MouseEvent e) { - return; + if (scrollThread != null) + { + scrollThread.running = false; + } } - int y = e.getY(); - - if (av.getWrapAlignment()) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseExited(MouseEvent e) { - y -= (2 * av.charHeight); - } + if (av.getWrapAlignment()) + { + return; + } - int seq = av.getIndex(y); + if (mouseDragging && (e.getY() < 0) && (av.getStartSeq() > 0)) + { + scrollThread = new ScrollThread(true); + } - if (seq == -1) - { - return; + if (mouseDragging && (e.getY() >= getHeight()) && + (av.alignment.getHeight() > av.getEndSeq())) + { + scrollThread = new ScrollThread(false); + } } - if (javax.swing.SwingUtilities.isRightMouseButton(e)) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mousePressed(MouseEvent e) { - jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, - (Sequence) av.getAlignment().getSequenceAt(seq)); - pop.show(this, e.getX(), y); + if (e.getClickCount() == 2) + { + return; + } - return; - } + int y = e.getY(); - if (!e.isControlDown() && !e.isShiftDown() && - (av.alignment.findGroup(av.alignment.getSequenceAt(seq)) != null)) - { - SequenceGroup selection = new SequenceGroup(); - SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt( - seq)); - selection.setStartRes(0); - selection.setEndRes(av.alignment.getWidth() - 1); + if (av.getWrapAlignment()) + { + y -= (2 * av.charHeight); + } - for (int i = 0; i < sg.getSize(); i++) - { - selection.addSequence(sg.getSequenceAt(i), true); - } + int seq = av.getIndex(y); - av.setSelectionGroup(selection); + if (seq == -1) + { + return; + } - return; - } + if (javax.swing.SwingUtilities.isRightMouseButton(e)) + { + jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, + (Sequence) av.getAlignment().getSequenceAt(seq)); + pop.show(this, e.getX(), y); - if ( (av.getSelectionGroup() == null) || - (!e.isControlDown() && (av.getSelectionGroup() != null))) - { - av.setSelectionGroup(new SequenceGroup()); - } + return; + } - av.getSelectionGroup().setStartRes(0); - av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); + if (!e.isControlDown() && !e.isShiftDown() && + (av.alignment.findGroup(av.alignment.getSequenceAt(seq)) != null)) + { + SequenceGroup selection = new SequenceGroup(); + SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt( + seq)); + selection.setStartRes(0); + selection.setEndRes(av.alignment.getWidth() - 1); - if (e.isShiftDown() && (lastid != -1)) - { - selectSeqs(lastid, seq); - } - else - { - selectSeq(seq); - } + for (int i = 0; i < sg.getSize(); i++) + { + selection.addSequence(sg.getSequenceAt(i), true); + } - alignPanel.repaint(); - } + av.setSelectionGroup(selection); - void selectSeq(int seq) - { - lastid = seq; + return; + } - SequenceI pickedSeq = av.getAlignment().getSequenceAt(seq); - av.getSelectionGroup().addOrRemove(pickedSeq, true); - } + if ((av.getSelectionGroup() == null) || + (!e.isControlDown() && (av.getSelectionGroup() != null))) + { + av.setSelectionGroup(new SequenceGroup()); + } - void selectSeqs(int start, int end) - { - lastid = start; + av.getSelectionGroup().setStartRes(0); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); - if (end < start) - { - int tmp = start; - start = end; - end = tmp; - lastid = end; - } + if (e.isShiftDown() && (lastid != -1)) + { + selectSeqs(lastid, seq); + } + else + { + selectSeq(seq); + } - for (int i = start; i <= end; i++) - { - av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i), true); + alignPanel.repaint(); } - } - public void mouseReleased(MouseEvent e) - { - if (scrollThread != null) + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + */ + void selectSeq(int seq) { - scrollThread.running = false; - } - - mouseDragging = false; - PaintRefresher.Refresh(av.alignment); - } - - public void highlightSearchResults(java.util.Vector found) - { - idCanvas.setHighlighted(found); + lastid = seq; - if (found == null) - { - return; + SequenceI pickedSeq = av.getAlignment().getSequenceAt(seq); + av.getSelectionGroup().addOrRemove(pickedSeq, true); } - int index = av.alignment.findIndex( (SequenceI) found.get(0)); - - // do we need to scroll the panel? - if ( (av.getStartSeq() > index) || (av.getEndSeq() < index)) + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + */ + void selectSeqs(int start, int end) { - alignPanel.setScrollValues(av.getStartRes(), index); - } - } + lastid = start; - // this class allows scrolling off the bottom of the visible alignment - class ScrollThread - extends Thread - { - boolean running = false; - boolean up = true; + if (end < start) + { + int tmp = start; + start = end; + end = tmp; + lastid = end; + } - public ScrollThread(boolean up) - { - this.up = up; - start(); + for (int i = start; i <= end; i++) + { + av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i), + true); + } } - public void stopScrolling() + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseReleased(MouseEvent e) { - running = false; + if (scrollThread != null) + { + scrollThread.running = false; + } + + mouseDragging = false; + PaintRefresher.Refresh(av.alignment); } - public void run() + /** + * DOCUMENT ME! + * + * @param found DOCUMENT ME! + */ + public void highlightSearchResults(java.util.Vector found) { - running = true; + idCanvas.setHighlighted(found); - while (running) - { - if (alignPanel.scrollUp(up)) + if (found == null) { - // scroll was ok, so add new sequence to selection - int seq = av.getStartSeq(); - - if (!up) - { - seq = av.getEndSeq(); - } + return; + } - if (seq < lastid) - { - selectSeqs(lastid - 1, seq); - } - else if (seq > lastid) - { - selectSeqs(lastid + 1, seq); - } + int index = av.alignment.findIndex((SequenceI) found.get(0)); - lastid = seq; - } - else + // do we need to scroll the panel? + if ((av.getStartSeq() > index) || (av.getEndSeq() < index)) { - running = false; + alignPanel.setScrollValues(av.getStartRes(), index); } + } - alignPanel.repaint(); + // this class allows scrolling off the bottom of the visible alignment + class ScrollThread extends Thread + { + boolean running = false; + boolean up = true; + + public ScrollThread(boolean up) + { + this.up = up; + start(); + } - try + public void stopScrolling() { - Thread.sleep(100); + running = false; } - catch (Exception ex) + + public void run() { + running = true; + + while (running) + { + if (alignPanel.scrollUp(up)) + { + // scroll was ok, so add new sequence to selection + int seq = av.getStartSeq(); + + if (!up) + { + seq = av.getEndSeq(); + } + + if (seq < lastid) + { + selectSeqs(lastid - 1, seq); + } + else if (seq > lastid) + { + selectSeqs(lastid + 1, seq); + } + + lastid = seq; + } + else + { + running = false; + } + + alignPanel.repaint(); + + try + { + Thread.sleep(100); + } + catch (Exception ex) + { + } + } } - } } - } } diff --git a/src/jalview/gui/IdwidthAdjuster.java b/src/jalview/gui/IdwidthAdjuster.java index 5599a6d..1fc524a 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -20,91 +20,143 @@ package jalview.gui; import java.awt.*; import java.awt.event.*; + import javax.swing.*; -public class IdwidthAdjuster - extends JPanel implements MouseListener, + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class IdwidthAdjuster extends JPanel implements MouseListener, MouseMotionListener { - boolean active = false; - int oldX = 0; - Image image; - AlignmentPanel ap; + boolean active = false; + int oldX = 0; + Image image; + AlignmentPanel ap; + + /** + * Creates a new IdwidthAdjuster object. + * + * @param ap DOCUMENT ME! + */ + public IdwidthAdjuster(AlignmentPanel ap) + { + this.ap = ap; - public IdwidthAdjuster(AlignmentPanel ap) - { - this.ap = ap; + java.net.URL url = getClass().getResource("/images/idwidth.gif"); - java.net.URL url = getClass().getResource("/images/idwidth.gif"); + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + } - if (url != null) + addMouseListener(this); + addMouseMotionListener(this); + } + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mousePressed(MouseEvent evt) { - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + oldX = evt.getX(); } - addMouseListener(this); - addMouseMotionListener(this); - } - - public void mousePressed(MouseEvent evt) - { - oldX = evt.getX(); - } - - public void mouseReleased(MouseEvent evt) - { - active = false; - repaint(); - } - - public void mouseEntered(MouseEvent evt) - { - active = true; - repaint(); - } - - public void mouseExited(MouseEvent evt) - { - active = false; - repaint(); - } - - public void mouseDragged(MouseEvent evt) - { - active = true; - - Dimension d = ap.idPanel.idCanvas.getPreferredSize(); - int dif = evt.getX() - oldX; - - if ( ( (d.width + dif) > 20) || (dif > 0)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseReleased(MouseEvent evt) { - ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif, - d.height)); - ap.repaint(); + active = false; + repaint(); } - oldX = evt.getX(); - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseEntered(MouseEvent evt) + { + active = true; + repaint(); + } - public void mouseMoved(MouseEvent evt) - { - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseExited(MouseEvent evt) + { + active = false; + repaint(); + } - public void mouseClicked(MouseEvent evt) - { - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseDragged(MouseEvent evt) + { + active = true; + + Dimension d = ap.idPanel.idCanvas.getPreferredSize(); + int dif = evt.getX() - oldX; + + if (((d.width + dif) > 20) || (dif > 0)) + { + ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif, + d.height)); + ap.repaint(); + } + + oldX = evt.getX(); + } - public void paintComponent(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseMoved(MouseEvent evt) + { + } + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseClicked(MouseEvent evt) + { + } - if (active) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - if (image != null) - { - g.drawImage(image, getWidth() - 20, 2, this); - } + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + + if (active) + { + if (image != null) + { + g.drawImage(image, getWidth() - 20, 2, this); + } + } } - } } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index bdd255c..ee96baa 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -18,761 +18,778 @@ */ package jalview.gui; +import jalview.binding.*; + +import jalview.io.*; + +import jalview.schemes.*; + import java.io.*; + import java.net.*; + import java.util.*; import java.util.jar.*; import javax.swing.*; -import jalview.binding.*; -import jalview.io.*; -import jalview.schemes.*; +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class Jalview2XML { - // SAVES SEVERAL ALIGNEMENT WINDOWS TO SAME JARFILE - public static void SaveState(File statefile) - { - long creation = System.currentTimeMillis(); - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); - - if (frames == null) - { - return; - } - - try + // SAVES SEVERAL ALIGNEMENT WINDOWS TO SAME JARFILE + public static void SaveState(File statefile) { - FileOutputStream fos = new FileOutputStream(statefile); - JarOutputStream jout = new JarOutputStream(fos); + long creation = System.currentTimeMillis(); + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); - //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS - //////////////////////////////////////////////////// - PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, - "UTF-8")); - - Vector shortNames = new Vector(); - int treeCount=1; - - //REVERSE ORDER - for (int i = frames.length - 1; i > -1; i--) - { - if (frames[i] instanceof AlignFrame) + if (frames == null) { - AlignFrame af = (AlignFrame) frames[i]; + return; + } - String shortName = af.getTitle(); + try + { + FileOutputStream fos = new FileOutputStream(statefile); + JarOutputStream jout = new JarOutputStream(fos); - if (shortName.indexOf(File.separatorChar) > -1) - { - shortName = shortName.substring(shortName.lastIndexOf( - File.separatorChar) + 1); - } + //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS + //////////////////////////////////////////////////// + PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, + "UTF-8")); - int count = 1; + Vector shortNames = new Vector(); - while (shortNames.contains(shortName)) - { - if (shortName.endsWith("_" + (count - 1))) + //REVERSE ORDER + for (int i = frames.length - 1; i > -1; i--) { - shortName = shortName.substring(0, - shortName.lastIndexOf("_")); - } + if (frames[i] instanceof AlignFrame) + { + AlignFrame af = (AlignFrame) frames[i]; - shortName = shortName.concat("_" + count); - count++; - } + String shortName = af.getTitle(); - shortNames.addElement(shortName); + if (shortName.indexOf(File.separatorChar) > -1) + { + shortName = shortName.substring(shortName.lastIndexOf( + File.separatorChar) + 1); + } - if (!shortName.endsWith(".xml")) - { - shortName = shortName + ".xml"; - } + int count = 1; - SaveState(af, creation, shortName, jout, out); - } - } + while (shortNames.contains(shortName)) + { + if (shortName.endsWith("_" + (count - 1))) + { + shortName = shortName.substring(0, + shortName.lastIndexOf("_")); + } - out.close(); - jout.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } + shortName = shortName.concat("_" + count); + count++; + } + shortNames.addElement(shortName); - // USE THIS METHOD TO SAVE A SINGLE ALIGNMENT WINDOW - public static void SaveAlignment(AlignFrame af, String jarFile, String fileName) - { - try - { - FileOutputStream fos = new FileOutputStream(jarFile); - JarOutputStream jout = new JarOutputStream(fos); + if (!shortName.endsWith(".xml")) + { + shortName = shortName + ".xml"; + } - //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS - //////////////////////////////////////////////////// - PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, - "UTF-8")); + SaveState(af, creation, shortName, jout, out); + } + } - SaveState(af, System.currentTimeMillis(), fileName, jout, out); - out.close(); - jout.close(); - } - catch (Exception ex) - { + out.close(); + jout.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - } - public static void SaveState(AlignFrame af, long timeStamp, - String fileName, JarOutputStream jout, - PrintWriter out) - { - Vector seqids = new Vector(); - Vector userColours = new Vector(); + // USE THIS METHOD TO SAVE A SINGLE ALIGNMENT WINDOW + public static void SaveAlignment(AlignFrame af, String jarFile, + String fileName) + { + try + { + FileOutputStream fos = new FileOutputStream(jarFile); + JarOutputStream jout = new JarOutputStream(fos); - AlignViewport av = af.viewport; + //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS + //////////////////////////////////////////////////// + PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, + "UTF-8")); - JalviewModel object = new JalviewModel(); - object.setVamsasModel(new VamsasModel()); + SaveState(af, System.currentTimeMillis(), fileName, jout, out); + out.close(); + jout.close(); + } + catch (Exception ex) + { + } + } - object.setCreationDate(new java.util.Date(timeStamp)); - object.setVersion(jalview.bin.Cache.VERSION); + /** + * DOCUMENT ME! + * + * @param af DOCUMENT ME! + * @param timeStamp DOCUMENT ME! + * @param fileName DOCUMENT ME! + * @param jout DOCUMENT ME! + * @param out DOCUMENT ME! + */ + public static void SaveState(AlignFrame af, long timeStamp, + String fileName, JarOutputStream jout, PrintWriter out) + { + Vector seqids = new Vector(); + Vector userColours = new Vector(); - jalview.datamodel.AlignmentI jal = af.viewport.alignment; + AlignViewport av = af.viewport; - SequenceSet vamsasSet = new SequenceSet(); - Sequence vamsasSeq; - JalviewModelSequence jms = new JalviewModelSequence(); + JalviewModel object = new JalviewModel(); + object.setVamsasModel(new VamsasModel()); - vamsasSet.setGapChar(jal.getGapCharacter() + ""); + object.setCreationDate(new java.util.Date(timeStamp)); + object.setVersion(jalview.bin.Cache.VERSION); - JSeq jseq; + jalview.datamodel.AlignmentI jal = af.viewport.alignment; - //SAVE SEQUENCES - int id = 0; + SequenceSet vamsasSet = new SequenceSet(); + Sequence vamsasSeq; + JalviewModelSequence jms = new JalviewModelSequence(); - for (int i = 0; i < jal.getHeight(); i++) - { - seqids.add(jal.getSequenceAt(i)); + vamsasSet.setGapChar(jal.getGapCharacter() + ""); - vamsasSeq = new Sequence(); - vamsasSeq.setId(id + ""); - vamsasSeq.setName(jal.getSequenceAt(i).getName()); - vamsasSeq.setSequence(jal.getSequenceAt(i).getSequence()); + JSeq jseq; - jseq = new JSeq(); - jseq.setStart(jal.getSequenceAt(i).getStart()); - jseq.setEnd(jal.getSequenceAt(i).getEnd()); + //SAVE SEQUENCES + int id = 0; - jseq.setColour(jal.getSequenceAt(i).getColor().getRGB()); + for (int i = 0; i < jal.getHeight(); i++) + { + seqids.add(jal.getSequenceAt(i)); - jseq.setId(id); + vamsasSeq = new Sequence(); + vamsasSeq.setId(id + ""); + vamsasSeq.setName(jal.getSequenceAt(i).getName()); + vamsasSeq.setSequence(jal.getSequenceAt(i).getSequence()); - jms.addJSeq(jseq); - vamsasSet.addSequence(vamsasSeq); - id++; - } + jseq = new JSeq(); + jseq.setStart(jal.getSequenceAt(i).getStart()); + jseq.setEnd(jal.getSequenceAt(i).getEnd()); - //SAVE TREES - /////////////////////////////////// - if (af.viewport.currentTree != null) - { - // FIND ANY ASSOCIATED TREES - JInternalFrame[] frames = Desktop.desktop.getAllFrames(); - for(int t=0; t 0) { - anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa]. - getDisplayCharacter(), - ae[aa].getDescription(), - ae[aa].getSecondaryStructure().charAt(0), - ae[aa].getValue()); - } + JGroup[] groups = jms.getJGroup(); - jalview.datamodel.AlignmentAnnotation jaa = null; + for (int i = 0; i < groups.length; i++) + { + ColourSchemeI cs = null; + + if (groups[i].getColour() != null) + { + if (groups[i].getColour().startsWith("ucs")) + { + cs = GetUserColourScheme(jms, groups[i].getColour()); + } + else + { + cs = ColourSchemeProperty.getColour(al, + groups[i].getColour()); + } + + if (cs instanceof ResidueColourScheme) + { + ((ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold()); + } + else if (cs instanceof ScoreColourScheme) + { + ((ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold()); + } + } + + Vector seqs = new Vector(); + int[] ids = groups[i].getSeq(); + + for (int s = 0; s < ids.length; s++) + { + seqs.addElement((jalview.datamodel.SequenceI) seqids.elementAt( + ids[s])); + } + + jalview.datamodel.SequenceGroup sg = new jalview.datamodel.SequenceGroup(seqs, + groups[i].getName(), cs, groups[i].getDisplayBoxes(), + groups[i].getDisplayText(), groups[i].getColourText(), + groups[i].getStart(), groups[i].getEnd()); + + sg.setOutlineColour(new java.awt.Color( + groups[i].getOutlineColour())); + + if (groups[i].getConsThreshold() != 0) + { + jalview.analysis.Conservation c = new jalview.analysis.Conservation("All", + ResidueProperties.propHash, 3, sg.sequences, 0, + sg.getWidth() - 1); + c.calculate(); + c.verdict(false, 25); + cs = new ConservationColourScheme(c, cs); + sg.cs = cs; + } + + al.addGroup(sg); + } + } - if (an[i].getGraph()) + Desktop.addInternalFrame(af, view.getTitle(), + AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); + af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(), + view.getHeight()); + af.viewport.setStartRes(view.getStartRes()); + af.viewport.setStartSeq(view.getStartSeq()); + af.viewport.showConservation = view.getShowConservation(); + af.viewport.showQuality = view.getShowQuality(); + af.viewport.showIdentity = view.getShowIdentity(); + af.viewport.setAbovePIDThreshold(view.getPidSelected()); + af.abovePIDThreshold.setSelected(view.getPidSelected()); + af.viewport.setColourText(view.getShowColourText()); + af.colourTextMenuItem.setSelected(view.getShowColourText()); + af.viewport.setConservationSelected(view.getConservationSelected()); + af.conservationMenuItem.setSelected(view.getConservationSelected()); + + af.viewport.setShowFullId(view.getShowFullId()); + af.fullSeqId.setSelected(view.getShowFullId()); + + af.viewport.setFont(new java.awt.Font(view.getFontName(), + view.getFontStyle(), view.getFontSize())); + af.alignPanel.fontChanged(); + + af.viewport.setRenderGaps(view.getRenderGaps()); + af.renderGapsMenuItem.setSelected(view.getRenderGaps()); + + af.viewport.setWrapAlignment(view.getWrapAlignment()); + af.wrapMenuItem.setSelected(view.getWrapAlignment()); + + if (view.getWrapAlignment()) { - jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(), - an[i].getDescription(), anot, 0, 0, 1); + af.alignPanel.setWrapAlignment(view.getWrapAlignment()); } else { - jaa = new jalview.datamodel.AlignmentAnnotation(an[i].getLabel(), - an[i].getDescription(), anot); + af.annotationPanelMenuItem.setState(view.getShowAnnotation()); + af.viewport.setShowAnnotation(view.getShowAnnotation()); + af.alignPanel.setAnnotationVisible(view.getShowAnnotation()); } - al.addAnnotation(jaa); - } - } - - ///////////////////////////////// - // LOAD VIEWPORT - Viewport[] views = jms.getViewport(); - Viewport view = views[0]; // DEAL WITH MULTIPLE VIEWPORTS LATER - - AlignFrame af = new AlignFrame(al); + af.viewport.setShowBoxes(view.getShowBoxes()); + af.viewBoxesMenuItem.setSelected(view.getShowBoxes()); + af.viewport.setShowText(view.getShowText()); + af.viewTextMenuItem.setSelected(view.getShowText()); - // af.changeColour() ); - ///////////////////////// - //LOAD GROUPS - if (jms.getJGroupCount() > 0) - { - JGroup[] groups = jms.getJGroup(); - - for (int i = 0; i < groups.length; i++) - { ColourSchemeI cs = null; - if (groups[i].getColour() != null) + if (view.getBgColour() != null) { - if (groups[i].getColour().startsWith("ucs")) - { - cs = GetUserColourScheme(jms, groups[i].getColour()); - } - else - { - cs = ColourSchemeProperty.getColour(al, - groups[i].getColour()); - } - - if (cs instanceof ResidueColourScheme) - { - ( (ResidueColourScheme) cs).setThreshold(groups[i].getPidThreshold()); - } - else if (cs instanceof ScoreColourScheme) - { - ( (ScoreColourScheme) cs).setThreshold(groups[i].getPidThreshold()); - } - } + if (view.getBgColour().startsWith("ucs")) + { + cs = GetUserColourScheme(jms, view.getBgColour()); + } + else + { + cs = ColourSchemeProperty.getColour(al, view.getBgColour()); + } - Vector seqs = new Vector(); - int[] ids = groups[i].getSeq(); + if (cs instanceof ConservationColourScheme) + { + ((ConservationColourScheme) cs).inc = view.getConsThreshold(); + } - for (int s = 0; s < ids.length; s++) - { - seqs.addElement( (jalview.datamodel.SequenceI) seqids.elementAt( - ids[s])); + if (cs instanceof ResidueColourScheme) + { + ((ResidueColourScheme) cs).setThreshold(view.getPidThreshold()); + } + else if (cs instanceof ScoreColourScheme) + { + ((ScoreColourScheme) cs).setThreshold(view.getPidThreshold()); + } } - jalview.datamodel.SequenceGroup sg = new jalview.datamodel. - SequenceGroup(seqs, groups[i].getName(), - cs, groups[i].getDisplayBoxes(), - groups[i].getDisplayText(), groups[i].getColourText(), - groups[i].getStart(), groups[i].getEnd()); + af.viewport.setGlobalColourScheme(cs); - sg.setOutlineColour(new java.awt.Color( - groups[i].getOutlineColour())); + af.viewport.setColourAppliesToAllGroups(false); + af.changeColour(af.viewport.getGlobalColourScheme()); + af.viewport.setColourAppliesToAllGroups(true); - - if (groups[i].getConsThreshold() != 0) + if (view.getShowSequenceFeatures()) { - jalview.analysis.Conservation c = new jalview.analysis.Conservation( - "All", - ResidueProperties.propHash, 3, sg.sequences, 0, - sg.getWidth() - 1); - c.calculate(); - c.verdict(false, 25); - cs = new ConservationColourScheme(c, cs); - sg.cs = cs; + af.viewport.showSequenceFeatures = true; + af.sequenceFeatures.setSelected(true); + new SequenceFeatureFetcher(al, af.alignPanel); + al.featuresAdded = true; } - al.addGroup(sg); - } - } - - Desktop.addInternalFrame(af, view.getTitle(), - AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - af.setBounds(view.getXpos(), view.getYpos(), view.getWidth(), - view.getHeight()); - af.viewport.setStartRes(view.getStartRes()); - af.viewport.setStartSeq(view.getStartSeq()); - af.viewport.showConservation = view.getShowConservation(); - af.viewport.showQuality = view.getShowQuality(); - af.viewport.showIdentity = view.getShowIdentity(); - af.viewport.setAbovePIDThreshold(view.getPidSelected()); - af.abovePIDThreshold.setSelected(view.getPidSelected()); - af.viewport.setColourText(view.getShowColourText()); - af.colourTextMenuItem.setSelected(view.getShowColourText()); - af.viewport.setConservationSelected(view.getConservationSelected()); - af.conservationMenuItem.setSelected(view.getConservationSelected()); - - af.viewport.setShowFullId(view.getShowFullId()); - af.fullSeqId.setSelected(view.getShowFullId()); - - af.viewport.setFont(new java.awt.Font(view.getFontName(), - view.getFontStyle(), view.getFontSize())); - af.alignPanel.fontChanged(); - - af.viewport.setRenderGaps(view.getRenderGaps()); - af.renderGapsMenuItem.setSelected(view.getRenderGaps()); - - af.viewport.setWrapAlignment(view.getWrapAlignment()); - af.wrapMenuItem.setSelected(view.getWrapAlignment()); - - if (view.getWrapAlignment()) - { - af.alignPanel.setWrapAlignment(view.getWrapAlignment()); - } - else - { - af.annotationPanelMenuItem.setState(view.getShowAnnotation()); - af.viewport.setShowAnnotation(view.getShowAnnotation()); - af.alignPanel.setAnnotationVisible(view.getShowAnnotation()); - } - - af.viewport.setShowBoxes(view.getShowBoxes()); - af.viewBoxesMenuItem.setSelected(view.getShowBoxes()); - af.viewport.setShowText(view.getShowText()); - af.viewTextMenuItem.setSelected(view.getShowText()); - - ColourSchemeI cs = null; - - if (view.getBgColour() != null) - { - if (view.getBgColour().startsWith("ucs")) - { - cs = GetUserColourScheme(jms, view.getBgColour()); - } - else - { - cs = ColourSchemeProperty.getColour(al, view.getBgColour()); - } - - if (cs instanceof ConservationColourScheme) - { - ( (ConservationColourScheme) cs).inc = view.getConsThreshold(); - } - - if (cs instanceof ResidueColourScheme) - { - ( (ResidueColourScheme) cs).setThreshold(view.getPidThreshold()); - } - else if (cs instanceof ScoreColourScheme) - { - ( (ScoreColourScheme) cs).setThreshold(view.getPidThreshold()); - } - } - - af.viewport.setGlobalColourScheme(cs); - - af.viewport.setColourAppliesToAllGroups(false); - af.changeColour(af.viewport.getGlobalColourScheme()); - af.viewport.setColourAppliesToAllGroups(true); - - if (view.getShowSequenceFeatures()) - { - af.viewport.showSequenceFeatures = true; - af.sequenceFeatures.setSelected(true); - new SequenceFeatureFetcher(al, af.alignPanel); - al.featuresAdded = true; - } - - //LOAD TREES - /////////////////////////////////////// - if (jms.getTreeCount() > 0) - { - try - { - for(int t = 0; t 0) { - Tree tree = jms.getTree(t); - - TreePanel tp = af.ShowNewickTree(new jalview.io.NewickFile( - tree.getNewick()), tree.getTitle()); - - tp.setBounds( tree.getXpos(), - tree.getYpos(), - tree.getWidth(), - tree.getHeight()); - - tp.fitToWindow.setState(tree.getFitToWindow()); - tp.fitToWindow_actionPerformed(null); - tp.treeCanvas.fontSize = tree.getFontSize(); - tp.fontSize.setText("Font Size - "+tree.getFontSize()); - tp.placeholdersMenu.setState(tree.getMarkUnlinked()); - tp.placeholdersMenu_actionPerformed(null); - tp.bootstrapMenu.setState(tree.getShowBootstrap()); - tp.bootstrapMenu_actionPerformed(null); - tp.distanceMenu.setState(tree.getShowDistances()); - tp.distanceMenu_actionPerformed(null); - tp.treeCanvas.threshold = tree.getThreshold(); - if(tree.getCurrentTree()); - af.viewport.setCurrentTree(tp.getTree()); + try + { + for (int t = 0; t < jms.getTreeCount(); t++) + { + Tree tree = jms.getTree(t); + + TreePanel tp = af.ShowNewickTree(new jalview.io.NewickFile( + tree.getNewick()), tree.getTitle()); + + tp.setBounds(tree.getXpos(), tree.getYpos(), + tree.getWidth(), tree.getHeight()); + + tp.fitToWindow.setState(tree.getFitToWindow()); + tp.fitToWindow_actionPerformed(null); + tp.treeCanvas.fontSize = tree.getFontSize(); + tp.fontSize.setText("Font Size - " + tree.getFontSize()); + tp.placeholdersMenu.setState(tree.getMarkUnlinked()); + tp.placeholdersMenu_actionPerformed(null); + tp.bootstrapMenu.setState(tree.getShowBootstrap()); + tp.bootstrapMenu_actionPerformed(null); + tp.distanceMenu.setState(tree.getShowDistances()); + tp.distanceMenu_actionPerformed(null); + tp.treeCanvas.threshold = tree.getThreshold(); + + if (tree.getCurrentTree()) + af.viewport.setCurrentTree(tp.getTree()); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - } - catch (Exception ex) - { - ex.printStackTrace(); - } + return af; } - } } diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 244d884..62f8ca9 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -21,305 +21,346 @@ package jalview.gui; import java.awt.*; import java.awt.event.*; import java.awt.image.*; + import javax.swing.*; -public class OverviewPanel - extends JPanel implements Runnable + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class OverviewPanel extends JPanel implements Runnable { - BufferedImage miniMe; - AlignViewport av; - AlignmentPanel ap; - float scalew = 1f; - float scaleh = 1f; - int width; - int sequencesHeight; - int graphHeight = 30; - int boxX = -1; - int boxY = -1; - int boxWidth = -1; - int boxHeight = -1; - boolean resizing = false; - - public OverviewPanel(AlignmentPanel ap) - { - this.av = ap.av; - this.ap = ap; - setLayout(null); - - // scale the initial size of overviewpanel to shape of alignment - float initialScale = (float) av.alignment.getWidth() / - (float) av.alignment.getHeight(); - - if (av.alignment.getWidth() > av.alignment.getHeight()) + BufferedImage miniMe; + AlignViewport av; + AlignmentPanel ap; + float scalew = 1f; + float scaleh = 1f; + int width; + int sequencesHeight; + int graphHeight = 30; + int boxX = -1; + int boxY = -1; + int boxWidth = -1; + int boxHeight = -1; + boolean resizing = false; + + /** + * Creates a new OverviewPanel object. + * + * @param ap DOCUMENT ME! + */ + public OverviewPanel(AlignmentPanel ap) { - // wider - width = 400; - sequencesHeight = (int) (400f / initialScale); - } - else - { - // taller - width = (int) (400f * initialScale); - sequencesHeight = 300; - - if (width < 120) - { - width = 120; - } - } + this.av = ap.av; + this.ap = ap; + setLayout(null); - addComponentListener(new ComponentAdapter() - { - public void componentResized(ComponentEvent evt) - { - if ( (getWidth() != width) || - (getHeight() != (sequencesHeight + graphHeight))) + // scale the initial size of overviewpanel to shape of alignment + float initialScale = (float) av.alignment.getWidth() / (float) av.alignment.getHeight(); + + if (av.alignment.getWidth() > av.alignment.getHeight()) { - updateOverviewImage(); + // wider + width = 400; + sequencesHeight = (int) (400f / initialScale); + } + else + { + // taller + width = (int) (400f * initialScale); + sequencesHeight = 300; + + if (width < 120) + { + width = 120; + } } - } - }); - - addMouseMotionListener(new MouseMotionAdapter() - { - public void mouseDragged(MouseEvent evt) - { - doMouseDragged(evt); - } - }); - addMouseListener(new MouseAdapter() - { - public void mousePressed(MouseEvent evt) - { - doMousePressed(evt); - } - - public void mouseReleased(MouseEvent evt) - { - doMouseReleased(evt); - } - }); - - updateOverviewImage(); - } - - public void doMousePressed(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - - checkValid(); - repaint(); - } - - public void doMouseReleased(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - - if (!resizing) - { - ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); + addComponentListener(new ComponentAdapter() + { + public void componentResized(ComponentEvent evt) + { + if ((getWidth() != width) || + (getHeight() != (sequencesHeight + graphHeight))) + { + updateOverviewImage(); + } + } + }); + + addMouseMotionListener(new MouseMotionAdapter() + { + public void mouseDragged(MouseEvent evt) + { + doMouseDragged(evt); + } + }); + + addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent evt) + { + doMousePressed(evt); + } + + public void mouseReleased(MouseEvent evt) + { + doMouseReleased(evt); + } + }); + + updateOverviewImage(); } - } - public void doMouseDragged(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - - if (!resizing) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMousePressed(MouseEvent evt) { - ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); - } - } + boxX = evt.getX(); + boxY = evt.getY(); - void checkValid() - { - if (boxY < 0) - { - boxY = 0; + checkValid(); + repaint(); } - if (boxY > (sequencesHeight - boxHeight)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseReleased(MouseEvent evt) { - boxY = sequencesHeight - boxHeight + 1; - } + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); - if (boxX < 0) - { - boxX = 0; + if (!resizing) + { + ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); + } } - if (boxX > (width - boxWidth)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseDragged(MouseEvent evt) { - boxX = width - boxWidth; - } - } + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); - public void updateOverviewImage() - { - if (resizing) - { - return; + if (!resizing) + { + ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); + } } - resizing = true; - - Thread thread = new Thread(this); - thread.start(); - repaint(); - } + /** + * DOCUMENT ME! + */ + void checkValid() + { + if (boxY < 0) + { + boxY = 0; + } - public void run() - { - miniMe = null; + if (boxY > (sequencesHeight - boxHeight)) + { + boxY = sequencesHeight - boxHeight + 1; + } - int alwidth = av.alignment.getWidth(); - int alheight = av.alignment.getHeight(); + if (boxX < 0) + { + boxX = 0; + } - if ( (getWidth() > 0) && (getHeight() > 0)) - { - width = getWidth(); - sequencesHeight = getHeight() - graphHeight; + if (boxX > (width - boxWidth)) + { + boxX = width - boxWidth; + } } - setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); - - int fullsizeWidth = alwidth * av.getCharWidth(); - int fullsizeHeight = alheight * av.getCharHeight(); + /** + * DOCUMENT ME! + */ + public void updateOverviewImage() + { + if (resizing) + { + return; + } - scalew = (float) width / (float) fullsizeWidth; - scaleh = (float) sequencesHeight / (float) fullsizeHeight; + resizing = true; - miniMe = new BufferedImage(width, sequencesHeight + graphHeight, - BufferedImage.TYPE_INT_RGB); + Thread thread = new Thread(this); + thread.start(); + repaint(); + } - Graphics mg = miniMe.getGraphics(); - BufferedImage consensus = new BufferedImage(fullsizeWidth, 60, - BufferedImage.TYPE_3BYTE_BGR); - Graphics g = consensus.getGraphics(); - ap.annotationPanel.drawGraph(g, av.conservation, fullsizeWidth, 60); - mg.drawImage(consensus, 0, sequencesHeight, width, - sequencesHeight + graphHeight, 0, 0, fullsizeWidth, 60, this); + /** + * DOCUMENT ME! + */ + public void run() + { + miniMe = null; - boolean oldRenderGaps = av.renderGaps; + int alwidth = av.alignment.getWidth(); + int alheight = av.alignment.getHeight(); - try - { - // We'll have to draw the full size alignment in chunks, as an image of the - // whole alignment requires too much memory - // Max size depends on the font size, the following is a - // guess at a size which works - int maxSize = 2000 / av.getFont().getSize(); - BufferedImage block; - int blockx = 0; - int blocky = 0; - int blockw = 0; - int blockh = 0; - int eRes = 0; - int eSeq = 0; - - av.setRenderGaps(false); - - for (int sRes = 0, chunkx = 0; sRes < alwidth; - sRes += maxSize, chunkx++) - { - eSeq = 0; - eRes += maxSize; - - if (eRes > alwidth) + if ((getWidth() > 0) && (getHeight() > 0)) { - eRes = alwidth; + width = getWidth(); + sequencesHeight = getHeight() - graphHeight; } - for (int sSeq = 0, chunky = 0; sSeq < alheight; - sSeq += maxSize, chunky++) - { - eSeq += maxSize; + setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); - if (eSeq > alheight) - { - eSeq = alheight; - } + int fullsizeWidth = alwidth * av.getCharWidth(); + int fullsizeHeight = alheight * av.getCharHeight(); - blocky = 0; - blockx = (int) ( (float) sRes / (float) alwidth * width); + scalew = (float) width / (float) fullsizeWidth; + scaleh = (float) sequencesHeight / (float) fullsizeHeight; - block = new BufferedImage( (eRes - sRes) * av.charWidth, - (eSeq - sSeq) * av.charHeight, - BufferedImage.TYPE_3BYTE_BGR); - g = block.getGraphics(); + miniMe = new BufferedImage(width, sequencesHeight + graphHeight, + BufferedImage.TYPE_INT_RGB); - ap.seqPanel.seqCanvas.drawPanel(g, sRes, eRes, sSeq, eSeq, - sRes, sSeq, 0); + Graphics mg = miniMe.getGraphics(); + BufferedImage consensus = new BufferedImage(fullsizeWidth, 60, + BufferedImage.TYPE_3BYTE_BGR); + Graphics g = consensus.getGraphics(); + ap.annotationPanel.drawGraph(g, av.conservation, fullsizeWidth, 60); + mg.drawImage(consensus, 0, sequencesHeight, width, + sequencesHeight + graphHeight, 0, 0, fullsizeWidth, 60, this); - blockh = (int) ( (float) (eSeq - sSeq) / (float) alheight * - sequencesHeight) + - 1; - blockw = (int) ( (float) (eRes - sRes) / (float) alwidth * width) + - 1; + boolean oldRenderGaps = av.renderGaps; - blocky += (int) ( (float) sSeq / (float) alheight * sequencesHeight); + try + { + // We'll have to draw the full size alignment in chunks, as an image of the + // whole alignment requires too much memory + // Max size depends on the font size, the following is a + // guess at a size which works + int maxSize = 2000 / av.getFont().getSize(); + BufferedImage block; + int blockx = 0; + int blocky = 0; + int blockw = 0; + int blockh = 0; + int eRes = 0; + int eSeq = 0; + + av.setRenderGaps(false); + + for (int sRes = 0, chunkx = 0; sRes < alwidth; + sRes += maxSize, chunkx++) + { + eSeq = 0; + eRes += maxSize; + + if (eRes > alwidth) + { + eRes = alwidth; + } + + for (int sSeq = 0, chunky = 0; sSeq < alheight; + sSeq += maxSize, chunky++) + { + eSeq += maxSize; + + if (eSeq > alheight) + { + eSeq = alheight; + } + + blocky = 0; + blockx = (int) ((float) sRes / (float) alwidth * width); + + block = new BufferedImage((eRes - sRes) * av.charWidth, + (eSeq - sSeq) * av.charHeight, + BufferedImage.TYPE_3BYTE_BGR); + g = block.getGraphics(); + + ap.seqPanel.seqCanvas.drawPanel(g, sRes, eRes, sSeq, eSeq, + sRes, sSeq, 0); + + blockh = (int) ((float) (eSeq - sSeq) / (float) alheight * sequencesHeight) + + 1; + blockw = (int) ((float) (eRes - sRes) / (float) alwidth * width) + + 1; + + blocky += (int) ((float) sSeq / (float) alheight * sequencesHeight); + + mg.drawImage(block, blockx, blocky, blockx + blockw, + blocky + blockh, 0, 0, block.getWidth(), + block.getHeight(), this); + + block = null; + } + } + } + catch (OutOfMemoryError error) + { + System.err.println( + "Out of memory when trying to calculate the overview window image!"); + } - mg.drawImage(block, blockx, blocky, blockx + blockw, - blocky + blockh, 0, 0, block.getWidth(), - block.getHeight(), this); + av.setRenderGaps(oldRenderGaps); + resizing = false; - block = null; - } - } - } - catch (OutOfMemoryError error) - { - System.err.println( - "Out of memory when trying to calculate the overview window image!"); + setBoxPosition(); } - av.setRenderGaps(oldRenderGaps); - resizing = false; - - setBoxPosition(); - } - - public void setBoxPosition() - { - boxX = (int) (av.getStartRes() * av.getCharWidth() * scalew); - boxY = (int) (av.getStartSeq() * av.getCharHeight() * scaleh); - boxWidth = (int) ( (av.getEndRes() - av.getStartRes() + 1) * - av.getCharWidth() * scalew); - boxHeight = (int) (av.getEndSeq() * av.getCharHeight() * scaleh) - - boxY; - repaint(); - } - - public void paintComponent(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - g.setColor(Color.black); - - if (resizing) + /** + * DOCUMENT ME! + */ + public void setBoxPosition() { - g.setFont(new Font("Verdana", Font.BOLD, 15)); - g.drawString("Recalculating", 5, sequencesHeight / 2); - g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20); + boxX = (int) (av.getStartRes() * av.getCharWidth() * scalew); + boxY = (int) (av.getStartSeq() * av.getCharHeight() * scaleh); + boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth() * scalew); + boxHeight = (int) (av.getEndSeq() * av.getCharHeight() * scaleh) - + boxY; + repaint(); } - else + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - if (miniMe != null) - { - g.drawImage(miniMe, 0, 0, this); - } - - g.setColor(Color.red); - g.drawRect(boxX, boxY, boxWidth, boxHeight); - g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.black); + + if (resizing) + { + g.setFont(new Font("Verdana", Font.BOLD, 15)); + g.drawString("Recalculating", 5, sequencesHeight / 2); + g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20); + } + else + { + if (miniMe != null) + { + g.drawImage(miniMe, 0, 0, this); + } + + g.setColor(Color.red); + g.drawRect(boxX, boxY, boxWidth, boxHeight); + g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); + } } - } } diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index ebde9cb..7bda65a 100755 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -18,133 +18,168 @@ */ package jalview.gui; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - import jalview.analysis.*; + import jalview.datamodel.*; -import jalview.jbgui.*; -public class PCAPanel - extends GPCAPanel implements Runnable -{ - PCA pca; - int top; - RotatableCanvas rc; - AlignViewport av; +import jalview.jbgui.*; - public PCAPanel(AlignViewport av, SequenceI[] s) - { - this.av = av; +import java.awt.*; +import java.awt.event.*; - if ( (av.getSelectionGroup() != null) && - (av.getSelectionGroup().getSize() > 3)) - { - s = new Sequence[av.getSelectionGroup().getSize()]; +import java.util.*; - for (int i = 0; i < s.length; i++) - { - s[i] = av.getSelectionGroup().getSequenceAt(i); - } - } - if (s == null) +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class PCAPanel extends GPCAPanel implements Runnable +{ + PCA pca; + int top; + RotatableCanvas rc; + AlignViewport av; + + /** + * Creates a new PCAPanel object. + * + * @param av DOCUMENT ME! + * @param s DOCUMENT ME! + */ + public PCAPanel(AlignViewport av, SequenceI[] s) { - s = new Sequence[av.getAlignment().getHeight()]; - - for (int i = 0; i < av.getAlignment().getHeight(); i++) - { - s[i] = av.getAlignment().getSequenceAt(i); - } + this.av = av; + + if ((av.getSelectionGroup() != null) && + (av.getSelectionGroup().getSize() > 3)) + { + s = new Sequence[av.getSelectionGroup().getSize()]; + + for (int i = 0; i < s.length; i++) + { + s[i] = av.getSelectionGroup().getSequenceAt(i); + } + } + + if (s == null) + { + s = new Sequence[av.getAlignment().getHeight()]; + + for (int i = 0; i < av.getAlignment().getHeight(); i++) + { + s[i] = av.getAlignment().getSequenceAt(i); + } + } + + //////////////////////This part was done in PCATHread originally. Is it too slow??? + pca = new PCA(s); + pca.run(); + + // Now find the component coordinates + int ii = 0; + + while ((ii < s.length) && (s[ii] != null)) + { + ii++; + } + + double[][] comps = new double[ii][ii]; + + for (int i = 0; i < ii; i++) + { + if (pca.getEigenvalue(i) > 1e-4) + { + comps[i] = pca.component(i); + } + } + + ////////////////// + xCombobox.setSelectedIndex(0); + yCombobox.setSelectedIndex(1); + zCombobox.setSelectedIndex(2); + + top = pca.getM().rows - 1; + + Vector points = new Vector(); + float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100); + + for (int i = 0; i < pca.getM().rows; i++) + { + SequencePoint sp = new SequencePoint(s[i], scores[i]); + points.addElement(sp); + } + + rc = new RotatableCanvas(av, points, pca.getM().rows); + + //rc.printPoints(); + add(rc, BorderLayout.CENTER); } - //////////////////////This part was done in PCATHread originally. Is it too slow??? - pca = new PCA(s); - pca.run(); - - // Now find the component coordinates - int ii = 0; - - while ( (ii < s.length) && (s[ii] != null)) + /** + * DOCUMENT ME! + */ + public void run() { - ii++; + // do stuff } - double[][] comps = new double[ii][ii]; - - for (int i = 0; i < ii; i++) + /** + * DOCUMENT ME! + */ + void doDimensionChange() { - if (pca.getEigenvalue(i) > 1e-4) - { - comps[i] = pca.component(i); - } + if (top == 0) + { + return; + } + + int dim1 = top - xCombobox.getSelectedIndex(); + int dim2 = top - yCombobox.getSelectedIndex(); + int dim3 = top - zCombobox.getSelectedIndex(); + + float[][] scores = pca.getComponents(dim1, dim2, dim3, 100); + + for (int i = 0; i < pca.getM().rows; i++) + { + ((SequencePoint) rc.points.elementAt(i)).coord = scores[i]; + } + + rc.img = null; + rc.rotmat.setIdentity(); + rc.initAxes(); + rc.paint(rc.getGraphics()); } - ////////////////// - xCombobox.setSelectedIndex(0); - yCombobox.setSelectedIndex(1); - zCombobox.setSelectedIndex(2); - - top = pca.getM().rows - 1; - - Vector points = new Vector(); - float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100); - - for (int i = 0; i < pca.getM().rows; i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void xCombobox_actionPerformed(ActionEvent e) { - SequencePoint sp = new SequencePoint(s[i], scores[i]); - points.addElement(sp); + doDimensionChange(); } - rc = new RotatableCanvas(av, points, pca.getM().rows); - - //rc.printPoints(); - add(rc, BorderLayout.CENTER); - } - - public void run() - { - // do stuff - } - - void doDimensionChange() - { - if (top == 0) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void yCombobox_actionPerformed(ActionEvent e) { - return; + doDimensionChange(); } - int dim1 = top - xCombobox.getSelectedIndex(); - int dim2 = top - yCombobox.getSelectedIndex(); - int dim3 = top - zCombobox.getSelectedIndex(); - - float[][] scores = pca.getComponents(dim1, dim2, dim3, 100); - - for (int i = 0; i < pca.getM().rows; i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void zCombobox_actionPerformed(ActionEvent e) { - ( (SequencePoint) rc.points.elementAt(i)).coord = scores[i]; + doDimensionChange(); } - - rc.img = null; - rc.rotmat.setIdentity(); - rc.initAxes(); - rc.paint(rc.getGraphics()); - } - - protected void xCombobox_actionPerformed(ActionEvent e) - { - doDimensionChange(); - } - - protected void yCombobox_actionPerformed(ActionEvent e) - { - doDimensionChange(); - } - - protected void zCombobox_actionPerformed(ActionEvent e) - { - doDimensionChange(); - } } diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index e59ecd9..0fe4b85 100755 --- a/src/jalview/gui/PaintRefresher.java +++ b/src/jalview/gui/PaintRefresher.java @@ -16,53 +16,82 @@ * 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 jalview.datamodel.*; + import java.awt.*; + import java.util.*; -import jalview.datamodel.*; + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class PaintRefresher { - static Hashtable components = new Hashtable(); + static Hashtable components = new Hashtable(); - public static void Register(Component comp, AlignmentI al) - { - if(components.containsKey(al)) + /** + * DOCUMENT ME! + * + * @param comp DOCUMENT ME! + * @param al DOCUMENT ME! + */ + public static void Register(Component comp, AlignmentI al) { - Vector comps = (Vector)components.get(al); - comps.addElement(comp); + if (components.containsKey(al)) + { + Vector comps = (Vector) components.get(al); + comps.addElement(comp); + } + else + { + Vector vcoms = new Vector(); + vcoms.addElement(comp); + components.put(al, vcoms); + } } - else + + /** + * DOCUMENT ME! + * + * @param al DOCUMENT ME! + */ + public static void Refresh(AlignmentI al) { - Vector vcoms = new Vector(); - vcoms.addElement(comp); - components.put(al, vcoms); + Refresh(null, al); } - } - - public static void Refresh(AlignmentI al) - { - Refresh(null, al); - } - public static void Refresh(Component c, AlignmentI al) - { - Component temp; - Vector coms = (Vector)components.get(al); - Enumeration e = coms.elements(); - while( e.hasMoreElements() ) + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * @param al DOCUMENT ME! + */ + public static void Refresh(Component c, AlignmentI al) { - temp = (Component)e.nextElement(); + Component temp; + Vector coms = (Vector) components.get(al); + Enumeration e = coms.elements(); - if(!temp.isValid()) - coms.removeElement( temp ); - else if( temp == c ) - continue; + while (e.hasMoreElements()) + { + temp = (Component) e.nextElement(); - temp.repaint(); - } - - } + if (!temp.isValid()) + { + coms.removeElement(temp); + } + else if (temp == c) + { + continue; + } + temp.repaint(); + } + } } diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index 69789b9..6509063 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -18,101 +18,118 @@ */ package jalview.gui; -import java.util.*; - -import java.awt.event.*; - import jalview.analysis.*; + import jalview.datamodel.*; + import jalview.jbgui.*; -public class PairwiseAlignPanel - extends GPairwiseAlignPanel -{ - Vector sequences = new Vector(); - AlignViewport av; +import java.awt.event.*; - public PairwiseAlignPanel(AlignViewport av) - { - super(); - this.av = av; +import java.util.*; - Vector selsubset = new Vector(); - for (int i = 0, j = av.getSelectionGroup().getSize(); i < j; i++) +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class PairwiseAlignPanel extends GPairwiseAlignPanel +{ + Vector sequences = new Vector(); + AlignViewport av; + + /** + * Creates a new PairwiseAlignPanel object. + * + * @param av DOCUMENT ME! + */ + public PairwiseAlignPanel(AlignViewport av) { - if (av.getAlignment().getSequences().contains(av.getSelectionGroup() - .getSequenceAt(i))) - { - selsubset.add(av.getSelectionGroup().getSequenceAt(i)); - } - } - - float[][] scores = new float[selsubset.size()][selsubset.size()]; - double totscore = 0; - int count = selsubset.size(); + super(); + this.av = av; - int acount = 0; + Vector selsubset = new Vector(); - for (int i = 1; i < count; i++) - { - for (int j = 0; j < i; j++) - { - acount++; - - AlignSeq as = new AlignSeq( (SequenceI) selsubset.elementAt(i), - (SequenceI) selsubset.elementAt(j), "pep"); - as.calcScoreMatrix(); - as.traceAlignment(); - as.printAlignment(); - scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length; - totscore = totscore + scores[i][j]; - - textarea.append(as.getOutput()); - sequences.add(new Sequence(as.getS1().getName(), as.getAStr1())); - sequences.add(new Sequence(as.getS2().getName(), as.getAStr2())); - } - } - - if (count > 2) - { - System.out.println( - "Pairwise alignment scaled similarity score matrix\n"); + for (int i = 0, j = av.getSelectionGroup().getSize(); i < j; i++) + { + if (av.getAlignment().getSequences().contains(av.getSelectionGroup() + .getSequenceAt(i))) + { + selsubset.add(av.getSelectionGroup().getSequenceAt(i)); + } + } - for (int i = 0; i < count; i++) - { - jalview.util.Format.print(System.out, "%s \n", - ("" + i) + " " + - ( (SequenceI) selsubset.elementAt(i)).getName()); - } + float[][] scores = new float[selsubset.size()][selsubset.size()]; + double totscore = 0; + int count = selsubset.size(); - System.out.println("\n"); + int acount = 0; - for (int i = 0; i < count; i++) - { - for (int j = 0; j < i; j++) + for (int i = 1; i < count; i++) { - jalview.util.Format.print(System.out, "%7.3f", - scores[i][j] / totscore); + for (int j = 0; j < i; j++) + { + acount++; + + AlignSeq as = new AlignSeq((SequenceI) selsubset.elementAt(i), + (SequenceI) selsubset.elementAt(j), "pep"); + as.calcScoreMatrix(); + as.traceAlignment(); + as.printAlignment(); + scores[i][j] = (float) as.getMaxScore() / (float) as.getASeq1().length; + totscore = totscore + scores[i][j]; + + textarea.append(as.getOutput()); + sequences.add(new Sequence(as.getS1().getName(), as.getAStr1())); + sequences.add(new Sequence(as.getS2().getName(), as.getAStr2())); + } } - } - System.out.println("\n"); + if (count > 2) + { + System.out.println( + "Pairwise alignment scaled similarity score matrix\n"); + + for (int i = 0; i < count; i++) + { + jalview.util.Format.print(System.out, "%s \n", + ("" + i) + " " + + ((SequenceI) selsubset.elementAt(i)).getName()); + } + + System.out.println("\n"); + + for (int i = 0; i < count; i++) + { + for (int j = 0; j < i; j++) + { + jalview.util.Format.print(System.out, "%7.3f", + scores[i][j] / totscore); + } + } + + System.out.println("\n"); + } } - } - - protected void viewInEditorButton_actionPerformed(ActionEvent e) - { - Sequence[] seq = new Sequence[sequences.size()]; - for (int i = 0; i < sequences.size(); i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void viewInEditorButton_actionPerformed(ActionEvent e) { - seq[i] = (Sequence) sequences.elementAt(i); - } + Sequence[] seq = new Sequence[sequences.size()]; - AlignFrame af = new AlignFrame(new Alignment(seq)); - Desktop.addInternalFrame(af, "Pairwise Aligned Sequences", - AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - } + for (int i = 0; i < sequences.size(); i++) + { + seq[i] = (Sequence) sequences.elementAt(i); + } + + AlignFrame af = new AlignFrame(new Alignment(seq)); + Desktop.addInternalFrame(af, "Pairwise Aligned Sequences", + AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); + } } diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 828bbe8..5ff9ad9 100755 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -18,689 +18,842 @@ */ package jalview.gui; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - import MCview.*; + import jalview.analysis.*; + import jalview.datamodel.*; + import jalview.io.*; + import jalview.schemes.*; -public class PopupMenu - extends JPopupMenu +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class PopupMenu extends JPopupMenu { - JMenu groupMenu = new JMenu(); - JMenuItem groupName = new JMenuItem(); - protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem hydrophobicityColour = new - JRadioButtonMenuItem(); - protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); - protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); - JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - AlignmentPanel ap; - JMenu sequenceMenu = new JMenu(); - JMenuItem sequenceName = new JMenuItem(); - Sequence sequence; - JMenuItem unGroupMenuItem = new JMenuItem(); - JMenuItem pdbMenuItem = new JMenuItem(); - JMenuItem outline = new JMenuItem(); - JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem(); - JMenu colourMenu = new JMenu(); - JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem(); - JCheckBoxMenuItem showText = new JCheckBoxMenuItem(); - JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem(); - - public PopupMenu(AlignmentPanel ap, Sequence seq) - { - /////////////////////////////////////////////////////////// - // If this is activated from the sequence panel, the user may want to - // edit or annotate a particular residue. Therefore display the residue menu - // - // If from the IDPanel, we must display the sequence menu - ////////////////////////////////////////////////////////// - this.ap = ap; - sequence = seq; - - ButtonGroup colours = new ButtonGroup(); - colours.add(noColourmenuItem); - colours.add(clustalColour); - colours.add(zappoColour); - colours.add(taylorColour); - colours.add(hydrophobicityColour); - colours.add(helixColour); - colours.add(strandColour); - colours.add(turnColour); - colours.add(buriedColour); - colours.add(abovePIDColour); - colours.add(userDefinedColour); - colours.add(PIDColour); - colours.add(BLOSUM62Colour); - - try - { - jbInit(); + JMenu groupMenu = new JMenu(); + JMenuItem groupName = new JMenuItem(); + protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); + protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem(); + protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); + JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); + protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); + AlignmentPanel ap; + JMenu sequenceMenu = new JMenu(); + JMenuItem sequenceName = new JMenuItem(); + Sequence sequence; + JMenuItem unGroupMenuItem = new JMenuItem(); + JMenuItem pdbMenuItem = new JMenuItem(); + JMenuItem outline = new JMenuItem(); + JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem(); + JMenu colourMenu = new JMenu(); + JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem(); + JCheckBoxMenuItem showText = new JCheckBoxMenuItem(); + JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem(); + + /** + * Creates a new PopupMenu object. + * + * @param ap DOCUMENT ME! + * @param seq DOCUMENT ME! + */ + public PopupMenu(AlignmentPanel ap, Sequence seq) + { + /////////////////////////////////////////////////////////// + // If this is activated from the sequence panel, the user may want to + // edit or annotate a particular residue. Therefore display the residue menu + // + // If from the IDPanel, we must display the sequence menu + ////////////////////////////////////////////////////////// + this.ap = ap; + sequence = seq; + + ButtonGroup colours = new ButtonGroup(); + colours.add(noColourmenuItem); + colours.add(clustalColour); + colours.add(zappoColour); + colours.add(taylorColour); + colours.add(hydrophobicityColour); + colours.add(helixColour); + colours.add(strandColour); + colours.add(turnColour); + colours.add(buriedColour); + colours.add(abovePIDColour); + colours.add(userDefinedColour); + colours.add(PIDColour); + colours.add(BLOSUM62Colour); + + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + if ((seq == null) || (seq.getPDBId() == null)) + { + pdbMenuItem.setVisible(false); + } + + SequenceGroup sg = ap.av.getSelectionGroup(); + + if (sg != null) + { + groupName.setText(sg.getName()); + + if (sg.cs instanceof ZappoColourScheme) + { + zappoColour.setSelected(true); + } + else if (sg.cs instanceof TaylorColourScheme) + { + taylorColour.setSelected(true); + } + else if (sg.cs instanceof PIDColourScheme) + { + PIDColour.setSelected(true); + } + else if (sg.cs instanceof Blosum62ColourScheme) + { + BLOSUM62Colour.setSelected(true); + } + else if (sg.cs instanceof UserColourScheme) + { + userDefinedColour.setSelected(true); + } + else if (sg.cs instanceof HydrophobicColourScheme) + { + hydrophobicityColour.setSelected(true); + } + else if (sg.cs instanceof HelixColourScheme) + { + helixColour.setSelected(true); + } + else if (sg.cs instanceof StrandColourScheme) + { + strandColour.setSelected(true); + } + else if (sg.cs instanceof TurnColourScheme) + { + turnColour.setSelected(true); + } + else if (sg.cs instanceof BuriedColourScheme) + { + buriedColour.setSelected(true); + } + else if (sg.cs instanceof ClustalxColourScheme) + { + clustalColour.setSelected(true); + } + else + { + noColourmenuItem.setSelected(true); + } + + if (sg.cs instanceof ConservationColourScheme) + { + conservationMenuItem.setSelected(true); + } + + showText.setSelected(sg.getDisplayText()); + showColourText.setSelected(sg.getColourText()); + showBoxes.setSelected(sg.getDisplayBoxes()); + } + + if (!ap.av.alignment.getGroups().contains(sg)) + { + unGroupMenuItem.setVisible(false); + } + else + { + groupMenu.insertSeparator(3); + } + + if (seq == null) + { + sequenceMenu.setVisible(false); + } } - catch (Exception e) - { - e.printStackTrace(); + + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { + groupMenu.setText("Group"); + groupMenu.setText("Define"); + groupName.setText("Name"); + groupName.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + groupName_actionPerformed(e); + } + }); + sequenceMenu.setText("Sequence"); + sequenceName.setText("Edit name"); + sequenceName.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sequenceName_actionPerformed(e); + } + }); + PIDColour.setFocusPainted(false); + unGroupMenuItem.setText("Remove Group"); + unGroupMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + unGroupMenuItem_actionPerformed(e); + } + }); + pdbMenuItem.setText("View PDB structure"); + pdbMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + pdbMenuItem_actionPerformed(e); + } + }); + outline.setText("Border colour"); + outline.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + outline_actionPerformed(e); + } + }); + nucleotideMenuItem.setText("Nucleotide"); + nucleotideMenuItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + nucleotideMenuItem_actionPerformed(e); + } + }); + colourMenu.setText("Group Colour"); + showBoxes.setText("Boxes"); + showBoxes.setState(true); + showBoxes.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + showBoxes_actionPerformed(e); + } + }); + showText.setText("Text"); + showText.setState(true); + showText.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + showText_actionPerformed(e); + } + }); + showColourText.setText("Colour Text"); + showColourText.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + showColourText_actionPerformed(e); + } + }); + add(groupMenu); + add(sequenceMenu); + groupMenu.add(groupName); + groupMenu.addSeparator(); + groupMenu.add(unGroupMenuItem); + groupMenu.add(colourMenu); + groupMenu.addSeparator(); + groupMenu.add(showBoxes); + groupMenu.add(showText); + groupMenu.add(showColourText); + groupMenu.addSeparator(); + groupMenu.add(outline); + sequenceMenu.add(sequenceName); + sequenceMenu.add(pdbMenuItem); + colourMenu.add(noColourmenuItem); + colourMenu.add(clustalColour); + colourMenu.add(BLOSUM62Colour); + colourMenu.add(PIDColour); + colourMenu.add(zappoColour); + colourMenu.add(taylorColour); + colourMenu.add(hydrophobicityColour); + colourMenu.add(helixColour); + colourMenu.add(strandColour); + colourMenu.add(turnColour); + colourMenu.add(buriedColour); + colourMenu.add(nucleotideMenuItem); + colourMenu.add(userDefinedColour); + colourMenu.addSeparator(); + colourMenu.add(abovePIDColour); + colourMenu.add(conservationMenuItem); + noColourmenuItem.setText("None"); + noColourmenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + noColourmenuItem_actionPerformed(e); + } + }); + + clustalColour.setText("Clustalx colours"); + clustalColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + clustalColour_actionPerformed(e); + } + }); + zappoColour.setText("Zappo"); + zappoColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + zappoColour_actionPerformed(e); + } + }); + taylorColour.setText("Taylor"); + taylorColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + taylorColour_actionPerformed(e); + } + }); + hydrophobicityColour.setText("Hydrophobicity"); + hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + hydrophobicityColour_actionPerformed(e); + } + }); + helixColour.setText("Helix propensity"); + helixColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + helixColour_actionPerformed(e); + } + }); + strandColour.setText("Strand propensity"); + strandColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + strandColour_actionPerformed(e); + } + }); + turnColour.setText("Turn propensity"); + turnColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + turnColour_actionPerformed(e); + } + }); + buriedColour.setText("Buried Index"); + buriedColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + buriedColour_actionPerformed(e); + } + }); + abovePIDColour.setText("Above % Identity"); + abovePIDColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + abovePIDColour_actionPerformed(e); + } + }); + userDefinedColour.setText("User Defined"); + userDefinedColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + userDefinedColour_actionPerformed(e); + } + }); + PIDColour.setText("Percentage Identity"); + PIDColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + PIDColour_actionPerformed(e); + } + }); + BLOSUM62Colour.setText("BLOSUM62"); + BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + BLOSUM62Colour_actionPerformed(e); + } + }); + conservationMenuItem.setText("Conservation"); + conservationMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + conservationMenuItem_actionPerformed(e); + } + }); } - if(seq==null || seq.getPDBId()==null) - pdbMenuItem.setVisible(false); + /** + * DOCUMENT ME! + */ + void refresh() + { + SequenceGroup sg = getGroup(); + SuperGroup superG = ap.av.alignment.getSuperGroup(sg); - SequenceGroup sg = ap.av.getSelectionGroup(); + if (superG != null) + { + superG.setSuperGroupProperties(sg); + } - if (sg != null) - { - groupName.setText(sg.getName()); - - if (sg.cs instanceof ZappoColourScheme) - { - zappoColour.setSelected(true); - } - else if (sg.cs instanceof TaylorColourScheme) - { - taylorColour.setSelected(true); - } - else if (sg.cs instanceof PIDColourScheme) - { - PIDColour.setSelected(true); - } - else if (sg.cs instanceof Blosum62ColourScheme) - { - BLOSUM62Colour.setSelected(true); - } - else if (sg.cs instanceof UserColourScheme) - { - userDefinedColour.setSelected(true); - } - else if (sg.cs instanceof HydrophobicColourScheme) - { - hydrophobicityColour.setSelected(true); - } - else if (sg.cs instanceof HelixColourScheme) - { - helixColour.setSelected(true); - } - else if (sg.cs instanceof StrandColourScheme) - { - strandColour.setSelected(true); - } - else if (sg.cs instanceof TurnColourScheme) - { - turnColour.setSelected(true); - } - else if (sg.cs instanceof BuriedColourScheme) - { - buriedColour.setSelected(true); - } - else if (sg.cs instanceof ClustalxColourScheme) - { - clustalColour.setSelected(true); - } - else - { - noColourmenuItem.setSelected(true); - } - - if (sg.cs instanceof ConservationColourScheme) - { - conservationMenuItem.setSelected(true); - } - - showText.setSelected(sg.getDisplayText()); - showColourText.setSelected(sg.getColourText()); - showBoxes.setSelected(sg.getDisplayBoxes()); + ap.seqPanel.repaint(); } - if (!ap.av.alignment.getGroups().contains(sg)) - { - unGroupMenuItem.setVisible(false); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void clustalColour_actionPerformed(ActionEvent e) + { + SequenceGroup sg = getGroup(); + sg.cs = new ClustalxColourScheme(sg.sequences, + ap.av.alignment.getWidth()); + refresh(); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void zappoColour_actionPerformed(ActionEvent e) { - groupMenu.insertSeparator(3); + getGroup().cs = new ZappoColourScheme(); + refresh(); } - if (seq == null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void taylorColour_actionPerformed(ActionEvent e) { - sequenceMenu.setVisible(false); + getGroup().cs = new TaylorColourScheme(); + refresh(); } - } - - private void jbInit() - throws Exception - { - groupMenu.setText("Group"); - groupMenu.setText("Define"); - groupName.setText("Name"); - groupName.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - groupName_actionPerformed(e); - } - }); - sequenceMenu.setText("Sequence"); - sequenceName.setText("Edit name"); - sequenceName.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - sequenceName_actionPerformed(e); - } - }); - PIDColour.setFocusPainted(false); - unGroupMenuItem.setText("Remove Group"); - unGroupMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - unGroupMenuItem_actionPerformed(e); - } - }); - pdbMenuItem.setText("View PDB structure"); - pdbMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - pdbMenuItem_actionPerformed(e); - } - }); - outline.setText("Border colour"); - outline.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - outline_actionPerformed(e); - } - }); - nucleotideMenuItem.setText("Nucleotide"); - nucleotideMenuItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - nucleotideMenuItem_actionPerformed(e); - } - }); - colourMenu.setText("Group Colour"); - showBoxes.setText("Boxes"); - showBoxes.setState(true); - showBoxes.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showBoxes_actionPerformed(e); - } - }); - showText.setText("Text"); - showText.setState(true); - showText.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showText_actionPerformed(e); - } - }); - showColourText.setText("Colour Text"); - showColourText.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - showColourText_actionPerformed(e); - } - }); - add(groupMenu); - add(sequenceMenu); - groupMenu.add(groupName); - groupMenu.addSeparator(); - groupMenu.add(unGroupMenuItem); - groupMenu.add(colourMenu); - groupMenu.addSeparator(); - groupMenu.add(showBoxes); - groupMenu.add(showText); - groupMenu.add(showColourText); - groupMenu.addSeparator(); - groupMenu.add(outline); - sequenceMenu.add(sequenceName); - sequenceMenu.add(pdbMenuItem); - colourMenu.add(noColourmenuItem); - colourMenu.add(clustalColour); - colourMenu.add(BLOSUM62Colour); - colourMenu.add(PIDColour); - colourMenu.add(zappoColour); - colourMenu.add(taylorColour); - colourMenu.add(hydrophobicityColour); - colourMenu.add(helixColour); - colourMenu.add(strandColour); - colourMenu.add(turnColour); - colourMenu.add(buriedColour); - colourMenu.add(nucleotideMenuItem); - colourMenu.add(userDefinedColour); - colourMenu.addSeparator(); - colourMenu.add(abovePIDColour); - colourMenu.add(conservationMenuItem); - noColourmenuItem.setText("None"); - noColourmenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - noColourmenuItem_actionPerformed(e); - } - }); - - clustalColour.setText("Clustalx colours"); - clustalColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - clustalColour_actionPerformed(e); - } - }); - zappoColour.setText("Zappo"); - zappoColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - zappoColour_actionPerformed(e); - } - }); - taylorColour.setText("Taylor"); - taylorColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - taylorColour_actionPerformed(e); - } - }); - hydrophobicityColour.setText("Hydrophobicity"); - hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - hydrophobicityColour_actionPerformed(e); - } - }); - helixColour.setText("Helix propensity"); - helixColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - helixColour_actionPerformed(e); - } - }); - strandColour.setText("Strand propensity"); - strandColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - strandColour_actionPerformed(e); - } - }); - turnColour.setText("Turn propensity"); - turnColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - turnColour_actionPerformed(e); - } - }); - buriedColour.setText("Buried Index"); - buriedColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - buriedColour_actionPerformed(e); - } - }); - abovePIDColour.setText("Above % Identity"); - abovePIDColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - abovePIDColour_actionPerformed(e); - } - }); - userDefinedColour.setText("User Defined"); - userDefinedColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - userDefinedColour_actionPerformed(e); - } - }); - PIDColour.setText("Percentage Identity"); - PIDColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - PIDColour_actionPerformed(e); - } - }); - BLOSUM62Colour.setText("BLOSUM62"); - BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void hydrophobicityColour_actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - BLOSUM62Colour_actionPerformed(e); - } - }); - conservationMenuItem.setText("Conservation"); - conservationMenuItem.addActionListener(new java.awt.event.ActionListener() + getGroup().cs = new HydrophobicColourScheme(); + refresh(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void helixColour_actionPerformed(ActionEvent e) { - public void actionPerformed(ActionEvent e) - { - conservationMenuItem_actionPerformed(e); - } - }); - } - - void refresh() - { - SequenceGroup sg = getGroup(); - SuperGroup superG = ap.av.alignment.getSuperGroup(sg); - - if (superG != null) + getGroup().cs = new HelixColourScheme(); + refresh(); + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void strandColour_actionPerformed(ActionEvent e) { - superG.setSuperGroupProperties(sg); + getGroup().cs = new StrandColourScheme(); + refresh(); } - ap.seqPanel.repaint(); - } - - protected void clustalColour_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - sg.cs = new ClustalxColourScheme(sg.sequences, - ap.av.alignment.getWidth()); - refresh(); - } - - protected void zappoColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new ZappoColourScheme(); - refresh(); - } - - protected void taylorColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new TaylorColourScheme(); - refresh(); - } - - protected void hydrophobicityColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new HydrophobicColourScheme(); - refresh(); - } - - protected void helixColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new HelixColourScheme(); - refresh(); - } - - protected void strandColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new StrandColourScheme(); - refresh(); - } - - protected void turnColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new TurnColourScheme(); - refresh(); - } - - protected void buriedColour_actionPerformed(ActionEvent e) - { - getGroup().cs = new BuriedColourScheme(); - refresh(); - } - - public void nucleotideMenuItem_actionPerformed(ActionEvent e) - { - getGroup().cs = new NucleotideColourScheme(); - refresh(); - } - - protected void abovePIDColour_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - - if (abovePIDColour.isSelected()) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void turnColour_actionPerformed(ActionEvent e) { - sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); - - int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, - getGroup().getName()); - - if (sg.cs instanceof ResidueColourScheme) - { - ( (ResidueColourScheme) sg.cs).setThreshold(threshold); - } - else if (sg.cs instanceof ScoreColourScheme) - { - ( (ScoreColourScheme) sg.cs).setThreshold(threshold); - } - - SliderPanel.showPIDSlider(); + getGroup().cs = new TurnColourScheme(); + refresh(); } - else // remove PIDColouring + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void buriedColour_actionPerformed(ActionEvent e) { - ResidueColourScheme rcs = (ResidueColourScheme) sg.cs; - rcs.setThreshold(0); - sg.cs = rcs; + getGroup().cs = new BuriedColourScheme(); + refresh(); } - refresh(); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void nucleotideMenuItem_actionPerformed(ActionEvent e) + { + getGroup().cs = new NucleotideColourScheme(); + refresh(); + } - protected void userDefinedColour_actionPerformed(ActionEvent e) - { - new UserDefinedColours(ap, getGroup()); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void abovePIDColour_actionPerformed(ActionEvent e) + { + SequenceGroup sg = getGroup(); + + if (abovePIDColour.isSelected()) + { + sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, + ap.av.alignment.getWidth())); + + int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, + getGroup().getName()); + + if (sg.cs instanceof ResidueColourScheme) + { + ((ResidueColourScheme) sg.cs).setThreshold(threshold); + } + else if (sg.cs instanceof ScoreColourScheme) + { + ((ScoreColourScheme) sg.cs).setThreshold(threshold); + } + + SliderPanel.showPIDSlider(); + } + else // remove PIDColouring + { + ResidueColourScheme rcs = (ResidueColourScheme) sg.cs; + rcs.setThreshold(0); + sg.cs = rcs; + } + + refresh(); + } - protected void PIDColour_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - sg.cs = new PIDColourScheme(); - sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); - refresh(); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void userDefinedColour_actionPerformed(ActionEvent e) + { + new UserDefinedColours(ap, getGroup()); + } - protected void BLOSUM62Colour_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void PIDColour_actionPerformed(ActionEvent e) + { + SequenceGroup sg = getGroup(); + sg.cs = new PIDColourScheme(); + sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, + ap.av.alignment.getWidth())); + refresh(); + } - sg.cs = new Blosum62ColourScheme(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void BLOSUM62Colour_actionPerformed(ActionEvent e) + { + SequenceGroup sg = getGroup(); - sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); + sg.cs = new Blosum62ColourScheme(); - refresh(); - } + sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, + ap.av.alignment.getWidth())); - protected void noColourmenuItem_actionPerformed(ActionEvent e) - { - getGroup().cs = null; - refresh(); - } + refresh(); + } - protected void conservationMenuItem_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void noColourmenuItem_actionPerformed(ActionEvent e) + { + getGroup().cs = null; + refresh(); + } - if (conservationMenuItem.isSelected()) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void conservationMenuItem_actionPerformed(ActionEvent e) { - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, 0, - ap.av.alignment.getWidth()); + SequenceGroup sg = getGroup(); - c.calculate(); - c.verdict(false, ap.av.ConsPercGaps); + if (conservationMenuItem.isSelected()) + { + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, sg.sequences, 0, + ap.av.alignment.getWidth()); - ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); + c.calculate(); + c.verdict(false, ap.av.ConsPercGaps); - sg.cs = ccs; + ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); - SliderPanel.setConservationSlider(ap, ccs, sg.getName()); - SliderPanel.showConservationSlider(); - } - else // remove ConservationColouring - { - ConservationColourScheme ccs = (ConservationColourScheme) sg.cs; - sg.cs = ccs.cs; - } + sg.cs = ccs; - refresh(); - } + SliderPanel.setConservationSlider(ap, ccs, sg.getName()); + SliderPanel.showConservationSlider(); + } + else // remove ConservationColouring + { + ConservationColourScheme ccs = (ConservationColourScheme) sg.cs; + sg.cs = ccs.cs; + } - protected void groupName_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - String reply = JOptionPane.showInternalInputDialog(Desktop.desktop, - "Enter new group name", "Edit group name", - JOptionPane.QUESTION_MESSAGE); + refresh(); + } - if (reply == null) - { - return; + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void groupName_actionPerformed(ActionEvent e) + { + SequenceGroup sg = getGroup(); + String reply = JOptionPane.showInternalInputDialog(Desktop.desktop, + "Enter new group name", "Edit group name", + JOptionPane.QUESTION_MESSAGE); + + if (reply == null) + { + return; + } + + sg.setName(reply); + groupName.setText(reply); } - sg.setName(reply); - groupName.setText(reply); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void analyze_actionPerformed(ActionEvent e) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(cap); + Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300); + + SequenceGroup sg = getGroup(); + StringBuffer sb = new StringBuffer(); + + for (int i = 0; i < sg.sequences.size(); i++) + { + Sequence tmp = (Sequence) sg.sequences.get(i); + sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1)); + sb.append("\n"); + } + + sb.append("Something amazing will happen soon"); + cap.setText(sb.toString()); + } - protected void analyze_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(cap); - Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + SequenceGroup getGroup() + { + SequenceGroup sg = ap.av.getSelectionGroup(); - SequenceGroup sg = getGroup(); - StringBuffer sb = new StringBuffer(); + // this method won't add a new group if it already exists + ap.av.alignment.addGroup(sg); - for (int i = 0; i < sg.sequences.size(); i++) - { - Sequence tmp = (Sequence) sg.sequences.get(i); - sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1)); - sb.append("\n"); + return sg; } - sb.append("Something amazing will happen soon"); - cap.setText(sb.toString()); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + void sequenceName_actionPerformed(ActionEvent e) + { + String id = sequence.getName(); + String s = (String) JOptionPane.showInternalInputDialog(ap, + "Edit sequence name", + "Edit sequence name (" + sequence.getName() + ")", + JOptionPane.PLAIN_MESSAGE, null, null, id); + + if (s != null) + { + if (s.indexOf(" ") > -1) + { + JOptionPane.showMessageDialog(ap, + "Spaces have been converted to \"_\"", + "No spaces allowed in Sequence Name", + JOptionPane.WARNING_MESSAGE); + } + + s = s.replace(' ', '_'); + sequence.setName(s); + ap.repaint(); + } + } - SequenceGroup getGroup() - { - SequenceGroup sg = ap.av.getSelectionGroup(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + void unGroupMenuItem_actionPerformed(ActionEvent e) + { + SequenceGroup sg = ap.av.getSelectionGroup(); + ap.av.alignment.deleteGroup(sg); + ap.av.setSelectionGroup(null); + refresh(); + } - // this method won't add a new group if it already exists - ap.av.alignment.addGroup(sg); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + void pdbMenuItem_actionPerformed(ActionEvent e) + { + if (sequence.getPDBId() == null) + { + return; + } + + try + { + EBIFetchClient ebi = new EBIFetchClient(); + String[] result = ebi.fetchData("pdb:" + sequence.getPDBId(), null, + null); + + PDBfile pdb = new PDBfile(result); + + rotCanvas rc = new rotCanvas(pdb, sequence, ap.av); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(rc); + Desktop.addInternalFrame(frame, + sequence.getName() + " " + sequence.getPDBId(), 400, 400); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } - return sg; - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void outline_actionPerformed(ActionEvent e) + { + SequenceGroup sg = getGroup(); + Color col = JColorChooser.showDialog(this, "Select Outline Colour", + Color.BLUE); - void sequenceName_actionPerformed(ActionEvent e) - { - String id = sequence.getName(); - String s = (String) JOptionPane.showInternalInputDialog(ap, - "Edit sequence name", - "Edit sequence name (" + sequence.getName() + ")", - JOptionPane.PLAIN_MESSAGE, null, null, id); + if (col != null) + { + sg.setOutlineColour(col); + } - if (s != null) - { - if(s.indexOf(" ")>-1) - JOptionPane.showMessageDialog(ap, "Spaces have been converted to \"_\"", - "No spaces allowed in Sequence Name", JOptionPane.WARNING_MESSAGE); - s = s.replace(' ', '_'); - sequence.setName(s); - ap.repaint(); - } - } - - void unGroupMenuItem_actionPerformed(ActionEvent e) - { - SequenceGroup sg = ap.av.getSelectionGroup(); - ap.av.alignment.deleteGroup(sg); - ap.av.setSelectionGroup(null); - refresh(); - } - - void pdbMenuItem_actionPerformed(ActionEvent e) - { - if (sequence.getPDBId() == null) - { - return; + refresh(); } - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void showBoxes_actionPerformed(ActionEvent e) { - EBIFetchClient ebi = new EBIFetchClient(); - String[] result = ebi.fetchData("pdb:" + sequence.getPDBId(), null, - null); - - PDBfile pdb = new PDBfile(result); - - rotCanvas rc = new rotCanvas(pdb, sequence, ap.av); - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(rc); - Desktop.addInternalFrame(frame, - sequence.getName() + " " + sequence.getPDBId(), - 400, 400); + getGroup().setDisplayBoxes(showBoxes.isSelected()); + refresh(); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void showText_actionPerformed(ActionEvent e) { - ex.printStackTrace(); + getGroup().setDisplayText(showText.isSelected()); + refresh(); } - } - protected void outline_actionPerformed(ActionEvent e) - { - SequenceGroup sg = getGroup(); - Color col = JColorChooser.showDialog(this, "Select Outline Colour", - Color.BLUE); - - if (col != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void showColourText_actionPerformed(ActionEvent e) { - sg.setOutlineColour(col); + getGroup().setColourText(showColourText.isSelected()); + refresh(); } - - refresh(); - } - - public void showBoxes_actionPerformed(ActionEvent e) - { - getGroup().setDisplayBoxes(showBoxes.isSelected()); - refresh(); - } - - public void showText_actionPerformed(ActionEvent e) - { - getGroup().setDisplayText(showText.isSelected()); - refresh(); - } - - public void showColourText_actionPerformed(ActionEvent e) - { - getGroup().setColourText(showColourText.isSelected()); - refresh(); - } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index b16ae32..8a3c372 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -18,300 +18,358 @@ */ package jalview.gui; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - import jalview.bin.*; + import jalview.io.*; + import jalview.jbgui.*; + import jalview.schemes.*; -public class Preferences - extends GPreferences +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Preferences extends GPreferences { - static boolean preferencesLoaded = false; - public static boolean showFullscreen = false; - public static boolean showFullId = true; - public static boolean showAnnotation = true; - public static boolean showConservation = true; - public static boolean showQuality = true; - public static boolean showIdentity = true; - public static String fontName = "SansSerif"; - public static String fontSize = "10"; - public static String fontStyle = Font.PLAIN + ""; - public static char gapSymbol = '-'; - public static String defaultColour = null; - public static boolean showStartupFile = true; - public static String startupFile = - "http://www.jalview.org/examples/exampleFile.jar"; - JInternalFrame frame; - - public Preferences() - { - initPreferences(); - - frame = new JInternalFrame(); - frame.setContentPane(this); - Desktop.addInternalFrame(frame, "Preferences", 480, 390); - - fullID.setSelected(showFullId); - - String string = Cache.getProperty("SHOW_FULLSCREEN"); - boolean value = false; - - if (string != null) - { - value = Boolean.valueOf(string).booleanValue(); - } + static boolean preferencesLoaded = false; - fullScreen.setSelected(value); - annotations.setSelected(showAnnotation); + /** DOCUMENT ME!! */ + public static boolean showFullscreen = false; - conservation.setEnabled(showAnnotation); - quality.setEnabled(showAnnotation); - identity.setEnabled(showAnnotation); + /** DOCUMENT ME!! */ + public static boolean showFullId = true; - conservation.setSelected(showConservation); - quality.setSelected(showQuality); - identity.setSelected(showIdentity); + /** DOCUMENT ME!! */ + public static boolean showAnnotation = true; - for (int i = 0; i < 12; i++) - { - colour.addItem(ColourSchemeProperty.getColourName(i)); - } + /** DOCUMENT ME!! */ + public static boolean showConservation = true; - string = Cache.getProperty("DEFAULT_COLOUR"); + /** DOCUMENT ME!! */ + public static boolean showQuality = true; - if (string != null) - { - colour.setSelectedItem(string); - } - else - { - colour.setSelectedIndex(11); - } + /** DOCUMENT ME!! */ + public static boolean showIdentity = true; - String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() - .getAvailableFontFamilyNames(); + /** DOCUMENT ME!! */ + public static String fontName = "SansSerif"; - for (int i = 0; i < fonts.length; i++) - { - fontNameCB.addItem(fonts[i]); - } + /** DOCUMENT ME!! */ + public static String fontSize = "10"; + + /** DOCUMENT ME!! */ + public static String fontStyle = Font.PLAIN + ""; - for (int i = 1; i < 31; i++) + /** DOCUMENT ME!! */ + public static char gapSymbol = '-'; + + /** DOCUMENT ME!! */ + public static String defaultColour = null; + + /** DOCUMENT ME!! */ + public static boolean showStartupFile = true; + + /** DOCUMENT ME!! */ + public static String startupFile = "http://www.jalview.org/examples/exampleFile.jar"; + JInternalFrame frame; + + /** + * Creates a new Preferences object. + */ + public Preferences() { - fontSizeCB.addItem(i + ""); - } + initPreferences(); - fontStyleCB.addItem("plain"); - fontStyleCB.addItem("bold"); - fontStyleCB.addItem("italic"); + frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, "Preferences", 480, 390); - fontNameCB.setSelectedItem(fontName); - fontSizeCB.setSelectedItem(fontSize); - fontStyleCB.setSelectedItem(fontStyle); + fullID.setSelected(showFullId); - gapSymbolCB.addItem("-"); - gapSymbolCB.addItem("."); + String string = Cache.getProperty("SHOW_FULLSCREEN"); + boolean value = false; - gapSymbolCB.setSelectedItem(gapSymbol + ""); + if (string != null) + { + value = Boolean.valueOf(string).booleanValue(); + } - startupCheckbox.setSelected(showStartupFile); - startupFileTextfield.setText(startupFile); - } + fullScreen.setSelected(value); + annotations.setSelected(showAnnotation); - public static void initPreferences() - { - String string = Cache.getProperty("SHOW_FULL_ID"); + conservation.setEnabled(showAnnotation); + quality.setEnabled(showAnnotation); + identity.setEnabled(showAnnotation); - if (string != null) - { - showFullId = Boolean.valueOf(string).booleanValue(); - } + conservation.setSelected(showConservation); + quality.setSelected(showQuality); + identity.setSelected(showIdentity); - string = Cache.getProperty("SHOW_FULLSCREEN"); + for (int i = 0; i < 12; i++) + { + colour.addItem(ColourSchemeProperty.getColourName(i)); + } - if (string != null) - { - showFullscreen = Boolean.valueOf(string).booleanValue(); - } + string = Cache.getProperty("DEFAULT_COLOUR"); - string = Cache.getProperty("SHOW_ANNOTATIONS"); + if (string != null) + { + colour.setSelectedItem(string); + } + else + { + colour.setSelectedIndex(11); + } - if (string != null) - { - showAnnotation = Boolean.valueOf(string).booleanValue(); - } + String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment() + .getAvailableFontFamilyNames(); - string = Cache.getProperty("SHOW_CONSERVATION"); + for (int i = 0; i < fonts.length; i++) + { + fontNameCB.addItem(fonts[i]); + } - if (string != null) - { - showConservation = Boolean.valueOf(string).booleanValue(); - } + for (int i = 1; i < 31; i++) + { + fontSizeCB.addItem(i + ""); + } - string = Cache.getProperty("SHOW_QUALITY"); + fontStyleCB.addItem("plain"); + fontStyleCB.addItem("bold"); + fontStyleCB.addItem("italic"); - if (string != null) - { - showQuality = Boolean.valueOf(string).booleanValue(); - } + fontNameCB.setSelectedItem(fontName); + fontSizeCB.setSelectedItem(fontSize); + fontStyleCB.setSelectedItem(fontStyle); - string = Cache.getProperty("SHOW_IDENTITY"); + gapSymbolCB.addItem("-"); + gapSymbolCB.addItem("."); - if (string != null) - { - showIdentity = Boolean.valueOf(string).booleanValue(); - } + gapSymbolCB.setSelectedItem(gapSymbol + ""); - string = Cache.getProperty("GAP_SYMBOL"); + startupCheckbox.setSelected(showStartupFile); + startupFileTextfield.setText(startupFile); + } - if (string != null) + /** + * DOCUMENT ME! + */ + public static void initPreferences() { - gapSymbol = string.charAt(0); - } + String string = Cache.getProperty("SHOW_FULL_ID"); - string = Cache.getProperty("SHOW_FULL_ID"); + if (string != null) + { + showFullId = Boolean.valueOf(string).booleanValue(); + } - if (string != null) - { - showFullId = Boolean.valueOf(string).booleanValue(); - } + string = Cache.getProperty("SHOW_FULLSCREEN"); - string = Cache.getProperty("FONT_NAME"); + if (string != null) + { + showFullscreen = Boolean.valueOf(string).booleanValue(); + } - if (string != null) - { - fontName = string; - } + string = Cache.getProperty("SHOW_ANNOTATIONS"); - string = Cache.getProperty("FONT_STYLE"); + if (string != null) + { + showAnnotation = Boolean.valueOf(string).booleanValue(); + } - if (string != null) - { - fontStyle = string; - } + string = Cache.getProperty("SHOW_CONSERVATION"); - string = Cache.getProperty("FONT_SIZE"); + if (string != null) + { + showConservation = Boolean.valueOf(string).booleanValue(); + } - if (string != null) - { - fontSize = string; - } + string = Cache.getProperty("SHOW_QUALITY"); - string = Cache.getProperty("DEFAULT_COLOUR"); + if (string != null) + { + showQuality = Boolean.valueOf(string).booleanValue(); + } - if (string != null) - { - defaultColour = string; - } + string = Cache.getProperty("SHOW_IDENTITY"); + + if (string != null) + { + showIdentity = Boolean.valueOf(string).booleanValue(); + } - string = Cache.getProperty("STARTUP_FILE"); + string = Cache.getProperty("GAP_SYMBOL"); - if (string != null) - { - startupFile = string; - } + if (string != null) + { + gapSymbol = string.charAt(0); + } - string = Cache.getProperty("SHOW_STARTUP_FILE"); + string = Cache.getProperty("SHOW_FULL_ID"); - if (string != null) - { - showStartupFile = Boolean.valueOf(string).booleanValue(); - } + if (string != null) + { + showFullId = Boolean.valueOf(string).booleanValue(); + } - preferencesLoaded = true; - } - - public void ok_actionPerformed(ActionEvent e) - { - showFullId = fullID.isSelected(); - showFullscreen = fullScreen.isSelected(); - showAnnotation = annotations.isSelected(); - showConservation = conservation.isSelected(); - showQuality = quality.isSelected(); - showIdentity = identity.isSelected(); - defaultColour = colour.getSelectedItem().toString(); - gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0); - fontName = fontNameCB.getSelectedItem().toString(); - fontSize = fontSizeCB.getSelectedItem().toString(); - fontStyle = fontStyleCB.getSelectedItem().toString(); - startupFile = startupFileTextfield.getText(); - showStartupFile = startupCheckbox.isSelected(); - - Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId)); - Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString(showFullscreen)); - - Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString(showAnnotation)); - Cache.setProperty("SHOW_CONSERVATION", - Boolean.toString(showConservation)); - Cache.setProperty("SHOW_QUALITY", Boolean.toString(showQuality)); - Cache.setProperty("SHOW_IDENTITY", Boolean.toString(showIdentity)); - - Cache.setProperty("DEFAULT_COLOUR", defaultColour); - Cache.setProperty("GAP_SYMBOL", gapSymbol + ""); - - Cache.setProperty("FONT_NAME", fontName); - Cache.setProperty("FONT_STYLE", fontStyle); - Cache.setProperty("FONT_SIZE", fontSize); - - Cache.setProperty("STARTUP_FILE", startupFile); - Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile)); - - try - { - frame.setClosed(true); + string = Cache.getProperty("FONT_NAME"); + + if (string != null) + { + fontName = string; + } + + string = Cache.getProperty("FONT_STYLE"); + + if (string != null) + { + fontStyle = string; + } + + string = Cache.getProperty("FONT_SIZE"); + + if (string != null) + { + fontSize = string; + } + + string = Cache.getProperty("DEFAULT_COLOUR"); + + if (string != null) + { + defaultColour = string; + } + + string = Cache.getProperty("STARTUP_FILE"); + + if (string != null) + { + startupFile = string; + } + + string = Cache.getProperty("SHOW_STARTUP_FILE"); + + if (string != null) + { + showStartupFile = Boolean.valueOf(string).booleanValue(); + } + + preferencesLoaded = true; } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void ok_actionPerformed(ActionEvent e) { - } - } - - public void startupFileTextfield_mouseClicked() - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), - new String[] + showFullId = fullID.isSelected(); + showFullscreen = fullScreen.isSelected(); + showAnnotation = annotations.isSelected(); + showConservation = conservation.isSelected(); + showQuality = quality.isSelected(); + showIdentity = identity.isSelected(); + defaultColour = colour.getSelectedItem().toString(); + gapSymbol = gapSymbolCB.getSelectedItem().toString().charAt(0); + fontName = fontNameCB.getSelectedItem().toString(); + fontSize = fontSizeCB.getSelectedItem().toString(); + fontStyle = fontStyleCB.getSelectedItem().toString(); + startupFile = startupFileTextfield.getText(); + showStartupFile = startupCheckbox.isSelected(); + + Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId)); + Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString(showFullscreen)); + + Cache.setProperty("SHOW_ANNOTATIONS", Boolean.toString(showAnnotation)); + Cache.setProperty("SHOW_CONSERVATION", + Boolean.toString(showConservation)); + Cache.setProperty("SHOW_QUALITY", Boolean.toString(showQuality)); + Cache.setProperty("SHOW_IDENTITY", Boolean.toString(showIdentity)); + + Cache.setProperty("DEFAULT_COLOUR", defaultColour); + Cache.setProperty("GAP_SYMBOL", gapSymbol + ""); + + Cache.setProperty("FONT_NAME", fontName); + Cache.setProperty("FONT_STYLE", fontStyle); + Cache.setProperty("FONT_SIZE", fontSize); + + Cache.setProperty("STARTUP_FILE", startupFile); + Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile)); + + try { - "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", - "jar" - }, - new String[] + frame.setClosed(true); + } + catch (Exception ex) { - "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" - }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Select startup file"); - - int value = chooser.showOpenDialog(this); + } + } - if (value == JalviewFileChooser.APPROVE_OPTION) + /** + * DOCUMENT ME! + */ + public void startupFileTextfield_mouseClicked() { - jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", - chooser.getSelectedFormat()); - startupFileTextfield.setText(chooser.getSelectedFile() - .getAbsolutePath()); + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), + new String[] + { + "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc", + "jar" + }, + new String[] + { + "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview" + }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Select startup file"); + + int value = chooser.showOpenDialog(this); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", + chooser.getSelectedFormat()); + startupFileTextfield.setText(chooser.getSelectedFile() + .getAbsolutePath()); + } } - } - public void cancel_actionPerformed(ActionEvent e) - { - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void cancel_actionPerformed(ActionEvent e) { - frame.setClosed(true); + try + { + frame.setClosed(true); + } + catch (Exception ex) + { + } } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void annotations_actionPerformed(ActionEvent e) { + conservation.setEnabled(annotations.isSelected()); + quality.setEnabled(annotations.isSelected()); + identity.setEnabled(annotations.isSelected()); } - } - - public void annotations_actionPerformed(ActionEvent e) - { - conservation.setEnabled(annotations.isSelected()); - quality.setEnabled(annotations.isSelected()); - identity.setEnabled(annotations.isSelected()); - } } diff --git a/src/jalview/gui/RedundancyPanel.java b/src/jalview/gui/RedundancyPanel.java index daee862..17b5dfa 100755 --- a/src/jalview/gui/RedundancyPanel.java +++ b/src/jalview/gui/RedundancyPanel.java @@ -18,144 +18,173 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; + +import jalview.jbgui.*; import java.awt.event.*; -import javax.swing.event.*; -import jalview.datamodel.*; -import jalview.jbgui.*; +import java.util.*; -public class RedundancyPanel - extends GSliderPanel -{ - AlignFrame af; - AlignmentPanel ap; - Stack historyList = new Stack(); // simpler than synching with alignFrame. +import javax.swing.event.*; - public RedundancyPanel(AlignmentPanel ap, AlignFrame af) - { - this.ap = ap; - this.af = af; - label.setText("Enter the redundancy threshold"); - slider.addChangeListener(new ChangeListener() - { - public void stateChanged(ChangeEvent evt) - { - valueField.setText(slider.getValue() + ""); - } - }); - - slider.setMinimum(0); - slider.setMaximum(100); - slider.setValue(100); - } - - public void applyButton_actionPerformed(ActionEvent e) - { - float threshold = slider.getValue(); - Vector del; - HistoryItem it; - historyList.push(it = new HistoryItem("Remove redundancy", - ap.av.alignment, HistoryItem.HIDE)); - - if ( (historyList.size() == 1) || - !af.historyList.contains(historyList.firstElement())) +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class RedundancyPanel extends GSliderPanel +{ + AlignFrame af; + AlignmentPanel ap; + Stack historyList = new Stack(); // simpler than synching with alignFrame. + + /** + * Creates a new RedundancyPanel object. + * + * @param ap DOCUMENT ME! + * @param af DOCUMENT ME! + */ + public RedundancyPanel(AlignmentPanel ap, AlignFrame af) { - af.addHistoryItem( (HistoryItem) historyList.firstElement()); - af.updateEditMenuBar(); + this.ap = ap; + this.af = af; + label.setText("Enter the redundancy threshold"); + + slider.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent evt) + { + valueField.setText(slider.getValue() + ""); + } + }); + + slider.setMinimum(0); + slider.setMaximum(100); + slider.setValue(100); } - undoButton.setEnabled(true); - - SequenceGroup sg = ap.av.getSelectionGroup(); - - if ( (sg != null) && (sg.getSize() >= 1)) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void applyButton_actionPerformed(ActionEvent e) { - del = ap.av.alignment.removeRedundancy(threshold, sg.sequences); - - for (int i = 0; i < del.size(); i++) - { - if (sg.sequences.contains( (SequenceI) del.elementAt(i))) + float threshold = slider.getValue(); + Vector del; + HistoryItem it; + historyList.push(it = new HistoryItem("Remove redundancy", + ap.av.alignment, HistoryItem.HIDE)); + + if ((historyList.size() == 1) || + !af.historyList.contains(historyList.firstElement())) { - sg.deleteSequence( (SequenceI) del.elementAt(i), true); + af.addHistoryItem((HistoryItem) historyList.firstElement()); + af.updateEditMenuBar(); } - } - } - else - { - Vector s = new Vector(); - int i = 0; - while (i < ap.av.alignment.getHeight()) - { - s.addElement(ap.av.alignment.getSequenceAt(i)); - i++; - } + undoButton.setEnabled(true); - del = ap.av.alignment.removeRedundancy(threshold, s); - } + SequenceGroup sg = ap.av.getSelectionGroup(); - // This has to be done before the restoreHistoryItem method of alignFrame will - // actually restore these sequences. - if (del.size() > 0) - { - for (int i = 0, j = del.size(); i < j; i++) - { - SequenceI sq = (SequenceI) del.elementAt(i); - sq.deleteChars(0, sq.getLength()); - } - } + if ((sg != null) && (sg.getSize() >= 1)) + { + del = ap.av.alignment.removeRedundancy(threshold, sg.sequences); + + for (int i = 0; i < del.size(); i++) + { + if (sg.sequences.contains((SequenceI) del.elementAt(i))) + { + sg.deleteSequence((SequenceI) del.elementAt(i), true); + } + } + } + else + { + Vector s = new Vector(); + int i = 0; - ap.av.firePropertyChange("alignment", null, - ap.av.getAlignment().getSequences()); - ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight()); + while (i < ap.av.alignment.getHeight()) + { + s.addElement(ap.av.alignment.getSequenceAt(i)); + i++; + } - if (ap.av.getAlignment().getHeight() < 1) - { - try - { - af.setClosed(true); - } - catch (Exception ex) - { - } - } + del = ap.av.alignment.removeRedundancy(threshold, s); + } - ap.av.updateConservation(); - ap.av.updateConsensus(); - af.updateEditMenuBar(); - ap.repaint(); - } + // This has to be done before the restoreHistoryItem method of alignFrame will + // actually restore these sequences. + if (del.size() > 0) + { + for (int i = 0, j = del.size(); i < j; i++) + { + SequenceI sq = (SequenceI) del.elementAt(i); + sq.deleteChars(0, sq.getLength()); + } + } - public void undoButton_actionPerformed(ActionEvent e) - { - HistoryItem hi = (HistoryItem) historyList.pop(); - af.restoreHistoryItem(hi); + ap.av.firePropertyChange("alignment", null, + ap.av.getAlignment().getSequences()); + ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight()); - if (historyList.size() == 0) - { - undoButton.setEnabled(false); + if (ap.av.getAlignment().getHeight() < 1) + { + try + { + af.setClosed(true); + } + catch (Exception ex) + { + } + } - if (af.historyList.contains(hi)) - { - af.historyList.remove(hi); + ap.av.updateConservation(); + ap.av.updateConsensus(); af.updateEditMenuBar(); - } + ap.repaint(); } - } - public void valueField_actionPerformed(ActionEvent e) - { - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void undoButton_actionPerformed(ActionEvent e) { - int i = Integer.parseInt(valueField.getText()); - slider.setValue(i); + HistoryItem hi = (HistoryItem) historyList.pop(); + af.restoreHistoryItem(hi); + + if (historyList.size() == 0) + { + undoButton.setEnabled(false); + + if (af.historyList.contains(hi)) + { + af.historyList.remove(hi); + af.updateEditMenuBar(); + } + } } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void valueField_actionPerformed(ActionEvent e) { - valueField.setText(slider.getValue() + ""); + try + { + int i = Integer.parseInt(valueField.getText()); + slider.setValue(i); + } + catch (Exception ex) + { + valueField.setText(slider.getValue() + ""); + } } - } } diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index c3384f9..fbbf269 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -18,620 +18,745 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; + +import jalview.math.*; + +import jalview.util.*; import java.awt.*; import java.awt.event.*; + +import java.util.*; + import javax.swing.*; -import jalview.datamodel.*; -import jalview.math.*; -import jalview.util.*; -public class RotatableCanvas - extends JPanel implements MouseListener, +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class RotatableCanvas extends JPanel implements MouseListener, MouseMotionListener, KeyListener //RubberbandListener, //SequenceSelectionListener { - RotatableMatrix idmat = new RotatableMatrix(3, 3); - RotatableMatrix objmat = new RotatableMatrix(3, 3); - RotatableMatrix rotmat = new RotatableMatrix(3, 3); - - //RubberbandRectangle rubberband; - boolean drawAxes = true; - int omx = 0; - int mx = 0; - int omy = 0; - int my = 0; - Image img; - Graphics ig; - Dimension prefsize; - float[] centre = new float[3]; - float[] width = new float[3]; - float[] max = new float[3]; - float[] min = new float[3]; - float maxwidth; - float scale; - int npoint; - Vector points; - float[][] orig; - float[][] axes; - int startx; - int starty; - int lastx; - int lasty; - int rectx1; - int recty1; - int rectx2; - int recty2; - float scalefactor = 1; - AlignViewport av; - - // Controller controller; - public RotatableCanvas(AlignViewport av, Vector points, int npoint) - { - this.points = points; - this.npoint = npoint; - this.av = av; - ToolTipManager.sharedInstance().registerComponent(this); - ToolTipManager.sharedInstance().setInitialDelay(0); - ToolTipManager.sharedInstance().setDismissDelay(10000); - PaintRefresher.Register(this, av.alignment); - - prefsize = getPreferredSize(); - orig = new float[npoint][3]; - - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - - for (int j = 0; j < 3; j++) - { - orig[i][j] = sp.coord[j]; - } - } - - //Initialize the matrices to identity - for (int i = 0; i < 3; i++) + RotatableMatrix idmat = new RotatableMatrix(3, 3); + RotatableMatrix objmat = new RotatableMatrix(3, 3); + RotatableMatrix rotmat = new RotatableMatrix(3, 3); + + //RubberbandRectangle rubberband; + boolean drawAxes = true; + int omx = 0; + int mx = 0; + int omy = 0; + int my = 0; + Image img; + Graphics ig; + Dimension prefsize; + float[] centre = new float[3]; + float[] width = new float[3]; + float[] max = new float[3]; + float[] min = new float[3]; + float maxwidth; + float scale; + int npoint; + Vector points; + float[][] orig; + float[][] axes; + int startx; + int starty; + int lastx; + int lasty; + int rectx1; + int recty1; + int rectx2; + int recty2; + float scalefactor = 1; + AlignViewport av; + + // Controller controller; + public RotatableCanvas(AlignViewport av, Vector points, int npoint) { - for (int j = 0; j < 3; j++) - { - if (i != j) + this.points = points; + this.npoint = npoint; + this.av = av; + ToolTipManager.sharedInstance().registerComponent(this); + ToolTipManager.sharedInstance().setInitialDelay(0); + ToolTipManager.sharedInstance().setDismissDelay(10000); + PaintRefresher.Register(this, av.alignment); + + prefsize = getPreferredSize(); + orig = new float[npoint][3]; + + for (int i = 0; i < npoint; i++) { - idmat.addElement(i, j, 0); - objmat.addElement(i, j, 0); - rotmat.addElement(i, j, 0); + SequencePoint sp = (SequencePoint) points.elementAt(i); + + for (int j = 0; j < 3; j++) + { + orig[i][j] = sp.coord[j]; + } } - else + + //Initialize the matrices to identity + for (int i = 0; i < 3; i++) { - idmat.addElement(i, j, 0); - objmat.addElement(i, j, 0); - rotmat.addElement(i, j, 0); + for (int j = 0; j < 3; j++) + { + if (i != j) + { + idmat.addElement(i, j, 0); + objmat.addElement(i, j, 0); + rotmat.addElement(i, j, 0); + } + else + { + idmat.addElement(i, j, 0); + objmat.addElement(i, j, 0); + rotmat.addElement(i, j, 0); + } + } } - } - } - axes = new float[3][3]; - initAxes(); + axes = new float[3][3]; + initAxes(); - findCentre(); - findWidth(); + findCentre(); + findWidth(); - scale = findScale(); + scale = findScale(); - // System.out.println("Scale factor = " + scale); - addMouseListener(this); - addKeyListener(this); + // System.out.println("Scale factor = " + scale); + addMouseListener(this); + addKeyListener(this); - // if (getParent() != null) { - // getParent().addKeyListener(this); - //} - addMouseMotionListener(this); - - // Add rubberband - // rubberband = new RubberbandRectangle(this); - // rubberband.setActive(true); - // rubberband.addListener(this); - } - - /* public boolean handleSequenceSelectionEvent(SequenceSelectionEvent evt) { - redrawneeded = true; - repaint(); - return true; - } - - public void removeNotify() { - controller.removeListener(this); - super.removeNotify(); - }*/ - public void initAxes() - { - for (int i = 0; i < 3; i++) + // if (getParent() != null) { + // getParent().addKeyListener(this); + //} + addMouseMotionListener(this); + + // Add rubberband + // rubberband = new RubberbandRectangle(this); + // rubberband.setActive(true); + // rubberband.addListener(this); + } + + /* public boolean handleSequenceSelectionEvent(SequenceSelectionEvent evt) { + redrawneeded = true; + repaint(); + return true; + } + + public void removeNotify() { + controller.removeListener(this); + super.removeNotify(); + }*/ + public void initAxes() { - for (int j = 0; j < 3; j++) - { - if (i != j) - { - axes[i][j] = 0; - } - else + for (int i = 0; i < 3; i++) { - axes[i][j] = 1; + for (int j = 0; j < 3; j++) + { + if (i != j) + { + axes[i][j] = 0; + } + else + { + axes[i][j] = 1; + } + } } - } } - } - public void findWidth() - { - max = new float[3]; - min = new float[3]; + /** + * DOCUMENT ME! + */ + public void findWidth() + { + max = new float[3]; + min = new float[3]; - max[0] = (float) - 1e30; - max[1] = (float) - 1e30; - max[2] = (float) - 1e30; + max[0] = (float) -1e30; + max[1] = (float) -1e30; + max[2] = (float) -1e30; - min[0] = (float) 1e30; - min[1] = (float) 1e30; - min[2] = (float) 1e30; + min[0] = (float) 1e30; + min[1] = (float) 1e30; + min[2] = (float) 1e30; - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < npoint; j++) - { - SequencePoint sp = (SequencePoint) points.elementAt(j); + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < npoint; j++) + { + SequencePoint sp = (SequencePoint) points.elementAt(j); + + if (sp.coord[i] >= max[i]) + { + max[i] = sp.coord[i]; + } + + if (sp.coord[i] <= min[i]) + { + min[i] = sp.coord[i]; + } + } + } + + // System.out.println("xmax " + max[0] + " min " + min[0]); + //System.out.println("ymax " + max[1] + " min " + min[1]); + //System.out.println("zmax " + max[2] + " min " + min[2]); + width[0] = Math.abs(max[0] - min[0]); + width[1] = Math.abs(max[1] - min[1]); + width[2] = Math.abs(max[2] - min[2]); - if (sp.coord[i] >= max[i]) + maxwidth = width[0]; + + if (width[1] > width[0]) { - max[i] = sp.coord[i]; + maxwidth = width[1]; } - if (sp.coord[i] <= min[i]) + if (width[2] > width[1]) { - min[i] = sp.coord[i]; + maxwidth = width[2]; } - } + + //System.out.println("Maxwidth = " + maxwidth); } - // System.out.println("xmax " + max[0] + " min " + min[0]); - //System.out.println("ymax " + max[1] + " min " + min[1]); - //System.out.println("zmax " + max[2] + " min " + min[2]); - width[0] = Math.abs(max[0] - min[0]); - width[1] = Math.abs(max[1] - min[1]); - width[2] = Math.abs(max[2] - min[2]); + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float findScale() + { + int dim; + int width; + int height; - maxwidth = width[0]; + if (getWidth() != 0) + { + width = getWidth(); + height = getHeight(); + } + else + { + width = prefsize.width; + height = prefsize.height; + } - if (width[1] > width[0]) - { - maxwidth = width[1]; - } + if (width < height) + { + dim = width; + } + else + { + dim = height; + } - if (width[2] > width[1]) - { - maxwidth = width[2]; + return (float) ((dim * scalefactor) / (2 * maxwidth)); } - //System.out.println("Maxwidth = " + maxwidth); - } + /** + * DOCUMENT ME! + */ + public void findCentre() + { + //Find centre coordinate + findWidth(); - public float findScale() - { - int dim; - int width; - int height; + centre[0] = (max[0] + min[0]) / 2; + centre[1] = (max[1] + min[1]) / 2; + centre[2] = (max[2] + min[2]) / 2; - if (getWidth() != 0) - { - width = getWidth(); - height = getHeight(); + // System.out.println("Centre x " + centre[0]); + //System.out.println("Centre y " + centre[1]); + //System.out.println("Centre z " + centre[2]); } - else + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Dimension getPreferredSize() { - width = prefsize.width; - height = prefsize.height; + if (prefsize != null) + { + return prefsize; + } + else + { + return new Dimension(400, 400); + } } - if (width < height) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Dimension getMinimumSize() { - dim = width; + return getPreferredSize(); } - else + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - dim = height; - } + //Only create the image at the beginning - + if ((img == null) || (prefsize.width != getWidth()) || + (prefsize.height != getHeight())) + { + prefsize.width = getWidth(); + prefsize.height = getHeight(); - return (float) ( (dim * scalefactor) / (2 * maxwidth)); - } + scale = findScale(); - public void findCentre() - { - //Find centre coordinate - findWidth(); + // System.out.println("New scale = " + scale); + img = createImage(getWidth(), getHeight()); + ig = img.getGraphics(); + } - centre[0] = (max[0] + min[0]) / 2; - centre[1] = (max[1] + min[1]) / 2; - centre[2] = (max[2] + min[2]) / 2; + drawBackground(ig, Color.black); + drawScene(ig); - // System.out.println("Centre x " + centre[0]); - //System.out.println("Centre y " + centre[1]); - //System.out.println("Centre z " + centre[2]); - } + if (drawAxes == true) + { + drawAxes(ig); + } + + g.drawImage(img, 0, 0, this); + } - public Dimension getPreferredSize() - { - if (prefsize != null) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void drawAxes(Graphics g) { - return prefsize; + g.setColor(Color.yellow); + + for (int i = 0; i < 3; i++) + { + g.drawLine(getWidth() / 2, getHeight() / 2, + (int) ((axes[i][0] * scale * max[0]) + (getWidth() / 2)), + (int) ((axes[i][1] * scale * max[1]) + (getHeight() / 2))); + } } - else + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param col DOCUMENT ME! + */ + public void drawBackground(Graphics g, Color col) { - return new Dimension(400, 400); + g.setColor(col); + g.fillRect(0, 0, prefsize.width, prefsize.height); } - } - - public Dimension getMinimumSize() - { - return getPreferredSize(); - } - - public void paintComponent(Graphics g) - { - //Only create the image at the beginning - - if ( (img == null) || (prefsize.width != getWidth()) || - (prefsize.height != getHeight())) + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void drawScene(Graphics g) { - prefsize.width = getWidth(); - prefsize.height = getHeight(); + boolean darker = false; - scale = findScale(); + int halfwidth = getWidth() / 2; + int halfheight = getHeight() / 2; - // System.out.println("New scale = " + scale); - img = createImage(getWidth(), getHeight()); - ig = img.getGraphics(); - } + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + int x = (int) ((float) (sp.coord[0] - centre[0]) * scale) + + halfwidth; + int y = (int) ((float) (sp.coord[1] - centre[1]) * scale) + + halfheight; + float z = sp.coord[1] - centre[2]; + + if (sp.sequence.getColor() == Color.black) + { + g.setColor(Color.white); + } + else + { + g.setColor(sp.sequence.getColor()); + } + + if (av.getSelectionGroup() != null) + { + if (av.getSelectionGroup().sequences.contains( + ((SequencePoint) points.elementAt(i)).sequence)) + { + g.setColor(Color.gray); + } + } + + if (z < 0) + { + g.setColor(g.getColor().darker()); + } + + g.fillRect(x - 3, y - 3, 6, 6); + g.setColor(Color.red); + } - drawBackground(ig, Color.black); - drawScene(ig); + // //Now the rectangle + // if (rectx2 != -1 && recty2 != -1) { + // g.setColor(Color.white); + // + // g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); + // } + } - if (drawAxes == true) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Dimension minimumsize() { - drawAxes(ig); + return prefsize; } - g.drawImage(img, 0, 0, this); - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Dimension preferredsize() + { + return prefsize; + } - public void drawAxes(Graphics g) - { - g.setColor(Color.yellow); + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void keyTyped(KeyEvent evt) + { + } - for (int i = 0; i < 3; i++) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void keyReleased(KeyEvent evt) { - g.drawLine(getWidth() / 2, getHeight() / 2, - (int) ( (axes[i][0] * scale * max[0]) + (getWidth() / 2)), - (int) ( (axes[i][1] * scale * max[1]) + (getHeight() / 2))); } - } - public void drawBackground(Graphics g, Color col) - { - g.setColor(col); - g.fillRect(0, 0, prefsize.width, prefsize.height); - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void keyPressed(KeyEvent evt) + { + requestFocus(); + + if (evt.getKeyCode() == KeyEvent.VK_UP) + { + scalefactor = (float) (scalefactor * 1.1); + scale = findScale(); + } + else if (evt.getKeyCode() == KeyEvent.VK_DOWN) + { + scalefactor = (float) (scalefactor * 0.9); + scale = findScale(); + } + else if (evt.getKeyChar() == 's') + { + System.err.println("DEBUG: Rectangle selection"); // log.debug - public void drawScene(Graphics g) - { - boolean darker = false; + if ((rectx2 != -1) && (recty2 != -1)) + { + rectSelect(rectx1, recty1, rectx2, recty2); + } + } - int halfwidth = getWidth() / 2; - int halfheight = getHeight() / 2; + repaint(); + } - for (int i = 0; i < npoint; i++) + /** + * DOCUMENT ME! + */ + public void printPoints() { - SequencePoint sp = (SequencePoint) points.elementAt(i); - int x = (int) ( (float) (sp.coord[0] - centre[0]) * scale) + - halfwidth; - int y = (int) ( (float) (sp.coord[1] - centre[1]) * scale) + - halfheight; - float z = sp.coord[1] - centre[2]; - - if (sp.sequence.getColor() == Color.black) - { - g.setColor(Color.white); - } - else - { - g.setColor(sp.sequence.getColor()); - } - - if (av.getSelectionGroup() != null) - { - if (av.getSelectionGroup().sequences.contains( - ( (SequencePoint) points.elementAt(i)).sequence)) + for (int i = 0; i < npoint; i++) { - g.setColor(Color.gray); - } - } + SequencePoint sp = (SequencePoint) points.elementAt(i); + Format.print(System.out, "%5d ", i); - if (z < 0) - { - g.setColor(g.getColor().darker()); - } + for (int j = 0; j < 3; j++) + { + Format.print(System.out, "%13.3f ", sp.coord[j]); + } - g.fillRect(x - 3, y - 3, 6, 6); - g.setColor(Color.red); + System.out.println(); + } } - // //Now the rectangle - // if (rectx2 != -1 && recty2 != -1) { - // g.setColor(Color.white); - // - // g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); - // } - } - - public Dimension minimumsize() - { - return prefsize; - } - - public Dimension preferredsize() - { - return prefsize; - } - - public void keyTyped(KeyEvent evt) - { - } - - public void keyReleased(KeyEvent evt) - { - } - - public void keyPressed(KeyEvent evt) - { - requestFocus(); - - if (evt.getKeyCode() == KeyEvent.VK_UP) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseClicked(MouseEvent evt) { - scalefactor = (float) (scalefactor * 1.1); - scale = findScale(); } - else if (evt.getKeyCode() == KeyEvent.VK_DOWN) + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseEntered(MouseEvent evt) { - scalefactor = (float) (scalefactor * 0.9); - scale = findScale(); } - else if (evt.getKeyChar() == 's') - { - System.err.println("DEBUG: Rectangle selection"); // log.debug - if ( (rectx2 != -1) && (recty2 != -1)) - { - rectSelect(rectx1, recty1, rectx2, recty2); - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseExited(MouseEvent evt) + { } - repaint(); - } - - public void printPoints() - { - for (int i = 0; i < npoint; i++) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseReleased(MouseEvent evt) { - SequencePoint sp = (SequencePoint) points.elementAt(i); - Format.print(System.out, "%5d ", i); - - for (int j = 0; j < 3; j++) - { - Format.print(System.out, "%13.3f ", sp.coord[j]); - } - - System.out.println(); } - } - - public void mouseClicked(MouseEvent evt) - { - } - - public void mouseEntered(MouseEvent evt) - { - } - public void mouseExited(MouseEvent evt) - { - } - - public void mouseReleased(MouseEvent evt) - { - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mousePressed(MouseEvent evt) + { + int x = evt.getX(); + int y = evt.getY(); - public void mousePressed(MouseEvent evt) - { - int x = evt.getX(); - int y = evt.getY(); + mx = x; + my = y; - mx = x; - my = y; + omx = mx; + omy = my; - omx = mx; - omy = my; + startx = x; + starty = y; - startx = x; - starty = y; + rectx1 = x; + recty1 = y; - rectx1 = x; - recty1 = y; + rectx2 = -1; + recty2 = -1; - rectx2 = -1; - recty2 = -1; + SequenceI found = findPoint(x, y); - SequenceI found = findPoint(x, y); + if (found != null) + { + if (av.getSelectionGroup() != null) + { + av.getSelectionGroup().addOrRemove(found, true); + PaintRefresher.Refresh(this, av.alignment); + } + else + { + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().addOrRemove(found, true); + av.getSelectionGroup().setEndRes(av.alignment.getWidth()); + } + } - if (found != null) - { - if (av.getSelectionGroup() != null) - { - av.getSelectionGroup().addOrRemove(found, true); - PaintRefresher.Refresh(this, av.alignment); - } - else - { - av.setSelectionGroup(new SequenceGroup()); - av.getSelectionGroup().addOrRemove(found, true); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()); - } + repaint(); } - repaint(); - } - - // private void fireSequenceSelectionEvent(Selection sel) { - // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); - //} - public void mouseMoved(MouseEvent evt) - { - SequenceI found = findPoint(evt.getX(), evt.getY()); - - if (found != null) - { - this.setToolTipText(found.getName()); - } - else + // private void fireSequenceSelectionEvent(Selection sel) { + // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); + //} + public void mouseMoved(MouseEvent evt) { - this.setToolTipText(null); - } - } + SequenceI found = findPoint(evt.getX(), evt.getY()); - public void mouseDragged(MouseEvent evt) - { - mx = evt.getX(); - my = evt.getY(); - - //Check if this is a rectangle drawing drag - if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) - { - // rectx2 = evt.getX(); - // recty2 = evt.getY(); + if (found != null) + { + this.setToolTipText(found.getName()); + } + else + { + this.setToolTipText(null); + } } - else + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void mouseDragged(MouseEvent evt) { - rotmat.setIdentity(); + mx = evt.getX(); + my = evt.getY(); - rotmat.rotate( (float) (my - omy), 'x'); - rotmat.rotate( (float) (mx - omx), 'y'); + //Check if this is a rectangle drawing drag + if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) + { + // rectx2 = evt.getX(); + // recty2 = evt.getY(); + } + else + { + rotmat.setIdentity(); - 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]; + rotmat.rotate((float) (my - omy), 'x'); + rotmat.rotate((float) (mx - omx), 'y'); - //Now apply the rotation matrix - sp.coord = rotmat.vectorMultiply(sp.coord); + 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 translate back again - 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); - for (int i = 0; i < 3; i++) - { - axes[i] = rotmat.vectorMultiply(axes[i]); - } + //Now translate back again + sp.coord[0] += centre[0]; + sp.coord[1] += centre[1]; + sp.coord[2] += centre[2]; + } - omx = mx; - omy = my; + for (int i = 0; i < 3; i++) + { + axes[i] = rotmat.vectorMultiply(axes[i]); + } - paint(this.getGraphics()); - } - } + omx = mx; + omy = my; - public void rectSelect(int x1, int y1, int x2, int y2) - { - boolean changedSel = false; + paint(this.getGraphics()); + } + } - for (int i = 0; i < npoint; i++) + /** + * DOCUMENT ME! + * + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param x2 DOCUMENT ME! + * @param y2 DOCUMENT ME! + */ + public void rectSelect(int x1, int y1, int x2, int y2) { - SequencePoint sp = (SequencePoint) points.elementAt(i); - int tmp1 = (int) ( ( (sp.coord[0] - centre[0]) * scale) + - ( (float) getWidth() / 2.0)); - int tmp2 = (int) ( ( (sp.coord[1] - centre[1]) * scale) + - ( (float) getHeight() / 2.0)); - - if ( (tmp1 > x1) && (tmp1 < x2) && (tmp2 > y1) && (tmp2 < y2)) - { - if (av != null) + boolean changedSel = false; + + for (int i = 0; i < npoint; i++) { - if (!av.getSelectionGroup().sequences.contains(sp.sequence)) - { - changedSel = true; - av.getSelectionGroup().addSequence(sp.sequence, true); - } + SequencePoint sp = (SequencePoint) points.elementAt(i); + int tmp1 = (int) (((sp.coord[0] - centre[0]) * scale) + + ((float) getWidth() / 2.0)); + int tmp2 = (int) (((sp.coord[1] - centre[1]) * scale) + + ((float) getHeight() / 2.0)); + + if ((tmp1 > x1) && (tmp1 < x2) && (tmp2 > y1) && (tmp2 < y2)) + { + if (av != null) + { + if (!av.getSelectionGroup().sequences.contains(sp.sequence)) + { + changedSel = true; + av.getSelectionGroup().addSequence(sp.sequence, true); + } + } + } } - } - } - // if (changedSel) { - // fireSequenceSelectionEvent(av.getSelection()); - // } - } + // if (changedSel) { + // fireSequenceSelectionEvent(av.getSelection()); + // } + } - public SequenceI findPoint(int x, int y) - { - int halfwidth = getWidth() / 2; - int halfheight = getHeight() / 2; + /** + * DOCUMENT ME! + * + * @param x DOCUMENT ME! + * @param y DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceI findPoint(int x, int y) + { + int halfwidth = getWidth() / 2; + int halfheight = getHeight() / 2; - int found = -1; + int found = -1; - for (int i = 0; i < npoint; i++) - { - SequencePoint sp = (SequencePoint) points.elementAt(i); - int px = (int) ( (float) (sp.coord[0] - centre[0]) * scale) + - halfwidth; - int py = (int) ( (float) (sp.coord[1] - centre[1]) * scale) + - halfheight; - - if ( (Math.abs(px - x) < 3) && (Math.abs(py - y) < 3)) - { - found = i; - } - } + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + int px = (int) ((float) (sp.coord[0] - centre[0]) * scale) + + halfwidth; + int py = (int) ((float) (sp.coord[1] - centre[1]) * scale) + + halfheight; + + if ((Math.abs(px - x) < 3) && (Math.abs(py - y) < 3)) + { + found = i; + } + } - if (found != -1) - { - return ( (SequencePoint) points.elementAt(found)).sequence; - } - else - { - return null; + if (found != -1) + { + return ((SequencePoint) points.elementAt(found)).sequence; + } + else + { + return null; + } } - } - /* public boolean handleRubberbandEvent(RubberbandEvent evt) { - System.out.println("Rubberband handler called in RotatableCanvas with " + - evt.getBounds()); + /* public boolean handleRubberbandEvent(RubberbandEvent evt) { + System.out.println("Rubberband handler called in RotatableCanvas with " + + evt.getBounds()); - Rubberband rb = (Rubberband)evt.getSource(); + Rubberband rb = (Rubberband)evt.getSource(); - // Clear the current selection (instance variable) - //if ((rb.getModifiers() & Event.SHIFT_MASK) == 0) { - // clearSelection(); - //} + // Clear the current selection (instance variable) + //if ((rb.getModifiers() & Event.SHIFT_MASK) == 0) { + // clearSelection(); + //} - if (rb.getComponent() == this) { - Rectangle bounds = evt.getBounds(); - rectSelect(bounds.x,bounds.y,bounds.x+bounds.width,bounds.y+bounds.height); - } + if (rb.getComponent() == this) { + Rectangle bounds = evt.getBounds(); + rectSelect(bounds.x,bounds.y,bounds.x+bounds.width,bounds.y+bounds.height); + } - redrawneeded = true; - paint(this.getGraphics()); + redrawneeded = true; + paint(this.getGraphics()); - return true; - }*/ + return true; + }*/ } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 73a9e6e..486b87a 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -18,227 +18,264 @@ */ package jalview.gui; +import jalview.datamodel.*; + import java.awt.*; import java.awt.event.*; + import javax.swing.*; -import jalview.datamodel.*; -public class ScalePanel - extends JPanel +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class ScalePanel extends JPanel { - protected int offy = 4; - public int width; - protected AlignViewport av; - AlignmentPanel ap; - boolean stretchingGroup = false; - - int min, max; //used by mouseDragged to see if user - // wants to delete columns - - public ScalePanel(AlignViewport av, AlignmentPanel ap) - { - this.av = av; - this.ap = ap; - - addMouseListener(new MouseAdapter() + protected int offy = 4; + + /** DOCUMENT ME!! */ + public int width; + protected AlignViewport av; + AlignmentPanel ap; + boolean stretchingGroup = false; + int min; //used by mouseDragged to see if user + int max; //used by mouseDragged to see if user + + // wants to delete columns + public ScalePanel(AlignViewport av, AlignmentPanel ap) { - public void mousePressed(MouseEvent evt) - { - doMousePressed(evt); - } - - public void mouseReleased(MouseEvent evt) - { - doMouseReleased(evt); - } - }); - addMouseMotionListener(new MouseMotionAdapter() - { - public void mouseDragged(MouseEvent evt) - { - doMouseDragged(evt); - } - }); - } - - public void doMousePressed(MouseEvent evt) - { - int x = evt.getX(); - int res = (x / av.getCharWidth()) + av.getStartRes(); - SequenceGroup sg = null; - - min=res; - max=res; - - if (av.getColumnSelection().contains(res)) - { - av.getColumnSelection().removeElement(res); - ap.annotationPanel.removeEditableColumn(res); + this.av = av; + this.ap = ap; + + addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent evt) + { + doMousePressed(evt); + } + + public void mouseReleased(MouseEvent evt) + { + doMouseReleased(evt); + } + }); + addMouseMotionListener(new MouseMotionAdapter() + { + public void mouseDragged(MouseEvent evt) + { + doMouseDragged(evt); + } + }); } - else + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMousePressed(MouseEvent evt) { - av.getColumnSelection().addElement(res); - sg = new SequenceGroup(); + int x = evt.getX(); + int res = (x / av.getCharWidth()) + av.getStartRes(); + SequenceGroup sg = null; + + min = res; + max = res; + + if (av.getColumnSelection().contains(res)) + { + av.getColumnSelection().removeElement(res); + ap.annotationPanel.removeEditableColumn(res); + } + else + { + av.getColumnSelection().addElement(res); + sg = new SequenceGroup(); - for (int i = 0; i < av.alignment.getSequences().size(); i++) - { - sg.addSequence(av.alignment.getSequenceAt(i), false); - } + for (int i = 0; i < av.alignment.getSequences().size(); i++) + { + sg.addSequence(av.alignment.getSequenceAt(i), false); + } - sg.setStartRes(res); - sg.setEndRes(res); + sg.setStartRes(res); + sg.setEndRes(res); + } + av.setSelectionGroup(sg); + ap.repaint(); } - av.setSelectionGroup(sg); - ap.repaint(); - } - - public void doMouseReleased(MouseEvent evt) - { - int x = evt.getX(); - int res = (x / av.getCharWidth()) + av.getStartRes(); - - if(av.getColumnSelection()!=null) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseReleased(MouseEvent evt) { - for(int i=0; i sg.getStartRes()) + { + sg.setEndRes(res); + } + else if (res < sg.getStartRes()) + { + sg.setStartRes(res); + } + + stretchingGroup = false; + ap.repaint(); } - if (!stretchingGroup) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseDragged(MouseEvent evt) { - ap.repaint(); - return; + int x = evt.getX(); + int res = (x / av.getCharWidth()) + av.getStartRes(); + + if (res < min) + { + min = res; + } + + if (res > max) + { + max = res; + } + + SequenceGroup sg = av.getSelectionGroup(); + + if (sg != null) + { + stretchingGroup = true; + + if (!av.getColumnSelection().contains(res)) + { + av.getColumnSelection().addElement(res); + } + + if (res > sg.getStartRes()) + { + sg.setEndRes(res); + } + else if (res < sg.getStartRes()) + { + sg.setStartRes(res); + } + + for (int i = min; i <= max; i++) + { + if ((i < sg.getStartRes()) || (i > sg.getEndRes())) + { + av.getColumnSelection().removeElement(i); + ap.annotationPanel.removeEditableColumn(res); + } + else + { + av.getColumnSelection().addElement(i); + } + } + + ap.repaint(); + } } - SequenceGroup sg = av.getSelectionGroup(); - - if (res > sg.getStartRes()) - { - sg.setEndRes(res); - } - else if (res < sg.getStartRes()) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - sg.setStartRes(res); + drawScale(g, av.getStartRes(), av.getEndRes(), getWidth(), getHeight()); } - stretchingGroup = false; - ap.repaint(); - } - - public void doMouseDragged(MouseEvent evt) - { - int x = evt.getX(); - int res = (x / av.getCharWidth()) + av.getStartRes(); - - if(res < min) - min = res; - if(res>max) - max = res; - - SequenceGroup sg = av.getSelectionGroup(); - - if (sg != null) + // scalewidth will normally be screenwidth, + public void drawScale(Graphics g, int startx, int endx, int width, + int height) { - stretchingGroup = true; - if (!av.getColumnSelection().contains(res)) - { - av.getColumnSelection().addElement(res); - } - - - if (res > sg.getStartRes()) - { - sg.setEndRes(res); - } - else if (res < sg.getStartRes()) - { - sg.setStartRes(res); - } - - for(int i=min; i<=max; i++) - { - if (i < sg.getStartRes() || i > sg.getEndRes()) - { - av.getColumnSelection().removeElement(i); - ap.annotationPanel.removeEditableColumn(res); - } - else - av.getColumnSelection().addElement(i); - } - ap.repaint(); - } - } - - public void paintComponent(Graphics g) - { - drawScale(g, av.getStartRes(), av.getEndRes(), getWidth(), getHeight()); - } - - // scalewidth will normally be screenwidth, - public void drawScale(Graphics g, int startx, int endx, int width, - int height) - { - Graphics2D gg = (Graphics2D) g; - gg.setFont(av.getFont()); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - //Fill in the background - gg.setColor(Color.white); - gg.fillRect(0, 0, width, height); - gg.setColor(Color.black); - - //Fill the selected columns - ColumnSelection cs = av.getColumnSelection(); - gg.setColor(new Color(220, 0, 0)); - - for (int i = 0; i < cs.size(); i++) - { - int sel = cs.columnAt(i); - - if ( (sel >= startx) && (sel <= endx)) - { - gg.fillRect( (sel - startx) * av.charWidth, 0, av.charWidth, + Graphics2D gg = (Graphics2D) g; + gg.setFont(av.getFont()); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + //Fill in the background + gg.setColor(Color.white); + gg.fillRect(0, 0, width, height); + gg.setColor(Color.black); + + //Fill the selected columns + ColumnSelection cs = av.getColumnSelection(); + gg.setColor(new Color(220, 0, 0)); + + for (int i = 0; i < cs.size(); i++) + { + int sel = cs.columnAt(i); + + if ((sel >= startx) && (sel <= endx)) + { + gg.fillRect((sel - startx) * av.charWidth, 0, av.charWidth, getHeight()); - } - } - - // Draw the scale numbers - gg.setColor(Color.black); - - int scalestartx = (startx / 10) * 10; - - FontMetrics fm = gg.getFontMetrics(av.getFont()); - int y = av.charHeight - fm.getDescent(); - - if ( (scalestartx % 10) == 0) - { - scalestartx += 5; - } - - for (int i = scalestartx; i < endx; i += 5) - { - if ( (i % 10) == 0) - { - gg.drawString(String.valueOf(i), - (i - startx - 1) * av.charWidth, y); - gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + 2, - (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + (fm.getDescent() * 2)); - } - else - { - gg.drawLine( (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + fm.getDescent(), - (int) ( ( (i - startx - 1) * av.charWidth) + - (av.charWidth / 2)), y + (fm.getDescent() * 2)); - } + } + } + + // Draw the scale numbers + gg.setColor(Color.black); + + int scalestartx = (startx / 10) * 10; + + FontMetrics fm = gg.getFontMetrics(av.getFont()); + int y = av.charHeight - fm.getDescent(); + + if ((scalestartx % 10) == 0) + { + scalestartx += 5; + } + + for (int i = scalestartx; i < endx; i += 5) + { + if ((i % 10) == 0) + { + gg.drawString(String.valueOf(i), + (i - startx - 1) * av.charWidth, y); + gg.drawLine((int) (((i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + 2, + (int) (((i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + (fm.getDescent() * 2)); + } + else + { + gg.drawLine((int) (((i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + fm.getDescent(), + (int) (((i - startx - 1) * av.charWidth) + + (av.charWidth / 2)), y + (fm.getDescent() * 2)); + } + } } - } } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index c442465..841f929 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -18,574 +18,641 @@ */ package jalview.gui; +import jalview.datamodel.*; + import java.awt.*; import java.awt.image.*; + import javax.swing.*; -import jalview.analysis.*; -import jalview.datamodel.*; -public class SeqCanvas - extends JComponent +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SeqCanvas extends JComponent { - FeatureRenderer fr; - SequenceRenderer sr; - BufferedImage img; - Graphics2D gg; - int imgWidth; - int imgHeight; - AlignViewport av; - boolean showScores = false; - boolean displaySearch = false; - int[] searchResults = null; - int chunkHeight; - int chunkWidth; - boolean fastPaint = false; - 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, av.alignment); - setBackground(Color.white); - } - - void drawNorthScale(Graphics g, int startx, int endx, int ypos) - { - int scalestartx = startx - (startx % 10) + 10; - - g.setColor(Color.black); - - // NORTH SCALE - for (int i = scalestartx; i < endx; i += 10) + FeatureRenderer fr; + SequenceRenderer sr; + BufferedImage img; + Graphics2D gg; + int imgWidth; + int imgHeight; + AlignViewport av; + boolean showScores = false; + boolean displaySearch = false; + int[] searchResults = null; + int chunkHeight; + int chunkWidth; + boolean fastPaint = false; + int LABEL_WEST; + int LABEL_EAST; + + /** + * Creates a new SeqCanvas object. + * + * @param av DOCUMENT ME! + */ + public SeqCanvas(AlignViewport av) { - String string = String.valueOf(i); - g.drawString(string, (i - startx - 1) * av.charWidth, - ypos - (av.charHeight / 2)); - - g.drawLine( ( (i - startx - 1) * av.charWidth) + (av.charWidth / 2), - (ypos + 2) - (av.charHeight / 2), - ( (i - startx - 1) * av.charWidth) + (av.charWidth / 2), ypos - - 2); + this.av = av; + fr = new FeatureRenderer(av); + sr = new SequenceRenderer(av); + setLayout(new BorderLayout()); + PaintRefresher.Register(this, av.alignment); + setBackground(Color.white); } - } - void drawWestScale(Graphics g, int startx, int endx, int ypos) - { - FontMetrics fm = getFontMetrics(av.getFont()); - ypos += av.charHeight; + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param startx DOCUMENT ME! + * @param endx DOCUMENT ME! + * @param ypos DOCUMENT ME! + */ + void drawNorthScale(Graphics g, int startx, int endx, int ypos) + { + int scalestartx = startx - (startx % 10) + 10; + + g.setColor(Color.black); - // EAST SCALE - for (int i = 0; i < av.alignment.getHeight(); i++) + // NORTH SCALE + for (int i = scalestartx; i < endx; i += 10) + { + String string = String.valueOf(i); + g.drawString(string, (i - startx - 1) * av.charWidth, + ypos - (av.charHeight / 2)); + + g.drawLine(((i - startx - 1) * av.charWidth) + (av.charWidth / 2), + (ypos + 2) - (av.charHeight / 2), + ((i - startx - 1) * av.charWidth) + (av.charWidth / 2), ypos - + 2); + } + } + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param startx DOCUMENT ME! + * @param endx DOCUMENT ME! + * @param ypos DOCUMENT ME! + */ + void drawWestScale(Graphics g, int startx, int endx, int ypos) { - SequenceI seq = av.alignment.getSequenceAt(i); - int index = startx; - int value = -1; + FontMetrics fm = getFontMetrics(av.getFont()); + ypos += av.charHeight; - while (index < endx) - { - if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + // EAST SCALE + for (int i = 0; i < av.alignment.getHeight(); i++) { - index++; + SequenceI seq = av.alignment.getSequenceAt(i); + int index = startx; + int value = -1; - continue; - } + while (index < endx) + { + if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + { + index++; - value = av.alignment.getSequenceAt(i).findPosition(index); + continue; + } - break; - } + value = av.alignment.getSequenceAt(i).findPosition(index); - if (value != -1) - { - int x = LABEL_WEST - fm.stringWidth(value + ""); - g.drawString(value + "", x, - (ypos + (i * av.charHeight)) - (av.charHeight / 5)); - } - } - } + break; + } - void drawEastScale(Graphics g, int startx, int endx, int ypos) - { - ypos += av.charHeight; + if (value != -1) + { + int x = LABEL_WEST - fm.stringWidth(value + ""); + g.drawString(value + "", x, + (ypos + (i * av.charHeight)) - (av.charHeight / 5)); + } + } + } - // EAST SCALE - for (int i = 0; i < av.alignment.getHeight(); i++) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param startx DOCUMENT ME! + * @param endx DOCUMENT ME! + * @param ypos DOCUMENT ME! + */ + void drawEastScale(Graphics g, int startx, int endx, int ypos) { - SequenceI seq = av.alignment.getSequenceAt(i); - int index = endx; - int value = -1; + ypos += av.charHeight; - while (index > startx) - { - if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + // EAST SCALE + for (int i = 0; i < av.alignment.getHeight(); i++) { - index--; + SequenceI seq = av.alignment.getSequenceAt(i); + int index = endx; + int value = -1; - continue; - } + while (index > startx) + { + if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + { + index--; + + continue; + } - value = av.alignment.getSequenceAt(i).findPosition(index); + value = av.alignment.getSequenceAt(i).findPosition(index); - break; - } + break; + } - if (value != -1) - { - g.drawString(value + "", 0, - (ypos + (i * av.charHeight)) - (av.charHeight / 5)); - } + if (value != -1) + { + g.drawString(value + "", 0, + (ypos + (i * av.charHeight)) - (av.charHeight / 5)); + } + } } - } - public void fastPaint(int horizontal, int vertical) - { - if ( ( (horizontal == 0) && (vertical == 0)) || (gg == null)) + /** + * DOCUMENT ME! + * + * @param horizontal DOCUMENT ME! + * @param vertical DOCUMENT ME! + */ + public void fastPaint(int horizontal, int vertical) { - return; - } + if (((horizontal == 0) && (vertical == 0)) || (gg == null)) + { + return; + } - gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth, - -vertical * av.charHeight); + gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth, + -vertical * av.charHeight); - int sr = av.startRes; - int er = av.endRes; - int ss = av.startSeq; - int es = av.endSeq; - int transX = 0; - int transY = 0; + int sr = av.startRes; + int er = av.endRes; + int ss = av.startSeq; + int es = av.endSeq; + int transX = 0; + int transY = 0; - if (horizontal > 0) // scrollbar pulled right, image to the left - { - transX = (er - sr - horizontal) * av.charWidth; - sr = er - horizontal; - } - else if (horizontal < 0) - { - er = sr - horizontal; - } - else if (vertical > 0) // scroll down - { - ss = es - vertical; - - if (ss < av.startSeq) - { // ie scrolling too fast, more than a page at a time - ss = av.startSeq; - } - else - { - transY = imgHeight - (vertical * av.charHeight); - } - } - else if (vertical < 0) - { - es = ss - vertical; + if (horizontal > 0) // scrollbar pulled right, image to the left + { + transX = (er - sr - horizontal) * av.charWidth; + sr = er - horizontal; + } + else if (horizontal < 0) + { + er = sr - horizontal; + } + else if (vertical > 0) // scroll down + { + ss = es - vertical; - if (es > av.endSeq) - { - es = av.endSeq; - } - } + if (ss < av.startSeq) + { // ie scrolling too fast, more than a page at a time + ss = av.startSeq; + } + else + { + transY = imgHeight - (vertical * av.charHeight); + } + } + else if (vertical < 0) + { + es = ss - vertical; - gg.translate(transX, transY); - - gg.setColor(Color.white); - gg.fillRect(0, 0, (er - sr + 1) * av.charWidth, - (es - ss) * av.charHeight); - drawPanel(gg, sr, er, ss, es, sr, ss, 0); - gg.translate( -transX, -transY); - - fastPaint = true; - repaint(); - } - - /** - * Definitions of startx and endx (hopefully): - * SMJS This is what I'm working towards! - * startx is the first residue (starting at 0) to display. - * endx is the last residue to display (starting at 0). - * starty is the first sequence to display (starting at 0). - * endy is the last sequence to display (starting at 0). - * 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) - { - if (img!=null - && (fastPaint || getWidth() != g.getClipBounds().width - || getHeight() != g.getClipBounds().height)) - { - g.drawImage(img, 0, 0, this); - fastPaint = false; - return; - } + if (es > av.endSeq) + { + es = av.endSeq; + } + } - // this draws the whole of the alignment - imgWidth = getWidth(); - imgHeight = getHeight(); + gg.translate(transX, transY); - imgWidth -= (imgWidth % av.charWidth); - imgHeight -= (imgHeight % av.charHeight); + gg.setColor(Color.white); + gg.fillRect(0, 0, (er - sr + 1) * av.charWidth, + (es - ss) * av.charHeight); + drawPanel(gg, sr, er, ss, es, sr, ss, 0); + gg.translate(-transX, -transY); - if ( (imgWidth < 1) || (imgHeight < 1)) - { - return; + fastPaint = true; + repaint(); } - img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) img.getGraphics(); - gg.setFont(av.getFont()); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + /** + * Definitions of startx and endx (hopefully): + * SMJS This is what I'm working towards! + * startx is the first residue (starting at 0) to display. + * endx is the last residue to display (starting at 0). + * starty is the first sequence to display (starting at 0). + * endy is the last sequence to display (starting at 0). + * 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) + { + if ((img != null) && + (fastPaint || (getWidth() != g.getClipBounds().width) || + (getHeight() != g.getClipBounds().height))) + { + g.drawImage(img, 0, 0, this); + fastPaint = false; - gg.setColor(Color.white); - gg.fillRect(0, 0, imgWidth, imgHeight); + return; + } - chunkWidth = getWrappedCanvasWidth(getWidth()); - chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; + // this draws the whole of the alignment + imgWidth = getWidth(); + imgHeight = getHeight(); - av.setChunkHeight(chunkHeight); - av.setChunkWidth(chunkWidth); + imgWidth -= (imgWidth % av.charWidth); + imgHeight -= (imgHeight % av.charHeight); - if (av.getWrapAlignment()) - { - drawWrappedPanel(gg, getWidth(), getHeight(), av.startRes); - } - else - { - drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, - av.startRes, av.startSeq, 0); - } + if ((imgWidth < 1) || (imgHeight < 1)) + { + return; + } - g.drawImage(img, 0, 0, this); - } + img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); + gg = (Graphics2D) img.getGraphics(); + gg.setFont(av.getFont()); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - public int getWrappedCanvasWidth(int cwidth) - { - FontMetrics fm = getFontMetrics(av.getFont()); + gg.setColor(Color.white); + gg.fillRect(0, 0, imgWidth, imgHeight); - LABEL_EAST = 0; - LABEL_WEST = 0; + chunkWidth = getWrappedCanvasWidth(getWidth()); + chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - if (av.scaleRightWrapped) - { - LABEL_EAST = fm.stringWidth(av.alignment.getWidth() + "000"); + av.setChunkHeight(chunkHeight); + av.setChunkWidth(chunkWidth); + + if (av.getWrapAlignment()) + { + drawWrappedPanel(gg, getWidth(), getHeight(), av.startRes); + } + else + { + drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, + av.startRes, av.startSeq, 0); + } + + g.drawImage(img, 0, 0, this); } - if (av.scaleLeftWrapped) + /** + * DOCUMENT ME! + * + * @param cwidth DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getWrappedCanvasWidth(int cwidth) { - LABEL_WEST = fm.stringWidth(av.alignment.getWidth() + ""); - } + FontMetrics fm = getFontMetrics(av.getFont()); - return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - } + LABEL_EAST = 0; + LABEL_WEST = 0; - public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, - int startRes) - { - AlignmentI al = av.getAlignment(); + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(av.alignment.getWidth() + "000"); + } - FontMetrics fm = getFontMetrics(av.getFont()); + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(av.alignment.getWidth() + ""); + } - int LABEL_EAST = 0; + return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + } - if (av.scaleRightWrapped) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param canvasWidth DOCUMENT ME! + * @param canvasHeight DOCUMENT ME! + * @param startRes DOCUMENT ME! + */ + public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, + int startRes) { - LABEL_EAST = fm.stringWidth(al.getWidth() + "000"); - } + AlignmentI al = av.getAlignment(); - int LABEL_WEST = 0; + FontMetrics fm = getFontMetrics(av.getFont()); - if (av.scaleLeftWrapped) - { - LABEL_WEST = fm.stringWidth(al.getWidth() + "0"); - } + int LABEL_EAST = 0; - int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; - int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(al.getWidth() + "000"); + } - av.endRes = av.startRes + cWidth; + int LABEL_WEST = 0; - int endx = (startRes + cWidth) - 1; - int ypos = 2 * av.charHeight; + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(al.getWidth() + "0"); + } - while ( (ypos <= canvasHeight) && (startRes < av.alignment.getWidth())) - { - g.setColor(Color.black); - - if (av.scaleLeftWrapped) - { - drawWestScale(g, startRes, endx, ypos); - } - - if (av.scaleRightWrapped) - { - g.translate(canvasWidth - LABEL_EAST + av.charWidth, 0); - drawEastScale(g, startRes, endx, ypos); - g.translate( - (canvasWidth - LABEL_EAST + av.charWidth), 0); - } - - g.translate(LABEL_WEST, 0); - - if (av.scaleAboveWrapped) - { - drawNorthScale(g, startRes, endx, ypos); - } - - // When printing we have an extra clipped region, - // the Printable page which we need to account for here - Shape clip = g.getClip(); - - if (clip == null) - { - g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); - } - else - { - g.setClip(0, (int) clip.getBounds().getY(), - cWidth * av.charWidth, (int) clip.getBounds().getHeight()); - } - - drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos); - g.setClip(clip); - g.translate( -LABEL_WEST, 0); - - ypos += cHeight; - startRes += cWidth; - endx = (startRes + cWidth) - 1; - - if (endx > al.getWidth()) - { - endx = al.getWidth(); - } - } - } + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1, - int y2, int startx, int starty, int offset) - { - Graphics2D g = (Graphics2D) g1; - g.setFont(av.getFont()); - sr.renderGaps(av.renderGaps); + av.endRes = av.startRes + cWidth; - SequenceI nextSeq; + int endx = (startRes + cWidth) - 1; + int ypos = 2 * av.charHeight; - /// First draw the sequences - ///////////////////////////// - for (int i = y1; i < y2; i++) - { - nextSeq = av.alignment.getSequenceAt(i); - - sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), - x1, x2, (x1 - startx) * av.charWidth, - offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), - av.charWidth, av.charHeight); - - if (av.showSequenceFeatures) - { - fr.drawSequence(g, nextSeq, - av.alignment.findAllGroups(nextSeq), x1, x2, - (x1 - startx) * av.charWidth, - offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight), - av.charWidth, av.charHeight); - } - } + while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth())) + { + g.setColor(Color.black); - // - ///////////////////////////////////// - // Now outline any areas if necessary - ///////////////////////////////////// - SequenceGroup group = av.getSelectionGroup(); - java.util.Vector groups = av.alignment.getGroups(); + if (av.scaleLeftWrapped) + { + drawWestScale(g, startRes, endx, ypos); + } - int sx = -1; - int sy = -1; - int ex = -1; - int groupIndex = -1; + if (av.scaleRightWrapped) + { + g.translate(canvasWidth - LABEL_EAST + av.charWidth, 0); + drawEastScale(g, startRes, endx, ypos); + g.translate(-(canvasWidth - LABEL_EAST + av.charWidth), 0); + } - if ( (group == null) && (groups.size() > 0)) - { - group = (SequenceGroup) groups.elementAt(0); - groupIndex = 0; - } + g.translate(LABEL_WEST, 0); - if (group != null) - { - do - { - int oldY = -1; - int i = 0; - boolean inGroup = false; - int top = -1; - int bottom = -1; - - for (i = y1; i < y2; i++) - { - sx = (group.getStartRes() - startx) * av.charWidth; - sy = offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight); - ex = ( ( (group.getEndRes() + 1) - group.getStartRes()) * - av.charWidth) - - 1; - - if ( (sx < getWidth()) && (ex > 0) && - group.sequences.contains(av.alignment.getSequenceAt( - i))) - { - if ( (bottom == -1) && - !group.sequences.contains( - av.alignment.getSequenceAt(i + 1))) + if (av.scaleAboveWrapped) { - bottom = sy + av.charHeight; + drawNorthScale(g, startRes, endx, ypos); } - if (!inGroup) + // When printing we have an extra clipped region, + // the Printable page which we need to account for here + Shape clip = g.getClip(); + + if (clip == null) { - if ( ( (top == -1) && (i == 0)) || - !group.sequences.contains( - av.alignment.getSequenceAt(i - 1))) - { - top = sy; - } - - oldY = sy; - inGroup = true; - - if (group == av.getSelectionGroup()) - { - g.setStroke(new BasicStroke(1, - BasicStroke.CAP_BUTT, - BasicStroke.JOIN_ROUND, 3f, - new float[] - {5f, 3f}, 0f)); - g.setColor(Color.RED); - } - else - { - g.setStroke(new BasicStroke()); - g.setColor(group.getOutlineColour()); - } + g.setClip(0, 0, cWidth * av.charWidth, canvasHeight); } - } - else - { - if (inGroup) + else { - g.drawLine(sx, oldY, sx, sy); - g.drawLine(sx + ex, oldY, sx + ex, sy); - - if (top != -1) - { - g.drawLine(sx, top, sx + ex, top); - top = -1; - } - - if (bottom != -1) - { - g.drawLine(sx, bottom, sx + ex, bottom); - bottom = -1; - } - - inGroup = false; + g.setClip(0, (int) clip.getBounds().getY(), + cWidth * av.charWidth, (int) clip.getBounds().getHeight()); + } + + drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos); + g.setClip(clip); + g.translate(-LABEL_WEST, 0); + + ypos += cHeight; + startRes += cWidth; + endx = (startRes + cWidth) - 1; + + if (endx > al.getWidth()) + { + endx = al.getWidth(); } - } } + } + + /** + * DOCUMENT ME! + * + * @param g1 DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param x2 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param y2 DOCUMENT ME! + * @param startx DOCUMENT ME! + * @param starty DOCUMENT ME! + * @param offset DOCUMENT ME! + */ + synchronized public void drawPanel(Graphics g1, int x1, int x2, int y1, + int y2, int startx, int starty, int offset) + { + Graphics2D g = (Graphics2D) g1; + g.setFont(av.getFont()); + sr.renderGaps(av.renderGaps); - if (inGroup) + SequenceI nextSeq; + + /// First draw the sequences + ///////////////////////////// + for (int i = y1; i < y2; i++) { - if (top != -1) - { - g.drawLine(sx, top, sx + ex, top); - top = -1; - } - - if (bottom != -1) - { - g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); - bottom = -1; - } - - sy = offset + - AlignmentUtil.getPixelHeight(starty, i, av.charHeight); - g.drawLine(sx, oldY, sx, sy); - g.drawLine(sx + ex, oldY, sx + ex, sy); - inGroup = false; + nextSeq = av.alignment.getSequenceAt(i); + + sr.drawSequence(g, nextSeq, av.alignment.findAllGroups(nextSeq), + x1, x2, (x1 - startx) * av.charWidth, + offset + ((i - starty) * av.charHeight), av.charWidth, + av.charHeight); + + if (av.showSequenceFeatures) + { + fr.drawSequence(g, nextSeq, + av.alignment.findAllGroups(nextSeq), x1, x2, + (x1 - startx) * av.charWidth, + offset + ((i - starty) * av.charHeight), av.charWidth, + av.charHeight); + } } - groupIndex++; + // + ///////////////////////////////////// + // Now outline any areas if necessary + ///////////////////////////////////// + SequenceGroup group = av.getSelectionGroup(); + java.util.Vector groups = av.alignment.getGroups(); + + int sx = -1; + int sy = -1; + int ex = -1; + int groupIndex = -1; - if (groupIndex >= groups.size()) + if ((group == null) && (groups.size() > 0)) { - break; + group = (SequenceGroup) groups.elementAt(0); + groupIndex = 0; } - group = (SequenceGroup) groups.elementAt(groupIndex); - } - while (groupIndex < groups.size()); - } - /// Highlight search Results once all sequences have been drawn - ////////////////////////////////////////////////////////// - if (displaySearch) - { - for (int r = 0; r < searchResults.length; r += 3) - { - int searchSeq = searchResults[r]; + if (group != null) + { + do + { + int oldY = -1; + int i = 0; + boolean inGroup = false; + int top = -1; + int bottom = -1; + + for (i = y1; i < y2; i++) + { + sx = (group.getStartRes() - startx) * av.charWidth; + sy = offset + ((i - starty) * av.charHeight); + ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - + 1; + + + if ((sx < (x2-x1)*av.charWidth) && + group.sequences.contains(av.alignment.getSequenceAt( + i))) + { + if ((bottom == -1) && + !group.sequences.contains( + av.alignment.getSequenceAt(i + 1))) + { + bottom = sy + av.charHeight; + } + + if (!inGroup) + { + if (((top == -1) && (i == 0)) || + !group.sequences.contains( + av.alignment.getSequenceAt(i - 1))) + { + top = sy; + } + + oldY = sy; + inGroup = true; + + if (group == av.getSelectionGroup()) + { + g.setStroke(new BasicStroke(1, + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_ROUND, 3f, + new float[] { 5f, 3f }, 0f)); + g.setColor(Color.RED); + } + else + { + g.setStroke(new BasicStroke()); + g.setColor(group.getOutlineColour()); + } + } + } + else + { + if (inGroup) + { + g.drawLine(sx, oldY, sx, sy); + g.drawLine(sx + ex, oldY, sx + ex, sy); + + if (top != -1) + { + g.drawLine(sx, top, sx + ex, top); + top = -1; + } + + if (bottom != -1) + { + g.drawLine(sx, bottom, sx + ex, bottom); + bottom = -1; + } + + inGroup = false; + } + } + } + + + if (inGroup) + { + if (top != -1) + { + g.drawLine(sx, top, sx + ex, top); + top = -1; + } + + if (bottom != -1) + { + g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); + bottom = -1; + } + + sy = offset + ((i - starty) * av.charHeight); + g.drawLine(sx, oldY, sx, sy); + g.drawLine(sx + ex, oldY, sx + ex, sy); + inGroup = false; + } + + groupIndex++; + + if (groupIndex >= groups.size()) + { + break; + } + + group = (SequenceGroup) groups.elementAt(groupIndex); + } + while (groupIndex < groups.size()); + } - if ( (searchSeq >= y1) && (searchSeq < y2)) + /// Highlight search Results once all sequences have been drawn + ////////////////////////////////////////////////////////// + if (displaySearch) { - SequenceI seq = av.getAlignment().getSequenceAt(searchSeq); + for (int r = 0; r < searchResults.length; r += 3) + { + int searchSeq = searchResults[r]; + + if ((searchSeq >= y1) && (searchSeq < y2)) + { + SequenceI seq = av.getAlignment().getSequenceAt(searchSeq); - int searchStart = seq.findIndex(searchResults[r + 1]) - 1; - int searchEnd = seq.findIndex(searchResults[r + 2]) - 1; + int searchStart = seq.findIndex(searchResults[r + 1]) - 1; + int searchEnd = seq.findIndex(searchResults[r + 2]) - 1; - SequenceRenderer ssr = (SequenceRenderer) sr; + SequenceRenderer ssr = (SequenceRenderer) sr; - if (searchStart < x1) - { - searchStart = x1; - } + if (searchStart < x1) + { + searchStart = x1; + } - if (searchEnd > x2) - { - searchEnd = x2; - } + if (searchEnd > x2) + { + searchEnd = x2; + } - ssr.drawHighlightedText(seq, searchStart, searchEnd, - (searchStart - startx) * av.charWidth, - offset + - AlignmentUtil.getPixelHeight(starty, - searchSeq, - av.charHeight), av.charWidth, av.charHeight); + ssr.drawHighlightedText(seq, searchStart, searchEnd, + (searchStart - startx) * av.charWidth, + offset + ((searchSeq - starty) * av.charHeight), + av.charWidth, av.charHeight); + } + } } - } } - } - public void highlightSearchResults(int[] results) - { - // results are in the order sequence, startRes, endRes - if (results == null) + /** + * DOCUMENT ME! + * + * @param results DOCUMENT ME! + */ + public void highlightSearchResults(int[] results) { - displaySearch = false; - } - else - { - displaySearch = true; - } + // results are in the order sequence, startRes, endRes + if (results == null) + { + displaySearch = false; + } + else + { + displaySearch = true; + } - searchResults = results; + searchResults = results; - repaint(); - } + repaint(); + } } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 2718ddb..db120e1 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -18,827 +18,912 @@ */ package jalview.gui; -import java.util.*; +import jalview.analysis.*; + +import jalview.datamodel.*; + +import jalview.schemes.*; import java.awt.*; import java.awt.event.*; + +import java.util.*; + import javax.swing.*; -import jalview.analysis.*; -import jalview.datamodel.*; -import jalview.schemes.*; -public class SeqPanel - extends JPanel +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SeqPanel extends JPanel { - public SeqCanvas seqCanvas; - public AlignmentPanel ap; - protected int lastres; - protected int startseq; - int startEdit = -1; - int endEdit = -1; - protected AlignViewport av; - - // if character is inserted or deleted, we will need to recalculate the conservation - int seqEditOccurred = -1; - ScrollThread scrollThread = null; - boolean mouseDragging = false; - boolean editingSeqs = false; - boolean groupEditing = false; - - ////////////////////////////////////////// - /////Everything below this is for defining the boundary of the rubberband - ////////////////////////////////////////// - int oldSeq = -1; - boolean changeEndSeq = false; - boolean changeStartSeq = false; - boolean changeEndRes = false; - boolean changeStartRes = false; - SequenceGroup stretchGroup = null; - boolean remove = false; - - public SeqPanel(AlignViewport avp, AlignmentPanel p) - { - ToolTipManager.sharedInstance().registerComponent(this); - ToolTipManager.sharedInstance().setInitialDelay(0); - ToolTipManager.sharedInstance().setDismissDelay(10000); - this.av = avp; - setBackground(Color.white); - - seqCanvas = new SeqCanvas(avp); - setLayout(new BorderLayout()); - add(seqCanvas, BorderLayout.CENTER); - - ap = p; - - addMouseMotionListener(new MouseMotionAdapter() - { - public void mouseMoved(MouseEvent evt) - { - if (av.getWrapAlignment()) + /** DOCUMENT ME!! */ + public SeqCanvas seqCanvas; + + /** DOCUMENT ME!! */ + public AlignmentPanel ap; + protected int lastres; + protected int startseq; + int startEdit = -1; + int endEdit = -1; + protected AlignViewport av; + + // if character is inserted or deleted, we will need to recalculate the conservation + int seqEditOccurred = -1; + ScrollThread scrollThread = null; + boolean mouseDragging = false; + boolean editingSeqs = false; + boolean groupEditing = false; + + ////////////////////////////////////////// + /////Everything below this is for defining the boundary of the rubberband + ////////////////////////////////////////// + int oldSeq = -1; + boolean changeEndSeq = false; + boolean changeStartSeq = false; + boolean changeEndRes = false; + boolean changeStartRes = false; + SequenceGroup stretchGroup = null; + boolean remove = false; + + /** + * Creates a new SeqPanel object. + * + * @param avp DOCUMENT ME! + * @param p DOCUMENT ME! + */ + public SeqPanel(AlignViewport avp, AlignmentPanel p) + { + ToolTipManager.sharedInstance().registerComponent(this); + ToolTipManager.sharedInstance().setInitialDelay(0); + ToolTipManager.sharedInstance().setDismissDelay(10000); + this.av = avp; + setBackground(Color.white); + + seqCanvas = new SeqCanvas(avp); + setLayout(new BorderLayout()); + add(seqCanvas, BorderLayout.CENTER); + + ap = p; + + addMouseMotionListener(new MouseMotionAdapter() + { + public void mouseMoved(MouseEvent evt) + { + if (av.getWrapAlignment()) + { + return; + } + + doMouseMoved(evt); + } + + public void mouseDragged(MouseEvent evt) + { + if (av.getWrapAlignment()) + { + return; + } + + if (editingSeqs) + { + doMouseDragged(evt); + } + else + { + doMouseDraggedDefineMode(evt); + } + } + }); + + addMouseListener(new MouseAdapter() + { + public void mouseReleased(MouseEvent evt) + { + if (av.getWrapAlignment()) + { + return; + } + + if (editingSeqs) + { + doMouseReleased(evt); + } + else + { + doMouseReleasedDefineMode(evt); + } + } + + public void mousePressed(MouseEvent evt) + { + if (av.getWrapAlignment()) + { + return; + } + + if (evt.isShiftDown() || evt.isAltDown() || + evt.isControlDown()) + { + if (evt.isAltDown() || evt.isControlDown()) + { + groupEditing = true; + } + + editingSeqs = true; + doMousePressed(evt); + } + else + { + doMousePressedDefineMode(evt); + } + } + + public void mouseExited(MouseEvent evt) + { + if (av.getWrapAlignment() || editingSeqs) + { + return; + } + + doMouseExitedDefineMode(evt); + } + + public void mouseEntered(MouseEvent evt) + { + if (av.getWrapAlignment() || editingSeqs) + { + return; + } + + doMouseEnteredDefineMode(evt); + } + }); + } + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseReleased(MouseEvent evt) + { + if (seqEditOccurred > -1) { - return; + editOccurred(seqEditOccurred); } - doMouseMoved(evt); - } + startseq = -1; + lastres = -1; + seqEditOccurred = -1; + editingSeqs = false; + groupEditing = false; - public void mouseDragged(MouseEvent evt) - { - if (av.getWrapAlignment()) - { - return; - } + ap.repaint(); + } + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMousePressed(MouseEvent evt) + { + ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence", + av.alignment, HistoryItem.EDIT)); + + int seq; + int res; + + int x = evt.getX(); + int y = evt.getY(); - if (editingSeqs) + res = (x / av.getCharWidth()) + av.getStartRes(); + seq = (y / av.getCharHeight()) + av.getStartSeq(); + + if ((seq < av.getAlignment().getHeight()) && + (res < av.getAlignment().getSequenceAt(seq).getLength())) { - doMouseDragged(evt); + startseq = seq; + lastres = res; } else { - doMouseDraggedDefineMode(evt); + startseq = -1; + lastres = -1; } - } - }); - addMouseListener(new MouseAdapter() + startEdit = lastres; + endEdit = lastres; + + return; + } + + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseMoved(MouseEvent evt) { - public void mouseReleased(MouseEvent evt) - { - if (av.getWrapAlignment()) - { - return; - } + int res = 0; + int seq = 0; + int x = evt.getX(); + int y = evt.getY(); - if (editingSeqs) + if (av.wrapAlignment) { - doMouseReleased(evt); - } - else - { - doMouseReleasedDefineMode(evt); - } - } + y -= (2 * av.charHeight); - public void mousePressed(MouseEvent evt) - { - if (av.getWrapAlignment()) - { - return; - } + int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - if (evt.isShiftDown() || evt.isAltDown() || - evt.isControlDown()) - { - if (evt.isAltDown() || evt.isControlDown()) - { - groupEditing = true; - } + res = (int) ((y / chunkHeight) * (getWidth() / av.charWidth)) + + (x / av.getCharWidth()) + av.getStartRes(); - editingSeqs = true; - doMousePressed(evt); + y %= chunkHeight; + seq = (y / av.getCharHeight()) + av.getStartSeq(); } else { - doMousePressedDefineMode(evt); + res = (x / av.getCharWidth()) + av.getStartRes(); + seq = (y / av.getCharHeight()) + av.getStartSeq(); } - } - public void mouseExited(MouseEvent evt) - { - if (av.getWrapAlignment() || editingSeqs) + if (seq >= av.getAlignment().getHeight()) { - return; + return; } - doMouseExitedDefineMode(evt); - } + SequenceI sequence = av.getAlignment().getSequenceAt(seq); - public void mouseEntered(MouseEvent evt) - { - if (av.getWrapAlignment() || editingSeqs) + if (res > sequence.getLength()) { - return; + return; } - doMouseEnteredDefineMode(evt); - } - }); - } - - - public void doMouseReleased(MouseEvent evt) - { - if (seqEditOccurred > -1) - { - editOccurred(seqEditOccurred); - } + Object obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + + ""); + String aa = ""; - startseq = -1; - lastres = -1; - seqEditOccurred = -1; - editingSeqs = false; - groupEditing = false; + if (obj != null) + { + aa = obj.toString(); + } - ap.repaint(); - } + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + + sequence.getName()); - public void doMousePressed(MouseEvent evt) - { - ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence", - av.alignment, HistoryItem.EDIT)); + if (aa != "") + { + text.append(" Residue: " + aa + " (" + + av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + } - int seq; - int res; + ap.alignFrame.statusBar.setText(text.toString()); - int x = evt.getX(); - int y = evt.getY(); + // use aa to see if the mouse pointer is on a + if (av.showSequenceFeatures) + { + Vector features = sequence.getSequenceFeatures(); + Enumeration e = features.elements(); + StringBuffer sbuffer = new StringBuffer(); - res = (x / av.getCharWidth()) + av.getStartRes(); - seq = (y / av.getCharHeight()) + av.getStartSeq(); + while (e.hasMoreElements()) + { + SequenceFeature sf = (SequenceFeature) e.nextElement(); + + if ((sf.getStart() <= sequence.findPosition(res)) && + (sf.getEnd() >= sequence.findPosition(res))) + { + if (sbuffer.length() > 0) + { + sbuffer.append("; "); + } + + sbuffer.append(sf.getType() + " " + sf.getDescription()); + + if (sf.getStatus().length() > 0) + { + sbuffer.append(" (" + sf.getStatus() + ")"); + } + } + } - if ( (seq < av.getAlignment().getHeight()) && - (res < av.getAlignment().getSequenceAt(seq).getLength())) - { - startseq = seq; - lastres = res; - } - else - { - startseq = -1; - lastres = -1; + this.setToolTipText(sbuffer.toString()); + } } - startEdit = lastres; - endEdit = lastres; + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseDragged(MouseEvent evt) + { + // If we're dragging we're editing + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - return; - } + if (res < 0) + { + res = 0; + } - public void doMouseMoved(MouseEvent evt) - { - int res = 0; - int seq = 0; - int x = evt.getX(); - int y = evt.getY(); + if ((lastres == -1) || (lastres == res)) + { + return; + } - if (av.wrapAlignment) - { - y -= (2 * av.charHeight); + boolean dragRight = true; - int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; + if ((res < av.getAlignment().getWidth()) && (res < lastres)) + { + dragRight = false; + } - res = (int) ( (y / chunkHeight) * (getWidth() / av.charWidth)) + - (x / av.getCharWidth()) + av.getStartRes(); + if (res != lastres) + { + // Group editing + if (groupEditing) + { + SequenceGroup sg = av.getSelectionGroup(); + + if (sg == null) + { + lastres = -1; + + return; + } + + // drag to right + if (dragRight) + { + sg.setEndRes(sg.getEndRes() + (res - lastres)); + } + + // drag to left + else + { + /// Are we able to delete? + // ie are all columns blank? + boolean deleteAllowed = false; + + for (int s = 0; s < sg.getSize(); s++) + { + SequenceI seq = sg.getSequenceAt(s); + + for (int j = res; j < lastres; j++) + { + if (seq.getSequence().length() <= j) + { + continue; + } + + if (!jalview.util.Comparison.isGap( + seq.getSequence().charAt(j))) + { + // Not a gap, block edit not valid + res = j + 1; + deleteAllowed = false; + + continue; + } + + deleteAllowed = true; + } + } + + if (!deleteAllowed) + { + lastres = -1; + + return; + } + + sg.setEndRes(sg.getEndRes() - (lastres - res)); + } + + for (int i = 0; i < sg.getSize(); i++) + { + SequenceI s = sg.getSequenceAt(i); + int k = av.alignment.findIndex(s); + + // drag to right + if (dragRight) + { + for (int j = lastres; j < res; j++) + { + insertChar(j, k); + } + } + + // drag to left + else + { + for (int j = res; j < lastres; j++) + { + if (s.getLength() > j) + { + deleteChar(res, k); + } + } + } + } + } + else /////Editing a single sequence/////////// + { + if ((res < av.getAlignment().getWidth()) && (res > lastres)) + { + // dragging to the right + for (int j = lastres; j < res; j++) + { + insertChar(j, startseq); + } + } + else if ((res < av.getAlignment().getWidth()) && + (res < lastres)) + { + // dragging to the left + for (int j = lastres; j > res; j--) + { + if (jalview.util.Comparison.isGap( + av.alignment.getSequenceAt(startseq) + .getSequence().charAt(res))) + { + deleteChar(res, startseq); + } + else + { + break; + } + } + } + } + } - y %= chunkHeight; - seq = (y / av.getCharHeight()) + av.getStartSeq(); - } - else - { - res = (x / av.getCharWidth()) + av.getStartRes(); - seq = (y / av.getCharHeight()) + av.getStartSeq(); + endEdit = res; + lastres = res; + seqCanvas.repaint(); } - if (seq >= av.getAlignment().getHeight()) + /** + * DOCUMENT ME! + * + * @param seqstart DOCUMENT ME! + * @param seqend DOCUMENT ME! + * @param start DOCUMENT ME! + */ + public void drawChars(int seqstart, int seqend, int start) { - return; + seqCanvas.drawPanel(seqCanvas.gg, start, av.getEndRes(), seqstart, + seqend, av.getStartRes(), av.getStartSeq(), 0); + seqCanvas.repaint(); } - SequenceI sequence = av.getAlignment().getSequenceAt(seq); - - if (res > sequence.getLength()) + /** + * DOCUMENT ME! + * + * @param j DOCUMENT ME! + * @param seq DOCUMENT ME! + */ + public void insertChar(int j, int seq) { - return; + av.alignment.getSequenceAt(seq).insertCharAt(j, av.getGapCharacter()); + seqEditOccurred = seq; } - Object obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + - ""); - String aa = ""; - - if (obj != null) + /** + * DOCUMENT ME! + * + * @param j DOCUMENT ME! + * @param seq DOCUMENT ME! + */ + public void deleteChar(int j, int seq) { - aa = obj.toString(); - } + av.alignment.getSequenceAt(seq).deleteCharAt(j); + seqEditOccurred = seq; - StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + - sequence.getName()); - - if (aa != "") - { - text.append(" Residue: " + aa + " (" + - av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + av.alignment.getWidth(); + seqCanvas.repaint(); } - ap.alignFrame.statusBar.setText(text.toString()); - - // use aa to see if the mouse pointer is on a - if (av.showSequenceFeatures) + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + void editOccurred(int i) { - Vector features = sequence.getSequenceFeatures(); - Enumeration e = features.elements(); - StringBuffer sbuffer = new StringBuffer(); - - while (e.hasMoreElements()) - { - SequenceFeature sf = (SequenceFeature) e.nextElement(); - - if ( (sf.getStart() <= sequence.findPosition(res)) && - (sf.getEnd() >= sequence.findPosition(res))) + if (endEdit == startEdit) { - if (sbuffer.length() > 0) - { - sbuffer.append("; "); - } - - sbuffer.append(sf.getType() + " " + sf.getDescription()); - - if (sf.getStatus().length() > 0) - { - sbuffer.append(" (" + sf.getStatus() + ")"); - } + ap.alignFrame.historyList.pop(); + ap.alignFrame.updateEditMenuBar(); } - } - - this.setToolTipText(sbuffer.toString()); - } - } - public void doMouseDragged(MouseEvent evt) - { - // If we're dragging we're editing - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - - if (res < 0) - { - res = 0; - } - - if ( (lastres == -1) || (lastres == res)) - { - return; - } + av.updateConservation(); + av.updateConsensus(); - boolean dragRight = true; + // Y O Y CLUSTALX + ColourSchemeI cs = av.getGlobalColourScheme(); - if ( (res < av.getAlignment().getWidth()) && (res < lastres)) - { - dragRight = false; - } - - if (res != lastres) - { - // Group editing - if (groupEditing) - { - SequenceGroup sg = av.getSelectionGroup(); - - if (sg == null) + if (av.getSelectionGroup() != null) { - lastres = -1; - - return; + av.getSelectionGroup().recalcConservation(); } - // drag to right - if (dragRight) + if (cs instanceof ConservationColourScheme) { - sg.setEndRes(sg.getEndRes() + (res - lastres)); + ConservationColourScheme ccs = (ConservationColourScheme) cs; + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, av.alignment.getSequences(), + 0, av.alignment.getWidth() - 1); + c.calculate(); + c.verdict(false, av.ConsPercGaps); + + if (ccs.cs instanceof ClustalxColourScheme) + { + ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs; + cxs.resetClustalX(av.alignment.getSequences(), + av.alignment.getWidth()); + ccs = new ConservationColourScheme(c, cxs); + av.setGlobalColourScheme(ccs); + } + else + { + ccs = new ConservationColourScheme(c, ccs.cs); + av.setGlobalColourScheme(ccs); + } } - // drag to left - else - { - /// Are we able to delete? - // ie are all columns blank? - boolean deleteAllowed = false; - for (int s = 0; s < sg.getSize(); s++) - { - SequenceI seq = sg.getSequenceAt(s); + if (cs instanceof ClustalxColourScheme) + { + ((ClustalxColourScheme) cs).resetClustalX(av.alignment.getSequences(), + av.alignment.getWidth()); + av.setGlobalColourScheme(cs); + } + } - for (int j = res; j < lastres; j++) - { - if (seq.getSequence().length() <= j) - { - continue; - } - - if (!jalview.util.Comparison.isGap( - seq.getSequence().charAt(j))) - { - // Not a gap, block edit not valid - res = j + 1; - deleteAllowed = false; - - continue; - } - - deleteAllowed = true; - } - } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMousePressedDefineMode(MouseEvent evt) + { + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + int seq = (evt.getY() / av.getCharHeight()) + av.getStartSeq(); + oldSeq = seq; - if (!deleteAllowed) - { - lastres = -1; + SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); + if ((sequence == null) || (res > sequence.getLength())) + { return; - } - - sg.setEndRes(sg.getEndRes() - (lastres - res)); } - for (int i = 0; i < sg.getSize(); i++) + stretchGroup = av.getSelectionGroup(); + + if (stretchGroup == null) { - SequenceI s = sg.getSequenceAt(i); - int k = av.alignment.findIndex(s); + stretchGroup = av.alignment.findGroup(sequence); - // drag to right - if (dragRight) - { - for (int j = lastres; j < res; j++) - { - insertChar(j, k); - } - } - // drag to left - else - { - for (int j = res; j < lastres; j++) + if ((stretchGroup != null) && (res > stretchGroup.getStartRes()) && + (res < stretchGroup.getEndRes())) { - if (s.getLength() > j) - { - deleteChar(res, k); - } - } - } - } - } - else /////Editing a single sequence/////////// - { - if ( (res < av.getAlignment().getWidth()) && (res > lastres)) - { - // dragging to the right - for (int j = lastres; j < res; j++) - { - insertChar(j, startseq); - } - } - else if ( (res < av.getAlignment().getWidth()) && - (res < lastres)) - { - // dragging to the left - for (int j = lastres; j > res; j--) - { - if (jalview.util.Comparison.isGap( - av.alignment.getSequenceAt(startseq) - .getSequence().charAt(res))) - { - deleteChar(res, startseq); + av.setSelectionGroup(stretchGroup); } else { - break; + stretchGroup = null; } - } } - } - } - - endEdit = res; - lastres = res; - 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); - seqCanvas.repaint(); - } - - public void insertChar(int j, int seq) - { - av.alignment.getSequenceAt(seq).insertCharAt(j, av.getGapCharacter()); - seqEditOccurred = seq; - } - - public void deleteChar(int j, int seq) - { - av.alignment.getSequenceAt(seq).deleteCharAt(j); - seqEditOccurred = seq; - - av.alignment.getWidth(); - seqCanvas.repaint(); - } - - void editOccurred(int i) - { - if (endEdit == startEdit) - { - ap.alignFrame.historyList.pop(); - ap.alignFrame.updateEditMenuBar(); - } - - av.updateConservation(); - av.updateConsensus(); - - // Y O Y CLUSTALX - ColourSchemeI cs = av.getGlobalColourScheme(); - - if(av.getSelectionGroup()!=null) - av.getSelectionGroup().recalcConservation(); - - - if (cs instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme) cs; - Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, - av.alignment.getSequences(), 0, - av.alignment.getWidth() - 1); - c.calculate(); - c.verdict(false, av.ConsPercGaps); - - if (ccs.cs instanceof ClustalxColourScheme) - { - - ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs; - cxs.resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); - ccs = new ConservationColourScheme(c, cxs); - av.setGlobalColourScheme(ccs); - } - else - { - ccs = new ConservationColourScheme(c, ccs.cs); - av.setGlobalColourScheme(ccs); - } - } - - if (cs instanceof ClustalxColourScheme) - { - ( (ClustalxColourScheme) cs).resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); - av.setGlobalColourScheme(cs); - } - } - - public void doMousePressedDefineMode(MouseEvent evt) - { - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - int seq = (evt.getY() / av.getCharHeight()) + av.getStartSeq(); - oldSeq = seq; + else if (!stretchGroup.sequences.contains(sequence) || + (stretchGroup.getStartRes() > res) || + (stretchGroup.getEndRes() < res)) + { + stretchGroup = null; - SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); + SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence); - if ( (sequence == null) || (res > sequence.getLength())) - { - return; - } + if (allGroups != null) + { + for (int i = 0; i < allGroups.length; i++) + { + if ((allGroups[i].getStartRes() <= res) && + (allGroups[i].getEndRes() >= res)) + { + stretchGroup = allGroups[i]; + av.setSelectionGroup(stretchGroup); + + break; + } + } + } + } - stretchGroup = av.getSelectionGroup(); + if (stretchGroup == null) + { + // define a new group here + SequenceGroup sg = new SequenceGroup(); + sg.setStartRes(res); + sg.setEndRes(res); + sg.addSequence(sequence, false); + av.setSelectionGroup(sg); + stretchGroup = sg; + + if (av.getConservationSelected()) + { + SliderPanel.setConservationSlider(ap, + av.getGlobalColourScheme(), "Background"); + } - if (stretchGroup == null) - { - stretchGroup = av.alignment.findGroup(sequence); - - if ( (stretchGroup != null) && (res > stretchGroup.getStartRes()) && - (res < stretchGroup.getEndRes())) - { - av.setSelectionGroup(stretchGroup); - } - else - { - stretchGroup = null; - } - } - else if (!stretchGroup.sequences.contains(sequence) || - (stretchGroup.getStartRes() > res) || - (stretchGroup.getEndRes() < res)) - { - stretchGroup = null; + if (av.getAbovePIDThreshold()) + { + SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), + "Background"); + } + } + else if (javax.swing.SwingUtilities.isRightMouseButton(evt)) + { + jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null); + pop.show(this, evt.getX(), evt.getY()); - SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence); + // edit the properties of existing group + } - if (allGroups != null) - { - for (int i = 0; i < allGroups.length; i++) + if ((stretchGroup != null) && (stretchGroup.getEndRes() == res)) { - if ( (allGroups[i].getStartRes() <= res) && - (allGroups[i].getEndRes() >= res)) - { - stretchGroup = allGroups[i]; - av.setSelectionGroup(stretchGroup); - - break; - } + // Edit end res position of selected group + changeEndRes = true; + } + else if ((stretchGroup != null) && (stretchGroup.getStartRes() == res)) + { + // Edit end res position of selected group + changeStartRes = true; } - } - } - if (stretchGroup == null) - { - // define a new group here - SequenceGroup sg = new SequenceGroup(); - sg.setStartRes(res); - sg.setEndRes(res); - sg.addSequence(sequence, false); - av.setSelectionGroup(sg); - stretchGroup = sg; - - if (av.getConservationSelected()) - { - SliderPanel.setConservationSlider(ap, - av.getGlobalColourScheme(), - "Background"); - } - - if (av.getAbovePIDThreshold()) - { - SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), - "Background"); - } - } - else if (javax.swing.SwingUtilities.isRightMouseButton(evt)) - { - jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null); - pop.show(this, evt.getX(), evt.getY()); + stretchGroup.getWidth(); - // edit the properties of existing group + seqCanvas.repaint(); } - if ( (stretchGroup != null) && (stretchGroup.getEndRes() == res)) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseReleasedDefineMode(MouseEvent evt) { - // Edit end res position of selected group - changeEndRes = true; - } - else if ( (stretchGroup != null) && (stretchGroup.getStartRes() == res)) - { - // Edit end res position of selected group - changeStartRes = true; - } - - stretchGroup.getWidth(); + if (mouseDragging) + { + stretchGroup.recalcConservation(); + mouseDragging = false; + } - seqCanvas.repaint(); - } + if (stretchGroup == null) + { + return; + } - public void doMouseReleasedDefineMode(MouseEvent evt) - { - if(mouseDragging) - { - stretchGroup.recalcConservation(); - mouseDragging = false; - } + if (stretchGroup.cs instanceof ClustalxColourScheme) + { + ((ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.sequences, + stretchGroup.getWidth()); + } - if (stretchGroup == null) - { - return; - } + if (stretchGroup.cs instanceof ConservationColourScheme) + { + ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs; + stretchGroup.cs = ccs; + SliderPanel.setConservationSlider(ap, stretchGroup.cs, + stretchGroup.getName()); + } + else + { + SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, + stretchGroup.getName()); + } - if (stretchGroup.cs instanceof ClustalxColourScheme) - { - ( (ClustalxColourScheme) stretchGroup.cs).resetClustalX(stretchGroup.sequences, - stretchGroup.getWidth()); + changeEndRes = false; + changeStartRes = false; + stretchGroup = null; + PaintRefresher.Refresh(av.alignment); } - if (stretchGroup.cs instanceof ConservationColourScheme) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void doMouseDraggedDefineMode(MouseEvent evt) { - ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs; - stretchGroup.cs = ccs; - SliderPanel.setConservationSlider(ap, stretchGroup.cs, - stretchGroup.getName()); + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + int y = (evt.getY() / av.getCharHeight()) + av.getStartSeq(); - } - else - { - SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, - stretchGroup.getName()); - } + if (stretchGroup == null) + { + return; + } - changeEndRes = false; - changeStartRes = false; - stretchGroup = null; - PaintRefresher.Refresh(av.alignment); - } + if (res > av.alignment.getWidth()) + { + res = av.alignment.getWidth() - 1; + } - public void doMouseDraggedDefineMode(MouseEvent evt) - { - int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - int y = (evt.getY() / av.getCharHeight()) + av.getStartSeq(); + if (stretchGroup.getEndRes() == res) + { + // Edit end res position of selected group + changeEndRes = true; + } + else if (stretchGroup.getStartRes() == res) + { + // Edit start res position of selected group + changeStartRes = true; + } - if (stretchGroup == null) - { - return; - } + if (res < av.getStartRes()) + { + res = av.getStartRes(); + } + else if (res > av.getEndRes()) + { + res = av.getEndRes(); + } - if (res > av.alignment.getWidth()) - { - res = av.alignment.getWidth() - 1; - } + if (changeEndRes) + { + if (res > (stretchGroup.getStartRes() - 1)) + { + stretchGroup.setEndRes(res); + } + } + else if (changeStartRes) + { + if (res < (stretchGroup.getEndRes() + 1)) + { + stretchGroup.setStartRes(res); + } + } - if (stretchGroup.getEndRes() == res) - { - // Edit end res position of selected group - changeEndRes = true; - } - else if (stretchGroup.getStartRes() == res) - { - // Edit start res position of selected group - changeStartRes = true; - } + int dragDirection = 0; - if (res < av.getStartRes()) - { - res = av.getStartRes(); - } - else if (res > av.getEndRes()) - { - res = av.getEndRes(); - } + if (y > oldSeq) + { + dragDirection = 1; + } + else if (y < oldSeq) + { + dragDirection = -1; + } - if (changeEndRes) - { - if (res > (stretchGroup.getStartRes() - 1)) - { - stretchGroup.setEndRes(res); - } - } - else if (changeStartRes) - { - if (res < (stretchGroup.getEndRes() + 1)) - { - stretchGroup.setStartRes(res); - } - } + while ((y != oldSeq) && (oldSeq > 0) && (y < av.alignment.getHeight())) + { + // This routine ensures we don't skip any sequences, as the + // selection is quite slow. + Sequence seq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); - int dragDirection = 0; + oldSeq += dragDirection; - if (y > oldSeq) - { - dragDirection = 1; - } - else if (y < oldSeq) - { - dragDirection = -1; - } + Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); - while ( (y != oldSeq) && (oldSeq > 0) && (y < av.alignment.getHeight())) - { - // This routine ensures we don't skip any sequences, as the - // selection is quite slow. - Sequence seq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + if (stretchGroup.sequences.contains(nextSeq)) + { + stretchGroup.deleteSequence(seq, false); + } + else + { + if (seq != null) + { + stretchGroup.addSequence(seq, false); + } - oldSeq += dragDirection; + stretchGroup.addSequence(nextSeq, false); + } + } - Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); + oldSeq = y; + mouseDragging = true; - if (stretchGroup.sequences.contains(nextSeq)) - { - stretchGroup.deleteSequence(seq, false); - } - else - { - if (seq != null) + if (scrollThread != null) { - stretchGroup.addSequence(seq, false); + scrollThread.setEvent(evt); } - stretchGroup.addSequence(nextSeq, false); - } - } - oldSeq = y; - mouseDragging = true; - - if (scrollThread != null) - { - scrollThread.setEvent(evt); - } - - seqCanvas.repaint(); - } - - public void doMouseEnteredDefineMode(MouseEvent e) - { - if (scrollThread != null) - { - scrollThread.running = false; + seqCanvas.repaint(); } - } - public void doMouseExitedDefineMode(MouseEvent e) - { - if (av.getWrapAlignment()) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void doMouseEnteredDefineMode(MouseEvent e) { - return; - } - - if (mouseDragging) - { - scrollThread = new ScrollThread(); - } - } - - // this class allows scrolling off the bottom of the visible alignment - class ScrollThread - extends Thread - { - MouseEvent evt; - boolean running = false; - - public ScrollThread() - { - start(); + if (scrollThread != null) + { + scrollThread.running = false; + } } - public void setEvent(MouseEvent e) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void doMouseExitedDefineMode(MouseEvent e) { - evt = e; - } + if (av.getWrapAlignment()) + { + return; + } - public void stopScrolling() - { - running = false; + if (mouseDragging) + { + scrollThread = new ScrollThread(); + } } - public void run() + // this class allows scrolling off the bottom of the visible alignment + class ScrollThread extends Thread { - running = true; + MouseEvent evt; + boolean running = false; - while (running) - { - if (evt != null) + public ScrollThread() { - if (mouseDragging && (evt.getY() < 0) && - (av.getStartSeq() > 0)) - { - running = ap.scrollUp(true); - } - - if (mouseDragging && (evt.getY() >= getHeight()) && - (av.alignment.getHeight() > av.getEndSeq())) - { - running = ap.scrollUp(false); - } + start(); + } - if (mouseDragging && (evt.getX() < 0)) - { - running = ap.scrollRight(true); - } - else if (mouseDragging && (evt.getX() >= getWidth())) - { - running = ap.scrollRight(false); - } + public void setEvent(MouseEvent e) + { + evt = e; } - try + public void stopScrolling() { - Thread.sleep(75); + running = false; } - catch (Exception ex) + + public void run() { + running = true; + + while (running) + { + if (evt != null) + { + if (mouseDragging && (evt.getY() < 0) && + (av.getStartSeq() > 0)) + { + running = ap.scrollUp(true); + } + + if (mouseDragging && (evt.getY() >= getHeight()) && + (av.alignment.getHeight() > av.getEndSeq())) + { + running = ap.scrollUp(false); + } + + if (mouseDragging && (evt.getX() < 0)) + { + running = ap.scrollRight(true); + } + else if (mouseDragging && (evt.getX() >= getWidth())) + { + running = ap.scrollRight(false); + } + } + + try + { + Thread.sleep(75); + } + catch (Exception ex) + { + } + } } - } } - } } diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 896fda5..e36160a 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -18,237 +18,321 @@ */ package jalview.gui; -import java.awt.*; - import jalview.datamodel.*; + import jalview.schemes.*; +import java.awt.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class SequenceRenderer { - AlignViewport av; - FontMetrics fm; - boolean renderGaps = true; - SequenceGroup currentSequenceGroup = null; - SequenceGroup[] allGroups = null; - Color resBoxColour; - Graphics graphics; - - public SequenceRenderer(AlignViewport av) - { - this.av = av; - } - - public void renderGaps(boolean b) - { - renderGaps = b; - } - - public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) - { - getBoxColour(cs, seq, i); - - return resBoxColour; - } - - void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) - { - if (cs != null) + AlignViewport av; + FontMetrics fm; + boolean renderGaps = true; + SequenceGroup currentSequenceGroup = null; + SequenceGroup[] allGroups = null; + Color resBoxColour; + Graphics graphics; + + /** + * Creates a new SequenceRenderer object. + * + * @param av DOCUMENT ME! + */ + public SequenceRenderer(AlignViewport av) { - resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); + this.av = av; } - else + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void renderGaps(boolean b) { - resBoxColour = Color.white; + renderGaps = b; } - } - - public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, - int start, int end, int x1, int y1, int width, - int height) - { - allGroups = sg; - - graphics = g; - drawBoxes(seq, start, end, x1, y1, (int) width, height); - - fm = g.getFontMetrics(); - drawText(seq, start, end, x1, y1, (int) width, height); - } - - public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1, - int width, int height) - { - int i = start; - int length = seq.getLength(); - - int curStart = -1; - int curWidth = width; + /** + * DOCUMENT ME! + * + * @param cs DOCUMENT ME! + * @param seq DOCUMENT ME! + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color getResidueBoxColour(ColourSchemeI cs, SequenceI seq, int i) + { + getBoxColour(cs, seq, i); - Color tempColour = null; + return resBoxColour; + } - while ( (i <= end) && (i < length)) + /** + * DOCUMENT ME! + * + * @param cs DOCUMENT ME! + * @param seq DOCUMENT ME! + * @param i DOCUMENT ME! + */ + void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) { - if (inCurrentSequenceGroup(i)) - { - if (currentSequenceGroup.getDisplayBoxes()) + if (cs != null) { - getBoxColour(currentSequenceGroup.cs, seq, i); + resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); } else { - resBoxColour = Color.white; - } - } - else if (av.getShowBoxes()) - { - getBoxColour(av.getGlobalColourScheme(), seq, i); - } - else - { - resBoxColour = Color.white; - } - - if (resBoxColour != tempColour) - { - if (tempColour != null) - { - graphics.fillRect(x1 + (width * (curStart - start)), y1, - curWidth, height); + resBoxColour = Color.white; } + } + + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param seq DOCUMENT ME! + * @param sg DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, + int start, int end, int x1, int y1, int width, int height) + { + allGroups = sg; - graphics.setColor(resBoxColour); + graphics = g; - curStart = i; - curWidth = width; - tempColour = resBoxColour; - } - else - { - curWidth += width; - } + drawBoxes(seq, start, end, x1, y1, (int) width, height); - i++; + fm = g.getFontMetrics(); + drawText(seq, start, end, x1, y1, (int) width, height); } - graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, - height); - } + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1, + int width, int height) + { + int i = start; + int length = seq.getLength(); - public void drawText(SequenceI seq, int start, int end, int x1, int y1, - int width, int height) - { - int pady = height / 5; - int charOffset = 0; - char s; + int curStart = -1; + int curWidth = width; - // Need to find the sequence position here. - String sequence = seq.getSequence(); + Color tempColour = null; - for (int i = start; i <= end; i++) - { - graphics.setColor(Color.black); - - if (i < sequence.length()) - { - s = sequence.charAt(i); - } - else - { - s = ' '; - } - - if (!renderGaps && jalview.util.Comparison.isGap(s)) - { - continue; - } - - if (inCurrentSequenceGroup(i)) - { - if (!currentSequenceGroup.getDisplayText()) + while ((i <= end) && (i < length)) { - continue; + if (inCurrentSequenceGroup(i)) + { + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } + else + { + resBoxColour = Color.white; + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); + } + else + { + resBoxColour = Color.white; + } + + if (resBoxColour != tempColour) + { + if (tempColour != null) + { + graphics.fillRect(x1 + (width * (curStart - start)), y1, + curWidth, height); + } + + graphics.setColor(resBoxColour); + + curStart = i; + curWidth = width; + tempColour = resBoxColour; + } + else + { + curWidth += width; + } + + i++; } - if (currentSequenceGroup.getColourText()) + graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, + height); + } + + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void drawText(SequenceI seq, int start, int end, int x1, int y1, + int width, int height) + { + int pady = height / 5; + int charOffset = 0; + char s; + + // Need to find the sequence position here. + String sequence = seq.getSequence(); + + for (int i = start; i <= end; i++) { - getBoxColour(currentSequenceGroup.cs, seq, i); - graphics.setColor(resBoxColour.darker()); + graphics.setColor(Color.black); + + if (i < sequence.length()) + { + s = sequence.charAt(i); + } + else + { + s = ' '; + } + + if (!renderGaps && jalview.util.Comparison.isGap(s)) + { + continue; + } + + if (inCurrentSequenceGroup(i)) + { + if (!currentSequenceGroup.getDisplayText()) + { + continue; + } + + if (currentSequenceGroup.getColourText()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + graphics.setColor(resBoxColour.darker()); + } + } + else + { + if (!av.getShowText()) + { + continue; + } + + if (av.getColourText()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); + + if (av.getShowBoxes()) + { + graphics.setColor(resBoxColour.darker()); + } + else + { + graphics.setColor(resBoxColour); + } + } + } + + charOffset = (width - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), (y1 + height) - pady); } - } - else - { - if (!av.getShowText()) + } + + /** + * DOCUMENT ME! + * + * @param res DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + boolean inCurrentSequenceGroup(int res) + { + if (allGroups == null) { - continue; + return false; } - if (av.getColourText()) + for (int i = 0; i < allGroups.length; i++) { - getBoxColour(av.getGlobalColourScheme(), seq, i); - - if (av.getShowBoxes()) - { - graphics.setColor(resBoxColour.darker()); - } - else - { - graphics.setColor(resBoxColour); - } - } - } + if ((allGroups[i].getStartRes() <= res) && + (allGroups[i].getEndRes() >= res)) + { + currentSequenceGroup = allGroups[i]; - charOffset = (width - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), - (y1 + height) - pady); - } - } + return true; + } + } - boolean inCurrentSequenceGroup(int res) - { - if (allGroups == null) - { - return false; + return false; } - for (int i = 0; i < allGroups.length; i++) + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + * @param start DOCUMENT ME! + * @param end DOCUMENT ME! + * @param x1 DOCUMENT ME! + * @param y1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void drawHighlightedText(SequenceI seq, int start, int end, int x1, + int y1, int width, int height) { - if ( (allGroups[i].getStartRes() <= res) && - (allGroups[i].getEndRes() >= res)) - { - currentSequenceGroup = allGroups[i]; - - return true; - } - } + int pady = height / 5; + int charOffset = 0; + graphics.setColor(Color.BLACK); + graphics.fillRect(x1, y1, width * (end - start + 1), height); + graphics.setColor(Color.white); - return false; - } + char s = '~'; - public void drawHighlightedText(SequenceI seq, int start, int end, int x1, - int y1, int width, int height) - { - int pady = height / 5; - int charOffset = 0; - graphics.setColor(Color.BLACK); - graphics.fillRect(x1, y1, width * (end - start + 1), height); - graphics.setColor(Color.white); - - char s = '~'; - - // Need to find the sequence position here. - for (int i = start; i <= end; i++) - { - if (i < seq.getLength()) - { - s = seq.getSequence().charAt(i); - } - - charOffset = (width - fm.charWidth(s)) / 2; - graphics.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), - (y1 + height) - pady); + // Need to find the sequence position here. + for (int i = start; i <= end; i++) + { + if (i < seq.getLength()) + { + s = seq.getSequence().charAt(i); + } + + charOffset = (width - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), (y1 + height) - pady); + } } - } } diff --git a/src/jalview/gui/SliderPanel.java b/src/jalview/gui/SliderPanel.java index 1a62fff..c18cc05 100755 --- a/src/jalview/gui/SliderPanel.java +++ b/src/jalview/gui/SliderPanel.java @@ -18,270 +18,336 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; + +import jalview.jbgui.*; + +import jalview.schemes.*; import java.awt.event.*; + +import java.util.*; + import javax.swing.*; import javax.swing.event.*; -import jalview.datamodel.*; -import jalview.jbgui.*; -import jalview.schemes.*; -public class SliderPanel - extends GSliderPanel +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SliderPanel extends GSliderPanel { - static JInternalFrame conservationSlider; - static JInternalFrame PIDSlider; - AlignmentPanel ap; - boolean forConservation = true; - ColourSchemeI cs; - - public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, - ColourSchemeI cs) - { - this.ap = ap; - this.cs = cs; - forConservation = forConserve; - undoButton.setVisible(false); - applyButton.setVisible(false); - - if (forConservation) - { - label.setText("Enter value to increase conservation visibility"); - slider.setMinimum(0); - slider.setMaximum(50); - } - else - { - label.setText("Enter % identity above which to colour residues"); - slider.setMinimum(0); - slider.setMaximum(100); - } - - slider.addChangeListener(new ChangeListener() + static JInternalFrame conservationSlider; + static JInternalFrame PIDSlider; + AlignmentPanel ap; + boolean forConservation = true; + ColourSchemeI cs; + + /** + * Creates a new SliderPanel object. + * + * @param ap DOCUMENT ME! + * @param value DOCUMENT ME! + * @param forConserve DOCUMENT ME! + * @param cs DOCUMENT ME! + */ + public SliderPanel(AlignmentPanel ap, int value, boolean forConserve, + ColourSchemeI cs) { - public void stateChanged(ChangeEvent evt) - { - valueField.setText(slider.getValue() + ""); - valueChanged(slider.getValue()); - } - }); - - slider.setValue(value); - valueField.setText(value + ""); - } - - public static int setConservationSlider(AlignmentPanel ap, - ColourSchemeI cs, String source) - { - SliderPanel sp = null; - ConservationColourScheme ccs = (ConservationColourScheme) cs; - - if (conservationSlider == null) - { - sp = new SliderPanel(ap, ccs.inc, true, cs); - conservationSlider = new JInternalFrame(); - conservationSlider.setContentPane(sp); - conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); - } - else - { - sp = (SliderPanel) conservationSlider.getContentPane(); - sp.cs = cs; - } + this.ap = ap; + this.cs = cs; + forConservation = forConserve; + undoButton.setVisible(false); + applyButton.setVisible(false); - conservationSlider.setTitle("Conservation Colour Increment (" + - source + ")"); + if (forConservation) + { + label.setText("Enter value to increase conservation visibility"); + slider.setMinimum(0); + slider.setMaximum(50); + } + else + { + label.setText("Enter % identity above which to colour residues"); + slider.setMinimum(0); + slider.setMaximum(100); + } - if (ap.av.alignment.getGroups() != null) - { - sp.setAllGroupsCheckEnabled(true); + slider.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent evt) + { + valueField.setText(slider.getValue() + ""); + valueChanged(slider.getValue()); + } + }); + + slider.setValue(value); + valueField.setText(value + ""); } - else - { - sp.setAllGroupsCheckEnabled(false); - } - - return sp.getValue(); - } - public static void showConservationSlider() - { - try + /** + * DOCUMENT ME! + * + * @param ap DOCUMENT ME! + * @param cs DOCUMENT ME! + * @param source DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static int setConservationSlider(AlignmentPanel ap, + ColourSchemeI cs, String source) { - PIDSlider.setClosed(true); - PIDSlider = null; - } - catch (Exception ex) - { - } + SliderPanel sp = null; + ConservationColourScheme ccs = (ConservationColourScheme) cs; - if (!conservationSlider.isVisible()) - { - Desktop.addInternalFrame(conservationSlider, - conservationSlider.getTitle(), 420, 90, false); - conservationSlider.addInternalFrameListener(new javax.swing.event. - InternalFrameAdapter() - { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent e) + if (conservationSlider == null) { - conservationSlider = null; + sp = new SliderPanel(ap, ccs.inc, true, cs); + conservationSlider = new JInternalFrame(); + conservationSlider.setContentPane(sp); + conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); + } + else + { + sp = (SliderPanel) conservationSlider.getContentPane(); + sp.cs = cs; } - }); - conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); - } - } - public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, - String source) - { - SliderPanel pid = null; + conservationSlider.setTitle("Conservation Colour Increment (" + + source + ")"); - int threshold = 50; + if (ap.av.alignment.getGroups() != null) + { + sp.setAllGroupsCheckEnabled(true); + } + else + { + sp.setAllGroupsCheckEnabled(false); + } - if (cs instanceof ResidueColourScheme) - { - threshold = ( ( (ResidueColourScheme) cs).getThreshold()); - } - else if (cs instanceof ScoreColourScheme) - { - threshold = ( ( (ScoreColourScheme) cs).getThreshold()); + return sp.getValue(); } - if (PIDSlider == null) + /** + * DOCUMENT ME! + */ + public static void showConservationSlider() { - pid = new SliderPanel(ap, threshold, false, cs); - PIDSlider = new JInternalFrame(); - PIDSlider.setContentPane(pid); - PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); + try + { + PIDSlider.setClosed(true); + PIDSlider = null; + } + catch (Exception ex) + { + } + + if (!conservationSlider.isVisible()) + { + Desktop.addInternalFrame(conservationSlider, + conservationSlider.getTitle(), 420, 90, false); + conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent e) + { + conservationSlider = null; + } + }); + conservationSlider.setLayer(JLayeredPane.PALETTE_LAYER); + } } - else + + /** + * DOCUMENT ME! + * + * @param ap DOCUMENT ME! + * @param cs DOCUMENT ME! + * @param source DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, + String source) { - pid = (SliderPanel) PIDSlider.getContentPane(); - pid.cs = cs; - } + SliderPanel pid = null; - PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")"); + int threshold = 50; - if (ap.av.alignment.getGroups() != null) - { - pid.setAllGroupsCheckEnabled(true); - } - else - { - pid.setAllGroupsCheckEnabled(false); - } + if (cs instanceof ResidueColourScheme) + { + threshold = (((ResidueColourScheme) cs).getThreshold()); + } + else if (cs instanceof ScoreColourScheme) + { + threshold = (((ScoreColourScheme) cs).getThreshold()); + } - return pid.getValue(); - } + if (PIDSlider == null) + { + pid = new SliderPanel(ap, threshold, false, cs); + PIDSlider = new JInternalFrame(); + PIDSlider.setContentPane(pid); + PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); + } + else + { + pid = (SliderPanel) PIDSlider.getContentPane(); + pid.cs = cs; + } - public static void showPIDSlider() - { - try - { - conservationSlider.setClosed(true); - conservationSlider = null; - } - catch (Exception ex) - { + PIDSlider.setTitle("Percentage Identity Threshold (" + source + ")"); + + if (ap.av.alignment.getGroups() != null) + { + pid.setAllGroupsCheckEnabled(true); + } + else + { + pid.setAllGroupsCheckEnabled(false); + } + + return pid.getValue(); } - if (!PIDSlider.isVisible()) + /** + * DOCUMENT ME! + */ + public static void showPIDSlider() { - Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90, - false); - PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); - PIDSlider.addInternalFrameListener(new javax.swing.event. - InternalFrameAdapter() - { - public void internalFrameClosed( - javax.swing.event.InternalFrameEvent e) + try { - PIDSlider = null; + conservationSlider.setClosed(true); + conservationSlider = null; + } + catch (Exception ex) + { + } + + if (!PIDSlider.isVisible()) + { + Desktop.addInternalFrame(PIDSlider, PIDSlider.getTitle(), 420, 90, + false); + PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); + PIDSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent e) + { + PIDSlider = null; + } + }); + PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); } - }); - PIDSlider.setLayer(JLayeredPane.PALETTE_LAYER); } - } - public void valueChanged(int i) - { - if (cs == null) + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + */ + public void valueChanged(int i) { - return; - } + if (cs == null) + { + return; + } - ColourSchemeI toChange = null; - Vector allGroups = null; - int groupIndex = 0; + ColourSchemeI toChange = null; + Vector allGroups = null; + int groupIndex = 0; - if (allGroupsCheck.isSelected()) - { - allGroups = ap.av.alignment.getGroups(); - groupIndex = allGroups.size() - 1; + if (allGroupsCheck.isSelected()) + { + allGroups = ap.av.alignment.getGroups(); + groupIndex = allGroups.size() - 1; + } + else + { + toChange = cs; + } + + while (groupIndex > -1) + { + if (allGroups != null) + { + toChange = ((SequenceGroup) allGroups.get(groupIndex)).cs; + + if (toChange == null) + { + groupIndex--; + + continue; + } + } + + if (forConservation) + { + if (toChange instanceof ConservationColourScheme) + { + ((ConservationColourScheme) toChange).inc = i; + } + } + else + { + ((ResidueColourScheme) toChange).setThreshold(i); + } + + groupIndex--; + } + + ap.seqPanel.seqCanvas.repaint(); } - else + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setAllGroupsCheckEnabled(boolean b) { - toChange = cs; + allGroupsCheck.setEnabled(b); } - while (groupIndex > -1) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void valueField_actionPerformed(ActionEvent e) { - if (allGroups != null) - { - toChange = ( (SequenceGroup) allGroups.get(groupIndex)).cs; - if(toChange==null) + try { - groupIndex--; - continue; + int i = Integer.parseInt(valueField.getText()); + slider.setValue(i); } - } - - if (forConservation) - { - if (toChange instanceof ConservationColourScheme) + catch (Exception ex) { - ( (ConservationColourScheme) toChange).inc = i; + valueField.setText(slider.getValue() + ""); } - } - else - { - ( (ResidueColourScheme) toChange).setThreshold(i); - } - - groupIndex--; } - ap.seqPanel.seqCanvas.repaint(); - } - - public void setAllGroupsCheckEnabled(boolean b) - { - allGroupsCheck.setEnabled(b); - } - - public void valueField_actionPerformed(ActionEvent e) - { - try + /** + * DOCUMENT ME! + * + * @param value DOCUMENT ME! + */ + public void setValue(int value) { - int i = Integer.parseInt(valueField.getText()); - slider.setValue(i); + slider.setValue(value); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getValue() { - valueField.setText(slider.getValue() + ""); + return Integer.parseInt(valueField.getText()); } - } - - public void setValue(int value) - { - slider.setValue(value); - } - - public int getValue() - { - return Integer.parseInt(valueField.getText()); - } } diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 6edab5d..aff93d7 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -20,99 +20,121 @@ package jalview.gui; import java.awt.*; import java.awt.event.*; + import javax.swing.*; -public class SplashScreen - extends JPanel implements Runnable + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SplashScreen extends JPanel implements Runnable { - boolean visible = true; - JInternalFrame iframe; - Image image; - int fontSize = 11; - int yoffset = 30; + boolean visible = true; + JInternalFrame iframe; + Image image; + int fontSize = 11; + int yoffset = 30; - public SplashScreen(JInternalFrame iframe, Image i) - { - this.iframe = iframe; - image = i; + /** + * Creates a new SplashScreen object. + * + * @param iframe DOCUMENT ME! + * @param i DOCUMENT ME! + */ + public SplashScreen(JInternalFrame iframe, Image i) + { + this.iframe = iframe; + image = i; + + Thread t = new Thread(this); + t.start(); + addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent evt) + { + try + { + closeSplash(); + } + catch (Exception ex) + { + } + } + }); + } - Thread t = new Thread(this); - t.start(); - addMouseListener(new MouseAdapter() + /** + * DOCUMENT ME! + */ + public void run() + { + long startTime = System.currentTimeMillis() / 1000; + + while (visible) + { + if (((System.currentTimeMillis() / 1000) - startTime) > 5) + { + visible = false; + } + + try + { + Thread.sleep(1000); + } + catch (Exception ex) + { + } + } + + closeSplash(); + } + + /** + * DOCUMENT ME! + */ + public void closeSplash() { - public void mousePressed(MouseEvent evt) - { try { - closeSplash(); + iframe.setClosed(true); } catch (Exception ex) { } - } - }); - } - - public void run() - { - long startTime = System.currentTimeMillis() / 1000; - - while (visible) - { - if ( ( (System.currentTimeMillis() / 1000) - startTime) > 5) - { - visible = false; - } - - try - { - Thread.sleep(1000); - } - catch (Exception ex) - { - } } - closeSplash(); - } - - public void closeSplash() - { - try + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - iframe.setClosed(true); - } - catch (Exception ex) - { - } - } + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(Color.black); + g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6)); - public void paintComponent(Graphics g) - { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - g.setColor(Color.black); - g.setFont(new Font("Verdana", Font.BOLD, fontSize + 6)); + if (image != null) + { + g.drawImage(image, 5, yoffset + 12, this); + } - if (image != null) - { - g.drawImage(image, 5, yoffset + 12, this); + g.drawString("JalView 2005 ", 50, yoffset); + g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); + g.drawString("Version " + jalview.bin.Cache.VERSION + + "; Last updated: " + jalview.bin.Cache.BUILD_DATE, 180, yoffset); + g.setFont(new Font("Verdana", Font.BOLD, fontSize)); + g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.", + 50, yoffset + 20); + g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.", + 50, yoffset + 24 + fontSize); + g.drawString("If you use JalView, please cite: Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004),", + 50, yoffset + 28 + (fontSize * 2)); + g.drawString("\"The Jalview Java Alignment Editor\" Bioinformatics, 2004 12;426-7.", + 50, yoffset + 32 + (fontSize * 3)); } - - g.drawString("JalView 2005 ", 50, yoffset); - g.setFont(new Font("Verdana", Font.BOLD, fontSize + 2)); - g.drawString("Version " + jalview.bin.Cache.VERSION + - "; Last updated: " + jalview.bin.Cache.BUILD_DATE, 180, - yoffset); - g.setFont(new Font("Verdana", Font.BOLD, fontSize)); - g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.", - 50, yoffset + 20); - g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.", - 50, yoffset + 24 + fontSize); - g.drawString("If you use JalView, please cite: Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004),", - 50, yoffset + 28 + (fontSize * 2)); - g.drawString( - "\"The Jalview Java Alignment Editor\" Bioinformatics, 2004 12;426-7.", - 50, yoffset + 32 + (fontSize * 3)); - } } diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 1fddc5b..d8ed3ee 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -18,611 +18,759 @@ */ package jalview.gui; -import java.util.*; +import jalview.analysis.*; + +import jalview.datamodel.*; + +import jalview.schemes.*; + +import jalview.util.*; import java.awt.*; import java.awt.event.*; import java.awt.print.*; + +import java.util.*; + import javax.swing.*; -import jalview.analysis.*; -import jalview.datamodel.*; -import jalview.schemes.*; -import jalview.util.*; -public class TreeCanvas - extends JPanel implements MouseListener, Runnable, +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class TreeCanvas extends JPanel implements MouseListener, Runnable, Printable { - public static final String PLACEHOLDER = " * "; - NJTree tree; - JScrollPane scrollPane; - AlignViewport av; - Font font; - int fontSize = 12; - boolean fitToWindow = true; - boolean showDistances = false; - boolean showBootstrap = false; - boolean markPlaceholders = false; - int offx = 20; - int offy = 20; - float threshold; - String longestName; - int labelLength = -1; - - //RubberbandRectangle rubberband; - Vector listeners; - Hashtable nameHash = new Hashtable(); - Hashtable nodeHash = new Hashtable(); - - public TreeCanvas(AlignViewport av, NJTree tree, JScrollPane scroller, - String label) - { - this.av = av; - this.tree = tree; - scrollPane = scroller; - addMouseListener(this); - tree.findHeight(tree.getTopNode()); - longestName = label; - - PaintRefresher.Register(this, av.alignment); - } - - public void TreeSelectionChanged(Sequence sequence) - { - SequenceGroup selected = av.getSelectionGroup(); - - if (selected == null) + /** DOCUMENT ME!! */ + public static final String PLACEHOLDER = " * "; + NJTree tree; + JScrollPane scrollPane; + AlignViewport av; + Font font; + int fontSize = 12; + boolean fitToWindow = true; + boolean showDistances = false; + boolean showBootstrap = false; + boolean markPlaceholders = false; + int offx = 20; + int offy = 20; + float threshold; + String longestName; + int labelLength = -1; + + //RubberbandRectangle rubberband; + Vector listeners; + Hashtable nameHash = new Hashtable(); + Hashtable nodeHash = new Hashtable(); + + /** + * Creates a new TreeCanvas object. + * + * @param av DOCUMENT ME! + * @param tree DOCUMENT ME! + * @param scroller DOCUMENT ME! + * @param label DOCUMENT ME! + */ + public TreeCanvas(AlignViewport av, NJTree tree, JScrollPane scroller, + String label) { - selected = new SequenceGroup(); - av.setSelectionGroup(selected); + this.av = av; + this.tree = tree; + scrollPane = scroller; + addMouseListener(this); + tree.findHeight(tree.getTopNode()); + longestName = label; + + PaintRefresher.Register(this, av.alignment); } - selected.setEndRes(av.alignment.getWidth()); - selected.addOrRemove(sequence, true); + /** + * DOCUMENT ME! + * + * @param sequence DOCUMENT ME! + */ + public void TreeSelectionChanged(Sequence sequence) + { + SequenceGroup selected = av.getSelectionGroup(); + + if (selected == null) + { + selected = new SequenceGroup(); + av.setSelectionGroup(selected); + } - PaintRefresher.Refresh(this, av.alignment); - repaint(); - } + selected.setEndRes(av.alignment.getWidth()); + selected.addOrRemove(sequence, true); - public void setTree(NJTree tree) - { - this.tree = tree; - tree.findHeight(tree.getTopNode()); - } + PaintRefresher.Refresh(this, av.alignment); + repaint(); + } - public void drawNode(Graphics g, SequenceNode node, float chunk, - float scale, int width, int offx, int offy) - { - if (node == null) + /** + * DOCUMENT ME! + * + * @param tree DOCUMENT ME! + */ + public void setTree(NJTree tree) { - return; + this.tree = tree; + tree.findHeight(tree.getTopNode()); } - if ( (node.left() == null) && (node.right() == null)) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + * @param node DOCUMENT ME! + * @param chunk DOCUMENT ME! + * @param scale DOCUMENT ME! + * @param width DOCUMENT ME! + * @param offx DOCUMENT ME! + * @param offy DOCUMENT ME! + */ + public void drawNode(Graphics g, SequenceNode node, float chunk, + float scale, int width, int offx, int offy) { - // Drawing leaf node - float height = node.height; - float dist = node.dist; - - int xstart = (int) ( (height - dist) * scale) + offx; - int xend = (int) (height * scale) + offx; - - int ypos = (int) (node.ycount * chunk) + offy; - - if (node.element() instanceof SequenceI) - { - if ( ( (SequenceI) ( (SequenceNode) node).element()).getColor() == - Color.white) - { - g.setColor(Color.black); - } - else + if (node == null) { - g.setColor( ( (SequenceI) ( (SequenceNode) node).element()).getColor() - .darker()); + return; } - } - else - { - g.setColor(Color.black); - } - - // Draw horizontal line - g.drawLine(xstart, ypos, xend, ypos); - - String nodeLabel = ""; - if (showDistances && (node.dist > 0)) - { - nodeLabel = new Format("%5.2f").form(node.dist); - } - - if (showBootstrap) - { - if (showDistances) + if ((node.left() == null) && (node.right() == null)) { - nodeLabel = nodeLabel + " : "; + // Drawing leaf node + float height = node.height; + float dist = node.dist; + + int xstart = (int) ((height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; + + int ypos = (int) (node.ycount * chunk) + offy; + + if (node.element() instanceof SequenceI) + { + if (((SequenceI) ((SequenceNode) node).element()).getColor() == Color.white) + { + g.setColor(Color.black); + } + else + { + g.setColor(((SequenceI) ((SequenceNode) node).element()).getColor() + .darker()); + } + } + else + { + g.setColor(Color.black); + } + + // Draw horizontal line + g.drawLine(xstart, ypos, xend, ypos); + + String nodeLabel = ""; + + if (showDistances && (node.dist > 0)) + { + nodeLabel = new Format("%5.2f").form(node.dist); + } + + if (showBootstrap) + { + if (showDistances) + { + nodeLabel = nodeLabel + " : "; + } + + nodeLabel = nodeLabel + String.valueOf(node.getBootstrap()); + } + + if (!nodeLabel.equals("")) + { + g.drawString(nodeLabel, xstart, ypos - 10); + } + + String name = (markPlaceholders && node.isPlaceholder()) + ? (PLACEHOLDER + node.getName()) : node.getName(); + FontMetrics fm = g.getFontMetrics(font); + int charWidth = fm.stringWidth(name) + 3; + int charHeight = fm.getHeight(); + + Rectangle rect = new Rectangle(xend + 20, ypos - charHeight, + charWidth, charHeight); + + nameHash.put((SequenceI) node.element(), rect); + + // Colour selected leaves differently + SequenceGroup selected = av.getSelectionGroup(); + + if ((selected != null) && + selected.sequences.contains((SequenceI) node.element())) + { + g.setColor(Color.gray); + + g.fillRect(xend + 10, ypos - charHeight + 3, charWidth, + charHeight); + g.setColor(Color.white); + } + + g.drawString(name, xend + 10, ypos); + g.setColor(Color.black); } + else + { + drawNode(g, (SequenceNode) node.left(), chunk, scale, width, offx, + offy); + drawNode(g, (SequenceNode) node.right(), chunk, scale, width, offx, + offy); - nodeLabel = nodeLabel + String.valueOf(node.getBootstrap()); - } - - if (!nodeLabel.equals("")) - { - g.drawString(nodeLabel, xstart, ypos - 10); - } + float height = node.height; + float dist = node.dist; - String name = (markPlaceholders && node.isPlaceholder()) - ? (PLACEHOLDER + node.getName()) : node.getName(); - FontMetrics fm = g.getFontMetrics(font); - int charWidth = fm.stringWidth(name) + 3; - int charHeight = fm.getHeight(); + int xstart = (int) ((height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; + int ypos = (int) (node.ycount * chunk) + offy; - Rectangle rect = new Rectangle(xend + 20, ypos - charHeight, - charWidth, charHeight); + g.setColor(((SequenceNode) node).color.darker()); - nameHash.put( (SequenceI) node.element(), rect); + // Draw horizontal line + g.drawLine(xstart, ypos, xend, ypos); + g.fillRect(xend - 2, ypos - 2, 4, 4); - // Colour selected leaves differently - SequenceGroup selected = av.getSelectionGroup(); + int ystart = (int) (((SequenceNode) node.left()).ycount * chunk) + + offy; + int yend = (int) (((SequenceNode) node.right()).ycount * chunk) + + offy; - if ( (selected != null) && - selected.sequences.contains( (SequenceI) node.element())) - { - g.setColor(Color.gray); + Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); + nodeHash.put(node, pos); - g.fillRect(xend + 10, ypos - charHeight + 3, charWidth, - charHeight); - g.setColor(Color.white); - } + g.drawLine((int) (height * scale) + offx, ystart, + (int) (height * scale) + offx, yend); - g.drawString(name, xend + 10, ypos); - g.setColor(Color.black); + if (showDistances && (node.dist > 0)) + { + g.drawString(new Format("%5.2f").form(node.dist), xstart, + ypos - 5); + } + } } - else - { - drawNode(g, (SequenceNode) node.left(), chunk, scale, width, offx, - offy); - drawNode(g, (SequenceNode) node.right(), chunk, scale, width, offx, - offy); - float height = node.height; - float dist = node.dist; - - int xstart = (int) ( (height - dist) * scale) + offx; - int xend = (int) (height * scale) + offx; - int ypos = (int) (node.ycount * chunk) + offy; - - g.setColor( ( (SequenceNode) node).color.darker()); - - // Draw horizontal line - g.drawLine(xstart, ypos, xend, ypos); - g.fillRect(xend - 2, ypos - 2, 4, 4); - - int ystart = (int) ( ( (SequenceNode) node.left()).ycount * chunk) + - offy; - int yend = (int) ( ( (SequenceNode) node.right()).ycount * chunk) + - offy; - - Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); - nodeHash.put(node, pos); + /** + * DOCUMENT ME! + * + * @param x DOCUMENT ME! + * @param y DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Object findElement(int x, int y) + { + Enumeration keys = nameHash.keys(); - g.drawLine( (int) (height * scale) + offx, ystart, - (int) (height * scale) + offx, yend); + while (keys.hasMoreElements()) + { + Object ob = keys.nextElement(); + Rectangle rect = (Rectangle) nameHash.get(ob); + + if ((x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y) && + (y <= (rect.y + rect.height))) + { + return ob; + } + } - if (showDistances && (node.dist > 0)) - { - g.drawString(new Format("%5.2f").form(node.dist), xstart, - ypos - 5); - } - } - } + keys = nodeHash.keys(); - public Object findElement(int x, int y) - { - Enumeration keys = nameHash.keys(); + while (keys.hasMoreElements()) + { + Object ob = keys.nextElement(); + Rectangle rect = (Rectangle) nodeHash.get(ob); + + if ((x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y) && + (y <= (rect.y + rect.height))) + { + return ob; + } + } - while (keys.hasMoreElements()) - { - Object ob = keys.nextElement(); - Rectangle rect = (Rectangle) nameHash.get(ob); - - if ( (x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y) && - (y <= (rect.y + rect.height))) - { - return ob; - } + return null; } - keys = nodeHash.keys(); - - while (keys.hasMoreElements()) + /** + * DOCUMENT ME! + * + * @param pickBox DOCUMENT ME! + */ + public void pickNodes(Rectangle pickBox) { - Object ob = keys.nextElement(); - Rectangle rect = (Rectangle) nodeHash.get(ob); - - if ( (x >= rect.x) && (x <= (rect.x + rect.width)) && (y >= rect.y) && - (y <= (rect.y + rect.height))) - { - return ob; - } - } + int width = getWidth(); + int height = getHeight(); - return null; - } + SequenceNode top = tree.getTopNode(); - public void pickNodes(Rectangle pickBox) - { - int width = getWidth(); - int height = getHeight(); + float wscale = (float) ((width * .8) - (offx * 2)) / tree.getMaxHeight(); - SequenceNode top = tree.getTopNode(); + if (top.count == 0) + { + top.count = ((SequenceNode) top.left()).count + + ((SequenceNode) top.right()).count; + } - float wscale = (float) ( (width * .8) - (offx * 2)) / tree.getMaxHeight(); + float chunk = (float) (height - (offy * 2)) / top.count; - if (top.count == 0) - { - top.count = ( (SequenceNode) top.left()).count + - ( (SequenceNode) top.right()).count; + pickNode(pickBox, top, chunk, wscale, width, offx, offy); } - float chunk = (float) (height - (offy * 2)) / top.count; - - pickNode(pickBox, top, chunk, wscale, width, offx, offy); - } - - public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, - float scale, int width, int offx, int offy) - { - if (node == null) + /** + * DOCUMENT ME! + * + * @param pickBox DOCUMENT ME! + * @param node DOCUMENT ME! + * @param chunk DOCUMENT ME! + * @param scale DOCUMENT ME! + * @param width DOCUMENT ME! + * @param offx DOCUMENT ME! + * @param offy DOCUMENT ME! + */ + public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, + float scale, int width, int offx, int offy) { - return; + if (node == null) + { + return; + } + + if ((node.left() == null) && (node.right() == null)) + { + float height = node.height; + float dist = node.dist; + + int xstart = (int) ((height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; + + int ypos = (int) (node.ycount * chunk) + offy; + + if (pickBox.contains(new Point(xend, ypos))) + { + if (node.element() instanceof SequenceI) + { + SequenceI seq = (SequenceI) node.element(); + SequenceGroup sg = av.getSelectionGroup(); + + if (sg != null) + { + sg.addOrRemove(seq, true); + } + } + } + } + else + { + pickNode(pickBox, (SequenceNode) node.left(), chunk, scale, width, + offx, offy); + pickNode(pickBox, (SequenceNode) node.right(), chunk, scale, width, + offx, offy); + } } - if ( (node.left() == null) && (node.right() == null)) + /** + * DOCUMENT ME! + * + * @param node DOCUMENT ME! + * @param c DOCUMENT ME! + */ + public void setColor(SequenceNode node, Color c) { - float height = node.height; - float dist = node.dist; - - int xstart = (int) ( (height - dist) * scale) + offx; - int xend = (int) (height * scale) + offx; - - int ypos = (int) (node.ycount * chunk) + offy; + if (node == null) + { + return; + } - if (pickBox.contains(new Point(xend, ypos))) - { - if (node.element() instanceof SequenceI) + if ((node.left() == null) && (node.right() == null)) { - SequenceI seq = (SequenceI) node.element(); - SequenceGroup sg = av.getSelectionGroup(); + node.color = c; - if (sg != null) - { - sg.addOrRemove(seq, true); - } + if (node.element() instanceof SequenceI) + { + ((SequenceI) node.element()).setColor(c); + } + } + else + { + node.color = c; + setColor((SequenceNode) node.left(), c); + setColor((SequenceNode) node.right(), c); } - } - } - else - { - pickNode(pickBox, (SequenceNode) node.left(), chunk, scale, width, - offx, offy); - pickNode(pickBox, (SequenceNode) node.right(), chunk, scale, width, - offx, offy); } - } - public void setColor(SequenceNode node, Color c) - { - if (node == null) + /** + * DOCUMENT ME! + */ + void startPrinting() { - return; + Thread thread = new Thread(this); + thread.start(); } - if ( (node.left() == null) && (node.right() == null)) + // put printing in a thread to avoid painting problems + public void run() { - node.color = c; + PrinterJob printJob = PrinterJob.getPrinterJob(); + PageFormat pf = printJob.pageDialog(printJob.defaultPage()); - if (node.element() instanceof SequenceI) - { - ( (SequenceI) node.element()).setColor(c); - } - } - else - { - node.color = c; - setColor( (SequenceNode) node.left(), c); - setColor( (SequenceNode) node.right(), c); + printJob.setPrintable(this, pf); + + if (printJob.printDialog()) + { + try + { + printJob.print(); + } + catch (Exception PrintException) + { + PrintException.printStackTrace(); + } + } } - } - void startPrinting() - { - Thread thread = new Thread(this); - thread.start(); - } + /** + * DOCUMENT ME! + * + * @param pg DOCUMENT ME! + * @param pf DOCUMENT ME! + * @param pi DOCUMENT ME! + * + * @return DOCUMENT ME! + * + * @throws PrinterException DOCUMENT ME! + */ + public int print(Graphics pg, PageFormat pf, int pi) + throws PrinterException + { + pg.setFont(font); + pg.translate((int) pf.getImageableX(), (int) pf.getImageableY()); - // put printing in a thread to avoid painting problems - public void run() - { - PrinterJob printJob = PrinterJob.getPrinterJob(); - PageFormat pf = printJob.pageDialog(printJob.defaultPage()); + int pwidth = (int) pf.getImageableWidth(); + int pheight = (int) pf.getImageableHeight(); - printJob.setPrintable(this, pf); + int noPages = getHeight() / pheight; - if (printJob.printDialog()) - { - try - { - printJob.print(); - } - catch (Exception PrintException) - { - PrintException.printStackTrace(); - } - } - } + if (pi > noPages) + { + return Printable.NO_SUCH_PAGE; + } - public int print(Graphics pg, PageFormat pf, int pi) - throws PrinterException - { - pg.setFont(font); - pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY()); + if (pwidth > getWidth()) + { + pwidth = getWidth(); + } - int pwidth = (int) pf.getImageableWidth(); - int pheight = (int) pf.getImageableHeight(); + if (fitToWindow) + { + if (pheight > getHeight()) + { + pheight = getHeight(); + } - int noPages = getHeight() / pheight; + noPages = 0; + } + else + { + FontMetrics fm = pg.getFontMetrics(font); + int height = fm.getHeight() * nameHash.size(); + pg.translate(0, -pi * pheight); + pg.setClip(0, pi * pheight, pwidth, (pi * pheight) + pheight); + + // translate number of pages, + // height is screen size as this is the + // non overlapping text size + pheight = height; + } - if (pi > noPages) - { - return Printable.NO_SUCH_PAGE; - } + draw(pg, pwidth, pheight); - if (pwidth > getWidth()) - { - pwidth = getWidth(); + return Printable.PAGE_EXISTS; } - if (fitToWindow) + /** + * DOCUMENT ME! + * + * @param g DOCUMENT ME! + */ + public void paintComponent(Graphics g) { - if (pheight > getHeight()) - { - pheight = getHeight(); - } + super.paintComponent(g); + font = new Font("Verdana", Font.PLAIN, fontSize); + g.setFont(font); - noPages = 0; - } - else - { - FontMetrics fm = pg.getFontMetrics(font); - int height = fm.getHeight() * nameHash.size(); - pg.translate(0, -pi * pheight); - pg.setClip(0, pi * pheight, pwidth, (pi * pheight) + pheight); - - // translate number of pages, - // height is screen size as this is the - // non overlapping text size - pheight = height; - } + FontMetrics fm = g.getFontMetrics(font); - draw(pg, pwidth, pheight); - - return Printable.PAGE_EXISTS; - } + if (nameHash.size() == 0) + { + repaint(); + } - public void paintComponent(Graphics g) - { - super.paintComponent(g); - font = new Font("Verdana", Font.PLAIN, fontSize); - g.setFont(font); + if (fitToWindow || + (!fitToWindow && + (scrollPane.getHeight() > ((fm.getHeight() * nameHash.size()) + + offy)))) + { + draw(g, scrollPane.getWidth(), scrollPane.getHeight()); + setPreferredSize(null); + } + else + { + setPreferredSize(new Dimension(scrollPane.getWidth(), + fm.getHeight() * nameHash.size())); + draw(g, scrollPane.getWidth(), fm.getHeight() * nameHash.size()); + } - FontMetrics fm = g.getFontMetrics(font); + scrollPane.revalidate(); + } - if (nameHash.size() == 0) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getFontSize() { - repaint(); + return fontSize; } - if (fitToWindow || - (!fitToWindow && - (scrollPane.getHeight() > ( (fm.getHeight() * nameHash.size()) + - offy)))) + /** + * DOCUMENT ME! + * + * @param fontSize DOCUMENT ME! + */ + public void setFontSize(int fontSize) { - draw(g, scrollPane.getWidth(), scrollPane.getHeight()); - setPreferredSize(null); + this.fontSize = fontSize; + repaint(); } - else + + /** + * DOCUMENT ME! + * + * @param g1 DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public void draw(Graphics g1, int width, int height) { - setPreferredSize(new Dimension(scrollPane.getWidth(), - fm.getHeight() * nameHash.size())); - draw(g, scrollPane.getWidth(), fm.getHeight() * nameHash.size()); - } + Graphics2D g2 = (Graphics2D) g1; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + g2.setColor(Color.white); + g2.fillRect(0, 0, width, height); - scrollPane.revalidate(); - } + labelLength = g2.getFontMetrics(font).stringWidth(longestName) + 20; //20 allows for scrollbar - public int getFontSize() - { - return fontSize; - } + float wscale = (float) (width - labelLength - (offx * 2)) / tree.getMaxHeight(); - public void setFontSize(int fontSize) - { - this.fontSize = fontSize; - repaint(); - } + SequenceNode top = tree.getTopNode(); - public void draw(Graphics g1, int width, int height) - { - Graphics2D g2 = (Graphics2D) g1; - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2.setColor(Color.white); - g2.fillRect(0, 0, width, height); + if (top.count == 0) + { + top.count = ((SequenceNode) top.left()).count + + ((SequenceNode) top.right()).count; + } - labelLength = g2.getFontMetrics(font).stringWidth(longestName) + 20; //20 allows for scrollbar + float chunk = (float) (height - (offy * 2)) / top.count; - float wscale = (float) (width - labelLength - (offx * 2)) / - tree.getMaxHeight(); + drawNode(g2, tree.getTopNode(), chunk, wscale, width, offx, offy); - SequenceNode top = tree.getTopNode(); + if (threshold != 0) + { + if (av.getCurrentTree() == tree) + { + g2.setColor(Color.red); + } + else + { + g2.setColor(Color.gray); + } + + int x = (int) ((threshold * (float) (getWidth() - labelLength - + (2 * offx))) + offx); + + g2.drawLine(x, 0, x, getHeight()); + } + } - if (top.count == 0) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseReleased(MouseEvent e) { - top.count = ( (SequenceNode) top.left()).count + - ( (SequenceNode) top.right()).count; } - float chunk = (float) (height - (offy * 2)) / top.count; - - drawNode(g2, tree.getTopNode(), chunk, wscale, width, offx, offy); - - if (threshold != 0) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseEntered(MouseEvent e) { - if (av.getCurrentTree() == tree) - { - g2.setColor(Color.red); - } - else - { - g2.setColor(Color.gray); - } - - int x = (int) ( (threshold * (float) (getWidth() - labelLength - - (2 * offx))) + offx); - - g2.drawLine(x, 0, x, getHeight()); } - } - - public void mouseReleased(MouseEvent e) - { - } - - public void mouseEntered(MouseEvent e) - { - } - - public void mouseExited(MouseEvent e) - { - } - - public void mouseClicked(MouseEvent e) - { - } - public void mousePressed(MouseEvent e) - { - av.setCurrentTree(tree); - - int x = e.getX(); - int y = e.getY(); - - Object ob = findElement(x, y); - - if (ob instanceof SequenceI) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseExited(MouseEvent e) { - TreeSelectionChanged( (Sequence) ob); - repaint(); - - return; } - else if (ob instanceof SequenceNode) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mouseClicked(MouseEvent e) { - SequenceNode tmpnode = (SequenceNode) ob; - tree.swapNodes(tmpnode); - tree.reCount(tree.getTopNode()); - tree.findHeight(tree.getTopNode()); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void mousePressed(MouseEvent e) { - // Find threshold - if (tree.getMaxHeight() != 0) - { - threshold = (float) (x - offx) / (float) (getWidth() - - labelLength - (2 * offx)); + av.setCurrentTree(tree); - tree.getGroups().removeAllElements(); - tree.groupNodes(tree.getTopNode(), threshold); - setColor(tree.getTopNode(), Color.black); + int x = e.getX(); + int y = e.getY(); - av.setSelectionGroup(null); - av.alignment.deleteAllGroups(); + Object ob = findElement(x, y); - for (int i = 0; i < tree.getGroups().size(); i++) + if (ob instanceof SequenceI) { - Color col = new Color( (int) (Math.random() * 255), - (int) (Math.random() * 255), - (int) (Math.random() * 255)); - setColor( (SequenceNode) tree.getGroups().elementAt(i), - col.brighter()); - - Vector l = tree.findLeaves( (SequenceNode) tree.getGroups() - .elementAt(i), - new Vector()); - - Vector sequences = new Vector(); - for (int j = 0; j < l.size(); j++) - { - SequenceI s1 = (SequenceI) ( (SequenceNode) l.elementAt(j)).element(); - if (!sequences.contains(s1)) - sequences.addElement(s1); - - } + TreeSelectionChanged((Sequence) ob); + repaint(); - 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(sg.cs !=null) - ( (ResidueColourScheme) sg.cs).setThreshold(25); - - - if (av.getGlobalColourScheme() instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme) av. - getGlobalColourScheme(); - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, - sg.getStartRes(), sg.getEndRes()); + return; + } + else if (ob instanceof SequenceNode) + { + SequenceNode tmpnode = (SequenceNode) ob; + tree.swapNodes(tmpnode); + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); + } + else + { + // Find threshold + if (tree.getMaxHeight() != 0) + { + threshold = (float) (x - offx) / (float) (getWidth() - + labelLength - (2 * offx)); + + tree.getGroups().removeAllElements(); + tree.groupNodes(tree.getTopNode(), threshold); + setColor(tree.getTopNode(), Color.black); + + av.setSelectionGroup(null); + av.alignment.deleteAllGroups(); + + for (int i = 0; i < tree.getGroups().size(); i++) + { + Color col = new Color((int) (Math.random() * 255), + (int) (Math.random() * 255), + (int) (Math.random() * 255)); + setColor((SequenceNode) tree.getGroups().elementAt(i), + col.brighter()); + + Vector l = tree.findLeaves((SequenceNode) tree.getGroups() + .elementAt(i), + new Vector()); + + Vector sequences = new Vector(); + + for (int j = 0; j < l.size(); j++) + { + SequenceI s1 = (SequenceI) ((SequenceNode) l.elementAt(j)).element(); + + if (!sequences.contains(s1)) + { + sequences.addElement(s1); + } + } + + 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 (sg.cs != null) + { + ((ResidueColourScheme) sg.cs).setThreshold(25); + } + + if (av.getGlobalColourScheme() instanceof ConservationColourScheme) + { + ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme(); + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, sg.sequences, + sg.getStartRes(), sg.getEndRes()); + + c.calculate(); + c.verdict(false, av.ConsPercGaps); + ccs = new ConservationColourScheme(c, ccs.cs); + + sg.cs = ccs; + } + + av.alignment.addGroup(sg); + } + } + } - c.calculate(); - c.verdict(false, av.ConsPercGaps); - ccs = new ConservationColourScheme(c, ccs.cs); + PaintRefresher.Refresh(this, av.alignment); + repaint(); + } - sg.cs = ccs; - } + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setShowDistances(boolean state) + { + this.showDistances = state; + repaint(); + } - av.alignment.addGroup(sg); - } - } + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setShowBootstrap(boolean state) + { + this.showBootstrap = state; + repaint(); } - PaintRefresher.Refresh(this, av.alignment); - repaint(); - } - - public void setShowDistances(boolean state) - { - this.showDistances = state; - repaint(); - } - - public void setShowBootstrap(boolean state) - { - this.showBootstrap = state; - repaint(); - } - - public void setMarkPlaceholders(boolean state) - { - this.markPlaceholders = state; - repaint(); - } + /** + * DOCUMENT ME! + * + * @param state DOCUMENT ME! + */ + public void setMarkPlaceholders(boolean state) + { + this.markPlaceholders = state; + repaint(); + } } diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index 3ba9cdd..ff02d49 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -18,350 +18,439 @@ */ package jalview.gui; -import java.io.*; -import java.util.*; -import javax.imageio.*; - -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; -import javax.swing.*; - -import org.jibble.epsgraphics.*; import jalview.analysis.*; + import jalview.datamodel.*; + import jalview.io.*; + import jalview.jbgui.*; -public class TreePanel - extends GTreePanel -{ - SequenceI[] seq; - String type; - String pwtype; - int start; - int end; - TreeCanvas treeCanvas; - NJTree tree; +import org.jibble.epsgraphics.*; - public TreePanel(AlignViewport av, Vector seqVector, String type, - String pwtype, int s, int e) - { - super(); +import java.awt.*; +import java.awt.event.*; +import java.awt.image.*; - this.type = type; - this.pwtype = pwtype; +import java.io.*; - start = s; - end = e; +import java.util.*; - String longestName = ""; - seq = new Sequence[seqVector.size()]; +import javax.imageio.*; + +import javax.swing.*; - for (int i = 0; i < seqVector.size(); i++) + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class TreePanel extends GTreePanel +{ + SequenceI[] seq; + String type; + String pwtype; + int start; + int end; + TreeCanvas treeCanvas; + NJTree tree; + + /** + * Creates a new TreePanel object. + * + * @param av DOCUMENT ME! + * @param seqVector DOCUMENT ME! + * @param type DOCUMENT ME! + * @param pwtype DOCUMENT ME! + * @param s DOCUMENT ME! + * @param e DOCUMENT ME! + */ + public TreePanel(AlignViewport av, Vector seqVector, String type, + String pwtype, int s, int e) { - seq[i] = (Sequence) seqVector.elementAt(i); + super(); - if (seq[i].getName().length() > longestName.length()) - { - longestName = seq[i].getName(); - } - } + this.type = type; + this.pwtype = pwtype; - tree = new NJTree(seq, type, pwtype, start, end); + start = s; + end = e; - treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName); - treeCanvas.setShowDistances(true); // We know this tree has distances. JBPNote TODO: prolly should add this as a userdefined default - setViewStateFromTreeCanvas(treeCanvas); - tree.reCount(tree.getTopNode()); - tree.findHeight(tree.getTopNode()); - scrollPane.setViewportView(treeCanvas); - } + String longestName = ""; + seq = new Sequence[seqVector.size()]; - public TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree, - String type, String pwtype) - { - super(); + for (int i = 0; i < seqVector.size(); i++) + { + seq[i] = (Sequence) seqVector.elementAt(i); + + if (seq[i].getName().length() > longestName.length()) + { + longestName = seq[i].getName(); + } + } + + tree = new NJTree(seq, type, pwtype, start, end); + + treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName); + treeCanvas.setShowDistances(true); // We know this tree has distances. JBPNote TODO: prolly should add this as a userdefined default + setViewStateFromTreeCanvas(treeCanvas); + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); + scrollPane.setViewportView(treeCanvas); + } - // These are probably only arbitrary strings reflecting source of tree - this.type = type; - this.pwtype = pwtype; + /** + * Creates a new TreePanel object. + * + * @param av DOCUMENT ME! + * @param seqVector DOCUMENT ME! + * @param newtree DOCUMENT ME! + * @param type DOCUMENT ME! + * @param pwtype DOCUMENT ME! + */ + public TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree, + String type, String pwtype) + { + super(); - start = 0; - end = seqVector.size(); + // These are probably only arbitrary strings reflecting source of tree + this.type = type; + this.pwtype = pwtype; - String longestName = ""; - seq = new Sequence[seqVector.size()]; + start = 0; + end = seqVector.size(); - for (int i = 0; i < seqVector.size(); i++) - { - seq[i] = (Sequence) seqVector.elementAt(i); - } + String longestName = ""; + seq = new Sequence[seqVector.size()]; - // This constructor matches sequence names to treenodes and sets up the tree layouts. - tree = new NJTree(seq, newtree); + for (int i = 0; i < seqVector.size(); i++) + { + seq[i] = (Sequence) seqVector.elementAt(i); + } - // Now have to calculate longest name based on the leaves - Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector()); - boolean has_placeholders = false; + // This constructor matches sequence names to treenodes and sets up the tree layouts. + tree = new NJTree(seq, newtree); - for (int i = 0; i < leaves.size(); i++) - { - SequenceNode lf = (SequenceNode) leaves.elementAt(i); - - if (lf.isPlaceholder()) - { - has_placeholders = true; - } - - if (longestName.length() < ( (Sequence) lf.element()).getName() - .length()) - { - longestName = TreeCanvas.PLACEHOLDER + - ( (Sequence) lf.element()).getName(); - } - } + // Now have to calculate longest name based on the leaves + Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector()); + boolean has_placeholders = false; - tree.reCount(tree.getTopNode()); - tree.findHeight(tree.getTopNode()); - - treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName); - treeCanvas.setShowBootstrap(newtree.HasBootstrap()); - treeCanvas.setShowDistances(newtree.HasDistances()); - scrollPane.setViewportView(treeCanvas); - treeCanvas.setMarkPlaceholders(has_placeholders); - setViewStateFromTreeCanvas(treeCanvas); - - // JBPNote TODO: preference for always marking placeholders in new associated tree - } - - public NJTree getTree() - { - return tree; - } - - private void setViewStateFromTreeCanvas(TreeCanvas tree) - { - // update view menu state from treeCanvas render state - distanceMenu.setSelected(tree.showDistances); - bootstrapMenu.setSelected(tree.showBootstrap); - placeholdersMenu.setSelected(tree.markPlaceholders); - } - - private void setTreeCanvasFromViewState(TreeCanvas tree) - { - // update view menu state from treeCanvas render state - tree.showDistances = distanceMenu.isSelected(); - tree.showBootstrap = bootstrapMenu.isSelected(); - tree.markPlaceholders = placeholdersMenu.isSelected(); - } - - public void textbox_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - - StringBuffer buffer = new StringBuffer(); - - if (type.equals("AV")) - { - buffer.append("Average distance tree using "); + for (int i = 0; i < leaves.size(); i++) + { + SequenceNode lf = (SequenceNode) leaves.elementAt(i); + + if (lf.isPlaceholder()) + { + has_placeholders = true; + } + + if (longestName.length() < ((Sequence) lf.element()).getName() + .length()) + { + longestName = TreeCanvas.PLACEHOLDER + + ((Sequence) lf.element()).getName(); + } + } + + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); + + treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName); + treeCanvas.setShowBootstrap(newtree.HasBootstrap()); + treeCanvas.setShowDistances(newtree.HasDistances()); + scrollPane.setViewportView(treeCanvas); + treeCanvas.setMarkPlaceholders(has_placeholders); + setViewStateFromTreeCanvas(treeCanvas); + + // JBPNote TODO: preference for always marking placeholders in new associated tree } - else + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public NJTree getTree() { - buffer.append("Neighbour joining tree using "); + return tree; } - if (pwtype.equals("BL")) + /** + * DOCUMENT ME! + * + * @param tree DOCUMENT ME! + */ + private void setViewStateFromTreeCanvas(TreeCanvas tree) { - buffer.append("BLOSUM62"); + // update view menu state from treeCanvas render state + distanceMenu.setSelected(tree.showDistances); + bootstrapMenu.setSelected(tree.showBootstrap); + placeholdersMenu.setSelected(tree.markPlaceholders); } - else + + /** + * DOCUMENT ME! + * + * @param tree DOCUMENT ME! + */ + private void setTreeCanvasFromViewState(TreeCanvas tree) { - buffer.append("PID"); + // update view menu state from treeCanvas render state + tree.showDistances = distanceMenu.isSelected(); + tree.showBootstrap = bootstrapMenu.isSelected(); + tree.markPlaceholders = placeholdersMenu.isSelected(); } - Desktop.addInternalFrame(cap, buffer.toString(), 500, 100); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void textbox_actionPerformed(ActionEvent e) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(); - jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); - cap.setText(fout.print(false, true)); - } + StringBuffer buffer = new StringBuffer(); - public void saveAsNewick_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY")); - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Save tree as newick file"); - chooser.setToolTipText("Save"); + if (type.equals("AV")) + { + buffer.append("Average distance tree using "); + } + else + { + buffer.append("Neighbour joining tree using "); + } - int value = chooser.showSaveDialog(null); + if (pwtype.equals("BL")) + { + buffer.append("BLOSUM62"); + } + else + { + buffer.append("PID"); + } - if (value == JalviewFileChooser.APPROVE_OPTION) - { - String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); + Desktop.addInternalFrame(cap, buffer.toString(), 500, 100); - try - { jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); - String output = fout.print(false, true); // distances only - java.io.PrintWriter out = new java.io.PrintWriter(new java.io. - FileWriter( - choice)); - out.println(output); - out.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } + cap.setText(fout.print(false, true)); } - } - - public void printMenu_actionPerformed(ActionEvent e) - { - //Putting in a thread avoids Swing painting problems - treeCanvas.startPrinting(); - } - - public void fitToWindow_actionPerformed(ActionEvent e) - { - treeCanvas.fitToWindow = fitToWindow.isSelected(); - repaint(); - } - - public void fontSize_actionPerformed(ActionEvent e) - { - if (treeCanvas == null) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void saveAsNewick_actionPerformed(ActionEvent e) { - return; - } + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save tree as newick file"); + chooser.setToolTipText("Save"); - String size = fontSize.getText().substring(fontSize.getText().indexOf("-") + - 1); + int value = chooser.showSaveDialog(null); - Object selection = JOptionPane.showInternalInputDialog(Desktop.desktop, - "Select font size", "Font size", JOptionPane.QUESTION_MESSAGE, - null, - new String[] + if (value == JalviewFileChooser.APPROVE_OPTION) { - "1", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20" - }, "Font Size - " + size); + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + + try + { + jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); + String output = fout.print(false, true); // distances only + java.io.PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter( + choice)); + out.println(output); + out.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } - if (selection != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void printMenu_actionPerformed(ActionEvent e) { - fontSize.setText("Font Size - " + selection); + //Putting in a thread avoids Swing painting problems + treeCanvas.startPrinting(); + } - int i = Integer.parseInt(selection.toString()); - treeCanvas.setFontSize(i); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void fitToWindow_actionPerformed(ActionEvent e) + { + treeCanvas.fitToWindow = fitToWindow.isSelected(); + repaint(); } - scrollPane.setViewportView(treeCanvas); - } + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void fontSize_actionPerformed(ActionEvent e) + { + if (treeCanvas == null) + { + return; + } - public void distanceMenu_actionPerformed(ActionEvent e) - { - treeCanvas.setShowDistances(distanceMenu.isSelected()); - } + String size = fontSize.getText().substring(fontSize.getText().indexOf("-") + + 1); - public void bootstrapMenu_actionPerformed(ActionEvent e) - { - treeCanvas.setShowBootstrap(bootstrapMenu.isSelected()); - } + Object selection = JOptionPane.showInternalInputDialog(Desktop.desktop, + "Select font size", "Font size", JOptionPane.QUESTION_MESSAGE, + null, + new String[] + { + "1", "2", "4", "6", "8", "10", "12", "14", "16", "18", "20" + }, "Font Size - " + size); - public void placeholdersMenu_actionPerformed(ActionEvent e) - { - treeCanvas.setMarkPlaceholders(placeholdersMenu.isSelected()); - } + if (selection != null) + { + fontSize.setText("Font Size - " + selection); + + int i = Integer.parseInt(selection.toString()); + treeCanvas.setFontSize(i); + } - public void epsTree_actionPerformed(ActionEvent e) - { - int width = treeCanvas.getWidth(); - int height = treeCanvas.getHeight(); + scrollPane.setViewportView(treeCanvas); + } - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void distanceMenu_actionPerformed(ActionEvent e) { - jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), new String[] - {"eps"}, - new String[] - {"Encapsulated Postscript"}, - "Encapsulated Postscript"); - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Create EPS file from tree"); - chooser.setToolTipText("Save"); - - int value = chooser.showSaveDialog(this); - - if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) - { - return; - } - - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); - - FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); - EpsGraphics2D pg = new EpsGraphics2D("Tree", out, 0, 0, width, - height); - - treeCanvas.draw(pg, width, height); - - pg.flush(); - pg.close(); + treeCanvas.setShowDistances(distanceMenu.isSelected()); } - catch (Exception ex) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void bootstrapMenu_actionPerformed(ActionEvent e) { - ex.printStackTrace(); + treeCanvas.setShowBootstrap(bootstrapMenu.isSelected()); } - } - public void pngTree_actionPerformed(ActionEvent e) - { - int width = treeCanvas.getWidth(); - int height = treeCanvas.getHeight(); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void placeholdersMenu_actionPerformed(ActionEvent e) + { + treeCanvas.setMarkPlaceholders(placeholdersMenu.isSelected()); + } - try + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void epsTree_actionPerformed(ActionEvent e) { - jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), new String[] - {"png"}, - new String[] - {"Portable network graphics"}, - "Portable network graphics"); + int width = treeCanvas.getWidth(); + int height = treeCanvas.getHeight(); - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Create PNG image from tree"); - chooser.setToolTipText("Save"); + try + { + jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "eps" }, + new String[] { "Encapsulated Postscript" }, + "Encapsulated Postscript"); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Create EPS file from tree"); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(this); + + if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) + { + return; + } + + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + + FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); + EpsGraphics2D pg = new EpsGraphics2D("Tree", out, 0, 0, width, + height); + + treeCanvas.draw(pg, width, height); + + pg.flush(); + pg.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } - int value = chooser.showSaveDialog(this); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void pngTree_actionPerformed(ActionEvent e) + { + int width = treeCanvas.getWidth(); + int height = treeCanvas.getHeight(); - if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) - { - return; - } + try + { + jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "png" }, + new String[] { "Portable network graphics" }, + "Portable network graphics"); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Create PNG image from tree"); + chooser.setToolTipText("Save"); - FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); + int value = chooser.showSaveDialog(this); - BufferedImage bi = new BufferedImage(width, height, - BufferedImage.TYPE_INT_RGB); - Graphics png = bi.getGraphics(); + if (value != jalview.io.JalviewFileChooser.APPROVE_OPTION) + { + return; + } - treeCanvas.draw(png, width, height); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); - ImageIO.write(bi, "png", out); - out.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); + FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); + + BufferedImage bi = new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + Graphics png = bi.getGraphics(); + + treeCanvas.draw(png, width, height); + + ImageIO.write(bi, "png", out); + out.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - } } diff --git a/src/jalview/gui/UserDefinedColours.java b/src/jalview/gui/UserDefinedColours.java index 18382fb..651f40c 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -18,321 +18,451 @@ */ package jalview.gui; -import java.io.*; -import java.util.*; +import jalview.datamodel.*; + +import jalview.io.*; + +import jalview.jbgui.*; + +import jalview.schemes.*; import java.awt.*; import java.awt.event.*; + +import java.io.*; + +import java.util.*; + import javax.swing.*; import javax.swing.event.*; -import jalview.datamodel.*; -import jalview.io.*; -import jalview.jbgui.*; -import jalview.schemes.*; -public class UserDefinedColours - extends GUserDefinedColours implements ChangeListener +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class UserDefinedColours extends GUserDefinedColours + implements ChangeListener { - AlignmentPanel ap; - SequenceGroup seqGroup; - JButton selectedButton; - Vector oldColours = new Vector(); - ColourSchemeI oldColourScheme; - JInternalFrame frame; - - public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) - { - super(); - frame = new JInternalFrame(); - frame.setContentPane(this); - Desktop.addInternalFrame(frame, "User Defined Colours", 450, 530, false); - - if (System.getProperty("os.name").startsWith("Mac")) + AlignmentPanel ap; + SequenceGroup seqGroup; + Vector selectedButtons; + Vector oldColours = new Vector(); + ColourSchemeI oldColourScheme; + JInternalFrame frame; + + /** + * Creates a new UserDefinedColours object. + * + * @param ap DOCUMENT ME! + * @param sg DOCUMENT ME! + */ + public UserDefinedColours(AlignmentPanel ap, SequenceGroup sg) { - frame.setSize(450, 560); - } + super(); + frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, "User Defined Colours", 450, 530, false); - if (sg != null) - { - frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")"); - } + if (System.getProperty("os.name").startsWith("Mac")) + { + frame.setSize(450, 560); + } - colorChooser.getSelectionModel().addChangeListener(this); + if (sg != null) + { + frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")"); + } - this.ap = ap; - seqGroup = sg; + colorChooser.getSelectionModel().addChangeListener(this); - if (seqGroup != null) - { - oldColourScheme = seqGroup.cs; - } - else - { - oldColourScheme = ap.av.getGlobalColourScheme(); - } + this.ap = ap; + seqGroup = sg; - for (int i = 0; i < 20; i++) - { - makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + - "", ResidueProperties.aa[i]); - } + if (seqGroup != null) + { + oldColourScheme = seqGroup.cs; + } + else + { + oldColourScheme = ap.av.getGlobalColourScheme(); + } + + for (int i = 0; i < 20; i++) + { + makeButton(ResidueProperties.aa2Triplet.get(ResidueProperties.aa[i]) + + "", ResidueProperties.aa[i]); + } - makeButton("B", "B"); - makeButton("Z", "Z"); - makeButton("X", "X"); - makeButton("Gap", "'.','-',' '"); + makeButton("B", "B"); + makeButton("Z", "Z"); + makeButton("X", "X"); + makeButton("Gap", "'.','-',' '"); - if (jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR") != null) - { - loadColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")); + if (jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR") != null) + { + loadColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")); + } } - } - public void stateChanged(ChangeEvent evt) - { - if (selectedButton != null) + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + */ + public void stateChanged(ChangeEvent evt) { - selectedButton.setBackground(colorChooser.getColor()); + if (selectedButtons != null) + { + JButton button; + for(int i=0; i endIndex) + { + int temp = startIndex; + startIndex = endIndex; + endIndex = temp; + } - buttonPanel.add(button, null); - } + for(int b=startIndex; b<=endIndex; b++) + { + JButton button = (JButton)buttonPanel.getComponent(b); + if(!selectedButtons.contains(button)) + { + button.setForeground(button.getBackground().brighter().brighter()); + selectedButtons.add(button); + } + } + } + else if(!e.isControlDown()) + { + for(int b=0; b0) + colorChooser.setColor( ((JButton)selectedButtons.elementAt(0)).getBackground()); } - catch (Exception ex) - { - } - } - protected void applyButton_actionPerformed(ActionEvent e) - { - Color[] newColours = new Color[24]; - - for (int i = 0; i < 24; i++) + /** + * DOCUMENT ME! + * + * @param label DOCUMENT ME! + * @param aa DOCUMENT ME! + */ + void makeButton(String label, String aa) { - JButton button = (JButton) buttonPanel.getComponent(i); - newColours[i] = button.getBackground(); - } + final JButton button = new JButton(); + Color col = Color.white; - UserColourScheme ucs = new UserColourScheme(newColours); - ucs.setThreshold(0); + try + { + col = oldColourScheme.findColour(aa, -1); + } + catch (Exception ex) + { + } - if (seqGroup != null) - { - seqGroup.cs = ucs; - ap.repaint(); + button.setBackground(col); + oldColours.addElement(col); + button.setText(label); + button.setForeground(col.darker().darker().darker()); + button.setFont(new java.awt.Font("Verdana", 1, 10)); + button.addMouseListener(new java.awt.event.MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + colourButtonPressed(e); + } + }); + + buttonPanel.add(button, null); } - else + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void okButton_actionPerformed(ActionEvent e) { - ap.alignFrame.changeColour(ucs); + applyButton_actionPerformed(null); + + try + { + frame.setClosed(true); + } + catch (Exception ex) + { + } } - } - - protected void loadbutton_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), new String[] - {"jc"}, - new String[] - {"Jalview User Colours"}, "Jalview User Colours"); - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Load colour scheme"); - chooser.setToolTipText("Load"); - - int value = chooser.showOpenDialog(this); - - if (value == JalviewFileChooser.APPROVE_OPTION) + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void applyButton_actionPerformed(ActionEvent e) { - File choice = chooser.getSelectedFile(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); - jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", - choice.getPath()); + Color[] newColours = new Color[24]; - Color[] colors = loadColours(choice.getAbsolutePath()); + for (int i = 0; i < 24; i++) + { + JButton button = (JButton) buttonPanel.getComponent(i); + newColours[i] = button.getBackground(); + } - for (int i = 0; i < colors.length; i++) - { - JButton button = (JButton) buttonPanel.getComponent(i); - button.setBackground(colors[i]); - } - } - } + UserColourScheme ucs = new UserColourScheme(newColours); + ucs.setThreshold(0); - public static UserColourScheme loadDefaultColours() - { - if (jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR") != null) - { - return loadDefaultColours(jalview.bin.Cache.getProperty( - "USER_DEFINED_COLOUR")); - } - else - { - return null; + if (seqGroup != null) + { + seqGroup.cs = ucs; + ap.repaint(); + } + else + { + ap.alignFrame.changeColour(ucs); + } } - } - - public static UserColourScheme loadDefaultColours(String file) - { - UserColourScheme ucs = null; - Color[] cols = loadColours(file); - if (cols != null) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void loadbutton_actionPerformed(ActionEvent e) { - ucs = new UserColourScheme(cols); - ucs.setThreshold(0); - } + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "jc" }, + new String[] { "Jalview User Colours" }, "Jalview User Colours"); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Load colour scheme"); + chooser.setToolTipText("Load"); - return ucs; - } + int value = chooser.showOpenDialog(this); - static Color[] loadColours(String file) - { - Color[] newColours = null; + if (value == JalviewFileChooser.APPROVE_OPTION) + { + File choice = chooser.getSelectedFile(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); + jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", + choice.getPath()); + + Color[] colors = loadColours(choice.getAbsolutePath()); + + for (int i = 0; i < colors.length; i++) + { + JButton button = (JButton) buttonPanel.getComponent(i); + button.setBackground(colors[i]); + } + } + } - try + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static UserColourScheme loadDefaultColours() { - InputStreamReader in = new InputStreamReader(new FileInputStream( - file), "UTF-8"); + if (jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR") != null) + { + return loadDefaultColours(jalview.bin.Cache.getProperty( + "USER_DEFINED_COLOUR")); + } + else + { + return null; + } + } - jalview.binding.JalviewUserColours ucs = new jalview.binding. - JalviewUserColours(); - ucs = (jalview.binding.JalviewUserColours) ucs.unmarshal(in); + /** + * DOCUMENT ME! + * + * @param file DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static UserColourScheme loadDefaultColours(String file) + { + UserColourScheme ucs = null; + Color[] cols = loadColours(file); - newColours = new Color[ucs.getColourCount()]; + if (cols != null) + { + ucs = new UserColourScheme(cols); + ucs.setThreshold(0); + } - for (int i = 0; i < 24; i++) - { - newColours[i] = new Color(Integer.parseInt( - ucs.getColour(i).getRGB(), 16)); - } + return ucs; } - catch (Exception ex) + + static Color[] loadColours(String file) { - System.out.println("Error loading UserColourFile " + file); - } + Color[] newColours = null; + + try + { + InputStreamReader in = new InputStreamReader(new FileInputStream( + file), "UTF-8"); - return newColours; - } + jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours(); + ucs = (jalview.binding.JalviewUserColours) ucs.unmarshal(in); - protected void savebutton_actionPerformed(ActionEvent e) - { - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty( - "LAST_DIRECTORY"), new String[] - {"jc"}, - new String[] - {"Jalview User Colours"}, "Jalview User Colours"); + newColours = new Color[ucs.getColourCount()]; - chooser.setFileView(new jalview.io.JalviewFileView()); - chooser.setDialogTitle("Save colour scheme"); - chooser.setToolTipText("Save"); + for (int i = 0; i < 24; i++) + { + newColours[i] = new Color(Integer.parseInt( + ucs.getColour(i).getRGB(), 16)); + } + } + catch (Exception ex) + { + System.out.println("Error loading UserColourFile " + file); + } - int value = chooser.showSaveDialog(this); + return newColours; + } - if (value == JalviewFileChooser.APPROVE_OPTION) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void savebutton_actionPerformed(ActionEvent e) { - String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice); + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "jc" }, + new String[] { "Jalview User Colours" }, "Jalview User Colours"); - jalview.binding.JalviewUserColours ucs = new jalview.binding. - JalviewUserColours(); + chooser.setFileView(new jalview.io.JalviewFileView()); + chooser.setDialogTitle("Save colour scheme"); + chooser.setToolTipText("Save"); - try - { - PrintWriter out = new PrintWriter(new OutputStreamWriter( - new FileOutputStream(choice), "UTF-8")); + int value = chooser.showSaveDialog(this); - for (int i = 0; i < 24; i++) + if (value == JalviewFileChooser.APPROVE_OPTION) { - JButton button = (JButton) buttonPanel.getComponent(i); - jalview.binding.Colour col = new jalview.binding.Colour(); - col.setName(button.getText()); - col.setRGB(jalview.util.Format.getHexString( - button.getBackground())); - ucs.addColour(col); + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice); + + jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours(); + + try + { + PrintWriter out = new PrintWriter(new OutputStreamWriter( + new FileOutputStream(choice), "UTF-8")); + + for (int i = 0; i < 24; i++) + { + JButton button = (JButton) buttonPanel.getComponent(i); + jalview.binding.Colour col = new jalview.binding.Colour(); + col.setName(button.getText()); + col.setRGB(jalview.util.Format.getHexString( + button.getBackground())); + ucs.addColour(col); + } + + ucs.marshal(out); + out.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - - ucs.marshal(out); - out.close(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } } - } - - protected void cancelButton_actionPerformed(ActionEvent e) - { - Color[] newColours = new Color[24]; - for (int i = 0; i < 24; i++) + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cancelButton_actionPerformed(ActionEvent e) { - newColours[i] = (Color) oldColours.elementAt(i); - buttonPanel.getComponent(i).setBackground(newColours[i]); - } + Color[] newColours = new Color[24]; - UserColourScheme ucs = new UserColourScheme(newColours); + for (int i = 0; i < 24; i++) + { + newColours[i] = (Color) oldColours.elementAt(i); + buttonPanel.getComponent(i).setBackground(newColours[i]); + } - if (seqGroup != null) - { - seqGroup.cs = ucs; - } - else - { - ap.av.setGlobalColourScheme(ucs); - } + UserColourScheme ucs = new UserColourScheme(newColours); + + if (seqGroup != null) + { + seqGroup.cs = ucs; + } + else + { + ap.av.setGlobalColourScheme(ucs); + } - ap.repaint(); + ap.repaint(); - try - { - frame.setClosed(true); - } - catch (Exception ex) - { + try + { + frame.setClosed(true); + } + catch (Exception ex) + { + } } - } } diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 0a098e5..5241ec4 100755 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -18,209 +18,296 @@ */ package jalview.gui; +import jalview.jbgui.*; + import java.awt.*; import java.awt.event.*; + import javax.swing.*; -import jalview.jbgui.*; -public class WebserviceInfo - extends GWebserviceInfo +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class WebserviceInfo extends GWebserviceInfo { - public static final int STATE_QUEUING = 0; - public static final int STATE_RUNNING = 1; - public static final int STATE_STOPPED_OK = 2; - public static final int STATE_CANCELLED_OK = 3; - public static final int STATE_STOPPED_ERROR = 4; - public static final int STATE_STOPPED_SERVERERROR = 5; - int currentStatus = STATE_QUEUING; - Image image; - int angle = 0; - String title = ""; - jalview.ws.WSClientI thisService; - boolean serviceIsCancellable; - - public WebserviceInfo(String title, String info) - { - init(title, info, 520, 500); - } - - public WebserviceInfo(String title, String info, int width, int height) - { - init(title, info, width, height); - } - - public jalview.ws.WSClientI getthisService() - { - return thisService; - } - - public void setthisService(jalview.ws.WSClientI newservice) - { - thisService = newservice; - serviceIsCancellable = newservice.isCancellable(); - } - - void init(String title, String info, int width, int height) - { - JInternalFrame frame = new JInternalFrame(); - frame.setContentPane(this); - Desktop.addInternalFrame(frame, title, width, height); - - this.title = title; - setInfoText(info); - - java.net.URL url = getClass().getResource("/images/logo.gif"); - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); - - MediaTracker mt = new MediaTracker(this); - mt.addImage(image, 0); - - try + /** DOCUMENT ME!! */ + public static final int STATE_QUEUING = 0; + + /** DOCUMENT ME!! */ + public static final int STATE_RUNNING = 1; + + /** DOCUMENT ME!! */ + public static final int STATE_STOPPED_OK = 2; + + /** DOCUMENT ME!! */ + public static final int STATE_CANCELLED_OK = 3; + + /** DOCUMENT ME!! */ + public static final int STATE_STOPPED_ERROR = 4; + + /** DOCUMENT ME!! */ + public static final int STATE_STOPPED_SERVERERROR = 5; + int currentStatus = STATE_QUEUING; + Image image; + int angle = 0; + String title = ""; + jalview.ws.WSClientI thisService; + boolean serviceIsCancellable; + + /** + * Creates a new WebserviceInfo object. + * + * @param title DOCUMENT ME! + * @param info DOCUMENT ME! + */ + public WebserviceInfo(String title, String info) { - mt.waitForID(0); + init(title, info, 520, 500); } - catch (Exception ex) + + /** + * Creates a new WebserviceInfo object. + * + * @param title DOCUMENT ME! + * @param info DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + public WebserviceInfo(String title, String info, int width, int height) { + init(title, info, width, height); } - AnimatedPanel ap = new AnimatedPanel(); - titlePanel.add(ap, BorderLayout.CENTER); - - Thread thread = new Thread(ap); - thread.start(); - } - - public void setStatus(int status) - { - currentStatus = status; - } - - public String getInfoText() - { - return infoText.getText(); - } - - public void setInfoText(String text) - { - infoText.setText(text); - } - - public void appendInfoText(String text) - { - infoText.append(text); - } - - public String getProgressText() - { - return progressText.getText(); - } - - public void setProgressText(String text) - { - progressText.setText(text); - } - - public void appendProgressText(String text) - { - progressText.append(text); - } - - protected void cancel_actionPerformed(ActionEvent e) - { - if (!serviceIsCancellable) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public jalview.ws.WSClientI getthisService() { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "This job cannot be cancelled.", - "Cancel job", - JOptionPane.WARNING_MESSAGE); + return thisService; } - else + + /** + * DOCUMENT ME! + * + * @param newservice DOCUMENT ME! + */ + public void setthisService(jalview.ws.WSClientI newservice) { - thisService.cancelJob(); + thisService = newservice; + serviceIsCancellable = newservice.isCancellable(); } - } - - class AnimatedPanel - extends JPanel implements Runnable - { - long startTime = 0; - public void run() + /** + * DOCUMENT ME! + * + * @param title DOCUMENT ME! + * @param info DOCUMENT ME! + * @param width DOCUMENT ME! + * @param height DOCUMENT ME! + */ + void init(String title, String info, int width, int height) { - startTime = System.currentTimeMillis(); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(this); + Desktop.addInternalFrame(frame, title, width, height); - while (currentStatus < STATE_STOPPED_OK) - { + this.title = title; + setInfoText(info); + + java.net.URL url = getClass().getResource("/images/logo.gif"); + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + + MediaTracker mt = new MediaTracker(this); + mt.addImage(image, 0); try { - Thread.sleep(50); - - int units = (int) ( (System.currentTimeMillis() - startTime) / 10f); - angle += units; - angle %= 360; - startTime = System.currentTimeMillis(); - repaint(); + mt.waitForID(0); } catch (Exception ex) { } - } - angle = 0; - cancel.setEnabled(false); + AnimatedPanel ap = new AnimatedPanel(); + titlePanel.add(ap, BorderLayout.CENTER); + + Thread thread = new Thread(ap); + thread.start(); } - synchronized public void paintComponent(Graphics g1) + /** + * DOCUMENT ME! + * + * @param status DOCUMENT ME! + */ + public void setStatus(int status) { - Graphics2D g = (Graphics2D) g1; - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); + currentStatus = status; + } - if (image != null) - { - g.rotate(Math.toRadians(angle), 28, 28); - g.drawImage(image, 10, 10, this); - g.rotate( -Math.toRadians(angle), 28, 28); - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getInfoText() + { + return infoText.getText(); + } - g.setFont(new Font("Arial", Font.BOLD, 12)); - g.setColor(Color.black); + /** + * DOCUMENT ME! + * + * @param text DOCUMENT ME! + */ + public void setInfoText(String text) + { + infoText.setText(text); + } - switch (currentStatus) - { - case STATE_QUEUING: - g.drawString(title.concat(" - queuing"), 60, 30); + /** + * DOCUMENT ME! + * + * @param text DOCUMENT ME! + */ + public void appendInfoText(String text) + { + infoText.append(text); + } - break; + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getProgressText() + { + return progressText.getText(); + } - case STATE_RUNNING: - g.drawString(title.concat(" - running"), 60, 30); + /** + * DOCUMENT ME! + * + * @param text DOCUMENT ME! + */ + public void setProgressText(String text) + { + progressText.setText(text); + } - break; + /** + * DOCUMENT ME! + * + * @param text DOCUMENT ME! + */ + public void appendProgressText(String text) + { + progressText.append(text); + } - case STATE_STOPPED_OK: - g.drawString(title.concat(" - complete"), 60, 30); + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cancel_actionPerformed(ActionEvent e) + { + if (!serviceIsCancellable) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "This job cannot be cancelled.", "Cancel job", + JOptionPane.WARNING_MESSAGE); + } + else + { + thisService.cancelJob(); + } + } - break; + class AnimatedPanel extends JPanel implements Runnable + { + long startTime = 0; - case STATE_CANCELLED_OK: - g.drawString(title.concat(" - job cancelled!"), 60, 30); + public void run() + { + startTime = System.currentTimeMillis(); + + while (currentStatus < STATE_STOPPED_OK) + { + try + { + Thread.sleep(50); + + int units = (int) ((System.currentTimeMillis() - startTime) / 10f); + angle += units; + angle %= 360; + startTime = System.currentTimeMillis(); + repaint(); + } + catch (Exception ex) + { + } + } + + angle = 0; + cancel.setEnabled(false); + } - break; + synchronized public void paintComponent(Graphics g1) + { + Graphics2D g = (Graphics2D) g1; + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); - case STATE_STOPPED_ERROR: - g.drawString(title.concat(" - job error!"), 60, 30); + if (image != null) + { + g.rotate(Math.toRadians(angle), 28, 28); + g.drawImage(image, 10, 10, this); + g.rotate(-Math.toRadians(angle), 28, 28); + } - break; + g.setFont(new Font("Arial", Font.BOLD, 12)); + g.setColor(Color.black); - case STATE_STOPPED_SERVERERROR: - g.drawString(title.concat(" - Server Error! (try later)"), 60, - 30); + switch (currentStatus) + { + case STATE_QUEUING: + g.drawString(title.concat(" - queuing"), 60, 30); - break; - } + break; + + case STATE_RUNNING: + g.drawString(title.concat(" - running"), 60, 30); + + break; + + case STATE_STOPPED_OK: + g.drawString(title.concat(" - complete"), 60, 30); + + break; + + case STATE_CANCELLED_OK: + g.drawString(title.concat(" - job cancelled!"), 60, 30); + + break; + + case STATE_STOPPED_ERROR: + g.drawString(title.concat(" - job error!"), 60, 30); + + break; + + case STATE_STOPPED_SERVERERROR: + g.drawString(title.concat(" - Server Error! (try later)"), 60, + 30); + + break; + } + } } - } } diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index 04ddff3..d22dc12 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -25,7 +25,14 @@ import java.io.*; import java.util.*; -public abstract class AlignFile extends FileParse { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public abstract class AlignFile extends FileParse +{ int noSeqs = 0; int maxLength = 0; Vector seqs; @@ -33,16 +40,29 @@ public abstract class AlignFile extends FileParse { long start; long end; - public AlignFile() { + /** + * Creates a new AlignFile object. + */ + public AlignFile() + { } - public AlignFile(String inStr) { + /** + * Creates a new AlignFile object. + * + * @param inStr DOCUMENT ME! + */ + public AlignFile(String inStr) + { initData(); System.out.println("is this ever called??"); - try { + try + { parse(); - } catch (Exception ex) { + } + catch (Exception ex) + { } } @@ -51,7 +71,8 @@ public abstract class AlignFile extends FileParse { * @param inFile Filename to read from. * @param type What type of file to read from (File, URL) */ - public AlignFile(String inFile, String type) throws IOException { + public AlignFile(String inFile, String type) throws IOException + { super(inFile, type); initData(); @@ -62,17 +83,20 @@ public abstract class AlignFile extends FileParse { /** * Return the seqs Vector */ - public Vector getSeqs() { + public Vector getSeqs() + { return seqs; } /** * Return the Sequences in the seqs Vector as an array of Sequences */ - public SequenceI[] getSeqsAsArray() { + public SequenceI[] getSeqsAsArray() + { SequenceI[] s = new SequenceI[seqs.size()]; - for (int i = 0; i < seqs.size(); i++) { + for (int i = 0; i < seqs.size(); i++) + { s[i] = (SequenceI) seqs.elementAt(i); } @@ -82,24 +106,34 @@ public abstract class AlignFile extends FileParse { /** * Initialise objects to store sequence data in. */ - protected void initData() { + protected void initData() + { seqs = new Vector(); headers = new Vector(); } - protected void setSeqs(SequenceI[] s) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + */ + protected void setSeqs(SequenceI[] s) + { seqs = new Vector(); - for (int i = 0; i < s.length; i++) { + for (int i = 0; i < s.length; i++) + { seqs.addElement(s[i]); } } // Checks whether sequence is valid aa characters - protected boolean isValidProteinSequence(String sequence) { + protected boolean isValidProteinSequence(String sequence) + { for (int i = 0; i < sequence.length(); i++) if (!jalview.schemes.ResidueProperties.aaHash.containsKey( - String.valueOf(sequence.charAt(i)))) { + String.valueOf(sequence.charAt(i)))) + { return false; } diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index e0750d5..074e6ce 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -25,26 +25,60 @@ import java.io.*; import java.util.*; -public class BLCFile extends AlignFile { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class BLCFile extends AlignFile +{ Vector titles; - public BLCFile() { + /** + * Creates a new BLCFile object. + */ + public BLCFile() + { } - public BLCFile(String inStr) { + /** + * Creates a new BLCFile object. + * + * @param inStr DOCUMENT ME! + */ + public BLCFile(String inStr) + { super(inStr); } - public BLCFile(String inFile, String type) throws IOException { + /** + * Creates a new BLCFile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public BLCFile(String inFile, String type) throws IOException + { super(inFile, type); } - public void initData() { + /** + * DOCUMENT ME! + */ + public void initData() + { super.initData(); titles = new Vector(); } - public void parse() { + /** + * DOCUMENT ME! + */ + public void parse() + { boolean idsFound = false; Vector ids = new Vector(); StringBuffer[] seqstrings; @@ -53,12 +87,15 @@ public class BLCFile extends AlignFile { String line = null; - try { - do { + try + { + do + { line = nextLine(); // seek end of ids - if (line.indexOf("*") > -1) { + if (line.indexOf("*") > -1) + { idsFound = true; break; @@ -66,14 +103,16 @@ public class BLCFile extends AlignFile { int abracket = line.indexOf(">"); - if (abracket > -1) { + if (abracket > -1) + { if (line.indexOf(" ") > -1) // - { + { ///Colur it be this format? //>54402046 0 1 137 137: // or this?? // 1 >L1H14 30539 343 - try { + try + { ids.addElement(line.substring(abracket + 1, line.indexOf(" ", abracket + 1))); @@ -92,75 +131,106 @@ public class BLCFile extends AlignFile { value = Integer.parseInt(line.substring(0, line.indexOf(" "))); ends.addElement(value + ""); - } catch (Exception ex) { + } + catch (Exception ex) + { System.err.println("Error during blockfile read."); ex.printStackTrace(); starts.addElement("0"); ends.addElement("0"); } - } else { - if(line.indexOf("/")>-1) + } + else + { + if (line.indexOf("/") > -1) { - ids.addElement(line.substring(abracket + 1, - line.indexOf("/"))); - line = line.substring(line.indexOf("/") + 1); - starts.addElement(line.substring(0, line.indexOf("-"))); - ends.addElement(line.substring(line.indexOf("-") + 1)); + ids.addElement(line.substring(abracket + 1, + line.indexOf("/"))); + line = line.substring(line.indexOf("/") + 1); + starts.addElement(line.substring(0, + line.indexOf("-"))); + ends.addElement(line.substring(line.indexOf("-") + + 1)); } - else{ - ids.addElement(line.substring(abracket+1)); - starts.addElement("0"); - ends.addElement("0"); + else + { + ids.addElement(line.substring(abracket + 1)); + starts.addElement("0"); + ends.addElement("0"); } - } } - } while (!idsFound); + } + while (!idsFound); int starCol = line.indexOf("*"); seqstrings = new StringBuffer[ids.size()]; - for (int i = 0; i < ids.size(); i++) { - if (seqstrings[i] == null) { + for (int i = 0; i < ids.size(); i++) + { + if (seqstrings[i] == null) + { seqstrings[i] = new StringBuffer(); } } - while ((line = nextLine()).indexOf("*") == -1) { - for (int i = 0; i < ids.size(); i++) { - if (line.length() > (i + starCol)) { + while ((line = nextLine()).indexOf("*") == -1) + { + for (int i = 0; i < ids.size(); i++) + { + if (line.length() > (i + starCol)) + { seqstrings[i].append(line.charAt(i + starCol)); } } } - for (int i = 0; i < ids.size(); i++) { + for (int i = 0; i < ids.size(); i++) + { Sequence newSeq = new Sequence(ids.elementAt(i).toString(), seqstrings[i].toString(), Integer.parseInt(starts.elementAt(i).toString()), Integer.parseInt(ends.elementAt(i).toString())); seqs.addElement(newSeq); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } } - public String print() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() + { return print(getSeqsAsArray()); } - public static String print(SequenceI[] s) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String print(SequenceI[] s) + { StringBuffer out = new StringBuffer(); int i = 0; int max = -1; - while ((i < s.length) && (s[i] != null)) { + while ((i < s.length) && (s[i] != null)) + { out.append(">" + s[i].getName() + "/" + s[i].getStart() + "-" + s[i].getEnd() + "\n"); - if (s[i].getSequence().length() > max) { + if (s[i].getSequence().length() > max) + { max = s[i].getSequence().length(); } @@ -169,13 +239,18 @@ public class BLCFile extends AlignFile { out.append("* iteration 1\n"); - for (int j = 0; j < max; j++) { + for (int j = 0; j < max; j++) + { i = 0; - while ((i < s.length) && (s[i] != null)) { - if (s[i].getSequence().length() > j) { + while ((i < s.length) && (s[i] != null)) + { + if (s[i].getSequence().length() > j) + { out.append(s[i].getSequence().substring(j, j + 1)); - } else { + } + else + { out.append("-"); } diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index b0d46b2..74cb2d0 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -1,215 +1,261 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; -import jalview.datamodel.*; - -import jalview.util.*; - import java.io.*; - import java.util.*; +import jalview.datamodel.*; +import jalview.util.*; -public class ClustalFile extends AlignFile { - Vector ids; - - public ClustalFile() { - } - - public ClustalFile(String inStr) { - super(inStr); - } - - public ClustalFile(String inFile, String type) throws IOException { - super(inFile, type); - } - - public void initData() { - super.initData(); - ids = new Vector(); - } +public class ClustalFile + extends AlignFile +{ + Vector ids; + + public ClustalFile() + { + } + + public ClustalFile(String inStr) + { + super(inStr); + } + + public ClustalFile(String inFile, String type) + throws IOException + { + super(inFile, type); + } + + public void initData() + { + super.initData(); + ids = new Vector(); + } + + public void parse() + { + int i = 0; + boolean flag = false; + + Vector headers = new Vector(); + Hashtable seqhash = new Hashtable(); + + String line; + + try + { + while ( (line = nextLine()) != null) + { + if (line.indexOf(" ") != 0) + { + StringTokenizer str = new StringTokenizer(line, " "); + String id = ""; + + if (str.hasMoreTokens()) + { + id = str.nextToken(); + + if (id.equals("CLUSTAL")) + { + flag = true; + } + else + { + if (flag) + { + StringBuffer tempseq; + + if (seqhash.containsKey(id)) + { + tempseq = (StringBuffer) seqhash.get(id); + } + else + { + tempseq = new StringBuffer(); + seqhash.put(id, tempseq); + } - public void parse() { - int i = 0; - boolean flag = false; - - Vector headers = new Vector(); - Hashtable seqhash = new Hashtable(); - - String line; - - try { - while ((line = nextLine()) != null) { - if (line.indexOf(" ") != 0) { - StringTokenizer str = new StringTokenizer(line, " "); - String id = ""; - - if (str.hasMoreTokens()) { - id = str.nextToken(); - - if (id.equals("CLUSTAL")) { - flag = true; - } else { - if (flag) { - StringBuffer tempseq; - - if (seqhash.containsKey(id)) { - tempseq = (StringBuffer) seqhash.get(id); - } else { - tempseq = new StringBuffer(); - seqhash.put(id, tempseq); - } - - if (!(headers.contains(id))) { - headers.addElement(id); - } - - if (str.hasMoreTokens()) { - tempseq.append(str.nextToken()); - } - } - } - } + if (! (headers.contains(id))) + { + headers.addElement(id); } - } - } catch (IOException e) { - System.err.println("Exception parsing clustal file " + e); - e.printStackTrace(); - } - if (flag) { - this.noSeqs = headers.size(); - - //Add sequences to the hash - for (i = 0; i < headers.size(); i++) { - int start = -1; - int end = -1; - - if (seqhash.get(headers.elementAt(i)) != null) { - if (maxLength < seqhash.get(headers.elementAt(i)).toString() - .length()) { - maxLength = seqhash.get(headers.elementAt(i)).toString() - .length(); - } - - String head = headers.elementAt(i).toString(); - start = 1; - end = seqhash.get(headers.elementAt(i)).toString().length(); - - if (head.indexOf("/") > 0) { - StringTokenizer st = new StringTokenizer(head, "/"); - - if (st.countTokens() == 2) { - ids.addElement(st.nextToken()); - - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) { - start = Integer.valueOf(st.nextToken()) - .intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } - } else { - ids.addElement(headers.elementAt(i)); - } - } else { - ids.addElement(headers.elementAt(i)); - } - - Sequence newSeq = new Sequence(ids.elementAt(i).toString(), - seqhash.get(headers.elementAt(i).toString()) - .toString(), start, end); - - seqs.addElement(newSeq); - } else { - System.err.println( - "Clustal File Reader: Can't find sequence for " + - headers.elementAt(i)); + if (str.hasMoreTokens()) + { + tempseq.append(str.nextToken()); } + } } + } } + } } - - public String print() { - return print(getSeqsAsArray()); + catch (IOException e) + { + System.err.println("Exception parsing clustal file " + e); + e.printStackTrace(); } - public static String print(SequenceI[] s) { - StringBuffer out = new StringBuffer("CLUSTAL\n\n"); + if (flag) + { + this.noSeqs = headers.size(); + + //Add sequences to the hash + for (i = 0; i < headers.size(); i++) + { + int start = -1; + int end = -1; + + if (seqhash.get(headers.elementAt(i)) != null) + { + if (maxLength < seqhash.get(headers.elementAt(i)).toString() + .length()) + { + maxLength = seqhash.get(headers.elementAt(i)).toString() + .length(); + } + + String head = headers.elementAt(i).toString(); + start = 1; + end = seqhash.get(headers.elementAt(i)).toString().length(); + + if (head.indexOf("/") > 0) + { + StringTokenizer st = new StringTokenizer(head, "/"); + + if (st.countTokens() == 2) + { + ids.addElement(st.nextToken()); + + String tmp = st.nextToken(); + st = new StringTokenizer(tmp, "-"); + + if (st.countTokens() == 2) + { + start = Integer.valueOf(st.nextToken()) + .intValue(); + end = Integer.valueOf(st.nextToken()).intValue(); + } + } + else + { + ids.addElement(headers.elementAt(i)); + } + } + else + { + ids.addElement(headers.elementAt(i)); + } + + Sequence newSeq = new Sequence(ids.elementAt(i).toString(), + seqhash.get(headers.elementAt(i). + toString()) + .toString(), start, end); + + seqs.addElement(newSeq); + } + else + { + System.err.println( + "Clustal File Reader: Can't find sequence for " + + headers.elementAt(i)); + } + } + } + } - int max = 0; - int maxid = 0; + public String print() + { + return print(getSeqsAsArray()); + } - int i = 0; + public static String print(SequenceI[] s) + { + StringBuffer out = new StringBuffer("CLUSTAL\n\n"); - while ((i < s.length) && (s[i] != null)) { - String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd(); + int max = 0; + int maxid = 0; - if (s[i].getSequence().length() > max) { - max = s[i].getSequence().length(); - } + int i = 0; - if (tmp.length() > maxid) { - maxid = tmp.length(); - } + while ( (i < s.length) && (s[i] != null)) + { + String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + + s[i].getEnd(); - i++; - } + if (s[i].getSequence().length() > max) + { + max = s[i].getSequence().length(); + } - if (maxid < 15) { - maxid = 15; - } + if (tmp.length() > maxid) + { + maxid = tmp.length(); + } - maxid++; + i++; + } - int len = 60; - int nochunks = (max / len) + 1; + if (maxid < 15) + { + maxid = 15; + } - for (i = 0; i < nochunks; i++) { - int j = 0; + maxid++; - while ((j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(s[j].getName() + - "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); + int len = 60; + int nochunks = (max / len) + 1; - int start = i * len; - int end = start + len; + for (i = 0; i < nochunks; i++) + { + int j = 0; - if ((end < s[j].getSequence().length()) && - (start < s[j].getSequence().length())) { - out.append(s[j].getSequence().substring(start, end)); - } else { - if (start < s[j].getSequence().length()) { - out.append(s[j].getSequence().substring(start)); - } - } + while ( (j < s.length) && (s[j] != null)) + { + out.append(new Format("%-" + maxid + "s").form(s[j].getName() + + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); - out.append("\n"); - j++; - } + int start = i * len; + int end = start + len; - out.append("\n"); + if ( (end < s[j].getSequence().length()) && + (start < s[j].getSequence().length())) + { + out.append(s[j].getSequence().substring(start, end)); + } + else + { + if (start < s[j].getSequence().length()) + { + out.append(s[j].getSequence().substring(start)); + } } - return out.toString(); + out.append("\n"); + j++; + } + + out.append("\n"); } + + return out.toString(); + } } diff --git a/src/jalview/io/EBIFetchClient.java b/src/jalview/io/EBIFetchClient.java index 5b21bfe..2c829ff 100755 --- a/src/jalview/io/EBIFetchClient.java +++ b/src/jalview/io/EBIFetchClient.java @@ -32,83 +32,151 @@ import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; -public class EBIFetchClient { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class EBIFetchClient +{ Call call; String format = "default"; String style = "raw"; - public EBIFetchClient() { - try { + /** + * Creates a new EBIFetchClient object. + */ + public EBIFetchClient() + { + try + { call = (Call) new Service().createCall(); call.setTargetEndpointAddress(new java.net.URL( "http://www.ebi.ac.uk/ws/services/Dbfetch")); - } catch (Exception ex) { + } + catch (Exception ex) + { } } - public String[] getSupportedDBs() { - try { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] getSupportedDBs() + { + try + { call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs")); call.setReturnType(XMLType.SOAP_ARRAY); return (String[]) call.invoke(new Object[] { }); - } catch (Exception ex) { + } + catch (Exception ex) + { return null; } } - public String[] getSupportedFormats() { - try { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] getSupportedFormats() + { + try + { call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats")); call.setReturnType(XMLType.SOAP_ARRAY); return (String[]) call.invoke(new Object[] { }); - } catch (Exception ex) { + } + catch (Exception ex) + { return null; } } - public String[] getSupportedStyles() { - try { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] getSupportedStyles() + { + try + { call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles")); call.setReturnType(XMLType.SOAP_ARRAY); return (String[]) call.invoke(new Object[] { }); - } catch (Exception ex) { + } + catch (Exception ex) + { return null; } } - public String[] fetchData(String ids, String f, String s) { + /** + * DOCUMENT ME! + * + * @param ids DOCUMENT ME! + * @param f DOCUMENT ME! + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String[] fetchData(String ids, String f, String s) + { // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS; // max 50 ids can be added at one time - try { + try + { call.setOperationName(new QName("urn:Dbfetch", "fetchData")); call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); call.setReturnType(XMLType.SOAP_ARRAY); - if (f != null) { + if (f != null) + { format = f; } - if (s != null) { + if (s != null) + { style = s; } return (String[]) call.invoke(new Object[] { ids, format, style }); - } catch (Exception ex) { + } + catch (Exception ex) + { return null; } } - public String fetchDataFile(String arg, String f, String s) { - if (f != null) { + /** + * DOCUMENT ME! + * + * @param arg DOCUMENT ME! + * @param f DOCUMENT ME! + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String fetchDataFile(String arg, String f, String s) + { + if (f != null) + { format = f; } - if (s != null) { + if (s != null) + { style = s; } @@ -124,21 +192,25 @@ public class EBIFetchClient { call.setReturnType(qnameAttachment); - try { + try + { Object ret = call.invoke(new Object[] { arg, format, style }); - if (null == ret) { + if (null == ret) + { System.err.println("Received null "); throw new AxisFault("", "Received null", null, null); } - if (ret instanceof String) { + if (ret instanceof String) + { System.err.println("Received problem response from server: " + ret); throw new AxisFault("", (String) ret, null, null); } - if (!(ret instanceof DataHandler)) { + if (!(ret instanceof DataHandler)) + { //The wrong type of object that what was expected. System.err.println("Received problem response from server:" + ret.getClass().getName()); @@ -153,20 +225,28 @@ public class EBIFetchClient { //From here we'll just treat the data resource as file. String receivedfileName = rdh.getName(); //Get the filename. - if (receivedfileName == null) { + if (receivedfileName == null) + { System.err.println("Could not get the file name."); throw new AxisFault("", "Could not get the file name.", null, null); } - if (arg.equalsIgnoreCase("medline")) { + if (arg.equalsIgnoreCase("medline")) + { return receivedfileName; - } else if (arg.equalsIgnoreCase("interpro")) { + } + else if (arg.equalsIgnoreCase("interpro")) + { return receivedfileName; - } else { + } + else + { System.err.println(receivedfileName); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index 458465e..757bb57 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -27,19 +27,51 @@ import java.io.*; import java.util.*; -public class FastaFile extends AlignFile { - public FastaFile() { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class FastaFile extends AlignFile +{ + /** + * Creates a new FastaFile object. + */ + public FastaFile() + { } - public FastaFile(String inStr) { + /** + * Creates a new FastaFile object. + * + * @param inStr DOCUMENT ME! + */ + public FastaFile(String inStr) + { super(inStr); } - public FastaFile(String inFile, String type) throws IOException { + /** + * Creates a new FastaFile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public FastaFile(String inFile, String type) throws IOException + { super(inFile, type); } - public void parse() throws IOException { + /** + * DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public void parse() throws IOException + { String id = ""; StringBuffer seq = new StringBuffer(); int count = 0; @@ -49,20 +81,25 @@ public class FastaFile extends AlignFile { String line; - while ((line = nextLine()) != null) { - if (line.length() > 0) { + while ((line = nextLine()) != null) + { + if (line.length() > 0) + { // Do we have an id line? // JBPNote - this code needs to be standardised to EBI/whatever for the // >dbref/dbref/dbref|refid1|refid2|refid3 'human-readable' style of naming (should it really exist) - - if (line.substring(0, 1).equals(">")) { - if (count != 0) { - if (sstart != 0) { - seqs.addElement(new Sequence(id, - seq.toString(), sstart, send)); - } else { - seqs.addElement(new Sequence(id, - seq.toString(), 1, + if (line.substring(0, 1).equals(">")) + { + if (count != 0) + { + if (sstart != 0) + { + seqs.addElement(new Sequence(id, seq.toString(), + sstart, send)); + } + else + { + seqs.addElement(new Sequence(id, seq.toString(), 1, seq.length())); } } @@ -76,31 +113,39 @@ public class FastaFile extends AlignFile { com.stevesoft.pat.Regex dbId = new com.stevesoft.pat.Regex( "[A-Za-z-]+/?[A-Za-z-]+\\|(\\w+)\\|(.+)"); + // JBPNote At the moment - we don't get rid of the friendly names but this // behaviour is probably wrong in the long run. - if (dbId.search(id)) { + if (dbId.search(id)) + { String dbid = dbId.stringMatched(1); String idname = dbId.stringMatched(2); - if ( (idname.length() > 0) && - (idname.indexOf("_") > -1)) { - id = idname; // use the friendly name - apparently no dbid - } else - if (dbid.length()>1) { + + if ((idname.length() > 0) && + (idname.indexOf("_") > -1)) + { + id = idname; // use the friendly name - apparently no dbid + } + else if (dbid.length() > 1) + { id = dbid; // ignore the friendly name - we lose uniprot accession ID otherwise } } - if (id.indexOf("/") > 0) { + if (id.indexOf("/") > 0) + { StringTokenizer st = new StringTokenizer(id, "/"); - if (st.countTokens() == 2) { + if (st.countTokens() == 2) + { id = st.nextToken(); String tmp = st.nextToken(); st = new StringTokenizer(tmp, "-"); - if (st.countTokens() == 2) { + if (st.countTokens() == 2) + { sstart = Integer.valueOf(st.nextToken()) .intValue(); send = Integer.valueOf(st.nextToken()).intValue(); @@ -109,50 +154,99 @@ public class FastaFile extends AlignFile { } seq = new StringBuffer(); - } else { + } + else + { seq = seq.append(line); } } } - if (count > 0) { - if (!isValidProteinSequence(seq.toString().toUpperCase())) { + if (count > 0) + { + if (!isValidProteinSequence(seq.toString().toUpperCase())) + { throw new IOException("Invalid protein sequence"); } - if (sstart != 0) { + if (sstart != 0) + { seqs.addElement(new Sequence(id, seq.toString().toUpperCase(), sstart, send)); - } else { + } + else + { seqs.addElement(new Sequence(id, seq.toString().toUpperCase(), 1, seq.length())); } } } - public static String print(SequenceI[] s) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String print(SequenceI[] s) + { return print(s, 72); } - public static String print(SequenceI[] s, int len) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param len DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String print(SequenceI[] s, int len) + { return print(s, len, true); } - public static String print(SequenceI[] s, int len, boolean gaps) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param len DOCUMENT ME! + * @param gaps DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String print(SequenceI[] s, int len, boolean gaps) + { return print(s, len, gaps, true); } + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param len DOCUMENT ME! + * @param gaps DOCUMENT ME! + * @param displayId DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public static String print(SequenceI[] s, int len, boolean gaps, - boolean displayId) { + boolean displayId) + { StringBuffer out = new StringBuffer(); int i = 0; - while ((i < s.length) && (s[i] != null)) { + while ((i < s.length) && (s[i] != null)) + { String seq = ""; - if (gaps) { + if (gaps) + { seq = s[i].getSequence(); - } else { + } + else + { seq = AlignSeq.extractGaps("-. ", s[i].getSequence()); } @@ -162,13 +256,17 @@ public class FastaFile extends AlignFile { int nochunks = (seq.length() / len) + 1; - for (int j = 0; j < nochunks; j++) { + for (int j = 0; j < nochunks; j++) + { int start = j * len; int end = start + len; - if (end < seq.length()) { + if (end < seq.length()) + { out.append(seq.substring(start, end) + "\n"); - } else if (start < seq.length()) { + } + else if (start < seq.length()) + { out.append(seq.substring(start) + "\n"); } } @@ -179,7 +277,13 @@ public class FastaFile extends AlignFile { return out.toString(); } - public String print() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() + { return print(getSeqsAsArray()); } } diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index 0c46a17..af3bbec 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -1,63 +1,72 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; import java.io.*; - import java.net.*; +public class FileParse +{ + public File inFile; + public int fileSize; + public int noLines; + protected String type; + protected BufferedReader dataIn; -public class FileParse { - public File inFile; - public int fileSize; - public int noLines; - protected String type; - protected BufferedReader dataIn; + public FileParse() + { + } - public FileParse() { - } + public FileParse(String fileStr, String type) + throws MalformedURLException, IOException + { + this.type = type; - public FileParse(String fileStr, String type) - throws MalformedURLException, IOException { - this.type = type; - - if (type.equals("File")) { - this.inFile = new File(fileStr); - this.fileSize = (int) inFile.length(); - - dataIn = new BufferedReader(new FileReader(fileStr)); - } else if (type.equals("URL")) { - URL url = new URL(fileStr); - this.fileSize = 0; - dataIn = new BufferedReader(new InputStreamReader(url.openStream())); - } else if (type.equals("Paste")) { - dataIn = new BufferedReader(new StringReader(fileStr)); - } - } + if (type.equals("File")) + { + this.inFile = new File(fileStr); + this.fileSize = (int) inFile.length(); - public String nextLine() throws IOException { - String next = dataIn.readLine(); + dataIn = new BufferedReader(new FileReader(fileStr)); + } + else if (type.equals("URL")) + { + URL url = new URL(fileStr); + this.fileSize = 0; + dataIn = new BufferedReader(new InputStreamReader(url.openStream())); + } + else if (type.equals("Paste")) + { + dataIn = new BufferedReader(new StringReader(fileStr)); + } + } - if (next != null) { - noLines++; - } + public String nextLine() + throws IOException + { + String next = dataIn.readLine(); - return next; + if (next != null) + { + noLines++; } + + return next; + } } diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index e59c191..6ac110d 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -23,10 +23,19 @@ import jalview.datamodel.*; import java.util.Vector; -public class FormatAdapter { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class FormatAdapter +{ + /** DOCUMENT ME!! */ public static Vector formats = new Vector(); - static { + static + { formats.addElement("FASTA"); formats.addElement("MSF"); formats.addElement("PileUp"); @@ -36,28 +45,54 @@ public class FormatAdapter { formats.addElement("PFAM"); } - public static SequenceI[] readFile(String inFile, String type, String format) { - try { + /** + * DOCUMENT ME! + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * @param format DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static SequenceI[] readFile(String inFile, String type, String format) + { + try + { AlignFile afile = null; - if (format.equals("FASTA")) { + if (format.equals("FASTA")) + { afile = new FastaFile(inFile, type); - } else if (format.equals("MSF")) { + } + else if (format.equals("MSF")) + { afile = new MSFfile(inFile, type); - } else if (format.equals("PileUp")) { + } + else if (format.equals("PileUp")) + { afile = new PileUpfile(inFile, type); - } else if (format.equals("CLUSTAL")) { + } + else if (format.equals("CLUSTAL")) + { afile = new ClustalFile(inFile, type); - } else if (format.equals("BLC")) { + } + else if (format.equals("BLC")) + { afile = new BLCFile(inFile, type); - } else if (format.equals("PIR")) { + } + else if (format.equals("PIR")) + { afile = new PIRFile(inFile, type); - } else if (format.equals("PFAM")) { + } + else if (format.equals("PFAM")) + { afile = new PfamFile(inFile, type); } return afile.getSeqsAsArray(); - } catch (Exception e) { + } + catch (Exception e) + { System.err.println("Failed to read alignment using the '" + format + "' reader."); e.printStackTrace(); @@ -66,35 +101,60 @@ public class FormatAdapter { return null; } - public static String formatSequences(String format, Vector seqs) { + /** + * DOCUMENT ME! + * + * @param format DOCUMENT ME! + * @param seqs DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String formatSequences(String format, Vector seqs) + { SequenceI[] s = new SequenceI[seqs.size()]; for (int i = 0; i < seqs.size(); i++) s[i] = (SequenceI) seqs.elementAt(i); - try { + try + { AlignFile afile = null; - if (format.equals("FASTA")) { + if (format.equalsIgnoreCase("FASTA")) + { afile = new FastaFile(); - } else if (format.equals("MSF")) { + } + else if (format.equalsIgnoreCase("MSF")) + { afile = new MSFfile(); - } else if (format.equals("PileUp")) { + } + else if (format.equalsIgnoreCase("PileUp")) + { afile = new PileUpfile(); - } else if (format.equals("CLUSTAL")) { + } + else if (format.equalsIgnoreCase("CLUSTAL")) + { afile = new ClustalFile(); - } else if (format.equals("BLC")) { + } + else if (format.equalsIgnoreCase("BLC")) + { afile = new BLCFile(); - } else if (format.equals("PIR")) { + } + else if (format.equalsIgnoreCase("PIR")) + { afile = new PIRFile(); - } else if (format.equals("PFAM")) { + } + else if (format.equalsIgnoreCase("PFAM")) + { afile = new PfamFile(); } afile.setSeqs(s); return afile.print(); - } catch (Exception e) { + } + catch (Exception e) + { System.err.println("Failed to write alignment as a '" + format + "' file\n"); e.printStackTrace(); diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index 54b9595..e4dc83e 100755 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -1,267 +1,398 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; -import jalview.datamodel.*; - -import jalview.gui.*; - -import jalview.schemes.*; - -import java.awt.*; - import java.io.*; -import java.util.*; - -import javax.swing.*; - - -public class HTMLOutput { - AlignViewport av; - SequenceRenderer sr; - Color color; - - public HTMLOutput(AlignViewport av) { - this.av = av; - sr = new SequenceRenderer(av); - - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), new String[] { "html" }, - new String[] { "HTML files" }, "HTML files"); - - chooser.setFileView(new JalviewFileView()); - chooser.setDialogTitle("Save as HTML"); - chooser.setToolTipText("Save"); - - int value = chooser.showSaveDialog(null); - - if (value == JalviewFileChooser.APPROVE_OPTION) { - String choice = chooser.getSelectedFile().getPath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", - chooser.getSelectedFile().getParent()); - - try { - PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter( - choice)); - out.println(""); - out.println(""); - out.println(""); +import java.awt.*; - if (av.getWrapAlignment()) { - drawWrappedAlignment(out); - } else { - drawUnwrappedAlignment(out); - } +import jalview.datamodel.*; +import jalview.gui.*; +import jalview.schemes.*; - out.println("\n\n"); - out.close(); - jalview.util.BrowserLauncher.openURL("file:///" + choice); - } catch (Exception ex) { - ex.printStackTrace(); - } +public class HTMLOutput +{ + AlignViewport av; + SequenceRenderer sr; + Color color; + + public HTMLOutput(AlignViewport av) + { + this.av = av; + sr = new SequenceRenderer(av); + + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. + getProperty( + "LAST_DIRECTORY"), new String[] + {"html"}, + new String[] + {"HTML files"}, "HTML files"); + + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save as HTML"); + chooser.setToolTipText("Save"); + + int value = chooser.showSaveDialog(null); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + + try + { + PrintWriter out = new java.io.PrintWriter(new java.io.FileWriter( + choice)); + out.println(""); + out.println(""); + out.println(""); - int i = 0; + if (av.getWrapAlignment()) + { + drawWrappedAlignment(out); + } + else + { + drawUnwrappedAlignment(out); + } - for (i = 10; i < (alignment.getWidth() - 10); i += 10) - out.println("" + i + "
|"); + out.println("\n\n"); + out.close(); + jalview.util.BrowserLauncher.openURL("file:///" + choice); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + } + + void drawUnwrappedAlignment(PrintWriter out) + { + out.println("
\n"); + out.println( + "\n"); + + ////////////// + SequenceGroup[] groups; + SequenceI seq; + ColourSchemeI cs = null; + AlignmentI alignment = av.getAlignment(); + String r; + String g; + String b; + + // draws the top row, the measure rule + out.println(""); + + int i = 0; + + for (i = 10; i < (alignment.getWidth() - 10); i += 10) + { + out.println(""); + } - out.println(""); - out.println(""); + out.println(""); + out.println(""); - for (i = 0; i < alignment.getHeight(); i++) { - seq = alignment.getSequenceAt(i); - groups = alignment.findAllGroups(seq); + for (i = 0; i < alignment.getHeight(); i++) + { + seq = alignment.getSequenceAt(i); + groups = alignment.findAllGroups(seq); - if (av.getShowFullId()) { - out.println(""); - } else { - out.println(""); + } + + for (int res = 0; res < seq.getLength(); res++) + { + cs = av.getGlobalColourScheme(); + + if (groups != null) + { + for (int k = 0; k < groups.length; k++) + { + if ( (groups[k].getStartRes() <= res) && + (groups[k].getEndRes() >= res)) + { + cs = groups[k].cs; + + break; } + } + } - for (int res = 0; res < seq.getLength(); res++) { - cs = av.getGlobalColourScheme(); - - if (groups != null) { - for (int k = 0; k < groups.length; k++) - if ((groups[k].getStartRes() <= res) && - (groups[k].getEndRes() >= res)) { - cs = groups[k].cs; - - break; - } - } - - color = sr.getResidueBoxColour(cs, seq, res); + color = sr.getResidueBoxColour(cs, seq, res); - if (color.getRGB() < -1) { - out.println(""); - } else { - out.println(""); - } - } - - out.println(""); + if (color.getRGB() < -1) + { + out.println(""); + } + else + { + out.println(""); } + } - ////////////// - out.println("
" + i + "
|
" + i + - "
|
" + i + + "
|
" + seq.getDisplayId() + + if (av.getShowFullId()) + { + out.println("
" + seq.getDisplayId() + "  
" + seq.getName() + + } + else + { + out.println("
" + seq.getName() + "  " + - seq.getCharAt(res) + "" + seq.getCharAt(res) + "
" + + seq.getCharAt(res) + "" + seq.getCharAt(res) + "
"); - out.println("
"); + out.println(""); } - void drawWrappedAlignment(PrintWriter out) { - //////////////////////////////////// - /// How many sequences and residues can we fit on a printable page? - AlignmentI al = av.getAlignment(); - SequenceGroup[] groups; - SequenceI seq; - ColourSchemeI cs = null; - String r; - String g; - String b; - - out.println("
\n"); - out.println( - "\n"); - - for (int startRes = 0; startRes < al.getWidth(); - startRes += av.getChunkWidth()) { - int endRes = startRes + av.getChunkWidth(); - - if (endRes > al.getWidth()) { - endRes = al.getWidth(); - } - - out.println(""); - out.println(""); - - for (int i = startRes + 10; i < endRes; i += 10) - out.println(""); - - // out.println(""); - out.println(""); - - for (int s = 0; s < al.getHeight(); s++) { - out.println(""); - seq = al.getSequenceAt(s); - groups = al.findAllGroups(seq); - - if (av.getShowFullId()) { - out.println(""); - } else { - out.println(""); - } - - for (int res = startRes; res < endRes; res++) { - cs = av.getGlobalColourScheme(); - - if (groups != null) { - for (int k = 0; k < groups.length; k++) - if ((groups[k].getStartRes() <= res) && - (groups[k].getEndRes() >= res)) { - cs = groups[k].cs; - - break; - } - } - - color = sr.getResidueBoxColour(cs, seq, res); + ////////////// + out.println("
 " + i + "
|
" + i + - // "
|
" + seq.getDisplayId() + - "  " + seq.getName() + - "  
"); + out.println("
"); + } + + void drawWrappedAlignment(PrintWriter out) + { + //////////////////////////////////// + /// How many sequences and residues can we fit on a printable page? + AlignmentI al = av.getAlignment(); + SequenceGroup[] groups; + SequenceI seq; + ColourSchemeI cs = null; + String r; + String g; + String b; + + out.println("
\n"); + out.println( + "\n"); + + for (int startRes = 0; startRes < al.getWidth(); + startRes += av.getChunkWidth()) + { + int endRes = startRes + av.getChunkWidth(); + + if (endRes > al.getWidth()) + { + endRes = al.getWidth(); + } + + out.println(""); + out.println(""); + + for (int i = startRes + 10; i < endRes; i += 10) + { + out.println(""); + } + + // out.println(""); + out.println(""); + + for (int s = 0; s < al.getHeight(); s++) + { + out.println(""); + seq = al.getSequenceAt(s); + groups = al.findAllGroups(seq); + + if (av.getShowFullId()) + { + out.println(""); + } + else + { + out.println(""); + } - if (color.getRGB() < -1) { - r = Integer.toHexString(color.getRed()); + for (int res = startRes; res < endRes; res++) + { + cs = av.getGlobalColourScheme(); + + if (groups != null) + { + for (int k = 0; k < groups.length; k++) + { + if ( (groups[k].getStartRes() <= res) && + (groups[k].getEndRes() >= res)) + { + cs = groups[k].cs; + + break; + } + } + } - if (r.length() < 2) { - r = "0" + r; - } + color = sr.getResidueBoxColour(cs, seq, res); - g = Integer.toHexString(color.getGreen()); + if (color.getRGB() < -1) + { + r = Integer.toHexString(color.getRed()); - if (g.length() < 2) { - g = "0" + g; - } + if (r.length() < 2) + { + r = "0" + r; + } - b = Integer.toHexString(color.getBlue()); + g = Integer.toHexString(color.getGreen()); - if (b.length() < 2) { - b = "0" + b; - } + if (g.length() < 2) + { + g = "0" + g; + } - out.println(""); - } else { - out.println(""); - } - } + b = Integer.toHexString(color.getBlue()); - out.println(""); + if (b.length() < 2) + { + b = "0" + b; } - if (endRes < al.getWidth()) { - out.println(""); - } + out.println(""); + } + else + { + out.println(""); + } } - out.println("
 " + i + "
|
" + i + + // "
|
" + seq.getDisplayId() + + "  " + seq.getName() + + "  " + - seq.getCharAt(res) + "" + seq.getCharAt(res) + "
" + + seq.getCharAt(res) + "" + seq.getCharAt(res) + "
"); - out.println("
"); + out.println(""); + } + + if (endRes < al.getWidth()) + { + out.println(""); + } } + + out.println(""); + out.println(""); + } + + public static String getImageMapHTML() + { + return new String( + "\n" + +"\n" + +"\n" + +"\n" + +"\n" + +"
\n" + +"\n"); + + } } diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 2442b4b..dbee007 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -23,37 +23,61 @@ import java.io.*; import java.net.*; -public class IdentifyFile { - public static String Identify(String file, String protocol) { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class IdentifyFile +{ + /** + * DOCUMENT ME! + * + * @param file DOCUMENT ME! + * @param protocol DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String Identify(String file, String protocol) + { String reply = "PFAM"; - try { + try + { BufferedReader reader = null; - if (protocol.equals("File")) { + if (protocol.equals("File")) + { reader = new BufferedReader(new FileReader(file)); } - else if (protocol.equals("URL")) { + else if (protocol.equals("URL")) + { reply = "URL NOT FOUND"; URL url = new URL(file); reader = new BufferedReader(new InputStreamReader( url.openStream())); reply = "error"; - } else if (protocol.equals("Paste")) { + } + else if (protocol.equals("Paste")) + { reader = new BufferedReader(new StringReader(file)); } String data; - while ((data = reader.readLine()) != null) { + while ((data = reader.readLine()) != null) + { data = data.toUpperCase(); - if ((data.indexOf("#") == 0) || (data.length() < 1)) { + if ((data.indexOf("#") == 0) || (data.length() < 1)) + { continue; } - if (data.indexOf("PILEUP") > -1) { + if (data.indexOf("PILEUP") > -1) + { reply = "PileUp"; break; @@ -62,26 +86,36 @@ public class IdentifyFile { if ((data.indexOf("//") == 0) || ((data.indexOf("!!") > -1) && (data.indexOf("!!") < data.indexOf( - "_MULTIPLE_ALIGNMENT ")))) { + "_MULTIPLE_ALIGNMENT ")))) + { reply = "MSF"; break; - } else if (data.indexOf("CLUSTAL") > -1) { + } + else if (data.indexOf("CLUSTAL") > -1) + { reply = "CLUSTAL"; break; - } else if ((data.indexOf(">P1;") > -1) || - (data.indexOf(">DL;") > -1)) { + } + else if ((data.indexOf(">P1;") > -1) || + (data.indexOf(">DL;") > -1)) + { reply = "PIR"; break; - } else if (data.indexOf(">") > -1) { + } + else if (data.indexOf(">") > -1) + { // could be BLC file, read next line to confirm data = reader.readLine(); - if (data.indexOf(">") > -1) { + if (data.indexOf(">") > -1) + { reply = "BLC"; - } else { + } + else + { reply = "FASTA"; } @@ -90,7 +124,9 @@ public class IdentifyFile { } reader.close(); - } catch (Exception ex) { + } + catch (Exception ex) + { System.err.println("File Identification failed!\n" + ex); } diff --git a/src/jalview/io/JPredFile.java b/src/jalview/io/JPredFile.java index 12be9de..901c204 100755 --- a/src/jalview/io/JPredFile.java +++ b/src/jalview/io/JPredFile.java @@ -33,38 +33,88 @@ import java.io.*; import java.util.*; -public class JPredFile extends AlignFile { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class JPredFile extends AlignFile +{ Vector ids; Vector conf; Hashtable Scores; // Hash of names and score vectors Hashtable Symscores; // indexes of symbol annotation properties in sequenceI vector private int QuerySeqPosition; - public JPredFile(String inStr) { + /** + * Creates a new JPredFile object. + * + * @param inStr DOCUMENT ME! + */ + public JPredFile(String inStr) + { super(inStr); } - public JPredFile(String inFile, String type) throws IOException { + /** + * Creates a new JPredFile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public JPredFile(String inFile, String type) throws IOException + { super(inFile, type); } - public void setQuerySeqPosition(int QuerySeqPosition) { + /** + * DOCUMENT ME! + * + * @param QuerySeqPosition DOCUMENT ME! + */ + public void setQuerySeqPosition(int QuerySeqPosition) + { this.QuerySeqPosition = QuerySeqPosition; } - public int getQuerySeqPosition() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getQuerySeqPosition() + { return QuerySeqPosition; } - public Hashtable getScores() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Hashtable getScores() + { return Scores; } - public Hashtable getSymscores() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Hashtable getSymscores() + { return Symscores; } - public void initData() { + /** + * DOCUMENT ME! + */ + public void initData() + { super.initData(); Scores = new Hashtable(); ids = null; @@ -74,7 +124,8 @@ public class JPredFile extends AlignFile { /** * parse a JPred concise file into a sequence-alignment like object. */ - public void parse() throws IOException { + public void parse() throws IOException + { // JBPNote log.System.out.println("all read in "); String line; QuerySeqPosition = -1; @@ -84,12 +135,14 @@ public class JPredFile extends AlignFile { Vector ids = new Vector(); Hashtable Symscores = new Hashtable(); - while ((line = nextLine()) != null) { + while ((line = nextLine()) != null) + { // Concise format allows no comments or non comma-formatted data StringTokenizer str = new StringTokenizer(line, ":"); String id = ""; - if (!str.hasMoreTokens()) { + if (!str.hasMoreTokens()) + { continue; } @@ -101,16 +154,20 @@ public class JPredFile extends AlignFile { // decide if we have more than just alphanumeric symbols int numSymbols = symbols.countTokens(); - if (numSymbols == 0) { + if (numSymbols == 0) + { continue; } - if (seqsym.length() != (2 * numSymbols)) { + if (seqsym.length() != (2 * numSymbols)) + { // Set of scalars for some property - if (Scores.containsKey(id)) { + if (Scores.containsKey(id)) + { int i = 1; - while (Scores.containsKey(id + "_" + i)) { + while (Scores.containsKey(id + "_" + i)) + { i++; } @@ -123,9 +180,11 @@ public class JPredFile extends AlignFile { int i = 0; String ascore = "dead"; - try { + try + { // store elements as floats... - while (symbols.hasMoreTokens()) { + while (symbols.hasMoreTokens()) + { ascore = symbols.nextToken(); Float score = new Float(ascore); @@ -133,55 +192,70 @@ public class JPredFile extends AlignFile { } Scores.put(id, scores); - } catch (Exception e) { + } + catch (Exception e) + { // or just keep them as strings i = scores.size(); - for (int j = 0; j < i; j++) { + for (int j = 0; j < i; j++) + { scores.set(j, (Object) ((Float) scores.get(j)).toString()); } scores.addElement((Object) ascore); - while (symbols.hasMoreTokens()) { + while (symbols.hasMoreTokens()) + { ascore = symbols.nextToken(); scores.addElement((Object) ascore); } Scores.put(id, scores); } - } else if (id.equals("jnetconf")) { + } + else if (id.equals("jnetconf")) + { // log.debug System.out.println("here"); id = "Prediction Confidence"; this.conf = new Vector(numSymbols); - for (int i = 0; i < numSymbols; i++) { + for (int i = 0; i < numSymbols; i++) + { conf.set(i, (Object) symbols.nextToken()); } - } else { + } + else + { // Sequence or a prediction string (rendered as sequence) StringBuffer newseq = new StringBuffer(); - for (int i = 0; i < numSymbols; i++) { + for (int i = 0; i < numSymbols; i++) + { newseq.append(symbols.nextToken()); } - if (id.indexOf(";") > -1) { + if (id.indexOf(";") > -1) + { seq_entries.addElement(newseq); int i = 1; String name = id.substring(id.indexOf(";") + 1); - while (ids.lastIndexOf(name) > -1) { + while (ids.lastIndexOf(name) > -1) + { name = id.substring(id.indexOf(";") + 1) + "_" + 1; } ids.addElement(name); noSeqs++; - } else { - if (id.equals("JNETPRED")) { + } + else + { + if (id.equals("JNETPRED")) + { id = "Predicted Secondary Structure"; } @@ -193,34 +267,39 @@ public class JPredFile extends AlignFile { } } - if (noSeqs < 1) { + if (noSeqs < 1) + { throw new IOException( "JpredFile Parser: No sequence in the prediction!"); } maxLength = seq_entries.elementAt(0).toString().length(); - for (int i = 0; i < ids.size(); i++) { + for (int i = 0; i < ids.size(); i++) + { // Add all sequence like objects Sequence newSeq = new Sequence(ids.elementAt(i).toString(), seq_entries.elementAt(i).toString(), 1, seq_entries.elementAt(i).toString().length()); if (!Symscores.containsKey(ids.elementAt(i)) && - !isValidProteinSequence(newSeq.getSequence())) { + !isValidProteinSequence(newSeq.getSequence())) + { throw new IOException( "JPredConcise: Not a valid protein sequence - (" + ids.elementAt(i).toString() + ")"); } - if (maxLength != seq_entries.elementAt(i).toString().length()) { + if (maxLength != seq_entries.elementAt(i).toString().length()) + { throw new IOException("JPredConcise: Entry (" + ids.elementAt(i).toString() + ") has an unexpected number of columns"); } if (newSeq.getName().startsWith("QUERY") && - (QuerySeqPosition == -1)) { + (QuerySeqPosition == -1)) + { QuerySeqPosition = seqs.size(); } @@ -233,20 +312,31 @@ public class JPredFile extends AlignFile { * * @return String */ - public String print() { + public String print() + { return "Not Supported"; } - public static void main(String[] args) { - try { + /** + * DOCUMENT ME! + * + * @param args DOCUMENT ME! + */ + public static void main(String[] args) + { + try + { JPredFile blc = new JPredFile(args[0], "File"); - for (int i = 0; i < blc.seqs.size(); i++) { + for (int i = 0; i < blc.seqs.size(); i++) + { System.out.println(((Sequence) blc.seqs.elementAt(i)).getName() + "\n" + ((Sequence) blc.seqs.elementAt(i)).getSequence() + "\n"); } - } catch (java.io.IOException e) { + } + catch (java.io.IOException e) + { System.err.println("Exception " + e); e.printStackTrace(); } diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index d44275a..585ed4f 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -1,21 +1,21 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ /*/////////////////////////////////////////////////////////////////// // This file was taken from java forum // Re: JFileChooser functioning like normal Windows Apps FileChooser @@ -26,380 +26,442 @@ ////////////////////////////////////////////////////////////////// package jalview.io; -import java.awt.*; -import java.awt.event.*; - import java.io.*; - import java.util.*; +import java.awt.*; +import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import javax.swing.plaf.metal.*; import javax.swing.table.*; +public class JalviewFileChooser + extends JFileChooser +{ -public class JalviewFileChooser extends JFileChooser { - private static final int COLUMN_FILENAME = 0; - private static final int COLUMN_FILESIZE = 1; - private static final int COLUMN_FILETYPE = 2; - private static final int COLUMN_FILEDATE = 3; - private static final int COLUMN_FILEATTR = 4; - private static final int COLUMN_COLCOUNT = 5; - private static String[] COLUMNS = null; - - public JalviewFileChooser(String dir, String[] suffix, String[] desc, - String selected) { - super(dir); - JalviewFileFilter chosen = null; + public JalviewFileChooser(String dir, String[] suffix, String[] desc, + String selected) + { + super(dir); - for (int i = 0; i < suffix.length; i++) { - JalviewFileFilter jvf = new JalviewFileFilter(suffix[i], desc[i]); - addChoosableFileFilter(jvf); - - if ((selected != null) && selected.equalsIgnoreCase(desc[i])) { - chosen = jvf; - } - } + JalviewFileFilter chosen = null; - if (chosen != null) { - setFileFilter(chosen); - } + for (int i = 0; i < suffix.length; i++) + { + JalviewFileFilter jvf = new JalviewFileFilter(suffix[i], desc[i]); + addChoosableFileFilter(jvf); - initColumns(); + if ( (selected != null) && selected.equalsIgnoreCase(desc[i])) + { + chosen = jvf; + } } - public JalviewFileChooser(String dir) { - super(dir); - initColumns(); + if (chosen != null) + { + setFileFilter(chosen); } - public String getSelectedFormat() { - String format = getFileFilter().getDescription(); - - if (format.toUpperCase().startsWith("JALVIEW")) { - format = "Jalview"; - } else if (format.toUpperCase().startsWith("FASTA")) { - format = "FASTA"; - } else if (format.toUpperCase().startsWith("MSF")) { - format = "MSF"; - } else if (format.toUpperCase().startsWith("CLUSTAL")) { - format = "CLUSTAL"; - } else if (format.toUpperCase().startsWith("BLC")) { - format = "BLC"; - } else if (format.toUpperCase().startsWith("PIR")) { - format = "PIR"; - } else if (format.toUpperCase().startsWith("PFAM")) { - format = "PFAM"; - } + } + + + public void setFileFilter(javax.swing.filechooser.FileFilter filter) + { + super.setFileFilter(filter); + + if (!(getUI() instanceof BasicFileChooserUI)) { + return; + } + + final BasicFileChooserUI ui = (BasicFileChooserUI) getUI(); + final String name = ui.getFileName().trim(); + + if ((name == null) || (name.length() == 0)) { + return; + } + + EventQueue.invokeLater(new Thread() { + public void run() { + String currentName = ui.getFileName(); + if ((currentName == null) || (currentName.length() == 0)) { + ui.setFileName(name); + } + } + }); + } + - return format; + public JalviewFileChooser(String dir) + { + super(dir); + } + + public String getSelectedFormat() + { + String format = getFileFilter().getDescription(); + + if (format.toUpperCase().startsWith("JALVIEW")) + { + format = "Jalview"; + } + else if (format.toUpperCase().startsWith("FASTA")) + { + format = "FASTA"; + } + else if (format.toUpperCase().startsWith("MSF")) + { + format = "MSF"; + } + else if (format.toUpperCase().startsWith("CLUSTAL")) + { + format = "CLUSTAL"; + } + else if (format.toUpperCase().startsWith("BLC")) + { + format = "BLC"; + } + else if (format.toUpperCase().startsWith("PIR")) + { + format = "PIR"; + } + else if (format.toUpperCase().startsWith("PFAM")) + { + format = "PFAM"; } - public int showSaveDialog(Component parent) throws HeadlessException { - setDialogType(SAVE_DIALOG); + return format; + } - int ret = showDialog(parent, null); + public int showSaveDialog(Component parent) + throws HeadlessException + { + setDialogType(SAVE_DIALOG); - if (getFileFilter() instanceof JalviewFileFilter) { - JalviewFileFilter jvf = (JalviewFileFilter) getFileFilter(); + int ret = showDialog(parent, null); - if (!jvf.accept(getSelectedFile())) { - String withExtension = getSelectedFile() + "." + - jvf.getAcceptableExtension(); - setSelectedFile(new File(withExtension)); - } - } + if (getFileFilter() instanceof JalviewFileFilter) + { + JalviewFileFilter jvf = (JalviewFileFilter) getFileFilter(); - if ((ret == JalviewFileChooser.APPROVE_OPTION) && - getSelectedFile().exists()) { - int confirm = JOptionPane.showConfirmDialog(parent, - "Overwrite existing file?", "File exists", - JOptionPane.YES_NO_OPTION); + if (!jvf.accept(getSelectedFile())) + { + String withExtension = getSelectedFile() + "." + + jvf.getAcceptableExtension(); + setSelectedFile(new File(withExtension)); + } + } - if (confirm != JOptionPane.YES_OPTION) { - ret = this.CANCEL_OPTION; - } - } + if ( (ret == JalviewFileChooser.APPROVE_OPTION) && + getSelectedFile().exists()) + { + int confirm = JOptionPane.showConfirmDialog(parent, + "Overwrite existing file?", + "File exists", + JOptionPane.YES_NO_OPTION); + + if (confirm != JOptionPane.YES_OPTION) + { + ret = this.CANCEL_OPTION; + } + } + + return ret; + } + + /************************************************************************** + * Always create the local UI + * @param comp + *************************************************************************/ + public final void setUI(ComponentUI comp) + { + super.setUI(new UI(this)); + } + + /************************************************************************** + * Internal implementation of Metal LookAndFeel to create the table sorting + * ability. + *************************************************************************/ + private class UI + extends MetalFileChooserUI + { + private DirectoryModel model; - return ret; + /************************************************************************** + * Must be overridden to extend + * @param e + *************************************************************************/ + public UI(JFileChooser e) + { + super(e); } - void initColumns() { - if (COLUMNS == null) { - Locale l = getLocale(); - COLUMNS = new String[] { - UIManager.getString("FileChooser.fileNameHeaderText", l), - UIManager.getString("FileChooser.fileSizeHeaderText", l), - UIManager.getString("FileChooser.fileTypeHeaderText", l), - UIManager.getString("FileChooser.fileDateHeaderText", l), - UIManager.getString("FileChooser.fileAttrHeaderText", l) - }; - } + /************************************************************************** + * Overridden to create our own model + *************************************************************************/ + protected final void createModel() + { + model = new DirectoryModel(getFileChooser()); } /************************************************************************** - * Always create the local UI - * @param comp + * Overridden to get our own model + * @return *************************************************************************/ - public final void setUI(ComponentUI comp) { - super.setUI(new UI(this)); + public final BasicDirectoryModel getModel() + { + return model; } /************************************************************************** - * Internal implementation of Metal LookAndFeel to create the table sorting - * ability. + * Calls the default method then adds a MouseListener to the JTable + * @param chooser + * @return *************************************************************************/ - private final static class UI extends MetalFileChooserUI { - private DirectoryModel model; - - /************************************************************************** - * Must be overridden to extend - * @param e - *************************************************************************/ - public UI(JFileChooser e) { - super(e); - } + protected final JPanel createDetailsView(JFileChooser chooser) + { + final JPanel panel = super.createDetailsView(chooser); - /************************************************************************** - * Overridden to create our own model - *************************************************************************/ - protected final void createModel() { - model = new DirectoryModel(getFileChooser()); - } + //Since we can't access MetalFileChooserUI's private member detailsTable + //directly, we have to find it in the JPanel + final JTable tbl = findJTable(panel.getComponents()); - /************************************************************************** - * Overridden to get our own model - * @return - *************************************************************************/ - public final BasicDirectoryModel getModel() { - return model; - } + if (tbl != null) + { + //Add a mouselistener to listen for presses on column headers + tbl.getTableHeader().addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent e) + { - /************************************************************************** - * Calls the default method then adds a MouseListener to the JTable - * @param chooser - * @return - *************************************************************************/ - protected final JPanel createDetailsView(JFileChooser chooser) { - final JPanel panel = super.createDetailsView(chooser); - - //Since we can't access MetalFileChooserUI's private member detailsTable - //directly, we have to find it in the JPanel - final JTable tbl = findJTable(panel.getComponents()); - - if (tbl != null) { - //Fix the columns so they can't be rearranged, if we don't do this - //we would need to keep track when each column is moved - tbl.getTableHeader().setReorderingAllowed(false); - - //Add a mouselistener to listen for clicks on column headers - tbl.getTableHeader().addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - //Only process single clicks - if (e.getClickCount() > 1) { - return; - } - - e.consume(); - - final int col = tbl.getTableHeader().columnAtPoint(e.getPoint()); - - if ((col == COLUMN_FILENAME) || - (col == COLUMN_FILESIZE) || - (col == COLUMN_FILEDATE)) { - model.sort(col, tbl); - } - } - }); - } + e.consume(); - return panel; - } + final int col = tbl.getTableHeader().columnAtPoint(e.getPoint()); + model.sort(col, tbl); - /************************************************************************** - * Finds the JTable in the panel so we can add MouseListener - * @param comp - * @return - *************************************************************************/ - private final static JTable findJTable(Component[] comp) { - for (int i = 0; i < comp.length; i++) { - if (comp[i] instanceof JTable) { - return (JTable) comp[i]; - } - - if (comp[i] instanceof Container) { - JTable tbl = findJTable(((Container) comp[i]).getComponents()); - - if (tbl != null) { - return tbl; - } - } - } + } + }); + } - return null; - } + return panel; } - /*************************************************************************** - * Implementation of BasicDirectoryModel that sorts the Files by column - **************************************************************************/ - private final static class DirectoryModel extends BasicDirectoryModel { - int col = 0; - boolean ascending; - - /************************************************************************** - * Must be overridden to extend BasicDirectoryModel - * @param chooser - *************************************************************************/ - DirectoryModel(JFileChooser chooser) { - super(chooser); + /************************************************************************** + * Finds the JTable in the panel so we can add MouseListener + * @param comp + * @return + *************************************************************************/ + private JTable findJTable(Component[] comp) + { + for (int i = 0; i < comp.length; i++) + { + if (comp[i] instanceof JTable) + { + return (JTable) comp[i]; } - /************************************************************************** - * Supposedly this is not used anymore, hopefully not. We implemented - * some basic attempt at sorting just in case - * @param a - * @param b - * @return - *************************************************************************/ - protected final boolean lt(File a, File b) { - System.out.println("DEBUG:LT called?"); - - boolean less = false; + if (comp[i] instanceof Container) + { + JTable tbl = findJTable( ( (Container) comp[i]).getComponents()); - switch (col) { - case COLUMN_FILEDATE: - less = a.lastModified() > b.lastModified(); - - break; + if (tbl != null) + { + return tbl; + } + } + } - case COLUMN_FILESIZE: - less = a.length() > b.length(); + return null; + } + } + + /*************************************************************************** + * Implementation of BasicDirectoryModel that sorts the Files by column + **************************************************************************/ + private final class DirectoryModel + extends BasicDirectoryModel + { + String sortingColumnName=null; + int col = 0; + boolean ascending; - break; + /************************************************************************** + * Must be overridden to extend BasicDirectoryModel + * @param chooser + *************************************************************************/ + DirectoryModel(JFileChooser chooser) + { + super(chooser); + } - default: - less = a.getName().compareToIgnoreCase(b.getName()) > 0; - break; - } + /************************************************************************** + * Resorts the JFileChooser table based on new column + * @param c + *************************************************************************/ + protected final void sort(int c, JTable tbl) + { - if (ascending) { - return less = !less; - } - return less; - } + //Set column and order + col = c; + ascending = !ascending; - /************************************************************************** - * Resorts the JFileChooser table based on new column - * @param c - *************************************************************************/ - protected final void sort(int c, JTable tbl) { - //Set column and order - col = c; - ascending = !ascending; + String indicator = " (^)"; - String indicator = " (^)"; + if (ascending) + { + indicator = " (v)"; + } - if (ascending) { - indicator = " (v)"; - } + final JTableHeader th = tbl.getTableHeader(); + final TableColumnModel tcm = th.getColumnModel(); + TableColumn tc = null; + String title = null; - final JTableHeader th = tbl.getTableHeader(); - final TableColumnModel tcm = th.getColumnModel(); - for (int i = 0; i < JalviewFileChooser.COLUMN_COLCOUNT; i++) { - final TableColumn tc = tcm.getColumn(i); // the column to change - tc.setHeaderValue(COLUMNS[i]); - } + //Remove indicator from old sort, and add to new + for(int i=0; i b.lastModified()) { - ret = -1; - } else if (a.lastModified() == b.lastModified()) { - ret = 0; - } - - if (ascending) { - ret *= -1; - } - - return ret; - } - }); - - - break; - - case COLUMN_FILESIZE: - Collections.sort(data, - new Comparator() { - public int compare(Object o1, Object o2) { - int ret = 1; - final File a = (File) o1; - final File b = (File) o2; - - if (a.length() > b.length()) { - ret = -1; - } else if (a.length() == b.length()) { - ret = 0; - } - - if (ascending) { - ret *= -1; - } - - return ret; - } - }); - - - break; - - case COLUMN_FILENAME: - Collections.sort(data, - new Comparator() { - public int compare(Object o1, Object o2) { - final File a = (File) o1; - final File b = (File) o2; - - if (ascending) { - return a.getName().compareToIgnoreCase(b.getName()); - } else { - return -1 * a.getName().compareToIgnoreCase(b.getName()); - } - } - }); - - - break; + /************************************************************************** + * Sorts the data based on current column setting + * @param data + *************************************************************************/ + protected final void sort(Vector data) + { + /* + UIManager.getString("FileChooser.fileTypeHeaderText", l), + UIManager.getString("FileChooser.fileAttrHeaderText", l) +*/ + if(sortingColumnName==null) + return; + + + if(sortingColumnName.equals(UIManager.getString("FileChooser.fileDateHeaderText"))) + { + Collections.sort(data, + new Comparator() + { + + public int compare(Object o1, Object o2) + { + int ret = 1; + final File a = (File) o1; + final File b = (File) o2; + + if (a.lastModified() > b.lastModified()) + { + ret = -1; + } + else if (a.lastModified() == b.lastModified()) + { + ret = 0; + } + + if (ascending) + { + ret *= -1; + } + + return ret; } + }); + } + else if(sortingColumnName.equals(UIManager.getString("FileChooser.fileSizeHeaderText"))) + { + + Collections.sort(data, + new Comparator() + { + + public int compare(Object o1, Object o2) + { + int ret = 1; + final File a = (File) o1; + final File b = (File) o2; + + if (a.length() > b.length()) + { + ret = -1; + } + else if (a.length() == b.length()) + { + ret = 0; + } + + if (ascending) + { + ret *= -1; + } + + return ret; + } + }); + } + else if(sortingColumnName.equals(UIManager.getString("FileChooser.fileTypeHeaderText"))) + { + Collections.sort(data, + new Comparator() + { + public int compare(Object o1, Object o2) + { + final String a = getFileSystemView().getSystemTypeDescription( (File)o1 ); + final String b = getFileSystemView().getSystemTypeDescription( (File)o2 ); + if (ascending) + { + return a.compareToIgnoreCase(b); + } + else + { + return -1 * a.compareToIgnoreCase(b); + } + } + }); + } + else if(sortingColumnName.equals(UIManager.getString("FileChooser.fileNameHeaderText"))) +{ + Collections.sort(data, + new Comparator() + { + public int compare(Object o1, Object o2) + { + final String a = ((File) o1).getName(); + final String b = ((File) o2).getName(); + + if (ascending) + { + return a.compareToIgnoreCase(b); + } + else + { + return -1 * a.compareToIgnoreCase(b); + } } + }); + } + } + } } diff --git a/src/jalview/io/JalviewFileFilter.java b/src/jalview/io/JalviewFileFilter.java index e2692e2..907b1b3 100755 --- a/src/jalview/io/JalviewFileFilter.java +++ b/src/jalview/io/JalviewFileFilter.java @@ -1,154 +1,184 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; -import java.io.File; - +import java.io.*; import java.util.*; -import javax.swing.filechooser.*; - - -public class JalviewFileFilter extends FileFilter { - private static String TYPE_UNKNOWN = "Type Unknown"; - private static String HIDDEN_FILE = "Hidden File"; - public static Hashtable suffixHash = new Hashtable(); - private Hashtable filters = null; - private String description = "no description"; - private String fullDescription = "full description"; - private boolean useExtensionsInDescription = true; - - public JalviewFileFilter(String extension, String description) { - StringTokenizer st = new StringTokenizer(extension, ","); - - while (st.hasMoreElements()) { - addExtension(st.nextToken().trim()); - } - - setDescription(description); +import javax.swing.filechooser.FileFilter; + +public class JalviewFileFilter + extends FileFilter +{ + private static String TYPE_UNKNOWN = "Type Unknown"; + private static String HIDDEN_FILE = "Hidden File"; + public static Hashtable suffixHash = new Hashtable(); + private Hashtable filters = null; + private String description = "no description"; + private String fullDescription = "full description"; + private boolean useExtensionsInDescription = true; + + public JalviewFileFilter(String extension, String description) + { + StringTokenizer st = new StringTokenizer(extension, ","); + + while (st.hasMoreElements()) + { + addExtension(st.nextToken().trim()); } - public JalviewFileFilter(String[] filts) { - this(filts, null); - } + setDescription(description); + } - public JalviewFileFilter(String[] filts, String description) { - for (int i = 0; i < filts.length; i++) { - // add filters one by one - addExtension(filts[i]); - } + public JalviewFileFilter(String[] filts) + { + this(filts, null); + } - if (description != null) { - setDescription(description); - } + public JalviewFileFilter(String[] filts, String description) + { + for (int i = 0; i < filts.length; i++) + { + // add filters one by one + addExtension(filts[i]); } - public String getAcceptableExtension() { - return filters.keys().nextElement().toString(); + if (description != null) + { + setDescription(description); } - - // takes account of the fact that database is a directory - public boolean accept(File f) { - if (f != null) { - String extension = getExtension(f); - - if (f.isDirectory()) { - if ((extension == null) || extension.equals("")) { - return true; - } else { - if (filters.get(getExtension(f)) != null) { - return true; - } - } - } - - if ((extension != null) && (filters.get(getExtension(f)) != null)) { - return true; - } + } + + public String getAcceptableExtension() + { + return filters.keys().nextElement().toString(); + } + + // takes account of the fact that database is a directory + public boolean accept(File f) + { + if (f != null) + { + String extension = getExtension(f); + + if (f.isDirectory()) + { + if ( (extension == null) || extension.equals("")) + { + return true; + } + else + { + if (filters.get(getExtension(f)) != null) + { + return true; + } } + } - return false; + if ( (extension != null) && (filters.get(getExtension(f)) != null)) + { + return true; + } } - public String getExtension(File f) { - if (f != null) { - String filename = f.getName(); - int i = filename.lastIndexOf('.'); + return false; + } - if ((i > 0) && (i < (filename.length() - 1))) { - return filename.substring(i + 1).toLowerCase(); - } + public String getExtension(File f) + { + if (f != null) + { + String filename = f.getName(); + int i = filename.lastIndexOf('.'); - ; - } + if ( (i > 0) && (i < (filename.length() - 1))) + { + return filename.substring(i + 1).toLowerCase(); + } - return ""; + ; } - public void addExtension(String extension) { - if (filters == null) { - filters = new Hashtable(5); - } + return ""; + } - filters.put(extension.toLowerCase(), this); - fullDescription = null; + public void addExtension(String extension) + { + if (filters == null) + { + filters = new Hashtable(5); } - public String getDescription() { - if (fullDescription == null) { - if ((description == null) || isExtensionListInDescription()) { - fullDescription = (description == null) ? "(" : (description + - " ("); - - // build the description from the extension list - Enumeration extensions = filters.keys(); - - if (extensions != null) { - fullDescription += ("." + - (String) extensions.nextElement()); - - while (extensions.hasMoreElements()) { - fullDescription += (", " + - (String) extensions.nextElement()); - } - } - - fullDescription += ")"; - } else { - fullDescription = description; - } + filters.put(extension.toLowerCase(), this); + fullDescription = null; + } + + public String getDescription() + { + if (fullDescription == null) + { + if ( (description == null) || isExtensionListInDescription()) + { + fullDescription = (description == null) ? "(" : (description + + " ("); + + // build the description from the extension list + Enumeration extensions = filters.keys(); + + if (extensions != null) + { + fullDescription += ("." + + (String) extensions.nextElement()); + + while (extensions.hasMoreElements()) + { + fullDescription += (", " + + (String) extensions.nextElement()); + } } - return fullDescription; + fullDescription += ")"; + } + else + { + fullDescription = description; + } } - public void setDescription(String description) { - this.description = description; - fullDescription = null; - } - - public void setExtensionListInDescription(boolean b) { - useExtensionsInDescription = b; - fullDescription = null; - } - - public boolean isExtensionListInDescription() { - return useExtensionsInDescription; - } + return fullDescription; + } + + public void setDescription(String description) + { + this.description = description; + fullDescription = null; + } + + public void setExtensionListInDescription(boolean b) + { + useExtensionsInDescription = b; + fullDescription = null; + } + + public boolean isExtensionListInDescription() + { + return useExtensionsInDescription; + } } diff --git a/src/jalview/io/JalviewFileView.java b/src/jalview/io/JalviewFileView.java index f4c7f23..04189e1 100755 --- a/src/jalview/io/JalviewFileView.java +++ b/src/jalview/io/JalviewFileView.java @@ -1,97 +1,111 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; import java.io.*; - import java.util.*; import javax.swing.*; -import javax.swing.filechooser.FileView; - - -public class JalviewFileView extends FileView { - static Hashtable alignSuffix = new Hashtable(); - - static { - alignSuffix.put("fasta", "Fasta file"); - alignSuffix.put("fa", "Fasta file"); - alignSuffix.put("fastq", "Fasta file"); - alignSuffix.put("blc", "BLC file"); - alignSuffix.put("msf", "MSF file"); - alignSuffix.put("pfam", "PFAM file"); - alignSuffix.put("aln", "Clustal file"); - alignSuffix.put("pir", "PIR file"); +import javax.swing.filechooser.*; + +public class JalviewFileView + extends FileView +{ + static Hashtable alignSuffix = new Hashtable(); + + static + { + alignSuffix.put("fasta", "Fasta file"); + alignSuffix.put("fa", "Fasta file"); + alignSuffix.put("fastq", "Fasta file"); + alignSuffix.put("blc", "BLC file"); + alignSuffix.put("msf", "MSF file"); + alignSuffix.put("pfam", "PFAM file"); + alignSuffix.put("aln", "Clustal file"); + alignSuffix.put("pir", "PIR file"); + alignSuffix.put("jar", "Jalview file"); + } + + public String getTypeDescription(File f) + { + String extension = getExtension(f); + String type = null; + + if (extension != null) + { + if (alignSuffix.containsKey(extension)) + { + type = alignSuffix.get(extension).toString(); + } } - public String getTypeDescription(File f) { - String extension = getExtension(f); - String type = null; + return type; + } - if (extension != null) { - if (alignSuffix.containsKey(extension)) { - type = alignSuffix.get(extension).toString(); - } - } + public Icon getIcon(File f) + { + String extension = getExtension(f); + Icon icon = null; - return type; + if (extension != null) + { + if (alignSuffix.containsKey(extension)) + { + icon = createImageIcon("/images/file.png"); + } } - public Icon getIcon(File f) { - String extension = getExtension(f); - Icon icon = null; - - if (extension != null) { - if (alignSuffix.containsKey(extension)) { - icon = createImageIcon("/images/file.png"); - } - } - - return icon; + return icon; + } + + /* + * Get the extension of a file. + */ + public static String getExtension(File f) + { + String ext = null; + String s = f.getName(); + int i = s.lastIndexOf('.'); + + if ( (i > 0) && (i < (s.length() - 1))) + { + ext = s.substring(i + 1).toLowerCase(); } - /* - * Get the extension of a file. - */ - public static String getExtension(File f) { - String ext = null; - String s = f.getName(); - int i = s.lastIndexOf('.'); + return ext; + } - if ((i > 0) && (i < (s.length() - 1))) { - ext = s.substring(i + 1).toLowerCase(); - } + /** Returns an ImageIcon, or null if the path was invalid. */ + protected static ImageIcon createImageIcon(String path) + { + java.net.URL imgURL = JalviewFileView.class.getResource(path); - return ext; + if (imgURL != null) + { + return new ImageIcon(imgURL); } + else + { + System.err.println( + "JalviewFileView.createImageIcon: Couldn't find file: " + path); - /** Returns an ImageIcon, or null if the path was invalid. */ - protected static ImageIcon createImageIcon(String path) { - java.net.URL imgURL = JalviewFileView.class.getResource(path); - - if (imgURL != null) { - return new ImageIcon(imgURL); - } else { - System.err.println( - "JalviewFileView.createImageIcon: Couldn't find file: " + path); - - return null; - } + return null; } + } } diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index 2a6e10f..5f81215 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -27,24 +27,54 @@ import java.io.*; import java.util.*; -public class MSFfile extends AlignFile { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class MSFfile extends AlignFile +{ private static com.stevesoft.pat.Regex gapre = new com.stevesoft.pat.Regex("\\~", "-"); private static com.stevesoft.pat.Regex re2gap = new com.stevesoft.pat.Regex( "[" + jalview.util.Comparison.GapChars + "]", "\\~"); - public MSFfile() { + /** + * Creates a new MSFfile object. + */ + public MSFfile() + { } - public MSFfile(String inStr) { + /** + * Creates a new MSFfile object. + * + * @param inStr DOCUMENT ME! + */ + public MSFfile(String inStr) + { super(inStr); } - public MSFfile(String inFile, String type) throws IOException { + /** + * Creates a new MSFfile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public MSFfile(String inFile, String type) throws IOException + { super(inFile, type); } - public void parse() { + /** + * DOCUMENT ME! + */ + public void parse() + { int i = 0; boolean seqFlag = false; String key = new String(); @@ -52,48 +82,60 @@ public class MSFfile extends AlignFile { Hashtable seqhash = new Hashtable(); String line; - try { - while ((line = nextLine()) != null) { + try + { + while ((line = nextLine()) != null) + { StringTokenizer str = new StringTokenizer(line); - while (str.hasMoreTokens()) { + while (str.hasMoreTokens()) + { String inStr = str.nextToken(); //If line has header information add to the headers vector - if (inStr.indexOf("Name:") != -1) { + if (inStr.indexOf("Name:") != -1) + { key = str.nextToken(); headers.addElement(key); } //if line has // set SeqFlag to 1 so we know sequences are coming - if (inStr.indexOf("//") != -1) { + if (inStr.indexOf("//") != -1) + { seqFlag = true; } //Process lines as sequence lines if seqFlag is set - if ((inStr.indexOf("//") == -1) && (seqFlag == true)) { + if ((inStr.indexOf("//") == -1) && (seqFlag == true)) + { //seqeunce id is the first field key = inStr; StringBuffer tempseq; //Get sequence from hash if it exists - if (seqhash.containsKey(key)) { + if (seqhash.containsKey(key)) + { tempseq = (StringBuffer) seqhash.get(key); - } else { + } + else + { tempseq = new StringBuffer(); seqhash.put(key, tempseq); } //loop through the rest of the words - while (str.hasMoreTokens()) { + while (str.hasMoreTokens()) + { //append the word to the sequence tempseq.append(str.nextToken()); } } } } - } catch (IOException e) { + } + catch (IOException e) + { System.err.println("Exception parsing MSFFile " + e); e.printStackTrace(); } @@ -101,28 +143,34 @@ public class MSFfile extends AlignFile { this.noSeqs = headers.size(); //Add sequences to the hash - for (i = 0; i < headers.size(); i++) { - if (seqhash.get(headers.elementAt(i)) != null) { + for (i = 0; i < headers.size(); i++) + { + if (seqhash.get(headers.elementAt(i)) != null) + { String head = headers.elementAt(i).toString(); String seq = seqhash.get(head).toString(); int start = 1; int end = seq.length(); - if (maxLength < head.length()) { + if (maxLength < head.length()) + { maxLength = head.length(); } - if (head.indexOf("/") > 0) { + if (head.indexOf("/") > 0) + { StringTokenizer st = new StringTokenizer(head, "/"); - if (st.countTokens() == 2) { + if (st.countTokens() == 2) + { head = st.nextToken(); String tmp = st.nextToken(); st = new StringTokenizer(tmp, "-"); - if (st.countTokens() == 2) { + if (st.countTokens() == 2) + { start = Integer.valueOf(st.nextToken()).intValue(); end = Integer.valueOf(st.nextToken()).intValue(); } @@ -135,30 +183,44 @@ public class MSFfile extends AlignFile { Sequence newSeq = new Sequence(head, seq, start, end); seqs.addElement(newSeq); - } else { + } + else + { System.err.println("MSFFile Parser: Can't find sequence for " + headers.elementAt(i)); } } } - public static int checkSum(String seq) { + /** + * DOCUMENT ME! + * + * @param seq DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static int checkSum(String seq) + { //String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.*~&@"; int check = 0; + String sequence = seq.toUpperCase(); String index = "--------------------------------------&---*---.-----------------@ABCDEFGHIJKLMNOPQRSTUVWXYZ------ABCDEFGHIJKLMNOPQRSTUVWXYZ----@"; - index += "--------------------------------------------------------------------------------------------------------------------------------"; + index += "--------------------------------------------------------------------------------------------------------------------------------"; - for (int i = 0; i < seq.length(); i++) { - try { - if (i < seq.length()) { - int pos = index.indexOf(seq.substring(i, i + 1)); + for (int i = 0; i < sequence.length(); i++) + { + try + { + int pos = index.indexOf(sequence.charAt(i)); - if (!index.substring(pos, pos + 1).equals("_")) { + if (index.charAt(pos)!='_') + { check += (((i % 57) + 1) * pos); } - } - } catch (Exception e) { + } + catch (Exception e) + { System.err.println("Exception during MSF Checksum calculation"); e.printStackTrace(); } @@ -167,11 +229,28 @@ public class MSFfile extends AlignFile { return check % 10000; } - public static String print(SequenceI[] s) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String print(SequenceI[] s) + { return print(s, false); } - public static String print(SequenceI[] s, boolean is_NA) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param is_NA DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String print(SequenceI[] s, boolean is_NA) + { StringBuffer out = new StringBuffer("!!" + (is_NA ? "NA" : "AA") + "_MULTIPLE_ALIGNMENT 1.0\n\n"); // TODO: JBPNote : Jalview doesn't remember NA or AA yet. @@ -180,11 +259,13 @@ public class MSFfile extends AlignFile { int i = 0; String big = ""; - while ((i < s.length) && (s[i] != null)) { + while ((i < s.length) && (s[i] != null)) + { String sq; big += (sq = s[i].getSequence()); - if (sq.length() > max) { + if (sq.length() > max) + { max = sq.length(); } @@ -205,8 +286,8 @@ public class MSFfile extends AlignFile { String[] nameBlock = new String[s.length]; String[] idBlock = new String[s.length]; - while ((i < s.length) && (s[i] != null)) { - String seq = s[i].getSequence(); + while ((i < s.length) && (s[i] != null)) + { String name = s[i].getName() + "/" + s[i].getStart() + "-" + s[i].getEnd(); int check = checkSum(s[i].getSequence()); @@ -215,28 +296,33 @@ public class MSFfile extends AlignFile { maxLenpad.form(s[i].getSequence().length()) + " Check:" + maxChkpad.form(check) + " Weight: 1.00\n"); - if (name.length() > maxid) { + if (name.length() > maxid) + { maxid = name.length(); } - if (nameBlock[i].length() > maxNB) { + if (nameBlock[i].length() > maxNB) + { maxNB = nameBlock[i].length(); } i++; } - if (maxid < 10) { + if (maxid < 10) + { maxid = 10; } - if (maxNB < 15) { + if (maxNB < 15) + { maxNB = 15; } Format nbFormat = new Format("%-" + maxNB + "s"); - for (i = 0; (i < s.length) && (s[i] != null); i++) { + for (i = 0; (i < s.length) && (s[i] != null); i++) + { out.append(nbFormat.form(nameBlock[i]) + idBlock[i]); } @@ -247,39 +333,53 @@ public class MSFfile extends AlignFile { int nochunks = (max / len) + 1; - if ((max % len) == 0) { + if ((max % len) == 0) + { nochunks--; } - for (i = 0; i < nochunks; i++) { + for (i = 0; i < nochunks; i++) + { int j = 0; - while ((j < s.length) && (s[j] != null)) { + while ((j < s.length) && (s[j] != null)) + { String name = s[j].getName(); out.append(new Format("%-" + maxid + "s").form(name + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); - for (int k = 0; k < 5; k++) { + for (int k = 0; k < 5; k++) + { int start = (i * 50) + (k * 10); int end = start + 10; if ((end < s[j].getSequence().length()) && - (start < s[j].getSequence().length())) { + (start < s[j].getSequence().length())) + { out.append(re2gap.replaceAll(s[j].getSequence() .substring(start, end))); - if (k < 4) { + if (k < 4) + { // out.append(" "); - } else { + } + else + { out.append("\n"); } - } else { - if (start < s[j].getSequence().length()) { + } + else + { + if (start < s[j].getSequence().length()) + { out.append(re2gap.replaceAll( s[j].getSequence().substring(start))); out.append("\n"); - } else { - if (k == 0) { + } + else + { + if (k == 0) + { out.append("\n"); } } @@ -295,7 +395,13 @@ public class MSFfile extends AlignFile { return out.toString(); } - public String print() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() + { return print(getSeqsAsArray()); } } diff --git a/src/jalview/io/NewickFile.java b/src/jalview/io/NewickFile.java index a6f1580..c1ef5b6 100755 --- a/src/jalview/io/NewickFile.java +++ b/src/jalview/io/NewickFile.java @@ -29,7 +29,14 @@ import java.io.*; import java.util.*; -public class NewickFile extends FileParse { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class NewickFile extends FileParse +{ SequenceNode root; private boolean HasBootstrap = false; private boolean HasDistances = false; @@ -38,46 +45,106 @@ public class NewickFile extends FileParse { // File IO Flags boolean ReplaceUnderscores = false; boolean printRootInfo = false; - private com.stevesoft.pat.Regex[] NodeSafeName = new com.stevesoft.pat.Regex[] { + private com.stevesoft.pat.Regex[] NodeSafeName = new com.stevesoft.pat.Regex[] + { new com.stevesoft.pat.Regex().perlCode("m/[\\[,:'()]/"), // test for requiring quotes new com.stevesoft.pat.Regex().perlCode("s/'/''/"), // escaping quote characters new com.stevesoft.pat.Regex().perlCode("s/\\/w/_/") // unqoted whitespace transformation }; char QuoteChar = '\''; - public NewickFile(String inStr) throws IOException { + /** + * Creates a new NewickFile object. + * + * @param inStr DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public NewickFile(String inStr) throws IOException + { super(inStr, "Paste"); } - public NewickFile(String inFile, String type) throws IOException { + /** + * Creates a new NewickFile object. + * + * @param inFile DOCUMENT ME! + * @param type DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public NewickFile(String inFile, String type) throws IOException + { super(inFile, type); } - public NewickFile(SequenceNode newtree) { + /** + * Creates a new NewickFile object. + * + * @param newtree DOCUMENT ME! + */ + public NewickFile(SequenceNode newtree) + { root = newtree; } - public NewickFile(SequenceNode newtree, boolean bootstrap) { + /** + * Creates a new NewickFile object. + * + * @param newtree DOCUMENT ME! + * @param bootstrap DOCUMENT ME! + */ + public NewickFile(SequenceNode newtree, boolean bootstrap) + { HasBootstrap = bootstrap; root = newtree; } - public NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances) { + /** + * Creates a new NewickFile object. + * + * @param newtree DOCUMENT ME! + * @param bootstrap DOCUMENT ME! + * @param distances DOCUMENT ME! + */ + public NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances) + { root = newtree; HasBootstrap = bootstrap; HasDistances = distances; } + /** + * Creates a new NewickFile object. + * + * @param newtree DOCUMENT ME! + * @param bootstrap DOCUMENT ME! + * @param distances DOCUMENT ME! + * @param rootdistance DOCUMENT ME! + */ public NewickFile(SequenceNode newtree, boolean bootstrap, - boolean distances, boolean rootdistance) { + boolean distances, boolean rootdistance) + { root = newtree; HasBootstrap = bootstrap; HasDistances = distances; RootHasDistance = rootdistance; } + /** + * DOCUMENT ME! + * + * @param Error DOCUMENT ME! + * @param Er DOCUMENT ME! + * @param r DOCUMENT ME! + * @param p DOCUMENT ME! + * @param s DOCUMENT ME! + * + * @return DOCUMENT ME! + */ private String ErrorStringrange(String Error, String Er, int r, int p, - String s) { + String s) + { return ((Error == null) ? "" : Error) + Er + " at position " + p + " ( " + s.substring(((p - r) < 0) ? 0 : (p - r), @@ -86,22 +153,36 @@ public class NewickFile extends FileParse { // @tree annotations // These are set automatically by the reader - public boolean HasBootstrap() { + public boolean HasBootstrap() + { return HasBootstrap; } - public boolean HasDistances() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean HasDistances() + { return HasDistances; } - public void parse() throws IOException { + /** + * DOCUMENT ME! + * + * @throws IOException DOCUMENT ME! + */ + public void parse() throws IOException + { String nf; { // fill nf with complete tree file StringBuffer file = new StringBuffer(); - while ((nf = nextLine()) != null) { + while ((nf = nextLine()) != null) + { file.append(nf); } @@ -131,19 +212,24 @@ public class NewickFile extends FileParse { com.stevesoft.pat.Regex majorsyms = new com.stevesoft.pat.Regex( "[(\\['),;]"); - while (majorsyms.searchFrom(nf, cp) && (Error == null)) { + while (majorsyms.searchFrom(nf, cp) && (Error == null)) + { int fcp = majorsyms.matchedFrom(); - switch (nf.charAt(fcp)) { + switch (nf.charAt(fcp)) + { case '[': // Comment or structured/extended NH format info com.stevesoft.pat.Regex comment = new com.stevesoft.pat.Regex( "]"); - if (comment.searchFrom(nf, fcp)) { + if (comment.searchFrom(nf, fcp)) + { // Skip the comment field cp = 1 + comment.matchedFrom(); - } else { + } + else + { Error = ErrorStringrange(Error, "Unterminated comment", 3, fcp, nf); } @@ -156,7 +242,8 @@ public class NewickFile extends FileParse { // ascending should not be set // New Internal node - if (ascending) { + if (ascending) + { Error = ErrorStringrange(Error, "Unexpected '('", 7, fcp, nf); continue; @@ -165,12 +252,16 @@ public class NewickFile extends FileParse { ; d++; - if (c.right() == null) { + if (c.right() == null) + { c.setRight(new SequenceNode(null, c, null, DefDistance, DefBootstrap, false)); c = (SequenceNode) c.right(); - } else { - if (c.left() != null) { + } + else + { + if (c.left() != null) + { // Dummy node for polytomy - keeps c.left free for new node SequenceNode tmpn = new SequenceNode(null, c, null, 0, 0, true); @@ -183,7 +274,8 @@ public class NewickFile extends FileParse { c = (SequenceNode) c.left(); } - if (realroot == null) { + if (realroot == null) + { realroot = c; } @@ -200,12 +292,15 @@ public class NewickFile extends FileParse { com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex( "([^']|'')+'"); - if (qnodename.searchFrom(nf, fcp)) { + if (qnodename.searchFrom(nf, fcp)) + { int nl = qnodename.stringMatched().length(); nodename = new String(qnodename.stringMatched().substring(0, nl - 1)); cp = fcp + nl + 1; - } else { + } + else + { Error = ErrorStringrange(Error, "Unterminated quotes for nodename", 7, fcp, nf); } @@ -214,7 +309,8 @@ public class NewickFile extends FileParse { case ';': - if (d != -1) { + if (d != -1) + { Error = ErrorStringrange(Error, "Wayward semicolon (depth=" + d + ")", 7, fcp, nf); } @@ -234,15 +330,21 @@ public class NewickFile extends FileParse { if (uqnodename.search(fstring) && ((uqnodename.matchedFrom(1) == 0) || (fstring.charAt(uqnodename.matchedFrom(1) - 1) != ':'))) // JBPNote HACK! - { - if (nodename == null) { - if (ReplaceUnderscores) { + { + if (nodename == null) + { + if (ReplaceUnderscores) + { nodename = uqnodename.stringMatched(1).replace('_', ' '); - } else { + } + else + { nodename = uqnodename.stringMatched(1); } - } else { + } + else + { Error = ErrorStringrange(Error, "File has broken algorithm - overwritten nodename", 10, fcp, nf); @@ -251,11 +353,15 @@ public class NewickFile extends FileParse { if (nbootstrap.search(fstring) && (nbootstrap.matchedFrom(1) > (uqnodename.matchedFrom(1) + - uqnodename.stringMatched().length()))) { - try { + uqnodename.stringMatched().length()))) + { + try + { bootstrap = (new Integer(nbootstrap.stringMatched(1))).intValue(); HasBootstrap = true; - } catch (Exception e) { + } + catch (Exception e) + { Error = ErrorStringrange(Error, "Can't parse bootstrap value", 4, cp + nbootstrap.matchedFrom(), nf); @@ -264,39 +370,53 @@ public class NewickFile extends FileParse { boolean nodehasdistance = false; - if (ndist.search(fstring)) { - try { + if (ndist.search(fstring)) + { + try + { distance = (new Float(ndist.stringMatched(1))).floatValue(); HasDistances = true; nodehasdistance = true; - } catch (Exception e) { + } + catch (Exception e) + { Error = ErrorStringrange(Error, "Can't parse node distance value", 7, cp + ndist.matchedFrom(), nf); } } - if (ascending) { + if (ascending) + { // Write node info here c.setName(nodename); c.dist = (HasDistances) ? distance : 0; c.setBootstrap((HasBootstrap) ? bootstrap : 0); - if (c == realroot) { + if (c == realroot) + { RootHasDistance = nodehasdistance; // JBPNote This is really UGLY!!! } - } else { + } + else + { // Find a place to put the leaf SequenceNode newnode = new SequenceNode(null, c, nodename, (HasDistances) ? distance : DefDistance, (HasBootstrap) ? bootstrap : DefBootstrap, false); - if (c.right() == null) { + if (c.right() == null) + { c.setRight(newnode); - } else { - if (c.left() == null) { + } + else + { + if (c.left() == null) + { c.setLeft(newnode); - } else { + } + else + { // Insert a dummy node for polytomy SequenceNode newdummy = new SequenceNode(null, c, null, 0, 0, true); @@ -306,32 +426,43 @@ public class NewickFile extends FileParse { } } - if (ascending) { + if (ascending) + { // move back up the tree from preceding closure c = c.AscendTree(); - if ((d > -1) && (c == null)) { + if ((d > -1) && (c == null)) + { Error = ErrorStringrange(Error, "File broke algorithm: Lost place in tree (is there an extra ')' ?)", 7, fcp, nf); } } - if (nf.charAt(fcp) == ')') { + if (nf.charAt(fcp) == ')') + { d--; ascending = true; - } else { - if (nf.charAt(fcp) == ',') { - if (ascending) { + } + else + { + if (nf.charAt(fcp) == ',') + { + if (ascending) + { ascending = false; - } else { + } + else + { // Just advance focus, if we need to - if ((c.left() != null) && (!c.left().isLeaf())) { + if ((c.left() != null) && (!c.left().isLeaf())) + { c = (SequenceNode) c.left(); } } } - // else : We do nothing if ';' is encountered. + + // else : We do nothing if ';' is encountered. } // Reset new node properties to obvious fakes @@ -343,23 +474,38 @@ public class NewickFile extends FileParse { } } - if (Error != null) { + if (Error != null) + { throw (new IOException("NewickFile: " + Error + "\n")); } root = (SequenceNode) root.right().detach(); // remove the imaginary root. - if (!RootHasDistance) { + if (!RootHasDistance) + { root.dist = 0; } } - public SequenceNode getTree() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public SequenceNode getTree() + { return root; } - public String print() { - synchronized (this) { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print() + { + synchronized (this) + { StringBuffer tf = new StringBuffer(); print(tf, root); @@ -367,8 +513,17 @@ public class NewickFile extends FileParse { } } - public String print(boolean withbootstraps) { - synchronized (this) { + /** + * DOCUMENT ME! + * + * @param withbootstraps DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print(boolean withbootstraps) + { + synchronized (this) + { boolean boots = this.HasBootstrap; this.HasBootstrap = withbootstraps; @@ -379,8 +534,18 @@ public class NewickFile extends FileParse { } } - public String print(boolean withbootstraps, boolean withdists) { - synchronized (this) { + /** + * DOCUMENT ME! + * + * @param withbootstraps DOCUMENT ME! + * @param withdists DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String print(boolean withbootstraps, boolean withdists) + { + synchronized (this) + { boolean dists = this.HasDistances; this.HasDistances = withdists; @@ -391,9 +556,20 @@ public class NewickFile extends FileParse { } } + /** + * DOCUMENT ME! + * + * @param withbootstraps DOCUMENT ME! + * @param withdists DOCUMENT ME! + * @param printRootInfo DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public String print(boolean withbootstraps, boolean withdists, - boolean printRootInfo) { - synchronized (this) { + boolean printRootInfo) + { + synchronized (this) + { boolean rootinfo = printRootInfo; this.printRootInfo = printRootInfo; @@ -404,33 +580,74 @@ public class NewickFile extends FileParse { } } - char getQuoteChar() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + char getQuoteChar() + { return QuoteChar; } - char setQuoteChar(char c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + char setQuoteChar(char c) + { char old = QuoteChar; QuoteChar = c; return old; } - private String nodeName(String name) { - if (NodeSafeName[0].search(name)) { + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String nodeName(String name) + { + if (NodeSafeName[0].search(name)) + { return QuoteChar + NodeSafeName[1].replaceAll(name) + QuoteChar; - } else { + } + else + { return NodeSafeName[2].replaceAll(name); } } - private String printNodeField(SequenceNode c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String printNodeField(SequenceNode c) + { return ((c.getName() == null) ? "" : nodeName(c.getName())) + ((HasBootstrap) ? ((c.getBootstrap() > -1) ? (" " + c.getBootstrap()) : "") : "") + ((HasDistances) ? (":" + c.dist) : ""); } - private String printRootField(SequenceNode root) { + /** + * DOCUMENT ME! + * + * @param root DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String printRootField(SequenceNode root) + { return (printRootInfo) ? (((root.getName() == null) ? "" : nodeName(root.getName())) + ((HasBootstrap) @@ -439,19 +656,28 @@ public class NewickFile extends FileParse { } // Non recursive call deals with root node properties - public void print(StringBuffer tf, SequenceNode root) { - if (root != null) { - if (root.isLeaf() && printRootInfo) { + public void print(StringBuffer tf, SequenceNode root) + { + if (root != null) + { + if (root.isLeaf() && printRootInfo) + { tf.append(printRootField(root)); - } else { - if (root.isDummy()) { + } + else + { + if (root.isDummy()) + { _print(tf, (SequenceNode) root.right()); _print(tf, (SequenceNode) root.left()); - } else { + } + else + { tf.append("("); _print(tf, (SequenceNode) root.right()); - if (root.left() != null) { + if (root.left() != null) + { tf.append(","); } @@ -463,19 +689,28 @@ public class NewickFile extends FileParse { } // Recursive call for non-root nodes - public void _print(StringBuffer tf, SequenceNode c) { - if (c != null) { - if (c.isLeaf()) { + public void _print(StringBuffer tf, SequenceNode c) + { + if (c != null) + { + if (c.isLeaf()) + { tf.append(printNodeField(c)); - } else { - if (c.isDummy()) { + } + else + { + if (c.isDummy()) + { _print(tf, (SequenceNode) c.right()); _print(tf, (SequenceNode) c.left()); - } else { + } + else + { tf.append("("); _print(tf, (SequenceNode) c.right()); - if (c.left() != null) { + if (c.left() != null) + { tf.append(","); } @@ -487,15 +722,18 @@ public class NewickFile extends FileParse { } // Test - public static void main(String[] args) { - try { + public static void main(String[] args) + { + try + { File fn = new File(args[0]); StringBuffer newickfile = new StringBuffer(); BufferedReader treefile = new BufferedReader(new FileReader(fn)); String l; - while ((l = treefile.readLine()) != null) { + while ((l = treefile.readLine()) != null) + { newickfile.append(l); } @@ -522,7 +760,9 @@ public class NewickFile extends FileParse { System.out.println(trf.print(false, false)); System.out.println("With bootstraps and with distances.\n"); System.out.println(trf.print(true, true)); - } catch (java.io.IOException e) { + } + catch (java.io.IOException e) + { System.err.println("Exception\n" + e); e.printStackTrace(); } diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index 42334e3..a15a4cb 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -1,145 +1,173 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; -import jalview.analysis.*; - -import jalview.datamodel.*; - import java.io.*; - import java.util.*; +import jalview.analysis.*; +import jalview.datamodel.*; + +public class PIRFile + extends AlignFile +{ + Vector words = new Vector(); //Stores the words in a line after splitting + + public PIRFile() + { + } + + public PIRFile(String inStr) + { + super(inStr); + } + + public PIRFile(String inFile, String type) + throws IOException + { + super(inFile, type); + } + + public void parse() + { + try + { + String id; + String start; + String end; + StringBuffer sequence; + String line = null; + + while ( (line = nextLine()) != null) + { + try + { + id = line.substring(line.indexOf(";") + 1, line.indexOf("/")); + line = line.substring(line.indexOf("/") + 1); + start = line.substring(0, line.indexOf("-")); + end = line.substring(line.indexOf("-") + 1); + } + catch (Exception ex) + { + id = "No id"; + start = "0"; + end = "0"; + } -public class PIRFile extends AlignFile { - Vector words = new Vector(); //Stores the words in a line after splitting + sequence = new StringBuffer(); - public PIRFile() { - } + line = nextLine(); // this is the title line - public PIRFile(String inStr) { - super(inStr); - } + boolean starFound = false; - public PIRFile(String inFile, String type) throws IOException { - super(inFile, type); - } + do + { + line = nextLine(); + sequence.append(line); - public void parse() { - try { - String id; - String start; - String end; - StringBuffer sequence; - String line = null; - - while ((line = nextLine()) != null) { - try { - id = line.substring(line.indexOf(";") + 1, line.indexOf("/")); - line = line.substring(line.indexOf("/") + 1); - start = line.substring(0, line.indexOf("-")); - end = line.substring(line.indexOf("-") + 1); - } catch (Exception ex) { - id = "No id"; - start = "0"; - end = "0"; - } - - sequence = new StringBuffer(); - - line = nextLine(); // this is the title line - - boolean starFound = false; - - do { - line = nextLine(); - sequence.append(line); - - if (line.indexOf("*") > -1) { - starFound = true; - } - } while (!starFound); - - sequence.setLength(sequence.length() - 1); - - Sequence newSeq = new Sequence(id, sequence.toString(), - Integer.parseInt(start), Integer.parseInt(end)); - seqs.addElement(newSeq); - } - } catch (Exception ex) { - ex.printStackTrace(); + if (line.indexOf("*") > -1) + { + starFound = true; + } } - } + while (!starFound); - public String print() { - return print(getSeqsAsArray()); - } + sequence.setLength(sequence.length() - 1); - public static String print(SequenceI[] s) { - return print(s, 72, true); + Sequence newSeq = new Sequence(id, sequence.toString(), + Integer.parseInt(start), + Integer.parseInt(end)); + seqs.addElement(newSeq); + } } - - public static String print(SequenceI[] s, int len) { - return print(s, len, true); + catch (Exception ex) + { + ex.printStackTrace(); } - - public static String print(SequenceI[] s, int len, boolean gaps) { - StringBuffer out = new StringBuffer(); - int i = 0; - - while ((i < s.length) && (s[i] != null)) { - String seq = ""; - - if (gaps) { - seq = s[i].getSequence() + "*"; - } else { - seq = AlignSeq.extractGaps(s[i].getSequence(), "-"); - seq = AlignSeq.extractGaps(seq, "."); - seq = AlignSeq.extractGaps(seq, " "); - seq = seq + "*"; - } - - out.append(">P1;" + s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd() + "\n"); - out.append(" Dummy title\n"); - - int nochunks = (seq.length() / len) + 1; - - for (int j = 0; j < nochunks; j++) { - int start = j * len; - int end = start + len; - - if (end < seq.length()) { - out.append(seq.substring(start, end) + "\n"); - } else if (start < seq.length()) { - out.append(seq.substring(start) + "\n"); - } - } - - i++; + } + + public String print() + { + return print(getSeqsAsArray()); + } + + public static String print(SequenceI[] s) + { + return print(s, 72, true); + } + + public static String print(SequenceI[] s, int len) + { + return print(s, len, true); + } + + public static String print(SequenceI[] s, int len, boolean gaps) + { + StringBuffer out = new StringBuffer(); + int i = 0; + + while ( (i < s.length) && (s[i] != null)) + { + String seq = ""; + + if (gaps) + { + seq = s[i].getSequence() + "*"; + } + else + { + seq = AlignSeq.extractGaps(s[i].getSequence(), "-"); + seq = AlignSeq.extractGaps(seq, "."); + seq = AlignSeq.extractGaps(seq, " "); + seq = seq + "*"; + } + + out.append(">P1;" + s[i].getName() + "/" + s[i].getStart() + "-" + + s[i].getEnd() + "\n"); + out.append(" Dummy title\n"); + + int nochunks = (seq.length() / len) + 1; + + for (int j = 0; j < nochunks; j++) + { + int start = j * len; + int end = start + len; + + if (end < seq.length()) + { + out.append(seq.substring(start, end) + "\n"); } + else if (start < seq.length()) + { + out.append(seq.substring(start) + "\n"); + } + } - return out.toString(); + i++; } - public static void main(String[] args) { - String inStr = ">P1;LCAT_MOUSE_90.35\nMGLPGSPWQRVLLLLGLLLPPATPFWLLNVLFPPHTTPKAELSNHTRPVILVPGCLGNRLEAKLDKPDVVNW\nMCYRKTEDFFTIWLDFNLFLPLGVDCWIDNTRIVYNHSSGRVSNAPGVQIRVPGFGKTESVEYVDDNKLAGY\n\n>LCAT_PAPAN_95.78\nMGPPGSPWQWVPLLLGLLLPPAAPFWLLNVLFPPHTTPKAELSNHTRPVILVPGCLGNQLEAKLDKPDVVNW\nMCYRKTEDFFTIWLDLNMFLPLGVDCWIDNTRVVYNRSSGLVSNAPGVQIRVPGFGKTYSVEYLDSSKLAGY\nLHTLVQNLVNNGYVRDETVRAAPYDWRLEPGQQEEYYHKLAGLVEEMHAAYGKPVFLIGHSLGCLHLLYFLL\n"; - PIRFile fa = new PIRFile(inStr); - } + return out.toString(); + } + + public static void main(String[] args) + { + String inStr = ">P1;LCAT_MOUSE_90.35\nMGLPGSPWQRVLLLLGLLLPPATPFWLLNVLFPPHTTPKAELSNHTRPVILVPGCLGNRLEAKLDKPDVVNW\nMCYRKTEDFFTIWLDFNLFLPLGVDCWIDNTRIVYNHSSGRVSNAPGVQIRVPGFGKTESVEYVDDNKLAGY\n\n>LCAT_PAPAN_95.78\nMGPPGSPWQWVPLLLGLLLPPAAPFWLLNVLFPPHTTPKAELSNHTRPVILVPGCLGNQLEAKLDKPDVVNW\nMCYRKTEDFFTIWLDLNMFLPLGVDCWIDNTRVVYNRSSGLVSNAPGVQIRVPGFGKTYSVEYLDSSKLAGY\nLHTLVQNLVNNGYVRDETVRAAPYDWRLEPGQQEEYYHKLAGLVEEMHAAYGKPVFLIGHSLGCLHLLYFLL\n"; + PIRFile fa = new PIRFile(inStr); + } } diff --git a/src/jalview/io/PfamFile.java b/src/jalview/io/PfamFile.java index b31a148..a6c7a4f 100755 --- a/src/jalview/io/PfamFile.java +++ b/src/jalview/io/PfamFile.java @@ -1,197 +1,237 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; -import jalview.datamodel.*; - -import jalview.util.*; - import java.io.*; - import java.util.*; +import jalview.datamodel.*; +import jalview.util.*; -public class PfamFile extends AlignFile { - Vector ids; +public class PfamFile + extends AlignFile +{ + Vector ids; + + public PfamFile() + { + } + + public PfamFile(String inStr) + { + super(inStr); + } + + public PfamFile(String inFile, String type) + throws IOException + { + super(inFile, type); + } + + public void initData() + { + super.initData(); + ids = new Vector(); + } + + public void parse() + throws IOException + { + int i = 0; + String line; + + Hashtable seqhash = new Hashtable(); + Vector headers = new Vector(); + + while ( (line = nextLine()) != null) + { + if (line.indexOf(" ") != 0) + { + if (line.indexOf("#") != 0) + { + StringTokenizer str = new StringTokenizer(line, " "); + String id = ""; + + if (str.hasMoreTokens()) + { + id = str.nextToken(); + + StringBuffer tempseq; + + if (seqhash.containsKey(id)) + { + tempseq = (StringBuffer) seqhash.get(id); + } + else + { + tempseq = new StringBuffer(); + seqhash.put(id, tempseq); + } - public PfamFile() { - } + if (! (headers.contains(id))) + { + headers.addElement(id); + } - public PfamFile(String inStr) { - super(inStr); + tempseq.append(str.nextToken()); + } + } + } } - public PfamFile(String inFile, String type) throws IOException { - super(inFile, type); - } + this.noSeqs = headers.size(); - public void initData() { - super.initData(); - ids = new Vector(); + if (noSeqs < 1) + { + throw new IOException("No sequences found (PFAM input)"); } - public void parse() throws IOException { - int i = 0; - String line; - - Hashtable seqhash = new Hashtable(); - Vector headers = new Vector(); - - while ((line = nextLine()) != null) { - if (line.indexOf(" ") != 0) { - if (line.indexOf("#") != 0) { - StringTokenizer str = new StringTokenizer(line, " "); - String id = ""; + for (i = 0; i < headers.size(); i++) + { + if (seqhash.get(headers.elementAt(i)) != null) + { + if (maxLength < seqhash.get(headers.elementAt(i)).toString() + .length()) + { + maxLength = seqhash.get(headers.elementAt(i)).toString() + .length(); + } - if (str.hasMoreTokens()) { - id = str.nextToken(); + String head = headers.elementAt(i).toString(); + int start = 1; + int end = seqhash.get(headers.elementAt(i)).toString().length(); - StringBuffer tempseq; + if (head.indexOf("/") > 0) + { + StringTokenizer st = new StringTokenizer(head, "/"); - if (seqhash.containsKey(id)) { - tempseq = (StringBuffer) seqhash.get(id); - } else { - tempseq = new StringBuffer(); - seqhash.put(id, tempseq); - } + if (st.countTokens() == 2) + { + ids.addElement(st.nextToken()); - if (!(headers.contains(id))) { - headers.addElement(id); - } + String tmp = st.nextToken(); + st = new StringTokenizer(tmp, "-"); - tempseq.append(str.nextToken()); - } - } + if (st.countTokens() == 2) + { + start = Integer.valueOf(st.nextToken()).intValue(); + end = Integer.valueOf(st.nextToken()).intValue(); + } + else + { + start = -1; + end = -1; } + } + else + { + ids.addElement(headers.elementAt(i)); + } + } + else + { + ids.addElement(headers.elementAt(i)); } - this.noSeqs = headers.size(); + Sequence newSeq = null; - if (noSeqs < 1) { - throw new IOException("No sequences found (PFAM input)"); + if ( (start != -1) && (end != -1)) + { + newSeq = new Sequence(ids.elementAt(i).toString(), + seqhash.get(headers.elementAt(i).toString()) + .toString(), start, end); + seqs.addElement(newSeq); + } + else + { + newSeq = new Sequence(ids.elementAt(i).toString(), + seqhash.get(headers.elementAt(i).toString()) + .toString(), 1, + seqhash.get(headers.elementAt(i).toString()) + .toString().length()); + seqs.addElement(newSeq); } - for (i = 0; i < headers.size(); i++) { - if (seqhash.get(headers.elementAt(i)) != null) { - if (maxLength < seqhash.get(headers.elementAt(i)).toString() - .length()) { - maxLength = seqhash.get(headers.elementAt(i)).toString() - .length(); - } - - String head = headers.elementAt(i).toString(); - int start = 1; - int end = seqhash.get(headers.elementAt(i)).toString().length(); - - if (head.indexOf("/") > 0) { - StringTokenizer st = new StringTokenizer(head, "/"); - - if (st.countTokens() == 2) { - ids.addElement(st.nextToken()); - - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); - - if (st.countTokens() == 2) { - start = Integer.valueOf(st.nextToken()).intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } else { - start = -1; - end = -1; - } - } else { - ids.addElement(headers.elementAt(i)); - } - } else { - ids.addElement(headers.elementAt(i)); - } - - Sequence newSeq = null; - - if ((start != -1) && (end != -1)) { - newSeq = new Sequence(ids.elementAt(i).toString(), - seqhash.get(headers.elementAt(i).toString()) - .toString(), start, end); - seqs.addElement(newSeq); - } else { - newSeq = new Sequence(ids.elementAt(i).toString(), - seqhash.get(headers.elementAt(i).toString()) - .toString(), 1, - seqhash.get(headers.elementAt(i).toString()) - .toString().length()); - seqs.addElement(newSeq); - } - - if (!isValidProteinSequence(newSeq.getSequence())) { - throw new IOException( - "Not a valid protein sequence - (PFAM input)"); - } - } else { - System.err.println("PFAM File reader: Can't find sequence for " + - headers.elementAt(i)); - } + if (!isValidProteinSequence(newSeq.getSequence())) + { + throw new IOException( + "Not a valid protein sequence - (PFAM input)"); } + } + else + { + System.err.println("PFAM File reader: Can't find sequence for " + + headers.elementAt(i)); + } } + } - public static String print(SequenceI[] s) { - StringBuffer out = new StringBuffer(""); + public static String print(SequenceI[] s) + { + StringBuffer out = new StringBuffer(""); - int max = 0; - int maxid = 0; + int max = 0; + int maxid = 0; - int i = 0; + int i = 0; - while ((i < s.length) && (s[i] != null)) { - String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd(); + while ( (i < s.length) && (s[i] != null)) + { + String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + + s[i].getEnd(); - if (s[i].getSequence().length() > max) { - max = s[i].getSequence().length(); - } + if (s[i].getSequence().length() > max) + { + max = s[i].getSequence().length(); + } - if (tmp.length() > maxid) { - maxid = tmp.length(); - } + if (tmp.length() > maxid) + { + maxid = tmp.length(); + } - i++; - } + i++; + } - if (maxid < 15) { - maxid = 15; - } + if (maxid < 15) + { + maxid = 15; + } - int j = 0; + int j = 0; - while ((j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(s[j].getName() + - "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); + while ( (j < s.length) && (s[j] != null)) + { + out.append(new Format("%-" + maxid + "s").form(s[j].getName() + + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); - out.append(s[j].getSequence() + "\n"); - j++; - } + out.append(s[j].getSequence() + "\n"); + j++; + } - out.append("\n"); + out.append("\n"); - return out.toString(); - } + return out.toString(); + } - public String print() { - return print(getSeqsAsArray()); - } + public String print() + { + return print(getSeqsAsArray()); + } } diff --git a/src/jalview/io/PileUpfile.java b/src/jalview/io/PileUpfile.java index 9f879c0..1cb5b43 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -1,276 +1,327 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.io; - -/** - *

Title:

- * PileUpfile - *

Description:

- * - * Read and write PileUp style MSF Files. - * This used to be the MSFFile class, and was written according to the EBI's idea - * of a subset of the MSF alignment format. But, that was updated to reflect current - * GCG style IO fashion, as found in Emboss (thanks David Martin!) - * +/** + *

Title:

+ * PileUpfile + *

Description:

+ * + * Read and write PileUp style MSF Files. + * This used to be the MSFFile class, and was written according to the EBI's idea + * of a subset of the MSF alignment format. But, that was updated to reflect current + * GCG style IO fashion, as found in Emboss (thanks David Martin!) + * **/ -import jalview.datamodel.*; - -import jalview.util.*; - import java.io.*; - import java.util.*; +import jalview.datamodel.*; +import jalview.util.*; -public class PileUpfile extends AlignFile { - public PileUpfile() { - } - - public PileUpfile(String inStr) { - super(inStr); - } - - public PileUpfile(String inFile, String type) throws IOException { - super(inFile, type); - } +public class PileUpfile + extends AlignFile +{ + public PileUpfile() + { + } + + public PileUpfile(String inStr) + { + super(inStr); + } + + public PileUpfile(String inFile, String type) + throws IOException + { + super(inFile, type); + } + + public void parse() + { + int i = 0; + boolean seqFlag = false; + String key = new String(); + Vector headers = new Vector(); + Hashtable seqhash = new Hashtable(); + String line; + + try + { + while ( (line = nextLine()) != null) + { + StringTokenizer str = new StringTokenizer(line); + + while (str.hasMoreTokens()) + { + String inStr = str.nextToken(); + + //If line has header information add to the headers vector + if (inStr.indexOf("Name:") != -1) + { + key = str.nextToken(); + headers.addElement(key); + } + + //if line has // set SeqFlag to 1 so we know sequences are coming + if (inStr.indexOf("//") != -1) + { + seqFlag = true; + } + + //Process lines as sequence lines if seqFlag is set + if ( (inStr.indexOf("//") == -1) && (seqFlag == true)) + { + //seqeunce id is the first field + key = inStr; + + StringBuffer tempseq; + + //Get sequence from hash if it exists + if (seqhash.containsKey(key)) + { + tempseq = (StringBuffer) seqhash.get(key); + } + else + { + tempseq = new StringBuffer(); + seqhash.put(key, tempseq); + } - public void parse() { - int i = 0; - boolean seqFlag = false; - String key = new String(); - Vector headers = new Vector(); - Hashtable seqhash = new Hashtable(); - String line; - - try { - while ((line = nextLine()) != null) { - StringTokenizer str = new StringTokenizer(line); - - while (str.hasMoreTokens()) { - String inStr = str.nextToken(); - - //If line has header information add to the headers vector - if (inStr.indexOf("Name:") != -1) { - key = str.nextToken(); - headers.addElement(key); - } - - //if line has // set SeqFlag to 1 so we know sequences are coming - if (inStr.indexOf("//") != -1) { - seqFlag = true; - } - - //Process lines as sequence lines if seqFlag is set - if ((inStr.indexOf("//") == -1) && (seqFlag == true)) { - //seqeunce id is the first field - key = inStr; - - StringBuffer tempseq; - - //Get sequence from hash if it exists - if (seqhash.containsKey(key)) { - tempseq = (StringBuffer) seqhash.get(key); - } else { - tempseq = new StringBuffer(); - seqhash.put(key, tempseq); - } - - //loop through the rest of the words - while (str.hasMoreTokens()) { - //append the word to the sequence - tempseq.append(str.nextToken()); - } - } - } + //loop through the rest of the words + while (str.hasMoreTokens()) + { + //append the word to the sequence + tempseq.append(str.nextToken()); } - } catch (IOException e) { - System.err.println("Exception parsing PileUpfile " + e); - e.printStackTrace(); + } } + } + } + catch (IOException e) + { + System.err.println("Exception parsing PileUpfile " + e); + e.printStackTrace(); + } - this.noSeqs = headers.size(); - - //Add sequences to the hash - for (i = 0; i < headers.size(); i++) { - if (seqhash.get(headers.elementAt(i)) != null) { - String head = headers.elementAt(i).toString(); - String seq = seqhash.get(head).toString(); - - int start = 1; - int end = seq.length(); + this.noSeqs = headers.size(); - if (maxLength < head.length()) { - maxLength = head.length(); - } + //Add sequences to the hash + for (i = 0; i < headers.size(); i++) + { + if (seqhash.get(headers.elementAt(i)) != null) + { + String head = headers.elementAt(i).toString(); + String seq = seqhash.get(head).toString(); - if (head.indexOf("/") > 0) { - StringTokenizer st = new StringTokenizer(head, "/"); + int start = 1; + int end = seq.length(); - if (st.countTokens() == 2) { - head = st.nextToken(); + if (maxLength < head.length()) + { + maxLength = head.length(); + } - String tmp = st.nextToken(); - st = new StringTokenizer(tmp, "-"); + if (head.indexOf("/") > 0) + { + StringTokenizer st = new StringTokenizer(head, "/"); - if (st.countTokens() == 2) { - start = Integer.valueOf(st.nextToken()).intValue(); - end = Integer.valueOf(st.nextToken()).intValue(); - } - } - } + if (st.countTokens() == 2) + { + head = st.nextToken(); - Sequence newSeq = new Sequence(head, seq, start, end); + String tmp = st.nextToken(); + st = new StringTokenizer(tmp, "-"); - seqs.addElement(newSeq); - } else { - System.err.println( - "PileUpfile Parser: Can't find sequence for " + - headers.elementAt(i)); + if (st.countTokens() == 2) + { + start = Integer.valueOf(st.nextToken()).intValue(); + end = Integer.valueOf(st.nextToken()).intValue(); } + } } - } - public static int checkSum(String seq) { - //String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.*~&@"; - int check = 0; - - String index = "--------------------------------------&---*---.-----------------@ABCDEFGHIJKLMNOPQRSTUVWXYZ------ABCDEFGHIJKLMNOPQRSTUVWXYZ----@"; - index += "--------------------------------------------------------------------------------------------------------------------------------"; - - for (int i = 0; i < seq.length(); i++) { - try { - if (i < seq.length()) { - int pos = index.indexOf(seq.substring(i, i + 1)); - - if (!index.substring(pos, pos + 1).equals("_")) { - check += (((i % 57) + 1) * pos); - } - } - } catch (Exception e) { - System.err.println("Exception during MSF Checksum calculation"); - e.printStackTrace(); - } - } + Sequence newSeq = new Sequence(head, seq, start, end); - return check % 10000; + seqs.addElement(newSeq); + } + else + { + System.err.println( + "PileUpfile Parser: Can't find sequence for " + + headers.elementAt(i)); + } + } + } + + public static int checkSum(String seq) + { + //String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.*~&@"; + int check = 0; + + String index = "--------------------------------------&---*---.-----------------@ABCDEFGHIJKLMNOPQRSTUVWXYZ------ABCDEFGHIJKLMNOPQRSTUVWXYZ----@"; + index += "--------------------------------------------------------------------------------------------------------------------------------"; + + for (int i = 0; i < seq.length(); i++) + { + try + { + if (i < seq.length()) + { + int pos = index.indexOf(seq.substring(i, i + 1)); + + if (!index.substring(pos, pos + 1).equals("_")) + { + check += ( ( (i % 57) + 1) * pos); + } + } + } + catch (Exception e) + { + System.err.println("Exception during MSF Checksum calculation"); + e.printStackTrace(); + } } - public static String print(SequenceI[] s) { - StringBuffer out = new StringBuffer("PileUp\n\n"); + return check % 10000; + } - int max = 0; - int maxid = 0; + public static String print(SequenceI[] s) + { + StringBuffer out = new StringBuffer("PileUp\n\n"); - int i = 0; - String big = ""; + int max = 0; + int maxid = 0; - while ((i < s.length) && (s[i] != null)) { - big += s[i].getSequence(); - i++; - } + int i = 0; + String big = ""; - i = 0; + while ( (i < s.length) && (s[i] != null)) + { + big += s[i].getSequence(); + i++; + } - int bigcheck = checkSum(big); + i = 0; - out.append(" MSF: " + s[0].getSequence().length() + - " Type: P Check: " + bigcheck + " ..\n\n\n"); + int bigcheck = checkSum(big); - while ((i < s.length) && (s[i] != null)) { - String seq = s[i].getSequence(); - String name = s[i].getName() + "/" + s[i].getStart() + "-" + - s[i].getEnd(); - int check = checkSum(s[i].getSequence()); - out.append(" Name: " + name + " oo Len: " + - s[i].getSequence().length() + " Check: " + check + - " Weight: 1.00\n"); + out.append(" MSF: " + s[0].getSequence().length() + + " Type: P Check: " + bigcheck + " ..\n\n\n"); - if (seq.length() > max) { - max = seq.length(); - } + while ( (i < s.length) && (s[i] != null)) + { + String seq = s[i].getSequence(); + String name = s[i].getName() + "/" + s[i].getStart() + "-" + + s[i].getEnd(); + int check = checkSum(s[i].getSequence()); + out.append(" Name: " + name + " oo Len: " + + s[i].getSequence().length() + " Check: " + check + + " Weight: 1.00\n"); - if (name.length() > maxid) { - maxid = name.length(); - } + if (seq.length() > max) + { + max = seq.length(); + } - i++; - } + if (name.length() > maxid) + { + maxid = name.length(); + } - if (maxid < 10) { - maxid = 10; - } + i++; + } - maxid++; - out.append("\n\n//\n\n"); + if (maxid < 10) + { + maxid = 10; + } - int len = 50; + maxid++; + out.append("\n\n//\n\n"); - int nochunks = (max / len) + 1; + int len = 50; - if ((max % len) == 0) { - nochunks--; - } + int nochunks = (max / len) + 1; - for (i = 0; i < nochunks; i++) { - int j = 0; - - while ((j < s.length) && (s[j] != null)) { - String name = s[j].getName(); - out.append(new Format("%-" + maxid + "s").form(name + "/" + - s[j].getStart() + "-" + s[j].getEnd()) + " "); - - for (int k = 0; k < 5; k++) { - int start = (i * 50) + (k * 10); - int end = start + 10; - - if ((end < s[j].getSequence().length()) && - (start < s[j].getSequence().length())) { - out.append(s[j].getSequence().substring(start, end)); - - if (k < 4) { - out.append(" "); - } else { - out.append("\n"); - } - } else { - if (start < s[j].getSequence().length()) { - out.append(s[j].getSequence().substring(start)); - out.append("\n"); - } else { - if (k == 0) { - out.append("\n"); - } - } - } - } - - j++; - } + if ( (max % len) == 0) + { + nochunks--; + } - out.append("\n"); + for (i = 0; i < nochunks; i++) + { + int j = 0; + + while ( (j < s.length) && (s[j] != null)) + { + String name = s[j].getName(); + out.append(new Format("%-" + maxid + "s").form(name + "/" + + s[j].getStart() + "-" + s[j].getEnd()) + " "); + + for (int k = 0; k < 5; k++) + { + int start = (i * 50) + (k * 10); + int end = start + 10; + + if ( (end < s[j].getSequence().length()) && + (start < s[j].getSequence().length())) + { + out.append(s[j].getSequence().substring(start, end)); + + if (k < 4) + { + out.append(" "); + } + else + { + out.append("\n"); + } + } + else + { + if (start < s[j].getSequence().length()) + { + out.append(s[j].getSequence().substring(start)); + out.append("\n"); + } + else + { + if (k == 0) + { + out.append("\n"); + } + } + } } - return out.toString(); - } + j++; + } - public String print() { - return print(getSeqsAsArray()); + out.append("\n"); } + + return out.toString(); + } + + public String print() + { + return print(getSeqsAsArray()); + } } diff --git a/src/jalview/io/SequenceFeatureFetcher.java b/src/jalview/io/SequenceFeatureFetcher.java index cdd628b..89d84b0 100755 --- a/src/jalview/io/SequenceFeatureFetcher.java +++ b/src/jalview/io/SequenceFeatureFetcher.java @@ -29,14 +29,28 @@ import java.io.*; import java.util.*; -public class SequenceFeatureFetcher implements Runnable { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class SequenceFeatureFetcher implements Runnable +{ AlignmentI align; AlignmentPanel ap; ArrayList unknownSequences; CutAndPasteTransfer output = new CutAndPasteTransfer(); StringBuffer sbuffer = new StringBuffer(); - public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap) { + /** + * Creates a new SequenceFeatureFetcher object. + * + * @param align DOCUMENT ME! + * @param ap DOCUMENT ME! + */ + public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap) + { unknownSequences = new ArrayList(); this.align = align; this.ap = ap; @@ -45,28 +59,38 @@ public class SequenceFeatureFetcher implements Runnable { thread.start(); } - public void run() { - + /** + * DOCUMENT ME! + */ + public void run() + { RandomAccessFile out = null; - try { - String cache = System.getProperty("user.home") + "/.jalview.uniprot.xml"; + try + { + String cache = System.getProperty("user.home") + + "/.jalview.uniprot.xml"; File test = new File(cache); - if (!test.exists()) { + if (!test.exists()) + { out = new RandomAccessFile(cache, "rw"); out.writeBytes("\n"); out.writeBytes("\n"); - } else { + } + else + { out = new RandomAccessFile(cache, "rw"); // open exisiting cache and remove from the end long lastLine = 0; String data; - while ((data = out.readLine()) != null) { - if (data.indexOf("") > -1) { + while ((data = out.readLine()) != null) + { + if (data.indexOf("") > -1) + { lastLine = out.getFilePointer(); } } @@ -77,18 +101,21 @@ public class SequenceFeatureFetcher implements Runnable { int seqIndex = 0; Vector sequences = align.getSequences(); - while (seqIndex < sequences.size()) { + while (seqIndex < sequences.size()) + { ArrayList ids = new ArrayList(); for (int i = 0; (seqIndex < sequences.size()) && (i < 50); - seqIndex++, i++) { + seqIndex++, i++) + { SequenceI sequence = (SequenceI) sequences.get(seqIndex); ids.add(sequence.getName()); } tryLocalCacheFirst(ids, align); - if (ids.size() > 0) { + if (ids.size() > 0) + { StringBuffer remainingIds = new StringBuffer("uniprot:"); for (int i = 0; i < ids.size(); i++) @@ -98,23 +125,28 @@ public class SequenceFeatureFetcher implements Runnable { String[] result = ebi.fetchData(remainingIds.toString(), "xml", null); - if (result != null) { + if (result != null) + { ReadUniprotFile(result, out, align); } } } - if (out != null) { + if (out != null) + { out.writeBytes("\n"); out.close(); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } findMissingIds(align); - if (sbuffer.length() > 0) { + if (sbuffer.length() > 0) + { output.setText( "Your sequences have been matched to Uniprot. Some of the ids have been\n" + "altered, most likely the start/end residue will have been updated.\n" + @@ -123,7 +155,8 @@ public class SequenceFeatureFetcher implements Runnable { Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300); } - if (unknownSequences.size() > 0) { + if (unknownSequences.size() > 0) + { //ignore for now!!!!!!!!!! // WSWUBlastClient blastClient = new WSWUBlastClient(align, unknownSequences); } @@ -131,7 +164,15 @@ public class SequenceFeatureFetcher implements Runnable { jalview.gui.PaintRefresher.Refresh(null, align); } - void ReadUniprotFile(String[] result, RandomAccessFile out, AlignmentI align) { + /** + * DOCUMENT ME! + * + * @param result DOCUMENT ME! + * @param out DOCUMENT ME! + * @param align DOCUMENT ME! + */ + void ReadUniprotFile(String[] result, RandomAccessFile out, AlignmentI align) + { SequenceI sequence = null; Vector features = null; String type; @@ -141,42 +182,54 @@ public class SequenceFeatureFetcher implements Runnable { String end; String pdb = null; - for (int r = 0; r < result.length; r++) { - if ((sequence == null) && (result[r].indexOf("") > -1)) { + for (int r = 0; r < result.length; r++) + { + if ((sequence == null) && (result[r].indexOf("") > -1)) + { long filePointer = 0; - if (out != null) { - try { + if (out != null) + { + try + { filePointer = out.getFilePointer(); out.writeBytes("\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } String seqName = parseElement(result[r], "", out); sequence = align.findName(seqName); - if (sequence == null) { + if (sequence == null) + { sequence = align.findName(seqName.substring(0, seqName.indexOf('_'))); - if (sequence != null) { + if (sequence != null) + { sbuffer.append("changing " + sequence.getName() + " to " + seqName + "\n"); sequence.setName(seqName); } } - if (sequence == null) { + if (sequence == null) + { sbuffer.append("UNIPROT updated suggestion is " + result[r] + "\n"); sequence = align.findName(result[r]); // this entry has been suggested by ebi. // doesn't match id in alignment file - try { + try + { out.setLength(filePointer); - } catch (Exception ex) { + } + catch (Exception ex) + { } // now skip to next entry @@ -193,29 +246,36 @@ public class SequenceFeatureFetcher implements Runnable { pdb = ""; } - if (sequence == null) { + if (sequence == null) + { continue; } - if (result[r].indexOf(" -1) { + if (result[r].indexOf(" -1) + { pdb = parseValue(result[r], "value=", out); sequence.setPDBId(pdb); } - if (result[r].indexOf("feature type") > -1) { + if (result[r].indexOf("feature type") > -1) + { type = parseValue(result[r], "type=", out); description = parseValue(result[r], "description=", null); status = parseValue(result[r], "status=", null); - while (result[r].indexOf("position") == -1) { + while (result[r].indexOf("position") == -1) + { r++; // } // r++; - if (result[r].indexOf("begin") > -1) { + if (result[r].indexOf("begin") > -1) + { start = parseValue(result[r], "position=", out); end = parseValue(result[++r], "position=", out); - } else { + } + else + { start = parseValue(result[r], "position=", out); end = parseValue(result[r], "position=", null); } @@ -223,10 +283,14 @@ public class SequenceFeatureFetcher implements Runnable { int sstart = Integer.parseInt(start); int eend = Integer.parseInt(end); - if (out != null) { - try { + if (out != null) + { + try + { out.writeBytes("\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } @@ -235,45 +299,62 @@ public class SequenceFeatureFetcher implements Runnable { features.add(sf); } - if (result[r].indexOf(" -1) { + if (result[r].indexOf(" -1) + { StringBuffer seqString = new StringBuffer(); - if (out != null) { - try { + if (out != null) + { + try + { out.writeBytes(result[r] + "\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } - while (result[++r].indexOf("") == -1) { + while (result[++r].indexOf("") == -1) + { seqString.append(result[r]); - if (out != null) { - try { + if (out != null) + { + try + { out.writeBytes(result[r] + "\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } } - if (out != null) { - try { + if (out != null) + { + try + { out.writeBytes(result[r] + "\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } StringBuffer nonGapped = new StringBuffer(); - for (int i = 0; i < sequence.getSequence().length(); i++) { - if (!jalview.util.Comparison.isGap(sequence.getCharAt(i))) { + for (int i = 0; i < sequence.getSequence().length(); i++) + { + if (!jalview.util.Comparison.isGap(sequence.getCharAt(i))) + { nonGapped.append(sequence.getCharAt(i)); } } int absStart = seqString.toString().indexOf(nonGapped.toString()); - if (absStart == -1) { + if (absStart == -1) + { unknownSequences.add(sequence.getName()); features = null; sbuffer.append(sequence.getName() + @@ -286,7 +367,8 @@ public class SequenceFeatureFetcher implements Runnable { absStart += 1; if ((absStart != sequence.getStart()) || - (absEnd != sequence.getEnd())) { + (absEnd != sequence.getEnd())) + { sbuffer.append("Updated: " + sequence.getName() + " " + sequence.getStart() + "/" + sequence.getEnd() + " to " + absStart + "/" + absEnd + "\n"); @@ -296,52 +378,78 @@ public class SequenceFeatureFetcher implements Runnable { sequence.setEnd(absEnd); } - if (result[r].indexOf("") > -1) { - if (features != null) { + if (result[r].indexOf("") > -1) + { + if (features != null) + { sequence.setSequenceFeatures(features); } features = null; sequence = null; - if (out != null) { - try { + if (out != null) + { + try + { out.writeBytes("\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } } } } - void findMissingIds(AlignmentI align) { + /** + * DOCUMENT ME! + * + * @param align DOCUMENT ME! + */ + void findMissingIds(AlignmentI align) + { String data; ArrayList cachedIds = new ArrayList(); - try { + try + { BufferedReader in = new BufferedReader(new FileReader( jalview.bin.Cache.getProperty("UNIPROT_CACHE"))); - while ((data = in.readLine()) != null) { - if (data.indexOf("name") > -1) { + while ((data = in.readLine()) != null) + { + if (data.indexOf("name") > -1) + { String name = parseElement(data, "", null); cachedIds.add(name); } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } for (int i = 0; i < align.getHeight(); i++) - if (!cachedIds.contains(align.getSequenceAt(i).getName())) { + if (!cachedIds.contains(align.getSequenceAt(i).getName())) + { unknownSequences.add(align.getSequenceAt(i).getName()); } } - void tryLocalCacheFirst(ArrayList ids, AlignmentI align) { + /** + * DOCUMENT ME! + * + * @param ids DOCUMENT ME! + * @param align DOCUMENT ME! + */ + void tryLocalCacheFirst(ArrayList ids, AlignmentI align) + { ArrayList cacheData = new ArrayList(); - try { + try + { BufferedReader in = new BufferedReader(new FileReader( jalview.bin.Cache.getProperty("UNIPROT_CACHE"))); @@ -350,15 +458,19 @@ public class SequenceFeatureFetcher implements Runnable { // make sure we remove the ids from the list to retrieve from EBI String data; - while ((data = in.readLine()) != null) { - if (data.indexOf("name") > -1) { + while ((data = in.readLine()) != null) + { + if (data.indexOf("name") > -1) + { String name = parseElement(data, "", null); - if (ids.contains(name)) { + if (ids.contains(name)) + { cacheData.add(""); cacheData.add(data); - while (data.indexOf("") == -1) { + while (data.indexOf("") == -1) + { data = in.readLine(); cacheData.add(data); } @@ -369,40 +481,72 @@ public class SequenceFeatureFetcher implements Runnable { } } } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } String[] localData = new String[cacheData.size()]; cacheData.toArray(localData); - if ((localData != null) && (localData.length > 0)) { + if ((localData != null) && (localData.length > 0)) + { ReadUniprotFile(localData, null, align); } } - String parseValue(String line, String tag, RandomAccessFile out) { - if (out != null) { - try { + /** + * DOCUMENT ME! + * + * @param line DOCUMENT ME! + * @param tag DOCUMENT ME! + * @param out DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + String parseValue(String line, String tag, RandomAccessFile out) + { + if (out != null) + { + try + { out.writeBytes(line + "\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } int index = line.indexOf(tag) + tag.length() + 1; - if (index == tag.length()) { + if (index == tag.length()) + { return ""; } return line.substring(index, line.indexOf("\"", index + 1)); } - String parseElement(String line, String tag, RandomAccessFile out) { - if (out != null) { - try { + /** + * DOCUMENT ME! + * + * @param line DOCUMENT ME! + * @param tag DOCUMENT ME! + * @param out DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + String parseElement(String line, String tag, RandomAccessFile out) + { + if (out != null) + { + try + { out.writeBytes(line + "\n"); - } catch (Exception ex) { + } + catch (Exception ex) + { } } diff --git a/src/jalview/io/WSWUBlastClient.java b/src/jalview/io/WSWUBlastClient.java index 29a0900..33d6d92 100755 --- a/src/jalview/io/WSWUBlastClient.java +++ b/src/jalview/io/WSWUBlastClient.java @@ -33,23 +33,40 @@ import javax.swing.*; import javax.xml.namespace.QName; -public class WSWUBlastClient { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class WSWUBlastClient +{ CutAndPasteTransfer output = new CutAndPasteTransfer(); int jobsRunning = 0; - public WSWUBlastClient(AlignmentI al, ArrayList ids) { + /** + * Creates a new WSWUBlastClient object. + * + * @param al DOCUMENT ME! + * @param ids DOCUMENT ME! + */ + public WSWUBlastClient(AlignmentI al, ArrayList ids) + { output.setText( "To display sequence features an exact Uniprot id with 100% sequence identity match must be entered." + "\nIn order to display these features, try changing the names of your sequences to the ids suggested below."); Desktop.addInternalFrame(output, "BLASTing for unidentified sequences ", 800, 300); - for (int i = 0; i < ids.size(); i++) { + for (int i = 0; i < ids.size(); i++) + { SequenceI sequence = al.findName(ids.get(i).toString()); StringBuffer nonGapped = new StringBuffer(); - for (int n = 0; n < sequence.getSequence().length(); n++) { - if (!jalview.util.Comparison.isGap(sequence.getCharAt(n))) { + for (int n = 0; n < sequence.getSequence().length(); n++) + { + if (!jalview.util.Comparison.isGap(sequence.getCharAt(n))) + { nonGapped.append(sequence.getCharAt(n)); } } @@ -64,29 +81,41 @@ public class WSWUBlastClient { thread.start(); } - void parseResult(String id1, String res) { + /** + * DOCUMENT ME! + * + * @param id1 DOCUMENT ME! + * @param res DOCUMENT ME! + */ + void parseResult(String id1, String res) + { StringTokenizer st = new StringTokenizer(res, "\n"); String data; String id2; int maxFound = 90; StringBuffer buffer = new StringBuffer("\n\n" + id1 + " :"); - while (st.hasMoreTokens()) { + while (st.hasMoreTokens()) + { data = st.nextToken(); - if (data.indexOf("database=\"uniprot\" id=") > -1) { + if (data.indexOf("database=\"uniprot\" id=") > -1) + { int index = data.indexOf("database=\"uniprot\" id=") + 23; id2 = data.substring(index, data.indexOf("\"", index)); - while (data.indexOf("") == -1) { + while (data.indexOf("") == -1) + { data = st.nextToken(); - if (data.indexOf("") > -1) { + if (data.indexOf("") > -1) + { int value = Integer.parseInt(data.substring(data.indexOf( "") + 10, data.indexOf(""))); - if (value >= maxFound) { + if (value >= maxFound) + { maxFound = value; buffer.append(" " + id2 + " " + value + "%; "); } @@ -98,65 +127,81 @@ public class WSWUBlastClient { output.setText(output.getText() + buffer.toString()); } - class ImageTwirler extends Thread { + class ImageTwirler extends Thread + { ImageIcon[] imageIcon; int imageIndex = 0; - public ImageTwirler() { + public ImageTwirler() + { imageIcon = new ImageIcon[9]; - for (int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) + { java.net.URL url = getClass().getResource("/images/dna" + (i + 1) + ".gif"); - if (url != null) { + if (url != null) + { imageIcon[i] = new ImageIcon(url); } } } - public void run() { - while (jobsRunning > 0) { - try { + public void run() + { + while (jobsRunning > 0) + { + try + { Thread.sleep(100); imageIndex++; imageIndex %= 9; output.setFrameIcon(imageIcon[imageIndex]); output.setTitle("BLASTing for unidentified sequences - " + jobsRunning + " jobs running."); - } catch (Exception ex) { + } + catch (Exception ex) + { } } } } - class BlastThread extends Thread { + class BlastThread extends Thread + { String sequence; String seqid; String jobid; boolean jobComplete = false; - BlastThread(String id, String sequence) { + BlastThread(String id, String sequence) + { this.sequence = sequence; seqid = id; } - public void run() { + public void run() + { StartJob(); - while (!jobComplete) { - try { + while (!jobComplete) + { + try + { Call call = (Call) new Service().createCall(); call.setTargetEndpointAddress(new java.net.URL( "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast")); call.setOperationName(new QName("WSWUBlast", "polljob")); - String result = (String) call.invoke(new Object[] { + String result = (String) call.invoke(new Object[] + { jobid, "xml" }); if ((result.indexOf("JOB PENDING") == -1) && - (result.indexOf("JOB RUNNING") == -1)) { + (result.indexOf("JOB RUNNING") == -1)) + { parseResult(seqid, result); jobComplete = true; jobsRunning--; @@ -165,12 +210,15 @@ public class WSWUBlastClient { Thread.sleep(5000); // System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug - } catch (Exception ex) { + } + catch (Exception ex) + { } } } - void StartJob() { + void StartJob() + { HashMap params = new HashMap(); params.put("database", "uniprot"); params.put("sensitivity", "low"); @@ -183,20 +231,24 @@ public class WSWUBlastClient { byte[] seqbytes = sequence.getBytes(); - try { + try + { Call call = (Call) new Service().createCall(); call.setTargetEndpointAddress(new java.net.URL( "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast")); call.setOperationName(new QName("WSWUBlast", "doWUBlast")); - String result = (String) call.invoke(new Object[] { + String result = (String) call.invoke(new Object[] + { params, seqbytes }); jobid = result; System.out.println( "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast JobId '" + jobid + "'"); - } catch (Exception exp) { + } + catch (Exception exp) + { System.err.println("WSWUBlastClient error:\n" + exp.toString()); exp.printStackTrace(); } diff --git a/src/jalview/jbappletgui/GAlignFrame.java b/src/jalview/jbappletgui/GAlignFrame.java index a401b6e..7775b65 100755 --- a/src/jalview/jbappletgui/GAlignFrame.java +++ b/src/jalview/jbappletgui/GAlignFrame.java @@ -229,20 +229,20 @@ public class GAlignFrame extends Frame { pairwiseAlignmentMenuItem_actionPerformed(e); } }); - PCAMenuItem.setLabel("Principal Component Analysis..."); + PCAMenuItem.setLabel("Principal Component Analysis"); PCAMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { PCAMenuItem_actionPerformed(e); } }); averageDistanceTreeMenuItem.setLabel( - "Average Distance Using % Identity..."); + "Average Distance Using % Identity"); averageDistanceTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { averageDistanceTreeMenuItem_actionPerformed(e); } }); - neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity..."); + neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity"); neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { neighbourTreeMenuItem_actionPerformed(e); @@ -321,13 +321,13 @@ public class GAlignFrame extends Frame { } }); avDistanceTreeBlosumMenuItem.setLabel( - "Average Distance Using BLOSUM62..."); + "Average Distance Using BLOSUM62"); avDistanceTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { avTreeBlosumMenuItem_actionPerformed(e); } }); - njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62..."); + njTreeBlosumMenuItem.setLabel("Neighbour Joining Using BLOSUM62"); njTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { njTreeBlosumMenuItem_actionPerformed(e); @@ -347,7 +347,7 @@ public class GAlignFrame extends Frame { colourTextMenuItem_actionPerformed(null); } }); - overviewMenuItem.setLabel("Overview Window..."); + overviewMenuItem.setLabel("Overview Window"); overviewMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { overviewMenuItem_actionPerformed(e); diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 6bf71cf..6c235a4 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -1,1030 +1,1263 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.jbgui; -import jalview.gui.Preferences; - -import jalview.schemes.ColourSchemeProperty; - import java.awt.*; import java.awt.event.*; - import javax.swing.*; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; - - -public class GAlignFrame extends JInternalFrame { - protected JMenuBar alignFrameMenuBar = new JMenuBar(); - protected JMenu fileMenu = new JMenu(); - protected JMenuItem closeMenuItem = new JMenuItem(); - protected JMenu editMenu = new JMenu(); - protected JMenu viewMenu = new JMenu(); - protected JMenu colourMenu = new JMenu(); - protected JMenu calculateMenu = new JMenu(); - protected JMenu webService = new JMenu(); - protected JMenuItem selectAllSequenceMenuItem = new JMenuItem(); - protected JMenuItem deselectAllSequenceMenuItem = new JMenuItem(); - protected JMenuItem invertSequenceMenuItem = new JMenuItem(); - protected JMenuItem remove2LeftMenuItem = new JMenuItem(); - protected JMenuItem remove2RightMenuItem = new JMenuItem(); - protected JMenuItem removeGappedColumnMenuItem = new JMenuItem(); - protected JMenuItem removeAllGapsMenuItem = new JMenuItem(); - public JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem(); - protected JMenuItem sortPairwiseMenuItem = new JMenuItem(); - protected JMenuItem sortIDMenuItem = new JMenuItem(); - protected JMenuItem sortGroupMenuItem = new JMenuItem(); - protected JMenuItem removeRedundancyMenuItem = new JMenuItem(); - protected JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(); - protected JMenuItem PCAMenuItem = new JMenuItem(); - protected JMenuItem averageDistanceTreeMenuItem = new JMenuItem(); - protected JMenuItem neighbourTreeMenuItem = new JMenuItem(); - protected JMenuItem clustalAlignMenuItem = new JMenuItem(); - BorderLayout borderLayout1 = new BorderLayout(); - public JLabel statusBar = new JLabel(); - protected JMenuItem saveAlignmentMenu = new JMenuItem(); - protected JMenu outputTextboxMenu = new JMenu(); - protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); - protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); - JMenuItem njTreeBlosumMenuItem = new JMenuItem(); - JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(); - public JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); - JMenuItem htmlMenuItem = new JMenuItem(); - JMenuItem overviewMenuItem = new JMenuItem(); - protected JMenuItem undoMenuItem = new JMenuItem(); - protected JMenuItem redoMenuItem = new JMenuItem(); - public JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); - public JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); - JMenuItem printMenuItem = new JMenuItem(); - public JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); - JMenuItem findMenuItem = new JMenuItem(); - JMenu searchMenu = new JMenu(); - public JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem sequenceFeatures = new JCheckBoxMenuItem(); - protected JRadioButtonMenuItem nucleotideColour = new JRadioButtonMenuItem(); - JMenuItem deleteGroups = new JMenuItem(); - JMenuItem delete = new JMenuItem(); - JMenuItem copy = new JMenuItem(); - JMenuItem cut = new JMenuItem(); - JMenu jMenu1 = new JMenu(); - JMenuItem pasteNew = new JMenuItem(); - JMenuItem pasteThis = new JMenuItem(); - public JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); - JMenuItem createPNG = new JMenuItem(); - protected JMenuItem font = new JMenuItem(); - public JCheckBoxMenuItem fullSeqId = new JCheckBoxMenuItem(); - JMenuItem epsFile = new JMenuItem(); - JMenuItem LoadtreeMenuItem = new JMenuItem(); - JMenuItem jnet = new JMenuItem(); - public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem(); - JMenuItem modifyPID = new JMenuItem(); - JMenuItem modifyConservation = new JMenuItem(); - protected JMenu sortByTreeMenu = new JMenu(); - protected JMenu sort = new JMenu(); - JMenu calculate = new JMenu(); - JMenuItem msaAlignMenuItem = new JMenuItem(); - JMenu jMenu2 = new JMenu(); - JMenuItem padGapsMenuitem = new JMenuItem(); - JMenuItem ClustalRealign = new JMenuItem(); - - public GAlignFrame() { - ButtonGroup colours = new ButtonGroup(); - colours.add(noColourmenuItem); - colours.add(clustalColour); - colours.add(zappoColour); - colours.add(taylorColour); - colours.add(hydrophobicityColour); - colours.add(helixColour); - colours.add(strandColour); - colours.add(turnColour); - colours.add(buriedColour); - colours.add(userDefinedColour); - colours.add(PIDColour); - colours.add(BLOSUM62Colour); - colours.add(nucleotideColour); - - noColourmenuItem.setSelected(true); - - String defaultColour = Preferences.defaultColour; - - if (defaultColour != null) { - int index = ColourSchemeProperty.getColourIndexFromName(defaultColour); - - switch (index) { - case ColourSchemeProperty.CLUSTAL: - clustalColour.setSelected(true); - - break; - - case ColourSchemeProperty.BLOSUM: - BLOSUM62Colour.setSelected(true); - - break; - - case ColourSchemeProperty.PID: - PIDColour.setSelected(true); - - break; - - case ColourSchemeProperty.ZAPPO: - zappoColour.setSelected(true); - - break; - - case ColourSchemeProperty.HYDROPHOBIC: - hydrophobicityColour.setSelected(true); - - break; - - case ColourSchemeProperty.HELIX: - helixColour.setSelected(true); - - break; - - case ColourSchemeProperty.STRAND: - strandColour.setSelected(true); - - break; - - case ColourSchemeProperty.TURN: - turnColour.setSelected(true); - - break; - - case ColourSchemeProperty.BURIED: - buriedColour.setSelected(true); - - break; - - case ColourSchemeProperty.NUCLEOTIDE: - nucleotideColour.setSelected(true); - - break; - - case ColourSchemeProperty.USER_DEFINED: - userDefinedColour.setSelected(true); - - break; - } - } - - try { - jbInit(); - setJMenuBar(alignFrameMenuBar); - - JMenuItem item; - - // dynamically fill save as menu with available formats - for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++) { - item = new JMenuItem((String) jalview.io.FormatAdapter.formats.elementAt( - i)); - item.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - outputText_actionPerformed(e); - } - }); - - outputTextboxMenu.add(item); - } - } catch (Exception e) { - e.printStackTrace(); - } - - } - - private void jbInit() throws Exception { - fileMenu.setMnemonic('F'); - fileMenu.setText("File"); - saveAlignmentMenu.setMnemonic('L'); - saveAlignmentMenu.setText("Save As"); - saveAlignmentMenu.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - saveAlignmentMenu_actionPerformed(e); - } - }); - closeMenuItem.setMnemonic('C'); - closeMenuItem.setText("Close"); - closeMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - closeMenuItem_actionPerformed(e); - } - }); - editMenu.setText("Edit"); - viewMenu.setText("View"); - colourMenu.setText("Colour"); - calculateMenu.setText("Calculate"); - webService.setText("Web Service"); - selectAllSequenceMenuItem.setText("Select all"); - selectAllSequenceMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_A, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); - selectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - selectAllSequenceMenuItem_actionPerformed(e); - } - }); - deselectAllSequenceMenuItem.setText("Deselect All"); - deselectAllSequenceMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_ESCAPE, 0, false)); - deselectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - deselectAllSequenceMenuItem_actionPerformed(e); - } - }); - invertSequenceMenuItem.setText("Invert Selection"); - invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - invertSequenceMenuItem_actionPerformed(e); - } - }); - remove2LeftMenuItem.setText("Remove Left"); - remove2LeftMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - remove2LeftMenuItem_actionPerformed(e); - } - }); - remove2RightMenuItem.setText("Remove Right"); - remove2RightMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - remove2RightMenuItem_actionPerformed(e); - } - }); - removeGappedColumnMenuItem.setText("Remove Empty Columns"); - removeGappedColumnMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - removeGappedColumnMenuItem_actionPerformed(e); - } - }); - removeAllGapsMenuItem.setText("Remove All Gaps"); - removeAllGapsMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - removeAllGapsMenuItem_actionPerformed(e); - } - }); - viewBoxesMenuItem.setText("Boxes"); - viewBoxesMenuItem.setState(true); - viewBoxesMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - viewBoxesMenuItem_actionPerformed(e); - } - }); - viewTextMenuItem.setText("Text"); - viewTextMenuItem.setState(true); - viewTextMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - viewTextMenuItem_actionPerformed(e); - } - }); - sortPairwiseMenuItem.setText("by Pairwise Identity"); - sortPairwiseMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - sortPairwiseMenuItem_actionPerformed(e); - } - }); - sortIDMenuItem.setText("by ID"); - sortIDMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - sortIDMenuItem_actionPerformed(e); - } - }); - sortGroupMenuItem.setText("by Group"); - sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - sortGroupMenuItem_actionPerformed(e); - } - }); - removeRedundancyMenuItem.setText("Remove Redundancy..."); - removeRedundancyMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - removeRedundancyMenuItem_actionPerformed(e); - } - }); - pairwiseAlignmentMenuItem.setText("Pairwise Alignments..."); - pairwiseAlignmentMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - pairwiseAlignmentMenuItem_actionPerformed(e); - } - }); - PCAMenuItem.setText("Principal Component Analysis..."); - PCAMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - PCAMenuItem_actionPerformed(e); - } - }); - averageDistanceTreeMenuItem.setText( - "Average Distance Using % Identity..."); - averageDistanceTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - averageDistanceTreeMenuItem_actionPerformed(e); - } - }); - neighbourTreeMenuItem.setText("Neighbour Joining Using % Identity..."); - neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - neighbourTreeMenuItem_actionPerformed(e); - } - }); - clustalAlignMenuItem.setText("Clustal Alignment..."); - clustalAlignMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - clustalAlignMenuItem_actionPerformed(e); - } - }); - this.getContentPane().setLayout(borderLayout1); - alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11)); - alignFrameMenuBar.addAncestorListener(new AncestorListener() { - public void ancestorAdded(AncestorEvent event) { - alignFrameMenuBar_ancestorAdded(event); - } - - public void ancestorRemoved(AncestorEvent event) { - } - - public void ancestorMoved(AncestorEvent event) { - } - }); - statusBar.setBackground(Color.white); - statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); - statusBar.setBorder(BorderFactory.createLineBorder(Color.black)); - statusBar.setText("Status bar"); - outputTextboxMenu.setMnemonic('T'); - outputTextboxMenu.setText("Output to Textbox"); - clustalColour.setText("Clustalx"); - - clustalColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - clustalColour_actionPerformed(e); - } - }); - zappoColour.setText("Zappo"); - zappoColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - zappoColour_actionPerformed(e); - } - }); - taylorColour.setText("Taylor"); - taylorColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - taylorColour_actionPerformed(e); - } - }); - hydrophobicityColour.setText("Hydrophobicity"); - hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - hydrophobicityColour_actionPerformed(e); - } - }); - helixColour.setText("Helix Propensity"); - helixColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - helixColour_actionPerformed(e); - } - }); - strandColour.setText("Strand Propensity"); - strandColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - strandColour_actionPerformed(e); - } - }); - turnColour.setText("Turn Propensity"); - turnColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - turnColour_actionPerformed(e); - } - }); - buriedColour.setText("Buried Index"); - buriedColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - buriedColour_actionPerformed(e); - } - }); - userDefinedColour.setText("User Defined..."); - userDefinedColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - userDefinedColour_actionPerformed(e); - } - }); - PIDColour.setText("Percentage Identity"); - PIDColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - PIDColour_actionPerformed(e); - } - }); - BLOSUM62Colour.setText("BLOSUM62 Score"); - BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - BLOSUM62Colour_actionPerformed(e); - } - }); - avDistanceTreeBlosumMenuItem.setText( - "Average Distance Using BLOSUM62..."); - avDistanceTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - avTreeBlosumMenuItem_actionPerformed(e); - } - }); - njTreeBlosumMenuItem.setText("Neighbour Joining using BLOSUM62..."); - njTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - njTreeBlosumMenuItem_actionPerformed(e); - } - }); - annotationPanelMenuItem.setActionCommand(""); - annotationPanelMenuItem.setText("Show Annotations"); - annotationPanelMenuItem.setState(jalview.gui.Preferences.showAnnotation); - annotationPanelMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - annotationPanelMenuItem_actionPerformed(e); - } - }); - colourTextMenuItem.setText("Colour Text"); - colourTextMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - colourTextMenuItem_actionPerformed(e); - } - }); - htmlMenuItem.setText("HTML"); - htmlMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - htmlMenuItem_actionPerformed(e); - } - }); - overviewMenuItem.setText("Overview Window..."); - overviewMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - overviewMenuItem_actionPerformed(e); - } - }); - undoMenuItem.setEnabled(false); - undoMenuItem.setMnemonic('Z'); - undoMenuItem.setText("Undo"); - undoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_Z, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); - undoMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - undoMenuItem_actionPerformed(e); - } - }); - redoMenuItem.setEnabled(false); - redoMenuItem.setMnemonic('0'); - redoMenuItem.setText("Redo"); - redoMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - redoMenuItem_actionPerformed(e); - } - }); - conservationMenuItem.setText("By Conservation"); - conservationMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - conservationMenuItem_actionPerformed(e); - } - }); - noColourmenuItem.setText("None"); - noColourmenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - noColourmenuItem_actionPerformed(e); - } - }); - wrapMenuItem.setText("Wrap"); - wrapMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - wrapMenuItem_actionPerformed(e); - } - }); - printMenuItem.setText("Print"); - printMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - printMenuItem_actionPerformed(e); - } - }); - renderGapsMenuItem.setText("Show Gaps"); - renderGapsMenuItem.setState(true); - renderGapsMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - renderGapsMenuItem_actionPerformed(e); - } - }); - findMenuItem.setText("Find..."); - findMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_F, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); - findMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - findMenuItem_actionPerformed(e); - } - }); - searchMenu.setText("Search"); - - abovePIDThreshold.setText("Above Identity Threshold"); - abovePIDThreshold.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - abovePIDThreshold_actionPerformed(e); - } - }); - sequenceFeatures.setText("Sequence Features"); - sequenceFeatures.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - sequenceFeatures_actionPerformed(actionEvent); - } - }); - nucleotideColour.setText("Nucleotide"); - nucleotideColour.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - nucleotideColour_actionPerformed(e); - } - }); - deleteGroups.setText("Undefine groups"); - deleteGroups.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - deleteGroups_actionPerformed(e); - } - }); - copy.setText("Copy"); - copy.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_C, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); - copy.setMnemonic(KeyEvent.VK_C); - - copy.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - copy_actionPerformed(e); - } - }); - cut.setText("Cut"); - cut.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_X, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); - cut.setMnemonic(KeyEvent.VK_X); - cut.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - cut_actionPerformed(e); - } - }); - delete.setText("Delete"); - delete.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - delete_actionPerformed(e); - } - }); - jMenu1.setMnemonic('V'); - jMenu1.setText("Paste"); - pasteNew.setText("To New Alignment"); - pasteNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke( - java.awt.event.KeyEvent.VK_V, - Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); - pasteNew.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - pasteNew_actionPerformed(e); - } - }); - pasteThis.setText("Add To This Alignment"); - pasteThis.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - pasteThis_actionPerformed(e); - } - }); - applyToAllGroups.setText("Apply Colour To All Groups"); - applyToAllGroups.setState(true); - applyToAllGroups.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - applyToAllGroups_actionPerformed(e); - } - }); - createPNG.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - createPNG_actionPerformed(e); - } - }); - createPNG.setActionCommand("Save As PNG Image"); - createPNG.setText("PNG"); - font.setText("Font..."); - font.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - font_actionPerformed(e); - } - }); - fullSeqId.setText("Show Full Sequence ID"); - fullSeqId.setState(true); - fullSeqId.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - fullSeqId_actionPerformed(e); - } - }); - epsFile.setText("EPS"); - epsFile.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - epsFile_actionPerformed(e); - } - }); - LoadtreeMenuItem.setActionCommand("Load a tree for this sequence set"); - LoadtreeMenuItem.setText("Load Assocated Tree"); - LoadtreeMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - LoadtreeMenuItem_actionPerformed(e); - } - }); - jnet.setText("JNet..."); - jnet.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - jpred_actionPerformed(e); - } - }); - scaleAbove.setVisible(false); - scaleAbove.setText("Scale Above"); - scaleAbove.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - scaleAbove_actionPerformed(e); - } - }); - scaleLeft.setVisible(false); - scaleLeft.setSelected(true); - scaleLeft.setText("Scale Left"); - scaleLeft.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - scaleLeft_actionPerformed(e); - } - }); - scaleRight.setVisible(false); - scaleRight.setSelected(true); - scaleRight.setText("Scale Right"); - scaleRight.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - scaleRight_actionPerformed(e); - } - }); - modifyPID.setText("Modify Identity Threshold..."); - modifyPID.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - modifyPID_actionPerformed(e); - } - }); - modifyConservation.setText("Modify Conservation Threshold..."); - modifyConservation.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - modifyConservation_actionPerformed(e); - } - }); - sortByTreeMenu.setText("By Tree Order"); - sort.setText("Sort"); - calculate.setText("Calculate Tree"); - msaAlignMenuItem.setText("Muscle Alignment..."); - msaAlignMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - msaAlignMenuItem_actionPerformed(e); - } - }); - jMenu2.setText("Export"); - padGapsMenuitem.setText("Pad Gaps"); - padGapsMenuitem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - padGapsMenuitem_actionPerformed(e); - } - }); - ClustalRealign.setText("Clustal Realign..."); - ClustalRealign.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - ClustalRealign_actionPerformed(e); - } - }); - alignFrameMenuBar.add(fileMenu); - alignFrameMenuBar.add(editMenu); - alignFrameMenuBar.add(searchMenu); - alignFrameMenuBar.add(viewMenu); - alignFrameMenuBar.add(colourMenu); - alignFrameMenuBar.add(calculateMenu); - fileMenu.add(saveAlignmentMenu); - fileMenu.add(jMenu2); - fileMenu.add(outputTextboxMenu); - fileMenu.add(printMenuItem); - fileMenu.addSeparator(); - fileMenu.add(LoadtreeMenuItem); - fileMenu.addSeparator(); - fileMenu.add(closeMenuItem); - editMenu.add(undoMenuItem); - editMenu.add(redoMenuItem); - editMenu.add(cut); - editMenu.add(copy); - editMenu.add(jMenu1); - editMenu.add(delete); - editMenu.addSeparator(); - editMenu.add(selectAllSequenceMenuItem); - editMenu.add(deselectAllSequenceMenuItem); - editMenu.add(invertSequenceMenuItem); - editMenu.add(deleteGroups); - editMenu.addSeparator(); - editMenu.add(remove2LeftMenuItem); - editMenu.add(remove2RightMenuItem); - editMenu.add(removeGappedColumnMenuItem); - editMenu.add(removeAllGapsMenuItem); - editMenu.add(removeRedundancyMenuItem); - editMenu.addSeparator(); - editMenu.add(padGapsMenuitem); - searchMenu.add(findMenuItem); - viewMenu.add(font); - viewMenu.addSeparator(); - viewMenu.add(wrapMenuItem); - viewMenu.add(fullSeqId); - viewMenu.add(scaleAbove); - viewMenu.add(scaleLeft); - viewMenu.add(scaleRight); - viewMenu.add(viewBoxesMenuItem); - viewMenu.add(viewTextMenuItem); - viewMenu.add(colourTextMenuItem); - viewMenu.add(renderGapsMenuItem); - viewMenu.add(annotationPanelMenuItem); - viewMenu.add(sequenceFeatures); - viewMenu.addSeparator(); - viewMenu.add(overviewMenuItem); - colourMenu.add(applyToAllGroups); - colourMenu.addSeparator(); - colourMenu.add(noColourmenuItem); - colourMenu.add(clustalColour); - colourMenu.add(BLOSUM62Colour); - colourMenu.add(PIDColour); - colourMenu.add(zappoColour); - colourMenu.add(taylorColour); - colourMenu.add(hydrophobicityColour); - colourMenu.add(helixColour); - colourMenu.add(strandColour); - colourMenu.add(turnColour); - colourMenu.add(buriedColour); - colourMenu.add(nucleotideColour); - colourMenu.add(userDefinedColour); - colourMenu.addSeparator(); - colourMenu.add(conservationMenuItem); - colourMenu.add(modifyConservation); - colourMenu.add(abovePIDThreshold); - colourMenu.add(modifyPID); - calculateMenu.add(sort); - calculateMenu.add(calculate); - calculateMenu.addSeparator(); - calculateMenu.add(pairwiseAlignmentMenuItem); - calculateMenu.add(PCAMenuItem); - calculateMenu.addSeparator(); - calculateMenu.add(webService); - webService.add(clustalAlignMenuItem); - webService.add(msaAlignMenuItem); - webService.add(jnet); - webService.add(ClustalRealign); - this.getContentPane().add(statusBar, BorderLayout.SOUTH); - jMenu1.add(pasteNew); - jMenu1.add(pasteThis); - sort.add(sortIDMenuItem); - sort.add(sortGroupMenuItem); - sort.add(sortPairwiseMenuItem); - calculate.add(averageDistanceTreeMenuItem); - calculate.add(neighbourTreeMenuItem); - calculate.add(avDistanceTreeBlosumMenuItem); - calculate.add(njTreeBlosumMenuItem); - jMenu2.add(htmlMenuItem); - jMenu2.add(epsFile); - jMenu2.add(createPNG); - } - - protected void outputText_actionPerformed(ActionEvent e) { - } - - protected void htmlMenuItem_actionPerformed(ActionEvent e) { - } - - protected void closeMenuItem_actionPerformed(ActionEvent e) { - } - - protected void redoMenuItem_actionPerformed(ActionEvent e) { - } - - protected void undoMenuItem_actionPerformed(ActionEvent e) { - } - - protected void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) { - } - - protected void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) { - } - - protected void invertSequenceMenuItem_actionPerformed(ActionEvent e) { - } - - protected void remove2LeftMenuItem_actionPerformed(ActionEvent e) { - } - - protected void remove2RightMenuItem_actionPerformed(ActionEvent e) { - } - - protected void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) { - } - - protected void removeAllGapsMenuItem_actionPerformed(ActionEvent e) { - } - - protected void wrapMenuItem_actionPerformed(ActionEvent e) { - } - - protected void viewBoxesMenuItem_actionPerformed(ActionEvent e) { - } - - protected void viewTextMenuItem_actionPerformed(ActionEvent e) { - } - - protected void colourTextMenuItem_actionPerformed(ActionEvent e) { - } - - protected void annotationPanelMenuItem_actionPerformed(ActionEvent e) { - } - - protected void overviewMenuItem_actionPerformed(ActionEvent e) { - } - - protected void sortPairwiseMenuItem_actionPerformed(ActionEvent e) { - } - - protected void sortIDMenuItem_actionPerformed(ActionEvent e) { - } - - protected void sortGroupMenuItem_actionPerformed(ActionEvent e) { - } +import javax.swing.event.*; + +import jalview.gui.*; +import jalview.schemes.*; + +public class GAlignFrame + extends JInternalFrame +{ + protected JMenuBar alignFrameMenuBar = new JMenuBar(); + protected JMenu fileMenu = new JMenu(); + protected JMenuItem closeMenuItem = new JMenuItem(); + protected JMenu editMenu = new JMenu(); + protected JMenu viewMenu = new JMenu(); + protected JMenu colourMenu = new JMenu(); + protected JMenu calculateMenu = new JMenu(); + protected JMenu webService = new JMenu(); + protected JMenuItem selectAllSequenceMenuItem = new JMenuItem(); + protected JMenuItem deselectAllSequenceMenuItem = new JMenuItem(); + protected JMenuItem invertSequenceMenuItem = new JMenuItem(); + protected JMenuItem remove2LeftMenuItem = new JMenuItem(); + protected JMenuItem remove2RightMenuItem = new JMenuItem(); + protected JMenuItem removeGappedColumnMenuItem = new JMenuItem(); + protected JMenuItem removeAllGapsMenuItem = new JMenuItem(); + public JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem viewTextMenuItem = new JCheckBoxMenuItem(); + protected JMenuItem sortPairwiseMenuItem = new JMenuItem(); + protected JMenuItem sortIDMenuItem = new JMenuItem(); + protected JMenuItem sortGroupMenuItem = new JMenuItem(); + protected JMenuItem removeRedundancyMenuItem = new JMenuItem(); + protected JMenuItem pairwiseAlignmentMenuItem = new JMenuItem(); + protected JMenuItem PCAMenuItem = new JMenuItem(); + protected JMenuItem averageDistanceTreeMenuItem = new JMenuItem(); + protected JMenuItem neighbourTreeMenuItem = new JMenuItem(); + protected JMenuItem clustalAlignMenuItem = new JMenuItem(); + BorderLayout borderLayout1 = new BorderLayout(); + public JLabel statusBar = new JLabel(); + protected JMenuItem saveAlignmentMenu = new JMenuItem(); + protected JMenu outputTextboxMenu = new JMenu(); + protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem hydrophobicityColour = new + JRadioButtonMenuItem(); + protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem(); + protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem(); + JMenuItem njTreeBlosumMenuItem = new JMenuItem(); + JMenuItem avDistanceTreeBlosumMenuItem = new JMenuItem(); + public JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); + JMenuItem htmlMenuItem = new JMenuItem(); + JMenuItem overviewMenuItem = new JMenuItem(); + protected JMenuItem undoMenuItem = new JMenuItem(); + protected JMenuItem redoMenuItem = new JMenuItem(); + public JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); + JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); + public JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); + JMenuItem printMenuItem = new JMenuItem(); + public JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); + JMenuItem findMenuItem = new JMenuItem(); + JMenu searchMenu = new JMenu(); + public JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem sequenceFeatures = new JCheckBoxMenuItem(); + protected JRadioButtonMenuItem nucleotideColour = new JRadioButtonMenuItem(); + JMenuItem deleteGroups = new JMenuItem(); + JMenuItem delete = new JMenuItem(); + JMenuItem copy = new JMenuItem(); + JMenuItem cut = new JMenuItem(); + JMenu jMenu1 = new JMenu(); + JMenuItem pasteNew = new JMenuItem(); + JMenuItem pasteThis = new JMenuItem(); + public JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); + JMenuItem createPNG = new JMenuItem(); + protected JMenuItem font = new JMenuItem(); + public JCheckBoxMenuItem fullSeqId = new JCheckBoxMenuItem(); + JMenuItem epsFile = new JMenuItem(); + JMenuItem LoadtreeMenuItem = new JMenuItem(); + JMenuItem jnet = new JMenuItem(); + public JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem scaleRight = new JCheckBoxMenuItem(); + JMenuItem modifyPID = new JMenuItem(); + JMenuItem modifyConservation = new JMenuItem(); + protected JMenu sortByTreeMenu = new JMenu(); + protected JMenu sort = new JMenu(); + JMenu calculate = new JMenu(); + JMenuItem msaAlignMenuItem = new JMenuItem(); + JMenu jMenu2 = new JMenu(); + JMenuItem padGapsMenuitem = new JMenuItem(); + JMenuItem ClustalRealign = new JMenuItem(); + + public GAlignFrame() + { + ButtonGroup colours = new ButtonGroup(); + colours.add(noColourmenuItem); + colours.add(clustalColour); + colours.add(zappoColour); + colours.add(taylorColour); + colours.add(hydrophobicityColour); + colours.add(helixColour); + colours.add(strandColour); + colours.add(turnColour); + colours.add(buriedColour); + colours.add(userDefinedColour); + colours.add(PIDColour); + colours.add(BLOSUM62Colour); + colours.add(nucleotideColour); + + noColourmenuItem.setSelected(true); + + String defaultColour = Preferences.defaultColour; + + if (defaultColour != null) + { + int index = ColourSchemeProperty.getColourIndexFromName(defaultColour); + + switch (index) + { + case ColourSchemeProperty.CLUSTAL: + clustalColour.setSelected(true); + + break; + + case ColourSchemeProperty.BLOSUM: + BLOSUM62Colour.setSelected(true); + + break; + + case ColourSchemeProperty.PID: + PIDColour.setSelected(true); + + break; + + case ColourSchemeProperty.ZAPPO: + zappoColour.setSelected(true); + + break; + + case ColourSchemeProperty.HYDROPHOBIC: + hydrophobicityColour.setSelected(true); + + break; + + case ColourSchemeProperty.HELIX: + helixColour.setSelected(true); + + break; + + case ColourSchemeProperty.STRAND: + strandColour.setSelected(true); + + break; + + case ColourSchemeProperty.TURN: + turnColour.setSelected(true); + + break; + + case ColourSchemeProperty.BURIED: + buriedColour.setSelected(true); + + break; + + case ColourSchemeProperty.NUCLEOTIDE: + nucleotideColour.setSelected(true); + + break; + + case ColourSchemeProperty.USER_DEFINED: + userDefinedColour.setSelected(true); + + break; + } + } + + try + { + jbInit(); + setJMenuBar(alignFrameMenuBar); + + JMenuItem item; + + // dynamically fill save as menu with available formats + for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++) + { + item = new JMenuItem( (String) jalview.io.FormatAdapter.formats. + elementAt( + i)); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + outputText_actionPerformed(e); + } + }); + + outputTextboxMenu.add(item); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + + private void jbInit() + throws Exception + { + fileMenu.setMnemonic('F'); + fileMenu.setText("File"); + saveAlignmentMenu.setMnemonic('L'); + saveAlignmentMenu.setText("Save As"); + saveAlignmentMenu.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + saveAlignmentMenu_actionPerformed(e); + } + }); + closeMenuItem.setMnemonic('C'); + closeMenuItem.setText("Close"); + closeMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + closeMenuItem_actionPerformed(e); + } + }); + editMenu.setText("Edit"); + viewMenu.setText("View"); + colourMenu.setText("Colour"); + calculateMenu.setText("Calculate"); + webService.setText("Web Service"); + selectAllSequenceMenuItem.setText("Select all"); + selectAllSequenceMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( + java.awt.event.KeyEvent.VK_A, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); + selectAllSequenceMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + selectAllSequenceMenuItem_actionPerformed(e); + } + }); + deselectAllSequenceMenuItem.setText("Deselect All"); + deselectAllSequenceMenuItem.setAccelerator(javax.swing.KeyStroke. + getKeyStroke( + java.awt.event.KeyEvent.VK_ESCAPE, 0, false)); + deselectAllSequenceMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + deselectAllSequenceMenuItem_actionPerformed(e); + } + }); + invertSequenceMenuItem.setText("Invert Selection"); + invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + invertSequenceMenuItem_actionPerformed(e); + } + }); + remove2LeftMenuItem.setText("Remove Left"); + remove2LeftMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + remove2LeftMenuItem_actionPerformed(e); + } + }); + remove2RightMenuItem.setText("Remove Right"); + remove2RightMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + remove2RightMenuItem_actionPerformed(e); + } + }); + removeGappedColumnMenuItem.setText("Remove Empty Columns"); + removeGappedColumnMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + removeGappedColumnMenuItem_actionPerformed(e); + } + }); + removeAllGapsMenuItem.setText("Remove All Gaps"); + removeAllGapsMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + removeAllGapsMenuItem_actionPerformed(e); + } + }); + viewBoxesMenuItem.setText("Boxes"); + viewBoxesMenuItem.setState(true); + viewBoxesMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + viewBoxesMenuItem_actionPerformed(e); + } + }); + viewTextMenuItem.setText("Text"); + viewTextMenuItem.setState(true); + viewTextMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + viewTextMenuItem_actionPerformed(e); + } + }); + sortPairwiseMenuItem.setText("by Pairwise Identity"); + sortPairwiseMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sortPairwiseMenuItem_actionPerformed(e); + } + }); + sortIDMenuItem.setText("by ID"); + sortIDMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sortIDMenuItem_actionPerformed(e); + } + }); + sortGroupMenuItem.setText("by Group"); + sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sortGroupMenuItem_actionPerformed(e); + } + }); + removeRedundancyMenuItem.setText("Remove Redundancy..."); + removeRedundancyMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + removeRedundancyMenuItem_actionPerformed(e); + } + }); + pairwiseAlignmentMenuItem.setText("Pairwise Alignments..."); + pairwiseAlignmentMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + pairwiseAlignmentMenuItem_actionPerformed(e); + } + }); + PCAMenuItem.setText("Principal Component Analysis"); + PCAMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + PCAMenuItem_actionPerformed(e); + } + }); + averageDistanceTreeMenuItem.setText( + "Average Distance Using % Identity"); + averageDistanceTreeMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + averageDistanceTreeMenuItem_actionPerformed(e); + } + }); + neighbourTreeMenuItem.setText("Neighbour Joining Using % Identity"); + neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + neighbourTreeMenuItem_actionPerformed(e); + } + }); + clustalAlignMenuItem.setText("Clustal Alignment"); + clustalAlignMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + clustalAlignMenuItem_actionPerformed(e); + } + }); + this.getContentPane().setLayout(borderLayout1); + alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11)); + alignFrameMenuBar.addAncestorListener(new AncestorListener() + { + public void ancestorAdded(AncestorEvent event) + { + alignFrameMenuBar_ancestorAdded(event); + } + + public void ancestorRemoved(AncestorEvent event) + { + } + + public void ancestorMoved(AncestorEvent event) + { + } + }); + statusBar.setBackground(Color.white); + statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setBorder(BorderFactory.createLineBorder(Color.black)); + statusBar.setText("Status bar"); + outputTextboxMenu.setMnemonic('T'); + outputTextboxMenu.setText("Output to Textbox"); + clustalColour.setText("Clustalx"); + + clustalColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + clustalColour_actionPerformed(e); + } + }); + zappoColour.setText("Zappo"); + zappoColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + zappoColour_actionPerformed(e); + } + }); + taylorColour.setText("Taylor"); + taylorColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + taylorColour_actionPerformed(e); + } + }); + hydrophobicityColour.setText("Hydrophobicity"); + hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + hydrophobicityColour_actionPerformed(e); + } + }); + helixColour.setText("Helix Propensity"); + helixColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + helixColour_actionPerformed(e); + } + }); + strandColour.setText("Strand Propensity"); + strandColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + strandColour_actionPerformed(e); + } + }); + turnColour.setText("Turn Propensity"); + turnColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + turnColour_actionPerformed(e); + } + }); + buriedColour.setText("Buried Index"); + buriedColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + buriedColour_actionPerformed(e); + } + }); + userDefinedColour.setText("User Defined..."); + userDefinedColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + userDefinedColour_actionPerformed(e); + } + }); + PIDColour.setText("Percentage Identity"); + PIDColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + PIDColour_actionPerformed(e); + } + }); + BLOSUM62Colour.setText("BLOSUM62 Score"); + BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + BLOSUM62Colour_actionPerformed(e); + } + }); + avDistanceTreeBlosumMenuItem.setText( + "Average Distance Using BLOSUM62"); + avDistanceTreeBlosumMenuItem.addActionListener(new java.awt.event. + ActionListener() + { + public void actionPerformed(ActionEvent e) + { + avTreeBlosumMenuItem_actionPerformed(e); + } + }); + njTreeBlosumMenuItem.setText("Neighbour Joining using BLOSUM62"); + njTreeBlosumMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + njTreeBlosumMenuItem_actionPerformed(e); + } + }); + annotationPanelMenuItem.setActionCommand(""); + annotationPanelMenuItem.setText("Show Annotations"); + annotationPanelMenuItem.setState(jalview.gui.Preferences.showAnnotation); + annotationPanelMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + annotationPanelMenuItem_actionPerformed(e); + } + }); + colourTextMenuItem.setText("Colour Text"); + colourTextMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + colourTextMenuItem_actionPerformed(e); + } + }); + htmlMenuItem.setText("HTML"); + htmlMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + htmlMenuItem_actionPerformed(e); + } + }); + overviewMenuItem.setText("Overview Window"); + overviewMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + overviewMenuItem_actionPerformed(e); + } + }); + undoMenuItem.setEnabled(false); + undoMenuItem.setMnemonic('Z'); + undoMenuItem.setText("Undo"); + undoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( + java.awt.event.KeyEvent.VK_Z, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); + undoMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + undoMenuItem_actionPerformed(e); + } + }); + redoMenuItem.setEnabled(false); + redoMenuItem.setMnemonic('0'); + redoMenuItem.setText("Redo"); + redoMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + redoMenuItem_actionPerformed(e); + } + }); + conservationMenuItem.setText("By Conservation"); + conservationMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + conservationMenuItem_actionPerformed(e); + } + }); + noColourmenuItem.setText("None"); + noColourmenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + noColourmenuItem_actionPerformed(e); + } + }); + wrapMenuItem.setText("Wrap"); + wrapMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + wrapMenuItem_actionPerformed(e); + } + }); + printMenuItem.setText("Print"); + printMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + printMenuItem_actionPerformed(e); + } + }); + renderGapsMenuItem.setText("Show Gaps"); + renderGapsMenuItem.setState(true); + renderGapsMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + renderGapsMenuItem_actionPerformed(e); + } + }); + findMenuItem.setText("Find..."); + findMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( + java.awt.event.KeyEvent.VK_F, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); + findMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + findMenuItem_actionPerformed(e); + } + }); + searchMenu.setText("Search"); + + abovePIDThreshold.setText("Above Identity Threshold"); + abovePIDThreshold.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + abovePIDThreshold_actionPerformed(e); + } + }); + sequenceFeatures.setText("Sequence Features"); + sequenceFeatures.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + sequenceFeatures_actionPerformed(actionEvent); + } + }); + nucleotideColour.setText("Nucleotide"); + nucleotideColour.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + nucleotideColour_actionPerformed(e); + } + }); + deleteGroups.setText("Undefine groups"); + deleteGroups.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + deleteGroups_actionPerformed(e); + } + }); + copy.setText("Copy"); + copy.setAccelerator(javax.swing.KeyStroke.getKeyStroke( + java.awt.event.KeyEvent.VK_C, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); + copy.setMnemonic(KeyEvent.VK_C); + + copy.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + copy_actionPerformed(e); + } + }); + cut.setText("Cut"); + cut.setAccelerator(javax.swing.KeyStroke.getKeyStroke( + java.awt.event.KeyEvent.VK_X, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); + cut.setMnemonic(KeyEvent.VK_X); + cut.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + cut_actionPerformed(e); + } + }); + delete.setText("Delete"); + delete.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + delete_actionPerformed(e); + } + }); + jMenu1.setMnemonic('V'); + jMenu1.setText("Paste"); + pasteNew.setText("To New Alignment"); + pasteNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke( + java.awt.event.KeyEvent.VK_V, + Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); + pasteNew.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + pasteNew_actionPerformed(e); + } + }); + pasteThis.setText("Add To This Alignment"); + pasteThis.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + pasteThis_actionPerformed(e); + } + }); + applyToAllGroups.setText("Apply Colour To All Groups"); + applyToAllGroups.setState(true); + applyToAllGroups.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + applyToAllGroups_actionPerformed(e); + } + }); + createPNG.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + createPNG(null); + } + }); + createPNG.setActionCommand("Save As PNG Image"); + createPNG.setText("PNG"); + font.setText("Font..."); + font.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + font_actionPerformed(e); + } + }); + fullSeqId.setText("Show Full Sequence ID"); + fullSeqId.setState(true); + fullSeqId.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + fullSeqId_actionPerformed(e); + } + }); + epsFile.setText("EPS"); + epsFile.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + createEPS(null); + } + }); + LoadtreeMenuItem.setActionCommand("Load a tree for this sequence set"); + LoadtreeMenuItem.setText("Load Assocated Tree"); + LoadtreeMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + LoadtreeMenuItem_actionPerformed(e); + } + }); + jnet.setText("JNet"); + jnet.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + jpred_actionPerformed(e); + } + }); + scaleAbove.setVisible(false); + scaleAbove.setText("Scale Above"); + scaleAbove.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + scaleAbove_actionPerformed(e); + } + }); + scaleLeft.setVisible(false); + scaleLeft.setSelected(true); + scaleLeft.setText("Scale Left"); + scaleLeft.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + scaleLeft_actionPerformed(e); + } + }); + scaleRight.setVisible(false); + scaleRight.setSelected(true); + scaleRight.setText("Scale Right"); + scaleRight.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + scaleRight_actionPerformed(e); + } + }); + modifyPID.setText("Modify Identity Threshold..."); + modifyPID.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + modifyPID_actionPerformed(e); + } + }); + modifyConservation.setText("Modify Conservation Threshold..."); + modifyConservation.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + modifyConservation_actionPerformed(e); + } + }); + sortByTreeMenu.setText("By Tree Order"); + sort.setText("Sort"); + calculate.setText("Calculate Tree"); + msaAlignMenuItem.setText("Muscle Alignment"); + msaAlignMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + msaAlignMenuItem_actionPerformed(e); + } + }); + jMenu2.setText("Export"); + padGapsMenuitem.setText("Pad Gaps"); + padGapsMenuitem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + padGapsMenuitem_actionPerformed(e); + } + }); + ClustalRealign.setText("Clustal Realign"); + ClustalRealign.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + ClustalRealign_actionPerformed(e); + } + }); + alignFrameMenuBar.add(fileMenu); + alignFrameMenuBar.add(editMenu); + alignFrameMenuBar.add(searchMenu); + alignFrameMenuBar.add(viewMenu); + alignFrameMenuBar.add(colourMenu); + alignFrameMenuBar.add(calculateMenu); + fileMenu.add(saveAlignmentMenu); + fileMenu.add(jMenu2); + fileMenu.add(outputTextboxMenu); + fileMenu.add(printMenuItem); + fileMenu.addSeparator(); + fileMenu.add(LoadtreeMenuItem); + fileMenu.addSeparator(); + fileMenu.add(closeMenuItem); + editMenu.add(undoMenuItem); + editMenu.add(redoMenuItem); + editMenu.add(cut); + editMenu.add(copy); + editMenu.add(jMenu1); + editMenu.add(delete); + editMenu.addSeparator(); + editMenu.add(selectAllSequenceMenuItem); + editMenu.add(deselectAllSequenceMenuItem); + editMenu.add(invertSequenceMenuItem); + editMenu.add(deleteGroups); + editMenu.addSeparator(); + editMenu.add(remove2LeftMenuItem); + editMenu.add(remove2RightMenuItem); + editMenu.add(removeGappedColumnMenuItem); + editMenu.add(removeAllGapsMenuItem); + editMenu.add(removeRedundancyMenuItem); + editMenu.addSeparator(); + editMenu.add(padGapsMenuitem); + searchMenu.add(findMenuItem); + viewMenu.add(font); + viewMenu.addSeparator(); + viewMenu.add(wrapMenuItem); + viewMenu.add(fullSeqId); + viewMenu.add(scaleAbove); + viewMenu.add(scaleLeft); + viewMenu.add(scaleRight); + viewMenu.add(viewBoxesMenuItem); + viewMenu.add(viewTextMenuItem); + viewMenu.add(colourTextMenuItem); + viewMenu.add(renderGapsMenuItem); + viewMenu.add(annotationPanelMenuItem); + viewMenu.add(sequenceFeatures); + viewMenu.addSeparator(); + viewMenu.add(overviewMenuItem); + colourMenu.add(applyToAllGroups); + colourMenu.addSeparator(); + colourMenu.add(noColourmenuItem); + colourMenu.add(clustalColour); + colourMenu.add(BLOSUM62Colour); + colourMenu.add(PIDColour); + colourMenu.add(zappoColour); + colourMenu.add(taylorColour); + colourMenu.add(hydrophobicityColour); + colourMenu.add(helixColour); + colourMenu.add(strandColour); + colourMenu.add(turnColour); + colourMenu.add(buriedColour); + colourMenu.add(nucleotideColour); + colourMenu.add(userDefinedColour); + colourMenu.addSeparator(); + colourMenu.add(conservationMenuItem); + colourMenu.add(modifyConservation); + colourMenu.add(abovePIDThreshold); + colourMenu.add(modifyPID); + calculateMenu.add(sort); + calculateMenu.add(calculate); + calculateMenu.addSeparator(); + calculateMenu.add(pairwiseAlignmentMenuItem); + calculateMenu.add(PCAMenuItem); + calculateMenu.addSeparator(); + calculateMenu.add(webService); + webService.add(clustalAlignMenuItem); + webService.add(msaAlignMenuItem); + webService.add(jnet); + webService.add(ClustalRealign); + this.getContentPane().add(statusBar, BorderLayout.SOUTH); + jMenu1.add(pasteNew); + jMenu1.add(pasteThis); + sort.add(sortIDMenuItem); + sort.add(sortGroupMenuItem); + sort.add(sortPairwiseMenuItem); + calculate.add(averageDistanceTreeMenuItem); + calculate.add(neighbourTreeMenuItem); + calculate.add(avDistanceTreeBlosumMenuItem); + calculate.add(njTreeBlosumMenuItem); + jMenu2.add(htmlMenuItem); + jMenu2.add(epsFile); + jMenu2.add(createPNG); + } + + protected void outputText_actionPerformed(ActionEvent e) + { + } + + protected void htmlMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void closeMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void redoMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void undoMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void invertSequenceMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void remove2LeftMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void remove2RightMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void removeAllGapsMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void wrapMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void viewBoxesMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void viewTextMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void colourTextMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void annotationPanelMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void overviewMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void sortPairwiseMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void sortIDMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void sortGroupMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) + { + } + + protected void PCAMenuItem_actionPerformed(ActionEvent e) + { + } - protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e) { - } + protected void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) + { + } - protected void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) { - } + protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e) + { + } - protected void PCAMenuItem_actionPerformed(ActionEvent e) { - } + protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) + { + } - protected void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) { - } + protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) + { + } - protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e) { - } + protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) + { + } - protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) { - } + protected void clustalColour_actionPerformed(ActionEvent e) + { + } - protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) { - } + protected void zappoColour_actionPerformed(ActionEvent e) + { + } - protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) { - } + protected void taylorColour_actionPerformed(ActionEvent e) + { + } - protected void clustalColour_actionPerformed(ActionEvent e) { - } + protected void hydrophobicityColour_actionPerformed(ActionEvent e) + { + } - protected void zappoColour_actionPerformed(ActionEvent e) { - } + protected void helixColour_actionPerformed(ActionEvent e) + { + } - protected void taylorColour_actionPerformed(ActionEvent e) { - } + protected void strandColour_actionPerformed(ActionEvent e) + { + } - protected void hydrophobicityColour_actionPerformed(ActionEvent e) { - } + protected void turnColour_actionPerformed(ActionEvent e) + { + } - protected void helixColour_actionPerformed(ActionEvent e) { - } + protected void buriedColour_actionPerformed(ActionEvent e) + { + } - protected void strandColour_actionPerformed(ActionEvent e) { - } + protected void userDefinedColour_actionPerformed(ActionEvent e) + { + } - protected void turnColour_actionPerformed(ActionEvent e) { - } + protected void PIDColour_actionPerformed(ActionEvent e) + { + } - protected void buriedColour_actionPerformed(ActionEvent e) { - } + protected void BLOSUM62Colour_actionPerformed(ActionEvent e) + { + } - protected void userDefinedColour_actionPerformed(ActionEvent e) { - } + protected void noColourmenuItem_actionPerformed(ActionEvent e) + { + } - protected void PIDColour_actionPerformed(ActionEvent e) { - } + protected void conservationMenuItem_actionPerformed(ActionEvent e) + { + } - protected void BLOSUM62Colour_actionPerformed(ActionEvent e) { - } + protected void printMenuItem_actionPerformed(ActionEvent e) + { + } - protected void noColourmenuItem_actionPerformed(ActionEvent e) { - } + protected void renderGapsMenuItem_actionPerformed(ActionEvent e) + { + } - protected void conservationMenuItem_actionPerformed(ActionEvent e) { - } - - protected void printMenuItem_actionPerformed(ActionEvent e) { - } - - protected void renderGapsMenuItem_actionPerformed(ActionEvent e) { - } - - protected void findMenuItem_actionPerformed(ActionEvent e) { - } + protected void findMenuItem_actionPerformed(ActionEvent e) + { + } - protected void abovePIDThreshold_actionPerformed(ActionEvent e) { - } + protected void abovePIDThreshold_actionPerformed(ActionEvent e) + { + } - public void sequenceFeatures_actionPerformed(ActionEvent actionEvent) { - } + public void sequenceFeatures_actionPerformed(ActionEvent actionEvent) + { + } - protected void nucleotideColour_actionPerformed(ActionEvent e) { - } + protected void nucleotideColour_actionPerformed(ActionEvent e) + { + } - protected void deleteGroups_actionPerformed(ActionEvent e) { - } + protected void deleteGroups_actionPerformed(ActionEvent e) + { + } - protected void copy_actionPerformed(ActionEvent e) { - } + protected void copy_actionPerformed(ActionEvent e) + { + } - protected void cut_actionPerformed(ActionEvent e) { - } + protected void cut_actionPerformed(ActionEvent e) + { + } - protected void delete_actionPerformed(ActionEvent e) { - } + protected void delete_actionPerformed(ActionEvent e) + { + } - protected void pasteNew_actionPerformed(ActionEvent e) { - } + protected void pasteNew_actionPerformed(ActionEvent e) + { + } - protected void pasteThis_actionPerformed(ActionEvent e) { - } + protected void pasteThis_actionPerformed(ActionEvent e) + { + } - protected void applyToAllGroups_actionPerformed(ActionEvent e) { - } + protected void applyToAllGroups_actionPerformed(ActionEvent e) + { + } - protected void createPNG_actionPerformed(ActionEvent e) { - } + public void createPNG(java.io.File f) + { + } - protected void font_actionPerformed(ActionEvent e) { - } + protected void font_actionPerformed(ActionEvent e) + { + } - protected void fullSeqId_actionPerformed(ActionEvent e) { - } + protected void fullSeqId_actionPerformed(ActionEvent e) + { + } - protected void epsFile_actionPerformed(ActionEvent e) { - } + public void createEPS(java.io.File f) + { + } - protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { - } + protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) + { + } - protected void jpred_actionPerformed(ActionEvent e) { - } + protected void jpred_actionPerformed(ActionEvent e) + { + } - protected void scaleAbove_actionPerformed(ActionEvent e) { - } + protected void scaleAbove_actionPerformed(ActionEvent e) + { + } - protected void scaleLeft_actionPerformed(ActionEvent e) { - } + protected void scaleLeft_actionPerformed(ActionEvent e) + { + } - protected void scaleRight_actionPerformed(ActionEvent e) { - } + protected void scaleRight_actionPerformed(ActionEvent e) + { + } - protected void modifyPID_actionPerformed(ActionEvent e) { - } + protected void modifyPID_actionPerformed(ActionEvent e) + { + } - protected void modifyConservation_actionPerformed(ActionEvent e) { - } + protected void modifyConservation_actionPerformed(ActionEvent e) + { + } - protected void preferences_actionPerformed(ActionEvent e) { - } + protected void preferences_actionPerformed(ActionEvent e) + { + } - protected void msaAlignMenuItem_actionPerformed(ActionEvent e) { - } + protected void msaAlignMenuItem_actionPerformed(ActionEvent e) + { + } - protected void alignFrameMenuBar_ancestorAdded(AncestorEvent event) { - } + protected void alignFrameMenuBar_ancestorAdded(AncestorEvent event) + { + } - protected void saveAlignmentMenu_actionPerformed(ActionEvent e) { - } + protected void saveAlignmentMenu_actionPerformed(ActionEvent e) + { + } - protected void padGapsMenuitem_actionPerformed(ActionEvent e) { - } + protected void padGapsMenuitem_actionPerformed(ActionEvent e) + { + } - protected void ClustalRealign_actionPerformed(ActionEvent e) { - } + protected void ClustalRealign_actionPerformed(ActionEvent e) + { + } } diff --git a/src/jalview/jbgui/GAlignmentPanel.java b/src/jalview/jbgui/GAlignmentPanel.java index fc8b8dd..3bc577a 100755 --- a/src/jalview/jbgui/GAlignmentPanel.java +++ b/src/jalview/jbgui/GAlignmentPanel.java @@ -1,102 +1,122 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.jbgui; import java.awt.*; - import javax.swing.*; import javax.swing.border.*; +import java.awt.event.MouseWheelListener; +import java.awt.event.MouseWheelEvent; +public class GAlignmentPanel + extends JPanel +{ + protected JPanel sequenceHolderPanel = new JPanel(); + protected JScrollBar vscroll = new JScrollBar(); + protected JScrollBar hscroll = new JScrollBar(); + protected JPanel seqPanelHolder = new JPanel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + protected JPanel scalePanelHolder = new JPanel(); + protected JPanel idPanelHolder = new JPanel(); + BorderLayout borderLayout5 = new BorderLayout(); + protected JPanel idSpaceFillerPanel1 = new JPanel(); + public JPanel annotationSpaceFillerHolder = new JPanel(); + BorderLayout borderLayout6 = new BorderLayout(); + ButtonGroup buttonGroup1 = new ButtonGroup(); + BorderLayout borderLayout7 = new BorderLayout(); + JPanel hscrollHolder = new JPanel(); + BorderLayout borderLayout10 = new BorderLayout(); + protected JPanel hscrollFillerPanel = new JPanel(); + BorderLayout borderLayout11 = new BorderLayout(); + public JScrollPane annotationScroller = new JScrollPane(); + Border border1; + BorderLayout borderLayout4 = new BorderLayout(); -public class GAlignmentPanel extends JPanel { - protected JPanel sequenceHolderPanel = new JPanel(); - protected JScrollBar vscroll = new JScrollBar(); - protected JScrollBar hscroll = new JScrollBar(); - protected JPanel seqPanelHolder = new JPanel(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout3 = new BorderLayout(); - protected JPanel scalePanelHolder = new JPanel(); - protected JPanel idPanelHolder = new JPanel(); - BorderLayout borderLayout5 = new BorderLayout(); - protected JPanel idSpaceFillerPanel1 = new JPanel(); - public JPanel annotationSpaceFillerHolder = new JPanel(); - BorderLayout borderLayout6 = new BorderLayout(); - ButtonGroup buttonGroup1 = new ButtonGroup(); - BorderLayout borderLayout7 = new BorderLayout(); - JPanel hscrollHolder = new JPanel(); - BorderLayout borderLayout10 = new BorderLayout(); - protected JPanel hscrollFillerPanel = new JPanel(); - BorderLayout borderLayout11 = new BorderLayout(); - public JScrollPane annotationScroller = new JScrollPane(); - Border border1; - BorderLayout borderLayout4 = new BorderLayout(); - - public GAlignmentPanel() { - try { - jbInit(); - } catch (Exception e) { - e.printStackTrace(); - } + public GAlignmentPanel() + { + try + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); } + } - private void jbInit() throws Exception { - border1 = BorderFactory.createLineBorder(Color.gray, 1); - idPanelHolder.setBorder(null); - idPanelHolder.setPreferredSize(new Dimension(70, 10)); - this.setLayout(borderLayout7); - sequenceHolderPanel.setMaximumSize(new Dimension(2147483647, 2147483647)); - sequenceHolderPanel.setMinimumSize(new Dimension(150, 150)); - sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); - sequenceHolderPanel.setLayout(borderLayout3); - seqPanelHolder.setLayout(borderLayout1); - scalePanelHolder.setBackground(Color.white); - scalePanelHolder.setMinimumSize(new Dimension(10, 80)); - scalePanelHolder.setPreferredSize(new Dimension(10, 30)); - scalePanelHolder.setLayout(borderLayout6); - idPanelHolder.setLayout(borderLayout5); - idSpaceFillerPanel1.setBackground(Color.white); - idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); - idSpaceFillerPanel1.setLayout(borderLayout11); - annotationSpaceFillerHolder.setBackground(Color.white); - annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); - annotationSpaceFillerHolder.setLayout(borderLayout4); - hscroll.setOrientation(JScrollBar.HORIZONTAL); - hscrollHolder.setLayout(borderLayout10); - hscrollFillerPanel.setBackground(Color.white); - hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); - hscrollHolder.setBackground(Color.white); - annotationScroller.setBorder(null); - annotationScroller.setPreferredSize(new Dimension(10, 80)); - this.setPreferredSize(new Dimension(220, 166)); - this.setRequestFocusEnabled(true); - sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); - sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); - seqPanelHolder.add(vscroll, BorderLayout.EAST); - sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH); + private void jbInit() + throws Exception + { + border1 = BorderFactory.createLineBorder(Color.gray, 1); + idPanelHolder.setBorder(null); + idPanelHolder.setPreferredSize(new Dimension(70, 10)); + this.setLayout(borderLayout7); + sequenceHolderPanel.setMaximumSize(new Dimension(2147483647, 2147483647)); + sequenceHolderPanel.setMinimumSize(new Dimension(150, 150)); + sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); + sequenceHolderPanel.setLayout(borderLayout3); + seqPanelHolder.setLayout(borderLayout1); + scalePanelHolder.setBackground(Color.white); + scalePanelHolder.setMinimumSize(new Dimension(10, 80)); + scalePanelHolder.setPreferredSize(new Dimension(10, 30)); + scalePanelHolder.setLayout(borderLayout6); + idPanelHolder.setLayout(borderLayout5); + idSpaceFillerPanel1.setBackground(Color.white); + idSpaceFillerPanel1.setPreferredSize(new Dimension(10, 30)); + idSpaceFillerPanel1.setLayout(borderLayout11); + annotationSpaceFillerHolder.setBackground(Color.white); + annotationSpaceFillerHolder.setPreferredSize(new Dimension(10, 80)); + annotationSpaceFillerHolder.setLayout(borderLayout4); + hscroll.setOrientation(JScrollBar.HORIZONTAL); + hscrollHolder.setLayout(borderLayout10); + hscrollFillerPanel.setBackground(Color.white); + hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); + hscrollHolder.setBackground(Color.white); + annotationScroller.setBorder(null); + annotationScroller.setPreferredSize(new Dimension(10, 80)); + this.setPreferredSize(new Dimension(220, 166)); + this.setRequestFocusEnabled(true); + this.addMouseWheelListener(new MouseWheelListener() + { + public void mouseWheelMoved(MouseWheelEvent e) + { + this_mouseWheelMoved(e); + } + }); + sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); + sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); + seqPanelHolder.add(vscroll, BorderLayout.EAST); + sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH); - // jPanel3.add(secondaryPanelHolder, BorderLayout.SOUTH); - this.add(idPanelHolder, BorderLayout.WEST); - idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH); - idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH); - this.add(hscrollHolder, BorderLayout.SOUTH); - hscrollHolder.add(hscroll, BorderLayout.CENTER); - hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST); - this.add(sequenceHolderPanel, BorderLayout.CENTER); - } + // jPanel3.add(secondaryPanelHolder, BorderLayout.SOUTH); + this.add(idPanelHolder, BorderLayout.WEST); + idPanelHolder.add(idSpaceFillerPanel1, BorderLayout.NORTH); + idPanelHolder.add(annotationSpaceFillerHolder, BorderLayout.SOUTH); + this.add(hscrollHolder, BorderLayout.SOUTH); + hscrollHolder.add(hscroll, BorderLayout.CENTER); + hscrollHolder.add(hscrollFillerPanel, BorderLayout.WEST); + this.add(sequenceHolderPanel, BorderLayout.CENTER); + } + + public void this_mouseWheelMoved(MouseWheelEvent e) + { + + } } diff --git a/src/jalview/jbgui/GCutAndPasteTransfer.java b/src/jalview/jbgui/GCutAndPasteTransfer.java index e469571..0c42724 100755 --- a/src/jalview/jbgui/GCutAndPasteTransfer.java +++ b/src/jalview/jbgui/GCutAndPasteTransfer.java @@ -28,7 +28,14 @@ import java.beans.VetoableChangeListener; import javax.swing.*; -public class GCutAndPasteTransfer extends JInternalFrame { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GCutAndPasteTransfer extends JInternalFrame +{ protected JTextArea textarea = new JTextArea(); protected JScrollPane scrollPane = new JScrollPane(); BorderLayout borderLayout1 = new BorderLayout(); @@ -41,57 +48,85 @@ public class GCutAndPasteTransfer extends JInternalFrame { JButton ok = new JButton(); JButton cancel = new JButton(); - public GCutAndPasteTransfer() { - try { + /** + * Creates a new GCutAndPasteTransfer object. + */ + public GCutAndPasteTransfer() + { + try + { setJMenuBar(editMenubar); jbInit(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { scrollPane.setBorder(null); ok.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); ok.setText("Accept"); - ok.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + ok.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { ok_actionPerformed(e); } }); cancel.setText("Cancel"); - cancel.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + cancel.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { cancel_actionPerformed(e); } }); textarea.setBorder(null); - textarea.addVetoableChangeListener(new VetoableChangeListener() { - public void vetoableChange(PropertyChangeEvent evt) { - try { + textarea.addVetoableChangeListener(new VetoableChangeListener() + { + public void vetoableChange(PropertyChangeEvent evt) + { + try + { textarea_vetoableChange(evt); - } catch (java.beans.PropertyVetoException exception0) { + } + catch (java.beans.PropertyVetoException exception0) + { exception0.printStackTrace(); } } }); editMenubar.add(editMenu); textarea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 12)); - textarea.addMouseListener(new java.awt.event.MouseAdapter() { - public void mousePressed(MouseEvent e) { + textarea.addMouseListener(new java.awt.event.MouseAdapter() + { + public void mousePressed(MouseEvent e) + { textarea_mousePressed(e); } }); editMenu.setText("Edit"); pasteMenu.setText("Paste"); - pasteMenu.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + pasteMenu.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { pasteMenu_actionPerformed(e); } }); copyItem.setText("Copy"); - copyItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + copyItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { copyItem_actionPerformed(e); } }); @@ -105,25 +140,64 @@ public class GCutAndPasteTransfer extends JInternalFrame { inputButtonPanel.add(cancel); } - void textarea_mousePressed(MouseEvent e) { - if (textarea.getText().equals("Paste your alignment file here")) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + void textarea_mousePressed(MouseEvent e) + { + if (textarea.getText().equals("Paste your alignment file here")) + { textarea.setText(""); } } - public void copyItem_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void copyItem_actionPerformed(ActionEvent e) + { } - public void pasteMenu_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void pasteMenu_actionPerformed(ActionEvent e) + { } - public void ok_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void ok_actionPerformed(ActionEvent e) + { } - public void cancel_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void cancel_actionPerformed(ActionEvent e) + { } + /** + * DOCUMENT ME! + * + * @param evt DOCUMENT ME! + * + * @throws PropertyVetoException DOCUMENT ME! + */ public void textarea_vetoableChange(PropertyChangeEvent evt) - throws PropertyVetoException { + throws PropertyVetoException + { } } diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 162f7e1..65ef8dc 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -24,7 +24,14 @@ import java.awt.event.*; import javax.swing.*; -public class GDesktop extends JFrame { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GDesktop extends JFrame +{ protected static JMenu windowMenu = new JMenu(); JMenuBar DesktopMenubar = new JMenuBar(); JMenu FileMenu = new JMenu(); @@ -42,79 +49,110 @@ public class GDesktop extends JFrame { JMenuItem loadState = new JMenuItem(); JMenu jMenu1 = new JMenu(); - public GDesktop() { - try { + /** + * Creates a new GDesktop object. + */ + public GDesktop() + { + try + { jbInit(); this.setJMenuBar(DesktopMenubar); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { FileMenu.setMnemonic('F'); FileMenu.setText("File"); HelpMenu.setText("Help"); inputLocalFileMenuItem.setMnemonic('L'); inputLocalFileMenuItem.setText("from File"); - inputLocalFileMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + inputLocalFileMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { inputLocalFileMenuItem_actionPerformed(e); } }); inputURLMenuItem.setMnemonic('U'); inputURLMenuItem.setText("from URL"); - inputURLMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + inputURLMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { inputURLMenuItem_actionPerformed(e); } }); inputTextboxMenuItem.setMnemonic('C'); inputTextboxMenuItem.setText("from Textbox"); - inputTextboxMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + inputTextboxMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { inputTextboxMenuItem_actionPerformed(e); } }); quit.setMnemonic('Q'); quit.setText("Quit"); - quit.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + quit.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { quit(); } }); aboutMenuItem.setText("About"); - aboutMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + aboutMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { aboutMenuItem_actionPerformed(e); } }); documentationMenuItem.setText("Documentation"); - documentationMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + documentationMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { documentationMenuItem_actionPerformed(e); } }); this.getContentPane().setLayout(flowLayout1); windowMenu.setText("Window"); preferences.setText("Preferences..."); - preferences.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + preferences.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { preferences_actionPerformed(e); } }); toolsMenu.setText("Tools"); saveState.setMnemonic('S'); saveState.setText("Save Project"); - saveState.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + saveState.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { saveState_actionPerformed(e); } }); loadState.setMnemonic('L'); loadState.setText("Load Project"); - loadState.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + loadState.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { loadState_actionPerformed(e); } }); @@ -139,36 +177,100 @@ public class GDesktop extends JFrame { jMenu1.add(inputTextboxMenuItem); } - protected void inputLocalFileMenuItem_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void inputLocalFileMenuItem_actionPerformed(ActionEvent e) + { } - protected void inputURLMenuItem_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void inputURLMenuItem_actionPerformed(ActionEvent e) + { } - protected void inputTextboxMenuItem_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void inputTextboxMenuItem_actionPerformed(ActionEvent e) + { } - protected void quit() { + /** + * DOCUMENT ME! + */ + protected void quit() + { } - protected void aboutMenuItem_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void aboutMenuItem_actionPerformed(ActionEvent e) + { } - protected void documentationMenuItem_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void documentationMenuItem_actionPerformed(ActionEvent e) + { } - public void SaveState_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void SaveState_actionPerformed(ActionEvent e) + { } - protected void preferences_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void preferences_actionPerformed(ActionEvent e) + { } - public void saveState_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void saveState_actionPerformed(ActionEvent e) + { } - public void loadState_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void loadState_actionPerformed(ActionEvent e) + { } - public void loadJalviewAlign_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void loadJalviewAlign_actionPerformed(ActionEvent e) + { } } diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index 554d8bc..0f9f0d4 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -1,37 +1,37 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.jbgui; import java.awt.*; import java.awt.event.*; - import javax.swing.*; -import javax.swing.event.CaretListener; -import javax.swing.event.CaretEvent; +import javax.swing.event.*; -public class GFinder extends JPanel { - JLabel jLabel1 = new JLabel(); +public class GFinder + extends JPanel +{ + JLabel jLabel1 = new JLabel(); protected JButton findAll = new JButton(); - protected JButton findNext = new JButton(); - JPanel jPanel1 = new JPanel(); - GridLayout gridLayout1 = new GridLayout(); - protected JButton createNewGroup = new JButton(); + protected JButton findNext = new JButton(); + JPanel jPanel1 = new JPanel(); + GridLayout gridLayout1 = new GridLayout(); + protected JButton createNewGroup = new JButton(); JScrollPane jScrollPane1 = new JScrollPane(); protected JTextArea textfield = new JTextArea(); BorderLayout borderLayout1 = new BorderLayout(); @@ -41,47 +41,59 @@ public class GFinder extends JPanel { BorderLayout borderLayout2 = new BorderLayout(); JPanel jPanel5 = new JPanel(); JPanel jPanel6 = new JPanel(); - public GFinder() { - try { - jbInit(); - } catch (Exception e) { - e.printStackTrace(); - } + public GFinder() + { + try + { + jbInit(); } + catch (Exception e) + { + e.printStackTrace(); + } + } - private void jbInit() throws Exception { - jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); - jLabel1.setText("Find"); + private void jbInit() + throws Exception + { + jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel1.setText("Find"); this.setLayout(borderLayout1); findAll.setFont(new java.awt.Font("Verdana", 0, 12)); - findAll.setText("Find all"); - findAll.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - findAll_actionPerformed(e); - } - }); - findNext.setEnabled(false); - findNext.setFont(new java.awt.Font("Verdana", 0, 12)); - findNext.setText("Find Next"); - findNext.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - findNext_actionPerformed(e); - } - }); + findAll.setText("Find all"); + findAll.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + findAll_actionPerformed(e); + } + }); + findNext.setEnabled(false); + findNext.setFont(new java.awt.Font("Verdana", 0, 12)); + findNext.setText("Find Next"); + findNext.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + findNext_actionPerformed(e); + } + }); jPanel1.setLayout(gridLayout1); - gridLayout1.setHgap(0); - gridLayout1.setRows(3); - gridLayout1.setVgap(2); - createNewGroup.setEnabled(false); - createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12)); - createNewGroup.setToolTipText(""); - createNewGroup.setMargin(new Insets(0, 0, 0, 0)); - createNewGroup.setText("Create new group"); - createNewGroup.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - createNewGroup_actionPerformed(e); - } - }); + gridLayout1.setHgap(0); + gridLayout1.setRows(3); + gridLayout1.setVgap(2); + createNewGroup.setEnabled(false); + createNewGroup.setFont(new java.awt.Font("Verdana", 0, 12)); + createNewGroup.setToolTipText(""); + createNewGroup.setMargin(new Insets(0, 0, 0, 0)); + createNewGroup.setText("Create new group"); + createNewGroup.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + createNewGroup_actionPerformed(e); + } + }); textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 12)); textfield.setText(""); textfield.setLineWrap(true); @@ -98,8 +110,8 @@ public class GFinder extends JPanel { jPanel2.setPreferredSize(new Dimension(10, 1)); jPanel3.setPreferredSize(new Dimension(10, 1)); jPanel1.add(findNext, null); - jPanel1.add(findAll, null); - jPanel1.add(createNewGroup, null); + jPanel1.add(findAll, null); + jPanel1.add(createNewGroup, null); this.add(jLabel1, java.awt.BorderLayout.WEST); this.add(jPanel1, java.awt.BorderLayout.EAST); this.add(jPanel2, java.awt.BorderLayout.SOUTH); @@ -111,35 +123,40 @@ public class GFinder extends JPanel { jScrollPane1.getViewport().add(textfield); } - protected void findNext_actionPerformed(ActionEvent e) { - } + protected void findNext_actionPerformed(ActionEvent e) + { + } - protected void findAll_actionPerformed(ActionEvent e) { - } + protected void findAll_actionPerformed(ActionEvent e) + { + } - protected void textfield_actionPerformed(ActionEvent e) { - } + protected void textfield_actionPerformed(ActionEvent e) + { + } - void textfield_keyTyped(KeyEvent e) { - findNext.setEnabled(true); - } + void textfield_keyTyped(KeyEvent e) + { + findNext.setEnabled(true); + } - public void createNewGroup_actionPerformed(ActionEvent e) { - } + public void createNewGroup_actionPerformed(ActionEvent e) + { + } public void textfield_caretUpdate(CaretEvent e) { - if (textfield.getText().indexOf("\t")>-1) + if (textfield.getText().indexOf("\t") > -1) { SwingUtilities.invokeLater(new Runnable() { public void run() { - String text = textfield.getText(); - text = text.substring(text.lastIndexOf("\t") + 1).trim(); - text = jalview.analysis.AlignSeq.extractGaps( - jalview.util.Comparison.GapChars, text); - textfield.setText(text); + String text = textfield.getText(); + text = text.substring(text.lastIndexOf("\t") + 1).trim(); + text = jalview.analysis.AlignSeq.extractGaps( + jalview.util.Comparison.GapChars, text); + textfield.setText(text); } }); } diff --git a/src/jalview/jbgui/GFontChooser.java b/src/jalview/jbgui/GFontChooser.java index 4ca3b42..f6a1e07 100755 --- a/src/jalview/jbgui/GFontChooser.java +++ b/src/jalview/jbgui/GFontChooser.java @@ -24,7 +24,14 @@ import java.awt.event.*; import javax.swing.*; -public class GFontChooser extends JPanel { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GFontChooser extends JPanel +{ JLabel jLabel1 = new JLabel(); protected JComboBox fontSize = new JComboBox(); protected JComboBox fontStyle = new JComboBox(); @@ -42,15 +49,28 @@ public class GFontChooser extends JPanel { FlowLayout flowLayout1 = new FlowLayout(); JButton defaultButton = new JButton(); - public GFontChooser() { - try { + /** + * Creates a new GFontChooser object. + */ + public GFontChooser() + { + try + { jbInit(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { jLabel1.setFont(new java.awt.Font("Verdana", 0, 11)); jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); jLabel1.setText("Font: "); @@ -59,16 +79,20 @@ public class GFontChooser extends JPanel { fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); fontSize.setOpaque(false); fontSize.setPreferredSize(new Dimension(50, 21)); - fontSize.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + fontSize.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { fontSize_actionPerformed(e); } }); fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); fontStyle.setOpaque(false); fontStyle.setPreferredSize(new Dimension(90, 21)); - fontStyle.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + fontStyle.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { fontStyle_actionPerformed(e); } }); @@ -85,22 +109,28 @@ public class GFontChooser extends JPanel { fontName.setMinimumSize(new Dimension(300, 21)); fontName.setOpaque(false); fontName.setPreferredSize(new Dimension(180, 21)); - fontName.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + fontName.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { fontName_actionPerformed(e); } }); ok.setFont(new java.awt.Font("Verdana", 0, 11)); ok.setText("OK"); - ok.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + ok.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { ok_actionPerformed(e); } }); cancel.setFont(new java.awt.Font("Verdana", 0, 11)); cancel.setText("Cancel"); - cancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + cancel.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { cancel_actionPerformed(e); } }); @@ -114,8 +144,10 @@ public class GFontChooser extends JPanel { flowLayout1.setAlignment(FlowLayout.CENTER); flowLayout1.setVgap(5); defaultButton.setText("Set as Default"); - defaultButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + defaultButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { defaultButton_actionPerformed(e); } }); @@ -133,21 +165,57 @@ public class GFontChooser extends JPanel { this.add(defaultButton); } - protected void ok_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void ok_actionPerformed(ActionEvent e) + { } - protected void cancel_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cancel_actionPerformed(ActionEvent e) + { } - protected void fontName_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void fontName_actionPerformed(ActionEvent e) + { } - protected void fontSize_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void fontSize_actionPerformed(ActionEvent e) + { } - protected void fontStyle_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void fontStyle_actionPerformed(ActionEvent e) + { } - public void defaultButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void defaultButton_actionPerformed(ActionEvent e) + { } } diff --git a/src/jalview/jbgui/GPCAPanel.java b/src/jalview/jbgui/GPCAPanel.java index 41d188e..7fc21a9 100755 --- a/src/jalview/jbgui/GPCAPanel.java +++ b/src/jalview/jbgui/GPCAPanel.java @@ -1,98 +1,114 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.jbgui; import java.awt.*; import java.awt.event.*; - import javax.swing.*; +public class GPCAPanel + extends JPanel +{ + JPanel jPanel2 = new JPanel(); + JLabel jLabel1 = new JLabel(); + JLabel jLabel2 = new JLabel(); + JLabel jLabel3 = new JLabel(); + protected JComboBox xCombobox = new JComboBox(); + protected JComboBox yCombobox = new JComboBox(); + protected JComboBox zCombobox = new JComboBox(); + FlowLayout flowLayout1 = new FlowLayout(); + BorderLayout borderLayout1 = new BorderLayout(); -public class GPCAPanel extends JPanel { - JPanel jPanel2 = new JPanel(); - JLabel jLabel1 = new JLabel(); - JLabel jLabel2 = new JLabel(); - JLabel jLabel3 = new JLabel(); - protected JComboBox xCombobox = new JComboBox(); - protected JComboBox yCombobox = new JComboBox(); - protected JComboBox zCombobox = new JComboBox(); - FlowLayout flowLayout1 = new FlowLayout(); - BorderLayout borderLayout1 = new BorderLayout(); - - public GPCAPanel() { - try { - jbInit(); - } catch (Exception e) { - e.printStackTrace(); - } - - for (int i = 1; i < 8; i++) { - xCombobox.addItem("dim " + i); - yCombobox.addItem("dim " + i); - zCombobox.addItem("dim " + i); - } + public GPCAPanel() + { + try + { + jbInit(); } - - private void jbInit() throws Exception { - this.setLayout(borderLayout1); - jPanel2.setLayout(flowLayout1); - jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); - jLabel1.setText("x="); - jLabel2.setFont(new java.awt.Font("Verdana", 0, 12)); - jLabel2.setText("y="); - jLabel3.setFont(new java.awt.Font("Verdana", 0, 12)); - jLabel3.setText("z="); - jPanel2.setBackground(Color.white); - jPanel2.setBorder(null); - zCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); - zCombobox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - zCombobox_actionPerformed(e); - } - }); - yCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); - yCombobox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - yCombobox_actionPerformed(e); - } - }); - xCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); - xCombobox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - xCombobox_actionPerformed(e); - } - }); - this.add(jPanel2, BorderLayout.SOUTH); - jPanel2.add(jLabel1, null); - jPanel2.add(xCombobox, null); - jPanel2.add(jLabel2, null); - jPanel2.add(yCombobox, null); - jPanel2.add(jLabel3, null); - jPanel2.add(zCombobox, null); + catch (Exception e) + { + e.printStackTrace(); } - protected void xCombobox_actionPerformed(ActionEvent e) { + for (int i = 1; i < 8; i++) + { + xCombobox.addItem("dim " + i); + yCombobox.addItem("dim " + i); + zCombobox.addItem("dim " + i); } + } - protected void yCombobox_actionPerformed(ActionEvent e) { - } + private void jbInit() + throws Exception + { + this.setLayout(borderLayout1); + jPanel2.setLayout(flowLayout1); + jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel1.setText("x="); + jLabel2.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel2.setText("y="); + jLabel3.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel3.setText("z="); + jPanel2.setBackground(Color.white); + jPanel2.setBorder(null); + zCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + zCombobox.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + zCombobox_actionPerformed(e); + } + }); + yCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + yCombobox.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + yCombobox_actionPerformed(e); + } + }); + xCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + xCombobox.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + xCombobox_actionPerformed(e); + } + }); + this.add(jPanel2, BorderLayout.SOUTH); + jPanel2.add(jLabel1, null); + jPanel2.add(xCombobox, null); + jPanel2.add(jLabel2, null); + jPanel2.add(yCombobox, null); + jPanel2.add(jLabel3, null); + jPanel2.add(zCombobox, null); + } - protected void zCombobox_actionPerformed(ActionEvent e) { - } + protected void xCombobox_actionPerformed(ActionEvent e) + { + } + + protected void yCombobox_actionPerformed(ActionEvent e) + { + } + + protected void zCombobox_actionPerformed(ActionEvent e) + { + } } diff --git a/src/jalview/jbgui/GPairwiseAlignPanel.java b/src/jalview/jbgui/GPairwiseAlignPanel.java index 96a1a40..7f9eea2 100755 --- a/src/jalview/jbgui/GPairwiseAlignPanel.java +++ b/src/jalview/jbgui/GPairwiseAlignPanel.java @@ -24,30 +24,52 @@ import java.awt.event.*; import javax.swing.*; -public class GPairwiseAlignPanel extends JPanel { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GPairwiseAlignPanel extends JPanel +{ protected JScrollPane scrollPane = new JScrollPane(); protected JTextArea textarea = new JTextArea(); protected JButton viewInEditorButton = new JButton(); JPanel jPanel1 = new JPanel(); BorderLayout borderLayout1 = new BorderLayout(); - public GPairwiseAlignPanel() { - try { + /** + * Creates a new GPairwiseAlignPanel object. + */ + public GPairwiseAlignPanel() + { + try + { jbInit(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { this.setLayout(borderLayout1); textarea.setFont(new java.awt.Font("Monospaced", 0, 12)); textarea.setText(""); textarea.setWrapStyleWord(false); viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12)); viewInEditorButton.setText("View in alignment editor"); - viewInEditorButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + viewInEditorButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { viewInEditorButton_actionPerformed(e); } }); @@ -57,6 +79,12 @@ public class GPairwiseAlignPanel extends JPanel { jPanel1.add(viewInEditorButton, null); } - protected void viewInEditorButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void viewInEditorButton_actionPerformed(ActionEvent e) + { } } diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 04ac596..fd61014 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -28,7 +28,14 @@ import javax.swing.*; import javax.swing.border.TitledBorder; -public class GPreferences extends JPanel { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GPreferences extends JPanel +{ JTabbedPane visaulTab = new JTabbedPane(); JPanel visual = new JPanel(); JButton ok = new JButton(); @@ -54,25 +61,42 @@ public class GPreferences extends JPanel { protected JCheckBox startupCheckbox = new JCheckBox(); protected JTextField startupFileTextfield = new JTextField(); - public GPreferences() { - try { + /** + * Creates a new GPreferences object. + */ + public GPreferences() + { + try + { jbInit(); - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { this.setLayout(borderLayout1); ok.setText("OK"); - ok.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + ok.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { ok_actionPerformed(e); } }); cancel.setText("Cancel"); - cancel.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + cancel.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { cancel_actionPerformed(e); } }); @@ -117,8 +141,10 @@ public class GPreferences extends JPanel { annotations.setSelected(true); annotations.setText("Show Annotations"); annotations.setBounds(new Rectangle(10, 53, 128, 23)); - annotations.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + annotations.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { annotations_actionPerformed(e); } }); @@ -146,8 +172,10 @@ public class GPreferences extends JPanel { gapSymbolCB.setBounds(new Rectangle(121, 140, 67, 21)); startupCheckbox.setText("Open file"); startupCheckbox.setBounds(new Rectangle(4, 200, 115, 23)); - startupCheckbox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + startupCheckbox.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { jCheckBox1_actionPerformed(e); } }); @@ -157,10 +185,14 @@ public class GPreferences extends JPanel { startupCheckbox.setSelected(true); startupFileTextfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); startupFileTextfield.setBounds(new Rectangle(122, 202, 309, 20)); - startupFileTextfield.addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent e) { - if(e.getClickCount()>1) - startupFileTextfield_mouseClicked(); + startupFileTextfield.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + if (e.getClickCount() > 1) + { + startupFileTextfield_mouseClicked(); + } } }); @@ -192,18 +224,46 @@ public class GPreferences extends JPanel { gapSymbolCB.setRenderer(dlcr); } - public void ok_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void ok_actionPerformed(ActionEvent e) + { } - public void cancel_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void cancel_actionPerformed(ActionEvent e) + { } - public void annotations_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void annotations_actionPerformed(ActionEvent e) + { } - public void jCheckBox1_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + public void jCheckBox1_actionPerformed(ActionEvent e) + { } - public void startupFileTextfield_mouseClicked() { + /** + * DOCUMENT ME! + */ + public void startupFileTextfield_mouseClicked() + { } } diff --git a/src/jalview/jbgui/GSliderPanel.java b/src/jalview/jbgui/GSliderPanel.java index 341263f..c452d11 100755 --- a/src/jalview/jbgui/GSliderPanel.java +++ b/src/jalview/jbgui/GSliderPanel.java @@ -24,7 +24,14 @@ import java.awt.event.*; import javax.swing.*; -public class GSliderPanel extends JPanel { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GSliderPanel extends JPanel +{ // this is used for conservation colours, PID colours and redundancy threshold protected JSlider slider = new JSlider(); protected JTextField valueField = new JTextField(); @@ -38,15 +45,28 @@ public class GSliderPanel extends JPanel { protected JCheckBox allGroupsCheck = new JCheckBox(); BorderLayout borderLayout1 = new BorderLayout(); - public GSliderPanel() { - try { + /** + * Creates a new GSliderPanel object. + */ + public GSliderPanel() + { + try + { jbInit(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { this.setLayout(gridLayout1); slider.setMajorTickSpacing(10); slider.setMinorTickSpacing(1); @@ -59,8 +79,10 @@ public class GSliderPanel extends JPanel { valueField.setPreferredSize(new Dimension(50, 12)); valueField.setText(""); valueField.setHorizontalAlignment(SwingConstants.CENTER); - valueField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + valueField.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { valueField_actionPerformed(e); } }); @@ -74,8 +96,10 @@ public class GSliderPanel extends JPanel { applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); applyButton.setOpaque(false); applyButton.setText("Apply"); - applyButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + applyButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { applyButton_actionPerformed(e); } }); @@ -83,8 +107,10 @@ public class GSliderPanel extends JPanel { undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); undoButton.setOpaque(false); undoButton.setText("Undo"); - undoButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + undoButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { undoButton_actionPerformed(e); } }); @@ -92,8 +118,10 @@ public class GSliderPanel extends JPanel { allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); allGroupsCheck.setOpaque(false); allGroupsCheck.setText("Apply to all Groups"); - allGroupsCheck.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + allGroupsCheck.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { allGroupsCheck_actionPerformed(e); } }); @@ -111,15 +139,39 @@ public class GSliderPanel extends JPanel { jPanel1.add(allGroupsCheck, BorderLayout.EAST); } - protected void valueField_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void valueField_actionPerformed(ActionEvent e) + { } - protected void applyButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void applyButton_actionPerformed(ActionEvent e) + { } - protected void undoButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void undoButton_actionPerformed(ActionEvent e) + { } - protected void allGroupsCheck_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void allGroupsCheck_actionPerformed(ActionEvent e) + { } } diff --git a/src/jalview/jbgui/GTreePanel.java b/src/jalview/jbgui/GTreePanel.java index 088dbde..24e80b6 100755 --- a/src/jalview/jbgui/GTreePanel.java +++ b/src/jalview/jbgui/GTreePanel.java @@ -1,170 +1,206 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.jbgui; import java.awt.*; import java.awt.event.*; - import javax.swing.*; - -public class GTreePanel extends JInternalFrame { - BorderLayout borderLayout1 = new BorderLayout(); - public JScrollPane scrollPane = new JScrollPane(); - JMenuBar jMenuBar1 = new JMenuBar(); - JMenu jMenu1 = new JMenu(); - JMenuItem saveAsNewick = new JMenuItem(); - JMenuItem printMenu = new JMenuItem(); - JMenu jMenu2 = new JMenu(); - public JMenuItem fontSize = new JMenuItem(); - public JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem(); - public JCheckBoxMenuItem placeholdersMenu = new JCheckBoxMenuItem(); - JMenuItem pngTree = new JMenuItem(); - JMenuItem epsTree = new JMenuItem(); - JMenu saveAsMenu = new JMenu(); - JMenuItem textbox = new JMenuItem(); - - public GTreePanel() { - try { - jbInit(); - this.setJMenuBar(jMenuBar1); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void jbInit() throws Exception { - this.getContentPane().setLayout(borderLayout1); - this.setBackground(Color.white); - this.setFont(new java.awt.Font("Verdana", 0, 12)); - scrollPane.setOpaque(false); - jMenu1.setText("File"); - saveAsNewick.setText("Newick Format"); - saveAsNewick.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - saveAsNewick_actionPerformed(e); - } - }); - printMenu.setText("Print"); - printMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - printMenu_actionPerformed(e); - } - }); - jMenu2.setText("View"); - fontSize.setText("Font Size - 12"); - fontSize.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - fontSize_actionPerformed(e); - } - }); - bootstrapMenu.setText("Show Bootstrap Values"); - bootstrapMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - bootstrapMenu_actionPerformed(e); - } - }); - distanceMenu.setText("Show Distances"); - distanceMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - distanceMenu_actionPerformed(e); - } - }); - fitToWindow.setSelected(true); - fitToWindow.setText("Fit To Window"); - fitToWindow.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - fitToWindow_actionPerformed(e); - } - }); - epsTree.setText("EPS"); - epsTree.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - epsTree_actionPerformed(e); - } - }); - pngTree.setText("PNG"); - pngTree.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - pngTree_actionPerformed(e); - } - }); - saveAsMenu.setText("Save as"); - placeholdersMenu.setToolTipText( - "Marks leaves of tree not associated with a sequence"); - placeholdersMenu.setText("Mark Unlinked Leaves"); - placeholdersMenu.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - placeholdersMenu_actionPerformed(e); - } - }); - textbox.setText("Output to Textbox..."); - textbox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - textbox_actionPerformed(e); - } - }); - this.getContentPane().add(scrollPane, BorderLayout.CENTER); - jMenuBar1.add(jMenu1); - jMenuBar1.add(jMenu2); - jMenu1.add(saveAsMenu); - jMenu1.add(textbox); - jMenu1.add(printMenu); - jMenu2.add(fitToWindow); - jMenu2.add(fontSize); - jMenu2.add(distanceMenu); - jMenu2.add(bootstrapMenu); - jMenu2.add(placeholdersMenu); - saveAsMenu.add(saveAsNewick); - saveAsMenu.add(epsTree); - saveAsMenu.add(pngTree); - } - - public void printMenu_actionPerformed(ActionEvent e) { - } - - public void fontSize_actionPerformed(ActionEvent e) { - } - - public void distanceMenu_actionPerformed(ActionEvent e) { - } - - public void bootstrapMenu_actionPerformed(ActionEvent e) { - } - - public void fitToWindow_actionPerformed(ActionEvent e) { - } - - public void pngTree_actionPerformed(ActionEvent e) { - } - - public void epsTree_actionPerformed(ActionEvent e) { - } - - public void saveAsNewick_actionPerformed(ActionEvent e) { +public class GTreePanel + extends JInternalFrame +{ + BorderLayout borderLayout1 = new BorderLayout(); + public JScrollPane scrollPane = new JScrollPane(); + JMenuBar jMenuBar1 = new JMenuBar(); + JMenu jMenu1 = new JMenu(); + JMenuItem saveAsNewick = new JMenuItem(); + JMenuItem printMenu = new JMenuItem(); + JMenu jMenu2 = new JMenu(); + public JMenuItem fontSize = new JMenuItem(); + public JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem placeholdersMenu = new JCheckBoxMenuItem(); + JMenuItem pngTree = new JMenuItem(); + JMenuItem epsTree = new JMenuItem(); + JMenu saveAsMenu = new JMenu(); + JMenuItem textbox = new JMenuItem(); + + public GTreePanel() + { + try + { + jbInit(); + this.setJMenuBar(jMenuBar1); } - - public void placeholdersMenu_actionPerformed(ActionEvent e) { - } - - public void textbox_actionPerformed(ActionEvent e) { + catch (Exception e) + { + e.printStackTrace(); } + } + + private void jbInit() + throws Exception + { + this.getContentPane().setLayout(borderLayout1); + this.setBackground(Color.white); + this.setFont(new java.awt.Font("Verdana", 0, 12)); + scrollPane.setOpaque(false); + jMenu1.setText("File"); + saveAsNewick.setText("Newick Format"); + saveAsNewick.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + saveAsNewick_actionPerformed(e); + } + }); + printMenu.setText("Print"); + printMenu.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + printMenu_actionPerformed(e); + } + }); + jMenu2.setText("View"); + fontSize.setText("Font Size - 12"); + fontSize.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + fontSize_actionPerformed(e); + } + }); + bootstrapMenu.setText("Show Bootstrap Values"); + bootstrapMenu.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + bootstrapMenu_actionPerformed(e); + } + }); + distanceMenu.setText("Show Distances"); + distanceMenu.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + distanceMenu_actionPerformed(e); + } + }); + fitToWindow.setSelected(true); + fitToWindow.setText("Fit To Window"); + fitToWindow.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + fitToWindow_actionPerformed(e); + } + }); + epsTree.setText("EPS"); + epsTree.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + epsTree_actionPerformed(e); + } + }); + pngTree.setText("PNG"); + pngTree.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + pngTree_actionPerformed(e); + } + }); + saveAsMenu.setText("Save as"); + placeholdersMenu.setToolTipText( + "Marks leaves of tree not associated with a sequence"); + placeholdersMenu.setText("Mark Unlinked Leaves"); + placeholdersMenu.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + placeholdersMenu_actionPerformed(e); + } + }); + textbox.setText("Output to Textbox..."); + textbox.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + textbox_actionPerformed(e); + } + }); + this.getContentPane().add(scrollPane, BorderLayout.CENTER); + jMenuBar1.add(jMenu1); + jMenuBar1.add(jMenu2); + jMenu1.add(saveAsMenu); + jMenu1.add(textbox); + jMenu1.add(printMenu); + jMenu2.add(fitToWindow); + jMenu2.add(fontSize); + jMenu2.add(distanceMenu); + jMenu2.add(bootstrapMenu); + jMenu2.add(placeholdersMenu); + saveAsMenu.add(saveAsNewick); + saveAsMenu.add(epsTree); + saveAsMenu.add(pngTree); + } + + public void printMenu_actionPerformed(ActionEvent e) + { + } + + public void fontSize_actionPerformed(ActionEvent e) + { + } + + public void distanceMenu_actionPerformed(ActionEvent e) + { + } + + public void bootstrapMenu_actionPerformed(ActionEvent e) + { + } + + public void fitToWindow_actionPerformed(ActionEvent e) + { + } + + public void pngTree_actionPerformed(ActionEvent e) + { + } + + public void epsTree_actionPerformed(ActionEvent e) + { + } + + public void saveAsNewick_actionPerformed(ActionEvent e) + { + } + + public void placeholdersMenu_actionPerformed(ActionEvent e) + { + } + + public void textbox_actionPerformed(ActionEvent e) + { + } } diff --git a/src/jalview/jbgui/GUserDefinedColours.java b/src/jalview/jbgui/GUserDefinedColours.java index 3cd9f51..49174a0 100755 --- a/src/jalview/jbgui/GUserDefinedColours.java +++ b/src/jalview/jbgui/GUserDefinedColours.java @@ -24,7 +24,14 @@ import java.awt.event.*; import javax.swing.*; -public class GUserDefinedColours extends JPanel { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GUserDefinedColours extends JPanel +{ protected JColorChooser colorChooser = new JColorChooser(); protected JPanel buttonPanel = new JPanel(); protected GridLayout gridLayout = new GridLayout(); @@ -36,51 +43,74 @@ public class GUserDefinedColours extends JPanel { protected JButton cancelButton = new JButton(); FlowLayout flowLayout1 = new FlowLayout(); - public GUserDefinedColours() { - try { + /** + * Creates a new GUserDefinedColours object. + */ + public GUserDefinedColours() + { + try + { jbInit(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { this.setLayout(flowLayout1); buttonPanel.setLayout(gridLayout); gridLayout.setColumns(6); gridLayout.setRows(4); okButton.setFont(new java.awt.Font("Verdana", 0, 11)); okButton.setText("OK"); - okButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + okButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { okButton_actionPerformed(e); } }); applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); applyButton.setText("Apply"); - applyButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + applyButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { applyButton_actionPerformed(e); } }); loadbutton.setFont(new java.awt.Font("Verdana", 0, 11)); loadbutton.setText("Load scheme"); - loadbutton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + loadbutton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { loadbutton_actionPerformed(e); } }); savebutton.setFont(new java.awt.Font("Verdana", 0, 11)); savebutton.setText("Save scheme"); - savebutton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + savebutton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { savebutton_actionPerformed(e); } }); cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); cancelButton.setText("Cancel"); - cancelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + cancelButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { cancelButton_actionPerformed(e); } }); @@ -97,18 +127,48 @@ public class GUserDefinedColours extends JPanel { jPanel2.add(cancelButton, null); } - protected void okButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void okButton_actionPerformed(ActionEvent e) + { } - protected void applyButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void applyButton_actionPerformed(ActionEvent e) + { } - protected void loadbutton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void loadbutton_actionPerformed(ActionEvent e) + { } - protected void savebutton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void savebutton_actionPerformed(ActionEvent e) + { } - protected void cancelButton_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cancelButton_actionPerformed(ActionEvent e) + { } } diff --git a/src/jalview/jbgui/GWebserviceInfo.java b/src/jalview/jbgui/GWebserviceInfo.java index 54eab04..6f8bbd7 100755 --- a/src/jalview/jbgui/GWebserviceInfo.java +++ b/src/jalview/jbgui/GWebserviceInfo.java @@ -24,7 +24,14 @@ import java.awt.event.*; import javax.swing.*; -public class GWebserviceInfo extends JPanel { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class GWebserviceInfo extends JPanel +{ protected JTextArea infoText = new JTextArea(); JScrollPane jScrollPane1 = new JScrollPane(); JScrollPane jScrollPane2 = new JScrollPane(); @@ -38,15 +45,28 @@ public class GWebserviceInfo extends JPanel { protected JButton cancel = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); - public GWebserviceInfo() { - try { + /** + * Creates a new GWebserviceInfo object. + */ + public GWebserviceInfo() + { + try + { jbInit(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); } } - private void jbInit() throws Exception { + /** + * DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + private void jbInit() throws Exception + { infoText.setFont(new java.awt.Font("Verdana", 0, 10)); infoText.setBorder(null); infoText.setEditable(false); @@ -69,8 +89,10 @@ public class GWebserviceInfo extends JPanel { jScrollPane1.setPreferredSize(new Dimension(400, 70)); cancel.setFont(new java.awt.Font("Verdana", 0, 11)); cancel.setText("Cancel"); - cancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { + cancel.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { cancel_actionPerformed(e); } }); @@ -89,6 +111,12 @@ public class GWebserviceInfo extends JPanel { new Insets(24, 5, 21, 5), 0, 0)); } - protected void cancel_actionPerformed(ActionEvent e) { + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void cancel_actionPerformed(ActionEvent e) + { } } diff --git a/src/jalview/math/Matrix.java b/src/jalview/math/Matrix.java index 30c534b..81d520a 100755 --- a/src/jalview/math/Matrix.java +++ b/src/jalview/math/Matrix.java @@ -23,27 +23,58 @@ import jalview.util.*; import java.io.*; -public class Matrix { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Matrix +{ /** * SMJSPUBLIC */ public double[][] value; + + /** DOCUMENT ME!! */ public int rows; + + /** DOCUMENT ME!! */ public int cols; + + /** DOCUMENT ME!! */ public double[] d; // Diagonal + + /** DOCUMENT ME!! */ public double[] e; // off diagonal - public Matrix(double[][] value, int rows, int cols) { + /** + * Creates a new Matrix object. + * + * @param value DOCUMENT ME! + * @param rows DOCUMENT ME! + * @param cols DOCUMENT ME! + */ + public Matrix(double[][] value, int rows, int cols) + { this.rows = rows; this.cols = cols; this.value = value; } - public Matrix transpose() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Matrix transpose() + { double[][] out = new double[cols][rows]; - for (int i = 0; i < cols; i++) { - for (int j = 0; j < rows; j++) { + for (int i = 0; i < cols; i++) + { + for (int j = 0; j < rows; j++) + { out[i][j] = value[j][i]; } } @@ -51,9 +82,17 @@ public class Matrix { return new Matrix(out, cols, rows); } - public void print(PrintStream ps) { - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { + /** + * DOCUMENT ME! + * + * @param ps DOCUMENT ME! + */ + public void print(PrintStream ps) + { + for (int i = 0; i < rows; i++) + { + for (int j = 0; j < cols; j++) + { Format.print(ps, "%8.2f", value[i][j]); } @@ -61,14 +100,25 @@ public class Matrix { } } - public Matrix preMultiply(Matrix in) { + /** + * DOCUMENT ME! + * + * @param in DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Matrix preMultiply(Matrix in) + { double[][] tmp = new double[in.rows][this.cols]; - for (int i = 0; i < in.rows; i++) { - for (int j = 0; j < this.cols; j++) { + for (int i = 0; i < in.rows; i++) + { + for (int j = 0; j < this.cols; j++) + { tmp[i][j] = 0.0; - for (int k = 0; k < in.cols; k++) { + for (int k = 0; k < in.cols; k++) + { tmp[i][j] += (in.value[i][k] * this.value[k][j]); } } @@ -77,13 +127,23 @@ public class Matrix { return new Matrix(tmp, in.rows, this.cols); } - public double[] vectorPostMultiply(double[] in) { + /** + * DOCUMENT ME! + * + * @param in DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public double[] vectorPostMultiply(double[] in) + { double[] out = new double[in.length]; - for (int i = 0; i < in.length; i++) { + for (int i = 0; i < in.length; i++) + { out[i] = 0.0; - for (int k = 0; k < in.length; k++) { + for (int k = 0; k < in.length; k++) + { out[i] += (value[i][k] * in[k]); } } @@ -91,14 +151,25 @@ public class Matrix { return out; } - public Matrix postMultiply(Matrix in) { + /** + * DOCUMENT ME! + * + * @param in DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Matrix postMultiply(Matrix in) + { double[][] out = new double[this.rows][in.cols]; - for (int i = 0; i < this.rows; i++) { - for (int j = 0; j < in.cols; j++) { + for (int i = 0; i < this.rows; i++) + { + for (int j = 0; j < in.cols; j++) + { out[i][j] = 0.0; - for (int k = 0; k < rows; k++) { + for (int k = 0; k < rows; k++) + { out[i][j] = out[i][j] + (value[i][k] * in.value[k][j]); } } @@ -107,11 +178,19 @@ public class Matrix { return new Matrix(out, this.cols, in.rows); } - public Matrix copy() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Matrix copy() + { double[][] newmat = new double[rows][cols]; - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { + for (int i = 0; i < rows; i++) + { + for (int j = 0; j < cols; j++) + { newmat[i][j] = value[i][j]; } } @@ -119,7 +198,11 @@ public class Matrix { return new Matrix(newmat, rows, cols); } - public void tred() { + /** + * DOCUMENT ME! + */ + public void tred() + { int n = rows; int l; int k; @@ -135,29 +218,39 @@ public class Matrix { this.d = new double[rows]; this.e = new double[rows]; - for (i = n; i >= 2; i--) { + for (i = n; i >= 2; i--) + { l = i - 1; h = 0.0; scale = 0.0; - if (l > 1) { - for (k = 1; k <= l; k++) { + if (l > 1) + { + for (k = 1; k <= l; k++) + { scale += Math.abs(value[i - 1][k - 1]); } - if (scale == 0.0) { + if (scale == 0.0) + { e[i - 1] = value[i - 1][l - 1]; - } else { - for (k = 1; k <= l; k++) { + } + else + { + for (k = 1; k <= l; k++) + { value[i - 1][k - 1] /= scale; h += (value[i - 1][k - 1] * value[i - 1][k - 1]); } f = value[i - 1][l - 1]; - if (f > 0) { + if (f > 0) + { g = -1.0 * Math.sqrt(h); - } else { + } + else + { g = Math.sqrt(h); } @@ -166,15 +259,18 @@ public class Matrix { value[i - 1][l - 1] = f - g; f = 0.0; - for (j = 1; j <= l; j++) { + for (j = 1; j <= l; j++) + { value[j - 1][i - 1] = value[i - 1][j - 1] / h; g = 0.0; - for (k = 1; k <= j; k++) { + for (k = 1; k <= j; k++) + { g += (value[j - 1][k - 1] * value[i - 1][k - 1]); } - for (k = j + 1; k <= l; k++) { + for (k = j + 1; k <= l; k++) + { g += (value[k - 1][j - 1] * value[i - 1][k - 1]); } @@ -184,18 +280,22 @@ public class Matrix { hh = f / (h + h); - for (j = 1; j <= l; j++) { + for (j = 1; j <= l; j++) + { f = value[i - 1][j - 1]; g = e[j - 1] - (hh * f); e[j - 1] = g; - for (k = 1; k <= j; k++) { + for (k = 1; k <= j; k++) + { value[j - 1][k - 1] -= ((f * e[k - 1]) + (g * value[i - 1][k - 1])); } } } - } else { + } + else + { e[i - 1] = value[i - 1][l - 1]; } @@ -205,18 +305,23 @@ public class Matrix { d[0] = 0.0; e[0] = 0.0; - for (i = 1; i <= n; i++) { + for (i = 1; i <= n; i++) + { l = i - 1; - if (d[i - 1] != 0.0) { - for (j = 1; j <= l; j++) { + if (d[i - 1] != 0.0) + { + for (j = 1; j <= l; j++) + { g = 0.0; - for (k = 1; k <= l; k++) { + for (k = 1; k <= l; k++) + { g += (value[i - 1][k - 1] * value[k - 1][j - 1]); } - for (k = 1; k <= l; k++) { + for (k = 1; k <= l; k++) + { value[k - 1][j - 1] -= (g * value[k - 1][i - 1]); } } @@ -225,14 +330,19 @@ public class Matrix { d[i - 1] = value[i - 1][i - 1]; value[i - 1][i - 1] = 1.0; - for (j = 1; j <= l; j++) { + for (j = 1; j <= l; j++) + { value[j - 1][i - 1] = 0.0; value[i - 1][j - 1] = 0.0; } } } - public void tqli() { + /** + * DOCUMENT ME! + */ + public void tqli() + { int n = rows; int m; @@ -251,31 +361,40 @@ public class Matrix { double c; double b; - for (i = 2; i <= n; i++) { + for (i = 2; i <= n; i++) + { e[i - 2] = e[i - 1]; } e[n - 1] = 0.0; - for (l = 1; l <= n; l++) { + for (l = 1; l <= n; l++) + { iter = 0; - do { - for (m = l; m <= (n - 1); m++) { + do + { + for (m = l; m <= (n - 1); m++) + { dd = Math.abs(d[m - 1]) + Math.abs(d[m]); - if ((Math.abs(e[m - 1]) + dd) == dd) { + if ((Math.abs(e[m - 1]) + dd) == dd) + { break; } } - if (m != l) { + if (m != l) + { iter++; - if (iter == 30) { + if (iter == 30) + { System.err.print("Too many iterations in tqli"); System.exit(0); // JBPNote - should this really be here ??? - } else { + } + else + { // System.out.println("Iteration " + iter); } @@ -286,17 +405,21 @@ public class Matrix { s = c; p = 0.0; - for (i = m - 1; i >= l; i--) { + for (i = m - 1; i >= l; i--) + { f = s * e[i - 1]; b = c * e[i - 1]; - if (Math.abs(f) >= Math.abs(g)) { + if (Math.abs(f) >= Math.abs(g)) + { c = g / f; r = Math.sqrt((c * c) + 1.0); e[i] = f * r; s = 1.0 / r; c *= s; - } else { + } + else + { s = f / g; r = Math.sqrt((s * s) + 1.0); e[i] = g * r; @@ -310,7 +433,8 @@ public class Matrix { d[i] = g + p; g = (c * r) - b; - for (k = 1; k <= n; k++) { + for (k = 1; k <= n; k++) + { f = value[k - 1][i]; value[k - 1][i] = (s * value[k - 1][i - 1]) + (c * f); @@ -323,11 +447,16 @@ public class Matrix { e[l - 1] = g; e[m - 1] = 0.0; } - } while (m != l); + } + while (m != l); } } - public void tred2() { + /** + * DOCUMENT ME! + */ + public void tred2() + { int n = rows; int l; int k; @@ -343,29 +472,39 @@ public class Matrix { this.d = new double[rows]; this.e = new double[rows]; - for (i = n - 1; i >= 1; i--) { + for (i = n - 1; i >= 1; i--) + { l = i - 1; h = 0.0; scale = 0.0; - if (l > 0) { - for (k = 0; k < l; k++) { + if (l > 0) + { + for (k = 0; k < l; k++) + { scale += Math.abs(value[i][k]); } - if (scale == 0.0) { + if (scale == 0.0) + { e[i] = value[i][l]; - } else { - for (k = 0; k < l; k++) { + } + else + { + for (k = 0; k < l; k++) + { value[i][k] /= scale; h += (value[i][k] * value[i][k]); } f = value[i][l]; - if (f > 0) { + if (f > 0) + { g = -1.0 * Math.sqrt(h); - } else { + } + else + { g = Math.sqrt(h); } @@ -374,15 +513,18 @@ public class Matrix { value[i][l] = f - g; f = 0.0; - for (j = 0; j < l; j++) { + for (j = 0; j < l; j++) + { value[j][i] = value[i][j] / h; g = 0.0; - for (k = 0; k < j; k++) { + for (k = 0; k < j; k++) + { g += (value[j][k] * value[i][k]); } - for (k = j; k < l; k++) { + for (k = j; k < l; k++) + { g += (value[k][j] * value[i][k]); } @@ -392,17 +534,21 @@ public class Matrix { hh = f / (h + h); - for (j = 0; j < l; j++) { + for (j = 0; j < l; j++) + { f = value[i][j]; g = e[j] - (hh * f); e[j] = g; - for (k = 0; k < j; k++) { + for (k = 0; k < j; k++) + { value[j][k] -= ((f * e[k]) + (g * value[i][k])); } } } - } else { + } + else + { e[i] = value[i][l]; } @@ -412,18 +558,23 @@ public class Matrix { d[0] = 0.0; e[0] = 0.0; - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) + { l = i - 1; - if (d[i] != 0.0) { - for (j = 0; j < l; j++) { + if (d[i] != 0.0) + { + for (j = 0; j < l; j++) + { g = 0.0; - for (k = 0; k < l; k++) { + for (k = 0; k < l; k++) + { g += (value[i][k] * value[k][j]); } - for (k = 0; k < l; k++) { + for (k = 0; k < l; k++) + { value[k][j] -= (g * value[k][i]); } } @@ -432,14 +583,19 @@ public class Matrix { d[i] = value[i][i]; value[i][i] = 1.0; - for (j = 0; j < l; j++) { + for (j = 0; j < l; j++) + { value[j][i] = 0.0; value[i][j] = 0.0; } } } - public void tqli2() { + /** + * DOCUMENT ME! + */ + public void tqli2() + { int n = rows; int m; @@ -458,31 +614,40 @@ public class Matrix { double c; double b; - for (i = 2; i <= n; i++) { + for (i = 2; i <= n; i++) + { e[i - 2] = e[i - 1]; } e[n - 1] = 0.0; - for (l = 1; l <= n; l++) { + for (l = 1; l <= n; l++) + { iter = 0; - do { - for (m = l; m <= (n - 1); m++) { + do + { + for (m = l; m <= (n - 1); m++) + { dd = Math.abs(d[m - 1]) + Math.abs(d[m]); - if ((Math.abs(e[m - 1]) + dd) == dd) { + if ((Math.abs(e[m - 1]) + dd) == dd) + { break; } } - if (m != l) { + if (m != l) + { iter++; - if (iter == 30) { + if (iter == 30) + { System.err.print("Too many iterations in tqli"); System.exit(0); // JBPNote - same as above - not a graceful exit! - } else { + } + else + { // System.out.println("Iteration " + iter); } @@ -493,17 +658,21 @@ public class Matrix { s = c; p = 0.0; - for (i = m - 1; i >= l; i--) { + for (i = m - 1; i >= l; i--) + { f = s * e[i - 1]; b = c * e[i - 1]; - if (Math.abs(f) >= Math.abs(g)) { + if (Math.abs(f) >= Math.abs(g)) + { c = g / f; r = Math.sqrt((c * c) + 1.0); e[i] = f * r; s = 1.0 / r; c *= s; - } else { + } + else + { s = f / g; r = Math.sqrt((s * s) + 1.0); e[i] = g * r; @@ -517,7 +686,8 @@ public class Matrix { d[i] = g + p; g = (c * r) - b; - for (k = 1; k <= n; k++) { + for (k = 1; k <= n; k++) + { f = value[k - 1][i]; value[k - 1][i] = (s * value[k - 1][i - 1]) + (c * f); @@ -530,46 +700,90 @@ public class Matrix { e[l - 1] = g; e[m - 1] = 0.0; } - } while (m != l); + } + while (m != l); } } - public double sign(double a, double b) { - if (b < 0) { + /** + * DOCUMENT ME! + * + * @param a DOCUMENT ME! + * @param b DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public double sign(double a, double b) + { + if (b < 0) + { return -Math.abs(a); - } else { + } + else + { return Math.abs(a); } } - public double[] getColumn(int n) { + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public double[] getColumn(int n) + { double[] out = new double[rows]; - for (int i = 0; i < rows; i++) { + for (int i = 0; i < rows; i++) + { out[i] = value[i][n]; } return out; } - public void printD(PrintStream ps) { - for (int j = 0; j < rows; j++) { + /** + * DOCUMENT ME! + * + * @param ps DOCUMENT ME! + */ + public void printD(PrintStream ps) + { + for (int j = 0; j < rows; j++) + { Format.print(ps, "%15.4e", d[j]); } } - public void printE(PrintStream ps) { - for (int j = 0; j < rows; j++) { + /** + * DOCUMENT ME! + * + * @param ps DOCUMENT ME! + */ + public void printE(PrintStream ps) + { + for (int j = 0; j < rows; j++) + { Format.print(ps, "%15.4e", e[j]); } } - public static void main(String[] args) { + /** + * DOCUMENT ME! + * + * @param args DOCUMENT ME! + */ + public static void main(String[] args) + { int n = Integer.parseInt(args[0]); double[][] in = new double[n][n]; - for (int i = 0; i < n; i++) { - for (int j = 0; j < n; j++) { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { in[i][j] = (double) Math.random(); } } diff --git a/src/jalview/math/RotatableMatrix.java b/src/jalview/math/RotatableMatrix.java index c0ec1c9..2385288 100755 --- a/src/jalview/math/RotatableMatrix.java +++ b/src/jalview/math/RotatableMatrix.java @@ -18,12 +18,27 @@ */ package jalview.math; -public class RotatableMatrix { + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class RotatableMatrix +{ float[][] matrix; float[] temp; float[][] rot; - public RotatableMatrix(int rows, int cols) { + /** + * Creates a new RotatableMatrix object. + * + * @param rows DOCUMENT ME! + * @param cols DOCUMENT ME! + */ + public RotatableMatrix(int rows, int cols) + { matrix = new float[rows][cols]; temp = new float[3]; @@ -31,11 +46,23 @@ public class RotatableMatrix { rot = new float[3][3]; } - public void addElement(int i, int j, float value) { + /** + * DOCUMENT ME! + * + * @param i DOCUMENT ME! + * @param j DOCUMENT ME! + * @param value DOCUMENT ME! + */ + public void addElement(int i, int j, float value) + { matrix[i][j] = value; } - public void print() { + /** + * DOCUMENT ME! + */ + public void print() + { System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + matrix[0][2]); @@ -46,12 +73,20 @@ public class RotatableMatrix { matrix[2][2]); } - public void rotate(float degrees, char axis) { + /** + * DOCUMENT ME! + * + * @param degrees DOCUMENT ME! + * @param axis DOCUMENT ME! + */ + public void rotate(float degrees, char axis) + { float costheta = (float) Math.cos((degrees * Math.PI) / (float) 180.0); float sintheta = (float) Math.sin((degrees * Math.PI) / (float) 180.0); - if (axis == 'z') { + if (axis == 'z') + { rot[0][0] = (float) costheta; rot[0][1] = (float) -sintheta; @@ -73,7 +108,8 @@ public class RotatableMatrix { preMultiply(rot); } - if (axis == 'x') { + if (axis == 'x') + { rot[0][0] = (float) 1.0; rot[0][1] = (float) 0.0; @@ -95,7 +131,8 @@ public class RotatableMatrix { preMultiply(rot); } - if (axis == 'y') { + if (axis == 'y') + { rot[0][0] = (float) costheta; rot[0][1] = (float) 0.0; @@ -118,14 +155,23 @@ public class RotatableMatrix { } } - public float[] vectorMultiply(float[] vect) { + /** + * DOCUMENT ME! + * + * @param vect DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public float[] vectorMultiply(float[] vect) + { temp[0] = vect[0]; temp[1] = vect[1]; temp[2] = vect[2]; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) + { temp[i] = (matrix[i][0] * vect[0]) + (matrix[i][1] * vect[1]) + (matrix[i][2] * vect[2]); } @@ -139,41 +185,67 @@ public class RotatableMatrix { return vect; } - public void preMultiply(float[][] mat) { + /** + * DOCUMENT ME! + * + * @param mat DOCUMENT ME! + */ + public void preMultiply(float[][] mat) + { float[][] tmp = new float[3][3]; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { tmp[i][j] = (mat[i][0] * matrix[0][j]) + (mat[i][1] * matrix[1][j]) + (mat[i][2] * matrix[2][j]); } } - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { matrix[i][j] = tmp[i][j]; } } } - public void postMultiply(float[][] mat) { + /** + * DOCUMENT ME! + * + * @param mat DOCUMENT ME! + */ + public void postMultiply(float[][] mat) + { float[][] tmp = new float[3][3]; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { tmp[i][j] = (matrix[i][0] * mat[0][j]) + (matrix[i][1] * mat[1][j]) + (matrix[i][2] * mat[2][j]); } } - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { matrix[i][j] = tmp[i][j]; } } } - public static void main(String[] args) { + /** + * DOCUMENT ME! + * + * @param args DOCUMENT ME! + */ + public static void main(String[] args) + { RotatableMatrix m = new RotatableMatrix(3, 3); m.addElement(0, 0, 1); @@ -234,7 +306,11 @@ public class RotatableMatrix { System.out.println(vect[0] + " " + vect[1] + " " + vect[2]); } - public void setIdentity() { + /** + * DOCUMENT ME! + */ + public void setIdentity() + { matrix[0][0] = (float) 1.0; matrix[1][1] = (float) 1.0; diff --git a/src/jalview/schemes/Blosum62ColourScheme.java b/src/jalview/schemes/Blosum62ColourScheme.java index 9c720ee..1aea477 100755 --- a/src/jalview/schemes/Blosum62ColourScheme.java +++ b/src/jalview/schemes/Blosum62ColourScheme.java @@ -1,63 +1,78 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; -import java.awt.*; - import java.util.*; +import java.awt.*; -public class Blosum62ColourScheme extends ResidueColourScheme { - public Blosum62ColourScheme() { - super(); +public class Blosum62ColourScheme + extends ResidueColourScheme +{ + public Blosum62ColourScheme() + { + super(); + } + + public Color findColour(String s, int j) + { + if ( (threshold != 0) && !aboveThreshold(s, j)) + { + return Color.white; } - public Color findColour(String s, int j) { - if ((threshold != 0) && !aboveThreshold(s, j)) { - return Color.white; + Hashtable hash = (Hashtable) consensus.elementAt(j); + + if (!jalview.util.Comparison.isGap( (s.charAt(0)))) + { + String max = (String) hash.get("maxResidue"); + + if (max.indexOf(s) > -1) + { + return new Color(154, 154, 255); + } + else + { + int c = 0; + int max_aa = 0; + int n = max.length(); + + do + { + c += ResidueProperties.getBLOSUM62(max.substring(max_aa, + max_aa + 1), s); } + while (++max_aa < n); - Hashtable hash = (Hashtable) consensus.elementAt(j); - - if (!jalview.util.Comparison.isGap((s.charAt(0)))) { - String max = (String) hash.get("maxResidue"); - - if (max.indexOf(s) > -1) { - return new Color(154, 154, 255); - } else { - int c = 0; - int max_aa = 0; - int n = max.length(); - - do { - c += ResidueProperties.getBLOSUM62(max.substring(max_aa, - max_aa + 1), s); - } while (++max_aa < n); - - if (c > 0) { - return new Color(204, 204, 255); - } else { - return Color.white; - } - } - } else { - return Color.white; + if (c > 0) + { + return new Color(204, 204, 255); } + else + { + return Color.white; + } + } + } + else + { + return Color.white; } + } } diff --git a/src/jalview/schemes/BuriedColourScheme.java b/src/jalview/schemes/BuriedColourScheme.java index 186b98a..691cd02 100755 --- a/src/jalview/schemes/BuriedColourScheme.java +++ b/src/jalview/schemes/BuriedColourScheme.java @@ -21,13 +21,32 @@ package jalview.schemes; import java.awt.*; -public class BuriedColourScheme extends ScoreColourScheme { - public BuriedColourScheme() { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class BuriedColourScheme extends ScoreColourScheme +{ + /** + * Creates a new BuriedColourScheme object. + */ + public BuriedColourScheme() + { super(ResidueProperties.buried, ResidueProperties.buriedmin, ResidueProperties.buriedmax); } - public Color makeColour(float c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color makeColour(float c) + { return new Color(0, (float) (1.0 - c), c); } } diff --git a/src/jalview/schemes/ClustalxColourScheme.java b/src/jalview/schemes/ClustalxColourScheme.java index 17398fc..addf00f 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -1,274 +1,297 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; -import jalview.datamodel.*; - -import java.awt.*; - import java.util.*; +import java.awt.*; -public class ClustalxColourScheme extends ResidueColourScheme { - public static Hashtable colhash = new Hashtable(); - Hashtable[] cons; - int[][] cons2; - ConsensusColour[] colours; - ConsensusColour[] ResidueColour; - int size; - Consensus[] conses = new Consensus[32]; - Vector colourTable = new Vector(); +import jalview.datamodel.*; +public class ClustalxColourScheme + extends ResidueColourScheme +{ + public static Hashtable colhash = new Hashtable(); + Hashtable[] cons; + int[][] cons2; + ConsensusColour[] colours; + ConsensusColour[] ResidueColour; + int size; + Consensus[] conses = new Consensus[32]; + Vector colourTable = new Vector(); + + { + colhash.put("RED", new Color( (float) 0.9, (float) 0.2, (float) 0.1)); + colhash.put("BLUE", new Color( (float) 0.5, (float) 0.7, (float) 0.9)); + colhash.put("GREEN", new Color( (float) 0.1, (float) 0.8, (float) 0.1)); + colhash.put("ORANGE", new Color( (float) 0.9, (float) 0.6, (float) 0.3)); + colhash.put("CYAN", new Color( (float) 0.1, (float) 0.7, (float) 0.7)); + colhash.put("PINK", new Color( (float) 0.9, (float) 0.5, (float) 0.5)); + colhash.put("MAGENTA", new Color( (float) 0.8, (float) 0.3, (float) 0.8)); + colhash.put("YELLOW", new Color( (float) 0.8, (float) 0.8, (float) 0.0)); + } + + public ClustalxColourScheme(Vector seqs, int maxWidth) + { + resetClustalX(seqs, maxWidth); + } + + public void resetClustalX(Vector seqs, int maxWidth) + { + cons2 = new int[maxWidth][24]; + + int start = 0; + + // Initialize the array + for (int j = 0; j < 24; j++) { - colhash.put("RED", new Color((float) 0.9, (float) 0.2, (float) 0.1)); - colhash.put("BLUE", new Color((float) 0.5, (float) 0.7, (float) 0.9)); - colhash.put("GREEN", new Color((float) 0.1, (float) 0.8, (float) 0.1)); - colhash.put("ORANGE", new Color((float) 0.9, (float) 0.6, (float) 0.3)); - colhash.put("CYAN", new Color((float) 0.1, (float) 0.7, (float) 0.7)); - colhash.put("PINK", new Color((float) 0.9, (float) 0.5, (float) 0.5)); - colhash.put("MAGENTA", new Color((float) 0.8, (float) 0.3, (float) 0.8)); - colhash.put("YELLOW", new Color((float) 0.8, (float) 0.8, (float) 0.0)); - } - - public ClustalxColourScheme(Vector seqs, int maxWidth) { - resetClustalX(seqs, maxWidth); + for (int i = 0; i < maxWidth; i++) + { + cons2[i][j] = 0; + } } - public void resetClustalX(Vector seqs, int maxWidth) { - cons2 = new int[maxWidth][24]; + int res; + int i; + int j = 0; + String seq; - int start = 0; - - // Initialize the array - for (int j = 0; j < 24; j++) - for (int i = 0; i < maxWidth; i++) - cons2[i][j] = 0; - - int res; - int i; - int j = 0; - String seq; - - while (j < seqs.size()) { - seq = ((SequenceI) seqs.elementAt(j)).getSequence(); - - int end_j = seq.length() - 1; - - for (i = start; i <= end_j; i++) { - if ((seq.length() - 1) < i) { - res = 23; - } else { - res = ((Integer) ResidueProperties.aaHash.get(seq.charAt(i) + - "")).intValue(); - } + while (j < seqs.size()) + { + seq = ( (SequenceI) seqs.elementAt(j)).getSequence(); - cons2[i][res]++; - } + int end_j = seq.length() - 1; - j++; + for (i = start; i <= end_j; i++) + { + if ( (seq.length() - 1) < i) + { + res = 23; + } + else + { + res = ( (Integer) ResidueProperties.aaHash.get(seq.charAt(i) + + "")).intValue(); } - this.size = seqs.size(); - makeColours(); - } + cons2[i][res]++; + } - public void makeColours() { - conses[0] = new Consensus("WLVIMAFCYHP", 60); - conses[1] = new Consensus("WLVIMAFCYHP", 80); - conses[2] = new Consensus("ED", 50); - conses[3] = new Consensus("KR", 60); - conses[4] = new Consensus("G", 50); - conses[5] = new Consensus("N", 50); - conses[6] = new Consensus("QE", 50); - conses[7] = new Consensus("P", 50); - conses[8] = new Consensus("TS", 50); - - conses[26] = new Consensus("A", 85); - conses[27] = new Consensus("C", 85); - conses[10] = new Consensus("E", 85); - conses[11] = new Consensus("F", 85); - conses[12] = new Consensus("G", 85); - conses[13] = new Consensus("H", 85); - conses[14] = new Consensus("I", 85); - conses[15] = new Consensus("L", 85); - conses[16] = new Consensus("M", 85); - conses[17] = new Consensus("N", 85); - conses[18] = new Consensus("P", 85); - conses[19] = new Consensus("Q", 85); - conses[20] = new Consensus("R", 85); - conses[21] = new Consensus("S", 85); - conses[22] = new Consensus("T", 85); - conses[23] = new Consensus("V", 85); - conses[24] = new Consensus("W", 85); - conses[25] = new Consensus("Y", 85); - conses[28] = new Consensus("K", 85); - conses[29] = new Consensus("D", 85); - - conses[30] = new Consensus("G", 0); - conses[31] = new Consensus("P", 0); - - // We now construct the colours - colours = new ConsensusColour[11]; - - Consensus[] tmp8 = new Consensus[1]; - tmp8[0] = conses[30]; //G - colours[7] = new ConsensusColour((Color) colhash.get("ORANGE"), tmp8); - - Consensus[] tmp9 = new Consensus[1]; - tmp9[0] = conses[31]; //P - colours[8] = new ConsensusColour((Color) colhash.get("YELLOW"), tmp9); - - Consensus[] tmp10 = new Consensus[1]; - tmp10[0] = conses[27]; //C - colours[9] = new ConsensusColour((Color) colhash.get("PINK"), tmp8); - - Consensus[] tmp1 = new Consensus[14]; - tmp1[0] = conses[0]; //% - tmp1[1] = conses[1]; //# - tmp1[2] = conses[26]; //A - tmp1[3] = conses[27]; //C - tmp1[4] = conses[11]; //F - tmp1[5] = conses[13]; //H - tmp1[6] = conses[14]; //I - tmp1[7] = conses[15]; //L - tmp1[8] = conses[16]; //M - tmp1[9] = conses[23]; //V - tmp1[10] = conses[24]; //W - tmp1[11] = conses[25]; //Y - tmp1[12] = conses[18]; //P - tmp1[13] = conses[19]; //p - colours[0] = new ConsensusColour((Color) colhash.get("BLUE"), tmp1); - - colours[10] = new ConsensusColour((Color) colhash.get("CYAN"), tmp1); - - Consensus[] tmp2 = new Consensus[5]; - tmp2[0] = conses[8]; //t - tmp2[1] = conses[21]; //S - tmp2[2] = conses[22]; //T - tmp2[3] = conses[0]; //% - tmp2[4] = conses[1]; //# - colours[1] = new ConsensusColour((Color) colhash.get("GREEN"), tmp2); - - Consensus[] tmp3 = new Consensus[3]; - - tmp3[0] = conses[17]; //N - tmp3[1] = conses[29]; //D - tmp3[2] = conses[5]; //n - colours[2] = new ConsensusColour((Color) colhash.get("GREEN"), tmp3); - - Consensus[] tmp4 = new Consensus[6]; - tmp4[0] = conses[6]; // q = QE - tmp4[1] = conses[19]; //Q - tmp4[2] = conses[22]; //E - tmp4[3] = conses[3]; //+ - tmp4[4] = conses[28]; //K - tmp4[5] = conses[20]; //R - colours[3] = new ConsensusColour((Color) colhash.get("GREEN"), tmp4); - - Consensus[] tmp5 = new Consensus[4]; - tmp5[0] = conses[3]; //+ - tmp5[1] = conses[28]; //K - tmp5[2] = conses[20]; //R - tmp5[3] = conses[19]; //Q - colours[4] = new ConsensusColour((Color) colhash.get("RED"), tmp5); - - Consensus[] tmp6 = new Consensus[5]; - tmp6[0] = conses[3]; //- - tmp6[1] = conses[29]; //D - tmp6[2] = conses[10]; //E - tmp6[3] = conses[6]; //q - tmp6[4] = conses[19]; //Q - colours[5] = new ConsensusColour((Color) colhash.get("MAGENTA"), tmp6); - - Consensus[] tmp7 = new Consensus[5]; - tmp7[0] = conses[3]; //- - tmp7[1] = conses[29]; //D - tmp7[2] = conses[10]; //E - tmp7[3] = conses[17]; //N - tmp7[4] = conses[2]; //DE - colours[6] = new ConsensusColour((Color) colhash.get("MAGENTA"), tmp7); - - // Now attach the ConsensusColours to the residue letters - ResidueColour = new ConsensusColour[20]; - ResidueColour[0] = colours[0]; // A - ResidueColour[1] = colours[4]; // R - ResidueColour[2] = colours[2]; // N - ResidueColour[3] = colours[6]; // D - ResidueColour[4] = colours[0]; // C - ResidueColour[5] = colours[3]; // Q - ResidueColour[6] = colours[5]; // E - ResidueColour[7] = colours[7]; // G - ResidueColour[8] = colours[10]; // H - ResidueColour[9] = colours[0]; // I - ResidueColour[10] = colours[0]; // L - ResidueColour[11] = colours[4]; // K - ResidueColour[12] = colours[0]; // M - ResidueColour[13] = colours[0]; // F - ResidueColour[14] = colours[8]; // P - ResidueColour[15] = colours[1]; // S - ResidueColour[16] = colours[1]; // T - ResidueColour[17] = colours[0]; // W - ResidueColour[18] = colours[10]; // Y - ResidueColour[19] = colours[0]; // V + j++; } - public Color findColour(String s) { - return Color.pink; + this.size = seqs.size(); + makeColours(); + } + + public void makeColours() + { + conses[0] = new Consensus("WLVIMAFCYHP", 60); + conses[1] = new Consensus("WLVIMAFCYHP", 80); + conses[2] = new Consensus("ED", 50); + conses[3] = new Consensus("KR", 60); + conses[4] = new Consensus("G", 50); + conses[5] = new Consensus("N", 50); + conses[6] = new Consensus("QE", 50); + conses[7] = new Consensus("P", 50); + conses[8] = new Consensus("TS", 50); + + conses[26] = new Consensus("A", 85); + conses[27] = new Consensus("C", 85); + conses[10] = new Consensus("E", 85); + conses[11] = new Consensus("F", 85); + conses[12] = new Consensus("G", 85); + conses[13] = new Consensus("H", 85); + conses[14] = new Consensus("I", 85); + conses[15] = new Consensus("L", 85); + conses[16] = new Consensus("M", 85); + conses[17] = new Consensus("N", 85); + conses[18] = new Consensus("P", 85); + conses[19] = new Consensus("Q", 85); + conses[20] = new Consensus("R", 85); + conses[21] = new Consensus("S", 85); + conses[22] = new Consensus("T", 85); + conses[23] = new Consensus("V", 85); + conses[24] = new Consensus("W", 85); + conses[25] = new Consensus("Y", 85); + conses[28] = new Consensus("K", 85); + conses[29] = new Consensus("D", 85); + + conses[30] = new Consensus("G", 0); + conses[31] = new Consensus("P", 0); + + // We now construct the colours + colours = new ConsensusColour[11]; + + Consensus[] tmp8 = new Consensus[1]; + tmp8[0] = conses[30]; //G + colours[7] = new ConsensusColour( (Color) colhash.get("ORANGE"), tmp8); + + Consensus[] tmp9 = new Consensus[1]; + tmp9[0] = conses[31]; //P + colours[8] = new ConsensusColour( (Color) colhash.get("YELLOW"), tmp9); + + Consensus[] tmp10 = new Consensus[1]; + tmp10[0] = conses[27]; //C + colours[9] = new ConsensusColour( (Color) colhash.get("PINK"), tmp8); + + Consensus[] tmp1 = new Consensus[14]; + tmp1[0] = conses[0]; //% + tmp1[1] = conses[1]; //# + tmp1[2] = conses[26]; //A + tmp1[3] = conses[27]; //C + tmp1[4] = conses[11]; //F + tmp1[5] = conses[13]; //H + tmp1[6] = conses[14]; //I + tmp1[7] = conses[15]; //L + tmp1[8] = conses[16]; //M + tmp1[9] = conses[23]; //V + tmp1[10] = conses[24]; //W + tmp1[11] = conses[25]; //Y + tmp1[12] = conses[18]; //P + tmp1[13] = conses[19]; //p + colours[0] = new ConsensusColour( (Color) colhash.get("BLUE"), tmp1); + + colours[10] = new ConsensusColour( (Color) colhash.get("CYAN"), tmp1); + + Consensus[] tmp2 = new Consensus[5]; + tmp2[0] = conses[8]; //t + tmp2[1] = conses[21]; //S + tmp2[2] = conses[22]; //T + tmp2[3] = conses[0]; //% + tmp2[4] = conses[1]; //# + colours[1] = new ConsensusColour( (Color) colhash.get("GREEN"), tmp2); + + Consensus[] tmp3 = new Consensus[3]; + + tmp3[0] = conses[17]; //N + tmp3[1] = conses[29]; //D + tmp3[2] = conses[5]; //n + colours[2] = new ConsensusColour( (Color) colhash.get("GREEN"), tmp3); + + Consensus[] tmp4 = new Consensus[6]; + tmp4[0] = conses[6]; // q = QE + tmp4[1] = conses[19]; //Q + tmp4[2] = conses[22]; //E + tmp4[3] = conses[3]; //+ + tmp4[4] = conses[28]; //K + tmp4[5] = conses[20]; //R + colours[3] = new ConsensusColour( (Color) colhash.get("GREEN"), tmp4); + + Consensus[] tmp5 = new Consensus[4]; + tmp5[0] = conses[3]; //+ + tmp5[1] = conses[28]; //K + tmp5[2] = conses[20]; //R + tmp5[3] = conses[19]; //Q + colours[4] = new ConsensusColour( (Color) colhash.get("RED"), tmp5); + + Consensus[] tmp6 = new Consensus[5]; + tmp6[0] = conses[3]; //- + tmp6[1] = conses[29]; //D + tmp6[2] = conses[10]; //E + tmp6[3] = conses[6]; //q + tmp6[4] = conses[19]; //Q + colours[5] = new ConsensusColour( (Color) colhash.get("MAGENTA"), tmp6); + + Consensus[] tmp7 = new Consensus[5]; + tmp7[0] = conses[3]; //- + tmp7[1] = conses[29]; //D + tmp7[2] = conses[10]; //E + tmp7[3] = conses[17]; //N + tmp7[4] = conses[2]; //DE + colours[6] = new ConsensusColour( (Color) colhash.get("MAGENTA"), tmp7); + + // Now attach the ConsensusColours to the residue letters + ResidueColour = new ConsensusColour[20]; + ResidueColour[0] = colours[0]; // A + ResidueColour[1] = colours[4]; // R + ResidueColour[2] = colours[2]; // N + ResidueColour[3] = colours[6]; // D + ResidueColour[4] = colours[0]; // C + ResidueColour[5] = colours[3]; // Q + ResidueColour[6] = colours[5]; // E + ResidueColour[7] = colours[7]; // G + ResidueColour[8] = colours[10]; // H + ResidueColour[9] = colours[0]; // I + ResidueColour[10] = colours[0]; // L + ResidueColour[11] = colours[4]; // K + ResidueColour[12] = colours[0]; // M + ResidueColour[13] = colours[0]; // F + ResidueColour[14] = colours[8]; // P + ResidueColour[15] = colours[1]; // S + ResidueColour[16] = colours[1]; // T + ResidueColour[17] = colours[0]; // W + ResidueColour[18] = colours[10]; // Y + ResidueColour[19] = colours[0]; // V + } + + public Color findColour(String s) + { + return Color.pink; + } + + public Color findColour(String s, int j) + { + if ( (threshold != 0) && !aboveThreshold(s, j)) + { + return Color.white; } - public Color findColour(String s, int j) { - if ((threshold != 0) && !aboveThreshold(s, j)) { - return Color.white; - } - - int i = ((Integer) ResidueProperties.aaHash.get(s)).intValue(); + int i = ( (Integer) ResidueProperties.aaHash.get(s)).intValue(); - Color c = Color.white; + Color c = Color.white; - if (i > 19) { - return c; - } - - for (int k = 0; k < ResidueColour[i].conses.length; k++) - if (ResidueColour[i].conses[k].isConserved(cons2, j, size)) { - c = ResidueColour[i].c; - } + if (i > 19) + { + return c; + } - if (i == 4) { - if (conses[27].isConserved(cons2, j, size)) { - c = (Color) colhash.get("PINK"); - } - } + for (int k = 0; k < ResidueColour[i].conses.length; k++) + { + if (ResidueColour[i].conses[k].isConserved(cons2, j, size)) + { + c = ResidueColour[i].c; + } + } - return c; + if (i == 4) + { + if (conses[27].isConserved(cons2, j, size)) + { + c = (Color) colhash.get("PINK"); + } } -} + return c; + } +} -class ConsensusColour { - Consensus[] conses; - Color c; +class ConsensusColour +{ + Consensus[] conses; + Color c; - public ConsensusColour(Color c, Consensus[] conses) { - this.conses = conses; + public ConsensusColour(Color c, Consensus[] conses) + { + this.conses = conses; - // this.list = list; - this.c = c; - } + // this.list = list; + this.c = c; + } } diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index 2e28695..9cc74f1 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -1,32 +1,32 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; -import java.awt.*; - import java.util.*; +import java.awt.*; -public interface ColourSchemeI { - public Color findColour(String aa); +public interface ColourSchemeI +{ + public Color findColour(String aa); - public Color findColour(String s, int j); + public Color findColour(String s, int j); - public void setConsensus(Vector v); + public void setConsensus(Vector v); } diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index 0d5ecc7..d27dcf0 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -18,88 +18,187 @@ */ package jalview.schemes; -public class ColourSchemeProperty { +import java.awt.*; +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class ColourSchemeProperty +{ + /** DOCUMENT ME!! */ public static final int CLUSTAL = 0; + + /** DOCUMENT ME!! */ public static final int BLOSUM = 1; + + /** DOCUMENT ME!! */ public static final int PID = 2; + + /** DOCUMENT ME!! */ public static final int ZAPPO = 3; + + /** DOCUMENT ME!! */ public static final int HYDROPHOBIC = 4; + + /** DOCUMENT ME!! */ public static final int HELIX = 5; + + /** DOCUMENT ME!! */ public static final int STRAND = 6; + + /** DOCUMENT ME!! */ public static final int TURN = 7; + + /** DOCUMENT ME!! */ public static final int BURIED = 8; + + /** DOCUMENT ME!! */ public static final int NUCLEOTIDE = 9; + + /** DOCUMENT ME!! */ public static final int USER_DEFINED = 10; + + /** DOCUMENT ME!! */ public static final int NONE = 11; - public static int getColourIndexFromName(String name) { + /** + * DOCUMENT ME! + * + * @param name DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static int getColourIndexFromName(String name) + { int ret = 11; - if (name.equalsIgnoreCase("Clustal")) { + if (name.equalsIgnoreCase("Clustal")) + { ret = CLUSTAL; - } else if (name.equalsIgnoreCase("Blosum62")) { + } + else if (name.equalsIgnoreCase("Blosum62")) + { ret = BLOSUM; - } else if (name.equalsIgnoreCase("% Identity")) { + } + else if (name.equalsIgnoreCase("% Identity")) + { ret = PID; - } else if (name.equalsIgnoreCase("Zappo")) { + } + else if (name.equalsIgnoreCase("Zappo")) + { ret = ZAPPO; - } else if (name.equalsIgnoreCase("Hydrophobic")) { + } + else if (name.equalsIgnoreCase("Hydrophobic")) + { ret = HYDROPHOBIC; - } else if (name.equalsIgnoreCase("Helix Propensity")) { + } + else if (name.equalsIgnoreCase("Helix Propensity")) + { ret = HELIX; - } else if (name.equalsIgnoreCase("Strand Propensity")) { + } + else if (name.equalsIgnoreCase("Strand Propensity")) + { ret = STRAND; - } else if (name.equalsIgnoreCase("Turn Propensity")) { + } + else if (name.equalsIgnoreCase("Turn Propensity")) + { ret = TURN; - } else if (name.equalsIgnoreCase("Buried Index")) { + } + else if (name.equalsIgnoreCase("Buried Index")) + { ret = BURIED; - } else if (name.equalsIgnoreCase("Nucleotide")) { + } + else if (name.equalsIgnoreCase("Nucleotide")) + { ret = NUCLEOTIDE; - } else if (name.equalsIgnoreCase("User Defined")) { + } + else if (name.equalsIgnoreCase("User Defined")) + { ret = USER_DEFINED; } return ret; } - public static String getColourName(ColourSchemeI cs) { - if (cs instanceof ConservationColourScheme) { + /** + * DOCUMENT ME! + * + * @param cs DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String getColourName(ColourSchemeI cs) + { + if (cs instanceof ConservationColourScheme) + { cs = ((ConservationColourScheme) cs).cs; } int index = 11; - if (cs instanceof ClustalxColourScheme) { + if (cs instanceof ClustalxColourScheme) + { index = CLUSTAL; - } else if (cs instanceof Blosum62ColourScheme) { + } + else if (cs instanceof Blosum62ColourScheme) + { index = BLOSUM; - } else if (cs instanceof PIDColourScheme) { + } + else if (cs instanceof PIDColourScheme) + { index = PID; - } else if (cs instanceof ZappoColourScheme) { + } + else if (cs instanceof ZappoColourScheme) + { index = ZAPPO; - } else if (cs instanceof HydrophobicColourScheme) { + } + else if (cs instanceof HydrophobicColourScheme) + { index = HYDROPHOBIC; - } else if (cs instanceof HelixColourScheme) { + } + else if (cs instanceof HelixColourScheme) + { index = HELIX; - } else if (cs instanceof StrandColourScheme) { + } + else if (cs instanceof StrandColourScheme) + { index = STRAND; - } else if (cs instanceof TurnColourScheme) { + } + else if (cs instanceof TurnColourScheme) + { index = TURN; - } else if (cs instanceof BuriedColourScheme) { + } + else if (cs instanceof BuriedColourScheme) + { index = BURIED; - } else if (cs instanceof NucleotideColourScheme) { + } + else if (cs instanceof NucleotideColourScheme) + { index = NUCLEOTIDE; - } else if (cs instanceof UserColourScheme) { + } + else if (cs instanceof UserColourScheme) + { index = USER_DEFINED; } return getColourName(index); } - public static String getColourName(int index) { + /** + * DOCUMENT ME! + * + * @param index DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static String getColourName(int index) + { String ret = null; - switch (index) { + switch (index) + { case CLUSTAL: ret = "Clustal"; @@ -164,21 +263,51 @@ public class ColourSchemeProperty { return ret; } - public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name) + /** + * DOCUMENT ME! + * + * @param al DOCUMENT ME! + * @param name DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, + String name) { - return getColour(al.getSequences(), al.getWidth(), name); + return getColour(al.getSequences(), al.getWidth(), name); } + /** + * DOCUMENT ME! + * + * @param seqs DOCUMENT ME! + * @param width DOCUMENT ME! + * @param name DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public static ColourSchemeI getColour(java.util.Vector seqs, int width, - String name) { + String name) + { return getColour(seqs, width, getColourIndexFromName(name)); } + /** + * DOCUMENT ME! + * + * @param seqs DOCUMENT ME! + * @param width DOCUMENT ME! + * @param index DOCUMENT ME! + * + * @return DOCUMENT ME! + */ public static ColourSchemeI getColour(java.util.Vector seqs, int width, - int index) { + int index) + { ColourSchemeI cs = null; - switch (index) { + switch (index) + { case CLUSTAL: cs = new ClustalxColourScheme(seqs, width); @@ -230,7 +359,7 @@ public class ColourSchemeProperty { break; case USER_DEFINED: - cs = new UserColourScheme(null); + cs = new UserColourScheme(new Color[0]); break; @@ -240,4 +369,38 @@ public class ColourSchemeProperty { return cs; } + + public static Color getAWTColorFromName(String name) + { + Color col = null; + name = name.toLowerCase(); + if(name.equals("black")) + col = Color.black; + else if(name.equals("blue")) + col = Color.blue; + else if(name.equals("cyan")) + col = Color.cyan; + else if(name.equals("darkGray")) + col = Color.darkGray; + else if(name.equals("gray")) + col = Color.gray; + else if(name.equals("green")) + col = Color.green; + else if(name.equals("lightGray")) + col = Color.lightGray; + else if(name.equals("magenta")) + col = Color.magenta; + else if(name.equals("orange")) + col = Color.orange; + else if(name.equals("pink")) + col = Color.pink; + else if(name.equals("red")) + col = Color.red; + else if(name.equals("white")) + col = Color.white; + else if(name.equals("yellow")) + col = Color.yellow; + + return col; + } } diff --git a/src/jalview/schemes/Consensus.java b/src/jalview/schemes/Consensus.java index 8ca0223..ac895bb 100755 --- a/src/jalview/schemes/Consensus.java +++ b/src/jalview/schemes/Consensus.java @@ -1,72 +1,80 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; - //////////////////////////////////////////// // This does nothing at all at the moment!!!!!!!!!! // AW 15th Dec 2004 ///////////////////////////////////////// -public class Consensus { - int[] mask; - double threshold; - String maskstr; - - public Consensus(String mask, double threshold) { - // this.id = id; - // this.mask = mask; - this.maskstr = mask; - setMask(mask); - this.threshold = threshold; - } +public class Consensus +{ + int[] mask; + double threshold; + String maskstr; - public void setMask(String s) { - this.mask = setNums(s); + public Consensus(String mask, double threshold) + { + // this.id = id; + // this.mask = mask; + this.maskstr = mask; + setMask(mask); + this.threshold = threshold; + } - // for (int i=0; i < mask.length; i++) { - // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]); - // } - } + public void setMask(String s) + { + this.mask = setNums(s); - public boolean isConserved(int[][] cons2, int col, int size) { - int tot = 0; + // for (int i=0; i < mask.length; i++) { + // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]); + // } + } - for (int i = 0; i < mask.length; i++) - tot += cons2[col][mask[i]]; + public boolean isConserved(int[][] cons2, int col, int size) + { + int tot = 0; - if ((double) tot > ((threshold * size) / 100)) { - return true; - } + for (int i = 0; i < mask.length; i++) + { + tot += cons2[col][mask[i]]; + } - return false; + if ( (double) tot > ( (threshold * size) / 100)) + { + return true; } - int[] setNums(String s) { - int[] out = new int[s.length()]; - int i = 0; + return false; + } - while (i < s.length()) { - out[i] = ((Integer) ResidueProperties.aaHash.get(s.substring(i, - i + 1))).intValue(); - i++; - } + int[] setNums(String s) + { + int[] out = new int[s.length()]; + int i = 0; - return out; + while (i < s.length()) + { + out[i] = ( (Integer) ResidueProperties.aaHash.get(s.substring(i, + i + 1))).intValue(); + i++; } + + return out; + } } diff --git a/src/jalview/schemes/ConservationColourScheme.java b/src/jalview/schemes/ConservationColourScheme.java index bbc0edd..5d0d1f6 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -25,47 +25,88 @@ import java.awt.*; import java.util.Vector; -public class ConservationColourScheme extends ResidueColourScheme { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class ConservationColourScheme extends ResidueColourScheme +{ + /** DOCUMENT ME!! */ public Conservation conserve; + + /** DOCUMENT ME!! */ public ColourSchemeI cs; + + /** DOCUMENT ME!! */ public int inc = 30; - public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) { + /** + * Creates a new ConservationColourScheme object. + * + * @param cons DOCUMENT ME! + * @param oldcs DOCUMENT ME! + */ + public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) + { super(); conserve = cons; cs = oldcs; } - public void setConsensus(Vector consensus) { + /** + * DOCUMENT ME! + * + * @param consensus DOCUMENT ME! + */ + public void setConsensus(Vector consensus) + { this.consensus = consensus; - if (cs != null) { + if (cs != null) + { cs.setConsensus(consensus); } } - public Color findColour(String s, int i) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param i DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color findColour(String s, int i) + { Color c = Color.white; - if (cs == null) { + if (cs == null) + { return c; } char ch = conserve.getConsSequence().getSequence().charAt(i); - if ((ch == '*') || (ch == '+')) { + if ((ch == '*') || (ch == '+')) + { c = cs.findColour(s, i); - } else { + } + else + { int tmp = 10; int t = 0; - if (!jalview.util.Comparison.isGap(ch)) { + if (!jalview.util.Comparison.isGap(ch)) + { t = Integer.parseInt(ch + ""); } c = cs.findColour(s, i); - while (tmp >= t) { + while (tmp >= t) + { c = lighter(c, inc); tmp--; } @@ -74,26 +115,44 @@ public class ConservationColourScheme extends ResidueColourScheme { return c; } - public Color lighter(Color c, int inc) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * @param inc DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color lighter(Color c, int inc) + { int red = c.getRed(); int blue = c.getBlue(); int green = c.getGreen(); - if (red < (255 - inc)) { + if (red < (255 - inc)) + { red = red + inc; - } else { + } + else + { red = 255; } - if (blue < (255 - inc)) { + if (blue < (255 - inc)) + { blue = blue + inc; - } else { + } + else + { blue = 255; } - if (green < (255 - inc)) { + if (green < (255 - inc)) + { green = green + inc; - } else { + } + else + { green = 255; } diff --git a/src/jalview/schemes/HelixColourScheme.java b/src/jalview/schemes/HelixColourScheme.java index a25f014..43ddcdc 100755 --- a/src/jalview/schemes/HelixColourScheme.java +++ b/src/jalview/schemes/HelixColourScheme.java @@ -1,33 +1,36 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; import java.awt.*; +public class HelixColourScheme + extends ScoreColourScheme +{ + public HelixColourScheme() + { + super(ResidueProperties.helix, ResidueProperties.helixmin, + ResidueProperties.helixmax); + } -public class HelixColourScheme extends ScoreColourScheme { - public HelixColourScheme() { - super(ResidueProperties.helix, ResidueProperties.helixmin, - ResidueProperties.helixmax); - } - - public Color makeColour(float c) { - return new Color(c, (float) 1.0 - c, c); - } + public Color makeColour(float c) + { + return new Color(c, (float) 1.0 - c, c); + } } diff --git a/src/jalview/schemes/HydrophobicColourScheme.java b/src/jalview/schemes/HydrophobicColourScheme.java index eeb43a3..aa04a6c 100755 --- a/src/jalview/schemes/HydrophobicColourScheme.java +++ b/src/jalview/schemes/HydrophobicColourScheme.java @@ -21,13 +21,32 @@ package jalview.schemes; import java.awt.*; -public class HydrophobicColourScheme extends ScoreColourScheme { - public HydrophobicColourScheme() { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class HydrophobicColourScheme extends ScoreColourScheme +{ + /** + * Creates a new HydrophobicColourScheme object. + */ + public HydrophobicColourScheme() + { super(ResidueProperties.hyd, ResidueProperties.hydmin, ResidueProperties.hydmax); } - public Color makeColour(float c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color makeColour(float c) + { return new Color(c, (float) 0.0, (float) 1.0 - c); } } diff --git a/src/jalview/schemes/NucleotideColourScheme.java b/src/jalview/schemes/NucleotideColourScheme.java index 0cca608..8785954 100755 --- a/src/jalview/schemes/NucleotideColourScheme.java +++ b/src/jalview/schemes/NucleotideColourScheme.java @@ -21,24 +21,58 @@ package jalview.schemes; import java.awt.*; -public class NucleotideColourScheme extends ResidueColourScheme { - public NucleotideColourScheme() { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class NucleotideColourScheme extends ResidueColourScheme +{ + /** + * Creates a new NucleotideColourScheme object. + */ + public NucleotideColourScheme() + { super(ResidueProperties.nucleotide, 0); } - public Color findColour(String n) { + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color findColour(String n) + { // System.out.println("called"); log.debug return colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()]; } - public Color findColour(String n, int j) { - if ((threshold == 0) || aboveThreshold(n, j)) { - try { + /** + * DOCUMENT ME! + * + * @param n DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color findColour(String n, int j) + { + if ((threshold == 0) || aboveThreshold(n, j)) + { + try + { return colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()]; - } catch (Exception ex) { + } + catch (Exception ex) + { return Color.white; } - } else { + } + else + { return Color.white; } } diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index 2535154..cfc9f94 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -1,67 +1,76 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; -import jalview.datamodel.*; +import java.util.*; import java.awt.*; -import java.util.*; +import jalview.datamodel.*; +public class PIDColourScheme + extends ResidueColourScheme +{ + public Color[] pidColours; + public float[] thresholds; + SequenceGroup group; -public class PIDColourScheme extends ResidueColourScheme { - public Color[] pidColours; - public float[] thresholds; - SequenceGroup group; + public PIDColourScheme() + { + this.pidColours = ResidueProperties.pidColours; + this.thresholds = ResidueProperties.pidThresholds; + } - public PIDColourScheme() { - this.pidColours = ResidueProperties.pidColours; - this.thresholds = ResidueProperties.pidThresholds; + public Color findColour(String s, int j) + { + if ( (threshold != 0) && !aboveThreshold(s, j)) + { + return Color.white; } - public Color findColour(String s, int j) { - if ((threshold != 0) && !aboveThreshold(s, j)) { - return Color.white; - } - - Color c = Color.white; - Hashtable hash = (Hashtable) consensus.elementAt(j); + Color c = Color.white; + Hashtable hash = (Hashtable) consensus.elementAt(j); - double sc = 0; + double sc = 0; - if ((Integer.parseInt(hash.get("maxCount").toString()) != -1) && - hash.contains(s)) { - sc = (((Integer) hash.get(s)).intValue() * 100.0) / ((Integer) hash.get( - "size")).intValue(); + if ( (Integer.parseInt(hash.get("maxCount").toString()) != -1) && + hash.contains(s)) + { + sc = ( ( (Integer) hash.get(s)).intValue() * 100.0) / + ( (Integer) hash.get( + "size")).intValue(); - // MC Should be isGap - if (!jalview.util.Comparison.isGap((s.charAt(0)))) { - for (int i = 0; i < thresholds.length; i++) { - if (sc > thresholds[i]) { - c = pidColours[i]; + // MC Should be isGap + if (!jalview.util.Comparison.isGap( (s.charAt(0)))) + { + for (int i = 0; i < thresholds.length; i++) + { + if (sc > thresholds[i]) + { + c = pidColours[i]; - break; - } - } - } + break; + } } - - return c; + } } + + return c; + } } diff --git a/src/jalview/schemes/ResidueColourScheme.java b/src/jalview/schemes/ResidueColourScheme.java index a688593..9c10e7d 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -23,53 +23,122 @@ import java.awt.*; import java.util.*; -public class ResidueColourScheme implements ColourSchemeI { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class ResidueColourScheme implements ColourSchemeI +{ Color[] colors; int threshold = 0; + + /** DOCUMENT ME!! */ public Vector consensus; - public ResidueColourScheme(Color[] colors, int threshold) { + /** + * Creates a new ResidueColourScheme object. + * + * @param colors DOCUMENT ME! + * @param threshold DOCUMENT ME! + */ + public ResidueColourScheme(Color[] colors, int threshold) + { this.colors = colors; this.threshold = threshold; } - public ResidueColourScheme() { + /** + * Creates a new ResidueColourScheme object. + */ + public ResidueColourScheme() + { } - public void setConsensus(Vector consensus) { + /** + * DOCUMENT ME! + * + * @param consensus DOCUMENT ME! + */ + public void setConsensus(Vector consensus) + { this.consensus = consensus; } - public Color findColour(String aa) { + /** + * DOCUMENT ME! + * + * @param aa DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color findColour(String aa) + { return colors[((Integer) (ResidueProperties.aaHash.get(aa))).intValue()]; } - public Color findColour(String s, int j) { - if ((threshold == 0) || aboveThreshold(s, j)) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color findColour(String s, int j) + { + if ((threshold == 0) || aboveThreshold(s, j)) + { return colors[((Integer) (ResidueProperties.aaHash.get(s))).intValue()]; - } else { + } + else + { return Color.white; } } - public int getThreshold() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getThreshold() + { return threshold; } - public void setThreshold(int ct) { + /** + * DOCUMENT ME! + * + * @param ct DOCUMENT ME! + */ + public void setThreshold(int ct) + { threshold = ct; } - public boolean aboveThreshold(String s, int j) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean aboveThreshold(String s, int j) + { Hashtable hash = (Hashtable) consensus.elementAt(j); if ((((Integer) hash.get("maxCount")).intValue() != -1) && - hash.contains(s)) { + hash.contains(s)) + { //// resCount//////////////////// ///////////////seq count//////////// double sc = (((Integer) hash.get(s)).intValue() * 100.0) / ((Integer) hash.get( "size")).intValue(); - if (sc >= threshold) { + if (sc >= threshold) + { return true; } } diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 552a463..14479a7 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -1,1131 +1,1199 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; -import java.awt.Color; - import java.util.*; - -public class ResidueProperties { - //Stores residue codes/names and colours and other things - public static Hashtable aaHash = new Hashtable(); // stores the number value of the aa - public static Hashtable aa3Hash = new Hashtable(); - public static Hashtable aa2Triplet = new Hashtable(); - public static Hashtable nucleotideHash = new Hashtable(); - - static { - aaHash.put("A", new Integer(0)); - aaHash.put("R", new Integer(1)); - aaHash.put("N", new Integer(2)); - aaHash.put("D", new Integer(3)); - aaHash.put("C", new Integer(4)); - aaHash.put("Q", new Integer(5)); - aaHash.put("E", new Integer(6)); - aaHash.put("G", new Integer(7)); - aaHash.put("H", new Integer(8)); - aaHash.put("I", new Integer(9)); - aaHash.put("L", new Integer(10)); - aaHash.put("K", new Integer(11)); - aaHash.put("M", new Integer(12)); - aaHash.put("F", new Integer(13)); - aaHash.put("P", new Integer(14)); - aaHash.put("S", new Integer(15)); - aaHash.put("T", new Integer(16)); - aaHash.put("W", new Integer(17)); - aaHash.put("Y", new Integer(18)); - aaHash.put("V", new Integer(19)); - aaHash.put("B", new Integer(20)); - aaHash.put("Z", new Integer(21)); - aaHash.put("X", new Integer(22)); - aaHash.put("a", new Integer(0)); - aaHash.put("r", new Integer(1)); - aaHash.put("n", new Integer(2)); - aaHash.put("d", new Integer(3)); - aaHash.put("c", new Integer(4)); - aaHash.put("q", new Integer(5)); - aaHash.put("e", new Integer(6)); - aaHash.put("g", new Integer(7)); - aaHash.put("h", new Integer(8)); - aaHash.put("i", new Integer(9)); - aaHash.put("l", new Integer(10)); - aaHash.put("k", new Integer(11)); - aaHash.put("m", new Integer(12)); - aaHash.put("f", new Integer(13)); - aaHash.put("p", new Integer(14)); - aaHash.put("s", new Integer(15)); - aaHash.put("t", new Integer(16)); - aaHash.put("w", new Integer(17)); - aaHash.put("y", new Integer(18)); - aaHash.put("v", new Integer(19)); - aaHash.put("b", new Integer(20)); - aaHash.put("z", new Integer(21)); - aaHash.put("x", new Integer(22)); - aaHash.put("-", new Integer(23)); - aaHash.put("*", new Integer(23)); - aaHash.put(".", new Integer(23)); - aaHash.put(" ", new Integer(23)); - } - - static { - nucleotideHash.put("A", new Integer(0)); - nucleotideHash.put("C", new Integer(1)); - nucleotideHash.put("G", new Integer(2)); - nucleotideHash.put("T", new Integer(3)); - nucleotideHash.put("U", new Integer(4)); - } - - // These numbers should correspond to the indices in the Color hashes - public static Hashtable aaSpecialsHash = new Hashtable(); - - static { - aaSpecialsHash.put("-", new Integer(23)); - aaSpecialsHash.put("*", new Integer(24)); - aaSpecialsHash.put(".", new Integer(25)); - aaSpecialsHash.put(" ", new Integer(26)); - } - - static { - aa3Hash.put("ALA", new Integer(0)); - aa3Hash.put("ARG", new Integer(1)); - aa3Hash.put("ASN", new Integer(2)); - aa3Hash.put("ASP", new Integer(3)); //D - aa3Hash.put("CYS", new Integer(4)); - aa3Hash.put("GLN", new Integer(5)); //Q - aa3Hash.put("GLU", new Integer(6)); // E - aa3Hash.put("GLY", new Integer(7)); - aa3Hash.put("HIS", new Integer(8)); - aa3Hash.put("ILE", new Integer(9)); - aa3Hash.put("LEU", new Integer(10)); - aa3Hash.put("LYS", new Integer(11)); - aa3Hash.put("MET", new Integer(12)); - aa3Hash.put("PHE", new Integer(13)); - aa3Hash.put("PRO", new Integer(14)); - aa3Hash.put("SER", new Integer(15)); - aa3Hash.put("THR", new Integer(16)); - aa3Hash.put("TRP", new Integer(17)); - aa3Hash.put("TYR", new Integer(18)); - aa3Hash.put("VAL", new Integer(19)); - aa3Hash.put("B", new Integer(20)); - aa3Hash.put("Z", new Integer(21)); - aa3Hash.put("X", new Integer(22)); - aa3Hash.put("-", new Integer(23)); - aa3Hash.put("*", new Integer(23)); - aa3Hash.put(".", new Integer(23)); - aa3Hash.put(" ", new Integer(23)); - } - - static { - aa2Triplet.put("A", "ALA"); - aa2Triplet.put("R", "ARG"); - aa2Triplet.put("N", "ASN"); - aa2Triplet.put("D", "ASP"); - aa2Triplet.put("C", "CYS"); - aa2Triplet.put("Q", "GLN"); - aa2Triplet.put("E", "GLU"); - aa2Triplet.put("G", "GLY"); - aa2Triplet.put("H", "HIS"); - aa2Triplet.put("I", "ILE"); - aa2Triplet.put("L", "LEU"); - aa2Triplet.put("K", "LYS"); - aa2Triplet.put("M", "MET"); - aa2Triplet.put("F", "PHE"); - aa2Triplet.put("P", "PRO"); - aa2Triplet.put("S", "SER"); - aa2Triplet.put("T", "THR"); - aa2Triplet.put("W", "TRP"); - aa2Triplet.put("Y", "TYR"); - aa2Triplet.put("V", "VAL"); - } - - public static String[] aa = { - "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", - "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " - }; - public static Color midBlue = new Color(100, 100, 255); - public static Vector scaleColours = new Vector(); - - static { - scaleColours.addElement(new Color(114, 0, 147)); - scaleColours.addElement(new Color(156, 0, 98)); - scaleColours.addElement(new Color(190, 0, 0)); - scaleColours.addElement(Color.red); - scaleColours.addElement(new Color(255, 125, 0)); - scaleColours.addElement(Color.orange); - scaleColours.addElement(new Color(255, 194, 85)); - scaleColours.addElement(Color.yellow); - scaleColours.addElement(new Color(255, 255, 181)); - scaleColours.addElement(Color.white); - } - - public static Color[] taylor = { - new Color(204, 255, 0), // A Greenish-yellowy-yellow - new Color(0, 0, 255), // R Blueish-bluey-blue - new Color(204, 0, 255), // N Blueish-reddy-blue - new Color(255, 0, 0), // D Reddish-reddy-red - new Color(255, 255, 0), // C Yellowish-yellowy-yellow - new Color(255, 0, 204), // Q Reddish-bluey-red - new Color(255, 0, 102), // E Blueish-reddy-red - new Color(255, 153, 0), // G Yellowy-reddy-yellow - new Color(0, 102, 255), // H Greenish-bluey-blue - new Color(102, 255, 0), // I Greenish-yellowy-green - new Color(51, 255, 0), // L Yellowish-greeny-green - new Color(102, 0, 255), // K Reddish-bluey-blue - new Color(0, 255, 0), // M Greenish-greeny-green - new Color(0, 255, 102), // F Blueish-greeny-green - new Color(255, 204, 0), // P Reddish-yellowy-yellow - new Color(255, 51, 0), // S Yellowish-reddy-red - new Color(255, 102, 0), // T Reddish-yellowy-red - new Color(0, 204, 255), // W Blueish-greeny-green - new Color(0, 255, 204), // Y Greenish-bluey-green - new Color(153, 255, 0), // V Yellowish-greeny-yellow - Color.white, // B - Color.white, // Z - Color.white, // X - Color.white, // - - Color.white, // * - Color.white // . - }; - public static Color[] nucleotide = { - new Color(100, 247, 63), // A - new Color(255, 179, 64), // C - new Color(235, 65, 60), // G - new Color(60, 136, 238), // T - new Color(60, 136, 238) // U - }; - public static Color[] color = { - Color.pink, // A - midBlue, // R - Color.green, // N - Color.red, // D - Color.yellow, // C - Color.green, // Q - Color.red, // E - Color.magenta, // G - Color.red, // H - Color.pink, // I - Color.pink, // L - midBlue, // K - Color.pink, // M - Color.orange, // F - Color.magenta, // P - Color.green, // S - Color.green, // T - Color.orange, // W - Color.orange, // Y - Color.pink, // V - Color.white, // B - Color.white, // Z - Color.white, // X - Color.white, // - - Color.white, // * - Color.white, // . - Color.white // ' ' - }; - - // Dunno where I got these numbers from - public static double[] hyd2 = { - 0.62, //A - 0.29, //R - -0.90, //N - -0.74, //D - 1.19, //C - 0.48, //Q - -0.40, //E - 1.38, //G - -1.50, //H - 1.06, //I - 0.64, //L - -0.78, //K - 0.12, //M - -0.85, //F - -2.53, //P - -0.18, //S - -0.05, //T - 1.08, //W - 0.81, //Y - 0.0, //V - 0.26, //B - 0.0, //Z - 0.0 //X - }; - public static double[] helix = { - 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, - 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 - }; - public static double helixmin = 0.57; - public static double helixmax = 1.51; - public static double[] strand = { - 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, - 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 - }; - public static double strandmin = 0.37; - public static double strandmax = 1.7; - public static double[] turn = { - 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01, - 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0 - }; - public static double turnmin = 0.47; - public static double turnmax = 1.56; - public static double[] buried = { - 1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2, - 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 - }; - public static double buriedmin = 0.05; - public static double buriedmax = 4.6; - - // This is hydropathy index - // Kyte, J., and Doolittle, R.F., J. Mol. Biol. - // 1157, 105-132, 1982 - public static double[] hyd = { - 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, - 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 - }; - public static final double hydmax = 4.5; - public static final double hydmin = -3.9; - - //public static final double hydmax = 1.38; - //public static final double hydmin = -2.53; - static final int[][] BLOSUM62 = { - { - 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, - -2, 0, -2, -1, 0, -4 - }, - { - -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, - -3, -1, 0, -1, -4 - }, - { - -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, - 3, 0, -1, -4 - }, - { - -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, - -3, -3, 4, 1, -1, -4 - }, - { - 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, - -2, -1, -3, -3, -2, -4 - }, - { - -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, - -2, 0, 3, -1, -4 - }, - { - -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, - -2, 1, 4, -1, -4 - }, - { - 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, - -3, -3, -1, -2, -1, -4 - }, - { - -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, - -3, 0, 0, -1, -4 - }, - { - -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, - -1, 3, -3, -3, -1, -4 - }, - { - -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, - -1, 1, -4, -3, -1, -4 - }, - { - -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, - -2, 0, 1, -1, -4 - }, - { - -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, - -1, 1, -3, -1, -1, -4 - }, - { - -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, - -1, -3, -3, -1, -4 - }, - { - -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, - -4, -3, -2, -2, -1, -2, -4 - }, - { - 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, - -2, 0, 0, 0, -4 - }, - { - 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, - -2, 0, -1, -1, 0, -4 - }, - { - -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, - 11, 2, -3, -4, -3, -2, -4 - }, - { - -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, - 7, -1, -3, -2, -1, -4 - }, - { - 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, - -1, 4, -3, -2, -1, -4 - }, - { - -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, - -3, 4, 1, -1, -4 - }, - { - -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, - -2, 1, 4, -1, -4 - }, - { - 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, - -1, -1, -1, -1, -1, -4 - }, - { - -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, - -4, -4, -4, -4, -4, -4, 1 - }, - }; - static final int[][] PAM250 = { - { - 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3, 0, - 0, 0, 0, -8 - }, - { - -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4, - -2, -1, 0, -1, -8 - }, - { - 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2, - 2, 1, 0, -8 - }, - { - 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4, -2, - 3, 3, -1, -8 - }, - { - -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2, - -8, 0, -2, -4, -5, -3, -8 - }, - { - 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4, - -2, 1, 3, -1, -8 - }, - { - 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4, -2, - 3, 3, -1, -8 - }, - { - 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5, - -1, 0, 0, -1, -8 - }, - { - -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0, - -2, 1, 2, -1, -8 - }, - { - -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5, - -1, 4, -2, -2, -1, -8 - }, - { - -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2, - -1, 2, -3, -3, -1, -8 - }, - { - -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4, -2, - 1, 0, -1, -8 - }, - { - -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4, -2, - 2, -2, -2, -1, -8 - }, - { - -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0, 7, - -1, -4, -5, -2, -8 - }, - { - 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5, - -1, -1, 0, -1, -8 - }, - { - 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3, -1, - 0, 0, 0, -8 - }, - { - 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3, 0, - 0, -1, 0, -8 - }, - { - -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5, 17, - 0, -6, -5, -6, -4, -8 - }, - { - -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0, - 10, -2, -3, -4, -2, -8 - }, - { - 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6, - -2, 4, -2, -2, -1, -8 - }, - { - 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3, -2, - 3, 2, -1, -8 - }, - { - 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4, -2, - 2, 3, -1, -8 - }, - { - 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4, - -2, -1, -1, -1, -1, -8 - }, - { - -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, - -8, -8, -8, -8, -8, -8, 1 - }, - }; - public static Hashtable ssHash = new Hashtable(); // stores the number value of the aa - - static { - ssHash.put("H", Color.magenta); - ssHash.put("E", Color.yellow); - ssHash.put("-", Color.white); - ssHash.put(".", Color.white); - ssHash.put("S", Color.cyan); - ssHash.put("T", Color.blue); - ssHash.put("G", Color.pink); - ssHash.put("I", Color.pink); - ssHash.put("B", Color.yellow); - } - - static final int[][] DNA = { - { 5, -4, -4, -4, 1 }, // C - { -4, 5, -4, -4, 1 }, // T - { -4, -4, 5, -4, 1 }, // A - { -4, -4, -4, 5, 1 }, // G - { 1, 1, 1, 1, 1 }, // - - }; - public static Color[] pidColours = { - midBlue, new Color(153, 153, 255), - // Color.lightGray, - new Color(204, 204, 255), - }; - public static float[] pidThresholds = { 80, 60, 40, }; - public static Hashtable codonHash = new Hashtable(); - public static Vector Lys = new Vector(); - public static Vector Asn = new Vector(); - public static Vector Gln = new Vector(); - public static Vector His = new Vector(); - public static Vector Glu = new Vector(); - public static Vector Asp = new Vector(); - public static Vector Tyr = new Vector(); - public static Vector Thr = new Vector(); - public static Vector Pro = new Vector(); - public static Vector Ala = new Vector(); - public static Vector Ser = new Vector(); - public static Vector Arg = new Vector(); - public static Vector Gly = new Vector(); - public static Vector Trp = new Vector(); - public static Vector Cys = new Vector(); - public static Vector Ile = new Vector(); - public static Vector Met = new Vector(); - public static Vector Leu = new Vector(); - public static Vector Val = new Vector(); - public static Vector Phe = new Vector(); - public static Vector STOP = new Vector(); - - static { - codonHash.put("K", Lys); - codonHash.put("N", Asn); - codonHash.put("Q", Gln); - codonHash.put("H", His); - codonHash.put("E", Glu); - codonHash.put("D", Asp); - codonHash.put("Y", Tyr); - codonHash.put("T", Thr); - codonHash.put("P", Pro); - codonHash.put("A", Ala); - codonHash.put("S", Ser); - codonHash.put("R", Arg); - codonHash.put("G", Gly); - codonHash.put("W", Trp); - codonHash.put("C", Cys); - codonHash.put("I", Ile); - codonHash.put("M", Met); - codonHash.put("L", Leu); - codonHash.put("V", Val); - codonHash.put("F", Phe); - codonHash.put("STOP", STOP); +import java.awt.*; + +public class ResidueProperties +{ + //Stores residue codes/names and colours and other things + public static Hashtable aaHash = new Hashtable(); // stores the number value of the aa + public static Hashtable aa3Hash = new Hashtable(); + public static Hashtable aa2Triplet = new Hashtable(); + public static Hashtable nucleotideHash = new Hashtable(); + + static + { + aaHash.put("A", new Integer(0)); + aaHash.put("R", new Integer(1)); + aaHash.put("N", new Integer(2)); + aaHash.put("D", new Integer(3)); + aaHash.put("C", new Integer(4)); + aaHash.put("Q", new Integer(5)); + aaHash.put("E", new Integer(6)); + aaHash.put("G", new Integer(7)); + aaHash.put("H", new Integer(8)); + aaHash.put("I", new Integer(9)); + aaHash.put("L", new Integer(10)); + aaHash.put("K", new Integer(11)); + aaHash.put("M", new Integer(12)); + aaHash.put("F", new Integer(13)); + aaHash.put("P", new Integer(14)); + aaHash.put("S", new Integer(15)); + aaHash.put("T", new Integer(16)); + aaHash.put("W", new Integer(17)); + aaHash.put("Y", new Integer(18)); + aaHash.put("V", new Integer(19)); + aaHash.put("B", new Integer(20)); + aaHash.put("Z", new Integer(21)); + aaHash.put("X", new Integer(22)); + aaHash.put("a", new Integer(0)); + aaHash.put("r", new Integer(1)); + aaHash.put("n", new Integer(2)); + aaHash.put("d", new Integer(3)); + aaHash.put("c", new Integer(4)); + aaHash.put("q", new Integer(5)); + aaHash.put("e", new Integer(6)); + aaHash.put("g", new Integer(7)); + aaHash.put("h", new Integer(8)); + aaHash.put("i", new Integer(9)); + aaHash.put("l", new Integer(10)); + aaHash.put("k", new Integer(11)); + aaHash.put("m", new Integer(12)); + aaHash.put("f", new Integer(13)); + aaHash.put("p", new Integer(14)); + aaHash.put("s", new Integer(15)); + aaHash.put("t", new Integer(16)); + aaHash.put("w", new Integer(17)); + aaHash.put("y", new Integer(18)); + aaHash.put("v", new Integer(19)); + aaHash.put("b", new Integer(20)); + aaHash.put("z", new Integer(21)); + aaHash.put("x", new Integer(22)); + aaHash.put("-", new Integer(23)); + aaHash.put("*", new Integer(23)); + aaHash.put(".", new Integer(23)); + aaHash.put(" ", new Integer(23)); + } + + static + { + nucleotideHash.put("A", new Integer(0)); + nucleotideHash.put("C", new Integer(1)); + nucleotideHash.put("G", new Integer(2)); + nucleotideHash.put("T", new Integer(3)); + nucleotideHash.put("U", new Integer(4)); + } + + // These numbers should correspond to the indices in the Color hashes + public static Hashtable aaSpecialsHash = new Hashtable(); + + static + { + aaSpecialsHash.put("-", new Integer(23)); + aaSpecialsHash.put("*", new Integer(24)); + aaSpecialsHash.put(".", new Integer(25)); + aaSpecialsHash.put(" ", new Integer(26)); + } + + static + { + aa3Hash.put("ALA", new Integer(0)); + aa3Hash.put("ARG", new Integer(1)); + aa3Hash.put("ASN", new Integer(2)); + aa3Hash.put("ASP", new Integer(3)); //D + aa3Hash.put("CYS", new Integer(4)); + aa3Hash.put("GLN", new Integer(5)); //Q + aa3Hash.put("GLU", new Integer(6)); // E + aa3Hash.put("GLY", new Integer(7)); + aa3Hash.put("HIS", new Integer(8)); + aa3Hash.put("ILE", new Integer(9)); + aa3Hash.put("LEU", new Integer(10)); + aa3Hash.put("LYS", new Integer(11)); + aa3Hash.put("MET", new Integer(12)); + aa3Hash.put("PHE", new Integer(13)); + aa3Hash.put("PRO", new Integer(14)); + aa3Hash.put("SER", new Integer(15)); + aa3Hash.put("THR", new Integer(16)); + aa3Hash.put("TRP", new Integer(17)); + aa3Hash.put("TYR", new Integer(18)); + aa3Hash.put("VAL", new Integer(19)); + aa3Hash.put("B", new Integer(20)); + aa3Hash.put("Z", new Integer(21)); + aa3Hash.put("X", new Integer(22)); + aa3Hash.put("-", new Integer(23)); + aa3Hash.put("*", new Integer(23)); + aa3Hash.put(".", new Integer(23)); + aa3Hash.put(" ", new Integer(23)); + } + + static + { + aa2Triplet.put("A", "ALA"); + aa2Triplet.put("R", "ARG"); + aa2Triplet.put("N", "ASN"); + aa2Triplet.put("D", "ASP"); + aa2Triplet.put("C", "CYS"); + aa2Triplet.put("Q", "GLN"); + aa2Triplet.put("E", "GLU"); + aa2Triplet.put("G", "GLY"); + aa2Triplet.put("H", "HIS"); + aa2Triplet.put("I", "ILE"); + aa2Triplet.put("L", "LEU"); + aa2Triplet.put("K", "LYS"); + aa2Triplet.put("M", "MET"); + aa2Triplet.put("F", "PHE"); + aa2Triplet.put("P", "PRO"); + aa2Triplet.put("S", "SER"); + aa2Triplet.put("T", "THR"); + aa2Triplet.put("W", "TRP"); + aa2Triplet.put("Y", "TYR"); + aa2Triplet.put("V", "VAL"); + } + + public static String[] aa = + { + "A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", + "P", "S", "T", "W", "Y", "V", "B", "Z", "X", "_", "*", ".", " " + }; + public static Color midBlue = new Color(100, 100, 255); + public static Vector scaleColours = new Vector(); + + static + { + scaleColours.addElement(new Color(114, 0, 147)); + scaleColours.addElement(new Color(156, 0, 98)); + scaleColours.addElement(new Color(190, 0, 0)); + scaleColours.addElement(Color.red); + scaleColours.addElement(new Color(255, 125, 0)); + scaleColours.addElement(Color.orange); + scaleColours.addElement(new Color(255, 194, 85)); + scaleColours.addElement(Color.yellow); + scaleColours.addElement(new Color(255, 255, 181)); + scaleColours.addElement(Color.white); + } + + public static Color[] taylor = + { + new Color(204, 255, 0), // A Greenish-yellowy-yellow + new Color(0, 0, 255), // R Blueish-bluey-blue + new Color(204, 0, 255), // N Blueish-reddy-blue + new Color(255, 0, 0), // D Reddish-reddy-red + new Color(255, 255, 0), // C Yellowish-yellowy-yellow + new Color(255, 0, 204), // Q Reddish-bluey-red + new Color(255, 0, 102), // E Blueish-reddy-red + new Color(255, 153, 0), // G Yellowy-reddy-yellow + new Color(0, 102, 255), // H Greenish-bluey-blue + new Color(102, 255, 0), // I Greenish-yellowy-green + new Color(51, 255, 0), // L Yellowish-greeny-green + new Color(102, 0, 255), // K Reddish-bluey-blue + new Color(0, 255, 0), // M Greenish-greeny-green + new Color(0, 255, 102), // F Blueish-greeny-green + new Color(255, 204, 0), // P Reddish-yellowy-yellow + new Color(255, 51, 0), // S Yellowish-reddy-red + new Color(255, 102, 0), // T Reddish-yellowy-red + new Color(0, 204, 255), // W Blueish-greeny-green + new Color(0, 255, 204), // Y Greenish-bluey-green + new Color(153, 255, 0), // V Yellowish-greeny-yellow + Color.white, // B + Color.white, // Z + Color.white, // X + Color.white, // - + Color.white, // * + Color.white // . + }; + public static Color[] nucleotide = + { + new Color(100, 247, 63), // A + new Color(255, 179, 64), // C + new Color(235, 65, 60), // G + new Color(60, 136, 238), // T + new Color(60, 136, 238) // U + }; + public static Color[] color = + { + Color.pink, // A + midBlue, // R + Color.green, // N + Color.red, // D + Color.yellow, // C + Color.green, // Q + Color.red, // E + Color.magenta, // G + Color.red, // H + Color.pink, // I + Color.pink, // L + midBlue, // K + Color.pink, // M + Color.orange, // F + Color.magenta, // P + Color.green, // S + Color.green, // T + Color.orange, // W + Color.orange, // Y + Color.pink, // V + Color.white, // B + Color.white, // Z + Color.white, // X + Color.white, // - + Color.white, // * + Color.white, // . + Color.white // ' ' + }; + + // Dunno where I got these numbers from + public static double[] hyd2 = + { + 0.62, //A + 0.29, //R + -0.90, //N + -0.74, //D + 1.19, //C + 0.48, //Q + -0.40, //E + 1.38, //G + -1.50, //H + 1.06, //I + 0.64, //L + -0.78, //K + 0.12, //M + -0.85, //F + -2.53, //P + -0.18, //S + -0.05, //T + 1.08, //W + 0.81, //Y + 0.0, //V + 0.26, //B + 0.0, //Z + 0.0 //X + }; + public static double[] helix = + { + 1.42, 0.98, 0.67, 1.01, 0.70, 1.11, 1.51, 0.57, 1.00, 1.08, 1.21, 1.16, + 1.45, 1.13, 0.57, 0.77, 0.83, 1.08, 0.69, 1.06, 0.84, 1.31, 1.00, 0.0 + }; + public static double helixmin = 0.57; + public static double helixmax = 1.51; + public static double[] strand = + { + 0.83, 0.93, 0.89, 0.54, 1.19, 1.10, 0.37, 0.75, 0.87, 1.60, 1.30, 0.74, + 1.05, 1.38, 0.55, 0.75, 1.19, 1.37, 1.47, 1.70, 0.72, 0.74, 1.0, 0.0 + }; + public static double strandmin = 0.37; + public static double strandmax = 1.7; + public static double[] turn = + { + 0.66, 0.95, 1.56, 1.46, 1.19, 0.98, 0.74, 1.56, 0.95, 0.47, 0.59, 1.01, + 0.60, 0.60, 1.52, 1.43, 0.96, 0.96, 1.14, 0.50, 1.51, 0.86, 1.00, 0, 0 + }; + public static double turnmin = 0.47; + public static double turnmax = 1.56; + public static double[] buried = + { + 1.7, 0.1, 0.4, 0.4, 4.6, 0.3, 0.3, 1.8, 0.8, 3.1, 2.4, 0.05, 1.9, 2.2, + 0.6, 0.8, 0.7, 1.6, 0.5, 2.9, 0.4, 0.3, 1.358, 0.00 + }; + public static double buriedmin = 0.05; + public static double buriedmax = 4.6; + + // This is hydropathy index + // Kyte, J., and Doolittle, R.F., J. Mol. Biol. + // 1157, 105-132, 1982 + public static double[] hyd = + { + 1.8, -4.5, -3.5, -3.5, 2.5, -3.5, -3.5, -0.4, -3.2, 4.5, 3.8, -3.9, 1.9, + 2.8, -1.6, -0.8, -0.7, -0.9, -1.3, 4.2, -3.5, -3.5, -0.49, 0.0 + }; + public static final double hydmax = 4.5; + public static final double hydmin = -3.9; + + //public static final double hydmax = 1.38; + //public static final double hydmin = -2.53; + static final int[][] BLOSUM62 = + { + { + 4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, + -2, 0, -2, -1, 0, -4 + }, + { + -1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, + -3, -1, 0, -1, -4 + }, + { + -2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, + 3, 0, -1, -4 + }, + { + -2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, + -3, -3, 4, 1, -1, -4 + }, + { + 0, 3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, + -2, -1, -3, -3, -2, -4 + }, + { + -1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, + -2, 0, 3, -1, -4 + }, + { + -1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, + -2, 1, 4, -1, -4 + }, + { + 0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, + -3, -3, -1, -2, -1, -4 + }, + { + -2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, + -3, 0, 0, -1, -4 + }, + { + -1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, + -1, 3, -3, -3, -1, -4 + }, + { + -1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, + -1, 1, -4, -3, -1, -4 + }, + { + -1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, + -2, 0, 1, -1, -4 + }, + { + -1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, + -1, 1, -3, -1, -1, -4 + }, + { + -2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, + -1, -3, -3, -1, -4 + }, + { + -1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, + -4, -3, -2, -2, -1, -2, -4 + }, + { + 1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, + -2, 0, 0, 0, -4 + }, + { + 0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, + -2, 0, -1, -1, 0, -4 + }, + { + -3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, + 11, 2, -3, -4, -3, -2, -4 + }, + { + -2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, + 7, -1, -3, -2, -1, -4 + }, + { + 0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, + -1, 4, -3, -2, -1, -4 + }, + { + -2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, + -3, 4, 1, -1, -4 + }, + { + -1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, + -2, 1, 4, -1, -4 + }, + { + 0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, + -1, -1, -1, -1, -1, -4 + }, + { + -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, + -4, -4, -4, -4, -4, -4, 1 + }, + }; + static final int[][] PAM250 = + { + { + 2, -2, 0, 0, -2, 0, 0, 1, -1, -1, -2, -1, -1, -3, 1, 1, 1, -6, -3, 0, + 0, 0, 0, -8 + }, + { + -2, 6, 0, -1, -4, 1, -1, -3, 2, -2, -3, 3, 0, -4, 0, 0, -1, 2, -4, + -2, -1, 0, -1, -8 + }, + { + 0, 0, 2, 2, -4, 1, 1, 0, 2, -2, -3, 1, -2, -3, 0, 1, 0, -4, -2, -2, + 2, 1, 0, -8 + }, + { + 0, -1, 2, 4, -5, 2, 3, 1, 1, -2, -4, 0, -3, -6, -1, 0, 0, -7, -4, -2, + 3, 3, -1, -8 + }, + { + -2, -4, -4, -5, 12, -5, -5, -3, -3, -2, -6, -5, -5, -4, -3, 0, -2, + -8, 0, -2, -4, -5, -3, -8 + }, + { + 0, 1, 1, 2, -5, 4, 2, -1, 3, -2, -2, 1, -1, -5, 0, -1, -1, -5, -4, + -2, 1, 3, -1, -8 + }, + { + 0, -1, 1, 3, -5, 2, 4, 0, 1, -2, -3, 0, -2, -5, -1, 0, 0, -7, -4, -2, + 3, 3, -1, -8 + }, + { + 1, -3, 0, 1, -3, -1, 0, 5, -2, -3, -4, -2, -3, -5, 0, 1, 0, -7, -5, + -1, 0, 0, -1, -8 + }, + { + -1, 2, 2, 1, -3, 3, 1, -2, 6, -2, -2, 0, -2, -2, 0, -1, -1, -3, 0, + -2, 1, 2, -1, -8 + }, + { + -1, -2, -2, -2, -2, -2, -2, -3, -2, 5, 2, -2, 2, 1, -2, -1, 0, -5, + -1, 4, -2, -2, -1, -8 + }, + { + -2, -3, -3, -4, -6, -2, -3, -4, -2, 2, 6, -3, 4, 2, -3, -3, -2, -2, + -1, 2, -3, -3, -1, -8 + }, + { + -1, 3, 1, 0, -5, 1, 0, -2, 0, -2, -3, 5, 0, -5, -1, 0, 0, -3, -4, -2, + 1, 0, -1, -8 + }, + { + -1, 0, -2, -3, -5, -1, -2, -3, -2, 2, 4, 0, 6, 0, -2, -2, -1, -4, -2, + 2, -2, -2, -1, -8 + }, + { + -3, -4, -3, -6, -4, -5, -5, -5, -2, 1, 2, -5, 0, 9, -5, -3, -3, 0, 7, + -1, -4, -5, -2, -8 + }, + { + 1, 0, 0, -1, -3, 0, -1, 0, 0, -2, -3, -1, -2, -5, 6, 1, 0, -6, -5, + -1, -1, 0, -1, -8 + }, + { + 1, 0, 1, 0, 0, -1, 0, 1, -1, -1, -3, 0, -2, -3, 1, 2, 1, -2, -3, -1, + 0, 0, 0, -8 + }, + { + 1, -1, 0, 0, -2, -1, 0, 0, -1, 0, -2, 0, -1, -3, 0, 1, 3, -5, -3, 0, + 0, -1, 0, -8 + }, + { + -6, 2, -4, -7, -8, -5, -7, -7, -3, -5, -2, -3, -4, 0, -6, -2, -5, 17, + 0, -6, -5, -6, -4, -8 + }, + { + -3, -4, -2, -4, 0, -4, -4, -5, 0, -1, -1, -4, -2, 7, -5, -3, -3, 0, + 10, -2, -3, -4, -2, -8 + }, + { + 0, -2, -2, -2, -2, -2, -2, -1, -2, 4, 2, -2, 2, -1, -1, -1, 0, -6, + -2, 4, -2, -2, -1, -8 + }, + { + 0, -1, 2, 3, -4, 1, 3, 0, 1, -2, -3, 1, -2, -4, -1, 0, 0, -5, -3, -2, + 3, 2, -1, -8 + }, + { + 0, 0, 1, 3, -5, 3, 3, 0, 2, -2, -3, 0, -2, -5, 0, 0, -1, -6, -4, -2, + 2, 3, -1, -8 + }, + { + 0, -1, 0, -1, -3, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, 0, 0, -4, + -2, -1, -1, -1, -1, -8 + }, + { + -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, -8, + -8, -8, -8, -8, -8, -8, 1 + }, + }; + public static Hashtable ssHash = new Hashtable(); // stores the number value of the aa + + static + { + ssHash.put("H", Color.magenta); + ssHash.put("E", Color.yellow); + ssHash.put("-", Color.white); + ssHash.put(".", Color.white); + ssHash.put("S", Color.cyan); + ssHash.put("T", Color.blue); + ssHash.put("G", Color.pink); + ssHash.put("I", Color.pink); + ssHash.put("B", Color.yellow); + } + + static final int[][] DNA = + { + { + 5, -4, -4, -4, 1}, // C + { + -4, 5, -4, -4, 1}, // T + { + -4, -4, 5, -4, 1}, // A + { + -4, -4, -4, 5, 1}, // G + { + 1, 1, 1, 1, 1}, // - + }; + public static Color[] pidColours = + { + midBlue, new Color(153, 153, 255), + // Color.lightGray, + new Color(204, 204, 255), + }; + public static float[] pidThresholds = + { + 80, 60, 40, }; + public static Hashtable codonHash = new Hashtable(); + public static Vector Lys = new Vector(); + public static Vector Asn = new Vector(); + public static Vector Gln = new Vector(); + public static Vector His = new Vector(); + public static Vector Glu = new Vector(); + public static Vector Asp = new Vector(); + public static Vector Tyr = new Vector(); + public static Vector Thr = new Vector(); + public static Vector Pro = new Vector(); + public static Vector Ala = new Vector(); + public static Vector Ser = new Vector(); + public static Vector Arg = new Vector(); + public static Vector Gly = new Vector(); + public static Vector Trp = new Vector(); + public static Vector Cys = new Vector(); + public static Vector Ile = new Vector(); + public static Vector Met = new Vector(); + public static Vector Leu = new Vector(); + public static Vector Val = new Vector(); + public static Vector Phe = new Vector(); + public static Vector STOP = new Vector(); + + static + { + codonHash.put("K", Lys); + codonHash.put("N", Asn); + codonHash.put("Q", Gln); + codonHash.put("H", His); + codonHash.put("E", Glu); + codonHash.put("D", Asp); + codonHash.put("Y", Tyr); + codonHash.put("T", Thr); + codonHash.put("P", Pro); + codonHash.put("A", Ala); + codonHash.put("S", Ser); + codonHash.put("R", Arg); + codonHash.put("G", Gly); + codonHash.put("W", Trp); + codonHash.put("C", Cys); + codonHash.put("I", Ile); + codonHash.put("M", Met); + codonHash.put("L", Leu); + codonHash.put("V", Val); + codonHash.put("F", Phe); + codonHash.put("STOP", STOP); + } + + public static Hashtable codonHash2 = new Hashtable(); + + static + { + codonHash2.put("AAA", "K"); + codonHash2.put("AAG", "K"); + codonHash2.put("AAC", "N"); + codonHash2.put("AAT", "N"); + + codonHash2.put("CAA", "E"); + codonHash2.put("CAG", "E"); + codonHash2.put("CAC", "H"); + codonHash2.put("CAT", "H"); + + codonHash2.put("GAA", "Q"); + codonHash2.put("GAG", "Q"); + codonHash2.put("GAC", "D"); + codonHash2.put("GAT", "D"); + + codonHash2.put("TAC", "Y"); + codonHash2.put("TAT", "Y"); + + codonHash2.put("ACA", "T"); + codonHash2.put("AAG", "T"); + codonHash2.put("ACC", "T"); + codonHash2.put("ACT", "T"); + + codonHash2.put("CCA", "P"); + codonHash2.put("CCG", "P"); + codonHash2.put("CCC", "P"); + codonHash2.put("CCT", "P"); + + codonHash2.put("GCA", "A"); + codonHash2.put("GCG", "A"); + codonHash2.put("GCC", "A"); + codonHash2.put("GCT", "A"); + + codonHash2.put("TCA", "S"); + codonHash2.put("TCG", "S"); + codonHash2.put("TCC", "S"); + codonHash2.put("TCT", "S"); + codonHash2.put("AGC", "S"); + codonHash2.put("AGT", "S"); + + codonHash2.put("AGA", "R"); + codonHash2.put("AGG", "R"); + codonHash2.put("CGA", "R"); + codonHash2.put("CGG", "R"); + codonHash2.put("CGC", "R"); + codonHash2.put("CGT", "R"); + + codonHash2.put("GGA", "G"); + codonHash2.put("GGG", "G"); + codonHash2.put("GGC", "G"); + codonHash2.put("GGT", "G"); + + codonHash2.put("TGA", "*"); + codonHash2.put("TAA", "*"); + codonHash2.put("TAG", "*"); + + codonHash2.put("TGG", "W"); + + codonHash2.put("TGC", "C"); + codonHash2.put("TGT", "C"); + + codonHash2.put("ATA", "I"); + codonHash2.put("ATC", "I"); + codonHash2.put("ATT", "I"); + + codonHash2.put("ATG", "M"); + + codonHash2.put("CTA", "L"); + codonHash2.put("CTG", "L"); + codonHash2.put("CTC", "L"); + codonHash2.put("CTT", "L"); + codonHash2.put("TTA", "L"); + codonHash2.put("TTG", "L"); + + codonHash2.put("GTA", "V"); + codonHash2.put("GTG", "V"); + codonHash2.put("GTC", "V"); + codonHash2.put("GTT", "V"); + + codonHash2.put("TTC", "F"); + codonHash2.put("TTT", "F"); + } + + static + { + Lys.addElement("AAA"); + Lys.addElement("AAG"); + Asn.addElement("AAC"); + Asn.addElement("AAT"); + + Gln.addElement("CAA"); + Gln.addElement("CAG"); + His.addElement("CAC"); + His.addElement("CAT"); + + Glu.addElement("GAA"); + Glu.addElement("GAG"); + Asp.addElement("GAC"); + Asp.addElement("GAT"); + + Tyr.addElement("TAC"); + Tyr.addElement("TAT"); + + Thr.addElement("ACA"); + Thr.addElement("ACG"); + Thr.addElement("ACC"); + Thr.addElement("ACT"); + + Pro.addElement("CCA"); + Pro.addElement("CCG"); + Pro.addElement("CCC"); + Pro.addElement("CCT"); + + Ala.addElement("GCA"); + Ala.addElement("GCG"); + Ala.addElement("GCC"); + Ala.addElement("GCT"); + + Ser.addElement("TCA"); + Ser.addElement("TCG"); + Ser.addElement("TCC"); + Ser.addElement("TCT"); + Ser.addElement("AGC"); + Ser.addElement("AGT"); + + Arg.addElement("AGA"); + Arg.addElement("AGG"); + Arg.addElement("CGA"); + Arg.addElement("CGG"); + Arg.addElement("CGC"); + Arg.addElement("CGT"); + + Gly.addElement("GGA"); + Gly.addElement("GGG"); + Gly.addElement("GGC"); + Gly.addElement("GGT"); + + STOP.addElement("TGA"); + STOP.addElement("TAA"); + STOP.addElement("TAG"); + + Trp.addElement("TGG"); + + Cys.addElement("TGC"); + Cys.addElement("TGT"); + + Ile.addElement("ATA"); + Ile.addElement("ATC"); + Ile.addElement("ATT"); + + Met.addElement("ATG"); + + Leu.addElement("CTA"); + Leu.addElement("CTG"); + Leu.addElement("CTC"); + Leu.addElement("CTT"); + Leu.addElement("TTA"); + Leu.addElement("TTG"); + + Val.addElement("GTA"); + Val.addElement("GTG"); + Val.addElement("GTC"); + Val.addElement("GTT"); + + Phe.addElement("TTC"); + Phe.addElement("TTT"); + } + + public static Color[][] groupColors = + { + { + Color.red, Color.red.brighter(), Color.red.brighter().brighter()}, + { + Color.orange, Color.orange.brighter(), + Color.orange.brighter().brighter() + }, + { + Color.green, Color.green.brighter(), Color.green.brighter().brighter()}, + { + Color.blue, Color.blue.brighter(), Color.blue.brighter().brighter()}, + { + Color.magenta, Color.magenta.brighter(), + Color.magenta.brighter().brighter() + }, + { + Color.cyan, Color.cyan.brighter(), Color.cyan.brighter().brighter()}, + { + Color.pink, Color.pink.brighter(), Color.pink.brighter().brighter()}, + }; + + //Stores residue codes/names and colours and other things + public static Hashtable propHash = new Hashtable(); + public static Hashtable hydrophobic = new Hashtable(); + public static Hashtable polar = new Hashtable(); + public static Hashtable small = new Hashtable(); + public static Hashtable positive = new Hashtable(); + public static Hashtable negative = new Hashtable(); + public static Hashtable charged = new Hashtable(); + public static Hashtable aromatic = new Hashtable(); + public static Hashtable aliphatic = new Hashtable(); + public static Hashtable tiny = new Hashtable(); + public static Hashtable proline = new Hashtable(); + + static + { + hydrophobic.put("I", new Integer(1)); + hydrophobic.put("L", new Integer(1)); + hydrophobic.put("V", new Integer(1)); + hydrophobic.put("C", new Integer(1)); + hydrophobic.put("A", new Integer(1)); + hydrophobic.put("G", new Integer(1)); + hydrophobic.put("M", new Integer(1)); + hydrophobic.put("F", new Integer(1)); + hydrophobic.put("Y", new Integer(1)); + hydrophobic.put("W", new Integer(1)); + hydrophobic.put("H", new Integer(1)); + hydrophobic.put("K", new Integer(1)); + hydrophobic.put("X", new Integer(1)); + hydrophobic.put("-", new Integer(1)); + hydrophobic.put("*", new Integer(1)); + hydrophobic.put("R", new Integer(0)); + hydrophobic.put("E", new Integer(0)); + hydrophobic.put("Q", new Integer(0)); + hydrophobic.put("D", new Integer(0)); + hydrophobic.put("N", new Integer(0)); + hydrophobic.put("S", new Integer(0)); + hydrophobic.put("T", new Integer(0)); + hydrophobic.put("P", new Integer(0)); + } + + static + { + polar.put("Y", new Integer(1)); + polar.put("W", new Integer(1)); + polar.put("H", new Integer(1)); + polar.put("K", new Integer(1)); + polar.put("R", new Integer(1)); + polar.put("E", new Integer(1)); + polar.put("Q", new Integer(1)); + polar.put("D", new Integer(1)); + polar.put("N", new Integer(1)); + polar.put("S", new Integer(1)); + polar.put("T", new Integer(1)); + polar.put("X", new Integer(1)); + polar.put("-", new Integer(1)); + polar.put("*", new Integer(1)); + polar.put("I", new Integer(0)); + polar.put("L", new Integer(0)); + polar.put("V", new Integer(0)); + polar.put("C", new Integer(0)); + polar.put("A", new Integer(0)); + polar.put("G", new Integer(0)); + polar.put("M", new Integer(0)); + polar.put("F", new Integer(0)); + polar.put("P", new Integer(0)); + } + + static + { + small.put("I", new Integer(0)); + small.put("L", new Integer(0)); + small.put("V", new Integer(1)); + small.put("C", new Integer(1)); + small.put("A", new Integer(1)); + small.put("G", new Integer(1)); + small.put("M", new Integer(0)); + small.put("F", new Integer(0)); + small.put("Y", new Integer(0)); + small.put("W", new Integer(0)); + small.put("H", new Integer(0)); + small.put("K", new Integer(0)); + small.put("R", new Integer(0)); + small.put("E", new Integer(0)); + small.put("Q", new Integer(0)); + small.put("D", new Integer(1)); + small.put("N", new Integer(1)); + small.put("S", new Integer(1)); + small.put("T", new Integer(1)); + small.put("P", new Integer(1)); + small.put("-", new Integer(1)); + small.put("*", new Integer(1)); + } + + static + { + positive.put("I", new Integer(0)); + positive.put("L", new Integer(0)); + positive.put("V", new Integer(0)); + positive.put("C", new Integer(0)); + positive.put("A", new Integer(0)); + positive.put("G", new Integer(0)); + positive.put("M", new Integer(0)); + positive.put("F", new Integer(0)); + positive.put("Y", new Integer(0)); + positive.put("W", new Integer(0)); + positive.put("H", new Integer(1)); + positive.put("K", new Integer(1)); + positive.put("R", new Integer(1)); + positive.put("E", new Integer(0)); + positive.put("Q", new Integer(0)); + positive.put("D", new Integer(0)); + positive.put("N", new Integer(0)); + positive.put("S", new Integer(0)); + positive.put("T", new Integer(0)); + positive.put("P", new Integer(0)); + positive.put("-", new Integer(1)); + positive.put("*", new Integer(1)); + } + + static + { + negative.put("I", new Integer(0)); + negative.put("L", new Integer(0)); + negative.put("V", new Integer(0)); + negative.put("C", new Integer(0)); + negative.put("A", new Integer(0)); + negative.put("G", new Integer(0)); + negative.put("M", new Integer(0)); + negative.put("F", new Integer(0)); + negative.put("Y", new Integer(0)); + negative.put("W", new Integer(0)); + negative.put("H", new Integer(0)); + negative.put("K", new Integer(0)); + negative.put("R", new Integer(0)); + negative.put("E", new Integer(1)); + negative.put("Q", new Integer(0)); + negative.put("D", new Integer(1)); + negative.put("N", new Integer(0)); + negative.put("S", new Integer(0)); + negative.put("T", new Integer(0)); + negative.put("P", new Integer(0)); + negative.put("-", new Integer(1)); + negative.put("*", new Integer(1)); + } + + static + { + charged.put("I", new Integer(0)); + charged.put("L", new Integer(0)); + charged.put("V", new Integer(0)); + charged.put("C", new Integer(0)); + charged.put("A", new Integer(0)); + charged.put("G", new Integer(0)); + charged.put("M", new Integer(0)); + charged.put("F", new Integer(0)); + charged.put("Y", new Integer(0)); + charged.put("W", new Integer(0)); + charged.put("H", new Integer(1)); + charged.put("K", new Integer(1)); + charged.put("R", new Integer(1)); + charged.put("E", new Integer(1)); + charged.put("Q", new Integer(0)); + charged.put("D", new Integer(1)); + charged.put("N", new Integer(1)); + charged.put("S", new Integer(0)); + charged.put("T", new Integer(0)); + charged.put("P", new Integer(0)); + charged.put("-", new Integer(1)); + charged.put("*", new Integer(1)); + } + + static + { + aromatic.put("I", new Integer(0)); + aromatic.put("L", new Integer(0)); + aromatic.put("V", new Integer(0)); + aromatic.put("C", new Integer(0)); + aromatic.put("A", new Integer(0)); + aromatic.put("G", new Integer(0)); + aromatic.put("M", new Integer(0)); + aromatic.put("F", new Integer(1)); + aromatic.put("Y", new Integer(1)); + aromatic.put("W", new Integer(1)); + aromatic.put("H", new Integer(1)); + aromatic.put("K", new Integer(0)); + aromatic.put("R", new Integer(0)); + aromatic.put("E", new Integer(0)); + aromatic.put("Q", new Integer(0)); + aromatic.put("D", new Integer(0)); + aromatic.put("N", new Integer(0)); + aromatic.put("S", new Integer(0)); + aromatic.put("T", new Integer(0)); + aromatic.put("P", new Integer(0)); + aromatic.put("-", new Integer(1)); + aromatic.put("*", new Integer(1)); + } + + static + { + aliphatic.put("I", new Integer(1)); + aliphatic.put("L", new Integer(1)); + aliphatic.put("V", new Integer(1)); + aliphatic.put("C", new Integer(0)); + aliphatic.put("A", new Integer(0)); + aliphatic.put("G", new Integer(0)); + aliphatic.put("M", new Integer(0)); + aliphatic.put("F", new Integer(0)); + aliphatic.put("Y", new Integer(0)); + aliphatic.put("W", new Integer(0)); + aliphatic.put("H", new Integer(0)); + aliphatic.put("K", new Integer(0)); + aliphatic.put("R", new Integer(0)); + aliphatic.put("E", new Integer(0)); + aliphatic.put("Q", new Integer(0)); + aliphatic.put("D", new Integer(0)); + aliphatic.put("N", new Integer(0)); + aliphatic.put("S", new Integer(0)); + aliphatic.put("T", new Integer(0)); + aliphatic.put("P", new Integer(0)); + aliphatic.put("-", new Integer(1)); + aliphatic.put("*", new Integer(1)); + } + + static + { + tiny.put("I", new Integer(0)); + tiny.put("L", new Integer(0)); + tiny.put("V", new Integer(0)); + tiny.put("C", new Integer(0)); + tiny.put("A", new Integer(1)); + tiny.put("G", new Integer(1)); + tiny.put("M", new Integer(0)); + tiny.put("F", new Integer(0)); + tiny.put("Y", new Integer(0)); + tiny.put("W", new Integer(0)); + tiny.put("H", new Integer(0)); + tiny.put("K", new Integer(0)); + tiny.put("R", new Integer(0)); + tiny.put("E", new Integer(0)); + tiny.put("Q", new Integer(0)); + tiny.put("D", new Integer(0)); + tiny.put("N", new Integer(0)); + tiny.put("S", new Integer(1)); + tiny.put("T", new Integer(0)); + tiny.put("P", new Integer(0)); + tiny.put("-", new Integer(1)); + tiny.put("*", new Integer(1)); + } + + static + { + proline.put("I", new Integer(0)); + proline.put("L", new Integer(0)); + proline.put("V", new Integer(0)); + proline.put("C", new Integer(0)); + proline.put("A", new Integer(0)); + proline.put("G", new Integer(0)); + proline.put("M", new Integer(0)); + proline.put("F", new Integer(0)); + proline.put("Y", new Integer(0)); + proline.put("W", new Integer(0)); + proline.put("H", new Integer(0)); + proline.put("K", new Integer(0)); + proline.put("R", new Integer(0)); + proline.put("E", new Integer(0)); + proline.put("Q", new Integer(0)); + proline.put("D", new Integer(0)); + proline.put("N", new Integer(0)); + proline.put("S", new Integer(0)); + proline.put("T", new Integer(0)); + proline.put("P", new Integer(1)); + proline.put("-", new Integer(1)); + proline.put("*", new Integer(1)); + } + + static + { + propHash.put("hydrophobic", hydrophobic); + propHash.put("small", small); + propHash.put("positive", positive); + propHash.put("negative", negative); + propHash.put("charged", charged); + propHash.put("aromatic", aromatic); + propHash.put("aliphatic", aliphatic); + propHash.put("tiny", tiny); + propHash.put("proline", proline); + propHash.put("polar", polar); + } + + public static Hashtable chainColours = new Hashtable(); + + static + { + chainColours.put("A", Color.red); + chainColours.put("B", Color.orange); + chainColours.put("C", Color.yellow); + chainColours.put("D", Color.green); + chainColours.put("E", Color.cyan); + chainColours.put("F", Color.blue); + chainColours.put("G", Color.magenta); + chainColours.put("H", Color.pink); + } + + private ResidueProperties() + { + } + + public static double getHydmax() + { + return hydmax; + } + + public static double getHydmin() + { + return hydmin; + } + + public static double[] getHyd() + { + return hyd; + } + + public static Hashtable getAAHash() + { + return aaHash; + } + + public static Hashtable getAA3Hash() + { + return aa3Hash; + } + + public static int[][] getDNA() + { + return ResidueProperties.DNA; + } + + public static int[][] getBLOSUM62() + { + return ResidueProperties.BLOSUM62; + } + + public static int getPAM250(String A1, String A2) + { + Integer pog1 = (Integer) aaHash.get(A1); + Integer pog2 = (Integer) aaHash.get(A2); + int pog = ResidueProperties.PAM250[pog1.intValue()][pog2.intValue()]; + + return pog; + } + + public static int getBLOSUM62(String A1, String A2) + { + int pog = 0; + + try + { + Integer pog1 = (Integer) aaHash.get(A1); + Integer pog2 = (Integer) aaHash.get(A2); + pog = ResidueProperties.BLOSUM62[pog1.intValue()][pog2.intValue()]; } - - public static Hashtable codonHash2 = new Hashtable(); - - static { - codonHash2.put("AAA", "K"); - codonHash2.put("AAG", "K"); - codonHash2.put("AAC", "N"); - codonHash2.put("AAT", "N"); - - codonHash2.put("CAA", "E"); - codonHash2.put("CAG", "E"); - codonHash2.put("CAC", "H"); - codonHash2.put("CAT", "H"); - - codonHash2.put("GAA", "Q"); - codonHash2.put("GAG", "Q"); - codonHash2.put("GAC", "D"); - codonHash2.put("GAT", "D"); - - codonHash2.put("TAC", "Y"); - codonHash2.put("TAT", "Y"); - - codonHash2.put("ACA", "T"); - codonHash2.put("AAG", "T"); - codonHash2.put("ACC", "T"); - codonHash2.put("ACT", "T"); - - codonHash2.put("CCA", "P"); - codonHash2.put("CCG", "P"); - codonHash2.put("CCC", "P"); - codonHash2.put("CCT", "P"); - - codonHash2.put("GCA", "A"); - codonHash2.put("GCG", "A"); - codonHash2.put("GCC", "A"); - codonHash2.put("GCT", "A"); - - codonHash2.put("TCA", "S"); - codonHash2.put("TCG", "S"); - codonHash2.put("TCC", "S"); - codonHash2.put("TCT", "S"); - codonHash2.put("AGC", "S"); - codonHash2.put("AGT", "S"); - - codonHash2.put("AGA", "R"); - codonHash2.put("AGG", "R"); - codonHash2.put("CGA", "R"); - codonHash2.put("CGG", "R"); - codonHash2.put("CGC", "R"); - codonHash2.put("CGT", "R"); - - codonHash2.put("GGA", "G"); - codonHash2.put("GGG", "G"); - codonHash2.put("GGC", "G"); - codonHash2.put("GGT", "G"); - - codonHash2.put("TGA", "*"); - codonHash2.put("TAA", "*"); - codonHash2.put("TAG", "*"); - - codonHash2.put("TGG", "W"); - - codonHash2.put("TGC", "C"); - codonHash2.put("TGT", "C"); - - codonHash2.put("ATA", "I"); - codonHash2.put("ATC", "I"); - codonHash2.put("ATT", "I"); - - codonHash2.put("ATG", "M"); - - codonHash2.put("CTA", "L"); - codonHash2.put("CTG", "L"); - codonHash2.put("CTC", "L"); - codonHash2.put("CTT", "L"); - codonHash2.put("TTA", "L"); - codonHash2.put("TTG", "L"); - - codonHash2.put("GTA", "V"); - codonHash2.put("GTG", "V"); - codonHash2.put("GTC", "V"); - codonHash2.put("GTT", "V"); - - codonHash2.put("TTC", "F"); - codonHash2.put("TTT", "F"); + catch (Exception e) + { + //System.out.println("Unknown residue in " + A1 + " " + A2); } - static { - Lys.addElement("AAA"); - Lys.addElement("AAG"); - Asn.addElement("AAC"); - Asn.addElement("AAT"); - - Gln.addElement("CAA"); - Gln.addElement("CAG"); - His.addElement("CAC"); - His.addElement("CAT"); - - Glu.addElement("GAA"); - Glu.addElement("GAG"); - Asp.addElement("GAC"); - Asp.addElement("GAT"); - - Tyr.addElement("TAC"); - Tyr.addElement("TAT"); - - Thr.addElement("ACA"); - Thr.addElement("ACG"); - Thr.addElement("ACC"); - Thr.addElement("ACT"); - - Pro.addElement("CCA"); - Pro.addElement("CCG"); - Pro.addElement("CCC"); - Pro.addElement("CCT"); - - Ala.addElement("GCA"); - Ala.addElement("GCG"); - Ala.addElement("GCC"); - Ala.addElement("GCT"); - - Ser.addElement("TCA"); - Ser.addElement("TCG"); - Ser.addElement("TCC"); - Ser.addElement("TCT"); - Ser.addElement("AGC"); - Ser.addElement("AGT"); - - Arg.addElement("AGA"); - Arg.addElement("AGG"); - Arg.addElement("CGA"); - Arg.addElement("CGG"); - Arg.addElement("CGC"); - Arg.addElement("CGT"); - - Gly.addElement("GGA"); - Gly.addElement("GGG"); - Gly.addElement("GGC"); - Gly.addElement("GGT"); - - STOP.addElement("TGA"); - STOP.addElement("TAA"); - STOP.addElement("TAG"); - - Trp.addElement("TGG"); - - Cys.addElement("TGC"); - Cys.addElement("TGT"); - - Ile.addElement("ATA"); - Ile.addElement("ATC"); - Ile.addElement("ATT"); - - Met.addElement("ATG"); - - Leu.addElement("CTA"); - Leu.addElement("CTG"); - Leu.addElement("CTC"); - Leu.addElement("CTT"); - Leu.addElement("TTA"); - Leu.addElement("TTG"); - - Val.addElement("GTA"); - Val.addElement("GTG"); - Val.addElement("GTC"); - Val.addElement("GTT"); - - Phe.addElement("TTC"); - Phe.addElement("TTT"); - } + return pog; + } - public static Color[][] groupColors = { - { Color.red, Color.red.brighter(), Color.red.brighter().brighter() }, - { - Color.orange, Color.orange.brighter(), - Color.orange.brighter().brighter() - }, - { Color.green, Color.green.brighter(), Color.green.brighter().brighter() }, - { Color.blue, Color.blue.brighter(), Color.blue.brighter().brighter() }, - { - Color.magenta, Color.magenta.brighter(), - Color.magenta.brighter().brighter() - }, - { Color.cyan, Color.cyan.brighter(), Color.cyan.brighter().brighter() }, - { Color.pink, Color.pink.brighter(), Color.pink.brighter().brighter() }, - }; - - //Stores residue codes/names and colours and other things - public static Hashtable propHash = new Hashtable(); - public static Hashtable hydrophobic = new Hashtable(); - public static Hashtable polar = new Hashtable(); - public static Hashtable small = new Hashtable(); - public static Hashtable positive = new Hashtable(); - public static Hashtable negative = new Hashtable(); - public static Hashtable charged = new Hashtable(); - public static Hashtable aromatic = new Hashtable(); - public static Hashtable aliphatic = new Hashtable(); - public static Hashtable tiny = new Hashtable(); - public static Hashtable proline = new Hashtable(); - - static { - hydrophobic.put("I", new Integer(1)); - hydrophobic.put("L", new Integer(1)); - hydrophobic.put("V", new Integer(1)); - hydrophobic.put("C", new Integer(1)); - hydrophobic.put("A", new Integer(1)); - hydrophobic.put("G", new Integer(1)); - hydrophobic.put("M", new Integer(1)); - hydrophobic.put("F", new Integer(1)); - hydrophobic.put("Y", new Integer(1)); - hydrophobic.put("W", new Integer(1)); - hydrophobic.put("H", new Integer(1)); - hydrophobic.put("K", new Integer(1)); - hydrophobic.put("X", new Integer(1)); - hydrophobic.put("-", new Integer(1)); - hydrophobic.put("*", new Integer(1)); - hydrophobic.put("R", new Integer(0)); - hydrophobic.put("E", new Integer(0)); - hydrophobic.put("Q", new Integer(0)); - hydrophobic.put("D", new Integer(0)); - hydrophobic.put("N", new Integer(0)); - hydrophobic.put("S", new Integer(0)); - hydrophobic.put("T", new Integer(0)); - hydrophobic.put("P", new Integer(0)); + public static Vector getCodons(String res) + { + if (codonHash.containsKey(res)) + { + return (Vector) codonHash.get(res); } - static { - polar.put("Y", new Integer(1)); - polar.put("W", new Integer(1)); - polar.put("H", new Integer(1)); - polar.put("K", new Integer(1)); - polar.put("R", new Integer(1)); - polar.put("E", new Integer(1)); - polar.put("Q", new Integer(1)); - polar.put("D", new Integer(1)); - polar.put("N", new Integer(1)); - polar.put("S", new Integer(1)); - polar.put("T", new Integer(1)); - polar.put("X", new Integer(1)); - polar.put("-", new Integer(1)); - polar.put("*", new Integer(1)); - polar.put("I", new Integer(0)); - polar.put("L", new Integer(0)); - polar.put("V", new Integer(0)); - polar.put("C", new Integer(0)); - polar.put("A", new Integer(0)); - polar.put("G", new Integer(0)); - polar.put("M", new Integer(0)); - polar.put("F", new Integer(0)); - polar.put("P", new Integer(0)); - } + return null; + } - static { - small.put("I", new Integer(0)); - small.put("L", new Integer(0)); - small.put("V", new Integer(1)); - small.put("C", new Integer(1)); - small.put("A", new Integer(1)); - small.put("G", new Integer(1)); - small.put("M", new Integer(0)); - small.put("F", new Integer(0)); - small.put("Y", new Integer(0)); - small.put("W", new Integer(0)); - small.put("H", new Integer(0)); - small.put("K", new Integer(0)); - small.put("R", new Integer(0)); - small.put("E", new Integer(0)); - small.put("Q", new Integer(0)); - small.put("D", new Integer(1)); - small.put("N", new Integer(1)); - small.put("S", new Integer(1)); - small.put("T", new Integer(1)); - small.put("P", new Integer(1)); - small.put("-", new Integer(1)); - small.put("*", new Integer(1)); - } + public static String codonTranslate(String codon) + { + Enumeration e = codonHash.keys(); - static { - positive.put("I", new Integer(0)); - positive.put("L", new Integer(0)); - positive.put("V", new Integer(0)); - positive.put("C", new Integer(0)); - positive.put("A", new Integer(0)); - positive.put("G", new Integer(0)); - positive.put("M", new Integer(0)); - positive.put("F", new Integer(0)); - positive.put("Y", new Integer(0)); - positive.put("W", new Integer(0)); - positive.put("H", new Integer(1)); - positive.put("K", new Integer(1)); - positive.put("R", new Integer(1)); - positive.put("E", new Integer(0)); - positive.put("Q", new Integer(0)); - positive.put("D", new Integer(0)); - positive.put("N", new Integer(0)); - positive.put("S", new Integer(0)); - positive.put("T", new Integer(0)); - positive.put("P", new Integer(0)); - positive.put("-", new Integer(1)); - positive.put("*", new Integer(1)); - } + while (e.hasMoreElements()) + { + String key = (String) e.nextElement(); + Vector tmp = (Vector) codonHash.get(key); - static { - negative.put("I", new Integer(0)); - negative.put("L", new Integer(0)); - negative.put("V", new Integer(0)); - negative.put("C", new Integer(0)); - negative.put("A", new Integer(0)); - negative.put("G", new Integer(0)); - negative.put("M", new Integer(0)); - negative.put("F", new Integer(0)); - negative.put("Y", new Integer(0)); - negative.put("W", new Integer(0)); - negative.put("H", new Integer(0)); - negative.put("K", new Integer(0)); - negative.put("R", new Integer(0)); - negative.put("E", new Integer(1)); - negative.put("Q", new Integer(0)); - negative.put("D", new Integer(1)); - negative.put("N", new Integer(0)); - negative.put("S", new Integer(0)); - negative.put("T", new Integer(0)); - negative.put("P", new Integer(0)); - negative.put("-", new Integer(1)); - negative.put("*", new Integer(1)); + if (tmp.contains(codon)) + { + return key; + } } - static { - charged.put("I", new Integer(0)); - charged.put("L", new Integer(0)); - charged.put("V", new Integer(0)); - charged.put("C", new Integer(0)); - charged.put("A", new Integer(0)); - charged.put("G", new Integer(0)); - charged.put("M", new Integer(0)); - charged.put("F", new Integer(0)); - charged.put("Y", new Integer(0)); - charged.put("W", new Integer(0)); - charged.put("H", new Integer(1)); - charged.put("K", new Integer(1)); - charged.put("R", new Integer(1)); - charged.put("E", new Integer(1)); - charged.put("Q", new Integer(0)); - charged.put("D", new Integer(1)); - charged.put("N", new Integer(1)); - charged.put("S", new Integer(0)); - charged.put("T", new Integer(0)); - charged.put("P", new Integer(0)); - charged.put("-", new Integer(1)); - charged.put("*", new Integer(1)); - } - - static { - aromatic.put("I", new Integer(0)); - aromatic.put("L", new Integer(0)); - aromatic.put("V", new Integer(0)); - aromatic.put("C", new Integer(0)); - aromatic.put("A", new Integer(0)); - aromatic.put("G", new Integer(0)); - aromatic.put("M", new Integer(0)); - aromatic.put("F", new Integer(1)); - aromatic.put("Y", new Integer(1)); - aromatic.put("W", new Integer(1)); - aromatic.put("H", new Integer(1)); - aromatic.put("K", new Integer(0)); - aromatic.put("R", new Integer(0)); - aromatic.put("E", new Integer(0)); - aromatic.put("Q", new Integer(0)); - aromatic.put("D", new Integer(0)); - aromatic.put("N", new Integer(0)); - aromatic.put("S", new Integer(0)); - aromatic.put("T", new Integer(0)); - aromatic.put("P", new Integer(0)); - aromatic.put("-", new Integer(1)); - aromatic.put("*", new Integer(1)); - } + return null; + } - static { - aliphatic.put("I", new Integer(1)); - aliphatic.put("L", new Integer(1)); - aliphatic.put("V", new Integer(1)); - aliphatic.put("C", new Integer(0)); - aliphatic.put("A", new Integer(0)); - aliphatic.put("G", new Integer(0)); - aliphatic.put("M", new Integer(0)); - aliphatic.put("F", new Integer(0)); - aliphatic.put("Y", new Integer(0)); - aliphatic.put("W", new Integer(0)); - aliphatic.put("H", new Integer(0)); - aliphatic.put("K", new Integer(0)); - aliphatic.put("R", new Integer(0)); - aliphatic.put("E", new Integer(0)); - aliphatic.put("Q", new Integer(0)); - aliphatic.put("D", new Integer(0)); - aliphatic.put("N", new Integer(0)); - aliphatic.put("S", new Integer(0)); - aliphatic.put("T", new Integer(0)); - aliphatic.put("P", new Integer(0)); - aliphatic.put("-", new Integer(1)); - aliphatic.put("*", new Integer(1)); - } - - static { - tiny.put("I", new Integer(0)); - tiny.put("L", new Integer(0)); - tiny.put("V", new Integer(0)); - tiny.put("C", new Integer(0)); - tiny.put("A", new Integer(1)); - tiny.put("G", new Integer(1)); - tiny.put("M", new Integer(0)); - tiny.put("F", new Integer(0)); - tiny.put("Y", new Integer(0)); - tiny.put("W", new Integer(0)); - tiny.put("H", new Integer(0)); - tiny.put("K", new Integer(0)); - tiny.put("R", new Integer(0)); - tiny.put("E", new Integer(0)); - tiny.put("Q", new Integer(0)); - tiny.put("D", new Integer(0)); - tiny.put("N", new Integer(0)); - tiny.put("S", new Integer(1)); - tiny.put("T", new Integer(0)); - tiny.put("P", new Integer(0)); - tiny.put("-", new Integer(1)); - tiny.put("*", new Integer(1)); - } - - static { - proline.put("I", new Integer(0)); - proline.put("L", new Integer(0)); - proline.put("V", new Integer(0)); - proline.put("C", new Integer(0)); - proline.put("A", new Integer(0)); - proline.put("G", new Integer(0)); - proline.put("M", new Integer(0)); - proline.put("F", new Integer(0)); - proline.put("Y", new Integer(0)); - proline.put("W", new Integer(0)); - proline.put("H", new Integer(0)); - proline.put("K", new Integer(0)); - proline.put("R", new Integer(0)); - proline.put("E", new Integer(0)); - proline.put("Q", new Integer(0)); - proline.put("D", new Integer(0)); - proline.put("N", new Integer(0)); - proline.put("S", new Integer(0)); - proline.put("T", new Integer(0)); - proline.put("P", new Integer(1)); - proline.put("-", new Integer(1)); - proline.put("*", new Integer(1)); - } - - static { - propHash.put("hydrophobic", hydrophobic); - propHash.put("small", small); - propHash.put("positive", positive); - propHash.put("negative", negative); - propHash.put("charged", charged); - propHash.put("aromatic", aromatic); - propHash.put("aliphatic", aliphatic); - propHash.put("tiny", tiny); - propHash.put("proline", proline); - propHash.put("polar", polar); - } - - public static Hashtable chainColours = new Hashtable(); - - static { - chainColours.put("A", Color.red); - chainColours.put("B", Color.orange); - chainColours.put("C", Color.yellow); - chainColours.put("D", Color.green); - chainColours.put("E", Color.cyan); - chainColours.put("F", Color.blue); - chainColours.put("G", Color.magenta); - chainColours.put("H", Color.pink); - } - - private ResidueProperties() { - } - - public static double getHydmax() { - return hydmax; - } - - public static double getHydmin() { - return hydmin; - } - - public static double[] getHyd() { - return hyd; - } - - public static Hashtable getAAHash() { - return aaHash; - } - - public static Hashtable getAA3Hash() { - return aa3Hash; - } - - public static int[][] getDNA() { - return ResidueProperties.DNA; - } - - public static int[][] getBLOSUM62() { - return ResidueProperties.BLOSUM62; - } - - public static int getPAM250(String A1, String A2) { - Integer pog1 = (Integer) aaHash.get(A1); - Integer pog2 = (Integer) aaHash.get(A2); - int pog = ResidueProperties.PAM250[pog1.intValue()][pog2.intValue()]; - - return pog; - } - - public static int getBLOSUM62(String A1, String A2) { - int pog = 0; - - try { - Integer pog1 = (Integer) aaHash.get(A1); - Integer pog2 = (Integer) aaHash.get(A2); - pog = ResidueProperties.BLOSUM62[pog1.intValue()][pog2.intValue()]; - } catch (Exception e) { - //System.out.println("Unknown residue in " + A1 + " " + A2); - } - - return pog; - } - - public static Vector getCodons(String res) { - if (codonHash.containsKey(res)) { - return (Vector) codonHash.get(res); - } - - return null; - } - - public static String codonTranslate(String codon) { - Enumeration e = codonHash.keys(); - - while (e.hasMoreElements()) { - String key = (String) e.nextElement(); - Vector tmp = (Vector) codonHash.get(key); - - if (tmp.contains(codon)) { - return key; - } - } - - return null; - } - - public static Hashtable getChainColours() { - return chainColours; - } + public static Hashtable getChainColours() + { + return chainColours; + } } diff --git a/src/jalview/schemes/ScoreColourScheme.java b/src/jalview/schemes/ScoreColourScheme.java index 12f252d..b69e536 100755 --- a/src/jalview/schemes/ScoreColourScheme.java +++ b/src/jalview/schemes/ScoreColourScheme.java @@ -21,12 +21,32 @@ package jalview.schemes; import java.awt.*; -public class ScoreColourScheme extends ResidueColourScheme { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class ScoreColourScheme extends ResidueColourScheme +{ + /** DOCUMENT ME!! */ public double min; + + /** DOCUMENT ME!! */ public double max; + + /** DOCUMENT ME!! */ public double[] scores; - public ScoreColourScheme(double[] scores, double min, double max) { + /** + * Creates a new ScoreColourScheme object. + * + * @param scores DOCUMENT ME! + * @param min DOCUMENT ME! + * @param max DOCUMENT ME! + */ + public ScoreColourScheme(double[] scores, double min, double max) + { super(); this.scores = scores; @@ -34,9 +54,20 @@ public class ScoreColourScheme extends ResidueColourScheme { this.max = max; } - public Color findColour(String s, int j) { - if (threshold > 0) { - if (!aboveThreshold(s, j)) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param j DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color findColour(String s, int j) + { + if (threshold > 0) + { + if (!aboveThreshold(s, j)) + { return Color.white; } } @@ -44,17 +75,20 @@ public class ScoreColourScheme extends ResidueColourScheme { float red = (float) (scores[((Integer) ResidueProperties.aaHash.get(s)).intValue()] - (float) min) / (float) (max - min); - if (red > 1.0f) { + if (red > 1.0f) + { red = 1.0f; } - if (red < 0.0f) { + if (red < 0.0f) + { red = 0.0f; } char c = s.charAt(0); - if (jalview.util.Comparison.isGap((c))) { + if (jalview.util.Comparison.isGap((c))) + { return Color.white; } @@ -62,7 +96,15 @@ public class ScoreColourScheme extends ResidueColourScheme { return makeColour(red); } - public Color makeColour(float c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color makeColour(float c) + { return new Color(c, (float) 0.0, (float) 1.0 - c); } } diff --git a/src/jalview/schemes/StrandColourScheme.java b/src/jalview/schemes/StrandColourScheme.java index 717e6dc..9944155 100755 --- a/src/jalview/schemes/StrandColourScheme.java +++ b/src/jalview/schemes/StrandColourScheme.java @@ -21,13 +21,32 @@ package jalview.schemes; import java.awt.*; -public class StrandColourScheme extends ScoreColourScheme { - public StrandColourScheme() { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class StrandColourScheme extends ScoreColourScheme +{ + /** + * Creates a new StrandColourScheme object. + */ + public StrandColourScheme() + { super(ResidueProperties.strand, ResidueProperties.strandmin, ResidueProperties.strandmax); } - public Color makeColour(float c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color makeColour(float c) + { return new Color(c, c, (float) 1.0 - c); } } diff --git a/src/jalview/schemes/TaylorColourScheme.java b/src/jalview/schemes/TaylorColourScheme.java index 10277e9..6220eaa 100755 --- a/src/jalview/schemes/TaylorColourScheme.java +++ b/src/jalview/schemes/TaylorColourScheme.java @@ -1,25 +1,28 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; -public class TaylorColourScheme extends ResidueColourScheme { - public TaylorColourScheme() { - super(ResidueProperties.taylor, 0); - } +public class TaylorColourScheme + extends ResidueColourScheme +{ + public TaylorColourScheme() + { + super(ResidueProperties.taylor, 0); + } } diff --git a/src/jalview/schemes/TurnColourScheme.java b/src/jalview/schemes/TurnColourScheme.java index e86c44c..dbf36e3 100755 --- a/src/jalview/schemes/TurnColourScheme.java +++ b/src/jalview/schemes/TurnColourScheme.java @@ -21,13 +21,32 @@ package jalview.schemes; import java.awt.*; -public class TurnColourScheme extends ScoreColourScheme { - public TurnColourScheme() { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class TurnColourScheme extends ScoreColourScheme +{ + /** + * Creates a new TurnColourScheme object. + */ + public TurnColourScheme() + { super(ResidueProperties.turn, ResidueProperties.turnmin, ResidueProperties.turnmax); } - public Color makeColour(float c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Color makeColour(float c) + { return new Color(c, 1 - c, 1 - c); } } diff --git a/src/jalview/schemes/UserColourScheme.java b/src/jalview/schemes/UserColourScheme.java index 38a1291..7bd61c1 100755 --- a/src/jalview/schemes/UserColourScheme.java +++ b/src/jalview/schemes/UserColourScheme.java @@ -1,32 +1,57 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.schemes; import java.awt.*; - -public class UserColourScheme extends ResidueColourScheme { - public UserColourScheme(Color[] newColors) { - colors = newColors; +public class UserColourScheme + extends ResidueColourScheme +{ + public UserColourScheme(String colour) + { + Color col = null; + try{ + int value = Integer.parseInt(colour, 16); + col = new Color(value); } + catch(NumberFormatException ex){} + + if(col==null) + col = ColourSchemeProperty.getAWTColorFromName(colour); - public Color[] getColours() { - return colors; + if(col==null) + { + System.out.println("Unknown colour!! "+colour); } + + colors = new Color[24]; + for(int i=0; i<24; i++) + colors[i] = col; + } + + public UserColourScheme(Color[] newColors) + { + colors = newColors; + } + + public Color[] getColours() + { + return colors; + } } diff --git a/src/jalview/schemes/ZappoColourScheme.java b/src/jalview/schemes/ZappoColourScheme.java index 2a439c0..4f5c42a 100755 --- a/src/jalview/schemes/ZappoColourScheme.java +++ b/src/jalview/schemes/ZappoColourScheme.java @@ -18,8 +18,20 @@ */ package jalview.schemes; -public class ZappoColourScheme extends ResidueColourScheme { - public ZappoColourScheme() { + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class ZappoColourScheme extends ResidueColourScheme +{ + /** + * Creates a new ZappoColourScheme object. + */ + public ZappoColourScheme() + { super(ResidueProperties.color, 0); } } diff --git a/src/jalview/util/BrowserLauncher.java b/src/jalview/util/BrowserLauncher.java index 12d6f02..6bac25b 100755 --- a/src/jalview/util/BrowserLauncher.java +++ b/src/jalview/util/BrowserLauncher.java @@ -1,767 +1,930 @@ -/* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.util; -import java.io.File; -import java.io.IOException; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - - -/** - * BrowserLauncher is a class that provides one static method, openURL, which opens the default - * web browser for the current user of the system to the given URL. It may support other - * protocols depending on the system -- mailto, ftp, etc. -- but that has not been rigorously - * tested and is not guaranteed to work. - *

- * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms - * that are not part of the standard JDK. What we're trying to do, though, is to take something - * that's frequently desirable but inherently platform-specific -- opening a default browser -- - * and allow programmers (you, for example) to do so without worrying about dropping into native - * code or doing anything else similarly evil. - *

- * Anyway, this code is completely in Java and will run on all JDK 1.1-compliant systems without - * modification or a need for additional libraries. All classes that are required on certain - * platforms to allow this to run are dynamically loaded at runtime via reflection and, if not - * found, will not cause this to do anything other than returning an error when opening the - * browser. - *

- * There are certain system requirements for this class, as it's running through Runtime.exec(), - * which is Java's way of making a native system call. Currently, this requires that a Macintosh - * have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that - * have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder - * in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and - * 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems - * (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops - * back from the inherently platform-sensitive concept of a default browser and simply attempts - * to launch Netscape via a shell command. - *

- * This code is Copyright 1999-2001 by Eric Albert (ejalbert\@cs.stanford.edu) and may be - * redistributed or modified in any form without restrictions as long as the portion of this - * comment from this paragraph through the end of the comment is not removed. The author - * requests that he be notified of any application, applet, or other binary that makes use of - * this code, but that's more out of curiosity than anything and is not required. This software - * includes no warranty. The author is not repsonsible for any loss of data or functionality - * or any adverse or unexpected effects of using this software. - *

- * Credits: - *
Steven Spencer, JavaWorld magazine (Java Tip 66) - *
Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea Cantatore, - * Larry Barowski, Trevor Bedzek, Frank Miedrich, and Ron Rabakukk - * - * @author Eric Albert (ejalbert@cs.stanford.edu) - * @version 1.4b1 (Released June 20, 2001) - */ -public class BrowserLauncher { - /** - * The Java virtual machine that we are running on. Actually, in most cases we only care - * about the operating system, but some operating systems require us to switch on the VM. */ - private static int jvm; - - /** The browser for the system */ - private static Object browser; - - /** - * Caches whether any classes, methods, and fields that are not part of the JDK and need to - * be dynamically loaded at runtime loaded successfully. - *

- * Note that if this is false, openURL() will always return an - * IOException. +import java.io.*; +import java.lang.reflect.*; + +/** + * BrowserLauncher is a class that provides one static method, openURL, which opens the default + * web browser for the current user of the system to the given URL. It may support other + * protocols depending on the system -- mailto, ftp, etc. -- but that has not been rigorously + * tested and is not guaranteed to work. + *

+ * Yes, this is platform-specific code, and yes, it may rely on classes on certain platforms + * that are not part of the standard JDK. What we're trying to do, though, is to take something + * that's frequently desirable but inherently platform-specific -- opening a default browser -- + * and allow programmers (you, for example) to do so without worrying about dropping into native + * code or doing anything else similarly evil. + *

+ * Anyway, this code is completely in Java and will run on all JDK 1.1-compliant systems without + * modification or a need for additional libraries. All classes that are required on certain + * platforms to allow this to run are dynamically loaded at runtime via reflection and, if not + * found, will not cause this to do anything other than returning an error when opening the + * browser. + *

+ * There are certain system requirements for this class, as it's running through Runtime.exec(), + * which is Java's way of making a native system call. Currently, this requires that a Macintosh + * have a Finder which supports the GURL event, which is true for Mac OS 8.0 and 8.1 systems that + * have the Internet Scripting AppleScript dictionary installed in the Scripting Additions folder + * in the Extensions folder (which is installed by default as far as I know under Mac OS 8.0 and + * 8.1), and for all Mac OS 8.5 and later systems. On Windows, it only runs under Win32 systems + * (Windows 95, 98, and NT 4.0, as well as later versions of all). On other systems, this drops + * back from the inherently platform-sensitive concept of a default browser and simply attempts + * to launch Netscape via a shell command. + *

+ * This code is Copyright 1999-2001 by Eric Albert (ejalbert\@cs.stanford.edu) and may be + * redistributed or modified in any form without restrictions as long as the portion of this + * comment from this paragraph through the end of the comment is not removed. The author + * requests that he be notified of any application, applet, or other binary that makes use of + * this code, but that's more out of curiosity than anything and is not required. This software + * includes no warranty. The author is not repsonsible for any loss of data or functionality + * or any adverse or unexpected effects of using this software. + *

+ * Credits: + *
Steven Spencer, JavaWorld magazine (Java Tip 66) + *
Thanks also to Ron B. Yeh, Eric Shapiro, Ben Engber, Paul Teitlebaum, Andrea Cantatore, + * Larry Barowski, Trevor Bedzek, Frank Miedrich, and Ron Rabakukk + * + * @author Eric Albert (ejalbert@cs.stanford.edu) + * @version 1.4b1 (Released June 20, 2001) */ - private static boolean loadedWithoutErrors; +public class BrowserLauncher +{ + /** + * The Java virtual machine that we are running on. Actually, in most cases we only care + * about the operating system, but some operating systems require us to switch on the VM. */ + private static int jvm; - /** The com.apple.mrj.MRJFileUtils class */ - private static Class mrjFileUtilsClass; + /** The browser for the system */ + private static Object browser; - /** The com.apple.mrj.MRJOSType class */ - private static Class mrjOSTypeClass; + /** + * Caches whether any classes, methods, and fields that are not part of the JDK and need to + * be dynamically loaded at runtime loaded successfully. + *

+ * Note that if this is false, openURL() will always return an + * IOException. + */ + private static boolean loadedWithoutErrors; - /** The com.apple.MacOS.AEDesc class */ - private static Class aeDescClass; + /** The com.apple.mrj.MRJFileUtils class */ + private static Class mrjFileUtilsClass; - /** The <init>(int) method of com.apple.MacOS.AETarget */ - private static Constructor aeTargetConstructor; + /** The com.apple.mrj.MRJOSType class */ + private static Class mrjOSTypeClass; - /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */ - private static Constructor appleEventConstructor; + /** The com.apple.MacOS.AEDesc class */ + private static Class aeDescClass; - /** The <init>(String) method of com.apple.MacOS.AEDesc */ - private static Constructor aeDescConstructor; + /** The <init>(int) method of com.apple.MacOS.AETarget */ + private static Constructor aeTargetConstructor; - /** The findFolder method of com.apple.mrj.MRJFileUtils */ - private static Method findFolder; + /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */ + private static Constructor appleEventConstructor; - /** The getFileCreator method of com.apple.mrj.MRJFileUtils */ - private static Method getFileCreator; + /** The <init>(String) method of com.apple.MacOS.AEDesc */ + private static Constructor aeDescConstructor; - /** The getFileType method of com.apple.mrj.MRJFileUtils */ - private static Method getFileType; + /** The findFolder method of com.apple.mrj.MRJFileUtils */ + private static Method findFolder; - /** The openURL method of com.apple.mrj.MRJFileUtils */ - private static Method openURL; + /** The getFileCreator method of com.apple.mrj.MRJFileUtils */ + private static Method getFileCreator; - /** The makeOSType method of com.apple.MacOS.OSUtils */ - private static Method makeOSType; + /** The getFileType method of com.apple.mrj.MRJFileUtils */ + private static Method getFileType; - /** The putParameter method of com.apple.MacOS.AppleEvent */ - private static Method putParameter; + /** The openURL method of com.apple.mrj.MRJFileUtils */ + private static Method openURL; - /** The sendNoReply method of com.apple.MacOS.AppleEvent */ - private static Method sendNoReply; + /** The makeOSType method of com.apple.MacOS.OSUtils */ + private static Method makeOSType; - /** Actually an MRJOSType pointing to the System Folder on a Macintosh */ - private static Object kSystemFolderType; + /** The putParameter method of com.apple.MacOS.AppleEvent */ + private static Method putParameter; - /** The keyDirectObject AppleEvent parameter type */ - private static Integer keyDirectObject; + /** The sendNoReply method of com.apple.MacOS.AppleEvent */ + private static Method sendNoReply; - /** The kAutoGenerateReturnID AppleEvent code */ - private static Integer kAutoGenerateReturnID; + /** Actually an MRJOSType pointing to the System Folder on a Macintosh */ + private static Object kSystemFolderType; - /** The kAnyTransactionID AppleEvent code */ - private static Integer kAnyTransactionID; + /** The keyDirectObject AppleEvent parameter type */ + private static Integer keyDirectObject; - /** The linkage object required for JDirect 3 on Mac OS X. */ - private static Object linkage; + /** The kAutoGenerateReturnID AppleEvent code */ + private static Integer kAutoGenerateReturnID; - /** The framework to reference on Mac OS X */ - private static final String JDirect_MacOSX = "/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox"; + /** The kAnyTransactionID AppleEvent code */ + private static Integer kAnyTransactionID; - /** JVM constant for MRJ 2.0 */ - private static final int MRJ_2_0 = 0; + /** The linkage object required for JDirect 3 on Mac OS X. */ + private static Object linkage; - /** JVM constant for MRJ 2.1 or later */ - private static final int MRJ_2_1 = 1; + /** The framework to reference on Mac OS X */ + private static final String JDirect_MacOSX = "/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/HIToolbox"; - /** JVM constant for Java on Mac OS X 10.0 (MRJ 3.0) */ - private static final int MRJ_3_0 = 3; + /** JVM constant for MRJ 2.0 */ + private static final int MRJ_2_0 = 0; - /** JVM constant for MRJ 3.1 */ - private static final int MRJ_3_1 = 4; + /** JVM constant for MRJ 2.1 or later */ + private static final int MRJ_2_1 = 1; - /** JVM constant for any Windows NT JVM */ - private static final int WINDOWS_NT = 5; + /** JVM constant for Java on Mac OS X 10.0 (MRJ 3.0) */ + private static final int MRJ_3_0 = 3; - /** JVM constant for any Windows 9x JVM */ - private static final int WINDOWS_9x = 6; + /** JVM constant for MRJ 3.1 */ + private static final int MRJ_3_1 = 4; - /** JVM constant for any other platform */ - private static final int OTHER = -1; + /** JVM constant for any Windows NT JVM */ + private static final int WINDOWS_NT = 5; - /** - * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep non-U.S. English - * systems from working properly. - */ - private static final String FINDER_TYPE = "FNDR"; + /** JVM constant for any Windows 9x JVM */ + private static final int WINDOWS_9x = 6; - /** - * The creator code of the Finder on a Macintosh, which is needed to send AppleEvents to the - * application. - */ - private static final String FINDER_CREATOR = "MACS"; + /** JVM constant for any other platform */ + private static final int OTHER = -1; - /** The name for the AppleEvent type corresponding to a GetURL event. */ - private static final String GURL_EVENT = "GURL"; + /** + * The file type of the Finder on a Macintosh. Hardcoding "Finder" would keep non-U.S. English + * systems from working properly. + */ + private static final String FINDER_TYPE = "FNDR"; - /** - * The first parameter that needs to be passed into Runtime.exec() to open the default web - * browser on Windows. - */ - private static final String FIRST_WINDOWS_PARAMETER = "/c"; + /** + * The creator code of the Finder on a Macintosh, which is needed to send AppleEvents to the + * application. + */ + private static final String FINDER_CREATOR = "MACS"; - /** The second parameter for Runtime.exec() on Windows. */ - private static final String SECOND_WINDOWS_PARAMETER = "start"; + /** The name for the AppleEvent type corresponding to a GetURL event. */ + private static final String GURL_EVENT = "GURL"; - /** - * The third parameter for Runtime.exec() on Windows. This is a "title" - * parameter that the command line expects. Setting this parameter allows - * URLs containing spaces to work. - */ - private static final String THIRD_WINDOWS_PARAMETER = "\"\""; + /** + * The first parameter that needs to be passed into Runtime.exec() to open the default web + * browser on Windows. + */ + private static final String FIRST_WINDOWS_PARAMETER = "/c"; - /** - * The shell parameters for Netscape that opens a given URL in an already-open copy of Netscape - * on many command-line systems. - */ - private static final String NETSCAPE_REMOTE_PARAMETER = "-remote"; - private static final String NETSCAPE_OPEN_PARAMETER_START = "openURL("; - private static final String NETSCAPE_OPEN_NEW_WINDOW = ", new-window"; - private static final String NETSCAPE_OPEN_PARAMETER_END = ")"; + /** The second parameter for Runtime.exec() on Windows. */ + private static final String SECOND_WINDOWS_PARAMETER = "start"; - /** - * The message from any exception thrown throughout the initialization process. - */ - private static String errorMessage; + /** + * The third parameter for Runtime.exec() on Windows. This is a "title" + * parameter that the command line expects. Setting this parameter allows + * URLs containing spaces to work. + */ + private static final String THIRD_WINDOWS_PARAMETER = "\"\""; - /** - * An initialization block that determines the operating system and loads the necessary - * runtime data. - */ - static { - loadedWithoutErrors = true; - - String osName = System.getProperty("os.name"); - - if (osName.startsWith("Mac OS")) { - String mrjVersion = System.getProperty("mrj.version"); - String majorMRJVersion = mrjVersion.substring(0, 3); - - try { - double version = Double.valueOf(majorMRJVersion).doubleValue(); - - if (version == 2) { - jvm = MRJ_2_0; - } else if ((version >= 2.1) && (version < 3)) { - // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually - // works via Runtime.exec() and 2.2 supports that but has an openURL() method - // as well that we currently ignore. - jvm = MRJ_2_1; - } else if (version == 3.0) { - jvm = MRJ_3_0; - } else if (version >= 3.1) { - // Assume that all 3.1 and later versions of MRJ work the same. - jvm = MRJ_3_1; - } else { - loadedWithoutErrors = false; - errorMessage = "Unsupported MRJ version: " + version; - } - } catch (NumberFormatException nfe) { - loadedWithoutErrors = false; - errorMessage = "Invalid MRJ version: " + mrjVersion; - } - } else if (osName.startsWith("Windows")) { - if (osName.indexOf("9") != -1) { - jvm = WINDOWS_9x; - } else { - jvm = WINDOWS_NT; - } - } else { - jvm = OTHER; - } + /** + * The shell parameters for Netscape that opens a given URL in an already-open copy of Netscape + * on many command-line systems. + */ + private static final String NETSCAPE_REMOTE_PARAMETER = "-remote"; + private static final String NETSCAPE_OPEN_PARAMETER_START = "openURL("; + private static final String NETSCAPE_OPEN_NEW_WINDOW = ", new-window"; + private static final String NETSCAPE_OPEN_PARAMETER_END = ")"; + + /** + * The message from any exception thrown throughout the initialization process. + */ + private static String errorMessage; - if (loadedWithoutErrors) { // if we haven't hit any errors yet - loadedWithoutErrors = loadClasses(); + /** + * An initialization block that determines the operating system and loads the necessary + * runtime data. + */ + static + { + loadedWithoutErrors = true; + + String osName = System.getProperty("os.name"); + + if (osName.startsWith("Mac OS")) + { + String mrjVersion = System.getProperty("mrj.version"); + String majorMRJVersion = mrjVersion.substring(0, 3); + + try + { + double version = Double.valueOf(majorMRJVersion).doubleValue(); + + if (version == 2) + { + jvm = MRJ_2_0; + } + else if ( (version >= 2.1) && (version < 3)) + { + // Assume that all 2.x versions of MRJ work the same. MRJ 2.1 actually + // works via Runtime.exec() and 2.2 supports that but has an openURL() method + // as well that we currently ignore. + jvm = MRJ_2_1; + } + else if (version == 3.0) + { + jvm = MRJ_3_0; } + else if (version >= 3.1) + { + // Assume that all 3.1 and later versions of MRJ work the same. + jvm = MRJ_3_1; + } + else + { + loadedWithoutErrors = false; + errorMessage = "Unsupported MRJ version: " + version; + } + } + catch (NumberFormatException nfe) + { + loadedWithoutErrors = false; + errorMessage = "Invalid MRJ version: " + mrjVersion; + } + } + else if (osName.startsWith("Windows")) + { + if (osName.indexOf("9") != -1) + { + jvm = WINDOWS_9x; + } + else + { + jvm = WINDOWS_NT; + } + } + else + { + jvm = OTHER; } - /** - * This class should be never be instantiated; this just ensures so. - */ - private BrowserLauncher() { + if (loadedWithoutErrors) + { // if we haven't hit any errors yet + loadedWithoutErrors = loadClasses(); } + } + + /** + * This class should be never be instantiated; this just ensures so. + */ + private BrowserLauncher() + { + } + + /** + * Called by a static initializer to load any classes, fields, and methods required at runtime + * to locate the user's web browser. + * @return true if all intialization succeeded + * false if any portion of the initialization failed + */ + private static boolean loadClasses() + { + switch (jvm) + { + case MRJ_2_0: + + try + { + Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); + Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); + Class appleEventClass = Class.forName( + "com.apple.MacOS.AppleEvent"); + Class aeClass = Class.forName("com.apple.MacOS.ae"); + aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); + + aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] + { + int.class + }); + appleEventConstructor = appleEventClass.getDeclaredConstructor(new + Class[] + { + int.class, int.class, aeTargetClass, int.class, + int.class + }); + aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] + { + String.class + }); + + makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", + new Class[] + {String.class}); + putParameter = appleEventClass.getDeclaredMethod("putParameter", + new Class[] + {int.class, aeDescClass}); + sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", + new Class[] + {}); + + Field keyDirectObjectField = aeClass.getDeclaredField( + "keyDirectObject"); + keyDirectObject = (Integer) keyDirectObjectField.get(null); + + Field autoGenerateReturnIDField = appleEventClass.getDeclaredField( + "kAutoGenerateReturnID"); + kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); + + Field anyTransactionIDField = appleEventClass.getDeclaredField( + "kAnyTransactionID"); + kAnyTransactionID = (Integer) anyTransactionIDField.get(null); + } + catch (ClassNotFoundException cnfe) + { + errorMessage = cnfe.getMessage(); - /** - * Called by a static initializer to load any classes, fields, and methods required at runtime - * to locate the user's web browser. - * @return true if all intialization succeeded - * false if any portion of the initialization failed - */ - private static boolean loadClasses() { - switch (jvm) { - case MRJ_2_0: - - try { - Class aeTargetClass = Class.forName("com.apple.MacOS.AETarget"); - Class osUtilsClass = Class.forName("com.apple.MacOS.OSUtils"); - Class appleEventClass = Class.forName( - "com.apple.MacOS.AppleEvent"); - Class aeClass = Class.forName("com.apple.MacOS.ae"); - aeDescClass = Class.forName("com.apple.MacOS.AEDesc"); - - aeTargetConstructor = aeTargetClass.getDeclaredConstructor(new Class[] { - int.class - }); - appleEventConstructor = appleEventClass.getDeclaredConstructor(new Class[] { - int.class, int.class, aeTargetClass, int.class, - int.class - }); - aeDescConstructor = aeDescClass.getDeclaredConstructor(new Class[] { - String.class - }); - - makeOSType = osUtilsClass.getDeclaredMethod("makeOSType", - new Class[] { String.class }); - putParameter = appleEventClass.getDeclaredMethod("putParameter", - new Class[] { int.class, aeDescClass }); - sendNoReply = appleEventClass.getDeclaredMethod("sendNoReply", - new Class[] { }); - - Field keyDirectObjectField = aeClass.getDeclaredField( - "keyDirectObject"); - keyDirectObject = (Integer) keyDirectObjectField.get(null); - - Field autoGenerateReturnIDField = appleEventClass.getDeclaredField( - "kAutoGenerateReturnID"); - kAutoGenerateReturnID = (Integer) autoGenerateReturnIDField.get(null); - - Field anyTransactionIDField = appleEventClass.getDeclaredField( - "kAnyTransactionID"); - kAnyTransactionID = (Integer) anyTransactionIDField.get(null); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); - - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - - return false; - } catch (NoSuchFieldException nsfe) { - errorMessage = nsfe.getMessage(); - - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); - - return false; - } + return false; + } + catch (NoSuchMethodException nsme) + { + errorMessage = nsme.getMessage(); - break; + return false; + } + catch (NoSuchFieldException nsfe) + { + errorMessage = nsfe.getMessage(); - case MRJ_2_1: + return false; + } + catch (IllegalAccessException iae) + { + errorMessage = iae.getMessage(); - try { - mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); - mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); - - Field systemFolderField = mrjFileUtilsClass.getDeclaredField( - "kSystemFolderType"); - kSystemFolderType = systemFolderField.get(null); - findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", - new Class[] { mrjOSTypeClass }); - getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", - new Class[] { File.class }); - getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", - new Class[] { File.class }); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); - - return false; - } catch (NoSuchFieldException nsfe) { - errorMessage = nsfe.getMessage(); - - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - - return false; - } catch (SecurityException se) { - errorMessage = se.getMessage(); - - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); - - return false; - } + return false; + } - break; + break + ; + + case MRJ_2_1: + + try + { + mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); + mrjOSTypeClass = Class.forName("com.apple.mrj.MRJOSType"); + + Field systemFolderField = mrjFileUtilsClass.getDeclaredField( + "kSystemFolderType"); + kSystemFolderType = systemFolderField.get(null); + findFolder = mrjFileUtilsClass.getDeclaredMethod("findFolder", + new Class[] + {mrjOSTypeClass}); + getFileCreator = mrjFileUtilsClass.getDeclaredMethod("getFileCreator", + new Class[] + {File.class}); + getFileType = mrjFileUtilsClass.getDeclaredMethod("getFileType", + new Class[] + {File.class}); + } + catch (ClassNotFoundException cnfe) + { + errorMessage = cnfe.getMessage(); - case MRJ_3_0: + return false; + } + catch (NoSuchFieldException nsfe) + { + errorMessage = nsfe.getMessage(); - try { - Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); - Constructor constructor = linker.getConstructor(new Class[] { - Class.class - }); - linkage = constructor.newInstance(new Object[] { - BrowserLauncher.class - }); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); + return false; + } + catch (NoSuchMethodException nsme) + { + errorMessage = nsme.getMessage(); - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); + return false; + } + catch (SecurityException se) + { + errorMessage = se.getMessage(); - return false; - } catch (InvocationTargetException ite) { - errorMessage = ite.getMessage(); + return false; + } + catch (IllegalAccessException iae) + { + errorMessage = iae.getMessage(); - return false; - } catch (InstantiationException ie) { - errorMessage = ie.getMessage(); + return false; + } - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); + break + ; + + case MRJ_3_0: + + try + { + Class linker = Class.forName("com.apple.mrj.jdirect.Linker"); + Constructor constructor = linker.getConstructor(new Class[] + { + Class.class + }); + linkage = constructor.newInstance(new Object[] + { + BrowserLauncher.class + }); + } + catch (ClassNotFoundException cnfe) + { + errorMessage = cnfe.getMessage(); - return false; - } + return false; + } + catch (NoSuchMethodException nsme) + { + errorMessage = nsme.getMessage(); - break; + return false; + } + catch (InvocationTargetException ite) + { + errorMessage = ite.getMessage(); - case MRJ_3_1: + return false; + } + catch (InstantiationException ie) + { + errorMessage = ie.getMessage(); - try { - mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); - openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", - new Class[] { String.class }); - } catch (ClassNotFoundException cnfe) { - errorMessage = cnfe.getMessage(); + return false; + } + catch (IllegalAccessException iae) + { + errorMessage = iae.getMessage(); - return false; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); + return false; + } - return false; - } + break + ; - break; + case MRJ_3_1: - default: - break; + try + { + mrjFileUtilsClass = Class.forName("com.apple.mrj.MRJFileUtils"); + openURL = mrjFileUtilsClass.getDeclaredMethod("openURL", + new Class[] + {String.class}); } + catch (ClassNotFoundException cnfe) + { + errorMessage = cnfe.getMessage(); - return true; - } + return false; + } + catch (NoSuchMethodException nsme) + { + errorMessage = nsme.getMessage(); - /** - * Attempts to locate the default web browser on the local system. Caches results so it - * only locates the browser once for each use of this class per JVM instance. - * @return The browser for the system. Note that this may not be what you would consider - * to be a standard web browser; instead, it's the application that gets called to - * open the default web browser. In some cases, this will be a non-String object - * that provides the means of calling the default browser. - */ - private static Object locateBrowser() { - if (browser != null) { - return browser; + return false; } - switch (jvm) { - case MRJ_2_0: - - try { - Integer finderCreatorCode = (Integer) makeOSType.invoke(null, - new Object[] { FINDER_CREATOR }); - Object aeTarget = aeTargetConstructor.newInstance(new Object[] { - finderCreatorCode - }); - Integer gurlType = (Integer) makeOSType.invoke(null, - new Object[] { GURL_EVENT }); - Object appleEvent = appleEventConstructor.newInstance(new Object[] { - gurlType, gurlType, aeTarget, kAutoGenerateReturnID, - kAnyTransactionID - }); - - // Don't set browser = appleEvent because then the next time we call - // locateBrowser(), we'll get the same AppleEvent, to which we'll already have - // added the relevant parameter. Instead, regenerate the AppleEvent every time. - // There's probably a way to do this better; if any has any ideas, please let - // me know. - return appleEvent; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); - - return browser; - } catch (InstantiationException ie) { - browser = null; - errorMessage = ie.getMessage(); - - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getMessage(); - - return browser; - } + break + ; - case MRJ_2_1: + default: + break; + } - File systemFolder; + return true; + } + + /** + * Attempts to locate the default web browser on the local system. Caches results so it + * only locates the browser once for each use of this class per JVM instance. + * @return The browser for the system. Note that this may not be what you would consider + * to be a standard web browser; instead, it's the application that gets called to + * open the default web browser. In some cases, this will be a non-String object + * that provides the means of calling the default browser. + */ + private static Object locateBrowser() + { + if (browser != null) + { + return browser; + } - try { - systemFolder = (File) findFolder.invoke(null, - new Object[] { kSystemFolderType }); - } catch (IllegalArgumentException iare) { - browser = null; - errorMessage = iare.getMessage(); + switch (jvm) + { + case MRJ_2_0: + + try + { + Integer finderCreatorCode = (Integer) makeOSType.invoke(null, + new Object[] + {FINDER_CREATOR}); + Object aeTarget = aeTargetConstructor.newInstance(new Object[] + { + finderCreatorCode + }); + Integer gurlType = (Integer) makeOSType.invoke(null, + new Object[] + {GURL_EVENT}); + Object appleEvent = appleEventConstructor.newInstance(new Object[] + { + gurlType, gurlType, aeTarget, kAutoGenerateReturnID, + kAnyTransactionID + }); + + // Don't set browser = appleEvent because then the next time we call + // locateBrowser(), we'll get the same AppleEvent, to which we'll already have + // added the relevant parameter. Instead, regenerate the AppleEvent every time. + // There's probably a way to do this better; if any has any ideas, please let + // me know. + return appleEvent; + } + catch (IllegalAccessException iae) + { + browser = null; + errorMessage = iae.getMessage(); - return browser; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); + return browser; + } + catch (InstantiationException ie) + { + browser = null; + errorMessage = ie.getMessage(); - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getTargetException().getClass() + ": " + - ite.getTargetException().getMessage(); + return browser; + } + catch (InvocationTargetException ite) + { + browser = null; + errorMessage = ite.getMessage(); - return browser; - } + return browser; + } - String[] systemFolderFiles = systemFolder.list(); - - // Avoid a FilenameFilter because that can't be stopped mid-list - for (int i = 0; i < systemFolderFiles.length; i++) { - try { - File file = new File(systemFolder, systemFolderFiles[i]); - - if (!file.isFile()) { - continue; - } - - // We're looking for a file with a creator code of 'MACS' and - // a type of 'FNDR'. Only requiring the type results in non-Finder - // applications being picked up on certain Mac OS 9 systems, - // especially German ones, and sending a GURL event to those - // applications results in a logout under Multiple Users. - Object fileType = getFileType.invoke(null, - new Object[] { file }); - - if (FINDER_TYPE.equals(fileType.toString())) { - Object fileCreator = getFileCreator.invoke(null, - new Object[] { file }); - - if (FINDER_CREATOR.equals(fileCreator.toString())) { - browser = file.toString(); // Actually the Finder, but that's OK - - return browser; - } - } - } catch (IllegalArgumentException iare) { - browser = browser; - errorMessage = iare.getMessage(); - - return null; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); - - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getTargetException().getClass() + ": " + - ite.getTargetException().getMessage(); - - return browser; - } - } + case MRJ_2_1: + File systemFolder; + + try + { + systemFolder = (File) findFolder.invoke(null, + new Object[] + {kSystemFolderType}); + } + catch (IllegalArgumentException iare) + { browser = null; + errorMessage = iare.getMessage(); - break; + return browser; + } + catch (IllegalAccessException iae) + { + browser = null; + errorMessage = iae.getMessage(); - case MRJ_3_0: - case MRJ_3_1: - browser = ""; // Return something non-null + return browser; + } + catch (InvocationTargetException ite) + { + browser = null; + errorMessage = ite.getTargetException().getClass() + ": " + + ite.getTargetException().getMessage(); - break; + return browser; + } + + String[] systemFolderFiles = systemFolder.list(); + + // Avoid a FilenameFilter because that can't be stopped mid-list + for (int i = 0; i < systemFolderFiles.length; i++) + { + try + { + File file = new File(systemFolder, systemFolderFiles[i]); + + if (!file.isFile()) + { + continue; + } + + // We're looking for a file with a creator code of 'MACS' and + // a type of 'FNDR'. Only requiring the type results in non-Finder + // applications being picked up on certain Mac OS 9 systems, + // especially German ones, and sending a GURL event to those + // applications results in a logout under Multiple Users. + Object fileType = getFileType.invoke(null, + new Object[] + {file}); + + if (FINDER_TYPE.equals(fileType.toString())) + { + Object fileCreator = getFileCreator.invoke(null, + new Object[] + {file}); + + if (FINDER_CREATOR.equals(fileCreator.toString())) + { + browser = file.toString(); // Actually the Finder, but that's OK + + return browser; + } + } + } + catch (IllegalArgumentException iare) + { + browser = browser; + errorMessage = iare.getMessage(); - case WINDOWS_NT: - browser = "cmd.exe"; + return null; + } + catch (IllegalAccessException iae) + { + browser = null; + errorMessage = iae.getMessage(); - break; + return browser; + } + catch (InvocationTargetException ite) + { + browser = null; + errorMessage = ite.getTargetException().getClass() + ": " + + ite.getTargetException().getMessage(); - case WINDOWS_9x: - browser = "command.com"; + return browser; + } + } - break; + browser = null; - case OTHER:default: - browser = jalview.bin.Cache.applicationProperties.getProperty( - "jalview.browser"); + break; - if (browser == null) { - // hope firefox exists :-/ - browser = "firefox"; - } + case MRJ_3_0: + case MRJ_3_1: + browser = ""; // Return something non-null - break; - } + break; - return browser; - } + case WINDOWS_NT: + browser = "cmd.exe"; - /** - * Attempts to open the default web browser to the given URL. - * @param url The URL to open - * @throws IOException If the web browser could not be located or does not run - */ - public static void openURL(String url) throws IOException { - if (!loadedWithoutErrors) { - throw new IOException("Exception in finding browser: " + - errorMessage); - } - - Object browser = locateBrowser(); - - if (browser == null) { - throw new IOException("Unable to locate browser: " + errorMessage); - } - - switch (jvm) { - case MRJ_2_0: - - Object aeDesc = null; - - try { - aeDesc = aeDescConstructor.newInstance(new Object[] { url }); - putParameter.invoke(browser, - new Object[] { keyDirectObject, aeDesc }); - sendNoReply.invoke(browser, new Object[] { }); - } catch (InvocationTargetException ite) { - throw new IOException( - "InvocationTargetException while creating AEDesc: " + - ite.getMessage()); - } catch (IllegalAccessException iae) { - throw new IOException( - "IllegalAccessException while building AppleEvent: " + - iae.getMessage()); - } catch (InstantiationException ie) { - throw new IOException( - "InstantiationException while creating AEDesc: " + - ie.getMessage()); - } finally { - aeDesc = null; // Encourage it to get disposed if it was created - browser = null; // Ditto - } + break; - break; + case WINDOWS_9x: + browser = "command.com"; - case MRJ_2_1: - Runtime.getRuntime().exec(new String[] { (String) browser, url }); + break; - break; + case OTHER: + default: + browser = jalview.bin.Cache.applicationProperties.getProperty( + "jalview.browser"); - case MRJ_3_0: + if (browser == null) + { + // hope firefox exists :-/ + browser = "firefox"; + } - int[] instance = new int[1]; - int result = ICStart(instance, 0); + break; + } - if (result == 0) { - int[] selectionStart = new int[] { 0 }; - byte[] urlBytes = url.getBytes(); - int[] selectionEnd = new int[] { urlBytes.length }; - result = ICLaunchURL(instance[0], new byte[] { 0 }, urlBytes, - urlBytes.length, selectionStart, selectionEnd); + return browser; + } + + /** + * Attempts to open the default web browser to the given URL. + * @param url The URL to open + * @throws IOException If the web browser could not be located or does not run + */ + public static void openURL(String url) + throws IOException + { + if (!loadedWithoutErrors) + { + throw new IOException("Exception in finding browser: " + + errorMessage); + } - if (result == 0) { - // Ignore the return value; the URL was launched successfully - // regardless of what happens here. - ICStop(instance); - } else { - throw new IOException("Unable to launch URL: " + result); - } - } else { - throw new IOException( - "Unable to create an Internet Config instance: " + result); - } + Object browser = locateBrowser(); - break; + if (browser == null) + { + throw new IOException("Unable to locate browser: " + errorMessage); + } - case MRJ_3_1: + switch (jvm) + { + case MRJ_2_0: + + Object aeDesc = null; + + try + { + aeDesc = aeDescConstructor.newInstance(new Object[] + {url}); + putParameter.invoke(browser, + new Object[] + {keyDirectObject, aeDesc}); + sendNoReply.invoke(browser, new Object[] + {}); + } + catch (InvocationTargetException ite) + { + throw new IOException( + "InvocationTargetException while creating AEDesc: " + + ite.getMessage()); + } + catch (IllegalAccessException iae) + { + throw new IOException( + "IllegalAccessException while building AppleEvent: " + + iae.getMessage()); + } + catch (InstantiationException ie) + { + throw new IOException( + "InstantiationException while creating AEDesc: " + + ie.getMessage()); + } + finally + { + aeDesc = null; // Encourage it to get disposed if it was created + browser = null; // Ditto + } - try { - openURL.invoke(null, new Object[] { url }); - } catch (InvocationTargetException ite) { - throw new IOException( - "InvocationTargetException while calling openURL: " + - ite.getMessage()); - } catch (IllegalAccessException iae) { - throw new IOException( - "IllegalAccessException while calling openURL: " + - iae.getMessage()); - } + break; + + case MRJ_2_1: + Runtime.getRuntime().exec(new String[] + { (String) browser, url}); + + break; + + case MRJ_3_0: + + int[] instance = new int[1]; + int result = ICStart(instance, 0); + + if (result == 0) + { + int[] selectionStart = new int[] + { + 0}; + byte[] urlBytes = url.getBytes(); + int[] selectionEnd = new int[] + { + urlBytes.length}; + result = ICLaunchURL(instance[0], new byte[] + {0}, urlBytes, + urlBytes.length, selectionStart, selectionEnd); + + if (result == 0) + { + // Ignore the return value; the URL was launched successfully + // regardless of what happens here. + ICStop(instance); + } + else + { + throw new IOException("Unable to launch URL: " + result); + } + } + else + { + throw new IOException( + "Unable to create an Internet Config instance: " + result); + } - break; - - case WINDOWS_NT: - case WINDOWS_9x: - - // Add quotes around the URL to allow ampersands and other special - // characters to work. - Process process = Runtime.getRuntime().exec(new String[] { - (String) browser, FIRST_WINDOWS_PARAMETER, - SECOND_WINDOWS_PARAMETER, THIRD_WINDOWS_PARAMETER, - '"' + url + '"' - }); - - // This avoids a memory leak on some versions of Java on Windows. - // That's hinted at in . - try { - process.waitFor(); - process.exitValue(); - } catch (InterruptedException ie) { - throw new IOException( - "InterruptedException while launching browser: " + - ie.getMessage()); - } + break; - break; + case MRJ_3_1: - case OTHER: + try + { + openURL.invoke(null, new Object[] + {url}); + } + catch (InvocationTargetException ite) + { + throw new IOException( + "InvocationTargetException while calling openURL: " + + ite.getMessage()); + } + catch (IllegalAccessException iae) + { + throw new IOException( + "IllegalAccessException while calling openURL: " + + iae.getMessage()); + } - // Assume that we're on Unix and that Netscape (actually Firefox) is installed - // First, attempt to open the URL in a currently running session of Netscape - // JBPNote log debug + break + ; + + case WINDOWS_NT: + case WINDOWS_9x: + + // Add quotes around the URL to allow ampersands and other special + // characters to work. + Process process = Runtime.getRuntime().exec(new String[] + { + (String) browser, FIRST_WINDOWS_PARAMETER, + SECOND_WINDOWS_PARAMETER, THIRD_WINDOWS_PARAMETER, + '"' + url + '"' + }); + + // This avoids a memory leak on some versions of Java on Windows. + // That's hinted at in . + try + { + process.waitFor(); + process.exitValue(); + } + catch (InterruptedException ie) + { + throw new IOException( + "InterruptedException while launching browser: " + + ie.getMessage()); + } - /* System.out.println("Executing : "+browser+" "+ - NETSCAPE_REMOTE_PARAMETER+" "+ - NETSCAPE_OPEN_PARAMETER_START + - url + - NETSCAPE_OPEN_NEW_WINDOW + - NETSCAPE_OPEN_PARAMETER_END); - */ - process = Runtime.getRuntime().exec(new String[] { - (String) browser, NETSCAPE_REMOTE_PARAMETER, - - NETSCAPE_OPEN_PARAMETER_START + url + - NETSCAPE_OPEN_NEW_WINDOW + NETSCAPE_OPEN_PARAMETER_END - }); - - try { - int exitCode = process.waitFor(); - - if (exitCode != 0) { // if Netscape was not open - Runtime.getRuntime().exec(new String[] { (String) browser, url }); - } - } catch (InterruptedException ie) { - throw new IOException( - "InterruptedException while launching browser: " + - ie.getMessage()); - } + break + ; + + case OTHER: + + // Assume that we're on Unix and that Netscape (actually Firefox) is installed + // First, attempt to open the URL in a currently running session of Netscape + // JBPNote log debug + + /* System.out.println("Executing : "+browser+" "+ + NETSCAPE_REMOTE_PARAMETER+" "+ + NETSCAPE_OPEN_PARAMETER_START + + url + + NETSCAPE_OPEN_NEW_WINDOW + + NETSCAPE_OPEN_PARAMETER_END); + */ + process = Runtime.getRuntime().exec(new String[] + { + (String) browser, + NETSCAPE_REMOTE_PARAMETER, + + NETSCAPE_OPEN_PARAMETER_START + url + + NETSCAPE_OPEN_NEW_WINDOW + + NETSCAPE_OPEN_PARAMETER_END + }); + + try + { + int exitCode = process.waitFor(); + + if (exitCode != 0) + { // if Netscape was not open + Runtime.getRuntime().exec(new String[] + { (String) browser, url}); + } + } + catch (InterruptedException ie) + { + throw new IOException( + "InterruptedException while launching browser: " + + ie.getMessage()); + } - break; + break + ; - default: + default: - // This should never occur, but if it does, we'll try the simplest thing possible - Runtime.getRuntime().exec(new String[] { (String) browser, url }); + // This should never occur, but if it does, we'll try the simplest thing possible + Runtime.getRuntime().exec(new String[] + { (String) browser, url}); - break; - } + break; } + } - /** - * Methods required for Mac OS X. The presence of native methods does not cause - * any problems on other platforms. - */ - private native static int ICStart(int[] instance, int signature); + /** + * Methods required for Mac OS X. The presence of native methods does not cause + * any problems on other platforms. + */ + private native static int ICStart(int[] instance, int signature); - private native static int ICStop(int[] instance); + private native static int ICStop(int[] instance); - private native static int ICLaunchURL(int instance, byte[] hint, - byte[] data, int len, int[] selectionStart, int[] selectionEnd); + private native static int ICLaunchURL(int instance, byte[] hint, + byte[] data, int len, + int[] selectionStart, + int[] selectionEnd); } diff --git a/src/jalview/util/Comparison.java b/src/jalview/util/Comparison.java index 8041d80..c779bb1 100755 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -21,10 +21,27 @@ package jalview.util; import jalview.datamodel.*; -public class Comparison { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Comparison +{ + /** DOCUMENT ME!! */ public static String GapChars = " .-"; - public static float compare(SequenceI ii, SequenceI jj) { + /** + * DOCUMENT ME! + * + * @param ii DOCUMENT ME! + * @param jj DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static float compare(SequenceI ii, SequenceI jj) + { return Comparison.compare(ii, jj, 0, ii.getLength() - 1); } @@ -36,18 +53,21 @@ public class Comparison { * @param end int * @return float */ - public static float compare(SequenceI ii, SequenceI jj, int start, int end) { + public static float compare(SequenceI ii, SequenceI jj, int start, int end) + { String si = ii.getSequence(); String sj = jj.getSequence(); int ilen = si.length() - 1; int jlen = sj.length() - 1; - while (jalview.util.Comparison.isGap(si.charAt(start + ilen))) { + while (jalview.util.Comparison.isGap(si.charAt(start + ilen))) + { ilen--; } - while (jalview.util.Comparison.isGap(sj.charAt(start + jlen))) { + while (jalview.util.Comparison.isGap(sj.charAt(start + jlen))) + { jlen--; } @@ -55,10 +75,13 @@ public class Comparison { int match = 0; float pid = -1; - if (ilen > jlen) { - for (int j = 0; j < jlen; j++) { + if (ilen > jlen) + { + for (int j = 0; j < jlen; j++) + { if (si.substring(start + j, start + j + 1).equals(sj.substring(start + - j, start + j + 1))) { + j, start + j + 1))) + { match++; } @@ -66,10 +89,14 @@ public class Comparison { } pid = (float) match / (float) ilen * 100; - } else { - for (int j = 0; j < jlen; j++) { + } + else + { + for (int j = 0; j < jlen; j++) + { if (si.substring(start + j, start + j + 1).equals(sj.substring(start + - j, start + j + 1))) { + j, start + j + 1))) + { match++; } @@ -89,36 +116,49 @@ public class Comparison { * @param s2 SequenceI * @return float */ - public static float PID(SequenceI s1, SequenceI s2) { + public static float PID(SequenceI s1, SequenceI s2) + { int len; - if (s1.getSequence().length() > s2.getSequence().length()) { + if (s1.getSequence().length() > s2.getSequence().length()) + { len = s1.getSequence().length(); - } else { + } + else + { len = s2.getSequence().length(); } int bad = 0; - for (int i = 0; i < len; i++) { + for (int i = 0; i < len; i++) + { char chr1; char chr2; - if (i < s1.getSequence().length()) { + if (i < s1.getSequence().length()) + { chr1 = s1.getSequence().charAt(i); - } else { + } + else + { chr1 = '.'; } - if (i < s2.getSequence().length()) { + if (i < s2.getSequence().length()) + { chr2 = s2.getSequence().charAt(i); - } else { + } + else + { chr2 = '.'; } if (!(jalview.util.Comparison.isGap(chr1)) && - !(jalview.util.Comparison.isGap(chr2))) { - if (chr1 != chr2) { + !(jalview.util.Comparison.isGap(chr2))) + { + if (chr1 != chr2) + { bad++; } } @@ -128,44 +168,59 @@ public class Comparison { } // Another pid with region specification - public static float PID(SequenceI s1, SequenceI s2, int start, int end) { + public static float PID(SequenceI s1, SequenceI s2, int start, int end) + { int len; - if (s1.getSequence().length() > s2.getSequence().length()) { + if (s1.getSequence().length() > s2.getSequence().length()) + { len = s1.getSequence().length(); - } else { + } + else + { len = s2.getSequence().length(); } - if (end < len) { + if (end < len) + { len = end; } - if (len < start) { + if (len < start) + { start = len - 1; // we just use a single residue for the difference } int bad = 0; - for (int i = start; i < len; i++) { + for (int i = start; i < len; i++) + { char chr1; char chr2; - if (i < s1.getSequence().length()) { + if (i < s1.getSequence().length()) + { chr1 = s1.getSequence().charAt(i); - } else { + } + else + { chr1 = '.'; } - if (i < s2.getSequence().length()) { + if (i < s2.getSequence().length()) + { chr2 = s2.getSequence().charAt(i); - } else { + } + else + { chr2 = '.'; } if (!(jalview.util.Comparison.isGap(chr1)) && - !(jalview.util.Comparison.isGap(chr2))) { - if (chr1 != chr2) { + !(jalview.util.Comparison.isGap(chr2))) + { + if (chr1 != chr2) + { bad++; } } @@ -174,7 +229,15 @@ public class Comparison { return ((float) 100 * (len - bad)) / len; } - public static boolean isGap(char c) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static boolean isGap(char c) + { return ((c != '.') && (c != '-') && (c != ' ')) ? false : true; } } diff --git a/src/jalview/util/Format.java b/src/jalview/util/Format.java index 4c47f65..629fbcf 100755 --- a/src/jalview/util/Format.java +++ b/src/jalview/util/Format.java @@ -30,7 +30,14 @@ package jalview.util; import java.io.*; -public class Format { +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ +public class Format +{ private int width; private int precision; private String pre; @@ -42,7 +49,13 @@ public class Format { private boolean left_align; private char fmt; // one of cdeEfgGiosxXos - public Format(String s) { + /** + * Creates a new Format object. + * + * @param s DOCUMENT ME! + */ + public Format(String s) + { width = 0; precision = -1; pre = ""; @@ -62,41 +75,67 @@ public class Format { // 4 = format, 5 = end int i = 0; - while (parse_state == 0) { - if (i >= length) { + while (parse_state == 0) + { + if (i >= length) + { parse_state = 5; - } else if (s.charAt(i) == '%') { - if (i < (length - 1)) { - if (s.charAt(i + 1) == '%') { + } + else if (s.charAt(i) == '%') + { + if (i < (length - 1)) + { + if (s.charAt(i + 1) == '%') + { pre = pre + '%'; i++; - } else { + } + else + { parse_state = 1; } - } else { + } + else + { throw new java.lang.IllegalArgumentException(); } - } else { + } + else + { pre = pre + s.charAt(i); } i++; } - while (parse_state == 1) { - if (i >= length) { + while (parse_state == 1) + { + if (i >= length) + { parse_state = 5; - } else if (s.charAt(i) == ' ') { + } + else if (s.charAt(i) == ' ') + { show_space = true; - } else if (s.charAt(i) == '-') { + } + else if (s.charAt(i) == '-') + { left_align = true; - } else if (s.charAt(i) == '+') { + } + else if (s.charAt(i) == '+') + { show_plus = true; - } else if (s.charAt(i) == '0') { + } + else if (s.charAt(i) == '0') + { leading_zeroes = true; - } else if (s.charAt(i) == '#') { + } + else if (s.charAt(i) == '#') + { alternate = true; - } else { + } + else + { parse_state = 2; i--; } @@ -104,43 +143,62 @@ public class Format { i++; } - while (parse_state == 2) { - if (i >= length) { + while (parse_state == 2) + { + if (i >= length) + { parse_state = 5; - } else if (('0' <= s.charAt(i)) && (s.charAt(i) <= '9')) { + } + else if (('0' <= s.charAt(i)) && (s.charAt(i) <= '9')) + { width = ((width * 10) + s.charAt(i)) - '0'; i++; - } else if (s.charAt(i) == '.') { + } + else if (s.charAt(i) == '.') + { parse_state = 3; precision = 0; i++; - } else { + } + else + { parse_state = 4; } } - while (parse_state == 3) { - if (i >= length) { + while (parse_state == 3) + { + if (i >= length) + { parse_state = 5; - } else if (('0' <= s.charAt(i)) && (s.charAt(i) <= '9')) { + } + else if (('0' <= s.charAt(i)) && (s.charAt(i) <= '9')) + { precision = ((precision * 10) + s.charAt(i)) - '0'; i++; - } else { + } + else + { parse_state = 4; } } - if (parse_state == 4) { - if (i >= length) { + if (parse_state == 4) + { + if (i >= length) + { parse_state = 5; - } else { + } + else + { fmt = s.charAt(i); } i++; } - if (i < length) { + if (i < length) + { post = s.substring(i, length); } } @@ -181,25 +239,29 @@ public class Format { * @exception IllegalArgumentException if bad format * */ - public static String getHexString(java.awt.Color color) { + public static String getHexString(java.awt.Color color) + { String r; String g; String b; r = Integer.toHexString(color.getRed()); - if (r.length() < 2) { + if (r.length() < 2) + { r = "0" + r; } g = Integer.toHexString(color.getGreen()); - if (g.length() < 2) { + if (g.length() < 2) + { g = "0" + g; } b = Integer.toHexString(color.getBlue()); - if (b.length() < 2) { + if (b.length() < 2) + { b = "0" + b; } @@ -212,7 +274,8 @@ public class Format { * @param fmt the format string * @param x the double to print */ - public static void print(java.io.PrintStream s, String fmt, double x) { + public static void print(java.io.PrintStream s, String fmt, double x) + { s.print(new Format(fmt).form(x)); } @@ -222,7 +285,8 @@ public class Format { * @param fmt the format string * @param x the long to print */ - public static void print(java.io.PrintStream s, String fmt, long x) { + public static void print(java.io.PrintStream s, String fmt, long x) + { s.print(new Format(fmt).form(x)); } @@ -232,7 +296,8 @@ public class Format { * @param fmt the format string * @param x the character to */ - public static void print(java.io.PrintStream s, String fmt, char x) { + public static void print(java.io.PrintStream s, String fmt, char x) + { s.print(new Format(fmt).form(x)); } @@ -241,7 +306,8 @@ public class Format { * @param s a PrintStream, fmt the format string * @param x a string that represents the digits to print */ - public static void print(java.io.PrintStream s, String fmt, String x) { + public static void print(java.io.PrintStream s, String fmt, String x) + { s.print(new Format(fmt).form(x)); } @@ -250,7 +316,8 @@ public class Format { * @param s a string * @return the numeric value of the prefix of s representing a base 10 integer */ - public static int atoi(String s) { + public static int atoi(String s) + { return (int) atol(s); } @@ -259,25 +326,41 @@ public class Format { * @param s a string * @return the numeric value of the prefix of s representing a base 10 integer */ - public static long atol(String s) { + public static long atol(String s) + { int i = 0; while ((i < s.length()) && Character.isWhitespace(s.charAt(i))) i++; - if ((i < s.length()) && (s.charAt(i) == '0')) { + if ((i < s.length()) && (s.charAt(i) == '0')) + { if (((i + 1) < s.length()) && - ((s.charAt(i + 1) == 'x') || (s.charAt(i + 1) == 'X'))) { + ((s.charAt(i + 1) == 'x') || (s.charAt(i + 1) == 'X'))) + { return parseLong(s.substring(i + 2), 16); - } else { + } + else + { return parseLong(s, 8); } - } else { + } + else + { return parseLong(s, 10); } } - private static long parseLong(String s, int base) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param base DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static long parseLong(String s, int base) + { int i = 0; int sign = 1; long r = 0; @@ -285,23 +368,34 @@ public class Format { while ((i < s.length()) && Character.isWhitespace(s.charAt(i))) i++; - if ((i < s.length()) && (s.charAt(i) == '-')) { + if ((i < s.length()) && (s.charAt(i) == '-')) + { sign = -1; i++; - } else if ((i < s.length()) && (s.charAt(i) == '+')) { + } + else if ((i < s.length()) && (s.charAt(i) == '+')) + { i++; } - while (i < s.length()) { + while (i < s.length()) + { char ch = s.charAt(i); - if (('0' <= ch) && (ch < ('0' + base))) { + if (('0' <= ch) && (ch < ('0' + base))) + { r = ((r * base) + ch) - '0'; - } else if (('A' <= ch) && (ch < (('A' + base) - 10))) { + } + else if (('A' <= ch) && (ch < (('A' + base) - 10))) + { r = ((r * base) + ch) - 'A' + 10; - } else if (('a' <= ch) && (ch < (('a' + base) - 10))) { + } + else if (('a' <= ch) && (ch < (('a' + base) - 10))) + { r = ((r * base) + ch) - 'a' + 10; - } else { + } + else + { return r * sign; } @@ -315,7 +409,8 @@ public class Format { * Converts a string of digits to an double * @param s a string */ - public static double atof(String s) { + public static double atof(String s) + { int i = 0; int sign = 1; double r = 0; // integer part @@ -326,34 +421,51 @@ public class Format { while ((i < s.length()) && Character.isWhitespace(s.charAt(i))) i++; - if ((i < s.length()) && (s.charAt(i) == '-')) { + if ((i < s.length()) && (s.charAt(i) == '-')) + { sign = -1; i++; - } else if ((i < s.length()) && (s.charAt(i) == '+')) { + } + else if ((i < s.length()) && (s.charAt(i) == '+')) + { i++; } - while (i < s.length()) { + while (i < s.length()) + { char ch = s.charAt(i); - if (('0' <= ch) && (ch <= '9')) { - if (state == 0) { + if (('0' <= ch) && (ch <= '9')) + { + if (state == 0) + { r = ((r * 10) + ch) - '0'; - } else if (state == 1) { + } + else if (state == 1) + { p = p / 10; r = r + (p * (ch - '0')); } - } else if (ch == '.') { - if (state == 0) { + } + else if (ch == '.') + { + if (state == 0) + { state = 1; - } else { + } + else + { return sign * r; } - } else if ((ch == 'e') || (ch == 'E')) { + } + else if ((ch == 'e') || (ch == 'E')) + { long e = (int) parseLong(s.substring(i + 1), 10); return sign * r * Math.pow(10, e); - } else { + } + else + { return sign * r; } @@ -369,26 +481,33 @@ public class Format { * @return the formatted string * @exception IllegalArgumentException if bad argument */ - public String form(double x) { + public String form(double x) + { String r; - if (precision < 0) { + if (precision < 0) + { precision = 6; } int s = 1; - if (x < 0) { + if (x < 0) + { x = -x; s = -1; } - if (fmt == 'f') { + if (fmt == 'f') + { r = fixed_format(x); - } else if ((fmt == 'e') || (fmt == 'E') || (fmt == 'g') || - (fmt == 'G')) { + } + else if ((fmt == 'e') || (fmt == 'E') || (fmt == 'g') || (fmt == 'G')) + { r = exp_format(x); - } else { + } + else + { throw new java.lang.IllegalArgumentException(); } @@ -400,25 +519,38 @@ public class Format { * @param x the number to format * @return the formatted string */ - public String form(long x) { + public String form(long x) + { String r; int s = 0; - if ((fmt == 'd') || (fmt == 'i')) { - if (x < 0) { + if ((fmt == 'd') || (fmt == 'i')) + { + if (x < 0) + { r = ("" + x).substring(1); s = -1; - } else { + } + else + { r = "" + x; s = 1; } - } else if (fmt == 'o') { + } + else if (fmt == 'o') + { r = convert(x, 3, 7, "01234567"); - } else if (fmt == 'x') { + } + else if (fmt == 'x') + { r = convert(x, 4, 15, "0123456789abcdef"); - } else if (fmt == 'X') { + } + else if (fmt == 'X') + { r = convert(x, 4, 15, "0123456789ABCDEF"); - } else { + } + else + { throw new java.lang.IllegalArgumentException(); } @@ -430,8 +562,10 @@ public class Format { * @param x the value to format * @return the formatted string */ - public String form(char c) { - if (fmt != 'c') { + public String form(char c) + { + if (fmt != 'c') + { throw new java.lang.IllegalArgumentException(); } @@ -445,12 +579,15 @@ public class Format { * @param x the value to format * @return the formatted string */ - public String form(String s) { - if (fmt != 's') { + public String form(String s) + { + if (fmt != 's') + { throw new java.lang.IllegalArgumentException(); } - if (precision >= 0) { + if (precision >= 0) + { s = s.substring(0, precision); } @@ -460,7 +597,8 @@ public class Format { /** * a test stub for the format class */ - public static void main(String[] a) { + public static void main(String[] a) + { double x = 1.23456789012; double y = 123; double z = 1.2345e30; @@ -530,8 +668,18 @@ public class Format { Format.print(System.out, "|%6.0f|\n", 9.999); } - private static String repeat(char c, int n) { - if (n <= 0) { + /** + * DOCUMENT ME! + * + * @param c DOCUMENT ME! + * @param n DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static String repeat(char c, int n) + { + if (n <= 0) + { return ""; } @@ -543,14 +691,27 @@ public class Format { return s.toString(); } - private static String convert(long x, int n, int m, String d) { - if (x == 0) { + /** + * DOCUMENT ME! + * + * @param x DOCUMENT ME! + * @param n DOCUMENT ME! + * @param m DOCUMENT ME! + * @param d DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private static String convert(long x, int n, int m, String d) + { + if (x == 0) + { return "0"; } String r = ""; - while (x != 0) { + while (x != 0) + { r = d.charAt((int) (x & m)) + r; x = x >>> n; } @@ -558,66 +719,113 @@ public class Format { return r; } - private String pad(String r) { + /** + * DOCUMENT ME! + * + * @param r DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String pad(String r) + { String p = repeat(' ', width - r.length()); - if (left_align) { + if (left_align) + { return pre + r + p + post; - } else { + } + else + { return pre + p + r + post; } } - private String sign(int s, String r) { + /** + * DOCUMENT ME! + * + * @param s DOCUMENT ME! + * @param r DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String sign(int s, String r) + { String p = ""; - if (s < 0) { + if (s < 0) + { p = "-"; - } else if (s > 0) { - if (show_plus) { + } + else if (s > 0) + { + if (show_plus) + { p = "+"; - } else if (show_space) { + } + else if (show_space) + { p = " "; } - } else { + } + else + { if ((fmt == 'o') && alternate && (r.length() > 0) && - (r.charAt(0) != '0')) { + (r.charAt(0) != '0')) + { p = "0"; - } else if ((fmt == 'x') && alternate) { + } + else if ((fmt == 'x') && alternate) + { p = "0x"; - } else if ((fmt == 'X') && alternate) { + } + else if ((fmt == 'X') && alternate) + { p = "0X"; } } int w = 0; - if (leading_zeroes) { + if (leading_zeroes) + { w = width; - } else if (((fmt == 'd') || (fmt == 'i') || (fmt == 'x') || - (fmt == 'X') || (fmt == 'o')) && (precision > 0)) { + } + else if (((fmt == 'd') || (fmt == 'i') || (fmt == 'x') || (fmt == 'X') || + (fmt == 'o')) && (precision > 0)) + { w = precision; } return p + repeat('0', w - p.length() - r.length()) + r; } - private String fixed_format(double d) { + /** + * DOCUMENT ME! + * + * @param d DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String fixed_format(double d) + { boolean removeTrailing = ((fmt == 'G') || (fmt == 'g')) && !alternate; // remove trailing zeroes and decimal point - if (d > 0x7FFFFFFFFFFFFFFFL) { + if (d > 0x7FFFFFFFFFFFFFFFL) + { return exp_format(d); } - if (precision == 0) { + if (precision == 0) + { return (long) (d + 0.5) + (removeTrailing ? "" : "."); } long whole = (long) d; double fr = d - whole; // fractional part - if ((fr >= 1) || (fr < 0)) { + if ((fr >= 1) || (fr < 0)) + { return exp_format(d); } @@ -625,29 +833,33 @@ public class Format { String leading_zeroes = ""; for (int i = 1; (i <= precision) && (factor <= 0x7FFFFFFFFFFFFFFFL); - i++) { + i++) + { factor *= 10; leading_zeroes = leading_zeroes + "0"; } long l = (long) ((factor * fr) + 0.5); - if (l >= factor) { + if (l >= factor) + { l = 0; whole++; } - // CSH 10-25-97 + // CSH 10-25-97 String z = leading_zeroes + l; z = "." + z.substring(z.length() - precision, z.length()); - if (removeTrailing) { + if (removeTrailing) + { int t = z.length() - 1; while ((t >= 0) && (z.charAt(t) == '0')) t--; - if ((t >= 0) && (z.charAt(t) == '.')) { + if ((t >= 0) && (z.charAt(t) == '.')) + { t--; } @@ -657,45 +869,63 @@ public class Format { return whole + z; } - private String exp_format(double d) { + /** + * DOCUMENT ME! + * + * @param d DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private String exp_format(double d) + { String f = ""; int e = 0; double dd = d; double factor = 1; - if (d != 0) { - while (dd > 10) { + if (d != 0) + { + while (dd > 10) + { e++; factor /= 10; dd = dd / 10; } - while (dd < 1) { + while (dd < 1) + { e--; factor *= 10; dd = dd * 10; } } - if (((fmt == 'g') || (fmt == 'G')) && (e >= -4) && (e < precision)) { + if (((fmt == 'g') || (fmt == 'G')) && (e >= -4) && (e < precision)) + { return fixed_format(d); } d = d * factor; f = f + fixed_format(d); - if ((fmt == 'e') || (fmt == 'g')) { + if ((fmt == 'e') || (fmt == 'g')) + { f = f + "e"; - } else { + } + else + { f = f + "E"; } String p = "000"; - if (e >= 0) { + if (e >= 0) + { f = f + "+"; p = p + e; - } else { + } + else + { f = f + "-"; p = p + (-e); } diff --git a/src/jalview/util/QuickSort.java b/src/jalview/util/QuickSort.java index 127b419..80734f7 100755 --- a/src/jalview/util/QuickSort.java +++ b/src/jalview/util/QuickSort.java @@ -1,105 +1,130 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.util; -public class QuickSort { - public static void sort(float[] arr, Object[] s) { - sort(arr, 0, arr.length - 1, s); +public class QuickSort +{ + public static void sort(float[] arr, Object[] s) + { + sort(arr, 0, arr.length - 1, s); + } + + public static void sort(String[] arr, Object[] s) + { + stringSort(arr, 0, arr.length - 1, s); + } + + public static void stringSort(String[] arr, int p, int r, Object[] s) + { + int q; + + if (p < r) + { + q = stringPartition(arr, p, r, s); + stringSort(arr, p, q, s); + stringSort(arr, q + 1, r, s); } + } - public static void sort(String[] arr, Object[] s) { - stringSort(arr, 0, arr.length - 1, s); - } - - public static void stringSort(String[] arr, int p, int r, Object[] s) { - int q; + public static void sort(float[] arr, int p, int r, Object[] s) + { + int q; - if (p < r) { - q = stringPartition(arr, p, r, s); - stringSort(arr, p, q, s); - stringSort(arr, q + 1, r, s); - } + if (p < r) + { + q = partition(arr, p, r, s); + sort(arr, p, q, s); + sort(arr, q + 1, r, s); } - - public static void sort(float[] arr, int p, int r, Object[] s) { - int q; - - if (p < r) { - q = partition(arr, p, r, s); - sort(arr, p, q, s); - sort(arr, q + 1, r, s); - } + } + + private static int partition(float[] arr, int p, int r, Object[] s) + { + float x = arr[p]; + int i = p - 1; + int j = r + 1; + + while (true) + { + do + { + j = j - 1; + } + while (arr[j] > x); + + do + { + i = i + 1; + } + while (arr[i] < x); + + if (i < j) + { + float tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + + Object tmp2 = s[i]; + s[i] = s[j]; + s[j] = tmp2; + } + else + { + return j; + } } - - private static int partition(float[] arr, int p, int r, Object[] s) { - float x = arr[p]; - int i = p - 1; - int j = r + 1; - - while (true) { - do { - j = j - 1; - } while (arr[j] > x); - - do { - i = i + 1; - } while (arr[i] < x); - - if (i < j) { - float tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; - - Object tmp2 = s[i]; - s[i] = s[j]; - s[j] = tmp2; - } else { - return j; - } - } - } - - private static int stringPartition(String[] arr, int p, int r, Object[] s) { - String x = arr[p]; - int i = p - 1; - int j = r + 1; - - while (true) { - do { - j = j - 1; - } while (arr[j].compareTo(x) < 0); - - do { - i = i + 1; - } while (arr[i].compareTo(x) > 0); - - if (i < j) { - String tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; - - Object tmp2 = s[i]; - s[i] = s[j]; - s[j] = tmp2; - } else { - return j; - } - } + } + + private static int stringPartition(String[] arr, int p, int r, Object[] s) + { + String x = arr[p]; + int i = p - 1; + int j = r + 1; + + while (true) + { + do + { + j = j - 1; + } + while (arr[j].compareTo(x) < 0); + + do + { + i = i + 1; + } + while (arr[i].compareTo(x) > 0); + + if (i < j) + { + String tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; + + Object tmp2 = s[i]; + s[i] = s[j]; + s[j] = tmp2; + } + else + { + return j; + } } + } } diff --git a/src/jalview/ws/JPredClient.java b/src/jalview/ws/JPredClient.java index fefb74c..e6f3899 100755 --- a/src/jalview/ws/JPredClient.java +++ b/src/jalview/ws/JPredClient.java @@ -1,396 +1,481 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -*/ + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.ws; -import ext.vamsas.*; +import java.util.*; -import jalview.analysis.AlignSeq; +import javax.swing.*; +import ext.vamsas.*; +import jalview.analysis.*; import jalview.datamodel.*; - import jalview.gui.*; -import org.apache.axis.client.*; +public class JPredClient + extends WSClient +{ + ext.vamsas.JPredWS server; + String altitle = ""; + java.util.Hashtable SequenceInfo = null; -import java.awt.*; + public JPredClient(String title, SequenceI[] msf) + { + wsInfo = setWebService(); -import java.util.*; + SequenceI seq = msf[0]; + altitle = "JNet prediction on " + seq.getName() + + " using alignment from " + title; -import javax.swing.*; - -import javax.xml.namespace.QName; + wsInfo.setProgressText("Job details for MSA based prediction (" + + title + ") on sequence :\n>" + seq.getName() + "\n" + + AlignSeq.extractGaps("-. ", seq.getSequence()) + + "\n"); + SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq); -public class JPredClient extends WSClient { - ext.vamsas.JPredWS server; - String altitle = ""; - java.util.Hashtable SequenceInfo = null; + if (!locateWebService()) + { + return; + } - public JPredClient(String title, SequenceI[] msf) { - wsInfo = setWebService(); + JPredThread jthread = new JPredThread(msf); + jthread.start(); + } + + public JPredClient(String title, SequenceI seq) + { + wsInfo = setWebService(); + wsInfo.setProgressText("Job details for prediction on sequence :\n>" + + seq.getName() + "\n" + + AlignSeq.extractGaps("-. ", seq.getSequence()) + + "\n"); + altitle = "JNet prediction for sequence " + seq.getName() + " from " + + title; + + SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq); + + if (!locateWebService()) + { + return; + } - SequenceI seq = msf[0]; - altitle = "JNet prediction on " + seq.getName() + - " using alignment from " + title; + JPredThread jthread = new JPredThread(seq); + jthread.start(); + } + + private WebserviceInfo setWebService() + { + WebServiceName = "JNetWS"; + WebServiceJobTitle = "JNet secondary structure prediction"; + WebServiceReference = + "\"Cuff J. A and Barton G.J (1999) Application of enhanced " + + "multiple sequence alignment profiles to improve protein secondary structure prediction, " + + "Proteins 40:502-511\"."; + WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; + + WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, + WebServiceReference); + + return wsInfo; + } + + private boolean locateWebService() + { + JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default + + try + { + this.server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set from properties + ( (JpredSoapBindingStub)this.server).setTimeout(60000); // one minute stub + } + catch (Exception ex) + { + JOptionPane.showMessageDialog(Desktop.desktop, + "The Secondary Structure Prediction Service named " + + WebServiceName + " at " + WsURL + + " couldn't be located.", + "Internal Jalview Error", + JOptionPane.WARNING_MESSAGE); + wsInfo.setProgressText("Serious! " + WebServiceName + + " Service location failed\nfor URL :" + WsURL + + "\n" + + ex.getMessage()); + wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); + + return false; + } - wsInfo.setProgressText("Job details for MSA based prediction (" + - title + ") on sequence :\n>" + seq.getName() + "\n" + - AlignSeq.extractGaps("-. ", seq.getSequence()) + "\n"); + return true; + } + + class JPredThread + extends Thread + { + String OutputHeader; + ext.vamsas.JpredResult result; + ext.vamsas.Sequence sequence; + ext.vamsas.Msfalignment msa; + String jobId; + boolean jobComplete = false; + int allowedServerExceptions = 3; // thread dies if too many exceptions. + + JPredThread(SequenceI seq) + { + OutputHeader = wsInfo.getProgressText(); + this.sequence = new ext.vamsas.Sequence(); + this.sequence.setId(seq.getName()); + this.sequence.setSeq(AlignSeq.extractGaps("-. ", seq.getSequence())); + } - SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq); + JPredThread(SequenceI[] msf) + { + OutputHeader = wsInfo.getProgressText(); + this.sequence = new ext.vamsas.Sequence(); + this.sequence.setId(msf[0].getName()); + this.sequence.setSeq(AlignSeq.extractGaps("-. ", + msf[0].getSequence())); + + jalview.io.PileUpfile mwrite = new jalview.io.PileUpfile(); + this.msa = new ext.vamsas.Msfalignment(); + msa.setMsf(mwrite.print(msf)); + } - if (!locateWebService()) { - return; + public void run() + { + StartJob(); + + while (!jobComplete && (allowedServerExceptions > 0)) + { + try + { + if ( (result = server.getresult(jobId)) == null) + { + throw (new Exception( + "Timed out when communicating with server\nTry again later.\n")); + } + + if (result.isRunning()) + { + wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); + } + else if (result.isQueued()) + { + wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); + } + + if (result.isFinished()) + { + parseResult(); + jobComplete = true; + jobsRunning--; + } + else + { + wsInfo.setProgressText(OutputHeader + "\n" + + result.getStatus()); + + if (! (result.isJobFailed() || result.isServerError())) + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException ex1) + { + } + + // System.out.println("I'm alive "+seqid+" "+jobid); + } + else + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); + } + } } - - JPredThread jthread = new JPredThread(msf); - jthread.start(); + catch (Exception ex) + { + allowedServerExceptions--; + wsInfo.appendProgressText("\nJPredWS Server exception!\n" + + ex.getMessage()); + + try + { + if (allowedServerExceptions > 0) + { + Thread.sleep(5000); + } + } + catch (InterruptedException ex1) + { + } + } + } + + if (! (result.isJobFailed() || result.isServerError())) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); + } + else + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); + } } - public JPredClient(String title, SequenceI seq) { - wsInfo = setWebService(); - wsInfo.setProgressText("Job details for prediction on sequence :\n>" + - seq.getName() + "\n" + - AlignSeq.extractGaps("-. ", seq.getSequence()) + "\n"); - altitle = "JNet prediction for sequence " + seq.getName() + " from " + - title; - - SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq); - - if (!locateWebService()) { - return; + void StartJob() + { + try + { + if (msa != null) + { + jobId = server.predictOnMsa(msa); + } + else + { + jobId = server.predict(sequence); } - JPredThread jthread = new JPredThread(seq); - jthread.start(); + if (jobId != null) + { + if (jobId.startsWith("Broken")) + { + throw new Exception("Submission " + jobId); + } + else + { + System.out.println(WsURL + " Job Id '" + jobId + "'"); + } + } + else + { + throw new Exception("Server timed out - try again later\n"); + } + } + catch (Exception e) + { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); + allowedServerExceptions = 0; + jobComplete = false; + + wsInfo.appendProgressText("Failed to submit the prediction.\n" + + + "It is most likely that there is a problem with the server.\n" + + "Just close the window\n"); + System.err.println( + "JPredWS Client: Failed to submit the prediction (Probably a server error - see below)\n" + + e.toString() + "\n"); + + // e.printStackTrace(); TODO: JBPNote DEBUG + } } - private WebserviceInfo setWebService() { - WebServiceName = "JNetWS"; - WebServiceJobTitle = "JNet secondary structure prediction"; - WebServiceReference = "\"Cuff J. A and Barton G.J (1999) Application of enhanced " + - "multiple sequence alignment profiles to improve protein secondary structure prediction, " + - "Proteins 40:502-511\"."; - WsURL = "http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred"; - - WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, - WebServiceReference); - - return wsInfo; + private void addFloatAnnotations(Alignment al, int[] gapmap, + Vector values, String Symname, + String Visname, float min, + float max, int winLength) + { + Annotation[] annotations = new Annotation[al.getWidth()]; + + for (int j = 0; j < values.size(); j++) + { + float value = Float.parseFloat(values.get(j).toString()); + annotations[gapmap[j]] = new Annotation("", value + "", ' ', + value); + } + + al.addAnnotation(new AlignmentAnnotation(Symname, Visname, + annotations, min, max, winLength)); } - private boolean locateWebService() { - JPredWSServiceLocator loc = new JPredWSServiceLocator(); // Default - - try { - this.server = loc.getjpred(new java.net.URL(WsURL)); // JBPNote will be set from properties - ((JpredSoapBindingStub) this.server).setTimeout(60000); // one minute stub - } catch (Exception ex) { - JOptionPane.showMessageDialog(Desktop.desktop, - "The Secondary Structure Prediction Service named " + - WebServiceName + " at " + WsURL + " couldn't be located.", - "Internal Jalview Error", JOptionPane.WARNING_MESSAGE); - wsInfo.setProgressText("Serious! " + WebServiceName + - " Service location failed\nfor URL :" + WsURL + "\n" + - ex.getMessage()); - wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); - - return false; + void parseResult() + { + // OutputHeader = output.getText(); + if (result.isFailed()) + { + OutputHeader += "Job failed.\n"; + } + + if (result.getStatus() != null) + { + OutputHeader += ("\n" + result.getStatus()); + } + + if (result.getPredfile() != null) + { + OutputHeader += ("\n" + result.getPredfile()); + + // JBPNote The returned files from a webservice could be hidden behind icons in the monitor window that, when clicked, pop up their corresponding data + } + + if (result.getAligfile() != null) + { + OutputHeader += ("\n" + result.getAligfile()); + } + + wsInfo.setProgressText(OutputHeader); + + try + { + // JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File"); + jalview.io.JPredFile prediction = new jalview.io.JPredFile(result. + getPredfile(), + "Paste"); + SequenceI[] preds = prediction.getSeqsAsArray(); + Alignment al; + int FirstSeq; // the position of the query sequence in Alignment al + boolean noMsa = true; // set if no MSA has been returned by JPred + + if ( (this.msa != null) && (result.getAligfile() != null)) + { + // we ignore the returned alignment if we only predicted on a single sequence + String format = jalview.io.IdentifyFile.Identify(result.getAligfile(), + "Paste"); + + if (jalview.io.FormatAdapter.formats.contains(format)) + { + al = new Alignment(jalview.io.FormatAdapter.readFile( + result.getAligfile(), "Paste", format)); + noMsa = false; + FirstSeq = 0; + } + else + { + throw (new Exception( + "Unknown format 'format' for file : \n" + + result.getAligfile())); + } } - - return true; - } - - class JPredThread extends Thread { - String OutputHeader; - ext.vamsas.JpredResult result; - ext.vamsas.Sequence sequence; - ext.vamsas.Msfalignment msa; - String jobId; - boolean jobComplete = false; - int allowedServerExceptions = 3; // thread dies if too many exceptions. - - JPredThread(SequenceI seq) { - OutputHeader = wsInfo.getProgressText(); - this.sequence = new ext.vamsas.Sequence(); - this.sequence.setId(seq.getName()); - this.sequence.setSeq(AlignSeq.extractGaps("-. ", seq.getSequence())); + else + { + al = new Alignment(preds); + FirstSeq = prediction.getQuerySeqPosition(); } - JPredThread(SequenceI[] msf) { - OutputHeader = wsInfo.getProgressText(); - this.sequence = new ext.vamsas.Sequence(); - this.sequence.setId(msf[0].getName()); - this.sequence.setSeq(AlignSeq.extractGaps("-. ", - msf[0].getSequence())); + if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash( + al.getSequenceAt(FirstSeq), SequenceInfo)) + { + throw (new Exception( + "Couldn't recover sequence properties for JNet Query sequence!")); + } - jalview.io.PileUpfile mwrite = new jalview.io.PileUpfile(); - this.msa = new ext.vamsas.Msfalignment(); - msa.setMsf(mwrite.print(msf)); + AlignmentAnnotation annot; + Annotation[] annotations = null; + int i = 0; + int width = preds[0].getSequence().length(); + + int[] gapmap = al.getSequenceAt(FirstSeq).gapMap(); + + if (gapmap.length != width) + { + throw (new Exception( + "Jnet Client Error\nNumber of residues in supposed query sequence :\n" + + al.getSequenceAt(FirstSeq).getName() + "\n" + + al.getSequenceAt(FirstSeq).getSequence() + + "\nDiffer from number of prediction sites in \n" + + result.getPredfile() + "\n")); } - public void run() { - StartJob(); - - while (!jobComplete && (allowedServerExceptions > 0)) { - try { - if ((result = server.getresult(jobId)) == null) { - throw (new Exception( - "Timed out when communicating with server\nTry again later.\n")); - } - - if (result.isRunning()) { - wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); - } else if (result.isQueued()) { - wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); - } - - if (result.isFinished()) { - parseResult(); - jobComplete = true; - jobsRunning--; - } else { - wsInfo.setProgressText(OutputHeader + "\n" + - result.getStatus()); - - if (!(result.isJobFailed() || result.isServerError())) { - try { - Thread.sleep(5000); - } catch (InterruptedException ex1) { - } - - // System.out.println("I'm alive "+seqid+" "+jobid); - } else { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); - } - } - } catch (Exception ex) { - allowedServerExceptions--; - wsInfo.appendProgressText("\nJPredWS Server exception!\n" + - ex.getMessage()); - - try { - if (allowedServerExceptions > 0) { - Thread.sleep(5000); - } - } catch (InterruptedException ex1) { - } - } + // JBPNote Should also rename the query sequence sometime... + i = 0; + + while (i < preds.length) + { + String id = preds[i].getName().toUpperCase(); + + if (id.startsWith("LUPAS") || id.startsWith("JNET") || + id.startsWith("JPRED")) + { + annotations = new Annotation[al.getWidth()]; + + if (id.equals("JNETPRED") || id.equals("JNETPSSM") || + id.equals("JNETFREQ") || id.equals("JNETHMM") || + id.equals("JNETALIGN") || id.equals("JPRED")) + { + for (int j = 0; j < width; j++) + { + annotations[gapmap[j]] = new Annotation("", "", + preds[i].getCharAt(j), 0); + } } - - if (!(result.isJobFailed() || result.isServerError())) { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); - } else { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); + else if (id.equals("JNETCONF")) + { + for (int j = 0; j < width; j++) + { + float value = Float.parseFloat(preds[i].getCharAt( + j) + ""); + annotations[gapmap[j]] = new Annotation(preds[i].getCharAt( + j) + "", "", preds[i].getCharAt(j), + value); + } + } + else + { + for (int j = 0; j < width; j++) + { + annotations[gapmap[j]] = new Annotation(preds[i].getCharAt( + j) + "", "", ' ', 0); + } } - } - void StartJob() { - try { - if (msa != null) { - jobId = server.predictOnMsa(msa); - } else { - jobId = server.predict(sequence); - } - - if (jobId != null) { - if (jobId.startsWith("Broken")) { - throw new Exception("Submission " + jobId); - } else { - System.out.println(WsURL + " Job Id '" + jobId + "'"); - } - } else { - throw new Exception("Server timed out - try again later\n"); - } - } catch (Exception e) { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); - allowedServerExceptions = 0; - jobComplete = false; - - wsInfo.appendProgressText("Failed to submit the prediction.\n" - +"It is most likely that there is a problem with the server.\n" - +"Just close the window\n"); - System.err.println( - "JPredWS Client: Failed to submit the prediction (Probably a server error - see below)\n" + - e.toString() + "\n"); - - // e.printStackTrace(); TODO: JBPNote DEBUG + if (id.equals("JNETCONF")) + { + annot = new AlignmentAnnotation(preds[i].getName(), + "JNet Output", annotations, 0f, + 10f, 1); + } + else + { + annot = new AlignmentAnnotation(preds[i].getName(), + "JNet Output", annotations); } - } - private void addFloatAnnotations(Alignment al, int[] gapmap, - Vector values, String Symname, String Visname, float min, - float max, int winLength) { - Annotation[] annotations = new Annotation[al.getWidth()]; + al.addAnnotation(annot); - for (int j = 0; j < values.size(); j++) { - float value = Float.parseFloat(values.get(j).toString()); - annotations[gapmap[j]] = new Annotation("", value + "", ' ', - value); + if (noMsa) + { + al.deleteSequence(preds[i]); } + } - al.addAnnotation(new AlignmentAnnotation(Symname, Visname, - annotations, min, max, winLength)); + i++; } - void parseResult() { - // OutputHeader = output.getText(); - if (result.isFailed()) { - OutputHeader += "Job failed.\n"; - } - - if (result.getStatus() != null) { - OutputHeader += ("\n" + result.getStatus()); - } + Hashtable scores = prediction.getScores(); - if (result.getPredfile() != null) { - OutputHeader += ("\n" + result.getPredfile()); + /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"), + "JnetpropH", "Jnet Helix Propensity", 0f,1f,1); - // JBPNote The returned files from a webservice could be hidden behind icons in the monitor window that, when clicked, pop up their corresponding data - } + addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"), + "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1); - if (result.getAligfile() != null) { - OutputHeader += ("\n" + result.getAligfile()); - } + addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"), + "JnetpropC", "Jnet Coil Propensity", 0f,1f,1); + */ + AlignFrame af = new AlignFrame(al); - wsInfo.setProgressText(OutputHeader); - - try { - // JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt", "File"); - jalview.io.JPredFile prediction = new jalview.io.JPredFile(result.getPredfile(), - "Paste"); - SequenceI[] preds = prediction.getSeqsAsArray(); - Alignment al; - int FirstSeq; // the position of the query sequence in Alignment al - boolean noMsa = true; // set if no MSA has been returned by JPred - - if ((this.msa != null) && (result.getAligfile() != null)) { - // we ignore the returned alignment if we only predicted on a single sequence - String format = jalview.io.IdentifyFile.Identify(result.getAligfile(), - "Paste"); - - if (jalview.io.FormatAdapter.formats.contains(format)) { - al = new Alignment(jalview.io.FormatAdapter.readFile( - result.getAligfile(), "Paste", format)); - noMsa = false; - FirstSeq = 0; - } else { - throw (new Exception( - "Unknown format 'format' for file : \n" + - result.getAligfile())); - } - } else { - al = new Alignment(preds); - FirstSeq = prediction.getQuerySeqPosition(); - } - - if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash( - al.getSequenceAt(FirstSeq), SequenceInfo)) { - throw (new Exception( - "Couldn't recover sequence properties for JNet Query sequence!")); - } - - AlignmentAnnotation annot; - Annotation[] annotations = null; - int i = 0; - int width = preds[0].getSequence().length(); - - int[] gapmap = al.getSequenceAt(FirstSeq).gapMap(); - - if (gapmap.length != width) { - throw (new Exception( - "Jnet Client Error\nNumber of residues in supposed query sequence :\n" + - al.getSequenceAt(FirstSeq).getName() + "\n" + - al.getSequenceAt(FirstSeq).getSequence() + - "\nDiffer from number of prediction sites in \n" + - result.getPredfile() + "\n")); - } - - // JBPNote Should also rename the query sequence sometime... - i = 0; - - while (i < preds.length) { - String id = preds[i].getName().toUpperCase(); - - if (id.startsWith("LUPAS") || id.startsWith("JNET") || - id.startsWith("JPRED")) { - annotations = new Annotation[al.getWidth()]; - - if (id.equals("JNETPRED") || id.equals("JNETPSSM") || - id.equals("JNETFREQ") || id.equals("JNETHMM") || - id.equals("JNETALIGN") || id.equals("JPRED")) { - for (int j = 0; j < width; j++) { - annotations[gapmap[j]] = new Annotation("", "", - preds[i].getCharAt(j), 0); - } - } else if (id.equals("JNETCONF")) { - for (int j = 0; j < width; j++) { - float value = Float.parseFloat(preds[i].getCharAt( - j) + ""); - annotations[gapmap[j]] = new Annotation(preds[i].getCharAt( - j) + "", "", preds[i].getCharAt(j), - value); - } - } else { - for (int j = 0; j < width; j++) { - annotations[gapmap[j]] = new Annotation(preds[i].getCharAt( - j) + "", "", ' ', 0); - } - } - - if (id.equals("JNETCONF")) { - annot = new AlignmentAnnotation(preds[i].getName(), - "JNet Output", annotations, 0f, 10f, 1); - } - else { - annot = new AlignmentAnnotation(preds[i].getName(), - "JNet Output", annotations); - } - - al.addAnnotation(annot); - - if (noMsa) { - al.deleteSequence(preds[i]); - } - } - - i++; - } - - Hashtable scores = prediction.getScores(); - - /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"), - "JnetpropH", "Jnet Helix Propensity", 0f,1f,1); - - addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"), - "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1); - - addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"), - "JnetpropC", "Jnet Coil Propensity", 0f,1f,1); - */ - AlignFrame af = new AlignFrame(al); - - Desktop.addInternalFrame(af, altitle, - AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); - } catch (Exception ex) { - ex.printStackTrace(); - } - } + Desktop.addInternalFrame(af, altitle, + AlignFrame.NEW_WINDOW_WIDTH, + AlignFrame.NEW_WINDOW_HEIGHT); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } + } } diff --git a/src/jalview/ws/MsaWSClient.java b/src/jalview/ws/MsaWSClient.java index 94e19e7..0d5c22e 100755 --- a/src/jalview/ws/MsaWSClient.java +++ b/src/jalview/ws/MsaWSClient.java @@ -26,28 +26,38 @@ import jalview.datamodel.*; import jalview.gui.*; -import org.apache.axis.client.*; - -import vamsas.objects.*; - -import java.awt.*; - import java.util.*; import javax.swing.*; -import javax.xml.namespace.QName; - -public class MsaWSClient extends WSClient { - /** - * server is a WSDL2Java generated stub for an archetypal MsaWSI service. +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ */ +public class MsaWSClient extends WSClient +{ + /** + * server is a WSDL2Java generated stub for an archetypal MsaWSI service. + */ ext.vamsas.MuscleWS server; + /** + * Creates a new MsaWSClient object. + * + * @param MsaWSName DOCUMENT ME! + * @param altitle DOCUMENT ME! + * @param msa DOCUMENT ME! + * @param submitGaps DOCUMENT ME! + * @param preserveOrder DOCUMENT ME! + */ public MsaWSClient(String MsaWSName, String altitle, SequenceI[] msa, - boolean submitGaps, boolean preserveOrder) { - if (setWebService(MsaWSName) == false) { + boolean submitGaps, boolean preserveOrder) + { + if (setWebService(MsaWSName) == false) + { JOptionPane.showMessageDialog(Desktop.desktop, "The Multiple Sequence Alignment Service named " + MsaWSName + " is unknown", "Internal Jalview Error", @@ -59,7 +69,8 @@ public class MsaWSClient extends WSClient { wsInfo = new jalview.gui.WebserviceInfo(WebServiceJobTitle, WebServiceReference); - if (!locateWebService()) { + if (!locateWebService()) + { return; } @@ -73,8 +84,10 @@ public class MsaWSClient extends WSClient { } // JBPNote Nasty object-global state setting methods shouldn't be allowed - private boolean setWebService(String MsaWSName) { - if (MsaWServices.info.containsKey(MsaWSName)) { + private boolean setWebService(String MsaWSName) + { + if (MsaWServices.info.containsKey(MsaWSName)) + { WebServiceName = MsaWSName; String[] wsinfo = (String[]) MsaWServices.info.get(MsaWSName); @@ -83,19 +96,30 @@ public class MsaWSClient extends WSClient { WebServiceReference = wsinfo[2]; return true; - } else { + } + else + { return false; } } - private boolean locateWebService() { + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + private boolean locateWebService() + { // TODO: MuscleWS transmuted to generic MsaWS client MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default - try { + try + { this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL)); ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute timeout - } catch (Exception ex) { + } + catch (Exception ex) + { wsInfo.setProgressText("Serious! " + WebServiceName + " Service location failed\nfor URL :" + WsURL + "\n" + ex.getMessage()); @@ -110,7 +134,8 @@ public class MsaWSClient extends WSClient { return true; } - protected class MsaWSThread extends Thread implements WSClientI { + protected class MsaWSThread extends Thread implements WSClientI + { String ServiceName = WebServiceName; String OutputHeader; vamsas.objects.simple.MsaResult result = null; @@ -124,7 +149,8 @@ public class MsaWSClient extends WSClient { boolean jobComplete = false; MsaWSThread(String title, SequenceI[] msa, boolean subgaps, - boolean presorder) { + boolean presorder) + { alTitle = title; submitGaps = subgaps; preserveOrder = presorder; @@ -134,7 +160,8 @@ public class MsaWSClient extends WSClient { vamsas.objects.simple.Sequence[] seqarray = new vamsas.objects.simple.Sequence[msa.length]; - for (int i = 0; i < msa.length; i++) { + for (int i = 0; i < msa.length; i++) + { String newname = jalview.analysis.SeqsetUtils.unique_name(i); // uniquify as we go @@ -152,85 +179,114 @@ public class MsaWSClient extends WSClient { this.seqs.setSeqs(seqarray); } - public boolean isCancellable() { + public boolean isCancellable() + { return true; } - public void cancelJob() { - if ((jobId != null) && !jobId.equals("") && !jobComplete) { + public void cancelJob() + { + if ((jobId != null) && !jobId.equals("") && !jobComplete) + { String cancelledMessage = ""; - try { + try + { vamsas.objects.simple.WsJobId cancelledJob = server.cancel(jobId); - if (cancelledJob.getStatus() == 2) { + if (cancelledJob.getStatus() == 2) + { // CANCELLED_JOB cancelledMessage = "Job cancelled."; wsInfo.setStatus(WebserviceInfo.STATE_CANCELLED_OK); jobComplete = true; jobsRunning--; result = null; - } else if (cancelledJob.getStatus() == 3) { + } + else if (cancelledJob.getStatus() == 3) + { // VALID UNSTOPPABLE JOB cancelledMessage += "Server cannot cancel this job. just close the window.\n"; } - if (cancelledJob.getJobId() != null) { + if (cancelledJob.getJobId() != null) + { cancelledMessage += ("[" + cancelledJob.getJobId() + "]"); } cancelledMessage += "\n"; - } catch (Exception exc) { + } + catch (Exception exc) + { cancelledMessage += ("\nProblems cancelling the job : Exception received...\n" + exc + "\n"); exc.printStackTrace(); } wsInfo.setProgressText(OutputHeader + cancelledMessage + "\n"); - } else { - if (!jobComplete) { + } + else + { + if (!jobComplete) + { wsInfo.setProgressText(OutputHeader + "Server cannot cancel this job because it has not been submitted properly. just close the window.\n"); } } } - public void run() { + public void run() + { StartJob(); - while (!jobComplete && (allowedServerExceptions > 0)) { - try { - if ((result = server.getResult(jobId)) == null) { + while (!jobComplete && (allowedServerExceptions > 0)) + { + try + { + if ((result = server.getResult(jobId)) == null) + { throw (new Exception( "Timed out when communicating with server\nTry again later.\n")); } - if (result.isRunning()) { + if (result.isRunning()) + { wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); - } else if (result.isQueued()) { + } + else if (result.isQueued()) + { wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); } - if (result.isFinished()) { + if (result.isFinished()) + { parseResult(); jobComplete = true; jobsRunning--; - } else { - if (result.getStatus() != null) { + } + else + { + if (result.getStatus() != null) + { wsInfo.setProgressText(OutputHeader + "\n" + result.getStatus()); } - if (!(result.isJobFailed() || result.isServerError())) { + if (!(result.isJobFailed() || result.isServerError())) + { Thread.sleep(5000); // System.out.println("I'm alive "+seqid+" "+jobid); - } else { + } + else + { break; } } - } catch (Exception ex) { + } + catch (Exception ex) + { allowedServerExceptions--; wsInfo.appendProgressText("\n" + ServiceName + " Server exception!\n" + ex.getMessage()); @@ -238,59 +294,81 @@ public class MsaWSClient extends WSClient { ex.getMessage()); // ex.printStackTrace(); JBPNote Debug - try { - if (allowedServerExceptions > 0) { + try + { + if (allowedServerExceptions > 0) + { Thread.sleep(5000); } - } catch (InterruptedException ex1) { + } + catch (InterruptedException ex1) + { } } } - if (allowedServerExceptions == 0) { + if (allowedServerExceptions == 0) + { wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); - } else { + } + else + { if (!((result != null) && - (result.isJobFailed() || result.isServerError()))) { + (result.isJobFailed() || result.isServerError()))) + { wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); - } else { - if (result.isFailed()) { + } + else + { + if (result.isFailed()) + { wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); } - if (result.isServerError()) { + if (result.isServerError()) + { wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); } } } } - void StartJob() { - try { + void StartJob() + { + try + { vamsas.objects.simple.WsJobId jobsubmit = server.align(seqs); - if ((jobsubmit != null) && (jobsubmit.getStatus() == 1)) { + if ((jobsubmit != null) && (jobsubmit.getStatus() == 1)) + { jobId = jobsubmit.getJobId(); System.out.println(WsURL + " Job Id '" + jobId + "'"); - } else { - if (jobsubmit == null) { + } + else + { + if (jobsubmit == null) + { throw new Exception("Server at " + WsURL + " returned null object, it probably cannot be contacted. Try again later ?"); } throw new Exception(jobsubmit.getJobId()); } - } catch (Exception e) { + } + catch (Exception e) + { // TODO: JBPNote catch timeout or other fault types explicitly // For unexpected errors System.err.println(WebServiceName + - "Client: Failed to submit the sequences for alignment (probably a server side problem)\n" - + "When contacting Server:"+WsURL + "\n" + e.toString() + "\n"); + "Client: Failed to submit the sequences for alignment (probably a server side problem)\n" + + "When contacting Server:" + WsURL + "\n" + e.toString() + + "\n"); this.allowedServerExceptions = 0; wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); - wsInfo.appendProgressText("Failed to submit sequences for alignment.\n" - + "It is most likely that there is a problem with the server.\n" - + "Just close the window\n"); + wsInfo.appendProgressText( + "Failed to submit sequences for alignment.\n" + + "It is most likely that there is a problem with the server.\n" + + "Just close the window\n"); // e.printStackTrace(); // TODO: JBPNote DEBUG } @@ -298,10 +376,12 @@ public class MsaWSClient extends WSClient { private void addFloatAnnotations(Alignment al, int[] gapmap, Vector values, String Symname, String Visname, float min, - float max, int winLength) { + float max, int winLength) + { Annotation[] annotations = new Annotation[al.getWidth()]; - for (int j = 0; j < values.size(); j++) { + for (int j = 0; j < values.size(); j++) + { float value = Float.parseFloat(values.get(j).toString()); annotations[gapmap[j]] = new Annotation("", value + "", ' ', value); @@ -312,7 +392,8 @@ public class MsaWSClient extends WSClient { } private jalview.datamodel.Sequence[] getVamsasAlignment( - vamsas.objects.simple.Alignment valign) { + vamsas.objects.simple.Alignment valign) + { vamsas.objects.simple.Sequence[] seqs = valign.getSeqs().getSeqs(); jalview.datamodel.Sequence[] msa = new jalview.datamodel.Sequence[seqs.length]; @@ -323,20 +404,25 @@ public class MsaWSClient extends WSClient { return msa; } - void parseResult() { + void parseResult() + { SequenceI[] seqs = null; - try { + try + { // OutputHeader = output.getText(); - if (result.isFailed()) { + if (result.isFailed()) + { OutputHeader += "Job failed.\n"; } - if (result.getStatus() != null) { + if (result.getStatus() != null) + { OutputHeader += ("\n" + result.getStatus()); } - if (result.getMsa() != null) { + if (result.getMsa() != null) + { OutputHeader += "\nAlignment Object Method Notes\n"; String[] lines = result.getMsa().getMethod(); @@ -350,10 +436,12 @@ public class MsaWSClient extends WSClient { wsInfo.setProgressText(OutputHeader); - if (seqs != null) { + if (seqs != null) + { AlignmentOrder msaorder = new AlignmentOrder(seqs); - if (preserveOrder) { + if (preserveOrder) + { jalview.analysis.AlignmentSorter.recoverOrder(seqs); } @@ -370,7 +458,9 @@ public class MsaWSClient extends WSClient { AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); } - } catch (Exception ex) { + } + catch (Exception ex) + { ex.printStackTrace(); } } diff --git a/src/jalview/ws/MsaWServices.java b/src/jalview/ws/MsaWServices.java index 84c07a2..75ddf16 100755 --- a/src/jalview/ws/MsaWServices.java +++ b/src/jalview/ws/MsaWServices.java @@ -36,25 +36,30 @@ import java.util.Hashtable; /** * TODO: MsaWServices will be set from properties and be dynamically discovered. */ -public class MsaWServices { +public class MsaWServices +{ + /** DOCUMENT ME!! */ public static Hashtable info; - static { + static + { info = new Hashtable(); info.put("ClustalWS", - new String[] { + new String[] + { "http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS", "ClustalW Alignment job", - + "\"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple" + " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice." + " Nucleic Acids Research, 22 4673-4680" }); info.put("MuscleWS", - new String[] { + new String[] + { "http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS", "Muscle Alignment job", - + "Edgar, Robert C. (2004), MUSCLE: multiple sequence alignment " + "with high accuracy and high throughput, Nucleic Acids Research 32(5), 1792-97." }); diff --git a/src/jalview/ws/WSClient.java b/src/jalview/ws/WSClient.java index 506bd9b..0ffb060 100755 --- a/src/jalview/ws/WSClient.java +++ b/src/jalview/ws/WSClient.java @@ -1,40 +1,40 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* 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.ws; - -import jalview.gui.WebserviceInfo; - - -public class WSClient { - /** + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.ws; -* MsaWSClient -* -* @param msa SequenceI[] -*/ - protected String WebServiceName; - protected String WebServiceJobTitle; - protected String WebServiceReference; - protected String WsURL; - protected WebserviceInfo wsInfo; - int jobsRunning = 0; - - public WSClient() { - } -} +import jalview.gui.*; + +public class WSClient +{ + /** + * MsaWSClient + * + * @param msa SequenceI[] + */ + protected String WebServiceName; + protected String WebServiceJobTitle; + protected String WebServiceReference; + protected String WsURL; + protected WebserviceInfo wsInfo; + int jobsRunning = 0; + + public WSClient() + { + } +} diff --git a/src/jalview/ws/WSClientI.java b/src/jalview/ws/WSClientI.java index c2db8c1..97eaa7f 100755 --- a/src/jalview/ws/WSClientI.java +++ b/src/jalview/ws/WSClientI.java @@ -1,25 +1,26 @@ /* -* Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 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 -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* 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.ws; - -public interface WSClientI { - boolean isCancellable(); - - void cancelJob(); -} + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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.ws; + +public interface WSClientI +{ + boolean isCancellable(); + + void cancelJob(); +} -- 1.7.10.2