From: amwaterhouse Date: Wed, 8 Jun 2005 13:41:35 +0000 (+0000) Subject: Formatted source X-Git-Tag: Release_2_0~98 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=588042b69abf8e60bcc950b24c283933c7dd422f;p=jalview.git Formatted source --- diff --git a/src/MCview/Atom.java b/src/MCview/Atom.java index b3a8fdb..0aaf040 100755 --- a/src/MCview/Atom.java +++ b/src/MCview/Atom.java @@ -16,56 +16,57 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; -import java.util.*; + import java.awt.*; -public class Atom { - double x; - double y; - double z; - int number; - String name; - String resName; - int resNumber; - int type; - Color color; - String chain; +import java.util.*; - public Atom(StringTokenizer str) { - this.number = (new Integer(str.nextToken())).intValue(); - this.name = str.nextToken(); - this.resName = str.nextToken(); - String tmpstr = new String(); +public class Atom { + double x; + double y; + double z; + int number; + String name; + String resName; + int resNumber; + int type; + Color color; + String chain; - try { - tmpstr = str.nextToken(); + public Atom(StringTokenizer str) { + this.number = (new Integer(str.nextToken())).intValue(); + this.name = str.nextToken(); + this.resName = str.nextToken(); - this.resNumber = (new Integer(tmpstr).intValue()); - this.chain = "A"; - this.color = Color.green; + String tmpstr = new String(); - } catch(NumberFormatException e) { - this.chain = tmpstr; + try { + tmpstr = str.nextToken(); - if (tmpstr.equals("A")) { - this.color = new Color((float)Math.random(),(float)Math.random(),(float)Math.random()); - } else { - this.color = Color.red; - } - this.resNumber = (new Integer(str.nextToken()).intValue()); - } + this.resNumber = (new Integer(tmpstr).intValue()); + this.chain = "A"; + this.color = Color.green; + } catch (NumberFormatException e) { + this.chain = tmpstr; - this.x = (double)(new Double(str.nextToken()).floatValue()); - this.y = (double)(new Double(str.nextToken()).floatValue()); - this.z = (double)(new Double(str.nextToken()).floatValue()); + if (tmpstr.equals("A")) { + this.color = new Color((float) Math.random(), + (float) Math.random(), (float) Math.random()); + } else { + this.color = Color.red; + } - } + this.resNumber = (new Integer(str.nextToken()).intValue()); + } - public void setColor(Color col) { - this.color = col; - } + this.x = (double) (new Double(str.nextToken()).floatValue()); + this.y = (double) (new Double(str.nextToken()).floatValue()); + this.z = (double) (new Double(str.nextToken()).floatValue()); + } + public void setColor(Color col) { + this.color = col; + } } diff --git a/src/MCview/Bond.java b/src/MCview/Bond.java index c84152a..17f66bb 100755 --- a/src/MCview/Bond.java +++ b/src/MCview/Bond.java @@ -16,69 +16,69 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; import java.awt.*; -public class Bond { - - float start[]; - float end[]; - - Color startCol; - Color endCol; - - public myAtom at1; - public myAtom at2; - - public Bond(float[] start, float[] end, myAtom at1, myAtom at2) { - this.start = start; - this.end = end; - this.startCol = at1.color; - this.endCol = at2.color; - this.at1 = at1; - this.at2 = at2; - } - public Bond(Bond bond) { - this.start = new float[3]; - - this.start[0] = bond.start[0]; - this.start[1] = bond.start[1]; - this.start[2] = bond.start[2]; - - this.end = new float[3]; - this.end[0] = bond.end[0]; - this.end[1] = bond.end[1]; - this.end[2] = bond.end[2]; - - this.startCol = bond.startCol; - this.endCol = bond.endCol; - } - - public void print() { - System.out.println("Start " + start[0] + " "+ start[1] + " " + start[2]); - System.out.println("End " + end[0] + " "+ end[1] + " " + end[2]); - } - - public float length() { - float len = (end[0] - start[0])*(end[0] - start[0]) + - (end[1] - start[1])*(end[1] - start[1]) + - (end[2] - start[2])*(end[2] - start[2]); - - len = (float)(Math.sqrt(len)); - - return len; - } - public void translate(float x, float y, float z) { - start[0] = (start[0] + x); - end[0] = (end[0] + x); - - start[1] = (start[1] + y); - end[1] = (end[1] + y); - - start[2] = (start[2] + z); - end[2] = (end[2] + z); - } +public class Bond { + float[] start; + float[] end; + Color startCol; + Color endCol; + public myAtom at1; + public myAtom at2; + + public Bond(float[] start, float[] end, myAtom at1, myAtom at2) { + this.start = start; + this.end = end; + this.startCol = at1.color; + this.endCol = at2.color; + this.at1 = at1; + this.at2 = at2; + } + + public Bond(Bond bond) { + this.start = new float[3]; + + this.start[0] = bond.start[0]; + this.start[1] = bond.start[1]; + this.start[2] = bond.start[2]; + + this.end = new float[3]; + + this.end[0] = bond.end[0]; + this.end[1] = bond.end[1]; + this.end[2] = bond.end[2]; + + this.startCol = bond.startCol; + this.endCol = bond.endCol; + } + + public void print() { + System.out.println("Start " + start[0] + " " + start[1] + " " + + start[2]); + System.out.println("End " + end[0] + " " + end[1] + " " + end[2]); + } + + public float length() { + float len = ((end[0] - start[0]) * (end[0] - start[0])) + + ((end[1] - start[1]) * (end[1] - start[1])) + + ((end[2] - start[2]) * (end[2] - start[2])); + + len = (float) (Math.sqrt(len)); + + return len; + } + + public void translate(float x, float y, float z) { + start[0] = (start[0] + x); + end[0] = (end[0] + x); + + start[1] = (start[1] + y); + end[1] = (end[1] + y); + + start[2] = (start[2] + z); + end[2] = (end[2] + z); + } } diff --git a/src/MCview/MCMatrix.java b/src/MCview/MCMatrix.java index 31af9d4..2effba6 100755 --- a/src/MCview/MCMatrix.java +++ b/src/MCview/MCMatrix.java @@ -16,147 +16,146 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; public class MCMatrix { - float matrix[][]; - float tmp[][]; - - float mycos; - float mysin; - float myconst = (float)(Math.PI/180); - - public MCMatrix(int rows, int cols) { - matrix = new float[rows][cols]; - tmp = new float[rows][cols]; - } - - public void addElement(int i, int j, float value) { - matrix[i][j] = value; - } - - public void print() { - System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + matrix[0][2]); - System.out.println(matrix[1][0] + " " + matrix[1][1] + " " + matrix[1][2]); - System.out.println(matrix[2][0] + " " + matrix[2][1] + " " + matrix[2][2]); - } - - public void rotatex(float degrees) { - mycos = (float)(Math.cos(degrees*myconst)); - mysin = (float)(Math.sin(degrees*myconst)); - - tmp[0][0] = 1; - tmp[0][1] = 0; - tmp[0][2] = 0; - tmp[1][0] = 0; - tmp[1][1] = mycos; - tmp[1][2] = mysin; - tmp[2][0] = 0; - tmp[2][1] = -mysin; - tmp[2][2] = mycos; - preMultiply(tmp); - } - - public void rotatez(float degrees) { - mycos = (float)(Math.cos(degrees*myconst)); - mysin = (float)(Math.sin(degrees*myconst)); - - tmp[0][0] = mycos; - tmp[0][1] = -mysin; - tmp[0][2] = 0; - tmp[1][0] = mysin; - tmp[1][1] = mycos; - tmp[1][2] = 0; - tmp[2][0] = 0; - tmp[2][1] = 0; - tmp[2][2] = 1; - - preMultiply(tmp); - } - - public void rotatey(float degrees) { - mycos = (float)(Math.cos(degrees*myconst)); - mysin = (float)(Math.sin(degrees*myconst)); - - tmp[0][0] = mycos; - tmp[0][1] = 0; - tmp[0][2] = -mysin; - tmp[1][0] = 0; - tmp[1][1] = 1; - tmp[1][2] = 0; - tmp[2][0] = mysin; - tmp[2][1] = 0; - tmp[2][2] = mycos; - - preMultiply(tmp); - } - - public float[] vectorMultiply(float[] vect) { - float temp[] = new float[3]; - - temp[0] = vect[0]; - temp[1] = vect[1]; - temp[2] = vect[2]; - - for (int i = 0; i < 3; i++) { - temp[i] = (float)matrix[i][0]*vect[0] + (float)matrix[i][1]*vect[1] +(float)matrix[i][2]*vect[2]; + float[][] matrix; + float[][] tmp; + float mycos; + float mysin; + float myconst = (float) (Math.PI / 180); + + public MCMatrix(int rows, int cols) { + matrix = new float[rows][cols]; + tmp = new float[rows][cols]; } - vect[0] = temp[0]; - vect[1] = temp[1]; - vect[2] = temp[2]; + public void addElement(int i, int j, float value) { + matrix[i][j] = value; + } - return vect; - } + public void print() { + System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + + matrix[0][2]); + System.out.println(matrix[1][0] + " " + matrix[1][1] + " " + + matrix[1][2]); + System.out.println(matrix[2][0] + " " + matrix[2][1] + " " + + matrix[2][2]); + } - public void preMultiply(float mat[][]) { - float tmp[][] = new float[3][3]; + public void rotatex(float degrees) { + mycos = (float) (Math.cos(degrees * myconst)); + mysin = (float) (Math.sin(degrees * myconst)); + + tmp[0][0] = 1; + tmp[0][1] = 0; + tmp[0][2] = 0; + tmp[1][0] = 0; + tmp[1][1] = mycos; + tmp[1][2] = mysin; + tmp[2][0] = 0; + tmp[2][1] = -mysin; + tmp[2][2] = mycos; + preMultiply(tmp); + } - 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]; - } + public void rotatez(float degrees) { + mycos = (float) (Math.cos(degrees * myconst)); + mysin = (float) (Math.sin(degrees * myconst)); + + tmp[0][0] = mycos; + tmp[0][1] = -mysin; + tmp[0][2] = 0; + tmp[1][0] = mysin; + tmp[1][1] = mycos; + tmp[1][2] = 0; + tmp[2][0] = 0; + tmp[2][1] = 0; + tmp[2][2] = 1; + + preMultiply(tmp); } - for (int i = 0; i < 3 ; i++) { - for (int j = 0; j < 3; j++ ) { - matrix[i][j] = tmp[i][j]; - } + public void rotatey(float degrees) { + mycos = (float) (Math.cos(degrees * myconst)); + mysin = (float) (Math.sin(degrees * myconst)); + + tmp[0][0] = mycos; + tmp[0][1] = 0; + tmp[0][2] = -mysin; + tmp[1][0] = 0; + tmp[1][1] = 1; + tmp[1][2] = 0; + tmp[2][0] = mysin; + tmp[2][1] = 0; + tmp[2][2] = mycos; + + preMultiply(tmp); } - } - public void postMultiply(float mat[][]) { - float tmp[][] = new float[3][3]; + public float[] vectorMultiply(float[] vect) { + float[] temp = new float[3]; + + temp[0] = vect[0]; + temp[1] = vect[1]; + temp[2] = vect[2]; + + for (int i = 0; i < 3; i++) { + temp[i] = ((float) matrix[i][0] * vect[0]) + + ((float) matrix[i][1] * vect[1]) + + ((float) matrix[i][2] * vect[2]); + } - 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]; - } + vect[0] = temp[0]; + vect[1] = temp[1]; + vect[2] = temp[2]; + + return vect; } - for (int i = 0; i < 3 ; i++) { - for (int j = 0; j < 3; j++ ) { - matrix[i][j] = tmp[i][j]; - } + 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++) { + 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++) { + matrix[i][j] = tmp[i][j]; + } + } } - } - - public void setIdentity() { - matrix[0][0] = 1; - matrix[1][1] = 1; - matrix[2][2] = 1; - matrix[0][1] = 0; - matrix[0][2] = 0; - matrix[1][0] = 0; - matrix[1][2] = 0; - matrix[2][0] = 0; - matrix[2][1] = 0; - } -} + 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++) { + 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++) { + matrix[i][j] = tmp[i][j]; + } + } + } + public void setIdentity() { + matrix[0][0] = 1; + matrix[1][1] = 1; + matrix[2][2] = 1; + matrix[0][1] = 0; + matrix[0][2] = 0; + matrix[1][0] = 0; + matrix[1][2] = 0; + matrix[2][0] = 0; + matrix[2][1] = 0; + } +} diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index fdb74bd..4bfe255 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -16,253 +16,268 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; import jalview.datamodel.*; + import jalview.schemes.ResidueProperties; import java.awt.*; + import java.util.*; public class PDBChain { + public String id; + public Vector bonds = new Vector(); + public Vector atoms = new Vector(); + public Vector residues = new Vector(); + public int offset; + public Sequence sequence; + public boolean isVisible = false; + public int pdbstart = 0; + public int pdbend = 0; + public int seqstart = 0; + public int seqend = 0; + + //public DrawableSequence ds; + public PDBChain(String id) { + this.id = id; + } - public String id; - public Vector bonds = new Vector(); - public Vector atoms = new Vector(); - public Vector residues = new Vector(); - public int offset; - - public Sequence sequence; - public boolean isVisible = false; - - public int pdbstart=0, pdbend=0, seqstart=0, seqend=0; - - //public DrawableSequence ds; - - public PDBChain(String id) { - this.id = id; - } - + public String print() { + String tmp = ""; - public String print() { - String tmp = ""; - for (int i=0; i < bonds.size() ;i++) { - tmp = tmp + ((Bond)bonds.elementAt(i)).at1.resName + " " + ((Bond)bonds.elementAt(i)).at1.resNumber +" " + offset+ "\n"; - } - return tmp; - } - public void makeCaBondList() { - for (int i = 0; i < (residues.size() - 1) ; i++) { - Residue tmpres = (Residue)residues.elementAt(i); - Residue tmpres2 = (Residue)residues.elementAt(i+1); - myAtom at1 = tmpres.findAtom("CA"); - myAtom at2 = tmpres2.findAtom("CA"); - if ((at1 != null) && (at2 != null)) { - if (at1.chain.equals(at2.chain)) { - makeBond(at1,at2); - } - } - } - } - - public void makeBond(myAtom at1, myAtom at2) { - float[] start = new float[3]; - float[] end = new float[3]; - - start[0] = at1.x; - start[1] = at1.y; - start[2] = at1.z; - - end[0] = at2.x; - end[1] = at2.y; - end[2] = at2.z; - - bonds.addElement(new Bond(start, end, at1,at2)); - } - - public void makeResidueList() { - int count = 0; - String seq = ""; - for (int i = 0; i < atoms.size(); i++) { - - myAtom tmp = (myAtom)atoms.elementAt(i); - String resName = tmp.resName; - int resNumber = tmp.resNumber; - int res = resNumber; - - if (i ==0) { - offset = resNumber; - } - Vector resAtoms = new Vector(); - - resAtoms.addElement((myAtom)atoms.elementAt(i)); - i++; - resNumber = ((myAtom)atoms.elementAt(i)).resNumber; - - //Add atoms to a vector while the residue number - //remains the same - while ((resNumber == res) && (i < atoms.size())) { - - resAtoms.addElement((myAtom)atoms.elementAt(i)); - i++; - if (i < atoms.size()) { - resNumber = ((myAtom)atoms.elementAt(i)).resNumber; - } else { - resNumber++; + for (int i = 0; i < bonds.size(); i++) { + tmp = tmp + ((Bond) bonds.elementAt(i)).at1.resName + " " + + ((Bond) bonds.elementAt(i)).at1.resNumber + " " + offset + + "\n"; } - } - - //We need this to keep in step with the outer for i = loop - i--; - - //Make a new Residue object with the new atoms vector - residues.addElement(new Residue(resAtoms, resNumber - 1,count)); - count++; - Residue tmpres = (Residue)residues.lastElement(); - myAtom tmpat = (myAtom)tmpres.atoms.elementAt(0); - - // Keep totting up the sequence - if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null) { - System.err.println("PDBReader:Null aa3Hash for " + tmpat.resName); - } else { - String tmpres2 = - ResidueProperties.aa[((Integer)ResidueProperties.getAA3Hash().get(tmpat.resName)).intValue()]; - seq = seq + tmpres2; - } - // System.out.println(tmpat.resName + " " + tmpres2); + + return tmp; } - sequence = new Sequence("PDB_seq",seq,1,seq.length()); - System.out.println("PDB Sequence is :\nSequence = " + seq); - System.out.println("No of residues = " +residues.size()); - } - - public void setChargeColours() { - for (int i = 0; i < bonds.size(); i++) { - try { - Bond b = (Bond)bonds.elementAt(i); - - if (b.at1.resName.toUpperCase().equals("ASP") || b.at1.resName.toUpperCase().equals("GLU")) { - b.startCol = Color.red; - } else if (b.at1.resName.toUpperCase().equals("LYS") || b.at1.resName.toUpperCase().equals("ARG")) { - b.startCol = Color.blue; - } else if (b.at1.resName.toUpperCase().equals("CYS")) { - b.startCol = Color.yellow; - } else { - int atno = ((Integer)ResidueProperties.getAA3Hash().get(b.at1.resName.toUpperCase())).intValue(); - b.startCol = Color.lightGray; - } - if (b.at2.resName.toUpperCase().equals("ASP") || b.at2.resName.toUpperCase().equals("GLU")) { - b.endCol = Color.red; - } else if (b.at2.resName.toUpperCase().equals("LYS") || b.at2.resName.toUpperCase().equals("ARG")) { - b.endCol = Color.blue; - } else if (b.at2.resName.toUpperCase().equals("CYS")) { - b.endCol = Color.yellow; - } else { - int atno = ((Integer)ResidueProperties.getAA3Hash().get(b.at2.resName.toUpperCase())).intValue(); - b.endCol = Color.lightGray; + + public void makeCaBondList() { + for (int i = 0; i < (residues.size() - 1); i++) { + Residue tmpres = (Residue) residues.elementAt(i); + Residue tmpres2 = (Residue) residues.elementAt(i + 1); + myAtom at1 = tmpres.findAtom("CA"); + myAtom at2 = tmpres2.findAtom("CA"); + + if ((at1 != null) && (at2 != null)) { + if (at1.chain.equals(at2.chain)) { + makeBond(at1, at2); + } + } } - } catch (Exception e) { - Bond b = (Bond)bonds.elementAt(i); - b.startCol = Color.gray; - b.endCol = Color.gray; - } } - } - public void setHydrophobicityColours() { - float hydmin = (float)ResidueProperties.getHydmin(); - float hydmax = (float)ResidueProperties.getHydmax(); - double[] hyd = ResidueProperties.getHyd(); + public void makeBond(myAtom at1, myAtom at2) { + float[] start = new float[3]; + float[] end = new float[3]; - Hashtable AA3Hash = ResidueProperties.getAA3Hash(); + start[0] = at1.x; + start[1] = at1.y; + start[2] = at1.z; - for (int i = 0; i < bonds.size(); i++) { - try { - Bond b = (Bond)bonds.elementAt(i); + end[0] = at2.x; + end[1] = at2.y; + end[2] = at2.z; - int atno = ((Integer)AA3Hash.get(b.at1.resName.toUpperCase())).intValue(); - float red = ((float)hyd[atno] - hydmin)/(hydmax - hydmin); + bonds.addElement(new Bond(start, end, at1, at2)); + } - if (red > (float)1.0) { - red = (float)1.0; - } - if (red < (float)0.0) { - red = (float)0.0; + public void makeResidueList() { + int count = 0; + String seq = ""; + + for (int i = 0; i < atoms.size(); i++) { + myAtom tmp = (myAtom) atoms.elementAt(i); + String resName = tmp.resName; + int resNumber = tmp.resNumber; + int res = resNumber; + + if (i == 0) { + offset = resNumber; + } + + Vector resAtoms = new Vector(); + + resAtoms.addElement((myAtom) atoms.elementAt(i)); + i++; + resNumber = ((myAtom) atoms.elementAt(i)).resNumber; + + //Add atoms to a vector while the residue number + //remains the same + while ((resNumber == res) && (i < atoms.size())) { + resAtoms.addElement((myAtom) atoms.elementAt(i)); + i++; + + if (i < atoms.size()) { + resNumber = ((myAtom) atoms.elementAt(i)).resNumber; + } else { + resNumber++; + } + } + + //We need this to keep in step with the outer for i = loop + i--; + + //Make a new Residue object with the new atoms vector + residues.addElement(new Residue(resAtoms, resNumber - 1, count)); + count++; + + Residue tmpres = (Residue) residues.lastElement(); + myAtom tmpat = (myAtom) tmpres.atoms.elementAt(0); + + // Keep totting up the sequence + if (ResidueProperties.getAA3Hash().get(tmpat.resName) == null) { + System.err.println("PDBReader:Null aa3Hash for " + + tmpat.resName); + } else { + String tmpres2 = ResidueProperties.aa[((Integer) ResidueProperties.getAA3Hash() + .get(tmpat.resName)).intValue()]; + seq = seq + tmpres2; + } + + // System.out.println(tmpat.resName + " " + tmpres2); } - b.startCol = new Color(red,(float)0.0,(float)1.0-red); - atno = ((Integer)AA3Hash.get(b.at2.resName.toUpperCase())).intValue(); - - red = ((float)hyd[atno] - hydmin)/(hydmax - hydmin); + sequence = new Sequence("PDB_seq", seq, 1, seq.length()); + System.out.println("PDB Sequence is :\nSequence = " + seq); + System.out.println("No of residues = " + residues.size()); + } - if (red > (float)1.0) { - red = (float)1.0; + public void setChargeColours() { + for (int i = 0; i < bonds.size(); i++) { + try { + Bond b = (Bond) bonds.elementAt(i); + + if (b.at1.resName.toUpperCase().equals("ASP") || + b.at1.resName.toUpperCase().equals("GLU")) { + b.startCol = Color.red; + } else if (b.at1.resName.toUpperCase().equals("LYS") || + b.at1.resName.toUpperCase().equals("ARG")) { + b.startCol = Color.blue; + } else if (b.at1.resName.toUpperCase().equals("CYS")) { + b.startCol = Color.yellow; + } else { + int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at1.resName.toUpperCase())).intValue(); + b.startCol = Color.lightGray; + } + + if (b.at2.resName.toUpperCase().equals("ASP") || + b.at2.resName.toUpperCase().equals("GLU")) { + b.endCol = Color.red; + } else if (b.at2.resName.toUpperCase().equals("LYS") || + b.at2.resName.toUpperCase().equals("ARG")) { + b.endCol = Color.blue; + } else if (b.at2.resName.toUpperCase().equals("CYS")) { + b.endCol = Color.yellow; + } else { + int atno = ((Integer) ResidueProperties.getAA3Hash().get(b.at2.resName.toUpperCase())).intValue(); + b.endCol = Color.lightGray; + } + } catch (Exception e) { + Bond b = (Bond) bonds.elementAt(i); + b.startCol = Color.gray; + b.endCol = Color.gray; + } } - if (red < (float)0.0) { - red = (float)0.0; - } - - b.endCol = new Color(red,(float)0.2,(float)1.0-red); - } catch (Exception e) { - Bond b = (Bond)bonds.elementAt(i); - b.startCol = Color.gray; - b.endCol = Color.gray; - } } - } - - public void colourBySequence(jalview.gui.AlignViewport av, Sequence seq) { -jalview.gui.SequenceRenderer sr = new jalview.gui.SequenceRenderer(av); + public void setHydrophobicityColours() { + float hydmin = (float) ResidueProperties.getHydmin(); + float hydmax = (float) ResidueProperties.getHydmax(); + double[] hyd = ResidueProperties.getHyd(); + Hashtable AA3Hash = ResidueProperties.getAA3Hash(); - for (int i = 0; i < bonds.size(); i++) { - Bond tmp = (Bond)bonds.elementAt(i); - try { + for (int i = 0; i < bonds.size(); i++) { + try { + Bond b = (Bond) bonds.elementAt(i); - if (tmp.at1.resNumber >= (offset + pdbstart - 1) && tmp.at1.resNumber <= (offset + pdbend - 1)) { + int atno = ((Integer) AA3Hash.get(b.at1.resName.toUpperCase())).intValue(); + float red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin); - int pos = seqstart + (tmp.at1.resNumber - pdbstart - offset) ; - int index = seq.findIndex(pos); + if (red > (float) 1.0) { + red = (float) 1.0; + } + if (red < (float) 0.0) { + red = (float) 0.0; + } - tmp.startCol = sr.getResidueBoxColour(av.getGlobalColourScheme(), seq, index); + b.startCol = new Color(red, (float) 0.0, (float) 1.0 - red); + atno = ((Integer) AA3Hash.get(b.at2.resName.toUpperCase())).intValue(); - } else { - tmp.startCol = Color.gray; - } + red = ((float) hyd[atno] - hydmin) / (hydmax - hydmin); - if (tmp.at2.resNumber >= (offset + pdbstart -1) && tmp.at2.resNumber <= (pdbend+offset-1)) { + if (red > (float) 1.0) { + red = (float) 1.0; + } - int pos = seqstart + (tmp.at2.resNumber - pdbstart-offset); - int index = seq.findIndex(pos); + if (red < (float) 0.0) { + red = (float) 0.0; + } - tmp.endCol = sr.getResidueBoxColour(av.getGlobalColourScheme(), seq, index); + b.endCol = new Color(red, (float) 0.2, (float) 1.0 - red); + } catch (Exception e) { + Bond b = (Bond) bonds.elementAt(i); + b.startCol = Color.gray; + b.endCol = Color.gray; + } + } + } - } else { - tmp.endCol = Color.gray; + public void colourBySequence(jalview.gui.AlignViewport av, Sequence seq) { + jalview.gui.SequenceRenderer sr = new jalview.gui.SequenceRenderer(av); + + for (int i = 0; i < bonds.size(); i++) { + Bond tmp = (Bond) bonds.elementAt(i); + + try { + if ((tmp.at1.resNumber >= ((offset + pdbstart) - 1)) && + (tmp.at1.resNumber <= ((offset + pdbend) - 1))) { + int pos = seqstart + + (tmp.at1.resNumber - pdbstart - offset); + int index = seq.findIndex(pos); + + tmp.startCol = sr.getResidueBoxColour(av.getGlobalColourScheme(), + seq, index); + } else { + tmp.startCol = Color.gray; + } + + if ((tmp.at2.resNumber >= ((offset + pdbstart) - 1)) && + (tmp.at2.resNumber <= ((pdbend + offset) - 1))) { + int pos = seqstart + + (tmp.at2.resNumber - pdbstart - offset); + int index = seq.findIndex(pos); + + tmp.endCol = sr.getResidueBoxColour(av.getGlobalColourScheme(), + seq, index); + } else { + tmp.endCol = Color.gray; + } + } catch (Exception e) { + tmp.startCol = Color.lightGray; + tmp.endCol = Color.lightGray; + } } - } catch (Exception e) { - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; - } } - } - - public void setChainColours() { - for (int i = 0; i < bonds.size(); i++) { - Bond tmp = (Bond)bonds.elementAt(i); - try { - tmp.startCol = (Color) ResidueProperties.getChainColours().get(id); - tmp.endCol = (Color) ResidueProperties.getChainColours().get(id); - } catch (Exception e) { - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; - } + + public void setChainColours() { + for (int i = 0; i < bonds.size(); i++) { + Bond tmp = (Bond) bonds.elementAt(i); + + try { + tmp.startCol = (Color) ResidueProperties.getChainColours().get(id); + tmp.endCol = (Color) ResidueProperties.getChainColours().get(id); + } catch (Exception e) { + tmp.startCol = Color.lightGray; + tmp.endCol = Color.lightGray; + } + } } - } } - - diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index 1937a8f..71d8c11 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -16,149 +16,150 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; import jalview.datamodel.*; + import java.io.*; + import java.net.*; + import java.util.*; public class PDBfile extends jalview.io.FileParse { + public Vector chains = new Vector(); + Vector lineArray = new Vector(); - public Vector chains = new Vector(); + public PDBfile(String[] lines) { + for (int i = 0; i < lines.length; i++) + lineArray.addElement(lines[i]); - Vector lineArray = new Vector(); - - public PDBfile(String [] lines) - { - for(int i=0; i= 0 && ((Bond)bonds.elementAt(j)).start[2] > x); + public static void sort(Vector bonds, int p, int r) { + int q; - do { - i = i+1; - } while (i < bonds.size() && ((Bond)bonds.elementAt(i)).start[2] < x); + if (p < r) { + q = partition(bonds, p, r); + sort(bonds, p, q); + sort(bonds, q + 1, r); + } + } - if ( i < j) { - Bond tmp = (Bond)bonds.elementAt(i); - bonds.setElementAt(bonds.elementAt(j),i); - bonds.setElementAt(tmp,j); - } else { - return j; - } + private static int partition(Vector bonds, int p, int r) { + float x = ((Bond) bonds.elementAt(p)).start[2]; + int i = p - 1; + int j = r + 1; + + while (true) { + do { + j = j - 1; + } while ((j >= 0) && (((Bond) bonds.elementAt(j)).start[2] > x)); + + do { + i = i + 1; + } while ((i < bonds.size()) && + (((Bond) bonds.elementAt(i)).start[2] < x)); + + if (i < j) { + Bond tmp = (Bond) bonds.elementAt(i); + bonds.setElementAt(bonds.elementAt(j), i); + bonds.setElementAt(tmp, j); + } else { + return j; + } + } } - } } - - - diff --git a/src/MCview/myAtom.java b/src/MCview/myAtom.java index 27a4b08..75dec37 100755 --- a/src/MCview/myAtom.java +++ b/src/MCview/myAtom.java @@ -16,59 +16,56 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; -import java.util.*; import java.awt.*; -public class myAtom { - float x; - float y; - float z; - - public int number; - public String name; - public String resName; - public int resNumber; - public int type; - public Color color; - public String chain; - public boolean isSelected = false; +import java.util.*; - public myAtom(StringTokenizer str) { - this.number = (new Integer(str.nextToken())).intValue(); - this.name = str.nextToken(); - this.resName = str.nextToken(); +public class myAtom { + float x; + float y; + float z; + public int number; + public String name; + public String resName; + public int resNumber; + public int type; + public Color color; + public String chain; + public boolean isSelected = false; - String tmpstr = new String(); + public myAtom(StringTokenizer str) { + this.number = (new Integer(str.nextToken())).intValue(); + this.name = str.nextToken(); + this.resName = str.nextToken(); - try { - tmpstr = str.nextToken(); - this.resNumber = (new Integer(tmpstr).intValue()); - this.chain = "A"; - this.color = Color.lightGray; + String tmpstr = new String(); - } catch(NumberFormatException e) { - this.chain = tmpstr; + try { + tmpstr = str.nextToken(); + this.resNumber = (new Integer(tmpstr).intValue()); + this.chain = "A"; + this.color = Color.lightGray; + } catch (NumberFormatException e) { + this.chain = tmpstr; - if (tmpstr.equals("A")) { - this.color = Color.lightGray; + if (tmpstr.equals("A")) { + this.color = Color.lightGray; + } else { + this.color = Color.red; + } - } else { - this.color = Color.red; - } + this.resNumber = (new Integer(str.nextToken()).intValue()); + } - this.resNumber = (new Integer(str.nextToken()).intValue()); + this.x = (float) (new Float(str.nextToken()).floatValue()); + this.y = (float) (new Float(str.nextToken()).floatValue()); + this.z = (float) (new Float(str.nextToken()).floatValue()); } - this.x = (float)(new Float(str.nextToken()).floatValue()); - this.y = (float)(new Float(str.nextToken()).floatValue()); - this.z = (float)(new Float(str.nextToken()).floatValue()); - } - - public void setColor(Color col) { - this.color = col; - } + public void setColor(Color col) { + this.color = col; + } } diff --git a/src/MCview/rotCanvas.java b/src/MCview/rotCanvas.java index a165129..154e7e6 100755 --- a/src/MCview/rotCanvas.java +++ b/src/MCview/rotCanvas.java @@ -16,709 +16,712 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package MCview; -// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import java.io.*; -import javax.swing.*; -import jalview.analysis.AlignSeq; -import jalview.datamodel.*; - -public class rotCanvas extends JPanel implements KeyListener, - MouseListener, - MouseMotionListener { - MCMatrix idmat = new MCMatrix(3,3); - MCMatrix objmat = new MCMatrix(3,3); - - boolean redrawneeded =true; - - int omx = 0; - int mx = 0; - int omy = 0; - int my = 0; - - public PDBfile pdb; - - int bsize; - - Image img; - Graphics ig; - Dimension prefsize; - - float centre[] = new float[3]; - float width[] = new float[3]; +import jalview.analysis.AlignSeq; - float maxwidth; - float scale; +import jalview.datamodel.*; - String inStr; - String inType; +// JBPNote TODO: This class is quite noisy - needs proper log.info/log.debug +import java.awt.*; +import java.awt.event.*; - boolean depthcue = true; - boolean wire = false; - boolean bymolecule = false; - boolean zbuffer = true; +import java.io.*; - boolean dragging; +import java.util.*; - int xstart; - int xend; - int ystart; - int yend; - int xmid; - int ymid; +import javax.swing.*; - Font font = new Font("Helvetica",Font.PLAIN,10); - public rotCanvas(PDBfile pdb, Sequence sequence, jalview.gui.AlignViewport av) throws IOException { +public class rotCanvas extends JPanel implements KeyListener, MouseListener, + MouseMotionListener { + MCMatrix idmat = new MCMatrix(3, 3); + MCMatrix objmat = new MCMatrix(3, 3); + boolean redrawneeded = true; + int omx = 0; + int mx = 0; + int omy = 0; + int my = 0; + public PDBfile pdb; + int bsize; + Image img; + Graphics ig; + Dimension prefsize; + float[] centre = new float[3]; + float[] width = new float[3]; + float maxwidth; + float scale; + String inStr; + String inType; + boolean depthcue = true; + boolean wire = false; + boolean bymolecule = false; + boolean zbuffer = true; + boolean dragging; + int xstart; + int xend; + int ystart; + int yend; + int xmid; + int ymid; + Font font = new Font("Helvetica", Font.PLAIN, 10); + + public rotCanvas(PDBfile pdb, Sequence sequence, + jalview.gui.AlignViewport av) throws IOException { + int max = -10; + int maxchain = -1; + int pdbstart = 0; + int pdbend = 0; + int seqstart = 0; + int seqend = 0; + + for (int i = 0; i < pdb.chains.size(); i++) { + // Now lets compare the sequences to get + // the start and end points. + java.util.StringTokenizer str = new java.util.StringTokenizer(sequence.getSequence(), + "."); + String newString = ""; + + while (str.hasMoreTokens()) { + newString += str.nextToken(); + } - int max = -10; - int maxchain = -1; - int pdbstart=0, pdbend=0, seqstart =0, seqend=0; + // Align the sequence to the pdb + AlignSeq as = new AlignSeq(sequence, + ((PDBChain) pdb.chains.elementAt(i)).sequence, "pep"); + as.calcScoreMatrix(); + as.traceAlignment(); + as.printAlignment(); + + if (as.maxscore > max) { + max = as.maxscore; + maxchain = i; + + pdbstart = as.seq2start; + pdbend = as.seq2end; + seqstart = as.seq1start - 1; + seqend = as.seq1end - 1; + } + System.out.println("PDB start/end " + pdbstart + " " + pdbend); + System.out.println("SEQ start/end " + seqstart + " " + seqend); + } - for (int i=0; i < pdb.chains.size(); i++) { - // Now lets compare the sequences to get - // the start and end points. + ((PDBChain) pdb.chains.elementAt(maxchain)).pdbstart = pdbstart; + ((PDBChain) pdb.chains.elementAt(maxchain)).pdbend = pdbend; + ((PDBChain) pdb.chains.elementAt(maxchain)).seqstart = seqstart; + ((PDBChain) pdb.chains.elementAt(maxchain)).seqend = seqend; + ((PDBChain) pdb.chains.elementAt(maxchain)).isVisible = true; + ((PDBChain) pdb.chains.elementAt(maxchain)).sequence = sequence; + ((PDBChain) pdb.chains.elementAt(maxchain)).colourBySequence(av, + sequence); + + this.pdb = pdb; + this.prefsize = new Dimension(getWidth(), getHeight()); + + //Initialize the matrices to identity + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + if (i != j) { + idmat.addElement(i, j, 0); + objmat.addElement(i, j, 0); + } else { + idmat.addElement(i, j, 1); + objmat.addElement(i, j, 1); + } + } + } - java.util.StringTokenizer str = new java.util.StringTokenizer(sequence.getSequence(), "."); - String newString = ""; + addMouseMotionListener(this); + addMouseListener(this); + addKeyListener(this); - while (str.hasMoreTokens()) { - newString += str.nextToken(); - } - // Align the sequence to the pdb - AlignSeq as = new AlignSeq(sequence,((PDBChain)pdb.chains.elementAt(i)).sequence,"pep"); - as.calcScoreMatrix(); - as.traceAlignment(); - as.printAlignment(); - - if (as.maxscore > max) { - max = as.maxscore; - maxchain = i; - - pdbstart = as.seq2start; - pdbend = as.seq2end; - seqstart = as.seq1start - 1 ; - seqend = as.seq1end -1; - } - - System.out.println("PDB start/end " + pdbstart + " " + pdbend); - System.out.println("SEQ start/end " + seqstart + " " + seqend); + addPDBfile(); + ToolTipManager.sharedInstance().registerComponent(this); } + public void addPDBfile() { + findCentre(); + findWidth(); - ( (PDBChain)pdb.chains.elementAt(maxchain)).pdbstart = pdbstart; - ( (PDBChain)pdb.chains.elementAt(maxchain)).pdbend = pdbend; - ( (PDBChain)pdb.chains.elementAt(maxchain)).seqstart = seqstart; - ( (PDBChain)pdb.chains.elementAt(maxchain)).seqend = seqend; - ( (PDBChain) pdb.chains.elementAt(maxchain)).isVisible = true; - ( (PDBChain) pdb.chains.elementAt(maxchain)).sequence = sequence; - ( (PDBChain)pdb.chains.elementAt(maxchain)).colourBySequence(av, sequence); + scale = findScale(); + System.out.println("Scale factor = " + scale); + } + public void deleteBonds() { + scale = 0; + maxwidth = 0; - this.pdb = pdb; - this.prefsize = new Dimension( getWidth(), getHeight()); + width[0] = 0; + width[1] = 0; + width[2] = 0; - //Initialize the matrices to identity + centre[0] = 0; + centre[1] = 0; + centre[2] = 0; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3 ; j++) { - if (i != j) { - idmat.addElement(i,j,0); - objmat.addElement(i,j,0); - } else { - idmat.addElement(i,j,1); - objmat.addElement(i,j,1); + for (int i = 0; i < pdb.chains.size(); i++) { + ((PDBChain) pdb.chains.elementAt(i)).bonds = null; } - } } - addMouseMotionListener(this); - addMouseListener(this); - addKeyListener(this); - - addPDBfile(); - ToolTipManager.sharedInstance().registerComponent(this); - - } + public void findWidth() { + float[] max = new float[3]; + float[] min = new float[3]; - public void addPDBfile() { - findCentre(); - findWidth(); + max[0] = (float) -1e30; + max[1] = (float) -1e30; + max[2] = (float) -1e30; - scale = findScale(); + min[0] = (float) 1e30; + min[1] = (float) 1e30; + min[2] = (float) 1e30; - System.out.println("Scale factor = " + scale); - } + for (int ii = 0; ii < pdb.chains.size(); ii++) { + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; - public void deleteBonds() { - scale = 0; - maxwidth = 0; + for (int i = 0; i < bonds.size(); i++) { + Bond tmp = (Bond) bonds.elementAt(i); - width[0] = 0; - width[1] = 0; - width[2] = 0; + if (tmp.start[0] >= max[0]) { + max[0] = tmp.start[0]; + } - centre[0] = 0; - centre[1] = 0; - centre[2] = 0; + if (tmp.start[1] >= max[1]) { + max[1] = tmp.start[1]; + } - for (int i=0; i < pdb.chains.size(); i++) { - ((PDBChain)pdb.chains.elementAt(i)).bonds = null; - } - } + if (tmp.start[2] >= max[2]) { + max[2] = tmp.start[2]; + } - public void findWidth() { - float max[] = new float[3]; - float min[] = new float[3]; + if (tmp.start[0] <= min[0]) { + min[0] = tmp.start[0]; + } - max[0] = (float)-1e30; - max[1] = (float)-1e30; - max[2] = (float)-1e30; + if (tmp.start[1] <= min[1]) { + min[1] = tmp.start[1]; + } - min[0] = (float)1e30; - min[1] = (float)1e30; - min[2] = (float)1e30; + if (tmp.start[2] <= min[2]) { + min[2] = tmp.start[2]; + } - for (int ii=0; ii < pdb.chains.size(); ii++) { - if (((PDBChain)pdb.chains.elementAt(ii)).isVisible) { + if (tmp.end[0] >= max[0]) { + max[0] = tmp.end[0]; + } - Vector bonds = ((PDBChain)pdb.chains.elementAt(ii)).bonds; + if (tmp.end[1] >= max[1]) { + max[1] = tmp.end[1]; + } - for (int i = 0; i < bonds.size(); i++) { - Bond tmp = (Bond)bonds.elementAt(i); - - if (tmp.start[0] >= max[0]) - max[0] = tmp.start[0]; - if (tmp.start[1] >= max[1]) - max[1] = tmp.start[1]; - if (tmp.start[2] >= max[2]) - max[2] = tmp.start[2]; - if (tmp.start[0] <= min[0]) - min[0] = tmp.start[0]; - if (tmp.start[1] <= min[1]) - min[1] = tmp.start[1]; - if (tmp.start[2] <= min[2]) - min[2] = tmp.start[2]; - - if (tmp.end[0] >= max[0]) - max[0] = tmp.end[0]; - if (tmp.end[1] >= max[1]) - max[1] = tmp.end[1]; - if (tmp.end[2] >= max[2]) - max[2] = tmp.end[2]; - if (tmp.end[0] <= min[0]) - min[0] = tmp.end[0]; - if (tmp.end[1] <= min[1]) - min[1] = tmp.end[1]; - if (tmp.end[2] <= min[2]) - min[2] = tmp.end[2]; - } - } - } + if (tmp.end[2] >= max[2]) { + max[2] = tmp.end[2]; + } - 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]); + if (tmp.end[0] <= min[0]) { + min[0] = tmp.end[0]; + } - width[0] = (float)Math.abs(max[0] - min[0]); - width[1] = (float)Math.abs(max[1] - min[1]); - width[2] = (float)Math.abs(max[2] - min[2]); + if (tmp.end[1] <= min[1]) { + min[1] = tmp.end[1]; + } - maxwidth = width[0]; + if (tmp.end[2] <= min[2]) { + min[2] = tmp.end[2]; + } + } + } + } - if (width[1] > width[0]) - maxwidth = width[1]; - if (width[2] > width[1]) - maxwidth = width[2]; + 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]); - System.out.println("Maxwidth = " + maxwidth); - } + width[0] = (float) Math.abs(max[0] - min[0]); + width[1] = (float) Math.abs(max[1] - min[1]); + width[2] = (float) Math.abs(max[2] - min[2]); - public float findScale() { - int dim, width, height; + maxwidth = width[0]; - if ( getWidth() != 0) { - width = getWidth(); - height = getHeight(); + if (width[1] > width[0]) { + maxwidth = width[1]; + } - } else { - width = prefsize.width; - height = prefsize.height; - } + if (width[2] > width[1]) { + maxwidth = width[2]; + } - if (width < height) { - dim = width; - } else { - dim = height; + System.out.println("Maxwidth = " + maxwidth); } - return (float)(dim/(1.5d*maxwidth)); - } - + public float findScale() { + int dim; + int width; + int height; + if (getWidth() != 0) { + width = getWidth(); + height = getHeight(); + } else { + width = prefsize.width; + height = prefsize.height; + } - public void findCentre() { - float xtot = 0; - float ytot = 0; - float ztot = 0; + if (width < height) { + dim = width; + } else { + dim = height; + } - int bsize = 0; - //Find centre coordinate + return (float) (dim / (1.5d * maxwidth)); + } - for (int ii = 0; ii < pdb.chains.size() ; ii++) { - if (((PDBChain)pdb.chains.elementAt(ii)).isVisible) { + public void findCentre() { + float xtot = 0; + float ytot = 0; + float ztot = 0; - Vector bonds = ((PDBChain)pdb.chains.elementAt(ii)).bonds; + int bsize = 0; - bsize += bonds.size(); + //Find centre coordinate + for (int ii = 0; ii < pdb.chains.size(); ii++) { + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; - for (int i = 0; i < bonds.size(); i++) { + bsize += bonds.size(); - xtot = xtot + ((Bond)bonds.elementAt(i)).start[0] + - ((Bond)bonds.elementAt(i)).end[0]; + for (int i = 0; i < bonds.size(); i++) { + xtot = xtot + ((Bond) bonds.elementAt(i)).start[0] + + ((Bond) bonds.elementAt(i)).end[0]; - ytot = ytot + ((Bond)bonds.elementAt(i)).start[1] + - ((Bond)bonds.elementAt(i)).end[1]; + ytot = ytot + ((Bond) bonds.elementAt(i)).start[1] + + ((Bond) bonds.elementAt(i)).end[1]; - ztot = ztot + ((Bond)bonds.elementAt(i)).start[2] + - ((Bond)bonds.elementAt(i)).end[2]; + ztot = ztot + ((Bond) bonds.elementAt(i)).start[2] + + ((Bond) bonds.elementAt(i)).end[2]; + } + } } - } + + centre[0] = xtot / (2 * (float) bsize); + centre[1] = ytot / (2 * (float) bsize); + centre[2] = ztot / (2 * (float) bsize); } - centre[0] = xtot / (2 * (float)bsize); - centre[1] = ytot / (2 * (float)bsize); - centre[2] = ztot / (2 * (float)bsize); - } + public void paint(Graphics g) { + //Only create the image at the beginning - + //this saves much memory usage + if ((img == null) || (prefsize.width != getWidth()) || + (prefsize.height != getHeight())) { + prefsize.width = getWidth(); + prefsize.height = getHeight(); - public void paint(Graphics g) { - //Only create the image at the beginning - - //this saves much memory usage - if ((img == null) || (prefsize.width != getWidth()) || (prefsize.height != getHeight())) { - prefsize.width = getWidth(); - prefsize.height = getHeight(); + scale = findScale(); + img = createImage(prefsize.width, prefsize.height); + ig = img.getGraphics(); - scale = findScale(); - img = createImage(prefsize.width,prefsize.height); - ig = img.getGraphics(); + redrawneeded = true; + } - redrawneeded = true; - } + if (redrawneeded == true) { + drawBackground(ig, Color.black); + drawScene(ig); + redrawneeded = false; + } else { + ig = img.getGraphics(); + } - if (redrawneeded == true) { - drawBackground(ig,Color.black); - drawScene(ig); - redrawneeded = false; - } else { - ig = img.getGraphics(); + g.drawImage(img, 0, 0, this); } - g.drawImage(img,0,0,this); - } + public void drawBackground(Graphics g, Color col) { + g.setColor(col); + g.fillRect(0, 0, prefsize.width, prefsize.height); + } - public void drawBackground(Graphics g, Color col) { - g.setColor(col); - g.fillRect(0,0,prefsize.width,prefsize.height); - } + public void drawScene(Graphics g) { + // Sort the bonds by z coord + Vector bonds = new Vector(); + for (int ii = 0; ii < pdb.chains.size(); ii++) { + if (((PDBChain) pdb.chains.elementAt(ii)).isVisible) { + Vector tmp = ((PDBChain) pdb.chains.elementAt(ii)).bonds; - public void drawScene(Graphics g) { - // Sort the bonds by z coord + for (int i = 0; i < tmp.size(); i++) { + bonds.addElement(tmp.elementAt(i)); + } + } + } - Vector bonds = new Vector(); + if (zbuffer) { + Zsort.Zsort(bonds); + } + for (int i = 0; i < bonds.size(); i++) { + Bond tmpBond = (Bond) bonds.elementAt(i); + + xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) + + (getWidth() / 2)); + ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) + + (getHeight() / 2)); + + xend = (int) (((tmpBond.end[0] - centre[0]) * scale) + + (getWidth() / 2)); + yend = (int) (((tmpBond.end[1] - centre[1]) * scale) + + (getHeight() / 2)); + + xmid = (xend + xstart) / 2; + ymid = (yend + ystart) / 2; + + if (depthcue && !bymolecule) { + if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) { + g.setColor(tmpBond.startCol.darker().darker()); + drawLine(g, xstart, ystart, xmid, ymid); + + g.setColor(tmpBond.endCol.darker().darker()); + drawLine(g, xmid, ymid, xend, yend); + } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) { + g.setColor(tmpBond.startCol.darker()); + drawLine(g, xstart, ystart, xmid, ymid); + + g.setColor(tmpBond.endCol.darker()); + drawLine(g, xmid, ymid, xend, yend); + } else { + g.setColor(tmpBond.startCol); + drawLine(g, xstart, ystart, xmid, ymid); + + g.setColor(tmpBond.endCol); + drawLine(g, xmid, ymid, xend, yend); + } + } else if (depthcue && bymolecule) { + if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) { + g.setColor(Color.green.darker().darker()); + drawLine(g, xstart, ystart, xend, yend); + } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) { + g.setColor(Color.green.darker()); + drawLine(g, xstart, ystart, xend, yend); + } else { + g.setColor(Color.green); + drawLine(g, xstart, ystart, xend, yend); + } + } else if (!depthcue && !bymolecule) { + g.setColor(tmpBond.startCol); + drawLine(g, xstart, ystart, xmid, ymid); + g.setColor(tmpBond.endCol); + drawLine(g, xmid, ymid, xend, yend); + } else { + drawLine(g, xstart, ystart, xend, yend); + } + } + } - for (int ii = 0; ii < pdb.chains.size() ; ii++) { - if (((PDBChain)pdb.chains.elementAt(ii)).isVisible) { + public void drawLine(Graphics g, int x1, int y1, int x2, int y2) { + if (!wire) { + if (((float) Math.abs(y2 - y1) / (float) Math.abs(x2 - x1)) < 0.5) { + g.drawLine(x1, y1, x2, y2); + g.drawLine(x1 + 1, y1 + 1, x2 + 1, y2 + 1); + g.drawLine(x1, y1 - 1, x2, y2 - 1); + } else { + g.setColor(g.getColor().brighter()); + g.drawLine(x1, y1, x2, y2); + g.drawLine(x1 + 1, y1, x2 + 1, y2); + g.drawLine(x1 - 1, y1, x2 - 1, y2); + } + } else { + g.drawLine(x1, y1, x2, y2); + } + } - Vector tmp = ((PDBChain)pdb.chains.elementAt(ii)).bonds; + public Dimension minimumsize() { + return prefsize; + } - for (int i=0; i < tmp.size(); i++) { - bonds.addElement(tmp.elementAt(i)); - } - } + public Dimension preferredsize() { + return prefsize; } - if (zbuffer) { - Zsort.Zsort(bonds); + public void keyTyped(KeyEvent evt) { } - for (int i = 0; i < bonds.size(); i++) { - Bond tmpBond = (Bond)bonds.elementAt(i); + public void keyReleased(KeyEvent evt) { + } - xstart = (int)((tmpBond.start[0] - centre[0])*scale + getWidth()/2); - ystart = (int)((tmpBond.start[1] - centre[1])*scale + getHeight()/2); + public void keyPressed(KeyEvent evt) { + int key = evt.getKeyChar(); + + if (evt.getKeyCode() == KeyEvent.VK_UP) { + scale = (float) (scale * 1.1); + redrawneeded = true; + repaint(); + } else if (evt.getKeyCode() == KeyEvent.VK_DOWN) { + scale = (float) (scale * 0.9); + redrawneeded = true; + repaint(); + } else if (key == 'w') { + wire = !wire; + System.out.println("wireframe " + wire); + redrawneeded = true; + repaint(); + } else if (key == 'd') { + depthcue = !depthcue; + System.out.println("Depth cueing is " + depthcue); + redrawneeded = true; + repaint(); + } else if (key == 'm') { + bymolecule = !bymolecule; + System.out.println("Bymolecule is " + bymolecule); + redrawneeded = true; + repaint(); + } else if (key == 'z') { + zbuffer = !zbuffer; + System.out.println("Z buffering is " + zbuffer); + redrawneeded = true; + repaint(); + } else if (key == 'c') { + bymolecule = false; + pdb.setChainColours(); + System.out.println("Colouring by chain"); + redrawneeded = true; + repaint(); + } else if (key == 'h') { + bymolecule = false; + pdb.setHydrophobicityColours(); + System.out.println("Colouring by hydrophobicity"); + redrawneeded = true; + repaint(); + } else if (key == 'q') { + bymolecule = false; + pdb.setChargeColours(); + System.out.println("Colouring charges and cysteines"); + redrawneeded = true; + repaint(); + } - xend = (int)((tmpBond.end[0] - centre[0])*scale + getWidth()/2); - yend = (int)((tmpBond.end[1] - centre[1])*scale + getHeight()/2); + return; + } - xmid = (xend+xstart)/2; - ymid = (yend+ystart)/2; + public void mousePressed(MouseEvent e) { + mx = e.getX(); + my = e.getY(); + omx = mx; + omy = my; + dragging = false; + } + public void mouseMoved(MouseEvent e) { + myAtom fatom = null; - if (depthcue && !bymolecule) { + for (int ii = 0; ii < pdb.chains.size(); ii++) { + PDBChain chain = (PDBChain) pdb.chains.elementAt(ii); - if (tmpBond.start[2] < (centre[2] - maxwidth/6)) { - g.setColor(tmpBond.startCol.darker().darker()); - drawLine(g,xstart,ystart,xmid,ymid); + if (chain.isVisible) { + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; - g.setColor(tmpBond.endCol.darker().darker()); - drawLine(g,xmid,ymid,xend,yend); - } else if (tmpBond.start[2] < (centre[2]+maxwidth/6)) { - g.setColor(tmpBond.startCol.darker()); - drawLine(g,xstart,ystart,xmid,ymid); + for (int i = 0; i < bonds.size(); i++) { + Bond tmpBond = (Bond) bonds.elementAt(i); + int truex = (int) (((tmpBond.start[0] - centre[0]) * scale) + + (getWidth() / 2)); - g.setColor(tmpBond.endCol.darker()); - drawLine(g,xmid,ymid,xend,yend); - } else { - g.setColor(tmpBond.startCol); - drawLine(g,xstart,ystart,xmid,ymid); + if (Math.abs(truex - e.getX()) <= 2) { + int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) + + (getHeight() / 2)); - g.setColor(tmpBond.endCol); - drawLine(g,xmid,ymid,xend,yend); + if (Math.abs(truey - e.getY()) <= 2) { + fatom = tmpBond.at1; + } + } + } + } } - } else if (depthcue && bymolecule) { - if (tmpBond.start[2] < (centre[2] - maxwidth/6)) { - g.setColor(Color.green.darker().darker()); - drawLine(g,xstart,ystart,xend,yend); - - } else if (tmpBond.start[2] < (centre[2]+maxwidth/6)) { - g.setColor(Color.green.darker()); - drawLine(g,xstart,ystart,xend,yend); + if (fatom != null) { + this.setToolTipText(fatom.resName); } else { - g.setColor(Color.green); - drawLine(g,xstart,ystart,xend,yend); - + this.setToolTipText(null); } - } else if (!depthcue && !bymolecule) { - g.setColor(tmpBond.startCol); - drawLine(g,xstart,ystart,xmid,ymid); - g.setColor(tmpBond.endCol); - drawLine(g,xmid,ymid,xend,yend); - - } else { - drawLine(g,xstart,ystart,xend,yend); - } } - } - public void drawLine(Graphics g, int x1, int y1, int x2, int y2) { - if (!wire) { - - if (((float)Math.abs(y2-y1)/(float)Math.abs(x2-x1)) < 0.5) { - - g.drawLine(x1,y1,x2,y2); - g.drawLine(x1+1,y1+1,x2+1,y2+1); - g.drawLine(x1,y1-1,x2,y2-1); - } else { - g.setColor(g.getColor().brighter()); - g.drawLine(x1,y1,x2,y2); - g.drawLine(x1+1,y1,x2+1,y2); - g.drawLine(x1-1,y1,x2-1,y2); + public void mouseClicked(MouseEvent e) { + } - } - } else { - g.drawLine(x1,y1,x2,y2); + public void mouseEntered(MouseEvent e) { } - } - - 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) { - int key = evt.getKeyChar(); - - if (evt.getKeyCode() == KeyEvent.VK_UP) { - scale = (float)(scale * 1.1); - redrawneeded = true; - repaint(); - - } else if (evt.getKeyCode() == KeyEvent.VK_DOWN) { - scale = (float)(scale * 0.9); - redrawneeded = true; - repaint(); - - } else if (key == 'w') { - - wire = !wire; - System.out.println("wireframe " + wire); - redrawneeded = true; - repaint(); - - } else if (key == 'd') { - depthcue = !depthcue; - System.out.println("Depth cueing is " + depthcue); - redrawneeded = true; - repaint(); - - } else if (key == 'm') { - bymolecule = !bymolecule; - System.out.println("Bymolecule is " + bymolecule); - redrawneeded = true; - repaint(); - - } else if (key == 'z') { - zbuffer = !zbuffer; - System.out.println("Z buffering is " + zbuffer); - redrawneeded = true; - repaint(); - - } else if (key == 'c') { - bymolecule = false; - pdb.setChainColours(); - System.out.println("Colouring by chain"); - redrawneeded = true; - repaint(); - - } else if (key == 'h') { - bymolecule = false; - pdb.setHydrophobicityColours(); - System.out.println("Colouring by hydrophobicity"); - redrawneeded = true; - repaint(); - - } else if (key == 'q') { - bymolecule = false; - pdb.setChargeColours(); - System.out.println("Colouring charges and cysteines"); - redrawneeded = true; - repaint(); + public void mouseExited(MouseEvent e) { } - return; - } - public void mousePressed(MouseEvent e) - { + public void mouseDragged(MouseEvent evt) { + int x = evt.getX(); + int y = evt.getY(); + mx = x; + my = y; - mx = e.getX(); - my = e.getY(); - omx = mx; - omy = my; - dragging = false; -} + MCMatrix objmat = new MCMatrix(3, 3); + objmat.setIdentity(); - public void mouseMoved(MouseEvent e) - { - myAtom fatom = null; - for (int ii = 0; ii < pdb.chains.size(); ii++) - { - - PDBChain chain = (PDBChain) pdb.chains.elementAt(ii); - if (chain.isVisible) - { - Vector bonds = ( (PDBChain) pdb.chains.elementAt(ii)).bonds; - for (int i = 0; i < bonds.size(); i++) - { - Bond tmpBond = (Bond) bonds.elementAt(i); - int truex = (int) ( (tmpBond.start[0] - centre[0]) * scale + - getWidth() / 2); - if (Math.abs(truex - e.getX()) <= 2) - { - int truey = (int) ( (tmpBond.start[1] - centre[1]) * scale + - getHeight() / 2); - if (Math.abs(truey - e.getY()) <= 2) - fatom = tmpBond.at1; - } + if ((evt.getModifiers() & Event.META_MASK) != 0) { + objmat.rotatez((float) ((mx - omx))); + } else { + objmat.rotatex((float) ((my - omy))); + objmat.rotatey((float) ((omx - mx))); } - } - } - if(fatom!=null) - { - this.setToolTipText(fatom.resName); - } - else - this.setToolTipText(null); - } - - public void mouseClicked(MouseEvent e) { } - public void mouseEntered(MouseEvent e) { } - public void mouseExited(MouseEvent e) { } - - public void mouseDragged(MouseEvent evt) { - int x = evt.getX(); - int y = evt.getY(); - mx = x; - my = y; - - MCMatrix objmat = new MCMatrix(3,3); - objmat.setIdentity(); - - if ((evt.getModifiers() & Event.META_MASK) != 0) { - objmat.rotatez((float)((mx-omx))); - } else { - objmat.rotatex((float)((my-omy))); - objmat.rotatey((float)((omx-mx))); - } - //Alter the bonds - for (int ii = 0; ii < pdb.chains.size() ; ii++) { - Vector bonds = ((PDBChain)pdb.chains.elementAt(ii)).bonds; + //Alter the bonds + for (int ii = 0; ii < pdb.chains.size(); ii++) { + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; - for (int i = 0; i < bonds.size(); i++) { + for (int i = 0; i < bonds.size(); i++) { + Bond tmpBond = (Bond) bonds.elementAt(i); - Bond tmpBond = (Bond)bonds.elementAt(i); + //Translate the bond so the centre is 0,0,0 + tmpBond.translate(-centre[0], -centre[1], -centre[2]); - //Translate the bond so the centre is 0,0,0 - tmpBond.translate(-centre[0],-centre[1],-centre[2]); - - //Now apply the rotation matrix - tmpBond.start = objmat.vectorMultiply(tmpBond.start); - tmpBond.end = objmat.vectorMultiply(tmpBond.end); - - //Now translate back again - tmpBond.translate(centre[0],centre[1],centre[2]); - } - } + //Now apply the rotation matrix + tmpBond.start = objmat.vectorMultiply(tmpBond.start); + tmpBond.end = objmat.vectorMultiply(tmpBond.end); - objmat = null; + //Now translate back again + tmpBond.translate(centre[0], centre[1], centre[2]); + } + } - omx = mx; - omy = my; + objmat = null; - redrawneeded = true; + omx = mx; + omy = my; - paint(this.getGraphics()); + redrawneeded = true; - dragging = true; - return; - } + paint(this.getGraphics()); - public void mouseReleased(MouseEvent evt) { - int x = evt.getX(); - int y = evt.getY(); + dragging = true; - if (!dragging) { - myAtom tmp = findAtom(x,y); + return; } - drawLabels(); - return; - } - - public void drawLabels() { - redrawneeded = true; - paint(this.getGraphics()); - - for (int ii = 0; ii < pdb.chains.size() ; ii++) { - PDBChain chain = (PDBChain)pdb.chains.elementAt(ii); - - if (chain.isVisible) { - - Vector bonds = ((PDBChain)pdb.chains.elementAt(ii)).bonds; - - for (int i = 0; i < bonds.size(); i++) { - Bond tmpBond = (Bond)bonds.elementAt(i); - - if (tmpBond.at1.isSelected) { - labelAtom(img.getGraphics(),tmpBond,1); - } - - if (tmpBond.at2.isSelected) { - labelAtom(img.getGraphics(),tmpBond,2); - } + public void mouseReleased(MouseEvent evt) { + int x = evt.getX(); + int y = evt.getY(); + if (!dragging) { + myAtom tmp = findAtom(x, y); } - } - } - - this.getGraphics().drawImage(img,0,0,this); - - dragging = false; - - } - - public void labelAtom(Graphics g,Bond b, int n) { - g.setFont(font); + drawLabels(); - if (n ==1) { - - int xstart = (int)((b.start[0] - centre[0])*scale + getWidth()/2); - int ystart = (int)((b.start[1] - centre[1])*scale + getHeight()/2); - - g.setColor(Color.red); - g.drawString(b.at1.resName + "-" + b.at1.resNumber,xstart,ystart); + return; } - if (n ==2) { + public void drawLabels() { + redrawneeded = true; + paint(this.getGraphics()); - int xstart = (int)((b.end[0] - centre[0])*scale + getWidth()/2); - int ystart = (int)((b.end[1] - centre[1])*scale + getHeight()/2); + for (int ii = 0; ii < pdb.chains.size(); ii++) { + PDBChain chain = (PDBChain) pdb.chains.elementAt(ii); - g.setColor(Color.red); - g.drawString(b.at2.resName + "-" + b.at2.resNumber,xstart,ystart); - } - } + if (chain.isVisible) { + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; + for (int i = 0; i < bonds.size(); i++) { + Bond tmpBond = (Bond) bonds.elementAt(i); - public myAtom findAtom(int x, int y) { - myAtom fatom = null; + if (tmpBond.at1.isSelected) { + labelAtom(img.getGraphics(), tmpBond, 1); + } - int foundchain = -1; + if (tmpBond.at2.isSelected) { + labelAtom(img.getGraphics(), tmpBond, 2); + } + } + } + } - for (int ii = 0; ii < pdb.chains.size() ; ii++) { + this.getGraphics().drawImage(img, 0, 0, this); - PDBChain chain = (PDBChain)pdb.chains.elementAt(ii); + dragging = false; + } - if (chain.isVisible) { + public void labelAtom(Graphics g, Bond b, int n) { + g.setFont(font); - Vector bonds = ((PDBChain)pdb.chains.elementAt(ii)).bonds; + if (n == 1) { + int xstart = (int) (((b.start[0] - centre[0]) * scale) + + (getWidth() / 2)); + int ystart = (int) (((b.start[1] - centre[1]) * scale) + + (getHeight() / 2)); - for (int i = 0; i < bonds.size(); i++) { - Bond tmpBond = (Bond)bonds.elementAt(i); + g.setColor(Color.red); + g.drawString(b.at1.resName + "-" + b.at1.resNumber, xstart, ystart); + } - int truex = (int)((tmpBond.start[0] - centre[0])*scale + getWidth()/2); + if (n == 2) { + int xstart = (int) (((b.end[0] - centre[0]) * scale) + + (getWidth() / 2)); + int ystart = (int) (((b.end[1] - centre[1]) * scale) + + (getHeight() / 2)); - if (Math.abs(truex - x) <= 2) { + g.setColor(Color.red); + g.drawString(b.at2.resName + "-" + b.at2.resNumber, xstart, ystart); + } + } - int truey = (int)((tmpBond.start[1] - centre[1])*scale + getHeight()/2); + public myAtom findAtom(int x, int y) { + myAtom fatom = null; + + int foundchain = -1; + + for (int ii = 0; ii < pdb.chains.size(); ii++) { + PDBChain chain = (PDBChain) pdb.chains.elementAt(ii); + + if (chain.isVisible) { + Vector bonds = ((PDBChain) pdb.chains.elementAt(ii)).bonds; + + for (int i = 0; i < bonds.size(); i++) { + Bond tmpBond = (Bond) bonds.elementAt(i); + + int truex = (int) (((tmpBond.start[0] - centre[0]) * scale) + + (getWidth() / 2)); + + if (Math.abs(truex - x) <= 2) { + int truey = (int) (((tmpBond.start[1] - centre[1]) * scale) + + (getHeight() / 2)); + + if (Math.abs(truey - y) <= 2) { + System.out.println("Found match"); + System.out.println(x + " " + y); + System.out.println(truex + " " + truey); + System.out.println(tmpBond.start[0] + " " + + tmpBond.start[1]); + System.out.println("Atom 1 = " + + tmpBond.at1.resName + " " + + tmpBond.at1.resNumber + " " + + tmpBond.at1.chain); + fatom = tmpBond.at1; + fatom.isSelected = !fatom.isSelected; + foundchain = ii; + } + } + } + } - if (Math.abs(truey - y) <= 2) { + if (fatom != null) //)&& chain.ds != null) + { + chain = (PDBChain) pdb.chains.elementAt(foundchain); - System.out.println("Found match"); - System.out.println(x + " " + y); - System.out.println(truex + " " + truey); - System.out.println(tmpBond.start[0] + " " + tmpBond.start[1]); - System.out.println("Atom 1 = " + tmpBond.at1.resName + " " + - tmpBond.at1.resNumber + " " + tmpBond.at1.chain); - fatom = tmpBond.at1; - fatom.isSelected = !fatom.isSelected; - foundchain = ii; + // SMJS TODO + // int tmp = chain.ds.seqstart + fatom.resNumber - chain.offset; + // int pos = chain.ds.findIndex(tmp); + // System.out.println("Found seq " + chain.ds.name + " " + tmp + " " + pos); } - } } - } - - if (fatom != null) //)&& chain.ds != null) - { - chain = (PDBChain)pdb.chains.elementAt(foundchain); - // SMJS TODO - // int tmp = chain.ds.seqstart + fatom.resNumber - chain.offset; - // int pos = chain.ds.findIndex(tmp); - // System.out.println("Found seq " + chain.ds.name + " " + tmp + " " + pos); - } + return fatom; } - return fatom; - } - - public void update(Graphics g) { - paint(g); - } + public void update(Graphics g) { + paint(g); + } } diff --git a/src/ext/vamsas/JPredWS.java b/src/ext/vamsas/JPredWS.java index 82e58c2..194272e 100755 --- a/src/ext/vamsas/JPredWS.java +++ b/src/ext/vamsas/JPredWS.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,13 +22,19 @@ * 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 ext.vamsas; - -public interface JPredWS extends java.rmi.Remote { - public java.lang.String predict(ext.vamsas.Sequence in0) throws java.rmi.RemoteException; - public java.lang.String predictOnMsa(ext.vamsas.Msfalignment in0) throws java.rmi.RemoteException; - public ext.vamsas.Secstructpred getpredict(java.lang.String in0) throws java.rmi.RemoteException; - public ext.vamsas.JpredResult getresult(java.lang.String in0) throws java.rmi.RemoteException; -} +*/ +package ext.vamsas; + +public interface JPredWS extends java.rmi.Remote { + public java.lang.String predict(ext.vamsas.Sequence in0) + throws java.rmi.RemoteException; + + public java.lang.String predictOnMsa(ext.vamsas.Msfalignment in0) + throws java.rmi.RemoteException; + + public ext.vamsas.Secstructpred getpredict(java.lang.String in0) + throws java.rmi.RemoteException; + + public ext.vamsas.JpredResult getresult(java.lang.String in0) + throws java.rmi.RemoteException; +} diff --git a/src/ext/vamsas/JPredWSService.java b/src/ext/vamsas/JPredWSService.java index e14c51d..3cb5e5d 100755 --- a/src/ext/vamsas/JPredWSService.java +++ b/src/ext/vamsas/JPredWSService.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,14 +22,14 @@ * 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 ext.vamsas; - -public interface JPredWSService extends javax.xml.rpc.Service { - public java.lang.String getjpredAddress(); - - public ext.vamsas.JPredWS getjpred() throws javax.xml.rpc.ServiceException; - - public ext.vamsas.JPredWS getjpred(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; -} +*/ +package ext.vamsas; + +public interface JPredWSService extends javax.xml.rpc.Service { + public java.lang.String getjpredAddress(); + + public ext.vamsas.JPredWS getjpred() throws javax.xml.rpc.ServiceException; + + public ext.vamsas.JPredWS getjpred(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; +} diff --git a/src/ext/vamsas/JPredWSServiceLocator.java b/src/ext/vamsas/JPredWSServiceLocator.java index af51043..cb4006d 100755 --- a/src/ext/vamsas/JPredWSServiceLocator.java +++ b/src/ext/vamsas/JPredWSServiceLocator.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,134 +22,146 @@ * 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 ext.vamsas; - -public class JPredWSServiceLocator extends org.apache.axis.client.Service implements ext.vamsas.JPredWSService { - - public JPredWSServiceLocator() { - } - - - public JPredWSServiceLocator(org.apache.axis.EngineConfiguration config) { - super(config); - } - - // Use to get a proxy class for jpred - private java.lang.String jpred_address = "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/jpred"; - - public java.lang.String getjpredAddress() { - return jpred_address; - } - - // The WSDD service name defaults to the port name. - private java.lang.String jpredWSDDServiceName = "jpred"; - - public java.lang.String getjpredWSDDServiceName() { - return jpredWSDDServiceName; - } - - public void setjpredWSDDServiceName(java.lang.String name) { - jpredWSDDServiceName = name; - } - - public ext.vamsas.JPredWS getjpred() throws javax.xml.rpc.ServiceException { - java.net.URL endpoint; - try { - endpoint = new java.net.URL(jpred_address); - } - catch (java.net.MalformedURLException e) { - throw new javax.xml.rpc.ServiceException(e); - } - return getjpred(endpoint); - } - - public ext.vamsas.JPredWS getjpred(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { - try { - ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub(portAddress, this); - _stub.setPortName(getjpredWSDDServiceName()); - return _stub; - } - catch (org.apache.axis.AxisFault e) { - return null; - } - } - - public void setjpredEndpointAddress(java.lang.String address) { - jpred_address = address; - } - +*/ +package ext.vamsas; + +public class JPredWSServiceLocator extends org.apache.axis.client.Service + implements ext.vamsas.JPredWSService { + // Use to get a proxy class for jpred + private java.lang.String jpred_address = "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/jpred"; + + // The WSDD service name defaults to the port name. + private java.lang.String jpredWSDDServiceName = "jpred"; + private java.util.HashSet ports = null; + + public JPredWSServiceLocator() { + } + + public JPredWSServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public java.lang.String getjpredAddress() { + return jpred_address; + } + + public java.lang.String getjpredWSDDServiceName() { + return jpredWSDDServiceName; + } + + public void setjpredWSDDServiceName(java.lang.String name) { + jpredWSDDServiceName = name; + } + + public ext.vamsas.JPredWS getjpred() throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + + try { + endpoint = new java.net.URL(jpred_address); + } catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + + return getjpred(endpoint); + } + + public ext.vamsas.JPredWS getjpred(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException { + try { + ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub(portAddress, + this); + _stub.setPortName(getjpredWSDDServiceName()); + + return _stub; + } catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setjpredEndpointAddress(java.lang.String address) { + jpred_address = address; + } + /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - try { - if (ext.vamsas.JPredWS.class.isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub(new java.net.URL(jpred_address), this); - _stub.setPortName(getjpredWSDDServiceName()); - return _stub; - } - } - catch (java.lang.Throwable t) { - throw new javax.xml.rpc.ServiceException(t); - } - throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); - } - + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException { + try { + if (ext.vamsas.JPredWS.class.isAssignableFrom( + serviceEndpointInterface)) { + ext.vamsas.JpredSoapBindingStub _stub = new ext.vamsas.JpredSoapBindingStub(new java.net.URL( + jpred_address), this); + _stub.setPortName(getjpredWSDDServiceName()); + + return _stub; + } + } catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + ((serviceEndpointInterface == null) ? "null" + : serviceEndpointInterface.getName())); + } + /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - if (portName == null) { - return getPort(serviceEndpointInterface); - } - java.lang.String inputPortName = portName.getLocalPart(); - if ("jpred".equals(inputPortName)) { - return getjpred(); - } - else { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ((org.apache.axis.client.Stub) _stub).setPortName(portName); - return _stub; - } - } - - public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("vamsas", "JPredWSService"); - } - - private java.util.HashSet ports = null; - - public java.util.Iterator getPorts() { - if (ports == null) { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "jpred")); - } - return ports.iterator(); - } - + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + + java.lang.String inputPortName = portName.getLocalPart(); + + if ("jpred".equals(inputPortName)) { + return getjpred(); + } else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("vamsas", "JPredWSService"); + } + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "jpred")); + } + + return ports.iterator(); + } + /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - if ("jpred".equals(portName)) { - setjpredEndpointAddress(address); - } - else { // Unknown Port Name - throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); - } - } - +* Set the endpoint address for the specified port name. +*/ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) throws javax.xml.rpc.ServiceException { + if ("jpred".equals(portName)) { + setjpredEndpointAddress(address); + } else { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); + } + } + /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - setEndpointAddress(portName.getLocalPart(), address); - } - -} +* Set the endpoint address for the specified port name. +*/ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } +} diff --git a/src/ext/vamsas/JpredResult.java b/src/ext/vamsas/JpredResult.java index 741d3df..e7d089b 100755 --- a/src/ext/vamsas/JpredResult.java +++ b/src/ext/vamsas/JpredResult.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,150 +22,164 @@ * 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 ext.vamsas; - -public class JpredResult extends ext.vamsas.Result implements java.io.Serializable { - private java.lang.String aligfile; - private java.lang.String predfile; - - public JpredResult() { - } - - public JpredResult( - java.lang.String aligfile, - java.lang.String predfile) { - this.aligfile = aligfile; - this.predfile = predfile; - } - - +*/ +package ext.vamsas; + +public class JpredResult extends ext.vamsas.Result + implements java.io.Serializable { + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(JpredResult.class, + true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "JpredResult")); + + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("aligfile"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "aligfile")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("predfile"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "predfile")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + } + + private java.lang.String aligfile; + private java.lang.String predfile; + private java.lang.Object __equalsCalc = null; + private boolean __hashCodeCalc = false; + + public JpredResult() { + } + + public JpredResult(java.lang.String aligfile, java.lang.String predfile) { + this.aligfile = aligfile; + this.predfile = predfile; + } + /** - * Gets the aligfile value for this JpredResult. - * - * @return aligfile - */ - public java.lang.String getAligfile() { - return aligfile; - } - - + * Gets the aligfile value for this JpredResult. + * + * @return aligfile + */ + public java.lang.String getAligfile() { + return aligfile; + } + /** - * Sets the aligfile value for this JpredResult. - * - * @param aligfile - */ - public void setAligfile(java.lang.String aligfile) { - this.aligfile = aligfile; - } - - + * Sets the aligfile value for this JpredResult. + * + * @param aligfile + */ + public void setAligfile(java.lang.String aligfile) { + this.aligfile = aligfile; + } + /** - * Gets the predfile value for this JpredResult. - * - * @return predfile - */ - public java.lang.String getPredfile() { - return predfile; - } - - + * Gets the predfile value for this JpredResult. + * + * @return predfile + */ + public java.lang.String getPredfile() { + return predfile; + } + /** - * Sets the predfile value for this JpredResult. - * - * @param predfile - */ - public void setPredfile(java.lang.String predfile) { - this.predfile = predfile; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof JpredResult)) return false; - JpredResult other = (JpredResult) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = super.equals(obj) && - ((this.aligfile==null && other.getAligfile()==null) || - (this.aligfile!=null && - this.aligfile.equals(other.getAligfile()))) && - ((this.predfile==null && other.getPredfile()==null) || - (this.predfile!=null && - this.predfile.equals(other.getPredfile()))); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = super.hashCode(); - if (getAligfile() != null) { - _hashCode += getAligfile().hashCode(); - } - if (getPredfile() != null) { - _hashCode += getPredfile().hashCode(); - } - __hashCodeCalc = false; - return _hashCode; - } - - // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(JpredResult.class, true); - - static { - typeDesc.setXmlType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "JpredResult")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("aligfile"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "aligfile")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("predfile"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "predfile")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - } - + * Sets the predfile value for this JpredResult. + * + * @param predfile + */ + public void setPredfile(java.lang.String predfile) { + this.predfile = predfile; + } + + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof JpredResult)) { + return false; + } + + JpredResult other = (JpredResult) obj; + + if (obj == null) { + return false; + } + + if (this == obj) { + return true; + } + + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + + __equalsCalc = obj; + + boolean _equals; + _equals = super.equals(obj) && + (((this.aligfile == null) && (other.getAligfile() == null)) || + ((this.aligfile != null) && + this.aligfile.equals(other.getAligfile()))) && + (((this.predfile == null) && (other.getPredfile() == null)) || + ((this.predfile != null) && + this.predfile.equals(other.getPredfile()))); + __equalsCalc = null; + + return _equals; + } + + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + + __hashCodeCalc = true; + + int _hashCode = super.hashCode(); + + if (getAligfile() != null) { + _hashCode += getAligfile().hashCode(); + } + + if (getPredfile() != null) { + _hashCode += getPredfile().hashCode(); + } + + __hashCodeCalc = false; + + return _hashCode; + } + /** - * Return type metadata object - */ - public static org.apache.axis.description.TypeDesc getTypeDesc() { - return typeDesc; - } - + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + /** - * Get Custom Serializer - */ - public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); - } - + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); + } + /** - * Get Custom Deserializer - */ - public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); - } - -} + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); + } +} diff --git a/src/ext/vamsas/JpredSoapBindingStub.java b/src/ext/vamsas/JpredSoapBindingStub.java index d27a582..bed6fa3 100755 --- a/src/ext/vamsas/JpredSoapBindingStub.java +++ b/src/ext/vamsas/JpredSoapBindingStub.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,308 +22,368 @@ * 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 ext.vamsas; - -public class JpredSoapBindingStub extends org.apache.axis.client.Stub implements ext.vamsas.JPredWS { - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); - - static org.apache.axis.description.OperationDesc [] _operations; - - static { - _operations = new org.apache.axis.description.OperationDesc[4]; - _initOperationDesc1(); - } - - private static void _initOperationDesc1(){ - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("predict"); - oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), new javax.xml.namespace.QName("http://dataTypes.vamsas", "Sequence"), ext.vamsas.Sequence.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - oper.setReturnClass(java.lang.String.class); - oper.setReturnQName(new javax.xml.namespace.QName("vamsas", "predictReturn")); - oper.setStyle(org.apache.axis.constants.Style.WRAPPED); - oper.setUse(org.apache.axis.constants.Use.LITERAL); - _operations[0] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("predictOnMsa"); - oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), new javax.xml.namespace.QName("http://dataTypes.vamsas", "Msfalignment"), ext.vamsas.Msfalignment.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - oper.setReturnClass(java.lang.String.class); - oper.setReturnQName(new javax.xml.namespace.QName("vamsas", "predictOnMsaReturn")); - oper.setStyle(org.apache.axis.constants.Style.WRAPPED); - oper.setUse(org.apache.axis.constants.Use.LITERAL); - _operations[1] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getpredict"); - oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "Secstructpred")); - oper.setReturnClass(ext.vamsas.Secstructpred.class); - oper.setReturnQName(new javax.xml.namespace.QName("vamsas", "getpredictReturn")); - oper.setStyle(org.apache.axis.constants.Style.WRAPPED); - oper.setUse(org.apache.axis.constants.Use.LITERAL); - _operations[2] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getresult"); - oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "JpredResult")); - oper.setReturnClass(ext.vamsas.JpredResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("vamsas", "getresultReturn")); - oper.setStyle(org.apache.axis.constants.Style.WRAPPED); - oper.setUse(org.apache.axis.constants.Use.LITERAL); - _operations[3] = oper; - - } - - public JpredSoapBindingStub() throws org.apache.axis.AxisFault { - this(null); - } - - public JpredSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - this(service); - super.cachedEndpoint = endpointURL; - } - - public JpredSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - if (service == null) { - super.service = new org.apache.axis.client.Service(); - } else { - super.service = service; - } - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; - java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", "Sequence"); - cachedSerQNames.add(qName); - cls = ext.vamsas.Sequence.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", "Secstructpred"); - cachedSerQNames.add(qName); - cls = ext.vamsas.Secstructpred.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", "Msfalignment"); - cachedSerQNames.add(qName); - cls = ext.vamsas.Msfalignment.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", "JpredResult"); - cachedSerQNames.add(qName); - cls = ext.vamsas.JpredResult.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", "Result"); - cachedSerQNames.add(qName); - cls = ext.vamsas.Result.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - } - - protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { - try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call) super.service.createCall(); - if (super.maintainSessionSet) { - _call.setMaintainSession(super.maintainSession); - } - if (super.cachedUsername != null) { - _call.setUsername(super.cachedUsername); - } - if (super.cachedPassword != null) { - _call.setPassword(super.cachedPassword); - } - if (super.cachedEndpoint != null) { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - if (super.cachedTimeout != null) { - _call.setTimeout(super.cachedTimeout); - } - if (super.cachedPortName != null) { - _call.setPortName(super.cachedPortName); - } - java.util.Enumeration keys = super.cachedProperties.keys(); - while (keys.hasMoreElements()) { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) { - if (firstCall()) { - // must set encoding style before registering serializers - _call.setEncodingStyle(null); - for (int i = 0; i < cachedSerFactories.size(); ++i) { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - return _call; - } - catch (java.lang.Throwable _t) { - throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); - } - } - - public java.lang.String predict(ext.vamsas.Sequence in0) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setEncodingStyle(null); - _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); - _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predict")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {in0}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (java.lang.String) _resp; - } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); - } - } - } - - public java.lang.String predictOnMsa(ext.vamsas.Msfalignment in0) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[1]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setEncodingStyle(null); - _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); - _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predictOnMsa")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {in0}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (java.lang.String) _resp; - } catch (java.lang.Exception _exception) { - return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.String.class); - } - } - } - - public ext.vamsas.Secstructpred getpredict(java.lang.String in0) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[2]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setEncodingStyle(null); - _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); - _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getpredict")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {in0}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (ext.vamsas.Secstructpred) _resp; - } catch (java.lang.Exception _exception) { - return (ext.vamsas.Secstructpred) org.apache.axis.utils.JavaUtils.convert(_resp, ext.vamsas.Secstructpred.class); - } - } - } - - public ext.vamsas.JpredResult getresult(java.lang.String in0) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[3]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setEncodingStyle(null); - _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); - _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getresult")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {in0}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (ext.vamsas.JpredResult) _resp; - } catch (java.lang.Exception _exception) { - return (ext.vamsas.JpredResult) org.apache.axis.utils.JavaUtils.convert(_resp, ext.vamsas.JpredResult.class); - } - } - } - -} +*/ +package ext.vamsas; + +public class JpredSoapBindingStub extends org.apache.axis.client.Stub + implements ext.vamsas.JPredWS { + static org.apache.axis.description.OperationDesc[] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[4]; + _initOperationDesc1(); + } + + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + public JpredSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public JpredSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public JpredSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", + "Sequence"); + cachedSerQNames.add(qName); + cls = ext.vamsas.Sequence.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", + "Secstructpred"); + cachedSerQNames.add(qName); + cls = ext.vamsas.Secstructpred.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", + "Msfalignment"); + cachedSerQNames.add(qName); + cls = ext.vamsas.Msfalignment.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", + "JpredResult"); + cachedSerQNames.add(qName); + cls = ext.vamsas.JpredResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://dataTypes.vamsas", + "Result"); + cachedSerQNames.add(qName); + cls = ext.vamsas.Result.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + } + + private static void _initOperationDesc1() { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("predict"); + oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), + new javax.xml.namespace.QName("http://dataTypes.vamsas", "Sequence"), + ext.vamsas.Sequence.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("vamsas", + "predictReturn")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("predictOnMsa"); + oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), + new javax.xml.namespace.QName("http://dataTypes.vamsas", + "Msfalignment"), ext.vamsas.Msfalignment.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + oper.setReturnClass(java.lang.String.class); + oper.setReturnQName(new javax.xml.namespace.QName("vamsas", + "predictOnMsaReturn")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getpredict"); + oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), + new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "Secstructpred")); + oper.setReturnClass(ext.vamsas.Secstructpred.class); + oper.setReturnQName(new javax.xml.namespace.QName("vamsas", + "getpredictReturn")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getresult"); + oper.addParameter(new javax.xml.namespace.QName("vamsas", "in0"), + new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "JpredResult")); + oper.setReturnClass(ext.vamsas.JpredResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("vamsas", + "getresultReturn")); + oper.setStyle(org.apache.axis.constants.Style.WRAPPED); + oper.setUse(org.apache.axis.constants.Use.LITERAL); + _operations[3] = oper; + } + + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service.createCall(); + + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + + java.util.Enumeration keys = super.cachedProperties.keys(); + + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setEncodingStyle(null); + + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + + return _call; + } catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", + _t); + } + } + + public java.lang.String predict(ext.vamsas.Sequence in0) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, + Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, + Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "predict")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { in0 }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, + java.lang.String.class); + } + } + } + + public java.lang.String predictOnMsa(ext.vamsas.Msfalignment in0) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, + Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, + Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "predictOnMsa")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { in0 }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (java.lang.String) _resp; + } catch (java.lang.Exception _exception) { + return (java.lang.String) org.apache.axis.utils.JavaUtils.convert(_resp, + java.lang.String.class); + } + } + } + + public ext.vamsas.Secstructpred getpredict(java.lang.String in0) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, + Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, + Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getpredict")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { in0 }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (ext.vamsas.Secstructpred) _resp; + } catch (java.lang.Exception _exception) { + return (ext.vamsas.Secstructpred) org.apache.axis.utils.JavaUtils.convert(_resp, + ext.vamsas.Secstructpred.class); + } + } + } + + public ext.vamsas.JpredResult getresult(java.lang.String in0) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setEncodingStyle(null); + _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, + Boolean.FALSE); + _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, + Boolean.FALSE); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getresult")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { in0 }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (ext.vamsas.JpredResult) _resp; + } catch (java.lang.Exception _exception) { + return (ext.vamsas.JpredResult) org.apache.axis.utils.JavaUtils.convert(_resp, + ext.vamsas.JpredResult.class); + } + } + } +} diff --git a/src/ext/vamsas/Msfalignment.java b/src/ext/vamsas/Msfalignment.java index d94e2b9..c9fbf85 100755 --- a/src/ext/vamsas/Msfalignment.java +++ b/src/ext/vamsas/Msfalignment.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,150 +22,161 @@ * 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 ext.vamsas; - -public class Msfalignment implements java.io.Serializable { - private java.lang.String msf; - private java.lang.String notes; - - public Msfalignment() { - } - - public Msfalignment( - java.lang.String msf, - java.lang.String notes) { - this.msf = msf; - this.notes = notes; - } - - +*/ +package ext.vamsas; + +public class Msfalignment implements java.io.Serializable { + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(Msfalignment.class, + true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "Msfalignment")); + + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("msf"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "msf")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("notes"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "notes")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + } + + private java.lang.String msf; + private java.lang.String notes; + private java.lang.Object __equalsCalc = null; + private boolean __hashCodeCalc = false; + + public Msfalignment() { + } + + public Msfalignment(java.lang.String msf, java.lang.String notes) { + this.msf = msf; + this.notes = notes; + } + /** - * Gets the msf value for this Msfalignment. - * - * @return msf - */ - public java.lang.String getMsf() { - return msf; - } - - + * Gets the msf value for this Msfalignment. + * + * @return msf + */ + public java.lang.String getMsf() { + return msf; + } + /** - * Sets the msf value for this Msfalignment. - * - * @param msf - */ - public void setMsf(java.lang.String msf) { - this.msf = msf; - } - - + * Sets the msf value for this Msfalignment. + * + * @param msf + */ + public void setMsf(java.lang.String msf) { + this.msf = msf; + } + /** - * Gets the notes value for this Msfalignment. - * - * @return notes - */ - public java.lang.String getNotes() { - return notes; - } - - + * Gets the notes value for this Msfalignment. + * + * @return notes + */ + public java.lang.String getNotes() { + return notes; + } + /** - * Sets the notes value for this Msfalignment. - * - * @param notes - */ - public void setNotes(java.lang.String notes) { - this.notes = notes; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof Msfalignment)) return false; - Msfalignment other = (Msfalignment) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = true && - ((this.msf==null && other.getMsf()==null) || - (this.msf!=null && - this.msf.equals(other.getMsf()))) && - ((this.notes==null && other.getNotes()==null) || - (this.notes!=null && - this.notes.equals(other.getNotes()))); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = 1; - if (getMsf() != null) { - _hashCode += getMsf().hashCode(); - } - if (getNotes() != null) { - _hashCode += getNotes().hashCode(); - } - __hashCodeCalc = false; - return _hashCode; - } - - // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(Msfalignment.class, true); - - static { - typeDesc.setXmlType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "Msfalignment")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("msf"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "msf")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("notes"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "notes")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - } - + * Sets the notes value for this Msfalignment. + * + * @param notes + */ + public void setNotes(java.lang.String notes) { + this.notes = notes; + } + + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof Msfalignment)) { + return false; + } + + Msfalignment other = (Msfalignment) obj; + + if (obj == null) { + return false; + } + + if (this == obj) { + return true; + } + + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + + __equalsCalc = obj; + + boolean _equals; + _equals = true && + (((this.msf == null) && (other.getMsf() == null)) || + ((this.msf != null) && this.msf.equals(other.getMsf()))) && + (((this.notes == null) && (other.getNotes() == null)) || + ((this.notes != null) && this.notes.equals(other.getNotes()))); + __equalsCalc = null; + + return _equals; + } + + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + + __hashCodeCalc = true; + + int _hashCode = 1; + + if (getMsf() != null) { + _hashCode += getMsf().hashCode(); + } + + if (getNotes() != null) { + _hashCode += getNotes().hashCode(); + } + + __hashCodeCalc = false; + + return _hashCode; + } + /** - * Return type metadata object - */ - public static org.apache.axis.description.TypeDesc getTypeDesc() { - return typeDesc; - } - + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + /** - * Get Custom Serializer - */ - public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); - } - + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); + } + /** - * Get Custom Deserializer - */ - public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); - } - -} + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); + } +} diff --git a/src/ext/vamsas/MuscleWS.java b/src/ext/vamsas/MuscleWS.java index 37f851d..ffbe5cb 100755 --- a/src/ext/vamsas/MuscleWS.java +++ b/src/ext/vamsas/MuscleWS.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,13 +22,20 @@ * 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 ext.vamsas; - -public interface MuscleWS extends java.rmi.Remote { - public vamsas.objects.simple.WsJobId align(vamsas.objects.simple.SequenceSet seqSet) throws java.rmi.RemoteException; - public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) throws java.rmi.RemoteException; - public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) throws java.rmi.RemoteException; - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) throws java.rmi.RemoteException; -} +*/ +package ext.vamsas; + +public interface MuscleWS extends java.rmi.Remote { + public vamsas.objects.simple.WsJobId align( + vamsas.objects.simple.SequenceSet seqSet) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) + throws java.rmi.RemoteException; + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException; +} diff --git a/src/ext/vamsas/MuscleWSService.java b/src/ext/vamsas/MuscleWSService.java index b1a41cc..ffc4abc 100755 --- a/src/ext/vamsas/MuscleWSService.java +++ b/src/ext/vamsas/MuscleWSService.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,14 +22,15 @@ * 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 ext.vamsas; - -public interface MuscleWSService extends javax.xml.rpc.Service { - public java.lang.String getMuscleWSAddress(); - - public ext.vamsas.MuscleWS getMuscleWS() throws javax.xml.rpc.ServiceException; - - public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) throws javax.xml.rpc.ServiceException; -} +*/ +package ext.vamsas; + +public interface MuscleWSService extends javax.xml.rpc.Service { + public java.lang.String getMuscleWSAddress(); + + public ext.vamsas.MuscleWS getMuscleWS() + throws javax.xml.rpc.ServiceException; + + public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException; +} diff --git a/src/ext/vamsas/MuscleWSServiceLocator.java b/src/ext/vamsas/MuscleWSServiceLocator.java index fd906cd..96ef074 100755 --- a/src/ext/vamsas/MuscleWSServiceLocator.java +++ b/src/ext/vamsas/MuscleWSServiceLocator.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,134 +22,147 @@ * 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 ext.vamsas; - -public class MuscleWSServiceLocator extends org.apache.axis.client.Service implements ext.vamsas.MuscleWSService { - - public MuscleWSServiceLocator() { - } - - - public MuscleWSServiceLocator(org.apache.axis.EngineConfiguration config) { - super(config); - } - - // Use to get a proxy class for MuscleWS - private java.lang.String MuscleWS_address = "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/MuscleWS"; - - public java.lang.String getMuscleWSAddress() { - return MuscleWS_address; - } - - // The WSDD service name defaults to the port name. - private java.lang.String MuscleWSWSDDServiceName = "MuscleWS"; - - public java.lang.String getMuscleWSWSDDServiceName() { - return MuscleWSWSDDServiceName; - } - - public void setMuscleWSWSDDServiceName(java.lang.String name) { - MuscleWSWSDDServiceName = name; - } - - public ext.vamsas.MuscleWS getMuscleWS() throws javax.xml.rpc.ServiceException { - java.net.URL endpoint; - try { - endpoint = new java.net.URL(MuscleWS_address); - } - catch (java.net.MalformedURLException e) { - throw new javax.xml.rpc.ServiceException(e); - } - return getMuscleWS(endpoint); - } - - public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) throws javax.xml.rpc.ServiceException { - try { - ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub(portAddress, this); - _stub.setPortName(getMuscleWSWSDDServiceName()); - return _stub; - } - catch (org.apache.axis.AxisFault e) { - return null; - } - } - - public void setMuscleWSEndpointAddress(java.lang.String address) { - MuscleWS_address = address; - } - +*/ +package ext.vamsas; + +public class MuscleWSServiceLocator extends org.apache.axis.client.Service + implements ext.vamsas.MuscleWSService { + // Use to get a proxy class for MuscleWS + private java.lang.String MuscleWS_address = "http://anaplog.compbio.dundee.ac.uk:8080/axis/services/MuscleWS"; + + // The WSDD service name defaults to the port name. + private java.lang.String MuscleWSWSDDServiceName = "MuscleWS"; + private java.util.HashSet ports = null; + + public MuscleWSServiceLocator() { + } + + public MuscleWSServiceLocator(org.apache.axis.EngineConfiguration config) { + super(config); + } + + public java.lang.String getMuscleWSAddress() { + return MuscleWS_address; + } + + public java.lang.String getMuscleWSWSDDServiceName() { + return MuscleWSWSDDServiceName; + } + + public void setMuscleWSWSDDServiceName(java.lang.String name) { + MuscleWSWSDDServiceName = name; + } + + public ext.vamsas.MuscleWS getMuscleWS() + throws javax.xml.rpc.ServiceException { + java.net.URL endpoint; + + try { + endpoint = new java.net.URL(MuscleWS_address); + } catch (java.net.MalformedURLException e) { + throw new javax.xml.rpc.ServiceException(e); + } + + return getMuscleWS(endpoint); + } + + public ext.vamsas.MuscleWS getMuscleWS(java.net.URL portAddress) + throws javax.xml.rpc.ServiceException { + try { + ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub(portAddress, + this); + _stub.setPortName(getMuscleWSWSDDServiceName()); + + return _stub; + } catch (org.apache.axis.AxisFault e) { + return null; + } + } + + public void setMuscleWSEndpointAddress(java.lang.String address) { + MuscleWS_address = address; + } + /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - try { - if (ext.vamsas.MuscleWS.class.isAssignableFrom(serviceEndpointInterface)) { - ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub(new java.net.URL(MuscleWS_address), this); - _stub.setPortName(getMuscleWSWSDDServiceName()); - return _stub; - } - } - catch (java.lang.Throwable t) { - throw new javax.xml.rpc.ServiceException(t); - } - throw new javax.xml.rpc.ServiceException("There is no stub implementation for the interface: " + (serviceEndpointInterface == null ? "null" : serviceEndpointInterface.getName())); - } - + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(Class serviceEndpointInterface) + throws javax.xml.rpc.ServiceException { + try { + if (ext.vamsas.MuscleWS.class.isAssignableFrom( + serviceEndpointInterface)) { + ext.vamsas.MuscleWSSoapBindingStub _stub = new ext.vamsas.MuscleWSSoapBindingStub(new java.net.URL( + MuscleWS_address), this); + _stub.setPortName(getMuscleWSWSDDServiceName()); + + return _stub; + } + } catch (java.lang.Throwable t) { + throw new javax.xml.rpc.ServiceException(t); + } + + throw new javax.xml.rpc.ServiceException( + "There is no stub implementation for the interface: " + + ((serviceEndpointInterface == null) ? "null" + : serviceEndpointInterface.getName())); + } + /** - * For the given interface, get the stub implementation. - * If this service has no port for the given interface, - * then ServiceException is thrown. - */ - public java.rmi.Remote getPort(javax.xml.namespace.QName portName, Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { - if (portName == null) { - return getPort(serviceEndpointInterface); - } - java.lang.String inputPortName = portName.getLocalPart(); - if ("MuscleWS".equals(inputPortName)) { - return getMuscleWS(); - } - else { - java.rmi.Remote _stub = getPort(serviceEndpointInterface); - ((org.apache.axis.client.Stub) _stub).setPortName(portName); - return _stub; - } - } - - public javax.xml.namespace.QName getServiceName() { - return new javax.xml.namespace.QName("vamsas", "MuscleWSService"); - } - - private java.util.HashSet ports = null; - - public java.util.Iterator getPorts() { - if (ports == null) { - ports = new java.util.HashSet(); - ports.add(new javax.xml.namespace.QName("vamsas", "MuscleWS")); - } - return ports.iterator(); - } - + * For the given interface, get the stub implementation. + * If this service has no port for the given interface, + * then ServiceException is thrown. + */ + public java.rmi.Remote getPort(javax.xml.namespace.QName portName, + Class serviceEndpointInterface) throws javax.xml.rpc.ServiceException { + if (portName == null) { + return getPort(serviceEndpointInterface); + } + + java.lang.String inputPortName = portName.getLocalPart(); + + if ("MuscleWS".equals(inputPortName)) { + return getMuscleWS(); + } else { + java.rmi.Remote _stub = getPort(serviceEndpointInterface); + ((org.apache.axis.client.Stub) _stub).setPortName(portName); + + return _stub; + } + } + + public javax.xml.namespace.QName getServiceName() { + return new javax.xml.namespace.QName("vamsas", "MuscleWSService"); + } + + public java.util.Iterator getPorts() { + if (ports == null) { + ports = new java.util.HashSet(); + ports.add(new javax.xml.namespace.QName("vamsas", "MuscleWS")); + } + + return ports.iterator(); + } + /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(java.lang.String portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - if ("MuscleWS".equals(portName)) { - setMuscleWSEndpointAddress(address); - } - else { // Unknown Port Name - throw new javax.xml.rpc.ServiceException(" Cannot set Endpoint Address for Unknown Port" + portName); - } - } - +* Set the endpoint address for the specified port name. +*/ + public void setEndpointAddress(java.lang.String portName, + java.lang.String address) throws javax.xml.rpc.ServiceException { + if ("MuscleWS".equals(portName)) { + setMuscleWSEndpointAddress(address); + } else { // Unknown Port Name + throw new javax.xml.rpc.ServiceException( + " Cannot set Endpoint Address for Unknown Port" + portName); + } + } + /** - * Set the endpoint address for the specified port name. - */ - public void setEndpointAddress(javax.xml.namespace.QName portName, java.lang.String address) throws javax.xml.rpc.ServiceException { - setEndpointAddress(portName.getLocalPart(), address); - } - -} +* Set the endpoint address for the specified port name. +*/ + public void setEndpointAddress(javax.xml.namespace.QName portName, + java.lang.String address) throws javax.xml.rpc.ServiceException { + setEndpointAddress(portName.getLocalPart(), address); + } +} diff --git a/src/ext/vamsas/MuscleWSSoapBindingStub.java b/src/ext/vamsas/MuscleWSSoapBindingStub.java index b2739bd..35e2470 100755 --- a/src/ext/vamsas/MuscleWSSoapBindingStub.java +++ b/src/ext/vamsas/MuscleWSSoapBindingStub.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,325 +22,373 @@ * 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 ext.vamsas; - -public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub implements ext.vamsas.MuscleWS { - private java.util.Vector cachedSerClasses = new java.util.Vector(); - private java.util.Vector cachedSerQNames = new java.util.Vector(); - private java.util.Vector cachedSerFactories = new java.util.Vector(); - private java.util.Vector cachedDeserFactories = new java.util.Vector(); - - static org.apache.axis.description.OperationDesc [] _operations; - - static { - _operations = new org.apache.axis.description.OperationDesc[4]; - _initOperationDesc1(); - } - - private static void _initOperationDesc1(){ - org.apache.axis.description.OperationDesc oper; - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("align"); - oper.addParameter(new javax.xml.namespace.QName("", "seqSet"), new javax.xml.namespace.QName("simple.objects.vamsas", "SequenceSet"), vamsas.objects.simple.SequenceSet.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "alignReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[0] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getalign"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "Alignment")); - oper.setReturnClass(vamsas.objects.simple.Alignment.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getalignReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[1] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("getResult"); - oper.addParameter(new javax.xml.namespace.QName("", "job_id"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "MsaResult")); - oper.setReturnClass(vamsas.objects.simple.MsaResult.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "getResultReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[2] = oper; - - oper = new org.apache.axis.description.OperationDesc(); - oper.setName("cancel"); - oper.addParameter(new javax.xml.namespace.QName("", "jobId"), new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"), java.lang.String.class, org.apache.axis.description.ParameterDesc.IN, false, false); - oper.setReturnType(new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId")); - oper.setReturnClass(vamsas.objects.simple.WsJobId.class); - oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); - oper.setStyle(org.apache.axis.constants.Style.RPC); - oper.setUse(org.apache.axis.constants.Use.ENCODED); - _operations[3] = oper; - - } - - public MuscleWSSoapBindingStub() throws org.apache.axis.AxisFault { - this(null); - } - - public MuscleWSSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - this(service); - super.cachedEndpoint = endpointURL; - } - - public MuscleWSSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { - if (service == null) { - super.service = new org.apache.axis.client.Service(); - } else { - super.service = service; - } - java.lang.Class cls; - javax.xml.namespace.QName qName; - java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; - java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; - java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; - java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; - java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; - java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; - java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; - java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; - java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; - java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Sequence[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "MsaResult"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.MsaResult.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "SequenceSet"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.SequenceSet.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", "Object"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Object.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Alignment"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Alignment.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.WsJobId.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); - cachedSerQNames.add(qName); - cls = java.lang.String[].class; - cachedSerClasses.add(cls); - cachedSerFactories.add(arraysf); - cachedDeserFactories.add(arraydf); - - qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); - cachedSerQNames.add(qName); - cls = vamsas.objects.simple.Result.class; - cachedSerClasses.add(cls); - cachedSerFactories.add(beansf); - cachedDeserFactories.add(beandf); - - } - - protected org.apache.axis.client.Call createCall() throws java.rmi.RemoteException { - try { - org.apache.axis.client.Call _call = - (org.apache.axis.client.Call) super.service.createCall(); - if (super.maintainSessionSet) { - _call.setMaintainSession(super.maintainSession); - } - if (super.cachedUsername != null) { - _call.setUsername(super.cachedUsername); - } - if (super.cachedPassword != null) { - _call.setPassword(super.cachedPassword); - } - if (super.cachedEndpoint != null) { - _call.setTargetEndpointAddress(super.cachedEndpoint); - } - if (super.cachedTimeout != null) { - _call.setTimeout(super.cachedTimeout); - } - if (super.cachedPortName != null) { - _call.setPortName(super.cachedPortName); - } - java.util.Enumeration keys = super.cachedProperties.keys(); - while (keys.hasMoreElements()) { - java.lang.String key = (java.lang.String) keys.nextElement(); - _call.setProperty(key, super.cachedProperties.get(key)); - } - // All the type mapping information is registered - // when the first call is made. - // The type mapping information is actually registered in - // the TypeMappingRegistry of the service, which - // is the reason why registration is only needed for the first call. - synchronized (this) { - if (firstCall()) { - // must set encoding style before registering serializers - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); - for (int i = 0; i < cachedSerFactories.size(); ++i) { - java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); - javax.xml.namespace.QName qName = - (javax.xml.namespace.QName) cachedSerQNames.get(i); - java.lang.Class sf = (java.lang.Class) - cachedSerFactories.get(i); - java.lang.Class df = (java.lang.Class) - cachedDeserFactories.get(i); - _call.registerTypeMapping(cls, qName, sf, df, false); - } - } - } - return _call; - } - catch (java.lang.Throwable _t) { - throw new org.apache.axis.AxisFault("Failure trying to get the Call object", _t); - } - } - - public vamsas.objects.simple.WsJobId align(vamsas.objects.simple.SequenceSet seqSet) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[0]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "align")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {seqSet}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } - } - - public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[1]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getalign")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {job_id}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.Alignment) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.Alignment) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.Alignment.class); - } - } - } - - public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[2]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "getResult")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {job_id}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.MsaResult) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.MsaResult) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.MsaResult.class); - } - } - } - - public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) throws java.rmi.RemoteException { - if (super.cachedEndpoint == null) { - throw new org.apache.axis.NoEndPointException(); - } - org.apache.axis.client.Call _call = createCall(); - _call.setOperation(_operations[3]); - _call.setUseSOAPAction(true); - _call.setSOAPActionURI(""); - _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); - _call.setOperationName(new javax.xml.namespace.QName("vamsas", "cancel")); - - setRequestHeaders(_call); - setAttachments(_call); - java.lang.Object _resp = _call.invoke(new java.lang.Object[] {jobId}); - - if (_resp instanceof java.rmi.RemoteException) { - throw (java.rmi.RemoteException)_resp; - } - else { - extractAttachments(_call); - try { - return (vamsas.objects.simple.WsJobId) _resp; - } catch (java.lang.Exception _exception) { - return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, vamsas.objects.simple.WsJobId.class); - } - } - } - -} +*/ +package ext.vamsas; + +public class MuscleWSSoapBindingStub extends org.apache.axis.client.Stub + implements ext.vamsas.MuscleWS { + static org.apache.axis.description.OperationDesc[] _operations; + + static { + _operations = new org.apache.axis.description.OperationDesc[4]; + _initOperationDesc1(); + } + + private java.util.Vector cachedSerClasses = new java.util.Vector(); + private java.util.Vector cachedSerQNames = new java.util.Vector(); + private java.util.Vector cachedSerFactories = new java.util.Vector(); + private java.util.Vector cachedDeserFactories = new java.util.Vector(); + + public MuscleWSSoapBindingStub() throws org.apache.axis.AxisFault { + this(null); + } + + public MuscleWSSoapBindingStub(java.net.URL endpointURL, + javax.xml.rpc.Service service) throws org.apache.axis.AxisFault { + this(service); + super.cachedEndpoint = endpointURL; + } + + public MuscleWSSoapBindingStub(javax.xml.rpc.Service service) + throws org.apache.axis.AxisFault { + if (service == null) { + super.service = new org.apache.axis.client.Service(); + } else { + super.service = service; + } + + java.lang.Class cls; + javax.xml.namespace.QName qName; + java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class; + java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class; + java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class; + java.lang.Class enumdf = org.apache.axis.encoding.ser.EnumDeserializerFactory.class; + java.lang.Class arraysf = org.apache.axis.encoding.ser.ArraySerializerFactory.class; + java.lang.Class arraydf = org.apache.axis.encoding.ser.ArrayDeserializerFactory.class; + java.lang.Class simplesf = org.apache.axis.encoding.ser.SimpleSerializerFactory.class; + java.lang.Class simpledf = org.apache.axis.encoding.ser.SimpleDeserializerFactory.class; + java.lang.Class simplelistsf = org.apache.axis.encoding.ser.SimpleListSerializerFactory.class; + java.lang.Class simplelistdf = org.apache.axis.encoding.ser.SimpleListDeserializerFactory.class; + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_tns1_Sequence"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Sequence[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "MsaResult"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.MsaResult.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "SequenceSet"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.SequenceSet.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("http://simple.objects.vamsas", + "Object"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Object.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", + "Alignment"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Alignment.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "WsJobId"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.WsJobId.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + + qName = new javax.xml.namespace.QName("vamsas", "ArrayOf_xsd_string"); + cachedSerQNames.add(qName); + cls = java.lang.String[].class; + cachedSerClasses.add(cls); + cachedSerFactories.add(arraysf); + cachedDeserFactories.add(arraydf); + + qName = new javax.xml.namespace.QName("simple.objects.vamsas", "Result"); + cachedSerQNames.add(qName); + cls = vamsas.objects.simple.Result.class; + cachedSerClasses.add(cls); + cachedSerFactories.add(beansf); + cachedDeserFactories.add(beandf); + } + + private static void _initOperationDesc1() { + org.apache.axis.description.OperationDesc oper; + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("align"); + oper.addParameter(new javax.xml.namespace.QName("", "seqSet"), + new javax.xml.namespace.QName("simple.objects.vamsas", "SequenceSet"), + vamsas.objects.simple.SequenceSet.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "alignReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[0] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getalign"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "Alignment")); + oper.setReturnClass(vamsas.objects.simple.Alignment.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getalignReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[1] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("getResult"); + oper.addParameter(new javax.xml.namespace.QName("", "job_id"), + new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "MsaResult")); + oper.setReturnClass(vamsas.objects.simple.MsaResult.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "getResultReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[2] = oper; + + oper = new org.apache.axis.description.OperationDesc(); + oper.setName("cancel"); + oper.addParameter(new javax.xml.namespace.QName("", "jobId"), + new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", + "string"), java.lang.String.class, + org.apache.axis.description.ParameterDesc.IN, false, false); + oper.setReturnType(new javax.xml.namespace.QName( + "simple.objects.vamsas", "WsJobId")); + oper.setReturnClass(vamsas.objects.simple.WsJobId.class); + oper.setReturnQName(new javax.xml.namespace.QName("", "cancelReturn")); + oper.setStyle(org.apache.axis.constants.Style.RPC); + oper.setUse(org.apache.axis.constants.Use.ENCODED); + _operations[3] = oper; + } + + protected org.apache.axis.client.Call createCall() + throws java.rmi.RemoteException { + try { + org.apache.axis.client.Call _call = (org.apache.axis.client.Call) super.service.createCall(); + + if (super.maintainSessionSet) { + _call.setMaintainSession(super.maintainSession); + } + + if (super.cachedUsername != null) { + _call.setUsername(super.cachedUsername); + } + + if (super.cachedPassword != null) { + _call.setPassword(super.cachedPassword); + } + + if (super.cachedEndpoint != null) { + _call.setTargetEndpointAddress(super.cachedEndpoint); + } + + if (super.cachedTimeout != null) { + _call.setTimeout(super.cachedTimeout); + } + + if (super.cachedPortName != null) { + _call.setPortName(super.cachedPortName); + } + + java.util.Enumeration keys = super.cachedProperties.keys(); + + while (keys.hasMoreElements()) { + java.lang.String key = (java.lang.String) keys.nextElement(); + _call.setProperty(key, super.cachedProperties.get(key)); + } + + // All the type mapping information is registered + // when the first call is made. + // The type mapping information is actually registered in + // the TypeMappingRegistry of the service, which + // is the reason why registration is only needed for the first call. + synchronized (this) { + if (firstCall()) { + // must set encoding style before registering serializers + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC); + + for (int i = 0; i < cachedSerFactories.size(); ++i) { + java.lang.Class cls = (java.lang.Class) cachedSerClasses.get(i); + javax.xml.namespace.QName qName = (javax.xml.namespace.QName) cachedSerQNames.get(i); + java.lang.Class sf = (java.lang.Class) cachedSerFactories.get(i); + java.lang.Class df = (java.lang.Class) cachedDeserFactories.get(i); + _call.registerTypeMapping(cls, qName, sf, df, false); + } + } + } + + return _call; + } catch (java.lang.Throwable _t) { + throw new org.apache.axis.AxisFault("Failure trying to get the Call object", + _t); + } + } + + public vamsas.objects.simple.WsJobId align( + vamsas.objects.simple.SequenceSet seqSet) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[0]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "align")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { seqSet }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, + vamsas.objects.simple.WsJobId.class); + } + } + } + + public vamsas.objects.simple.Alignment getalign(java.lang.String job_id) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[1]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getalign")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { job_id }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (vamsas.objects.simple.Alignment) _resp; + } catch (java.lang.Exception _exception) { + return (vamsas.objects.simple.Alignment) org.apache.axis.utils.JavaUtils.convert(_resp, + vamsas.objects.simple.Alignment.class); + } + } + } + + public vamsas.objects.simple.MsaResult getResult(java.lang.String job_id) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[2]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", + "getResult")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { job_id }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (vamsas.objects.simple.MsaResult) _resp; + } catch (java.lang.Exception _exception) { + return (vamsas.objects.simple.MsaResult) org.apache.axis.utils.JavaUtils.convert(_resp, + vamsas.objects.simple.MsaResult.class); + } + } + } + + public vamsas.objects.simple.WsJobId cancel(java.lang.String jobId) + throws java.rmi.RemoteException { + if (super.cachedEndpoint == null) { + throw new org.apache.axis.NoEndPointException(); + } + + org.apache.axis.client.Call _call = createCall(); + _call.setOperation(_operations[3]); + _call.setUseSOAPAction(true); + _call.setSOAPActionURI(""); + _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS); + _call.setOperationName(new javax.xml.namespace.QName("vamsas", "cancel")); + + setRequestHeaders(_call); + setAttachments(_call); + + java.lang.Object _resp = _call.invoke(new java.lang.Object[] { jobId }); + + if (_resp instanceof java.rmi.RemoteException) { + throw (java.rmi.RemoteException) _resp; + } else { + extractAttachments(_call); + + try { + return (vamsas.objects.simple.WsJobId) _resp; + } catch (java.lang.Exception _exception) { + return (vamsas.objects.simple.WsJobId) org.apache.axis.utils.JavaUtils.convert(_resp, + vamsas.objects.simple.WsJobId.class); + } + } + } +} diff --git a/src/ext/vamsas/Result.java b/src/ext/vamsas/Result.java index 97d766b..3115fd1 100755 --- a/src/ext/vamsas/Result.java +++ b/src/ext/vamsas/Result.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,416 +22,420 @@ * 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 ext.vamsas; - -public class Result implements java.io.Serializable { - private boolean broken; - private boolean failed; - private boolean finished; - private boolean invalid; - private boolean jobFailed; - private boolean queued; - private boolean running; - private boolean serverError; - private int state; - private java.lang.String status; - private boolean suspended; - - public Result() { - } - - public Result( - boolean broken, - boolean failed, - boolean finished, - boolean invalid, - boolean jobFailed, - boolean queued, - boolean running, - boolean serverError, - int state, - java.lang.String status, - boolean suspended) { - this.broken = broken; - this.failed = failed; - this.finished = finished; - this.invalid = invalid; - this.jobFailed = jobFailed; - this.queued = queued; - this.running = running; - this.serverError = serverError; - this.state = state; - this.status = status; - this.suspended = suspended; - } - - +*/ +package ext.vamsas; + +public class Result implements java.io.Serializable { + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(Result.class, + true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "Result")); + + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("broken"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "broken")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("failed"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "failed")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("finished"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "finished")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("invalid"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "invalid")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("jobFailed"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "jobFailed")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("queued"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "queued")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("running"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "running")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("serverError"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "serverError")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("state"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "state")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "int")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("status"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "status")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("suspended"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "suspended")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "boolean")); + typeDesc.addFieldDesc(elemField); + } + + private boolean broken; + private boolean failed; + private boolean finished; + private boolean invalid; + private boolean jobFailed; + private boolean queued; + private boolean running; + private boolean serverError; + private int state; + private java.lang.String status; + private boolean suspended; + private java.lang.Object __equalsCalc = null; + private boolean __hashCodeCalc = false; + + public Result() { + } + + public Result(boolean broken, boolean failed, boolean finished, + boolean invalid, boolean jobFailed, boolean queued, boolean running, + boolean serverError, int state, java.lang.String status, + boolean suspended) { + this.broken = broken; + this.failed = failed; + this.finished = finished; + this.invalid = invalid; + this.jobFailed = jobFailed; + this.queued = queued; + this.running = running; + this.serverError = serverError; + this.state = state; + this.status = status; + this.suspended = suspended; + } + /** - * Gets the broken value for this Result. - * - * @return broken - */ - public boolean isBroken() { - return broken; - } - - + * Gets the broken value for this Result. + * + * @return broken + */ + public boolean isBroken() { + return broken; + } + /** - * Sets the broken value for this Result. - * - * @param broken - */ - public void setBroken(boolean broken) { - this.broken = broken; - } - - + * Sets the broken value for this Result. + * + * @param broken + */ + public void setBroken(boolean broken) { + this.broken = broken; + } + /** - * Gets the failed value for this Result. - * - * @return failed - */ - public boolean isFailed() { - return failed; - } - - + * Gets the failed value for this Result. + * + * @return failed + */ + public boolean isFailed() { + return failed; + } + /** - * Sets the failed value for this Result. - * - * @param failed - */ - public void setFailed(boolean failed) { - this.failed = failed; - } - - + * Sets the failed value for this Result. + * + * @param failed + */ + public void setFailed(boolean failed) { + this.failed = failed; + } + /** - * Gets the finished value for this Result. - * - * @return finished - */ - public boolean isFinished() { - return finished; - } - - + * Gets the finished value for this Result. + * + * @return finished + */ + public boolean isFinished() { + return finished; + } + /** - * Sets the finished value for this Result. - * - * @param finished - */ - public void setFinished(boolean finished) { - this.finished = finished; - } - - + * Sets the finished value for this Result. + * + * @param finished + */ + public void setFinished(boolean finished) { + this.finished = finished; + } + /** - * Gets the invalid value for this Result. - * - * @return invalid - */ - public boolean isInvalid() { - return invalid; - } - - + * Gets the invalid value for this Result. + * + * @return invalid + */ + public boolean isInvalid() { + return invalid; + } + /** - * Sets the invalid value for this Result. - * - * @param invalid - */ - public void setInvalid(boolean invalid) { - this.invalid = invalid; - } - - + * Sets the invalid value for this Result. + * + * @param invalid + */ + public void setInvalid(boolean invalid) { + this.invalid = invalid; + } + /** - * Gets the jobFailed value for this Result. - * - * @return jobFailed - */ - public boolean isJobFailed() { - return jobFailed; - } - - + * Gets the jobFailed value for this Result. + * + * @return jobFailed + */ + public boolean isJobFailed() { + return jobFailed; + } + /** - * Sets the jobFailed value for this Result. - * - * @param jobFailed - */ - public void setJobFailed(boolean jobFailed) { - this.jobFailed = jobFailed; - } - - + * Sets the jobFailed value for this Result. + * + * @param jobFailed + */ + public void setJobFailed(boolean jobFailed) { + this.jobFailed = jobFailed; + } + /** - * Gets the queued value for this Result. - * - * @return queued - */ - public boolean isQueued() { - return queued; - } - - + * Gets the queued value for this Result. + * + * @return queued + */ + public boolean isQueued() { + return queued; + } + /** - * Sets the queued value for this Result. - * - * @param queued - */ - public void setQueued(boolean queued) { - this.queued = queued; - } - - + * Sets the queued value for this Result. + * + * @param queued + */ + public void setQueued(boolean queued) { + this.queued = queued; + } + /** - * Gets the running value for this Result. - * - * @return running - */ - public boolean isRunning() { - return running; - } - - + * Gets the running value for this Result. + * + * @return running + */ + public boolean isRunning() { + return running; + } + /** - * Sets the running value for this Result. - * - * @param running - */ - public void setRunning(boolean running) { - this.running = running; - } - - + * Sets the running value for this Result. + * + * @param running + */ + public void setRunning(boolean running) { + this.running = running; + } + /** - * Gets the serverError value for this Result. - * - * @return serverError - */ - public boolean isServerError() { - return serverError; - } - - + * Gets the serverError value for this Result. + * + * @return serverError + */ + public boolean isServerError() { + return serverError; + } + /** - * Sets the serverError value for this Result. - * - * @param serverError - */ - public void setServerError(boolean serverError) { - this.serverError = serverError; - } - - + * Sets the serverError value for this Result. + * + * @param serverError + */ + public void setServerError(boolean serverError) { + this.serverError = serverError; + } + /** - * Gets the state value for this Result. - * - * @return state - */ - public int getState() { - return state; - } - - + * Gets the state value for this Result. + * + * @return state + */ + public int getState() { + return state; + } + /** - * Sets the state value for this Result. - * - * @param state - */ - public void setState(int state) { - this.state = state; - } - - + * Sets the state value for this Result. + * + * @param state + */ + public void setState(int state) { + this.state = state; + } + /** - * Gets the status value for this Result. - * - * @return status - */ - public java.lang.String getStatus() { - return status; - } - - + * Gets the status value for this Result. + * + * @return status + */ + public java.lang.String getStatus() { + return status; + } + /** - * Sets the status value for this Result. - * - * @param status - */ - public void setStatus(java.lang.String status) { - this.status = status; - } - - + * Sets the status value for this Result. + * + * @param status + */ + public void setStatus(java.lang.String status) { + this.status = status; + } + /** - * Gets the suspended value for this Result. - * - * @return suspended - */ - public boolean isSuspended() { - return suspended; - } - - + * Gets the suspended value for this Result. + * + * @return suspended + */ + public boolean isSuspended() { + return suspended; + } + /** - * Sets the suspended value for this Result. - * - * @param suspended - */ - public void setSuspended(boolean suspended) { - this.suspended = suspended; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof Result)) return false; - Result other = (Result) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = true && - this.broken == other.isBroken() && - this.failed == other.isFailed() && - this.finished == other.isFinished() && - this.invalid == other.isInvalid() && - this.jobFailed == other.isJobFailed() && - this.queued == other.isQueued() && - this.running == other.isRunning() && - this.serverError == other.isServerError() && - this.state == other.getState() && - ((this.status==null && other.getStatus()==null) || - (this.status!=null && - this.status.equals(other.getStatus()))) && - this.suspended == other.isSuspended(); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = 1; - _hashCode += (isBroken() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isFailed() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isFinished() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isInvalid() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isJobFailed() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isQueued() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isRunning() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += (isServerError() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - _hashCode += getState(); - if (getStatus() != null) { - _hashCode += getStatus().hashCode(); - } - _hashCode += (isSuspended() ? Boolean.TRUE : Boolean.FALSE).hashCode(); - __hashCodeCalc = false; - return _hashCode; - } - - // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(Result.class, true); - - static { - typeDesc.setXmlType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "Result")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("broken"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "broken")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("failed"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "failed")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("finished"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "finished")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("invalid"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "invalid")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("jobFailed"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "jobFailed")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("queued"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "queued")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("running"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "running")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("serverError"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "serverError")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("state"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "state")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("status"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "status")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("suspended"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "suspended")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "boolean")); - typeDesc.addFieldDesc(elemField); - } - + * Sets the suspended value for this Result. + * + * @param suspended + */ + public void setSuspended(boolean suspended) { + this.suspended = suspended; + } + + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof Result)) { + return false; + } + + Result other = (Result) obj; + + if (obj == null) { + return false; + } + + if (this == obj) { + return true; + } + + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + + __equalsCalc = obj; + + boolean _equals; + _equals = true && (this.broken == other.isBroken()) && + (this.failed == other.isFailed()) && + (this.finished == other.isFinished()) && + (this.invalid == other.isInvalid()) && + (this.jobFailed == other.isJobFailed()) && + (this.queued == other.isQueued()) && + (this.running == other.isRunning()) && + (this.serverError == other.isServerError()) && + (this.state == other.getState()) && + (((this.status == null) && (other.getStatus() == null)) || + ((this.status != null) && this.status.equals(other.getStatus()))) && + (this.suspended == other.isSuspended()); + __equalsCalc = null; + + return _equals; + } + + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + + __hashCodeCalc = true; + + int _hashCode = 1; + _hashCode += (isBroken() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isFailed() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isFinished() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isInvalid() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isJobFailed() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isQueued() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isRunning() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += (isServerError() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + _hashCode += getState(); + + if (getStatus() != null) { + _hashCode += getStatus().hashCode(); + } + + _hashCode += (isSuspended() ? Boolean.TRUE : Boolean.FALSE).hashCode(); + __hashCodeCalc = false; + + return _hashCode; + } + /** - * Return type metadata object - */ - public static org.apache.axis.description.TypeDesc getTypeDesc() { - return typeDesc; - } - + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + /** - * Get Custom Serializer - */ - public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); - } - + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); + } + /** - * Get Custom Deserializer - */ - public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); - } - -} + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); + } +} diff --git a/src/ext/vamsas/Secstructpred.java b/src/ext/vamsas/Secstructpred.java index 290ac3c..d1da9be 100755 --- a/src/ext/vamsas/Secstructpred.java +++ b/src/ext/vamsas/Secstructpred.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,116 +22,128 @@ * 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 ext.vamsas; - -public class Secstructpred implements java.io.Serializable { - private java.lang.String output; - - public Secstructpred() { - } - - public Secstructpred( - java.lang.String output) { - this.output = output; - } - - +*/ +package ext.vamsas; + +public class Secstructpred implements java.io.Serializable { + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(Secstructpred.class, + true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "Secstructpred")); + + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("output"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "output")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + } + + private java.lang.String output; + private java.lang.Object __equalsCalc = null; + private boolean __hashCodeCalc = false; + + public Secstructpred() { + } + + public Secstructpred(java.lang.String output) { + this.output = output; + } + /** - * Gets the output value for this Secstructpred. - * - * @return output - */ - public java.lang.String getOutput() { - return output; - } - - + * Gets the output value for this Secstructpred. + * + * @return output + */ + public java.lang.String getOutput() { + return output; + } + /** - * Sets the output value for this Secstructpred. - * - * @param output - */ - public void setOutput(java.lang.String output) { - this.output = output; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof Secstructpred)) return false; - Secstructpred other = (Secstructpred) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = true && - ((this.output==null && other.getOutput()==null) || - (this.output!=null && - this.output.equals(other.getOutput()))); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = 1; - if (getOutput() != null) { - _hashCode += getOutput().hashCode(); - } - __hashCodeCalc = false; - return _hashCode; - } - - // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(Secstructpred.class, true); - - static { - typeDesc.setXmlType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "Secstructpred")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("output"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "output")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - } - + * Sets the output value for this Secstructpred. + * + * @param output + */ + public void setOutput(java.lang.String output) { + this.output = output; + } + + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof Secstructpred)) { + return false; + } + + Secstructpred other = (Secstructpred) obj; + + if (obj == null) { + return false; + } + + if (this == obj) { + return true; + } + + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + + __equalsCalc = obj; + + boolean _equals; + _equals = true && + (((this.output == null) && (other.getOutput() == null)) || + ((this.output != null) && this.output.equals(other.getOutput()))); + __equalsCalc = null; + + return _equals; + } + + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + + __hashCodeCalc = true; + + int _hashCode = 1; + + if (getOutput() != null) { + _hashCode += getOutput().hashCode(); + } + + __hashCodeCalc = false; + + return _hashCode; + } + /** - * Return type metadata object - */ - public static org.apache.axis.description.TypeDesc getTypeDesc() { - return typeDesc; - } - + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + /** - * Get Custom Serializer - */ - public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); - } - + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); + } + /** - * Get Custom Deserializer - */ - public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); - } - -} + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); + } +} diff --git a/src/ext/vamsas/Sequence.java b/src/ext/vamsas/Sequence.java index c2b9da8..4d73bcf 100755 --- a/src/ext/vamsas/Sequence.java +++ b/src/ext/vamsas/Sequence.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,150 +22,161 @@ * 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 ext.vamsas; - -public class Sequence implements java.io.Serializable { - private java.lang.String id; - private java.lang.String seq; - - public Sequence() { - } - - public Sequence( - java.lang.String id, - java.lang.String seq) { - this.id = id; - this.seq = seq; - } - - +*/ +package ext.vamsas; + +public class Sequence implements java.io.Serializable { + // Type metadata + private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(Sequence.class, + true); + + static { + typeDesc.setXmlType(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "Sequence")); + + org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("id"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "id")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("seq"); + elemField.setXmlName(new javax.xml.namespace.QName( + "http://dataTypes.vamsas", "seq")); + elemField.setXmlType(new javax.xml.namespace.QName( + "http://www.w3.org/2001/XMLSchema", "string")); + typeDesc.addFieldDesc(elemField); + } + + private java.lang.String id; + private java.lang.String seq; + private java.lang.Object __equalsCalc = null; + private boolean __hashCodeCalc = false; + + public Sequence() { + } + + public Sequence(java.lang.String id, java.lang.String seq) { + this.id = id; + this.seq = seq; + } + /** - * Gets the id value for this Sequence. - * - * @return id - */ - public java.lang.String getId() { - return id; - } - - + * Gets the id value for this Sequence. + * + * @return id + */ + public java.lang.String getId() { + return id; + } + /** - * Sets the id value for this Sequence. - * - * @param id - */ - public void setId(java.lang.String id) { - this.id = id; - } - - + * Sets the id value for this Sequence. + * + * @param id + */ + public void setId(java.lang.String id) { + this.id = id; + } + /** - * Gets the seq value for this Sequence. - * - * @return seq - */ - public java.lang.String getSeq() { - return seq; - } - - + * Gets the seq value for this Sequence. + * + * @return seq + */ + public java.lang.String getSeq() { + return seq; + } + /** - * Sets the seq value for this Sequence. - * - * @param seq - */ - public void setSeq(java.lang.String seq) { - this.seq = seq; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof Sequence)) return false; - Sequence other = (Sequence) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = true && - ((this.id==null && other.getId()==null) || - (this.id!=null && - this.id.equals(other.getId()))) && - ((this.seq==null && other.getSeq()==null) || - (this.seq!=null && - this.seq.equals(other.getSeq()))); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = 1; - if (getId() != null) { - _hashCode += getId().hashCode(); - } - if (getSeq() != null) { - _hashCode += getSeq().hashCode(); - } - __hashCodeCalc = false; - return _hashCode; - } - - // Type metadata - private static org.apache.axis.description.TypeDesc typeDesc = - new org.apache.axis.description.TypeDesc(Sequence.class, true); - - static { - typeDesc.setXmlType(new javax.xml.namespace.QName("http://dataTypes.vamsas", "Sequence")); - org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("id"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "id")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - elemField = new org.apache.axis.description.ElementDesc(); - elemField.setFieldName("seq"); - elemField.setXmlName(new javax.xml.namespace.QName("http://dataTypes.vamsas", "seq")); - elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); - typeDesc.addFieldDesc(elemField); - } - + * Sets the seq value for this Sequence. + * + * @param seq + */ + public void setSeq(java.lang.String seq) { + this.seq = seq; + } + + public synchronized boolean equals(java.lang.Object obj) { + if (!(obj instanceof Sequence)) { + return false; + } + + Sequence other = (Sequence) obj; + + if (obj == null) { + return false; + } + + if (this == obj) { + return true; + } + + if (__equalsCalc != null) { + return (__equalsCalc == obj); + } + + __equalsCalc = obj; + + boolean _equals; + _equals = true && + (((this.id == null) && (other.getId() == null)) || + ((this.id != null) && this.id.equals(other.getId()))) && + (((this.seq == null) && (other.getSeq() == null)) || + ((this.seq != null) && this.seq.equals(other.getSeq()))); + __equalsCalc = null; + + return _equals; + } + + public synchronized int hashCode() { + if (__hashCodeCalc) { + return 0; + } + + __hashCodeCalc = true; + + int _hashCode = 1; + + if (getId() != null) { + _hashCode += getId().hashCode(); + } + + if (getSeq() != null) { + _hashCode += getSeq().hashCode(); + } + + __hashCodeCalc = false; + + return _hashCode; + } + /** - * Return type metadata object - */ - public static org.apache.axis.description.TypeDesc getTypeDesc() { - return typeDesc; - } - + * Return type metadata object + */ + public static org.apache.axis.description.TypeDesc getTypeDesc() { + return typeDesc; + } + /** - * Get Custom Serializer - */ - public static org.apache.axis.encoding.Serializer getSerializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanSerializer( - _javaType, _xmlType, typeDesc); - } - + * Get Custom Serializer + */ + public static org.apache.axis.encoding.Serializer getSerializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanSerializer(_javaType, + _xmlType, typeDesc); + } + /** - * Get Custom Deserializer - */ - public static org.apache.axis.encoding.Deserializer getDeserializer( - java.lang.String mechType, - java.lang.Class _javaType, - javax.xml.namespace.QName _xmlType) { - return - new org.apache.axis.encoding.ser.BeanDeserializer( - _javaType, _xmlType, typeDesc); - } - -} + * Get Custom Deserializer + */ + public static org.apache.axis.encoding.Deserializer getDeserializer( + java.lang.String mechType, java.lang.Class _javaType, + javax.xml.namespace.QName _xmlType) { + return new org.apache.axis.encoding.ser.BeanDeserializer(_javaType, + _xmlType, typeDesc); + } +} diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index 02569ef..41c6599 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -16,397 +16,374 @@ * 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.jbgui.*; +import jalview.analysis.*; + import jalview.datamodel.*; + import jalview.io.*; -import jalview.analysis.*; -import java.awt.*; +import jalview.jbgui.*; + import java.applet.Applet; -import java.util.*; -import java.net.*; + +import java.awt.*; + import java.io.*; -public class AAFrequency { +import java.net.*; +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) { + Vector result = new Vector(); + + 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) { + Sequence s = (Sequence) sequences.elementAt(j); + + if (s.getSequence().length() > i) { + String res = s.getSequence().charAt(i) + ""; + + if (!jalview.util.Comparison.isGap(res.charAt(0))) { + nongap++; + } else { + res = "-"; // we always use this for gaps in the property vectors + } + + 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) { + maxResidue = res; + } else if (maxResidue.indexOf(res) == -1) { + maxResidue += res; + } + + maxCount = count; + } + + residueHash.put(res, new Integer(count)); + } else { + residueHash.put(res, new Integer(1)); + } + } else { + if (residueHash.containsKey("-")) { + int count = ((Integer) residueHash.get("-")).intValue(); + count++; + residueHash.put("-", new Integer(count)); + } else { + residueHash.put("-", new Integer(1)); + } + } + } + } + residueHash.put("maxCount", new Integer(maxCount)); - public static Vector calculate(Vector sequences,int start,int end) { - - Vector result = new Vector(); - - 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) - { - Sequence s = (Sequence)sequences.elementAt(j); - - if (s.getSequence().length() > i) - { - - String res = s.getSequence().charAt(i)+""; - - if (!jalview.util.Comparison.isGap(res.charAt(0))) - nongap++; - else - res = "-"; // we always use this for gaps in the property vectors - - 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) - maxResidue = res; - else if(maxResidue.indexOf(res)==-1) - maxResidue += res; - - maxCount = count; - } - - residueHash.put(res,new Integer(count)); + if (maxCount < 0) { + System.out.println("asasa " + maxCount); } - else - residueHash.put(res,new Integer(1)); - - - } - else - { - if (residueHash.containsKey("-")) - { - int count = ((Integer)residueHash.get("-")).intValue() ; - count++; - residueHash.put("-",new Integer(count)); - } - else - residueHash.put("-",new Integer(1)); - } + residueHash.put("maxResidue", maxResidue); + residueHash.put("size", new Integer(sequences.size())); + residueHash.put("nongap", new Integer(nongap)); + result.addElement(residueHash); } - } - - residueHash.put("maxCount",new Integer(maxCount)); - if(maxCount<0) - System.out.println("asasa "+maxCount); - residueHash.put("maxResidue", maxResidue); - residueHash.put("size", new Integer(sequences.size())); - residueHash.put("nongap", new Integer(nongap)); - result.addElement(residueHash); - } - - 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(); + return result; + } - result.addElement(values); + public static Vector calculatePID(SequenceI refseq, Vector sequences, + int window, int start, int end) { + Vector result = new Vector(); - // If start < window/2 then set value to zero. + boolean init = true; - 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; + Vector prev = null; - int winstart = i-window/2; - int winend = i+window/2; + for (int i = start; i <= end; i++) { + Vector values = new Vector(); - if (window%2 != 0) { - winend++; - } + result.addElement(values); - 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++) { + // 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; - Sequence s = (Sequence)sequences.elementAt(j); + int winstart = i - (window / 2); + int winend = i + (window / 2); - if (s.getSequence().length() > k) { + if ((window % 2) != 0) { + winend++; + } - String res = s.getSequence().substring(k,k+1); // no gapchar test needed + for (int j = 0; j < sequences.size(); j++) { + values.addElement(new Integer(0)); + } - if (res.equals(refchar)) { - int val = ((Integer)values.elementAt(j)).intValue(); - val++; - values.setElementAt(new Integer(val),j); - } + 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; + 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); + if ((window % 2) != 0) { + winend++; } - // 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)); + // 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); + } - } - prev = values; - } - } + for (int j = 0; j < sequences.size(); j++) { + // First copy the pid value from i-1 + int val = ((Integer) prev.elementAt(j)).intValue(); - return result; - } + Sequence s = (Sequence) sequences.elementAt(j); - public static Hashtable findBlocks(Vector seqs, int start, int end,Vector exc) { + String pre_char = s.getSequence().substring(winstart - 1, + winstart); - // start and end are in real (not relative coords); + String pos_char = "-"; - // The coords in the hashtable that is returned are in relative coords - // i.e. start from 0 + if (s.getSequence().length() > winend) { + pos_char = s.getSequence().substring(winend, winend + + 1); + } - Hashtable blocks = new Hashtable(); + // 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--; + } - boolean prev = false; - int bstart = -1; + if ((jalview.util.Comparison.isGap(pos_refchar.charAt(0)) == false) && + pos_char.equals(pos_refchar)) { + val++; + } - for (int i = start; i <= end ; i++) { - SequenceI seq = (SequenceI)seqs.elementAt(0); + values.addElement(new Integer(val)); + } - char c = seq.getCharAt(i); + prev = values; + } + } - boolean found = true; + return result; + } - int j = 1; + 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(); - while (j < seqs.size() && found == true) { + boolean prev = false; + int bstart = -1; - SequenceI jseq = (SequenceI)seqs.elementAt(j); + for (int i = start; i <= end; i++) { + SequenceI seq = (SequenceI) seqs.elementAt(0); - if (!exc.contains(jseq)) { + char c = seq.getCharAt(i); - char cc = jseq.getCharAt(i); + boolean found = true; - if ( cc != c) { - found = false; - } - } - j++; - } + int j = 1; + while ((j < seqs.size()) && (found == true)) { + SequenceI jseq = (SequenceI) seqs.elementAt(j); - if (prev == false && found == true) { - bstart = i; - } else if (prev == true && found == false && bstart != -1) { + if (!exc.contains(jseq)) { + char cc = jseq.getCharAt(i); - int blockstart = bstart-start; - int blocklen = i-bstart; + if (cc != c) { + found = false; + } + } - //System.out.println("Start len " + blockstart + " " + blocklen); + j++; + } - for (int jj = blockstart; jj < blockstart + blocklen;jj++) { - blocks.put(new Integer(jj),new Integer(blocklen)); - } + if ((prev == false) && (found == true)) { + bstart = i; + } else if ((prev == true) && (found == false) && (bstart != -1)) { + int blockstart = bstart - start; + int blocklen = i - bstart; - bstart = -1; - } - prev = found; - } + //System.out.println("Start len " + blockstart + " " + blocklen); + for (int jj = blockstart; jj < (blockstart + blocklen); jj++) { + blocks.put(new Integer(jj), new Integer(blocklen)); + } - if (bstart != -1) { + bstart = -1; + } - int blockstart = bstart-start; - int blocklen = end-bstart; + prev = found; + } - // System.out.println("Start len " + blockstart + " " + blocklen); + if (bstart != -1) { + int blockstart = bstart - start; + int blocklen = end - bstart; - for (int jj = blockstart; jj < blockstart + blocklen;jj++) { - blocks.put(new Integer(blockstart),new Integer(blocklen)); - } + // 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; + 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)); - public static Hashtable findKmerCount(SequenceI seq, int start, int end,int window, int step,Vector kmers) { - - int tmpstart = start; - Hashtable vals = new Hashtable(); + int count = 0; - while (tmpstart <= end) { + //System.out.println("Str " + tmpstr); + for (int ii = 0; ii < kmers.size(); ii++) { + String kmer = ((SequenceI) kmers.elementAt(ii)).getSequence(); - String tmpstr = seq.getSequence().substring(tmpstart-window/2,tmpstart+window/2); + int i = -1; - int count = 0; + while (tmpstr.indexOf(kmer, i) != -1) { + i = tmpstr.indexOf(kmer, i); - //System.out.println("Str " + tmpstr); - - for (int ii = 0; ii < kmers.size(); ii++) { - String kmer = ((SequenceI)kmers.elementAt(ii)).getSequence(); + i++; + count++; + } - int i = -1; + ii++; + } - while (tmpstr.indexOf(kmer,i) != -1) { - i = tmpstr.indexOf(kmer,i); + vals.put(new Integer(tmpstart), new Integer(count)); + tmpstart += step; + } - i++; - count++; - } - ii++; - } - vals.put(new Integer(tmpstart),new Integer(count)); - tmpstart += step; - } - return vals; + 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 + 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(); - Hashtable blocks = new Hashtable(); + boolean prev = false; + int bstart = -1; - boolean prev = false; - int bstart = -1; + for (int i = start; i <= end; i++) { + SequenceI seq = (SequenceI) seqs.elementAt(0); - for (int i = start; i <= end ; i++) { - SequenceI seq = (SequenceI)seqs.elementAt(0); + char c = seq.getCharAt(i); - char c = seq.getCharAt(i); + boolean found = true; - boolean found = true; + int j = 1; - int j = 1; + while ((j < seqs.size()) && (found == true)) { + SequenceI jseq = (SequenceI) seqs.elementAt(j); - while (j < seqs.size() && found == true) { + if (!exc.contains(jseq)) { + char cc = jseq.getCharAt(i); - 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) { + if (cc != c) { + found = false; + } + } - int blockstart = bstart-start; - int blocklen = i-bstart; + j++; + } - // System.out.println("Start len " + blockstart + " " + blocklen); + if ((prev == false) && (found == true)) { + bstart = i; + } else if ((prev == true) && (found == false) && (bstart != -1)) { + int blockstart = bstart - start; + int blocklen = i - bstart; - //for (int jj = blockstart; jj < blockstart + blocklen;jj++) { - blocks.put(new Integer(blockstart),new Integer(blocklen)); - // } + // 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; - } + // } + bstart = -1; + } - if (bstart != -1) { + prev = found; + } - int blockstart = bstart-start; - int blocklen = end-bstart; + if (bstart != -1) { + int blockstart = bstart - start; + int blocklen = end - bstart; - // System.out.println("Start len " + blockstart + " " + blocklen); + // System.out.println("Start len " + blockstart + " " + blocklen); + //for (int jj = blockstart; jj < blockstart + blocklen;jj++) { + blocks.put(new Integer(blockstart), new Integer(blocklen)); - //for (int jj = blockstart; jj < blockstart + blocklen;jj++) { - blocks.put(new Integer(blockstart),new Integer(blocklen)); - // } + // } + } - } - return blocks; + return blocks; } - } - diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index e77a0d3..47c17a3 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -16,528 +16,566 @@ * 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.schemes.*; import jalview.datamodel.SequenceI; -import jalview.util.*; + import jalview.io.*; -import java.util.*; -import java.io.*; +import jalview.schemes.*; + +import jalview.util.*; + import java.awt.*; +import java.io.*; + +import java.util.*; + + public class AlignSeq { + public static java.util.Hashtable dnaHash = new java.util.Hashtable(); + + static { + dnaHash.put("C", new Integer(0)); + dnaHash.put("T", new Integer(1)); + dnaHash.put("A", new Integer(2)); + dnaHash.put("G", new Integer(3)); + dnaHash.put("-", new Integer(4)); + } + + static String[] dna = { "C", "T", "A", "G", "-" }; + 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", "-" + }; + int[][] score; + int[][] E; + int[][] F; + int[][] traceback; + int[] seq1; + int[] seq2; + SequenceI s1; + SequenceI s2; + String s1str; + String s2str; + int maxi; + int maxj; + int[] aseq1; + int[] aseq2; + String astr1 = ""; + String astr2 = ""; + public int seq1start; + public int seq1end; + public int seq2start; + public int seq2end; + int count; + public int maxscore; + float pid; + int prev = 0; + int gapOpen = 120; + int gapExtend = 20; + int[][] lookup = ResidueProperties.getBLOSUM62(); + String[] intToStr = pep; + int defInt = 23; + String output = ""; + String type; + Runtime rt; + + public AlignSeq() { + } + + public AlignSeq(SequenceI s1, SequenceI s2, String type) { + rt = Runtime.getRuntime(); + SeqInit(s1, s2, type); + } + + public int getMaxScore() { + return maxscore; + } - int[][] score; - int[][] E; - int[][] F; - int[][] traceback; - - int[] seq1; - int[] seq2; - - SequenceI s1; - SequenceI s2; - - String s1str; - String s2str; - - int maxi; - int maxj; - - int[] aseq1; - int[] aseq2; - - String astr1 = ""; - String astr2 = ""; - - public int seq1start; - public int seq1end; - public int seq2start; - public int seq2end; - - int count; - - public int maxscore; - float pid; - int prev = 0; - - public static java.util.Hashtable dnaHash = new java.util.Hashtable(); - - static { - dnaHash.put("C", new Integer(0)); - dnaHash.put("T", new Integer(1)); - dnaHash.put("A", new Integer(2)); - dnaHash.put("G", new Integer(3)); - dnaHash.put("-", new Integer(4)); - } - - static String dna[] = {"C","T","A","G","-"}; - 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","-"}; - - int gapOpen = 120; - int gapExtend = 20; - - int lookup[][] = ResidueProperties.getBLOSUM62(); - String intToStr[] = pep; - int defInt = 23; - - String output = ""; - - String type; - Runtime rt; - public AlignSeq() {} - - public AlignSeq(SequenceI s1, SequenceI s2,String type) { - rt = Runtime.getRuntime(); - SeqInit(s1,s2,type); - } - - public int getMaxScore() { - return maxscore; - } - - public int getSeq2Start() { - return seq2start; - } - - public int getSeq2End() { - return seq2end; - } - - public int getSeq1Start() { - return seq1start; - } - - public int getSeq1End() { - return seq1end; - } - - public String getOutput() { - return output; - } - - public String getAStr1() { - return astr1; - } - public String getAStr2() { - return astr2; - } - public int [] getASeq1() { - return aseq1; - } - public int [] getASeq2() { - return aseq2; - } - public SequenceI getS1() { - return s1; - } - 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); - - this.s1 = s1; - this.s2 = s2; - - this.type = type; - - if (type.equals("pep")) { - lookup = ResidueProperties.getBLOSUM62(); - intToStr = pep; - defInt = 23; - } else if (type.equals("dna")) { - lookup = ResidueProperties.getDNA(); - intToStr = dna; - defInt = 4; - } else { - output = output + ("Wrong type = dna or pep only"); - System.exit(0); + public int getSeq2Start() { + return seq2start; } + public int getSeq2End() { + return seq2end; + } - //System.out.println("lookuip " + rt.freeMemory() + " "+ rt.totalMemory()); - seq1 = new int[s1str.length()]; - //System.out.println("seq1 " + rt.freeMemory() +" " + rt.totalMemory()); - seq2 = new int[s2str.length()]; - //System.out.println("seq2 " + rt.freeMemory() + " " + rt.totalMemory()); - score = new int[s1str.length()][s2str.length()]; - //System.out.println("score " + rt.freeMemory() + " " + rt.totalMemory()); - E = new int[s1str.length()][s2str.length()]; - //System.out.println("E " + rt.freeMemory() + " " + rt.totalMemory()); - F = new int[s1str.length()][s2str.length()]; - traceback = new int[s1str.length()][s2str.length()]; - //System.out.println("F " + rt.freeMemory() + " " + rt.totalMemory()); - seq1 = stringToInt(s1str,type); - //System.out.println("seq1 " + rt.freeMemory() + " " + rt.totalMemory()); - seq2 = stringToInt(s2str,type); - //System.out.println("Seq2 " + rt.freeMemory() + " " + rt.totalMemory()); - - // long tstart = System.currentTimeMillis(); - // calcScoreMatrix(); - //long tend = System.currentTimeMillis(); - - //System.out.println("Time take to calculate score matrix = " + (tend-tstart) + " ms"); - - - // printScoreMatrix(score); - //System.out.println(); - - //printScoreMatrix(traceback); - //System.out.println(); - - // printScoreMatrix(E); - //System.out.println(); - - ///printScoreMatrix(F); - //System.out.println(); - // tstart = System.currentTimeMillis(); - //traceAlignment(); - //tend = System.currentTimeMillis(); - //System.out.println("Time take to traceback alignment = " + (tend-tstart) + " ms"); - } - - 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 ) { - max = score[i][seq2.length - 1]; - maxi = i; - maxj = seq2.length-1; - } + public int getSeq1Start() { + return seq1start; } - 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; - } + + public int getSeq1End() { + return seq1end; } - // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]); - - int i = maxi; - int j = maxj; - int trace; - maxscore = score[i][j] / 10; - - seq1end = maxi+1; - seq2end = maxj+1; - - aseq1 = new int[seq1.length + seq2.length]; - aseq2 = new int[seq1.length + seq2.length]; - - count = seq1.length + seq2.length - 1; - - 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) { - aseq2[count] = seq2[j]; - astr2 = intToStr[seq2[j]] + astr2; - } - trace = findTrace(i,j); - if (trace == 0) { - i--; - j--; - - } else if (trace == 1) { - j--; - aseq1[count] = defInt; - astr1 = "-" + astr1.substring(1); - } else if (trace == -1) { - i--; - aseq2[count] = defInt; - astr2 = "-" + astr2.substring(1); - } - count--; + public String getOutput() { + return output; } - seq1start = i+1; - seq2start = j+1; + public String getAStr1() { + return astr1; + } - if (aseq1[count] != defInt) { - aseq1[count] = seq1[i]; - astr1 = intToStr[seq1[i]] + astr1; + public String getAStr2() { + return astr2; } - if (aseq2[count] != defInt) { - aseq2[count] = seq2[j]; - astr2 = intToStr[seq2[j]] + astr2; + public int[] getASeq1() { + return aseq1; } - } - public void printAlignment() { - // Find the biggest id length for formatting purposes - int maxid = s1.getName().length(); + public int[] getASeq2() { + return aseq2; + } - if (s2.getName().length() > maxid) { - maxid = s2.getName().length(); + public SequenceI getS1() { + return s1; } - int len = 72 - maxid - 1; - 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"); - output = output + ("Sequence "); - output = output + (new Format("%" + maxid + "s").form(s1.getName())); - output = output + (" : " + seq1start + " - " + seq1end + " (Sequence length = " + s1str.length() + ")\n"); - output = output + ("Sequence "); - output = output + (new Format("%" + maxid + "s").form(s2.getName())); - output = output + (" : " + seq2start + " - " + seq2end + " (Sequence length = " + s2str.length() + ")\n\n"); - - 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) { - output = output + (new Format("%s").form(intToStr[aseq1[count + i + j*len]])); + 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); + + this.s1 = s1; + this.s2 = s2; + + this.type = type; + + if (type.equals("pep")) { + lookup = ResidueProperties.getBLOSUM62(); + intToStr = pep; + defInt = 23; + } else if (type.equals("dna")) { + lookup = ResidueProperties.getDNA(); + intToStr = dna; + defInt = 4; + } else { + output = output + ("Wrong type = dna or pep only"); + System.exit(0); } - } - - output = output + ("\n"); - output = output + (new Format("%" + (maxid) + "s").form(" ") + " "); - // Print out the matching chars - 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("-")) { - pid++; - output = output + ("|"); - } else if (type.equals("pep")) { - if (ResidueProperties.getPAM250(intToStr[aseq1[count+i+j*len]],intToStr[aseq2[count+i+j*len]]) > 0) { - output = output + ("."); - } else { - output = output + (" "); + + //System.out.println("lookuip " + rt.freeMemory() + " "+ rt.totalMemory()); + seq1 = new int[s1str.length()]; + + //System.out.println("seq1 " + rt.freeMemory() +" " + rt.totalMemory()); + seq2 = new int[s2str.length()]; + + //System.out.println("seq2 " + rt.freeMemory() + " " + rt.totalMemory()); + score = new int[s1str.length()][s2str.length()]; + + //System.out.println("score " + rt.freeMemory() + " " + rt.totalMemory()); + E = new int[s1str.length()][s2str.length()]; + + //System.out.println("E " + rt.freeMemory() + " " + rt.totalMemory()); + F = new int[s1str.length()][s2str.length()]; + traceback = new int[s1str.length()][s2str.length()]; + + //System.out.println("F " + rt.freeMemory() + " " + rt.totalMemory()); + seq1 = stringToInt(s1str, type); + + //System.out.println("seq1 " + rt.freeMemory() + " " + rt.totalMemory()); + seq2 = stringToInt(s2str, type); + + //System.out.println("Seq2 " + rt.freeMemory() + " " + rt.totalMemory()); + // long tstart = System.currentTimeMillis(); + // calcScoreMatrix(); + //long tend = System.currentTimeMillis(); + //System.out.println("Time take to calculate score matrix = " + (tend-tstart) + " ms"); + // printScoreMatrix(score); + //System.out.println(); + //printScoreMatrix(traceback); + //System.out.println(); + // printScoreMatrix(E); + //System.out.println(); + ///printScoreMatrix(F); + //System.out.println(); + // tstart = System.currentTimeMillis(); + //traceAlignment(); + //tend = System.currentTimeMillis(); + //System.out.println("Time take to traceback alignment = " + (tend-tstart) + " ms"); + } + + 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) { + max = score[i][seq2.length - 1]; + maxi = i; + maxj = seq2.length - 1; } - } else { - output = output + (" "); - } + } + 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; + } } - } - // Now print the second aligned sequence - output = output + ("\n"); - output = output + (new Format("%" + (maxid) + "s").form(s2.getName()) + " " ); - 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]])); + + // System.out.println(maxi + " " + maxj + " " + score[maxi][maxj]); + int i = maxi; + int j = maxj; + int trace; + maxscore = score[i][j] / 10; + + seq1end = maxi + 1; + seq2end = maxj + 1; + + aseq1 = new int[seq1.length + seq2.length]; + aseq2 = new int[seq1.length + seq2.length]; + + count = (seq1.length + seq2.length) - 1; + + 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)) { + aseq2[count] = seq2[j]; + astr2 = intToStr[seq2[j]] + astr2; + } + + trace = findTrace(i, j); + + if (trace == 0) { + i--; + j--; + } else if (trace == 1) { + j--; + aseq1[count] = defInt; + astr1 = "-" + astr1.substring(1); + } else if (trace == -1) { + i--; + aseq2[count] = defInt; + astr2 = "-" + astr2.substring(1); + } + + count--; } - } - output = output + ("\n\n"); - } - pid = pid/(float)(aseq1.length-count)*100; - output = output + (new Format("Percentage ID = %2.2f\n\n").form(pid)); - } + seq1start = i + 1; + seq2start = j + 1; - public void printScoreMatrix(int[][] mat) { - int n = seq1.length; - int m = seq2.length; + if (aseq1[count] != defInt) { + aseq1[count] = seq1[i]; + astr1 = intToStr[seq1[i]] + astr1; + } - for (int i = 0; i < n;i++) { - // Print the top sequence - if (i == 0) { - Format.print(System.out,"%8s",s2str.substring(0,1)); - for (int jj = 1;jj < m; jj++) { - Format.print(System.out,"%5s",s2str.substring(jj,jj+1)); + if (aseq2[count] != defInt) { + aseq2[count] = seq2[j]; + astr2 = intToStr[seq2[j]] + astr2; } - System.out.println(); - } + } - for (int j = 0;j < m; j++) { - if (j == 0) { - Format.print(System.out,"%3s",s1str.substring(i,i+1)); + public void printAlignment() { + // Find the biggest id length for formatting purposes + int maxid = s1.getName().length(); + + if (s2.getName().length() > maxid) { + maxid = s2.getName().length(); } - Format.print(System.out,"%3d ",mat[i][j]/10); - } - System.out.println(); + + int len = 72 - maxid - 1; + 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"); + output = output + ("Sequence "); + output = output + (new Format("%" + maxid + "s").form(s1.getName())); + output = output + + (" : " + seq1start + " - " + seq1end + " (Sequence length = " + + s1str.length() + ")\n"); + output = output + ("Sequence "); + output = output + (new Format("%" + maxid + "s").form(s2.getName())); + output = output + + (" : " + seq2start + " - " + seq2end + " (Sequence length = " + + s2str.length() + ")\n\n"); + + 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) { + output = output + + (new Format("%s").form(intToStr[aseq1[count + i + + (j * len)]])); + } + } + + output = output + ("\n"); + output = output + + (new Format("%" + (maxid) + "s").form(" ") + " "); + + // Print out the matching chars + 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("-")) { + pid++; + output = output + ("|"); + } else if (type.equals("pep")) { + if (ResidueProperties.getPAM250( + intToStr[aseq1[count + i + (j * len)]], + intToStr[aseq2[count + i + (j * len)]]) > 0) { + output = output + ("."); + } else { + output = output + (" "); + } + } else { + output = output + (" "); + } + } + } + + // Now print the second aligned sequence + output = output + ("\n"); + output = output + + (new Format("%" + (maxid) + "s").form(s2.getName()) + " "); + + 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)]])); + } + } + + output = output + ("\n\n"); + } + + pid = pid / (float) (aseq1.length - count) * 100; + output = output + (new Format("Percentage ID = %2.2f\n\n").form(pid)); } - } - - 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) { - max = F[i][j]; - t = -1; - } else if (F[i][j] == max) { - if (prev == -1) { - max = F[i][j]; - t = -1; - } + + public void printScoreMatrix(int[][] mat) { + int n = seq1.length; + int m = seq2.length; + + for (int i = 0; i < n; i++) { + // Print the top sequence + if (i == 0) { + Format.print(System.out, "%8s", s2str.substring(0, 1)); + + 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) { + Format.print(System.out, "%3s", s1str.substring(i, i + 1)); + } + + Format.print(System.out, "%3d ", mat[i][j] / 10); + } + + System.out.println(); + } } - if (E[i][j] >= max) { - max = E[i][j]; - t = 1; - } else if (E[i][j] == max) { - if (prev == 1) { - max = E[i][j]; - t = 1; - } + + 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) { + max = F[i][j]; + t = -1; + } else if (F[i][j] == max) { + if (prev == -1) { + max = F[i][j]; + t = -1; + } + } + + if (E[i][j] >= max) { + max = E[i][j]; + t = 1; + } else if (E[i][j] == max) { + if (prev == 1) { + max = E[i][j]; + t = 1; + } + } + + prev = t; + + return t; } - prev = t; - return t; - } - public void calcScoreMatrix() { + public void calcScoreMatrix() { + int n = seq1.length; + int m = seq2.length; + // top left hand element + score[0][0] = lookup[seq1[0]][seq2[0]] * 10; + E[0][0] = -gapExtend; + F[0][0] = 0; - int n = seq1.length; - int m = seq2.length; + // Calculate the top row first + 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; + score[0][j] = max(lookup[seq1[0]][seq2[j]] * 10, -gapOpen, + -gapExtend); - // top left hand element - score[0][0] = lookup[seq1[0]][seq2[0]] * 10; - E[0][0] = -gapExtend; - F[0][0] = 0; + traceback[0][j] = 1; + } - // Calculate the top row first - 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; + // Now do the left hand column + 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); - score[0][j] = max( lookup[seq1[0]][seq2[j]] * 10 ,-gapOpen,-gapExtend); + score[i][0] = max(lookup[seq1[i]][seq2[0]] * 10, E[i][0], F[i][0]); + traceback[i][0] = -1; + } - traceback[0][j] = 1; + // Now do all the other rows + 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] - + gapExtend); + + score[i][j] = max(score[i - 1][j - 1] + + (lookup[seq1[i]][seq2[j]] * 10), E[i][j], F[i][j]); + traceback[i][j] = findTrace(i, j); + } + } } - // Now do the left hand column - 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); + 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); + } - score[i][0] = max( lookup[seq1[i]][seq2[0]] * 10 ,E[i][0],F[i][0]); - traceback[i][0] = -1; + return out; } - // Now do all the other rows - for (int i = 1; i < n; i++) { - for (int j = 1; j < m; j++) { + public static String extractGaps(String gapChar, String seq) { + StringTokenizer str = new StringTokenizer(seq, gapChar); + String newString = ""; - 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] - gapExtend); + while (str.hasMoreTokens()) { + newString = newString + str.nextToken(); + } - score[i][j] = max(score[i-1][j-1] + lookup[seq1[i]][seq2[j]]*10, - E[i][j], - F[i][j]); - traceback[i][j] = findTrace(i,j); - } + return newString; } - } - 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) { - StringTokenizer str = new StringTokenizer(seq,gapChar); - String newString = ""; - - while (str.hasMoreTokens()) { - newString = newString + str.nextToken(); - } - return newString; - } + public int max(int i1, int i2, int i3) { + int max = i1; + if (i2 > i1) { + max = i2; + } - public int max(int i1, int i2, int i3) { - int max = i1; - if (i2 > i1) { - max = i2; - } - if (i3 > max) { - max = i3; - } - return max; - } + if (i3 > max) { + max = i3; + } - public int max(int i1, int i2) { - int max = i1; - if (i2 > i1) { - max = i2; + return max; } - return max; - } - public int[] stringToInt(String s,String type) { - int[] seq1 = new int[s.length()]; + public int max(int i1, int i2) { + int max = i1; - for (int i = 0;i < s.length(); i++) { - String ss = s.substring(i,i+1).toUpperCase(); - try { - if (type.equals("pep")) { - seq1[i] = ((Integer)ResidueProperties.aaHash.get(ss)).intValue(); - } else if (type.equals("dna")) { - seq1[i] = ((Integer)dnaHash.get(ss)).intValue(); - } - if (seq1[i] > 23) { - seq1[i] = 23; + if (i2 > i1) { + max = i2; } - } catch (Exception e) { - if (type.equals("dna")) { - seq1[i] = 4; - } else { - seq1[i] = 23; + + return max; + } + + public int[] stringToInt(String s, String type) { + int[] seq1 = new int[s.length()]; + + for (int i = 0; i < s.length(); i++) { + String ss = s.substring(i, i + 1).toUpperCase(); + + try { + if (type.equals("pep")) { + seq1[i] = ((Integer) ResidueProperties.aaHash.get(ss)).intValue(); + } else if (type.equals("dna")) { + seq1[i] = ((Integer) dnaHash.get(ss)).intValue(); + } + + if (seq1[i] > 23) { + seq1[i] = 23; + } + } catch (Exception e) { + if (type.equals("dna")) { + seq1[i] = 4; + } else { + seq1[i] = 23; + } + } } - } + + return seq1; } - return seq1; - } - public static void displayMatrix(Graphics g, int[][] mat, int n, int m,int psize) { + public static void displayMatrix(Graphics g, int[][] mat, int n, int m, + int psize) { + int max = -1000; + int min = 1000; - 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) { + max = mat[i][j]; + } - 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) { - min = mat[i][j]; + if (mat[i][j] <= min) { + min = mat[i][j]; + } + } } - } - } - System.out.println(max + " " + min); - for (int i=0; i < n; i++) { - for (int j=0; j < m; j++) { - int x = psize*i; - int y = psize*j; - // System.out.println(mat[i][j]); - float score = (float)(mat[i][j] - min)/(float)(max-min); - g.setColor(new Color(score,0,0)); - g.fillRect(x,y,psize,psize); - // System.out.println(x + " " + y + " " + score); - } - } - } + System.out.println(max + " " + min); + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + int x = psize * i; + int y = psize * j; + + // System.out.println(mat[i][j]); + float score = (float) (mat[i][j] - min) / (float) (max - min); + g.setColor(new Color(score, 0, 0)); + g.fillRect(x, y, psize, psize); + // System.out.println(x + " " + y + " " + score); + } + } + } } diff --git a/src/jalview/analysis/AlignmentSorter.java b/src/jalview/analysis/AlignmentSorter.java index 53eb1dd..7c2a554 100755 --- a/src/jalview/analysis/AlignmentSorter.java +++ b/src/jalview/analysis/AlignmentSorter.java @@ -16,296 +16,327 @@ * 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.*; -import jalview.util.*; + import jalview.io.*; +import jalview.util.*; + import java.util.*; + /** Data structure to hold and manipulate a multiple sequence alignment */ public class AlignmentSorter { - - private AlignmentSorter() { - try - { - jbInit(); + /** */ + static boolean sortIdAscending = true; + static int lastGroupHash = 0; + static boolean sortGroupAscending = true; + static AlignmentOrder lastOrder = null; + static boolean sortOrderAscending = true; + static NJTree lastTree = null; + static boolean sortTreeAscending = true; + + private AlignmentSorter() { + try { + jbInit(); + } catch (Exception ex) { + ex.printStackTrace(); + } } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - public static void sortGroups(AlignmentI align) { - Vector groups = align.getGroups(); - int nGroup = groups.size(); + public static void sortGroups(AlignmentI align) { + Vector groups = align.getGroups(); + int nGroup = groups.size(); + + float[] arr = new float[nGroup]; + Object[] s = new Object[nGroup]; - float[] arr = new float [nGroup]; - Object[] s = new Object[nGroup]; + for (int i = 0; i < nGroup; i++) { + arr[i] = ((SequenceGroup) groups.elementAt(i)).getSize(); + s[i] = groups.elementAt(i); + } - for (int i=0; i < nGroup; i++) { - arr[i] = ((SequenceGroup)groups.elementAt(i)).getSize(); - s[i] = groups.elementAt(i); + QuickSort.sort(arr, s); + + // align..setGroups(newg); } - QuickSort.sort(arr,s); + /** + * Sort by Percentage Identity + * + * @param align AlignmentI + * @param s SequenceI + */ + public static void sortByPID(AlignmentI align, SequenceI s) { + int nSeq = align.getHeight(); - // align..setGroups(newg); - } + float[] scores = new float[nSeq]; + SequenceI[] seqs = new SequenceI[nSeq]; - /** - * Sort by Percentage Identity - * - * @param align AlignmentI - * @param s SequenceI - */ - public static void sortByPID(AlignmentI align, SequenceI s) { - int nSeq = align.getHeight(); + for (int i = 0; i < nSeq; i++) { + scores[i] = Comparison.PID(align.getSequenceAt(i), s); + seqs[i] = align.getSequenceAt(i); + } - float scores[] = new float[nSeq]; - SequenceI seqs[] = new SequenceI[nSeq]; + QuickSort.sort(scores, 0, scores.length - 1, seqs); - for (int i = 0; i < nSeq; i++) { - scores[i] = Comparison.PID(align.getSequenceAt(i),s); - seqs[i] = align.getSequenceAt(i); + setReverseOrder(align, seqs); } - QuickSort.sort(scores,0,scores.length-1,seqs); + private static void setReverseOrder(AlignmentI align, SequenceI[] seqs) { + int nSeq = seqs.length; + + int len = 0; - setReverseOrder(align,seqs); - } + if ((nSeq % 2) == 0) { + len = nSeq / 2; + } else { + len = (nSeq + 1) / 2; + } - private static void setReverseOrder(AlignmentI align, SequenceI [] seqs) { - int nSeq = seqs.length; + // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work + 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); + } + } - int len = 0; - if (nSeq%2 == 0) { - len = nSeq/2; - } else { - len = (nSeq+1)/2; + private static void setOrder(AlignmentI align, Vector tmp) { + setOrder(align, vectorSubsetToArray(tmp, align.getSequences())); } -// NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work - 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, SequenceI[] seqs) { + // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work + Vector algn = align.getSequences(); + + for (int i = 0, p = 0; i < seqs.length; i++) + algn.setElementAt(seqs[i], p++); } - } - private static void setOrder(AlignmentI align, Vector tmp) { - setOrder(align,vectorSubsetToArray(tmp, align.getSequences())); - } + public static void sortByID(AlignmentI align) { + int nSeq = align.getHeight(); - private static void setOrder(AlignmentI align, SequenceI [] seqs) { - // NOTE: DO NOT USE align.setSequenceAt() here - it will NOT work + String[] ids = new String[nSeq]; + SequenceI[] seqs = new SequenceI[nSeq]; - Vector algn = align.getSequences(); + for (int i = 0; i < nSeq; i++) { + ids[i] = align.getSequenceAt(i).getName(); + seqs[i] = align.getSequenceAt(i); + } - for (int i = 0, p = 0; i < seqs.length; i++) - algn.setElementAt(seqs[i], p++); - } - /** */ - static boolean sortIdAscending = true; - public static void sortByID(AlignmentI align) { - int nSeq = align.getHeight(); + QuickSort.sort(ids, seqs); - String ids[] = new String[nSeq]; - SequenceI seqs[] = new SequenceI[nSeq]; + if (sortIdAscending) { + setReverseOrder(align, seqs); + } else { + setOrder(align, seqs); + } - for (int i = 0; i < nSeq; i++) { - ids[i] = align.getSequenceAt(i).getName(); - seqs[i] = align.getSequenceAt(i); + sortIdAscending = !sortIdAscending; } - QuickSort.sort(ids,seqs); + public static void sortByGroup(AlignmentI align) { + Vector groups = align.getGroups(); + + if (groups.hashCode() != lastGroupHash) { + sortGroupAscending = true; + lastGroupHash = groups.hashCode(); + } else { + sortGroupAscending = !sortGroupAscending; + } + + Vector seqs = new Vector(); + + for (int i = 0; i < groups.size(); i++) { + SequenceGroup sg = (SequenceGroup) groups.elementAt(i); + + for (int j = 0; j < sg.getSize(); j++) { + seqs.addElement(sg.getSequenceAt(j)); + } + } + + // Deletions can happen so this check may fail + + /* + if (seqs.size() != nSeq) { + System.err.println("ERROR: tmp.size() != nseq in sortByGroups"); + if (seqs.size() < nSeq) { + addStrays(align,seqs); + } + } + */ + if (sortGroupAscending) { + setOrder(align, seqs); + } else { + setReverseOrder(align, + vectorSubsetToArray(seqs, align.getSequences())); + } + } + + private static SequenceI[] vectorToArray(Vector tmp) { + SequenceI[] seqs = new SequenceI[tmp.size()]; - if(sortIdAscending) - setReverseOrder(align,seqs); - else - setOrder(align, seqs); + for (int i = 0; i < tmp.size(); i++) { + seqs[i] = (SequenceI) tmp.elementAt(i); + } + + return seqs; + } - sortIdAscending = !sortIdAscending; - } - static int lastGroupHash = 0; - static boolean sortGroupAscending = true; + private static SequenceI[] vectorSubsetToArray(Vector tmp, Vector mask) { + Vector seqs = new Vector(); + int i; + int m; + int p; + boolean[] tmask = new boolean[m = mask.size()]; - public static void sortByGroup(AlignmentI align) { - Vector groups = align.getGroups(); - if (groups.hashCode()!=lastGroupHash) { - sortGroupAscending=true; - lastGroupHash = groups.hashCode(); - } else - sortGroupAscending = ! sortGroupAscending; + for (i = 0; i < m; i++) + tmask[i] = true; - Vector seqs = new Vector(); + for (i = 0; i < tmp.size(); i++) { + Object sq; - for (int i=0; i < groups.size(); i++) { - SequenceGroup sg = (SequenceGroup)groups.elementAt(i); + if (mask.contains(sq = tmp.elementAt(i))) { + tmask[mask.indexOf(sq)] = false; + seqs.addElement(sq); + m--; + } + } - for (int j = 0; j < sg.getSize(); j++) { - seqs.addElement(sg.getSequenceAt(j)); - } + for (i = 0; i < tmask.length; i++) + if (tmask[i]) { + seqs.addElement(mask.elementAt(i)); + } + + return vectorToArray(seqs); } - // Deletions can happen so this check may fail - /* - if (seqs.size() != nSeq) { - System.err.println("ERROR: tmp.size() != nseq in sortByGroups"); - if (seqs.size() < nSeq) { - addStrays(align,seqs); - } + 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 (tmp.size()= 0 && - seqint[k][i] >= 0) { - counts[seqint[k][i]][seqint[j][i]]++; + public static int[][] percentIdentity2(AlignmentI align, int start, int end) { + int[][] cons2 = new int[align.getWidth()][24]; - // print_matrix(counts,4,4); - tots[seqint[j][i]]++; - tot++; - } - if (seqint[j][i] != -1) { - fulltots[seqint[j][i]]++; - fulltot++; - } - } - } + // Initialize the array + for (int j = 0; j < 24; j++) { + for (int i = 0; i < align.getWidth(); i++) { + cons2[i][j] = 0; + } + } - if (k != j) { - - System.out.println(); - - System.out.println("Sequence " + align.getSequenceAt(j).getName() + " " + align.getSequenceAt(k).getName()); - - System.out.println(); - print_matrix(counts,4,4); - System.out.println(); - - - - double[][] out = new double[4][4];// = constant_multiply_matrix(counts,1.0/tot,4,4); - - for (int i = 0; i < 4; i++) { - for (int jj = 0; jj < 4; jj++) { - out[i][jj] = (double)counts[i][jj]/tots[jj]; - } - } - - print_matrix(out,4,4); - System.out.println(); - - - System.out.print("RATES\t"); - System.out.print(align.getSequenceAt(j).getName() + "\t" + align.getSequenceAt(k).getName() + "\t"); - - for (int i = 0; i < 4; i++) { - for (int jj = 0; jj < 4; jj++) { - Format.print(System.out,"%4.3f\t",out[i][jj]); - } - } - System.out.println(); - - for (int i = 0; i < 4; i++) { - Format.print(System.out,"%4.3f\t",(double)fulltots[i]*1.0/fulltot); - } - - System.out.println(); - System.out.print("\nGC "); - - Format.print(System.out,"%4.3f\t",(double)(100*fulltots[1]+fulltots[3])/fulltot); - - System.out.print((fulltots[1]+fulltots[3]) + "\t" + fulltot); + return cons2; + } + public static int getPixelHeight(int i, int j, int charHeight) { + int h = 0; - System.out.println(); + while (i < j) { + h += charHeight; + i++; + } - rates.addElement(out); - } + return h; + } - } - } - return rates; + public static Vector substitution_rates(AlignmentI align, int start, int end) { + Vector rates = new Vector(); + + int len = (end - start + 1); + + // Turn seqs into char arrays + int[][] seqint = new int[align.getHeight()][len]; + + for (int j = 0; j < align.getHeight(); j++) { + SequenceI seq = align.getSequenceAt(j); + + for (int i = 0; i < len; i++) { + char c = seq.getCharAt((start + i) - 1); + + if (c == 'A') { + seqint[j][i] = 0; + } else if (c == 'C') { + seqint[j][i] = 1; + } else if (c == 'T') { + seqint[j][i] = 2; + } else if (c == 'G') { + seqint[j][i] = 3; + } else { + seqint[j][i] = -1; + } + } + } + + // print_matrix(seqint,2,len); for (int j = 0; j < align.getHeight(); j++) { + for (int j = 0; j < align.getHeight(); j++) { + for (int k = 0; k < align.getHeight(); k++) { + int[][] counts = new int[4][4]; + int tot = 0; + int[] tots = new int[4]; + int fulltot = 0; + int[] fulltots = new int[4]; + + for (int i = 0; i < len; i++) { + if (k != j) { + // System.out.println("Seq " + j + " " + k + " " + i + " " + seqint[j][i] + " " + seqint[k][i]); + if ((seqint[j][i] >= 0) && (seqint[k][i] >= 0)) { + counts[seqint[k][i]][seqint[j][i]]++; + + // print_matrix(counts,4,4); + tots[seqint[j][i]]++; + tot++; + } + + if (seqint[j][i] != -1) { + fulltots[seqint[j][i]]++; + fulltot++; + } + } + } + + if (k != j) { + System.out.println(); + + System.out.println("Sequence " + + align.getSequenceAt(j).getName() + " " + + align.getSequenceAt(k).getName()); + + System.out.println(); + print_matrix(counts, 4, 4); + System.out.println(); + + double[][] out = new double[4][4]; // = constant_multiply_matrix(counts,1.0/tot,4,4); + + for (int i = 0; i < 4; i++) { + for (int jj = 0; jj < 4; jj++) { + out[i][jj] = (double) counts[i][jj] / tots[jj]; + } + } + + print_matrix(out, 4, 4); + System.out.println(); + + System.out.print("RATES\t"); + System.out.print(align.getSequenceAt(j).getName() + "\t" + + align.getSequenceAt(k).getName() + "\t"); + + for (int i = 0; i < 4; i++) { + for (int jj = 0; jj < 4; jj++) { + Format.print(System.out, "%4.3f\t", out[i][jj]); + } + } + + System.out.println(); + + for (int i = 0; i < 4; i++) { + Format.print(System.out, "%4.3f\t", + ((double) fulltots[i] * 1.0) / fulltot); + } + + System.out.println(); + System.out.print("\nGC "); + + Format.print(System.out, "%4.3f\t", + (double) ((100 * fulltots[1]) + fulltots[3]) / fulltot); + + System.out.print((fulltots[1] + fulltots[3]) + "\t" + + fulltot); + + System.out.println(); + + rates.addElement(out); + } + } + } + + return rates; } - public static double[][] constant_multiply_matrix(int[][] matrix, double c,int n, int m) { - double[][] out = new double[n][m]; + public static double[][] constant_multiply_matrix(int[][] matrix, double c, + int n, int m) { + double[][] out = new double[n][m]; - 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++) { + out[i][j] = matrix[i][j] * c; + } + } - out[i][j] = matrix[i][j]*c; - } - } - return out; + return out; } - public static void print_matrix(int[][] matrix, int n, int m) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + System.out.print(matrix[i][j] + "\t"); + } - - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - - System.out.print(matrix[i][j] + "\t"); - } - System.out.println(); - } + System.out.println(); + } } - public static void print_matrix(double[][] matrix, int n, int m) { - - - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - Format.print(System.out,"%4.3f\t",matrix[i][j]); + public static void print_matrix(double[][] matrix, int n, int m) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + Format.print(System.out, "%4.3f\t", matrix[i][j]); + } - } - System.out.println(); - } + System.out.println(); + } } - - } diff --git a/src/jalview/analysis/CompareAlignments.java b/src/jalview/analysis/CompareAlignments.java index e2dd742..2752e6f 100755 --- a/src/jalview/analysis/CompareAlignments.java +++ b/src/jalview/analysis/CompareAlignments.java @@ -16,170 +16,161 @@ * 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.*; + import jalview.io.*; import java.util.*; -public class CompareAlignments { +public class CompareAlignments { Vector align; String refId; Vector ids; public CompareAlignments(Vector align) { + this.align = align; - this.align = align; - - ids = new Vector(); + ids = new Vector(); - Alignment al0 = (Alignment)align.elementAt(0); + Alignment al0 = (Alignment) align.elementAt(0); - for (int i = 0; i < al0.getHeight(); i++) { - SequenceI seq = al0.getSequenceAt(i); + for (int i = 0; i < al0.getHeight(); i++) { + SequenceI seq = al0.getSequenceAt(i); - ids.addElement(seq.getName()); - - if (i == 0) { - setReferenceId(seq.getName()); - } - } + ids.addElement(seq.getName()); + if (i == 0) { + setReferenceId(seq.getName()); + } + } } public void compare() { + Hashtable positions = new Hashtable(); - Hashtable positions = new Hashtable(); - - for (int k = 0; k < ids.size(); k++) { - - String id = (String)ids.elementAt(k); - - System.out.println("Ids " + id + " " + refId); + for (int k = 0; k < ids.size(); k++) { + String id = (String) ids.elementAt(k); - if (!id.equals(refId)) { + System.out.println("Ids " + id + " " + refId); - Hashtable fullhash = new Hashtable(); + if (!id.equals(refId)) { + Hashtable fullhash = new Hashtable(); - for (int i = 0; i < align.size(); i++) { - System.out.println("Alignment " + i); + for (int i = 0; i < align.size(); i++) { + System.out.println("Alignment " + i); - Alignment al = (Alignment)align.elementAt(i); + Alignment al = (Alignment) align.elementAt(i); - SequenceI refseq = null; + SequenceI refseq = null; - for (int j = 0; j < al.getHeight(); j++) { - if (((SequenceI)al.getSequenceAt(j)).getName().equals(refId)) { - refseq = (SequenceI)al.getSequenceAt(j); - } - } + for (int j = 0; j < al.getHeight(); j++) { + if (((SequenceI) al.getSequenceAt(j)).getName().equals(refId)) { + refseq = (SequenceI) al.getSequenceAt(j); + } + } - if (refseq != null) { + if (refseq != null) { + System.out.println("Refseq " + refseq.getName()); - System.out.println("Refseq " + refseq.getName()); + for (int jj = 0; jj < al.getHeight(); jj++) { + SequenceI seq = (SequenceI) al.getSequenceAt(jj); - for (int jj = 0; jj < al.getHeight(); jj++) { - SequenceI seq = (SequenceI)al.getSequenceAt(jj); + if (seq.getName().equals(id)) { + Hashtable hash = getAlignPositions(seq, refseq); - if (seq.getName().equals(id)) { - Hashtable hash = getAlignPositions(seq,refseq); + Enumeration keys = hash.keys(); - Enumeration keys = hash.keys(); + while (keys.hasMoreElements()) { + Integer key = (Integer) keys.nextElement(); - while (keys.hasMoreElements()) { - Integer key = (Integer)keys.nextElement(); - // System.out.println(key + " " + hash.get(key)); - if (fullhash.get(key) == null) { - fullhash.put(key,new Vector()); - } + // System.out.println(key + " " + hash.get(key)); + if (fullhash.get(key) == null) { + fullhash.put(key, new Vector()); + } - Vector tmp = (Vector)fullhash.get(key); + Vector tmp = (Vector) fullhash.get(key); - tmp.addElement(hash.get(key)); - } - } + tmp.addElement(hash.get(key)); + } + } + } + } + } - } - } - } + System.out.println("\nId " + id); - System.out.println ("\nId " + id); + Enumeration keys = fullhash.keys(); - Enumeration keys = fullhash.keys(); + int totdiff = 0; + while (keys.hasMoreElements()) { + Integer key = (Integer) keys.nextElement(); - int totdiff = 0; - while (keys.hasMoreElements()) { - Integer key = (Integer)keys.nextElement(); + Vector tmp = (Vector) fullhash.get(key); - Vector tmp = (Vector)fullhash.get(key); + int diff0 = ((Integer) tmp.elementAt(0)).intValue(); + ; + int diff = 0; + for (int l = 1; l < tmp.size(); l++) { + diff += Math.abs(diff0 - + ((Integer) tmp.elementAt(l)).intValue()); + } - int diff0 = ((Integer)tmp.elementAt(0)).intValue();; - int diff = 0; + if (diff > 0) { + totdiff++; + System.out.print(id + " Ref pos " + key + " : " + + diff0 + " " + diff + " : "); - for (int l = 1; l < tmp.size(); l++) { - diff += Math.abs(diff0 - ((Integer)tmp.elementAt(l)).intValue()); + for (int l = 1; l < tmp.size(); l++) { + System.out.print(diff0 - + ((Integer) tmp.elementAt(l)).intValue() + " "); + } - } + System.out.println(); + } + } - if (diff > 0) { - totdiff++; - System.out.print(id + " Ref pos " + key + " : " + diff0 + " " + diff + " : "); - - for (int l = 1; l < tmp.size(); l++) { - System.out.print(diff0 - ((Integer)tmp.elementAt(l)).intValue() + " "); - } - System.out.println(); - } - } - - System.out.println("Total " + id + " " + totdiff); - - } - } + System.out.println("Total " + id + " " + totdiff); + } + } } - public void setReferenceId(String id) { - this.refId = id; + this.refId = id; } public Hashtable getAlignPositions(SequenceI seq1, SequenceI seq2) { + Hashtable hash = new Hashtable(); - Hashtable hash = new Hashtable(); + int i = 0; - int i = 0; + int pos1 = 0; + int pos2 = 0; - int pos1 = 0; - int pos2 = 0; + while (i < seq1.getLength()) { + char c1 = seq1.getCharAt(i); + char c2 = seq2.getCharAt(i); - while (i < seq1.getLength()) { + if (c1 != '-') { + pos1++; + } - char c1 = seq1.getCharAt(i); - char c2 = seq2.getCharAt(i); + if (c2 != '-') { + pos2++; + } - if (c1 != '-') { - pos1++; - } + if (c1 != '-') { + hash.put(new Integer(pos1), new Integer(pos2)); + } - if (c2 != '-') { - pos2++; - } + i++; + } - if (c1 != '-') { - hash.put(new Integer(pos1),new Integer(pos2)); - } - - i++; - } - return hash; + return hash; } - - - } diff --git a/src/jalview/analysis/Conservation.java b/src/jalview/analysis/Conservation.java index d3f1e01..bfb2e00 100755 --- a/src/jalview/analysis/Conservation.java +++ b/src/jalview/analysis/Conservation.java @@ -16,400 +16,426 @@ * 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.*; -import java.util.*; import jalview.gui.*; -import jalview.datamodel.*; + +import java.util.*; public class Conservation { - Vector sequences; - int start; - int end; - Vector seqNums; // vector of int vectors where first is sequence checksum - int maxLength=0; // used by quality calcs - boolean seqNumsChanged = false; // updated after any change via calcSeqNum; - private void calcSeqNums() { - for (int i=0; i-1 && i i) { - String res = s.getSequence().substring(i,i+1); - - if (residueHash.containsKey(res)) { - int count = ((Integer)residueHash.get(res)).intValue() ; - count++; - residueHash.put(res,new Integer(count)); - } else { - residueHash.put(res,new Integer(1)); + + private void calcSeqNums() { + for (int i = 0; i < sequences.size(); i++) { + calcSeqNum(i); + } + } + + private void calcSeqNum(int i) { + String sq = null; // for dumb jbuilder not-inited exception warning + int[] sqnum = null; + + if ((i > -1) && (i < sequences.size())) { + sq = ((SequenceI) sequences.elementAt(i)).getSequence(); + + if (seqNums.size() <= i) { + seqNums.addElement(new int[sq.length() + 1]); } - } else { - if (residueHash.containsKey("-")) { - int count = ((Integer)residueHash.get("-")).intValue() ; - count++; - residueHash.put("-",new Integer(count)); - } else { - residueHash.put("-",new Integer(1)); + + 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) { + 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++) { + sqnum[j] = ((Integer) jalview.schemes.ResidueProperties.aaHash.get(new String( + sq.substring(j - 1, j)))).intValue(); // yuk + } + + seqNums.setElementAt(sqnum, i); } - } + } else { + // JBPNote INFO level debug + System.err.println( + "ERROR: calcSeqNum called with out of range sequence index for Alignment\n"); } - } + } - //What is the count threshold to count the residues in residueHash() - int thresh = threshold*(sequences.size())/100; + 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++) { + // JBPNote - have to make sure elements of the sequences vector + // are tested like this everywhere... + if (sequences.elementAt(j) instanceof Sequence) { + Sequence s = (Sequence) sequences.elementAt(j); + + if (s.getLength() > i) { + String res = s.getSequence().substring(i, i + 1); + + if (residueHash.containsKey(res)) { + int count = ((Integer) residueHash.get(res)).intValue(); + count++; + residueHash.put(res, new Integer(count)); + } else { + residueHash.put(res, new Integer(1)); + } + } else { + if (residueHash.containsKey("-")) { + int count = ((Integer) residueHash.get("-")).intValue(); + count++; + residueHash.put("-", new Integer(count)); + } else { + residueHash.put("-", new Integer(1)); + } + } + } + } - //loop over all the found residues - Enumeration e = residueHash.keys(); + //What is the count threshold to count the residues in residueHash() + int thresh = (threshold * (sequences.size())) / 100; + + //loop over all the found residues + Enumeration e = residueHash.keys(); + + while (e.hasMoreElements()) { + String res = (String) e.nextElement(); + + if (((Integer) residueHash.get(res)).intValue() > thresh) { + //Now loop over the properties + Enumeration e2 = propHash.keys(); + + 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)) { + resultHash.put(type, ht.get(res)); + } else { + resultHash.put(type, ht.get("-")); + } + } else if (((Integer) resultHash.get(type)).equals( + (Integer) ht.get(res)) == false) { + resultHash.put(type, new Integer(-1)); + } + } + } + } + + total.addElement(resultHash); + } + } - while (e.hasMoreElements()) { + public int countGaps(int j) { + int count = 0; - String res = (String)e.nextElement(); - if (((Integer)residueHash.get(res)).intValue() > thresh) { + for (int i = 0; i < sequences.size(); i++) { + if ((j + 1) > ((Sequence) sequences.elementAt(i)).getSequence() + .length()) { + count++; - //Now loop over the properties - Enumeration e2 = propHash.keys(); + continue; + } - while (e2.hasMoreElements()) { - String type = (String)e2.nextElement(); - Hashtable ht = (Hashtable)propHash.get(type); + char c = ((Sequence) sequences.elementAt(i)).getSequence().charAt(j); - //Have we ticked this before? - if (! resultHash.containsKey(type)) { - if (ht.containsKey(res)) { - resultHash.put(type,ht.get(res)); - } else { - resultHash.put(type,ht.get("-")); - } - } else if ( ((Integer)resultHash.get(type)).equals((Integer)ht.get(res)) == false) { - resultHash.put(type,new Integer(-1)); + if (jalview.util.Comparison.isGap((c))) { + count++; } - } } - } - total.addElement(resultHash); + return count; } - } - public int countGaps(int j) - { - int count = 0; + /*** + * countConsNGaps + * returns gap count in int[0], and conserved residue count in int[1] + */ + 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()) { + count++; + + continue; + } - 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++; + } else { + nres++; + + if (nres == 1) { + f = c; + cons++; + } else if (f == c) { + cons++; + } + } + } - char c = ((Sequence)sequences.elementAt(i)).getSequence().charAt(j); - if (jalview.util.Comparison.isGap((c))) - count++; + r[0] = (nres == cons) ? 1 : 0; + r[1] = count; + return r; } - return count; - } - /*** - * countConsNGaps - * returns gap count in int[0], and conserved residue count in int[1] - */ - 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()) - { count++; - continue;} - - char c = ((Sequence)sequences.elementAt(i)).getSequence().charAt(j); - if (jalview.util.Comparison.isGap((c))) - count++; - else { - nres++; - if (nres==1) { - f = c; - cons++; - } else - if (f == c) { - cons++; - } - } + + public void verdict(boolean consflag, float percentageGaps) { + String consString = ""; + + 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) { + Hashtable resultHash = (Hashtable) total.elementAt(i - start); + + //Now find the verdict + int count = 0; + Enumeration e3 = resultHash.keys(); + + 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) { + count++; + } + } else { + if (result.intValue() != -1) { + count++; + } + } + } + + if (count < 10) { + consString = consString + String.valueOf(count); // Conserved props!=Identity + } else { + consString = consString + ((gapcons[0] == 1) ? "*" : "+"); + } + } else { + consString = consString + "-"; + } + } + + consSequence = new Sequence(name, consString, start, end); } - r[0] = (nres==cons) ? 1 : 0; - r[1] = count; + public Sequence getConsSequence() { + return consSequence; + } - return r; - } + // From Alignment.java in jalview118 + public void findQuality() { + findQuality(0, maxLength - 1); + } - public void verdict(boolean consflag, float percentageGaps) { - String consString = ""; + private void percentIdentity2() { + calcSeqNums(); // updates maxLength, too. - 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) - { - Hashtable resultHash = (Hashtable)total.elementAt(i-start); - - //Now find the verdict - int count = 0; - Enumeration e3 = resultHash.keys(); - - 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) - count++; - } - else - { - if (result.intValue() != -1) - count++; - } - } + if ((cons2 == null) || seqNumsChanged) { + cons2 = new int[maxLength][24]; - if (count < 10) - consString = consString + String.valueOf(count);// Conserved props!=Identity - else - consString = consString + ((gapcons[0]==1) ? "*" : "+"); + // Initialize the array + for (int j = 0; j < 24; j++) { + for (int i = 0; i < maxLength; i++) { + cons2[i][j] = 0; + } + } - } - else - { - consString = consString + "-"; - } - } + int[] sqnum; + int j = 0; - consSequence = new Sequence(name,consString,start,end); - } + while (j < sequences.size()) { + sqnum = (int[]) seqNums.elementAt(j); - public Sequence getConsSequence() { - return consSequence; - } + for (int i = 1; i < sqnum.length; i++) { + cons2[i - 1][sqnum[i]]++; + } - // From Alignment.java in jalview118 + for (int i = sqnum.length - 1; i < maxLength; i++) { + cons2[i][23]++; // gap count + } - public void findQuality() { - findQuality(0,maxLength-1); - } + j++; + } - int[][] cons2; + // unnecessary ? - private void percentIdentity2() { - calcSeqNums(); // updates maxLength, too. - 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++) { - cons2[i][j] = 0; - } - } - - int sqnum[]; - int j = 0; - while(j < sequences.size()) { - sqnum=(int[])seqNums.elementAt(j); - for (int i = 1; i < sqnum.length; i++) { - cons2[i-1][sqnum[i]]++; - } - for (int i=sqnum.length-1; i max) { - max = cons2[i][j]; - maxi = i; - maxj = j; - } + /* for (int i=start; i <= end; i++) { + int max = -1000; + int maxi = -1; + int maxj = -1; - } - } */ + for (int j=0;j<24;j++) { + if (cons2[i][j] > max) { + max = cons2[i][j]; + maxi = i; + maxj = j; + } + + } + } */ + } } -} + public void findQuality(int start, int end) { + quality = new Vector(); + + double max = -10000; + String s = ""; + int[][] BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62(); + + //Loop over columns // JBPNote Profiling info + // long ts = System.currentTimeMillis(); + //long te = System.currentTimeMillis(); + percentIdentity2(); + + int size = seqNums.size(); + int[] lengths = new int[size]; + + for (int l = 0; l < size; l++) + lengths[l] = ((int[]) seqNums.elementAt(l)).length - 1; + + 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++) { + x[ii] = 0; + try { + for (int i2 = 0; i2 < 24; i2++) { + x[ii] += (((double) cons2[j][i2] * BLOSUM62[ii][i2]) + + 4); + } + } catch (Exception e) { + System.err.println("Exception during quality calculation."); + e.printStackTrace(); + } -public void findQuality(int start, int end) { - quality = new Vector(); - double max = -10000; - String s = ""; - int[][] BLOSUM62 = jalview.schemes.ResidueProperties.getBLOSUM62(); - //Loop over columns // JBPNote Profiling info - // long ts = System.currentTimeMillis(); - //long te = System.currentTimeMillis(); - percentIdentity2(); - - int size = seqNums.size(); - int[] lengths = new int[size]; - - for (int l = 0; l < size; l++) - lengths[l] = ((int[]) seqNums.elementAt(l)).length-1; - - 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++) { - x[ii] = 0; - try { - for (int i2=0; i2 < 24; i2++) { - x[ii] += (double)cons2[j][i2] * BLOSUM62[ii][i2]+4; - } - } catch (Exception e) { - System.err.println("Exception during quality calculation."); - e.printStackTrace(); - } - //System.out.println("X " + ii + " " + x[ii]); - x[ii] /= (size); - //System.out.println("X " + ii + " " + x[ii]); - } - // Now calculate D for each position and sum - for (int k=0; k < size; k++) { - double tot = 0; - double[] xx = new double[24]; - int seqNum = - (jnewmax) - newmax = tmp; - } - // System.out.println("Quality " + s); - qualityRange[0] = new Double(0); - qualityRange[1] = new Double(newmax); - } + // System.out.println(tmp+ " " + j); + quality.setElementAt(new Double(tmp), j); + if (tmp > newmax) { + newmax = tmp; + } + } + // System.out.println("Quality " + s); + qualityRange[0] = new Double(0); + qualityRange[1] = new Double(newmax); + } } diff --git a/src/jalview/analysis/NJTree.java b/src/jalview/analysis/NJTree.java index 75d36c1..6daee9b 100755 --- a/src/jalview/analysis/NJTree.java +++ b/src/jalview/analysis/NJTree.java @@ -16,750 +16,772 @@ * 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.*; -import jalview.util.*; -import jalview.schemes.ResidueProperties; -import java.util.*; import jalview.io.NewickFile; -public class NJTree { - - Vector cluster; - SequenceI[] sequence; - - int done[]; - int noseqs; - int noClus; - - float distance[][]; - - int mini; - int minj; - float ri; - float rj; - - Vector groups = new Vector(); - SequenceNode maxdist; - SequenceNode top; - - float maxDistValue; - float maxheight; - - int ycount; - - Vector node; - - String type; - String pwtype; - - Object found = null; - Object leaves = null; - - int start; - int end; - - public NJTree(SequenceNode node) { - top = node; - maxheight = findHeight(top); - } - - public String toString() - { - jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode()); - return fout.print(false,true); // distances only - } - - public NJTree(SequenceI[] seqs, NewickFile treefile) { - top = treefile.getTree(); - maxheight = findHeight(top); - SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs); - - Vector leaves = new Vector(); - findLeaves(top, leaves); - - int i = 0; - int namesleft = seqs.length; - - SequenceNode j; - SequenceI nam; - String realnam; - while (i < leaves.size()) - { - j = (SequenceNode) leaves.elementAt(i++); - realnam = j.getName(); - nam = null; - if (namesleft>-1) - nam = algnIds.findIdMatch(realnam); - if (nam != null) { - j.setElement(nam); - namesleft--; - } else { - j.setElement(new Sequence(realnam, "THISISAPLACEHLDER")); - j.setPlaceholder(true); - - } - } - } - - /** - * - * used when the alignment associated to a tree has changed. - * - * @param alignment Vector - */ - public void UpdatePlaceHolders(Vector alignment) { - Vector leaves = new Vector(); - findLeaves(top, leaves); - int sz = leaves.size(); - SequenceIdMatcher seqmatcher=null; - int i=0; - while (i -1) { + nam = algnIds.findIdMatch(realnam); + } + + if (nam != null) { + j.setElement(nam); + namesleft--; + } else { + j.setElement(new Sequence(realnam, "THISISAPLACEHLDER")); + j.setPlaceholder(true); + } + } } - if (!(pwtype.equals("PID"))) { - type = "BL"; + public NJTree(SequenceI[] sequence, int start, int end) { + this(sequence, "NJ", "BL", start, end); } - int i=0; + public NJTree(SequenceI[] sequence, String type, String pwtype, int start, + int end) { + this.sequence = sequence; + this.node = new Vector(); + this.type = type; + this.pwtype = pwtype; + this.start = start; + this.end = end; - done = new int[sequence.length]; + if (!(type.equals("NJ"))) { + type = "AV"; + } + if (!(pwtype.equals("PID"))) { + type = "BL"; + } - while (i < sequence.length && sequence[i] != null) { - done[i] = 0; - i++; - } + int i = 0; - noseqs = i++; + done = new int[sequence.length]; - distance = findDistances(); + while ((i < sequence.length) && (sequence[i] != null)) { + done[i] = 0; + i++; + } - makeLeaves(); + noseqs = i++; - noClus = cluster.size(); + distance = findDistances(); - cluster(); + makeLeaves(); - } + noClus = cluster.size(); + cluster(); + } - public void cluster() { + public String toString() { + jalview.io.NewickFile fout = new jalview.io.NewickFile(getTopNode()); - while (noClus > 2) { - if (type.equals("NJ")) { - float mind = findMinNJDistance(); - } else { - float mind = findMinDistance(); - } + return fout.print(false, true); // distances only + } - Cluster c = joinClusters(mini,minj); + /** + * + * used when the alignment associated to a tree has changed. + * + * @param alignment Vector + */ + public void UpdatePlaceHolders(Vector alignment) { + Vector leaves = new Vector(); + findLeaves(top, leaves); + int sz = leaves.size(); + SequenceIdMatcher seqmatcher = null; + int i = 0; - done[minj] = 1; + while (i < sz) { + SequenceNode leaf = (SequenceNode) leaves.elementAt(i++); - cluster.setElementAt(null,minj); - cluster.setElementAt(c,mini); + if (alignment.contains(leaf.element())) { + leaf.setPlaceholder(false); + } else { + if (seqmatcher == null) { + // Only create this the first time we need it + SequenceI[] seqs = new SequenceI[alignment.size()]; - noClus--; - } + for (int j = 0; j < seqs.length; j++) + seqs[j] = (SequenceI) alignment.elementAt(j); - boolean onefound = false; + seqmatcher = new SequenceIdMatcher(seqs); + } - int one = -1; - int two = -1; + SequenceI nam = seqmatcher.findIdMatch(leaf.getName()); - for (int i=0; i < noseqs; i++) { - if (done[i] != 1) { - if (onefound == false) { - two = i; - onefound = true; - } else { - one = i; + if (nam != null) { + leaf.setPlaceholder(false); + leaf.setElement(nam); + } else { + leaf.setPlaceholder(true); + } + } } - } } - Cluster c = joinClusters(one,two); - top = (SequenceNode)(node.elementAt(one)); + public void cluster() { + while (noClus > 2) { + if (type.equals("NJ")) { + float mind = findMinNJDistance(); + } else { + float mind = findMinDistance(); + } - reCount(top); - findHeight(top); - findMaxDist(top); + Cluster c = joinClusters(mini, minj); - } + done[minj] = 1; - public Cluster joinClusters(int i, int j) { + cluster.setElementAt(null, minj); + cluster.setElementAt(c, mini); - float dist = distance[i][j]; + noClus--; + } - int noi = ((Cluster)cluster.elementAt(i)).value.length; - int noj = ((Cluster)cluster.elementAt(j)).value.length; + boolean onefound = false; - int[] value = new int[noi + noj]; + int one = -1; + int two = -1; - for (int ii = 0; ii < noi;ii++) { - value[ii] = ((Cluster)cluster.elementAt(i)).value[ii]; - } + for (int i = 0; i < noseqs; i++) { + if (done[i] != 1) { + if (onefound == false) { + two = i; + onefound = true; + } else { + one = i; + } + } + } + + Cluster c = joinClusters(one, two); + top = (SequenceNode) (node.elementAt(one)); - for (int ii = noi; ii < noi+ noj;ii++) { - value[ii] = ((Cluster)cluster.elementAt(j)).value[ii-noi]; + reCount(top); + findHeight(top); + findMaxDist(top); } - Cluster c = new Cluster(value); + public Cluster joinClusters(int i, int j) { + float dist = distance[i][j]; - ri = findr(i,j); - rj = findr(j,i); + int noi = ((Cluster) cluster.elementAt(i)).value.length; + int noj = ((Cluster) cluster.elementAt(j)).value.length; - if (type.equals("NJ")) { - findClusterNJDistance(i,j); - } else { - findClusterDistance(i,j); - } + int[] value = new int[noi + noj]; + + for (int ii = 0; ii < noi; ii++) { + value[ii] = ((Cluster) cluster.elementAt(i)).value[ii]; + } - SequenceNode sn = new SequenceNode(); + for (int ii = noi; ii < (noi + noj); ii++) { + value[ii] = ((Cluster) cluster.elementAt(j)).value[ii - noi]; + } - sn.setLeft((SequenceNode)(node.elementAt(i))); - sn.setRight((SequenceNode)(node.elementAt(j))); + Cluster c = new Cluster(value); - SequenceNode tmpi = (SequenceNode)(node.elementAt(i)); - SequenceNode tmpj = (SequenceNode)(node.elementAt(j)); + ri = findr(i, j); + rj = findr(j, i); - if (type.equals("NJ")) { - findNewNJDistances(tmpi,tmpj,dist); - } else { - findNewDistances(tmpi,tmpj,dist); - } + if (type.equals("NJ")) { + findClusterNJDistance(i, j); + } else { + findClusterDistance(i, j); + } - tmpi.setParent(sn); - tmpj.setParent(sn); + SequenceNode sn = new SequenceNode(); - node.setElementAt(sn,i); - return c; - } + sn.setLeft((SequenceNode) (node.elementAt(i))); + sn.setRight((SequenceNode) (node.elementAt(j))); - public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj, float dist) { + SequenceNode tmpi = (SequenceNode) (node.elementAt(i)); + SequenceNode tmpj = (SequenceNode) (node.elementAt(j)); - float ih = 0; - float jh = 0; + if (type.equals("NJ")) { + findNewNJDistances(tmpi, tmpj, dist); + } else { + findNewDistances(tmpi, tmpj, dist); + } - SequenceNode sni = tmpi; - SequenceNode snj = tmpj; + tmpi.setParent(sn); + tmpj.setParent(sn); - tmpi.dist = (dist + ri - rj)/2; - tmpj.dist = (dist - tmpi.dist); + node.setElementAt(sn, i); - if (tmpi.dist < 0) { - tmpi.dist = 0; + return c; } - if (tmpj.dist < 0) { - tmpj.dist = 0; - } - } - public void findNewDistances(SequenceNode tmpi,SequenceNode tmpj,float dist) { + public void findNewNJDistances(SequenceNode tmpi, SequenceNode tmpj, + float dist) { + float ih = 0; + float jh = 0; - float ih = 0; - float jh = 0; + SequenceNode sni = tmpi; + SequenceNode snj = tmpj; - SequenceNode sni = tmpi; - SequenceNode snj = tmpj; + tmpi.dist = ((dist + ri) - rj) / 2; + tmpj.dist = (dist - tmpi.dist); - while (sni != null) { - ih = ih + sni.dist; - sni = (SequenceNode)sni.left(); - } + if (tmpi.dist < 0) { + tmpi.dist = 0; + } - while (snj != null) { - jh = jh + snj.dist; - snj = (SequenceNode)snj.left(); + if (tmpj.dist < 0) { + tmpj.dist = 0; + } } - tmpi.dist = (dist/2 - ih); - tmpj.dist = (dist/2 - jh); - } + public void findNewDistances(SequenceNode tmpi, SequenceNode tmpj, + float dist) { + float ih = 0; + float jh = 0; + SequenceNode sni = tmpi; + SequenceNode snj = tmpj; + while (sni != null) { + ih = ih + sni.dist; + sni = (SequenceNode) sni.left(); + } - public void findClusterDistance(int i, int j) { + while (snj != null) { + jh = jh + snj.dist; + snj = (SequenceNode) snj.left(); + } - int noi = ((Cluster)cluster.elementAt(i)).value.length; - int noj = ((Cluster)cluster.elementAt(j)).value.length; + tmpi.dist = ((dist / 2) - ih); + tmpj.dist = ((dist / 2) - jh); + } - // New distances from cluster to others - float[] newdist = new float[noseqs]; + public void findClusterDistance(int i, int j) { + int noi = ((Cluster) cluster.elementAt(i)).value.length; + int noj = ((Cluster) cluster.elementAt(j)).value.length; - 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 { - newdist[l] = 0; - } - } + // New distances from cluster to others + float[] newdist = new float[noseqs]; + + 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 { + newdist[l] = 0; + } + } - for (int ii=0; ii < noseqs;ii++) { - distance[i][ii] = newdist[ii]; - distance[ii][i] = newdist[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) { + public void findClusterNJDistance(int i, int j) { + int noi = ((Cluster) cluster.elementAt(i)).value.length; + int noj = ((Cluster) cluster.elementAt(j)).value.length; - 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]; - // New distances from cluster to others - float[] newdist = new float[noseqs]; + 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 { + newdist[l] = 0; + } + } - 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 { - newdist[l] = 0; - } + for (int ii = 0; ii < noseqs; ii++) { + distance[i][ii] = newdist[ii]; + distance[ii][i] = newdist[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) { + float tmp = 1; + + for (int k = 0; k < noseqs; k++) { + if ((k != i) && (k != j) && (done[k] != 1)) { + tmp = tmp + distance[i][k]; + } + } + + if (noClus > 2) { + tmp = tmp / (noClus - 2); + } + + return tmp; } - } - public float findr(int i, int j) { + 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)) { + float tmp = distance[i][j] - (findr(i, j) + findr(j, i)); + + if (tmp < min) { + mini = i; + minj = j; - float tmp = 1; - for (int k=0; k < noseqs;k++) { - if (k!= i && k!= j && done[k] != 1) { - tmp = tmp + distance[i][k]; - } + min = tmp; + } + } + } + } + + return min; } - if (noClus > 2) { - tmp = tmp/(noClus - 2); + 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) { + mini = i; + minj = j; + + min = distance[i][j]; + } + } + } + } + + return min; + } + + 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) { + distance[i][i] = 0; + } else { + distance[i][j] = 100 - + Comparison.PID(sequence[i], sequence[j], start, end); + distance[j][i] = distance[i][j]; + } + } + } + } else if (pwtype.equals("BL")) { + int maxscore = 0; + + 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 { + score += ResidueProperties.getBLOSUM62(sequence[i].getSequence( + k, k + 1), sequence[j].getSequence(k, k + + 1)); + } catch (Exception ex) { + System.err.println("err creating BLOSUM62 tree"); + ex.printStackTrace(); + } + } + + distance[i][j] = (float) score; + + if (score > maxscore) { + maxscore = score; + } + } + } + + 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")) { + float max = -1; + + 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]) { + max = distance[i][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]; + } + } + } + + return distance; } - return tmp; - } + public void makeLeaves() { + cluster = new Vector(); + + for (int i = 0; i < noseqs; i++) { + SequenceNode sn = new SequenceNode(); - public float findMinNJDistance() { + sn.setElement(sequence[i]); + sn.setName(sequence[i].getName()); + node.addElement(sn); - float min = 100000; + int[] value = new int[1]; + value[0] = i; - 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) { + Cluster c = new Cluster(value); + cluster.addElement(c); + } + } - mini = i; - minj = j; + public Vector findLeaves(SequenceNode node, Vector leaves) { + if (node == null) { + return leaves; + } - min = tmp; + if ((node.left() == null) && (node.right() == null)) { + leaves.addElement(node); - } + return leaves; + } else { + findLeaves((SequenceNode) node.left(), leaves); + findLeaves((SequenceNode) node.right(), leaves); } - } + + return leaves; } - return min; - } - public float findMinDistance() { + public Object findLeaf(SequenceNode node, int count) { + found = _findLeaf(node, count); - float min = 100000; + return found; + } - 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; + public Object _findLeaf(SequenceNode node, int count) { + if (node == null) { + return null; + } - min = distance[i][j]; - } + if (node.ycount == count) { + found = node.element(); + + return found; + } else { + _findLeaf((SequenceNode) node.left(), count); + _findLeaf((SequenceNode) node.right(), count); } - } + + return found; } - return min; - } - public float[][] findDistances() { + /** + * printNode is mainly for debugging purposes. + * + * @param node SequenceNode + */ + public void printNode(SequenceNode node) { + if (node == null) { + return; + } + + 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 { + System.out.println("Dist " + ((SequenceNode) node).dist); + printNode((SequenceNode) node.left()); + printNode((SequenceNode) node.right()); + } + } - 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) { - distance[i][i] = 0; - } else { - distance[i][j] = 100-Comparison.PID(sequence[i], sequence[j], start, end); - distance[j][i] = distance[i][j]; - } + public void findMaxDist(SequenceNode node) { + if (node == null) { + return; } - } - } else if (pwtype.equals("BL")) { - int maxscore = 0; - 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{ - score += - ResidueProperties.getBLOSUM62(sequence[i].getSequence(k, - k + 1), - sequence[j].getSequence(k, - k + 1)); - }catch(Exception ex){System.err.println("err creating BLOSUM62 tree");ex.printStackTrace();} - } - distance[i][j] = (float)score; - if (score > maxscore) { - maxscore = score; - } + if ((node.left() == null) && (node.right() == null)) { + float dist = ((SequenceNode) node).dist; + + if (dist > maxDistValue) { + maxdist = (SequenceNode) node; + maxDistValue = dist; + } + } else { + findMaxDist((SequenceNode) node.left()); + findMaxDist((SequenceNode) node.right()); } - } - 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")) { - float max = -1; - 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]) { - max = distance[i][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]; - } - } - } - - return distance; - } - - public void makeLeaves() { - cluster = new Vector(); - - for (int i=0; i < noseqs; i++) { - SequenceNode sn = new SequenceNode(); - - sn.setElement(sequence[i]); - sn.setName(sequence[i].getName()); - node.addElement(sn); - - int[] value = new int[1]; - value[0] = i; - - Cluster c = new Cluster(value); - cluster.addElement(c); - } - } - - public Vector findLeaves(SequenceNode node, Vector leaves) { - if (node == null) { - return leaves; - } - - if (node.left() == null && node.right() == null) { - leaves.addElement(node); - return leaves; - } else { - findLeaves((SequenceNode)node.left(),leaves); - findLeaves((SequenceNode)node.right(),leaves); - } - return leaves; - } - - public Object findLeaf(SequenceNode node, int count) { - found = _findLeaf(node,count); - - return found; - } - public Object _findLeaf(SequenceNode node,int count) { - if (node == null) { - return null; - } - if (node.ycount == count) { - found = node.element(); - return found; - } else { - _findLeaf((SequenceNode)node.left(),count); - _findLeaf((SequenceNode)node.right(),count); - } - - return found; - } - - /** - * printNode is mainly for debugging purposes. - * - * @param node SequenceNode - */ - public void printNode(SequenceNode node) { - if (node == null) { - return; - } - 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 { - System.out.println("Dist " + ((SequenceNode)node).dist); - printNode((SequenceNode)node.left()); - printNode((SequenceNode)node.right()); - } - } - public void findMaxDist(SequenceNode node) { - if (node == null) { - return; - } - if (node.left() == null && node.right() == null) { - - float dist = ((SequenceNode)node).dist; - if (dist > maxDistValue) { - maxdist = (SequenceNode)node; - maxDistValue = dist; - } - } else { - findMaxDist((SequenceNode)node.left()); - findMaxDist((SequenceNode)node.right()); } - } + public Vector getGroups() { return groups; } + public float getMaxHeight() { return maxheight; } - public void groupNodes(SequenceNode node, float threshold) { - if (node == null) { - return; + + public void groupNodes(SequenceNode node, float threshold) { + if (node == null) { + return; + } + + if ((node.height / maxheight) > threshold) { + groups.addElement(node); + } else { + groupNodes((SequenceNode) node.left(), threshold); + groupNodes((SequenceNode) node.right(), threshold); + } } - if (node.height/maxheight > threshold) { - groups.addElement(node); - } else { - groupNodes((SequenceNode)node.left(),threshold); - groupNodes((SequenceNode)node.right(),threshold); + public float findHeight(SequenceNode node) { + if (node == null) { + return maxheight; + } + + if ((node.left() == null) && (node.right() == null)) { + node.height = ((SequenceNode) node.parent()).height + node.dist; + + if (node.height > maxheight) { + return node.height; + } else { + return maxheight; + } + } else { + if (node.parent() != null) { + node.height = ((SequenceNode) node.parent()).height + + node.dist; + } else { + maxheight = 0; + node.height = (float) 0.0; + } + + maxheight = findHeight((SequenceNode) (node.left())); + maxheight = findHeight((SequenceNode) (node.right())); + } + + return maxheight; } - } - public float findHeight(SequenceNode node) { + public SequenceNode reRoot() { + if (maxdist != null) { + ycount = 0; + + float tmpdist = maxdist.dist; + + // New top + SequenceNode sn = new SequenceNode(); + sn.setParent(null); + + // New right hand of top + SequenceNode snr = (SequenceNode) maxdist.parent(); + changeDirection(snr, maxdist); + System.out.println("Printing reversed tree"); + printN(snr); + snr.dist = tmpdist / 2; + maxdist.dist = tmpdist / 2; + + snr.setParent(sn); + maxdist.setParent(sn); + + sn.setRight(snr); + sn.setLeft(maxdist); - if (node == null) { - return maxheight; + top = sn; + + ycount = 0; + reCount(top); + findHeight(top); + } + + return top; } - if (node.left() == null && node.right() == null) { - node.height = ((SequenceNode)node.parent()).height + node.dist; + public static void printN(SequenceNode node) { + if (node == null) { + return; + } - if (node.height > maxheight) { - return node.height; - } else { - return maxheight; - } - } else { - if (node.parent() != null) { - node.height = ((SequenceNode)node.parent()).height + node.dist; - } else { - maxheight = 0; - node.height = (float)0.0; - } - - maxheight = findHeight((SequenceNode)(node.left())); - maxheight = findHeight((SequenceNode)(node.right())); - } - return maxheight; - } - public SequenceNode reRoot() { - if (maxdist != null) { - ycount = 0; - float tmpdist = maxdist.dist; - - // New top - SequenceNode sn = new SequenceNode(); - sn.setParent(null); - - // New right hand of top - SequenceNode snr = (SequenceNode)maxdist.parent(); - changeDirection(snr,maxdist); - System.out.println("Printing reversed tree"); - printN(snr); - snr.dist = tmpdist/2; - maxdist.dist = tmpdist/2; - - snr.setParent(sn); - maxdist.setParent(sn); - - sn.setRight(snr); - sn.setLeft(maxdist); - - top = sn; - - ycount = 0; - reCount(top); - findHeight(top); - - } - return top; - } - public static void printN(SequenceNode node) { - if (node == null) { - return; - } - - if (node.left() != null && node.right() != null) { - printN((SequenceNode)node.left()); - printN((SequenceNode)node.right()); - } else { - System.out.println(" name = " + ((SequenceI)node.element()).getName()); - } - System.out.println(" dist = " + ((SequenceNode)node).dist + " " + ((SequenceNode)node).count + " " + ((SequenceNode)node).height); - } + if ((node.left() != null) && (node.right() != null)) { + printN((SequenceNode) node.left()); + printN((SequenceNode) node.right()); + } else { + System.out.println(" name = " + + ((SequenceI) node.element()).getName()); + } + + System.out.println(" dist = " + ((SequenceNode) node).dist + " " + + ((SequenceNode) node).count + " " + ((SequenceNode) node).height); + } public void reCount(SequenceNode node) { ycount = 0; _reCount(node); } - public void _reCount(SequenceNode node) { - if (node == null) { - return; - } - if (node.left() != null && node.right() != null) { - _reCount((SequenceNode)node.left()); - _reCount((SequenceNode)node.right()); + public void _reCount(SequenceNode node) { + if (node == null) { + return; + } - SequenceNode l = (SequenceNode)node.left(); - SequenceNode r = (SequenceNode)node.right(); + if ((node.left() != null) && (node.right() != null)) { + _reCount((SequenceNode) node.left()); + _reCount((SequenceNode) node.right()); - ((SequenceNode)node).count = l.count + r.count; - ((SequenceNode)node).ycount = (l.ycount + r.ycount)/2; + SequenceNode l = (SequenceNode) node.left(); + SequenceNode r = (SequenceNode) node.right(); - } else { - ((SequenceNode)node).count = 1; - ((SequenceNode)node).ycount = ycount++; + ((SequenceNode) node).count = l.count + r.count; + ((SequenceNode) node).ycount = (l.ycount + r.ycount) / 2; + } else { + ((SequenceNode) node).count = 1; + ((SequenceNode) node).ycount = ycount++; + } } - } public void swapNodes(SequenceNode node) { if (node == null) { return; } - SequenceNode tmp = (SequenceNode)node.left(); + + SequenceNode tmp = (SequenceNode) node.left(); node.setLeft(node.right()); node.setRight(tmp); } - public void changeDirection(SequenceNode node, SequenceNode dir) { - if (node == null) { - return; - } - if (node.parent() != top) { - changeDirection((SequenceNode)node.parent(), node); - - SequenceNode tmp = (SequenceNode)node.parent(); - if (dir == node.left()) { - node.setParent(dir); - node.setLeft(tmp); - } else if (dir == node.right()) { - node.setParent(dir); - node.setRight(tmp); - } + public void changeDirection(SequenceNode node, SequenceNode dir) { + if (node == null) { + return; + } - } else { - if (dir == node.left()) { - node.setParent(node.left()); + if (node.parent() != top) { + changeDirection((SequenceNode) node.parent(), node); - if (top.left() == node) { - node.setRight(top.right()); - } else { - node.setRight(top.left()); - } - } else { - node.setParent(node.right()); + SequenceNode tmp = (SequenceNode) node.parent(); - if (top.left() == node) { - node.setLeft(top.right()); + if (dir == node.left()) { + node.setParent(dir); + node.setLeft(tmp); + } else if (dir == node.right()) { + node.setParent(dir); + node.setRight(tmp); + } } else { - node.setLeft(top.left()); + if (dir == node.left()) { + node.setParent(node.left()); + + if (top.left() == node) { + node.setRight(top.right()); + } else { + node.setRight(top.left()); + } + } else { + node.setParent(node.right()); + + if (top.left() == node) { + node.setLeft(top.right()); + } else { + node.setLeft(top.left()); + } + } } - } } - } + public void setMaxDist(SequenceNode node) { this.maxdist = maxdist; } + public SequenceNode getMaxDist() { return maxdist; } + public SequenceNode getTopNode() { return top; } - } - class Cluster { + int[] value; - int[] value; - - public Cluster(int[] value) { - this.value = value; - } - + public Cluster(int[] value) { + this.value = value; + } } - diff --git a/src/jalview/analysis/PCA.java b/src/jalview/analysis/PCA.java index 3948695..ecbe4ab 100755 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@ -16,193 +16,202 @@ * 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.math.*; import jalview.datamodel.*; + +import jalview.math.*; + import jalview.util.*; import java.awt.*; + import java.io.*; -public class PCA implements Runnable { - Matrix m; - Matrix symm; - Matrix m2; - double[] eigenvalue; - Matrix eigenvector; +public class PCA implements Runnable { + Matrix m; + Matrix symm; + Matrix m2; + double[] eigenvalue; + Matrix eigenvector; + + public PCA(Matrix m) { + this.m = m; + } - public PCA(Matrix m) { - this.m = m; - } + public PCA(SequenceI[] s) { + Runtime rt = Runtime.getRuntime(); + + BinarySequence[] bs = new BinarySequence[s.length]; + int ii = 0; + + while ((ii < s.length) && (s[ii] != null)) { + bs[ii] = new BinarySequence(s[ii]); + bs[ii].encode(); + ii++; + } + + BinarySequence[] bs2 = new BinarySequence[s.length]; + ii = 0; + + while ((ii < s.length) && (s[ii] != null)) { + bs2[ii] = new BinarySequence(s[ii]); + bs2[ii].blosumEncode(); + ii++; + } + + //System.out.println("Created binary encoding"); + //printMemory(rt); + int count = 0; + + while ((count < bs.length) && (bs[count] != null)) { + count++; + } + + double[][] seqmat = new double[count][bs[0].getDBinary().length]; + double[][] seqmat2 = new double[count][bs2[0].getDBinary().length]; + int i = 0; + + while (i < count) { + seqmat[i] = bs[i].getDBinary(); + seqmat2[i] = bs2[i].getDBinary(); + i++; + } + + //System.out.println("Created array"); + //printMemory(rt); + // System.out.println(" --- Original matrix ---- "); + 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 PCA(SequenceI[] s) { - Runtime rt = Runtime.getRuntime(); + public static void printMemory(Runtime rt) { + System.out.println("PCA:Free memory = " + rt.freeMemory()); + } - BinarySequence[] bs = new BinarySequence[s.length]; - int ii = 0; - while (ii < s.length && s[ii] != null) { + public Matrix getM() { + return m; + } - bs[ii] = new BinarySequence(s[ii]); - bs[ii].encode(); - ii++; + public double[] getEigenvector(int i) { + return eigenvector.getColumn(i); } - BinarySequence[] bs2 = new BinarySequence[s.length]; - ii = 0; - while (ii < s.length && s[ii] != null) { + public double getEigenvalue(int i) { + return eigenvector.d[i]; + } - bs2[ii] = new BinarySequence(s[ii]); - bs2[ii].blosumEncode(); - ii++; + 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) { + float[][] out = new float[m.rows][3]; - //System.out.println("Created binary encoding"); - //printMemory(rt); + 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; + } - int count=0; - while (count < bs.length && bs[count] != null) { - count++; - } - double[][] seqmat = new double[count][bs[0].getDBinary().length]; - double[][] seqmat2 = new double[count][bs2[0].getDBinary().length]; - int i=0; - while (i < count) { - seqmat[i] = bs[i].getDBinary(); - seqmat2[i] = bs2[i].getDBinary(); - i++; + return out; } - //System.out.println("Created array"); - //printMemory(rt); - // System.out.println(" --- Original matrix ---- "); - 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()); - } - - public Matrix getM() { - return m; - } - - public double[] getEigenvector(int i) { - return eigenvector.getColumn(i); - } - - 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) { - float[][] out = new float[m.rows][3]; - - 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; - } - return out; - } - public double[] component(int n) { - // n = index of eigenvector - double[] out = new double[m.rows]; + public double[] component(int n) { + // n = index of eigenvector + double[] out = new double[m.rows]; - for (int i=0; i < m.rows; i++) { - out[i] = component(i,n); - } - return out; - } - public double component(int row, int n) { - double out = 0.0; + for (int i = 0; i < m.rows; i++) { + out[i] = component(i, n); + } - for (int i = 0; i < symm.cols; i++) { - out += symm.value[row][i] * eigenvector.value[i][n]; + return out; } - return out/eigenvector.d[n]; - } - public void checkEigenvector(int n,PrintStream ps) { - ps.println(" --- Eigenvector " + n + " --- "); + public double component(int row, int n) { + double out = 0.0; - double[] eigenv = eigenvector.getColumn(n); + for (int i = 0; i < symm.cols; i++) { + out += (symm.value[row][i] * eigenvector.value[i][n]); + } - for (int i=0; i < eigenv.length;i++) { - Format.print(ps,"%15.4f",eigenv[i]); + return out / eigenvector.d[n]; } - System.out.println(); + public void checkEigenvector(int n, PrintStream ps) { + ps.println(" --- Eigenvector " + n + " --- "); + + double[] eigenv = eigenvector.getColumn(n); - 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]); - } + 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(); } - System.out.println(); - } - - public void run() { - Matrix mt = m.transpose(); - // System.out.println(" --- OrigT * Orig ---- "); - eigenvector = mt.preMultiply(m2); - // eigenvector.print(System.out); - symm = eigenvector.copy(); - - //TextArea ta = new TextArea(25,72); - //TextAreaPrintStream taps = new TextAreaPrintStream(System.out,ta); - //Frame f = new Frame("PCA output"); - //f.resize(500,500); - //f.setLayout(new BorderLayout()); - //f.add("Center",ta); - //f.show(); - //symm.print(taps); - long tstart = System.currentTimeMillis(); - eigenvector.tred(); - long tend = System.currentTimeMillis(); - //taps.println("Time take for tred = " + (tend-tstart) + "ms"); - //taps.println(" ---Tridiag transform matrix ---"); - - //taps.println(" --- D vector ---"); - //eigenvector.printD(taps); - //taps.println(); - //taps.println(" --- E vector ---"); - // eigenvector.printE(taps); - //taps.println(); - - // Now produce the diagonalization matrix - tstart = System.currentTimeMillis(); - eigenvector.tqli(); - tend = System.currentTimeMillis(); - //System.out.println("Time take for tqli = " + (tend-tstart) + " ms"); - - //System.out.println(" --- New diagonalization matrix ---"); - - //System.out.println(" --- Eigenvalues ---"); - //eigenvector.printD(taps); - - //System.out.println(); - - // for (int i=0; i < eigenvector.cols; i++) { - // checkEigenvector(i,taps); - // taps.println(); - // } - - // taps.println(); - // taps.println("Transformed sequences = "); - // Matrix trans = m.preMultiply(eigenvector); - // trans.print(System.out); - } + public void run() { + Matrix mt = m.transpose(); + + // System.out.println(" --- OrigT * Orig ---- "); + eigenvector = mt.preMultiply(m2); + + // eigenvector.print(System.out); + symm = eigenvector.copy(); + + //TextArea ta = new TextArea(25,72); + //TextAreaPrintStream taps = new TextAreaPrintStream(System.out,ta); + //Frame f = new Frame("PCA output"); + //f.resize(500,500); + //f.setLayout(new BorderLayout()); + //f.add("Center",ta); + //f.show(); + //symm.print(taps); + long tstart = System.currentTimeMillis(); + eigenvector.tred(); + + long tend = System.currentTimeMillis(); + + //taps.println("Time take for tred = " + (tend-tstart) + "ms"); + //taps.println(" ---Tridiag transform matrix ---"); + //taps.println(" --- D vector ---"); + //eigenvector.printD(taps); + //taps.println(); + //taps.println(" --- E vector ---"); + // eigenvector.printE(taps); + //taps.println(); + // Now produce the diagonalization matrix + tstart = System.currentTimeMillis(); + eigenvector.tqli(); + tend = System.currentTimeMillis(); + + //System.out.println("Time take for tqli = " + (tend-tstart) + " ms"); + //System.out.println(" --- New diagonalization matrix ---"); + //System.out.println(" --- Eigenvalues ---"); + //eigenvector.printD(taps); + //System.out.println(); + // for (int i=0; i < eigenvector.cols; i++) { + // checkEigenvector(i,taps); + // taps.println(); + // } + // taps.println(); + // taps.println("Transformed sequences = "); + // Matrix trans = m.preMultiply(eigenvector); + // trans.print(System.out); + } } diff --git a/src/jalview/analysis/SeqsetUtils.java b/src/jalview/analysis/SeqsetUtils.java index faa08e1..8a8ae28 100755 --- a/src/jalview/analysis/SeqsetUtils.java +++ b/src/jalview/analysis/SeqsetUtils.java @@ -15,13 +15,14 @@ * 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; - +*/ +package jalview.analysis; + +import jalview.datamodel.SequenceI; + +import java.util.Hashtable; + + /** *

Title:

* @@ -33,97 +34,105 @@ import java.util.Hashtable; * * @author not attributable * @version 1.0 - */ -public class SeqsetUtils -{ + */ +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; - 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; - } - - /** - * 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 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; - } - -} + * 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; + } 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; + } + + /** + * 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 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 1c156cd..f786243 100755 --- a/src/jalview/analysis/SequenceIdMatcher.java +++ b/src/jalview/analysis/SequenceIdMatcher.java @@ -15,14 +15,15 @@ * 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 java.util.Vector; -import java.util.Hashtable; -import jalview.datamodel.SequenceI; - +*/ +package jalview.analysis; + +import jalview.datamodel.SequenceI; + +import java.util.Hashtable; +import java.util.Vector; + + /** *

Title:

* SequenceIdMatcher @@ -34,123 +35,105 @@ import jalview.datamodel.SequenceI; * * @author not attributable * @version 1.0 - */ -public class SequenceIdMatcher -{ - - private class SeqIdName - { - String id; - - SeqIdName(String s) - { - id = new String(s); - } - - public int hashCode() - { - return (id.substring(0, 4).hashCode()); - } - - public boolean equals(Object s) - { - if (s instanceof SeqIdName) - { - return this.equals( (SeqIdName) s); - } - else - { - if (s instanceof String) - { - return this.equals( (String) s); - } - } - return false; - } - - public boolean equals(SeqIdName s) - { - if (id.startsWith(s.id) || s.id.startsWith(id)) - { - return true; - } - return false; - } - - public boolean equals(String s) - { - if (id.startsWith(s) || s.startsWith(id)) - { - return true; - } - return false; - } - } - - private Hashtable names; - - public SequenceIdMatcher(SequenceI[] seqs) - { - names = new Hashtable(); - 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()); - if (names.containsKey(nam)) - { - return (SequenceI) names.get(nam); - } - return null; - } - - SequenceI findIdMatch(String seqnam) - { - SeqIdName nam = new SeqIdName(seqnam); - if (names.containsKey(nam)) - { - return (SequenceI) names.get(nam); - } - 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); - } - else - { - namedseqs[i] = null; - } - } - while (i++ < seqs.length); - } - return namedseqs; - } - -} + */ +public class SequenceIdMatcher { + private Hashtable names; + + public SequenceIdMatcher(SequenceI[] seqs) { + names = new Hashtable(); + + 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()); + + if (names.containsKey(nam)) { + return (SequenceI) names.get(nam); + } + + return null; + } + + SequenceI findIdMatch(String seqnam) { + SeqIdName nam = new SeqIdName(seqnam); + + if (names.containsKey(nam)) { + return (SequenceI) names.get(nam); + } + + 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); + } else { + namedseqs[i] = null; + } + } while (i++ < seqs.length); + } + + return namedseqs; + } + + private class SeqIdName { + String id; + + SeqIdName(String s) { + id = new String(s); + } + + public int hashCode() { + return (id.substring(0, 4).hashCode()); + } + + public boolean equals(Object s) { + if (s instanceof SeqIdName) { + return this.equals((SeqIdName) s); + } else { + if (s instanceof String) { + return this.equals((String) s); + } + } + + return false; + } + + public boolean equals(SeqIdName s) { + if (id.startsWith(s.id) || s.id.startsWith(id)) { + return true; + } + + return false; + } + + public boolean equals(String s) { + if (id.startsWith(s) || s.startsWith(id)) { + return true; + } + + return false; + } + } +} diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 42643d0..42546f9 100755 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -1,31 +1,33 @@ /* -* 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.appletgui; -import jalview.datamodel.*; -import jalview.analysis.*; -import jalview.schemes.*; import java.awt.*; import java.awt.event.*; -public class APopupMenu extends java.awt.PopupMenu +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.schemes.*; + +public class APopupMenu + extends java.awt.PopupMenu { Menu groupMenu = new Menu(); protected MenuItem clustalColour = new MenuItem(); @@ -43,7 +45,6 @@ public class APopupMenu extends java.awt.PopupMenu MenuItem noColourmenuItem = new MenuItem(); protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); - AlignmentPanel ap; Menu sequenceMenu = new Menu(); MenuItem sequenceName = new MenuItem(); @@ -68,28 +69,36 @@ public class APopupMenu extends java.awt.PopupMenu sequence = seq; try - { jbInit(); } - catch(Exception e) - { e.printStackTrace(); } - + { + jbInit(); + } + catch (Exception e) + { + e.printStackTrace(); + } SequenceGroup sg = ap.av.getSelectionGroup(); - if(sg!=null) + if (sg != null) { showText.setState(sg.getDisplayText()); showColourText.setState(sg.getColourText()); showBoxes.setState(sg.getDisplayBoxes()); } - if( !ap.av.alignment.getGroups().contains(sg)) - groupMenu.remove(unGroupMenuItem); - - if(seq==null) - remove(sequenceMenu); + if (!ap.av.alignment.getGroups().contains(sg)) + { + groupMenu.remove(unGroupMenuItem); + } + if (seq == null) + { + remove(sequenceMenu); + } } - private void jbInit() throws Exception + + private void jbInit() + throws Exception { groupMenu.setLabel("Group"); groupMenu.setLabel("Define"); @@ -105,7 +114,6 @@ public class APopupMenu extends java.awt.PopupMenu } }); - nucleotideMenuItem.setLabel("Nucleotide"); nucleotideMenuItem.addActionListener(new ActionListener() { @@ -283,15 +291,16 @@ public class APopupMenu extends java.awt.PopupMenu }); conservationMenuItem.setLabel("Conservation"); - } void refresh() { SequenceGroup sg = getGroup(); - SuperGroup superG = ap.av.alignment.getSuperGroup( sg ); - if( superG !=null) - superG.setSuperGroupProperties( sg ); + SuperGroup superG = ap.av.alignment.getSuperGroup(sg); + if (superG != null) + { + superG.setSuperGroupProperties(sg); + } ap.seqPanel.seqCanvas.repaint(); } @@ -315,7 +324,6 @@ public class APopupMenu extends java.awt.PopupMenu refresh(); } - protected void hydrophobicityColour_actionPerformed(ActionEvent e) { getGroup().cs = new HydrophobicColourScheme(); @@ -352,8 +360,6 @@ public class APopupMenu extends java.awt.PopupMenu refresh(); } - - protected void abovePIDColour_itemStateChanged(ItemEvent ie) { SequenceGroup sg = getGroup(); @@ -361,15 +367,19 @@ public class APopupMenu extends java.awt.PopupMenu { sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, ap.av.alignment.getWidth())); - int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup().getName()); + int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, + getGroup().getName()); if (sg.cs instanceof ResidueColourScheme) - ( (ResidueColourScheme)sg. cs).setThreshold(threshold); + { + ( (ResidueColourScheme) sg.cs).setThreshold(threshold); + } else if (sg.cs instanceof ScoreColourScheme) + { ( (ScoreColourScheme) sg.cs).setThreshold(threshold); + } SliderPanel.showPIDSlider(); - } else // remove PIDColouring { @@ -382,10 +392,9 @@ public class APopupMenu extends java.awt.PopupMenu } - protected void userDefinedColour_actionPerformed(ActionEvent e) { - new UserDefinedColours( ap, getGroup()); + new UserDefinedColours(ap, getGroup()); } protected void PIDColour_actionPerformed(ActionEvent e) @@ -393,7 +402,7 @@ public class APopupMenu extends java.awt.PopupMenu SequenceGroup sg = getGroup(); sg.cs = new PIDColourScheme(); sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); + ap.av.alignment.getWidth())); refresh(); } @@ -404,34 +413,32 @@ public class APopupMenu extends java.awt.PopupMenu sg.cs = new Blosum62ColourScheme(); sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, - ap.av.alignment.getWidth())); + ap.av.alignment.getWidth())); refresh(); } - protected void noColourmenuItem_actionPerformed(ActionEvent e) { getGroup().cs = null; refresh(); } - protected void conservationMenuItem_itemStateChanged(ItemEvent ie) + protected void conservationMenuItem_itemStateChanged(ItemEvent ie) { SequenceGroup sg = getGroup(); - if(conservationMenuItem.getState()) + if (conservationMenuItem.getState()) { - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, 0, - ap.av.alignment.getWidth()); - - c.calculate(); - c.verdict(false, ap.av.ConsPercGaps); - ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, + sg.sequences, 0, + ap.av.alignment.getWidth()); + c.calculate(); + c.verdict(false, ap.av.ConsPercGaps); + ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs); sg.cs = ccs; @@ -440,32 +447,31 @@ public class APopupMenu extends java.awt.PopupMenu } else // remove ConservationColouring { - ConservationColourScheme ccs = (ConservationColourScheme)sg.cs; - sg.cs = ccs.cs; + ConservationColourScheme ccs = (ConservationColourScheme) sg.cs; + sg.cs = ccs.cs; } - refresh(); + refresh(); } - protected void analyze_actionPerformed(ActionEvent e) { - CutAndPasteTransfer cap = new CutAndPasteTransfer(false); - Frame frame = new Frame(); - frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, "Analyze this - ", 400, 300); - SequenceGroup sg = getGroup(); - StringBuffer sb = new StringBuffer(); - - for(int i=0; i0) - { - undoMenuItem.setEnabled(true); - HistoryItem hi = (HistoryItem)historyList.peek(); - undoMenuItem.setLabel("Undo "+hi.getDescription()); - } - else - { - undoMenuItem.setEnabled(false); - undoMenuItem.setLabel("Undo"); - } + { + if (historyList.size() > 0) + { + undoMenuItem.setEnabled(true); + HistoryItem hi = (HistoryItem) historyList.peek(); + undoMenuItem.setLabel("Undo " + hi.getDescription()); + } + else + { + undoMenuItem.setEnabled(false); + undoMenuItem.setLabel("Undo"); + } - if(redoList.size()>0) - { - redoMenuItem.setEnabled(true); - HistoryItem hi = (HistoryItem)redoList.peek(); - redoMenuItem.setLabel("Redo "+hi.getDescription()); - } - else - { - redoMenuItem.setEnabled(false); - redoMenuItem.setLabel("Redo"); - } - } - - 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(); - } + if (redoList.size() > 0) + { + redoMenuItem.setEnabled(true); + HistoryItem hi = (HistoryItem) redoList.peek(); + redoMenuItem.setLabel("Redo " + hi.getDescription()); + } + else + { + redoMenuItem.setEnabled(false); + redoMenuItem.setLabel("Redo"); + } + } + + 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) + // used by undo and redo + void restoreHistoryItem(HistoryItem hi) + { + if (hi.getType() == HistoryItem.SORT) + { + for (int i = 0; i < hi.getSequences().size(); i++) { - for(int i=0; ihi.getSequences().size()-1; i--) - viewport.alignment.deleteSequence(i); + 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(); - } + updateEditMenuBar(); + viewport.updateConsensus(); + viewport.updateConservation(); + alignPanel.repaint(); + } public void moveSelectedSequences(boolean up) { SequenceGroup sg = viewport.getSelectionGroup(); if (sg == null) + { return; + } if (up) { @@ -210,11 +222,15 @@ public class AlignFrame extends GAlignFrame { 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); @@ -226,11 +242,15 @@ public class AlignFrame extends GAlignFrame { 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); @@ -240,47 +260,52 @@ public class AlignFrame extends GAlignFrame alignPanel.repaint(); } - StringBuffer copiedSequences; protected void copy_actionPerformed(ActionEvent e) { - if(viewport.getSelectionGroup()==null) - return; + if (viewport.getSelectionGroup() == null) + { + return; + } - SequenceGroup sg = viewport.getSelectionGroup(); - copiedSequences = new StringBuffer(); - Hashtable orderedSeqs = new Hashtable(); - for(int i=0; i 0) { - addHistoryItem(new HistoryItem("Remove Left",viewport.alignment, + addHistoryItem(new HistoryItem("Remove Left", viewport.alignment, HistoryItem.HIDE)); int min = colSel.getMin(); viewport.getAlignment().trimLeft(min); - colSel.compensateForEdit(0,min); + colSel.compensateForEdit(0, min); - if(viewport.getSelectionGroup()!=null) + if (viewport.getSelectionGroup() != null) + { viewport.getSelectionGroup().adjustForRemoveLeft(min); + } Vector groups = viewport.alignment.getGroups(); - for(int i=0; i 0) { - addHistoryItem(new HistoryItem("Remove Right",viewport.alignment, + addHistoryItem(new HistoryItem("Remove Right", viewport.alignment, HistoryItem.HIDE)); int max = colSel.getMax(); viewport.getAlignment().trimRight(max); - if(viewport.getSelectionGroup()!=null) + if (viewport.getSelectionGroup() != null) + { viewport.getSelectionGroup().adjustForRemoveRight(max); + } Vector groups = viewport.alignment.getGroups(); - for(int i=0; i1) + if (viewport.getSelectionGroup().getSize() > 1) { Frame frame = new Frame(); frame.add(new PairwiseAlignPanel(viewport)); @@ -918,21 +991,25 @@ public class AlignFrame extends GAlignFrame public void PCAMenuItem_actionPerformed(ActionEvent e) { - if( (viewport.getSelectionGroup()!=null && viewport.getSelectionGroup().getSize()<4 && viewport.getSelectionGroup().getSize()>0) - || viewport.getAlignment().getHeight()<4) + if ( (viewport.getSelectionGroup() != null && + viewport.getSelectionGroup().getSize() < 4 && + viewport.getSelectionGroup().getSize() > 0) + || viewport.getAlignment().getHeight() < 4) { return; } - try{ + try + { PCAPanel pcaPanel = new PCAPanel(viewport, null); Frame frame = new Frame(); frame.add(pcaPanel); - jalview.bin.JalviewLite.addFrame(frame, "Principal component analysis", 400, 400); - }catch(java.lang.OutOfMemoryError ex) - { - } - + jalview.bin.JalviewLite.addFrame(frame, "Principal component analysis", + 400, 400); + } + catch (java.lang.OutOfMemoryError ex) + { + } } @@ -946,7 +1023,6 @@ public class AlignFrame extends GAlignFrame NewTreePanel("NJ", "PID", "Neighbour joining tree using PID"); } - protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) { NewTreePanel("NJ", "BL", "Neighbour joining tree using BLOSUM62"); @@ -960,7 +1036,7 @@ public class AlignFrame extends GAlignFrame void NewTreePanel(String type, String pwType, String title) { //are the sequences aligned? - if(!viewport.alignment.isAligned()) + if (!viewport.alignment.isAligned()) { return; } @@ -979,9 +1055,9 @@ public class AlignFrame extends GAlignFrame type, pwType, 0, viewport.alignment.getWidth()); } - addTreeMenuItem(tp, title); + addTreeMenuItem(tp, title); - jalview.bin.JalviewLite.addFrame(tp, title, 600, 500); + jalview.bin.JalviewLite.addFrame(tp, title, 600, 500); } void addTreeMenuItem(final TreePanel treePanel, String title) @@ -1008,7 +1084,8 @@ public class AlignFrame extends GAlignFrame }); } - protected void documentation_actionPerformed(ActionEvent e) { + protected void documentation_actionPerformed(ActionEvent e) + { jalview.bin.JalviewLite.showURL("http://www.jalview.org"); @@ -1016,33 +1093,38 @@ public class AlignFrame extends GAlignFrame protected void about_actionPerformed(ActionEvent e) { - class AboutPanel extends Canvas + class AboutPanel + extends Canvas { public void paint(Graphics g) { g.setColor(Color.white); - g.fillRect(0,0,getSize().width, getSize().height); + g.fillRect(0, 0, getSize().width, getSize().height); g.setFont(new Font("Helvetica", Font.PLAIN, 12)); FontMetrics fm = g.getFontMetrics(); int fh = fm.getHeight(); - int y=5, x=7; + int y = 5, x = 7; g.setColor(Color.black); g.setFont(new Font("Helvetica", Font.BOLD, 14)); - g.drawString("JalView - Release 2.0", 200,y+=fh); + g.drawString("JalView - Release 2.0", 200, y += fh); g.setFont(new Font("Helvetica", Font.PLAIN, 12)); - g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.",x,y+=fh*2); - g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.",x,y+=fh); - g.drawString("For any issues relating to Jalview, email help@jalview.org", x,y+=fh); - g.drawString("If you use JalView, please cite:",x,y+=fh+8); - g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",x,y+=fh); - g.drawString("Bioinformatics, 2004 12;426-7.",x,y+=fh); + g.drawString("Authors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton.", + x, y += fh * 2); + g.drawString("Current development managed by Andrew Waterhouse; Barton Group, University of Dundee.", + x, y += fh); + g.drawString( + "For any issues relating to Jalview, email help@jalview.org", x, + y += fh); + g.drawString("If you use JalView, please cite:", x, y += fh + 8); + g.drawString("\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", + x, y += fh); + g.drawString("Bioinformatics, 2004 12;426-7.", x, y += fh); } } + Frame frame = new Frame(); frame.add(new AboutPanel()); - jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580,200); - - + jalview.bin.JalviewLite.addFrame(frame, "Jalview", 580, 200); } } diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index bdc2359..51478f2 100755 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -1,30 +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.appletgui; +import java.util.*; + import java.awt.*; -import jalview.bin.*; + import jalview.analysis.*; +import jalview.bin.*; import jalview.datamodel.*; import jalview.schemes.*; -import java.util.*; public class AlignViewport { @@ -35,10 +37,10 @@ public class AlignViewport int endSeq; boolean showFullId = true; - boolean showText=true; - boolean showColourText=false; - boolean showBoxes=true; - boolean wrapAlignment=false; + boolean showText = true; + boolean showColourText = false; + boolean showBoxes = true; + boolean wrapAlignment = false; boolean renderGaps = true; boolean showSequenceFeatures = false; boolean showAnnotation = true; @@ -53,13 +55,13 @@ public class AlignViewport SequenceGroup selectionGroup = new SequenceGroup(); - int charHeight; - int charWidth; - int chunkWidth; - int chunkHeight; + int charHeight; + int charWidth; + int chunkWidth; + int chunkHeight; - Font font = new Font("SansSerif",Font.PLAIN,10); - AlignmentI alignment; + Font font = new Font("SansSerif", Font.PLAIN, 10); + AlignmentI alignment; ColumnSelection colSel = new ColumnSelection(); @@ -69,60 +71,70 @@ public class AlignViewport NJTree currentTree = null; boolean scaleAboveWrapped = true; - boolean scaleLeftWrapped = true; + boolean scaleLeftWrapped = true; boolean scaleRightWrapped = true; public AlignViewport(AlignmentI al, JalviewLite applet) { setAlignment(al); this.startRes = 0; - this.endRes = al.getWidth()-1; + this.endRes = al.getWidth() - 1; this.startSeq = 0; - this.endSeq = al.getHeight()-1; + this.endSeq = al.getHeight() - 1; setFont(font); - - if(applet!=null) + if (applet != null) { String param = applet.getParameter("showFullId"); if (param != null) + { showFullId = Boolean.valueOf(param).booleanValue(); + } param = applet.getParameter("showAnnotation"); if (param != null) + { showAnnotation = Boolean.valueOf(param).booleanValue(); + } param = applet.getParameter("showConservation"); if (param != null) + { showConservation = Boolean.valueOf(param).booleanValue(); + } param = applet.getParameter("showQuality"); if (param != null) + { showQuality = Boolean.valueOf(param).booleanValue(); + } param = applet.getParameter("showConsensus"); if (param != null) + { showConsensus = Boolean.valueOf(param).booleanValue(); + } } // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done updateConservation(); updateConsensus(); - if(applet!=null && applet.getParameter("defaultColour")!=null) + if (applet != null && applet.getParameter("defaultColour") != null) { globalColourScheme = ColourSchemeProperty.getColour(alignment, applet.getParameter("defaultColour")); - if(globalColourScheme!=null) - globalColourScheme.setConsensus( vconsensus ); - } - } - + if (globalColourScheme != null) + { + globalColourScheme.setConsensus(vconsensus); + } + } + } - public void showSequenceFeatures(boolean b) - { - showSequenceFeatures = b; - } + public void showSequenceFeatures(boolean b) + { + showSequenceFeatures = b; + } public Vector vconsensus; AlignmentAnnotation consensus; @@ -136,19 +148,21 @@ public class AlignViewport Conservation cons = new jalview.analysis.Conservation("All", jalview.schemes.ResidueProperties.propHash, 3, alignment.getSequences(), 0, - alignment.getWidth()-1); + 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]; + Annotation[] annotations = new Annotation[alWidth]; + Annotation[] qannotations = new Annotation[alWidth]; String sequence = cons.getConsSequence().getSequence(); - float minR,minG,minB, maxR,maxG,maxB; + float minR, minG, minB, maxR, maxG, 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 + 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(); @@ -158,108 +172,131 @@ public class AlignViewport { float value = 0; try + { + value = Integer.parseInt(sequence.charAt(i) + ""); + } + catch (Exception ex) + { + if (sequence.charAt(i) == '*') { - value = Integer.parseInt(sequence.charAt(i) + ""); + value = 11; } - catch (Exception ex) + if (sequence.charAt(i) == '+') { - if (sequence.charAt(i) == '*') value = 11; - if (sequence.charAt(i) == '+') value = 10; + value = 10; } - float vprop = value-min; - vprop/=max; + } + float vprop = value - min; + vprop /= max; annotations[i] = new Annotation(sequence.charAt(i) + "", - "", ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop)); + "", ' ', value, + new Color(minR + maxR * vprop, + minG + maxG * vprop, + minB + maxB * vprop)); // Quality calc - value = ((Double) cons.quality.elementAt(i)).floatValue(); + value = ( (Double) cons.quality.elementAt(i)).floatValue(); vprop = value - qmin; - vprop/=qmax; + vprop /= qmax; qannotations[i] = new Annotation(" ", - String.valueOf(value), ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop)); + String.valueOf(value), ' ', value, + new + Color(minR + maxR * vprop, + minG + maxG * vprop, + minB + maxB * vprop)); } - if(conservation==null) + if (conservation == null) { conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment less than "+ConsPercGaps+"% gaps", + "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); + 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) + if (showQuality) + { alignment.addAnnotation(quality); + } } - else { + else + { conservation.annotations = annotations; quality.annotations = qannotations; quality.graphMax = cons.qualityRange[1].floatValue(); } - } public void updateConsensus() { - Annotation [] annotations = new Annotation[alignment.getWidth()]; + 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(); + if (vconsensus == null) + { + vconsensus = alignment.getAAFrequency(); + } else { - Vector temp = alignment.getAAFrequency(); - vconsensus.removeAllElements(); - Enumeration e = temp.elements(); - while(e.hasMoreElements()) - { - vconsensus.addElement(e.nextElement()); - } + Vector temp = alignment.getAAFrequency(); + vconsensus.removeAllElements(); + Enumeration e = temp.elements(); + while (e.hasMoreElements()) + { + vconsensus.addElement(e.nextElement()); + } } Hashtable hash = null; - for (int i = 0; i2) - { - mouseOver = "["+maxRes+"] "; - maxRes = "+ "; - } + hash = (Hashtable) vconsensus.elementAt(i); + float value = new Float(hash.get("maxCount").toString()).floatValue(); + value /= new Float(hash.get("size").toString()).floatValue(); + + 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); + mouseOver += (int) value + "%"; + annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); } - if(consensus==null) - { - consensus = new AlignmentAnnotation("Consensus", - "PID", annotations, 0f, 100f, 1); - if(showConsensus) - alignment.addAnnotation(consensus); - } - else - consensus.annotations = annotations; + if (consensus == null) + { + consensus = new AlignmentAnnotation("Consensus", + "PID", annotations, 0f, 100f, 1); + if (showConsensus) + { + alignment.addAnnotation(consensus); + } + } + else + { + consensus.annotations = annotations; + } } - public SequenceGroup getSelectionGroup() { return selectionGroup; @@ -270,42 +307,44 @@ public class AlignViewport selectionGroup = sg; } + public boolean getConservationSelected() + { + return conservationColourSelected; + } - public boolean getConservationSelected() - { - return conservationColourSelected; - } - - public void setConservationSelected(boolean b) - { - conservationColourSelected = b; - } + public void setConservationSelected(boolean b) + { + conservationColourSelected = b; + } - public boolean getAbovePIDThreshold() - { - return abovePIDThreshold; - } + public boolean getAbovePIDThreshold() + { + return abovePIDThreshold; + } - public void setAbovePIDThreshold(boolean b) - { - abovePIDThreshold = b; - } + public void setAbovePIDThreshold(boolean b) + { + abovePIDThreshold = b; + } - public int getStartRes() { + public int getStartRes() + { return startRes; } - public int getEndRes() { + public int getEndRes() + { return endRes; } - public int getStartSeq() { + public int getStartSeq() + { return startSeq; } public void setGlobalColourScheme(ColourSchemeI cs) { - globalColourScheme = cs; + globalColourScheme = cs; } public ColourSchemeI getGlobalColourScheme() @@ -313,37 +352,50 @@ public class AlignViewport return globalColourScheme; } - - public void setStartRes(int res) { + public void setStartRes(int res) + { this.startRes = res; } - public void setStartSeq(int seq) { + + public void setStartSeq(int seq) + { this.startSeq = seq; } - public void setEndRes(int res) { - if (res > alignment.getWidth()-1) { + + 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; + res = alignment.getWidth() - 1; } - if (res < 0) { + if (res < 0) + { res = 0; } this.endRes = res; } - public void setEndSeq(int seq) { - if (seq > alignment.getHeight()) { + + public void setEndSeq(int seq) + { + if (seq > alignment.getHeight()) + { seq = alignment.getHeight(); } - if (seq < 0) { + if (seq < 0) + { seq = 0; } this.endSeq = seq; } - public int getEndSeq() { + + public int getEndSeq() + { return endSeq; } - public void setFont(Font f) { + public void setFont(Font f) + { font = f; java.awt.Frame temp = new java.awt.Frame(); temp.addNotify(); @@ -352,52 +404,76 @@ public class AlignViewport setCharWidth(fm.charWidth('M')); } - public Font getFont() { + public Font getFont() + { return font; } - public void setCharWidth(int w) { + + public void setCharWidth(int w) + { this.charWidth = w; } - public int getCharWidth() { + + public int getCharWidth() + { return charWidth; } - public void setCharHeight(int h) { + + public void setCharHeight(int h) + { this.charHeight = h; } - public int getCharHeight() { + + public int getCharHeight() + { return charHeight; } - public void setChunkWidth(int w) { + + public void setChunkWidth(int w) + { this.chunkWidth = w; } - public int getChunkWidth() { + + public int getChunkWidth() + { return chunkWidth; } - public void setChunkHeight(int h) { + + public void setChunkHeight(int h) + { this.chunkHeight = h; } - public int getChunkHeight() { + + public int getChunkHeight() + { return chunkHeight; } - public AlignmentI getAlignment() { + + public AlignmentI getAlignment() + { return alignment; } - public void setAlignment(AlignmentI align) { + + public void setAlignment(AlignmentI align) + { this.alignment = align; } - public void setWrapAlignment(boolean state) { + public void setWrapAlignment(boolean state) + { wrapAlignment = state; } - public void setShowText(boolean state) { + + public void setShowText(boolean state) + { showText = state; } - public void setRenderGaps(boolean state){ + public void setRenderGaps(boolean state) + { renderGaps = state; } - public boolean getColourText() { return showColourText; @@ -408,80 +484,114 @@ public class AlignViewport showColourText = state; } - public void setShowBoxes(boolean state) { + public void setShowBoxes(boolean state) + { showBoxes = state; } - public boolean getWrapAlignment() { - return wrapAlignment; + public boolean getWrapAlignment() + { + return wrapAlignment; } - public boolean getShowText() { + + public boolean getShowText() + { return showText; } - public boolean getShowBoxes() { + + public boolean getShowBoxes() + { return showBoxes; } - public char getGapCharacter() { + public char getGapCharacter() + { return getAlignment().getGapCharacter(); } - public void setGapCharacter(char gap) { - if (getAlignment() != null) { + + public void setGapCharacter(char gap) + { + if (getAlignment() != null) + { getAlignment().setGapCharacter(gap); } } - public void setThreshold(int thresh) { + + public void setThreshold(int thresh) + { threshold = thresh; } - public int getThreshold() { + + public int getThreshold() + { return threshold; } - public void setIncrement(int inc) { + + public void setIncrement(int inc) + { increment = inc; } - public int getIncrement() { + + public int getIncrement() + { return increment; } - public int getIndex(int y) { - int y1 = 0; + + public int getIndex(int y) + { + int y1 = 0; int starty = getStartSeq(); - int endy = getEndSeq(); + int endy = getEndSeq(); - for (int i = starty; i <= endy; i++) { - if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) { + for (int i = starty; i <= endy; i++) + { + if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) + { int y2 = y1 + getCharHeight(); - if (y>=y1 && y <=y2) { + if (y >= y1 && y <= y2) + { return i; } - y1 = y2; - } else { + y1 = y2; + } + else + { return -1; } } return -1; } - public ColumnSelection getColumnSelection() { + public ColumnSelection getColumnSelection() + { return colSel; } - public void resetSeqLimits(int height) { - setEndSeq(height/getCharHeight()); + public void resetSeqLimits(int height) + { + setEndSeq(height / getCharHeight()); } - public void setCurrentTree(NJTree tree) { - currentTree = tree; + + public void setCurrentTree(NJTree tree) + { + currentTree = tree; } - public NJTree getCurrentTree() { + + public NJTree getCurrentTree() + { return currentTree; } - public void setColourAppliesToAllGroups(boolean b) - { colourAppliesToAllGroups = b; } + { + colourAppliesToAllGroups = b; + } public boolean getColourAppliesToAllGroups() - {return colourAppliesToAllGroups; } + { + return colourAppliesToAllGroups; + } public boolean getShowFullId() { @@ -504,22 +614,33 @@ public class AlignViewport } public boolean getScaleAboveWrapped() - { return scaleAboveWrapped;} + { + return scaleAboveWrapped; + } public boolean getScaleLeftWrapped() - { return scaleLeftWrapped; } + { + return scaleLeftWrapped; + } public boolean getScaleRightWrapped() - { return scaleRightWrapped; } + { + return scaleRightWrapped; + } public void setScaleAboveWrapped(boolean b) - { scaleAboveWrapped = b; } + { + scaleAboveWrapped = b; + } public void setScaleLeftWrapped(boolean b) - { scaleLeftWrapped = b; } + { + scaleLeftWrapped = b; + } public void setScaleRightWrapped(boolean b) - { scaleRightWrapped = b; } - + { + scaleRightWrapped = b; + } } diff --git a/src/jalview/appletgui/AlignmentPanel.java b/src/jalview/appletgui/AlignmentPanel.java index 9c77e13..754d698 100755 --- a/src/jalview/appletgui/AlignmentPanel.java +++ b/src/jalview/appletgui/AlignmentPanel.java @@ -1,38 +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 -*/ + * 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.appletgui; -import jalview.jbappletgui.GAlignmentPanel; -import jalview.schemes.*; -import jalview.analysis.*; -import jalview.datamodel.*; import java.awt.*; import java.awt.event.*; -public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListener +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.jbappletgui.*; +import jalview.schemes.*; + +public class AlignmentPanel + extends GAlignmentPanel implements AdjustmentListener { - AlignViewport av; + AlignViewport av; OverviewPanel overviewPanel; - SeqPanel seqPanel; - IdPanel idPanel; + SeqPanel seqPanel; + IdPanel idPanel; IdwidthAdjuster idwidthAdjuster; public AlignFrame alignFrame; ScalePanel scalePanel; @@ -45,14 +47,13 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene 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); + this.av = av; + seqPanel = new SeqPanel(av, this); + idPanel = new IdPanel(av, this); + scalePanel = new ScalePanel(av, this); idwidthAdjuster = new IdwidthAdjuster(this); annotationPanel = new AnnotationPanel(this); - alabels = new AnnotationLabels(this); - + alabels = new AnnotationLabels(this); idPanelHolder.add(idPanel, BorderLayout.CENTER); idSpaceFillerPanel1.add(idwidthAdjuster, BorderLayout.CENTER); @@ -67,57 +68,67 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene hscroll.addAdjustmentListener(this); vscroll.addAdjustmentListener(this); - seqPanel.seqCanvas.addKeyListener( new MyKeyAdapter() ); - idPanel.idCanvas.addKeyListener( new MyKeyAdapter() ); + seqPanel.seqCanvas.addKeyListener(new MyKeyAdapter()); + idPanel.idCanvas.addKeyListener(new MyKeyAdapter()); - addComponentListener(new ComponentAdapter() - { - public void componentResized(ComponentEvent evt) - { - setScrollValues(av.getStartRes(), av.getStartSeq()); - repaint(); - } - }); + addComponentListener(new ComponentAdapter() + { + public void componentResized(ComponentEvent evt) + { + setScrollValues(av.getStartRes(), av.getStartSeq()); + repaint(); + } + }); - Dimension d = calculateIdWidth(); - idPanel.idCanvas.setSize(d); + Dimension d = calculateIdWidth(); + idPanel.idCanvas.setSize(d); - hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height); - annotationScroller.setSize(annotationPanel.getSize()); + hscrollFillerPanel.setSize(d.width, annotationPanel.getSize().height); + annotationScroller.setSize(annotationPanel.getSize()); - idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); - annotationSpaceFillerHolder.setSize(d.width,annotationPanel.getSize().height); - alabels.setSize(d.width,annotationPanel.getSize().height); + idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); + annotationSpaceFillerHolder.setSize(d.width, + annotationPanel.getSize().height); + alabels.setSize(d.width, annotationPanel.getSize().height); } - class MyKeyAdapter extends KeyAdapter + class MyKeyAdapter + extends KeyAdapter { - public void keyPressed(KeyEvent evt) - { - // System.out.println(evt.getKeyCode()); log. - switch(evt.getKeyCode()) - { - case 27: // escape key - av.setSelectionGroup(null); - alignFrame.alignPanel.repaint(); - break; - case KeyEvent.VK_X: - if(evt.isControlDown()) - alignFrame.cut_actionPerformed(null); - break; - case KeyEvent.VK_C: - if(evt.isControlDown()) - alignFrame.copy_actionPerformed(null); - break; - case KeyEvent.VK_V: - if(evt.isControlDown()) - alignFrame.paste(true); - break; - case KeyEvent.VK_A: - if(evt.isControlDown()) - alignFrame.selectAllSequenceMenuItem_actionPerformed(null); - break; + public void keyPressed(KeyEvent evt) + { + // System.out.println(evt.getKeyCode()); log. + switch (evt.getKeyCode()) + { + case 27: // escape key + av.setSelectionGroup(null); + alignFrame.alignPanel.repaint(); + break; + case KeyEvent.VK_X: + if (evt.isControlDown()) + { + alignFrame.cut_actionPerformed(null); + } + break; + case KeyEvent.VK_C: + if (evt.isControlDown()) + { + alignFrame.copy_actionPerformed(null); + } + break; + case KeyEvent.VK_V: + if (evt.isControlDown()) + { + alignFrame.paste(true); + } + break; + case KeyEvent.VK_A: + if (evt.isControlDown()) + { + alignFrame.selectAllSequenceMenuItem_actionPerformed(null); + } + break; case KeyEvent.VK_DOWN: alignFrame.moveSelectedSequences(false); break; @@ -125,11 +136,13 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene alignFrame.moveSelectedSequences(true); break; case KeyEvent.VK_F: - if(evt.isControlDown()) - alignFrame.findMenuItem_actionPerformed(null); + if (evt.isControlDown()) + { + alignFrame.findMenuItem_actionPerformed(null); + } break; - } - } + } + } } public void fontChanged() @@ -138,8 +151,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene // to prevent drawing old image FontMetrics fm = getFontMetrics(av.getFont()); - scalePanel.setSize(new Dimension(10, av.charHeight+fm.getDescent())); - idwidthAdjuster.setSize(new Dimension(10, av.charHeight+fm.getDescent())); + scalePanel.setSize(new Dimension(10, av.charHeight + fm.getDescent())); + idwidthAdjuster.setSize(new Dimension(10, av.charHeight + fm.getDescent())); annotationPanel.adjustPanelHeight(); annotationPanel.repaint(); @@ -153,17 +166,18 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene public void setIdWidth(int w, int h) { - idPanel.idCanvas.setSize(w,h); - idPanelHolder.setSize(w,idPanelHolder.getSize().height); - alabels.setSize(w,alabels.getSize().height); + idPanel.idCanvas.setSize(w, h); + idPanelHolder.setSize(w, idPanelHolder.getSize().height); + alabels.setSize(w, alabels.getSize().height); validate(); } + Dimension calculateIdWidth() { Frame frame = new Frame(); frame.addNotify(); Graphics g = frame.getGraphics(); - if(g==null) + if (g == null) { Frame f = new Frame(); f.addNotify(); @@ -173,70 +187,77 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene FontMetrics fm = g.getFontMetrics(av.font); AlignmentI al = av.getAlignment(); - int i = 0; - int idWidth = 0; - String id; - while (i < al.getHeight() && al.getSequenceAt(i) != null) - { - 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++; - } - - // Also check annotation label widths - i=0; - if(al.getAlignmentAnnotation()!=null) - { - fm = g.getFontMetrics(frame.getFont()); - while (i < al.getAlignmentAnnotation().length) - { - String label = al.getAlignmentAnnotation()[i].label; - if (fm.stringWidth(label) > idWidth) - idWidth = fm.stringWidth(label); - i++; - } - } - - return new Dimension(idWidth, idPanel.idCanvas.getSize().height); - } + int i = 0; + int idWidth = 0; + String id; + while (i < al.getHeight() && al.getSequenceAt(i) != null) + { + 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++; + } - public void highlightSearchResults(int [] results) - { - seqPanel.seqCanvas.highlightSearchResults( results ); + // Also check annotation label widths + i = 0; + if (al.getAlignmentAnnotation() != null) + { + fm = g.getFontMetrics(frame.getFont()); + while (i < al.getAlignmentAnnotation().length) + { + String label = al.getAlignmentAnnotation()[i].label; + if (fm.stringWidth(label) > idWidth) + { + idWidth = fm.stringWidth(label); + } + i++; + } + } + + return new Dimension(idWidth, idPanel.idCanvas.getSize().height); + } + + public void highlightSearchResults(int[] results) + { + seqPanel.seqCanvas.highlightSearchResults(results); - // do we need to scroll the panel? - if(results!=null) + // 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 + 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])) + || av.getEndSeq() < results[0])) + { setScrollValues(start, results[0]); + } } - } - - - public OverviewPanel getOverviewPanel() - { - return overviewPanel; - } + } - public void setOverviewPanel(OverviewPanel op) - { - overviewPanel = op; - } + public OverviewPanel getOverviewPanel() + { + return overviewPanel; + } + public void setOverviewPanel(OverviewPanel op) + { + overviewPanel = op; + } public void setAnnotationVisible(boolean b) { @@ -246,7 +267,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene repaint(); } - public void setWrapAlignment(boolean wrap) { scalePanelHolder.setVisible(!wrap); @@ -263,49 +283,52 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene } - public void setColourScheme() { ColourSchemeI cs = av.getGlobalColourScheme(); - if(av.getConservationSelected()) + if (av.getConservationSelected()) { - Alignment al = (Alignment)av.getAlignment(); - Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, al.getSequences(), 0, - al.getWidth() ); + Alignment al = (Alignment) av.getAlignment(); + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, + al.getSequences(), 0, + al.getWidth()); - c.calculate(); - c.verdict(false, av.ConsPercGaps); - ConservationColourScheme ccs = new ConservationColourScheme(c, cs); + c.calculate(); + c.verdict(false, av.ConsPercGaps); + ConservationColourScheme ccs = new ConservationColourScheme(c, cs); - av.setGlobalColourScheme( ccs ); + av.setGlobalColourScheme(ccs); } repaint(); } - int hextent = 0; int vextent = 0; // return value is true if the scroll is valid public boolean scrollUp(boolean up) { - if(up) + if (up) { - if(vscroll.getValue()<1) + if (vscroll.getValue() < 1) + { return false; - fastPaint = false; + } + fastPaint = false; vscroll.setValue(vscroll.getValue() - 1); } else { - if(vextent+vscroll.getValue() >= av.getAlignment().getHeight()) - return false; - fastPaint = false; + if (vextent + vscroll.getValue() >= av.getAlignment().getHeight()) + { + return false; + } + fastPaint = false; vscroll.setValue(vscroll.getValue() + 1); } fastPaint = true; @@ -318,14 +341,18 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene if (right) { if (hscroll.getValue() < 1) + { return false; + } fastPaint = false; hscroll.setValue(hscroll.getValue() - 1); } else { if (hextent + hscroll.getValue() >= av.getAlignment().getWidth()) + { return false; + } fastPaint = false; hscroll.setValue(hscroll.getValue() + 1); } @@ -333,47 +360,57 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene return true; } - public void setScrollValues(int x, int y) { av.setStartRes(x); av.setStartSeq(y); - av.setEndRes(x + seqPanel.seqCanvas.getSize().width/av.getCharWidth()-1); + av.setEndRes(x + seqPanel.seqCanvas.getSize().width / av.getCharWidth() - 1); - hextent = seqPanel.seqCanvas.getSize().width/av.charWidth; - vextent = seqPanel.seqCanvas.getSize().height/av.charHeight; + hextent = seqPanel.seqCanvas.getSize().width / av.charWidth; + vextent = seqPanel.seqCanvas.getSize().height / av.charHeight; - if(hextent > av.alignment.getWidth()) + if (hextent > av.alignment.getWidth()) + { hextent = av.alignment.getWidth(); - if(vextent > av.alignment.getHeight()) + } + if (vextent > av.alignment.getHeight()) + { vextent = av.alignment.getHeight(); + } - if(hextent+x > av.getAlignment().getWidth()) - x = av.getAlignment().getWidth()- hextent; + if (hextent + x > av.getAlignment().getWidth()) + { + x = av.getAlignment().getWidth() - hextent; + } - if(vextent+y > av.getAlignment().getHeight()) + if (vextent + y > av.getAlignment().getHeight()) + { y = av.getAlignment().getHeight() - vextent; + } - if(y<0) + if (y < 0) + { y = 0; + } - if(x<0) - x=0; - + if (x < 0) + { + x = 0; + } int endSeq = y + vextent; - if(endSeq>av.alignment.getHeight()) + if (endSeq > av.alignment.getHeight()) + { endSeq = av.alignment.getHeight(); + } - - av.setEndSeq( endSeq ); - hscroll.setValues(x,hextent,0,av.getAlignment().getWidth()); - vscroll.setValues(y,vextent,0,av.getAlignment().getHeight() ); + av.setEndSeq(endSeq); + hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth()); + vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight()); } - public void adjustmentValueChanged(AdjustmentEvent evt) { int oldX = av.getStartRes(); @@ -383,7 +420,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene { int x = hscroll.getValue(); av.setStartRes(x); - av.setEndRes(x + seqPanel.seqCanvas.getSize().width/av.getCharWidth()-1); + av.setEndRes(x + seqPanel.seqCanvas.getSize().width / av.getCharWidth() - + 1); } if (evt.getSource() == vscroll) @@ -391,22 +429,28 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene int offy = vscroll.getValue(); if (av.getWrapAlignment()) { - int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); - av.setStartRes( vscroll.getValue() * rowSize ); - av.setEndRes( (vscroll.getValue()+1) * rowSize ); + int rowSize = seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel. + seqCanvas.getSize().width); + av.setStartRes(vscroll.getValue() * rowSize); + av.setEndRes( (vscroll.getValue() + 1) * rowSize); } else { av.setStartSeq(offy); - av.setEndSeq(offy + seqPanel.seqCanvas.getSize().height / av.getCharHeight()); + av.setEndSeq(offy + + seqPanel.seqCanvas.getSize().height / av.getCharHeight()); } } - if(overviewPanel!=null) + if (overviewPanel != null) + { overviewPanel.setBoxPosition(); + } - if(av.getWrapAlignment() || !fastPaint) + if (av.getWrapAlignment() || !fastPaint) + { repaint(); + } else { idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY); @@ -415,23 +459,25 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene scalePanel.repaint(); if (av.getShowAnnotation()) + { annotationPanel.fastPaint(av.getStartRes() - oldX); + } } } public void update(Graphics g) { - paint (g); + paint(g); } - public void paint(Graphics g) { Dimension d = idPanel.idCanvas.getSize(); idPanel.idCanvas.setSize(d.width, seqPanel.seqCanvas.getSize().height); - annotationSpaceFillerHolder.setSize(d.width,annotationPanel.getSize().height); - alabels.setSize(d.width,annotationPanel.getSize().height); + annotationSpaceFillerHolder.setSize(d.width, + annotationPanel.getSize().height); + alabels.setSize(d.width, annotationPanel.getSize().height); alabels.repaint(); idPanel.idCanvas.repaint(); @@ -439,10 +485,11 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene scalePanel.repaint(); annotationPanel.repaint(); - if (av.getWrapAlignment()) { - int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); + int max = av.alignment.getWidth() / + seqPanel.seqCanvas. + getWrappedCanvasWidth(seqPanel.seqCanvas.getSize().width); vscroll.setMaximum(max); vscroll.setUnitIncrement(1); vscroll.setVisibleAmount(1); @@ -452,7 +499,5 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene setScrollValues(av.getStartRes(), av.getStartSeq()); } - - } } diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index 095377d..38013d1 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -1,40 +1,41 @@ - /* -* 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.appletgui; -import java.awt.event.*; import java.awt.*; +import java.awt.event.*; + import jalview.datamodel.*; -public class AnnotationLabels extends Panel implements ActionListener +public class AnnotationLabels + extends Panel implements ActionListener { boolean active = false; - AlignmentPanel ap ; + AlignmentPanel ap; boolean resizing = false; int oldY, mouseX; 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"; + static String SHOWALL = "Show all hidden rows"; + static String OUTPUT_TEXT = "Show Values In Textbox"; int selectedRow = 0; int scrollOffset = 0; @@ -43,7 +44,8 @@ public class AnnotationLabels extends Panel implements ActionListener this.ap = ap; setLayout(null); addMouseListener(new MouseAdapter() - {public void mousePressed(MouseEvent evt) + { + public void mousePressed(MouseEvent evt) { doMousePressed(evt); } @@ -60,30 +62,32 @@ public class AnnotationLabels extends Panel implements ActionListener { AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - if(evt.getActionCommand().equals(HIDE)) - { - aa[selectedRow].visible = false; - } - else if(evt.getActionCommand().equals(SHOWALL)) - { - for(int i=0; i-1 && res -1 && res < aa[row].annotations.length && aa[row].annotations[res] != null) + { + StringBuffer text = new StringBuffer("Sequence position " + (res + 1) + + " " + + aa[row].annotations[res].description); + ap.alignFrame.statusBar.setText(text.toString()); + } + } public void update(Graphics g) { @@ -171,258 +192,304 @@ public class AnnotationPanel extends Panel implements AdjustmentListener public void paint(Graphics g) { - imgWidth = (av.endRes-av.startRes+1) *av.charWidth; + imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; - if(image==null || imgWidth != image.getWidth(this)) - { - image = createImage(imgWidth, ap.annotationPanel.getSize().height); - gg = image.getGraphics(); - gg.setFont(av.getFont()); - fm = gg.getFontMetrics(); - fastPaint = false; + if (image == null || imgWidth != image.getWidth(this)) + { + image = createImage(imgWidth, ap.annotationPanel.getSize().height); + gg = image.getGraphics(); + gg.setFont(av.getFont()); + fm = gg.getFontMetrics(); + fastPaint = false; } - if(fastPaint) + if (fastPaint) { g.drawImage(image, 0, 0, this); fastPaint = false; return; } - drawComponent( gg, av.startRes, av.endRes+1); - g.drawImage( image, 0, 0, this); + drawComponent(gg, av.startRes, av.endRes + 1); + g.drawImage(image, 0, 0, this); } public void fastPaint(int horizontal) -{ - if( horizontal == 0 - || av.alignment.getAlignmentAnnotation()==null - || av.alignment.getAlignmentAnnotation().length<1 - ) { - repaint(); - return; - } - - gg.copyArea( 0,0, imgWidth, getSize().height, -horizontal*av.charWidth, 0 ); - int sr=av.startRes, er=av.endRes+1, transX=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; - } + if (horizontal == 0 + || av.alignment.getAlignmentAnnotation() == null + || av.alignment.getAlignmentAnnotation().length < 1 + ) + { + repaint(); + return; + } + gg.copyArea(0, 0, imgWidth, getSize().height, -horizontal * av.charWidth, 0); + int sr = av.startRes, er = av.endRes + 1, transX = 0; - gg.translate(transX, 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; + } - drawComponent(gg, sr, er); + gg.translate(transX, 0); - gg.translate( -transX, 0 ); + drawComponent(gg, sr, er); - fastPaint = true; - repaint(); -} + gg.translate( -transX, 0); + fastPaint = true; + repaint(); + } public void drawComponent(Graphics g, int startRes, int endRes) { g.setColor(Color.white); - g.fillRect(0,0,(endRes-startRes) *av.charWidth, getSize().height); - if(av.alignment.getAlignmentAnnotation()==null || av.alignment.getAlignmentAnnotation().length<1) + g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getSize().height); + if (av.alignment.getAlignmentAnnotation() == null || + av.alignment.getAlignmentAnnotation().length < 1) { g.setColor(Color.white); - g.fillRect(0,0,getSize().width, getSize().height); + g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.black); - g.drawString("Alignment has no annotations",20,15); + g.drawString("Alignment has no annotations", 20, 15); return; } - AlignmentAnnotation [] aa = av.alignment.getAlignmentAnnotation(); + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int j, x=0, y=0; - char [] lastSS = new char[aa.length]; - int [] lastSSX= new int[aa.length] ; - int iconOffset = av.charHeight/2; + int j, x = 0, 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; i0) - { - int charOffset = (av.charWidth - fm.charWidth(row.annotations[j].displayCharacter.charAt(0)))/2; - g.setColor( row.annotations[j].colour); - if(j==0) + 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) { if (row.annotations[0].secondaryStructure == 'H' || row.annotations[0].secondaryStructure == 'E') + { g.drawString(row.annotations[j].displayCharacter, x, y + iconOffset + 2); + } } - else if( (row.annotations[j].secondaryStructure=='H' - || row.annotations[j].secondaryStructure=='E') && - (row.annotations[j-1]==null || - row.annotations[j].secondaryStructure!=row.annotations[j-1].secondaryStructure)) + else if ( (row.annotations[j].secondaryStructure == 'H' + || row.annotations[j].secondaryStructure == 'E') && + (row.annotations[j - 1] == null || + row.annotations[j].secondaryStructure != + row.annotations[j - 1].secondaryStructure)) + { - g.drawString(row.annotations[j].displayCharacter, x, y + iconOffset + 2); + g.drawString(row.annotations[j].displayCharacter, x, + y + iconOffset + 2); + } - if(!row.hasIcons) + if (!row.hasIcons) + { 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); - 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=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 ); - } + } + } + + 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); + 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); + } } - x+=av.charWidth; + x += av.charWidth; - if(row.hasIcons) - switch (lastSS[i]) + if (row.hasIcons) { - 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; + 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 && row.hasText) - y+=av.charHeight; - 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) + 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)); + g.fillRect(0, 0, width, y); + g.setColor(new Color(0, 0, 180)); int x = 0; - for(int j=0; j max) { + for (int i = 0; i < selected.size(); i++) + { + if (columnAt(i) > max) + { max = columnAt(i); } } return max; } - public int getMin() { + public int getMin() + { int min = 1000000000; - for (int i=0;i= start) - selected.setElementAt(new Integer(temp-change),i); + { + selected.setElementAt(new Integer(temp - change), i); + } } } } diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index 22cfd67..ed89001 100755 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -1,43 +1,44 @@ /* -* 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.appletgui; -import jalview.jbappletgui.GCutAndPasteTransfer; -import jalview.datamodel.*; -import jalview.io.*; import java.awt.*; import java.awt.event.*; -public class CutAndPasteTransfer extends GCutAndPasteTransfer +import jalview.datamodel.*; +import jalview.io.*; +import jalview.jbappletgui.*; + +public class CutAndPasteTransfer + extends GCutAndPasteTransfer { public CutAndPasteTransfer(boolean forImport) { super(); - if(!forImport) + if (!forImport) { buttonPanel.setVisible(false); } } - public String getText() { return textarea.getText(); @@ -48,7 +49,6 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer textarea.setText(text); } - protected void ok_actionPerformed(ActionEvent e) { String text = getText(); @@ -68,14 +68,12 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer Frame frame = (Frame)this.getParent(); frame.setVisible(false); - } - - protected void cancel_actionPerformed(ActionEvent e) { - Frame frame = (Frame)this.getParent(); - frame.setVisible(false); - } - - + } + protected void cancel_actionPerformed(ActionEvent e) + { + Frame frame = (Frame)this.getParent(); + frame.setVisible(false); + } } diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index f6fe0be..291ce5f 100755 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -1,34 +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.appletgui; -import jalview.datamodel.*; -import java.awt.*; import java.util.*; +import java.awt.*; + +import jalview.datamodel.*; + public class FeatureRenderer { AlignViewport av; SequenceGroup currentSequenceGroup = null; - SequenceGroup [] allGroups = null; + SequenceGroup[] allGroups = null; Color resBoxColour; Graphics graphics; @@ -37,36 +39,43 @@ public class FeatureRenderer this.av = av; } - - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height) + 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() ) + while (e.hasMoreElements()) { - SequenceFeature sf = (SequenceFeature)e.nextElement(); - if(sf.getStart()>seq.getEnd()) + 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; + int fstart = seq.findIndex(sf.getStart()) - 1; + int fend = seq.findIndex(sf.getEnd()) - 1; - if( (fstart<=end && fend>=start) ) + if ( (fstart <= end && fend >= start)) { - if(fstart<0) // fix for if the feature we have starts before the sequence start, - fstart = 0;// but the feature end is still valid!! + if (fstart < 0) // fix for if the feature we have starts before the sequence start, + { + fstart = 0; // but the feature end is still valid!! + } - if(fstart==fend) + if (fstart == fend) { g.setColor(Color.red); - g.fillRoundRect( (fstart - start) * width, y1, width, height, 4,4); + 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); + 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 @@ -74,11 +83,13 @@ public class FeatureRenderer for (int i = fstart; i <= fend; i++) { char s = seq.getSequence().charAt(i); - if( jalview.util.Comparison.isGap(s) ) + if (jalview.util.Comparison.isGap(s)) + { continue; + } g.setColor(Color.blue); - g.fillRect( (i-start) * width, y1, width, height); + g.fillRect( (i - start) * width, y1, width, height); g.setColor(Color.white); @@ -86,13 +97,13 @@ public class FeatureRenderer int charOffset = (width - fm.charWidth(s)) / 2; int pady = height / 5; g.drawString(String.valueOf(s), - charOffset + x1 + width * (i-start), + charOffset + x1 + width * (i - start), y1 + height - pady); } } } } - } + } } diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index e6fb5e6..a3a6124 100755 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -1,31 +1,34 @@ /* -* 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.appletgui; -import jalview.jbappletgui.GFinder; -import jalview.datamodel.*; -import java.awt.event.*; import java.util.*; + import java.awt.*; +import java.awt.event.*; + +import jalview.datamodel.*; +import jalview.jbappletgui.*; -public class Finder extends GFinder +public class Finder + extends GFinder { AlignViewport av; AlignmentPanel ap; @@ -41,12 +44,15 @@ public class Finder extends GFinder this.ap = ap; frame = new Frame(); frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "Find", 340,120); + jalview.bin.JalviewLite.addFrame(frame, "Find", 340, 120); frame.repaint(); frame.addWindowListener(new WindowAdapter() - {public void windowClosing(WindowEvent evt) - { ap.highlightSearchResults( null ); } - }); + { + public void windowClosing(WindowEvent evt) + { + ap.highlightSearchResults(null); + } + }); } public void textfield_actionPerformed(ActionEvent e) @@ -61,197 +67,229 @@ public class Finder extends GFinder public void findAll_actionPerformed(ActionEvent e) { - resIndex=0; - seqIndex=0; + resIndex = 0; + seqIndex = 0; doSearch(true); } public void cancel_actionPerformed(ActionEvent e) { - try{ + try + { // if allResults is null, this effectively switches displaySearch flag in seqCanvas - ap.highlightSearchResults( null ); - ap.idPanel.highlightSearchResults( null ); - // frame.setClosed(true); - }catch(Exception ex){ } + ap.highlightSearchResults(null); + ap.idPanel.highlightSearchResults(null); + // frame.setClosed(true); + } + catch (Exception ex) + {} } - public void createNewGroup_actionPerformed(ActionEvent e) { - Color [] newColors = new Color[24]; - for(int i=0; i<24; i++) - newColors[i] = new Color(60,160,115); - - jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(newColors); - String searchString = textfield.getText(); + Color[] newColors = new Color[24]; + 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(); + searchGroup = new SuperGroup(searchString, ucs, true, true, false); - for(int i=0; i0) - seq = (Sequence)(av.getSelectionGroup().getSequenceAt(0)); + if (av.getSelectionGroup().getSize() > 0) + { + seq = (Sequence) (av.getSelectionGroup().getSequenceAt(0)); + } else - seq = (Sequence)av.getAlignment().getSequenceAt(0); + { + seq = (Sequence) av.getAlignment().getSequenceAt(0); + } - searchResults.addElement( Integer.toString( av.getAlignment().findIndex(seq) ) ); - searchResults.addElement( Integer.toString( seq.findIndex(res)-1 ) ); - searchResults.addElement( Integer.toString( seq.findIndex(res)-1 ) ); + searchResults.addElement(Integer.toString(av.getAlignment().findIndex(seq))); + searchResults.addElement(Integer.toString(seq.findIndex(res) - 1)); + searchResults.addElement(Integer.toString(seq.findIndex(res) - 1)); - }catch(NumberFormatException ex){} + } + catch (NumberFormatException ex) + {} /////////////////////////////////////////////// int end = av.alignment.getHeight(); SequenceGroup selection = av.getSelectionGroup(); - if(selection!=null) - if(selection.getSize()<1 || (selection.getEndRes()-selection.getStartRes()<2)) - selection = null; - - while( !found && seqIndex0) - ap.idPanel.highlightSearchResults( idMatch ); - + if (searchResults.size() == 0 && idMatch.size() > 0) + { + ap.idPanel.highlightSearchResults(idMatch); + } - if(searchResults.size()>0) + if (searchResults.size() > 0) { allResults = new int[searchResults.size()]; - for(int i=0; i 0) // scroll down - { - ss = es - vertical; - if(ss av.endSeq) - es = av.endSeq; - } - - - - gg.translate(0, transY); + { + 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 (es > av.endSeq) + { + es = av.endSeq; + } + } - drawIds(ss, es); + gg.translate(0, transY); - gg.translate( 0, -transY ); + drawIds(ss, es); + gg.translate(0, -transY); - fastPaint = true; - repaint(); + fastPaint = true; + repaint(); } public void update(Graphics g) { paint(g); } + public void paint(Graphics g) { - if(getSize().height<0 || getSize().width<0) + if (getSize().height < 0 || getSize().width < 0) + { return; + } if (fastPaint) { fastPaint = false; @@ -125,51 +150,53 @@ public class IdCanvas extends Panel imgHeight = getSize().height; imgHeight -= imgHeight % av.charHeight; - if (imgHeight<1) + if (imgHeight < 1) + { return; + } - if(image==null || imgHeight!=image.getHeight(this)) + if (image == null || imgHeight != image.getHeight(this)) { image = createImage(getSize().width, imgHeight); gg = image.getGraphics(); gg.setFont(av.getFont()); } - //Fill in the background - gg.setColor(Color.white); - Font italic = new Font(av.getFont().getName(), Font.ITALIC, + //Fill in the background + gg.setColor(Color.white); + Font italic = new Font(av.getFont().getName(), Font.ITALIC, av.getFont().getSize()); - gg.setFont(italic); + gg.setFont(italic); gg.fillRect(0, 0, getSize().width, getSize().height); - drawIds( av.getStartSeq(), av.endSeq); + drawIds(av.getStartSeq(), av.endSeq); g.drawImage(image, 0, 0, this); } void drawIds(int starty, int endy) { - Color currentColor = Color.white; + Color currentColor = Color.white; Color currentTextColor = Color.black; 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 <= getSize().height && row lastid) + { selectSeqs(lastid + 1, seq); + } lastid = seq; alignPanel.repaint(); @@ -74,57 +85,77 @@ public class IdPanel extends Panel implements MouseListener, MouseMotionListener { 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.bin.JalviewLite.showURL( - "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[swall-id:" + id + - "]+-vn+2"); - }catch(Exception ex){ex.printStackTrace();} + 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.bin.JalviewLite.showURL( + "http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[swall-id:" + id + + "]+-vn+2"); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } } + public void mouseEntered(MouseEvent e) { - if(scrollThread!=null) + if (scrollThread != null) + { scrollThread.running = false; + } } - public void mouseExited (MouseEvent e) + public void mouseExited(MouseEvent e) { - if(av.getWrapAlignment()) + if (av.getWrapAlignment()) + { return; + } - if(mouseDragging && e.getY()<0 && av.getStartSeq()>0) + if (mouseDragging && e.getY() < 0 && av.getStartSeq() > 0) { scrollThread = new ScrollThread(true); } - if(mouseDragging && e.getY()>=getSize().height && av.alignment.getHeight()>av.getEndSeq()) + if (mouseDragging && e.getY() >= getSize().height && + av.alignment.getHeight() > av.getEndSeq()) { scrollThread = new ScrollThread(false); } } - - public void mousePressed(MouseEvent e) { + public void mousePressed(MouseEvent e) + { if (e.getClickCount() == 2) + { return; + } int y = e.getY(); - if(av.getWrapAlignment()) - y-=2*av.charHeight; + if (av.getWrapAlignment()) + { + y -= 2 * av.charHeight; + } int seq = av.getIndex(y); if (seq == -1) + { return; + } - if ( (e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) + if ( (e.getModifiers() & InputEvent.BUTTON3_MASK) == + InputEvent.BUTTON3_MASK) { APopupMenu popup = new APopupMenu(alignPanel, null); this.add(popup); @@ -132,31 +163,40 @@ public class IdPanel extends Panel implements MouseListener, MouseMotionListener return; } - - if(!e.isControlDown() && !e.isShiftDown() && av.alignment.findGroup( av.alignment.getSequenceAt(seq))!=null) + 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); - for (int i =0; i< sg.getSize(); i++) + selection.setEndRes(av.alignment.getWidth() - 1); + for (int i = 0; i < sg.getSize(); i++) + { selection.addSequence(sg.getSequenceAt(i)); + } av.setSelectionGroup(selection); return; } - if(av.getSelectionGroup()==null || ( !e.isControlDown() && av.getSelectionGroup()!=null)) + if (av.getSelectionGroup() == null || + (!e.isControlDown() && av.getSelectionGroup() != null)) + { av.setSelectionGroup(new SequenceGroup()); + } av.getSelectionGroup().setStartRes(0); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()-1); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); - if(e.isShiftDown() && lastid!=-1) + if (e.isShiftDown() && lastid != -1) + { selectSeqs(lastid, seq); + } else + { selectSeq(seq); + } alignPanel.repaint(); } @@ -168,44 +208,52 @@ public class IdPanel extends Panel implements MouseListener, MouseMotionListener av.getSelectionGroup().addOrRemove(pickedSeq); } - void selectSeqs(int start, int end) { + void selectSeqs(int start, int end) + { lastid = start; if (end < start) - { - int tmp = start; - start = end; - end = tmp; - lastid = end; - } - - for (int i = start; i <= end; i++) - av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i)); + { + int tmp = start; + start = end; + end = tmp; + lastid = end; + } - } + for (int i = start; i <= end; i++) + { + av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i)); + } + } public void mouseReleased(MouseEvent e) { - if(scrollThread!=null) + if (scrollThread != null) + { scrollThread.running = false; + } mouseDragging = false; PaintRefresher.Refresh(this); } - public void highlightSearchResults( java.util.Vector found ) + public void highlightSearchResults(java.util.Vector found) { - idCanvas.setHighlighted( found ); + idCanvas.setHighlighted(found); - if(found == null) + if (found == null) + { return; + } - int index = av.alignment.findIndex( (SequenceI)found.elementAt(0)); + int index = av.alignment.findIndex( (SequenceI) found.elementAt(0)); // do we need to scroll the panel? - if(av.getStartSeq()>index || av.getEndSeq() index || av.getEndSeq() < index) + { + alignPanel.setScrollValues(av.getStartRes(), index); + } } // this class allows scrolling off the bottom of the visible alignment @@ -230,22 +278,30 @@ public class IdPanel extends Panel implements MouseListener, MouseMotionListener running = true; while (running) { - if(alignPanel.scrollUp(up)) + if (alignPanel.scrollUp(up)) { // scroll was ok, so add new sequence to selection int seq = av.getStartSeq(); - if(!up) + 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 @@ -256,6 +312,6 @@ public class IdPanel extends Panel implements MouseListener, MouseMotionListener {} } } -} + } } diff --git a/src/jalview/appletgui/IdwidthAdjuster.java b/src/jalview/appletgui/IdwidthAdjuster.java index 5e5df30..5b4de85 100755 --- a/src/jalview/appletgui/IdwidthAdjuster.java +++ b/src/jalview/appletgui/IdwidthAdjuster.java @@ -1,79 +1,103 @@ /* -* 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.appletgui; -import java.awt.event.*; import java.awt.*; +import java.awt.event.*; - -public class IdwidthAdjuster extends Panel implements MouseListener, MouseMotionListener +public class IdwidthAdjuster + extends Panel implements MouseListener, MouseMotionListener { boolean active = false; - int oldX=0; + int oldX = 0; Image image; - AlignmentPanel ap ; + AlignmentPanel ap; public IdwidthAdjuster(AlignmentPanel ap) { setLayout(null); this.ap = ap; java.net.URL url = getClass().getResource("/images/idwidth.gif"); - if (url != null) - image = java.awt.Toolkit.getDefaultToolkit().getImage(url); + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().getImage(url); + } addMouseListener(this); addMouseMotionListener(this); } public void mousePressed(MouseEvent evt) - { oldX = evt.getX(); } + { + 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 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.getSize(); int dif = evt.getX() - oldX; - if(d.width+dif>20 || dif>0) + if (d.width + dif > 20 || dif > 0) { - ap.setIdWidth(d.width + dif,d.height); + ap.setIdWidth(d.width + dif, d.height); this.setSize(d.width + dif, getSize().height); } oldX = evt.getX(); } - public void mouseMoved(MouseEvent evt) {} - public void mouseClicked(MouseEvent evt) {} + public void mouseMoved(MouseEvent evt) + {} + + public void mouseClicked(MouseEvent evt) + {} public void paint(Graphics g) { g.setColor(Color.white); - g.fillRect(0,0, getSize().width, getSize().height); - if(active) + g.fillRect(0, 0, getSize().width, getSize().height); + if (active) { - if(image!=null) - g.drawImage(image, getSize().width-20, 2, this); + if (image != null) + { + g.drawImage(image, getSize().width - 20, 2, this); + } } } diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 97f8147..d02892b 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -1,28 +1,29 @@ /* -* 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.appletgui; -import java.awt.event.*; import java.awt.*; +import java.awt.event.*; -public class OverviewPanel extends Panel implements Runnable +public class OverviewPanel + extends Panel implements Runnable { Image miniMe; AlignViewport av; @@ -31,8 +32,8 @@ public class OverviewPanel extends Panel implements Runnable float scaleh = 1f; public int width, sequencesHeight; - int graphHeight=30; - int boxX=-1, boxY=-1, boxWidth=-1, boxHeight=-1; + int graphHeight = 30; + int boxX = -1, boxY = -1, boxWidth = -1, boxHeight = -1; boolean resizing = false; @@ -47,47 +48,58 @@ public class OverviewPanel extends Panel implements Runnable nullFrame.addNotify(); // 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()) + float initialScale = (float) av.alignment.getWidth() / + (float) av.alignment.getHeight(); + if (av.alignment.getWidth() > av.alignment.getHeight()) { // wider width = 400; - sequencesHeight = (int)(400f/initialScale); + sequencesHeight = (int) (400f / initialScale); } else { // taller - width = (int)(400f*initialScale); + width = (int) (400f * initialScale); sequencesHeight = 300; - if(width<120) + if (width < 120) + { width = 120; + } } - setSize (new Dimension(width, sequencesHeight+graphHeight)); + setSize(new Dimension(width, sequencesHeight + graphHeight)); addComponentListener(new ComponentAdapter() - { + { - public void componentResized(ComponentEvent evt) - { - if( getSize().width!=width || getSize().height!=sequencesHeight+graphHeight) - { - updateOverviewImage(); - } - } - }); + public void componentResized(ComponentEvent evt) + { + if (getSize().width != width || + getSize().height != sequencesHeight + graphHeight) + { + updateOverviewImage(); + } + } + }); addMouseMotionListener(new MouseMotionAdapter() - { - public void mouseDragged(MouseEvent evt) - { doMouseDragged(evt);} - }); + { + public void mouseDragged(MouseEvent evt) + { + doMouseDragged(evt); + } + }); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) - { doMousePressed(evt);} + { + doMousePressed(evt); + } + public void mouseReleased(MouseEvent evt) - { doMouseReleased(evt);} + { + doMouseReleased(evt); + } }); updateOverviewImage(); @@ -108,9 +120,11 @@ public class OverviewPanel extends Panel implements Runnable boxX = evt.getX(); boxY = evt.getY(); checkValid(); - if(!resizing) - ap.setScrollValues( (int)(boxX/scalew/av.getCharWidth()), - (int)(boxY/scaleh/av.getCharHeight()) ); + if (!resizing) + { + ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); + } } public void doMouseDragged(MouseEvent evt) @@ -118,9 +132,11 @@ public class OverviewPanel extends Panel implements Runnable boxX = evt.getX(); boxY = evt.getY(); checkValid(); - if(!resizing) - ap.setScrollValues( (int)(boxX/scalew/av.getCharWidth()), - (int)(boxY/scaleh/av.getCharHeight()) ); + if (!resizing) + { + ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); + } repaint(); ap.repaint(); } @@ -128,21 +144,29 @@ public class OverviewPanel extends Panel implements Runnable void checkValid() { if (boxY < 0) + { boxY = 0; + } if (boxY > sequencesHeight - boxHeight) - boxY = sequencesHeight - boxHeight+1; + { + boxY = sequencesHeight - boxHeight + 1; + } if (boxX < 0) + { boxX = 0; + } if (boxX > width - boxWidth) + { boxX = width - boxWidth; + } } public void updateOverviewImage() { - if(resizing) + if (resizing) { return; } @@ -159,15 +183,15 @@ public class OverviewPanel extends Panel implements Runnable int alwidth = av.alignment.getWidth(); int alheight = av.alignment.getHeight(); - if(getSize().width>0 && getSize().height>0) + if (getSize().width > 0 && getSize().height > 0) { width = getSize().width; sequencesHeight = getSize().height - graphHeight; } - setSize (new Dimension(width, sequencesHeight+graphHeight)); + setSize(new Dimension(width, sequencesHeight + graphHeight)); - int fullsizeWidth = alwidth * av.getCharWidth(); + int fullsizeWidth = alwidth * av.getCharWidth(); int fullsizeHeight = alheight * av.getCharHeight(); scalew = (float) width / (float) fullsizeWidth; @@ -180,62 +204,72 @@ public class OverviewPanel extends Panel implements Runnable 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); - + sequencesHeight + graphHeight, 0, 0, fullsizeWidth, 60, this); boolean oldRenderGaps = av.renderGaps; - try{ - // We'll have to draw the full size alignment in chunks, as an image of the - // whole alignment requires too much memory + 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(); + int maxSize = 2000 / av.getFont().getSize(); Image block; - int blockx=0, blocky=0, blockw=0, blockh=0, eRes=0, eSeq=0; + int blockx = 0, blocky = 0, blockw = 0, blockh = 0, eRes = 0, eSeq = 0; av.setRenderGaps(false); - for(int sRes=0, chunkx=0; sResalwidth) - eRes = alwidth; - - for(int sSeq=0, chunky=0; sSeq alwidth) + { + eRes = alwidth; + } + + for (int sSeq = 0, chunky = 0; sSeq < alheight; sSeq += maxSize, chunky++) + { + eSeq += maxSize; + if (eSeq > alheight) { - eSeq+=maxSize; - if(eSeq>alheight) - eSeq = alheight; + eSeq = alheight; + } - blocky = 0; - blockx = (int)((float)sRes/(float)alwidth * width); + blocky = 0; + blockx = (int) ( (float) sRes / (float) alwidth * width); - block = nullFrame.createImage((eRes-sRes)*av.charWidth, (eSeq-sSeq)*av.charHeight); - g = block.getGraphics(); + block = nullFrame.createImage( (eRes - sRes) * av.charWidth, + (eSeq - sSeq) * av.charHeight); + g = block.getGraphics(); - ap.seqPanel.seqCanvas.drawPanel(g, sRes, eRes, sSeq, eSeq, sRes, sSeq, 0); + 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; + 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); + blocky += (int) ( (float) sSeq / (float) alheight * sequencesHeight); - mg.drawImage(block, blockx, - blocky , - blockx + blockw, - blocky + blockh, + mg.drawImage(block, blockx, + blocky, + blockx + blockw, + blocky + blockh, - 0, 0, block.getWidth(null),block.getHeight(null), this); + 0, 0, block.getWidth(null), block.getHeight(null), this); block = null; - } + } } - }catch(OutOfMemoryError error) - { System.err.println("Out of memory when trying to calculate the overview window image!"); } - + } + catch (OutOfMemoryError error) + { + System.err.println( + "Out of memory when trying to calculate the overview window image!"); + } av.setRenderGaps(oldRenderGaps); resizing = false; @@ -245,38 +279,41 @@ public class OverviewPanel extends Panel implements Runnable 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(); + 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 update(Graphics g) - { - paint(g); - } + public void update(Graphics g) + { + paint(g); + } public void paint(Graphics g) { - if(resizing) + if (resizing) { g.setColor(Color.white); g.fillRect(0, 0, getSize().width, getSize().height); g.setColor(Color.black); g.setFont(new Font("Verdana", Font.BOLD, 15)); - g.drawString("Recalculating", 5, sequencesHeight/2); - g.drawString("Overview.....", 5, sequencesHeight/2 +20); + g.drawString("Recalculating", 5, sequencesHeight / 2); + g.drawString("Overview.....", 5, sequencesHeight / 2 + 20); } else { - if(miniMe!=null) - g.drawImage(miniMe, 0,0,this); + 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.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } } diff --git a/src/jalview/appletgui/PCAPanel.java b/src/jalview/appletgui/PCAPanel.java index f652aae..1dd05e0 100755 --- a/src/jalview/appletgui/PCAPanel.java +++ b/src/jalview/appletgui/PCAPanel.java @@ -1,33 +1,35 @@ /* -* 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.appletgui; -import jalview.datamodel.*; -import jalview.analysis.PCA; -import jalview.jbappletgui.*; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import java.util.*; +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.jbappletgui.*; -public class PCAPanel extends GPCAPanel implements Runnable +public class PCAPanel + extends GPCAPanel implements Runnable { PCA pca; int top; @@ -39,30 +41,34 @@ public class PCAPanel extends GPCAPanel implements Runnable // do stuff } - public PCAPanel(AlignViewport av, SequenceI[] s) { + public PCAPanel(AlignViewport av, SequenceI[] s) + { this.av = av; - if(av.getSelectionGroup().getSize()>3) + if (av.getSelectionGroup().getSize() > 3) { s = new Sequence[av.getSelectionGroup().getSize()]; - for(int i=0; i 1e-4) { - comps[i] = pca.component(i); + comps[i] = pca.component(i); } } @@ -84,37 +90,39 @@ public class PCAPanel extends GPCAPanel implements Runnable yCombobox.select(1); zCombobox.select(2); - top = pca.getM().rows-1; + top = pca.getM().rows - 1; Vector points = new Vector(); - float[][] scores = pca.getComponents(top-1,top-2,top-3,100); + float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100); - for (int i =0; i < pca.getM().rows; i++ ) + for (int i = 0; i < pca.getM().rows; i++) { - SequencePoint sp = new SequencePoint(s[i],scores[i]); + SequencePoint sp = new SequencePoint(s[i], scores[i]); points.addElement(sp); } - rc = new RotatableCanvas(av,points,pca.getM().rows); + rc = new RotatableCanvas(av, points, pca.getM().rows); //rc.printPoints(); add(rc, BorderLayout.CENTER); } - void doDimensionChange() { - if(top==0) + 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]; + 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; diff --git a/src/jalview/appletgui/PaintRefresher.java b/src/jalview/appletgui/PaintRefresher.java index 0f2c1f6..670af70 100755 --- a/src/jalview/appletgui/PaintRefresher.java +++ b/src/jalview/appletgui/PaintRefresher.java @@ -1,50 +1,60 @@ /* -* 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.appletgui; -import java.awt.*; + import java.util.*; +import java.awt.*; + public class PaintRefresher { static Vector components = new Vector(); public static void Register(Component c) { - if(!components.contains(c)) + if (!components.contains(c)) + { components.addElement(c); + } else + { components.removeElement(c); + } } public static void Refresh(Component c) { Component temp; Enumeration e = components.elements(); - while( e.hasMoreElements() ) + while (e.hasMoreElements()) { - temp = (Component)e.nextElement(); + temp = (Component) e.nextElement(); - if(!temp.isValid()) - components.removeElement( temp ); - else if( temp == c ) - continue; + if (!temp.isValid()) + { + components.removeElement(temp); + } + else if (temp == c) + { + continue; + } temp.repaint(); } diff --git a/src/jalview/appletgui/PairwiseAlignPanel.java b/src/jalview/appletgui/PairwiseAlignPanel.java index 65f40c3..55cf2cc 100755 --- a/src/jalview/appletgui/PairwiseAlignPanel.java +++ b/src/jalview/appletgui/PairwiseAlignPanel.java @@ -1,89 +1,97 @@ /* -* 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.appletgui; -import jalview.datamodel.*; -import jalview.jbappletgui.GPairwiseAlignPanel; -import jalview.analysis.*; -import java.awt.event.*; import java.util.*; +import java.awt.event.*; + +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.jbappletgui.*; -public class PairwiseAlignPanel extends GPairwiseAlignPanel +public class PairwiseAlignPanel + extends GPairwiseAlignPanel { - Vector sequences = new Vector(); - AlignViewport av; + Vector sequences = new Vector(); + AlignViewport av; - public PairwiseAlignPanel(AlignViewport av) + public PairwiseAlignPanel(AlignViewport av) + { + super(); + this.av = av; + float scores[][] = new float[av.getAlignment().getHeight()][av.getAlignment(). + getHeight()]; + double totscore = 0; + int count = av.getSelectionGroup().getSize(); + + int acount = 0; + for (int i = 1; i < count; i++) { - super(); - this.av = av; - float scores[][] = new float[av.getAlignment().getHeight()][av.getAlignment().getHeight()]; - double totscore = 0; - int count = av.getSelectionGroup().getSize(); - - int acount = 0; - for (int i = 1; i < count; i++) - { - for (int j = 0; j < i; j++) - { - acount++; - AlignSeq as = new AlignSeq(av.getSelectionGroup().getSequenceAt(i), - av.getSelectionGroup().getSequenceAt(j),"pep"); - - as.calcScoreMatrix(); - as.traceAlignment(); - as.printAlignment(); - scores[i][j] = (float)as.getMaxScore()/(float)as.getASeq1().length; - totscore = totscore + scores[i][j]; + for (int j = 0; j < i; j++) + { + acount++; + AlignSeq as = new AlignSeq(av.getSelectionGroup().getSequenceAt(i), + av.getSelectionGroup().getSequenceAt(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.addElement(new Sequence(as.getS1().getName(), as.getAStr1())); + sequences.addElement(new Sequence(as.getS2().getName(), as.getAStr2())); - textarea.append(as.getOutput()); - sequences.addElement( new Sequence( as.getS1().getName(), as.getAStr1()) ); - sequences.addElement( new Sequence( as.getS2().getName(), as.getAStr2()) ); - - - } - } + } + } - if (count > 2) + if (count > 2) + { + for (int i = 0; i < count; i++) + { + for (int j = 0; j < i; j++) { - 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); + jalview.util.Format.print(System.out, "%7.3f", + scores[i][j] / totscore); } } - + } + } protected void viewInEditorButton_actionPerformed(ActionEvent e) { - Sequence [] seq = new Sequence[sequences.size()]; - - for (int i=0;i 1) + { - oldAlignment = new SequenceI[ap.av.alignment.getHeight()]; - for (int i = 0; i < ap.av.alignment.getHeight(); i++) + del = ap.av.alignment.removeRedundancy(threshold, sg.sequences); + for (int i = 0; i < del.size(); i++) + { + if (sg.sequences.contains( (SequenceI) del.elementAt(i))) { - oldAlignment[i] = new Sequence(ap.av.alignment.getSequenceAt(i).getName(), - ap.av.alignment.getSequenceAt(i). - getSequence()); + sg.deleteSequence( (SequenceI) del.elementAt(i)); } + } - undoButton.setEnabled(true); - - SequenceGroup sg = ap.av.getSelectionGroup(); - 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)); - - } - else - { - Vector s = new Vector(); - int i=0; - while(i < ap.av.alignment.getHeight()) - { - s.addElement( ap.av.alignment.getSequenceAt(i) ); - i++; - } - del = ap.av.alignment.removeRedundancy(threshold,s); - for (int j=0; j < del.size(); j++) - { - if (sg.sequences.contains((SequenceI)del.elementAt(j))) - sg.deleteSequence((SequenceI)del.elementAt(j)); - - } - } - - ap.repaint(); + } + else + { + Vector s = new Vector(); + int i = 0; + while (i < ap.av.alignment.getHeight()) + { + s.addElement(ap.av.alignment.getSequenceAt(i)); + i++; + } + del = ap.av.alignment.removeRedundancy(threshold, s); + for (int j = 0; j < del.size(); j++) + { + if (sg.sequences.contains( (SequenceI) del.elementAt(j))) + { + sg.deleteSequence( (SequenceI) del.elementAt(j)); + } + + } + } + + ap.repaint(); } public void undoButton_actionPerformed(ActionEvent e) { - undoButton.setEnabled(false); - ap.av.setAlignment( new Alignment(oldAlignment) ); - oldAlignment = null; - ap.repaint(); + undoButton.setEnabled(false); + ap.av.setAlignment(new Alignment(oldAlignment)); + oldAlignment = null; + ap.repaint(); } - public void valueField_actionPerformed(ActionEvent e) { - try{ + try + { int i = Integer.parseInt(valueField.getText()); slider.setValue(i); } - catch(Exception ex) + catch (Exception ex) { - valueField.setText( slider.getValue()+"" ); + valueField.setText(slider.getValue() + ""); } } } diff --git a/src/jalview/appletgui/RotatableCanvas.java b/src/jalview/appletgui/RotatableCanvas.java index a13b1a2..7d32b86 100755 --- a/src/jalview/appletgui/RotatableCanvas.java +++ b/src/jalview/appletgui/RotatableCanvas.java @@ -1,42 +1,43 @@ /* -* 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.appletgui; -import jalview.math.*; -import jalview.datamodel.*; -import jalview.util.*; +import java.util.*; import java.awt.*; import java.awt.event.*; -import java.util.*; +import jalview.datamodel.*; +import jalview.math.*; +import jalview.util.*; -public class RotatableCanvas extends Panel implements MouseListener, - MouseMotionListener, - KeyListener - //RubberbandListener, - //SequenceSelectionListener +public class RotatableCanvas + extends Panel implements MouseListener, + MouseMotionListener, + KeyListener +//RubberbandListener, +//SequenceSelectionListener { - RotatableMatrix idmat = new RotatableMatrix(3,3); - RotatableMatrix objmat = new RotatableMatrix(3,3); - RotatableMatrix rotmat = new RotatableMatrix(3,3); + RotatableMatrix idmat = new RotatableMatrix(3, 3); + RotatableMatrix objmat = new RotatableMatrix(3, 3); + RotatableMatrix rotmat = new RotatableMatrix(3, 3); //RubberbandRectangle rubberband; @@ -85,7 +86,8 @@ public class RotatableCanvas extends Panel implements MouseListener, public RotatableCanvas(AlignViewport av, - Vector points, int npoint) { + Vector points, int npoint) + { this.points = points; this.npoint = npoint; this.av = av; @@ -94,24 +96,31 @@ public class RotatableCanvas extends Panel implements MouseListener, 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++) { + 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++) { - 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); + for (int i = 0; i < 3; i++) + { + 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); } } } @@ -128,59 +137,70 @@ public class RotatableCanvas extends Panel implements MouseListener, addMouseListener(this); addKeyListener(this); - // if (getParent() != null) { - // getParent().addKeyListener(this); + // if (getParent() != null) { + // getParent().addKeyListener(this); //} addMouseMotionListener(this); // Add rubberband - // rubberband = new RubberbandRectangle(this); - // rubberband.setActive(true); - // rubberband.addListener(this); + // rubberband = new RubberbandRectangle(this); + // rubberband.setActive(true); + // rubberband.addListener(this); } - /* public boolean handleSequenceSelectionEvent(SequenceSelectionEvent evt) { - redrawneeded = true; - repaint(); - return true; - } + /* public boolean handleSequenceSelectionEvent(SequenceSelectionEvent evt) { + redrawneeded = true; + repaint(); + return true; + } - public void removeNotify() { - controller.removeListener(this); - super.removeNotify(); - }*/ + public void removeNotify() { + controller.removeListener(this); + super.removeNotify(); + }*/ - public void initAxes() { - for (int i = 0; i < 3; i++) { - for (int j=0; j < 3; j++) { - if (i != j) { + public void initAxes() + { + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + if (i != j) + { axes[i][j] = 0; - } else { + } + else + { axes[i][j] = 1; } } } } - public void findWidth() { + 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); - if (sp.coord[i] >= max[i]) { + 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]) { + if (sp.coord[i] <= min[i]) + { min[i] = sp.coord[i]; } } @@ -197,130 +217,156 @@ public class RotatableCanvas extends Panel implements MouseListener, maxwidth = width[0]; if (width[1] > width[0]) + { maxwidth = width[1]; + } if (width[2] > width[1]) + { maxwidth = width[2]; + } //System.out.println("Maxwidth = " + maxwidth); } - public float findScale() { + public float findScale() + { int dim, width, height; - if (getSize().width != 0) { + if (getSize().width != 0) + { width = getSize().width; height = getSize().height; - } else { + } + else + { width = prefsize.width; height = prefsize.height; } - if (width < height) { + if (width < height) + { dim = width; - } else { + } + else + { dim = height; } - return (float)(dim*scalefactor/(2*maxwidth)); + return (float) (dim * scalefactor / (2 * maxwidth)); } - public void findCentre() { + public void findCentre() + { //Find centre coordinate findWidth(); - centre[0] = (max[0] + min[0])/2; - centre[1] = (max[1] + min[1])/2; - centre[2] = (max[2] + min[2])/2; + centre[0] = (max[0] + min[0]) / 2; + centre[1] = (max[1] + min[1]) / 2; + centre[2] = (max[2] + min[2]) / 2; // System.out.println("Centre x " + centre[0]); //System.out.println("Centre y " + centre[1]); //System.out.println("Centre z " + centre[2]); } - public Dimension getPreferredSize() { - if (prefsize != null) { + public Dimension getPreferredSize() + { + if (prefsize != null) + { return prefsize; - } else { - return new Dimension(400,400); + } + else + { + return new Dimension(400, 400); } } - public Dimension getMinimumSize() { + public Dimension getMinimumSize() + { return getPreferredSize(); } - public void paint(Graphics g) { + public void paint(Graphics g) + { //Only create the image at the beginning - - if ((img == null) || (prefsize.width != getSize().width) || (prefsize.height != getSize().height)) { + if ( (img == null) || (prefsize.width != getSize().width) || + (prefsize.height != getSize().height)) + { prefsize.width = getSize().width; prefsize.height = getSize().height; scale = findScale(); // System.out.println("New scale = " + scale); - img = createImage(getSize().width,getSize().height); + img = createImage(getSize().width, getSize().height); ig = img.getGraphics(); } + drawBackground(ig, Color.black); + drawScene(ig); + if (drawAxes == true) + { + drawAxes(ig); + } - drawBackground(ig,Color.black); - drawScene(ig); - if (drawAxes == true) - { - drawAxes(ig); - } - - - g.drawImage(img,0,0,this); + g.drawImage(img, 0, 0, this); } - public void drawAxes(Graphics g) { + public void drawAxes(Graphics g) + { g.setColor(Color.yellow); - for (int i=0; i < 3 ; i++) { - g.drawLine(getSize().width/2,getSize().height/2, - (int)(axes[i][0]*scale*max[0] + getSize().width/2), - (int)(axes[i][1]*scale*max[1] + getSize().height/2)); + for (int i = 0; i < 3; i++) + { + g.drawLine(getSize().width / 2, getSize().height / 2, + (int) (axes[i][0] * scale * max[0] + getSize().width / 2), + (int) (axes[i][1] * scale * max[1] + getSize().height / 2)); } } - public void drawBackground(Graphics g, Color col) { + public void drawBackground(Graphics g, Color col) + { g.setColor(col); - g.fillRect(0,0,prefsize.width,prefsize.height); + g.fillRect(0, 0, prefsize.width, prefsize.height); } - - public void drawScene(Graphics g) { + public void drawScene(Graphics g) + { boolean darker = false; - int halfwidth = getSize().width/2; - int halfheight = getSize().height/2; + int halfwidth = getSize().width / 2; + int halfheight = getSize().height / 2; - 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; + 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); + { + g.setColor(Color.white); + } else - g.setColor(sp.sequence.getColor()); - + { + g.setColor(sp.sequence.getColor()); + } if (av.getSelectionGroup() != null) { - if (av.getSelectionGroup().sequences.contains(((SequencePoint)points.elementAt(i)).sequence)) + 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.fillRect(x - 3, y - 3, 6, 6); g.setColor(Color.red); } // //Now the rectangle @@ -331,52 +377,75 @@ public class RotatableCanvas extends Panel implements MouseListener, // } } - public Dimension minimumsize() { + public Dimension minimumsize() + { return prefsize; } - public Dimension preferredsize() { + public Dimension preferredsize() + { return prefsize; } - public void keyTyped(KeyEvent evt) { } - public void keyReleased(KeyEvent evt) { } + public void keyTyped(KeyEvent evt) + {} - public void keyPressed(KeyEvent evt) { + public void keyReleased(KeyEvent evt) + {} + + public void keyPressed(KeyEvent evt) + { requestFocus(); - if (evt.getKeyCode() == KeyEvent.VK_UP) { - scalefactor = (float)(scalefactor * 1.1); + 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); + } + else if (evt.getKeyCode() == KeyEvent.VK_DOWN) + { + scalefactor = (float) (scalefactor * 0.9); scale = findScale(); - } else if (evt.getKeyChar() == 's') { + } + else if (evt.getKeyChar() == 's') + { System.err.println("DEBUG: Rectangle selection"); // log.debug - if (rectx2 != -1 && recty2 != -1) { - rectSelect(rectx1,recty1,rectx2,recty2); + if (rectx2 != -1 && recty2 != -1) + { + rectSelect(rectx1, recty1, rectx2, recty2); } } repaint(); } - public void printPoints() { - for (int i=0; i < npoint; i++) { - 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]); + public void printPoints() + { + for (int i = 0; i < npoint; i++) + { + 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) { } + public void mouseClicked(MouseEvent evt) + {} - public void mousePressed(MouseEvent evt) { + public void mouseEntered(MouseEvent evt) + {} + + public void mouseExited(MouseEvent evt) + {} + + public void mouseReleased(MouseEvent evt) + {} + + public void mousePressed(MouseEvent evt) + { int x = evt.getX(); int y = evt.getY(); @@ -395,7 +464,7 @@ public class RotatableCanvas extends Panel implements MouseListener, rectx2 = -1; recty2 = -1; - SequenceI found = findPoint(x,y); + SequenceI found = findPoint(x, y); if (found != null) { @@ -406,45 +475,50 @@ public class RotatableCanvas extends Panel implements MouseListener, } else { - av.setSelectionGroup(new SequenceGroup()); - av.getSelectionGroup().addOrRemove(found); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()); + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().addOrRemove(found); + av.getSelectionGroup().setEndRes(av.alignment.getWidth()); } } repaint(); } - // private void fireSequenceSelectionEvent(Selection sel) { - // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); + // private void fireSequenceSelectionEvent(Selection sel) { + // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); //} public void mouseMoved(MouseEvent evt) { - // SequenceI found = findPoint(evt.getX(), evt.getY()); + // SequenceI found = findPoint(evt.getX(), evt.getY()); } - public void mouseDragged(MouseEvent evt) { + 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) { + if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) + { // rectx2 = evt.getX(); // recty2 = evt.getY(); - } else { + } + else + { rotmat.setIdentity(); - rotmat.rotate((float)(my-omy),'x'); - rotmat.rotate((float)(mx-omx),'y'); + rotmat.rotate( (float) (my - omy), 'x'); + rotmat.rotate( (float) (mx - omx), 'y'); - for (int i = 0; i < npoint; i++) { - SequencePoint sp = (SequencePoint)points.elementAt(i); + 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 apply the rotation matrix - sp.coord= rotmat.vectorMultiply(sp.coord); + sp.coord = rotmat.vectorMultiply(sp.coord); //Now translate back again sp.coord[0] += centre[0]; @@ -452,7 +526,8 @@ public class RotatableCanvas extends Panel implements MouseListener, sp.coord[2] += centre[2]; } - for (int i=0; i < 3; i++) { + for (int i = 0; i < 3; i++) + { axes[i] = rotmat.vectorMultiply(axes[i]); } omx = mx; @@ -463,15 +538,21 @@ public class RotatableCanvas extends Panel implements MouseListener, } - public void rectSelect(int x1, int y1, int x2, int y2) { + public void rectSelect(int x1, int y1, int x2, int y2) + { boolean changedSel = false; - for (int i=0; i < npoint; i++) { - SequencePoint sp = (SequencePoint)points.elementAt(i); - int tmp1 = (int)((sp.coord[0] - centre[0])*scale + (float)getSize().width/2.0); - int tmp2 = (int)((sp.coord[1] - centre[1])*scale + (float)getSize().height/2.0); + for (int i = 0; i < npoint; i++) + { + SequencePoint sp = (SequencePoint) points.elementAt(i); + int tmp1 = (int) ( (sp.coord[0] - centre[0]) * scale + + (float) getSize().width / 2.0); + int tmp2 = (int) ( (sp.coord[1] - centre[1]) * scale + + (float) getSize().height / 2.0); - if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) { - if (av != null) { + if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) + { + if (av != null) + { if (!av.getSelectionGroup().sequences.contains(sp.sequence)) { changedSel = true; @@ -480,54 +561,60 @@ public class RotatableCanvas extends Panel implements MouseListener, } } } - // if (changedSel) { - // fireSequenceSelectionEvent(av.getSelection()); - // } + // if (changedSel) { + // fireSequenceSelectionEvent(av.getSelection()); + // } } - public SequenceI findPoint(int x, int y) { - int halfwidth = getSize().width/2; - int halfheight = getSize().height/2; + public SequenceI findPoint(int x, int y) + { + + int halfwidth = getSize().width / 2; + int halfheight = getSize().height / 2; 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; + 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 ) { + if (Math.abs(px - x) < 3 && Math.abs(py - y) < 3) + { found = i; } } - if (found != -1) { - return ((SequencePoint)points.elementAt(found)).sequence; - } else { + 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/appletgui/ScalePanel.java b/src/jalview/appletgui/ScalePanel.java index 24460ba..71d360d 100755 --- a/src/jalview/appletgui/ScalePanel.java +++ b/src/jalview/appletgui/ScalePanel.java @@ -1,33 +1,35 @@ /* -* 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.appletgui; -import jalview.datamodel.*; import java.awt.*; import java.awt.event.*; -public class ScalePanel extends Panel +import jalview.datamodel.*; + +public class ScalePanel + extends Panel { protected int offy = 4; - public int width; + public int width; protected AlignViewport av; AlignmentPanel ap; @@ -37,7 +39,7 @@ public class ScalePanel extends Panel public ScalePanel(AlignViewport av, AlignmentPanel ap) { setLayout(null); - this.av = av; + this.av = av; this.ap = ap; addMouseListener(new MouseAdapter() @@ -46,6 +48,7 @@ public class ScalePanel extends Panel { doMousePressed(evt); } + public void mouseReleased(MouseEvent evt) { doMouseReleased(evt); @@ -62,21 +65,25 @@ public class ScalePanel extends Panel } - - public void doMousePressed(MouseEvent evt) { + public void doMousePressed(MouseEvent evt) + { int x = evt.getX(); - int res = x/av.getCharWidth() + av.getStartRes(); + int res = x / av.getCharWidth() + av.getStartRes(); SequenceGroup sg = null; if (av.getColumnSelection().contains(res)) + { av.getColumnSelection().removeElement(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)); + } sg.setStartRes(res); sg.setEndRes(res); @@ -89,41 +96,53 @@ public class ScalePanel extends Panel public void doMouseReleased(MouseEvent evt) { - if(!stretchingGroup) + if (!stretchingGroup) + { return; + } int x = evt.getX(); - int res = x/av.getCharWidth() + av.getStartRes(); + int res = x / av.getCharWidth() + av.getStartRes(); - if (! av.getColumnSelection().contains(res)) - av.getColumnSelection().addElement(res); + if (!av.getColumnSelection().contains(res)) + { + av.getColumnSelection().addElement(res); + } - SequenceGroup sg = av.getSelectionGroup(); + SequenceGroup sg = av.getSelectionGroup(); - if(res>sg.getStartRes()) - sg.setEndRes(res); - else if(res sg.getStartRes()) + { + sg.setEndRes(res); + } + else if (res < sg.getStartRes()) + { + sg.setStartRes(res); + } - stretchingGroup = false; - ap.repaint(); + stretchingGroup = false; + ap.repaint(); } public void doMouseDragged(MouseEvent evt) { int x = evt.getX(); - int res = x/av.getCharWidth() + av.getStartRes(); + int res = x / av.getCharWidth() + av.getStartRes(); SequenceGroup sg = av.getSelectionGroup(); - if(sg!=null) + if (sg != null) { stretchingGroup = true; if (res > sg.getStartRes()) + { sg.setEndRes(res); + } else if (res < sg.getStartRes()) + { sg.setStartRes(res); + } - ap.annotationPanel.addEditableColumn(res); + ap.annotationPanel.addEditableColumn(res); ap.repaint(); } } @@ -135,60 +154,65 @@ public class ScalePanel extends Panel public void paint(Graphics g) { - drawScale(g, av.getStartRes(), av.getEndRes(), getSize().width, getSize().height); + drawScale(g, av.getStartRes(), av.getEndRes(), getSize().width, + getSize().height); } // scalewidth will normally be screenwidth, - public void drawScale(Graphics gg, int startx, int endx, int width, int height) + public void drawScale(Graphics gg, int startx, int endx, int width, + int height) { gg.setFont(av.getFont()); //Fill in the background gg.setColor(Color.white); - gg.fillRect(0,0,width, height); + 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= startx && sel <= endx) - gg.fillRect((sel-startx)*av.charWidth,0,av.charWidth, getSize().height); + int sel = cs.columnAt(i); + if (sel >= startx && sel <= endx) + { + gg.fillRect( (sel - startx) * av.charWidth, 0, av.charWidth, + getSize().height); + } } - // Draw the scale numbers gg.setColor(Color.black); - int scalestartx = (startx/10) * 10; + int scalestartx = (startx / 10) * 10; FontMetrics fm = gg.getFontMetrics(av.getFont()); - int y = av.charHeight -fm.getDescent(); + int y = av.charHeight - fm.getDescent(); - if(scalestartx%10==0) - scalestartx+=5; + if (scalestartx % 10 == 0) + { + scalestartx += 5; + } - for (int i=scalestartx;i < endx; i+= 5) + for (int i = scalestartx; i < endx; i += 5) { - if(i%10==0) + 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, + y + 2, (int) ( (i - startx - 1) * av.charWidth + av.charWidth / 2), - y+fm.getDescent()*2); + y + fm.getDescent() * 2); } else + { gg.drawLine( (int) ( (i - startx - 1) * av.charWidth + av.charWidth / 2), - y+fm.getDescent(), + y + fm.getDescent(), (int) ( (i - startx - 1) * av.charWidth + av.charWidth / 2), - y+fm.getDescent()*2); - + y + fm.getDescent() * 2); + } } } - } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 6855468..438d7ad 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -1,60 +1,61 @@ /* -* 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.appletgui; import java.awt.*; -import jalview.datamodel.*; -import jalview.analysis.*; +import jalview.analysis.*; +import jalview.datamodel.*; -public class SeqCanvas extends Panel +public class SeqCanvas + extends Panel { - FeatureRenderer fr; - SequenceRenderer sr; - Image img; - Graphics gg; - int imgWidth; - int imgHeight; - - AlignViewport av; + FeatureRenderer fr; + SequenceRenderer sr; + Image img; + Graphics gg; + int imgWidth; + int imgHeight; - boolean showScores = false; - boolean displaySearch = false; - int [] searchResults = null; + AlignViewport av; - int chunkHeight; - int chunkWidth; + boolean showScores = false; + boolean displaySearch = false; + int[] searchResults = null; - boolean fastPaint = false; + int chunkHeight; + int chunkWidth; + boolean fastPaint = false; - public SeqCanvas(AlignViewport av) - { - this.av = av; - fr = new FeatureRenderer(av); - sr = new SequenceRenderer(av); - PaintRefresher.Register(this); + public SeqCanvas(AlignViewport av) + { + this.av = av; + fr = new FeatureRenderer(av); + sr = new SequenceRenderer(av); + PaintRefresher.Register(this); - } + } - void drawNorthScale(Graphics g, int startx, int endx,int ypos) { + void drawNorthScale(Graphics g, int startx, int endx, int ypos) + { int scalestartx = startx - startx % 10 + 10; g.setColor(Color.black); @@ -76,8 +77,8 @@ public class SeqCanvas extends Panel void drawWestScale(Graphics g, int startx, int endx, int ypos) { FontMetrics fm = getFontMetrics(av.getFont()); - ypos+= av.charHeight; - // EAST SCALE + ypos += av.charHeight; + // EAST SCALE for (int i = 0; i < av.alignment.getHeight(); i++) { SequenceI seq = av.alignment.getSequenceAt(i); @@ -94,46 +95,50 @@ public class SeqCanvas extends Panel value = av.alignment.getSequenceAt(i).findPosition(index); break; } - if(value!=-1) + if (value != -1) { - int x = LABEL_WEST - fm.stringWidth(value+""); - g.drawString(value + "", x, ypos + i*av.charHeight - av.charHeight/5); + int x = LABEL_WEST - fm.stringWidth(value + ""); + g.drawString(value + "", x, + ypos + i * av.charHeight - av.charHeight / 5); } } } void drawEastScale(Graphics g, int startx, int endx, int ypos) -{ - ypos+= av.charHeight; - // EAST SCALE - for (int i = 0; i < av.alignment.getHeight(); i++) { - SequenceI seq = av.alignment.getSequenceAt(i); - int index = endx; - int value = -1; - while (index > startx) + ypos += av.charHeight; + // EAST SCALE + for (int i = 0; i < av.alignment.getHeight(); i++) { - if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + SequenceI seq = av.alignment.getSequenceAt(i); + int index = endx; + int value = -1; + while (index > startx) { - index--; - continue; - } + if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + { + index--; + continue; + } - value = av.alignment.getSequenceAt(i).findPosition(index); - break; + value = av.alignment.getSequenceAt(i).findPosition(index); + 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) + public void fastPaint(int horizontal, int vertical) + { + if (horizontal == 0 && vertical == 0 || gg == null) + { return; + } gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth, -vertical * av.charHeight); @@ -146,46 +151,53 @@ public void fastPaint(int horizontal, int vertical) sr = er - horizontal; } else if (horizontal < 0) + { er = sr - horizontal; + } else if (vertical > 0) // scroll down { ss = es - vertical; - if(ss av.endSeq) + if (es > av.endSeq) + { es = av.endSeq; + } } - gg.translate(transX, transY); gg.setColor(Color.white); - gg.fillRect(0,0, (er-sr+1)*av.charWidth, (es-ss)*av.charHeight); + 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. - */ + /** + * 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. + */ public void update(Graphics g) { paint(g); @@ -201,36 +213,43 @@ public void fastPaint(int horizontal, int vertical) } // this draws the whole of the alignment - imgWidth = this.getSize().width; - imgHeight = this.getSize().height; + imgWidth = this.getSize().width; + imgHeight = this.getSize().height; - imgWidth -= imgWidth%av.charWidth; - imgHeight-= imgHeight%av.charHeight; + imgWidth -= imgWidth % av.charWidth; + imgHeight -= imgHeight % av.charHeight; - if(imgWidth<1 || imgHeight<1) - return; + if (imgWidth < 1 || imgHeight < 1) + { + return; + } - if(img==null || imgWidth!=img.getWidth(this) || imgHeight!=img.getHeight(this)) - { - img = createImage(imgWidth, imgHeight); - gg = img.getGraphics(); - gg.setFont(av.getFont()); - } + if (img == null || imgWidth != img.getWidth(this) || + imgHeight != img.getHeight(this)) + { + img = createImage(imgWidth, imgHeight); + gg = img.getGraphics(); + gg.setFont(av.getFont()); + } - gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); + gg.setColor(Color.white); + gg.fillRect(0, 0, imgWidth, imgHeight); - chunkWidth = getWrappedCanvasWidth( getSize().width ); - chunkHeight = (av.getAlignment().getHeight() + 2)*av.charHeight; + chunkWidth = getWrappedCanvasWidth(getSize().width); + chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; av.setChunkHeight(chunkHeight); av.setChunkWidth(chunkWidth); - if (av.getWrapAlignment()) + { drawWrappedPanel(gg, getSize().width, getSize().height, av.startRes); + } else - drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, av.startRes, av.startSeq, 0); + { + drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, av.startRes, + av.startSeq, 0); + } g.drawImage(img, 0, 0, this); @@ -244,84 +263,102 @@ public void fastPaint(int horizontal, int vertical) LABEL_EAST = 0; LABEL_WEST = 0; - if(av.scaleRightWrapped) - LABEL_EAST = fm.stringWidth( av.alignment.getWidth()+"000" ); + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(av.alignment.getWidth() + "000"); + } - if(av.scaleLeftWrapped) - LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"" ); + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(av.alignment.getWidth() + ""); + } - return (cwidth - LABEL_EAST -LABEL_WEST)/av.charWidth; + return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; } - public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) + public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, + int startRes) { - AlignmentI al = av.getAlignment(); + AlignmentI al = av.getAlignment(); - FontMetrics fm = getFontMetrics(av.getFont()); + FontMetrics fm = getFontMetrics(av.getFont()); - int LABEL_EAST = 0; - if(av.scaleRightWrapped) - LABEL_EAST = fm.stringWidth( al.getWidth()+"000" ); - int LABEL_WEST = 0; - if(av.scaleLeftWrapped) - LABEL_WEST = fm.stringWidth(al.getWidth()+"0"); + int LABEL_EAST = 0; + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(al.getWidth() + "000"); + } + int LABEL_WEST = 0; + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(al.getWidth() + "0"); + } + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - int cWidth = (canvasWidth - LABEL_EAST -LABEL_WEST)/av.charWidth; - int cHeight = (av.getAlignment().getHeight() + 2)*av.charHeight; + av.endRes = av.startRes + cWidth; - av.endRes = av.startRes + cWidth; + int endx = startRes + cWidth - 1; + int ypos = 2 * av.charHeight; - int endx = startRes+cWidth-1; - int ypos = 2*av.charHeight; + while (ypos <= canvasHeight && startRes < av.alignment.getWidth()) + { + g.setColor(Color.black); - while (ypos <= canvasHeight && startRes al.getWidth()) - endx = al.getWidth(); + // 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().y, + cWidth * av.charWidth, + (int) clip.getBounds().height + ); } - } + 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; - synchronized public void drawPanel(Graphics g,int x1,int x2, int y1, int y2,int startx, int starty,int offset) { + if (endx > al.getWidth()) + { + endx = al.getWidth(); + } + } + + } + + synchronized public void drawPanel(Graphics g, int x1, int x2, int y1, int y2, + int startx, int starty, int offset) + { g.setFont(av.getFont()); sr.renderGaps(av.renderGaps); @@ -330,23 +367,24 @@ public void fastPaint(int horizontal, int vertical) /// First draw the sequences ///////////////////////////// - for (int i = y1 ; i < y2 ;i++) + 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); - } + 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); + } } // ///////////////////////////////////// @@ -365,42 +403,47 @@ public void fastPaint(int horizontal, int vertical) } if (group != null) + { do { int oldY = -1; int i = 0; boolean inGroup = false; - int top=-1, bottom =-1; + int top = -1, 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; + ex = (group.getEndRes() + 1 - group.getStartRes()) * av.charWidth - 1; if (sx < getSize().width && ex > 0 && group.sequences.contains(av.alignment.getSequenceAt(i))) { - if (bottom == -1 && (i==av.alignment.getHeight()-1 || - !group.sequences.contains(av.alignment.getSequenceAt(i + 1)))) - bottom = sy + av.charHeight ; + if (bottom == -1 && (i == av.alignment.getHeight() - 1 || + !group.sequences.contains(av.alignment. + getSequenceAt(i + 1)))) + { + bottom = sy + av.charHeight; + } if (!inGroup) { - if (top == -1 && i==0 || + if (top == -1 && i == 0 || !group.sequences.contains(av.alignment.getSequenceAt(i - 1))) + { top = sy; - + } oldY = sy; inGroup = true; if (group == av.getSelectionGroup()) { - g.setColor(new Color(255,0,0)); + g.setColor(new Color(255, 0, 0)); } else { - g.setColor(group.getOutlineColour()); + g.setColor(group.getOutlineColour()); } } } @@ -408,13 +451,13 @@ public void fastPaint(int horizontal, int vertical) { if (inGroup) { - g.drawLine(sx, oldY, sx, sy ); - g.drawLine(sx+ex, oldY, sx+ex, sy ); + 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; + top = -1; } if (bottom != -1) { @@ -422,7 +465,6 @@ public void fastPaint(int horizontal, int vertical) bottom = -1; } - inGroup = false; } } @@ -431,37 +473,39 @@ public void fastPaint(int horizontal, int vertical) if (inGroup) { - if(top!=-1) + if (top != -1) { g.drawLine(sx, top, sx + ex, top); - top =-1; + top = -1; } - if(bottom!=-1) - { - g.drawLine(sx, bottom-1, sx + ex, bottom-1); - bottom = -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 ); + 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()); - + } /// Highlight search Results once all sequences have been drawn ////////////////////////////////////////////////////////// - if(displaySearch) + if (displaySearch) { - for(int r=0; r x2) + } + if (searchEnd > x2) + { searchEnd = x2; + } ssr.drawHighlightedText(seq, searchStart, searchEnd, (searchStart - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, searchSeq, + AlignmentUtil.getPixelHeight(starty, + searchSeq, av.charHeight), av.charWidth, av.charHeight); @@ -493,20 +542,21 @@ public void fastPaint(int horizontal, int vertical) } - - - public void highlightSearchResults(int [] results) + public void highlightSearchResults(int[] results) { // results are in the order sequence, startRes, endRes - if(results==null) + if (results == null) + { displaySearch = false; + } else + { displaySearch = true; + } searchResults = results; repaint(); } - } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 163b967..1720edc 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1,41 +1,43 @@ /* -* 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.appletgui; +import java.util.*; + import java.awt.*; import java.awt.event.*; + import jalview.datamodel.*; -import java.util.*; import jalview.schemes.*; - -public class SeqPanel extends Panel +public class SeqPanel + extends Panel { - public SeqCanvas seqCanvas; - public AlignmentPanel ap; + public SeqCanvas seqCanvas; + public AlignmentPanel ap; protected int lastres; protected int startseq; - int startEdit=-1; - int endEdit=-1; + int startEdit = -1; + int endEdit = -1; protected AlignViewport av; @@ -48,74 +50,101 @@ public class SeqPanel extends Panel boolean editingSeqs = false; boolean groupEditing = false; + public SeqPanel(AlignViewport avp, AlignmentPanel p) + { + this.av = avp; - - public SeqPanel(AlignViewport avp, AlignmentPanel p) { - this.av = avp; - - seqCanvas = new SeqCanvas(avp); + seqCanvas = new SeqCanvas(avp); setLayout(new BorderLayout()); add(seqCanvas); ap = p; - seqCanvas.addMouseMotionListener( new MouseMotionAdapter() + seqCanvas.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) { - if(av.getWrapAlignment()) - return; - doMouseMoved(evt); } + if (av.getWrapAlignment()) + { + return; + } + doMouseMoved(evt); + } public void mouseDragged(MouseEvent evt) { - if(av.getWrapAlignment()) - return; - if( editingSeqs ) + if (av.getWrapAlignment()) + { + return; + } + if (editingSeqs) + { doMouseDragged(evt); + } else + { doMouseDraggedDefineMode(evt); + } } }); - seqCanvas.addMouseListener( new MouseAdapter() + seqCanvas.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { - if(av.getWrapAlignment()) - return; - if(editingSeqs) + 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 (av.getWrapAlignment()) { - if(evt.isAltDown() || evt.isControlDown()) + 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); + { + return; + } + doMouseExitedDefineMode(evt); } + public void mouseEntered(MouseEvent evt) { if (av.getWrapAlignment() || editingSeqs) + { return; + } doMouseEnteredDefineMode(evt); } @@ -123,31 +152,34 @@ public class SeqPanel extends Panel seqCanvas.repaint(); } + public void doMouseReleased(MouseEvent evt) + { - public void doMouseReleased(MouseEvent evt) { - - if(seqEditOccurred>-1) + if (seqEditOccurred > -1) + { editOccurred(seqEditOccurred); + } startseq = -1; - lastres = -1; + lastres = -1; seqEditOccurred = -1; - editingSeqs = false; + editingSeqs = false; groupEditing = false; ap.repaint(); } - public void doMousePressed(MouseEvent evt) { - ap.alignFrame.addHistoryItem( new HistoryItem( - "Edit Sequence",av.alignment, HistoryItem.EDIT)); + 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(); - res = x/av.getCharWidth() + av.getStartRes(); - seq = y/av.getCharHeight() + av.getStartSeq(); + res = x / av.getCharWidth() + av.getStartRes(); + seq = y / av.getCharHeight() + av.getStartSeq(); if (seq < av.getAlignment().getHeight() && res < av.getAlignment().getSequenceAt(seq).getLength()) @@ -170,217 +202,248 @@ public class SeqPanel extends Panel public void doMouseMoved(MouseEvent evt) { - int res=0, seq=0; + int res = 0, seq = 0; int x = evt.getX(); int y = evt.getY(); - if(av.wrapAlignment) + if (av.wrapAlignment) { - y -= 2*av.charHeight; - int chunkHeight = (av.getAlignment().getHeight()+2)*av.charHeight; + y -= 2 * av.charHeight; + int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - - res = (int)((y/chunkHeight)*(getSize().width/av.charWidth)) + x/av.getCharWidth() + av.getStartRes(); + res = (int) ( (y / chunkHeight) * (getSize().width / av.charWidth)) + + x / av.getCharWidth() + av.getStartRes(); y %= chunkHeight; - seq = y / av.getCharHeight() + av.getStartSeq(); + seq = y / av.getCharHeight() + av.getStartSeq(); } else { - res = x / av.getCharWidth() + av.getStartRes(); + res = x / av.getCharWidth() + av.getStartRes(); seq = y / av.getCharHeight() + av.getStartSeq(); } - - if(seq>=av.getAlignment().getHeight()) + if (seq >= av.getAlignment().getHeight()) + { return; + } SequenceI sequence = av.getAlignment().getSequenceAt(seq); - if(res>sequence.getLength()) + if (res > sequence.getLength()) + { return; + } - Object obj = ResidueProperties.aa2Triplet.get( sequence.getCharAt(res)+"" ) ; + Object obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + ""); String aa = ""; - if(obj!=null) - aa = obj.toString(); + if (obj != null) + { + aa = obj.toString(); + } - StringBuffer text = new StringBuffer("Sequence " +(seq+1)+" ID: "+sequence.getName()); - if(aa!="") - text.append(" Residue: "+aa+" ("+ av.getAlignment().getSequenceAt(seq).findPosition(res)+")"); + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + + sequence.getName()); + if (aa != "") + { + text.append(" Residue: " + aa + " (" + + av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + } ap.alignFrame.statusBar.setText(text.toString()); // use aa to see if the mouse pointer is on a - if( av.showSequenceFeatures) + if (av.showSequenceFeatures) { 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(sbuffer.length()>0) + if (sbuffer.length() > 0) + { sbuffer.append("; "); + } sbuffer.append(sf.getType() + " " + sf.getDescription()); - if(sf.getStatus().length()>0) - sbuffer.append(" ("+sf.getStatus()+")"); + if (sf.getStatus().length() > 0) + { + sbuffer.append(" (" + sf.getStatus() + ")"); + } } } } - } - 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; - - boolean dragRight = true; - if (res < av.getAlignment().getWidth() && res < lastres) - dragRight = false; - - - 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; jj) - 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; - } - } - } - - } - } - - endEdit = res; - lastres = res; - seqCanvas.repaint(); + 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; + } + + boolean dragRight = true; + if (res < av.getAlignment().getWidth() && res < lastres) + { + dragRight = false; + } + + 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; + } + } + } + + } + } + + 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); + 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; + seqEditOccurred = seq; } public void deleteChar(int j, int seq) { av.alignment.getSequenceAt(seq).deleteCharAt(j); - seqEditOccurred=seq; + seqEditOccurred = seq; av.alignment.getWidth(); repaint(); } - void editOccurred(int i) { - if(endEdit==startEdit) + if (endEdit == startEdit) { ap.alignFrame.historyList.pop(); ap.alignFrame.updateEditMenuBar(); @@ -391,34 +454,33 @@ public class SeqPanel extends Panel // Y O Y CLUSTALX ColourSchemeI cs = av.getGlobalColourScheme(); - if(cs instanceof ConservationColourScheme) + if (cs instanceof ConservationColourScheme) { - ConservationColourScheme ccs = (ConservationColourScheme) cs; - if(ccs.cs instanceof ClustalxColourScheme) - { + ConservationColourScheme ccs = (ConservationColourScheme) cs; + if (ccs.cs instanceof ClustalxColourScheme) + { jalview.analysis.Conservation c = new jalview.analysis.Conservation ("All", - ResidueProperties.propHash, 3, - av.alignment.getSequences(), 0, - av.alignment.getWidth() - 1); + ResidueProperties.propHash, 3, + av.alignment.getSequences(), 0, + av.alignment.getWidth() - 1); c.calculate(); c.verdict(false, av.ConsPercGaps); - ClustalxColourScheme cxs = (ClustalxColourScheme)ccs.cs; - cxs.resetClustalX(av.alignment.getSequences(), av.alignment.getWidth()); + ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs; + cxs.resetClustalX(av.alignment.getSequences(), av.alignment.getWidth()); ccs = new ConservationColourScheme(c, cxs); av.setGlobalColourScheme(ccs); - } + } } - if(cs instanceof ClustalxColourScheme) + if (cs instanceof ClustalxColourScheme) { - ((ClustalxColourScheme)cs).resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); + ( (ClustalxColourScheme) cs).resetClustalX(av.alignment.getSequences(), + av.alignment.getWidth()); av.setGlobalColourScheme(cs); } - } ////////////////////////////////////////// @@ -427,78 +489,99 @@ public class SeqPanel extends Panel int oldSeq = -1; public void doMousePressedDefineMode(MouseEvent evt) { - int res = evt.getX()/av.getCharWidth() + av.getStartRes(); - int seq = evt.getY()/av.getCharHeight() + av.getStartSeq(); + int res = evt.getX() / av.getCharWidth() + av.getStartRes(); + int seq = evt.getY() / av.getCharHeight() + av.getStartSeq(); oldSeq = seq; SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); - if(sequence==null || res>sequence.getLength()) + if (sequence == null || res > sequence.getLength()) + { return; + } stretchGroup = av.getSelectionGroup(); - if(stretchGroup == null) - { - stretchGroup = av.alignment.findGroup( sequence ); - if(stretchGroup!=null && res>stretchGroup.getStartRes() && resres - || stretchGroup.getEndRes()= res) - { - stretchGroup = allGroups[i]; - av.setSelectionGroup(stretchGroup); - break; - } - } - - if(stretchGroup==null) + 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; + + SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence); + + 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; + } + } + } + } + + if (stretchGroup == null) { // define a new group here SequenceGroup sg = new SequenceGroup(); sg.setStartRes(res); sg.setEndRes(res); - sg.addSequence( sequence ); - av.setSelectionGroup( sg ); + sg.addSequence(sequence); + av.setSelectionGroup(sg); stretchGroup = sg; - if(av.getConservationSelected()) - SliderPanel.setConservationSlider(ap, av.getGlobalColourScheme(), "Background"); - if(av.getAbovePIDThreshold()) - SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), "Background"); + if (av.getConservationSelected()) + { + SliderPanel.setConservationSlider(ap, av.getGlobalColourScheme(), + "Background"); + } + if (av.getAbovePIDThreshold()) + { + SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), + "Background"); + } } // DETECT RIGHT MOUSE BUTTON IN AWT - else if( ( evt.getModifiers() & InputEvent .BUTTON3_MASK ) == InputEvent.BUTTON3_MASK ) + else if ( (evt.getModifiers() & InputEvent.BUTTON3_MASK) == + InputEvent.BUTTON3_MASK) { APopupMenu popup = new APopupMenu(ap, null); this.add(popup); popup.show(this, evt.getX(), evt.getY()); } - - if(stretchGroup!=null && stretchGroup.getEndRes()==res) + if (stretchGroup != null && stretchGroup.getEndRes() == res) + { // Edit end res position of selected group changeEndRes = true; + } - else if(stretchGroup!=null && stretchGroup.getStartRes()==res) + else if (stretchGroup != null && stretchGroup.getStartRes() == res) + { // Edit end res position of selected group changeStartRes = true; + } } @@ -512,85 +595,106 @@ public class SeqPanel extends Panel { mouseDragging = false; - if(stretchGroup==null) + if (stretchGroup == null) + { return; + } - if(stretchGroup.cs instanceof ClustalxColourScheme) + if (stretchGroup.cs instanceof ClustalxColourScheme) { - stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, av.alignment.getWidth()); + stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, + av.alignment.getWidth()); seqCanvas.repaint(); } - else if(stretchGroup.cs instanceof ConservationColourScheme) + else if (stretchGroup.cs instanceof ConservationColourScheme) { - ConservationColourScheme ccs = (ConservationColourScheme)stretchGroup.cs; - stretchGroup.cs = ccs; - SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup.getName()) ; + ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs; + stretchGroup.cs = ccs; + SliderPanel.setConservationSlider(ap, stretchGroup.cs, + stretchGroup.getName()); - seqCanvas.repaint(); + seqCanvas.repaint(); } else { - if(stretchGroup.cs !=null) + if (stretchGroup.cs != null) { - SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup.getName()); + SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, + stretchGroup.getName()); } } - changeEndRes = false; changeStartRes = false; stretchGroup = null; ap.repaint(); } - boolean remove = false; public void doMouseDraggedDefineMode(MouseEvent evt) { - int res = evt.getX()/av.getCharWidth() + av.getStartRes(); - int y = evt.getY()/av.getCharHeight() + av.getStartSeq(); + int res = evt.getX() / av.getCharWidth() + av.getStartRes(); + int y = evt.getY() / av.getCharHeight() + av.getStartSeq(); - if(stretchGroup==null) + if (stretchGroup == null) + { return; + } - if(res>av.alignment.getWidth()) - res = av.alignment.getWidth()-1; - + if (res > av.alignment.getWidth()) + { + res = av.alignment.getWidth() - 1; + } - if(stretchGroup.getEndRes()==res) + if (stretchGroup.getEndRes() == res) + { // Edit end res position of selected group changeEndRes = true; + } - else if(stretchGroup.getStartRes()==res) + else if (stretchGroup.getStartRes() == res) + { // Edit start res position of selected group changeStartRes = true; + } - - if(resav.getEndRes()) + } + else if (res > av.getEndRes()) + { res = av.getEndRes(); + } - if(changeEndRes) + if (changeEndRes) { - if(res>stretchGroup.getStartRes()-1) - stretchGroup.setEndRes( res ); + if (res > stretchGroup.getStartRes() - 1) + { + stretchGroup.setEndRes(res); + } } - else if(changeStartRes) + else if (changeStartRes) { - if(res oldSeq) + { dragDirection = 1; + } else if (y < oldSeq) + { dragDirection = -1; + } - while (y != oldSeq && oldSeq>0 && y 0 && y < av.alignment.getHeight()) { // This routine ensures we don't skip any sequences, as the // selection is quite slow. @@ -606,15 +710,19 @@ public class SeqPanel extends Panel } else { - if(seq!=null) - stretchGroup.addSequence(seq); + if (seq != null) + { + stretchGroup.addSequence(seq); + } stretchGroup.addSequence(nextSeq); } } oldSeq = y; mouseDragging = true; - if(scrollThread!=null) + if (scrollThread != null) + { scrollThread.setEvent(evt); + } seqCanvas.repaint(); } @@ -622,20 +730,28 @@ public class SeqPanel extends Panel public void doMouseEnteredDefineMode(MouseEvent e) { if (scrollThread != null) + { scrollThread.running = false; + } } public void doMouseExitedDefineMode(MouseEvent e) { if (av.getWrapAlignment()) + { return; + } - if(mouseDragging) + if (mouseDragging) + { scrollThread = new ScrollThread(); + } } + // this class allows scrolling off the bottom of the visible alignment - class ScrollThread extends Thread + class ScrollThread + extends Thread { MouseEvent evt; boolean running = false; @@ -659,21 +775,29 @@ public class SeqPanel extends Panel running = true; while (running) { - if(evt!=null) + if (evt != null) { if (mouseDragging && evt.getY() < 0 && av.getStartSeq() > 0) + { running = ap.scrollUp(true); + } if (mouseDragging && evt.getY() >= getSize().height && av.alignment.getHeight() > av.getEndSeq()) + { running = ap.scrollUp(false); + } if (mouseDragging && evt.getX() < 0) + { running = ap.scrollRight(true); + } else if (mouseDragging && evt.getX() >= getSize().width) + { running = ap.scrollRight(false); + } } try @@ -684,12 +808,6 @@ public class SeqPanel extends Panel {} } } -} - - + } } - - - - diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index 321edef..9a722f2 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -1,27 +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.appletgui; +import java.awt.*; + import jalview.datamodel.*; import jalview.schemes.*; -import java.awt.*; public class SequenceRenderer { @@ -29,7 +30,7 @@ public class SequenceRenderer FontMetrics fm; boolean renderGaps = true; SequenceGroup currentSequenceGroup = null; - SequenceGroup [] allGroups = null; + SequenceGroup[] allGroups = null; Color resBoxColour; Graphics graphics; @@ -38,7 +39,6 @@ public class SequenceRenderer this.av = av; } - public void renderGaps(boolean b) { renderGaps = b; @@ -52,13 +52,19 @@ public class SequenceRenderer void getBoxColour(ColourSchemeI cs, SequenceI seq, int i) { - if (cs != null) - resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); - else - resBoxColour = Color.white; + if (cs != null) + { + resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); + } + else + { + resBoxColour = Color.white; + } } - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height) + public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, + int start, int end, int x1, int y1, int width, + int height) { allGroups = sg; @@ -67,12 +73,14 @@ public class SequenceRenderer drawBoxes(seq, start, end, x1, y1, (int) width, height); fm = g.getFontMetrics(); - drawText(seq,start,end,x1,y1,(int)width,height); + 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; + 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; @@ -81,23 +89,33 @@ public class SequenceRenderer Color tempColour = null; while (i <= end && i < length) { - if(inCurrentSequenceGroup(i)) + if (inCurrentSequenceGroup(i)) { - if( currentSequenceGroup.getDisplayBoxes()) - getBoxColour(currentSequenceGroup.cs, seq, i); + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } else - resBoxColour = Color.white; + { + resBoxColour = Color.white; + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); } - 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); + if (tempColour != null) + { + graphics.fillRect(x1 + width * (curStart - start), y1, curWidth, + height); + } graphics.setColor(resBoxColour); curStart = i; @@ -106,104 +124,126 @@ public class SequenceRenderer } else + { curWidth += width; + } i++; } - - graphics.fillRect(x1+width*(curStart-start),y1,curWidth,height); + graphics.fillRect(x1 + width * (curStart - start), y1, curWidth, height); } - public void drawText(SequenceI seq,int start, int end, int x1, int y1, int width, int height) + public void drawText(SequenceI seq, int start, int end, int x1, int y1, + int width, int height) { - int pady = height/5; - int charOffset=0; + int pady = height / 5; + int charOffset = 0; char s; // Need to find the sequence position here. - String sequence = seq.getSequence(); + String sequence = seq.getSequence(); for (int i = start; i <= end; i++) { - graphics.setColor(Color.black); - if(i=res) + for (int i = 0; i < allGroups.length; i++) + { + if (allGroups[i].getStartRes() <= res && allGroups[i].getEndRes() >= res) { - currentSequenceGroup = allGroups[i]; - return true; + currentSequenceGroup = allGroups[i]; + return true; } + } return false; } - public void drawHighlightedText(SequenceI seq,int start, int end, int x1, int y1, int width, int height) + public void drawHighlightedText(SequenceI seq, int start, int end, int x1, + int y1, int width, int height) { - int pady = height/5; - int charOffset=0; + int pady = height / 5; + int charOffset = 0; graphics.setColor(Color.black); - graphics.fillRect(x1,y1,width*(end-start+1),height); + graphics.fillRect(x1, y1, width * (end - start + 1), height); graphics.setColor(Color.white); - char s='~'; + char s = '~'; // Need to find the sequence position here. for (int i = start; i <= end; i++) { - if(i -1 ) + while (groupIndex > -1) { - if(allGroups!=null) - toChange = ((SequenceGroup)allGroups.elementAt(groupIndex)).cs; + if (allGroups != null) + { + toChange = ( (SequenceGroup) allGroups.elementAt(groupIndex)).cs; + } if (forConservation) { if (toChange instanceof ConservationColourScheme) + { ( (ConservationColourScheme) toChange).inc = i; + } } else { - ( (ResidueColourScheme) toChange).setThreshold(i); + ( (ResidueColourScheme) toChange).setThreshold(i); } groupIndex--; @@ -212,16 +239,16 @@ public class SliderPanel extends GSliderPanel allGroupsCheck.setEnabled(b); } - public void valueField_actionPerformed(ActionEvent e) { - try{ + try + { int i = Integer.parseInt(valueField.getText()); slider.setValue(i); } - catch(Exception ex) + catch (Exception ex) { - valueField.setText( slider.getValue()+"" ); + valueField.setText(slider.getValue() + ""); } } @@ -229,10 +256,10 @@ public class SliderPanel extends GSliderPanel { slider.setValue(value); } + public int getValue() { return Integer.parseInt(valueField.getText()); } - } diff --git a/src/jalview/appletgui/TreeCanvas.java b/src/jalview/appletgui/TreeCanvas.java index be37813..434ad60 100755 --- a/src/jalview/appletgui/TreeCanvas.java +++ b/src/jalview/appletgui/TreeCanvas.java @@ -1,42 +1,43 @@ /* -* 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.appletgui; +import java.util.*; -import jalview.analysis.*; -import jalview.datamodel.*; -import jalview.util.*; -import jalview.schemes.*; import java.awt.*; import java.awt.event.*; -import java.util.*; +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.schemes.*; +import jalview.util.*; -public class TreeCanvas extends Panel implements MouseListener +public class TreeCanvas + extends Panel implements MouseListener { NJTree tree; ScrollPane scrollPane; AlignViewport av; - public static final String PLACEHOLDER=" * "; + public static final String PLACEHOLDER = " * "; Font font; - int fontSize = 12; + int fontSize = 12; boolean fitToWindow = true; boolean showDistances = false; @@ -49,19 +50,20 @@ public class TreeCanvas extends Panel implements MouseListener float threshold; String longestName; - int labelLength=-1; + int labelLength = -1; //RubberbandRectangle rubberband; - Vector listeners; + Vector listeners; Hashtable nameHash = new Hashtable(); Hashtable nodeHash = new Hashtable(); - public TreeCanvas(AlignViewport av, NJTree tree, ScrollPane scroller, String label) + public TreeCanvas(AlignViewport av, NJTree tree, ScrollPane scroller, + String label) { this.av = av; - this.tree = tree; + this.tree = tree; scrollPane = scroller; addMouseListener(this); tree.findHeight(tree.getTopNode()); @@ -70,10 +72,11 @@ public class TreeCanvas extends Panel implements MouseListener PaintRefresher.Register(this); } + public void TreeSelectionChanged(Sequence sequence) - { + { SequenceGroup selected = av.getSelectionGroup(); - if(selected == null) + if (selected == null) { selected = new SequenceGroup(); av.setSelectionGroup(selected); @@ -82,373 +85,450 @@ public class TreeCanvas extends Panel implements MouseListener selected.setEndRes(av.alignment.getWidth()); selected.addOrRemove(sequence); - PaintRefresher.Refresh(this); repaint(); - } - - + } - public void setTree(NJTree tree) { + public void setTree(NJTree tree) + { this.tree = tree; tree.findHeight(tree.getTopNode()); } - public void drawNode(Graphics g,SequenceNode node, float chunk, float scale, int width,int offx, int offy) { - if (node == null) { + public void drawNode(Graphics g, SequenceNode node, float chunk, float scale, + int width, int offx, int offy) + { + if (node == null) + { return; } - if (node.left() == null && node.right() == null) { + if (node.left() == null && node.right() == null) + { // Drawing leaf node float height = node.height; - float dist = node.dist; + float dist = node.dist; - int xstart = (int)((height-dist)*scale) + offx; - int xend = (int)(height*scale) + offx; + int xstart = (int) ( (height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; - int ypos = (int)(node.ycount * chunk) + offy; + 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()); + 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); - + { + g.setColor(Color.black); + } // Draw horizontal line - g.drawLine(xstart,ypos,xend,ypos); + g.drawLine(xstart, ypos, xend, ypos); String nodeLabel = ""; - if (showDistances && node.dist > 0) { + if (showDistances && node.dist > 0) + { nodeLabel = new Format("%5.2f").form(node.dist); } - if (showBootstrap) { - if (showDistances) { + if (showBootstrap) + { + if (showDistances) + { nodeLabel = nodeLabel + " : "; } nodeLabel = nodeLabel + String.valueOf(node.getBootstrap()); } - if (! nodeLabel.equals("")) { - g.drawString(nodeLabel,xstart,ypos - 10); + if (!nodeLabel.equals("")) + { + g.drawString(nodeLabel, xstart, ypos - 10); } - String name = (markPlaceholders && node.isPlaceholder()) ? (PLACEHOLDER+node.getName()) : node.getName(); + String name = (markPlaceholders && node.isPlaceholder()) ? + (PLACEHOLDER + node.getName()) : node.getName(); FontMetrics fm = g.getFontMetrics(font); - int charWidth = fm.stringWidth(name) + 3; + int charWidth = fm.stringWidth(name) + 3; int charHeight = fm.getHeight(); - Rectangle rect = new Rectangle(xend+20,ypos-charHeight, - charWidth,charHeight); + Rectangle rect = new Rectangle(xend + 20, ypos - charHeight, + charWidth, charHeight); - nameHash.put((SequenceI)node.element(),rect); + nameHash.put( (SequenceI) node.element(), rect); // Colour selected leaves differently SequenceGroup selected = av.getSelectionGroup(); - if (selected!=null && selected.sequences.contains((SequenceI)node.element())) { + if (selected != null && + selected.sequences.contains( (SequenceI) node.element())) + { g.setColor(Color.gray); - g.fillRect(xend + 10, ypos - charHeight + 3,charWidth,charHeight); + g.fillRect(xend + 10, ypos - charHeight + 3, charWidth, charHeight); g.setColor(Color.white); } - g.drawString(name,xend+10,ypos); + 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); + } + 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; + float dist = node.dist; - int xstart = (int)((height-dist)*scale) + offx; - int xend = (int)(height *scale) + offx; - int ypos = (int)(node.ycount *chunk) + offy; + 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()); + g.setColor( ( (SequenceNode) node).color.darker()); // Draw horizontal line - g.drawLine(xstart,ypos,xend,ypos); - g.fillRect(xend-2, ypos-2, 4,4); + 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; + 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); + Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); + nodeHash.put(node, pos); - g.drawLine((int)(height*scale) + offx, ystart, - (int)(height*scale) + offx, yend); + g.drawLine( (int) (height * scale) + offx, ystart, + (int) (height * scale) + offx, yend); - if (showDistances && node.dist > 0) { - g.drawString(new Format("%5.2f").form(node.dist),xstart,ypos - 5); + if (showDistances && node.dist > 0) + { + g.drawString(new Format("%5.2f").form(node.dist), xstart, ypos - 5); } } } - public Object findElement(int x, int y) { - Enumeration keys = nameHash.keys(); - while (keys.hasMoreElements()) { - Object ob = keys.nextElement(); - Rectangle rect = (Rectangle)nameHash.get(ob); + public Object findElement(int x, int y) + { + Enumeration keys = nameHash.keys(); - if (x >= rect.x && x <= (rect.x + rect.width) && - y >= rect.y && y <= (rect.y + rect.height)) { - return ob; - } - } - keys = nodeHash.keys(); + 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; + } + } + keys = nodeHash.keys(); - while (keys.hasMoreElements()) { - Object ob = keys.nextElement(); - Rectangle rect = (Rectangle)nodeHash.get(ob); + 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; - } + if (x >= rect.x && x <= (rect.x + rect.width) && + y >= rect.y && y <= (rect.y + rect.height)) + { + return ob; + } } - return null; + return null; } - public void pickNodes(Rectangle pickBox) { - int width = getSize().width; + public void pickNodes(Rectangle pickBox) + { + int width = getSize().width; int height = getSize().height; SequenceNode top = tree.getTopNode(); - float wscale = (float)(width*.8-offx*2)/tree.getMaxHeight() -; - if (top.count == 0) { - top.count = ((SequenceNode)top.left()).count + ((SequenceNode)top.right()).count ; + float wscale = (float) (width * .8 - offx * 2) / tree.getMaxHeight() + ; + if (top.count == 0) + { + top.count = ( (SequenceNode) top.left()).count + + ( (SequenceNode) top.right()).count; } - float chunk = (float)(height-offy*2)/top.count; + float chunk = (float) (height - offy * 2) / top.count; - pickNode(pickBox,top,chunk,wscale,width,offx,offy); + 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) { + public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, + float scale, int width, int offx, int offy) + { + if (node == null) + { return; } - if (node.left() == null && node.right() == null) { + if (node.left() == null && node.right() == null) + { float height = node.height; - float dist = node.dist; + float dist = node.dist; - int xstart = (int)((height-dist)*scale) + offx; - int xend = (int)(height*scale) + offx; + int xstart = (int) ( (height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; - int ypos = (int)(node.ycount * chunk) + offy; + int ypos = (int) (node.ycount * chunk) + offy; - if (pickBox.contains(new Point(xend,ypos))) { - if (node.element() instanceof SequenceI) { - SequenceI seq = (SequenceI)node.element(); + if (pickBox.contains(new Point(xend, ypos))) + { + if (node.element() instanceof SequenceI) + { + SequenceI seq = (SequenceI) node.element(); SequenceGroup sg = av.getSelectionGroup(); - if(sg!=null) + if (sg != null) + { sg.addOrRemove(seq); + } } } - } else { - pickNode(pickBox,(SequenceNode)node.left(), chunk,scale,width,offx,offy); - pickNode(pickBox,(SequenceNode)node.right(),chunk,scale,width,offx,offy); + } + 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) + { return; + } if (node.left() == null && node.right() == null) { node.color = c; if (node.element() instanceof SequenceI) - ((SequenceI)node.element()).setColor(c); - } else + { + ( (SequenceI) node.element()).setColor(c); + } + } + else { node.color = c; - setColor((SequenceNode)node.left(),c); - setColor((SequenceNode)node.right(),c); + setColor( (SequenceNode) node.left(), c); + setColor( (SequenceNode) node.right(), c); } } - public void paint(Graphics g) { - font = new Font("Verdana",Font.PLAIN,fontSize); + font = new Font("Verdana", Font.PLAIN, fontSize); g.setFont(font); FontMetrics fm = g.getFontMetrics(font); - if(nameHash.size()==0) + if (nameHash.size() == 0) + { repaint(); + } - - if( fitToWindow || (!fitToWindow && scrollPane.getSize().height > fm.getHeight() * nameHash.size()+offy ) ) - { - draw(g,scrollPane.getSize().width,scrollPane.getSize().height); - } + if (fitToWindow || + (!fitToWindow && + scrollPane.getSize().height > fm.getHeight() * nameHash.size() + offy)) + { + draw(g, scrollPane.getSize().width, scrollPane.getSize().height); + } else - { - setSize(new Dimension(scrollPane.getSize().width, fm.getHeight() * nameHash.size())); - draw( g,scrollPane.getSize().width, fm.getHeight() * nameHash.size()); - } + { + setSize(new Dimension(scrollPane.getSize().width, + fm.getHeight() * nameHash.size())); + draw(g, scrollPane.getSize().width, fm.getHeight() * nameHash.size()); + } scrollPane.validate(); } - public int getFontSize() { - return fontSize; - } - public void setFontSize(int fontSize) { - this.fontSize = fontSize; - repaint(); - } - public void draw(Graphics g, int width, int height) { - g.setColor(Color.white); - g.fillRect(0,0,width,height); + public int getFontSize() + { + return fontSize; + } + public void setFontSize(int fontSize) + { + this.fontSize = fontSize; + repaint(); + } - labelLength = g.getFontMetrics(font).stringWidth(longestName)+ 20;//20 allows for scrollbar + public void draw(Graphics g, int width, int height) + { - float wscale =(float)(width - labelLength -offx*2)/tree.getMaxHeight(); + g.setColor(Color.white); + g.fillRect(0, 0, width, height); - SequenceNode top = tree.getTopNode(); + labelLength = g.getFontMetrics(font).stringWidth(longestName) + 20; //20 allows for scrollbar - if (top.count == 0) { - top.count = ((SequenceNode)top.left()).count + ((SequenceNode)top.right()).count ; - } - float chunk = (float)(height-offy*2)/top.count ; + float wscale = (float) (width - labelLength - offx * 2) / tree.getMaxHeight(); - drawNode(g,tree.getTopNode(),chunk,wscale,width,offx,offy); + SequenceNode top = tree.getTopNode(); - if (threshold != 0) - { - if(av.getCurrentTree() == tree) - g.setColor(Color.red); - else - g.setColor(Color.gray); + if (top.count == 0) + { + top.count = ( (SequenceNode) top.left()).count + + ( (SequenceNode) top.right()).count; + } + float chunk = (float) (height - offy * 2) / top.count; - int x = (int)( threshold * (float)(getSize().width-labelLength - 2*offx) +offx ) ; + drawNode(g, tree.getTopNode(), chunk, wscale, width, offx, offy); - g.drawLine(x,0,x,getSize().height); + if (threshold != 0) + { + if (av.getCurrentTree() == tree) + { + g.setColor(Color.red); + } + else + { + g.setColor(Color.gray); } - } - - 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) { + int x = (int) (threshold * + (float) (getSize().width - labelLength - 2 * offx) + offx); - av.setCurrentTree(tree); + g.drawLine(x, 0, x, getSize().height); + } - int x = e.getX(); - int y = e.getY(); + } - Object ob = findElement(x,y); + public void mouseReleased(MouseEvent e) + {} - if (ob instanceof SequenceI) - { - TreeSelectionChanged((Sequence)ob); - repaint(); - return; + public void mouseEntered(MouseEvent e) + {} - } else if (ob instanceof SequenceNode) { - SequenceNode tmpnode = (SequenceNode)ob; - tree.swapNodes(tmpnode); - tree.reCount(tree.getTopNode()); - tree.findHeight(tree.getTopNode()); - } else { - // Find threshold + public void mouseExited(MouseEvent e) + {} - if (tree.getMaxHeight() != 0) { - threshold = (float)(x - offx)/(float)(getSize().width-labelLength - 2*offx); + public void mouseClicked(MouseEvent e) + { + } - tree.getGroups().removeAllElements(); - tree.groupNodes(tree.getTopNode(),threshold); - setColor(tree.getTopNode(),Color.black); + public void mousePressed(MouseEvent e) + { - av.setSelectionGroup(null); - av.alignment.deleteAllGroups(); + av.setCurrentTree(tree); - for (int i=0; i < tree.getGroups().size(); i++) - { + int x = e.getX(); + int y = e.getY(); - Color col = new Color((int)(Math.random()*255), - (int)(Math.random()*255), - (int)(Math.random()*255)); - setColor((SequenceNode)tree.getGroups().elementAt(i),col.brighter()); + Object ob = findElement(x, y); - Vector l = tree.findLeaves((SequenceNode)tree.getGroups().elementAt(i),new Vector()); - SequenceGroup sg = null; - for (int j = 0; j < l.size(); j++) - { - SequenceNode sn = (SequenceNode) l.elementAt(j); - if(sg==null) - sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth()); + if (ob instanceof SequenceI) + { + TreeSelectionChanged( (Sequence) ob); + repaint(); + return; - sg.addSequence( (Sequence) sn.element()); - } + } + else if (ob instanceof SequenceNode) + { + SequenceNode tmpnode = (SequenceNode) ob; + tree.swapNodes(tmpnode); + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); + } + else + { + // Find threshold - if (av.getGlobalColourScheme() instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme(); - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, sg.getStartRes(), - sg.getEndRes()); + if (tree.getMaxHeight() != 0) + { + threshold = (float) (x - offx) / + (float) (getSize().width - 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()); + SequenceGroup sg = null; + for (int j = 0; j < l.size(); j++) + { + SequenceNode sn = (SequenceNode) l.elementAt(j); + if (sg == null) + { + sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true, false, + 0, av.alignment.getWidth()); + } - c.calculate(); - c.verdict(false, av.ConsPercGaps); - ccs = new ConservationColourScheme(c, ccs.cs); + sg.addSequence( (Sequence) sn.element()); + } - sg.cs = ccs; + 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); + av.alignment.addGroup(sg); - } - } + } } + } - PaintRefresher.Refresh(this); - repaint(); + PaintRefresher.Refresh(this); + repaint(); } - public void setShowDistances(boolean state) { - this.showDistances = state; - 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(); - } + public void setShowBootstrap(boolean state) + { + this.showBootstrap = state; + repaint(); + } -} + public void setMarkPlaceholders(boolean state) + { + this.markPlaceholders = state; + repaint(); + } +} diff --git a/src/jalview/appletgui/TreePanel.java b/src/jalview/appletgui/TreePanel.java index c33975b..58da074 100755 --- a/src/jalview/appletgui/TreePanel.java +++ b/src/jalview/appletgui/TreePanel.java @@ -1,34 +1,35 @@ /* -* 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.appletgui; -import jalview.datamodel.*; -import jalview.io.NewickFile; -import jalview.analysis.*; -import jalview.jbappletgui.GTreePanel; -import java.awt.event.*; import java.util.*; -import jalview.io.NewickFile; +import java.awt.event.*; + +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.io.*; +import jalview.jbappletgui.*; -public class TreePanel extends GTreePanel +public class TreePanel + extends GTreePanel { SequenceI[] seq; String type; @@ -44,7 +45,8 @@ public class TreePanel extends GTreePanel return tree; } - public TreePanel(AlignViewport av, Vector seqVector, String type, String pwtype, int s, int e) + public TreePanel(AlignViewport av, Vector seqVector, String type, + String pwtype, int s, int e) { super(); @@ -55,12 +57,14 @@ public class TreePanel extends GTreePanel end = e; String longestName = ""; - seq = new Sequence [seqVector.size()]; - for (int i=0;i < seqVector.size();i++) + seq = new Sequence[seqVector.size()]; + for (int i = 0; i < seqVector.size(); i++) { seq[i] = (Sequence) seqVector.elementAt(i); - if(seq[i].getName().length()>longestName.length()) + if (seq[i].getName().length() > longestName.length()) + { longestName = seq[i].getName(); + } } tree = new NJTree(seq, type, pwtype, start, end); @@ -72,49 +76,61 @@ public class TreePanel extends GTreePanel scrollPane.add(treeCanvas); } + public TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree, String type, String pwtype) - { - super(); - // These are probably only arbitrary strings reflecting source of tree - this.type = type; - this.pwtype = pwtype; + { + super(); + // These are probably only arbitrary strings reflecting source of tree + this.type = type; + this.pwtype = pwtype; - start = 0; - end = seqVector.size(); + start = 0; + end = seqVector.size(); + + String longestName = ""; + seq = new Sequence[seqVector.size()]; + for (int i = 0; i < seqVector.size(); i++) + { + seq[i] = (Sequence) seqVector.elementAt(i); + } + // This constructor matches sequence names to treenodes and sets up the tree layouts. + tree = new NJTree(seq, newtree); + // Now have to calculate longest name based on the leaves + Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector()); - String longestName = ""; - seq = new Sequence [seqVector.size()]; - for (int i=0;i < seqVector.size();i++) + for (int i = 0; i < leaves.size(); i++) + { + if (longestName.length() < + ( (Sequence) ( (SequenceNode) leaves.elementAt(i)).element()).getName(). + length()) { - seq[i] = (Sequence) seqVector.elementAt(i); + longestName = TreeCanvas.PLACEHOLDER + + ( (Sequence) ( (SequenceNode) leaves.elementAt(i)).element()). + getName(); } - // This constructor matches sequence names to treenodes and sets up the tree layouts. - tree = new NJTree(seq, newtree); - // Now have to calculate longest name based on the leaves - Vector leaves = tree.findLeaves(tree.getTopNode(),new Vector()); - - for (int i=0;i < leaves.size();i++) - if (longestName.length()<((Sequence) ((SequenceNode) leaves.elementAt(i)).element()).getName().length()) - longestName = TreeCanvas.PLACEHOLDER+((Sequence) ((SequenceNode) leaves.elementAt(i)).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()); - distanceMenu.setState(newtree.HasDistances()); - bootstrapMenu.setState(newtree.HasBootstrap()); - if (true) // JBPNote TODO: preference for always marking placeholders in new associated tree - placeholdersMenu.setState(treeCanvas.markPlaceholders); - scrollPane.add(treeCanvas); + } + + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); + treeCanvas = new TreeCanvas(av, tree, scrollPane, longestName); + treeCanvas.setShowBootstrap(newtree.HasBootstrap()); + treeCanvas.setShowDistances(newtree.HasDistances()); + distanceMenu.setState(newtree.HasDistances()); + bootstrapMenu.setState(newtree.HasBootstrap()); + if (true) // JBPNote TODO: preference for always marking placeholders in new associated tree + { + placeholdersMenu.setState(treeCanvas.markPlaceholders); } + scrollPane.add(treeCanvas); -public String getText(String format) { - return null; -} + } + + public String getText(String format) + { + return null; + } protected void fitToWindow_actionPerformed(ActionEvent e) { @@ -130,33 +146,31 @@ public String getText(String format) { cap.setText(output); java.awt.Frame frame = new java.awt.Frame(); frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, type+" "+pwtype, 500,100); + jalview.bin.JalviewLite.addFrame(frame, type + " " + pwtype, 500, 100); } - - protected void fontSize_actionPerformed(ActionEvent e) { - /* if( treeCanvas==null ) - return; - - String size = fontSize.getLabel().substring( fontSize.getLabel().indexOf("-")+1); - - 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); - if(selection!=null) - { - fontSize.setText("Font Size - " + selection); - - int i = Integer.parseInt(selection.toString()); - treeCanvas.setFontSize(i); - } - scrollPane.setViewportView(treeCanvas); -*/ + /* if( treeCanvas==null ) + return; + + String size = fontSize.getLabel().substring( fontSize.getLabel().indexOf("-")+1); + + 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); + if(selection!=null) + { + fontSize.setText("Font Size - " + selection); + + int i = Integer.parseInt(selection.toString()); + treeCanvas.setFontSize(i); + } + scrollPane.setViewportView(treeCanvas); + */ } protected void distanceMenu_actionPerformed(ActionEvent e) @@ -171,7 +185,7 @@ public String getText(String format) { protected void placeholdersMenu_actionPerformed(ActionEvent e) { - treeCanvas.setMarkPlaceholders(placeholdersMenu.getState()); + treeCanvas.setMarkPlaceholders(placeholdersMenu.getState()); } } diff --git a/src/jalview/appletgui/UserDefinedColours.java b/src/jalview/appletgui/UserDefinedColours.java index 0c7e685..80d91ef 100755 --- a/src/jalview/appletgui/UserDefinedColours.java +++ b/src/jalview/appletgui/UserDefinedColours.java @@ -1,35 +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.appletgui; -import jalview.jbappletgui.GUserDefinedColours; -import jalview.datamodel.*; -import jalview.schemes.*; -import jalview.io.*; import java.io.*; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import java.util.*; +import jalview.datamodel.*; +import jalview.jbappletgui.*; +import jalview.schemes.*; -public class UserDefinedColours extends GUserDefinedColours +public class UserDefinedColours + extends GUserDefinedColours { AlignmentPanel ap; @@ -52,98 +53,120 @@ public class UserDefinedColours extends GUserDefinedColours super(); frame = new Frame(); frame.add(this); - jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420,345 ); - - if(sg!=null) - frame.setTitle( frame.getTitle()+ " ("+sg.getName()+")"); + jalview.bin.JalviewLite.addFrame(frame, "User defined colours", 420, 345); + if (sg != null) + { + frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")"); + } this.ap = ap; seqGroup = sg; + if (seqGroup != null) + { + oldColourScheme = seqGroup.cs; + } + else + { + oldColourScheme = ap.av.getGlobalColourScheme(); + } - 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]); + 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", "'.','-',' '"); } - protected void rText_actionPerformed(ActionEvent e) { - try{ + protected void rText_actionPerformed(ActionEvent e) + { + try + { int i = Integer.parseInt(rText.getText()); rScroller.setValue(i); - }catch(NumberFormatException ex){} + } + catch (NumberFormatException ex) + {} } - protected void gText_actionPerformed(ActionEvent e) { - try{ + protected void gText_actionPerformed(ActionEvent e) + { + try + { int i = Integer.parseInt(gText.getText()); gScroller.setValue(i); - }catch(NumberFormatException ex){} + } + catch (NumberFormatException ex) + {} } - protected void bText_actionPerformed(ActionEvent e) { - try{ + protected void bText_actionPerformed(ActionEvent e) + { + try + { int i = Integer.parseInt(bText.getText()); bScroller.setValue(i); - }catch(NumberFormatException ex){} + } + catch (NumberFormatException ex) + {} } - - protected void rScroller_adjustmentValueChanged(AdjustmentEvent e) { + protected void rScroller_adjustmentValueChanged(AdjustmentEvent e) + { R = rScroller.getValue(); - rText.setText(R+""); + rText.setText(R + ""); colourChanged(); } - protected void gScroller_adjustmentValueChanged(AdjustmentEvent e) { + protected void gScroller_adjustmentValueChanged(AdjustmentEvent e) + { G = gScroller.getValue(); - gText.setText(G+""); + gText.setText(G + ""); colourChanged(); } - protected void bScroller_adjustmentValueChanged(AdjustmentEvent e) { + protected void bScroller_adjustmentValueChanged(AdjustmentEvent e) + { B = bScroller.getValue(); - bText.setText(B+""); + bText.setText(B + ""); colourChanged(); } - public void colourChanged() - { - Color col = new Color(R,G,B); - target.setBackground( col ); + public void colourChanged() + { + Color col = new Color(R, G, B); + target.setBackground(col); - if(selectedButton!=null) - selectedButton.setBackground( col ); - } + if (selectedButton != null) + { + selectedButton.setBackground(col); + } + } public void colourButtonPressed(MouseEvent e) { - selectedButton = (Button)e.getSource(); - Color col = selectedButton.getBackground(); - R = col.getRed(); - G = col.getGreen(); - B = col.getBlue(); - rScroller.setValue(R); - gScroller.setValue(G); - bScroller.setValue(B); - rText.setText(R+""); - gText.setText(G+""); - bText.setText(B+""); - - colourChanged(); + selectedButton = (Button) e.getSource(); + Color col = selectedButton.getBackground(); + R = col.getRed(); + G = col.getGreen(); + B = col.getBlue(); + rScroller.setValue(R); + gScroller.setValue(G); + bScroller.setValue(B); + rText.setText(R + ""); + gText.setText(G + ""); + bText.setText(B + ""); + + colourChanged(); } void makeButton(String label, String aa) @@ -151,15 +174,17 @@ public class UserDefinedColours extends GUserDefinedColours final Button button = new Button(); Color col = Color.white; - - try{ + try + { col = oldColourScheme.findColour(aa, -1); - }catch(Exception ex){} + } + catch (Exception ex) + {} - button.setBackground( col ); - oldColours.addElement( col ); - button.setLabel( label ); - button.setForeground( col.darker().darker().darker() ); + button.setBackground(col); + oldColours.addElement(col); + button.setLabel(label); + button.setForeground(col.darker().darker().darker()); button.setFont(new java.awt.Font("Verdana", 1, 10)); button.addMouseListener(new java.awt.event.MouseAdapter() { @@ -172,42 +197,44 @@ public class UserDefinedColours extends GUserDefinedColours buttonPanel.add(button, null); } - protected void okButton_actionPerformed(ActionEvent e) { applyButton_actionPerformed(null); - frame.setVisible(false); + frame.setVisible(false); } protected void applyButton_actionPerformed(ActionEvent e) { - Color [] newColours = new Color[24]; - for(int i=0; i<24; i++) + Color[] newColours = new Color[24]; + for (int i = 0; i < 24; i++) { - Button button = (Button)buttonPanel.getComponent(i); - newColours[i] = button.getBackground(); + Button button = (Button) buttonPanel.getComponent(i); + newColours[i] = button.getBackground(); } - UserColourScheme ucs = new UserColourScheme( newColours ); + UserColourScheme ucs = new UserColourScheme(newColours); ucs.setThreshold(0); - if(seqGroup!=null) + if (seqGroup != null) + { seqGroup.cs = ucs; + } else + { ap.av.setGlobalColourScheme(ucs); + } ap.repaint(); } - public static UserColourScheme loadDefaultColours(String file) { UserColourScheme ucs = null; try { BufferedReader in = new BufferedReader(new FileReader(file)); - Color [] newColours = new Color[24]; + Color[] newColours = new Color[24]; for (int i = 0; i < 24; i++) { newColours[i] = new Color(Integer.parseInt(in.readLine())); @@ -223,28 +250,30 @@ public class UserDefinedColours extends GUserDefinedColours return ucs; } - protected void cancelButton_actionPerformed(ActionEvent e) { - Color [] newColours = new Color[24]; - for(int i=0; i<24; i++) + Color[] newColours = new Color[24]; + for (int i = 0; i < 24; i++) { - newColours[i] = (Color)oldColours.elementAt(i); - buttonPanel.getComponent(i).setBackground(newColours[i]); + newColours[i] = (Color) oldColours.elementAt(i); + buttonPanel.getComponent(i).setBackground(newColours[i]); } - UserColourScheme ucs = new UserColourScheme( newColours ); + UserColourScheme ucs = new UserColourScheme(newColours); if (seqGroup != null) + { seqGroup.cs = ucs; + } else + { ap.av.setGlobalColourScheme(ucs); + } ap.repaint(); frame.setVisible(false); } - } diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index d939a7e..9857f44 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -16,95 +16,88 @@ * 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.util.*; + import java.io.*; +import java.util.*; import java.util.jar.*; -public class Cache -{ - public static String VERSION = "Release 2.0"; - public static String BUILD_DATE = ""; - - 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) - // jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do. - public static void loadProperties() - { - // get last build time. - long date = 0; - try{ - String localFile = Cache.class.getProtectionDomain().getCodeSource().getLocation().toString(); - localFile = localFile.concat("!/"); - String tmpString = "jar:"; - String localJarFileString = tmpString.concat(localFile); - java.net.URL localJarFileURL = new java.net.URL(localJarFileString); - java.net.JarURLConnection localJarFile = (java.net.JarURLConnection)localJarFileURL.openConnection(); - date = localJarFile.getLastModified(); - }catch(Exception ex){ex.printStackTrace();} - 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 - - - java.io.File f = new java.io.File(System.getProperty("user.dir") + "/jalview/bin/Cache.class" ); - date = f.lastModified(); - } - - if(date!=0) - BUILD_DATE = new Date( date ).toString(); - applicationProperties = new Properties(); - try - { - FileInputStream in = new FileInputStream(System.getProperty("user.home") + - "/.jalview_properties"); - applicationProperties = new Properties(); - applicationProperties.load(in); - in.close(); +public class Cache { + public static String VERSION = "Release 2.0"; + public static String BUILD_DATE = ""; + 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) + // jalview.browser - used in the jalview.utils.browserLauncher class if it doesn't know what else to do. + public static void loadProperties() { + // get last build time. + long date = 0; + + try { + String localFile = Cache.class.getProtectionDomain().getCodeSource() + .getLocation().toString(); + localFile = localFile.concat("!/"); + + String tmpString = "jar:"; + String localJarFileString = tmpString.concat(localFile); + java.net.URL localJarFileURL = new java.net.URL(localJarFileString); + java.net.JarURLConnection localJarFile = (java.net.JarURLConnection) localJarFileURL.openConnection(); + date = localJarFile.getLastModified(); + } catch (Exception ex) { + ex.printStackTrace(); + } + + 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 + java.io.File f = new java.io.File(System.getProperty("user.dir") + + "/jalview/bin/Cache.class"); + date = f.lastModified(); + } + + if (date != 0) { + BUILD_DATE = new Date(date).toString(); + } + + applicationProperties = new Properties(); + + try { + FileInputStream in = new FileInputStream(System.getProperty( + "user.home") + "/.jalview_properties"); + applicationProperties = new Properties(); + applicationProperties.load(in); + in.close(); + } catch (Exception ex) { + } } - catch (Exception ex) - { } - } - - 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"); - - applicationProperties.setProperty(key, obj); - - applicationProperties.store(out, "---JalviewX Properties File---"); - out.close(); - } - catch (Exception ex) - {} - - return obj; - - } + 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"); + applicationProperties.setProperty(key, obj); + applicationProperties.store(out, "---JalviewX Properties File---"); + out.close(); + } catch (Exception ex) { + } + return obj; + } } diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 2524abd..07958b4 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -16,141 +16,139 @@ * 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 javax.swing.*; -import java.awt.event.*; + import jalview.io.*; import org.apache.log4j.*; -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); +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() { - Logger l = Logger.getLogger("org.apache.axis"); - if (Cache.getProperty("logs.Axis.Level")==null) { - Cache.setProperty("logs.Axis.Level", Level.INFO.toString()); + + public void destroy() { + if (applet != null) { + applet.stop(); + } else { + System.exit(0); + } + + frame.setVisible(false); } - l.setLevel(Level.toLevel(Cache.getProperty("logs.Axis.Level"))); - ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(),"System.err"); - ap.setName("Axis"); - l.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(); + private static void initLogger() { + Logger l = Logger.getLogger("org.apache.axis"); + + if (Cache.getProperty("logs.Axis.Level") == null) { + Cache.setProperty("logs.Axis.Level", Level.INFO.toString()); + } + + l.setLevel(Level.toLevel(Cache.getProperty("logs.Axis.Level"))); + + ConsoleAppender ap = new ConsoleAppender(new SimpleLayout(), + "System.err"); + ap.setName("Axis"); + l.addAppender(ap); } - try{ - UIManager.setLookAndFeel( - // "javax.swing.plaf.metal.MetalLookAndFeel" - // "javax.swing.plaf.multi.MultiLookAndFeel" - UIManager.getSystemLookAndFeelClassName() - // UIManager.getCrossPlatformLookAndFeelClassName() - // "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" - // "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" - // "com.sun.java.swing.plaf.motif.MotifLookAndFeel" - ); - } - catch (Exception ex) - {} - - Desktop frame = new Desktop(); - frame.setResizable(true); - frame.setVisible(true); - - - - if(args!=null && args.length>0) - { - String file=null; - if(args[0].equals("-open")) - file = args[1]; - else - file = args[0]; - - String protocol = "File"; - if(file.indexOf("http:")>-1) - protocol = "URL"; - - String format = jalview.io.IdentifyFile.Identify(file, protocol); - - frame.LoadFile(file, protocol, format); - } - - if(jalview.gui.Preferences.showStartupFile && - jalview.gui.Preferences.startupFile!=null) - { - String file = jalview.gui.Preferences.startupFile; - String 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); - } - } - - - - } + 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 { + UIManager.setLookAndFeel( + // "javax.swing.plaf.metal.MetalLookAndFeel" + // "javax.swing.plaf.multi.MultiLookAndFeel" + UIManager.getSystemLookAndFeelClassName()); + } catch (Exception ex) { + } + + Desktop frame = new Desktop(); + frame.setResizable(true); + frame.setVisible(true); + + if ((args != null) && (args.length > 0)) { + String file = null; + + if (args[0].equals("-open")) { + file = args[1]; + } else { + file = args[0]; + } + + String protocol = "File"; + + if (file.indexOf("http:") > -1) { + protocol = "URL"; + } + + String format = jalview.io.IdentifyFile.Identify(file, protocol); + + frame.LoadFile(file, protocol, format); + } + + if (jalview.gui.Preferences.showStartupFile && + (jalview.gui.Preferences.startupFile != null)) { + String file = jalview.gui.Preferences.startupFile; + String 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); + } + } + } } - diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index bd5abb0..35ebecc 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -16,126 +16,118 @@ * 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.appletgui.AlignFrame; + +import jalview.datamodel.*; + +import jalview.io.*; + import java.applet.*; + import java.awt.*; import java.awt.event.*; -import jalview.datamodel.*; -import jalview.io.*; -import jalview.appletgui.AlignFrame; -public class JalviewLite extends Applet -{ - static int lastFrameX = 200; - static int lastFrameY = 200; - static Applet applet; - boolean fileFound = true; - String file = "No file"; - Button launcher = new Button("Start Jalview"); - - public void init() - { - applet = this; - this.setBackground(Color.white); - - file = getParameter("file"); - if (file != null) - { - add(launcher); - file = applet.getCodeBase() + file; - launcher.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - String format = jalview.io.IdentifyFile.Identify( file, "URL"); - LoadFile(file, "URL", format); - } - }); + +public class JalviewLite extends Applet { + static int lastFrameX = 200; + static int lastFrameY = 200; + static Applet applet; + boolean fileFound = true; + String file = "No file"; + Button launcher = new Button("Start Jalview"); + + public void init() { + applet = this; + this.setBackground(Color.white); + + file = getParameter("file"); + + if (file != null) { + add(launcher); + file = applet.getCodeBase() + file; + 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 { + file = "NO FILE"; + fileFound = false; + } + } + + public static void showURL(String url) { + try { + applet.getAppletContext().showDocument(new java.net.URL(url), + "HELP_WINDOW"); + } catch (Exception ex) { + } } - else - { - file = "NO FILE"; - fileFound = false; - } - } - - - public static void showURL(String url) - { - try{ - applet.getAppletContext().showDocument(new java.net.URL(url), "HELP_WINDOW"); - }catch(Exception ex){} - } - - public void LoadFile(String file, String protocol, String format) - { - LoadingThread loader = new LoadingThread(file, protocol, format, this); - loader.start(); - } - - public static void addFrame(final Frame frame, String title, int width, 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.dispose(); - } - }); - frame.setVisible(true); - } - - - 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); - g.setColor(Color.red); - g.drawString("Jalview can't open file", 5, 15); - g.drawString("\""+ file+"\"", 5, 30); - } - } - - class LoadingThread extends Thread - { - String file, protocol, format; - JalviewLite jlapplet; - - public LoadingThread(String file, String protocol, String format, JalviewLite applet) - { - this.file = file; - this.protocol = protocol; - this.format = format; - this.jlapplet = applet; - } - public void run() - { - SequenceI [] sequences = null; - sequences = FormatAdapter.readFile(file, protocol, format); - - 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 - { - fileFound = false; - remove(launcher); - repaint(); - } - } - } -} + public void LoadFile(String file, String protocol, String format) { + LoadingThread loader = new LoadingThread(file, protocol, format, this); + loader.start(); + } + public static void addFrame(final Frame frame, String title, int width, + 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.dispose(); + } + }); + frame.setVisible(true); + } + + 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); + g.setColor(Color.red); + g.drawString("Jalview can't open file", 5, 15); + g.drawString("\"" + file + "\"", 5, 30); + } + } + + class LoadingThread extends Thread { + String file; + String protocol; + String format; + JalviewLite jlapplet; + + public LoadingThread(String file, String protocol, String format, + JalviewLite applet) { + this.file = file; + this.protocol = protocol; + this.format = format; + this.jlapplet = applet; + } + + public void run() { + SequenceI[] sequences = null; + sequences = FormatAdapter.readFile(file, protocol, format); + + 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 { + fileFound = false; + remove(launcher); + repaint(); + } + } + } +} diff --git a/src/jalview/binding/Alignment.java b/src/jalview/binding/Alignment.java index 644cd03..093ae6f 100755 --- a/src/jalview/binding/Alignment.java +++ b/src/jalview/binding/Alignment.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -62,30 +60,19 @@ public class Alignment implements java.io.Serializable { */ private jalview.binding.SequenceSet _sequenceSet; - - //----------------/ - //- Constructors -/ //----------------/ - + //- 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'. - */ - public jalview.binding.Annotation getAnnotation() - { + public jalview.binding.Annotation getAnnotation() { return this._annotation; - } //-- jalview.binding.Annotation getAnnotation() + } + //-- jalview.binding.Annotation getAnnotation() /** * Returns the value of field 'sequenceSet'. @@ -93,10 +80,10 @@ public class Alignment implements java.io.Serializable { * @return SequenceSet * @return the value of field 'sequenceSet'. */ - public jalview.binding.SequenceSet getSequenceSet() - { + public jalview.binding.SequenceSet getSequenceSet() { return this._sequenceSet; - } //-- jalview.binding.SequenceSet getSequenceSet() + } + //-- jalview.binding.SequenceSet getSequenceSet() /** * Method isValid @@ -105,16 +92,16 @@ public class Alignment implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -124,11 +111,11 @@ public class Alignment implements java.io.Serializable { * @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 @@ -138,31 +125,31 @@ public class Alignment implements java.io.Serializable { * @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) - { + 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) - { + public void setSequenceSet(jalview.binding.SequenceSet sequenceSet) { this._sequenceSet = sequenceSet; - } //-- void setSequenceSet(jalview.binding.SequenceSet) + } + //-- void setSequenceSet(jalview.binding.SequenceSet) /** * Method unmarshal @@ -173,20 +160,20 @@ public class Alignment implements java.io.Serializable { * @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.Alignment) Unmarshaller.unmarshal(jalview.binding.Alignment.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 4af694f..6879c96 100755 --- a/src/jalview/binding/Annotation.java +++ b/src/jalview/binding/Annotation.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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 Annotation. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class Annotation implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -79,33 +78,22 @@ public class Annotation implements java.io.Serializable { */ private java.lang.String _description; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public Annotation() { super(); _annotationElementList = new Vector(); - } //-- jalview.binding.Annotation() - + } + //-- jalview.binding.Annotation() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addAnnotationElement - * - * - * - * @param vAnnotationElement - */ - public void addAnnotationElement(jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException - { + public void addAnnotationElement( + jalview.binding.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException { _annotationElementList.addElement(vAnnotationElement); - } //-- void addAnnotationElement(jalview.binding.AnnotationElement) + } + //-- void addAnnotationElement(jalview.binding.AnnotationElement) /** * Method addAnnotationElement @@ -115,20 +103,21 @@ public class Annotation implements java.io.Serializable { * @param index * @param vAnnotationElement */ - public void addAnnotationElement(int index, jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException - { + public void addAnnotationElement(int index, + jalview.binding.AnnotationElement vAnnotationElement) + throws java.lang.IndexOutOfBoundsException { _annotationElementList.insertElementAt(vAnnotationElement, index); - } //-- void addAnnotationElement(int, jalview.binding.AnnotationElement) + } + //-- void addAnnotationElement(int, jalview.binding.AnnotationElement) /** * Method deleteGraph * */ - public void deleteGraph() - { - this._has_graph= false; - } //-- void deleteGraph() + public void deleteGraph() { + this._has_graph = false; + } + //-- void deleteGraph() /** * Method enumerateAnnotationElement @@ -137,10 +126,10 @@ public class Annotation implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateAnnotationElement() - { + public java.util.Enumeration enumerateAnnotationElement() { return _annotationElementList.elements(); - } //-- java.util.Enumeration enumerateAnnotationElement() + } + //-- java.util.Enumeration enumerateAnnotationElement() /** * Method getAnnotationElement @@ -151,15 +140,15 @@ public class Annotation implements java.io.Serializable { * @return AnnotationElement */ public jalview.binding.AnnotationElement getAnnotationElement(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.AnnotationElement getAnnotationElement(int) /** * Method getAnnotationElement @@ -168,15 +157,17 @@ public class Annotation implements java.io.Serializable { * * @return AnnotationElement */ - public jalview.binding.AnnotationElement[] getAnnotationElement() - { + 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() + } + //-- jalview.binding.AnnotationElement[] getAnnotationElement() /** * Method getAnnotationElementCount @@ -185,10 +176,10 @@ public class Annotation implements java.io.Serializable { * * @return int */ - public int getAnnotationElementCount() - { + public int getAnnotationElementCount() { return _annotationElementList.size(); - } //-- int getAnnotationElementCount() + } + //-- int getAnnotationElementCount() /** * Returns the value of field 'description'. @@ -196,10 +187,10 @@ public class Annotation implements java.io.Serializable { * @return String * @return the value of field 'description'. */ - public java.lang.String getDescription() - { + public java.lang.String getDescription() { return this._description; - } //-- java.lang.String getDescription() + } + //-- java.lang.String getDescription() /** * Returns the value of field 'graph'. @@ -207,10 +198,10 @@ public class Annotation implements java.io.Serializable { * @return boolean * @return the value of field 'graph'. */ - public boolean getGraph() - { + public boolean getGraph() { return this._graph; - } //-- boolean getGraph() + } + //-- boolean getGraph() /** * Returns the value of field 'label'. @@ -218,10 +209,10 @@ public class Annotation implements java.io.Serializable { * @return String * @return the value of field 'label'. */ - public java.lang.String getLabel() - { + public java.lang.String getLabel() { return this._label; - } //-- java.lang.String getLabel() + } + //-- java.lang.String getLabel() /** * Method hasGraph @@ -230,10 +221,10 @@ public class Annotation implements java.io.Serializable { * * @return boolean */ - public boolean hasGraph() - { + public boolean hasGraph() { return this._has_graph; - } //-- boolean hasGraph() + } + //-- boolean hasGraph() /** * Method isValid @@ -242,16 +233,16 @@ public class Annotation implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -261,11 +252,11 @@ public class Annotation implements java.io.Serializable { * @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 @@ -275,20 +266,20 @@ public class Annotation implements java.io.Serializable { * @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 removeAllAnnotationElement * */ - public void removeAllAnnotationElement() - { + public void removeAllAnnotationElement() { _annotationElementList.removeAllElements(); - } //-- void removeAllAnnotationElement() + } + //-- void removeAllAnnotationElement() /** * Method removeAnnotationElement @@ -298,12 +289,13 @@ public class Annotation implements java.io.Serializable { * @param index * @return AnnotationElement */ - public jalview.binding.AnnotationElement removeAnnotationElement(int index) - { + 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) + } + //-- jalview.binding.AnnotationElement removeAnnotationElement(int) /** * Method setAnnotationElement @@ -313,15 +305,17 @@ public class Annotation implements java.io.Serializable { * @param index * @param vAnnotationElement */ - public void setAnnotationElement(int index, jalview.binding.AnnotationElement vAnnotationElement) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setAnnotationElement(int, jalview.binding.AnnotationElement) /** * Method setAnnotationElement @@ -330,45 +324,47 @@ public class Annotation implements java.io.Serializable { * * @param annotationElementArray */ - public void setAnnotationElement(jalview.binding.AnnotationElement[] annotationElementArray) - { + public void setAnnotationElement( + jalview.binding.AnnotationElement[] annotationElementArray) { //-- copy array _annotationElementList.removeAllElements(); + for (int i = 0; i < annotationElementArray.length; i++) { _annotationElementList.addElement(annotationElementArray[i]); } - } //-- void setAnnotationElement(jalview.binding.AnnotationElement) + } + //-- 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) - { + 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 'graph'. * * @param graph the value of field 'graph'. */ - public void setGraph(boolean graph) - { + public void setGraph(boolean graph) { this._graph = graph; this._has_graph = true; - } //-- void setGraph(boolean) + } + //-- void setGraph(boolean) /** * Sets the value of field 'label'. * * @param label the value of field 'label'. */ - public void setLabel(java.lang.String label) - { + public void setLabel(java.lang.String label) { this._label = label; - } //-- void setLabel(java.lang.String) + } + //-- void setLabel(java.lang.String) /** * Method unmarshal @@ -379,20 +375,20 @@ public class Annotation implements java.io.Serializable { * @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) + 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 - { + 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/AnnotationElement.java b/src/jalview/binding/AnnotationElement.java index 211810d..3c6eba4 100755 --- a/src/jalview/binding/AnnotationElement.java +++ b/src/jalview/binding/AnnotationElement.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -87,37 +85,28 @@ public class AnnotationElement implements java.io.Serializable { */ private boolean _has_value; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public AnnotationElement() { super(); - } //-- jalview.binding.AnnotationElement() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.AnnotationElement() + //-----------/ - /** - * Method deletePosition - * - */ - public void deletePosition() - { - this._has_position= false; - } //-- void deletePosition() + public void deletePosition() { + this._has_position = false; + } + //-- void deletePosition() /** * Method deleteValue * */ - public void deleteValue() - { - this._has_value= false; - } //-- void deleteValue() + public void deleteValue() { + this._has_value = false; + } + //-- void deleteValue() /** * Returns the value of field 'description'. @@ -125,10 +114,10 @@ public class AnnotationElement implements java.io.Serializable { * @return String * @return the value of field 'description'. */ - public java.lang.String getDescription() - { + public java.lang.String getDescription() { return this._description; - } //-- java.lang.String getDescription() + } + //-- java.lang.String getDescription() /** * Returns the value of field 'displayCharacter'. @@ -136,10 +125,10 @@ public class AnnotationElement implements java.io.Serializable { * @return String * @return the value of field 'displayCharacter'. */ - public java.lang.String getDisplayCharacter() - { + public java.lang.String getDisplayCharacter() { return this._displayCharacter; - } //-- java.lang.String getDisplayCharacter() + } + //-- java.lang.String getDisplayCharacter() /** * Returns the value of field 'position'. @@ -147,10 +136,10 @@ public class AnnotationElement implements java.io.Serializable { * @return int * @return the value of field 'position'. */ - public int getPosition() - { + public int getPosition() { return this._position; - } //-- int getPosition() + } + //-- int getPosition() /** * Returns the value of field 'secondaryStructure'. @@ -158,10 +147,10 @@ public class AnnotationElement implements java.io.Serializable { * @return String * @return the value of field 'secondaryStructure'. */ - public java.lang.String getSecondaryStructure() - { + public java.lang.String getSecondaryStructure() { return this._secondaryStructure; - } //-- java.lang.String getSecondaryStructure() + } + //-- java.lang.String getSecondaryStructure() /** * Returns the value of field 'value'. @@ -169,10 +158,10 @@ public class AnnotationElement implements java.io.Serializable { * @return float * @return the value of field 'value'. */ - public float getValue() - { + public float getValue() { return this._value; - } //-- float getValue() + } + //-- float getValue() /** * Method hasPosition @@ -181,10 +170,10 @@ public class AnnotationElement implements java.io.Serializable { * * @return boolean */ - public boolean hasPosition() - { + public boolean hasPosition() { return this._has_position; - } //-- boolean hasPosition() + } + //-- boolean hasPosition() /** * Method hasValue @@ -193,10 +182,10 @@ public class AnnotationElement implements java.io.Serializable { * * @return boolean */ - public boolean hasValue() - { + public boolean hasValue() { return this._has_value; - } //-- boolean hasValue() + } + //-- boolean hasValue() /** * Method isValid @@ -205,16 +194,16 @@ public class AnnotationElement implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -224,11 +213,11 @@ public class AnnotationElement implements java.io.Serializable { * @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 @@ -238,42 +227,42 @@ public class AnnotationElement implements java.io.Serializable { * @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) - { + 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) - { + 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) - { + public void setPosition(int position) { this._position = position; this._has_position = true; - } //-- void setPosition(int) + } + //-- void setPosition(int) /** * Sets the value of field 'secondaryStructure'. @@ -281,21 +270,21 @@ public class AnnotationElement implements java.io.Serializable { * @param secondaryStructure the value of field * 'secondaryStructure'. */ - public void setSecondaryStructure(java.lang.String 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) - { + public void setValue(float value) { this._value = value; this._has_value = true; - } //-- void setValue(float) + } + //-- void setValue(float) /** * Method unmarshal @@ -306,20 +295,20 @@ public class AnnotationElement implements java.io.Serializable { * @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.AnnotationElement) Unmarshaller.unmarshal(jalview.binding.AnnotationElement.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 2a3423d..7cd04b3 100755 --- a/src/jalview/binding/Colour.java +++ b/src/jalview/binding/Colour.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -62,30 +60,19 @@ public class Colour implements java.io.Serializable { */ private java.lang.String _RGB; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public Colour() { super(); - } //-- jalview.binding.Colour() - + } + //-- jalview.binding.Colour() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'name'. - * - * @return String - * @return the value of field 'name'. - */ - public java.lang.String getName() - { + public java.lang.String getName() { return this._name; - } //-- java.lang.String getName() + } + //-- java.lang.String getName() /** * Returns the value of field 'RGB'. @@ -93,10 +80,10 @@ public class Colour implements java.io.Serializable { * @return String * @return the value of field 'RGB'. */ - public java.lang.String getRGB() - { + public java.lang.String getRGB() { return this._RGB; - } //-- java.lang.String getRGB() + } + //-- java.lang.String getRGB() /** * Method isValid @@ -105,16 +92,16 @@ public class Colour implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -124,11 +111,11 @@ public class Colour implements java.io.Serializable { * @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 @@ -138,31 +125,31 @@ public class Colour implements java.io.Serializable { * @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) - { + 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) - { + public void setRGB(java.lang.String RGB) { this._RGB = RGB; - } //-- void setRGB(java.lang.String) + } + //-- void setRGB(java.lang.String) /** * Method unmarshal @@ -173,20 +160,20 @@ public class Colour implements java.io.Serializable { * @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.Colour) Unmarshaller.unmarshal(jalview.binding.Colour.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 eef4a28..3b5c0b8 100755 --- a/src/jalview/binding/JGroup.java +++ b/src/jalview/binding/JGroup.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class JGroup implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -149,33 +148,20 @@ public class JGroup implements java.io.Serializable { */ private java.util.Vector _seqList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JGroup() { super(); _seqList = new Vector(); - } //-- jalview.binding.JGroup() - + } + //-- jalview.binding.JGroup() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addSeq - * - * - * - * @param vSeq - */ - 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 @@ -186,82 +172,82 @@ public class JGroup implements java.io.Serializable { * @param vSeq */ public void addSeq(int index, int vSeq) - throws java.lang.IndexOutOfBoundsException - { + 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() + public void deleteColourText() { + this._has_colourText = false; + } + //-- void deleteColourText() /** * Method deleteConsThreshold * */ - public void deleteConsThreshold() - { - this._has_consThreshold= false; - } //-- void deleteConsThreshold() + public void deleteConsThreshold() { + this._has_consThreshold = false; + } + //-- void deleteConsThreshold() /** * Method deleteDisplayBoxes * */ - public void deleteDisplayBoxes() - { - this._has_displayBoxes= false; - } //-- void deleteDisplayBoxes() + public void deleteDisplayBoxes() { + this._has_displayBoxes = false; + } + //-- void deleteDisplayBoxes() /** * Method deleteDisplayText * */ - public void deleteDisplayText() - { - this._has_displayText= false; - } //-- void deleteDisplayText() + public void deleteDisplayText() { + this._has_displayText = false; + } + //-- void deleteDisplayText() /** * Method deleteEnd * */ - public void deleteEnd() - { - this._has_end= false; - } //-- void deleteEnd() + public void deleteEnd() { + this._has_end = false; + } + //-- void deleteEnd() /** * Method deleteOutlineColour * */ - public void deleteOutlineColour() - { - this._has_outlineColour= false; - } //-- void deleteOutlineColour() + public void deleteOutlineColour() { + this._has_outlineColour = false; + } + //-- void deleteOutlineColour() /** * Method deletePidThreshold * */ - public void deletePidThreshold() - { - this._has_pidThreshold= false; - } //-- void deletePidThreshold() + public void deletePidThreshold() { + this._has_pidThreshold = false; + } + //-- void deletePidThreshold() /** * Method deleteStart * */ - public void deleteStart() - { - this._has_start= false; - } //-- void deleteStart() + public void deleteStart() { + this._has_start = false; + } + //-- void deleteStart() /** * Method enumerateSeq @@ -270,10 +256,10 @@ public class JGroup implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateSeq() - { + public java.util.Enumeration enumerateSeq() { return _seqList.elements(); - } //-- java.util.Enumeration enumerateSeq() + } + //-- java.util.Enumeration enumerateSeq() /** * Returns the value of field 'colour'. @@ -281,10 +267,10 @@ public class JGroup implements java.io.Serializable { * @return String * @return the value of field 'colour'. */ - public java.lang.String getColour() - { + public java.lang.String getColour() { return this._colour; - } //-- java.lang.String getColour() + } + //-- java.lang.String getColour() /** * Returns the value of field 'colourText'. @@ -292,10 +278,10 @@ public class JGroup implements java.io.Serializable { * @return boolean * @return the value of field 'colourText'. */ - public boolean getColourText() - { + public boolean getColourText() { return this._colourText; - } //-- boolean getColourText() + } + //-- boolean getColourText() /** * Returns the value of field 'consThreshold'. @@ -303,10 +289,10 @@ public class JGroup implements java.io.Serializable { * @return int * @return the value of field 'consThreshold'. */ - public int getConsThreshold() - { + public int getConsThreshold() { return this._consThreshold; - } //-- int getConsThreshold() + } + //-- int getConsThreshold() /** * Returns the value of field 'displayBoxes'. @@ -314,10 +300,10 @@ public class JGroup implements java.io.Serializable { * @return boolean * @return the value of field 'displayBoxes'. */ - public boolean getDisplayBoxes() - { + public boolean getDisplayBoxes() { return this._displayBoxes; - } //-- boolean getDisplayBoxes() + } + //-- boolean getDisplayBoxes() /** * Returns the value of field 'displayText'. @@ -325,10 +311,10 @@ public class JGroup implements java.io.Serializable { * @return boolean * @return the value of field 'displayText'. */ - public boolean getDisplayText() - { + public boolean getDisplayText() { return this._displayText; - } //-- boolean getDisplayText() + } + //-- boolean getDisplayText() /** * Returns the value of field 'end'. @@ -336,10 +322,10 @@ public class JGroup implements java.io.Serializable { * @return int * @return the value of field 'end'. */ - public int getEnd() - { + public int getEnd() { return this._end; - } //-- int getEnd() + } + //-- int getEnd() /** * Returns the value of field 'name'. @@ -347,10 +333,10 @@ public class JGroup implements java.io.Serializable { * @return String * @return the value of field 'name'. */ - public java.lang.String getName() - { + public java.lang.String getName() { return this._name; - } //-- java.lang.String getName() + } + //-- java.lang.String getName() /** * Returns the value of field 'outlineColour'. @@ -358,10 +344,10 @@ public class JGroup implements java.io.Serializable { * @return int * @return the value of field 'outlineColour'. */ - public int getOutlineColour() - { + public int getOutlineColour() { return this._outlineColour; - } //-- int getOutlineColour() + } + //-- int getOutlineColour() /** * Returns the value of field 'pidThreshold'. @@ -369,10 +355,10 @@ public class JGroup implements java.io.Serializable { * @return int * @return the value of field 'pidThreshold'. */ - public int getPidThreshold() - { + public int getPidThreshold() { return this._pidThreshold; - } //-- int getPidThreshold() + } + //-- int getPidThreshold() /** * Method getSeq @@ -382,16 +368,15 @@ public class JGroup implements java.io.Serializable { * @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())) { 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 @@ -400,15 +385,17 @@ public class JGroup implements java.io.Serializable { * * @return int */ - public int[] getSeq() - { + 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(); + mArray[index] = ((java.lang.Integer) _seqList.elementAt(index)).intValue(); } + return mArray; - } //-- int[] getSeq() + } + //-- int[] getSeq() /** * Method getSeqCount @@ -417,10 +404,10 @@ public class JGroup implements java.io.Serializable { * * @return int */ - public int getSeqCount() - { + public int getSeqCount() { return _seqList.size(); - } //-- int getSeqCount() + } + //-- int getSeqCount() /** * Returns the value of field 'start'. @@ -428,10 +415,10 @@ public class JGroup implements java.io.Serializable { * @return int * @return the value of field 'start'. */ - public int getStart() - { + public int getStart() { return this._start; - } //-- int getStart() + } + //-- int getStart() /** * Method hasColourText @@ -440,10 +427,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasColourText() - { + public boolean hasColourText() { return this._has_colourText; - } //-- boolean hasColourText() + } + //-- boolean hasColourText() /** * Method hasConsThreshold @@ -452,10 +439,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasConsThreshold() - { + public boolean hasConsThreshold() { return this._has_consThreshold; - } //-- boolean hasConsThreshold() + } + //-- boolean hasConsThreshold() /** * Method hasDisplayBoxes @@ -464,10 +451,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasDisplayBoxes() - { + public boolean hasDisplayBoxes() { return this._has_displayBoxes; - } //-- boolean hasDisplayBoxes() + } + //-- boolean hasDisplayBoxes() /** * Method hasDisplayText @@ -476,10 +463,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasDisplayText() - { + public boolean hasDisplayText() { return this._has_displayText; - } //-- boolean hasDisplayText() + } + //-- boolean hasDisplayText() /** * Method hasEnd @@ -488,10 +475,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasEnd() - { + public boolean hasEnd() { return this._has_end; - } //-- boolean hasEnd() + } + //-- boolean hasEnd() /** * Method hasOutlineColour @@ -500,10 +487,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasOutlineColour() - { + public boolean hasOutlineColour() { return this._has_outlineColour; - } //-- boolean hasOutlineColour() + } + //-- boolean hasOutlineColour() /** * Method hasPidThreshold @@ -512,10 +499,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasPidThreshold() - { + public boolean hasPidThreshold() { return this._has_pidThreshold; - } //-- boolean hasPidThreshold() + } + //-- boolean hasPidThreshold() /** * Method hasStart @@ -524,10 +511,10 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean hasStart() - { + public boolean hasStart() { return this._has_start; - } //-- boolean hasStart() + } + //-- boolean hasStart() /** * Method isValid @@ -536,16 +523,16 @@ public class JGroup implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -555,11 +542,11 @@ public class JGroup implements java.io.Serializable { * @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 @@ -569,20 +556,20 @@ public class JGroup implements java.io.Serializable { * @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() - { + public void removeAllSeq() { _seqList.removeAllElements(); - } //-- void removeAllSeq() + } + //-- void removeAllSeq() /** * Method removeSeq @@ -592,109 +579,110 @@ public class JGroup implements java.io.Serializable { * @param index * @return int */ - public int removeSeq(int index) - { + public int removeSeq(int index) { 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) - { + 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) - { + 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) - { + 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) - { + 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) - { + 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) - { + 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) - { + 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) - { + 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) - { + public void setPidThreshold(int pidThreshold) { this._pidThreshold = pidThreshold; this._has_pidThreshold = true; - } //-- void setPidThreshold(int) + } + //-- void setPidThreshold(int) /** * Method setSeq @@ -705,14 +693,15 @@ public class JGroup implements java.io.Serializable { * @param vSeq */ public void setSeq(int index, int vSeq) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -721,25 +710,26 @@ public class JGroup implements java.io.Serializable { * * @param seqArray */ - public void setSeq(int[] seqArray) - { + public void setSeq(int[] seqArray) { //-- copy array _seqList.removeAllElements(); + 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) - { + public void setStart(int start) { this._start = start; this._has_start = true; - } //-- void setStart(int) + } + //-- void setStart(int) /** * Method unmarshal @@ -750,20 +740,20 @@ public class JGroup implements java.io.Serializable { * @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.JGroup) Unmarshaller.unmarshal(jalview.binding.JGroup.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 9e02e60..cabf5c8 100755 --- a/src/jalview/binding/JSeq.java +++ b/src/jalview/binding/JSeq.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -92,55 +90,46 @@ public class JSeq implements java.io.Serializable { */ private boolean _has_id; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JSeq() { super(); - } //-- jalview.binding.JSeq() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.JSeq() + //-----------/ - /** - * Method deleteColour - * - */ - public void deleteColour() - { - this._has_colour= false; - } //-- void deleteColour() + public void deleteColour() { + this._has_colour = false; + } + //-- void deleteColour() /** * Method deleteEnd * */ - public void deleteEnd() - { - this._has_end= false; - } //-- void deleteEnd() + public void deleteEnd() { + this._has_end = false; + } + //-- void deleteEnd() /** * Method deleteId * */ - public void deleteId() - { - this._has_id= false; - } //-- void deleteId() + public void deleteId() { + this._has_id = false; + } + //-- void deleteId() /** * Method deleteStart * */ - public void deleteStart() - { - this._has_start= false; - } //-- void deleteStart() + public void deleteStart() { + this._has_start = false; + } + //-- void deleteStart() /** * Returns the value of field 'colour'. @@ -148,10 +137,10 @@ public class JSeq implements java.io.Serializable { * @return int * @return the value of field 'colour'. */ - public int getColour() - { + public int getColour() { return this._colour; - } //-- int getColour() + } + //-- int getColour() /** * Returns the value of field 'end'. @@ -159,10 +148,10 @@ public class JSeq implements java.io.Serializable { * @return int * @return the value of field 'end'. */ - public int getEnd() - { + public int getEnd() { return this._end; - } //-- int getEnd() + } + //-- int getEnd() /** * Returns the value of field 'id'. @@ -170,10 +159,10 @@ public class JSeq implements java.io.Serializable { * @return int * @return the value of field 'id'. */ - public int getId() - { + public int getId() { return this._id; - } //-- int getId() + } + //-- int getId() /** * Returns the value of field 'start'. @@ -181,10 +170,10 @@ public class JSeq implements java.io.Serializable { * @return int * @return the value of field 'start'. */ - public int getStart() - { + public int getStart() { return this._start; - } //-- int getStart() + } + //-- int getStart() /** * Method hasColour @@ -193,10 +182,10 @@ public class JSeq implements java.io.Serializable { * * @return boolean */ - public boolean hasColour() - { + public boolean hasColour() { return this._has_colour; - } //-- boolean hasColour() + } + //-- boolean hasColour() /** * Method hasEnd @@ -205,10 +194,10 @@ public class JSeq implements java.io.Serializable { * * @return boolean */ - public boolean hasEnd() - { + public boolean hasEnd() { return this._has_end; - } //-- boolean hasEnd() + } + //-- boolean hasEnd() /** * Method hasId @@ -217,10 +206,10 @@ public class JSeq implements java.io.Serializable { * * @return boolean */ - public boolean hasId() - { + public boolean hasId() { return this._has_id; - } //-- boolean hasId() + } + //-- boolean hasId() /** * Method hasStart @@ -229,10 +218,10 @@ public class JSeq implements java.io.Serializable { * * @return boolean */ - public boolean hasStart() - { + public boolean hasStart() { return this._has_start; - } //-- boolean hasStart() + } + //-- boolean hasStart() /** * Method isValid @@ -241,16 +230,16 @@ public class JSeq implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -260,11 +249,11 @@ public class JSeq implements java.io.Serializable { * @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 @@ -274,55 +263,55 @@ public class JSeq implements java.io.Serializable { * @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) - { + 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) - { + 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) - { + 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) - { + public void setStart(int start) { this._start = start; this._has_start = true; - } //-- void setStart(int) + } + //-- void setStart(int) /** * Method unmarshal @@ -333,20 +322,20 @@ public class JSeq implements java.io.Serializable { * @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.JSeq) Unmarshaller.unmarshal(jalview.binding.JSeq.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 d30e97d..85bfe26 100755 --- a/src/jalview/binding/JalviewModel.java +++ b/src/jalview/binding/JalviewModel.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,23 +22,25 @@ * 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.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. @@ -47,10 +48,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class JalviewModel implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -68,30 +67,19 @@ public class JalviewModel implements java.io.Serializable { */ private jalview.binding.JalviewModelSequence _jalviewModelSequence; - - //----------------/ - //- Constructors -/ //----------------/ - + //- 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'. - */ - public java.util.Date getCreationDate() - { + public java.util.Date getCreationDate() { return this._creationDate; - } //-- java.util.Date getCreationDate() + } + //-- java.util.Date getCreationDate() /** * Returns the value of field 'jalviewModelSequence'. @@ -99,10 +87,10 @@ public class JalviewModel implements java.io.Serializable { * @return JalviewModelSequence * @return the value of field 'jalviewModelSequence'. */ - public jalview.binding.JalviewModelSequence getJalviewModelSequence() - { + public jalview.binding.JalviewModelSequence getJalviewModelSequence() { return this._jalviewModelSequence; - } //-- jalview.binding.JalviewModelSequence getJalviewModelSequence() + } + //-- jalview.binding.JalviewModelSequence getJalviewModelSequence() /** * Returns the value of field 'vamsasModel'. @@ -110,10 +98,10 @@ public class JalviewModel implements java.io.Serializable { * @return VamsasModel * @return the value of field 'vamsasModel'. */ - public jalview.binding.VamsasModel getVamsasModel() - { + public jalview.binding.VamsasModel getVamsasModel() { return this._vamsasModel; - } //-- jalview.binding.VamsasModel getVamsasModel() + } + //-- jalview.binding.VamsasModel getVamsasModel() /** * Method isValid @@ -122,16 +110,16 @@ public class JalviewModel implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -141,11 +129,11 @@ public class JalviewModel implements java.io.Serializable { * @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 @@ -155,21 +143,21 @@ public class JalviewModel implements java.io.Serializable { * @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) - { + 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'. @@ -177,20 +165,21 @@ public class JalviewModel implements java.io.Serializable { * @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) - { + public void setVamsasModel(jalview.binding.VamsasModel vamsasModel) { this._vamsasModel = vamsasModel; - } //-- void setVamsasModel(jalview.binding.VamsasModel) + } + //-- void setVamsasModel(jalview.binding.VamsasModel) /** * Method unmarshal @@ -201,20 +190,20 @@ public class JalviewModel implements java.io.Serializable { * @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.JalviewModel) Unmarshaller.unmarshal(jalview.binding.JalviewModel.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 d22dcd4..2abee13 100755 --- a/src/jalview/binding/JalviewModelSequence.java +++ b/src/jalview/binding/JalviewModelSequence.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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 JalviewModelSequence. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class JalviewModelSequence implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -74,36 +73,24 @@ public class JalviewModelSequence implements java.io.Serializable { */ private java.util.Vector _userColoursList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JalviewModelSequence() { super(); _JSeqList = new Vector(); _JGroupList = new Vector(); _viewportList = new Vector(); _userColoursList = new Vector(); - } //-- jalview.binding.JalviewModelSequence() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.JalviewModelSequence() + //-----------/ - /** - * Method addJGroup - * - * - * - * @param vJGroup - */ public void addJGroup(jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _JGroupList.addElement(vJGroup); - } //-- void addJGroup(jalview.binding.JGroup) + } + //-- void addJGroup(jalview.binding.JGroup) /** * Method addJGroup @@ -114,10 +101,10 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vJGroup */ public void addJGroup(int index, jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _JGroupList.insertElementAt(vJGroup, index); - } //-- void addJGroup(int, jalview.binding.JGroup) + } + //-- void addJGroup(int, jalview.binding.JGroup) /** * Method addJSeq @@ -127,10 +114,10 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vJSeq */ public void addJSeq(jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _JSeqList.addElement(vJSeq); - } //-- void addJSeq(jalview.binding.JSeq) + } + //-- void addJSeq(jalview.binding.JSeq) /** * Method addJSeq @@ -141,10 +128,10 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vJSeq */ public void addJSeq(int index, jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _JSeqList.insertElementAt(vJSeq, index); - } //-- void addJSeq(int, jalview.binding.JSeq) + } + //-- void addJSeq(int, jalview.binding.JSeq) /** * Method addUserColours @@ -154,10 +141,10 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vUserColours */ public void addUserColours(jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _userColoursList.addElement(vUserColours); - } //-- void addUserColours(jalview.binding.UserColours) + } + //-- void addUserColours(jalview.binding.UserColours) /** * Method addUserColours @@ -167,11 +154,12 @@ public class JalviewModelSequence implements java.io.Serializable { * @param index * @param vUserColours */ - public void addUserColours(int index, jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException - { + public void addUserColours(int index, + jalview.binding.UserColours vUserColours) + throws java.lang.IndexOutOfBoundsException { _userColoursList.insertElementAt(vUserColours, index); - } //-- void addUserColours(int, jalview.binding.UserColours) + } + //-- void addUserColours(int, jalview.binding.UserColours) /** * Method addViewport @@ -181,10 +169,10 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vViewport */ public void addViewport(jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _viewportList.addElement(vViewport); - } //-- void addViewport(jalview.binding.Viewport) + } + //-- void addViewport(jalview.binding.Viewport) /** * Method addViewport @@ -195,10 +183,10 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vViewport */ public void addViewport(int index, jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _viewportList.insertElementAt(vViewport, index); - } //-- void addViewport(int, jalview.binding.Viewport) + } + //-- void addViewport(int, jalview.binding.Viewport) /** * Method enumerateJGroup @@ -207,10 +195,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateJGroup() - { + public java.util.Enumeration enumerateJGroup() { return _JGroupList.elements(); - } //-- java.util.Enumeration enumerateJGroup() + } + //-- java.util.Enumeration enumerateJGroup() /** * Method enumerateJSeq @@ -219,10 +207,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateJSeq() - { + public java.util.Enumeration enumerateJSeq() { return _JSeqList.elements(); - } //-- java.util.Enumeration enumerateJSeq() + } + //-- java.util.Enumeration enumerateJSeq() /** * Method enumerateUserColours @@ -231,10 +219,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateUserColours() - { + public java.util.Enumeration enumerateUserColours() { return _userColoursList.elements(); - } //-- java.util.Enumeration enumerateUserColours() + } + //-- java.util.Enumeration enumerateUserColours() /** * Method enumerateViewport @@ -243,10 +231,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateViewport() - { + public java.util.Enumeration enumerateViewport() { return _viewportList.elements(); - } //-- java.util.Enumeration enumerateViewport() + } + //-- java.util.Enumeration enumerateViewport() /** * Method getJGroup @@ -257,15 +245,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @return JGroup */ public jalview.binding.JGroup getJGroup(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.JGroup getJGroup(int) /** * Method getJGroup @@ -274,15 +262,17 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return JGroup */ - public jalview.binding.JGroup[] getJGroup() - { + 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() + } + //-- jalview.binding.JGroup[] getJGroup() /** * Method getJGroupCount @@ -291,10 +281,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return int */ - public int getJGroupCount() - { + public int getJGroupCount() { return _JGroupList.size(); - } //-- int getJGroupCount() + } + //-- int getJGroupCount() /** * Method getJSeq @@ -305,15 +295,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @return JSeq */ public jalview.binding.JSeq getJSeq(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.JSeq getJSeq(int) /** * Method getJSeq @@ -322,15 +312,17 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return JSeq */ - public jalview.binding.JSeq[] getJSeq() - { + 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() + } + //-- jalview.binding.JSeq[] getJSeq() /** * Method getJSeqCount @@ -339,10 +331,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return int */ - public int getJSeqCount() - { + public int getJSeqCount() { return _JSeqList.size(); - } //-- int getJSeqCount() + } + //-- int getJSeqCount() /** * Method getUserColours @@ -353,15 +345,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @return UserColours */ public jalview.binding.UserColours getUserColours(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.UserColours getUserColours(int) /** * Method getUserColours @@ -370,15 +362,17 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return UserColours */ - public jalview.binding.UserColours[] getUserColours() - { + 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() + } + //-- jalview.binding.UserColours[] getUserColours() /** * Method getUserColoursCount @@ -387,10 +381,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return int */ - public int getUserColoursCount() - { + public int getUserColoursCount() { return _userColoursList.size(); - } //-- int getUserColoursCount() + } + //-- int getUserColoursCount() /** * Method getViewport @@ -401,15 +395,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @return Viewport */ public jalview.binding.Viewport getViewport(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.Viewport getViewport(int) /** * Method getViewport @@ -418,15 +412,17 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return Viewport */ - public jalview.binding.Viewport[] getViewport() - { + 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() + } + //-- jalview.binding.Viewport[] getViewport() /** * Method getViewportCount @@ -435,10 +431,10 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return int */ - public int getViewportCount() - { + public int getViewportCount() { return _viewportList.size(); - } //-- int getViewportCount() + } + //-- int getViewportCount() /** * Method isValid @@ -447,16 +443,16 @@ public class JalviewModelSequence implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -466,11 +462,11 @@ public class JalviewModelSequence implements java.io.Serializable { * @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 @@ -480,47 +476,47 @@ public class JalviewModelSequence implements java.io.Serializable { * @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 removeAllJGroup * */ - public void removeAllJGroup() - { + public void removeAllJGroup() { _JGroupList.removeAllElements(); - } //-- void removeAllJGroup() + } + //-- void removeAllJGroup() /** * Method removeAllJSeq * */ - public void removeAllJSeq() - { + public void removeAllJSeq() { _JSeqList.removeAllElements(); - } //-- void removeAllJSeq() + } + //-- void removeAllJSeq() /** * Method removeAllUserColours * */ - public void removeAllUserColours() - { + public void removeAllUserColours() { _userColoursList.removeAllElements(); - } //-- void removeAllUserColours() + } + //-- void removeAllUserColours() /** * Method removeAllViewport * */ - public void removeAllViewport() - { + public void removeAllViewport() { _viewportList.removeAllElements(); - } //-- void removeAllViewport() + } + //-- void removeAllViewport() /** * Method removeJGroup @@ -530,12 +526,13 @@ public class JalviewModelSequence implements java.io.Serializable { * @param index * @return JGroup */ - public jalview.binding.JGroup removeJGroup(int index) - { + 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) + } + //-- jalview.binding.JGroup removeJGroup(int) /** * Method removeJSeq @@ -545,12 +542,13 @@ public class JalviewModelSequence implements java.io.Serializable { * @param index * @return JSeq */ - public jalview.binding.JSeq removeJSeq(int index) - { + 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) + } + //-- jalview.binding.JSeq removeJSeq(int) /** * Method removeUserColours @@ -560,12 +558,13 @@ public class JalviewModelSequence implements java.io.Serializable { * @param index * @return UserColours */ - public jalview.binding.UserColours removeUserColours(int index) - { + 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) + } + //-- jalview.binding.UserColours removeUserColours(int) /** * Method removeViewport @@ -575,12 +574,13 @@ public class JalviewModelSequence implements java.io.Serializable { * @param index * @return Viewport */ - public jalview.binding.Viewport removeViewport(int index) - { + 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) + } + //-- jalview.binding.Viewport removeViewport(int) /** * Method setJGroup @@ -591,14 +591,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vJGroup */ public void setJGroup(int index, jalview.binding.JGroup vJGroup) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setJGroup(int, jalview.binding.JGroup) /** * Method setJGroup @@ -607,14 +608,15 @@ public class JalviewModelSequence implements java.io.Serializable { * * @param JGroupArray */ - public void setJGroup(jalview.binding.JGroup[] 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) + } + //-- void setJGroup(jalview.binding.JGroup) /** * Method setJSeq @@ -625,14 +627,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vJSeq */ public void setJSeq(int index, jalview.binding.JSeq vJSeq) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setJSeq(int, jalview.binding.JSeq) /** * Method setJSeq @@ -641,14 +644,15 @@ public class JalviewModelSequence implements java.io.Serializable { * * @param JSeqArray */ - public void setJSeq(jalview.binding.JSeq[] 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) + } + //-- void setJSeq(jalview.binding.JSeq) /** * Method setUserColours @@ -658,15 +662,17 @@ public class JalviewModelSequence implements java.io.Serializable { * @param index * @param vUserColours */ - public void setUserColours(int index, jalview.binding.UserColours vUserColours) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setUserColours(int, jalview.binding.UserColours) /** * Method setUserColours @@ -675,14 +681,15 @@ public class JalviewModelSequence implements java.io.Serializable { * * @param userColoursArray */ - public void setUserColours(jalview.binding.UserColours[] 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) + } + //-- void setUserColours(jalview.binding.UserColours) /** * Method setViewport @@ -693,14 +700,15 @@ public class JalviewModelSequence implements java.io.Serializable { * @param vViewport */ public void setViewport(int index, jalview.binding.Viewport vViewport) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setViewport(int, jalview.binding.Viewport) /** * Method setViewport @@ -709,14 +717,15 @@ public class JalviewModelSequence implements java.io.Serializable { * * @param viewportArray */ - public void setViewport(jalview.binding.Viewport[] 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) + } + //-- void setViewport(jalview.binding.Viewport) /** * Method unmarshal @@ -727,20 +736,20 @@ public class JalviewModelSequence implements java.io.Serializable { * @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) + 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 - { + 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/JalviewModelSequence2.java b/src/jalview/binding/JalviewModelSequence2.java index 0cf1942..add536e 100755 --- a/src/jalview/binding/JalviewModelSequence2.java +++ b/src/jalview/binding/JalviewModelSequence2.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class JalviewModelSequence2 implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -59,33 +58,22 @@ public class JalviewModelSequence2 implements java.io.Serializable { */ private java.util.Vector _items; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JalviewModelSequence2() { super(); _items = new Vector(); - } //-- jalview.binding.JalviewModelSequence2() - + } + //-- jalview.binding.JalviewModelSequence2() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addJalviewModelSequence2Item - * - * - * - * @param vJalviewModelSequence2Item - */ - public void addJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) - throws java.lang.IndexOutOfBoundsException - { + 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 @@ -95,11 +83,12 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @param index * @param vJalviewModelSequence2Item */ - public void addJalviewModelSequence2Item(int index, jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) - throws java.lang.IndexOutOfBoundsException - { + 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 @@ -108,10 +97,10 @@ public class JalviewModelSequence2 implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateJalviewModelSequence2Item() - { + public java.util.Enumeration enumerateJalviewModelSequence2Item() { return _items.elements(); - } //-- java.util.Enumeration enumerateJalviewModelSequence2Item() + } + //-- java.util.Enumeration enumerateJalviewModelSequence2Item() /** * Method getJalviewModelSequence2Item @@ -121,16 +110,16 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @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())) { throw new IndexOutOfBoundsException(); } return (jalview.binding.JalviewModelSequence2Item) _items.elementAt(index); - } //-- jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item(int) + } + //-- jalview.binding.JalviewModelSequence2Item getJalviewModelSequence2Item(int) /** * Method getJalviewModelSequence2Item @@ -139,15 +128,17 @@ public class JalviewModelSequence2 implements java.io.Serializable { * * @return JalviewModelSequence2Item */ - public jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() - { + 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++) { mArray[index] = (jalview.binding.JalviewModelSequence2Item) _items.elementAt(index); } + return mArray; - } //-- jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() + } + //-- jalview.binding.JalviewModelSequence2Item[] getJalviewModelSequence2Item() /** * Method getJalviewModelSequence2ItemCount @@ -156,10 +147,10 @@ public class JalviewModelSequence2 implements java.io.Serializable { * * @return int */ - public int getJalviewModelSequence2ItemCount() - { + public int getJalviewModelSequence2ItemCount() { return _items.size(); - } //-- int getJalviewModelSequence2ItemCount() + } + //-- int getJalviewModelSequence2ItemCount() /** * Method isValid @@ -168,16 +159,16 @@ public class JalviewModelSequence2 implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -187,11 +178,11 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @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 @@ -201,20 +192,20 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @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() - { + public void removeAllJalviewModelSequence2Item() { _items.removeAllElements(); - } //-- void removeAllJalviewModelSequence2Item() + } + //-- void removeAllJalviewModelSequence2Item() /** * Method removeJalviewModelSequence2Item @@ -224,12 +215,14 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @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 @@ -239,15 +232,17 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @param index * @param vJalviewModelSequence2Item */ - public void setJalviewModelSequence2Item(int index, jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) - throws java.lang.IndexOutOfBoundsException - { + public void setJalviewModelSequence2Item(int index, + jalview.binding.JalviewModelSequence2Item vJalviewModelSequence2Item) + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -256,14 +251,16 @@ public class JalviewModelSequence2 implements java.io.Serializable { * * @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++) { _items.addElement(jalviewModelSequence2ItemArray[i]); } - } //-- void setJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) + } + //-- void setJalviewModelSequence2Item(jalview.binding.JalviewModelSequence2Item) /** * Method unmarshal @@ -274,20 +271,20 @@ public class JalviewModelSequence2 implements java.io.Serializable { * @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.JalviewModelSequence2) Unmarshaller.unmarshal(jalview.binding.JalviewModelSequence2.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 dcd3ebc..7998794 100755 --- a/src/jalview/binding/JalviewModelSequence2Item.java +++ b/src/jalview/binding/JalviewModelSequence2Item.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,18 +22,19 @@ * 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.binding; - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +//---------------------------------/ +//- 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; + /** * Class JalviewModelSequence2Item. @@ -42,10 +42,8 @@ import org.exolab.castor.xml.Unmarshaller; * @version $Revision$ $Date$ */ public class JalviewModelSequence2Item implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -53,33 +51,22 @@ public class JalviewModelSequence2Item implements java.io.Serializable { */ private java.util.Vector _userColourSchemeList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JalviewModelSequence2Item() { super(); _userColourSchemeList = new Vector(); - } //-- jalview.binding.JalviewModelSequence2Item() - + } + //-- jalview.binding.JalviewModelSequence2Item() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addUserColourScheme - * - * - * - * @param vUserColourScheme - */ - public void addUserColourScheme(jalview.binding.UserColourScheme vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { + public void addUserColourScheme( + jalview.binding.UserColourScheme vUserColourScheme) + throws java.lang.IndexOutOfBoundsException { _userColourSchemeList.addElement(vUserColourScheme); - } //-- void addUserColourScheme(jalview.binding.UserColourScheme) + } + //-- void addUserColourScheme(jalview.binding.UserColourScheme) /** * Method addUserColourScheme @@ -89,11 +76,12 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * @param index * @param vUserColourScheme */ - public void addUserColourScheme(int index, jalview.binding.UserColourScheme vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { + public void addUserColourScheme(int index, + jalview.binding.UserColourScheme vUserColourScheme) + throws java.lang.IndexOutOfBoundsException { _userColourSchemeList.insertElementAt(vUserColourScheme, index); - } //-- void addUserColourScheme(int, jalview.binding.UserColourScheme) + } + //-- void addUserColourScheme(int, jalview.binding.UserColourScheme) /** * Method enumerateUserColourScheme @@ -102,10 +90,10 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateUserColourScheme() - { + public java.util.Enumeration enumerateUserColourScheme() { return _userColourSchemeList.elements(); - } //-- java.util.Enumeration enumerateUserColourScheme() + } + //-- java.util.Enumeration enumerateUserColourScheme() /** * Method getUserColourScheme @@ -116,15 +104,15 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * @return UserColourScheme */ public jalview.binding.UserColourScheme getUserColourScheme(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.UserColourScheme getUserColourScheme(int) /** * Method getUserColourScheme @@ -133,15 +121,17 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * * @return UserColourScheme */ - public jalview.binding.UserColourScheme[] getUserColourScheme() - { + 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() + } + //-- jalview.binding.UserColourScheme[] getUserColourScheme() /** * Method getUserColourSchemeCount @@ -150,19 +140,19 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * * @return int */ - public int getUserColourSchemeCount() - { + public int getUserColourSchemeCount() { return _userColourSchemeList.size(); - } //-- int getUserColourSchemeCount() + } + //-- int getUserColourSchemeCount() /** * Method removeAllUserColourScheme * */ - public void removeAllUserColourScheme() - { + public void removeAllUserColourScheme() { _userColourSchemeList.removeAllElements(); - } //-- void removeAllUserColourScheme() + } + //-- void removeAllUserColourScheme() /** * Method removeUserColourScheme @@ -172,12 +162,13 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * @param index * @return UserColourScheme */ - public jalview.binding.UserColourScheme removeUserColourScheme(int index) - { + 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) + } + //-- jalview.binding.UserColourScheme removeUserColourScheme(int) /** * Method setUserColourScheme @@ -187,15 +178,17 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * @param index * @param vUserColourScheme */ - public void setUserColourScheme(int index, jalview.binding.UserColourScheme vUserColourScheme) - throws java.lang.IndexOutOfBoundsException - { + public void setUserColourScheme(int index, + jalview.binding.UserColourScheme vUserColourScheme) + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index if ((index < 0) || (index > _userColourSchemeList.size())) { throw new IndexOutOfBoundsException(); } + _userColourSchemeList.setElementAt(vUserColourScheme, index); - } //-- void setUserColourScheme(int, jalview.binding.UserColourScheme) + } + //-- void setUserColourScheme(int, jalview.binding.UserColourScheme) /** * Method setUserColourScheme @@ -204,13 +197,14 @@ public class JalviewModelSequence2Item implements java.io.Serializable { * * @param userColourSchemeArray */ - public void setUserColourScheme(jalview.binding.UserColourScheme[] userColourSchemeArray) - { + public void setUserColourScheme( + jalview.binding.UserColourScheme[] userColourSchemeArray) { //-- copy array _userColourSchemeList.removeAllElements(); + for (int i = 0; i < userColourSchemeArray.length; i++) { _userColourSchemeList.addElement(userColourSchemeArray[i]); } - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) - + } + //-- void setUserColourScheme(jalview.binding.UserColourScheme) } diff --git a/src/jalview/binding/JalviewUserColours.java b/src/jalview/binding/JalviewUserColours.java index 354dc2f..bbb1b97 100755 --- a/src/jalview/binding/JalviewUserColours.java +++ b/src/jalview/binding/JalviewUserColours.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class JalviewUserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -59,33 +58,21 @@ public class JalviewUserColours implements java.io.Serializable { */ private java.util.Vector _colourList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JalviewUserColours() { super(); _colourList = new Vector(); - } //-- jalview.binding.JalviewUserColours() - + } + //-- jalview.binding.JalviewUserColours() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addColour - * - * - * - * @param vColour - */ public void addColour(jalview.binding.Colour vColour) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _colourList.addElement(vColour); - } //-- void addColour(jalview.binding.Colour) + } + //-- void addColour(jalview.binding.Colour) /** * Method addColour @@ -96,10 +83,10 @@ public class JalviewUserColours implements java.io.Serializable { * @param vColour */ public void addColour(int index, jalview.binding.Colour vColour) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _colourList.insertElementAt(vColour, index); - } //-- void addColour(int, jalview.binding.Colour) + } + //-- void addColour(int, jalview.binding.Colour) /** * Method enumerateColour @@ -108,10 +95,10 @@ public class JalviewUserColours implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateColour() - { + public java.util.Enumeration enumerateColour() { return _colourList.elements(); - } //-- java.util.Enumeration enumerateColour() + } + //-- java.util.Enumeration enumerateColour() /** * Method getColour @@ -122,15 +109,15 @@ public class JalviewUserColours implements java.io.Serializable { * @return Colour */ public jalview.binding.Colour getColour(int index) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -139,15 +126,17 @@ public class JalviewUserColours implements java.io.Serializable { * * @return Colour */ - public jalview.binding.Colour[] getColour() - { + 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++) { mArray[index] = (jalview.binding.Colour) _colourList.elementAt(index); } + return mArray; - } //-- jalview.binding.Colour[] getColour() + } + //-- jalview.binding.Colour[] getColour() /** * Method getColourCount @@ -156,10 +145,10 @@ public class JalviewUserColours implements java.io.Serializable { * * @return int */ - public int getColourCount() - { + public int getColourCount() { return _colourList.size(); - } //-- int getColourCount() + } + //-- int getColourCount() /** * Method isValid @@ -168,16 +157,16 @@ public class JalviewUserColours implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -187,11 +176,11 @@ public class JalviewUserColours implements java.io.Serializable { * @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 @@ -201,20 +190,20 @@ public class JalviewUserColours implements java.io.Serializable { * @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() - { + public void removeAllColour() { _colourList.removeAllElements(); - } //-- void removeAllColour() + } + //-- void removeAllColour() /** * Method removeColour @@ -224,12 +213,13 @@ public class JalviewUserColours implements java.io.Serializable { * @param index * @return Colour */ - public jalview.binding.Colour removeColour(int index) - { + public jalview.binding.Colour removeColour(int index) { 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 @@ -240,14 +230,15 @@ public class JalviewUserColours implements java.io.Serializable { * @param vColour */ public void setColour(int index, jalview.binding.Colour vColour) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -256,14 +247,15 @@ public class JalviewUserColours implements java.io.Serializable { * * @param colourArray */ - public void setColour(jalview.binding.Colour[] colourArray) - { + public void setColour(jalview.binding.Colour[] colourArray) { //-- copy array _colourList.removeAllElements(); + for (int i = 0; i < colourArray.length; i++) { _colourList.addElement(colourArray[i]); } - } //-- void setColour(jalview.binding.Colour) + } + //-- void setColour(jalview.binding.Colour) /** * Method unmarshal @@ -274,20 +266,20 @@ public class JalviewUserColours implements java.io.Serializable { * @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.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 b7abdc5..ae96562 100755 --- a/src/jalview/binding/JalviewUserColoursItem.java +++ b/src/jalview/binding/JalviewUserColoursItem.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,27 +22,25 @@ * 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.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 -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -51,39 +48,27 @@ public class JalviewUserColoursItem implements java.io.Serializable { */ private jalview.binding.Colour _colour; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public JalviewUserColoursItem() { super(); - } //-- jalview.binding.JalviewUserColoursItem() - + } + //-- jalview.binding.JalviewUserColoursItem() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'colour'. - * - * @return Colour - * @return the value of field 'colour'. - */ - public jalview.binding.Colour getColour() - { + 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) - { + 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 9e68130..ff0cb63 100755 --- a/src/jalview/binding/Residue.java +++ b/src/jalview/binding/Residue.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 Residue. * * @version $Revision$ $Date$ */ public class Residue implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -67,28 +65,19 @@ public class Residue implements java.io.Serializable { */ private boolean _has_RGB; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public Residue() { super(); - } //-- jalview.binding.Residue() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.Residue() + //-----------/ - /** - * Method deleteRGB - * - */ - public void deleteRGB() - { - this._has_RGB= false; - } //-- void deleteRGB() + public void deleteRGB() { + this._has_RGB = false; + } + //-- void deleteRGB() /** * Returns the value of field 'name'. @@ -96,10 +85,10 @@ public class Residue implements java.io.Serializable { * @return String * @return the value of field 'name'. */ - public java.lang.String getName() - { + public java.lang.String getName() { return this._name; - } //-- java.lang.String getName() + } + //-- java.lang.String getName() /** * Returns the value of field 'RGB'. @@ -107,10 +96,10 @@ public class Residue implements java.io.Serializable { * @return int * @return the value of field 'RGB'. */ - public int getRGB() - { + public int getRGB() { return this._RGB; - } //-- int getRGB() + } + //-- int getRGB() /** * Method hasRGB @@ -119,10 +108,10 @@ public class Residue implements java.io.Serializable { * * @return boolean */ - public boolean hasRGB() - { + public boolean hasRGB() { return this._has_RGB; - } //-- boolean hasRGB() + } + //-- boolean hasRGB() /** * Method isValid @@ -131,16 +120,16 @@ public class Residue implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -150,11 +139,11 @@ public class Residue implements java.io.Serializable { * @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 @@ -164,32 +153,32 @@ public class Residue implements java.io.Serializable { * @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) - { + 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(int RGB) - { + public void setRGB(int RGB) { this._RGB = RGB; this._has_RGB = true; - } //-- void setRGB(int) + } + //-- void setRGB(int) /** * Method unmarshal @@ -200,20 +189,20 @@ public class Residue implements java.io.Serializable { * @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) + 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 - { + 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/Sequence.java b/src/jalview/binding/Sequence.java index 290354e..628e209 100755 --- a/src/jalview/binding/Sequence.java +++ b/src/jalview/binding/Sequence.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,63 +22,49 @@ * 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.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 Sequence. * * @version $Revision$ $Date$ */ -public class Sequence extends SequenceType -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ +public class Sequence extends SequenceType implements java.io.Serializable { + //----------------/ + //- Constructors -/ //----------------/ - public Sequence() { super(); - } //-- jalview.binding.Sequence() + } + //-- jalview.binding.Sequence() + //-----------/ - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -89,11 +74,11 @@ implements java.io.Serializable * @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 @@ -103,11 +88,11 @@ implements java.io.Serializable * @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 @@ -118,20 +103,20 @@ implements java.io.Serializable * @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) + 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 - { + 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/SequenceSet.java b/src/jalview/binding/SequenceSet.java index 7ef5fe7..4300c39 100755 --- a/src/jalview/binding/SequenceSet.java +++ b/src/jalview/binding/SequenceSet.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class SequenceSet implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -79,34 +78,22 @@ public class SequenceSet implements java.io.Serializable { */ private java.util.Vector _annotationList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public SequenceSet() { super(); _sequenceList = new Vector(); _annotationList = new Vector(); - } //-- jalview.binding.SequenceSet() + } + //-- jalview.binding.SequenceSet() + //-----------/ - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addAnnotation - * - * - * - * @param vAnnotation - */ public void addAnnotation(jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _annotationList.addElement(vAnnotation); - } //-- void addAnnotation(jalview.binding.Annotation) + } + //-- void addAnnotation(jalview.binding.Annotation) /** * Method addAnnotation @@ -117,10 +104,10 @@ public class SequenceSet implements java.io.Serializable { * @param vAnnotation */ public void addAnnotation(int index, jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _annotationList.insertElementAt(vAnnotation, index); - } //-- void addAnnotation(int, jalview.binding.Annotation) + } + //-- void addAnnotation(int, jalview.binding.Annotation) /** * Method addSequence @@ -130,10 +117,10 @@ public class SequenceSet implements java.io.Serializable { * @param vSequence */ public void addSequence(jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _sequenceList.addElement(vSequence); - } //-- void addSequence(jalview.binding.Sequence) + } + //-- void addSequence(jalview.binding.Sequence) /** * Method addSequence @@ -144,19 +131,19 @@ public class SequenceSet implements java.io.Serializable { * @param vSequence */ public void addSequence(int index, jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException - { + 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() + public void deleteAligned() { + this._has_aligned = false; + } + //-- void deleteAligned() /** * Method enumerateAnnotation @@ -165,10 +152,10 @@ public class SequenceSet implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateAnnotation() - { + public java.util.Enumeration enumerateAnnotation() { return _annotationList.elements(); - } //-- java.util.Enumeration enumerateAnnotation() + } + //-- java.util.Enumeration enumerateAnnotation() /** * Method enumerateSequence @@ -177,10 +164,10 @@ public class SequenceSet implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateSequence() - { + public java.util.Enumeration enumerateSequence() { return _sequenceList.elements(); - } //-- java.util.Enumeration enumerateSequence() + } + //-- java.util.Enumeration enumerateSequence() /** * Returns the value of field 'aligned'. @@ -188,10 +175,10 @@ public class SequenceSet implements java.io.Serializable { * @return boolean * @return the value of field 'aligned'. */ - public boolean getAligned() - { + public boolean getAligned() { return this._aligned; - } //-- boolean getAligned() + } + //-- boolean getAligned() /** * Method getAnnotation @@ -202,15 +189,15 @@ public class SequenceSet implements java.io.Serializable { * @return Annotation */ public jalview.binding.Annotation getAnnotation(int index) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -219,15 +206,17 @@ public class SequenceSet implements java.io.Serializable { * * @return Annotation */ - public jalview.binding.Annotation[] getAnnotation() - { + 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++) { mArray[index] = (jalview.binding.Annotation) _annotationList.elementAt(index); } + return mArray; - } //-- jalview.binding.Annotation[] getAnnotation() + } + //-- jalview.binding.Annotation[] getAnnotation() /** * Method getAnnotationCount @@ -236,10 +225,10 @@ public class SequenceSet implements java.io.Serializable { * * @return int */ - public int getAnnotationCount() - { + public int getAnnotationCount() { return _annotationList.size(); - } //-- int getAnnotationCount() + } + //-- int getAnnotationCount() /** * Returns the value of field 'gapChar'. @@ -247,10 +236,10 @@ public class SequenceSet implements java.io.Serializable { * @return String * @return the value of field 'gapChar'. */ - public java.lang.String getGapChar() - { + public java.lang.String getGapChar() { return this._gapChar; - } //-- java.lang.String getGapChar() + } + //-- java.lang.String getGapChar() /** * Method getSequence @@ -261,15 +250,15 @@ public class SequenceSet implements java.io.Serializable { * @return Sequence */ public jalview.binding.Sequence getSequence(int index) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -278,15 +267,17 @@ public class SequenceSet implements java.io.Serializable { * * @return Sequence */ - public jalview.binding.Sequence[] getSequence() - { + 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++) { mArray[index] = (jalview.binding.Sequence) _sequenceList.elementAt(index); } + return mArray; - } //-- jalview.binding.Sequence[] getSequence() + } + //-- jalview.binding.Sequence[] getSequence() /** * Method getSequenceCount @@ -295,10 +286,10 @@ public class SequenceSet implements java.io.Serializable { * * @return int */ - public int getSequenceCount() - { + public int getSequenceCount() { return _sequenceList.size(); - } //-- int getSequenceCount() + } + //-- int getSequenceCount() /** * Method hasAligned @@ -307,10 +298,10 @@ public class SequenceSet implements java.io.Serializable { * * @return boolean */ - public boolean hasAligned() - { + public boolean hasAligned() { return this._has_aligned; - } //-- boolean hasAligned() + } + //-- boolean hasAligned() /** * Method isValid @@ -319,16 +310,16 @@ public class SequenceSet implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -338,11 +329,11 @@ public class SequenceSet implements java.io.Serializable { * @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 @@ -352,29 +343,29 @@ public class SequenceSet implements java.io.Serializable { * @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() - { + public void removeAllAnnotation() { _annotationList.removeAllElements(); - } //-- void removeAllAnnotation() + } + //-- void removeAllAnnotation() /** * Method removeAllSequence * */ - public void removeAllSequence() - { + public void removeAllSequence() { _sequenceList.removeAllElements(); - } //-- void removeAllSequence() + } + //-- void removeAllSequence() /** * Method removeAnnotation @@ -384,12 +375,13 @@ public class SequenceSet implements java.io.Serializable { * @param index * @return Annotation */ - public jalview.binding.Annotation removeAnnotation(int index) - { + public jalview.binding.Annotation removeAnnotation(int index) { 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 @@ -399,23 +391,24 @@ public class SequenceSet implements java.io.Serializable { * @param index * @return Sequence */ - public jalview.binding.Sequence removeSequence(int index) - { + public jalview.binding.Sequence removeSequence(int index) { 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) - { + public void setAligned(boolean aligned) { this._aligned = aligned; this._has_aligned = true; - } //-- void setAligned(boolean) + } + //-- void setAligned(boolean) /** * Method setAnnotation @@ -426,14 +419,15 @@ public class SequenceSet implements java.io.Serializable { * @param vAnnotation */ public void setAnnotation(int index, jalview.binding.Annotation vAnnotation) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -442,24 +436,25 @@ public class SequenceSet implements java.io.Serializable { * * @param annotationArray */ - public void setAnnotation(jalview.binding.Annotation[] annotationArray) - { + public void setAnnotation(jalview.binding.Annotation[] annotationArray) { //-- copy array _annotationList.removeAllElements(); + 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) - { + public void setGapChar(java.lang.String gapChar) { this._gapChar = gapChar; - } //-- void setGapChar(java.lang.String) + } + //-- void setGapChar(java.lang.String) /** * Method setSequence @@ -470,14 +465,15 @@ public class SequenceSet implements java.io.Serializable { * @param vSequence */ public void setSequence(int index, jalview.binding.Sequence vSequence) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { //-- check bounds for index 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 @@ -486,14 +482,15 @@ public class SequenceSet implements java.io.Serializable { * * @param sequenceArray */ - public void setSequence(jalview.binding.Sequence[] sequenceArray) - { + public void setSequence(jalview.binding.Sequence[] sequenceArray) { //-- copy array _sequenceList.removeAllElements(); + for (int i = 0; i < sequenceArray.length; i++) { _sequenceList.addElement(sequenceArray[i]); } - } //-- void setSequence(jalview.binding.Sequence) + } + //-- void setSequence(jalview.binding.Sequence) /** * Method unmarshal @@ -504,20 +501,20 @@ public class SequenceSet implements java.io.Serializable { * @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.SequenceSet) Unmarshaller.unmarshal(jalview.binding.SequenceSet.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 bf560bb..6060e77 100755 --- a/src/jalview/binding/SequenceType.java +++ b/src/jalview/binding/SequenceType.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 SequenceType. * * @version $Revision$ $Date$ */ public class SequenceType implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -67,30 +65,19 @@ public class SequenceType implements java.io.Serializable { */ private java.lang.String _name; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public SequenceType() { super(); - } //-- jalview.binding.SequenceType() - + } + //-- jalview.binding.SequenceType() + //-----------/ - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Returns the value of field 'id'. - * - * @return String - * @return the value of field 'id'. - */ - public java.lang.String getId() - { + public java.lang.String getId() { return this._id; - } //-- java.lang.String getId() + } + //-- java.lang.String getId() /** * Returns the value of field 'name'. @@ -98,10 +85,10 @@ public class SequenceType implements java.io.Serializable { * @return String * @return the value of field 'name'. */ - public java.lang.String getName() - { + public java.lang.String getName() { return this._name; - } //-- java.lang.String getName() + } + //-- java.lang.String getName() /** * Returns the value of field 'sequence'. @@ -109,10 +96,10 @@ public class SequenceType implements java.io.Serializable { * @return String * @return the value of field 'sequence'. */ - public java.lang.String getSequence() - { + public java.lang.String getSequence() { return this._sequence; - } //-- java.lang.String getSequence() + } + //-- java.lang.String getSequence() /** * Method isValid @@ -121,16 +108,16 @@ public class SequenceType implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -140,11 +127,11 @@ public class SequenceType implements java.io.Serializable { * @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 @@ -154,41 +141,41 @@ public class SequenceType implements java.io.Serializable { * @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 'id'. * * @param id the value of field 'id'. */ - public void setId(java.lang.String id) - { + public void setId(java.lang.String id) { this._id = id; - } //-- void setId(java.lang.String) + } + //-- 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) - { + 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 'sequence'. * * @param sequence the value of field 'sequence'. */ - public void setSequence(java.lang.String sequence) - { + public void setSequence(java.lang.String sequence) { this._sequence = sequence; - } //-- void setSequence(java.lang.String) + } + //-- void setSequence(java.lang.String) /** * Method unmarshal @@ -199,20 +186,20 @@ public class SequenceType implements java.io.Serializable { * @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) + 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 - { + 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 fba081c..3ecb7bc 100755 --- a/src/jalview/binding/UserColour.java +++ b/src/jalview/binding/UserColour.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 UserColour. * * @version $Revision$ $Date$ */ public class UserColour implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -67,28 +65,19 @@ public class UserColour implements java.io.Serializable { */ private jalview.binding.UserColourScheme _userColourScheme; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public UserColour() { super(); - } //-- jalview.binding.UserColour() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.UserColour() + //-----------/ - /** - * Method deleteId - * - */ - public void deleteId() - { - this._has_id= false; - } //-- void deleteId() + public void deleteId() { + this._has_id = false; + } + //-- void deleteId() /** * Returns the value of field 'id'. @@ -96,10 +85,10 @@ public class UserColour implements java.io.Serializable { * @return int * @return the value of field 'id'. */ - public int getId() - { + public int getId() { return this._id; - } //-- int getId() + } + //-- int getId() /** * Returns the value of field 'userColourScheme'. @@ -107,10 +96,10 @@ public class UserColour implements java.io.Serializable { * @return UserColourScheme * @return the value of field 'userColourScheme'. */ - public jalview.binding.UserColourScheme getUserColourScheme() - { + public jalview.binding.UserColourScheme getUserColourScheme() { return this._userColourScheme; - } //-- jalview.binding.UserColourScheme getUserColourScheme() + } + //-- jalview.binding.UserColourScheme getUserColourScheme() /** * Method hasId @@ -119,10 +108,10 @@ public class UserColour implements java.io.Serializable { * * @return boolean */ - public boolean hasId() - { + public boolean hasId() { return this._has_id; - } //-- boolean hasId() + } + //-- boolean hasId() /** * Method isValid @@ -131,16 +120,16 @@ public class UserColour implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -150,11 +139,11 @@ public class UserColour implements java.io.Serializable { * @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 @@ -164,32 +153,33 @@ public class UserColour implements java.io.Serializable { * @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 'id'. * * @param id the value of field 'id'. */ - public void setId(int id) - { + public void setId(int id) { this._id = id; this._has_id = true; - } //-- void setId(int) + } + //-- void setId(int) /** * Sets the value of field 'userColourScheme'. * * @param userColourScheme the value of field 'userColourScheme' */ - public void setUserColourScheme(jalview.binding.UserColourScheme userColourScheme) - { + public void setUserColourScheme( + jalview.binding.UserColourScheme userColourScheme) { this._userColourScheme = userColourScheme; - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) + } + //-- void setUserColourScheme(jalview.binding.UserColourScheme) /** * Method unmarshal @@ -200,20 +190,20 @@ public class UserColour implements java.io.Serializable { * @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) + 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 - { + 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/UserColourScheme.java b/src/jalview/binding/UserColourScheme.java index f8c2fdb..e66e468 100755 --- a/src/jalview/binding/UserColourScheme.java +++ b/src/jalview/binding/UserColourScheme.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,63 +22,50 @@ * 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.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 UserColourScheme. * * @version $Revision$ $Date$ */ public class UserColourScheme extends JalviewUserColours -implements java.io.Serializable -{ - - - //----------------/ - //- Constructors -/ + implements java.io.Serializable { + //----------------/ + //- Constructors -/ //----------------/ - public UserColourScheme() { super(); - } //-- jalview.binding.UserColourScheme() + } + //-- jalview.binding.UserColourScheme() + //-----------/ - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -89,11 +75,11 @@ implements java.io.Serializable * @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 @@ -103,11 +89,11 @@ implements java.io.Serializable * @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 @@ -118,20 +104,20 @@ implements java.io.Serializable * @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) + 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 - { + 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/UserColours.java b/src/jalview/binding/UserColours.java index 2c4e91b..2dbffc1 100755 --- a/src/jalview/binding/UserColours.java +++ b/src/jalview/binding/UserColours.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,33 +22,32 @@ * 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.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 UserColours. * * @version $Revision$ $Date$ */ public class UserColours implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -62,30 +60,19 @@ public class UserColours implements java.io.Serializable { */ private jalview.binding.UserColourScheme _userColourScheme; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public UserColours() { super(); - } //-- jalview.binding.UserColours() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.UserColours() + //-----------/ - /** - * Returns the value of field 'id'. - * - * @return String - * @return the value of field 'id'. - */ - public java.lang.String getId() - { + public java.lang.String getId() { return this._id; - } //-- java.lang.String getId() + } + //-- java.lang.String getId() /** * Returns the value of field 'userColourScheme'. @@ -93,10 +80,10 @@ public class UserColours implements java.io.Serializable { * @return UserColourScheme * @return the value of field 'userColourScheme'. */ - public jalview.binding.UserColourScheme getUserColourScheme() - { + public jalview.binding.UserColourScheme getUserColourScheme() { return this._userColourScheme; - } //-- jalview.binding.UserColourScheme getUserColourScheme() + } + //-- jalview.binding.UserColourScheme getUserColourScheme() /** * Method isValid @@ -105,16 +92,16 @@ public class UserColours implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -124,11 +111,11 @@ public class UserColours implements java.io.Serializable { * @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 @@ -138,31 +125,32 @@ public class UserColours implements java.io.Serializable { * @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 'id'. * * @param id the value of field 'id'. */ - public void setId(java.lang.String id) - { + public void setId(java.lang.String id) { this._id = id; - } //-- void setId(java.lang.String) + } + //-- 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) - { + public void setUserColourScheme( + jalview.binding.UserColourScheme userColourScheme) { this._userColourScheme = userColourScheme; - } //-- void setUserColourScheme(jalview.binding.UserColourScheme) + } + //-- void setUserColourScheme(jalview.binding.UserColourScheme) /** * Method unmarshal @@ -173,20 +161,20 @@ public class UserColours implements java.io.Serializable { * @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) + 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 - { + 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/VAMSAS.java b/src/jalview/binding/VAMSAS.java index 2190b2f..5bc9b12 100755 --- a/src/jalview/binding/VAMSAS.java +++ b/src/jalview/binding/VAMSAS.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,24 +22,26 @@ * 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.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 VAMSAS. @@ -48,10 +49,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class VAMSAS implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -69,35 +68,23 @@ public class VAMSAS implements java.io.Serializable { */ private java.util.Vector _sequenceSetList; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public VAMSAS() { super(); _alignmentList = new Vector(); _treeList = new Vector(); _sequenceSetList = new Vector(); - } //-- jalview.binding.VAMSAS() + } + //-- jalview.binding.VAMSAS() + //-----------/ - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method addAlignment - * - * - * - * @param vAlignment - */ public void addAlignment(jalview.binding.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _alignmentList.addElement(vAlignment); - } //-- void addAlignment(jalview.binding.Alignment) + } + //-- void addAlignment(jalview.binding.Alignment) /** * Method addAlignment @@ -108,10 +95,10 @@ public class VAMSAS implements java.io.Serializable { * @param vAlignment */ public void addAlignment(int index, jalview.binding.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _alignmentList.insertElementAt(vAlignment, index); - } //-- void addAlignment(int, jalview.binding.Alignment) + } + //-- void addAlignment(int, jalview.binding.Alignment) /** * Method addSequenceSet @@ -121,10 +108,10 @@ public class VAMSAS implements java.io.Serializable { * @param vSequenceSet */ public void addSequenceSet(jalview.binding.SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _sequenceSetList.addElement(vSequenceSet); - } //-- void addSequenceSet(jalview.binding.SequenceSet) + } + //-- void addSequenceSet(jalview.binding.SequenceSet) /** * Method addSequenceSet @@ -134,11 +121,12 @@ public class VAMSAS implements java.io.Serializable { * @param index * @param vSequenceSet */ - public void addSequenceSet(int index, jalview.binding.SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException - { + public void addSequenceSet(int index, + jalview.binding.SequenceSet vSequenceSet) + throws java.lang.IndexOutOfBoundsException { _sequenceSetList.insertElementAt(vSequenceSet, index); - } //-- void addSequenceSet(int, jalview.binding.SequenceSet) + } + //-- void addSequenceSet(int, jalview.binding.SequenceSet) /** * Method addTree @@ -148,10 +136,10 @@ public class VAMSAS implements java.io.Serializable { * @param vTree */ public void addTree(java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _treeList.addElement(vTree); - } //-- void addTree(java.lang.String) + } + //-- void addTree(java.lang.String) /** * Method addTree @@ -162,10 +150,10 @@ public class VAMSAS implements java.io.Serializable { * @param vTree */ public void addTree(int index, java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException - { + throws java.lang.IndexOutOfBoundsException { _treeList.insertElementAt(vTree, index); - } //-- void addTree(int, java.lang.String) + } + //-- void addTree(int, java.lang.String) /** * Method enumerateAlignment @@ -174,10 +162,10 @@ public class VAMSAS implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateAlignment() - { + public java.util.Enumeration enumerateAlignment() { return _alignmentList.elements(); - } //-- java.util.Enumeration enumerateAlignment() + } + //-- java.util.Enumeration enumerateAlignment() /** * Method enumerateSequenceSet @@ -186,10 +174,10 @@ public class VAMSAS implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateSequenceSet() - { + public java.util.Enumeration enumerateSequenceSet() { return _sequenceSetList.elements(); - } //-- java.util.Enumeration enumerateSequenceSet() + } + //-- java.util.Enumeration enumerateSequenceSet() /** * Method enumerateTree @@ -198,10 +186,10 @@ public class VAMSAS implements java.io.Serializable { * * @return Enumeration */ - public java.util.Enumeration enumerateTree() - { + public java.util.Enumeration enumerateTree() { return _treeList.elements(); - } //-- java.util.Enumeration enumerateTree() + } + //-- java.util.Enumeration enumerateTree() /** * Method getAlignment @@ -212,15 +200,15 @@ public class VAMSAS implements java.io.Serializable { * @return Alignment */ public jalview.binding.Alignment getAlignment(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.Alignment getAlignment(int) /** * Method getAlignment @@ -229,15 +217,17 @@ public class VAMSAS implements java.io.Serializable { * * @return Alignment */ - public jalview.binding.Alignment[] getAlignment() - { + 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() + } + //-- jalview.binding.Alignment[] getAlignment() /** * Method getAlignmentCount @@ -246,10 +236,10 @@ public class VAMSAS implements java.io.Serializable { * * @return int */ - public int getAlignmentCount() - { + public int getAlignmentCount() { return _alignmentList.size(); - } //-- int getAlignmentCount() + } + //-- int getAlignmentCount() /** * Method getSequenceSet @@ -260,15 +250,15 @@ public class VAMSAS implements java.io.Serializable { * @return SequenceSet */ public jalview.binding.SequenceSet getSequenceSet(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- jalview.binding.SequenceSet getSequenceSet(int) /** * Method getSequenceSet @@ -277,15 +267,17 @@ public class VAMSAS implements java.io.Serializable { * * @return SequenceSet */ - public jalview.binding.SequenceSet[] getSequenceSet() - { + 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() + } + //-- jalview.binding.SequenceSet[] getSequenceSet() /** * Method getSequenceSetCount @@ -294,10 +286,10 @@ public class VAMSAS implements java.io.Serializable { * * @return int */ - public int getSequenceSetCount() - { + public int getSequenceSetCount() { return _sequenceSetList.size(); - } //-- int getSequenceSetCount() + } + //-- int getSequenceSetCount() /** * Method getTree @@ -308,15 +300,15 @@ public class VAMSAS implements java.io.Serializable { * @return String */ public java.lang.String getTree(int index) - throws java.lang.IndexOutOfBoundsException - { + 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) + return (String) _treeList.elementAt(index); + } + //-- java.lang.String getTree(int) /** * Method getTree @@ -325,15 +317,17 @@ public class VAMSAS implements java.io.Serializable { * * @return String */ - public java.lang.String[] getTree() - { + 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); + mArray[index] = (String) _treeList.elementAt(index); } + return mArray; - } //-- java.lang.String[] getTree() + } + //-- java.lang.String[] getTree() /** * Method getTreeCount @@ -342,10 +336,10 @@ public class VAMSAS implements java.io.Serializable { * * @return int */ - public int getTreeCount() - { + public int getTreeCount() { return _treeList.size(); - } //-- int getTreeCount() + } + //-- int getTreeCount() /** * Method isValid @@ -354,16 +348,16 @@ public class VAMSAS implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -373,11 +367,11 @@ public class VAMSAS implements java.io.Serializable { * @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 @@ -387,11 +381,11 @@ public class VAMSAS implements java.io.Serializable { * @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 removeAlignment @@ -401,39 +395,40 @@ public class VAMSAS implements java.io.Serializable { * @param index * @return Alignment */ - public jalview.binding.Alignment removeAlignment(int index) - { + 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) + } + //-- jalview.binding.Alignment removeAlignment(int) /** * Method removeAllAlignment * */ - public void removeAllAlignment() - { + public void removeAllAlignment() { _alignmentList.removeAllElements(); - } //-- void removeAllAlignment() + } + //-- void removeAllAlignment() /** * Method removeAllSequenceSet * */ - public void removeAllSequenceSet() - { + public void removeAllSequenceSet() { _sequenceSetList.removeAllElements(); - } //-- void removeAllSequenceSet() + } + //-- void removeAllSequenceSet() /** * Method removeAllTree * */ - public void removeAllTree() - { + public void removeAllTree() { _treeList.removeAllElements(); - } //-- void removeAllTree() + } + //-- void removeAllTree() /** * Method removeSequenceSet @@ -443,12 +438,13 @@ public class VAMSAS implements java.io.Serializable { * @param index * @return SequenceSet */ - public jalview.binding.SequenceSet removeSequenceSet(int index) - { + 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) + } + //-- jalview.binding.SequenceSet removeSequenceSet(int) /** * Method removeTree @@ -458,12 +454,13 @@ public class VAMSAS implements java.io.Serializable { * @param index * @return String */ - public java.lang.String removeTree(int index) - { + 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) + + return (String) obj; + } + //-- java.lang.String removeTree(int) /** * Method setAlignment @@ -474,14 +471,15 @@ public class VAMSAS implements java.io.Serializable { * @param vAlignment */ public void setAlignment(int index, jalview.binding.Alignment vAlignment) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setAlignment(int, jalview.binding.Alignment) /** * Method setAlignment @@ -490,14 +488,15 @@ public class VAMSAS implements java.io.Serializable { * * @param alignmentArray */ - public void setAlignment(jalview.binding.Alignment[] 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) + } + //-- void setAlignment(jalview.binding.Alignment) /** * Method setSequenceSet @@ -507,15 +506,17 @@ public class VAMSAS implements java.io.Serializable { * @param index * @param vSequenceSet */ - public void setSequenceSet(int index, jalview.binding.SequenceSet vSequenceSet) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setSequenceSet(int, jalview.binding.SequenceSet) /** * Method setSequenceSet @@ -524,14 +525,15 @@ public class VAMSAS implements java.io.Serializable { * * @param sequenceSetArray */ - public void setSequenceSet(jalview.binding.SequenceSet[] 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) + } + //-- void setSequenceSet(jalview.binding.SequenceSet) /** * Method setTree @@ -542,14 +544,15 @@ public class VAMSAS implements java.io.Serializable { * @param vTree */ public void setTree(int index, java.lang.String vTree) - throws java.lang.IndexOutOfBoundsException - { + 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) + } + //-- void setTree(int, java.lang.String) /** * Method setTree @@ -558,14 +561,15 @@ public class VAMSAS implements java.io.Serializable { * * @param treeArray */ - public void setTree(java.lang.String[] 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) + } + //-- void setTree(java.lang.String) /** * Method unmarshal @@ -576,20 +580,20 @@ public class VAMSAS implements java.io.Serializable { * @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) + 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 - { + 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/VamsasModel.java b/src/jalview/binding/VamsasModel.java index 4133b84..f802039 100755 --- a/src/jalview/binding/VamsasModel.java +++ b/src/jalview/binding/VamsasModel.java @@ -4,7 +4,6 @@ * Schema. * $Id$ */ - /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -23,63 +22,49 @@ * 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.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 -{ - - - //----------------/ - //- Constructors -/ +public class VamsasModel extends VAMSAS implements java.io.Serializable { + //----------------/ + //- Constructors -/ //----------------/ - public VamsasModel() { super(); - } //-- jalview.binding.VamsasModel() + } + //-- jalview.binding.VamsasModel() + //-----------/ - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -89,11 +74,11 @@ implements java.io.Serializable * @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 @@ -103,11 +88,11 @@ implements java.io.Serializable * @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 @@ -118,20 +103,20 @@ implements java.io.Serializable * @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.VamsasModel) Unmarshaller.unmarshal(jalview.binding.VamsasModel.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) + 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) /** * 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 99dbd1b..8bdee5d 100755 --- a/src/jalview/binding/Viewport.java +++ b/src/jalview/binding/Viewport.java @@ -16,30 +16,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - /* * This class was automatically generated with * Castor 0.9.6, using an XML * Schema. * $Id$ */ +package jalview.binding; +import org.exolab.castor.xml.MarshalException; +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.exolab.castor.xml.ValidationException; -package jalview.binding; +import org.xml.sax.ContentHandler; - //---------------------------------/ - //- 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; + /** * Class Viewport. @@ -47,10 +46,8 @@ import org.xml.sax.ContentHandler; * @version $Revision$ $Date$ */ public class Viewport implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ + //--------------------------/ + //- Class/Member Variables -/ //--------------------------/ /** @@ -298,226 +295,217 @@ public class Viewport implements java.io.Serializable { */ private boolean _has_fontStyle; - - //----------------/ - //- Constructors -/ //----------------/ - + //- Constructors -/ + //----------------/ public Viewport() { super(); - } //-- jalview.binding.Viewport() - - - //-----------/ - //- Methods -/ - //-----------/ + } + //-- jalview.binding.Viewport() + //-----------/ - /** - * Method deleteConsThreshold - * - */ - public void deleteConsThreshold() - { - this._has_consThreshold= false; - } //-- void deleteConsThreshold() + public void deleteConsThreshold() { + this._has_consThreshold = false; + } + //-- void deleteConsThreshold() /** * Method deleteConservationSelected * */ - public void deleteConservationSelected() - { - this._has_conservationSelected= false; - } //-- void deleteConservationSelected() + public void deleteConservationSelected() { + this._has_conservationSelected = false; + } + //-- void deleteConservationSelected() /** * Method deleteFontSize * */ - public void deleteFontSize() - { - this._has_fontSize= false; - } //-- void deleteFontSize() + public void deleteFontSize() { + this._has_fontSize = false; + } + //-- void deleteFontSize() /** * Method deleteFontStyle * */ - public void deleteFontStyle() - { - this._has_fontStyle= false; - } //-- void deleteFontStyle() + public void deleteFontStyle() { + this._has_fontStyle = false; + } + //-- void deleteFontStyle() /** * Method deleteHeight * */ - public void deleteHeight() - { - this._has_height= false; - } //-- void deleteHeight() + public void deleteHeight() { + this._has_height = false; + } + //-- void deleteHeight() /** * Method deletePidSelected * */ - public void deletePidSelected() - { - this._has_pidSelected= false; - } //-- void deletePidSelected() + public void deletePidSelected() { + this._has_pidSelected = false; + } + //-- void deletePidSelected() /** * Method deletePidThreshold * */ - public void deletePidThreshold() - { - this._has_pidThreshold= false; - } //-- void deletePidThreshold() + public void deletePidThreshold() { + this._has_pidThreshold = false; + } + //-- void deletePidThreshold() /** * Method deleteRenderGaps * */ - public void deleteRenderGaps() - { - this._has_renderGaps= false; - } //-- void deleteRenderGaps() + public void deleteRenderGaps() { + this._has_renderGaps = false; + } + //-- void deleteRenderGaps() /** * Method deleteShowAnnotation * */ - public void deleteShowAnnotation() - { - this._has_showAnnotation= false; - } //-- void deleteShowAnnotation() + public void deleteShowAnnotation() { + this._has_showAnnotation = false; + } + //-- void deleteShowAnnotation() /** * Method deleteShowBoxes * */ - public void deleteShowBoxes() - { - this._has_showBoxes= false; - } //-- void deleteShowBoxes() + public void deleteShowBoxes() { + this._has_showBoxes = false; + } + //-- void deleteShowBoxes() /** * Method deleteShowColourText * */ - public void deleteShowColourText() - { - this._has_showColourText= false; - } //-- void deleteShowColourText() + public void deleteShowColourText() { + this._has_showColourText = false; + } + //-- void deleteShowColourText() /** * Method deleteShowConservation * */ - public void deleteShowConservation() - { - this._has_showConservation= false; - } //-- void deleteShowConservation() + public void deleteShowConservation() { + this._has_showConservation = false; + } + //-- void deleteShowConservation() /** * Method deleteShowFullId * */ - public void deleteShowFullId() - { - this._has_showFullId= false; - } //-- void deleteShowFullId() + public void deleteShowFullId() { + this._has_showFullId = false; + } + //-- void deleteShowFullId() /** * Method deleteShowIdentity * */ - public void deleteShowIdentity() - { - this._has_showIdentity= false; - } //-- void deleteShowIdentity() + public void deleteShowIdentity() { + this._has_showIdentity = false; + } + //-- void deleteShowIdentity() /** * Method deleteShowQuality * */ - public void deleteShowQuality() - { - this._has_showQuality= false; - } //-- void deleteShowQuality() + public void deleteShowQuality() { + this._has_showQuality = false; + } + //-- void deleteShowQuality() /** * Method deleteShowSequenceFeatures * */ - public void deleteShowSequenceFeatures() - { - this._has_showSequenceFeatures= false; - } //-- void deleteShowSequenceFeatures() + public void deleteShowSequenceFeatures() { + this._has_showSequenceFeatures = false; + } + //-- void deleteShowSequenceFeatures() /** * Method deleteShowText * */ - public void deleteShowText() - { - this._has_showText= false; - } //-- void deleteShowText() + public void deleteShowText() { + this._has_showText = false; + } + //-- void deleteShowText() /** * Method deleteStartRes * */ - public void deleteStartRes() - { - this._has_startRes= false; - } //-- void deleteStartRes() + public void deleteStartRes() { + this._has_startRes = false; + } + //-- void deleteStartRes() /** * Method deleteStartSeq * */ - public void deleteStartSeq() - { - this._has_startSeq= false; - } //-- void deleteStartSeq() + public void deleteStartSeq() { + this._has_startSeq = false; + } + //-- void deleteStartSeq() /** * Method deleteWidth * */ - public void deleteWidth() - { - this._has_width= false; - } //-- void deleteWidth() + public void deleteWidth() { + this._has_width = false; + } + //-- void deleteWidth() /** * Method deleteWrapAlignment * */ - public void deleteWrapAlignment() - { - this._has_wrapAlignment= false; - } //-- void deleteWrapAlignment() + public void deleteWrapAlignment() { + this._has_wrapAlignment = false; + } + //-- void deleteWrapAlignment() /** * Method deleteXpos * */ - public void deleteXpos() - { - this._has_xpos= false; - } //-- void deleteXpos() + public void deleteXpos() { + this._has_xpos = false; + } + //-- void deleteXpos() /** * Method deleteYpos * */ - public void deleteYpos() - { - this._has_ypos= false; - } //-- void deleteYpos() + public void deleteYpos() { + this._has_ypos = false; + } + //-- void deleteYpos() /** * Returns the value of field 'bgColour'. @@ -525,10 +513,10 @@ public class Viewport implements java.io.Serializable { * @return String * @return the value of field 'bgColour'. */ - public java.lang.String getBgColour() - { + public java.lang.String getBgColour() { return this._bgColour; - } //-- java.lang.String getBgColour() + } + //-- java.lang.String getBgColour() /** * Returns the value of field 'consThreshold'. @@ -536,10 +524,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'consThreshold'. */ - public int getConsThreshold() - { + public int getConsThreshold() { return this._consThreshold; - } //-- int getConsThreshold() + } + //-- int getConsThreshold() /** * Returns the value of field 'conservationSelected'. @@ -547,10 +535,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'conservationSelected'. */ - public boolean getConservationSelected() - { + public boolean getConservationSelected() { return this._conservationSelected; - } //-- boolean getConservationSelected() + } + //-- boolean getConservationSelected() /** * Returns the value of field 'fontName'. @@ -558,10 +546,10 @@ public class Viewport implements java.io.Serializable { * @return String * @return the value of field 'fontName'. */ - public java.lang.String getFontName() - { + public java.lang.String getFontName() { return this._fontName; - } //-- java.lang.String getFontName() + } + //-- java.lang.String getFontName() /** * Returns the value of field 'fontSize'. @@ -569,10 +557,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'fontSize'. */ - public int getFontSize() - { + public int getFontSize() { return this._fontSize; - } //-- int getFontSize() + } + //-- int getFontSize() /** * Returns the value of field 'fontStyle'. @@ -580,10 +568,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'fontStyle'. */ - public int getFontStyle() - { + public int getFontStyle() { return this._fontStyle; - } //-- int getFontStyle() + } + //-- int getFontStyle() /** * Returns the value of field 'height'. @@ -591,10 +579,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'height'. */ - public int getHeight() - { + public int getHeight() { return this._height; - } //-- int getHeight() + } + //-- int getHeight() /** * Returns the value of field 'pidSelected'. @@ -602,10 +590,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'pidSelected'. */ - public boolean getPidSelected() - { + public boolean getPidSelected() { return this._pidSelected; - } //-- boolean getPidSelected() + } + //-- boolean getPidSelected() /** * Returns the value of field 'pidThreshold'. @@ -613,10 +601,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'pidThreshold'. */ - public int getPidThreshold() - { + public int getPidThreshold() { return this._pidThreshold; - } //-- int getPidThreshold() + } + //-- int getPidThreshold() /** * Returns the value of field 'renderGaps'. @@ -624,10 +612,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'renderGaps'. */ - public boolean getRenderGaps() - { + public boolean getRenderGaps() { return this._renderGaps; - } //-- boolean getRenderGaps() + } + //-- boolean getRenderGaps() /** * Returns the value of field 'showAnnotation'. @@ -635,10 +623,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showAnnotation'. */ - public boolean getShowAnnotation() - { + public boolean getShowAnnotation() { return this._showAnnotation; - } //-- boolean getShowAnnotation() + } + //-- boolean getShowAnnotation() /** * Returns the value of field 'showBoxes'. @@ -646,10 +634,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showBoxes'. */ - public boolean getShowBoxes() - { + public boolean getShowBoxes() { return this._showBoxes; - } //-- boolean getShowBoxes() + } + //-- boolean getShowBoxes() /** * Returns the value of field 'showColourText'. @@ -657,10 +645,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showColourText'. */ - public boolean getShowColourText() - { + public boolean getShowColourText() { return this._showColourText; - } //-- boolean getShowColourText() + } + //-- boolean getShowColourText() /** * Returns the value of field 'showConservation'. @@ -668,10 +656,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showConservation'. */ - public boolean getShowConservation() - { + public boolean getShowConservation() { return this._showConservation; - } //-- boolean getShowConservation() + } + //-- boolean getShowConservation() /** * Returns the value of field 'showFullId'. @@ -679,10 +667,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showFullId'. */ - public boolean getShowFullId() - { + public boolean getShowFullId() { return this._showFullId; - } //-- boolean getShowFullId() + } + //-- boolean getShowFullId() /** * Returns the value of field 'showIdentity'. @@ -690,10 +678,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showIdentity'. */ - public boolean getShowIdentity() - { + public boolean getShowIdentity() { return this._showIdentity; - } //-- boolean getShowIdentity() + } + //-- boolean getShowIdentity() /** * Returns the value of field 'showQuality'. @@ -701,10 +689,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showQuality'. */ - public boolean getShowQuality() - { + public boolean getShowQuality() { return this._showQuality; - } //-- boolean getShowQuality() + } + //-- boolean getShowQuality() /** * Returns the value of field 'showSequenceFeatures'. @@ -712,10 +700,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showSequenceFeatures'. */ - public boolean getShowSequenceFeatures() - { + public boolean getShowSequenceFeatures() { return this._showSequenceFeatures; - } //-- boolean getShowSequenceFeatures() + } + //-- boolean getShowSequenceFeatures() /** * Returns the value of field 'showText'. @@ -723,10 +711,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'showText'. */ - public boolean getShowText() - { + public boolean getShowText() { return this._showText; - } //-- boolean getShowText() + } + //-- boolean getShowText() /** * Returns the value of field 'startRes'. @@ -734,10 +722,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'startRes'. */ - public int getStartRes() - { + public int getStartRes() { return this._startRes; - } //-- int getStartRes() + } + //-- int getStartRes() /** * Returns the value of field 'startSeq'. @@ -745,10 +733,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'startSeq'. */ - public int getStartSeq() - { + public int getStartSeq() { return this._startSeq; - } //-- int getStartSeq() + } + //-- int getStartSeq() /** * Returns the value of field 'title'. @@ -756,10 +744,10 @@ public class Viewport implements java.io.Serializable { * @return String * @return the value of field 'title'. */ - public java.lang.String getTitle() - { + public java.lang.String getTitle() { return this._title; - } //-- java.lang.String getTitle() + } + //-- java.lang.String getTitle() /** * Returns the value of field 'width'. @@ -767,10 +755,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'width'. */ - public int getWidth() - { + public int getWidth() { return this._width; - } //-- int getWidth() + } + //-- int getWidth() /** * Returns the value of field 'wrapAlignment'. @@ -778,10 +766,10 @@ public class Viewport implements java.io.Serializable { * @return boolean * @return the value of field 'wrapAlignment'. */ - public boolean getWrapAlignment() - { + public boolean getWrapAlignment() { return this._wrapAlignment; - } //-- boolean getWrapAlignment() + } + //-- boolean getWrapAlignment() /** * Returns the value of field 'xpos'. @@ -789,10 +777,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'xpos'. */ - public int getXpos() - { + public int getXpos() { return this._xpos; - } //-- int getXpos() + } + //-- int getXpos() /** * Returns the value of field 'ypos'. @@ -800,10 +788,10 @@ public class Viewport implements java.io.Serializable { * @return int * @return the value of field 'ypos'. */ - public int getYpos() - { + public int getYpos() { return this._ypos; - } //-- int getYpos() + } + //-- int getYpos() /** * Method hasConsThreshold @@ -812,10 +800,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasConsThreshold() - { + public boolean hasConsThreshold() { return this._has_consThreshold; - } //-- boolean hasConsThreshold() + } + //-- boolean hasConsThreshold() /** * Method hasConservationSelected @@ -824,10 +812,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasConservationSelected() - { + public boolean hasConservationSelected() { return this._has_conservationSelected; - } //-- boolean hasConservationSelected() + } + //-- boolean hasConservationSelected() /** * Method hasFontSize @@ -836,10 +824,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasFontSize() - { + public boolean hasFontSize() { return this._has_fontSize; - } //-- boolean hasFontSize() + } + //-- boolean hasFontSize() /** * Method hasFontStyle @@ -848,10 +836,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasFontStyle() - { + public boolean hasFontStyle() { return this._has_fontStyle; - } //-- boolean hasFontStyle() + } + //-- boolean hasFontStyle() /** * Method hasHeight @@ -860,10 +848,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasHeight() - { + public boolean hasHeight() { return this._has_height; - } //-- boolean hasHeight() + } + //-- boolean hasHeight() /** * Method hasPidSelected @@ -872,10 +860,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasPidSelected() - { + public boolean hasPidSelected() { return this._has_pidSelected; - } //-- boolean hasPidSelected() + } + //-- boolean hasPidSelected() /** * Method hasPidThreshold @@ -884,10 +872,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasPidThreshold() - { + public boolean hasPidThreshold() { return this._has_pidThreshold; - } //-- boolean hasPidThreshold() + } + //-- boolean hasPidThreshold() /** * Method hasRenderGaps @@ -896,10 +884,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasRenderGaps() - { + public boolean hasRenderGaps() { return this._has_renderGaps; - } //-- boolean hasRenderGaps() + } + //-- boolean hasRenderGaps() /** * Method hasShowAnnotation @@ -908,10 +896,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowAnnotation() - { + public boolean hasShowAnnotation() { return this._has_showAnnotation; - } //-- boolean hasShowAnnotation() + } + //-- boolean hasShowAnnotation() /** * Method hasShowBoxes @@ -920,10 +908,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowBoxes() - { + public boolean hasShowBoxes() { return this._has_showBoxes; - } //-- boolean hasShowBoxes() + } + //-- boolean hasShowBoxes() /** * Method hasShowColourText @@ -932,10 +920,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowColourText() - { + public boolean hasShowColourText() { return this._has_showColourText; - } //-- boolean hasShowColourText() + } + //-- boolean hasShowColourText() /** * Method hasShowConservation @@ -944,10 +932,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowConservation() - { + public boolean hasShowConservation() { return this._has_showConservation; - } //-- boolean hasShowConservation() + } + //-- boolean hasShowConservation() /** * Method hasShowFullId @@ -956,10 +944,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowFullId() - { + public boolean hasShowFullId() { return this._has_showFullId; - } //-- boolean hasShowFullId() + } + //-- boolean hasShowFullId() /** * Method hasShowIdentity @@ -968,10 +956,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowIdentity() - { + public boolean hasShowIdentity() { return this._has_showIdentity; - } //-- boolean hasShowIdentity() + } + //-- boolean hasShowIdentity() /** * Method hasShowQuality @@ -980,10 +968,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowQuality() - { + public boolean hasShowQuality() { return this._has_showQuality; - } //-- boolean hasShowQuality() + } + //-- boolean hasShowQuality() /** * Method hasShowSequenceFeatures @@ -992,10 +980,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowSequenceFeatures() - { + public boolean hasShowSequenceFeatures() { return this._has_showSequenceFeatures; - } //-- boolean hasShowSequenceFeatures() + } + //-- boolean hasShowSequenceFeatures() /** * Method hasShowText @@ -1004,10 +992,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasShowText() - { + public boolean hasShowText() { return this._has_showText; - } //-- boolean hasShowText() + } + //-- boolean hasShowText() /** * Method hasStartRes @@ -1016,10 +1004,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasStartRes() - { + public boolean hasStartRes() { return this._has_startRes; - } //-- boolean hasStartRes() + } + //-- boolean hasStartRes() /** * Method hasStartSeq @@ -1028,10 +1016,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasStartSeq() - { + public boolean hasStartSeq() { return this._has_startSeq; - } //-- boolean hasStartSeq() + } + //-- boolean hasStartSeq() /** * Method hasWidth @@ -1040,10 +1028,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasWidth() - { + public boolean hasWidth() { return this._has_width; - } //-- boolean hasWidth() + } + //-- boolean hasWidth() /** * Method hasWrapAlignment @@ -1052,10 +1040,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasWrapAlignment() - { + public boolean hasWrapAlignment() { return this._has_wrapAlignment; - } //-- boolean hasWrapAlignment() + } + //-- boolean hasWrapAlignment() /** * Method hasXpos @@ -1064,10 +1052,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasXpos() - { + public boolean hasXpos() { return this._has_xpos; - } //-- boolean hasXpos() + } + //-- boolean hasXpos() /** * Method hasYpos @@ -1076,10 +1064,10 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean hasYpos() - { + public boolean hasYpos() { return this._has_ypos; - } //-- boolean hasYpos() + } + //-- boolean hasYpos() /** * Method isValid @@ -1088,16 +1076,16 @@ public class Viewport implements java.io.Serializable { * * @return boolean */ - public boolean isValid() - { + public boolean isValid() { 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 @@ -1107,11 +1095,11 @@ public class Viewport implements java.io.Serializable { * @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 @@ -1121,32 +1109,32 @@ public class Viewport implements java.io.Serializable { * @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 'bgColour'. * * @param bgColour the value of field 'bgColour'. */ - public void setBgColour(java.lang.String bgColour) - { + public void setBgColour(java.lang.String bgColour) { this._bgColour = bgColour; - } //-- void setBgColour(java.lang.String) + } + //-- void setBgColour(java.lang.String) /** * Sets the value of field 'consThreshold'. * * @param consThreshold the value of field 'consThreshold'. */ - public void setConsThreshold(int consThreshold) - { + public void setConsThreshold(int consThreshold) { this._consThreshold = consThreshold; this._has_consThreshold = true; - } //-- void setConsThreshold(int) + } + //-- void setConsThreshold(int) /** * Sets the value of field 'conservationSelected'. @@ -1154,164 +1142,164 @@ public class Viewport implements java.io.Serializable { * @param conservationSelected the value of field * 'conservationSelected'. */ - public void setConservationSelected(boolean conservationSelected) - { + public void setConservationSelected(boolean conservationSelected) { this._conservationSelected = conservationSelected; this._has_conservationSelected = true; - } //-- void setConservationSelected(boolean) + } + //-- void setConservationSelected(boolean) /** * Sets the value of field 'fontName'. * * @param fontName the value of field 'fontName'. */ - public void setFontName(java.lang.String fontName) - { + public void setFontName(java.lang.String fontName) { this._fontName = fontName; - } //-- void setFontName(java.lang.String) + } + //-- void setFontName(java.lang.String) /** * Sets the value of field 'fontSize'. * * @param fontSize the value of field 'fontSize'. */ - public void setFontSize(int fontSize) - { + public void setFontSize(int fontSize) { this._fontSize = fontSize; this._has_fontSize = true; - } //-- void setFontSize(int) + } + //-- void setFontSize(int) /** * Sets the value of field 'fontStyle'. * * @param fontStyle the value of field 'fontStyle'. */ - public void setFontStyle(int fontStyle) - { + public void setFontStyle(int fontStyle) { this._fontStyle = fontStyle; this._has_fontStyle = true; - } //-- void setFontStyle(int) + } + //-- void setFontStyle(int) /** * Sets the value of field 'height'. * * @param height the value of field 'height'. */ - public void setHeight(int height) - { + public void setHeight(int height) { this._height = height; this._has_height = true; - } //-- void setHeight(int) + } + //-- void setHeight(int) /** * Sets the value of field 'pidSelected'. * * @param pidSelected the value of field 'pidSelected'. */ - public void setPidSelected(boolean pidSelected) - { + public void setPidSelected(boolean pidSelected) { this._pidSelected = pidSelected; this._has_pidSelected = true; - } //-- void setPidSelected(boolean) + } + //-- void setPidSelected(boolean) /** * Sets the value of field 'pidThreshold'. * * @param pidThreshold the value of field 'pidThreshold'. */ - public void setPidThreshold(int pidThreshold) - { + public void setPidThreshold(int pidThreshold) { this._pidThreshold = pidThreshold; this._has_pidThreshold = true; - } //-- void setPidThreshold(int) + } + //-- void setPidThreshold(int) /** * Sets the value of field 'renderGaps'. * * @param renderGaps the value of field 'renderGaps'. */ - public void setRenderGaps(boolean renderGaps) - { + public void setRenderGaps(boolean renderGaps) { this._renderGaps = renderGaps; this._has_renderGaps = true; - } //-- void setRenderGaps(boolean) + } + //-- void setRenderGaps(boolean) /** * Sets the value of field 'showAnnotation'. * * @param showAnnotation the value of field 'showAnnotation'. */ - public void setShowAnnotation(boolean showAnnotation) - { + public void setShowAnnotation(boolean showAnnotation) { this._showAnnotation = showAnnotation; this._has_showAnnotation = true; - } //-- void setShowAnnotation(boolean) + } + //-- void setShowAnnotation(boolean) /** * Sets the value of field 'showBoxes'. * * @param showBoxes the value of field 'showBoxes'. */ - public void setShowBoxes(boolean showBoxes) - { + public void setShowBoxes(boolean showBoxes) { this._showBoxes = showBoxes; this._has_showBoxes = true; - } //-- void setShowBoxes(boolean) + } + //-- void setShowBoxes(boolean) /** * Sets the value of field 'showColourText'. * * @param showColourText the value of field 'showColourText'. */ - public void setShowColourText(boolean showColourText) - { + public void setShowColourText(boolean showColourText) { this._showColourText = showColourText; this._has_showColourText = true; - } //-- void setShowColourText(boolean) + } + //-- void setShowColourText(boolean) /** * Sets the value of field 'showConservation'. * * @param showConservation the value of field 'showConservation' */ - public void setShowConservation(boolean showConservation) - { + public void setShowConservation(boolean showConservation) { this._showConservation = showConservation; this._has_showConservation = true; - } //-- void setShowConservation(boolean) + } + //-- void setShowConservation(boolean) /** * Sets the value of field 'showFullId'. * * @param showFullId the value of field 'showFullId'. */ - public void setShowFullId(boolean showFullId) - { + public void setShowFullId(boolean showFullId) { this._showFullId = showFullId; this._has_showFullId = true; - } //-- void setShowFullId(boolean) + } + //-- void setShowFullId(boolean) /** * Sets the value of field 'showIdentity'. * * @param showIdentity the value of field 'showIdentity'. */ - public void setShowIdentity(boolean showIdentity) - { + public void setShowIdentity(boolean showIdentity) { this._showIdentity = showIdentity; this._has_showIdentity = true; - } //-- void setShowIdentity(boolean) + } + //-- void setShowIdentity(boolean) /** * Sets the value of field 'showQuality'. * * @param showQuality the value of field 'showQuality'. */ - public void setShowQuality(boolean showQuality) - { + public void setShowQuality(boolean showQuality) { this._showQuality = showQuality; this._has_showQuality = true; - } //-- void setShowQuality(boolean) + } + //-- void setShowQuality(boolean) /** * Sets the value of field 'showSequenceFeatures'. @@ -1319,98 +1307,98 @@ public class Viewport implements java.io.Serializable { * @param showSequenceFeatures the value of field * 'showSequenceFeatures'. */ - public void setShowSequenceFeatures(boolean showSequenceFeatures) - { + public void setShowSequenceFeatures(boolean showSequenceFeatures) { this._showSequenceFeatures = showSequenceFeatures; this._has_showSequenceFeatures = true; - } //-- void setShowSequenceFeatures(boolean) + } + //-- void setShowSequenceFeatures(boolean) /** * Sets the value of field 'showText'. * * @param showText the value of field 'showText'. */ - public void setShowText(boolean showText) - { + public void setShowText(boolean showText) { this._showText = showText; this._has_showText = true; - } //-- void setShowText(boolean) + } + //-- void setShowText(boolean) /** * Sets the value of field 'startRes'. * * @param startRes the value of field 'startRes'. */ - public void setStartRes(int startRes) - { + public void setStartRes(int startRes) { this._startRes = startRes; this._has_startRes = true; - } //-- void setStartRes(int) + } + //-- void setStartRes(int) /** * Sets the value of field 'startSeq'. * * @param startSeq the value of field 'startSeq'. */ - public void setStartSeq(int startSeq) - { + public void setStartSeq(int startSeq) { this._startSeq = startSeq; this._has_startSeq = true; - } //-- void setStartSeq(int) + } + //-- void setStartSeq(int) /** * Sets the value of field 'title'. * * @param title the value of field 'title'. */ - public void setTitle(java.lang.String 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) - { + public void setWidth(int width) { this._width = width; this._has_width = true; - } //-- void setWidth(int) + } + //-- void setWidth(int) /** * Sets the value of field 'wrapAlignment'. * * @param wrapAlignment the value of field 'wrapAlignment'. */ - public void setWrapAlignment(boolean wrapAlignment) - { + public void setWrapAlignment(boolean wrapAlignment) { this._wrapAlignment = wrapAlignment; this._has_wrapAlignment = true; - } //-- void setWrapAlignment(boolean) + } + //-- void setWrapAlignment(boolean) /** * Sets the value of field 'xpos'. * * @param xpos the value of field 'xpos'. */ - public void setXpos(int 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) - { + public void setYpos(int ypos) { this._ypos = ypos; this._has_ypos = true; - } //-- void setYpos(int) + } + //-- void setYpos(int) /** * Method unmarshal @@ -1421,20 +1409,20 @@ public class Viewport implements java.io.Serializable { * @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) + 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 - { + 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/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 804414a..b3cf890 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -16,568 +16,562 @@ * 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.*; + import jalview.util.*; + 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 = '-'; + public AlignmentAnnotation[] annotations; + public boolean featuresAdded = false; + + /** Make an alignment from an array of Sequences. + * + * @param sequences + */ + public Alignment(SequenceI[] seqs) { + sequences = new Vector(); - protected Vector sequences; - protected Vector groups = new Vector(); - protected Vector superGroup = new Vector(); - protected char gapCharacter = '-'; - public AlignmentAnnotation [] annotations; + for (int i = 0; i < seqs.length; i++) + sequences.addElement(seqs[i]); - public boolean featuresAdded = false; + getWidth(); + } - /** Make an alignment from an array of Sequences. - * - * @param sequences - */ - public Alignment(SequenceI[] seqs) { - sequences = new Vector(); + public Vector getSequences() { + return sequences; + } - for (int i=0; i < seqs.length; i++) - sequences.addElement(seqs[i]); + public SequenceI getSequenceAt(int i) { + if (i < sequences.size()) { + return (SequenceI) sequences.elementAt(i); + } - getWidth(); - } + return null; + } - public Vector getSequences() { - return sequences; - } + /** Adds a sequence to the alignment. Recalculates maxLength and size. + * + * @param snew + */ + public void addSequence(SequenceI snew) { + sequences.addElement(snew); + } - public SequenceI getSequenceAt(int i) { - if (i < sequences.size()) { - return (SequenceI)sequences.elementAt(i); + public void addSequence(SequenceI[] seq) { + for (int i = 0; i < seq.length; i++) { + addSequence(seq[i]); + } } - return null; - } + /** Adds a sequence to the alignment. Recalculates maxLength and size. + * + * @param snew + */ + public void setSequenceAt(int i, SequenceI snew) { + SequenceI oldseq = getSequenceAt(i); + deleteSequence(oldseq); - /** Adds a sequence to the alignment. Recalculates maxLength and size. - * - * @param snew - */ - public void addSequence(SequenceI snew) { - sequences.addElement(snew); - } + sequences.setElementAt(snew, i); + } - public void addSequence(SequenceI[] seq) { - for (int i=0; i < seq.length; i++) { - addSequence(seq[i]); + public Vector getGroups() { + return groups; } - } - /** Adds a sequence to the alignment. Recalculates maxLength and size. - * - * @param snew - */ - public void setSequenceAt(int i,SequenceI snew) { - SequenceI oldseq = getSequenceAt(i); - deleteSequence(oldseq); + /** Sorts the sequences by sequence group size - largest to smallest. + * Uses QuickSort. + */ + public void sortGroups() { + float[] arr = new float[groups.size()]; + Object[] s = new Object[groups.size()]; - sequences.setElementAt(snew,i); - } + for (int i = 0; i < groups.size(); i++) { + arr[i] = ((SequenceGroup) groups.elementAt(i)).sequences.size(); + s[i] = groups.elementAt(i); + } - public Vector getGroups() { - return groups; - } - - /** Sorts the sequences by sequence group size - largest to smallest. - * Uses QuickSort. - */ - 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); - QuickSort.sort(arr,s); + Vector newg = new Vector(groups.size()); - Vector newg = new Vector(groups.size()); + for (int i = groups.size() - 1; i >= 0; i--) { + newg.addElement(s[i]); + } - for (int i=groups.size()-1; i >= 0; i--) { - newg.addElement(s[i]); + groups = newg; } - groups = newg; - } + /** Takes out columns consisting entirely of gaps (-,.," ") + */ + public void removeGaps() { + SequenceI current; + int iSize = getWidth(); + + for (int i = 0; i < iSize; i++) { + boolean delete = true; + + for (int j = 0; j < getHeight(); j++) { + current = getSequenceAt(j); + + if (current.getLength() > i) { + /* MC Should move this to a method somewhere */ + if (!jalview.util.Comparison.isGap(current.getCharAt(i))) { + delete = false; + } + } + } + + if (delete) { + deleteColumns(i, i); + iSize--; + i--; + } + } + } - /** Takes out columns consisting entirely of gaps (-,.," ") - */ - public void removeGaps() - { + /** 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); + } - SequenceI current; - int iSize = getWidth(); - for (int i=0; i < iSize; i++) - { - boolean delete = true; - for (int j=0; j < getHeight(); j++) - { - current = getSequenceAt(j); - if (current.getLength() > i) - { - /* MC Should move this to a method somewhere */ - if ( !jalview.util.Comparison.isGap(current.getCharAt(i))) - delete = false; + /** 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) { + 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++) { + getSequenceAt(j).deleteCharAt(start); + } } - } + } - if ( delete ) - { - deleteColumns(i,i); - iSize--; - i--; - } + 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)); + } - /** 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) { - deleteColumns(0,getHeight()-1,start,end); - } + return seqs; + } - public void deleteColumns(int seq1, int seq2, int start, int end) { + public void trimLeft(int i) { + for (int j = 0; j < getHeight(); j++) { + SequenceI s = getSequenceAt(j); + int newstart = s.findPosition(i); - for (int i=0; i <= (end-start); i++) { - for (int j=seq1; j <= seq2; j++) { - getSequenceAt(j).deleteCharAt(start); - } + s.setStart(newstart); + s.setSequence(s.getSequence().substring(i)); + } } - } - 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 void trimRight(int i) { + for (int j = 0; j < getHeight(); j++) { + SequenceI s = getSequenceAt(j); + int newend = s.findPosition(i); + s.setEnd(newend); + s.setSequence(s.getSequence().substring(0, i + 1)); + } } - } - 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)); + public void deleteSequence(SequenceI s) { + for (int i = 0; i < getHeight(); i++) + if (getSequenceAt(i) == s) { + deleteSequence(i); + } } - return seqs; - } - public void trimLeft(int i) { - for (int j = 0;j< getHeight();j++) { + public void deleteSequence(int i) { + sequences.removeElementAt(i); + } - SequenceI s = getSequenceAt(j); - int newstart = s.findPosition(i); + 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++) { + // Only do the comparison if either have not been deleted + if (!del.contains((SequenceI) sel.elementAt(i)) || + !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) { + // Delete the shortest one + if (((SequenceI) sel.elementAt(j)).getSequence().length() > ((SequenceI) sel + .elementAt( + i)).getSequence().length()) { + del.addElement(sel.elementAt(i)); + } else { + del.addElement(sel.elementAt(i)); + } + } + } + } + } - s.setStart(newstart); - s.setSequence(s.getSequence().substring(i)); + // Now delete the sequences + for (int i = 0; i < del.size(); i++) + deleteSequence((SequenceI) del.elementAt(i)); + return del; } - } - public void trimRight(int i) { - for (int j = 0;j< getHeight();j++) { - SequenceI s = getSequenceAt(j); - int newend = s.findPosition(i); + 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; + } - s.setEnd(newend); - s.setSequence(s.getSequence().substring(0,i+1)); + 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 deleteSequence(SequenceI s) - { - for (int i=0; i < getHeight(); i++) - if (getSequenceAt(i) == s) - deleteSequence(i); - } + public void sortByID() { + String[] ids = new String[getHeight()]; + SequenceI[] seqs = new SequenceI[getHeight()]; - public void deleteSequence(int i) - { - sequences.removeElementAt(i); - } + for (int i = 0; i < getHeight(); i++) { + ids[i] = getSequenceAt(i).getName(); + seqs[i] = getSequenceAt(i); + } + QuickSort.sort(ids, seqs); - public Vector removeRedundancy(float threshold, Vector sel) { - Vector del = new Vector(); + int len = 0; - 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))) - { - // use PID instead of Comparison (which is really not pleasant) - float pid = Comparison.PID( (SequenceI) sel.elementAt(j), - (SequenceI) sel.elementAt(i)); + if ((getHeight() % 2) == 0) { + len = getHeight() / 2; + } else { + len = (getHeight() + 1) / 2; + System.out.println("DEBUG:Sort len is odd = " + len); // log. + } - if (pid >= threshold) - { - // Delete the shortest one - if ( ( (SequenceI) sel.elementAt(j)).getSequence().length() > - ( (SequenceI) sel.elementAt(i)).getSequence().length()) - del.addElement(sel.elementAt(i)); - else - del.addElement(sel.elementAt(i)); - } + 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); } - } } - // Now delete the sequences - for (int i=0; i < del.size(); i++) - deleteSequence((SequenceI)del.elementAt(i)); - - return del; - } + /** */ + public SequenceGroup findGroup(int i) { + return findGroup(getSequenceAt(i)); + } - public void sortByPID(SequenceI s) { + /** */ + public SequenceGroup findGroup(SequenceI s) { + for (int i = 0; i < this.groups.size(); i++) { + SequenceGroup sg = (SequenceGroup) groups.elementAt(i); - float scores[] = new float[getHeight()]; - SequenceI seqs[] = new SequenceI[getHeight()]; + if (sg.sequences.contains(s)) { + return sg; + } + } - for (int i = 0; i < getHeight(); i++) { - scores[i] = Comparison.compare(getSequenceAt(i),s); - seqs[i] = getSequenceAt(i); + return null; } - QuickSort.sort(scores,0,scores.length-1,seqs); + public SequenceGroup[] findAllGroups(SequenceI s) { + Vector temp = new Vector(); + + for (int i = 0; i < this.groups.size(); i++) { + SequenceGroup sg = (SequenceGroup) groups.elementAt(i); + + if (sg.sequences.contains(s)) { + temp.addElement(sg); + } + } + + SequenceGroup[] ret = new SequenceGroup[temp.size()]; - int len = 0; + for (int i = 0; i < temp.size(); i++) + ret[i] = (SequenceGroup) temp.elementAt(i); - if (getHeight()%2 == 0) { - len = getHeight()/2; - } else { - len = (getHeight()+1)/2; + return ret; } - 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 addToGroup(SequenceGroup g, SequenceI s) { + if (!(g.sequences.contains(s))) { + g.sequences.addElement(s); + } } - } - public void sortByID() { - String ids[] = new String[getHeight()]; - SequenceI seqs[] = new SequenceI[getHeight()]; + /** */ + 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); + } + } + } + } - for (int i = 0; i < getHeight(); i++) { - ids[i] = getSequenceAt(i).getName(); - seqs[i] = getSequenceAt(i); + public void addSuperGroup(SuperGroup sg) { + superGroup.addElement(sg); } - QuickSort.sort(ids,seqs); + public void removeSuperGroup(SuperGroup sg) { + superGroup.removeElement(sg); + } - int len = 0; + public SuperGroup getSuperGroup(SequenceGroup sg) { + for (int i = 0; i < this.superGroup.size(); i++) { + SuperGroup temp = (SuperGroup) superGroup.elementAt(i); - if (getHeight()%2 == 0) { - len = getHeight()/2; - } else { - len = (getHeight()+1)/2; - System.out.println("DEBUG:Sort len is odd = " + len); // log. + if (temp.sequenceGroups.contains(sg)) { + return temp; + } + } + + return null; } - 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); + + /** */ + public void addGroup(SequenceGroup sg) { + if (!groups.contains(sg)) { + groups.addElement(sg); + } } - } - /** */ - public SequenceGroup findGroup(int i) { - return findGroup(getSequenceAt(i)); - } + public void deleteAllGroups() { + groups.removeAllElements(); + superGroup.removeAllElements(); + + int i = 0; - /** */ - 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)) - return sg; + while (i < sequences.size()) { + SequenceI s = getSequenceAt(i); + s.setColor(java.awt.Color.white); + i++; + } + } + /** */ + public void deleteGroup(SequenceGroup g) { + if (groups.contains(g)) { + groups.removeElement(g); + } } - return null; - } - public SequenceGroup [] findAllGroups(SequenceI s) - { + /** */ + public SequenceI findName(String name) { + int i = 0; - Vector temp = new Vector(); + while (i < sequences.size()) { + SequenceI s = getSequenceAt(i); - for (int i = 0; i < this.groups.size();i++) - { - SequenceGroup sg = (SequenceGroup)groups.elementAt(i); + if (s.getName().equals(name)) { + return s; + } - if (sg.sequences.contains(s)) - temp.addElement(sg); + i++; + } + + return null; } - SequenceGroup [] ret = new SequenceGroup[temp.size()]; - for(int i=0; i maxLength) { + maxLength = getSequenceAt(i).getLength(); + } + } - 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)) - return temp; + return maxLength; } - return null; - } - /** */ - public void addGroup(SequenceGroup sg) { - if(!groups.contains(sg)) - groups.addElement(sg); - } + public int getMaxIdLength() { + int max = 0; + int i = 0; - public void deleteAllGroups() - { - groups.removeAllElements(); - superGroup.removeAllElements(); - int i=0; - while (i < sequences.size()) { - SequenceI s = getSequenceAt(i); - s.setColor(java.awt.Color.white); - i++; - } - - - } - - /** */ - public void deleteGroup(SequenceGroup g) { - if (groups.contains(g)) { - groups.removeElement(g); - } - } - - /** */ - public SequenceI findName(String name) { - int i = 0; - while (i < sequences.size()) { - SequenceI s = getSequenceAt(i); - if (s.getName().equals(name)) - return s; - - i++; - } - return null; - } - - /** */ - public SequenceI findbyDisplayId(String name) { - int i = 0; - while (i < sequences.size()) { - SequenceI s = getSequenceAt(i); - if (s.getDisplayId().equals(name)) - return s; - - i++; - } - return null; - } - - /** */ - public int findIndex(SequenceI s) - { - int i=0; - while (i < sequences.size()) - { - if (s == getSequenceAt(i)) - return i; - - i++; - } - return -1; - } - - public int getHeight() { - return sequences.size(); - } - - - public int getWidth() - { - int maxLength = -1; - for (int i = 0; i < sequences.size(); i++) - { - if (getSequenceAt(i).getLength() > maxLength) - maxLength = getSequenceAt(i).getLength(); - } - - return maxLength; - } - - - public int getMaxIdLength() { - int max = 0; - int i = 0; - - while (i < sequences.size()) { - SequenceI seq = getSequenceAt(i); - String tmp = seq.getName() + "/" + seq.getStart() + "-" + seq.getEnd(); - - if (tmp.length() > max) { - max = tmp.length(); - } - - i++; - } - return max; - } - - public void setGapCharacter(char gc) - { - gapCharacter = gc; - 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); - } - } + while (i < sequences.size()) { + SequenceI seq = getSequenceAt(i); + String tmp = seq.getName() + "/" + seq.getStart() + "-" + + seq.getEnd(); - public char getGapCharacter() { - return gapCharacter; - } + if (tmp.length() > max) { + max = tmp.length(); + } - public Vector getAAFrequency() - { - return AAFrequency.calculate(sequences, 0, getWidth()); - } + i++; + } - public boolean isAligned() - { - int width = getWidth(); - for (int i = 0; i < sequences.size(); i++) - if (getSequenceAt(i).getLength() != width) - return false; - - return true; - } + return max; + } - public void deleteAnnotation(AlignmentAnnotation aa) - { - int aSize = 1; - if(annotations!=null) - aSize = annotations.length; + public void setGapCharacter(char gc) { + gapCharacter = gc; - AlignmentAnnotation [] temp = new AlignmentAnnotation [aSize-1]; + 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); + } + } - int tIndex = 0; - for (int i = 0; i < aSize; i++) - { - if(annotations[i]==aa) - continue; + public char getGapCharacter() { + return gapCharacter; + } + public Vector getAAFrequency() { + return AAFrequency.calculate(sequences, 0, getWidth()); + } - temp[tIndex] = annotations[i]; - tIndex++; - } + public boolean isAligned() { + int width = getWidth(); - annotations = temp; + for (int i = 0; i < sequences.size(); i++) + if (getSequenceAt(i).getLength() != width) { + return false; + } - } + return true; + } - public void addAnnotation(AlignmentAnnotation aa) - { - int aSize = 1; - if(annotations!=null) - aSize = annotations.length+1; + public void deleteAnnotation(AlignmentAnnotation aa) { + int aSize = 1; - AlignmentAnnotation [] temp = new AlignmentAnnotation [aSize]; - int i=0; - if (aSize > 1) - for (i = 0; i < aSize-1; i++) - temp[i] = annotations[i]; + if (annotations != null) { + aSize = annotations.length; + } - temp[i] = aa; + AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1]; - annotations = temp; - } - public AlignmentAnnotation[] getAlignmentAnnotation() - { - return annotations; - } + int tIndex = 0; -} + for (int i = 0; i < aSize; i++) { + if (annotations[i] == aa) { + continue; + } + temp[tIndex] = annotations[i]; + tIndex++; + } + + annotations = temp; + } + public void addAnnotation(AlignmentAnnotation aa) { + int aSize = 1; + if (annotations != null) { + aSize = annotations.length + 1; + } + AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize]; + int i = 0; + if (aSize > 1) { + for (i = 0; i < (aSize - 1); i++) + temp[i] = annotations[i]; + } + temp[i] = aa; + annotations = temp; + } + public AlignmentAnnotation[] getAlignmentAnnotation() { + return annotations; + } +} diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 337d879..35297b5 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -16,107 +16,117 @@ * 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 AlignmentAnnotation -{ - public String label; - public String description; - public Annotation [] annotations; - public boolean isGraph = false; - public float graphMin, graphMax; - public int windowLength; - - // Graphical hints and tips - public boolean editable = false; - public boolean hasIcons; // - public boolean hasText; - public boolean visible = true; - public int height=0; - - public AlignmentAnnotation(String label, String description, Annotation [] annotations) - { - // always editable? - editable = true; - this.label = label; - this.description = description; - this.annotations = annotations; - for(int i=0; i0) - hasText = true; - } - } - - public AlignmentAnnotation(String label, String description, 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; imax) - max = annotations[i].value; - if(annotations[i].value 0)) { + hasText = true; + } + } } - graphMin = min; - graphMax = max; - windowLength = winLength; - for(int i=0; i0) - hasText = true; + public AlignmentAnnotation(String label, String description, + 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) { + continue; + } + + if (annotations[i].value > max) { + max = annotations[i].value; + } + + if (annotations[i].value < min) { + min = annotations[i].value; + } + } + } + + graphMin = min; + graphMax = max; + windowLength = winLength; + + for (int i = 0; i < annotations.length; i++) { + if ((annotations[i] != null) && + ((annotations[i].secondaryStructure == 'H') || + (annotations[i].secondaryStructure == 'E'))) { + hasIcons = true; + } + + if ((annotations[i] != null) && + (annotations[i].displayCharacter.length() > 0)) { + hasText = true; + } + } } - } - - public String toString() - { - StringBuffer buffer = new StringBuffer(); - for(int i=0; iTitle:

* @@ -32,105 +32,94 @@ import java.util.*; * * @author not attributable * @version 1.0 - */ -public class AlignmentOrder -{ - public AlignmentOrder() - { - } - - public void setType(int Type) - { - this.Type = Type; - } - - public int getType() - { - return Type; - } - - public void setName(String Name) - { - this.Name = Name; - } - - public String getName() - { - return Name; - } - - public void setOrder(Vector Order) - { - this.Order = Order; - } - - public Vector getOrder() - { - - return Order; - } -// 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) + */ +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) { - aanum = 20; - } + public void encode() { + // Set all matrix to 0 + dbinary = new double[getSequence().length() * 21]; - dbinary[i* nores + aanum] = 1.0; + int nores = 21; + for (int i = 0; i < dbinary.length; i++) { + dbinary[i] = 0.0; + } + + for (int i = 0; i < getSequence().length(); i++) { + int aanum = 20; + + try { + aanum = ((Integer) ResidueProperties.getAAHash().get(getSequence() + .substring(i, + i + 1))).intValue(); + } catch (NullPointerException e) { + aanum = 20; + } + + if (aanum > 20) { + aanum = 20; + } + + dbinary[(i * nores) + aanum] = 1.0; + } } - } - - public void blosumEncode() { - - // Set all matrix to 0 - dbinary = new double[getSequence().length() * 21]; - int nores = 21; - //for (int i = 0; i < dbinary.length; i++) { - // dbinary[i] = 0.0; - //} - - for (int i=0; i < getSequence().length(); i++ ) { - int aanum = 20; - try { - aanum = ((Integer)ResidueProperties.getAAHash().get(getSequence().substring(i,i+1))).intValue(); - } catch (NullPointerException e) { - aanum = 20; - } - if (aanum > 20) { - aanum = 20; - } - - // Do the blosum thing - for (int j = 0;j < 20;j++) { - dbinary[i * nores + j] = ResidueProperties.getBLOSUM62()[aanum][j]; - } + public void blosumEncode() { + // Set all matrix to 0 + dbinary = new double[getSequence().length() * 21]; + + int nores = 21; + + //for (int i = 0; i < dbinary.length; i++) { + // dbinary[i] = 0.0; + //} + for (int i = 0; i < getSequence().length(); i++) { + int aanum = 20; + + try { + aanum = ((Integer) ResidueProperties.getAAHash().get(getSequence() + .substring(i, + i + 1))).intValue(); + } catch (NullPointerException e) { + aanum = 20; + } + + if (aanum > 20) { + aanum = 20; + } + + // Do the blosum thing + for (int j = 0; j < 20; j++) { + dbinary[(i * nores) + j] = ResidueProperties.getBLOSUM62()[aanum][j]; + } + } } - } - - public String toBinaryString() { - String out = ""; - for (int i=0; i < binary.length;i++) { - out += (new Integer(binary[i])).toString(); - if (i < binary.length-1) { - out += " "; - } + + public String toBinaryString() { + String out = ""; + + for (int i = 0; i < binary.length; i++) { + out += (new Integer(binary[i])).toString(); + + if (i < (binary.length - 1)) { + out += " "; + } + } + + return out; } - return out; - } - public double[] getDBinary() { - return dbinary; - } + public double[] getDBinary() { + return dbinary; + } - public static void printMemory(Runtime rt) { - System.out.println("DEBUG: Free memory = " + rt.freeMemory()); // log. - } + 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 bb18b66..ed119e8 100755 --- a/src/jalview/datamodel/HistoryItem.java +++ b/src/jalview/datamodel/HistoryItem.java @@ -16,56 +16,54 @@ * 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.*; -public class HistoryItem -{ - public static final int EDIT = 0; - public static final int SORT = 1; - public static final int HIDE = 2; - public static final int PASTE= 3; - final int type; - Vector sequences; - Vector alignIndex; - String description; - Vector hiddenSeqs; +public class HistoryItem { + public static final int EDIT = 0; + public static final int SORT = 1; + public static final int HIDE = 2; + public static final int PASTE = 3; + final int type; + Vector sequences; + Vector alignIndex; + String description; + Vector hiddenSeqs; - public HistoryItem(String description, AlignmentI al, int type) - { - this.type = type; - this.description = description; - sequences = new Vector(); - alignIndex = new Vector(); - hiddenSeqs = new Vector(); + 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++) - { - SequenceI seq = al.getSequenceAt(i); - sequences.addElement(seq); - alignIndex.addElement(i + ""); - hiddenSeqs.addElement(seq.getSequence().toString()); + for (int i = 0; i < al.getHeight(); i++) { + SequenceI seq = al.getSequenceAt(i); + sequences.addElement(seq); + alignIndex.addElement(i + ""); + hiddenSeqs.addElement(seq.getSequence().toString()); + } } - } - - public int getType() - {return type;} - public Vector getSequences() - {return sequences;} + public int getType() { + return type; + } - public String getDescription() - {return description; } + public Vector getSequences() { + return sequences; + } - public Vector getHidden() - { return hiddenSeqs; } + public String getDescription() { + return description; + } - public int getAlignIndex(int seq) - { - return Integer.parseInt(alignIndex.elementAt(seq).toString()); - } + public Vector getHidden() { + return hiddenSeqs; + } + 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 d7f2b9f..3853af9 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -16,220 +16,241 @@ * 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 MCview.*; + import jalview.analysis.*; + import java.awt.*; + import java.util.*; -import MCview.*; -public class Sequence implements SequenceI -{ - protected String name; - protected String sequence; - protected String description; - protected int start; - protected int end; - protected String displayId; - protected Color color = Color.white; - String pdbId; - - public Vector sequenceFeatures = new Vector(); - public void setSequenceFeatures(Vector v) - { - sequenceFeatures = v; - } - - public Vector getSequenceFeatures() - {return sequenceFeatures; } - - public void setPDBId(String id) - { - pdbId = id; - } - public String getPDBId() - { - return pdbId; - } - - - public Sequence(String name, String sequence, int start, int end) - { - - this.name = name; - this.sequence = sequence; - this.start = start; - this.end = end; - - setDisplayId(); - - } - - public Sequence(String name,String sequence) { - this(name,sequence,1,sequence.length()); - } - public Sequence(SequenceI seq) { - this(seq.getName(),seq.getSequence(),seq.getStart(),seq.getEnd()); - } - public String getDisplayId() { - return displayId; - } - public void setDisplayId() { - displayId = name + "/" + start + "-" + end; - } - public void setName(String name) { - this.name = name; - setDisplayId(); - } - public String getName() { - return this.name; - } - public void setStart(int start) { - this.start = start; - setDisplayId(); - } - public int getStart() { - return this.start; - } - public void setEnd(int end) { - this.end = end; - setDisplayId(); - } - public int getEnd() { - return this.end; - } - public int getLength() { - return this.sequence.length(); - } - public void setSequence(String seq) { - this.sequence = seq; - } - public String getSequence() { - return this.sequence; - } - 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()) - return ""; - - if(end>=sequence.length()) - end = sequence.length(); - - return this.sequence.substring(start,end); - } - - public char getCharAt(int i) { - if (i < sequence.length()) { - return sequence.charAt(i); - } else { - return ' '; - } - } - public void setDescription(String desc) { - this.description = desc; - } - public String getDescription() { - return this.description; - } - - 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) { - - char c = sequence.charAt(i); - - if (!jalview.util.Comparison.isGap((c))) - j++; - - i++; - } - if (j == end && j < pos) - return end+1; - else - return i; - - } - - 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()) - return; - sequence = sequence.substring(0,i) + sequence.substring(i+1); - } - - public void deleteChars(int i, int j) - { - if (i>=sequence.length()) - return; - if (j>=sequence.length()) - sequence = sequence.substring(0,i); - else - sequence = sequence.substring(0,i) + sequence.substring(j); - } - - public void insertCharAt(int i, char c) - { - insertCharAt(i,c,true); - } - - public void insertCharAt(int i,char c,boolean chop) { - - String tmp = new String(sequence); - - if (i < sequence.length()) { - sequence = tmp.substring(0,i) + String.valueOf(c) + tmp.substring(i); - } 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()]; - for (int j=0, k=ch.length; j= sequence.length()) { + return ""; + } + + if (end >= sequence.length()) { + end = sequence.length(); + } + + return this.sequence.substring(start, end); + } + + public char getCharAt(int i) { + if (i < sequence.length()) { + return sequence.charAt(i); + } else { + return ' '; + } + } + + public void setDescription(String desc) { + this.description = desc; + } + + public String getDescription() { + return this.description; + } + + 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)) { + char c = sequence.charAt(i); + + if (!jalview.util.Comparison.isGap((c))) { + j++; + } + + i++; + } + + if ((j == end) && (j < pos)) { + return end + 1; + } else { + return i; + } + } + + 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())) { + char c = sequence.charAt(j); + + if (!jalview.util.Comparison.isGap((c))) { + pos++; + } + + j++; + } + + return pos; + } + + 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))) { + map[p++] = j; + } + + j++; + } + + return map; + } + + 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()) { + return; + } + + if (j >= sequence.length()) { + sequence = sequence.substring(0, i); + } else { + sequence = sequence.substring(0, i) + sequence.substring(j); + } + } + public void insertCharAt(int i, char c) { + insertCharAt(i, c, true); + } + + public void insertCharAt(int i, char c, boolean chop) { + String tmp = new String(sequence); + + if (i < sequence.length()) { + sequence = tmp.substring(0, i) + String.valueOf(c) + + tmp.substring(i); + } 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()]; + + for (int j = 0, k = ch.length; j < k; j++) + ch[j] = c; + + sequence = tmp + String.valueOf(ch); + } + } + + public void setColor(Color c) { + this.color = c; + } + + public Color getColor() { + return color; + } } diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index a2856fa..f7d8d89 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -16,85 +16,86 @@ * 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 SequenceFeature { - int begin; - int end; - String type; - String description; - String status; + int begin; + int end; + String type; + String description; + String status; - public SequenceFeature() - { - } + public SequenceFeature() { + } - public SequenceFeature(String type, int start, int end, String description, String status) - { - this.type = type; - this.begin = start; - this.end = end; - this.description = description; - this.status = status; - } + public SequenceFeature(String type, int start, int end, String description, + String status) { + this.type = type; + this.begin = start; + this.end = end; + this.description = description; + this.status = status; + } - public int getStart() { - return begin; - } - public int getEnd() { - return end; - } - public String getType() { - return type; - } - public String getDescription() { - return description; - } - public String getStatus() - {return status;} + public int getStart() { + return begin; + } + public int getEnd() { + return end; + } -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ + public String getType() { + return type; + } -} + public String getDescription() { + return description; + } + + public String getStatus() { + return status; + } + /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +} diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index d6ea5dd..0ae9ec2 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -16,272 +16,256 @@ * 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.schemes.*; import jalview.analysis.*; + import jalview.datamodel.*; -import java.util.Vector; + +import jalview.schemes.*; + import java.awt.*; -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(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) - startRes = startRes - col; - if(endRes>=col) - { - endRes = endRes - col; - if(startRes>endRes) - startRes = 0; +import java.util.Vector; + + +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(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) { + startRes = startRes - col; + } + + if (endRes >= col) { + endRes = endRes - col; + + if (startRes > endRes) { + startRes = 0; + } + } else { + // must delete this group!! + return false; + } + + return true; + } + + public boolean adjustForRemoveRight(int col) { + if (startRes > col) { + // delete this group + return false; + } + + if (endRes >= col) { + endRes = col; + } + + return true; + } + + public String getName() { + return groupName; + } + + public void setName(String name) { + groupName = name; + } + + public Conservation getConservation() { + return conserve; + } + + public void setConservation(Conservation c) { + conserve = c; + } + + public void addSequence(SequenceI s) { + if (!sequences.contains(s)) { + sequences.addElement(s); + } + + if (cs != null) { + cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth())); + } + + if (cs instanceof ConservationColourScheme) { + recalcConservation(); + } + } + + void recalcConservation() { + Conservation c = new Conservation(groupName, + ResidueProperties.propHash, 3, sequences, 0, getWidth()); + c.calculate(); + c.verdict(false, 25); + + ConservationColourScheme ccs = (ConservationColourScheme) cs; + ccs.conserve = c; } - else - { - // must delete this group!! - return false; + + public void addOrRemove(SequenceI s) { + if (sequences.contains(s)) { + deleteSequence(s); + } else { + addSequence(s); + } + } + + public void deleteSequence(SequenceI s) { + sequences.removeElement(s); + + if (cs != null) { + cs.setConsensus(AAFrequency.calculate(sequences, 0, getWidth())); + } + + if (cs instanceof ConservationColourScheme) { + recalcConservation(); + } + } + + public int getStartRes() { + return startRes; + } + + public int getEndRes() { + return endRes; + } + + public void setStartRes(int i) { + startRes = i; } - return true; - } + public void setEndRes(int i) { + endRes = i; + } - public boolean adjustForRemoveRight(int col) - { + public int getSize() { + return sequences.size(); + } - if(startRes>col) - { - // delete this group - return false; + public SequenceI getSequenceAt(int i) { + return (SequenceI) sequences.elementAt(i); } - if(endRes>=col) - endRes = col; - - return true; - } - - - public String getName() - { - return groupName; - } - - public void setName(String name) - { - groupName = name; - } - - public Conservation getConservation() - { - return conserve; - } - - public void setConservation(Conservation c) - { - conserve = c; - } - - public void addSequence(SequenceI s) - { - if(!sequences.contains(s)) - sequences.addElement(s); - - - if(cs!=null) - cs.setConsensus( AAFrequency.calculate(sequences, 0, getWidth()) ); - - if(cs instanceof ConservationColourScheme) - recalcConservation(); - } - - void recalcConservation() - { - Conservation c = new Conservation(groupName, - ResidueProperties.propHash, 3, - sequences, 0, getWidth()); - c.calculate(); - c.verdict(false, 25); - ConservationColourScheme ccs = (ConservationColourScheme)cs; - ccs.conserve = c; - } - - public void addOrRemove(SequenceI s) - { - if(sequences.contains(s)) - deleteSequence(s); - else - addSequence(s); - } - - public void deleteSequence(SequenceI s) - { - sequences.removeElement(s); - - if(cs!=null) - cs.setConsensus( AAFrequency.calculate(sequences, 0, getWidth()) ); - - if(cs instanceof ConservationColourScheme) - 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) - 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(); + public void setColourText(boolean state) { + colourText = state; } - 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(Alignment al) { - int sz; - java.util.Hashtable orderedSeqs = new java.util.Hashtable(); - SequenceI[] seqs=new SequenceI[sz=sequences.size()]; - for(int i=0; i 0) { + 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(); + } } - else - index++; - } - seqs[index] = seq; + + 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(Alignment al) { + int sz; + java.util.Hashtable orderedSeqs = new java.util.Hashtable(); + SequenceI[] seqs = new SequenceI[sz = sequences.size()]; + + 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 < sz; i++) { + SequenceI seq = null; + + while (seq == null) { + if (orderedSeqs.containsKey(index + "")) { + seq = (SequenceI) orderedSeqs.get(index + ""); + index++; + + break; + } else { + index++; + } + } + + seqs[index] = seq; + } + + return seqs; } - return seqs; - } } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index 9c2ab48..f16c009 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -16,62 +16,67 @@ * 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 { - public void setName(String name); - public String getName(); + public void setName(String name); + + public String getName(); + + public void setStart(int start); + + public int getStart(); + + public String getDisplayId(); - public void setStart(int start); - public int getStart(); + public void setEnd(int end); - public String getDisplayId(); + public int getEnd(); - public void setEnd(int end); - public int getEnd(); + public int getLength(); - public int getLength(); + public void setSequence(String sequence); - public void setSequence(String sequence); - public String getSequence(); - public String getSequence(int start,int end); - public char getCharAt(int i); + public String getSequence(); - public void setDescription(String desc); - public String getDescription(); + public String getSequence(int start, int end); - public int findIndex(int pos); - public int findPosition(int i); - public int[] gapMap(); - public void deleteChars(int i, int j); - public void deleteCharAt(int i); - public void insertCharAt(int i, char c); - public void insertCharAt(int i,char c,boolean chop); + public char getCharAt(int i); - public void setColor(Color c); - public Color getColor(); + public void setDescription(String desc); - public Vector getSequenceFeatures(); - public void setSequenceFeatures(Vector v); + public String getDescription(); - public void setPDBId(String id); - public String getPDBId(); + public int findIndex(int pos); - } + public int findPosition(int i); + public int[] gapMap(); + public void deleteChars(int i, int j); + public void deleteCharAt(int i); + public void insertCharAt(int i, char c); + public void insertCharAt(int i, char c, boolean chop); + public void setColor(Color c); + public Color getColor(); + public Vector getSequenceFeatures(); + public void setSequenceFeatures(Vector v); + public void setPDBId(String id); + public String getPDBId(); +} diff --git a/src/jalview/datamodel/SequenceNode.java b/src/jalview/datamodel/SequenceNode.java index 74776ea..f86c63e 100755 --- a/src/jalview/datamodel/SequenceNode.java +++ b/src/jalview/datamodel/SequenceNode.java @@ -16,73 +16,73 @@ * 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 { + public float dist; + public int count; + public float height; + public float ycount; + public Color color = Color.black; + public boolean dummy = false; + private boolean placeholder = false; + + public SequenceNode() { + super(); + } - public float dist; - public int count; - public float height; - public float ycount; - public Color color = Color.black; - public boolean dummy = false; - private boolean placeholder = false; + public SequenceNode(Object val, SequenceNode parent, float dist, String name) { + super(val, parent, name); + this.dist = dist; + } - public SequenceNode() { - super(); - } + public SequenceNode(Object val, SequenceNode parent, String name, + float dist, int bootstrap, boolean dummy) { + super(val, parent, name); + this.dist = dist; + this.bootstrap = bootstrap; + this.dummy = dummy; + } - public SequenceNode(Object val, SequenceNode parent, float dist,String name) { - super(val,parent,name); - this.dist = dist; - } - public SequenceNode(Object val, SequenceNode parent, String name, float dist, int bootstrap, boolean dummy) { - super(val,parent,name); - this.dist = dist; - this.bootstrap = bootstrap; - this.dummy = dummy; - } + /** + * @param dummy true if node is created for the representation of polytomous trees + */ + 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() { + return placeholder; + } - /** - * @param dummy true if node is created for the representation of polytomous trees - */ + public boolean setDummy(boolean newstate) { + boolean oldstate = dummy; + dummy = newstate; - 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() - { - return placeholder; - } + return oldstate; + } - public boolean setDummy(boolean newstate) { - boolean oldstate = dummy; - dummy = newstate; - return oldstate; - } + public void setPlaceholder(boolean Placeholder) { + this.placeholder = Placeholder; + } - public void setPlaceholder(boolean Placeholder) - { - this.placeholder = Placeholder; - } + /** + * 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() { + SequenceNode c = this; - /** - * 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. - */ + do { + c = (SequenceNode) c.parent(); + } while ((c != null) && c.dummy); - public SequenceNode AscendTree() { - SequenceNode c = this; - do { - c = (SequenceNode) c.parent(); - } while (c!=null && c.dummy); - return c; - } + return c; + } } diff --git a/src/jalview/datamodel/SequencePoint.java b/src/jalview/datamodel/SequencePoint.java index 5da4d64..fa91e59 100755 --- a/src/jalview/datamodel/SequencePoint.java +++ b/src/jalview/datamodel/SequencePoint.java @@ -16,22 +16,21 @@ * 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.*; -import java.awt.*; +import java.awt.*; -public class SequencePoint { +import java.util.*; - // SMJS PUBLIC - public SequenceI sequence; - public float[] coord; - // SMJS ENDPUBLIC - public SequencePoint(SequenceI sequence, float[] coord) { - this.sequence = sequence; - this.coord = coord; - } +public class SequencePoint { + // SMJS PUBLIC + public SequenceI sequence; + public float[] coord; + // SMJS ENDPUBLIC + 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 cd86ef6..ad6f703 100755 --- a/src/jalview/datamodel/SuperGroup.java +++ b/src/jalview/datamodel/SuperGroup.java @@ -16,99 +16,88 @@ * 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.schemes.*; import jalview.analysis.*; + import jalview.datamodel.*; + +import jalview.schemes.*; + import java.util.*; -public class SuperGroup -{ - String groupName; - boolean displayBoxes; - boolean displayText; - boolean colourText; - public ColourSchemeI cs; - Vector sequenceGroups = new Vector(); - - public SuperGroup() - { - groupName = "Super group"; - this.displayBoxes = true; - this.displayText = true; - this.colourText = false; - cs = null; - } - - - public SuperGroup(String groupName, ColourSchemeI scheme, - boolean displayBoxes, boolean displayText, - boolean colourText) - { - this.groupName = groupName; - this.displayBoxes = displayBoxes; - this.displayText = displayText; - this.colourText = colourText; - this.cs = scheme; - } - - public String getName() - { - return groupName; - } - - public void setName(String name) - { - groupName = name; - } - - - public void addGroup(SequenceGroup sg) - { - if(!sequenceGroups.contains(sg)) - sequenceGroups.addElement(sg); - } - - public void addOrRemove(SequenceGroup sg) - { - if(sequenceGroups.contains(sg)) - deleteGroup(sg); - else - addGroup(sg); - } - - public void deleteGroup(SequenceGroup sg) - { - sequenceGroups.removeElement(sg); - } - - public void setSuperGroupProperties(SequenceGroup sg) - { - cs = sg.cs; - colourText = sg.colourText; - displayText = sg.displayText; - displayBoxes = sg.displayBoxes; - - for(int i=0; i-1) - shortName = shortName.substring( - shortName.lastIndexOf(java.io.File.separatorChar)+1); - - String choice = chooser.getSelectedFile().getPath(); - Jalview2XML.SaveState(this, choice, 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(); - } - catch(Exception ex){} - } - - } - - 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(); - } - - 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(); - } - } - } - - } - - - - - public void closeMenuItem_actionPerformed(ActionEvent e) - { - try{ - this.setClosed(true); - }catch(Exception ex){} - } - - Stack historyList = new Stack(); - Stack redoList = new Stack(); - private int treeCount = 0; - - void updateEditMenuBar() - { - if(historyList.size()>0) - { - undoMenuItem.setEnabled(true); - HistoryItem hi = (HistoryItem)historyList.peek(); - undoMenuItem.setText("Undo "+hi.getDescription()); - } - else - { - undoMenuItem.setEnabled(false); - undoMenuItem.setText("Undo"); - } - - if(redoList.size()>0) - { - redoMenuItem.setEnabled(true); - HistoryItem hi = (HistoryItem)redoList.peek(); - redoMenuItem.setText("Redo "+hi.getDescription()); - } - else - { - redoMenuItem.setEnabled(false); - redoMenuItem.setText("Redo"); - } - } - - 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) - { - for(int i=0; ihi.getSequences().size()-1; i--) - viewport.alignment.deleteSequence(i); - } - } - updateEditMenuBar(); - - viewport.updateConsensus(); - viewport.updateConservation(); - alignPanel.repaint(); - viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences()); - } - - public void moveSelectedSequences(boolean up) - { - SequenceGroup sg = viewport.getSelectionGroup(); - if (sg == null) - return; - - 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)) - continue; - - viewport.alignment.getSequences().setElementAt(temp, i); - viewport.alignment.getSequences().setElementAt(seq, i - 1); - } - } - else - { - 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); - } - } - - alignPanel.repaint(); - } - - - - protected void copy_actionPerformed(ActionEvent e) - { - if(viewport.getSelectionGroup()==null) - return; - - SequenceGroup sg = viewport.getSelectionGroup(); - - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringBuffer buffer= new StringBuffer(); - - Hashtable orderedSeqs = new Hashtable(); - for(int i=0; i 0) - { - addHistoryItem(new HistoryItem("Remove Left",viewport.alignment, - HistoryItem.HIDE)); - int min = colSel.getMin(); - viewport.getAlignment().trimLeft(min); - colSel.compensateForEdit(0,min); - - if(viewport.getSelectionGroup()!=null) - viewport.getSelectionGroup().adjustForRemoveLeft(min); - - Vector groups = viewport.alignment.getGroups(); - for(int i=0; i 0) - { - addHistoryItem(new HistoryItem("Remove Right",viewport.alignment, - HistoryItem.HIDE)); - - int max = colSel.getMax(); - viewport.getAlignment().trimRight(max); - if(viewport.getSelectionGroup()!=null) - viewport.getSelectionGroup().adjustForRemoveRight(max); - - Vector groups = viewport.alignment.getGroups(); - for(int i=0; i0) - || viewport.getAlignment().getHeight()<4) - { - JOptionPane.showInternalMessageDialog(this, "Principal component analysis must take\n" - +"at least 4 input sequences.", - "Sequence selection insufficient", - JOptionPane.WARNING_MESSAGE); - return; - } - - try{ - 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) - { - String ltitle; - final TreePanel tp; - if (viewport.getSelectionGroup() != null && - viewport.getSelectionGroup().getSize() > 3) - { - int s=0; - SequenceGroup sg = viewport.getSelectionGroup(); - - /* Decide if the selection is a column region */ - while (s1) - { - // 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(); - - 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) { - jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", title, msa, false, true); - } - } - 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) - { - // 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(); - - 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) { - jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", title, msa, true, true); - } - } - - - protected void jpred_actionPerformed(ActionEvent e) -{ - SequenceI seq=null; - SequenceI[] msa=null; - - 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); - } - } - } - if (msa!=null) { - 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"); - } - } - protected void msaAlignMenuItem_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(); - - 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) { - MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS",title, msa, false, true); - } - } - 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"); - 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"); - ShowNewickTree(fin, choice); - } - catch (Exception ex) - { - JOptionPane.showMessageDialog(Desktop.desktop, - "Problem reading tree file", - ex.getMessage(), - JOptionPane.WARNING_MESSAGE); - ex.printStackTrace(); - } - } - } - - public void ShowNewickTree(NewickFile nf, String title) - { - try{ - nf.parse(); - if (nf.getTree() != null) - { - TreePanel tp = new TreePanel(viewport, - viewport.getAlignment().getSequences(), - nf, "FromFile", title); - Desktop.addInternalFrame(tp, title, 600, 500); - addTreeMenuItem(tp, title); - viewport.setCurrentTree(tp.getTree()); - } - }catch(Exception ex){ex.printStackTrace();} - } - -} +/* + * 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.gui; + +import java.beans.*; +import java.util.*; + +import java.awt.*; +import java.awt.datatransfer.*; +import java.awt.event.*; +import java.awt.print.*; +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 +{ + 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() + { + public void run() + { + alignPanel.requestFocus(); + } + }); + } + }); + } + + 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) + { + currentFileFormat = chooser.getSelectedFormat(); + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", + currentFileFormat); + + if (currentFileFormat.equals("Jalview")) + { + String shortName = title; + + if (shortName.indexOf(java.io.File.separatorChar) > -1) + { + shortName = shortName.substring(shortName.lastIndexOf( + java.io.File.separatorChar) + 1); + } + + String choice = chooser.getSelectedFile().getPath(); + Jalview2XML.SaveState(this, choice, 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(); + } + catch (Exception ex) + { + } + } + } + + 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 + { + this.setClosed(true); + } + catch (Exception ex) + { + } + } + + void updateEditMenuBar() + { + if (historyList.size() > 0) + { + undoMenuItem.setEnabled(true); + + HistoryItem hi = (HistoryItem) historyList.peek(); + undoMenuItem.setText("Undo " + hi.getDescription()); + } + else + { + undoMenuItem.setEnabled(false); + undoMenuItem.setText("Undo"); + } + + if (redoList.size() > 0) + { + redoMenuItem.setEnabled(true); + + HistoryItem hi = (HistoryItem) redoList.peek(); + redoMenuItem.setText("Redo " + hi.getDescription()); + } + else + { + redoMenuItem.setEnabled(false); + redoMenuItem.setText("Redo"); + } + } + + 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) + { + 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()); + } + + public void moveSelectedSequences(boolean up) + { + SequenceGroup sg = viewport.getSelectionGroup(); + + if (sg == null) + { + return; + } + + 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)) + { + continue; + } + + viewport.alignment.getSequences().setElementAt(temp, i); + viewport.alignment.getSequences().setElementAt(seq, i - 1); + } + } + else + { + 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); + } + } + + alignPanel.repaint(); + } + + protected void copy_actionPerformed(ActionEvent e) + { + if (viewport.getSelectionGroup() == null) + { + return; + } + + 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++) + { + SequenceI seq = sg.getSequenceAt(i); + int index = viewport.alignment.findIndex(seq); + orderedSeqs.put(index + "", seq); + } + + int index = 0; + + for (int i = 0; i < sg.getSize(); i++) + { + 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"); + } + + 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); + } + + void paste(boolean newAlignment) + { + try + { + 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(); + } + } + catch (Exception ex) + { + } + + // could be anything being pasted in here + } + + protected void cut_actionPerformed(ActionEvent e) + { + copy_actionPerformed(null); + delete_actionPerformed(null); + } + + protected void delete_actionPerformed(ActionEvent e) + { + boolean seqsdeleted = false; + + if (viewport.getSelectionGroup() == null) + { + return; + } + + addHistoryItem(new HistoryItem("Delete Sequences", viewport.alignment, + HistoryItem.HIDE)); + + SequenceGroup sg = viewport.getSelectionGroup(); + + for (int i = 0; i < sg.sequences.size(); i++) + { + 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); + } + } + + viewport.setSelectionGroup(null); + viewport.alignment.deleteGroup(sg); + + if (seqsdeleted) + { + viewport.firePropertyChange("alignment", null, + viewport.getAlignment().getSequences()); + } + + viewport.resetSeqLimits(alignPanel.seqPanel.seqCanvas.getHeight()); + + if (viewport.getAlignment().getHeight() < 1) + { + try + { + this.setClosed(true); + } + catch (Exception ex) + { + } + } + + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); + } + + protected void deleteGroups_actionPerformed(ActionEvent e) + { + viewport.alignment.deleteAllGroups(); + viewport.setSelectionGroup(null); + alignPanel.repaint(); + } + + public void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) + { + SequenceGroup sg = new SequenceGroup(); + + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + sg.addSequence(viewport.getAlignment().getSequenceAt(i)); + } + + sg.setEndRes(viewport.alignment.getWidth()); + viewport.setSelectionGroup(sg); + PaintRefresher.Refresh(null); + } + + public void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) + { + viewport.setSelectionGroup(null); + viewport.getColumnSelection().clear(); + viewport.setSelectionGroup(null); + PaintRefresher.Refresh(null); + } + + public void invertSequenceMenuItem_actionPerformed(ActionEvent e) + { + SequenceGroup sg = viewport.getSelectionGroup(); + + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + sg.addOrRemove(viewport.getAlignment().getSequenceAt(i)); + } + + PaintRefresher.Refresh(null); + } + + public void remove2LeftMenuItem_actionPerformed(ActionEvent e) + { + ColumnSelection colSel = viewport.getColumnSelection(); + + if (colSel.size() > 0) + { + addHistoryItem(new HistoryItem("Remove Left", viewport.alignment, + HistoryItem.HIDE)); + + int min = colSel.getMin(); + viewport.getAlignment().trimLeft(min); + colSel.compensateForEdit(0, min); + + if (viewport.getSelectionGroup() != null) + { + viewport.getSelectionGroup().adjustForRemoveLeft(min); + } + + Vector groups = viewport.alignment.getGroups(); + + for (int i = 0; i < groups.size(); i++) + { + SequenceGroup sg = (SequenceGroup) groups.get(i); + + if (!sg.adjustForRemoveLeft(min)) + { + viewport.alignment.deleteGroup(sg); + } + } + + alignPanel.repaint(); + } + } + + public void remove2RightMenuItem_actionPerformed(ActionEvent e) + { + ColumnSelection colSel = viewport.getColumnSelection(); + + if (colSel.size() > 0) + { + addHistoryItem(new HistoryItem("Remove Right", viewport.alignment, + HistoryItem.HIDE)); + + int max = colSel.getMax(); + viewport.getAlignment().trimRight(max); + + if (viewport.getSelectionGroup() != null) + { + viewport.getSelectionGroup().adjustForRemoveRight(max); + } + + Vector groups = viewport.alignment.getGroups(); + + for (int i = 0; i < groups.size(); i++) + { + SequenceGroup sg = (SequenceGroup) groups.get(i); + + if (!sg.adjustForRemoveRight(max)) + { + viewport.alignment.deleteGroup(sg); + } + } + + 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(); + } + + public void removeAllGapsMenuItem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Remove Gaps", viewport.alignment, + HistoryItem.HIDE)); + + SequenceI current; + int jSize; + + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + current = viewport.getAlignment().getSequenceAt(i); + jSize = current.getLength(); + + for (int j = 0; j < jSize; j++) + { + if (jalview.util.Comparison.isGap(current.getCharAt(j))) + { + current.deleteCharAt(j); + j--; + jSize--; + } + } + } + + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); + } + + public void padGapsMenuitem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Pad Gaps", viewport.alignment, + HistoryItem.HIDE)); + + SequenceI current; + int Width = viewport.getAlignment().getWidth() - 1; + + for (int i = 0; i < viewport.getAlignment().getSequences().size(); + i++) + { + current = viewport.getAlignment().getSequenceAt(i); + + if (current.getLength() < Width) + { + current.insertCharAt(Width, viewport.getGapCharacter()); + } + } + + viewport.updateConservation(); + viewport.updateConsensus(); + alignPanel.repaint(); + } + + public void findMenuItem_actionPerformed(ActionEvent e) + { + 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); + } + + public void font_actionPerformed(ActionEvent e) + { + FontChooser fc = new FontChooser(alignPanel); + } + + protected void fullSeqId_actionPerformed(ActionEvent e) + { + viewport.setShowFullId(fullSeqId.isSelected()); + + alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth()); + alignPanel.repaint(); + } + + protected void colourTextMenuItem_actionPerformed(ActionEvent e) + { + viewport.setColourText(colourTextMenuItem.isSelected()); + alignPanel.repaint(); + } + + protected void wrapMenuItem_actionPerformed(ActionEvent e) + { + viewport.setWrapAlignment(wrapMenuItem.isSelected()); + alignPanel.setWrapAlignment(wrapMenuItem.isSelected()); + scaleAbove.setVisible(wrapMenuItem.isSelected()); + scaleLeft.setVisible(wrapMenuItem.isSelected()); + scaleRight.setVisible(wrapMenuItem.isSelected()); + alignPanel.repaint(); + } + + protected void scaleAbove_actionPerformed(ActionEvent e) + { + viewport.setScaleAboveWrapped(scaleAbove.isSelected()); + alignPanel.repaint(); + } + + protected void scaleLeft_actionPerformed(ActionEvent e) + { + viewport.setScaleLeftWrapped(scaleLeft.isSelected()); + alignPanel.repaint(); + } + + protected void scaleRight_actionPerformed(ActionEvent e) + { + viewport.setScaleRightWrapped(scaleRight.isSelected()); + alignPanel.repaint(); + } + + public void viewBoxesMenuItem_actionPerformed(ActionEvent e) + { + viewport.setShowBoxes(viewBoxesMenuItem.isSelected()); + alignPanel.repaint(); + } + + public void viewTextMenuItem_actionPerformed(ActionEvent e) + { + viewport.setShowText(viewTextMenuItem.isSelected()); + alignPanel.repaint(); + } + + protected void renderGapsMenuItem_actionPerformed(ActionEvent e) + { + viewport.setRenderGaps(renderGapsMenuItem.isSelected()); + alignPanel.repaint(); + } + + public void sequenceFeatures_actionPerformed(ActionEvent evt) + { + viewport.showSequenceFeatures(sequenceFeatures.isSelected()); + + if (viewport.showSequenceFeatures && + ! ( (Alignment) viewport.alignment).featuresAdded) + { + SequenceFeatureFetcher sft = new SequenceFeatureFetcher(viewport. + alignment, + alignPanel); + ( (Alignment) viewport.alignment).featuresAdded = true; + } + + alignPanel.repaint(); + } + + public void annotationPanelMenuItem_actionPerformed(ActionEvent e) + { + if (annotationPanelMenuItem.isSelected() && + viewport.getWrapAlignment()) + { + annotationPanelMenuItem.setSelected(false); + + return; + } + + viewport.setShowAnnotation(annotationPanelMenuItem.isSelected()); + alignPanel.setAnnotationVisible(annotationPanelMenuItem.isSelected()); + } + + public void overviewMenuItem_actionPerformed(ActionEvent e) + { + if (alignPanel.overviewPanel != null) + { + return; + } + + JInternalFrame frame = new JInternalFrame(); + OverviewPanel overview = new OverviewPanel(alignPanel); + frame.setContentPane(overview); + Desktop.addInternalFrame(frame, "Overview " + this.getTitle(), + frame.getWidth(), frame.getHeight()); + frame.pack(); + frame.setLayer(JLayeredPane.PALETTE_LAYER); + frame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed( + javax.swing.event.InternalFrameEvent evt) + { + alignPanel.setOverviewPanel(null); + } + ; + }); + + alignPanel.setOverviewPanel(overview); + } + + protected void noColourmenuItem_actionPerformed(ActionEvent e) + { + changeColour(null); + } + + public void clustalColour_actionPerformed(ActionEvent e) + { + changeColour(new ClustalxColourScheme( + viewport.alignment.getSequences(), viewport.alignment.getWidth())); + } + + public void zappoColour_actionPerformed(ActionEvent e) + { + changeColour(new ZappoColourScheme()); + } + + public void taylorColour_actionPerformed(ActionEvent e) + { + changeColour(new TaylorColourScheme()); + } + + public void hydrophobicityColour_actionPerformed(ActionEvent e) + { + changeColour(new HydrophobicColourScheme()); + } + + public void helixColour_actionPerformed(ActionEvent e) + { + changeColour(new HelixColourScheme()); + } + + public void strandColour_actionPerformed(ActionEvent e) + { + changeColour(new StrandColourScheme()); + } + + public void turnColour_actionPerformed(ActionEvent e) + { + changeColour(new TurnColourScheme()); + } + + public void buriedColour_actionPerformed(ActionEvent e) + { + changeColour(new BuriedColourScheme()); + } + + public void nucleotideColour_actionPerformed(ActionEvent e) + { + changeColour(new NucleotideColourScheme()); + } + + protected void applyToAllGroups_actionPerformed(ActionEvent e) + { + viewport.setColourAppliesToAllGroups(applyToAllGroups.isSelected()); + } + + void changeColour(ColourSchemeI cs) + { + int threshold = 0; + + if (viewport.getAbovePIDThreshold()) + { + threshold = SliderPanel.setPIDSliderSource(alignPanel, cs, + "Background"); + + if (cs instanceof ResidueColourScheme) + { + ( (ResidueColourScheme) cs).setThreshold(threshold); + } + else if (cs instanceof ScoreColourScheme) + { + ( (ScoreColourScheme) cs).setThreshold(threshold); + } + + viewport.setGlobalColourScheme(cs); + } + else if (cs instanceof ResidueColourScheme) + { + ( (ResidueColourScheme) cs).setThreshold(0); + } + else if (cs instanceof ScoreColourScheme) + { + ( (ScoreColourScheme) cs).setThreshold(0); + } + + if (viewport.getConservationSelected()) + { + ConservationColourScheme ccs = null; + + Alignment al = (Alignment) viewport.alignment; + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, + al.getSequences(), 0, + al.getWidth() - 1); + + c.calculate(); + c.verdict(false, viewport.ConsPercGaps); + + ccs = new ConservationColourScheme(c, cs); + + // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS! + ccs.setConsensus(viewport.vconsensus); + viewport.setGlobalColourScheme(ccs); + + ccs.inc = SliderPanel.setConservationSlider(alignPanel, ccs, + "Background"); + } + else + { + // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS! + if (cs != null) + { + cs.setConsensus(viewport.vconsensus); + } + + viewport.setGlobalColourScheme(cs); + } + + if (viewport.getColourAppliesToAllGroups()) + { + Vector groups = viewport.alignment.getGroups(); + + for (int i = 0; i < groups.size(); i++) + { + SequenceGroup sg = (SequenceGroup) groups.elementAt(i); + + if (cs == null) + { + sg.cs = null; + } + else if (cs instanceof ClustalxColourScheme) + { + sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth()); + } + else if (cs instanceof UserColourScheme) + { + sg.cs = new UserColourScheme( ( (UserColourScheme) cs).getColours()); + } + else + { + try + { + sg.cs = (ColourSchemeI) cs.getClass().newInstance(); + } + catch (Exception ex) + { + } + } + + if (viewport.getAbovePIDThreshold()) + { + if (sg.cs instanceof ResidueColourScheme) + { + ( (ResidueColourScheme) sg.cs).setThreshold(threshold); + } + else if (sg.cs instanceof ScoreColourScheme) + { + ( (ScoreColourScheme) sg.cs).setThreshold(threshold); + } + + sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, + sg.getWidth())); + } + + if (viewport.getConservationSelected()) + { + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, + sg.sequences, 0, + viewport.alignment.getWidth() - 1); + c.calculate(); + c.verdict(false, viewport.ConsPercGaps); + + ConservationColourScheme ccs = new ConservationColourScheme(c, + sg.cs); + + // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS! + ccs.setConsensus(AAFrequency.calculate(sg.sequences, 0, + sg.getWidth())); + sg.cs = ccs; + } + else if (cs != null) + { + // MUST NOTIFY THE COLOURSCHEME OF CONSENSUS! + sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, + sg.getWidth())); + } + } + } + + if (alignPanel.getOverviewPanel() != null) + { + alignPanel.getOverviewPanel().updateOverviewImage(); + } + + alignPanel.repaint(); + } + + protected void modifyPID_actionPerformed(ActionEvent e) + { + if (viewport.getAbovePIDThreshold()) + { + SliderPanel.setPIDSliderSource(alignPanel, + viewport.getGlobalColourScheme(), + "Background"); + SliderPanel.showPIDSlider(); + } + } + + protected void modifyConservation_actionPerformed(ActionEvent e) + { + if (viewport.getConservationSelected()) + { + SliderPanel.setConservationSlider(alignPanel, + viewport.globalColourScheme, + "Background"); + SliderPanel.showConservationSlider(); + } + } + + protected void conservationMenuItem_actionPerformed(ActionEvent e) + { + viewport.setConservationSelected(conservationMenuItem.isSelected()); + + viewport.setAbovePIDThreshold(false); + abovePIDThreshold.setSelected(false); + + ColourSchemeI cs = viewport.getGlobalColourScheme(); + + if (cs instanceof ConservationColourScheme) + { + changeColour( ( (ConservationColourScheme) cs).cs); + } + else + { + changeColour(cs); + } + + modifyConservation_actionPerformed(null); + } + + public void abovePIDThreshold_actionPerformed(ActionEvent e) + { + viewport.setAbovePIDThreshold(abovePIDThreshold.isSelected()); + + conservationMenuItem.setSelected(false); + viewport.setConservationSelected(false); + + ColourSchemeI cs = viewport.getGlobalColourScheme(); + + if (cs instanceof ConservationColourScheme) + { + changeColour( ( (ConservationColourScheme) cs).cs); + } + else + { + changeColour(cs); + } + + modifyPID_actionPerformed(null); + } + + public void userDefinedColour_actionPerformed(ActionEvent e) + { + new UserDefinedColours(alignPanel, null); + } + + public void PIDColour_actionPerformed(ActionEvent e) + { + changeColour(new PIDColourScheme()); + } + + public void BLOSUM62Colour_actionPerformed(ActionEvent e) + { + changeColour(new Blosum62ColourScheme()); + } + + 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(); + } + + public void sortIDMenuItem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("ID Sort", viewport.alignment, + HistoryItem.SORT)); + AlignmentSorter.sortByID(viewport.getAlignment()); + alignPanel.repaint(); + } + + public void sortGroupMenuItem_actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Group Sort", viewport.alignment, + HistoryItem.SORT)); + + // AlignmentSorter.sortByGroup(viewport.getAlignment()); + AlignmentSorter.sortGroups(viewport.getAlignment()); + alignPanel.repaint(); + } + + public void removeRedundancyMenuItem_actionPerformed(ActionEvent e) + { + RedundancyPanel sp = new RedundancyPanel(alignPanel, this); + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(sp); + Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, + 100, false); + } + + public void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) + { + if ( (viewport.getSelectionGroup() == null) || + (viewport.getSelectionGroup().getSize() < 2)) + { + JOptionPane.showInternalMessageDialog(this, + "You must select at least 2 sequences.", + "Invalid Selection", + JOptionPane.WARNING_MESSAGE); + } + else + { + JInternalFrame frame = new JInternalFrame(); + frame.setContentPane(new PairwiseAlignPanel(viewport)); + Desktop.addInternalFrame(frame, "Pairwise Alignment", 600, 500); + } + } + + public void PCAMenuItem_actionPerformed(ActionEvent e) + { + 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); + + return; + } + + try + { + 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) + { + String ltitle; + final TreePanel tp; + + if ( (viewport.getSelectionGroup() != null) && + (viewport.getSelectionGroup().getSize() > 3)) + { + 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); + } + + 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() + { + public void actionPerformed(ActionEvent e) + { + addHistoryItem(new HistoryItem("Sort", viewport.alignment, + HistoryItem.SORT)); + + // TODO: JBPNote - have to map order entries to curent SequenceI pointers + AlignmentSorter.sortBy(viewport.getAlignment(), order); + alignPanel.repaint(); + } + }); + } + + void addTreeMenuItem(final TreePanel treePanel, String title) + { + final JMenuItem item = new JMenuItem(title); + + treeCount++; + + if (treeCount == 1) + { + sort.add(sortByTreeMenu); + } + + 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(); + } + } + }); + } + + 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(); + + 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) + { + jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", + title, msa, false, true); + } + } + + 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)) + { + // 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(); + + 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) + { + jalview.ws.MsaWSClient ct = new jalview.ws.MsaWSClient("ClustalWS", + title, msa, true, true); + } + } + + protected void jpred_actionPerformed(ActionEvent e) + { + SequenceI seq = null; + SequenceI[] msa = null; + + 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); + } + } + } + + if (msa != null) + { + 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"); + } + } + + protected void msaAlignMenuItem_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(); + + 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) + { + MsaWSClient ct = new jalview.ws.MsaWSClient("MuscleWS", title, msa, + false, true); + } + } + + 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"); + + 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"); + ShowNewickTree(fin, choice); + } + catch (Exception ex) + { + JOptionPane.showMessageDialog(Desktop.desktop, + "Problem reading tree file", + ex.getMessage(), + JOptionPane.WARNING_MESSAGE); + ex.printStackTrace(); + } + } + } + + public void ShowNewickTree(NewickFile nf, String title) + { + try + { + nf.parse(); + + if (nf.getTree() != null) + { + TreePanel tp = new TreePanel(viewport, + viewport.getAlignment().getSequences(), nf, + "FromFile", + title); + Desktop.addInternalFrame(tp, title, 600, 500); + addTreeMenuItem(tp, title); + viewport.setCurrentTree(tp.getTree()); + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + 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 1f5ec79..bd43a97 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -1,90 +1,86 @@ /* -* 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.gui; +import java.util.*; + import java.awt.*; + import jalview.analysis.*; -import jalview.analysis.NJTree; +import jalview.bin.*; import jalview.datamodel.*; import jalview.schemes.*; -import java.util.*; -import jalview.bin.Cache; 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 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; - + 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 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.endRes = al.getWidth() - 1; this.startSeq = 0; - this.endSeq = al.getHeight()-1; + this.endSeq = al.getHeight() - 1; updateFromPreferences(); - } public void updateFromPreferences() @@ -95,20 +91,30 @@ public class AlignViewport 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) + + if ( (fontName != null) && (fontStyle != null) && (fontSize != null)) { int style = 0; - if(fontStyle.equals("bold")) + + if (fontStyle.equals("bold")) + { style = 1; - else if(fontStyle.equals("italic")) + } + else if (fontStyle.equals("italic")) + { style = 2; + } + setFont(new Font(fontName, style, Integer.parseInt(fontSize))); } else + { setFont(font); + } alignment.setGapCharacter(Preferences.gapSymbol); @@ -116,49 +122,55 @@ public class AlignViewport // as Blosum and Clustal require this to be done updateConservation(); updateConsensus(); - if(Preferences.defaultColour!=null) + + if (Preferences.defaultColour != null) { - globalColourScheme = ColourSchemeProperty.getColour(alignment, Preferences.defaultColour); - if(globalColourScheme instanceof UserColourScheme) + 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 Vector vconsensus; - AlignmentAnnotation consensus; - AlignmentAnnotation conservation; - AlignmentAnnotation quality; + if (globalColourScheme != null) + { + globalColourScheme.setConsensus(vconsensus); + } + } + } - public int ConsPercGaps = 25; // JBPNote : This should be a scalable property! + 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); + 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]; + Annotation[] annotations = new Annotation[alWidth]; + Annotation[] qannotations = new Annotation[alWidth]; String sequence = cons.getConsSequence().getSequence(); - float minR,minG,minB, maxR,maxG,maxB; + 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 + 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(); @@ -167,108 +179,140 @@ public class AlignViewport 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 = Integer.parseInt(sequence.charAt(i) + ""); + value = 11; } - catch (Exception ex) + + if (sequence.charAt(i) == '+') { - if (sequence.charAt(i) == '*') value = 11; - if (sequence.charAt(i) == '+') value = 10; + value = 10; } - float vprop = value-min; - vprop/=max; - annotations[i] = new Annotation(sequence.charAt(i) + "", - "", ' ', value, new Color(minR+maxR*vprop, minG+maxG*vprop, minB+maxB*vprop)); + } + + float vprop = value - min; + vprop /= max; + annotations[i] = new Annotation(sequence.charAt(i) + "", "", ' ', + value, + new Color(minR + (maxR * vprop), + minG + (maxG * vprop), + minB + (maxB * vprop))); + // Quality calc - value = ((Double) cons.quality.get(i)).floatValue(); + 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)); + vprop /= qmax; + qannotations[i] = new Annotation(" ", String.valueOf(value), ' ', + value, + new Color(minR + (maxR * vprop), + minG + (maxG * vprop), + minB + (maxB * vprop))); } - if(conservation==null) + if (conservation == null) { conservation = new AlignmentAnnotation("Conservation", - "Conservation of total alignment less than "+ConsPercGaps+"% gaps", - annotations, - 0f, // cons.qualityRange[0].floatValue(), + "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); + + 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) + cons.qualityRange[1].floatValue(), 1); + + if (showQuality) + { alignment.addAnnotation(quality); + } } - else { + else + { conservation.annotations = annotations; quality.annotations = qannotations; quality.graphMax = cons.qualityRange[1].floatValue(); } - - } public void updateConsensus() { - Annotation [] annotations = new Annotation[alignment.getWidth()]; + 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(); + if (vconsensus == null) + { + vconsensus = alignment.getAAFrequency(); + } else { - Vector temp = alignment.getAAFrequency(); - vconsensus.clear(); - Enumeration e = temp.elements(); - while(e.hasMoreElements()) - { - vconsensus.add(e.nextElement()); - } + Vector temp = alignment.getAAFrequency(); + vconsensus.clear(); + + Enumeration e = temp.elements(); + + while (e.hasMoreElements()) + { + vconsensus.add(e.nextElement()); + } } + Hashtable hash = null; - for (int i = 0; i2) - { - mouseOver = "["+maxRes+"] "; - maxRes = "+ "; - } + hash = (Hashtable) vconsensus.elementAt(i); + + float value = Float.parseFloat(hash.get("maxCount").toString()); + value /= Float.parseFloat(hash.get("size").toString()); + + value *= 100; - mouseOver += (int)value+"%"; - annotations[i] = new Annotation(maxRes, mouseOver, ' ', value); + 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(consensus==null) - { - consensus = new AlignmentAnnotation("Consensus", - "PID", annotations, 0f, 100f, 1); - if(showIdentity) - alignment.addAnnotation(consensus); - } - else - consensus.annotations = annotations; + if (consensus == null) + { + consensus = new AlignmentAnnotation("Consensus", "PID", + annotations, 0f, 100f, 1); + if (showIdentity) + { + alignment.addAnnotation(consensus); + } + } + else + { + consensus.annotations = annotations; + } } - public SequenceGroup getSelectionGroup() { return selectionGroup; @@ -279,42 +323,44 @@ public class AlignViewport selectionGroup = sg; } + public boolean getConservationSelected() + { + return conservationColourSelected; + } - public boolean getConservationSelected() - { - return conservationColourSelected; - } - - public void setConservationSelected(boolean b) - { - conservationColourSelected = b; - } + public void setConservationSelected(boolean b) + { + conservationColourSelected = b; + } - public boolean getAbovePIDThreshold() - { - return abovePIDThreshold; - } + public boolean getAbovePIDThreshold() + { + return abovePIDThreshold; + } - public void setAbovePIDThreshold(boolean b) - { - abovePIDThreshold = b; - } + public void setAbovePIDThreshold(boolean b) + { + abovePIDThreshold = b; + } - public int getStartRes() { + public int getStartRes() + { return startRes; } - public int getEndRes() { + public int getEndRes() + { return endRes; } - public int getStartSeq() { + public int getStartSeq() + { return startSeq; } public void setGlobalColourScheme(ColourSchemeI cs) { - globalColourScheme = cs; + globalColourScheme = cs; } public ColourSchemeI getGlobalColourScheme() @@ -322,91 +368,134 @@ public class AlignViewport return globalColourScheme; } - - public void setStartRes(int res) { + public void setStartRes(int res) + { this.startRes = res; } - public void setStartSeq(int seq) { + + public void setStartSeq(int seq) + { this.startSeq = seq; } - public void setEndRes(int res) { - if (res > alignment.getWidth()-1) { + + 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; + res = alignment.getWidth() - 1; } - if (res < 0) { + + if (res < 0) + { res = 0; } + this.endRes = res; } - public void setEndSeq(int seq) { - if (seq > alignment.getHeight()) { + + public void setEndSeq(int seq) + { + if (seq > alignment.getHeight()) + { seq = alignment.getHeight(); } - if (seq < 0) { + + if (seq < 0) + { seq = 0; } + this.endSeq = seq; } - public int getEndSeq() { + + public int getEndSeq() + { return endSeq; } - public void setFont(Font f) { + 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() { + public Font getFont() + { return font; } - public void setCharWidth(int w) { + + public void setCharWidth(int w) + { this.charWidth = w; } - public int getCharWidth() { + + public int getCharWidth() + { return charWidth; } - public void setCharHeight(int h) { + + public void setCharHeight(int h) + { this.charHeight = h; } - public int getCharHeight() { + + public int getCharHeight() + { return charHeight; } - public void setChunkWidth(int w) { + + public void setChunkWidth(int w) + { this.chunkWidth = w; } - public int getChunkWidth() { + + public int getChunkWidth() + { return chunkWidth; } - public void setChunkHeight(int h) { + + public void setChunkHeight(int h) + { this.chunkHeight = h; } - public int getChunkHeight() { + + public int getChunkHeight() + { return chunkHeight; } - public AlignmentI getAlignment() { + + public AlignmentI getAlignment() + { return alignment; } - public void setAlignment(AlignmentI align) { + + public void setAlignment(AlignmentI align) + { this.alignment = align; } - public void setWrapAlignment(boolean state) { + public void setWrapAlignment(boolean state) + { wrapAlignment = state; } - public void setShowText(boolean state) { + + public void setShowText(boolean state) + { showText = state; } - public void setRenderGaps(boolean state){ + public void setRenderGaps(boolean state) + { renderGaps = state; } - public boolean getColourText() { return showColourText; @@ -417,79 +506,117 @@ public class AlignViewport showColourText = state; } - public void setShowBoxes(boolean state) { + public void setShowBoxes(boolean state) + { showBoxes = state; } - public boolean getWrapAlignment() { - return wrapAlignment; + public boolean getWrapAlignment() + { + return wrapAlignment; } - public boolean getShowText() { + + public boolean getShowText() + { return showText; } - public boolean getShowBoxes() { + + public boolean getShowBoxes() + { return showBoxes; } - public char getGapCharacter() { + public char getGapCharacter() + { return getAlignment().getGapCharacter(); } - public void setGapCharacter(char gap) { - if (getAlignment() != null) { + + public void setGapCharacter(char gap) + { + if (getAlignment() != null) + { getAlignment().setGapCharacter(gap); } } - public void setThreshold(int thresh) { + + public void setThreshold(int thresh) + { threshold = thresh; } - public int getThreshold() { + + public int getThreshold() + { return threshold; } - public void setIncrement(int inc) { + + public void setIncrement(int inc) + { increment = inc; } - public int getIncrement() { + + public int getIncrement() + { return increment; } - public int getIndex(int y) { - int y1 = 0; + + public int getIndex(int y) + { + int y1 = 0; int starty = getStartSeq(); - int endy = getEndSeq(); + int endy = getEndSeq(); - for (int i = starty; i <= endy; i++) { - if (i < alignment.getHeight() && alignment.getSequenceAt(i) != null) { + for (int i = starty; i <= endy; i++) + { + if ( (i < alignment.getHeight()) && + (alignment.getSequenceAt(i) != null)) + { int y2 = y1 + getCharHeight(); - if (y>=y1 && y <=y2) { + if ( (y >= y1) && (y <= y2)) + { return i; } - y1 = y2; - } else { + + y1 = y2; + } + else + { return -1; } } + return -1; } - public ColumnSelection getColumnSelection() { + public ColumnSelection getColumnSelection() + { return colSel; } - public void resetSeqLimits(int height) { - setEndSeq(height/getCharHeight()); + public void resetSeqLimits(int height) + { + setEndSeq(height / getCharHeight()); } - public void setCurrentTree(NJTree tree) { - currentTree = tree; + + public void setCurrentTree(NJTree tree) + { + currentTree = tree; } - public NJTree getCurrentTree() { + + public NJTree getCurrentTree() + { return currentTree; } public void setColourAppliesToAllGroups(boolean b) - { colourAppliesToAllGroups = b; } + { + colourAppliesToAllGroups = b; + } public boolean getColourAppliesToAllGroups() - {return colourAppliesToAllGroups; } + { + return colourAppliesToAllGroups; + } public boolean getShowFullId() { @@ -502,38 +629,59 @@ public class AlignViewport } public boolean getShowAnnotation() - { return showAnnotation; } + { + return showAnnotation; + } public void setShowAnnotation(boolean b) - { showAnnotation = b; } + { + showAnnotation = b; + } public boolean getScaleAboveWrapped() - { return scaleAboveWrapped;} + { + return scaleAboveWrapped; + } public boolean getScaleLeftWrapped() - { return scaleLeftWrapped; } + { + return scaleLeftWrapped; + } public boolean getScaleRightWrapped() - { return scaleRightWrapped; } + { + return scaleRightWrapped; + } public void setScaleAboveWrapped(boolean b) - { scaleAboveWrapped = b; } + { + scaleAboveWrapped = b; + } public void setScaleLeftWrapped(boolean b) - { scaleLeftWrapped = b; } + { + scaleLeftWrapped = b; + } public void setScaleRightWrapped(boolean b) - { scaleRightWrapped = b; } - // JBPNote Prolly only need this in the applet version. - private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(this); - public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) { + { + scaleRightWrapped = b; + } + + public void addPropertyChangeListener( + java.beans.PropertyChangeListener listener) + { changeSupport.addPropertyChangeListener(listener); } - public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) { + public void removePropertyChangeListener( + java.beans.PropertyChangeListener listener) + { changeSupport.removePropertyChangeListener(listener); } - public void firePropertyChange(String prop, Object oldvalue, Object newvalue) { + + 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 7a8a811..1a48af6 100755 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -1,46 +1,45 @@ /* -* 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.gui; -import jalview.jbgui.GAlignmentPanel; -import jalview.schemes.*; -import jalview.analysis.*; -import jalview.datamodel.*; +import java.io.*; +import javax.imageio.*; + import java.awt.*; import java.awt.event.*; -import java.awt.print.*; -import java.io.*; import java.awt.image.*; -import org.jibble.epsgraphics.*; -import javax.imageio.*; +import java.awt.print.*; 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 +public class AlignmentPanel + extends GAlignmentPanel implements AdjustmentListener, Printable { - - AlignViewport av; + AlignViewport av; OverviewPanel overviewPanel; - SeqPanel seqPanel; - IdPanel idPanel; + SeqPanel seqPanel; + IdPanel idPanel; IdwidthAdjuster idwidthAdjuster; public AlignFrame alignFrame; ScalePanel scalePanel; @@ -49,13 +48,15 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene // 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); + this.av = av; + seqPanel = new SeqPanel(av, this); + idPanel = new IdPanel(av, this); scalePanel = new ScalePanel(av, this); @@ -66,7 +67,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene annotationPanel = new AnnotationPanel(this); alabels = new AnnotationLabels(this); - annotationSpaceFillerHolder.setPreferredSize(annotationPanel.getPreferredSize()); + annotationSpaceFillerHolder.setPreferredSize(annotationPanel. + getPreferredSize()); annotationScroller.setPreferredSize(annotationPanel.getPreferredSize()); annotationScroller.setViewportView(annotationPanel); annotationSpaceFillerHolder.add(alabels, BorderLayout.CENTER); @@ -81,27 +83,31 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene hscroll.addAdjustmentListener(this); vscroll.addAdjustmentListener(this); - setFocusable(true); - addKeyListener(new KeyAdapter() - { - public void keyPressed(KeyEvent evt) - { - switch(evt.getKeyCode()) - { - case 27: // escape key - av.setSelectionGroup(null); - repaint(); - break; - - case KeyEvent.VK_DOWN: - alignFrame.moveSelectedSequences(false); - break; - case KeyEvent.VK_UP: - alignFrame.moveSelectedSequences(true); - break; - } - } - }); + setFocusable(true); + addKeyListener(new KeyAdapter() + { + public void keyPressed(KeyEvent evt) + { + switch (evt.getKeyCode()) + { + case 27: // escape key + av.setSelectionGroup(null); + repaint(); + + break; + + case KeyEvent.VK_DOWN: + alignFrame.moveSelectedSequences(false); + + break; + + case KeyEvent.VK_UP: + alignFrame.moveSelectedSequences(true); + + break; + } + } + }); } public void fontChanged() @@ -110,11 +116,14 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene // 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())); + 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); @@ -122,11 +131,11 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene repaint(); } - Dimension calculateIdWidth() { Graphics g = this.getGraphics(); - if(g==null) + + if (g == null) { javax.swing.JFrame f = new javax.swing.JFrame(); f.addNotify(); @@ -136,70 +145,83 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene FontMetrics fm = g.getFontMetrics(av.font); AlignmentI al = av.getAlignment(); - int i = 0; - int idWidth = 0; - String id; - while (i < al.getHeight() && al.getSequenceAt(i) != null) - { - 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++; - } - - // Also check annotation label widths - i=0; - if(al.getAlignmentAnnotation()!=null) - { - fm = g.getFontMetrics(alabels.getFont()); - while (i < al.getAlignmentAnnotation().length) - { - String label = al.getAlignmentAnnotation()[i].label; - if (fm.stringWidth(label) > idWidth) - idWidth = fm.stringWidth(label); - i++; - } - } - - return new Dimension(idWidth, 12); - } + int i = 0; + int idWidth = 0; + String id; + while ( (i < al.getHeight()) && (al.getSequenceAt(i) != null)) + { + SequenceI s = al.getSequenceAt(i); - public void highlightSearchResults(int [] results) - { - seqPanel.seqCanvas.highlightSearchResults( results ); + if (av.getShowFullId()) + { + id = s.getDisplayId(); + } + else + { + id = s.getName(); + } - // do we need to scroll the panel? - if(results!=null) + if (fm.stringWidth(id) > idWidth) + { + idWidth = fm.stringWidth(id); + } + + i++; + } + + // Also check annotation label widths + i = 0; + + if (al.getAlignmentAnnotation() != 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]); + fm = g.getFontMetrics(alabels.getFont()); + + while (i < al.getAlignmentAnnotation().length) + { + String label = al.getAlignmentAnnotation()[i].label; + + if (fm.stringWidth(label) > idWidth) + { + idWidth = fm.stringWidth(label); + } + + i++; + } } - } + return new Dimension(idWidth, 12); + } + + public void highlightSearchResults(int[] results) + { + seqPanel.seqCanvas.highlightSearchResults(results); + // 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; - public OverviewPanel getOverviewPanel() - { - return overviewPanel; - } + if ( (av.getStartRes() > start) || (av.getEndRes() < end) || + ( (av.getStartSeq() > results[0]) || + (av.getEndSeq() < results[0]))) + { + setScrollValues(start, results[0]); + } + } + } - public void setOverviewPanel(OverviewPanel op) - { - overviewPanel = op; - } + public OverviewPanel getOverviewPanel() + { + return overviewPanel; + } + public void setOverviewPanel(OverviewPanel op) + { + overviewPanel = op; + } public void setAnnotationVisible(boolean b) { @@ -207,7 +229,6 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene annotationScroller.setVisible(b); } - public void setWrapAlignment(boolean wrap) { scalePanelHolder.setVisible(!wrap); @@ -220,112 +241,130 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene idSpaceFillerPanel1.setVisible(!wrap); repaint(); - } - public void setColourScheme() { ColourSchemeI cs = av.getGlobalColourScheme(); - if(av.getConservationSelected()) + if (av.getConservationSelected()) { + Alignment al = (Alignment) av.getAlignment(); + Conservation c = new Conservation("All", + ResidueProperties.propHash, 3, + al.getSequences(), 0, + al.getWidth()); - Alignment al = (Alignment)av.getAlignment(); - Conservation c = new Conservation("All", - ResidueProperties.propHash, 3, al.getSequences(), 0, - al.getWidth() ); - - c.calculate(); - c.verdict(false, av.ConsPercGaps); - ConservationColourScheme ccs = new ConservationColourScheme(c, cs); + c.calculate(); + c.verdict(false, av.ConsPercGaps); - av.setGlobalColourScheme( ccs ); + ConservationColourScheme ccs = new ConservationColourScheme(c, cs); + av.setGlobalColourScheme(ccs); } repaint(); } - - int hextent = 0; - int vextent = 0; - // return value is true if the scroll is valid public boolean scrollUp(boolean up) { - if(up) + if (up) { - if(vscroll.getValue()<1) + if (vscroll.getValue() < 1) + { return false; - fastPaint = false; + } + + fastPaint = false; vscroll.setValue(vscroll.getValue() - 1); } else { - if(vextent+vscroll.getValue() >= av.getAlignment().getHeight()) - return false; - fastPaint = false; + if ( (vextent + vscroll.getValue()) >= av.getAlignment().getHeight()) + { + return false; + } + + fastPaint = false; vscroll.setValue(vscroll.getValue() + 1); } + fastPaint = true; + return true; } public boolean scrollRight(boolean right) { - if (right) { if (hscroll.getValue() < 1) + { return false; + } + fastPaint = false; hscroll.setValue(hscroll.getValue() - 1); } else { - if (hextent + hscroll.getValue() >= av.getAlignment().getWidth()) + if ( (hextent + hscroll.getValue()) >= av.getAlignment().getWidth()) + { return false; + } + fastPaint = false; hscroll.setValue(hscroll.getValue() + 1); } + fastPaint = true; + return true; } - public void setScrollValues(int x, int y) { - av.setEndRes(x + seqPanel.seqCanvas.getWidth()/av.getCharWidth()-1); + av.setEndRes( (x + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - + 1); - hextent = seqPanel.seqCanvas.getWidth()/av.charWidth; - vextent = seqPanel.seqCanvas.getHeight()/av.charHeight; + hextent = seqPanel.seqCanvas.getWidth() / av.charWidth; + vextent = seqPanel.seqCanvas.getHeight() / av.charHeight; - if(hextent > av.alignment.getWidth()) + if (hextent > av.alignment.getWidth()) + { hextent = av.alignment.getWidth(); - if(vextent > av.alignment.getHeight()) + } + + if (vextent > av.alignment.getHeight()) + { vextent = av.alignment.getHeight(); + } - if(hextent+x > av.getAlignment().getWidth()) - x = av.getAlignment().getWidth()- hextent; + if ( (hextent + x) > av.getAlignment().getWidth()) + { + x = av.getAlignment().getWidth() - hextent; + } - if(vextent+y > av.getAlignment().getHeight()) + if ( (vextent + y) > av.getAlignment().getHeight()) + { y = av.getAlignment().getHeight() - vextent; + } - if(y<0) + if (y < 0) + { y = 0; + } - if(x<0) - x=0; - - hscroll.setValues(x,hextent,0,av.getAlignment().getWidth()); - vscroll.setValues(y,vextent,0,av.getAlignment().getHeight() ); - - + if (x < 0) + { + x = 0; + } + hscroll.setValues(x, hextent, 0, av.getAlignment().getWidth()); + vscroll.setValues(y, vextent, 0, av.getAlignment().getHeight()); } - public void adjustmentValueChanged(AdjustmentEvent evt) { int oldX = av.getStartRes(); @@ -335,30 +374,38 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene { int x = hscroll.getValue(); av.setStartRes(x); - av.setEndRes(x + seqPanel.seqCanvas.getWidth()/av.getCharWidth()-1); + av.setEndRes( (x + + (seqPanel.seqCanvas.getWidth() / av.getCharWidth())) - 1); } 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 ); + 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()); + av.setEndSeq(offy + + (seqPanel.seqCanvas.getHeight() / av.getCharHeight())); } } - if(overviewPanel!=null) + if (overviewPanel != null) + { overviewPanel.setBoxPosition(); + } - if(av.getWrapAlignment() || !fastPaint) + if (av.getWrapAlignment() || !fastPaint) + { repaint(); + } else { idPanel.idCanvas.fastPaint(av.getStartSeq() - oldY); @@ -366,16 +413,18 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene av.getStartSeq() - oldY); scalePanel.repaint(); + if (av.getShowAnnotation()) + { annotationPanel.fastPaint(av.getStartRes() - oldX); + } } - } - public void paintComponent(Graphics g) { invalidate(); + Dimension d = idPanel.idCanvas.getPreferredSize(); idPanelHolder.setPreferredSize(d); hscrollFillerPanel.setPreferredSize(new Dimension(d.width, 12)); @@ -383,7 +432,8 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene if (av.getWrapAlignment()) { - int max = av.alignment.getWidth() / seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); + int max = av.alignment.getWidth() / + seqPanel.seqCanvas.getWrappedCanvasWidth(seqPanel.seqCanvas.getWidth()); vscroll.setMaximum(max); vscroll.setUnitIncrement(1); vscroll.setVisibleAmount(1); @@ -392,226 +442,270 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene { setScrollValues(av.getStartRes(), av.getStartSeq()); } - - - } - public int print(Graphics pg, PageFormat pf, int pi) throws PrinterException + public int print(Graphics pg, PageFormat pf, int pi) + throws PrinterException { - pg.translate((int)pf.getImageableX(), (int)pf.getImageableY()); + pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY()); int pwidth = (int) pf.getImageableWidth(); int pheight = (int) pf.getImageableHeight(); if (av.getWrapAlignment()) - return printWrappedAlignment(pg, pwidth,pheight, pi); + { + return printWrappedAlignment(pg, pwidth, pheight, pi); + } else - return printUnwrapped(pg,pwidth, pheight,pi); + { + return printUnwrapped(pg, pwidth, pheight, pi); + } } - public int printUnwrapped(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException + 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 idWidth = calculateIdWidth().width + 4; - FontMetrics fm = getFontMetrics(av.getFont()); - int scaleHeight = av.charHeight + fm.getDescent(); + pg.setColor(Color.white); + pg.fillRect(0, 0, pwidth, pheight); + pg.setFont(av.getFont()); - pg.setColor(Color.white); - pg.fillRect(0, 0, pwidth, pheight); - pg.setFont(av.getFont()); + //////////////////////////////////// + /// How many sequences and residues can we fit on a printable page? + int totalRes = (pwidth - idWidth) / av.getCharWidth(); - //////////////////////////////////// - /// How many sequences and residues can we fit on a printable page? - int totalRes = (pwidth - idWidth) / av.getCharWidth(); + int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) - + 1; - int totalSeq = (int) ( (pheight - scaleHeight) / av.getCharHeight()) - 1; + int pagesWide = (av.getAlignment().getWidth() / totalRes) + 1; - int pagesWide = av.getAlignment().getWidth() / totalRes + 1; + ///////////////////////////// + /// Only print these sequences and residues on this page + int startRes; - ///////////////////////////// - /// Only print these sequences and residues on this page - int startRes, endRes, startSeq, endSeq; - startRes = (pi % pagesWide) * totalRes; - endRes = startRes + totalRes - 1; - if (endRes > av.getAlignment().getWidth()-1) - endRes = av.getAlignment().getWidth()-1; + ///////////////////////////// + /// Only print these sequences and residues on this page + int endRes; - startSeq = (pi / pagesWide) * totalSeq; - endSeq = startSeq + totalSeq; - if (endSeq > av.getAlignment().getHeight()) - endSeq = av.getAlignment().getHeight(); + ///////////////////////////// + /// Only print these sequences and residues on this page + int startSeq; - int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight; + ///////////////////////////// + /// Only print these sequences and residues on this page + int endSeq; + startRes = (pi % pagesWide) * totalRes; + endRes = (startRes + totalRes) - 1; - if (av.showAnnotation) - pagesHigh += annotationPanel.getHeight(); + if (endRes > (av.getAlignment().getWidth() - 1)) + { + endRes = av.getAlignment().getWidth() - 1; + } + + startSeq = (pi / pagesWide) * totalSeq; + endSeq = startSeq + totalSeq; - pagesHigh /= pheight; + if (endSeq > av.getAlignment().getHeight()) + { + endSeq = av.getAlignment().getHeight(); + } - if (pi >= pagesWide * pagesHigh) - return Printable.NO_SUCH_PAGE; + int pagesHigh = ( (av.alignment.getHeight() / totalSeq) + 1) * pheight; - //draw Scale - pg.translate(idWidth, 0); - scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight); - pg.translate( -idWidth, scaleHeight); - //////////////// - // Draw the ids - Color currentColor = null; - Color currentTextColor = null; - 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; - } + if (av.showAnnotation) + { + pagesHigh += annotationPanel.getHeight(); + } - pg.setColor(currentColor); - pg.fillRect(0, - jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, - av.getCharHeight()), - idWidth, - av.getCharHeight()); + pagesHigh /= pheight; + + if (pi >= (pagesWide * pagesHigh)) + { + return Printable.NO_SUCH_PAGE; + } - pg.setColor(currentTextColor); + //draw Scale + pg.translate(idWidth, 0); + scalePanel.drawScale(pg, startRes, endRes, pwidth - idWidth, scaleHeight); + pg.translate( -idWidth, scaleHeight); - String string = av.getAlignment().getSequenceAt(i).getName(); - if (av.getShowFullId()) - string = av.getAlignment().getSequenceAt(i).getDisplayId(); + //////////////// + // Draw the ids + Color currentColor = null; + Color currentTextColor = null; - pg.drawString(string, 0, jalview.analysis.AlignmentUtil.getPixelHeight - (startSeq, i, av.getCharHeight()) + av.getCharHeight() - - (av.getCharHeight() / 5)); + 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 main sequence panel - pg.translate(idWidth, 0); - seqPanel.seqCanvas.drawPanel(pg, startRes, endRes, startSeq, endSeq, - startRes, startSeq, 0); + pg.setColor(currentColor); + pg.fillRect(0, + jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, + av.getCharHeight()), idWidth, av.getCharHeight()); + pg.setColor(currentTextColor); - if (av.showAnnotation && endSeq == av.alignment.getHeight()) + String string = av.getAlignment().getSequenceAt(i).getName(); + + if (av.getShowFullId()) { - pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight); - alabels.drawComponent( (Graphics2D) pg); - pg.translate(idWidth, 0); - annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes+1); + string = av.getAlignment().getSequenceAt(i).getDisplayId(); } - return Printable.PAGE_EXISTS; + pg.drawString(string, 0, + (jalview.analysis.AlignmentUtil.getPixelHeight(startSeq, i, + av.getCharHeight()) + av.getCharHeight()) - + (av.getCharHeight() / 5)); + } - } + // 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())) + { + pg.translate( -idWidth, (endSeq - startSeq) * av.charHeight); + alabels.drawComponent( (Graphics2D) pg); + pg.translate(idWidth, 0); + annotationPanel.drawComponent( (Graphics2D) pg, startRes, endRes + + 1); + } - public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, int pi) throws PrinterException + return Printable.PAGE_EXISTS; + } + + public int printWrappedAlignment(Graphics pg, int pwidth, int pheight, + int pi) + throws PrinterException { - int idWidth = calculateIdWidth().width + 4; + int idWidth = calculateIdWidth().width + 4; - int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth - idWidth); - int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * - ( (av.alignment.getWidth() - / resWidth) + 1) * av.charHeight; + int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth - + idWidth); + int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * + ( (av.alignment.getWidth() / resWidth) + + 1) * av.charHeight; + pg.setColor(Color.white); + pg.fillRect(0, 0, pwidth, pheight); + pg.setFont(av.getFont()); - pg.setColor(Color.white); - pg.fillRect(0, 0, pwidth, pheight); - pg.setFont(av.getFont()); + //////////////// + // Draw the ids + pg.setColor(Color.black); - //////////////// - // Draw the ids - pg.setColor(Color.black); + pg.translate(0, -pi * pheight); - pg.translate(0, -pi * pheight); + pg.setClip(0, pi * pheight, pwidth, pheight); - pg.setClip(0,pi*pheight,pwidth, pheight); + int ypos = 2 * av.charHeight; - int ypos = 2 * av.charHeight; - do + do + { + for (int i = 0; i < av.alignment.getHeight(); i++) { - 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, - AlignmentUtil.getPixelHeight(0, i, av.charHeight) + - ypos + - av.charHeight - (av.charHeight / 5)); + SequenceI s = av.alignment.getSequenceAt(i); + String string = s.getName(); + if (av.getShowFullId()) + { + string = s.getDisplayId(); } - ypos += (av.alignment.getHeight() + 2) * av.charHeight; - + pg.drawString(string, 0, + (AlignmentUtil.getPixelHeight(0, i, av.charHeight) + ypos + + av.charHeight) - (av.charHeight / 5)); } - while (ypos < totalHeight); - - pg.translate(idWidth, 0); - seqPanel.seqCanvas.drawWrappedPanel(pg, pwidth - idWidth, totalHeight, 0); - - if (pi * pheight < totalHeight) - return Printable.PAGE_EXISTS; - else - return Printable.NO_SUCH_PAGE; + ypos += ( (av.alignment.getHeight() + 2) * av.charHeight); + } + while (ypos < totalHeight); + pg.translate(idWidth, 0); + 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 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; + 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 { - jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), - new String[]{"eps"}, - new String[]{"Encapsulated Postscript"}, - "Encapsulated Postscript"); + 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; + } - 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); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); - if (av.getWrapAlignment()) - printWrappedAlignment(pg, width, height, 0); - else - printUnwrapped(pg, width, height, 0); + FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); + 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(); + pg.flush(); + pg.close(); } catch (Exception ex) { @@ -621,64 +715,76 @@ public class AlignmentPanel extends GAlignmentPanel implements AdjustmentListene 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; - } + 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; + } 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.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; + } + + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); - jalview.bin.Cache.setProperty("LAST_DIRECTORY",chooser.getSelectedFile().getParent()); FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - Graphics2D png = (Graphics2D)bi.getGraphics(); + BufferedImage bi = new BufferedImage(width, height, + BufferedImage.TYPE_INT_RGB); + Graphics2D png = (Graphics2D) bi.getGraphics(); - png.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + png.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - if (av.getWrapAlignment()) - printWrappedAlignment(png, width, height, 0); - else - printUnwrapped(png, width, height, 0); + if (av.getWrapAlignment()) + { + printWrappedAlignment(png, width, height, 0); + } + else + { + printUnwrapped(png, width, height, 0); + } - ImageIO.write(bi, "png", out); - out.close(); + ImageIO.write(bi, "png", out); + out.close(); } catch (Exception ex) { ex.printStackTrace(); } } - } -class Preview extends JFrame +class Preview + extends JFrame { - public Preview(Image image) { setResizable(true); @@ -691,22 +797,25 @@ class Preview extends JFrame } } -class PreviewPanel extends JPanel +class PreviewPanel + extends JPanel { Image image; + public PreviewPanel(Image image) { this.image = image; } + public void paintComponent(Graphics g) { - if(image!=null) - g.drawImage(image,0,0,this); + 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 f2603ea..1b9fd8f 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -1,44 +1,45 @@ - /* -* 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.gui; -import javax.swing.*; -import java.awt.event.*; import java.awt.*; +import java.awt.event.*; import java.awt.image.*; +import javax.swing.*; + import jalview.datamodel.*; -import jalview.io.FormatAdapter; -public class AnnotationLabels extends JPanel implements MouseListener, MouseMotionListener, ActionListener +public class AnnotationLabels + extends JPanel implements MouseListener, + MouseMotionListener, ActionListener { - boolean active = false; - Image image; - AlignmentPanel ap ; - boolean resizing = false; - int oldY, mouseX; 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"; + 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; @@ -48,8 +49,11 @@ public class AnnotationLabels extends JPanel implements MouseListener, MouseMoti java.net.URL url = getClass().getResource("/images/idwidth.gif"); Image temp = null; + if (url != null) + { temp = java.awt.Toolkit.getDefaultToolkit().createImage(url); + } try { @@ -57,9 +61,12 @@ public class AnnotationLabels extends JPanel implements MouseListener, MouseMoti mt.addImage(temp, 0); mt.waitForID(0); } - catch (Exception ex) {} + catch (Exception ex) + { + } - BufferedImage bi = new BufferedImage(temp.getHeight(this), temp.getWidth(this), + BufferedImage bi = new BufferedImage(temp.getHeight(this), + temp.getWidth(this), BufferedImage.TYPE_INT_RGB); Graphics2D g = (Graphics2D) bi.getGraphics(); g.rotate(Math.toRadians(90)); @@ -80,126 +87,175 @@ public class AnnotationLabels extends JPanel implements MouseListener, MouseMoti { AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - if(evt.getActionCommand().equals(ADDNEW)) + if (evt.getActionCommand().equals(ADDNEW)) { - String label = JOptionPane.showInputDialog(this, "Label for annotation"); - if(label==null) + String label = JOptionPane.showInputDialog(this, + "Label for annotation"); + + if (label == null) + { label = ""; - ap.av.alignment.addAnnotation(new AlignmentAnnotation - (label, - "New description", - new Annotation[ap.av.alignment.getWidth()])); + } + + ap.av.alignment.addAnnotation(new AlignmentAnnotation(label, + "New description", + new Annotation[ap.av.alignment.getWidth()])); + } + 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("Quality")) + { + ap.av.showQuality = false; + } + + if (aa[selectedRow].label.equals("Consensus")) + { + ap.av.showIdentity = false; + } + } + else if (evt.getActionCommand().equals(DELETE)) + { + ap.av.alignment.deleteAnnotation(aa[selectedRow]); + } + else if (evt.getActionCommand().equals(SHOWALL)) + { + for (int i = 0; i < aa.length; i++) + { + 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()); } - 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("Quality")) - ap.av.showQuality = false; - if(aa[selectedRow].label.equals("Consensus")) - ap.av.showIdentity = false; - } - else if(evt.getActionCommand().equals(DELETE)) - { - ap.av.alignment.deleteAnnotation(aa[selectedRow]); - } - else if(evt.getActionCommand().equals(SHOWALL)) - { - for(int i=0; i20) + if ( (d.height - dif) > 20) { - ap.annotationScroller.setPreferredSize(new Dimension(d.width,d.height - dif)); + 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.annotationSpaceFillerHolder.setPreferredSize(new Dimension( + d.width, d.height - dif)); ap.repaint(); } + ap.addNotify(); } - public void mouseMoved(MouseEvent evt) {} - public void mouseClicked(MouseEvent evt) {} + public void mouseMoved(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } public void paintComponent(Graphics g1) { - Graphics2D g = (Graphics2D)g1; - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + Graphics2D g = (Graphics2D) g1; + g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); drawComponent(g); } @@ -208,48 +264,56 @@ public class AnnotationLabels extends JPanel implements MouseListener, MouseMoti { FontMetrics fm = g.getFontMetrics(g.getFont()); g.setColor(Color.white); - g.fillRect(0,0, getWidth(), getHeight()); + 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; i0 && !aa[activeRow].hasText) - aa[activeRow].hasText = true; + if ( (label.length() > 0) && !aa[activeRow].hasText) + { + aa[activeRow].hasText = true; + } - for(int i=0; i0 && !aa[activeRow].hasText) - aa[activeRow].hasText = true; + if (label == null) + { + label = ""; + } - for(int i=0; i 0) && !aa[activeRow].hasText) { - anot[index] = new Annotation(label, "", type, 0); + aa[activeRow].hasText = true; } - anot[ index ].secondaryStructure = type; - anot[ index ].displayCharacter = label; - } + for (int i = 0; i < activeRes.size(); i++) + { + int index = Integer.parseInt(activeRes.get(i).toString()); + + if (anot[index] == null) + { + anot[index] = new Annotation(label, "", type, 0); + } + + anot[index].secondaryStructure = type; + anot[index].displayCharacter = label; + } } adjustPanelHeight(); activeRes = null; repaint(); - return; - + return; } public void mousePressed(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { - if(activeRes==null) + if (activeRes == null) + { return; + } JPopupMenu pop = new JPopupMenu("Structure type"); JMenuItem item = new JMenuItem(HELIX); @@ -237,371 +283,481 @@ public class AnnotationPanel extends JPanel implements MouseListener, MouseMotio item.addActionListener(this); pop.add(item); pop.show(this, evt.getX(), evt.getY()); + return; } + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - AlignmentAnnotation [] aa = av.alignment.getAlignmentAnnotation(); - if(aa==null) + if (aa == null) + { return; + } int height = 0; activeRow = -1; - for(int i=0; i-1 && res -1) && (res < aa[row].annotations.length) && + (aa[row].annotations[res] != null)) { this.setToolTipText(aa[row].annotations[res].description); - StringBuffer text = new StringBuffer("Sequence position " + (res + 1) + - " " + + + 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 mouseClicked(MouseEvent evt) + { + } public void paintComponent(Graphics g) { g.setColor(Color.white); - g.fillRect(0,0,getWidth(), getHeight()); + g.fillRect(0, 0, getWidth(), getHeight()); - if(fastPaint) + if (fastPaint) { g.drawImage(image, 0, 0, this); fastPaint = false; + return; } - imgWidth = (av.endRes-av.startRes+1) *av.charWidth; + imgWidth = (av.endRes - av.startRes + 1) * av.charWidth; - image = new BufferedImage(imgWidth, - ap.annotationPanel.getHeight(), - BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) image.getGraphics(); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + image = new BufferedImage(imgWidth, ap.annotationPanel.getHeight(), + BufferedImage.TYPE_INT_RGB); + gg = (Graphics2D) image.getGraphics(); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); - gg.setFont(av.getFont()); - fm = gg.getFontMetrics(); - - drawComponent( gg, av.startRes, av.endRes+1); - g.drawImage( image, 0, 0, this); + gg.setFont(av.getFont()); + fm = gg.getFontMetrics(); + drawComponent(gg, av.startRes, av.endRes + 1); + g.drawImage(image, 0, 0, this); } public void fastPaint(int horizontal) -{ - if( horizontal == 0 - || av.alignment.getAlignmentAnnotation()==null - || av.alignment.getAlignmentAnnotation().length<1 - ) { - repaint(); - return; - } + if ( (horizontal == 0) || + (av.alignment.getAlignmentAnnotation() == null) || + (av.alignment.getAlignmentAnnotation().length < 1)) + { + repaint(); - gg.copyArea( 0,0, imgWidth, getHeight(), -horizontal*av.charWidth, 0 ); - int sr=av.startRes, er=av.endRes+1, transX=0; + return; + } - 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; - } + gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.charWidth, 0); + int sr = av.startRes; + int er = av.endRes + 1; + int transX = 0; - gg.translate(transX, 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; + } - drawComponent(gg, sr, er); + gg.translate(transX, 0); - gg.translate( -transX, 0 ); + drawComponent(gg, sr, er); - fastPaint = true; - repaint(); -} + gg.translate( -transX, 0); + fastPaint = true; + repaint(); + } public void drawComponent(Graphics2D g, int startRes, int endRes) { g.setColor(Color.white); - g.fillRect(0,0,(endRes-startRes) *av.charWidth, getHeight()); - if(av.alignment.getAlignmentAnnotation()==null || av.alignment.getAlignmentAnnotation().length<1) + g.fillRect(0, 0, (endRes - startRes) * av.charWidth, getHeight()); + + if ( (av.alignment.getAlignmentAnnotation() == null) || + (av.alignment.getAlignmentAnnotation().length < 1)) { g.setColor(Color.white); - g.fillRect(0,0,getWidth(), getHeight()); + g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.black); - g.drawString("Alignment has no annotations",20,15); + g.drawString("Alignment has no annotations", 20, 15); + return; } - AlignmentAnnotation [] aa = av.alignment.getAlignmentAnnotation(); + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int j, x=0, y=0; - char [] lastSS = new char[aa.length]; - int [] lastSSX= new int[aa.length] ; - int iconOffset = av.charHeight/2; + 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 0)) + { + int charOffset = (av.charWidth - + fm.charWidth(row.annotations[j].displayCharacter. + charAt( + 0))) / 2; + g.setColor(row.annotations[j].colour); + if (j == 0) + { + if ( (row.annotations[0].secondaryStructure == 'H') || + (row.annotations[0].secondaryStructure == 'E')) + { + g.drawString(row.annotations[j].displayCharacter, + x, y + iconOffset + 2); + } + } + else if ( ( (row.annotations[j].secondaryStructure == 'H') || + (row.annotations[j].secondaryStructure == 'E')) && + ( (row.annotations[j - 1] == null) || + (row.annotations[j].secondaryStructure != row.annotations[j - + 1].secondaryStructure))) + { + g.drawString(row.annotations[j].displayCharacter, x, + y + iconOffset + 2); + } + if (!row.hasIcons) + { + g.drawString(row.annotations[j].displayCharacter, + x + charOffset, y + iconOffset + 2); + } + } - 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) + if (row.hasIcons) + { + if (!validRes || + (row.annotations[j].secondaryStructure != lastSS[i])) { - if (row.annotations[0].secondaryStructure == 'H' - || row.annotations[0].secondaryStructure == 'E') - g.drawString(row.annotations[j].displayCharacter, x, - y + iconOffset + 2); + 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 + 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; } - else if( (row.annotations[j].secondaryStructure=='H' - || row.annotations[j].secondaryStructure=='E') && - (row.annotations[j-1]==null || - row.annotations[j].secondaryStructure!=row.annotations[j-1].secondaryStructure)) + } - g.drawString(row.annotations[j].displayCharacter, x, y + iconOffset + 2); + if (validRes && row.isGraph) + { + g.setColor(new Color(0, 0, 180)); - if(!row.hasIcons) - 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); - 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=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 ); - } + 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); + } } - x+=av.charWidth; + x += av.charWidth; - if(row.hasIcons) - switch (lastSS[i]) + if (row.hasIcons) { - 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; + 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 && row.hasText) + { + y += av.charHeight; } - if(row.isGraph && row.hasText) - y+=av.charHeight; - if(!row.isGraph) - y+=aa[i].height; + if (!row.isGraph) + { + y += aa[i].height; + } } } // used by overview window - public void drawGraph(Graphics g, AlignmentAnnotation aa,int width, int y) + 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)); + g.fillRect(0, 0, width, y); + g.setColor(new Color(0, 0, 180)); + int x = 0; - for(int j=0; j max) { + for (int i = 0; i < selected.size(); i++) + { + if (columnAt(i) > max) + { max = columnAt(i); } } + return max; } - public int getMin() { + public int getMin() + { int min = 1000000000; - for (int i=0;i= start) - selected.setElementAt(new Integer(temp-change),i); + { + selected.setElementAt(new Integer(temp - change), i); + } } } } diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 262fc41..175a609 100755 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -1,115 +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 -*/ - -package jalview.gui; - -import jalview.jbgui.GCutAndPasteTransfer; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.datatransfer.*; -import jalview.datamodel.Alignment; -import jalview.io.FormatAdapter; -import jalview.datamodel.SequenceI; -import javax.swing.JOptionPane; -import jalview.io.IdentifyFile; - -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) - return; - try{ - textarea.setText( (String) contents.getTransferData(DataFlavor. - stringFlavor)); - }catch(Exception ex){} - } - - public void ok_actionPerformed(ActionEvent e) - { - 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); - } - - public void cancel_actionPerformed(ActionEvent e) - { - try{ - this.setClosed(true); - }catch(Exception ex){} - } - - -} +/* + * 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.gui; + +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 +{ + 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) + { + return; + } + + try + { + textarea.setText( (String) contents.getTransferData( + DataFlavor.stringFlavor)); + } + catch (Exception ex) + { + } + } + + public void ok_actionPerformed(ActionEvent e) + { + 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); + } + } + + 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 fca0acc..e239a10 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1,57 +1,61 @@ /* -* 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.gui; -import jalview.gui.*; -import jalview.io.*; -import jalview.datamodel.*; -import javax.swing.*; import java.awt.*; -import java.awt.event.*; +import java.awt.datatransfer.*; import java.awt.dnd.*; +import java.awt.event.*; import javax.swing.*; -import java.awt.datatransfer.*; -import jalview.bin.Cache; +import jalview.datamodel.*; +import jalview.io.*; -public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener +public class Desktop + extends jalview.jbgui.GDesktop implements DropTargetListener { public static JDesktopPane desktop; static int openFrameCount = 0; - static final int xOffset = 30, yOffset = 30; + static final int xOffset = 30; + static final int yOffset = 30; public Desktop() { - Image image =null; - try{ + Image image = null; + + try + { java.net.URL url = getClass().getResource("/images/logo.gif"); - if(url!=null) + + 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){} + } + catch (Exception ex) + { + } setTitle("Jalview 2005"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -60,11 +64,9 @@ public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListene 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() ); - + desktop.setDesktopManager(new DefaultDesktopManager()); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); String x = jalview.bin.Cache.getProperty("SCREEN_X"); @@ -72,311 +74,396 @@ public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListene 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) + if ( (x != null) && (y != null) && (width != null) && (height != null)) { - setBounds( Integer.parseInt(x), Integer.parseInt(y), - Integer.parseInt(width), Integer.parseInt(height)); + setBounds(Integer.parseInt(x), Integer.parseInt(y), + Integer.parseInt(width), Integer.parseInt(height)); } else - setBounds( (int)(screenSize.width-900)/2, - (int)(screenSize.height-650)/2, - 900 , - 650); + { + setBounds( (int) (screenSize.width - 900) / 2, + (int) (screenSize.height - 650) / 2, 900, 650); + } -this.addWindowListener(new WindowAdapter() -{ -public void windowClosing(WindowEvent evt) -{ - 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() + ""); -} -}); -setVisible(true); + this.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent evt) + { + 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() + ""); + } + }); + setVisible(true); -this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); + this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); -/////////Add a splashscreen on startup - /////////Add a splashscreen on startup + /////////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)); + 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) + + 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 ) + public static void addInternalFrame(final JInternalFrame frame, + String title, int w, int h, + boolean resizable) { - desktop.add(frame); - openFrameCount++; - try { - frame.setSelected(true); - } catch (java.beans.PropertyVetoException e) {} - 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() + desktop.add(frame); + openFrameCount++; + + try + { + frame.setSelected(true); + } + catch (java.beans.PropertyVetoException e) + { + } + + 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){}; + try + { + frame.setSelected(true); + frame.setIcon(false); + } + catch (java.beans.PropertyVetoException ex) + { + } + + ; } }); - frame.setVisible(true); - windowMenu.add(menuItem); - } + frame.setVisible(true); + windowMenu.add(menuItem); + } - public void dragEnter(DropTargetDragEvent evt){} - public void dragExit(DropTargetEvent evt){} - public void dragOver(DropTargetDragEvent evt){} - public void dropActionChanged(DropTargetDragEvent evt){} - public void drop(DropTargetDropEvent evt) -{ - Transferable t = evt.getTransferable(); - if(!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) - return; - - evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); - try{ - 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"; - if(file.endsWith(".jar")) - Jalview2XML.LoadJalviewAlign(file); + public void dragEnter(DropTargetDragEvent evt) + { + } + + public void dragExit(DropTargetEvent evt) + { + } + + public void dragOver(DropTargetDragEvent evt) + { + } + + public void dropActionChanged(DropTargetDragEvent evt) + { + } + + public void drop(DropTargetDropEvent evt) + { + Transferable t = evt.getTransferable(); + + if (!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) + { + return; + } + + evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); + + try + { + 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"; + + if (file.endsWith(".jar")) + { + Jalview2XML.LoadJalviewAlign(file); + } + else + { + String format = jalview.io.IdentifyFile.Identify(file, + protocol); + LoadFile(file, protocol, format); + } + } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + public void inputLocalFileMenuItem_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" + }, 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) + { + 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 = jalview.io.IdentifyFile.Identify(file, protocol); - LoadFile(file, protocol, format); + String format = IdentifyFile.Identify(choice, "File"); + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", format); + LoadFile(choice, "File", format); } - } + } + } - }catch(Exception ex){ex.printStackTrace();} + 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) + { + return; + } - public void inputLocalFileMenuItem_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"} - ,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) - { - 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); - } - } - } - - public void LoadFile(String file, String protocol, String format) - { - LoadingThread loader = new LoadingThread(file, protocol, format); - loader.start(); - } - - class LoadingThread extends Thread - { - String file, protocol, format; - - public LoadingThread(String file, String protocol, String format) - { - this.file = file; - this.protocol = protocol; - this.format = format; - } - public void run() - { - SequenceI [] sequences = null; - - 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{ - 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); - - } - } - - - 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) - 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; - } + 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); - } + } - public void inputTextboxMenuItem_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); - cap.setForInput(); - Desktop.addInternalFrame(cap, "Cut & Paste Alignment File", 600, 500); - } + 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_actionPerformed(ActionEvent e) - { - if(jalview.bin.Jalview.applet!=null) - jalview.bin.Jalview.applet.destroy(); + /* + * Exit the program + */ + public void quit_actionPerformed(ActionEvent e) + { + if (jalview.bin.Jalview.applet != null) + { + jalview.bin.Jalview.applet.destroy(); + } else + { 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 - { + } + } + + 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 + { 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); + 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.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(); - } - - 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"); - 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); - } - - } - - - 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) - { - String choice = chooser.getSelectedFile().getAbsolutePath(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser.getSelectedFile().getParent()); - Jalview2XML.LoadJalviewAlign(choice); - } - } -} + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + protected void preferences_actionPerformed(ActionEvent e) + { + Preferences pref = 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"); + + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save State"); + + 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); + } + } + 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) + { + String choice = chooser.getSelectedFile().getAbsolutePath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", + chooser.getSelectedFile().getParent()); + Jalview2XML.LoadJalviewAlign(choice); + } + } + + class LoadingThread + extends Thread + { + String file; + String protocol; + String format; + + public LoadingThread(String file, String protocol, String format) + { + this.file = file; + this.protocol = protocol; + this.format = format; + } + + public void run() + { + SequenceI[] sequences = null; + + 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 + { + 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); + } + } + } +} diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index 1dd434d..e80d01a 100755 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -1,35 +1,34 @@ /* -* 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.gui; -import jalview.datamodel.*; -import jalview.schemes.*; -import java.awt.*; import java.util.*; +import java.awt.*; + +import jalview.datamodel.*; + public class FeatureRenderer { AlignViewport av; - SequenceGroup currentSequenceGroup = null; - SequenceGroup [] allGroups = null; + SequenceGroup[] allGroups = null; Color resBoxColour; Graphics graphics; @@ -38,48 +37,60 @@ public class FeatureRenderer this.av = av; } - - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height) + 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() ) + + while (e.hasMoreElements()) { - SequenceFeature sf = (SequenceFeature)e.nextElement(); - if(sf.getStart()>seq.getEnd()) + 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; + int fstart = seq.findIndex(sf.getStart()) - 1; + int fend = seq.findIndex(sf.getEnd()) - 1; - if( (fstart<=end && fend>=start) ) + if ( ( (fstart <= end) && (fend >= start))) { - if(fstart<0) // fix for if the feature we have starts before the sequence start, - fstart = 0;// but the feature end is still valid!! + if (fstart < 0) + { // fix for if the feature we have starts before the sequence start, + fstart = 0; // but the feature end is still valid!! + } - if(fstart==fend) + if (fstart == fend) { g.setColor(Color.red); - g.fillRoundRect( (fstart - start) * width, y1, width, height, 4,4); + 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); - + 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) ) + + if (jalview.util.Comparison.isGap(s)) + { continue; + } g.setColor(Color.blue); - g.fillRect( (i-start) * width, y1, width, height); + g.fillRect( (i - start) * width, y1, width, height); g.setColor(Color.white); @@ -87,13 +98,11 @@ public class FeatureRenderer int charOffset = (width - fm.charWidth(s)) / 2; int pady = height / 5; g.drawString(String.valueOf(s), - charOffset + x1 + width * (i-start), - y1 + height - pady); + charOffset + x1 + (width * (i - start)), + (y1 + height) - pady); } } } - } - } - + } } diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index d20cb65..af1888c 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -1,42 +1,44 @@ /* -* 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.gui; -import jalview.jbgui.GFinder; -import jalview.datamodel.*; +import java.util.*; + +import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import java.util.*; -import java.awt.*; -public class Finder extends GFinder +import jalview.datamodel.*; +import jalview.jbgui.*; + +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; @@ -52,16 +54,17 @@ public class Finder extends GFinder SwingUtilities.invokeLater(new Runnable() { public void run() - { textfield.requestFocus(); } - }); - } - - public void internalFrameClosing(InternalFrameEvent evt) - { - cancel_actionPerformed(null); - } -}); + { + textfield.requestFocus(); + } + }); + } + public void internalFrameClosing(InternalFrameEvent evt) + { + cancel_actionPerformed(null); + } + }); } public void textfield_actionPerformed(ActionEvent e) @@ -76,213 +79,257 @@ public class Finder extends GFinder public void findAll_actionPerformed(ActionEvent e) { - resIndex=0; - seqIndex=0; + resIndex = 0; + seqIndex = 0; doSearch(true); } public void cancel_actionPerformed(ActionEvent e) { - try{ + try + { // if allResults is null, this effectively switches displaySearch flag in seqCanvas - ap.highlightSearchResults( null ); - ap.idPanel.highlightSearchResults( null ); - // frame.setClosed(true); - }catch(Exception ex){ } - } + ap.highlightSearchResults(null); + ap.idPanel.highlightSearchResults(null); + // frame.setClosed(true); + } + catch (Exception ex) + { + } + } public void createNewGroup_actionPerformed(ActionEvent e) { + Color[] newColors = new Color[24]; - Color [] newColors = new Color[24]; - for(int i=0; i<24; i++) - newColors[i] = new Color(60,160,115); - - jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(newColors); - String searchString = textfield.getText(); + 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(); + searchGroup = new SuperGroup(searchString, ucs, true, true, false); - for(int i=0; i0) - seq = (Sequence)(av.getSelectionGroup().getSequenceAt(0)); + if (av.getSelectionGroup().getSize() > 0) + { + seq = (Sequence) (av.getSelectionGroup().getSequenceAt(0)); + } else - seq = (Sequence)av.getAlignment().getSequenceAt(0); + { + 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 ) ); + searchResults.add(Integer.toString(av.getAlignment().findIndex(seq))); + searchResults.add(Integer.toString(seq.findIndex(res) - 1)); + searchResults.add(Integer.toString(seq.findIndex(res) - 1)); + } + catch (NumberFormatException ex) + { + } - }catch(NumberFormatException ex){} /////////////////////////////////////////////// + Color[] newColors = new Color[24]; + for (int i = 0; i < 24; i++) + { + newColors[i] = new Color(60, 160, 115); + } + jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme( + newColors); - Color [] newColors = new Color[24]; - for(int i=0; i<24; i++) - newColors[i] = new Color(60,160,115); - - jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(newColors); - - searchGroup = new SuperGroup(searchString, ucs , true, true, false); + searchGroup = new SuperGroup(searchString, ucs, true, true, false); int end = av.alignment.getHeight(); SequenceGroup selection = av.getSelectionGroup(); - if(selection!=null) - if(selection.getSize()<1 || (selection.getEndRes()-selection.getStartRes()<2)) - selection = null; - while( !found && seqIndex0) - ap.idPanel.highlightSearchResults( idMatch ); - + if ( (searchResults.size() == 0) && (idMatch.size() > 0)) + { + ap.idPanel.highlightSearchResults(idMatch); + } - if(searchResults.size()>0) + if (searchResults.size() > 0) { allResults = new int[searchResults.size()]; - for(int i=0; i 0) // scroll down - { - ss = es - vertical; - if(ss av.endSeq) - es = av.endSeq; - } + gg.copyArea(0, 0, getWidth(), imgHeight, 0, -vertical * av.charHeight); + int ss = av.startSeq; + int es = av.endSeq; + int transY = 0; + if (vertical > 0) // scroll down + { + ss = es - vertical; - gg.translate(0, transY); + 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 (es > av.endSeq) + { + es = av.endSeq; + } + } - drawIds(ss, es); + gg.translate(0, transY); - gg.translate( 0, -transY ); + drawIds(ss, es); + gg.translate(0, -transY); - fastPaint = true; - repaint(); + fastPaint = true; + repaint(); } public void paintComponent(Graphics g) @@ -119,70 +145,74 @@ public class IdCanvas extends JPanel { fastPaint = false; g.drawImage(image, 0, 0, this); + return; } imgHeight = getHeight(); - imgHeight -= imgHeight % av.charHeight; + imgHeight -= (imgHeight % av.charHeight); - if (imgHeight<1) + if (imgHeight < 1) + { return; + } - image = new BufferedImage(getWidth(), imgHeight, BufferedImage.TYPE_INT_RGB); + image = new BufferedImage(getWidth(), imgHeight, + BufferedImage.TYPE_INT_RGB); gg = (Graphics2D) image.getGraphics(); + //Fill in the background gg.setColor(Color.white); gg.fillRect(0, 0, getWidth(), imgHeight); gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + Font italic = new Font(av.getFont().getName(), Font.ITALIC, av.getFont().getSize()); gg.setFont(italic); - drawIds( av.getStartSeq(), av.endSeq); + drawIds(av.getStartSeq(), av.endSeq); g.drawImage(image, 0, 0, this); } void drawIds(int starty, int endy) { - Color currentColor = Color.white; + Color currentColor = Color.white; Color currentTextColor = Color.black; if (av.getWrapAlignment()) { + int rowSize = av.getEndRes() - av.getStartRes(); - int rowSize = av.getEndRes() - av.getStartRes(); - // Draw the rest of the panels - - for(int ypos=2*av.charHeight, row=av.startRes; - ypos <= getHeight() && row lastid) + { selectSeqs(lastid + 1, seq); + } lastid = seq; alignPanel.repaint(); @@ -76,95 +87,128 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene { 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+[swall-id:" + 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(); - } - } + 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+[swall-id:" + + 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 mouseEntered(MouseEvent e) { - if(scrollThread!=null) + if (scrollThread != null) + { scrollThread.running = false; + } } - public void mouseExited (MouseEvent e) + public void mouseExited(MouseEvent e) { - if(av.getWrapAlignment()) + if (av.getWrapAlignment()) + { return; + } - if(mouseDragging && e.getY()<0 && av.getStartSeq()>0) + if (mouseDragging && (e.getY() < 0) && (av.getStartSeq() > 0)) { scrollThread = new ScrollThread(true); } - if(mouseDragging && e.getY()>=getHeight() && av.alignment.getHeight()>av.getEndSeq()) + if (mouseDragging && (e.getY() >= getHeight()) && + (av.alignment.getHeight() > av.getEndSeq())) { scrollThread = new ScrollThread(false); } } - - public void mousePressed(MouseEvent e) { + public void mousePressed(MouseEvent e) + { if (e.getClickCount() == 2) + { return; + } int y = e.getY(); - if(av.getWrapAlignment()) - y-=2*av.charHeight; + + if (av.getWrapAlignment()) + { + y -= (2 * av.charHeight); + } int seq = av.getIndex(y); + if (seq == -1) + { return; + } if (javax.swing.SwingUtilities.isRightMouseButton(e)) { jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(alignPanel, - (Sequence)av.getAlignment().getSequenceAt(seq)); + (Sequence) av.getAlignment().getSequenceAt(seq)); pop.show(this, e.getX(), y); + return; } - if(!e.isControlDown() && !e.isShiftDown() && av.alignment.findGroup( av.alignment.getSequenceAt(seq))!=null) + 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)); + SequenceGroup sg = av.alignment.findGroup(av.alignment.getSequenceAt( + seq)); selection.setStartRes(0); - selection.setEndRes(av.alignment.getWidth()-1); - for (int i =0; i< sg.getSize(); i++) + selection.setEndRes(av.alignment.getWidth() - 1); + + for (int i = 0; i < sg.getSize(); i++) + { selection.addSequence(sg.getSequenceAt(i)); + } av.setSelectionGroup(selection); + return; } - if(av.getSelectionGroup()==null || ( !e.isControlDown() && av.getSelectionGroup()!=null)) + if ( (av.getSelectionGroup() == null) || + (!e.isControlDown() && (av.getSelectionGroup() != null))) + { av.setSelectionGroup(new SequenceGroup()); + } av.getSelectionGroup().setStartRes(0); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()-1); + av.getSelectionGroup().setEndRes(av.alignment.getWidth() - 1); - if(e.isShiftDown() && lastid!=-1) + if (e.isShiftDown() && (lastid != -1)) + { selectSeqs(lastid, seq); + } else + { selectSeq(seq); + } alignPanel.repaint(); } @@ -172,48 +216,56 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene void selectSeq(int seq) { lastid = seq; + SequenceI pickedSeq = av.getAlignment().getSequenceAt(seq); av.getSelectionGroup().addOrRemove(pickedSeq); } - void selectSeqs(int start, int end) { - + void selectSeqs(int start, int end) + { lastid = start; - if (end < start) - { - int tmp = start; - start = end; - end = tmp; - lastid = end; - } - - for (int i = start; i <= end; i++) - av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i)); - } + if (end < start) + { + int tmp = start; + start = end; + end = tmp; + lastid = end; + } + for (int i = start; i <= end; i++) + { + av.getSelectionGroup().addSequence(av.getAlignment().getSequenceAt(i)); + } + } public void mouseReleased(MouseEvent e) { - if(scrollThread!=null) + if (scrollThread != null) + { scrollThread.running = false; + } mouseDragging = false; PaintRefresher.Refresh(this); } - public void highlightSearchResults( java.util.Vector found ) + public void highlightSearchResults(java.util.Vector found) { - idCanvas.setHighlighted( found ); + idCanvas.setHighlighted(found); - if(found == null) + if (found == null) + { return; + } - int index = av.alignment.findIndex( (SequenceI)found.get(0)); + int index = av.alignment.findIndex( (SequenceI) found.get(0)); // do we need to scroll the panel? - if(av.getStartSeq()>index || av.getEndSeq() index) || (av.getEndSeq() < index)) + { + alignPanel.setScrollValues(av.getStartRes(), index); + } } // this class allows scrolling off the bottom of the visible alignment @@ -222,6 +274,7 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene { boolean running = false; boolean up = true; + public ScrollThread(boolean up) { this.up = up; @@ -236,34 +289,45 @@ public class IdPanel extends JPanel implements MouseListener, MouseMotionListene public void run() { running = true; + while (running) { - if(alignPanel.scrollUp(up)) + if (alignPanel.scrollUp(up)) { // scroll was ok, so add new sequence to selection int seq = av.getStartSeq(); - if(!up) + + 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 ead38dc..5599a6d 100755 --- a/src/jalview/gui/IdwidthAdjuster.java +++ b/src/jalview/gui/IdwidthAdjuster.java @@ -1,80 +1,110 @@ /* -* 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.gui; -import javax.swing.*; -import java.awt.event.*; import java.awt.*; +import java.awt.event.*; +import javax.swing.*; - -public class IdwidthAdjuster extends JPanel implements MouseListener, MouseMotionListener +public class IdwidthAdjuster + extends JPanel implements MouseListener, + MouseMotionListener { boolean active = false; - int oldX=0; + int oldX = 0; Image image; - AlignmentPanel ap ; + AlignmentPanel ap; public IdwidthAdjuster(AlignmentPanel ap) { this.ap = ap; + java.net.URL url = getClass().getResource("/images/idwidth.gif"); - if (url != null) - image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + + if (url != null) + { + image = java.awt.Toolkit.getDefaultToolkit().createImage(url); + } addMouseListener(this); addMouseMotionListener(this); } public void mousePressed(MouseEvent evt) - { oldX = evt.getX(); } + { + 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 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) + if ( ( (d.width + dif) > 20) || (dif > 0)) { - ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif,d.height)); + ap.idPanel.idCanvas.setPreferredSize(new Dimension(d.width + dif, + d.height)); ap.repaint(); } oldX = evt.getX(); } - public void mouseMoved(MouseEvent evt) {} - public void mouseClicked(MouseEvent evt) {} + public void mouseMoved(MouseEvent evt) + { + } + + public void mouseClicked(MouseEvent evt) + { + } public void paintComponent(Graphics g) { g.setColor(Color.white); - g.fillRect(0,0, getWidth(), getHeight()); - if(active) + g.fillRect(0, 0, getWidth(), getHeight()); + + if (active) { - if(image!=null) - g.drawImage(image, getWidth()-20, 2, this); + 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 89a7bfc..bfd97f0 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1,119 +1,143 @@ /* -* 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.gui; 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.*; -import javax.swing.JInternalFrame; -import java.net.URL; -import jalview.io.SequenceFeatureFetcher; - 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{ - FileOutputStream fos = new FileOutputStream(statefile); - JarOutputStream jout = new JarOutputStream(fos); - //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS - //////////////////////////////////////////////////// - PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, "UTF-8")); - - Vector shortNames = new Vector(); - //REVERSE ORDER - for (int i = frames.length-1; i > -1; i--) + long creation = System.currentTimeMillis(); + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + + if (frames == null) + { + return; + } + + try + { + FileOutputStream fos = new FileOutputStream(statefile); + JarOutputStream jout = new JarOutputStream(fos); + + //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS + //////////////////////////////////////////////////// + PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, + "UTF-8")); + + Vector shortNames = new Vector(); + + //REVERSE ORDER + for (int i = frames.length - 1; i > -1; i--) + { + if (frames[i] instanceof AlignFrame) { - if (frames[i] instanceof AlignFrame) - { - AlignFrame af = (AlignFrame) frames[i]; + AlignFrame af = (AlignFrame) frames[i]; - String shortName = af.getTitle(); + String shortName = af.getTitle(); - if(shortName.indexOf(File.separatorChar)>-1) - shortName = shortName.substring( - shortName.lastIndexOf(File.separatorChar)+1); + if (shortName.indexOf(File.separatorChar) > -1) + { + shortName = shortName.substring(shortName.lastIndexOf( + File.separatorChar) + 1); + } - int count=1; - while( shortNames.contains(shortName) ) - { - if(shortName.endsWith("_"+(count-1))) - shortName = shortName.substring(0, shortName.lastIndexOf("_")); + int count = 1; - shortName = shortName.concat("_"+count); - count++; + while (shortNames.contains(shortName)) + { + if (shortName.endsWith("_" + (count - 1))) + { + shortName = shortName.substring(0, + shortName.lastIndexOf("_")); } - shortNames.addElement(shortName); - if(!shortName.endsWith(".xml")) - shortName = shortName+".xml"; + shortName = shortName.concat("_" + count); + count++; + } + + shortNames.addElement(shortName); + + if (!shortName.endsWith(".xml")) + { + shortName = shortName + ".xml"; + } - SaveState( af, creation, shortName, jout, out); - } + SaveState(af, creation, shortName, jout, out); } - out.close(); - jout.close(); } - catch(Exception ex){ex.printStackTrace();} + + out.close(); + jout.close(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } // USE THIS METHOD TO SAVE A SINGLE ALIGNMENT WINDOW - public static void SaveState( AlignFrame af, String jarFile, String fileName) + public static void SaveState(AlignFrame af, String jarFile, String fileName) { - try{ + try + { FileOutputStream fos = new FileOutputStream(jarFile); JarOutputStream jout = new JarOutputStream(fos); + //NOTE UTF-8 MUST BE USED FOR WRITING UNICODE CHARS //////////////////////////////////////////////////// - PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, "UTF-8")); + PrintWriter out = new PrintWriter(new OutputStreamWriter(jout, + "UTF-8")); SaveState(af, System.currentTimeMillis(), fileName, jout, out); out.close(); jout.close(); - }catch(Exception ex){} + } + catch (Exception ex) + { + } } - public static void SaveState( AlignFrame af, long timeStamp, - String fileName, JarOutputStream jout, PrintWriter out) + public static void SaveState(AlignFrame af, long timeStamp, + String fileName, JarOutputStream jout, + PrintWriter out) { - Vector seqids = new Vector(); Vector userColours = new Vector(); AlignViewport av = af.viewport; JalviewModel object = new JalviewModel(); - object.setVamsasModel( new VamsasModel() ); + object.setVamsasModel(new VamsasModel()); - object.setCreationDate( new java.util.Date(timeStamp) ); + object.setCreationDate(new java.util.Date(timeStamp)); jalview.datamodel.AlignmentI jal = af.viewport.alignment; @@ -121,19 +145,19 @@ public class Jalview2XML Sequence vamsasSeq; JalviewModelSequence jms = new JalviewModelSequence(); - vamsasSet.setGapChar(jal.getGapCharacter()+""); + vamsasSet.setGapChar(jal.getGapCharacter() + ""); JSeq jseq; - //SAVE SEQUENCES int id = 0; - for(int i=0; i0) + 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 (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()); - } - - jalview.datamodel.SequenceGroup sg = new jalview.datamodel.SequenceGroup - (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())); - int [] ids = groups[i].getSeq(); - for(int s=0; s0) + if (object.getVamsasModel().getTreeCount() > 0) { - try{ + try + { af.ShowNewickTree(new jalview.io.NewickFile( - (String)object.getVamsasModel().getTree(0)), "Tree"); - }catch(Exception ex){ex.printStackTrace();} + (String) object.getVamsasModel().getTree(0)), "Tree"); + } + catch (Exception ex) + { + ex.printStackTrace(); + } } - } } - - - diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index a55af89..244d884 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -1,41 +1,43 @@ /* -* 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.gui; -import javax.swing.*; +import java.awt.*; import java.awt.event.*; import java.awt.image.*; -import java.awt.*; +import javax.swing.*; -public class OverviewPanel extends JPanel implements Runnable +public class OverviewPanel + extends JPanel implements Runnable { BufferedImage miniMe; AlignViewport av; AlignmentPanel ap; float scalew = 1f; float scaleh = 1f; - - int width, sequencesHeight; - int graphHeight=30; - int boxX=-1, boxY=-1, boxWidth=-1, boxHeight=-1; - + 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) @@ -45,50 +47,61 @@ public class OverviewPanel extends JPanel implements Runnable 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()) + float initialScale = (float) av.alignment.getWidth() / + (float) av.alignment.getHeight(); + + if (av.alignment.getWidth() > av.alignment.getHeight()) { // wider width = 400; - sequencesHeight = (int)(400f/initialScale); + sequencesHeight = (int) (400f / initialScale); } else { // taller - width = (int)(400f*initialScale); + width = (int) (400f * initialScale); sequencesHeight = 300; - if(width<120) + + if (width < 120) + { width = 120; + } } addComponentListener(new ComponentAdapter() - { - - public void componentResized(ComponentEvent evt) - { - if( getWidth()!=width || getHeight()!=sequencesHeight+graphHeight) - { - updateOverviewImage(); - } - } - }); + { + public void componentResized(ComponentEvent evt) + { + if ( (getWidth() != width) || + (getHeight() != (sequencesHeight + graphHeight))) + { + updateOverviewImage(); + } + } + }); addMouseMotionListener(new MouseMotionAdapter() - { - public void mouseDragged(MouseEvent evt) - { doMouseDragged(evt);} - }); + { + public void mouseDragged(MouseEvent evt) + { + doMouseDragged(evt); + } + }); addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) - { doMousePressed(evt);} + { + doMousePressed(evt); + } + public void mouseReleased(MouseEvent evt) - { doMouseReleased(evt);} + { + doMouseReleased(evt); + } }); updateOverviewImage(); - } public void doMousePressed(MouseEvent evt) @@ -105,9 +118,12 @@ public class OverviewPanel extends JPanel implements Runnable boxX = evt.getX(); boxY = evt.getY(); checkValid(); - if(!resizing) - ap.setScrollValues( (int)(boxX/scalew/av.getCharWidth()), - (int)(boxY/scaleh/av.getCharHeight()) ); + + if (!resizing) + { + ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); + } } public void doMouseDragged(MouseEvent evt) @@ -115,34 +131,46 @@ public class OverviewPanel extends JPanel implements Runnable boxX = evt.getX(); boxY = evt.getY(); checkValid(); - if(!resizing) - ap.setScrollValues( (int)(boxX/scalew/av.getCharWidth()), - (int)(boxY/scaleh/av.getCharHeight()) ); + + if (!resizing) + { + ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); + } } void checkValid() { if (boxY < 0) + { boxY = 0; + } - if (boxY > sequencesHeight - boxHeight) - boxY = sequencesHeight - boxHeight+1; + if (boxY > (sequencesHeight - boxHeight)) + { + boxY = sequencesHeight - boxHeight + 1; + } if (boxX < 0) + { boxX = 0; + } - if (boxX > width - boxWidth) + if (boxX > (width - boxWidth)) + { boxX = width - boxWidth; + } } public void updateOverviewImage() { - if(resizing) + if (resizing) { return; } resizing = true; + Thread thread = new Thread(this); thread.start(); repaint(); @@ -151,18 +179,19 @@ public class OverviewPanel extends JPanel implements Runnable public void run() { miniMe = null; + int alwidth = av.alignment.getWidth(); int alheight = av.alignment.getHeight(); - if(getWidth()>0 && getHeight()>0) + if ( (getWidth() > 0) && (getHeight() > 0)) { width = getWidth(); sequencesHeight = getHeight() - graphHeight; } - setPreferredSize (new Dimension(width, sequencesHeight+graphHeight)); + setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); - int fullsizeWidth = alwidth * av.getCharWidth(); + int fullsizeWidth = alwidth * av.getCharWidth(); int fullsizeHeight = alheight * av.getCharHeight(); scalew = (float) width / (float) fullsizeWidth; @@ -172,70 +201,85 @@ public class OverviewPanel extends JPanel implements Runnable BufferedImage.TYPE_INT_RGB); Graphics mg = miniMe.getGraphics(); - BufferedImage consensus = new BufferedImage(fullsizeWidth, - 60, - BufferedImage.TYPE_3BYTE_BGR); + 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); - + sequencesHeight + graphHeight, 0, 0, fullsizeWidth, 60, this); boolean oldRenderGaps = av.renderGaps; - try{ - // We'll have to draw the full size alignment in chunks, as an image of the - // whole alignment requires too much memory + 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(); + int maxSize = 2000 / av.getFont().getSize(); BufferedImage block; - int blockx=0, blocky=0, blockw=0, blockh=0, eRes=0, eSeq=0; + 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; sResalwidth) - eRes = alwidth; + eSeq = 0; + eRes += maxSize; - for(int sSeq=0, chunky=0; sSeqalheight) - eSeq = alheight; + if (eRes > alwidth) + { + eRes = alwidth; + } - blocky = 0; - blockx = (int)((float)sRes/(float)alwidth * width); + for (int sSeq = 0, chunky = 0; sSeq < alheight; + sSeq += maxSize, chunky++) + { + eSeq += maxSize; - block = new BufferedImage((eRes-sRes)*av.charWidth, - (eSeq-sSeq)*av.charHeight, - BufferedImage.TYPE_3BYTE_BGR); - g = block.getGraphics(); + if (eSeq > alheight) + { + eSeq = alheight; + } - ap.seqPanel.seqCanvas.drawPanel(g, sRes, eRes, sSeq, eSeq, sRes, sSeq, 0); + blocky = 0; + blockx = (int) ( (float) sRes / (float) alwidth * width); - blockh = (int)( (float)(eSeq-sSeq)/(float)alheight * sequencesHeight )+1 ; - blockw = (int)( (float)(eRes-sRes)/(float)alwidth * width )+1; + block = new BufferedImage( (eRes - sRes) * av.charWidth, + (eSeq - sSeq) * av.charHeight, + BufferedImage.TYPE_3BYTE_BGR); + g = block.getGraphics(); - blocky += (int) ((float)sSeq/(float)alheight* sequencesHeight); + ap.seqPanel.seqCanvas.drawPanel(g, sRes, eRes, sSeq, eSeq, + sRes, sSeq, 0); - mg.drawImage(block, blockx, - blocky , - blockx + blockw, - blocky + blockh, + blockh = (int) ( (float) (eSeq - sSeq) / (float) alheight * + sequencesHeight) + + 1; + blockw = (int) ( (float) (eRes - sRes) / (float) alwidth * width) + + 1; - 0, 0, block.getWidth(),block.getHeight(), this); + blocky += (int) ( (float) sSeq / (float) alheight * sequencesHeight); - block = null; - } + 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!"); } - + } + catch (OutOfMemoryError error) + { + System.err.println( + "Out of memory when trying to calculate the overview window image!"); + } av.setRenderGaps(oldRenderGaps); resizing = false; @@ -245,35 +289,37 @@ public class OverviewPanel extends JPanel implements Runnable 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(); + 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.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Color.black); - if(resizing) + if (resizing) { g.setFont(new Font("Verdana", Font.BOLD, 15)); - g.drawString("Recalculating", 5, sequencesHeight/2); - g.drawString("Overview.....", 5, sequencesHeight/2 +20); + g.drawString("Recalculating", 5, sequencesHeight / 2); + g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20); } else { - if(miniMe!=null) - g.drawImage(miniMe, 0,0,this); + 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.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } } - } diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 8f3ff73..ebde9cb 100755 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -1,120 +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.gui; -import jalview.datamodel.*; -import jalview.analysis.PCA; -import jalview.jbgui.*; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import java.util.*; +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.jbgui.*; -public class PCAPanel extends GPCAPanel implements Runnable +public class PCAPanel + extends GPCAPanel implements Runnable { PCA pca; int top; RotatableCanvas rc; AlignViewport av; - public void run() + public PCAPanel(AlignViewport av, SequenceI[] s) { - // do stuff - } - - public PCAPanel(AlignViewport av, SequenceI[] s) { - this.av = av; - if(av.getSelectionGroup()!=null && av.getSelectionGroup().getSize()>3) + + if ( (av.getSelectionGroup() != null) && + (av.getSelectionGroup().getSize() > 3)) { s = new Sequence[av.getSelectionGroup().getSize()]; - for(int i=0; i 1e-4) { - comps[i] = pca.component(i); + comps[i] = pca.component(i); } } ////////////////// - xCombobox.setSelectedIndex(0); yCombobox.setSelectedIndex(1); zCombobox.setSelectedIndex(2); - top = pca.getM().rows-1; + top = pca.getM().rows - 1; Vector points = new Vector(); - float[][] scores = pca.getComponents(top-1,top-2,top-3,100); + float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100); - for (int i =0; i < pca.getM().rows; i++ ) + for (int i = 0; i < pca.getM().rows; i++) { - SequencePoint sp = new SequencePoint(s[i],scores[i]); + SequencePoint sp = new SequencePoint(s[i], scores[i]); points.addElement(sp); } - rc = new RotatableCanvas(av,points,pca.getM().rows); + rc = new RotatableCanvas(av, points, pca.getM().rows); //rc.printPoints(); - add(rc, BorderLayout.CENTER); } + public void run() + { + // do stuff + } void doDimensionChange() { - if(top==0) + 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]; + 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; @@ -137,5 +147,4 @@ public class PCAPanel extends GPCAPanel implements Runnable { doDimensionChange(); } - } diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index 12545af..6bec8fd 100755 --- a/src/jalview/gui/PaintRefresher.java +++ b/src/jalview/gui/PaintRefresher.java @@ -1,54 +1,62 @@ /* -* 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.gui; -import java.awt.*; + import java.util.*; +import java.awt.*; + public class PaintRefresher { static Vector components = new Vector(); public static void Register(Component c) { - if(!components.contains(c)) + if (!components.contains(c)) + { components.add(c); + } else + { components.remove(c); + } } public static void Refresh(Component c) { Component temp; Enumeration e = components.elements(); - while( e.hasMoreElements() ) + + while (e.hasMoreElements()) { - temp = (Component)e.nextElement(); + temp = (Component) e.nextElement(); - if(!temp.isValid()) - components.removeElement( temp ); - else if( temp == c ) - continue; + if (!temp.isValid()) + { + components.removeElement(temp); + } + else if (temp == c) + { + continue; + } temp.repaint(); } - } - } diff --git a/src/jalview/gui/PairwiseAlignPanel.java b/src/jalview/gui/PairwiseAlignPanel.java index 2825467..69789b9 100755 --- a/src/jalview/gui/PairwiseAlignPanel.java +++ b/src/jalview/gui/PairwiseAlignPanel.java @@ -1,98 +1,118 @@ /* -* 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.gui; -import jalview.datamodel.*; -import jalview.jbgui.GPairwiseAlignPanel; -import jalview.analysis.*; -import java.awt.event.*; -import javax.swing.*; import java.util.*; +import java.awt.event.*; + +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.jbgui.*; -public class PairwiseAlignPanel extends GPairwiseAlignPanel +public class PairwiseAlignPanel + extends GPairwiseAlignPanel { - Vector sequences = new Vector(); - AlignViewport av; + Vector sequences = new Vector(); + AlignViewport av; + + public PairwiseAlignPanel(AlignViewport av) + { + super(); + this.av = av; - public PairwiseAlignPanel(AlignViewport av) + Vector selsubset = new Vector(); + + for (int i = 0, j = av.getSelectionGroup().getSize(); i < j; i++) { - super(); - this.av = av; - Vector selsubset = new Vector(); - for (int i=0, j=av.getSelectionGroup().getSize(); i 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"); + } + + float[][] scores = new float[selsubset.size()][selsubset.size()]; + double totscore = 0; + int count = selsubset.size(); + int acount = 0; + + 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"); - protected void viewInEditorButton_actionPerformed(ActionEvent e) - { + for (int i = 0; i < count; i++) + { + jalview.util.Format.print(System.out, "%s \n", + ("" + i) + " " + + ( (SequenceI) selsubset.elementAt(i)).getName()); + } - Sequence [] seq = new Sequence[sequences.size()]; + System.out.println("\n"); - for (int i=0;i= 1) - { + 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))) @@ -77,32 +82,36 @@ public class RedundancyPanel sg.deleteSequence( (SequenceI) del.elementAt(i)); } } - } else { Vector s = new Vector(); int i = 0; + while (i < ap.av.alignment.getHeight()) { s.addElement(ap.av.alignment.getSequenceAt(i)); i++; } + del = ap.av.alignment.removeRedundancy(threshold, s); } // 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 0) + { + for (int i = 0, j = del.size(); i < j; i++) + { SequenceI sq = (SequenceI) del.elementAt(i); - sq.deleteChars(0,sq.getLength()); + sq.deleteChars(0, sq.getLength()); } + } ap.av.firePropertyChange("alignment", null, ap.av.getAlignment().getSequences()); ap.av.resetSeqLimits(ap.seqPanel.seqCanvas.getHeight()); + if (ap.av.getAlignment().getHeight() < 1) { try @@ -110,22 +119,25 @@ public class RedundancyPanel af.setClosed(true); } catch (Exception ex) - {} + { + } } + ap.av.updateConservation(); ap.av.updateConsensus(); af.updateEditMenuBar(); ap.repaint(); - } public void undoButton_actionPerformed(ActionEvent e) { HistoryItem hi = (HistoryItem) historyList.pop(); af.restoreHistoryItem(hi); + if (historyList.size() == 0) { undoButton.setEnabled(false); + if (af.historyList.contains(hi)) { af.historyList.remove(hi); @@ -133,6 +145,7 @@ public class RedundancyPanel } } } + public void valueField_actionPerformed(ActionEvent e) { try diff --git a/src/jalview/gui/RotatableCanvas.java b/src/jalview/gui/RotatableCanvas.java index 0d5025e..0fc83c3 100755 --- a/src/jalview/gui/RotatableCanvas.java +++ b/src/jalview/gui/RotatableCanvas.java @@ -1,119 +1,112 @@ /* -* 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.gui; -import jalview.math.*; -import jalview.datamodel.*; -import jalview.util.*; +import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import java.util.*; +import jalview.datamodel.*; +import jalview.math.*; +import jalview.util.*; -public class RotatableCanvas extends JPanel implements MouseListener, - MouseMotionListener, - KeyListener - //RubberbandListener, - //SequenceSelectionListener +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); + 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[] 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) { + // Controller controller; + public RotatableCanvas(AlignViewport av, Vector points, int npoint) + { this.points = points; this.npoint = npoint; this.av = av; ToolTipManager.sharedInstance().registerComponent(this); PaintRefresher.Register(this); -// + + // 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++) { + 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++) { - 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); + //Initialize the matrices to identity + for (int i = 0; i < 3; i++) + { + 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); } } } @@ -127,62 +120,74 @@ public class RotatableCanvas extends JPanel implements MouseListener, scale = findScale(); // System.out.println("Scale factor = " + scale); - addMouseListener(this); addKeyListener(this); - // if (getParent() != null) { - // getParent().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; + // rubberband = new RubberbandRectangle(this); + // rubberband.setActive(true); + // rubberband.addListener(this); } - public void removeNotify() { - controller.removeListener(this); - super.removeNotify(); - }*/ - - public void initAxes() { - for (int i = 0; i < 3; i++) { - for (int j=0; j < 3; j++) { - if (i != j) { + /* 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++) + { + for (int j = 0; j < 3; j++) + { + if (i != j) + { axes[i][j] = 0; - } else { + } + else + { axes[i][j] = 1; } } } } - public void findWidth() { + 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]) { + if (sp.coord[i] >= max[i]) + { max[i] = sp.coord[i]; } - if (sp.coord[i] <= min[i]) { + + if (sp.coord[i] <= min[i]) + { min[i] = sp.coord[i]; } } @@ -191,7 +196,6 @@ public class RotatableCanvas extends JPanel implements MouseListener, // 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]); @@ -199,186 +203,253 @@ public class RotatableCanvas extends JPanel implements MouseListener, maxwidth = width[0]; if (width[1] > width[0]) + { maxwidth = width[1]; + } + if (width[2] > width[1]) + { maxwidth = width[2]; + } //System.out.println("Maxwidth = " + maxwidth); } - public float findScale() { - int dim, width, height; - if (getWidth() != 0) { + public float findScale() + { + int dim; + int width; + int height; + + if (getWidth() != 0) + { width = getWidth(); height = getHeight(); - } else { + } + else + { width = prefsize.width; height = prefsize.height; } - if (width < height) { + if (width < height) + { dim = width; - } else { + } + else + { dim = height; } - return (float)(dim*scalefactor/(2*maxwidth)); + return (float) ( (dim * scalefactor) / (2 * maxwidth)); } - public void findCentre() { + public void findCentre() + { //Find centre coordinate findWidth(); - centre[0] = (max[0] + min[0])/2; - centre[1] = (max[1] + min[1])/2; - centre[2] = (max[2] + min[2])/2; + centre[0] = (max[0] + min[0]) / 2; + centre[1] = (max[1] + min[1]) / 2; + centre[2] = (max[2] + min[2]) / 2; // System.out.println("Centre x " + centre[0]); //System.out.println("Centre y " + centre[1]); //System.out.println("Centre z " + centre[2]); } - public Dimension getPreferredSize() { - if (prefsize != null) { + public Dimension getPreferredSize() + { + if (prefsize != null) + { return prefsize; - } else { - return new Dimension(400,400); + } + else + { + return new Dimension(400, 400); } } - public Dimension getMinimumSize() { + public Dimension getMinimumSize() + { return getPreferredSize(); } - public void paintComponent(Graphics g) { + public void paintComponent(Graphics g) + { //Only create the image at the beginning - - if ((img == null) || (prefsize.width != getWidth()) || (prefsize.height != getHeight())) { + if ( (img == null) || (prefsize.width != getWidth()) || + (prefsize.height != getHeight())) + { prefsize.width = getWidth(); prefsize.height = getHeight(); scale = findScale(); // System.out.println("New scale = " + scale); - img = createImage(getWidth(),getHeight()); + img = createImage(getWidth(), getHeight()); ig = img.getGraphics(); - } + drawBackground(ig, Color.black); + drawScene(ig); - drawBackground(ig,Color.black); - drawScene(ig); - if (drawAxes == true) - { - drawAxes(ig); - } - + if (drawAxes == true) + { + drawAxes(ig); + } - g.drawImage(img,0,0,this); + g.drawImage(img, 0, 0, this); } - public void drawAxes(Graphics g) { - + public void drawAxes(Graphics g) + { 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)); + + 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))); } } - public void drawBackground(Graphics g, Color col) { + public void drawBackground(Graphics g, Color col) + { g.setColor(col); - g.fillRect(0,0,prefsize.width,prefsize.height); + g.fillRect(0, 0, prefsize.width, prefsize.height); } - - public void drawScene(Graphics g) { + public void drawScene(Graphics g) + { boolean darker = false; - int halfwidth = getWidth()/2; - int halfheight = getHeight()/2; + int halfwidth = getWidth() / 2; + int halfheight = getHeight() / 2; - 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; + 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); + { + g.setColor(Color.white); + } else - g.setColor(sp.sequence.getColor()); - + { + g.setColor(sp.sequence.getColor()); + } if (av.getSelectionGroup() != null) { - if (av.getSelectionGroup().sequences.contains(((SequencePoint)points.elementAt(i)).sequence)) + 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.fillRect(x - 3, y - 3, 6, 6); g.setColor(Color.red); } -// //Now the rectangle -// if (rectx2 != -1 && recty2 != -1) { -// g.setColor(Color.white); -// -// g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); -// } + + // //Now the rectangle + // if (rectx2 != -1 && recty2 != -1) { + // g.setColor(Color.white); + // + // g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1); + // } } - public Dimension minimumsize() { + public Dimension minimumsize() + { return prefsize; } - public Dimension preferredsize() { + public Dimension preferredsize() + { return prefsize; } - public void keyTyped(KeyEvent evt) { } - public void keyReleased(KeyEvent evt) { } + public void keyTyped(KeyEvent evt) + { + } - public void keyPressed(KeyEvent evt) { + public void keyReleased(KeyEvent evt) + { + } + + public void keyPressed(KeyEvent evt) + { requestFocus(); - if (evt.getKeyCode() == KeyEvent.VK_UP) { - scalefactor = (float)(scalefactor * 1.1); + + 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); + } + else if (evt.getKeyCode() == KeyEvent.VK_DOWN) + { + scalefactor = (float) (scalefactor * 0.9); scale = findScale(); - } else if (evt.getKeyChar() == 's') { + } + else if (evt.getKeyChar() == 's') + { System.err.println("DEBUG: Rectangle selection"); // log.debug - if (rectx2 != -1 && recty2 != -1) { - rectSelect(rectx1,recty1,rectx2,recty2); + if ( (rectx2 != -1) && (recty2 != -1)) + { + rectSelect(rectx1, recty1, rectx2, recty2); } } + repaint(); } - public void printPoints() { - for (int i=0; i < npoint; i++) { - 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]); + public void printPoints() + { + for (int i = 0; i < npoint; i++) + { + 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) { } + public void mouseClicked(MouseEvent evt) + { + } + + public void mouseEntered(MouseEvent evt) + { + } + + public void mouseExited(MouseEvent evt) + { + } - public void mousePressed(MouseEvent evt) { + public void mouseReleased(MouseEvent evt) + { + } + + public void mousePressed(MouseEvent evt) + { int x = evt.getX(); int y = evt.getY(); @@ -397,7 +468,7 @@ public class RotatableCanvas extends JPanel implements MouseListener, rectx2 = -1; recty2 = -1; - SequenceI found = findPoint(x,y); + SequenceI found = findPoint(x, y); if (found != null) { @@ -408,49 +479,59 @@ public class RotatableCanvas extends JPanel implements MouseListener, } else { - av.setSelectionGroup(new SequenceGroup()); - av.getSelectionGroup().addOrRemove(found); - av.getSelectionGroup().setEndRes(av.alignment.getWidth()); - + av.setSelectionGroup(new SequenceGroup()); + av.getSelectionGroup().addOrRemove(found); + av.getSelectionGroup().setEndRes(av.alignment.getWidth()); } } + repaint(); } - // private void fireSequenceSelectionEvent(Selection sel) { - // controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this,sel)); + // 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 - this.setToolTipText(null); - } - - public void mouseDragged(MouseEvent evt) { + SequenceI found = findPoint(evt.getX(), evt.getY()); + + if (found != null) + { + this.setToolTipText(found.getName()); + } + else + { + this.setToolTipText(null); + } + } + + 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(); - } else { + if ( (evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) + { + // rectx2 = evt.getX(); + // recty2 = evt.getY(); + } + else + { rotmat.setIdentity(); - rotmat.rotate((float)(my-omy),'x'); - rotmat.rotate((float)(mx-omx),'y'); + rotmat.rotate( (float) (my - omy), 'x'); + rotmat.rotate( (float) (mx - omx), 'y'); - for (int i = 0; i < npoint; i++) { - SequencePoint sp = (SequencePoint)points.elementAt(i); + 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 apply the rotation matrix - sp.coord= rotmat.vectorMultiply(sp.coord); + sp.coord = rotmat.vectorMultiply(sp.coord); //Now translate back again sp.coord[0] += centre[0]; @@ -458,26 +539,34 @@ public class RotatableCanvas extends JPanel implements MouseListener, sp.coord[2] += centre[2]; } - for (int i=0; i < 3; i++) { + for (int i = 0; i < 3; i++) + { axes[i] = rotmat.vectorMultiply(axes[i]); } + omx = mx; omy = my; paint(this.getGraphics()); } - } - public void rectSelect(int x1, int y1, int x2, int y2) { + public void rectSelect(int x1, int y1, int x2, int y2) + { boolean changedSel = false; - for (int i=0; i < npoint; i++) { - 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) { + for (int i = 0; i < npoint; i++) + { + 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; @@ -486,54 +575,62 @@ public class RotatableCanvas extends JPanel implements MouseListener, } } } - // 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; + public SequenceI findPoint(int x, int y) + { + int halfwidth = getWidth() / 2; + int halfheight = getHeight() / 2; 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; - + 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 ) { + if ( (Math.abs(px - x) < 3) && (Math.abs(py - y) < 3)) + { found = i; } } - if (found != -1) { - return ((SequencePoint)points.elementAt(found)).sequence; - } else { + + 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()); - Rubberband rb = (Rubberband)evt.getSource(); + /* public boolean handleRubberbandEvent(RubberbandEvent evt) { + System.out.println("Rubberband handler called in RotatableCanvas with " + + evt.getBounds()); - // Clear the current selection (instance variable) - //if ((rb.getModifiers() & Event.SHIFT_MASK) == 0) { - // clearSelection(); - //} + Rubberband rb = (Rubberband)evt.getSource(); - if (rb.getComponent() == this) { - Rectangle bounds = evt.getBounds(); - rectSelect(bounds.x,bounds.y,bounds.x+bounds.width,bounds.y+bounds.height); - } + // Clear the current selection (instance variable) + //if ((rb.getModifiers() & Event.SHIFT_MASK) == 0) { + // clearSelection(); + //} - redrawneeded = true; - paint(this.getGraphics()); + if (rb.getComponent() == this) { + Rectangle bounds = evt.getBounds(); + rectSelect(bounds.x,bounds.y,bounds.x+bounds.width,bounds.y+bounds.height); + } - return true; - }*/ + redrawneeded = true; + paint(this.getGraphics()); + return true; + }*/ } diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index de0a7b1..250998f 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -1,43 +1,41 @@ /* -* 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.gui; -import jalview.datamodel.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; -public class ScalePanel extends JPanel -{ +import jalview.datamodel.*; +public class ScalePanel + extends JPanel +{ protected int offy = 4; - public int width; - + public int width; protected AlignViewport av; AlignmentPanel ap; - boolean stretchingGroup = false; public ScalePanel(AlignViewport av, AlignmentPanel ap) { - this.av = av; + this.av = av; this.ap = ap; addMouseListener(new MouseAdapter() @@ -46,11 +44,11 @@ public class ScalePanel extends JPanel { doMousePressed(evt); } + public void mouseReleased(MouseEvent evt) { doMouseReleased(evt); } - }); addMouseMotionListener(new MouseMotionAdapter() { @@ -59,71 +57,90 @@ public class ScalePanel extends JPanel doMouseDragged(evt); } }); - } - - public void doMousePressed(MouseEvent evt) { + public void doMousePressed(MouseEvent evt) + { int x = evt.getX(); - int res = x/av.getCharWidth() + av.getStartRes(); + int res = (x / av.getCharWidth()) + av.getStartRes(); SequenceGroup sg = null; if (av.getColumnSelection().contains(res)) + { av.getColumnSelection().removeElement(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)); + } sg.setStartRes(res); sg.setEndRes(res); ap.annotationPanel.addEditableColumn(res); } + av.setSelectionGroup(sg); ap.repaint(); } public void doMouseReleased(MouseEvent evt) { - if(!stretchingGroup) + if (!stretchingGroup) + { return; + } int x = evt.getX(); - int res = x/av.getCharWidth() + av.getStartRes(); + int res = (x / av.getCharWidth()) + av.getStartRes(); - if (! av.getColumnSelection().contains(res)) - av.getColumnSelection().addElement(res); + if (!av.getColumnSelection().contains(res)) + { + av.getColumnSelection().addElement(res); + } - SequenceGroup sg = av.getSelectionGroup(); + SequenceGroup sg = av.getSelectionGroup(); - if(res>sg.getStartRes()) - sg.setEndRes(res); - else if(res sg.getStartRes()) + { + sg.setEndRes(res); + } + else if (res < sg.getStartRes()) + { + sg.setStartRes(res); + } - stretchingGroup = false; - ap.repaint(); + stretchingGroup = false; + ap.repaint(); } public void doMouseDragged(MouseEvent evt) { int x = evt.getX(); - int res = x/av.getCharWidth() + av.getStartRes(); + int res = (x / av.getCharWidth()) + av.getStartRes(); SequenceGroup sg = av.getSelectionGroup(); - if(sg!=null) + + if (sg != null) { stretchingGroup = true; + if (res > sg.getStartRes()) + { sg.setEndRes(res); + } else if (res < sg.getStartRes()) + { sg.setStartRes(res); + } - ap.annotationPanel.addEditableColumn(res); + ap.annotationPanel.addEditableColumn(res); ap.repaint(); } } @@ -133,59 +150,66 @@ public class ScalePanel extends JPanel 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) + // scalewidth will normally be screenwidth, + public void drawScale(Graphics g, int startx, int endx, int width, + int height) { - Graphics2D gg = (Graphics2D)g; + Graphics2D gg = (Graphics2D) g; gg.setFont(av.getFont()); - gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); //Fill in the background gg.setColor(Color.white); - gg.fillRect(0,0,width, height); + 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= startx && sel <= endx) - gg.fillRect((sel-startx)*av.charWidth,0,av.charWidth,getHeight()); - } + 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; + + int scalestartx = (startx / 10) * 10; FontMetrics fm = gg.getFontMetrics(av.getFont()); - int y = av.charHeight -fm.getDescent(); + int y = av.charHeight - fm.getDescent(); - if(scalestartx%10==0) - scalestartx+=5; + if ( (scalestartx % 10) == 0) + { + scalestartx += 5; + } - for (int i=scalestartx;i < endx; i+= 5) + for (int i = scalestartx; i < endx; i += 5) { - if(i%10==0) + 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); + 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); - - + { + 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 d40f971..1194d08 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1,64 +1,61 @@ /* -* 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.gui; import java.awt.*; import java.awt.image.*; import javax.swing.*; -import jalview.datamodel.*; -import jalview.analysis.*; +import jalview.analysis.*; +import jalview.datamodel.*; -public class SeqCanvas extends JComponent +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; - - - public SeqCanvas(AlignViewport av) - { - this.av = av; - fr = new FeatureRenderer(av); - sr = new SequenceRenderer(av); - setLayout(new BorderLayout()); - PaintRefresher.Register(this); - - } + 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); + } - void drawNorthScale(Graphics g, int startx, int endx,int ypos) { - int scalestartx = startx - startx % 10 + 10; + void drawNorthScale(Graphics g, int startx, int endx, int ypos) + { + int scalestartx = startx - (startx % 10) + 10; g.setColor(Color.black); @@ -67,131 +64,154 @@ public class SeqCanvas extends JComponent { 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); + 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); } } void drawWestScale(Graphics g, int startx, int endx, int ypos) { FontMetrics fm = getFontMetrics(av.getFont()); - ypos+= av.charHeight; - // EAST SCALE + ypos += av.charHeight; + + // EAST SCALE for (int i = 0; i < av.alignment.getHeight(); i++) { SequenceI seq = av.alignment.getSequenceAt(i); int index = startx; int value = -1; + while (index < endx) { if (jalview.util.Comparison.isGap(seq.getCharAt(index))) { index++; + continue; } value = av.alignment.getSequenceAt(i).findPosition(index); + break; } - if(value!=-1) + + if (value != -1) { - int x = LABEL_WEST - fm.stringWidth(value+""); - g.drawString(value + "", x, ypos + i*av.charHeight - av.charHeight/5); + int x = LABEL_WEST - fm.stringWidth(value + ""); + g.drawString(value + "", x, + (ypos + (i * av.charHeight)) - (av.charHeight / 5)); } } } void drawEastScale(Graphics g, int startx, int endx, int ypos) -{ - ypos+= av.charHeight; - // EAST SCALE - for (int i = 0; i < av.alignment.getHeight(); i++) { - SequenceI seq = av.alignment.getSequenceAt(i); - int index = endx; - int value = -1; - while (index > startx) - { - if (jalview.util.Comparison.isGap(seq.getCharAt(index))) - { - index--; - continue; - } + ypos += av.charHeight; - value = av.alignment.getSequenceAt(i).findPosition(index); - break; - } - if(value!=-1) - g.drawString(value + "", 0, ypos + i*av.charHeight - av.charHeight/5); - } + // EAST SCALE + for (int i = 0; i < av.alignment.getHeight(); i++) + { + SequenceI seq = av.alignment.getSequenceAt(i); + int index = endx; + int value = -1; -} + while (index > startx) + { + if (jalview.util.Comparison.isGap(seq.getCharAt(index))) + { + index--; + continue; + } + value = av.alignment.getSequenceAt(i).findPosition(index); + break; + } + 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) + public void fastPaint(int horizontal, int vertical) + { + if ( ( (horizontal == 0) && (vertical == 0)) || (gg == null)) + { return; + } gg.copyArea(0, 0, imgWidth, imgHeight, -horizontal * av.charWidth, -vertical * av.charHeight); - int sr = av.startRes, er = av.endRes, ss = av.startSeq, es = av.endSeq, - transX = 0, 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.endSeq) + + if (es > av.endSeq) + { es = av.endSeq; + } } - gg.translate(transX, transY); gg.setColor(Color.white); - gg.fillRect(0,0, (er-sr+1)*av.charWidth, (es-ss)*av.charHeight); + 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. - */ - + /** + * 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. + */ public void paintComponent(Graphics g) { g.setColor(Color.white); @@ -201,44 +221,50 @@ public void fastPaint(int horizontal, int vertical) { g.drawImage(img, 0, 0, this); fastPaint = false; + return; } // this draws the whole of the alignment - imgWidth = getWidth(); - imgHeight = getHeight(); + imgWidth = getWidth(); + imgHeight = getHeight(); - imgWidth -= imgWidth%av.charWidth; - imgHeight-= imgHeight%av.charHeight; + imgWidth -= (imgWidth % av.charWidth); + imgHeight -= (imgHeight % av.charHeight); - if(imgWidth<1 || imgHeight<1) - return; + if ( (imgWidth < 1) || (imgHeight < 1)) + { + return; + } - 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); + 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); - gg.setColor(Color.white); - gg.fillRect(0,0,imgWidth,imgHeight); + gg.setColor(Color.white); + gg.fillRect(0, 0, imgWidth, imgHeight); - chunkWidth = getWrappedCanvasWidth( getWidth() ); - chunkHeight = (av.getAlignment().getHeight() + 2)*av.charHeight; + chunkWidth = getWrappedCanvasWidth(getWidth()); + chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; 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); + { + drawPanel(gg, av.startRes, av.endRes, av.startSeq, av.endSeq, + av.startRes, av.startSeq, 0); + } g.drawImage(img, 0, 0, this); - } - int LABEL_WEST, LABEL_EAST; public int getWrappedCanvasWidth(int cwidth) { FontMetrics fm = getFontMetrics(av.getFont()); @@ -246,161 +272,199 @@ public void fastPaint(int horizontal, int vertical) LABEL_EAST = 0; LABEL_WEST = 0; - if(av.scaleRightWrapped) - LABEL_EAST = fm.stringWidth( av.alignment.getWidth()+"000" ); + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(av.alignment.getWidth() + "000"); + } - if(av.scaleLeftWrapped) - LABEL_WEST = fm.stringWidth( av.alignment.getWidth()+"" ); + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(av.alignment.getWidth() + ""); + } - return (cwidth - LABEL_EAST -LABEL_WEST)/av.charWidth; + return (cwidth - LABEL_EAST - LABEL_WEST) / av.charWidth; } - public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) + public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, + int startRes) { - AlignmentI al = av.getAlignment(); + AlignmentI al = av.getAlignment(); + + FontMetrics fm = getFontMetrics(av.getFont()); + + int LABEL_EAST = 0; + + if (av.scaleRightWrapped) + { + LABEL_EAST = fm.stringWidth(al.getWidth() + "000"); + } - FontMetrics fm = getFontMetrics(av.getFont()); + int LABEL_WEST = 0; - int LABEL_EAST = 0; - if(av.scaleRightWrapped) - LABEL_EAST = fm.stringWidth( al.getWidth()+"000" ); - int LABEL_WEST = 0; - if(av.scaleLeftWrapped) - LABEL_WEST = fm.stringWidth(al.getWidth()+"0"); + if (av.scaleLeftWrapped) + { + LABEL_WEST = fm.stringWidth(al.getWidth() + "0"); + } + int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth; + int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - int cWidth = (canvasWidth - LABEL_EAST -LABEL_WEST)/av.charWidth; - int cHeight = (av.getAlignment().getHeight() + 2)*av.charHeight; + av.endRes = av.startRes + cWidth; - av.endRes = av.startRes + cWidth; + int endx = (startRes + cWidth) - 1; + int ypos = 2 * av.charHeight; - int endx = startRes+cWidth-1; - int ypos = 2*av.charHeight; + while ( (ypos <= canvasHeight) && (startRes < av.alignment.getWidth())) + { + g.setColor(Color.black); - while (ypos <= canvasHeight && startRes al.getWidth()) - endx = al.getWidth(); + 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); - synchronized public void drawPanel(Graphics g1,int x1,int x2, int y1, int y2,int startx, int starty,int offset) { + ypos += cHeight; + startRes += cWidth; + endx = (startRes + cWidth) - 1; + + if (endx > al.getWidth()) + { + endx = al.getWidth(); + } + } + } - Graphics2D g = (Graphics2D)g1; + 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); - SequenceI nextSeq; /// First draw the sequences ///////////////////////////// - for (int i = y1 ; i < y2 ;i++) + 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); - } + 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); + } } + // ///////////////////////////////////// - // Now outline any areas if necessary ///////////////////////////////////// SequenceGroup group = av.getSelectionGroup(); java.util.Vector groups = av.alignment.getGroups(); - int sx = -1, sy = -1, ex = -1; + int sx = -1; + int sy = -1; + int ex = -1; int groupIndex = -1; - if (group == null && groups.size() > 0) + + if ( (group == null) && (groups.size() > 0)) { group = (SequenceGroup) groups.elementAt(0); groupIndex = 0; } if (group != null) + { do { int oldY = -1; int i = 0; boolean inGroup = false; - int top=-1, bottom =-1; + 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))) + 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))) - bottom = sy + av.charHeight ; + 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))) + 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.setStroke(new BasicStroke(1, + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_ROUND, 3f, + new float[] + {5f, 3f}, 0f)); g.setColor(Color.RED); } else @@ -414,21 +478,21 @@ public void fastPaint(int horizontal, int vertical) { if (inGroup) { - g.drawLine(sx, oldY, sx, sy ); - g.drawLine(sx+ex, oldY, sx+ex, sy ); + 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; + top = -1; } + if (bottom != -1) { g.drawLine(sx, bottom, sx + ex, bottom); bottom = -1; } - inGroup = false; } } @@ -436,83 +500,89 @@ public void fastPaint(int horizontal, int vertical) if (inGroup) { - - if(top!=-1) + if (top != -1) { g.drawLine(sx, top, sx + ex, top); - top =-1; + top = -1; + } + + if (bottom != -1) + { + g.drawLine(sx, bottom - 1, sx + ex, bottom - 1); + bottom = -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 ); + + sy = offset + + AlignmentUtil.getPixelHeight(starty, i, 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()); - + } /// Highlight search Results once all sequences have been drawn ////////////////////////////////////////////////////////// - if(displaySearch) + if (displaySearch) { - for(int r=0; r= y1 && searchSeq < y2) + 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; - if(searchStart x2) + } + + if (searchEnd > x2) + { searchEnd = x2; + } - ssr.drawHighlightedText(seq, - searchStart, - searchEnd, + ssr.drawHighlightedText(seq, searchStart, searchEnd, (searchStart - startx) * av.charWidth, offset + - AlignmentUtil.getPixelHeight(starty, searchSeq, - av.charHeight), - av.charWidth, - av.charHeight); + AlignmentUtil.getPixelHeight(starty, + searchSeq, + av.charHeight), av.charWidth, av.charHeight); } } } - } - - - public void highlightSearchResults(int [] results) + public void highlightSearchResults(int[] results) { // results are in the order sequence, startRes, endRes - if(results==null) + if (results == null) + { displaySearch = false; + } else + { displaySearch = true; + } searchResults = results; repaint(); } - - } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 44cf4d4..f4d77c3 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1,147 +1,188 @@ /* -* 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.gui; +import java.util.*; + import java.awt.*; import java.awt.event.*; -import jalview.datamodel.*; import javax.swing.*; -import java.util.*; + +import jalview.analysis.*; +import jalview.datamodel.*; import jalview.schemes.*; -import jalview.analysis.Conservation; -public class SeqPanel extends JPanel +public class SeqPanel + extends JPanel { - - public SeqCanvas seqCanvas; - public AlignmentPanel ap; - + public SeqCanvas seqCanvas; + public AlignmentPanel ap; protected int lastres; protected int startseq; - int startEdit=-1; - int endEdit=-1; - + 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) { - this.av = avp; + public SeqPanel(AlignViewport avp, AlignmentPanel p) + { + this.av = avp; - seqCanvas = new SeqCanvas(avp); + seqCanvas = new SeqCanvas(avp); setLayout(new BorderLayout()); add(seqCanvas, BorderLayout.CENTER); ap = p; - addMouseMotionListener( new MouseMotionAdapter() + addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) { - if(av.getWrapAlignment()) - return; - doMouseMoved(evt); } + if (av.getWrapAlignment()) + { + return; + } + + doMouseMoved(evt); + } public void mouseDragged(MouseEvent evt) { - if(av.getWrapAlignment()) - return; - if( editingSeqs ) + if (av.getWrapAlignment()) + { + return; + } + + if (editingSeqs) + { doMouseDragged(evt); + } else + { doMouseDraggedDefineMode(evt); + } } }); - addMouseListener( new MouseAdapter() + addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { - if(av.getWrapAlignment()) - return; - if(editingSeqs) + 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 (av.getWrapAlignment()) { - if(evt.isAltDown() || evt.isControlDown()) + 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); + { + return; + } + doMouseExitedDefineMode(evt); } + public void mouseEntered(MouseEvent evt) { if (av.getWrapAlignment() || editingSeqs) + { return; + } + doMouseEnteredDefineMode(evt); } - }); repaint(); } - - public void doMouseReleased(MouseEvent evt) { - - if(seqEditOccurred>-1) + public void doMouseReleased(MouseEvent evt) + { + if (seqEditOccurred > -1) + { editOccurred(seqEditOccurred); + } startseq = -1; - lastres = -1; + lastres = -1; seqEditOccurred = -1; - editingSeqs = false; + editingSeqs = false; groupEditing = false; ap.repaint(); } - public void doMousePressed(MouseEvent evt) { - - ap.alignFrame.addHistoryItem( new HistoryItem( - "Edit Sequence",av.alignment, HistoryItem.EDIT)); + public void doMousePressed(MouseEvent evt) + { + ap.alignFrame.addHistoryItem(new HistoryItem("Edit Sequence", + av.alignment, HistoryItem.EDIT)); int seq; int res; @@ -149,11 +190,11 @@ public class SeqPanel extends JPanel int x = evt.getX(); int y = evt.getY(); - res = x/av.getCharWidth() + av.getStartRes(); - seq = y/av.getCharHeight() + av.getStartSeq(); + res = (x / av.getCharWidth()) + av.getStartRes(); + seq = (y / av.getCharHeight()) + av.getStartSeq(); - if (seq < av.getAlignment().getHeight() && - res < av.getAlignment().getSequenceAt(seq).getLength()) + if ( (seq < av.getAlignment().getHeight()) && + (res < av.getAlignment().getSequenceAt(seq).getLength())) { startseq = seq; lastres = res; @@ -172,189 +213,232 @@ public class SeqPanel extends JPanel public void doMouseMoved(MouseEvent evt) { - int res=0, seq=0; + int res = 0; + int seq = 0; int x = evt.getX(); int y = evt.getY(); - if(av.wrapAlignment) + + if (av.wrapAlignment) { - y -= 2*av.charHeight; - int chunkHeight = (av.getAlignment().getHeight()+2)*av.charHeight; + y -= (2 * av.charHeight); + int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight; - res = (int)((y/chunkHeight)*(getWidth()/av.charWidth)) + x/av.getCharWidth() + av.getStartRes(); + res = (int) ( (y / chunkHeight) * (getWidth() / av.charWidth)) + + (x / av.getCharWidth()) + av.getStartRes(); y %= chunkHeight; - seq = y / av.getCharHeight() + av.getStartSeq(); - + seq = (y / av.getCharHeight()) + av.getStartSeq(); } else { - res = x / av.getCharWidth() + av.getStartRes(); - seq = y / av.getCharHeight() + av.getStartSeq(); + res = (x / av.getCharWidth()) + av.getStartRes(); + seq = (y / av.getCharHeight()) + av.getStartSeq(); } - - if(seq>=av.getAlignment().getHeight()) + if (seq >= av.getAlignment().getHeight()) + { return; + } SequenceI sequence = av.getAlignment().getSequenceAt(seq); - if(res>sequence.getLength()) + + if (res > sequence.getLength()) + { return; + } - Object obj = ResidueProperties.aa2Triplet.get( sequence.getCharAt(res)+"" ) ; + Object obj = ResidueProperties.aa2Triplet.get(sequence.getCharAt(res) + + ""); String aa = ""; - if(obj!=null) - aa = obj.toString(); - StringBuffer text = new StringBuffer("Sequence " +(seq+1)+" ID: "+sequence.getName()); - if(aa!="") - text.append(" Residue: "+aa+" ("+ av.getAlignment().getSequenceAt(seq).findPosition(res)+")"); + if (obj != null) + { + aa = obj.toString(); + } + + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + + sequence.getName()); + + if (aa != "") + { + text.append(" Residue: " + aa + " (" + + av.getAlignment().getSequenceAt(seq).findPosition(res) + ")"); + } ap.alignFrame.statusBar.setText(text.toString()); // use aa to see if the mouse pointer is on a - if( av.showSequenceFeatures) + if (av.showSequenceFeatures) { 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 ( (sf.getStart() <= sequence.findPosition(res)) && + (sf.getEnd() >= sequence.findPosition(res))) { - if(sbuffer.length()>0) + if (sbuffer.length() > 0) + { sbuffer.append("; "); + } + sbuffer.append(sf.getType() + " " + sf.getDescription()); - if(sf.getStatus().length()>0) - sbuffer.append(" ("+sf.getStatus()+")"); - } + if (sf.getStatus().length() > 0) + { + sbuffer.append(" (" + sf.getStatus() + ")"); + } + } } ToolTipManager.sharedInstance().registerComponent(this); this.setToolTipText(sbuffer.toString()); } - - } - public void doMouseDragged(MouseEvent evt) { - + public void doMouseDragged(MouseEvent evt) + { // If we're dragging we're editing - int res = evt.getX() / av.getCharWidth() + av.getStartRes(); + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + if (res < 0) + { res = 0; + } - if (lastres == -1 || lastres == res) + if ( (lastres == -1) || (lastres == res)) + { return; + } boolean dragRight = true; - if (res < av.getAlignment().getWidth() && res < lastres) - dragRight = false; + if ( (res < av.getAlignment().getWidth()) && (res < lastres)) + { + dragRight = false; + } if (res != lastres) { - // Group editing - if (groupEditing) + // Group editing + if (groupEditing) + { + SequenceGroup sg = av.getSelectionGroup(); + + if (sg == null) { - SequenceGroup sg = av.getSelectionGroup(); - if(sg==null) - { - lastres=-1; - return; - } + lastres = -1; - // drag to right - if(dragRight) - sg.setEndRes(sg.getEndRes() + (res-lastres)); + return; + } - // drag to left - else + // 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++) { - /// Are we able to delete? - // ie are all columns blank? - boolean deleteAllowed = false; - for (int s = 0; s < sg.getSize(); s++) + if (seq.getSequence().length() <= j) { - SequenceI seq = sg.getSequenceAt(s); - for (int j=res; j j) { - for (int j = res; j < lastres; j++) - { - if(s.getLength()>j) - deleteChar(res, k); - } + deleteChar(res, k); } } + } } - else /////Editing a single sequence/////////// + } + else /////Editing a single sequence/////////// + { + if ( (res < av.getAlignment().getWidth()) && (res > lastres)) { - if (res < av.getAlignment().getWidth() && res > lastres) + // dragging to the right + for (int j = lastres; j < res; j++) { - // dragging to the right - for (int j = lastres; j < res; j++) - insertChar(j, startseq); + insertChar(j, startseq); } - else if (res < av.getAlignment().getWidth() && res < lastres) + } + else if ( (res < av.getAlignment().getWidth()) && + (res < lastres)) + { + // dragging to the left + for (int j = lastres; j > res; j--) { - // dragging to the left - for (int j = lastres; j > res; j--) + if (jalview.util.Comparison.isGap( + av.alignment.getSequenceAt(startseq) + .getSequence().charAt(res))) { - if( jalview.util.Comparison.isGap( - av.alignment.getSequenceAt(startseq).getSequence().charAt(res))) - deleteChar(res, startseq); - else - { - - break; - } + } + else + { + break; } } - } + } } endEdit = res; @@ -362,30 +446,31 @@ public class SeqPanel extends JPanel repaint(); } - public void drawChars(int seqstart, int seqend, int start) { - seqCanvas.drawPanel(seqCanvas.gg, start,av.getEndRes(),seqstart,seqend,av.getStartRes(),av.getStartSeq(),0); + public void drawChars(int seqstart, int seqend, int start) + { + seqCanvas.drawPanel(seqCanvas.gg, start, av.getEndRes(), seqstart, + seqend, av.getStartRes(), av.getStartSeq(), 0); repaint(); } public void insertChar(int j, int seq) { av.alignment.getSequenceAt(seq).insertCharAt(j, av.getGapCharacter()); - seqEditOccurred=seq; + seqEditOccurred = seq; } public void deleteChar(int j, int seq) { av.alignment.getSequenceAt(seq).deleteCharAt(j); - seqEditOccurred=seq; + seqEditOccurred = seq; av.alignment.getWidth(); repaint(); } - void editOccurred(int i) { - if(endEdit==startEdit) + if (endEdit == startEdit) { ap.alignFrame.historyList.pop(); ap.alignFrame.updateEditMenuBar(); @@ -396,11 +481,13 @@ public class SeqPanel extends JPanel // Y O Y CLUSTALX ColourSchemeI cs = av.getGlobalColourScheme(); - if(cs instanceof ConservationColourScheme) + + if (cs instanceof ConservationColourScheme) { - ConservationColourScheme ccs = (ConservationColourScheme) cs; - if(ccs.cs instanceof ClustalxColourScheme) - { + ConservationColourScheme ccs = (ConservationColourScheme) cs; + + if (ccs.cs instanceof ClustalxColourScheme) + { Conservation c = new Conservation("All", ResidueProperties.propHash, 3, av.alignment.getSequences(), 0, @@ -408,135 +495,151 @@ public class SeqPanel extends JPanel c.calculate(); c.verdict(false, av.ConsPercGaps); - ClustalxColourScheme cxs = (ClustalxColourScheme)ccs.cs; - cxs.resetClustalX(av.alignment.getSequences(), av.alignment.getWidth()); + ClustalxColourScheme cxs = (ClustalxColourScheme) ccs.cs; + cxs.resetClustalX(av.alignment.getSequences(), + av.alignment.getWidth()); ccs = new ConservationColourScheme(c, cxs); av.setGlobalColourScheme(ccs); - } + } } - if(cs instanceof ClustalxColourScheme) + if (cs instanceof ClustalxColourScheme) { - ((ClustalxColourScheme)cs).resetClustalX(av.alignment.getSequences(), - av.alignment.getWidth()); + ( (ClustalxColourScheme) cs).resetClustalX(av.alignment.getSequences(), + av.alignment.getWidth()); av.setGlobalColourScheme(cs); } - } -////////////////////////////////////////// -/////Everything below this is for defining the boundary of the rubberband -////////////////////////////////////////// - int oldSeq = -1; public void doMousePressedDefineMode(MouseEvent evt) { - int res = evt.getX()/av.getCharWidth() + av.getStartRes(); - int seq = evt.getY()/av.getCharHeight() + av.getStartSeq(); + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + int seq = (evt.getY() / av.getCharHeight()) + av.getStartSeq(); oldSeq = seq; SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq); - if(sequence==null || res>sequence.getLength()) + if ( (sequence == null) || (res > sequence.getLength())) + { return; + } stretchGroup = av.getSelectionGroup(); - if(stretchGroup == null) - { - stretchGroup = av.alignment.findGroup( sequence ); - if(stretchGroup!=null && res>stretchGroup.getStartRes() && resres - || stretchGroup.getEndRes()= res) - { - stretchGroup = allGroups[i]; - av.setSelectionGroup(stretchGroup); - break; - } - } - - if(stretchGroup==null) + 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; + + SequenceGroup[] allGroups = av.alignment.findAllGroups(sequence); + + 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; + } + } + } + } + + if (stretchGroup == null) { // define a new group here SequenceGroup sg = new SequenceGroup(); sg.setStartRes(res); sg.setEndRes(res); - sg.addSequence( sequence ); - av.setSelectionGroup( sg ); + sg.addSequence(sequence); + av.setSelectionGroup(sg); stretchGroup = sg; - if(av.getConservationSelected()) - SliderPanel.setConservationSlider(ap, av.getGlobalColourScheme(), "Background"); - if(av.getAbovePIDThreshold()) - SliderPanel.setPIDSliderSource(ap, av.getGlobalColourScheme(), "Background"); + 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)) + else if (javax.swing.SwingUtilities.isRightMouseButton(evt)) { - jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu( ap , null); - pop.show(this, evt.getX(), evt.getY()); + jalview.gui.PopupMenu pop = new jalview.gui.PopupMenu(ap, null); + pop.show(this, evt.getX(), evt.getY()); - // edit the properties of existing group + // edit the properties of existing group } - if(stretchGroup!=null && stretchGroup.getEndRes()==res) + if ( (stretchGroup != null) && (stretchGroup.getEndRes() == res)) + { // Edit end res position of selected group changeEndRes = true; - - else if(stretchGroup!=null && stretchGroup.getStartRes()==res) + } + else if ( (stretchGroup != null) && (stretchGroup.getStartRes() == res)) + { // Edit end res position of selected group changeStartRes = true; + } stretchGroup.getWidth(); repaint(); - } - boolean changeEndSeq = false; - boolean changeStartSeq = false; - boolean changeEndRes = false; - boolean changeStartRes = false; - SequenceGroup stretchGroup = null; - public void doMouseReleasedDefineMode(MouseEvent evt) { mouseDragging = false; - if(stretchGroup==null) + if (stretchGroup == null) + { return; + } - if(stretchGroup.cs instanceof ClustalxColourScheme) + if (stretchGroup.cs instanceof ClustalxColourScheme) { - stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, av.alignment.getWidth()); + stretchGroup.cs = new ClustalxColourScheme(stretchGroup.sequences, + av.alignment.getWidth()); repaint(); } - - else if(stretchGroup.cs instanceof ConservationColourScheme) + else if (stretchGroup.cs instanceof ConservationColourScheme) { - ConservationColourScheme ccs = (ConservationColourScheme)stretchGroup.cs; - stretchGroup.cs = ccs; - SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup.getName()) ; + ConservationColourScheme ccs = (ConservationColourScheme) stretchGroup.cs; + stretchGroup.cs = ccs; + SliderPanel.setConservationSlider(ap, stretchGroup.cs, + stretchGroup.getName()); - repaint(); + repaint(); } else - SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup.getName()); - + { + SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, + stretchGroup.getName()); + } changeEndRes = false; changeStartRes = false; @@ -544,58 +647,75 @@ public class SeqPanel extends JPanel ap.idPanel.repaint(); } - - boolean remove = false; public void doMouseDraggedDefineMode(MouseEvent evt) { - int res = evt.getX()/av.getCharWidth() + av.getStartRes(); - int y = evt.getY()/av.getCharHeight() + av.getStartSeq(); + int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); + int y = (evt.getY() / av.getCharHeight()) + av.getStartSeq(); - if(stretchGroup==null) + if (stretchGroup == null) + { return; + } - if(res>av.alignment.getWidth()) - res = av.alignment.getWidth()-1; - + if (res > av.alignment.getWidth()) + { + res = av.alignment.getWidth() - 1; + } - if(stretchGroup.getEndRes()==res) + if (stretchGroup.getEndRes() == res) + { // Edit end res position of selected group changeEndRes = true; - - else if(stretchGroup.getStartRes()==res) + } + else if (stretchGroup.getStartRes() == res) + { // Edit start res position of selected group changeStartRes = true; + } - - if(resav.getEndRes()) + } + else if (res > av.getEndRes()) + { res = av.getEndRes(); + } - if(changeEndRes) + if (changeEndRes) { - if(res>stretchGroup.getStartRes()-1) - stretchGroup.setEndRes( res ); + if (res > (stretchGroup.getStartRes() - 1)) + { + stretchGroup.setEndRes(res); + } } - else if(changeStartRes) + else if (changeStartRes) { - if(res oldSeq) + { dragDirection = 1; + } else if (y < oldSeq) + { dragDirection = -1; + } - while (y != oldSeq && oldSeq>0 && y 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); oldSeq += dragDirection; + Sequence nextSeq = (Sequence) av.getAlignment().getSequenceAt(oldSeq); if (stretchGroup.sequences.contains(nextSeq)) @@ -605,15 +725,22 @@ public class SeqPanel extends JPanel } else { - if(seq!=null) - stretchGroup.addSequence(seq); + if (seq != null) + { + stretchGroup.addSequence(seq); + } + stretchGroup.addSequence(nextSeq); } } + oldSeq = y; mouseDragging = true; - if(scrollThread!=null) + + if (scrollThread != null) + { scrollThread.setEvent(evt); + } repaint(); } @@ -621,23 +748,31 @@ public class SeqPanel extends JPanel public void doMouseEnteredDefineMode(MouseEvent e) { if (scrollThread != null) + { scrollThread.running = false; + } } public void doMouseExitedDefineMode(MouseEvent e) { if (av.getWrapAlignment()) + { return; + } - if(mouseDragging) + if (mouseDragging) + { scrollThread = new ScrollThread(); - + } } + // this class allows scrolling off the bottom of the visible alignment - class ScrollThread extends Thread + class ScrollThread + extends Thread { MouseEvent evt; boolean running = false; + public ScrollThread() { start(); @@ -656,23 +791,31 @@ public class SeqPanel extends JPanel public void run() { running = true; + while (running) { - if(evt!=null) + if (evt != null) { - - if (mouseDragging && evt.getY() < 0 && av.getStartSeq() > 0) + if (mouseDragging && (evt.getY() < 0) && + (av.getStartSeq() > 0)) + { running = ap.scrollUp(true); + } - if (mouseDragging && evt.getY() >= getHeight() && - av.alignment.getHeight() > av.getEndSeq()) + if (mouseDragging && (evt.getY() >= getHeight()) && + (av.alignment.getHeight() > av.getEndSeq())) + { running = ap.scrollUp(false); + } - if (mouseDragging && evt.getX() < 0) + if (mouseDragging && (evt.getX() < 0)) + { running = ap.scrollRight(true); - - else if (mouseDragging && evt.getX() >= getWidth()) + } + else if (mouseDragging && (evt.getX() >= getWidth())) + { running = ap.scrollRight(false); + } } try @@ -680,15 +823,9 @@ public class SeqPanel extends JPanel Thread.sleep(75); } catch (Exception ex) - {} + { + } } } + } } - - - -} - - - - diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index 2c98754..896fda5 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -1,27 +1,27 @@ /* -* 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.gui; +import java.awt.*; + import jalview.datamodel.*; import jalview.schemes.*; -import java.awt.*; public class SequenceRenderer { @@ -29,7 +29,7 @@ public class SequenceRenderer FontMetrics fm; boolean renderGaps = true; SequenceGroup currentSequenceGroup = null; - SequenceGroup [] allGroups = null; + SequenceGroup[] allGroups = null; Color resBoxColour; Graphics graphics; @@ -38,7 +38,6 @@ public class SequenceRenderer this.av = av; } - public void renderGaps(boolean b) { renderGaps = b; @@ -47,18 +46,25 @@ public class SequenceRenderer 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) - resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); - else - resBoxColour = Color.white; + if (cs != null) + { + resBoxColour = cs.findColour(seq.getSequence(i, i + 1), i); + } + else + { + resBoxColour = Color.white; + } } - public void drawSequence(Graphics g,SequenceI seq,SequenceGroup [] sg, int start, int end, int x1, int y1, int width, int height) + public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg, + int start, int end, int x1, int y1, int width, + int height) { allGroups = sg; @@ -67,145 +73,182 @@ public class SequenceRenderer drawBoxes(seq, start, end, x1, y1, (int) width, height); fm = g.getFontMetrics(); - drawText(seq,start,end,x1,y1,(int)width,height); - + 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; + 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; Color tempColour = null; - while (i <= end && i < length) + + while ( (i <= end) && (i < length)) { - if(inCurrentSequenceGroup(i)) + if (inCurrentSequenceGroup(i)) { - if( currentSequenceGroup.getDisplayBoxes()) - getBoxColour(currentSequenceGroup.cs, seq, i); + if (currentSequenceGroup.getDisplayBoxes()) + { + getBoxColour(currentSequenceGroup.cs, seq, i); + } else - resBoxColour = Color.white; + { + resBoxColour = Color.white; + } + } + else if (av.getShowBoxes()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); } - 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); + 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++; } - - graphics.fillRect(x1+width*(curStart-start),y1,curWidth,height); + graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, + height); } - public void drawText(SequenceI seq,int start, int end, int x1, int y1, int width, int height) + public void drawText(SequenceI seq, int start, int end, int x1, int y1, + int width, int height) { - int pady = height/5; - int charOffset=0; + int pady = height / 5; + int charOffset = 0; char s; - // Need to find the sequence position here. + // Need to find the sequence position here. + String sequence = seq.getSequence(); - String sequence = seq.getSequence(); for (int i = start; i <= end; i++) { - graphics.setColor(Color.black); + graphics.setColor(Color.black); - if(i=res) + for (int i = 0; i < allGroups.length; i++) + { + if ( (allGroups[i].getStartRes() <= res) && + (allGroups[i].getEndRes() >= res)) { - currentSequenceGroup = allGroups[i]; - return true; + currentSequenceGroup = allGroups[i]; + + return true; } + } return false; } - public void drawHighlightedText(SequenceI seq,int start, int end, int x1, int y1, int width, int height) + public void drawHighlightedText(SequenceI seq, int start, int end, int x1, + int y1, int width, int height) { - int pady = height/5; - int charOffset=0; + int pady = height / 5; + int charOffset = 0; graphics.setColor(Color.BLACK); - graphics.fillRect(x1,y1,width*(end-start+1),height); + graphics.fillRect(x1, y1, width * (end - start + 1), height); graphics.setColor(Color.white); - char s='~'; + char s = '~'; + // Need to find the sequence position here. for (int i = start; i <= end; i++) { - if(i -1 ) + while (groupIndex > -1) { - if(allGroups!=null) - toChange = ((SequenceGroup)allGroups.get(groupIndex)).cs; + if (allGroups != null) + { + toChange = ( (SequenceGroup) allGroups.get(groupIndex)).cs; + } if (forConservation) { if (toChange instanceof ConservationColourScheme) + { ( (ConservationColourScheme) toChange).inc = i; + } } else { - ( (ResidueColourScheme) toChange).setThreshold(i); + ( (ResidueColourScheme) toChange).setThreshold(i); } groupIndex--; } ap.seqPanel.seqCanvas.repaint(); - } public void setAllGroupsCheckEnabled(boolean b) @@ -226,16 +257,16 @@ public class SliderPanel extends GSliderPanel allGroupsCheck.setEnabled(b); } - public void valueField_actionPerformed(ActionEvent e) { - try{ + try + { int i = Integer.parseInt(valueField.getText()); slider.setValue(i); } - catch(Exception ex) + catch (Exception ex) { - valueField.setText( slider.getValue()+"" ); + valueField.setText(slider.getValue() + ""); } } @@ -243,10 +274,9 @@ public class SliderPanel extends GSliderPanel { 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 794bbb8..6edab5d 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -1,66 +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.gui; -import javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.*; -public class SplashScreen extends JPanel implements Runnable +public class SplashScreen + extends JPanel implements Runnable { boolean visible = true; JInternalFrame iframe; Image image; + int fontSize = 11; + int yoffset = 30; 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) + { + public void mousePressed(MouseEvent evt) { try - { closeSplash(); } + { + closeSplash(); + } catch (Exception ex) - {} + { + } } - }); + }); } - public void run() { - long startTime = System.currentTimeMillis()/1000; + long startTime = System.currentTimeMillis() / 1000; - while( visible ) + while (visible) { - if( System.currentTimeMillis()/1000 - startTime > 5) + if ( ( (System.currentTimeMillis() / 1000) - startTime) > 5) + { visible = false; + } - try{ + try + { Thread.sleep(1000); } - catch(Exception ex){} + catch (Exception ex) + { + } } + closeSplash(); } @@ -71,29 +83,36 @@ public class SplashScreen extends JPanel implements Runnable iframe.setClosed(true); } catch (Exception ex) - {} - + { + } } - int fontSize = 11; - int yoffset = 30; public void paintComponent(Graphics g) { g.setColor(Color.white); - g.fillRect(0,0,getWidth(),getHeight()); + 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); - 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.setFont(new Font("Verdana", Font.BOLD, fontSize + 6)); - } + 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)); + } } diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 5ebf323..12416ae 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -1,68 +1,65 @@ /* -* 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.gui; +import java.util.*; -import jalview.analysis.*; -import jalview.datamodel.*; -import jalview.util.*; -import jalview.schemes.*; -import javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.util.*; import java.awt.print.*; +import javax.swing.*; -public class TreeCanvas extends JPanel implements MouseListener, Runnable, Printable +import jalview.analysis.*; +import jalview.datamodel.*; +import jalview.schemes.*; +import jalview.util.*; + +public class TreeCanvas + extends JPanel implements MouseListener, Runnable, + Printable { + public static final String PLACEHOLDER = " * "; NJTree tree; JScrollPane scrollPane; AlignViewport av; - public static final String PLACEHOLDER=" * "; Font font; - int fontSize = 12; - + 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; + int labelLength = -1; //RubberbandRectangle rubberband; - - Vector listeners; - + Vector listeners; Hashtable nameHash = new Hashtable(); Hashtable nodeHash = new Hashtable(); - public TreeCanvas(AlignViewport av, NJTree tree, JScrollPane scroller, String label) + public TreeCanvas(AlignViewport av, NJTree tree, JScrollPane scroller, + String label) { this.av = av; - this.tree = tree; + this.tree = tree; scrollPane = scroller; addMouseListener(this); tree.findHeight(tree.getTopNode()); @@ -70,10 +67,12 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print PaintRefresher.Register(this); } + public void TreeSelectionChanged(Sequence sequence) - { + { SequenceGroup selected = av.getSelectionGroup(); - if(selected == null) + + if (selected == null) { selected = new SequenceGroup(); av.setSelectionGroup(selected); @@ -82,205 +81,259 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print selected.setEndRes(av.alignment.getWidth()); selected.addOrRemove(sequence); - PaintRefresher.Refresh(this); repaint(); - } - - + } - public void setTree(NJTree tree) { + public void setTree(NJTree tree) + { this.tree = tree; tree.findHeight(tree.getTopNode()); } - public void drawNode(Graphics g,SequenceNode node, float chunk, float scale, int width,int offx, int offy) { - if (node == null) { + public void drawNode(Graphics g, SequenceNode node, float chunk, + float scale, int width, int offx, int offy) + { + if (node == null) + { return; } - if (node.left() == null && node.right() == null) { + if ( (node.left() == null) && (node.right() == null)) + { // Drawing leaf node - float height = node.height; - float dist = node.dist; + float dist = node.dist; - int xstart = (int)((height-dist)*scale) + offx; - int xend = (int)(height*scale) + offx; + int xstart = (int) ( (height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; - int ypos = (int)(node.ycount * chunk) + offy; + 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()); - + 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); - + { + g.setColor(Color.black); + } // Draw horizontal line - g.drawLine(xstart,ypos,xend,ypos); + g.drawLine(xstart, ypos, xend, ypos); String nodeLabel = ""; - if (showDistances && node.dist > 0) { + + if (showDistances && (node.dist > 0)) + { nodeLabel = new Format("%5.2f").form(node.dist); } - if (showBootstrap) { - if (showDistances) { + + if (showBootstrap) + { + if (showDistances) + { nodeLabel = nodeLabel + " : "; } + nodeLabel = nodeLabel + String.valueOf(node.getBootstrap()); } - if (! nodeLabel.equals("")) { - g.drawString(nodeLabel,xstart,ypos - 10); + + if (!nodeLabel.equals("")) + { + g.drawString(nodeLabel, xstart, ypos - 10); } - String name = (markPlaceholders && node.isPlaceholder()) ? (PLACEHOLDER+node.getName()) : node.getName(); + String name = (markPlaceholders && node.isPlaceholder()) + ? (PLACEHOLDER + node.getName()) : node.getName(); FontMetrics fm = g.getFontMetrics(font); - int charWidth = fm.stringWidth(name) + 3; + int charWidth = fm.stringWidth(name) + 3; int charHeight = fm.getHeight(); - Rectangle rect = new Rectangle(xend+20,ypos-charHeight, - charWidth,charHeight); + Rectangle rect = new Rectangle(xend + 20, ypos - charHeight, + charWidth, charHeight); - nameHash.put((SequenceI)node.element(),rect); + nameHash.put( (SequenceI) node.element(), rect); // Colour selected leaves differently SequenceGroup selected = av.getSelectionGroup(); - if (selected!=null && selected.sequences.contains((SequenceI)node.element())) { + + if ( (selected != null) && + selected.sequences.contains( (SequenceI) node.element())) + { g.setColor(Color.gray); - g.fillRect(xend + 10, ypos - charHeight + 3,charWidth,charHeight); + g.fillRect(xend + 10, ypos - charHeight + 3, charWidth, + charHeight); g.setColor(Color.white); } - g.drawString(name,xend+10,ypos); + + 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); + } + 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; + float dist = node.dist; - int xstart = (int)((height-dist)*scale) + offx; - int xend = (int)(height *scale) + offx; - int ypos = (int)(node.ycount *chunk) + offy; + 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()); + g.setColor( ( (SequenceNode) node).color.darker()); // Draw horizontal line - g.drawLine(xstart,ypos,xend,ypos); - g.fillRect(xend-2, ypos-2, 4,4); + 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; + 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); + Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5); + nodeHash.put(node, pos); - g.drawLine((int)(height*scale) + offx, ystart, - (int)(height*scale) + offx, yend); + g.drawLine( (int) (height * scale) + offx, ystart, + (int) (height * scale) + offx, yend); - if (showDistances && node.dist > 0) { - g.drawString(new Format("%5.2f").form(node.dist),xstart,ypos - 5); + if (showDistances && (node.dist > 0)) + { + g.drawString(new Format("%5.2f").form(node.dist), xstart, + ypos - 5); } - } } - public Object findElement(int x, int y) { - Enumeration keys = nameHash.keys(); - while (keys.hasMoreElements()) { - Object ob = keys.nextElement(); - Rectangle rect = (Rectangle)nameHash.get(ob); + public Object findElement(int x, int y) + { + Enumeration keys = nameHash.keys(); - if (x >= rect.x && x <= (rect.x + rect.width) && - y >= rect.y && y <= (rect.y + rect.height)) { - return ob; - } - } - keys = nodeHash.keys(); + while (keys.hasMoreElements()) + { + Object ob = keys.nextElement(); + Rectangle rect = (Rectangle) nameHash.get(ob); - 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; + } + } - if (x >= rect.x && x <= (rect.x + rect.width) && - y >= rect.y && y <= (rect.y + rect.height)) { - return ob; - } + keys = nodeHash.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; + } } - return null; + return null; } - public void pickNodes(Rectangle pickBox) { - int width = getWidth(); + public void pickNodes(Rectangle pickBox) + { + int width = getWidth(); int height = getHeight(); SequenceNode top = tree.getTopNode(); - float wscale = (float)(width*.8-offx*2)/tree.getMaxHeight() -; - if (top.count == 0) { - top.count = ((SequenceNode)top.left()).count + ((SequenceNode)top.right()).count ; + float wscale = (float) ( (width * .8) - (offx * 2)) / tree.getMaxHeight(); + + if (top.count == 0) + { + top.count = ( (SequenceNode) top.left()).count + + ( (SequenceNode) top.right()).count; } - float chunk = (float)(height-offy*2)/top.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) { + public void pickNode(Rectangle pickBox, SequenceNode node, float chunk, + float scale, int width, int offx, int offy) + { + if (node == null) + { return; } - if (node.left() == null && node.right() == null) { + if ( (node.left() == null) && (node.right() == null)) + { float height = node.height; - float dist = node.dist; + float dist = node.dist; - int xstart = (int)((height-dist)*scale) + offx; - int xend = (int)(height*scale) + offx; + int xstart = (int) ( (height - dist) * scale) + offx; + int xend = (int) (height * scale) + offx; - int ypos = (int)(node.ycount * chunk) + offy; + int ypos = (int) (node.ycount * chunk) + offy; - if (pickBox.contains(new Point(xend,ypos))) { - if (node.element() instanceof SequenceI) { - SequenceI seq = (SequenceI)node.element(); + if (pickBox.contains(new Point(xend, ypos))) + { + if (node.element() instanceof SequenceI) + { + SequenceI seq = (SequenceI) node.element(); SequenceGroup sg = av.getSelectionGroup(); - if(sg!=null) + + if (sg != null) + { sg.addOrRemove(seq); + } } } - } else { - pickNode(pickBox,(SequenceNode)node.left(), chunk,scale,width,offx,offy); - pickNode(pickBox,(SequenceNode)node.right(),chunk,scale,width,offx,offy); + } + 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) + { return; + } - if (node.left() == null && node.right() == null) + if ( (node.left() == null) && (node.right() == null)) { node.color = c; if (node.element() instanceof SequenceI) - ((SequenceI)node.element()).setColor(c); - } else + { + ( (SequenceI) node.element()).setColor(c); + } + } + else { node.color = c; - setColor((SequenceNode)node.left(),c); - setColor((SequenceNode)node.right(),c); + setColor( (SequenceNode) node.left(), c); + setColor( (SequenceNode) node.right(), c); } } @@ -297,6 +350,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print PageFormat pf = printJob.pageDialog(printJob.defaultPage()); printJob.setPrintable(this, pf); + if (printJob.printDialog()) { try @@ -310,216 +364,259 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, Print } } - - public int print(Graphics pg, PageFormat pf, int pi) throws PrinterException + public int print(Graphics pg, PageFormat pf, int pi) + throws PrinterException { - pg.setFont(font); - pg.translate((int)pf.getImageableX(), (int)pf.getImageableY()); + pg.translate( (int) pf.getImageableX(), (int) pf.getImageableY()); + int pwidth = (int) pf.getImageableWidth(); int pheight = (int) pf.getImageableHeight(); int noPages = getHeight() / pheight; - if(pi>noPages) - return Printable.NO_SUCH_PAGE; + if (pi > noPages) + { + return Printable.NO_SUCH_PAGE; + } if (pwidth > getWidth()) - pwidth = getWidth(); + { + pwidth = getWidth(); + } - if(fitToWindow) + if (fitToWindow) { if (pheight > getHeight()) + { pheight = getHeight(); + } 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 = 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; } draw(pg, pwidth, pheight); return Printable.PAGE_EXISTS; - } public void paintComponent(Graphics g) { - - font = new Font("Verdana",Font.PLAIN,fontSize); + font = new Font("Verdana", Font.PLAIN, fontSize); g.setFont(font); FontMetrics fm = g.getFontMetrics(font); - if(nameHash.size()==0) + if (nameHash.size() == 0) + { repaint(); + } - - if( fitToWindow || (!fitToWindow && scrollPane.getHeight() > fm.getHeight() * nameHash.size()+offy ) ) - { - draw(g,scrollPane.getWidth(),scrollPane.getHeight()); - setPreferredSize(null); - } + 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()); - } + { + setPreferredSize(new Dimension(scrollPane.getWidth(), + fm.getHeight() * nameHash.size())); + draw(g, scrollPane.getWidth(), fm.getHeight() * nameHash.size()); + } scrollPane.revalidate(); } - public int getFontSize() { - return fontSize; - } - public void setFontSize(int fontSize) { - this.fontSize = fontSize; - repaint(); - } - 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); + public int getFontSize() + { + return fontSize; + } + public void setFontSize(int fontSize) + { + this.fontSize = fontSize; + repaint(); + } - labelLength = g2.getFontMetrics(font).stringWidth(longestName)+ 20;//20 allows for scrollbar + 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); - float wscale =(float)(width - labelLength -offx*2)/tree.getMaxHeight(); + labelLength = g2.getFontMetrics(font).stringWidth(longestName) + 20; //20 allows for scrollbar - SequenceNode top = tree.getTopNode(); + float wscale = (float) (width - labelLength - (offx * 2)) / + tree.getMaxHeight(); - if (top.count == 0) { - top.count = ((SequenceNode)top.left()).count + ((SequenceNode)top.right()).count ; - } - float chunk = (float)(height-offy*2)/top.count ; + SequenceNode top = tree.getTopNode(); - drawNode(g2,tree.getTopNode(),chunk,wscale,width,offx,offy); + if (top.count == 0) + { + top.count = ( (SequenceNode) top.left()).count + + ( (SequenceNode) top.right()).count; + } - if (threshold != 0) - { - if(av.getCurrentTree() == tree) - g2.setColor(Color.red); - else - g2.setColor(Color.gray); + float chunk = (float) (height - (offy * 2)) / top.count; - int x = (int)( threshold * (float)(getWidth()-labelLength - 2*offx) +offx ) ; + drawNode(g2, tree.getTopNode(), chunk, wscale, width, offx, offy); - g2.drawLine(x,0,x,getHeight()); + if (threshold != 0) + { + if (av.getCurrentTree() == tree) + { + g2.setColor(Color.red); } - - } - - 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) + else { - TreeSelectionChanged((Sequence)ob); - repaint(); - return; - - } else if (ob instanceof SequenceNode) { - SequenceNode tmpnode = (SequenceNode)ob; - tree.swapNodes(tmpnode); - tree.reCount(tree.getTopNode()); - tree.findHeight(tree.getTopNode()); - } else { - // Find threshold + g2.setColor(Color.gray); + } - if (tree.getMaxHeight() != 0) { - threshold = (float)(x - offx)/(float)(getWidth()-labelLength - 2*offx); + int x = (int) ( (threshold * (float) (getWidth() - labelLength - + (2 * offx))) + offx); - tree.getGroups().removeAllElements(); - tree.groupNodes(tree.getTopNode(),threshold); - setColor(tree.getTopNode(),Color.black); + g2.drawLine(x, 0, x, getHeight()); + } + } - av.setSelectionGroup(null); - av.alignment.deleteAllGroups(); + public void mouseReleased(MouseEvent e) + { + } - for (int i=0; i < tree.getGroups().size(); i++) - { + public void mouseEntered(MouseEvent e) + { + } - Color col = new Color((int)(Math.random()*255), - (int)(Math.random()*255), - (int)(Math.random()*255)); - setColor((SequenceNode)tree.getGroups().elementAt(i),col.brighter()); + public void mouseExited(MouseEvent e) + { + } - Vector l = tree.findLeaves((SequenceNode)tree.getGroups().elementAt(i),new Vector()); - SequenceGroup sg = null; - for (int j = 0; j < l.size(); j++) - { - SequenceNode sn = (SequenceNode) l.elementAt(j); - if(sg==null) - sg = new SequenceGroup("TreeGroup", av.getGlobalColourScheme(), true, true,false,0,av.alignment.getWidth()); + public void mouseClicked(MouseEvent e) + { + } - sg.addSequence( (Sequence) sn.element()); - } + public void mousePressed(MouseEvent e) + { + av.setCurrentTree(tree); - if (av.getGlobalColourScheme() instanceof ConservationColourScheme) - { - ConservationColourScheme ccs = (ConservationColourScheme) av.getGlobalColourScheme(); - Conservation c = new Conservation("Group", - ResidueProperties.propHash, 3, - sg.sequences, sg.getStartRes(), - sg.getEndRes()); + int x = e.getX(); + int y = e.getY(); - c.calculate(); - c.verdict(false, av.ConsPercGaps); - ccs = new ConservationColourScheme(c, ccs.cs); + Object ob = findElement(x, y); - sg.cs = ccs; + if (ob instanceof SequenceI) + { + TreeSelectionChanged( (Sequence) ob); + repaint(); - } + 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()); + SequenceGroup sg = null; + + for (int j = 0; j < l.size(); j++) + { + SequenceNode sn = (SequenceNode) l.elementAt(j); + + if (sg == null) + { + sg = new SequenceGroup("TreeGroup", + av.getGlobalColourScheme(), true, true, + false, 0, av.alignment.getWidth()); + } + sg.addSequence( (Sequence) sn.element()); + } + if (av.getGlobalColourScheme() instanceof ConservationColourScheme) + { + ConservationColourScheme ccs = (ConservationColourScheme) av. + getGlobalColourScheme(); + Conservation c = new Conservation("Group", + ResidueProperties.propHash, 3, + sg.sequences, + sg.getStartRes(), sg.getEndRes()); - av.alignment.addGroup(sg); + c.calculate(); + c.verdict(false, av.ConsPercGaps); + ccs = new ConservationColourScheme(c, ccs.cs); - } + sg.cs = ccs; } - } - PaintRefresher.Refresh(this); - repaint(); + av.alignment.addGroup(sg); + } + } + } + PaintRefresher.Refresh(this); + repaint(); } - public void setShowDistances(boolean state) { - this.showDistances = state; - 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(); - } + public void setShowBootstrap(boolean state) + { + this.showBootstrap = state; + repaint(); + } + public void setMarkPlaceholders(boolean state) + { + this.markPlaceholders = state; + repaint(); + } } - diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index a574795..2a8c9b4 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.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 -*/ - + * 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.gui; -import jalview.datamodel.*; -import jalview.analysis.*; -import jalview.jbgui.GTreePanel; -import jalview.io.*; -import java.awt.event.*; -import java.util.*; import java.io.*; -import javax.swing.*; -import java.awt.*; -import java.awt.image.*; -import org.jibble.epsgraphics.*; +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 +public class TreePanel + extends GTreePanel { SequenceI[] seq; String type; @@ -45,12 +45,8 @@ public class TreePanel extends GTreePanel TreeCanvas treeCanvas; NJTree tree; - public NJTree getTree() - { - return tree; - } - - public TreePanel(AlignViewport av, Vector seqVector, String type, String pwtype, int s, int e) + public TreePanel(AlignViewport av, Vector seqVector, String type, + String pwtype, int s, int e) { super(); @@ -61,12 +57,16 @@ public class TreePanel extends GTreePanel end = e; String longestName = ""; - seq = new Sequence [seqVector.size()]; - for (int i=0;i < seqVector.size();i++) + seq = new Sequence[seqVector.size()]; + + for (int i = 0; i < seqVector.size(); i++) { seq[i] = (Sequence) seqVector.elementAt(i); - if(seq[i].getName().length()>longestName.length()) + + if (seq[i].getName().length() > longestName.length()) + { longestName = seq[i].getName(); + } } tree = new NJTree(seq, type, pwtype, start, end); @@ -77,108 +77,145 @@ public class TreePanel extends GTreePanel tree.reCount(tree.getTopNode()); tree.findHeight(tree.getTopNode()); scrollPane.setViewportView(treeCanvas); - } - 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 TreePanel(AlignViewport av, Vector seqVector, NewickFile newtree, String type, String pwtype) + { + super(); + + // These are probably only arbitrary strings reflecting source of tree + this.type = type; + this.pwtype = pwtype; + + start = 0; + end = seqVector.size(); + + String longestName = ""; + seq = new Sequence[seqVector.size()]; + + for (int i = 0; i < seqVector.size(); i++) { - super(); - // These are probably only arbitrary strings reflecting source of tree - this.type = type; - this.pwtype = pwtype; + seq[i] = (Sequence) seqVector.elementAt(i); + } + + // This constructor matches sequence names to treenodes and sets up the tree layouts. + tree = new NJTree(seq, newtree); + + // Now have to calculate longest name based on the leaves + Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector()); + boolean has_placeholders = false; - start = 0; - end = seqVector.size(); + for (int i = 0; i < leaves.size(); i++) + { + SequenceNode lf = (SequenceNode) leaves.elementAt(i); - String longestName = ""; - seq = new Sequence [seqVector.size()]; - for (int i=0;i < seqVector.size();i++) + if (lf.isPlaceholder()) { - seq[i] = (Sequence) seqVector.elementAt(i); + has_placeholders = true; } - // This constructor matches sequence names to treenodes and sets up the tree layouts. - tree = new NJTree(seq, newtree); - // Now have to calculate longest name based on the leaves - Vector leaves = tree.findLeaves(tree.getTopNode(),new Vector()); - boolean has_placeholders = false; - 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(); + + 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 } + tree.reCount(tree.getTopNode()); + tree.findHeight(tree.getTopNode()); - public void textbox_actionPerformed(ActionEvent e) - { - CutAndPasteTransfer cap = new CutAndPasteTransfer(); + 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 + } - StringBuffer buffer = new StringBuffer(); + public NJTree getTree() + { + return tree; + } - if(type.equals("AV")) - buffer.append("Average distance tree using "); - else - buffer.append("Neighbour joining tree using "); + 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); + } - if(pwtype.equals("BL")) - buffer.append("BLOSUM62"); - else - buffer.append("PID"); + 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(); + } - Desktop.addInternalFrame(cap,buffer.toString(), 500, 100); - jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); - cap.setText( fout.print(false,true) ); + public void textbox_actionPerformed(ActionEvent e) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(); - } + StringBuffer buffer = new StringBuffer(); + if (type.equals("AV")) + { + buffer.append("Average distance tree using "); + } + else + { + buffer.append("Neighbour joining tree using "); + } - public void saveAsNewick_actionPerformed(ActionEvent e) + if (pwtype.equals("BL")) + { + buffer.append("BLOSUM62"); + } + else { + buffer.append("PID"); + } - JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. - getProperty("LAST_DIRECTORY")); + Desktop.addInternalFrame(cap, buffer.toString(), 500, 100); + + jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode()); + cap.setText(fout.print(false, true)); + } + + 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"); + 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{ + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + 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 ) ); + 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) { + catch (Exception ex) + { ex.printStackTrace(); } } @@ -186,7 +223,6 @@ public class TreePanel extends GTreePanel protected void printMenu_actionPerformed(ActionEvent e) { - //Putting in a thread avoids Swing painting problems treeCanvas.startPrinting(); } @@ -197,29 +233,33 @@ public class TreePanel extends GTreePanel repaint(); } - protected void fontSize_actionPerformed(ActionEvent e) { - if( treeCanvas==null ) - return; - - String size = fontSize.getText().substring( fontSize.getText().indexOf("-")+1); - - 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); - if(selection!=null) - { - fontSize.setText("Font Size - " + selection); - - int i = Integer.parseInt(selection.toString()); - treeCanvas.setFontSize(i); - } - scrollPane.setViewportView(treeCanvas); + if (treeCanvas == null) + { + return; + } + + String size = fontSize.getText().substring(fontSize.getText().indexOf("-") + + 1); + + 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); + if (selection != null) + { + fontSize.setText("Font Size - " + selection); + + int i = Integer.parseInt(selection.toString()); + treeCanvas.setFontSize(i); + } + + scrollPane.setViewportView(treeCanvas); } protected void distanceMenu_actionPerformed(ActionEvent e) @@ -233,37 +273,46 @@ public class TreePanel extends GTreePanel } protected void placeholdersMenu_actionPerformed(ActionEvent e) - { - treeCanvas.setMarkPlaceholders(placeholdersMenu.isSelected()); + { + treeCanvas.setMarkPlaceholders(placeholdersMenu.isSelected()); } protected void epsTree_actionPerformed(ActionEvent e) { - int width = treeCanvas.getWidth(), height=treeCanvas.getHeight(); + int width = treeCanvas.getWidth(); + int height = treeCanvas.getHeight(); + try { - jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(jalview.bin.Cache.getProperty( - "LAST_DIRECTORY"), - new String[]{"eps"}, - new String[]{"Encapsulated Postscript"}, - "Encapsulated Postscript"); + 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); + 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(); + pg.flush(); + pg.close(); } catch (Exception ex) { @@ -272,14 +321,18 @@ public class TreePanel extends GTreePanel } protected void pngTree_actionPerformed(ActionEvent e) - { - int width = treeCanvas.getWidth(), height = treeCanvas.getHeight(); + { + int width = treeCanvas.getWidth(); + int height = treeCanvas.getHeight(); + try { jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser( - jalview.bin.Cache.getProperty("LAST_DIRECTORY"), - new String[] {"png"}, - new String[] {"Portable network graphics"}, + jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] + {"png"}, + new String[] + {"Portable network graphics"}, "Portable network graphics"); chooser.setFileView(new jalview.io.JalviewFileView()); @@ -287,24 +340,29 @@ public class TreePanel extends GTreePanel 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()); - jalview.bin.Cache.setProperty("LAST_DIRECTORY",chooser.getSelectedFile().getParent()); FileOutputStream out = new FileOutputStream(chooser.getSelectedFile()); - BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + 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(); + 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 f0cf6c1..18382fb 100755 --- a/src/jalview/gui/UserDefinedColours.java +++ b/src/jalview/gui/UserDefinedColours.java @@ -1,39 +1,39 @@ /* -* 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.gui; -import jalview.jbgui.GUserDefinedColours; -import jalview.datamodel.*; -import jalview.io.*; -import javax.swing.*; +import java.io.*; +import java.util.*; + import java.awt.*; import java.awt.event.*; +import javax.swing.*; import javax.swing.event.*; -import jalview.schemes.*; -import java.io.*; -import java.util.*; +import jalview.datamodel.*; +import jalview.io.*; +import jalview.jbgui.*; +import jalview.schemes.*; -public class UserDefinedColours extends GUserDefinedColours implements ChangeListener +public class UserDefinedColours + extends GUserDefinedColours implements ChangeListener { - AlignmentPanel ap; SequenceGroup seqGroup; JButton selectedButton; @@ -41,55 +41,66 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis 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")) - frame.setSize(450,560); + 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); + } + + if (sg != null) + { + frame.setTitle(frame.getTitle() + " (" + sg.getName() + ")"); + } colorChooser.getSelectionModel().addChangeListener(this); this.ap = ap; seqGroup = sg; + if (seqGroup != null) + { + oldColourScheme = seqGroup.cs; + } + else + { + oldColourScheme = ap.av.getGlobalColourScheme(); + } - 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]); + 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) - selectedButton.setBackground( colorChooser.getColor() ); - } + public void stateChanged(ChangeEvent evt) + { + if (selectedButton != null) + { + selectedButton.setBackground(colorChooser.getColor()); + } + } public void colourButtonPressed(MouseEvent e) { - selectedButton = (JButton)e.getSource(); - colorChooser.setColor(selectedButton.getBackground()); + selectedButton = (JButton) e.getSource(); + colorChooser.setColor(selectedButton.getBackground()); } void makeButton(String label, String aa) @@ -97,15 +108,18 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis final JButton button = new JButton(); Color col = Color.white; - - try{ + try + { col = oldColourScheme.findColour(aa, -1); - }catch(Exception ex){} + } + catch (Exception ex) + { + } - button.setBackground( col ); - oldColours.addElement( col ); - button.setText( label ); - button.setForeground( col.darker().darker().darker() ); + 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() { @@ -118,167 +132,207 @@ public class UserDefinedColours extends GUserDefinedColours implements ChangeLis buttonPanel.add(button, null); } - protected void okButton_actionPerformed(ActionEvent e) { applyButton_actionPerformed(null); - try{ + + try + { frame.setClosed(true); - }catch(Exception ex){} + } + catch (Exception ex) + { + } } protected void applyButton_actionPerformed(ActionEvent e) { - Color [] newColours = new Color[24]; - for(int i=0; i<24; i++) + Color[] newColours = new Color[24]; + + for (int i = 0; i < 24; i++) { - JButton button = (JButton)buttonPanel.getComponent(i); - newColours[i] = button.getBackground(); + JButton button = (JButton) buttonPanel.getComponent(i); + newColours[i] = button.getBackground(); } UserColourScheme ucs = new UserColourScheme(newColours); ucs.setThreshold(0); - if(seqGroup!=null) + if (seqGroup != null) { seqGroup.cs = ucs; ap.repaint(); } else + { ap.alignFrame.changeColour(ucs); - + } } 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"); + 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) { File choice = chooser.getSelectedFile(); - jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice.getParent()); - jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice.getPath()); + 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]); } - } } public static UserColourScheme loadDefaultColours() { - if(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")!=null) - return loadDefaultColours(jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR")); + if (jalview.bin.Cache.getProperty("USER_DEFINED_COLOUR") != null) + { + return loadDefaultColours(jalview.bin.Cache.getProperty( + "USER_DEFINED_COLOUR")); + } else + { return null; + } } public static UserColourScheme loadDefaultColours(String file) { - UserColourScheme ucs = null; - Color cols[] = loadColours(file); - if(cols!=null) - { - ucs = new UserColourScheme(cols); - ucs.setThreshold(0); - } - return ucs; + UserColourScheme ucs = null; + Color[] cols = loadColours(file); + + if (cols != null) + { + ucs = new UserColourScheme(cols); + ucs.setThreshold(0); + } + + return ucs; } - static Color [] loadColours(String file) + static Color[] loadColours(String file) { - Color [] newColours=null; + Color[] newColours = null; + try { - InputStreamReader in = new InputStreamReader( - new FileInputStream(file), "UTF-8"); + InputStreamReader in = new InputStreamReader(new FileInputStream( + file), "UTF-8"); - jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours(); - ucs = (jalview.binding.JalviewUserColours)ucs.unmarshal(in); + jalview.binding.JalviewUserColours ucs = new jalview.binding. + JalviewUserColours(); + ucs = (jalview.binding.JalviewUserColours) ucs.unmarshal(in); newColours = new Color[ucs.getColourCount()]; - for (int i = 0; i < 24; i++) - newColours[i] = new Color(Integer.parseInt(ucs.getColour(i).getRGB(), 16)); + 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);} + { + System.out.println("Error loading UserColourFile " + file); + } return newColours; } 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"); + 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("Save colour scheme"); chooser.setToolTipText("Save"); + int value = chooser.showSaveDialog(this); + if (value == JalviewFileChooser.APPROVE_OPTION) { String choice = chooser.getSelectedFile().getPath(); jalview.bin.Cache.setProperty("USER_DEFINED_COLOUR", choice); - jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours(); - try{ + 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++) + 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); + 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();} + catch (Exception ex) + { + ex.printStackTrace(); + } } - } protected void cancelButton_actionPerformed(ActionEvent e) { + Color[] newColours = new Color[24]; - Color [] newColours = new Color[24]; - for(int i=0; i<24; i++) + for (int i = 0; i < 24; i++) { - newColours[i] = (Color)oldColours.elementAt(i); - buttonPanel.getComponent(i).setBackground(newColours[i]); + newColours[i] = (Color) oldColours.elementAt(i); + buttonPanel.getComponent(i).setBackground(newColours[i]); } - UserColourScheme ucs = new UserColourScheme( newColours ); + UserColourScheme ucs = new UserColourScheme(newColours); if (seqGroup != null) + { seqGroup.cs = ucs; + } else + { ap.av.setGlobalColourScheme(ucs); + } ap.repaint(); - try{ + try + { frame.setClosed(true); - }catch(Exception ex){} + } + catch (Exception ex) + { + } } - - } diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index 9e980c5..0a098e5 100755 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.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.gui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import jalview.jbgui.GWebserviceInfo; -public class WebserviceInfo extends GWebserviceInfo -{ +import jalview.jbgui.*; +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; @@ -36,17 +36,9 @@ public class WebserviceInfo extends GWebserviceInfo int currentStatus = STATE_QUEUING; Image image; int angle = 0; - - String title=""; + String title = ""; jalview.ws.WSClientI thisService; boolean serviceIsCancellable; - public jalview.ws.WSClientI getthisService() { - return thisService; - } - public void setthisService(jalview.ws.WSClientI newservice) { - thisService = newservice; - serviceIsCancellable = newservice.isCancellable(); - } public WebserviceInfo(String title, String info) { @@ -58,6 +50,17 @@ public class WebserviceInfo extends GWebserviceInfo 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(); @@ -66,20 +69,24 @@ public class WebserviceInfo extends GWebserviceInfo 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 { mt.waitForID(0); } catch (Exception ex) - {} - + { + } AnimatedPanel ap = new AnimatedPanel(); titlePanel.add(ap, BorderLayout.CENTER); + Thread thread = new Thread(ap); thread.start(); } @@ -90,97 +97,130 @@ public class WebserviceInfo extends GWebserviceInfo } public String getInfoText() - { return infoText.getText(); } + { + return infoText.getText(); + } public void setInfoText(String text) - { infoText.setText(text); } + { + infoText.setText(text); + } public void appendInfoText(String text) - { infoText.append(text); } + { + infoText.append(text); + } public String getProgressText() - { return progressText.getText(); } + { + return progressText.getText(); + } public void setProgressText(String text) - { progressText.setText(text); } + { + progressText.setText(text); + } public void appendProgressText(String text) - { progressText.append(text); } + { + progressText.append(text); + } protected void cancel_actionPerformed(ActionEvent e) { if (!serviceIsCancellable) + { JOptionPane.showInternalMessageDialog(Desktop.desktop, - "This job cannot be cancelled." , - "Cancel job" - ,JOptionPane.WARNING_MESSAGE); + "This job cannot be cancelled.", + "Cancel job", + JOptionPane.WARNING_MESSAGE); + } else + { thisService.cancelJob(); + } } - - class AnimatedPanel extends JPanel implements Runnable + class AnimatedPanel + extends JPanel implements Runnable { - long startTime=0; + long startTime = 0; + public void run() { startTime = System.currentTimeMillis(); - while(currentStatus -1) - { - idsFound=true; - break; - } - - int abracket = line.indexOf(">"); - - if (abracket > -1) - { - - if(line.indexOf(" ")>-1)// - { - ///Colur it be this format? - //>54402046 0 1 137 137: - // or this?? - // 1 >L1H14 30539 343 - try{ - ids.addElement(line.substring(abracket + 1, - line.indexOf(" ", abracket + 1))); - - - // remove p Value - line = line.substring(abracket + 1); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - int value = Integer.parseInt(line.substring(0, line.indexOf(" "))); - starts.addElement(value+""); - line = line.substring(line.indexOf(" ") + 1); - line = line.trim(); - value = Integer.parseInt(line.substring(0, line.indexOf(" "))); - ends.addElement(value+""); - - }catch(Exception ex) - { - System.err.println("Error during blockfile read."); - ex.printStackTrace(); - starts.addElement("0"); - ends.addElement("0"); - } + public BLCFile() { + } - } - else - { - 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)); - } - } - }while(!idsFound); - - int starCol = line.indexOf("*"); - seqstrings = new StringBuffer[ids.size()]; - for(int i=0; ii+starCol) - seqstrings[i].append(line.charAt(i + starCol)); - } + public void initData() { + super.initData(); + titles = new Vector(); } - for(int i=0; i -1) { + idsFound = true; + + break; + } + + int abracket = line.indexOf(">"); + + if (abracket > -1) { + if (line.indexOf(" ") > -1) // + { + ///Colur it be this format? + //>54402046 0 1 137 137: + // or this?? + // 1 >L1H14 30539 343 + try { + ids.addElement(line.substring(abracket + 1, + line.indexOf(" ", abracket + 1))); + + // remove p Value + line = line.substring(abracket + 1); + line = line.substring(line.indexOf(" ") + 1); + line = line.trim(); + line = line.substring(line.indexOf(" ") + 1); + line = line.trim(); + + int value = Integer.parseInt(line.substring(0, + line.indexOf(" "))); + starts.addElement(value + ""); + line = line.substring(line.indexOf(" ") + 1); + line = line.trim(); + value = Integer.parseInt(line.substring(0, + line.indexOf(" "))); + ends.addElement(value + ""); + } catch (Exception ex) { + System.err.println("Error during blockfile read."); + ex.printStackTrace(); + starts.addElement("0"); + ends.addElement("0"); + } + } else { + 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)); + } + } + } while (!idsFound); + + int starCol = line.indexOf("*"); + seqstrings = new StringBuffer[ids.size()]; + + 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)) { + seqstrings[i].append(line.charAt(i + starCol)); + } + } + } + + 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) { + ex.printStackTrace(); + } } - }catch(Exception ex){ex.printStackTrace();} - } - - public String print() { - return print(getSeqsAsArray()); - } - public static String print(SequenceI[] s) { - StringBuffer out = new StringBuffer(); - - int i=0; - int max = -1; - 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) { max = s[i].getSequence().length();} - i++; + public String print() { + return print(getSeqsAsArray()); } - out.append("* iteration 1\n"); - for (int j = 0; j < max; j++) { - i=0; - while (i < s.length && s[i] != null) { - if(s[i].getSequence().length()>j ) - out.append(s[i].getSequence().substring(j,j+1)); - else - out.append("-"); - i++; + public static String print(SequenceI[] s) { + StringBuffer out = new StringBuffer(); + + int i = 0; + int max = -1; + + 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) { + max = s[i].getSequence().length(); + } + + i++; } - out.append("\n"); - } - out.append("*\n"); - return out.toString(); - } + out.append("* iteration 1\n"); + + for (int j = 0; j < max; j++) { + i = 0; + + while ((i < s.length) && (s[i] != null)) { + if (s[i].getSequence().length() > j) { + out.append(s[i].getSequence().substring(j, j + 1)); + } else { + out.append("-"); + } + + i++; + } + + out.append("\n"); + } + + out.append("*\n"); + + return out.toString(); + } } diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 9b56526..b0d46b2 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -16,183 +16,200 @@ * 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.*; + public class ClustalFile extends AlignFile { + Vector ids; - Vector ids; - - public ClustalFile() - {} - - public ClustalFile(String inStr) { - super(inStr); - } - - - public void initData() { - super.initData(); - ids = new Vector(); - } - - public ClustalFile(String inFile, String type) throws IOException { - super(inFile,type); - } - - 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()); - } - } - } - } - } - } catch (IOException e) { - System.err.println("Exception parsing clustal file " + e); - e.printStackTrace(); + public ClustalFile() { } - 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)); + public ClustalFile(String inStr) { + super(inStr); + } + + public ClustalFile(String inFile, String type) throws IOException { + super(inFile, type); + } - } - Sequence newSeq = new Sequence(ids.elementAt(i).toString(), - seqhash.get(headers.elementAt(i).toString()).toString(),start,end); + public void initData() { + super.initData(); + ids = new Vector(); + } - seqs.addElement(newSeq); + 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()); + } + } + } + } + } + } + } catch (IOException e) { + System.err.println("Exception parsing clustal file " + e); + e.printStackTrace(); + } - } else { - System.err.println("Clustal File Reader: Can't find sequence for " + headers.elementAt(i)); + 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)); + } + } } - } } - } + public String print() { + return print(getSeqsAsArray()); + } + + public static String print(SequenceI[] s) { + StringBuffer out = new StringBuffer("CLUSTAL\n\n"); - public String print() { - return print(getSeqsAsArray()); - } - public static String print(SequenceI[] s) { + int max = 0; + int maxid = 0; - StringBuffer out = new StringBuffer("CLUSTAL\n\n"); + int i = 0; - int max = 0; - int maxid = 0; + while ((i < s.length) && (s[i] != null)) { + String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + + s[i].getEnd(); - int i = 0; + if (s[i].getSequence().length() > max) { + max = s[i].getSequence().length(); + } - while (i < s.length && s[i] != null) { - String tmp = s[i].getName() + "/" + s[i].getStart() + "-" + s[i].getEnd(); + if (tmp.length() > maxid) { + maxid = tmp.length(); + } - if (s[i].getSequence().length() > max) { - max = s[i].getSequence().length(); - } - if (tmp.length() > maxid) { - maxid = tmp.length(); - } - i++; - } + i++; + } - if (maxid < 15) { - maxid = 15; - } - maxid++; - int len = 60; - int nochunks = max / len + 1; - - for (i = 0; i < nochunks; i++) { - 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()) + " "); - int start = i*len; - int end = start + len; - - 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)); + if (maxid < 15) { + maxid = 15; } - out.append("\n"); - j++; - } - out.append("\n"); - } + maxid++; + + int len = 60; + int nochunks = (max / len) + 1; - return out.toString(); - } + for (i = 0; i < nochunks; i++) { + 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()) + " "); + int start = i * len; + int end = start + len; + + 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)); + } + } + + 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 3c6e5f9..5b21bfe 100755 --- a/src/jalview/io/EBIFetchClient.java +++ b/src/jalview/io/EBIFetchClient.java @@ -16,166 +16,160 @@ * 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 org.apache.axis.client.*; - -import java.io.*; - -import javax.activation.DataHandler; import org.apache.axis.AxisFault; +import org.apache.axis.client.*; import org.apache.axis.encoding.XMLType; -import javax.xml.rpc.ParameterMode; -import javax.xml.namespace.QName; -import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory; import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory; +import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory; +import java.io.*; -public class EBIFetchClient -{ - Call call; - String format = "default"; - String style = "raw"; - - 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){} - } - - - 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){return null;} - } +import javax.activation.DataHandler; - public String [] getSupportedFormats() - { - try{ - call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats")); - call.setReturnType(XMLType.SOAP_ARRAY); - return (String[]) call.invoke(new Object[] {}); +import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; - }catch(Exception ex){ return null; } - } - public String [] getSupportedStyles() - { - try{ - call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles")); - call.setReturnType(XMLType.SOAP_ARRAY); - return (String[]) call.invoke(new Object[] {}); +public class EBIFetchClient { + Call call; + String format = "default"; + String style = "raw"; - }catch(Exception ex){return null;} + 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) { + } } - 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{ - 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) - format = f; - - if (s != null) - style = s; - - return (String[]) call.invoke(new Object[] {ids, format, style}); - - }catch(Exception ex){return null;} + 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) { + return null; + } } - public String fetchDataFile(String arg, String f, String s) - { - - if (f != null) - format = f; + public String[] getSupportedFormats() { + try { + call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats")); + call.setReturnType(XMLType.SOAP_ARRAY); - if (s != null) - style = s; - - - call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile")); - call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); - call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); - call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); - - QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler"); - call.registerTypeMapping(javax.activation.DataSource.class, - qnameAttachment, - JAFDataHandlerSerializerFactory.class, - JAFDataHandlerDeserializerFactory.class); + return (String[]) call.invoke(new Object[] { }); + } catch (Exception ex) { + return null; + } + } - call.setReturnType(qnameAttachment); + public String[] getSupportedStyles() { + try { + call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles")); + call.setReturnType(XMLType.SOAP_ARRAY); - try{ - Object ret = call.invoke(new Object[] - {arg, format, style}); + return (String[]) call.invoke(new Object[] { }); + } catch (Exception ex) { + return null; + } + } - if (null == ret) - { - System.err.println("Received null "); - throw new AxisFault("", "Received null", null, null); + 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 { + 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) { + format = f; + } + + if (s != null) { + style = s; + } + + return (String[]) call.invoke(new Object[] { ids, format, style }); + } catch (Exception ex) { + return null; } - if (ret instanceof String) - { - System.err.println("Received problem response from server: " + ret); - throw new AxisFault("", (String) ret, null, null); + } + + public String fetchDataFile(String arg, String f, String s) { + if (f != null) { + format = f; } - if (! (ret instanceof DataHandler)) - { - //The wrong type of object that what was expected. - System.err.println("Received problem response from server:" + - ret.getClass().getName()); - throw new AxisFault("", "Received problem response from server:" + - ret.getClass().getName(), null, null); + if (s != null) { + style = s; } - //Still here, so far so good. - DataHandler rdh = (DataHandler) ret; - //From here we'll just treat the data resource as file. - String receivedfileName = rdh.getName(); //Get the filename. + call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile")); + call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN); + call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN); - if (receivedfileName == null) - { - System.err.println("Could not get the file name."); - throw new AxisFault("", "Could not get the file name.", null, null); + QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler"); + call.registerTypeMapping(javax.activation.DataSource.class, + qnameAttachment, JAFDataHandlerSerializerFactory.class, + JAFDataHandlerDeserializerFactory.class); + + call.setReturnType(qnameAttachment); + + try { + Object ret = call.invoke(new Object[] { arg, format, style }); + + if (null == ret) { + System.err.println("Received null "); + throw new AxisFault("", "Received null", null, null); + } + + if (ret instanceof String) { + System.err.println("Received problem response from server: " + + ret); + throw new AxisFault("", (String) ret, null, null); + } + + if (!(ret instanceof DataHandler)) { + //The wrong type of object that what was expected. + System.err.println("Received problem response from server:" + + ret.getClass().getName()); + throw new AxisFault("", + "Received problem response from server:" + + ret.getClass().getName(), null, null); + } + + //Still here, so far so good. + DataHandler rdh = (DataHandler) ret; + + //From here we'll just treat the data resource as file. + String receivedfileName = rdh.getName(); //Get the filename. + + 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")) { + return receivedfileName; + } else if (arg.equalsIgnoreCase("interpro")) { + return receivedfileName; + } else { + System.err.println(receivedfileName); + } + } catch (Exception ex) { + ex.printStackTrace(); } - if (arg.equalsIgnoreCase("medline")) - { - return receivedfileName; - } - else if (arg.equalsIgnoreCase("interpro")) - { - return receivedfileName; - } - else - System.err.println(receivedfileName); - }catch(Exception ex) - { - ex.printStackTrace(); - } - - return "ERROR"; - } - + return "ERROR"; + } } diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index 7910340..7e7e06b 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -16,160 +16,167 @@ * 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.analysis.*; +import jalview.datamodel.*; + import java.io.*; + import java.util.*; + public class FastaFile extends AlignFile { + public FastaFile() { + } - public FastaFile() - {} - - public FastaFile(String inStr) { - super(inStr); - } - - public FastaFile(String inFile, String type) throws IOException { - super(inFile,type); - } - - public void parse() throws IOException - { - - String id = ""; - StringBuffer seq = new StringBuffer(); - int count = 0; - boolean flag = false; - - int sstart = 0; - int send = 0; - - String line; - - while ((line = nextLine()) != null) { - - if (line.length() > 0) { - - // Do we have an id line? - - if (line.substring(0,1).equals(">")) { - - if (count != 0) { - if (sstart != 0) { - seqs.addElement(new Sequence(id,seq.toString().toUpperCase(),sstart,send)); - } else { - seqs.addElement(new Sequence(id,seq.toString().toUpperCase(),1,seq.length())); - } - } - - count++; - - StringTokenizer str = new StringTokenizer(line," "); - - id = str.nextToken(); - id = id.substring(1); - com.stevesoft.pat.Regex dbId = new com.stevesoft.pat.Regex("[A-Za-z-]+/[A-Za-z-]+\\|(\\w+)\\|(.+)"); - if (dbId.search(id)) - { - String dbid = dbId.stringMatched(1); - String idname = dbId.stringMatched(2); - if (idname.length()>0 && idname.indexOf("_") > -1) - { - id = idname; // just use friendly name // JBPNote: we may lose uniprot standardised ID here. - } - else - { - id = dbid; // use dbid to ensure sensible queries - } - - } - if (id.indexOf("/") > 0 ) { - - StringTokenizer st = new StringTokenizer(id,"/"); - if (st.countTokens() == 2) { - id = st.nextToken(); - String tmp = st.nextToken(); - - st = new StringTokenizer(tmp,"-"); - - if (st.countTokens() == 2) { - sstart = Integer.valueOf(st.nextToken()).intValue(); - send = Integer.valueOf(st.nextToken()).intValue(); - } - } - } - - seq = new StringBuffer(); - - } else { - seq = seq.append(line); - } - } - } - if (count > 0) { - - if(!isValidProteinSequence(seq.toString().toUpperCase())) - throw new IOException("Invalid protein sequence"); - - if (sstart != 0) { - seqs.addElement(new Sequence(id,seq.toString().toUpperCase(),sstart,send)); - } else { - seqs.addElement(new Sequence(id,seq.toString().toUpperCase(),1,seq.length())); - } - } - - } - - public static String print(SequenceI[] s) { - return print(s,72); - } - public static String print(SequenceI[] s, int len) { - return print(s,len,true); - } - - public static String print(SequenceI[] s, int len,boolean gaps) { - return print(s,len,gaps,true); - } - - public static String print(SequenceI[] s, int len,boolean gaps, boolean displayId) { - 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()); - } - // used to always put this here: + "/" + s[i].getStart() + "-" + s[i].getEnd() + - out.append(">" + ((displayId) ? s[i].getDisplayId() : s[i].getName())+"\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"); + public FastaFile(String inStr) { + super(inStr); + } + + public FastaFile(String inFile, String type) throws IOException { + super(inFile, type); + } + + public void parse() throws IOException { + String id = ""; + StringBuffer seq = new StringBuffer(); + int count = 0; + boolean flag = false; + + int sstart = 0; + int send = 0; + + String line; + + while ((line = nextLine()) != null) { + if (line.length() > 0) { + // Do we have an id line? + if (line.substring(0, 1).equals(">")) { + if (count != 0) { + if (sstart != 0) { + seqs.addElement(new Sequence(id, + seq.toString().toUpperCase(), sstart, send)); + } else { + seqs.addElement(new Sequence(id, + seq.toString().toUpperCase(), 1, + seq.length())); + } + } + + count++; + + StringTokenizer str = new StringTokenizer(line, " "); + + id = str.nextToken(); + id = id.substring(1); + + com.stevesoft.pat.Regex dbId = new com.stevesoft.pat.Regex( + "[A-Za-z-]+/[A-Za-z-]+\\|(\\w+)\\|(.+)"); + + if (dbId.search(id)) { + String dbid = dbId.stringMatched(1); + String idname = dbId.stringMatched(2); + + if ((idname.length() > 0) && + (idname.indexOf("_") > -1)) { + id = idname; // just use friendly name // JBPNote: we may lose uniprot standardised ID here. + } else { + id = dbid; // use dbid to ensure sensible queries + } + } + + if (id.indexOf("/") > 0) { + StringTokenizer st = new StringTokenizer(id, "/"); + + if (st.countTokens() == 2) { + id = st.nextToken(); + + String tmp = st.nextToken(); + + st = new StringTokenizer(tmp, "-"); + + if (st.countTokens() == 2) { + sstart = Integer.valueOf(st.nextToken()) + .intValue(); + send = Integer.valueOf(st.nextToken()).intValue(); + } + } + } + + seq = new StringBuffer(); + } else { + seq = seq.append(line); + } + } + } + + if (count > 0) { + if (!isValidProteinSequence(seq.toString().toUpperCase())) { + throw new IOException("Invalid protein sequence"); + } + + if (sstart != 0) { + seqs.addElement(new Sequence(id, seq.toString().toUpperCase(), + sstart, send)); + } else { + seqs.addElement(new Sequence(id, seq.toString().toUpperCase(), + 1, seq.length())); + } } - } - i++; } - return out.toString(); - } - public String print() { - return print(getSeqsAsArray()); - } -} + public static String print(SequenceI[] s) { + return print(s, 72); + } + public static String print(SequenceI[] s, int len) { + return print(s, len, true); + } + + public static String print(SequenceI[] s, int len, boolean gaps) { + return print(s, len, gaps, true); + } + + public static String print(SequenceI[] s, int len, boolean gaps, + boolean displayId) { + 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()); + } + + // used to always put this here: + "/" + s[i].getStart() + "-" + s[i].getEnd() + + out.append(">" + + ((displayId) ? s[i].getDisplayId() : s[i].getName()) + "\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++; + } + + return out.toString(); + } + + public String print() { + return print(getSeqsAsArray()); + } +} diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index ea86ae0..0c46a17 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -16,50 +16,48 @@ * 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; +import java.net.*; - public FileParse() {} - public FileParse(String fileStr, String type) throws MalformedURLException, IOException - { +public class FileParse { + public File inFile; + public int fileSize; + public int noLines; + protected String type; + protected BufferedReader dataIn; - this.type = type; + public FileParse() { + } - if (type.equals("File")) { - this.inFile = new File(fileStr); - this.fileSize = (int)inFile.length(); + 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)); + } + } - dataIn = new BufferedReader(new FileReader( fileStr )); + public String nextLine() throws IOException { + String next = dataIn.readLine(); - } 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(); - if (next != null) { - noLines++; + return next; } - return next; - } - } diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 0382cee..e59c191 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -16,90 +16,90 @@ * 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 java.util.Vector; -public class FormatAdapter -{ - - public static Vector formats = new Vector(); - static{ - formats.addElement("FASTA"); - formats.addElement("MSF"); - formats.addElement("PileUp"); - formats.addElement("CLUSTAL"); - formats.addElement("BLC"); - formats.addElement("PIR"); - formats.addElement("PFAM"); - } - - public static SequenceI[] readFile(String inFile, String type, String format) - { - - try - { - AlignFile afile = null; - if (format.equals("FASTA")) - afile = new FastaFile(inFile, type); - else if (format.equals("MSF")) - afile = new MSFfile(inFile, type); - else if (format.equals("PileUp")) - afile = new PileUpfile(inFile, type); - else if (format.equals("CLUSTAL")) - afile = new ClustalFile(inFile, type); - else if (format.equals("BLC")) - afile = new BLCFile(inFile, type); - else if (format.equals("PIR")) - afile = new PIRFile(inFile, type); - else if (format.equals("PFAM")) - afile = new PfamFile(inFile, type); - - return afile.getSeqsAsArray(); - } - catch (Exception e) { - System.err.println("Failed to read alignment using the '"+format+"' reader."); - e.printStackTrace(); - } - return null; - } - - - 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 - { - AlignFile afile = null; - if (format.equals("FASTA")) - afile = new FastaFile(); - else if (format.equals("MSF")) - afile = new MSFfile(); - else if (format.equals("PileUp")) - afile = new PileUpfile(); - else if (format.equals("CLUSTAL")) - afile = new ClustalFile(); - else if (format.equals("BLC")) - afile = new BLCFile(); - else if (format.equals("PIR")) - afile = new PIRFile(); - else if (format.equals("PFAM")) - afile = new PfamFile(); - - afile.setSeqs(s); - return afile.print(); + +public class FormatAdapter { + public static Vector formats = new Vector(); + + static { + formats.addElement("FASTA"); + formats.addElement("MSF"); + formats.addElement("PileUp"); + formats.addElement("CLUSTAL"); + formats.addElement("BLC"); + formats.addElement("PIR"); + formats.addElement("PFAM"); } - catch (Exception e) { - System.err.println("Failed to write alignment as a '"+format+"' file\n"); - e.printStackTrace(); + + public static SequenceI[] readFile(String inFile, String type, String format) { + try { + AlignFile afile = null; + + if (format.equals("FASTA")) { + afile = new FastaFile(inFile, type); + } else if (format.equals("MSF")) { + afile = new MSFfile(inFile, type); + } else if (format.equals("PileUp")) { + afile = new PileUpfile(inFile, type); + } else if (format.equals("CLUSTAL")) { + afile = new ClustalFile(inFile, type); + } else if (format.equals("BLC")) { + afile = new BLCFile(inFile, type); + } else if (format.equals("PIR")) { + afile = new PIRFile(inFile, type); + } else if (format.equals("PFAM")) { + afile = new PfamFile(inFile, type); + } + + return afile.getSeqsAsArray(); + } catch (Exception e) { + System.err.println("Failed to read alignment using the '" + format + + "' reader."); + e.printStackTrace(); + } + + return null; } - return null; - } + 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 { + AlignFile afile = null; + + if (format.equals("FASTA")) { + afile = new FastaFile(); + } else if (format.equals("MSF")) { + afile = new MSFfile(); + } else if (format.equals("PileUp")) { + afile = new PileUpfile(); + } else if (format.equals("CLUSTAL")) { + afile = new ClustalFile(); + } else if (format.equals("BLC")) { + afile = new BLCFile(); + } else if (format.equals("PIR")) { + afile = new PIRFile(); + } else if (format.equals("PFAM")) { + afile = new PfamFile(); + } + + afile.setSeqs(s); + + return afile.print(); + } catch (Exception e) { + System.err.println("Failed to write alignment as a '" + format + + "' file\n"); + e.printStackTrace(); + } + + return null; + } } diff --git a/src/jalview/io/HTMLOutput.java b/src/jalview/io/HTMLOutput.java index 290dee7..54b9595 100755 --- a/src/jalview/io/HTMLOutput.java +++ b/src/jalview/io/HTMLOutput.java @@ -16,237 +16,252 @@ * 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.gui.*; import jalview.datamodel.*; + +import jalview.gui.*; + import jalview.schemes.*; + import java.awt.*; -import javax.swing.*; + import java.io.*; -import java.util.*; +import java.util.*; -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(""); - - - if(av.getWrapAlignment()) - drawWrappedAlignment(out); - else - drawUnwrappedAlignment(out); - - out.println("\n\n"); - out.close(); - jalview.util.BrowserLauncher.openURL( "file:///"+choice ); - } - catch(Exception ex){ex.printStackTrace();} - } - } +import javax.swing.*; - void drawUnwrappedAlignment(PrintWriter out) - { - out.println("
\n"); - out.println("\n"); +public class HTMLOutput { + AlignViewport av; + SequenceRenderer sr; + Color color; + public HTMLOutput(AlignViewport av) { + this.av = av; + sr = new SequenceRenderer(av); - ////////////// - SequenceGroup [] groups; - SequenceI seq; - ColourSchemeI cs = null; - AlignmentI alignment = av.getAlignment(); - String r,g,b; + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty( + "LAST_DIRECTORY"), new String[] { "html" }, + new String[] { "HTML files" }, "HTML files"); - // draws the top row, the measure rule - out.println(""); - int i=0; - for(i=10; i"+i+"
|
"); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Save as HTML"); + chooser.setToolTipText("Save"); - out.println(""); - out.println(""); + int value = chooser.showSaveDialog(null); - for (i = 0; i < alignment.getHeight(); i++) - { - seq = alignment.getSequenceAt(i); - groups = alignment.findAllGroups( seq ); - if(av.getShowFullId()) - out.println(""); - else - out.println(""); + 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(""); - color = sr.getResidueBoxColour(cs, seq, res); + if (av.getWrapAlignment()) { + drawWrappedAlignment(out); + } else { + drawUnwrappedAlignment(out); + } - if(color.getRGB()<-1) - { - out.println(""); + out.println("\n\n"); + out.close(); + jalview.util.BrowserLauncher.openURL("file:///" + choice); + } catch (Exception ex) { + ex.printStackTrace(); + } } - else - out.println(""); - - } - - out.println(""); } - ////////////// - out.println("
"+i+"
|
"+seq.getDisplayId()+"  
"+seq.getName()+"  "+seq.getCharAt(res)+""+seq.getCharAt(res)+"
"); - 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,g,b; - - out.println(""); + } else { + out.println(""); + } + } + + out.println(""); + } + if (endRes < al.getWidth()) { + out.println(""); + } + } + out.println("
\n"); - out.println("\n"); - - for(int startRes=0; startResal.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++) - { + + void drawUnwrappedAlignment(PrintWriter out) { + out.println("
 " + i + "
|
" + i + - // "
|
"+seq.getDisplayId()+"  "+seq.getName()+"  
\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(""); + + 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; - } - } + + 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); - if(color.getRGB()<-1) - { - r = Integer.toHexString(color.getRed()); - if(r.length()<2) - r = "0"+r; - g = Integer.toHexString(color.getGreen()); - if(g.length()<2) - g = "0"+g; - b = Integer.toHexString(color.getBlue()); - if(b.length()<2) - b = "0"+b; - out.println(""); + if (color.getRGB() < -1) { + out.println(""); + } else { + out.println(""); + } + } + + out.println(""); + } + + ////////////// + out.println("
" + i + "
|
" + i + + "
|
" + seq.getDisplayId() + + "  
" + seq.getName() + + "  "+seq.getCharAt(res)+"" + + seq.getCharAt(res) + "" + seq.getCharAt(res) + "
"); + 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(""); } - 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; - out.println(""); + break; + } + } - } - if(endRes"); + color = sr.getResidueBoxColour(cs, seq, res); + if (color.getRGB() < -1) { + r = Integer.toHexString(color.getRed()); + if (r.length() < 2) { + r = "0" + r; + } - } + g = Integer.toHexString(color.getGreen()); - out.println("
 " + i + "
|
" + i + + // "
|
" + seq.getDisplayId() + + "  " + seq.getName() + + "  "+seq.getCharAt(res)+"
"); - out.println("
"); + if (g.length() < 2) { + g = "0" + g; + } + b = Integer.toHexString(color.getBlue()); + if (b.length() < 2) { + b = "0" + b; + } - } + out.println("
" + + seq.getCharAt(res) + "" + seq.getCharAt(res) + "
"); + out.println(""); + } } diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index f1cf1e0..2442b4b 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -16,83 +16,84 @@ * 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 IdentifyFile -{ - public static String Identify(String file, String protocol) - { - String reply = "PFAM"; - try{ - - BufferedReader reader = null; - - if(protocol.equals("File")) - reader = new BufferedReader(new FileReader(file)); - - 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")) - reader = new BufferedReader( new StringReader(file) ); - - - String data; - while( (data=reader.readLine())!=null) - { - data = data.toUpperCase(); - if(data.indexOf("#")==0 || data.length()<1) - continue; - - if(data.indexOf("PILEUP")>-1) - { - reply = "PileUp"; - break; - } - if((data.indexOf("//")==0) - || ((data.indexOf("!!")>-1) - && (data.indexOf("!!")-1) - { - reply = "CLUSTAL"; - break; - } - else if(data.indexOf(">P1;")>-1 || data.indexOf(">DL;")>-1) - { - reply = "PIR"; - break; - } - else if(data.indexOf(">")>-1) - { - // could be BLC file, read next line to confirm - data = reader.readLine(); - if(data.indexOf(">")>-1) - reply = "BLC"; - else - reply = "FASTA"; - - break; - } - } - reader.close(); - } - catch(Exception ex){ - System.err.println("File Identification failed!\n"+ex);} - return reply; - } +public class IdentifyFile { + public static String Identify(String file, String protocol) { + String reply = "PFAM"; + + try { + BufferedReader reader = null; + + if (protocol.equals("File")) { + reader = new BufferedReader(new FileReader(file)); + } + 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")) { + reader = new BufferedReader(new StringReader(file)); + } + + String data; + while ((data = reader.readLine()) != null) { + data = data.toUpperCase(); + if ((data.indexOf("#") == 0) || (data.length() < 1)) { + continue; + } + + if (data.indexOf("PILEUP") > -1) { + reply = "PileUp"; + + break; + } + + if ((data.indexOf("//") == 0) || + ((data.indexOf("!!") > -1) && + (data.indexOf("!!") < data.indexOf( + "_MULTIPLE_ALIGNMENT ")))) { + reply = "MSF"; + + break; + } else if (data.indexOf("CLUSTAL") > -1) { + reply = "CLUSTAL"; + + break; + } else if ((data.indexOf(">P1;") > -1) || + (data.indexOf(">DL;") > -1)) { + reply = "PIR"; + + break; + } else if (data.indexOf(">") > -1) { + // could be BLC file, read next line to confirm + data = reader.readLine(); + + if (data.indexOf(">") > -1) { + reply = "BLC"; + } else { + reply = "FASTA"; + } + + break; + } + } + + reader.close(); + } catch (Exception ex) { + System.err.println("File Identification failed!\n" + ex); + } + + return reply; + } } diff --git a/src/jalview/io/JPredFile.java b/src/jalview/io/JPredFile.java index 38addf7..12be9de 100755 --- a/src/jalview/io/JPredFile.java +++ b/src/jalview/io/JPredFile.java @@ -15,299 +15,286 @@ * 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 -*/ - +*/ + /** * PredFile.java * JalviewX / Vamsas Project * JPred.seq.concise reader - */ - -package jalview.io; - -import jalview.datamodel.*; -import jalview.util.*; - -import java.io.*; -import java.util.*; - -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 void setQuerySeqPosition(int QuerySeqPosition) - { - this.QuerySeqPosition = QuerySeqPosition; - } - - public int getQuerySeqPosition() - { - return QuerySeqPosition; - } - public Hashtable getScores() { - return Scores; - } - public Hashtable getSymscores() { - return Symscores; - } - - public JPredFile(String inStr) - { - super(inStr); - } - - public void initData() - { - - super.initData(); - Scores = new Hashtable(); - ids = null; - conf = null; - } - - public JPredFile(String inFile, String type) - throws IOException - { - - super(inFile, type); - } + */ +package jalview.io; + +import jalview.datamodel.*; + +import jalview.util.*; + +import java.io.*; + +import java.util.*; + + +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) { + super(inStr); + } + + public JPredFile(String inFile, String type) throws IOException { + super(inFile, type); + } + + public void setQuerySeqPosition(int QuerySeqPosition) { + this.QuerySeqPosition = QuerySeqPosition; + } + + public int getQuerySeqPosition() { + return QuerySeqPosition; + } + + public Hashtable getScores() { + return Scores; + } + + public Hashtable getSymscores() { + return Symscores; + } + + public void initData() { + super.initData(); + Scores = new Hashtable(); + ids = null; + conf = null; + } + + /** + * parse a JPred concise file into a sequence-alignment like object. + */ + public void parse() throws IOException { + // JBPNote log.System.out.println("all read in "); + String line; + QuerySeqPosition = -1; + noSeqs = 0; + + Vector seq_entries = new Vector(); + Vector ids = new Vector(); + Hashtable Symscores = new Hashtable(); + + while ((line = nextLine()) != null) { + // Concise format allows no comments or non comma-formatted data + StringTokenizer str = new StringTokenizer(line, ":"); + String id = ""; + + if (!str.hasMoreTokens()) { + continue; + } + + id = str.nextToken(); + + String seqsym = str.nextToken(); + StringTokenizer symbols = new StringTokenizer(seqsym, ","); + + // decide if we have more than just alphanumeric symbols + int numSymbols = symbols.countTokens(); + + if (numSymbols == 0) { + continue; + } + + if (seqsym.length() != (2 * numSymbols)) { + // Set of scalars for some property + if (Scores.containsKey(id)) { + int i = 1; + + while (Scores.containsKey(id + "_" + i)) { + i++; + } + + id = id + "_" + i; + } + + Vector scores = new Vector(); + + // Typecheck from first entry + int i = 0; + String ascore = "dead"; + + try { + // store elements as floats... + while (symbols.hasMoreTokens()) { + ascore = symbols.nextToken(); + + Float score = new Float(ascore); + scores.addElement((Object) score); + } + + Scores.put(id, scores); + } catch (Exception e) { + // or just keep them as strings + i = scores.size(); + + for (int j = 0; j < i; j++) { + scores.set(j, + (Object) ((Float) scores.get(j)).toString()); + } + + scores.addElement((Object) ascore); + + while (symbols.hasMoreTokens()) { + ascore = symbols.nextToken(); + scores.addElement((Object) ascore); + } + + Scores.put(id, scores); + } + } 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++) { + conf.set(i, (Object) symbols.nextToken()); + } + } else { + // Sequence or a prediction string (rendered as sequence) + StringBuffer newseq = new StringBuffer(); + + for (int i = 0; i < numSymbols; i++) { + newseq.append(symbols.nextToken()); + } + + if (id.indexOf(";") > -1) { + seq_entries.addElement(newseq); + + int i = 1; + String name = id.substring(id.indexOf(";") + 1); + + while (ids.lastIndexOf(name) > -1) { + name = id.substring(id.indexOf(";") + 1) + "_" + 1; + } + + ids.addElement(name); + + noSeqs++; + } else { + if (id.equals("JNETPRED")) { + id = "Predicted Secondary Structure"; + } + + seq_entries.addElement(newseq.toString()); + ids.addElement(id); + Symscores.put((Object) id, + (Object) new Integer(ids.size() - 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++) { + // 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())) { + throw new IOException( + "JPredConcise: Not a valid protein sequence - (" + + ids.elementAt(i).toString() + ")"); + } + + 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 = seqs.size(); + } + + seqs.addElement(newSeq); + } + } + + /** + * print + * + * @return String + */ + public String print() { + return "Not Supported"; + } + + public static void main(String[] args) { + try { + JPredFile blc = new JPredFile(args[0], "File"); + + 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) { + System.err.println("Exception " + e); + e.printStackTrace(); + } + } +} + + +/* + StringBuffer out = new StringBuffer(); + + out.append("START PRED\n"); + for (int i = 0; i < s[0].sequence.length(); i++) + { + out.append(s[0].sequence.substring(i, i + 1) + " "); + out.append(s[1].sequence.substring(i, i + 1) + " "); + out.append(s[1].score[0].elementAt(i) + " "); + out.append(s[1].score[1].elementAt(i) + " "); + out.append(s[1].score[2].elementAt(i) + " "); + out.append(s[1].score[3].elementAt(i) + " "); + + out.append("\n"); + } + out.append("END PRED\n"); + return out.toString(); + } - /** - * parse a JPred concise file into a sequence-alignment like object. - */ - public void parse() - throws IOException + public static void main(String[] args) + { + try { - // JBPNote log.System.out.println("all read in "); - String line; - QuerySeqPosition = -1; - noSeqs = 0; - Vector seq_entries = new Vector(); - Vector ids = new Vector(); - Hashtable Symscores = new Hashtable(); - while ( (line = nextLine()) != null) + BLCFile blc = new BLCFile(args[0], "File"); + DrawableSequence[] s = new DrawableSequence[blc.seqs.size()]; + for (int i = 0; i < blc.seqs.size(); i++) { - // Concise format allows no comments or non comma-formatted data - StringTokenizer str = new StringTokenizer(line, ":"); - String id = ""; - if (!str.hasMoreTokens()) - { - continue; - } - - id = str.nextToken(); - String seqsym = str.nextToken(); - StringTokenizer symbols = new StringTokenizer(seqsym, ","); - // decide if we have more than just alphanumeric symbols - int numSymbols = symbols.countTokens(); - - if (numSymbols==0) { - continue; - } - - if (seqsym.length() != (2 * numSymbols)) - { - // Set of scalars for some property - if (Scores.containsKey(id)) - { - int i = 1; - while (Scores.containsKey(id + "_" + i)) - { - i++; - } - id = id + "_" + i; - } - Vector scores = new Vector(); - // Typecheck from first entry - int i = 0; - String ascore="dead"; - try - { - // store elements as floats... - while (symbols.hasMoreTokens()) { - ascore = symbols.nextToken(); - Float score = new Float(ascore); - scores.addElement( (Object) score); - } - Scores.put(id, scores); - } - catch (Exception e) - { - // or just keep them as strings - i = scores.size(); - for (int j = 0; j < i; j++) - { - scores.set(j, - (Object) ( (Float) scores.get(j)).toString()); - } - scores.addElement((Object) ascore); - while (symbols.hasMoreTokens()) { - { - ascore = symbols.nextToken(); - scores.addElement( (Object) ascore); - } - } - Scores.put(id, scores); - } - } - 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++) - { - conf.set(i, (Object) symbols.nextToken()); - } - } - else - { - // Sequence or a prediction string (rendered as sequence) - - StringBuffer newseq = new StringBuffer(); - - for (int i = 0; i < numSymbols; i++) { - newseq.append(symbols.nextToken()); - } - - if (id.indexOf(";") > -1) { - seq_entries.addElement(newseq); - int i=1; - String name = id.substring(id.indexOf(";")+1); - while (ids.lastIndexOf(name)>-1) { - name = id.substring(id.indexOf(";")+1)+"_"+1; - } - ids.addElement(name); - - noSeqs++; - } - else - { - if (id.equals("JNETPRED")) { - id = "Predicted Secondary Structure"; - } - seq_entries.addElement( newseq.toString() ); - ids.addElement(id); - Symscores.put((Object) id, (Object) new Integer(ids.size()-1)); - } - } - } - - - if (noSeqs < 1) - { - throw new IOException( - "JpredFile Parser: No sequence in the prediction!"); + s[i] = new DrawableSequence( (Sequence) blc.seqs.elementAt(i)); } - maxLength = seq_entries.elementAt(0).toString().length(); - 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())) - { - throw new IOException( - "JPredConcise: Not a valid protein sequence - (" - + ids.elementAt(i).toString() + ")"); - } + String out = BLCFile.print(s); - 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 = seqs.size(); - } - - seqs.addElement(newSeq); - - } + AlignFrame af = new AlignFrame(null, s); + af.resize(700, 500); + af.show(); + System.out.println(out); } - - /** - * print - * - * @return String - */ - - public String print() - { - return "Not Supported"; - } - - public static void main(String[] args) - { - try - { - JPredFile blc = new JPredFile(args[0], "File"); - 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) - { - System.err.println("Exception " + e); - e.printStackTrace(); - } - } + catch (java.io.IOException e) + { + System.out.println("Exception " + e); } + } - /* - StringBuffer out = new StringBuffer(); - - out.append("START PRED\n"); - for (int i = 0; i < s[0].sequence.length(); i++) - { - out.append(s[0].sequence.substring(i, i + 1) + " "); - out.append(s[1].sequence.substring(i, i + 1) + " "); - out.append(s[1].score[0].elementAt(i) + " "); - out.append(s[1].score[1].elementAt(i) + " "); - out.append(s[1].score[2].elementAt(i) + " "); - out.append(s[1].score[3].elementAt(i) + " "); - - out.append("\n"); - } - out.append("END PRED\n"); - return out.toString(); - } - - public static void main(String[] args) - { - try - { - BLCFile blc = new BLCFile(args[0], "File"); - DrawableSequence[] s = new DrawableSequence[blc.seqs.size()]; - for (int i = 0; i < blc.seqs.size(); i++) - { - s[i] = new DrawableSequence( (Sequence) blc.seqs.elementAt(i)); - } - String out = BLCFile.print(s); - - AlignFrame af = new AlignFrame(null, s); - af.resize(700, 500); - af.show(); - System.out.println(out); - } - catch (java.io.IOException e) - { - System.out.println("Exception " + e); - } - } - - } - */ + } + */ diff --git a/src/jalview/io/JalviewFileChooser.java b/src/jalview/io/JalviewFileChooser.java index 5a29ba7..d44275a 100755 --- a/src/jalview/io/JalviewFileChooser.java +++ b/src/jalview/io/JalviewFileChooser.java @@ -16,20 +16,21 @@ * 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 // Author: ddanimal // http://forum.java.sun.com/thread.jspa?forumID=57&threadID=327712 -*/////////////////////////////////////////////////////////////////// +*/ +////////////////////////////////////////////////////////////////// package jalview.io; import java.awt.*; import java.awt.event.*; + import java.io.*; + import java.util.*; import javax.swing.*; @@ -38,341 +39,367 @@ import javax.swing.plaf.basic.*; import javax.swing.plaf.metal.*; import javax.swing.table.*; -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; - for(int i=0; i 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); - } - }); - } - return panel; - } - - /************************************************************************** - * 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 b.lastModified(); - break; - case COLUMN_FILESIZE: - less = a.length() > b.length(); - break; - default: - less = a.getName().compareToIgnoreCase(b.getName()) > 0; - break; - } - if (ascending) return less = !less; - return less; - } - - /************************************************************************** - * 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 = " (^)"; - if (ascending) - indicator = " (v)"; - - final JTableHeader th = tbl.getTableHeader(); - final TableColumnModel tcm = th.getColumnModel(); - - 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; - } - } - } -} + public int showSaveDialog(Component parent) throws HeadlessException { + setDialogType(SAVE_DIALOG); + + int ret = showDialog(parent, null); + + if (getFileFilter() instanceof JalviewFileFilter) { + JalviewFileFilter jvf = (JalviewFileFilter) getFileFilter(); + + if (!jvf.accept(getSelectedFile())) { + String withExtension = getSelectedFile() + "." + + jvf.getAcceptableExtension(); + setSelectedFile(new File(withExtension)); + } + } + + 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; + } + + 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) + }; + } + } + + /************************************************************************** + * 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 final static class UI extends MetalFileChooserUI { + private DirectoryModel model; + + /************************************************************************** + * Must be overridden to extend + * @param e + *************************************************************************/ + public UI(JFileChooser e) { + super(e); + } + + /************************************************************************** + * Overridden to create our own model + *************************************************************************/ + protected final void createModel() { + model = new DirectoryModel(getFileChooser()); + } + + /************************************************************************** + * Overridden to get our own model + * @return + *************************************************************************/ + public final BasicDirectoryModel getModel() { + return model; + } + + /************************************************************************** + * 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); + } + } + }); + } + + return panel; + } + + /************************************************************************** + * 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; + } + } + + /*************************************************************************** + * 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); + } + + /************************************************************************** + * 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; + + switch (col) { + case COLUMN_FILEDATE: + less = a.lastModified() > b.lastModified(); + + break; + + case COLUMN_FILESIZE: + less = a.length() > b.length(); + + break; + + default: + less = a.getName().compareToIgnoreCase(b.getName()) > 0; + + break; + } + + if (ascending) { + return less = !less; + } + + return less; + } + + /************************************************************************** + * 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 = " (^)"; + + if (ascending) { + indicator = " (v)"; + } + + 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]); + } + + final TableColumn tc = tcm.getColumn(col); // the column to change + tc.setHeaderValue(COLUMNS[col] + indicator); + + th.repaint(); + + //Requery the file listing + validateFileCache(); + } + + /************************************************************************** + * Sorts the data based on current column setting + * @param data + *************************************************************************/ + protected final void sort(Vector data) { + switch (col) { + case COLUMN_FILEDATE: + 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; + } + }); + + + 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; + } + } + } +} diff --git a/src/jalview/io/JalviewFileFilter.java b/src/jalview/io/JalviewFileFilter.java index d6c6d4b..e2692e2 100755 --- a/src/jalview/io/JalviewFileFilter.java +++ b/src/jalview/io/JalviewFileFilter.java @@ -16,123 +16,139 @@ * 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 javax.swing.filechooser.*; import java.io.File; + import java.util.*; -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(); +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; - 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 extension, String description) { + setDescription(description); + } - StringTokenizer st = new StringTokenizer(extension, ","); - while(st.hasMoreElements()) - { - addExtension(st.nextToken().trim()); - } - setDescription(description); - } + public JalviewFileFilter(String[] filts) { + this(filts, null); + } - public JalviewFileFilter(String[] filts) { - this(filts, null); - } + 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() - { + if (description != null) { + setDescription(description); + } + } + + public String getAcceptableExtension() { return filters.keys().nextElement().toString(); - } - - public JalviewFileFilter(String[] filts, String description) { - for (int i = 0; i < filts.length; i++) { - // add filters one by one - addExtension(filts[i]); - } - 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("")) { + } + + // 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; + } else { + if (filters.get(getExtension(f)) != null) { + return true; + } + } + } + + if ((extension != null) && (filters.get(getExtension(f)) != null)) { + return true; + } + } + + return false; + } + + 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); + } + + 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()); } - } - } - if(extension != null && filters.get(getExtension(f)) != null) { - return true; - } - } - return false; - } - - public String getExtension(File f) { - if(f != null) { - String filename = f.getName(); - int i = filename.lastIndexOf('.'); - if(i>0 && i 0 && i < s.length() - 1) { - ext = s.substring(i+1).toLowerCase(); - } - return ext; - } - - /** 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; - } - } -} + 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; + } + + /* + * 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(); + } + return ext; + } + + /** 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; + } + } +} diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index 104b9d7..2a6e10f 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -16,258 +16,286 @@ * 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.*; + 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() - {} + public MSFfile() { + } - public MSFfile(String inStr) { - super(inStr); - } + public MSFfile(String inStr) { + super(inStr); + } - public MSFfile(String inFile, String type) throws IOException { - super(inFile,type); - } + public MSFfile(String inFile, String type) throws IOException { + super(inFile, type); + } - 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 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()); + } + } + } + } + } catch (IOException e) { + System.err.println("Exception parsing MSFFile " + e); + e.printStackTrace(); + } - public void parse() { - int i = 0; - boolean seqFlag = false; - String key = new String(); - Vector headers = new Vector(); - Hashtable seqhash = new Hashtable(); - String line; + this.noSeqs = headers.size(); - try { - while ((line = nextLine()) != null) { + //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(); - StringTokenizer str = new StringTokenizer(line); + int start = 1; + int end = seq.length(); - while (str.hasMoreTokens()) { + if (maxLength < head.length()) { + maxLength = head.length(); + } - String inStr = str.nextToken(); + if (head.indexOf("/") > 0) { + StringTokenizer st = new StringTokenizer(head, "/"); - //If line has header information add to the headers vector - if (inStr.indexOf("Name:") != -1) { - key = str.nextToken(); - headers.addElement(key); - } + if (st.countTokens() == 2) { + head = st.nextToken(); - //if line has // set SeqFlag to 1 so we know sequences are coming - if (inStr.indexOf("//") != -1) { - seqFlag = true; - } + String tmp = st.nextToken(); + st = new StringTokenizer(tmp, "-"); - //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()); - } - } - } - } - } catch (IOException e) { - System.err.println("Exception parsing MSFFile " + e); - e.printStackTrace(); - } - - this.noSeqs = headers.size(); + if (st.countTokens() == 2) { + start = Integer.valueOf(st.nextToken()).intValue(); + end = Integer.valueOf(st.nextToken()).intValue(); + } + } + } - //Add sequences to the hash - for (i = 0; i < headers.size(); i++ ) { + // Replace ~ with a sensible gap character + seq = gapre.replaceAll(seq); - if ( seqhash.get(headers.elementAt(i)) != null) { - String head = headers.elementAt(i).toString(); - String seq = seqhash.get(head).toString(); + Sequence newSeq = new Sequence(head, seq, start, end); - int start = 1; - int end = seq.length(); + seqs.addElement(newSeq); + } else { + System.err.println("MSFFile Parser: Can't find sequence for " + + headers.elementAt(i)); + } + } + } - if (maxLength < head.length() ) { - maxLength = head.length(); + 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(); + } } - if (head.indexOf("/") > 0 ) { + return check % 10000; + } + + public static String print(SequenceI[] s) { + return print(s, false); + } + + 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. - StringTokenizer st = new StringTokenizer(head,"/"); + int max = 0; + int maxid = 0; + int i = 0; + String big = ""; - if (st.countTokens() == 2) { + while ((i < s.length) && (s[i] != null)) { + String sq; + big += (sq = s[i].getSequence()); - head = 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(); + if (sq.length() > max) { + max = sq.length(); } - } - } - // Replace ~ with a sensible gap character - seq = gapre.replaceAll(seq); - Sequence newSeq = new Sequence(head,seq,start,end); - seqs.addElement(newSeq); + i++; + } - } else { - System.err.println("MSFFile Parser: Can't find sequence for " + headers.elementAt(i)); - } - } + Format maxLenpad = new Format("%" + (new String("" + max)).length() + + "d"); + Format maxChkpad = new Format("%" + (new String("1" + max)).length() + + "d"); + i = 0; + + long bigcheck = checkSum(big); + long maxNB = 0; + out.append(" MSF: " + s[0].getSequence().length() + " Type: " + + (is_NA ? "N" : "P") + " Check: " + bigcheck + " ..\n\n\n"); + + String[] nameBlock = new String[s.length]; + String[] idBlock = new String[s.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()); + nameBlock[i] = new String(" Name: " + name + " "); + idBlock[i] = new String("Len: " + + maxLenpad.form(s[i].getSequence().length()) + " Check:" + + maxChkpad.form(check) + " Weight: 1.00\n"); + + if (name.length() > maxid) { + maxid = name.length(); + } - } + if (nameBlock[i].length() > maxNB) { + maxNB = nameBlock[i].length(); + } - public static int checkSum(String seq) { - //String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.*~&@"; - int check = 0; + i++; + } - String index = "--------------------------------------&---*---.-----------------@ABCDEFGHIJKLMNOPQRSTUVWXYZ------ABCDEFGHIJKLMNOPQRSTUVWXYZ----@"; - index += "--------------------------------------------------------------------------------------------------------------------------------"; + if (maxid < 10) { + maxid = 10; + } - for(int i = 0; i < seq.length(); i++) { - try { - if (i max) { - max = sq.length(); - } - i++; - } - Format maxLenpad = new Format("%"+(new String(""+max)).length()+"d"); - Format maxChkpad = new Format("%"+(new String("1"+max)).length()+"d"); - i = 0; - long bigcheck = checkSum(big); - long maxNB=0; - out.append(" MSF: " + s[0].getSequence().length() + " Type: "+(is_NA?"N":"P")+" Check: " + bigcheck + " ..\n\n\n"); - String nameBlock[] = new String[s.length]; - String idBlock[] = new String[s.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()); - nameBlock[i]=new String(" Name: "+name+" "); - idBlock[i] = new String("Len: " + maxLenpad.form(s[i].getSequence().length()) + " Check:" + maxChkpad.form(check) + " Weight: 1.00\n"); - - if (name.length() > maxid) { - maxid = name.length(); - } - if (nameBlock[i].length()>maxNB) { - maxNB=nameBlock[i].length(); - } - - i++; - } - if (maxid < 10) { - maxid = 10; - } - if (maxNB<15) { - maxNB=15; - } - Format nbFormat = new Format("%-"+maxNB+"s"); - for (i=0;is.length() ? s.length() : (p+r)) - + " )\n"; - } - - // @tree annotations - // These are set automatically by the reader - public boolean HasBootstrap() { - return HasBootstrap; - } - - public boolean HasDistances() { - return HasDistances; - } - public NewickFile(String inStr) throws IOException - { - super(inStr, "Paste"); - } - - public NewickFile(String inFile, String type) - throws IOException - { - - super(inFile, type); - } - // File IO Flags - boolean ReplaceUnderscores = false; - - public void parse() throws IOException - { - String nf; - - { // fill nf with complete tree file - StringBuffer file = new StringBuffer(); - while ( (nf = nextLine()) != null) - { - file.append(nf); - } - nf = file.toString(); - } - - root = new SequenceNode(); - SequenceNode realroot = null; - SequenceNode c = root; - - int d = -1; - int cp = 0; - int flen = nf.length(); - - String Error = null; - String nodename = null; - - float DefDistance = (float) 0.00001; // @param Default distance for a node - very very small - int DefBootstrap = 0; // @param Default bootstrap for a node - - float distance=DefDistance; - int bootstrap=DefBootstrap; - - boolean ascending = false; // flag indicating that we are leaving the current node - - com.stevesoft.pat.Regex majorsyms = new com.stevesoft.pat.Regex("[(\\['),;]"); - - while (majorsyms.searchFrom(nf, cp) && Error==null) { - int fcp = majorsyms.matchedFrom(); - 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)) - { - // Skip the comment field - cp = 1 + comment.matchedFrom(); - } - else - { - Error = ErrorStringrange(Error, "Unterminated comment", 3, fcp, nf); - } - ; - break; - - case '(': - - // ascending should not be set - // New Internal node - if (ascending) - { - Error = ErrorStringrange(Error, "Unexpected '('", 7, fcp, nf); - continue; - } - ; - d++; - if (c.right() == null) - { - c.setRight(new SequenceNode(null, c, null, DefDistance, DefBootstrap, false)); - c = (SequenceNode) c.right(); - } - 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); - tmpn.SetChildren(c.left(), c.right()); - c.setRight(tmpn); - } - c.setLeft(new SequenceNode(null, c, null, DefDistance, DefBootstrap, false)); - c = (SequenceNode) c.left(); - } - if (realroot==null) { - realroot = c; - } - nodename = null; - distance = DefDistance; - bootstrap = DefBootstrap; - cp = fcp + 1; - break; - - // Deal with quoted fields - case '\'': - com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex( - "([^']|'')+'"); - if (qnodename.searchFrom(nf, fcp)) - { - int nl = qnodename.stringMatched().length(); - nodename = new String(qnodename.stringMatched().substring(0, nl - 1)); - cp = fcp + nl + 1; - } - else - { - Error = ErrorStringrange(Error, "Unterminated quotes for nodename", - 7, fcp, nf); - } - break; - - case ';': - if (d != -1) - { - Error = ErrorStringrange(Error, - "Wayward semicolon (depth=" + d + ")", 7, - fcp, nf); - } - // cp advanced at the end of default - - default: - - // Parse simpler field strings - String fstring = nf.substring(cp, fcp); - com.stevesoft.pat.Regex uqnodename = new com.stevesoft.pat.Regex( - "\\b([^' :;\\](),]+)"); - com.stevesoft.pat.Regex nbootstrap = new com.stevesoft.pat.Regex( - "\\S+([0-9+]+)\\S*:"); - com.stevesoft.pat.Regex ndist = new com.stevesoft.pat.Regex( - ":([-0-9.+]+)"); - if (uqnodename.search(fstring) - && (uqnodename.matchedFrom(1) == 0 - || fstring.charAt(uqnodename.matchedFrom(1) - 1) != ':')) // JBPNote HACK! - - { - if (nodename == null) - { - if (ReplaceUnderscores) { - nodename = uqnodename.stringMatched(1).replace('_', ' '); - } else { - nodename = uqnodename.stringMatched(1); - } - } - else - { - Error = ErrorStringrange(Error, - "File has broken algorithm - overwritten nodename", - 10, fcp, - nf); - } - } - if (nbootstrap.search(fstring) - && - nbootstrap.matchedFrom(1) - > uqnodename.matchedFrom(1) + uqnodename.stringMatched().length()) - { - try - { - bootstrap = (new Integer(nbootstrap.stringMatched(1))).intValue(); - HasBootstrap = true; - } - catch (Exception e) - { - Error = ErrorStringrange(Error, "Can't parse bootstrap value", 4, - cp + nbootstrap.matchedFrom(), nf); - } - } - boolean nodehasdistance=false; - if (ndist.search(fstring)) - { - try - { - distance = (new Float(ndist.stringMatched(1))).floatValue(); - HasDistances = true; - nodehasdistance = true; - } - catch (Exception e) - { - Error = ErrorStringrange(Error, "Can't parse node distance value", - 7, cp + ndist.matchedFrom(), nf); - } - } - - if (ascending) - { - // Write node info here - c.setName(nodename); - c.dist = (HasDistances) ? distance : 0; - c.setBootstrap((HasBootstrap) ? bootstrap : 0); - if (c==realroot) { - RootHasDistance = nodehasdistance; // JBPNote This is really UGLY!!! - } - } - 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) - { - c.setRight(newnode); - } - else - { - if (c.left() == null) - { - c.setLeft(newnode); - } - else - { - // Insert a dummy node for polytomy - SequenceNode newdummy = new SequenceNode(null, c, null, 0, 0, true); - newdummy.SetChildren(c.left(), newnode); - c.setLeft(newdummy); - } - } - } - if (ascending) - { - // move back up the tree from preceding closure - c = c.AscendTree(); - 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) == ')') { - d--; - ascending = true; - } else { - if (nf.charAt(fcp) == ',') { - if (ascending) { - ascending = false; - } else { - // Just advance focus, if we need to - if (c.left()!=null && (!c.left().isLeaf())) { - c = (SequenceNode) c.left(); - } - } - } // else : We do nothing if ';' is encountered. - } - // Reset new node properties to obvious fakes - nodename = null; - distance = DefDistance; - bootstrap = DefBootstrap; - - cp=fcp+1; - } - } - - if (Error!=null) { - throw(new IOException("NewickFile: "+Error+"\n")); - } - - root = (SequenceNode) root.right().detach(); // remove the imaginary root. - if (!RootHasDistance) { - root.dist = 0; - } - - } - - public NewickFile(SequenceNode newtree) { - root = newtree; - } - - public NewickFile(SequenceNode newtree, boolean bootstrap) { - HasBootstrap = bootstrap; - root=newtree; - } - public NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances) { - root = newtree; - HasBootstrap = bootstrap; - HasDistances = distances; - } - - public NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances, boolean rootdistance) { - root = newtree; - HasBootstrap = bootstrap; - HasDistances = distances; - RootHasDistance = rootdistance; - } - - public SequenceNode getTree() { - return root; - } - - public String print() { - synchronized (this) { - StringBuffer tf = new StringBuffer(); - print(tf, root); - return (tf.append(";").toString()); - } - } - - public String print(boolean withbootstraps) { - synchronized(this) { - boolean boots = this.HasBootstrap; - this.HasBootstrap = withbootstraps; - String rv = print(); - this.HasBootstrap = boots; - return rv; - } - } - - public String print(boolean withbootstraps, boolean withdists) { - synchronized(this) { - boolean dists = this.HasDistances; - this.HasDistances = withdists; - String rv = print(withbootstraps); - this.HasDistances = dists; - return rv; - } - } - boolean printRootInfo = false; - - - public String print(boolean withbootstraps, boolean withdists, boolean printRootInfo) { - synchronized(this) { - boolean rootinfo = printRootInfo; - this.printRootInfo = printRootInfo; - String rv = print(withbootstraps, withdists); - this.printRootInfo = rootinfo; - return rv; - } - } - 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='\''; - char getQuoteChar() { - return QuoteChar; - } - - char setQuoteChar(char c) { - char old = QuoteChar; - QuoteChar = c; - return old; - } - - private String nodeName(String name) { - if (NodeSafeName[0].search(name)) { - return QuoteChar + NodeSafeName[1].replaceAll(name) + QuoteChar; - } else { - return NodeSafeName[2].replaceAll(name); - } - } - 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) { - - return (printRootInfo) - ? (( (root.getName() == null) ? "" - : nodeName(root.getName())) - + ( (HasBootstrap) - ? ( (root.getBootstrap() > -1) - ? " " + root.getBootstrap() - : "") - : "") - + ( (RootHasDistance) - ? ":" + root.dist : "")) - : ""; - } - -// Non recursive call deals with root node properties - public void print(StringBuffer tf, SequenceNode root) { - if (root!=null) { - if (root.isLeaf() && printRootInfo) { - tf.append(printRootField(root)); - } else { - if (root.isDummy()) { - _print(tf, (SequenceNode) root.right()); - _print(tf, (SequenceNode) root.left()); - } else { - tf.append("("); - _print(tf, (SequenceNode) root.right()); - if (root.left() != null) { - tf.append(","); - } - _print(tf, (SequenceNode) root.left()); - tf.append(")" + printRootField(root)); - } - } - } - } - - // Recursive call for non-root nodes - public void _print(StringBuffer tf, SequenceNode c) { - if (c!=null) { - if (c.isLeaf()) { - tf.append(printNodeField(c)); - } else { - if (c.isDummy()) { - _print(tf, (SequenceNode) c.right()); - _print(tf, (SequenceNode) c.left()); - } else { - tf.append("("); - _print(tf, (SequenceNode) c.right()); - if (c.left() != null) { - tf.append(","); - } - _print(tf, (SequenceNode) c.left()); - tf.append(")" + printNodeField(c)); - } - } - } - } - -// Test - 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) { - newickfile.append(l); - } - treefile.close(); - System.out.println("Read file :\n"); - NewickFile trf = new NewickFile(args[0], "File"); - trf.parse(); - System.out.println("Original file :\n"); - com.stevesoft.pat.Regex nonl = new com.stevesoft.pat.Regex("\n+", ""); - System.out.println(nonl.replaceAll(newickfile.toString())+"\n"); - - System.out.println("Parsed file.\n"); - System.out.println("Default output type for original input.\n"); - System.out.println(trf.print()); - System.out.println("Without bootstraps.\n"); - System.out.println(trf.print(false)); - System.out.println("Without distances.\n"); - System.out.println(trf.print(true,false)); - System.out.println("Without bootstraps but with distanecs.\n"); - System.out.println(trf.print(false, true)); - System.out.println("Without bootstraps or distanecs.\n"); - 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) - { - System.err.println("Exception\n" + e); - e.printStackTrace(); - } -} - -} +*/ + +// NewickFile.java +// Tree I/O +// http://evolution.genetics.washington.edu/phylip/newick_doc.html +package jalview.io; + +import jalview.datamodel.*; + +import java.io.*; + +import java.util.*; + + +public class NewickFile extends FileParse { + SequenceNode root; + private boolean HasBootstrap = false; + private boolean HasDistances = false; + private boolean RootHasDistance = false; + + // File IO Flags + boolean ReplaceUnderscores = false; + boolean printRootInfo = false; + 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 { + super(inStr, "Paste"); + } + + public NewickFile(String inFile, String type) throws IOException { + super(inFile, type); + } + + public NewickFile(SequenceNode newtree) { + root = newtree; + } + + public NewickFile(SequenceNode newtree, boolean bootstrap) { + HasBootstrap = bootstrap; + root = newtree; + } + + public NewickFile(SequenceNode newtree, boolean bootstrap, boolean distances) { + root = newtree; + HasBootstrap = bootstrap; + HasDistances = distances; + } + + public NewickFile(SequenceNode newtree, boolean bootstrap, + boolean distances, boolean rootdistance) { + root = newtree; + HasBootstrap = bootstrap; + HasDistances = distances; + RootHasDistance = rootdistance; + } + + private String ErrorStringrange(String Error, String Er, int r, int p, + String s) { + return ((Error == null) ? "" : Error) + Er + " at position " + p + + " ( " + + s.substring(((p - r) < 0) ? 0 : (p - r), + ((p + r) > s.length()) ? s.length() : (p + r)) + " )\n"; + } + + // @tree annotations + // These are set automatically by the reader + public boolean HasBootstrap() { + return HasBootstrap; + } + + public boolean HasDistances() { + return HasDistances; + } + + public void parse() throws IOException { + String nf; + + { // fill nf with complete tree file + + StringBuffer file = new StringBuffer(); + + while ((nf = nextLine()) != null) { + file.append(nf); + } + + nf = file.toString(); + } + + root = new SequenceNode(); + + SequenceNode realroot = null; + SequenceNode c = root; + + int d = -1; + int cp = 0; + int flen = nf.length(); + + String Error = null; + String nodename = null; + + float DefDistance = (float) 0.00001; // @param Default distance for a node - very very small + int DefBootstrap = 0; // @param Default bootstrap for a node + + float distance = DefDistance; + int bootstrap = DefBootstrap; + + boolean ascending = false; // flag indicating that we are leaving the current node + + com.stevesoft.pat.Regex majorsyms = new com.stevesoft.pat.Regex( + "[(\\['),;]"); + + while (majorsyms.searchFrom(nf, cp) && (Error == null)) { + int fcp = majorsyms.matchedFrom(); + + 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)) { + // Skip the comment field + cp = 1 + comment.matchedFrom(); + } else { + Error = ErrorStringrange(Error, "Unterminated comment", 3, + fcp, nf); + } + + ; + + break; + + case '(': + + // ascending should not be set + // New Internal node + if (ascending) { + Error = ErrorStringrange(Error, "Unexpected '('", 7, fcp, nf); + + continue; + } + + ; + d++; + + if (c.right() == null) { + c.setRight(new SequenceNode(null, c, null, DefDistance, + DefBootstrap, false)); + c = (SequenceNode) c.right(); + } 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); + tmpn.SetChildren(c.left(), c.right()); + c.setRight(tmpn); + } + + c.setLeft(new SequenceNode(null, c, null, DefDistance, + DefBootstrap, false)); + c = (SequenceNode) c.left(); + } + + if (realroot == null) { + realroot = c; + } + + nodename = null; + distance = DefDistance; + bootstrap = DefBootstrap; + cp = fcp + 1; + + break; + + // Deal with quoted fields + case '\'': + + com.stevesoft.pat.Regex qnodename = new com.stevesoft.pat.Regex( + "([^']|'')+'"); + + if (qnodename.searchFrom(nf, fcp)) { + int nl = qnodename.stringMatched().length(); + nodename = new String(qnodename.stringMatched().substring(0, + nl - 1)); + cp = fcp + nl + 1; + } else { + Error = ErrorStringrange(Error, + "Unterminated quotes for nodename", 7, fcp, nf); + } + + break; + + case ';': + + if (d != -1) { + Error = ErrorStringrange(Error, + "Wayward semicolon (depth=" + d + ")", 7, fcp, nf); + } + + // cp advanced at the end of default + default: + + // Parse simpler field strings + String fstring = nf.substring(cp, fcp); + com.stevesoft.pat.Regex uqnodename = new com.stevesoft.pat.Regex( + "\\b([^' :;\\](),]+)"); + com.stevesoft.pat.Regex nbootstrap = new com.stevesoft.pat.Regex( + "\\S+([0-9+]+)\\S*:"); + com.stevesoft.pat.Regex ndist = new com.stevesoft.pat.Regex( + ":([-0-9.+]+)"); + + if (uqnodename.search(fstring) && + ((uqnodename.matchedFrom(1) == 0) || + (fstring.charAt(uqnodename.matchedFrom(1) - 1) != ':'))) // JBPNote HACK! + { + if (nodename == null) { + if (ReplaceUnderscores) { + nodename = uqnodename.stringMatched(1).replace('_', + ' '); + } else { + nodename = uqnodename.stringMatched(1); + } + } else { + Error = ErrorStringrange(Error, + "File has broken algorithm - overwritten nodename", + 10, fcp, nf); + } + } + + if (nbootstrap.search(fstring) && + (nbootstrap.matchedFrom(1) > (uqnodename.matchedFrom(1) + + uqnodename.stringMatched().length()))) { + try { + bootstrap = (new Integer(nbootstrap.stringMatched(1))).intValue(); + HasBootstrap = true; + } catch (Exception e) { + Error = ErrorStringrange(Error, + "Can't parse bootstrap value", 4, + cp + nbootstrap.matchedFrom(), nf); + } + } + + boolean nodehasdistance = false; + + if (ndist.search(fstring)) { + try { + distance = (new Float(ndist.stringMatched(1))).floatValue(); + HasDistances = true; + nodehasdistance = true; + } catch (Exception e) { + Error = ErrorStringrange(Error, + "Can't parse node distance value", 7, + cp + ndist.matchedFrom(), nf); + } + } + + if (ascending) { + // Write node info here + c.setName(nodename); + c.dist = (HasDistances) ? distance : 0; + c.setBootstrap((HasBootstrap) ? bootstrap : 0); + + if (c == realroot) { + RootHasDistance = nodehasdistance; // JBPNote This is really UGLY!!! + } + } 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) { + c.setRight(newnode); + } else { + if (c.left() == null) { + c.setLeft(newnode); + } else { + // Insert a dummy node for polytomy + SequenceNode newdummy = new SequenceNode(null, c, + null, 0, 0, true); + newdummy.SetChildren(c.left(), newnode); + c.setLeft(newdummy); + } + } + } + + if (ascending) { + // move back up the tree from preceding closure + c = c.AscendTree(); + + 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) == ')') { + d--; + ascending = true; + } else { + if (nf.charAt(fcp) == ',') { + if (ascending) { + ascending = false; + } else { + // Just advance focus, if we need to + if ((c.left() != null) && (!c.left().isLeaf())) { + c = (SequenceNode) c.left(); + } + } + } + // else : We do nothing if ';' is encountered. + } + + // Reset new node properties to obvious fakes + nodename = null; + distance = DefDistance; + bootstrap = DefBootstrap; + + cp = fcp + 1; + } + } + + if (Error != null) { + throw (new IOException("NewickFile: " + Error + "\n")); + } + + root = (SequenceNode) root.right().detach(); // remove the imaginary root. + + if (!RootHasDistance) { + root.dist = 0; + } + } + + public SequenceNode getTree() { + return root; + } + + public String print() { + synchronized (this) { + StringBuffer tf = new StringBuffer(); + print(tf, root); + + return (tf.append(";").toString()); + } + } + + public String print(boolean withbootstraps) { + synchronized (this) { + boolean boots = this.HasBootstrap; + this.HasBootstrap = withbootstraps; + + String rv = print(); + this.HasBootstrap = boots; + + return rv; + } + } + + public String print(boolean withbootstraps, boolean withdists) { + synchronized (this) { + boolean dists = this.HasDistances; + this.HasDistances = withdists; + + String rv = print(withbootstraps); + this.HasDistances = dists; + + return rv; + } + } + + public String print(boolean withbootstraps, boolean withdists, + boolean printRootInfo) { + synchronized (this) { + boolean rootinfo = printRootInfo; + this.printRootInfo = printRootInfo; + + String rv = print(withbootstraps, withdists); + this.printRootInfo = rootinfo; + + return rv; + } + } + + char getQuoteChar() { + return QuoteChar; + } + + char setQuoteChar(char c) { + char old = QuoteChar; + QuoteChar = c; + + return old; + } + + private String nodeName(String name) { + if (NodeSafeName[0].search(name)) { + return QuoteChar + NodeSafeName[1].replaceAll(name) + QuoteChar; + } else { + return NodeSafeName[2].replaceAll(name); + } + } + + 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) { + return (printRootInfo) + ? (((root.getName() == null) ? "" : nodeName(root.getName())) + + ((HasBootstrap) + ? ((root.getBootstrap() > -1) ? (" " + root.getBootstrap()) : "") : "") + + ((RootHasDistance) ? (":" + root.dist) : "")) : ""; + } + + // Non recursive call deals with root node properties + public void print(StringBuffer tf, SequenceNode root) { + if (root != null) { + if (root.isLeaf() && printRootInfo) { + tf.append(printRootField(root)); + } else { + if (root.isDummy()) { + _print(tf, (SequenceNode) root.right()); + _print(tf, (SequenceNode) root.left()); + } else { + tf.append("("); + _print(tf, (SequenceNode) root.right()); + + if (root.left() != null) { + tf.append(","); + } + + _print(tf, (SequenceNode) root.left()); + tf.append(")" + printRootField(root)); + } + } + } + } + + // Recursive call for non-root nodes + public void _print(StringBuffer tf, SequenceNode c) { + if (c != null) { + if (c.isLeaf()) { + tf.append(printNodeField(c)); + } else { + if (c.isDummy()) { + _print(tf, (SequenceNode) c.right()); + _print(tf, (SequenceNode) c.left()); + } else { + tf.append("("); + _print(tf, (SequenceNode) c.right()); + + if (c.left() != null) { + tf.append(","); + } + + _print(tf, (SequenceNode) c.left()); + tf.append(")" + printNodeField(c)); + } + } + } + } + + // Test + 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) { + newickfile.append(l); + } + + treefile.close(); + System.out.println("Read file :\n"); + + NewickFile trf = new NewickFile(args[0], "File"); + trf.parse(); + System.out.println("Original file :\n"); + + com.stevesoft.pat.Regex nonl = new com.stevesoft.pat.Regex("\n+", ""); + System.out.println(nonl.replaceAll(newickfile.toString()) + "\n"); + + System.out.println("Parsed file.\n"); + System.out.println("Default output type for original input.\n"); + System.out.println(trf.print()); + System.out.println("Without bootstraps.\n"); + System.out.println(trf.print(false)); + System.out.println("Without distances.\n"); + System.out.println(trf.print(true, false)); + System.out.println("Without bootstraps but with distanecs.\n"); + System.out.println(trf.print(false, true)); + System.out.println("Without bootstraps or distanecs.\n"); + 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) { + System.err.println("Exception\n" + e); + e.printStackTrace(); + } + } +} diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index 410628f..42334e3 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -16,120 +16,130 @@ * 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.analysis.*; +import jalview.datamodel.*; + import java.io.*; + import java.util.*; + public class PIRFile extends AlignFile { + Vector words = new Vector(); //Stores the words in a line after splitting + + public PIRFile() { + } - 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, start, 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); - } + public PIRFile(String inStr) { + super(inStr); + } + public PIRFile(String inFile, String type) throws IOException { + super(inFile, type); } - catch(Exception ex){ex.printStackTrace();} - } - - 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"); + + 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(); } - } - i++; } - 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); - } -} + 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"); + } + } + + i++; + } + + 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 d0ffbc9..b31a148 100755 --- a/src/jalview/io/PfamFile.java +++ b/src/jalview/io/PfamFile.java @@ -16,177 +16,182 @@ * 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.*; - -public class PfamFile extends AlignFile { - - Vector ids; - public PfamFile() - {} +import java.util.*; - public PfamFile(String inStr) { - super(inStr); - } - public void initData() { - super.initData(); - ids = new Vector(); - } +public class PfamFile extends AlignFile { + Vector ids; - public PfamFile(String inFile, String type) throws IOException { - super(inFile,type); - } + public PfamFile() { + } - public void parse() throws IOException{ - int i = 0; - String line; + public PfamFile(String inStr) { + super(inStr); + } + public PfamFile(String inFile, String type) throws IOException { + super(inFile, type); + } - Hashtable seqhash = new Hashtable(); - Vector headers = new Vector(); + public void initData() { + super.initData(); + ids = new Vector(); + } + public void parse() throws IOException { + int i = 0; + String line; - while ((line = nextLine()) != null) - { + Hashtable seqhash = new Hashtable(); + Vector headers = new Vector(); - if (line.indexOf(" ") != 0) - { - if (line.indexOf("#") != 0) - { + while ((line = nextLine()) != null) { + if (line.indexOf(" ") != 0) { + if (line.indexOf("#") != 0) { + StringTokenizer str = new StringTokenizer(line, " "); + String id = ""; - StringTokenizer str = new StringTokenizer(line," "); - String id = ""; + if (str.hasMoreTokens()) { + id = str.nextToken(); - if (str.hasMoreTokens()) - { - id = str.nextToken(); + StringBuffer tempseq; - StringBuffer tempseq; + if (seqhash.containsKey(id)) { + tempseq = (StringBuffer) seqhash.get(id); + } else { + tempseq = new StringBuffer(); + seqhash.put(id, 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 (!(headers.contains(id))) - headers.addElement(id); + tempseq.append(str.nextToken()); + } + } + } + } + this.noSeqs = headers.size(); - tempseq.append(str.nextToken()); - } + if (noSeqs < 1) { + throw new IOException("No sequences found (PFAM input)"); } - } - } - this.noSeqs = headers.size(); - if(noSeqs<1) - throw new IOException("No sequences found (PFAM input)"); - - 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; + 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)); } - } else - ids.addElement(headers.elementAt(i)); - } - else - ids.addElement(headers.elementAt(i)); + } + public static String print(SequenceI[] s) { + StringBuffer out = new StringBuffer(""); - 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); - } + int max = 0; + int maxid = 0; - 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)); + int i = 0; - } + 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(); + } - public static String print(SequenceI[] s) { - StringBuffer out = new StringBuffer(""); + if (tmp.length() > maxid) { + maxid = tmp.length(); + } - int max = 0; - int maxid = 0; + i++; + } - int i = 0; + if (maxid < 15) { + maxid = 15; + } - while (i < s.length && s[i] != null) { - String tmp = s[i].getName() + "/" + s[i].getStart()+ "-" + s[i].getEnd(); + int j = 0; - if (s[i].getSequence().length() > max) { - max = s[i].getSequence().length(); - } - if (tmp.length() > maxid) { - maxid = tmp.length(); - } - i++; - } + while ((j < s.length) && (s[j] != null)) { + out.append(new Format("%-" + maxid + "s").form(s[j].getName() + + "/" + s[j].getStart() + "-" + s[j].getEnd()) + " "); - if (maxid < 15) { - maxid = 15; - } + out.append(s[j].getSequence() + "\n"); + j++; + } - 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() ) + " "); + out.append("\n"); - out.append(s[j].getSequence() + "\n"); - j++; + return out.toString(); } - out.append("\n"); - - 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 f5f709e..9f879c0 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -15,10 +15,10 @@ * 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; - +*/ +package jalview.io; + + /** *

Title:

* PileUpfile @@ -29,239 +29,248 @@ package jalview.io; * 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.*; - - -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); - } - - //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(); - } - - 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(); - - if (maxLength < head.length() ) { - maxLength = head.length(); - } - - if (head.indexOf("/") > 0 ) { - - StringTokenizer st = new StringTokenizer(head,"/"); - - if (st.countTokens() == 2) { - - head = 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(); - } - } - } - - Sequence newSeq = new Sequence(head,seq,start,end); - - 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 max) { - max = seq.length(); - } - if (name.length() > maxid) { - maxid = name.length(); - } - i++; - } - - if (maxid < 10) { - maxid = 10; - } - maxid++; - out.append( "\n\n//\n\n"); - - int len = 50; - - int nochunks = max / len + 1; - if (max%len == 0) { - nochunks--; - } - 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++; - } - out.append("\n"); - - } - return out.toString(); -} -public String print() { - return print(getSeqsAsArray()); -} -} - - - - - - - + **/ +import jalview.datamodel.*; + +import jalview.util.*; + +import java.io.*; + +import java.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 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()); + } + } + } + } + } 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(); + + if (maxLength < head.length()) { + maxLength = head.length(); + } + + if (head.indexOf("/") > 0) { + StringTokenizer st = new StringTokenizer(head, "/"); + + if (st.countTokens() == 2) { + head = 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(); + } + } + } + + Sequence newSeq = new Sequence(head, seq, start, end); + + 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(); + } + } + + return check % 10000; + } + + public static String print(SequenceI[] s) { + StringBuffer out = new StringBuffer("PileUp\n\n"); + + int max = 0; + int maxid = 0; + + int i = 0; + String big = ""; + + while ((i < s.length) && (s[i] != null)) { + big += s[i].getSequence(); + i++; + } + + i = 0; + + int bigcheck = checkSum(big); + + out.append(" MSF: " + s[0].getSequence().length() + + " Type: P Check: " + bigcheck + " ..\n\n\n"); + + 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 (seq.length() > max) { + max = seq.length(); + } + + if (name.length() > maxid) { + maxid = name.length(); + } + + i++; + } + + if (maxid < 10) { + maxid = 10; + } + + maxid++; + out.append("\n\n//\n\n"); + + int len = 50; + + int nochunks = (max / len) + 1; + + if ((max % len) == 0) { + nochunks--; + } + + 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++; + } + + 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 b8300a0..c8c39dc 100755 --- a/src/jalview/io/SequenceFeatureFetcher.java +++ b/src/jalview/io/SequenceFeatureFetcher.java @@ -16,372 +16,404 @@ * 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.io.*; + import java.io.*; + import java.util.*; + import javax.swing.*; -import jalview.io.*; -import jalview.gui.*; -import jalview.datamodel.*; -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) - { - unknownSequences = new ArrayList(); - this.align = align; - this.ap = ap; - Thread thread = new Thread(this); - thread.start(); - } - - public void run() -{ - - String cache = jalview.bin.Cache.getProperty("UNIPROT_CACHE"); - - RandomAccessFile out = null; - - try{ - if (cache == null) - { - jalview.bin.Cache.setProperty("UNIPROT_CACHE", System.getProperty("user.home")+"/uniprot.xml"); - cache = jalview.bin.Cache.getProperty("UNIPROT_CACHE"); - } +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) { + unknownSequences = new ArrayList(); + this.align = align; + this.ap = ap; - File test = new File(cache); - if( !test.exists() ) - { - out = new RandomAccessFile(cache, "rw"); - out.writeBytes("\n"); - out.writeBytes("\n"); - } - 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) - lastLine = out.getFilePointer(); - - } - out.seek(lastLine); + Thread thread = new Thread(this); + thread.start(); } - int seqIndex = 0; - Vector sequences = align.getSequences(); + public void run() { + String cache = jalview.bin.Cache.getProperty("UNIPROT_CACHE"); - while (seqIndex < sequences.size()) - { - ArrayList ids = new ArrayList(); - for (int i = 0; seqIndex < sequences.size() && i < 50; seqIndex++, i++) - { - SequenceI sequence = (SequenceI) sequences.get(seqIndex); - ids.add(sequence.getName()); - } + RandomAccessFile out = null; - tryLocalCacheFirst(ids, align); + try { + if (cache == null) { + jalview.bin.Cache.setProperty("UNIPROT_CACHE", + System.getProperty("user.home") + "/uniprot.xml"); + cache = jalview.bin.Cache.getProperty("UNIPROT_CACHE"); + } - if (ids.size() > 0) - { - StringBuffer remainingIds = new StringBuffer("uniprot:"); - for (int i = 0; i < ids.size(); i++) - remainingIds.append(ids.get(i) + ";"); + File test = new File(cache); - EBIFetchClient ebi = new EBIFetchClient(); - String[] result = ebi.fetchData(remainingIds.toString(), "xml", null); + if (!test.exists()) { + out = new RandomAccessFile(cache, "rw"); + out.writeBytes("\n"); + out.writeBytes("\n"); + } else { + out = new RandomAccessFile(cache, "rw"); - if(result!=null) - ReadUniprotFile(result, out, align); - } + // open exisiting cache and remove from the end + long lastLine = 0; + String data; - } + while ((data = out.readLine()) != null) { + if (data.indexOf("") > -1) { + lastLine = out.getFilePointer(); + } + } - if (out != null) - { - out.writeBytes("\n"); - out.close(); - } - }catch(Exception ex){ex.printStackTrace();} + out.seek(lastLine); + } - ap.repaint(); - findMissingIds(align); - 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" - +"Save your alignment to maintain the updated id.\n\n"+sbuffer.toString()); - Desktop.addInternalFrame(output, "Sequence names updated ", 600,300); + int seqIndex = 0; + Vector sequences = align.getSequences(); - } + while (seqIndex < sequences.size()) { + ArrayList ids = new ArrayList(); - if(unknownSequences.size()>0) - { - //ignore for now!!!!!!!!!! - // WSWUBlastClient blastClient = new WSWUBlastClient(align, unknownSequences); - } + for (int i = 0; (seqIndex < sequences.size()) && (i < 50); + seqIndex++, i++) { + SequenceI sequence = (SequenceI) sequences.get(seqIndex); + ids.add(sequence.getName()); + } -} + tryLocalCacheFirst(ids, align); + + if (ids.size() > 0) { + StringBuffer remainingIds = new StringBuffer("uniprot:"); -void ReadUniprotFile(String [] result, RandomAccessFile out, AlignmentI align) -{ - SequenceI sequence = null; - Vector features = null; - String type, description, status, start, end, pdb = null; - - - for (int r = 0; r < result.length; r++) - { - if(sequence==null && result[r].indexOf("")>-1) - { - long filePointer = 0; - - if(out!=null) - try{ - filePointer=out.getFilePointer(); - out.writeBytes("\n"); - }catch(Exception ex){} - - String seqName = parseElement( result[r], "" , out); - sequence = align.findName( seqName ) ; - if(sequence==null) - { - sequence = align.findName( seqName.substring(0, seqName.indexOf('_'))); - if(sequence!=null) - { - sbuffer.append("changing "+sequence.getName()+" to "+seqName+"\n"); - sequence.setName(seqName); + for (int i = 0; i < ids.size(); i++) + remainingIds.append(ids.get(i) + ";"); + + EBIFetchClient ebi = new EBIFetchClient(); + String[] result = ebi.fetchData(remainingIds.toString(), + "xml", null); + + if (result != null) { + ReadUniprotFile(result, out, align); + } + } + } + + if (out != null) { + out.writeBytes("\n"); + out.close(); + } + } catch (Exception ex) { + ex.printStackTrace(); } - } - 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 { out.setLength(filePointer); } catch (Exception ex) {} - // now skip to next entry - while( result[r].indexOf("")==-1) - r++; - } - - features = new Vector(); - type=""; start="0"; end="0"; description=""; status=""; pdb=""; + ap.repaint(); + findMissingIds(align); + + 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" + + "Save your alignment to maintain the updated id.\n\n" + + sbuffer.toString()); + Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300); + } + + if (unknownSequences.size() > 0) { + //ignore for now!!!!!!!!!! + // WSWUBlastClient blastClient = new WSWUBlastClient(align, unknownSequences); + } } - if(sequence==null) - continue; - - if( result[r].indexOf("-1) - { - pdb = parseValue( result[r], "value=" , out); - sequence.setPDBId(pdb); - } - - 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) - { - r++; // - } - // r++; - if(result[r].indexOf("begin")>-1) - { - start = parseValue( result[r], "position=" , out); - end = parseValue( result[++r], "position=" , out); - } - else - { - start = parseValue( result[r], "position=" , out); - end = parseValue( result[r], "position=" , null); - } - int sstart = Integer.parseInt(start); - int eend = Integer.parseInt(end); - if(out!=null) - try{ out.writeBytes("\n"); }catch(Exception ex){} - - SequenceFeature sf = new SequenceFeature(type, - sstart, - eend, - description, - status); - features.add(sf); - } - - if(result[r].indexOf("-1) - { - StringBuffer seqString = new StringBuffer(); - - if(out!=null) - try { out.writeBytes(result[r]+"\n"); } catch (Exception ex){} - - while(result[++r].indexOf("")==-1) - { - seqString.append(result[r]); - if(out!=null) - try { out.writeBytes(result[r]+"\n"); } catch (Exception ex){} - } - - if(out!=null) - try { out.writeBytes(result[r]+"\n"); } catch (Exception ex){} - - StringBuffer nonGapped = new StringBuffer(); - 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) - { - unknownSequences.add(sequence.getName()); - features = null; - sbuffer.append(sequence.getName()+ " SEQUENCE NOT %100 MATCH \n"); - continue; - } - - int absEnd = absStart + nonGapped.toString().length(); - absStart+=1; - - if(absStart!=sequence.getStart() || absEnd!=sequence.getEnd()) - sbuffer.append("Updated: "+sequence.getName()+" "+ - sequence.getStart()+"/"+sequence.getEnd()+" to "+ absStart+"/"+absEnd+"\n"); - - - sequence.setStart(absStart); - sequence.setEnd(absEnd); - - } - - if(result[r].indexOf("")>-1) - { - if(features!=null) - sequence.setSequenceFeatures( features ); - features = null; - sequence = null; - if(out!=null) - try{ out.writeBytes("\n"); }catch(Exception ex){} - - } - } -} + void ReadUniprotFile(String[] result, RandomAccessFile out, AlignmentI align) { + SequenceI sequence = null; + Vector features = null; + String type; + String description; + String status; + String start; + String end; + String pdb = null; + + for (int r = 0; r < result.length; r++) { + if ((sequence == null) && (result[r].indexOf("") > -1)) { + long filePointer = 0; + + if (out != null) { + try { + filePointer = out.getFilePointer(); + out.writeBytes("\n"); + } catch (Exception ex) { + } + } + + String seqName = parseElement(result[r], "", out); + sequence = align.findName(seqName); + + if (sequence == null) { + sequence = align.findName(seqName.substring(0, + seqName.indexOf('_'))); + + if (sequence != null) { + sbuffer.append("changing " + sequence.getName() + + " to " + seqName + "\n"); + sequence.setName(seqName); + } + } + + 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 { + out.setLength(filePointer); + } catch (Exception ex) { + } + + // now skip to next entry + while (result[r].indexOf("") == -1) + r++; + } + + features = new Vector(); + type = ""; + start = "0"; + end = "0"; + description = ""; + status = ""; + pdb = ""; + } + + if (sequence == null) { + continue; + } + + if (result[r].indexOf(" -1) { + pdb = parseValue(result[r], "value=", out); + sequence.setPDBId(pdb); + } + + 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) { + r++; // + } + + // r++; + if (result[r].indexOf("begin") > -1) { + start = parseValue(result[r], "position=", out); + end = parseValue(result[++r], "position=", out); + } else { + start = parseValue(result[r], "position=", out); + end = parseValue(result[r], "position=", null); + } + + int sstart = Integer.parseInt(start); + int eend = Integer.parseInt(end); + + if (out != null) { + try { + out.writeBytes("\n"); + } catch (Exception ex) { + } + } + + SequenceFeature sf = new SequenceFeature(type, sstart, eend, + description, status); + features.add(sf); + } + + if (result[r].indexOf(" -1) { + StringBuffer seqString = new StringBuffer(); + + if (out != null) { + try { + out.writeBytes(result[r] + "\n"); + } catch (Exception ex) { + } + } + + while (result[++r].indexOf("") == -1) { + seqString.append(result[r]); + + if (out != null) { + try { + out.writeBytes(result[r] + "\n"); + } catch (Exception ex) { + } + } + } + + if (out != null) { + try { + out.writeBytes(result[r] + "\n"); + } catch (Exception ex) { + } + } + + StringBuffer nonGapped = new StringBuffer(); + + 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) { + unknownSequences.add(sequence.getName()); + features = null; + sbuffer.append(sequence.getName() + + " SEQUENCE NOT %100 MATCH \n"); + + continue; + } + + int absEnd = absStart + nonGapped.toString().length(); + absStart += 1; + + if ((absStart != sequence.getStart()) || + (absEnd != sequence.getEnd())) { + sbuffer.append("Updated: " + sequence.getName() + " " + + sequence.getStart() + "/" + sequence.getEnd() + + " to " + absStart + "/" + absEnd + "\n"); + } + + sequence.setStart(absStart); + sequence.setEnd(absEnd); + } + + if (result[r].indexOf("") > -1) { + if (features != null) { + sequence.setSequenceFeatures(features); + } + + features = null; + sequence = null; + + if (out != null) { + try { + out.writeBytes("\n"); + } catch (Exception ex) { + } + } + } + } + } -void findMissingIds(AlignmentI align) -{ - String data; - ArrayList cachedIds = new ArrayList(); - - try - { - BufferedReader in = new BufferedReader( - new FileReader(jalview.bin.Cache.getProperty("UNIPROT_CACHE"))); - - while ( (data = in.readLine()) != null) - { - if (data.indexOf("name") > -1) - { - String name = parseElement(data, "", null); - cachedIds.add(name); - } + void findMissingIds(AlignmentI align) { + String data; + ArrayList cachedIds = new ArrayList(); + + try { + BufferedReader in = new BufferedReader(new FileReader( + jalview.bin.Cache.getProperty("UNIPROT_CACHE"))); + + while ((data = in.readLine()) != null) { + if (data.indexOf("name") > -1) { + String name = parseElement(data, "", null); + cachedIds.add(name); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + for (int i = 0; i < align.getHeight(); i++) + if (!cachedIds.contains(align.getSequenceAt(i).getName())) { + unknownSequences.add(align.getSequenceAt(i).getName()); + } } - } - catch (Exception ex) - { ex.printStackTrace(); } - for(int i=0; i-1) - { - String name = parseElement( data, "" , null) ; - if(ids.contains( name ) ) - { - cacheData.add(""); - cacheData.add(data); - while( data.indexOf("")==-1) - { - data = in.readLine(); - cacheData.add(data); - } - cacheData.add(data); - - ids.remove( name ); - } - } - } - } - catch(Exception ex){ex.printStackTrace();} + while ((data = in.readLine()) != null) { + if (data.indexOf("name") > -1) { + String name = parseElement(data, "", null); - String [] localData = new String[cacheData.size()]; - cacheData.toArray( localData ); - if(localData!=null && localData.length>0) - ReadUniprotFile(localData, null, align); -} + if (ids.contains(name)) { + cacheData.add(""); + cacheData.add(data); + while (data.indexOf("") == -1) { + data = in.readLine(); + cacheData.add(data); + } -String parseValue(String line, String tag, RandomAccessFile out) -{ - if(out!=null) - try{ out.writeBytes(line+"\n"); }catch(Exception ex){} + cacheData.add(data); + ids.remove(name); + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } - int index = line.indexOf(tag)+tag.length()+1; - if(index==tag.length()) - return ""; + String[] localData = new String[cacheData.size()]; + cacheData.toArray(localData); - return line.substring( index, line.indexOf("\"", index+1) ); -} + if ((localData != null) && (localData.length > 0)) { + ReadUniprotFile(localData, null, align); + } + } + + String parseValue(String line, String tag, RandomAccessFile out) { + if (out != null) { + try { + out.writeBytes(line + "\n"); + } catch (Exception ex) { + } + } + int index = line.indexOf(tag) + tag.length() + 1; -String parseElement(String line, String tag, RandomAccessFile out) -{ - if (out != null) - try - { - out.writeBytes(line + "\n"); + if (index == tag.length()) { + return ""; + } + + return line.substring(index, line.indexOf("\"", index + 1)); } - catch (Exception ex) - {} - int index = line.indexOf(tag) + tag.length(); - return line.substring(index, line.indexOf("0) - { - try{ - Thread.sleep(100); - imageIndex++; - imageIndex %=9; - output.setFrameIcon( imageIcon[imageIndex]); - output.setTitle("BLASTing for unidentified sequences - "+jobsRunning+" jobs running."); +import javax.swing.*; - }catch(Exception ex){} +import javax.xml.namespace.QName; - } - } - } +public class WSWUBlastClient { + CutAndPasteTransfer output = new CutAndPasteTransfer(); + int jobsRunning = 0; + 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++) { + SequenceI sequence = al.findName(ids.get(i).toString()); + StringBuffer nonGapped = new StringBuffer(); - class BlastThread extends Thread - { - String sequence; - String seqid; - String jobid; - boolean jobComplete = false; + for (int n = 0; n < sequence.getSequence().length(); n++) { + if (!jalview.util.Comparison.isGap(sequence.getCharAt(n))) { + nonGapped.append(sequence.getCharAt(n)); + } + } + + BlastThread thread = new BlastThread(ids.get(i).toString(), + nonGapped.toString()); + thread.start(); + jobsRunning++; + } - BlastThread(String id, String sequence) - { - this.sequence = sequence; - seqid = id; + ImageTwirler thread = new ImageTwirler(); + thread.start(); } - public void run() - { - StartJob(); - - 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[] - {jobid, "xml"}); - if(result.indexOf("JOB PENDING")==-1 && result.indexOf("JOB RUNNING")==-1) - { - parseResult(seqid, result); - jobComplete = true; - jobsRunning --; - } - Thread.sleep(5000); - // System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug + 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()) { + data = st.nextToken(); + + 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) { + data = st.nextToken(); + + if (data.indexOf("") > -1) { + int value = Integer.parseInt(data.substring(data.indexOf( + "") + 10, + data.indexOf(""))); + + if (value >= maxFound) { + maxFound = value; + buffer.append(" " + id2 + " " + value + "%; "); + } + } + } + } } - catch (Exception ex) - {} - } - } - void StartJob() - { - HashMap params = new HashMap(); - params.put("database", "uniprot"); - params.put("sensitivity", "low"); - params.put("sort", "totalscore"); - params.put("matrix", "pam10"); - params.put("program", "blastp"); - params.put("alignments", "5"); - params.put("outformat", "xml"); - params.put("searchtype", "1"); - byte[] seqbytes = sequence.getBytes(); - - 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[] - {params, seqbytes}); - jobid = result; - System.out.println("http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast JobId '"+jobid+"'"); - - } - catch (Exception exp) - { - System.err.println("WSWUBlastClient error:\n" + exp.toString()); - exp.printStackTrace(); - } + output.setText(output.getText() + buffer.toString()); } - } - - 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() ) - { - data = st.nextToken(); - - 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) - { - data = st.nextToken(); - if(data.indexOf("")>-1) - { - int value = Integer.parseInt( data.substring(data.indexOf("")+10, data.indexOf(""))); - if(value>=maxFound) - { - maxFound = value; - buffer.append(" "+ id2 + " " + value+"%; "); - } + + class ImageTwirler extends Thread { + ImageIcon[] imageIcon; + int imageIndex = 0; + + public ImageTwirler() { + imageIcon = new ImageIcon[9]; + + for (int i = 0; i < 9; i++) { + java.net.URL url = getClass().getResource("/images/dna" + + (i + 1) + ".gif"); + + if (url != null) { + imageIcon[i] = new ImageIcon(url); + } } - } + } + 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) { + } + } } + } + class BlastThread extends Thread { + String sequence; + String seqid; + String jobid; + boolean jobComplete = false; - } + BlastThread(String id, String sequence) { + this.sequence = sequence; + seqid = id; + } - output.setText(output.getText()+buffer.toString()); - } + public void run() { + StartJob(); + + 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[] { + jobid, "xml" + }); + if ((result.indexOf("JOB PENDING") == -1) && + (result.indexOf("JOB RUNNING") == -1)) { + parseResult(seqid, result); + jobComplete = true; + jobsRunning--; + } + + Thread.sleep(5000); + + // System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug + } catch (Exception ex) { + } + } + } + + void StartJob() { + HashMap params = new HashMap(); + params.put("database", "uniprot"); + params.put("sensitivity", "low"); + params.put("sort", "totalscore"); + params.put("matrix", "pam10"); + params.put("program", "blastp"); + params.put("alignments", "5"); + params.put("outformat", "xml"); + params.put("searchtype", "1"); + + byte[] seqbytes = sequence.getBytes(); + + 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[] { + params, seqbytes + }); + jobid = result; + System.out.println( + "http://www.ebi.ac.uk/cgi-bin/webservices/WSWUBlast JobId '" + + jobid + "'"); + } 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 58c8029..a401b6e 100755 --- a/src/jalview/jbappletgui/GAlignFrame.java +++ b/src/jalview/jbappletgui/GAlignFrame.java @@ -16,1110 +16,816 @@ * 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.jbappletgui; -import java.awt.event.*; import java.awt.*; - -public class GAlignFrame extends Frame -{ - protected MenuBar alignFrameMenuBar = new MenuBar(); - protected Menu fileMenu = new Menu(); - protected MenuItem closeMenuItem = new MenuItem(); - protected Menu editMenu = new Menu(); - protected Menu viewMenu = new Menu(); - protected Menu colourMenu = new Menu(); - protected Menu calculateMenu = new Menu(); - protected MenuItem selectAllSequenceMenuItem = new MenuItem(); - protected MenuItem deselectAllSequenceMenuItem = new MenuItem(); - protected MenuItem invertSequenceMenuItem = new MenuItem(); - protected MenuItem remove2LeftMenuItem = new MenuItem(); - protected MenuItem remove2RightMenuItem = new MenuItem(); - protected MenuItem removeGappedColumnMenuItem = new MenuItem(); - protected MenuItem removeAllGapsMenuItem = new MenuItem(); - protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); - protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); - protected MenuItem sortPairwiseMenuItem = new MenuItem(); - protected MenuItem sortIDMenuItem = new MenuItem(); - protected MenuItem sortGroupMenuItem = new MenuItem(); - protected MenuItem removeRedundancyMenuItem = new MenuItem(); - protected MenuItem pairwiseAlignmentMenuItem = new MenuItem(); - protected MenuItem PCAMenuItem = new MenuItem(); - protected MenuItem averageDistanceTreeMenuItem = new MenuItem(); - protected MenuItem neighbourTreeMenuItem = new MenuItem(); - BorderLayout borderLayout1 = new BorderLayout(); - public Label statusBar = new Label(); - protected Menu outputTextboxMenu = new Menu(); - protected MenuItem clustalColour = new MenuItem(); - protected MenuItem zappoColour = new MenuItem(); - protected MenuItem taylorColour = new MenuItem(); - protected MenuItem hydrophobicityColour = new MenuItem(); - protected MenuItem helixColour = new MenuItem(); - protected MenuItem strandColour = new MenuItem(); - protected MenuItem turnColour = new MenuItem(); - protected MenuItem buriedColour = new MenuItem(); - protected MenuItem userDefinedColour = new MenuItem(); - protected MenuItem PIDColour = new MenuItem(); - protected MenuItem BLOSUM62Colour = new MenuItem(); - MenuItem njTreeBlosumMenuItem = new MenuItem(); - MenuItem avDistanceTreeBlosumMenuItem = new MenuItem(); - protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); - protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); - MenuItem overviewMenuItem = new MenuItem(); - protected MenuItem undoMenuItem = new MenuItem(); - protected MenuItem redoMenuItem = new MenuItem(); - protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); - MenuItem noColourmenuItem = new MenuItem(); - protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); - protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); - MenuItem findMenuItem = new MenuItem(); - Menu searchMenu = new Menu(); - protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem(); - protected MenuItem nucleotideColour = new MenuItem(); - MenuItem deleteGroups = new MenuItem(); - MenuItem delete = new MenuItem(); - MenuItem copy = new MenuItem(); - MenuItem cut = new MenuItem(); - Menu Menu1 = new Menu(); - MenuItem pasteNew = new MenuItem(); - MenuItem pasteThis = new MenuItem(); - protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); - protected MenuItem font = new MenuItem(); - protected CheckboxMenuItem fullSeqId = new CheckboxMenuItem(); - protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); - protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); - protected CheckboxMenuItem scaleRight = new CheckboxMenuItem(); - MenuItem modifyPID = new MenuItem(); - MenuItem modifyConservation = new MenuItem(); - protected Menu sortByTreeMenu = new Menu(); - Menu sort = new Menu(); - Menu calculate = new Menu(); - MenuItem inputText = new MenuItem(); - Menu helpMenu = new Menu(); - MenuItem documentation = new MenuItem(); - MenuItem about = new MenuItem(); - public GAlignFrame() - { - try - { - jbInit(); - setMenuBar(alignFrameMenuBar); - - MenuItem item; - // dynamically fill save as menu with available formats - for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++) { - item = new MenuItem((String) jalview.io.FormatAdapter.formats.elementAt(i)); - item.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - saveAs_actionPerformed(e); - } - }); - - item = new MenuItem((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.setLabel("File"); - closeMenuItem.setLabel("Close"); - closeMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - closeMenuItem_actionPerformed(e); - } - }); - editMenu.setLabel("Edit"); - viewMenu.setLabel("View"); - colourMenu.setLabel("Colour"); - calculateMenu.setLabel("Calculate"); - selectAllSequenceMenuItem.setLabel("Select all"); - selectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - selectAllSequenceMenuItem_actionPerformed(e); - } - }); - deselectAllSequenceMenuItem.setLabel("Deselect All"); - deselectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - deselectAllSequenceMenuItem_actionPerformed(e); - } - }); - invertSequenceMenuItem.setLabel("Invert Selection"); - invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - invertSequenceMenuItem_actionPerformed(e); - } - }); - remove2LeftMenuItem.setLabel("Remove Left"); - remove2LeftMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - remove2LeftMenuItem_actionPerformed(e); - } - }); - remove2RightMenuItem.setLabel("Remove Right"); - remove2RightMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - remove2RightMenuItem_actionPerformed(e); - } - }); - removeGappedColumnMenuItem.setLabel("Remove Empty Columns"); - removeGappedColumnMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - removeGappedColumnMenuItem_actionPerformed(e); - } - }); - removeAllGapsMenuItem.setLabel("Remove All Gaps"); - removeAllGapsMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - removeAllGapsMenuItem_actionPerformed(e); - } - }); - viewBoxesMenuItem.setLabel("Boxes"); - viewBoxesMenuItem.setState(true); - viewBoxesMenuItem.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - viewBoxesMenuItem_actionPerformed(null); - } - }); - viewTextMenuItem.setLabel("Text"); - viewTextMenuItem.setState(true); - viewTextMenuItem.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - viewTextMenuItem_actionPerformed(null); - } - }); - sortPairwiseMenuItem.setLabel("by Pairwise Identity"); - sortPairwiseMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - sortPairwiseMenuItem_actionPerformed(e); - } - }); - sortIDMenuItem.setLabel("by ID"); - sortIDMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - sortIDMenuItem_actionPerformed(e); - } - }); - sortGroupMenuItem.setLabel("by Group"); - sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - sortGroupMenuItem_actionPerformed(e); - } - }); - removeRedundancyMenuItem.setLabel("Remove Redundancy..."); - removeRedundancyMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - removeRedundancyMenuItem_actionPerformed(e); - } - }); - pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments..."); - pairwiseAlignmentMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - pairwiseAlignmentMenuItem_actionPerformed(e); - } - }); - 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..."); - averageDistanceTreeMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - averageDistanceTreeMenuItem_actionPerformed(e); - } - }); - neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity..."); - neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - neighbourTreeMenuItem_actionPerformed(e); - } - }); - alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11)); - statusBar.setBackground(Color.white); - statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); - statusBar.setText("Status bar"); - outputTextboxMenu.setLabel("Output to Textbox"); - clustalColour.setLabel("Clustalx"); - - clustalColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - clustalColour_actionPerformed(e); - } - }); - zappoColour.setLabel("Zappo"); - zappoColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - zappoColour_actionPerformed(e); - } - }); - taylorColour.setLabel("Taylor"); - taylorColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - taylorColour_actionPerformed(e); - } - }); - hydrophobicityColour.setLabel("Hydrophobicity"); - hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - hydrophobicityColour_actionPerformed(e); - } - }); - helixColour.setLabel("Helix Propensity"); - helixColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - helixColour_actionPerformed(e); - } - }); - strandColour.setLabel("Strand Propensity"); - strandColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - strandColour_actionPerformed(e); - } - }); - turnColour.setLabel("Turn Propensity"); - turnColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - turnColour_actionPerformed(e); - } - }); - buriedColour.setLabel("Buried Index"); - buriedColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - buriedColour_actionPerformed(e); - } - }); - userDefinedColour.setLabel("User Defined..."); - userDefinedColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - userDefinedColour_actionPerformed(e); - } - }); - PIDColour.setLabel("Percentage Identity"); - PIDColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - PIDColour_actionPerformed(e); - } - }); - BLOSUM62Colour.setLabel("BLOSUM62 Score"); - BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - BLOSUM62Colour_actionPerformed(e); - } - }); - avDistanceTreeBlosumMenuItem.setLabel("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.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - njTreeBlosumMenuItem_actionPerformed(e); - } - }); - annotationPanelMenuItem.setActionCommand(""); - annotationPanelMenuItem.setState(true); - annotationPanelMenuItem.setLabel("Show Annotations"); - annotationPanelMenuItem.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - annotationPanelMenuItem_actionPerformed(null); - } - }); - colourTextMenuItem.setLabel("Colour Text"); - colourTextMenuItem.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - colourTextMenuItem_actionPerformed(null); - } - }); - overviewMenuItem.setLabel("Overview Window..."); - overviewMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - overviewMenuItem_actionPerformed(e); - } - }); - undoMenuItem.setEnabled(false); - undoMenuItem.setLabel("Undo"); - undoMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - undoMenuItem_actionPerformed(e); - } - }); - redoMenuItem.setEnabled(false); - redoMenuItem.setLabel("Redo"); - redoMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - redoMenuItem_actionPerformed(e); - } - }); - conservationMenuItem.setLabel("by Conservation"); - conservationMenuItem.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - conservationMenuItem_actionPerformed(null); - } - }); - noColourmenuItem.setLabel("None"); - noColourmenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - noColourmenuItem_actionPerformed(e); - } - }); - wrapMenuItem.setLabel("Wrap"); - wrapMenuItem.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - wrapMenuItem_actionPerformed(null); - } - }); - renderGapsMenuItem.setLabel("Show Gaps"); - renderGapsMenuItem.setState(true); - renderGapsMenuItem.addItemListener(new java.awt.event.ItemListener() - { - - public void itemStateChanged(ItemEvent e) - { - - renderGapsMenuItem_actionPerformed(null); - } - }); - findMenuItem.setLabel("Find..."); - findMenuItem.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - findMenuItem_actionPerformed(e); - } - }); - searchMenu.setLabel("Search"); - - abovePIDThreshold.setLabel("Above Identity Threshold"); - abovePIDThreshold.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - abovePIDThreshold_actionPerformed(null); - } - }); - nucleotideColour.setLabel("Nucleotide"); - nucleotideColour.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - nucleotideColour_actionPerformed(e); - } - }); - deleteGroups.setLabel("Undefine Groups"); - deleteGroups.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - deleteGroups_actionPerformed(e); - } - }); - copy.setLabel("Copy"); - copy.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - copy_actionPerformed(e); - } - }); - cut.setLabel("Cut"); - cut.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - cut_actionPerformed(e); - } - }); - delete.setLabel("Delete"); - delete.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - delete_actionPerformed(e); - } - }); - Menu1.setLabel("Paste"); - pasteNew.setLabel("To New Alignment"); - pasteNew.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - pasteNew_actionPerformed(e); - } - }); - pasteThis.setLabel("Add To This Alignment"); - pasteThis.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - pasteThis_actionPerformed(e); - } - }); - applyToAllGroups.setLabel("Apply Colour To All Groups"); - applyToAllGroups.setState(true); - applyToAllGroups.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - applyToAllGroups_actionPerformed(null); - } - }); - font.setLabel("Font..."); - font.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - font_actionPerformed(e); - } - }); - fullSeqId.setLabel("Show Full Sequence ID"); - fullSeqId.setState(true); - fullSeqId.addItemListener(new java.awt.event.ItemListener() - { - - public void itemStateChanged(ItemEvent e) - { - fullSeqId_actionPerformed(null); - } - }); - scaleAbove.setLabel("Scale Above"); - scaleAbove.setState(true); - scaleAbove.addItemListener(new java.awt.event.ItemListener() - { - - public void itemStateChanged(ItemEvent e) - { - - scaleAbove_actionPerformed(null); - } - }); - scaleLeft.setEnabled(false); - scaleLeft.setState(true); - scaleLeft.setLabel("Scale Left"); - scaleLeft.addItemListener(new java.awt.event.ItemListener() - { - - public void itemStateChanged(ItemEvent e) - { - - scaleLeft_actionPerformed(null); - } - }); - scaleRight.setEnabled(false); - scaleRight.setState(true); - scaleRight.setLabel("Scale Right"); - scaleRight.addItemListener(new java.awt.event.ItemListener() - { - - public void itemStateChanged(ItemEvent e) - { - - scaleRight_actionPerformed(null); - } - }); - modifyPID.setLabel("Modify Identity Threshold..."); - modifyPID.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - modifyPID_actionPerformed(e); - } - }); - modifyConservation.setLabel("Modify Conservation Threshold..."); - modifyConservation.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - modifyConservation_actionPerformed(e); - } - }); - sortByTreeMenu.setLabel("By Tree Order"); - sort.setLabel("Sort"); - calculate.setLabel("Calculate Tree"); - inputText.setLabel("Input from textbox"); - inputText.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - inputText_actionPerformed(e); - } - }); - - helpMenu.setLabel("Help"); - documentation.setLabel("Documentation"); - documentation.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - documentation_actionPerformed(e); - } - }); - - about.setLabel("About..."); - about.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - about_actionPerformed(e); - } - }); - - alignFrameMenuBar.add(fileMenu); - alignFrameMenuBar.add(editMenu); - alignFrameMenuBar.add(searchMenu); - alignFrameMenuBar.add(viewMenu); - alignFrameMenuBar.add(colourMenu); - alignFrameMenuBar.add(calculateMenu); - alignFrameMenuBar.add(helpMenu); - fileMenu.add(inputText); - fileMenu.add(outputTextboxMenu); - fileMenu.addSeparator(); - fileMenu.add(closeMenuItem); - editMenu.add(undoMenuItem); - editMenu.add(redoMenuItem); - editMenu.add(cut); - editMenu.add(copy); - editMenu.add(Menu1); - 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); - searchMenu.add(findMenuItem); - viewMenu.add(font); - viewMenu.addSeparator(); - viewMenu.add(wrapMenuItem); - viewMenu.add(scaleAbove); - viewMenu.add(scaleLeft); - viewMenu.add(scaleRight); - viewMenu.addSeparator(); - viewMenu.add(fullSeqId); - viewMenu.add(viewBoxesMenuItem); - viewMenu.add(viewTextMenuItem); - viewMenu.add(colourTextMenuItem); - viewMenu.add(renderGapsMenuItem); - viewMenu.add(annotationPanelMenuItem); - 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); - this.add(statusBar, BorderLayout.SOUTH); - Menu1.add(pasteNew); - Menu1.add(pasteThis); - sort.add(sortIDMenuItem); - sort.add(sortByTreeMenu); - sort.add(sortGroupMenuItem); - sort.add(sortPairwiseMenuItem); - calculate.add(averageDistanceTreeMenuItem); - calculate.add(neighbourTreeMenuItem); - calculate.add(avDistanceTreeBlosumMenuItem); - calculate.add(njTreeBlosumMenuItem); - helpMenu.add(documentation); - helpMenu.add(about); - } - - protected void saveAs_actionPerformed(ActionEvent e) - { - - } - - 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 averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) - { - - } - - protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e) - { - - } - - - protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) - { - - } - - protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) - { - - } - - - - protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) - { - - } - - - - - protected void clustalColour_actionPerformed(ActionEvent e) - { - - } - - protected void zappoColour_actionPerformed(ActionEvent e) - { - - } - - protected void taylorColour_actionPerformed(ActionEvent e) - { - - } - - - protected void hydrophobicityColour_actionPerformed(ActionEvent e) - { - - } - - protected void helixColour_actionPerformed(ActionEvent e) - { - - } - - protected void strandColour_actionPerformed(ActionEvent e) - { - - } - - protected void turnColour_actionPerformed(ActionEvent e) - { - - } - - protected void buriedColour_actionPerformed(ActionEvent e) - { - - } - +import java.awt.event.*; - protected void userDefinedColour_actionPerformed(ActionEvent e) - { +public class GAlignFrame extends Frame { + protected MenuBar alignFrameMenuBar = new MenuBar(); + protected Menu fileMenu = new Menu(); + protected MenuItem closeMenuItem = new MenuItem(); + protected Menu editMenu = new Menu(); + protected Menu viewMenu = new Menu(); + protected Menu colourMenu = new Menu(); + protected Menu calculateMenu = new Menu(); + protected MenuItem selectAllSequenceMenuItem = new MenuItem(); + protected MenuItem deselectAllSequenceMenuItem = new MenuItem(); + protected MenuItem invertSequenceMenuItem = new MenuItem(); + protected MenuItem remove2LeftMenuItem = new MenuItem(); + protected MenuItem remove2RightMenuItem = new MenuItem(); + protected MenuItem removeGappedColumnMenuItem = new MenuItem(); + protected MenuItem removeAllGapsMenuItem = new MenuItem(); + protected CheckboxMenuItem viewBoxesMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem viewTextMenuItem = new CheckboxMenuItem(); + protected MenuItem sortPairwiseMenuItem = new MenuItem(); + protected MenuItem sortIDMenuItem = new MenuItem(); + protected MenuItem sortGroupMenuItem = new MenuItem(); + protected MenuItem removeRedundancyMenuItem = new MenuItem(); + protected MenuItem pairwiseAlignmentMenuItem = new MenuItem(); + protected MenuItem PCAMenuItem = new MenuItem(); + protected MenuItem averageDistanceTreeMenuItem = new MenuItem(); + protected MenuItem neighbourTreeMenuItem = new MenuItem(); + BorderLayout borderLayout1 = new BorderLayout(); + public Label statusBar = new Label(); + protected Menu outputTextboxMenu = new Menu(); + protected MenuItem clustalColour = new MenuItem(); + protected MenuItem zappoColour = new MenuItem(); + protected MenuItem taylorColour = new MenuItem(); + protected MenuItem hydrophobicityColour = new MenuItem(); + protected MenuItem helixColour = new MenuItem(); + protected MenuItem strandColour = new MenuItem(); + protected MenuItem turnColour = new MenuItem(); + protected MenuItem buriedColour = new MenuItem(); + protected MenuItem userDefinedColour = new MenuItem(); + protected MenuItem PIDColour = new MenuItem(); + protected MenuItem BLOSUM62Colour = new MenuItem(); + MenuItem njTreeBlosumMenuItem = new MenuItem(); + MenuItem avDistanceTreeBlosumMenuItem = new MenuItem(); + protected CheckboxMenuItem annotationPanelMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem colourTextMenuItem = new CheckboxMenuItem(); + MenuItem overviewMenuItem = new MenuItem(); + protected MenuItem undoMenuItem = new MenuItem(); + protected MenuItem redoMenuItem = new MenuItem(); + protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem(); + MenuItem noColourmenuItem = new MenuItem(); + protected CheckboxMenuItem wrapMenuItem = new CheckboxMenuItem(); + protected CheckboxMenuItem renderGapsMenuItem = new CheckboxMenuItem(); + MenuItem findMenuItem = new MenuItem(); + Menu searchMenu = new Menu(); + protected CheckboxMenuItem abovePIDThreshold = new CheckboxMenuItem(); + protected MenuItem nucleotideColour = new MenuItem(); + MenuItem deleteGroups = new MenuItem(); + MenuItem delete = new MenuItem(); + MenuItem copy = new MenuItem(); + MenuItem cut = new MenuItem(); + Menu Menu1 = new Menu(); + MenuItem pasteNew = new MenuItem(); + MenuItem pasteThis = new MenuItem(); + protected CheckboxMenuItem applyToAllGroups = new CheckboxMenuItem(); + protected MenuItem font = new MenuItem(); + protected CheckboxMenuItem fullSeqId = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleAbove = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleLeft = new CheckboxMenuItem(); + protected CheckboxMenuItem scaleRight = new CheckboxMenuItem(); + MenuItem modifyPID = new MenuItem(); + MenuItem modifyConservation = new MenuItem(); + protected Menu sortByTreeMenu = new Menu(); + Menu sort = new Menu(); + Menu calculate = new Menu(); + MenuItem inputText = new MenuItem(); + Menu helpMenu = new Menu(); + MenuItem documentation = new MenuItem(); + MenuItem about = new MenuItem(); + + public GAlignFrame() { + try { + jbInit(); + setMenuBar(alignFrameMenuBar); + + MenuItem item; + + // dynamically fill save as menu with available formats + for (int i = 0; i < jalview.io.FormatAdapter.formats.size(); i++) { + item = new MenuItem((String) jalview.io.FormatAdapter.formats.elementAt( + i)); + item.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + saveAs_actionPerformed(e); + } + }); + + item = new MenuItem((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.setLabel("File"); + closeMenuItem.setLabel("Close"); + closeMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + closeMenuItem_actionPerformed(e); + } + }); + editMenu.setLabel("Edit"); + viewMenu.setLabel("View"); + colourMenu.setLabel("Colour"); + calculateMenu.setLabel("Calculate"); + selectAllSequenceMenuItem.setLabel("Select all"); + selectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + selectAllSequenceMenuItem_actionPerformed(e); + } + }); + deselectAllSequenceMenuItem.setLabel("Deselect All"); + deselectAllSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + deselectAllSequenceMenuItem_actionPerformed(e); + } + }); + invertSequenceMenuItem.setLabel("Invert Selection"); + invertSequenceMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + invertSequenceMenuItem_actionPerformed(e); + } + }); + remove2LeftMenuItem.setLabel("Remove Left"); + remove2LeftMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + remove2LeftMenuItem_actionPerformed(e); + } + }); + remove2RightMenuItem.setLabel("Remove Right"); + remove2RightMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + remove2RightMenuItem_actionPerformed(e); + } + }); + removeGappedColumnMenuItem.setLabel("Remove Empty Columns"); + removeGappedColumnMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + removeGappedColumnMenuItem_actionPerformed(e); + } + }); + removeAllGapsMenuItem.setLabel("Remove All Gaps"); + removeAllGapsMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + removeAllGapsMenuItem_actionPerformed(e); + } + }); + viewBoxesMenuItem.setLabel("Boxes"); + viewBoxesMenuItem.setState(true); + viewBoxesMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + viewBoxesMenuItem_actionPerformed(null); + } + }); + viewTextMenuItem.setLabel("Text"); + viewTextMenuItem.setState(true); + viewTextMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + viewTextMenuItem_actionPerformed(null); + } + }); + sortPairwiseMenuItem.setLabel("by Pairwise Identity"); + sortPairwiseMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + sortPairwiseMenuItem_actionPerformed(e); + } + }); + sortIDMenuItem.setLabel("by ID"); + sortIDMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + sortIDMenuItem_actionPerformed(e); + } + }); + sortGroupMenuItem.setLabel("by Group"); + sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + sortGroupMenuItem_actionPerformed(e); + } + }); + removeRedundancyMenuItem.setLabel("Remove Redundancy..."); + removeRedundancyMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + removeRedundancyMenuItem_actionPerformed(e); + } + }); + pairwiseAlignmentMenuItem.setLabel("Pairwise Alignments..."); + pairwiseAlignmentMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + pairwiseAlignmentMenuItem_actionPerformed(e); + } + }); + 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..."); + averageDistanceTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + averageDistanceTreeMenuItem_actionPerformed(e); + } + }); + neighbourTreeMenuItem.setLabel("Neighbour Joining Using % Identity..."); + neighbourTreeMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + neighbourTreeMenuItem_actionPerformed(e); + } + }); + alignFrameMenuBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setBackground(Color.white); + statusBar.setFont(new java.awt.Font("Verdana", 0, 11)); + statusBar.setText("Status bar"); + outputTextboxMenu.setLabel("Output to Textbox"); + clustalColour.setLabel("Clustalx"); + + clustalColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + clustalColour_actionPerformed(e); + } + }); + zappoColour.setLabel("Zappo"); + zappoColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + zappoColour_actionPerformed(e); + } + }); + taylorColour.setLabel("Taylor"); + taylorColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + taylorColour_actionPerformed(e); + } + }); + hydrophobicityColour.setLabel("Hydrophobicity"); + hydrophobicityColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + hydrophobicityColour_actionPerformed(e); + } + }); + helixColour.setLabel("Helix Propensity"); + helixColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + helixColour_actionPerformed(e); + } + }); + strandColour.setLabel("Strand Propensity"); + strandColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + strandColour_actionPerformed(e); + } + }); + turnColour.setLabel("Turn Propensity"); + turnColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + turnColour_actionPerformed(e); + } + }); + buriedColour.setLabel("Buried Index"); + buriedColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + buriedColour_actionPerformed(e); + } + }); + userDefinedColour.setLabel("User Defined..."); + userDefinedColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + userDefinedColour_actionPerformed(e); + } + }); + PIDColour.setLabel("Percentage Identity"); + PIDColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + PIDColour_actionPerformed(e); + } + }); + BLOSUM62Colour.setLabel("BLOSUM62 Score"); + BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + BLOSUM62Colour_actionPerformed(e); + } + }); + avDistanceTreeBlosumMenuItem.setLabel( + "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.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + njTreeBlosumMenuItem_actionPerformed(e); + } + }); + annotationPanelMenuItem.setActionCommand(""); + annotationPanelMenuItem.setState(true); + annotationPanelMenuItem.setLabel("Show Annotations"); + annotationPanelMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + annotationPanelMenuItem_actionPerformed(null); + } + }); + colourTextMenuItem.setLabel("Colour Text"); + colourTextMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + colourTextMenuItem_actionPerformed(null); + } + }); + overviewMenuItem.setLabel("Overview Window..."); + overviewMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + overviewMenuItem_actionPerformed(e); + } + }); + undoMenuItem.setEnabled(false); + undoMenuItem.setLabel("Undo"); + undoMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + undoMenuItem_actionPerformed(e); + } + }); + redoMenuItem.setEnabled(false); + redoMenuItem.setLabel("Redo"); + redoMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + redoMenuItem_actionPerformed(e); + } + }); + conservationMenuItem.setLabel("by Conservation"); + conservationMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + conservationMenuItem_actionPerformed(null); + } + }); + noColourmenuItem.setLabel("None"); + noColourmenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + noColourmenuItem_actionPerformed(e); + } + }); + wrapMenuItem.setLabel("Wrap"); + wrapMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + wrapMenuItem_actionPerformed(null); + } + }); + renderGapsMenuItem.setLabel("Show Gaps"); + renderGapsMenuItem.setState(true); + renderGapsMenuItem.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + renderGapsMenuItem_actionPerformed(null); + } + }); + findMenuItem.setLabel("Find..."); + findMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + findMenuItem_actionPerformed(e); + } + }); + searchMenu.setLabel("Search"); + + abovePIDThreshold.setLabel("Above Identity Threshold"); + abovePIDThreshold.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + abovePIDThreshold_actionPerformed(null); + } + }); + nucleotideColour.setLabel("Nucleotide"); + nucleotideColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + nucleotideColour_actionPerformed(e); + } + }); + deleteGroups.setLabel("Undefine Groups"); + deleteGroups.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + deleteGroups_actionPerformed(e); + } + }); + copy.setLabel("Copy"); + copy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + copy_actionPerformed(e); + } + }); + cut.setLabel("Cut"); + cut.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cut_actionPerformed(e); + } + }); + delete.setLabel("Delete"); + delete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + delete_actionPerformed(e); + } + }); + Menu1.setLabel("Paste"); + pasteNew.setLabel("To New Alignment"); + pasteNew.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + pasteNew_actionPerformed(e); + } + }); + pasteThis.setLabel("Add To This Alignment"); + pasteThis.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + pasteThis_actionPerformed(e); + } + }); + applyToAllGroups.setLabel("Apply Colour To All Groups"); + applyToAllGroups.setState(true); + applyToAllGroups.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + applyToAllGroups_actionPerformed(null); + } + }); + font.setLabel("Font..."); + font.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + font_actionPerformed(e); + } + }); + fullSeqId.setLabel("Show Full Sequence ID"); + fullSeqId.setState(true); + fullSeqId.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fullSeqId_actionPerformed(null); + } + }); + scaleAbove.setLabel("Scale Above"); + scaleAbove.setState(true); + scaleAbove.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + scaleAbove_actionPerformed(null); + } + }); + scaleLeft.setEnabled(false); + scaleLeft.setState(true); + scaleLeft.setLabel("Scale Left"); + scaleLeft.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + scaleLeft_actionPerformed(null); + } + }); + scaleRight.setEnabled(false); + scaleRight.setState(true); + scaleRight.setLabel("Scale Right"); + scaleRight.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + scaleRight_actionPerformed(null); + } + }); + modifyPID.setLabel("Modify Identity Threshold..."); + modifyPID.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + modifyPID_actionPerformed(e); + } + }); + modifyConservation.setLabel("Modify Conservation Threshold..."); + modifyConservation.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + modifyConservation_actionPerformed(e); + } + }); + sortByTreeMenu.setLabel("By Tree Order"); + sort.setLabel("Sort"); + calculate.setLabel("Calculate Tree"); + inputText.setLabel("Input from textbox"); + inputText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + inputText_actionPerformed(e); + } + }); + + helpMenu.setLabel("Help"); + documentation.setLabel("Documentation"); + documentation.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + documentation_actionPerformed(e); + } + }); + + about.setLabel("About..."); + about.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + about_actionPerformed(e); + } + }); + + alignFrameMenuBar.add(fileMenu); + alignFrameMenuBar.add(editMenu); + alignFrameMenuBar.add(searchMenu); + alignFrameMenuBar.add(viewMenu); + alignFrameMenuBar.add(colourMenu); + alignFrameMenuBar.add(calculateMenu); + alignFrameMenuBar.add(helpMenu); + fileMenu.add(inputText); + fileMenu.add(outputTextboxMenu); + fileMenu.addSeparator(); + fileMenu.add(closeMenuItem); + editMenu.add(undoMenuItem); + editMenu.add(redoMenuItem); + editMenu.add(cut); + editMenu.add(copy); + editMenu.add(Menu1); + 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); + searchMenu.add(findMenuItem); + viewMenu.add(font); + viewMenu.addSeparator(); + viewMenu.add(wrapMenuItem); + viewMenu.add(scaleAbove); + viewMenu.add(scaleLeft); + viewMenu.add(scaleRight); + viewMenu.addSeparator(); + viewMenu.add(fullSeqId); + viewMenu.add(viewBoxesMenuItem); + viewMenu.add(viewTextMenuItem); + viewMenu.add(colourTextMenuItem); + viewMenu.add(renderGapsMenuItem); + viewMenu.add(annotationPanelMenuItem); + 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); + this.add(statusBar, BorderLayout.SOUTH); + Menu1.add(pasteNew); + Menu1.add(pasteThis); + sort.add(sortIDMenuItem); + sort.add(sortByTreeMenu); + sort.add(sortGroupMenuItem); + sort.add(sortPairwiseMenuItem); + calculate.add(averageDistanceTreeMenuItem); + calculate.add(neighbourTreeMenuItem); + calculate.add(avDistanceTreeBlosumMenuItem); + calculate.add(njTreeBlosumMenuItem); + helpMenu.add(documentation); + helpMenu.add(about); + } - protected void PIDColour_actionPerformed(ActionEvent e) - { + protected void saveAs_actionPerformed(ActionEvent e) { + } - } + protected void outputText_actionPerformed(ActionEvent e) { + } - protected void BLOSUM62Colour_actionPerformed(ActionEvent e) - { + protected void htmlMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void closeMenuItem_actionPerformed(ActionEvent e) { + } + protected void redoMenuItem_actionPerformed(ActionEvent e) { + } - protected void noColourmenuItem_actionPerformed(ActionEvent e) - { + protected void undoMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) { + } - protected void conservationMenuItem_actionPerformed(ActionEvent e) - { + protected void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void invertSequenceMenuItem_actionPerformed(ActionEvent e) { + } + protected void remove2LeftMenuItem_actionPerformed(ActionEvent e) { + } - protected void printMenuItem_actionPerformed(ActionEvent e) - { + protected void remove2RightMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) { + } - protected void renderGapsMenuItem_actionPerformed(ActionEvent e) - { + protected void removeAllGapsMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void wrapMenuItem_actionPerformed(ActionEvent e) { + } - protected void findMenuItem_actionPerformed(ActionEvent e) - { + protected void viewBoxesMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void viewTextMenuItem_actionPerformed(ActionEvent e) { + } + protected void colourTextMenuItem_actionPerformed(ActionEvent e) { + } - protected void abovePIDThreshold_actionPerformed(ActionEvent e) { + protected void annotationPanelMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void overviewMenuItem_actionPerformed(ActionEvent e) { + } - public void sequenceFeatures_actionPerformed(ActionEvent actionEvent) - { + protected void sortPairwiseMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void sortIDMenuItem_actionPerformed(ActionEvent e) { + } - protected void nucleotideColour_actionPerformed(ActionEvent e) - { + protected void sortGroupMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e) { + } - protected void deleteGroups_actionPerformed(ActionEvent e) - { + protected void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void PCAMenuItem_actionPerformed(ActionEvent e) { + } - protected void copy_actionPerformed(ActionEvent e) - { + protected void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e) { + } + protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) { + } - protected void cut_actionPerformed(ActionEvent e) - { + protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) { + } - protected void delete_actionPerformed(ActionEvent e) - { + protected void clustalColour_actionPerformed(ActionEvent e) { + } - } + protected void zappoColour_actionPerformed(ActionEvent e) { + } - protected void pasteNew_actionPerformed(ActionEvent e) - { + protected void taylorColour_actionPerformed(ActionEvent e) { + } - } + protected void hydrophobicityColour_actionPerformed(ActionEvent e) { + } - protected void pasteThis_actionPerformed(ActionEvent e) - { + protected void helixColour_actionPerformed(ActionEvent e) { + } - } + protected void strandColour_actionPerformed(ActionEvent e) { + } - protected void applyToAllGroups_actionPerformed(ActionEvent e) - { + protected void turnColour_actionPerformed(ActionEvent e) { + } - } + protected void buriedColour_actionPerformed(ActionEvent e) { + } - protected void createPNG_actionPerformed(ActionEvent e) - { + protected void userDefinedColour_actionPerformed(ActionEvent e) { + } - } + protected void PIDColour_actionPerformed(ActionEvent e) { + } - protected void font_actionPerformed(ActionEvent e) - { + protected void BLOSUM62Colour_actionPerformed(ActionEvent e) { + } - } + protected void noColourmenuItem_actionPerformed(ActionEvent e) { + } - protected void fullSeqId_actionPerformed(ActionEvent e) - { + protected void conservationMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void printMenuItem_actionPerformed(ActionEvent e) { + } - protected void epsFile_actionPerformed(ActionEvent e) - { + protected void renderGapsMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void findMenuItem_actionPerformed(ActionEvent e) { + } - protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { + protected void abovePIDThreshold_actionPerformed(ActionEvent e) { + } - } + public void sequenceFeatures_actionPerformed(ActionEvent actionEvent) { + } - protected void jpred_actionPerformed(ActionEvent e) - { + protected void nucleotideColour_actionPerformed(ActionEvent e) { + } - } + protected void deleteGroups_actionPerformed(ActionEvent e) { + } - protected void scaleAbove_actionPerformed(ActionEvent e) - { + protected void copy_actionPerformed(ActionEvent e) { + } - } + protected void cut_actionPerformed(ActionEvent e) { + } - protected void scaleLeft_actionPerformed(ActionEvent e) - { + protected void delete_actionPerformed(ActionEvent e) { + } - } + protected void pasteNew_actionPerformed(ActionEvent e) { + } - protected void scaleRight_actionPerformed(ActionEvent e) - { + protected void pasteThis_actionPerformed(ActionEvent e) { + } - } + protected void applyToAllGroups_actionPerformed(ActionEvent e) { + } - protected void modifyPID_actionPerformed(ActionEvent e) - { + protected void createPNG_actionPerformed(ActionEvent e) { + } - } + protected void font_actionPerformed(ActionEvent e) { + } - protected void modifyConservation_actionPerformed(ActionEvent e) - { + protected void fullSeqId_actionPerformed(ActionEvent e) { + } - } + protected void epsFile_actionPerformed(ActionEvent e) { + } - protected void preferences_actionPerformed(ActionEvent e) - { + protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void jpred_actionPerformed(ActionEvent e) { + } - protected void msaAlignMenuItem_actionPerformed(ActionEvent e) { + protected void scaleAbove_actionPerformed(ActionEvent e) { + } - } + protected void scaleLeft_actionPerformed(ActionEvent e) { + } - protected void inputText_actionPerformed(ActionEvent e) { + protected void scaleRight_actionPerformed(ActionEvent e) { + } - } + protected void modifyPID_actionPerformed(ActionEvent e) { + } - protected void documentation_actionPerformed(ActionEvent e) { + protected void modifyConservation_actionPerformed(ActionEvent e) { + } - } + protected void preferences_actionPerformed(ActionEvent e) { + } - protected void about_actionPerformed(ActionEvent e) { + protected void msaAlignMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void inputText_actionPerformed(ActionEvent e) { + } + protected void documentation_actionPerformed(ActionEvent e) { + } + protected void about_actionPerformed(ActionEvent e) { + } } - diff --git a/src/jalview/jbappletgui/GAlignmentPanel.java b/src/jalview/jbappletgui/GAlignmentPanel.java index 272e8df..683c9c1 100755 --- a/src/jalview/jbappletgui/GAlignmentPanel.java +++ b/src/jalview/jbappletgui/GAlignmentPanel.java @@ -16,85 +16,85 @@ * 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.jbappletgui; import java.awt.*; -public class GAlignmentPanel extends Panel -{ - protected Panel sequenceHolderPanel = new Panel(); - protected Scrollbar vscroll = new Scrollbar(); - protected Scrollbar hscroll = new Scrollbar(); - protected Panel seqPanelHolder = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout3 = new BorderLayout(); - protected Panel scalePanelHolder = new Panel(); - protected Panel idPanelHolder = new Panel(); - BorderLayout borderLayout5 = new BorderLayout(); - protected Panel idSpaceFillerPanel1 = new Panel(); - public Panel annotationSpaceFillerHolder = new Panel(); - BorderLayout borderLayout6 = new BorderLayout(); - BorderLayout borderLayout7 = new BorderLayout(); - Panel hscrollHolder = new Panel(); - BorderLayout borderLayout10 = new BorderLayout(); - protected Panel hscrollFillerPanel = new Panel(); - BorderLayout borderLayout11 = new BorderLayout(); - public Panel annotationScroller = new Panel(); - BorderLayout borderLayout4 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - public GAlignmentPanel() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); +public class GAlignmentPanel extends Panel { + protected Panel sequenceHolderPanel = new Panel(); + protected Scrollbar vscroll = new Scrollbar(); + protected Scrollbar hscroll = new Scrollbar(); + protected Panel seqPanelHolder = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + protected Panel scalePanelHolder = new Panel(); + protected Panel idPanelHolder = new Panel(); + BorderLayout borderLayout5 = new BorderLayout(); + protected Panel idSpaceFillerPanel1 = new Panel(); + public Panel annotationSpaceFillerHolder = new Panel(); + BorderLayout borderLayout6 = new BorderLayout(); + BorderLayout borderLayout7 = new BorderLayout(); + Panel hscrollHolder = new Panel(); + BorderLayout borderLayout10 = new BorderLayout(); + protected Panel hscrollFillerPanel = new Panel(); + BorderLayout borderLayout11 = new BorderLayout(); + public Panel annotationScroller = new Panel(); + BorderLayout borderLayout4 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + + public GAlignmentPanel() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - } - private void jbInit() throws Exception - { - // idPanelHolder.setPreferredSize(new Dimension(70, 10)); - this.setLayout(borderLayout7); - // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); - sequenceHolderPanel.setLayout(borderLayout3); - seqPanelHolder.setLayout(borderLayout1); - scalePanelHolder.setBackground(Color.white); - // 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(Scrollbar.HORIZONTAL); - hscrollHolder.setLayout(borderLayout10); - hscrollFillerPanel.setBackground(Color.white); - // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); - hscrollHolder.setBackground(Color.white); - // annotationScroller.setPreferredSize(new Dimension(10, 80)); - // this.setPreferredSize(new Dimension(220, 166)); - seqPanelHolder.setBackground(Color.white); - idPanelHolder.setBackground(Color.white); - annotationScroller.setLayout(borderLayout2); - sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); - sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); - seqPanelHolder.add(vscroll, BorderLayout.EAST); - sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH); - // Panel3.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); - } + private void jbInit() throws Exception { + // idPanelHolder.setPreferredSize(new Dimension(70, 10)); + this.setLayout(borderLayout7); + + // sequenceHolderPanel.setPreferredSize(new Dimension(150, 150)); + sequenceHolderPanel.setLayout(borderLayout3); + seqPanelHolder.setLayout(borderLayout1); + scalePanelHolder.setBackground(Color.white); + + // 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(Scrollbar.HORIZONTAL); + hscrollHolder.setLayout(borderLayout10); + hscrollFillerPanel.setBackground(Color.white); + + // hscrollFillerPanel.setPreferredSize(new Dimension(70, 10)); + hscrollHolder.setBackground(Color.white); + + // annotationScroller.setPreferredSize(new Dimension(10, 80)); + // this.setPreferredSize(new Dimension(220, 166)); + seqPanelHolder.setBackground(Color.white); + idPanelHolder.setBackground(Color.white); + annotationScroller.setLayout(borderLayout2); + sequenceHolderPanel.add(scalePanelHolder, BorderLayout.NORTH); + sequenceHolderPanel.add(seqPanelHolder, BorderLayout.CENTER); + seqPanelHolder.add(vscroll, BorderLayout.EAST); + sequenceHolderPanel.add(annotationScroller, BorderLayout.SOUTH); + + // Panel3.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); + } } diff --git a/src/jalview/jbappletgui/GCutAndPasteTransfer.java b/src/jalview/jbappletgui/GCutAndPasteTransfer.java index 33fe5a6..df702fd 100755 --- a/src/jalview/jbappletgui/GCutAndPasteTransfer.java +++ b/src/jalview/jbappletgui/GCutAndPasteTransfer.java @@ -16,77 +16,63 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GCutAndPasteTransfer extends Panel -{ - protected TextArea textarea = new TextArea(); - Button ok = new Button(); - Button cancel = new Button(); - protected Panel buttonPanel = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); - public GCutAndPasteTransfer() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - - } - private void jbInit() throws Exception - { - textarea.setFont(new java.awt.Font("Verdana", 0, 12)); - textarea.setText("Paste your alignment file here"); - textarea.addMouseListener(new java.awt.event.MouseAdapter() - { - public void mousePressed(MouseEvent e) - { - textarea_mousePressed(e); - } - }); - this.setLayout(borderLayout1); - ok.setLabel("OK"); - ok.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - ok_actionPerformed(e); - } - }); - cancel.setLabel("Cancel"); - cancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - cancel_actionPerformed(e); - } - }); - this.add(buttonPanel, BorderLayout.SOUTH); - buttonPanel.add(ok, null); - buttonPanel.add(cancel, null); - this.add(textarea, java.awt.BorderLayout.CENTER); - } - - - +public class GCutAndPasteTransfer extends Panel { + protected TextArea textarea = new TextArea(); + Button ok = new Button(); + Button cancel = new Button(); + protected Panel buttonPanel = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); - void textarea_mousePressed(MouseEvent e) - { - if(textarea.getText().equals("Paste your alignment file here")) - textarea.setText(""); - } - - protected void ok_actionPerformed(ActionEvent e) { + public GCutAndPasteTransfer() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } - } + private void jbInit() throws Exception { + textarea.setFont(new java.awt.Font("Verdana", 0, 12)); + textarea.setText("Paste your alignment file here"); + textarea.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(MouseEvent e) { + textarea_mousePressed(e); + } + }); + this.setLayout(borderLayout1); + ok.setLabel("OK"); + ok.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + ok_actionPerformed(e); + } + }); + cancel.setLabel("Cancel"); + cancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cancel_actionPerformed(e); + } + }); + this.add(buttonPanel, BorderLayout.SOUTH); + buttonPanel.add(ok, null); + buttonPanel.add(cancel, null); + this.add(textarea, java.awt.BorderLayout.CENTER); + } - protected void cancel_actionPerformed(ActionEvent e) { + void textarea_mousePressed(MouseEvent e) { + if (textarea.getText().equals("Paste your alignment file here")) { + textarea.setText(""); + } + } - } + protected void ok_actionPerformed(ActionEvent e) { + } + protected void cancel_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbappletgui/GFinder.java b/src/jalview/jbappletgui/GFinder.java index 283b28d..434c8ea 100755 --- a/src/jalview/jbappletgui/GFinder.java +++ b/src/jalview/jbappletgui/GFinder.java @@ -16,123 +16,96 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GFinder extends Panel -{ - Label jLabel1 = new Label(); - protected TextField textfield = new TextField(); - protected Button findAll = new Button(); - protected Button findNext = new Button(); - Panel jPanel1 = new Panel(); - GridLayout gridLayout1 = new GridLayout(); - protected Button createNewGroup = new Button(); - - public GFinder() - { - try - { - jbInit(); +public class GFinder extends Panel { + Label jLabel1 = new Label(); + protected TextField textfield = new TextField(); + protected Button findAll = new Button(); + protected Button findNext = new Button(); + Panel jPanel1 = new Panel(); + GridLayout gridLayout1 = new GridLayout(); + protected Button createNewGroup = new Button(); + + public GFinder() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - catch(Exception e) - { - e.printStackTrace(); - } - } - private void jbInit() throws Exception - { - jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); - jLabel1.setText("Find"); - jLabel1.setBounds(new Rectangle(3, 30, 34, 15)); - this.setLayout(null); - textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - textfield.setText(""); - textfield.setBounds(new Rectangle(40, 27, 133, 21)); - textfield.addKeyListener(new java.awt.event.KeyAdapter() - { - public void keyTyped(KeyEvent e) - { - textfield_keyTyped(e); - } - }); - textfield.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - textfield_actionPerformed(e); - } - }); - findAll.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - findAll.setLabel("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", Font.PLAIN, 10)); - findNext.setLabel("Find Next"); - findNext.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - findNext_actionPerformed(e); - } - }); - jPanel1.setBounds(new Rectangle(180, 5, 141, 64)); - jPanel1.setLayout(gridLayout1); - gridLayout1.setHgap(0); - gridLayout1.setRows(3); - gridLayout1.setVgap(2); - createNewGroup.setEnabled(false); - createNewGroup.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - createNewGroup.setLabel("Create new group"); - createNewGroup.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - createNewGroup_actionPerformed(e); - } - }); - jPanel1.add(findNext, null); - jPanel1.add(findAll, null); - jPanel1.add(createNewGroup, null); - this.add(textfield, null); - this.add(jLabel1, null); - this.add(jPanel1, null); - } - - protected void findNext_actionPerformed(ActionEvent e) - { - - } - - protected void findAll_actionPerformed(ActionEvent e) - { - - } + private void jbInit() throws Exception { + jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel1.setText("Find"); + jLabel1.setBounds(new Rectangle(3, 30, 34, 15)); + this.setLayout(null); + textfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + textfield.setText(""); + textfield.setBounds(new Rectangle(40, 27, 133, 21)); + textfield.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(KeyEvent e) { + textfield_keyTyped(e); + } + }); + textfield.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + textfield_actionPerformed(e); + } + }); + findAll.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + findAll.setLabel("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", Font.PLAIN, 10)); + findNext.setLabel("Find Next"); + findNext.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + findNext_actionPerformed(e); + } + }); + jPanel1.setBounds(new Rectangle(180, 5, 141, 64)); + jPanel1.setLayout(gridLayout1); + gridLayout1.setHgap(0); + gridLayout1.setRows(3); + gridLayout1.setVgap(2); + createNewGroup.setEnabled(false); + createNewGroup.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + createNewGroup.setLabel("Create new group"); + createNewGroup.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + createNewGroup_actionPerformed(e); + } + }); + jPanel1.add(findNext, null); + jPanel1.add(findAll, null); + jPanel1.add(createNewGroup, null); + this.add(textfield, null); + this.add(jLabel1, null); + this.add(jPanel1, null); + } - protected void textfield_actionPerformed(ActionEvent e) - { - - } + protected void findNext_actionPerformed(ActionEvent e) { + } - void textfield_keyTyped(KeyEvent e) - { - findNext.setEnabled(true); - } + protected void findAll_actionPerformed(ActionEvent e) { + } - public void createNewGroup_actionPerformed(ActionEvent e) - { + protected void textfield_actionPerformed(ActionEvent e) { + } - } + void textfield_keyTyped(KeyEvent e) { + findNext.setEnabled(true); + } + public void createNewGroup_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbappletgui/GFontChooser.java b/src/jalview/jbappletgui/GFontChooser.java index 1c087c5..794dbbb 100755 --- a/src/jalview/jbappletgui/GFontChooser.java +++ b/src/jalview/jbappletgui/GFontChooser.java @@ -16,146 +16,118 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GFontChooser extends Panel -{ - Label label1 = new Label(); - protected Choice fontSize = new Choice(); - protected Choice fontStyle = new Choice(); - Label label2 = new Label(); - Label label3 = new Label(); - protected Choice fontName = new Choice(); - Button ok = new Button(); - Button cancel = new Button(); - Panel panel1 = new Panel(); - Panel panel2 = new Panel(); - Panel panel3 = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - BorderLayout borderLayout3 = new BorderLayout(); - Panel panel4 = new Panel(); - Panel panel5 = new Panel(); - BorderLayout borderLayout4 = new BorderLayout(); - - public GFontChooser() - { - try - { - jbInit(); +public class GFontChooser extends Panel { + Label label1 = new Label(); + protected Choice fontSize = new Choice(); + protected Choice fontStyle = new Choice(); + Label label2 = new Label(); + Label label3 = new Label(); + protected Choice fontName = new Choice(); + Button ok = new Button(); + Button cancel = new Button(); + Panel panel1 = new Panel(); + Panel panel2 = new Panel(); + Panel panel3 = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + Panel panel4 = new Panel(); + Panel panel5 = new Panel(); + BorderLayout borderLayout4 = new BorderLayout(); + + public GFontChooser() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - catch(Exception e) - { - e.printStackTrace(); - } - } - private void jbInit() throws Exception - { - label1.setFont(new java.awt.Font("Verdana", 0, 11)); - label1.setAlignment(Label.RIGHT); - label1.setText("Font: "); - this.setLayout(borderLayout4); - fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); - fontSize.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - fontSize_actionPerformed(); - } - }); - fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); - fontStyle.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - fontStyle_actionPerformed(); - } - }); - label2.setAlignment(Label.RIGHT); - label2.setFont(new java.awt.Font("Verdana", 0, 11)); - label2.setText("Size: "); - label3.setAlignment(Label.RIGHT); - label3.setFont(new java.awt.Font("Verdana", 0, 11)); - label3.setText("Style: "); - fontName.setFont(new java.awt.Font("Verdana", 0, 11)); - fontName.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - fontName_actionPerformed(); - } - }); - ok.setFont(new java.awt.Font("Verdana", 0, 11)); - ok.setLabel("OK"); - ok.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - ok_actionPerformed(); - } - }); - cancel.setFont(new java.awt.Font("Verdana", 0, 11)); - cancel.setLabel("Cancel"); - cancel.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - cancel_actionPerformed(); - } - }); - this.setBackground(Color.white); - panel1.setLayout(borderLayout1); - panel2.setLayout(borderLayout3); - panel3.setLayout(borderLayout2); - panel5.setBackground(Color.white); - panel4.setBackground(Color.white); - panel1.setBackground(Color.white); - panel2.setBackground(Color.white); - panel3.setBackground(Color.white); - panel1.add(label1, BorderLayout.WEST); - panel1.add(fontName, BorderLayout.CENTER); - panel5.add(panel1, null); - panel5.add(panel3, null); - panel5.add(panel2, null); - panel2.add(label3, BorderLayout.WEST); - panel2.add(fontStyle, BorderLayout.CENTER); - panel3.add(label2, BorderLayout.WEST); - panel3.add(fontSize, BorderLayout.CENTER); - this.add(panel4, BorderLayout.SOUTH); - panel4.add(ok, null); - panel4.add(cancel, null); - this.add(panel5, BorderLayout.CENTER); - - } - - protected void ok_actionPerformed() - { - - } - - protected void cancel_actionPerformed() - { - - } - protected void fontName_actionPerformed() - { - - } + private void jbInit() throws Exception { + label1.setFont(new java.awt.Font("Verdana", 0, 11)); + label1.setAlignment(Label.RIGHT); + label1.setText("Font: "); + this.setLayout(borderLayout4); + fontSize.setFont(new java.awt.Font("Verdana", 0, 11)); + fontSize.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fontSize_actionPerformed(); + } + }); + fontStyle.setFont(new java.awt.Font("Verdana", 0, 11)); + fontStyle.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fontStyle_actionPerformed(); + } + }); + label2.setAlignment(Label.RIGHT); + label2.setFont(new java.awt.Font("Verdana", 0, 11)); + label2.setText("Size: "); + label3.setAlignment(Label.RIGHT); + label3.setFont(new java.awt.Font("Verdana", 0, 11)); + label3.setText("Style: "); + fontName.setFont(new java.awt.Font("Verdana", 0, 11)); + fontName.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fontName_actionPerformed(); + } + }); + ok.setFont(new java.awt.Font("Verdana", 0, 11)); + ok.setLabel("OK"); + ok.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + ok_actionPerformed(); + } + }); + cancel.setFont(new java.awt.Font("Verdana", 0, 11)); + cancel.setLabel("Cancel"); + cancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cancel_actionPerformed(); + } + }); + this.setBackground(Color.white); + panel1.setLayout(borderLayout1); + panel2.setLayout(borderLayout3); + panel3.setLayout(borderLayout2); + panel5.setBackground(Color.white); + panel4.setBackground(Color.white); + panel1.setBackground(Color.white); + panel2.setBackground(Color.white); + panel3.setBackground(Color.white); + panel1.add(label1, BorderLayout.WEST); + panel1.add(fontName, BorderLayout.CENTER); + panel5.add(panel1, null); + panel5.add(panel3, null); + panel5.add(panel2, null); + panel2.add(label3, BorderLayout.WEST); + panel2.add(fontStyle, BorderLayout.CENTER); + panel3.add(label2, BorderLayout.WEST); + panel3.add(fontSize, BorderLayout.CENTER); + this.add(panel4, BorderLayout.SOUTH); + panel4.add(ok, null); + panel4.add(cancel, null); + this.add(panel5, BorderLayout.CENTER); + } - protected void fontSize_actionPerformed() - { + protected void ok_actionPerformed() { + } - } + protected void cancel_actionPerformed() { + } - protected void fontStyle_actionPerformed() - { + protected void fontName_actionPerformed() { + } - } + protected void fontSize_actionPerformed() { + } + protected void fontStyle_actionPerformed() { + } } diff --git a/src/jalview/jbappletgui/GPCAPanel.java b/src/jalview/jbappletgui/GPCAPanel.java index b13b563..f33521c 100755 --- a/src/jalview/jbappletgui/GPCAPanel.java +++ b/src/jalview/jbappletgui/GPCAPanel.java @@ -16,99 +16,80 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GPCAPanel extends Panel -{ - Panel jPanel2 = new Panel(); - Label jLabel1 = new Label(); - Label jLabel2 = new Label(); - Label jLabel3 = new Label(); - protected Choice xCombobox = new Choice(); - protected Choice yCombobox = new Choice(); - protected Choice zCombobox = new Choice(); - 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); - } - } - 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); - zCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); - zCombobox.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - zCombobox_actionPerformed(null); - } - }); - yCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); - yCombobox.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - yCombobox_actionPerformed(null); - } - }); - xCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); - xCombobox.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - xCombobox_actionPerformed(null); - } - }); - 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 xCombobox_actionPerformed(ActionEvent e) - { +public class GPCAPanel extends Panel { + Panel jPanel2 = new Panel(); + Label jLabel1 = new Label(); + Label jLabel2 = new Label(); + Label jLabel3 = new Label(); + protected Choice xCombobox = new Choice(); + protected Choice yCombobox = new Choice(); + protected Choice zCombobox = new Choice(); + FlowLayout flowLayout1 = new FlowLayout(); + BorderLayout borderLayout1 = new BorderLayout(); - } + public GPCAPanel() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } - protected void yCombobox_actionPerformed(ActionEvent e) - { + for (int i = 1; i < 8; i++) { + xCombobox.addItem("dim " + i); + yCombobox.addItem("dim " + i); + zCombobox.addItem("dim " + i); + } + } - } + 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); + zCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + zCombobox.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + zCombobox_actionPerformed(null); + } + }); + yCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + yCombobox.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + yCombobox_actionPerformed(null); + } + }); + xCombobox.setFont(new java.awt.Font("Verdana", 0, 12)); + xCombobox.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + xCombobox_actionPerformed(null); + } + }); + 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/jbappletgui/GPairwiseAlignPanel.java b/src/jalview/jbappletgui/GPairwiseAlignPanel.java index 54bb555..10bd01e 100755 --- a/src/jalview/jbappletgui/GPairwiseAlignPanel.java +++ b/src/jalview/jbappletgui/GPairwiseAlignPanel.java @@ -16,55 +16,44 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GPairwiseAlignPanel extends Panel -{ - protected ScrollPane scrollPane = new ScrollPane(); - protected TextArea textarea = new TextArea(); - protected Button viewInEditorButton = new Button(); - Panel jPanel1 = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); +public class GPairwiseAlignPanel extends Panel { + protected ScrollPane scrollPane = new ScrollPane(); + protected TextArea textarea = new TextArea(); + protected Button viewInEditorButton = new Button(); + Panel jPanel1 = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); - public GPairwiseAlignPanel() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); + public GPairwiseAlignPanel() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - } - private void jbInit() throws Exception - { - this.setLayout(borderLayout1); - textarea.setFont(new java.awt.Font("Monospaced", 0, 12)); - textarea.setText(""); - viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12)); - viewInEditorButton.setLabel("View in alignment editor"); - viewInEditorButton.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - viewInEditorButton_actionPerformed(e); - } - }); - this.add(scrollPane, BorderLayout.CENTER); - scrollPane.add(textarea); - this.add(jPanel1, BorderLayout.SOUTH); - jPanel1.add(viewInEditorButton, null); - } - - protected void viewInEditorButton_actionPerformed(ActionEvent e) - { - } + private void jbInit() throws Exception { + this.setLayout(borderLayout1); + textarea.setFont(new java.awt.Font("Monospaced", 0, 12)); + textarea.setText(""); + viewInEditorButton.setFont(new java.awt.Font("Verdana", 0, 12)); + viewInEditorButton.setLabel("View in alignment editor"); + viewInEditorButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + viewInEditorButton_actionPerformed(e); + } + }); + this.add(scrollPane, BorderLayout.CENTER); + scrollPane.add(textarea); + this.add(jPanel1, BorderLayout.SOUTH); + jPanel1.add(viewInEditorButton, null); + } + protected void viewInEditorButton_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbappletgui/GSliderPanel.java b/src/jalview/jbappletgui/GSliderPanel.java index d8120b4..5e33300 100755 --- a/src/jalview/jbappletgui/GSliderPanel.java +++ b/src/jalview/jbappletgui/GSliderPanel.java @@ -16,121 +16,100 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GSliderPanel extends Panel -{ - // this is used for conservation colours, PID colours and redundancy threshold - protected Scrollbar slider = new Scrollbar(); - protected TextField valueField = new TextField(); - protected Label label = new Label(); - Panel jPanel1 = new Panel(); - Panel jPanel2 = new Panel(); - protected Button applyButton = new Button(); - protected Button undoButton = new Button(); - FlowLayout flowLayout1 = new FlowLayout(); - protected Checkbox allGroupsCheck = new Checkbox(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - FlowLayout flowLayout2 = new FlowLayout(); - - public GSliderPanel() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - } - private void jbInit() throws Exception - { - this.setLayout(borderLayout2); - // slider.setMajorTickSpacing(10); - // slider.setMinorTickSpacing(1); - // slider.setPaintTicks(true); - slider.setBackground(Color.white); - slider.setFont(new java.awt.Font("Verdana", 0, 11)); - slider.setOrientation(0); - valueField.setFont(new java.awt.Font("Verdana", 0, 11)); - valueField.setText(" "); - valueField.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - valueField_actionPerformed(e); - } - }); - label.setFont(new java.awt.Font("Verdana", 0, 11)); - label.setText("set this label text"); - jPanel1.setLayout(borderLayout1); - jPanel2.setLayout(flowLayout1); - applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); - applyButton.setLabel("Apply"); - applyButton.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - applyButton_actionPerformed(e); - } - }); - undoButton.setEnabled(false); - undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); - undoButton.setLabel("Undo"); - undoButton.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - undoButton_actionPerformed(e); - } - }); - allGroupsCheck.setEnabled(false); - allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); - allGroupsCheck.setLabel("Apply threshold to all groups"); - allGroupsCheck.setName("Apply to all Groups"); - allGroupsCheck.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - allGroupsCheck_actionPerformed(); - } - }); - this.setBackground(Color.white); - this.setForeground(Color.black); - jPanel2.add(label, null); - jPanel2.add(applyButton, null); - jPanel2.add(undoButton, null); - jPanel2.add(allGroupsCheck); - jPanel1.add(valueField, java.awt.BorderLayout.EAST); - jPanel1.add(slider, java.awt.BorderLayout.CENTER); - this.add(jPanel1, java.awt.BorderLayout.SOUTH); - this.add(jPanel2, java.awt.BorderLayout.CENTER); - } - - protected void valueField_actionPerformed(ActionEvent e) - { - } +public class GSliderPanel extends Panel { + // this is used for conservation colours, PID colours and redundancy threshold + protected Scrollbar slider = new Scrollbar(); + protected TextField valueField = new TextField(); + protected Label label = new Label(); + Panel jPanel1 = new Panel(); + Panel jPanel2 = new Panel(); + protected Button applyButton = new Button(); + protected Button undoButton = new Button(); + FlowLayout flowLayout1 = new FlowLayout(); + protected Checkbox allGroupsCheck = new Checkbox(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + FlowLayout flowLayout2 = new FlowLayout(); - protected void applyButton_actionPerformed(ActionEvent e) - { + public GSliderPanel() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } - } + private void jbInit() throws Exception { + this.setLayout(borderLayout2); - protected void undoButton_actionPerformed(ActionEvent e) - { + // slider.setMajorTickSpacing(10); + // slider.setMinorTickSpacing(1); + // slider.setPaintTicks(true); + slider.setBackground(Color.white); + slider.setFont(new java.awt.Font("Verdana", 0, 11)); + slider.setOrientation(0); + valueField.setFont(new java.awt.Font("Verdana", 0, 11)); + valueField.setText(" "); + valueField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + valueField_actionPerformed(e); + } + }); + label.setFont(new java.awt.Font("Verdana", 0, 11)); + label.setText("set this label text"); + jPanel1.setLayout(borderLayout1); + jPanel2.setLayout(flowLayout1); + applyButton.setFont(new java.awt.Font("Verdana", 0, 11)); + applyButton.setLabel("Apply"); + applyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + applyButton_actionPerformed(e); + } + }); + undoButton.setEnabled(false); + undoButton.setFont(new java.awt.Font("Verdana", 0, 11)); + undoButton.setLabel("Undo"); + undoButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + undoButton_actionPerformed(e); + } + }); + allGroupsCheck.setEnabled(false); + allGroupsCheck.setFont(new java.awt.Font("Verdana", 0, 11)); + allGroupsCheck.setLabel("Apply threshold to all groups"); + allGroupsCheck.setName("Apply to all Groups"); + allGroupsCheck.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + allGroupsCheck_actionPerformed(); + } + }); + this.setBackground(Color.white); + this.setForeground(Color.black); + jPanel2.add(label, null); + jPanel2.add(applyButton, null); + jPanel2.add(undoButton, null); + jPanel2.add(allGroupsCheck); + jPanel1.add(valueField, java.awt.BorderLayout.EAST); + jPanel1.add(slider, java.awt.BorderLayout.CENTER); + this.add(jPanel1, java.awt.BorderLayout.SOUTH); + this.add(jPanel2, java.awt.BorderLayout.CENTER); + } - } + protected void valueField_actionPerformed(ActionEvent e) { + } - protected void allGroupsCheck_actionPerformed() - { + protected void applyButton_actionPerformed(ActionEvent e) { + } - } + protected void undoButton_actionPerformed(ActionEvent e) { + } + protected void allGroupsCheck_actionPerformed() { + } } diff --git a/src/jalview/jbappletgui/GTreePanel.java b/src/jalview/jbappletgui/GTreePanel.java index a663402..1810719 100755 --- a/src/jalview/jbappletgui/GTreePanel.java +++ b/src/jalview/jbappletgui/GTreePanel.java @@ -16,140 +16,106 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GTreePanel extends Frame -{ - BorderLayout borderLayout1 = new BorderLayout(); - protected ScrollPane scrollPane = new ScrollPane(); - MenuBar jMenuBar1 = new MenuBar(); - Menu jMenu2 = new Menu(); - protected MenuItem fontSize = new MenuItem(); - protected CheckboxMenuItem bootstrapMenu = new CheckboxMenuItem(); - protected CheckboxMenuItem distanceMenu = new CheckboxMenuItem(); - protected CheckboxMenuItem placeholdersMenu = new CheckboxMenuItem(); - protected CheckboxMenuItem fitToWindow = new CheckboxMenuItem(); - Menu fileMenu = new Menu(); - MenuItem newickOutput = new MenuItem(); - public GTreePanel() - { - try - { - jbInit(); - this.setMenuBar(jMenuBar1); - } - catch(Exception e) - { - e.printStackTrace(); +public class GTreePanel extends Frame { + BorderLayout borderLayout1 = new BorderLayout(); + protected ScrollPane scrollPane = new ScrollPane(); + MenuBar jMenuBar1 = new MenuBar(); + Menu jMenu2 = new Menu(); + protected MenuItem fontSize = new MenuItem(); + protected CheckboxMenuItem bootstrapMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem distanceMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem placeholdersMenu = new CheckboxMenuItem(); + protected CheckboxMenuItem fitToWindow = new CheckboxMenuItem(); + Menu fileMenu = new Menu(); + MenuItem newickOutput = new MenuItem(); + + public GTreePanel() { + try { + jbInit(); + this.setMenuBar(jMenuBar1); + } catch (Exception e) { + e.printStackTrace(); + } } - } - private void jbInit() throws Exception - { - setLayout(borderLayout1); - this.setBackground(Color.white); - this.setFont(new java.awt.Font("Verdana", 0, 12)); - jMenu2.setLabel("View"); - fontSize.setLabel("Font Size - 12"); - fontSize.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - fontSize_actionPerformed(e); - } - }); - bootstrapMenu.setLabel("Show Bootstrap Values"); - bootstrapMenu.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - bootstrapMenu_actionPerformed(null); - } - }); - distanceMenu.setLabel("Show Distances"); - distanceMenu.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - distanceMenu_actionPerformed(null); - } - }); - placeholdersMenu.setLabel("Mark Unassociated Leaves"); - placeholdersMenu.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - placeholdersMenu_actionPerformed(null); - } - }); - fitToWindow.setState(true); - fitToWindow.setLabel("Fit To Window"); - fitToWindow.addItemListener(new java.awt.event.ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - fitToWindow_actionPerformed(null); - } - }); - fileMenu.setLabel("File"); - newickOutput.setLabel("Newick Format"); - newickOutput.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent actionEvent) - { - newickOutput_actionPerformed(actionEvent); - } - }); - add(scrollPane, BorderLayout.CENTER); - jMenuBar1.add(fileMenu); - jMenuBar1.add(jMenu2); - jMenu2.add(fitToWindow); - jMenu2.add(fontSize); - jMenu2.add(distanceMenu); - jMenu2.add(bootstrapMenu); - jMenu2.add(placeholdersMenu); - fileMenu.add(newickOutput); - } - - - protected void printMenu_actionPerformed(ActionEvent e) - { - - } - - protected void fontSize_actionPerformed(ActionEvent e) - { - - } - - protected void distanceMenu_actionPerformed(ActionEvent e) - { - - } - - protected void bootstrapMenu_actionPerformed(ActionEvent e) - { - - } + private void jbInit() throws Exception { + setLayout(borderLayout1); + this.setBackground(Color.white); + this.setFont(new java.awt.Font("Verdana", 0, 12)); + jMenu2.setLabel("View"); + fontSize.setLabel("Font Size - 12"); + fontSize.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + fontSize_actionPerformed(e); + } + }); + bootstrapMenu.setLabel("Show Bootstrap Values"); + bootstrapMenu.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + bootstrapMenu_actionPerformed(null); + } + }); + distanceMenu.setLabel("Show Distances"); + distanceMenu.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + distanceMenu_actionPerformed(null); + } + }); + placeholdersMenu.setLabel("Mark Unassociated Leaves"); + placeholdersMenu.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + placeholdersMenu_actionPerformed(null); + } + }); + fitToWindow.setState(true); + fitToWindow.setLabel("Fit To Window"); + fitToWindow.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(ItemEvent e) { + fitToWindow_actionPerformed(null); + } + }); + fileMenu.setLabel("File"); + newickOutput.setLabel("Newick Format"); + newickOutput.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + newickOutput_actionPerformed(actionEvent); + } + }); + add(scrollPane, BorderLayout.CENTER); + jMenuBar1.add(fileMenu); + jMenuBar1.add(jMenu2); + jMenu2.add(fitToWindow); + jMenu2.add(fontSize); + jMenu2.add(distanceMenu); + jMenu2.add(bootstrapMenu); + jMenu2.add(placeholdersMenu); + fileMenu.add(newickOutput); + } - protected void placeholdersMenu_actionPerformed(ActionEvent e) - { + protected void printMenu_actionPerformed(ActionEvent e) { + } - } + protected void fontSize_actionPerformed(ActionEvent e) { + } - protected void fitToWindow_actionPerformed(ActionEvent e) - { + protected void distanceMenu_actionPerformed(ActionEvent e) { + } - } + protected void bootstrapMenu_actionPerformed(ActionEvent e) { + } - public void newickOutput_actionPerformed(ActionEvent actionEvent) - { + protected void placeholdersMenu_actionPerformed(ActionEvent e) { + } - } + protected void fitToWindow_actionPerformed(ActionEvent e) { + } + public void newickOutput_actionPerformed(ActionEvent actionEvent) { + } } diff --git a/src/jalview/jbappletgui/GUserDefinedColours.java b/src/jalview/jbappletgui/GUserDefinedColours.java index 0acc0b1..bc57798 100755 --- a/src/jalview/jbappletgui/GUserDefinedColours.java +++ b/src/jalview/jbappletgui/GUserDefinedColours.java @@ -16,205 +16,174 @@ * 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.jbappletgui; import java.awt.*; import java.awt.event.*; -public class GUserDefinedColours extends Panel -{ - protected Panel buttonPanel = new Panel(); - protected GridLayout gridLayout = new GridLayout(); - Panel jPanel2 = new Panel(); - protected Button okButton = new Button(); - protected Button applyButton = new Button(); - protected Button cancelButton = new Button(); - protected Scrollbar rScroller = new Scrollbar(); - Label label1 = new Label(); - Panel panel2 = new Panel(); - BorderLayout borderLayout1 = new BorderLayout(); - protected TextField rText = new TextField(); - Panel panel3 = new Panel(); - Label label4 = new Label(); - protected Scrollbar gScroller = new Scrollbar(); - protected TextField gText = new TextField(); - BorderLayout borderLayout2 = new BorderLayout(); - Panel panel4 = new Panel(); - Label label5 = new Label(); - protected Scrollbar bScroller = new Scrollbar(); - protected TextField bText = new TextField(); - BorderLayout borderLayout3 = new BorderLayout(); - protected Panel target = new Panel(); - - public GUserDefinedColours() - { - try - { - jbInit(); +public class GUserDefinedColours extends Panel { + protected Panel buttonPanel = new Panel(); + protected GridLayout gridLayout = new GridLayout(); + Panel jPanel2 = new Panel(); + protected Button okButton = new Button(); + protected Button applyButton = new Button(); + protected Button cancelButton = new Button(); + protected Scrollbar rScroller = new Scrollbar(); + Label label1 = new Label(); + Panel panel2 = new Panel(); + BorderLayout borderLayout1 = new BorderLayout(); + protected TextField rText = new TextField(); + Panel panel3 = new Panel(); + Label label4 = new Label(); + protected Scrollbar gScroller = new Scrollbar(); + protected TextField gText = new TextField(); + BorderLayout borderLayout2 = new BorderLayout(); + Panel panel4 = new Panel(); + Label label5 = new Label(); + protected Scrollbar bScroller = new Scrollbar(); + protected TextField bText = new TextField(); + BorderLayout borderLayout3 = new BorderLayout(); + protected Panel target = new Panel(); + + public GUserDefinedColours() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - catch(Exception e) - { - e.printStackTrace(); - } - } - private void jbInit() throws Exception - { - this.setLayout(null); - buttonPanel.setLayout(gridLayout); - gridLayout.setColumns(6); - gridLayout.setRows(4); - okButton.setFont(new java.awt.Font("Verdana", 0, 11)); - okButton.setLabel("OK"); - 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.setLabel("Apply"); - applyButton.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - applyButton_actionPerformed(e); - } - }); - cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); - cancelButton.setLabel("Cancel"); - cancelButton.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - cancelButton_actionPerformed(e); - } - }); - this.setBackground(new Color(212, 208, 223)); - jPanel2.setBounds(new Rectangle(0, 265, 400, 35)); - buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); - rScroller.setMaximum(255); - rScroller.setMinimum(0); - rScroller.setOrientation(0); - rScroller.setUnitIncrement(1); - rScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { - public void adjustmentValueChanged(AdjustmentEvent e) { - rScroller_adjustmentValueChanged(e); - } - }); - label1.setText("R"); - panel2.setBounds(new Rectangle(20, 29, 180, 19)); - panel2.setLayout(borderLayout1); - rText.setText(" 0"); - rText.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - rText_actionPerformed(e); - } - }); - panel3.setLayout(borderLayout2); - label4.setText("G"); - gScroller.setMaximum(255); - gScroller.setMinimum(0); - gScroller.setOrientation(0); - gScroller.setUnitIncrement(1); - gScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { - public void adjustmentValueChanged(AdjustmentEvent e) { - gScroller_adjustmentValueChanged(e); - } - }); - gText.setText(" 0"); - gText.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - gText_actionPerformed(e); - } - }); - panel3.setBounds(new Rectangle(19, 54, 181, 20)); - panel4.setLayout(borderLayout3); - label5.setText("B"); - bScroller.setMaximum(255); - bScroller.setMinimum(0); - bScroller.setOrientation(0); - bScroller.setUnitIncrement(1); - bScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { - public void adjustmentValueChanged(AdjustmentEvent e) { - bScroller_adjustmentValueChanged(e); - } - }); - bText.setSelectionStart(6); - bText.setText(" 0"); - bText.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(ActionEvent e) { - bText_actionPerformed(e); - } - }); - panel4.setBounds(new Rectangle(19, 87, 180, 20)); - target.setBackground(Color.black); - target.setBounds(new Rectangle(229, 26, 134, 79)); - this.add(jPanel2, null); - jPanel2.add(okButton, null); - jPanel2.add(applyButton, null); - jPanel2.add(cancelButton, null); - this.add(buttonPanel, null); - panel2.add(label1, BorderLayout.WEST); - panel2.add(rScroller, BorderLayout.CENTER); - panel2.add(rText, BorderLayout.EAST); - this.add(target, null); - this.add(panel4, null); - panel3.add(label4, BorderLayout.WEST); - panel3.add(gScroller, BorderLayout.CENTER); - panel3.add(gText, BorderLayout.EAST); - this.add(panel2, null); - panel4.add(label5, BorderLayout.WEST); - panel4.add(bScroller, BorderLayout.CENTER); - panel4.add(bText, BorderLayout.EAST); - this.add(panel3, null); - } - - - protected void okButton_actionPerformed(ActionEvent e) - { - - } - - protected void applyButton_actionPerformed(ActionEvent e) - { - - } - - - - protected void cancelButton_actionPerformed(ActionEvent e) - { - - } - - protected void rScroller_adjustmentValueChanged(AdjustmentEvent e) { - - } - protected void gScroller_adjustmentValueChanged(AdjustmentEvent e) { - - } - - protected void bScroller_adjustmentValueChanged(AdjustmentEvent e) { - - } - - protected void rText_actionPerformed(ActionEvent e) { + private void jbInit() throws Exception { + this.setLayout(null); + buttonPanel.setLayout(gridLayout); + gridLayout.setColumns(6); + gridLayout.setRows(4); + okButton.setFont(new java.awt.Font("Verdana", 0, 11)); + okButton.setLabel("OK"); + 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.setLabel("Apply"); + applyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + applyButton_actionPerformed(e); + } + }); + cancelButton.setFont(new java.awt.Font("Verdana", 0, 11)); + cancelButton.setLabel("Cancel"); + cancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + cancelButton_actionPerformed(e); + } + }); + this.setBackground(new Color(212, 208, 223)); + jPanel2.setBounds(new Rectangle(0, 265, 400, 35)); + buttonPanel.setBounds(new Rectangle(0, 123, 400, 142)); + rScroller.setMaximum(255); + rScroller.setMinimum(0); + rScroller.setOrientation(0); + rScroller.setUnitIncrement(1); + rScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + rScroller_adjustmentValueChanged(e); + } + }); + label1.setText("R"); + panel2.setBounds(new Rectangle(20, 29, 180, 19)); + panel2.setLayout(borderLayout1); + rText.setText(" 0"); + rText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + rText_actionPerformed(e); + } + }); + panel3.setLayout(borderLayout2); + label4.setText("G"); + gScroller.setMaximum(255); + gScroller.setMinimum(0); + gScroller.setOrientation(0); + gScroller.setUnitIncrement(1); + gScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + gScroller_adjustmentValueChanged(e); + } + }); + gText.setText(" 0"); + gText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + gText_actionPerformed(e); + } + }); + panel3.setBounds(new Rectangle(19, 54, 181, 20)); + panel4.setLayout(borderLayout3); + label5.setText("B"); + bScroller.setMaximum(255); + bScroller.setMinimum(0); + bScroller.setOrientation(0); + bScroller.setUnitIncrement(1); + bScroller.addAdjustmentListener(new java.awt.event.AdjustmentListener() { + public void adjustmentValueChanged(AdjustmentEvent e) { + bScroller_adjustmentValueChanged(e); + } + }); + bText.setSelectionStart(6); + bText.setText(" 0"); + bText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + bText_actionPerformed(e); + } + }); + panel4.setBounds(new Rectangle(19, 87, 180, 20)); + target.setBackground(Color.black); + target.setBounds(new Rectangle(229, 26, 134, 79)); + this.add(jPanel2, null); + jPanel2.add(okButton, null); + jPanel2.add(applyButton, null); + jPanel2.add(cancelButton, null); + this.add(buttonPanel, null); + panel2.add(label1, BorderLayout.WEST); + panel2.add(rScroller, BorderLayout.CENTER); + panel2.add(rText, BorderLayout.EAST); + this.add(target, null); + this.add(panel4, null); + panel3.add(label4, BorderLayout.WEST); + panel3.add(gScroller, BorderLayout.CENTER); + panel3.add(gText, BorderLayout.EAST); + this.add(panel2, null); + panel4.add(label5, BorderLayout.WEST); + panel4.add(bScroller, BorderLayout.CENTER); + panel4.add(bText, BorderLayout.EAST); + this.add(panel3, null); + } - } + protected void okButton_actionPerformed(ActionEvent e) { + } - protected void gText_actionPerformed(ActionEvent e) { + protected void applyButton_actionPerformed(ActionEvent e) { + } - } + protected void cancelButton_actionPerformed(ActionEvent e) { + } - protected void bText_actionPerformed(ActionEvent e) { + protected void rScroller_adjustmentValueChanged(AdjustmentEvent e) { + } - } + protected void gScroller_adjustmentValueChanged(AdjustmentEvent e) { + } + protected void bScroller_adjustmentValueChanged(AdjustmentEvent e) { + } + protected void rText_actionPerformed(ActionEvent e) { + } + protected void gText_actionPerformed(ActionEvent e) { + } + protected void bText_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index 00b4bc9..81325d5 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -16,1266 +16,1014 @@ * 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 javax.swing.*; -import java.awt.event.*; -import java.awt.*; - import jalview.gui.Preferences; -import jalview.schemes.ColourSchemeProperty; -import javax.swing.event.AncestorListener; -import javax.swing.event.AncestorEvent; - -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(); - protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); - protected 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(); - protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); - protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); - JMenuItem htmlMenuItem = new JMenuItem(); - JMenuItem overviewMenuItem = new JMenuItem(); - protected JMenuItem undoMenuItem = new JMenuItem(); - protected JMenuItem redoMenuItem = new JMenuItem(); - protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); - JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); - protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); - JMenuItem printMenuItem = new JMenuItem(); - protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); - JMenuItem findMenuItem = new JMenuItem(); - JMenu searchMenu = new JMenu(); - protected JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); - protected 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(); - protected JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); - JMenuItem createPNG = new JMenuItem(); - protected JMenuItem font = new JMenuItem(); - protected JCheckBoxMenuItem fullSeqId = new JCheckBoxMenuItem(); - JMenuItem epsFile = new JMenuItem(); - JMenuItem LoadtreeMenuItem = new JMenuItem(); - JMenuItem jpred = new JMenuItem(); - protected JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); - protected JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem(); - protected 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); - } - }); - jpred.setText("JPred..."); - jpred.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(jpred); - 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 averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) - { - - } - - protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e) - { - - } - - - protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) - { - - } - - protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) - { - - } - - - - protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) - { - - } - - - - - protected void clustalColour_actionPerformed(ActionEvent e) - { - - } - - protected void zappoColour_actionPerformed(ActionEvent e) - { - - } - - protected void taylorColour_actionPerformed(ActionEvent e) - { - - } - - - protected void hydrophobicityColour_actionPerformed(ActionEvent e) - { - - } - - protected void helixColour_actionPerformed(ActionEvent e) - { - } - - protected void strandColour_actionPerformed(ActionEvent e) - { - - } +import jalview.schemes.ColourSchemeProperty; - protected void turnColour_actionPerformed(ActionEvent e) - { +import java.awt.*; +import java.awt.event.*; - } +import javax.swing.*; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; - protected void buriedColour_actionPerformed(ActionEvent e) - { - } +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(); + protected JCheckBoxMenuItem viewBoxesMenuItem = new JCheckBoxMenuItem(); + protected 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(); + protected JCheckBoxMenuItem annotationPanelMenuItem = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem colourTextMenuItem = new JCheckBoxMenuItem(); + JMenuItem htmlMenuItem = new JMenuItem(); + JMenuItem overviewMenuItem = new JMenuItem(); + protected JMenuItem undoMenuItem = new JMenuItem(); + protected JMenuItem redoMenuItem = new JMenuItem(); + protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem(); + JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem(); + protected JCheckBoxMenuItem wrapMenuItem = new JCheckBoxMenuItem(); + JMenuItem printMenuItem = new JMenuItem(); + protected JCheckBoxMenuItem renderGapsMenuItem = new JCheckBoxMenuItem(); + JMenuItem findMenuItem = new JMenuItem(); + JMenu searchMenu = new JMenu(); + protected JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); + protected 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(); + protected JCheckBoxMenuItem applyToAllGroups = new JCheckBoxMenuItem(); + JMenuItem createPNG = new JMenuItem(); + protected JMenuItem font = new JMenuItem(); + protected JCheckBoxMenuItem fullSeqId = new JCheckBoxMenuItem(); + JMenuItem epsFile = new JMenuItem(); + JMenuItem LoadtreeMenuItem = new JMenuItem(); + JMenuItem jpred = new JMenuItem(); + protected JCheckBoxMenuItem scaleAbove = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem scaleLeft = new JCheckBoxMenuItem(); + protected 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; - protected void userDefinedColour_actionPerformed(ActionEvent e) - { + // 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(); + } + } - protected void PIDColour_actionPerformed(ActionEvent e) - { + 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); + } + }); + jpred.setText("JPred..."); + jpred.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(jpred); + 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 BLOSUM62Colour_actionPerformed(ActionEvent e) - { + protected void htmlMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void closeMenuItem_actionPerformed(ActionEvent e) { + } + protected void redoMenuItem_actionPerformed(ActionEvent e) { + } - protected void noColourmenuItem_actionPerformed(ActionEvent e) - { + protected void undoMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void selectAllSequenceMenuItem_actionPerformed(ActionEvent e) { + } - protected void conservationMenuItem_actionPerformed(ActionEvent e) - { + protected void deselectAllSequenceMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void invertSequenceMenuItem_actionPerformed(ActionEvent e) { + } + protected void remove2LeftMenuItem_actionPerformed(ActionEvent e) { + } - protected void printMenuItem_actionPerformed(ActionEvent e) - { + protected void remove2RightMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void removeGappedColumnMenuItem_actionPerformed(ActionEvent e) { + } - protected void renderGapsMenuItem_actionPerformed(ActionEvent e) - { + protected void removeAllGapsMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void wrapMenuItem_actionPerformed(ActionEvent e) { + } - protected void findMenuItem_actionPerformed(ActionEvent e) - { + protected void viewBoxesMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void viewTextMenuItem_actionPerformed(ActionEvent e) { + } + protected void colourTextMenuItem_actionPerformed(ActionEvent e) { + } - protected void abovePIDThreshold_actionPerformed(ActionEvent e) { + protected void annotationPanelMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void overviewMenuItem_actionPerformed(ActionEvent e) { + } - public void sequenceFeatures_actionPerformed(ActionEvent actionEvent) - { + protected void sortPairwiseMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void sortIDMenuItem_actionPerformed(ActionEvent e) { + } - protected void nucleotideColour_actionPerformed(ActionEvent e) - { + protected void sortGroupMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void removeRedundancyMenuItem_actionPerformed(ActionEvent e) { + } - protected void deleteGroups_actionPerformed(ActionEvent e) - { + protected void pairwiseAlignmentMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void PCAMenuItem_actionPerformed(ActionEvent e) { + } - protected void copy_actionPerformed(ActionEvent e) - { + protected void averageDistanceTreeMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void neighbourTreeMenuItem_actionPerformed(ActionEvent e) { + } + protected void njTreeBlosumMenuItem_actionPerformed(ActionEvent e) { + } - protected void cut_actionPerformed(ActionEvent e) - { + protected void avTreeBlosumMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void clustalAlignMenuItem_actionPerformed(ActionEvent e) { + } - protected void delete_actionPerformed(ActionEvent e) - { + protected void clustalColour_actionPerformed(ActionEvent e) { + } - } + protected void zappoColour_actionPerformed(ActionEvent e) { + } - protected void pasteNew_actionPerformed(ActionEvent e) - { + protected void taylorColour_actionPerformed(ActionEvent e) { + } - } + protected void hydrophobicityColour_actionPerformed(ActionEvent e) { + } - protected void pasteThis_actionPerformed(ActionEvent e) - { + protected void helixColour_actionPerformed(ActionEvent e) { + } - } + protected void strandColour_actionPerformed(ActionEvent e) { + } - protected void applyToAllGroups_actionPerformed(ActionEvent e) - { + protected void turnColour_actionPerformed(ActionEvent e) { + } - } + protected void buriedColour_actionPerformed(ActionEvent e) { + } - protected void createPNG_actionPerformed(ActionEvent e) - { + protected void userDefinedColour_actionPerformed(ActionEvent e) { + } - } + protected void PIDColour_actionPerformed(ActionEvent e) { + } - protected void font_actionPerformed(ActionEvent e) - { + protected void BLOSUM62Colour_actionPerformed(ActionEvent e) { + } - } + protected void noColourmenuItem_actionPerformed(ActionEvent e) { + } - protected void fullSeqId_actionPerformed(ActionEvent e) - { + protected void conservationMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void printMenuItem_actionPerformed(ActionEvent e) { + } - protected void epsFile_actionPerformed(ActionEvent e) - { + protected void renderGapsMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void findMenuItem_actionPerformed(ActionEvent e) { + } - protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { + protected void abovePIDThreshold_actionPerformed(ActionEvent e) { + } - } + public void sequenceFeatures_actionPerformed(ActionEvent actionEvent) { + } - protected void jpred_actionPerformed(ActionEvent e) - { + protected void nucleotideColour_actionPerformed(ActionEvent e) { + } - } + protected void deleteGroups_actionPerformed(ActionEvent e) { + } - protected void scaleAbove_actionPerformed(ActionEvent e) - { + protected void copy_actionPerformed(ActionEvent e) { + } - } + protected void cut_actionPerformed(ActionEvent e) { + } - protected void scaleLeft_actionPerformed(ActionEvent e) - { + protected void delete_actionPerformed(ActionEvent e) { + } - } + protected void pasteNew_actionPerformed(ActionEvent e) { + } - protected void scaleRight_actionPerformed(ActionEvent e) - { + protected void pasteThis_actionPerformed(ActionEvent e) { + } - } + protected void applyToAllGroups_actionPerformed(ActionEvent e) { + } - protected void modifyPID_actionPerformed(ActionEvent e) - { + protected void createPNG_actionPerformed(ActionEvent e) { + } - } + protected void font_actionPerformed(ActionEvent e) { + } - protected void modifyConservation_actionPerformed(ActionEvent e) - { + protected void fullSeqId_actionPerformed(ActionEvent e) { + } - } + protected void epsFile_actionPerformed(ActionEvent e) { + } - protected void preferences_actionPerformed(ActionEvent e) - { + protected void LoadtreeMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void jpred_actionPerformed(ActionEvent e) { + } - protected void msaAlignMenuItem_actionPerformed(ActionEvent e) { + protected void scaleAbove_actionPerformed(ActionEvent e) { + } - } + protected void scaleLeft_actionPerformed(ActionEvent e) { + } - protected void alignFrameMenuBar_ancestorAdded(AncestorEvent event) - { + protected void scaleRight_actionPerformed(ActionEvent e) { + } - } + protected void modifyPID_actionPerformed(ActionEvent e) { + } - protected void saveAlignmentMenu_actionPerformed(ActionEvent e) - { + protected void modifyConservation_actionPerformed(ActionEvent e) { + } - } + protected void preferences_actionPerformed(ActionEvent e) { + } - protected void padGapsMenuitem_actionPerformed(ActionEvent e) - { + protected void msaAlignMenuItem_actionPerformed(ActionEvent e) { + } - } + protected void alignFrameMenuBar_ancestorAdded(AncestorEvent event) { + } - protected void ClustalRealign_actionPerformed(ActionEvent e) - { + protected void saveAlignmentMenu_actionPerformed(ActionEvent e) { + } - } + protected void padGapsMenuitem_actionPerformed(ActionEvent e) { + } + protected void ClustalRealign_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GAlignmentPanel.java b/src/jalview/jbgui/GAlignmentPanel.java index fc6fc1e..fc8b8dd 100755 --- a/src/jalview/jbgui/GAlignmentPanel.java +++ b/src/jalview/jbgui/GAlignmentPanel.java @@ -15,93 +15,88 @@ * 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.*; - -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(); - } - } - 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); - // 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); - } - - -} +*/ +package jalview.jbgui; + +import java.awt.*; + +import javax.swing.*; +import javax.swing.border.*; + + +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(); + } + } + + 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); + + // 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); + } +} diff --git a/src/jalview/jbgui/GCutAndPasteTransfer.java b/src/jalview/jbgui/GCutAndPasteTransfer.java index 7b0c621..8b2582c 100755 --- a/src/jalview/jbgui/GCutAndPasteTransfer.java +++ b/src/jalview/jbgui/GCutAndPasteTransfer.java @@ -16,145 +16,114 @@ * 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 javax.swing.*; import java.awt.*; import java.awt.event.*; -import java.beans.VetoableChangeListener; + import java.beans.PropertyChangeEvent; import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; -public class GCutAndPasteTransfer extends JInternalFrame -{ - protected JTextArea textarea = new JTextArea(); - protected JScrollPane scrollPane = new JScrollPane(); - BorderLayout borderLayout1 = new BorderLayout(); - JMenuBar editMenubar = new JMenuBar(); - JMenu editMenu = new JMenu(); - JMenuItem copyItem = new JMenuItem(); - JMenuItem pasteMenu = new JMenuItem(); - BorderLayout borderLayout2 = new BorderLayout(); - protected JPanel inputButtonPanel = new JPanel(); - JButton ok = new JButton(); - JButton cancel = new JButton(); - public GCutAndPasteTransfer() - { - try - { - setJMenuBar(editMenubar); - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - - } - 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_actionPerformed(e); - } - }); - cancel.setText("Cancel"); - 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_vetoableChange(evt); - } - catch (java.beans.PropertyVetoException exception0) - { - exception0.printStackTrace(); - } - - } - }); - editMenubar.add(editMenu); - textarea.setFont(new java.awt.Font("Verdana", 0, 12)); - 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_actionPerformed(e); - } - }); - copyItem.setText("Copy"); - copyItem.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - copyItem_actionPerformed(e); - } - }); - this.getContentPane().setLayout(borderLayout2); - scrollPane.setBorder(null); - scrollPane.getViewport().add(textarea, null); - editMenu.add(copyItem); - editMenu.add(pasteMenu); - this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER); - inputButtonPanel.add(ok); - inputButtonPanel.add(cancel); - - } - - void textarea_mousePressed(MouseEvent e) - { - if(textarea.getText().equals("Paste your alignment file here")) - textarea.setText(""); - } - - public void copyItem_actionPerformed(ActionEvent e) - { - - } +import javax.swing.*; - public void pasteMenu_actionPerformed(ActionEvent e) - { - } +public class GCutAndPasteTransfer extends JInternalFrame { + protected JTextArea textarea = new JTextArea(); + protected JScrollPane scrollPane = new JScrollPane(); + BorderLayout borderLayout1 = new BorderLayout(); + JMenuBar editMenubar = new JMenuBar(); + JMenu editMenu = new JMenu(); + JMenuItem copyItem = new JMenuItem(); + JMenuItem pasteMenu = new JMenuItem(); + BorderLayout borderLayout2 = new BorderLayout(); + protected JPanel inputButtonPanel = new JPanel(); + JButton ok = new JButton(); + JButton cancel = new JButton(); + + public GCutAndPasteTransfer() { + try { + setJMenuBar(editMenubar); + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } - public void ok_actionPerformed(ActionEvent e) - { + 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_actionPerformed(e); + } + }); + cancel.setText("Cancel"); + 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_vetoableChange(evt); + } catch (java.beans.PropertyVetoException exception0) { + exception0.printStackTrace(); + } + } + }); + editMenubar.add(editMenu); + textarea.setFont(new java.awt.Font("Verdana", 0, 12)); + 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_actionPerformed(e); + } + }); + copyItem.setText("Copy"); + copyItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + copyItem_actionPerformed(e); + } + }); + this.getContentPane().setLayout(borderLayout2); + scrollPane.setBorder(null); + scrollPane.getViewport().add(textarea, null); + editMenu.add(copyItem); + editMenu.add(pasteMenu); + this.getContentPane().add(scrollPane, java.awt.BorderLayout.CENTER); + inputButtonPanel.add(ok); + inputButtonPanel.add(cancel); + } - } + void textarea_mousePressed(MouseEvent e) { + if (textarea.getText().equals("Paste your alignment file here")) { + textarea.setText(""); + } + } - public void cancel_actionPerformed(ActionEvent e) - { + public void copyItem_actionPerformed(ActionEvent e) { + } - } + public void pasteMenu_actionPerformed(ActionEvent e) { + } - public void textarea_vetoableChange(PropertyChangeEvent evt) - throws PropertyVetoException - { + public void ok_actionPerformed(ActionEvent e) { + } - } + public void cancel_actionPerformed(ActionEvent e) { + } + public void textarea_vetoableChange(PropertyChangeEvent evt) + throws PropertyVetoException { + } } diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 1dc49b7..06340c3 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -16,194 +16,159 @@ * 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 javax.swing.*; -import java.awt.event.*; import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +public class GDesktop extends JFrame { + protected static JMenu windowMenu = new JMenu(); + JMenuBar DesktopMenubar = new JMenuBar(); + JMenu FileMenu = new JMenu(); + JMenu HelpMenu = new JMenu(); + JMenuItem inputLocalFileMenuItem = new JMenuItem(); + JMenuItem inputURLMenuItem = new JMenuItem(); + JMenuItem inputTextboxMenuItem = new JMenuItem(); + JMenuItem quit = new JMenuItem(); + JMenuItem aboutMenuItem = new JMenuItem(); + JMenuItem documentationMenuItem = new JMenuItem(); + FlowLayout flowLayout1 = new FlowLayout(); + JMenu toolsMenu = new JMenu(); + JMenuItem preferences = new JMenuItem(); + JMenuItem saveState = new JMenuItem(); + JMenuItem loadState = new JMenuItem(); + JMenu jMenu1 = new JMenu(); + + public GDesktop() { + try { + jbInit(); + this.setJMenuBar(DesktopMenubar); + } catch (Exception e) { + e.printStackTrace(); + } + } + + 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_actionPerformed(e); + } + }); + inputURLMenuItem.setMnemonic('U'); + inputURLMenuItem.setText("from URL"); + 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_actionPerformed(e); + } + }); + quit.setMnemonic('Q'); + quit.setText("Quit"); + quit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + quit_actionPerformed(e); + } + }); + aboutMenuItem.setText("About"); + 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_actionPerformed(e); + } + }); + this.getContentPane().setLayout(flowLayout1); + windowMenu.setText("Window"); + preferences.setText("Preferences..."); + 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_actionPerformed(e); + } + }); + loadState.setMnemonic('L'); + loadState.setText("Load Project"); + loadState.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + loadState_actionPerformed(e); + } + }); + jMenu1.setMnemonic('I'); + jMenu1.setText("Input Alignment"); + DesktopMenubar.add(FileMenu); + DesktopMenubar.add(toolsMenu); + DesktopMenubar.add(HelpMenu); + DesktopMenubar.add(windowMenu); + FileMenu.addSeparator(); + FileMenu.add(jMenu1); + FileMenu.addSeparator(); + FileMenu.add(saveState); + FileMenu.add(loadState); + FileMenu.addSeparator(); + FileMenu.add(quit); + HelpMenu.add(aboutMenuItem); + HelpMenu.add(documentationMenuItem); + toolsMenu.add(preferences); + jMenu1.add(inputLocalFileMenuItem); + jMenu1.add(inputURLMenuItem); + jMenu1.add(inputTextboxMenuItem); + } + + protected void inputLocalFileMenuItem_actionPerformed(ActionEvent e) { + } + + protected void inputURLMenuItem_actionPerformed(ActionEvent e) { + } + + protected void inputTextboxMenuItem_actionPerformed(ActionEvent e) { + } + + protected void quit_actionPerformed(ActionEvent e) { + } + + protected void aboutMenuItem_actionPerformed(ActionEvent e) { + } + protected void documentationMenuItem_actionPerformed(ActionEvent e) { + } + + public void SaveState_actionPerformed(ActionEvent e) { + } -public class GDesktop extends JFrame -{ - JMenuBar DesktopMenubar = new JMenuBar(); - JMenu FileMenu = new JMenu(); - JMenu HelpMenu = new JMenu(); - JMenuItem inputLocalFileMenuItem = new JMenuItem(); - JMenuItem inputURLMenuItem = new JMenuItem(); - JMenuItem inputTextboxMenuItem = new JMenuItem(); - JMenuItem quit = new JMenuItem(); - JMenuItem aboutMenuItem = new JMenuItem(); - JMenuItem documentationMenuItem = new JMenuItem(); - FlowLayout flowLayout1 = new FlowLayout(); - protected static JMenu windowMenu = new JMenu(); - JMenu toolsMenu = new JMenu(); - JMenuItem preferences = new JMenuItem(); - JMenuItem saveState = new JMenuItem(); - JMenuItem loadState = new JMenuItem(); - JMenu jMenu1 = new JMenu(); - public GDesktop() - { - try - { - jbInit(); - this.setJMenuBar(DesktopMenubar); + protected void preferences_actionPerformed(ActionEvent e) { } - catch(Exception e) - { - e.printStackTrace(); + + public void saveState_actionPerformed(ActionEvent e) { } - } - 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_actionPerformed(e); - } - }); - inputURLMenuItem.setMnemonic('U'); - inputURLMenuItem.setText("from URL"); - 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_actionPerformed(e); - } - }); - quit.setMnemonic('Q'); - quit.setText("Quit"); - quit.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - quit_actionPerformed(e); - } - }); - aboutMenuItem.setText("About"); - 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_actionPerformed(e); - } - }); - this.getContentPane().setLayout(flowLayout1); - windowMenu.setText("Window"); - preferences.setText("Preferences..."); - 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_actionPerformed(e); - } - }); - loadState.setMnemonic('L'); - loadState.setText("Load Project"); - loadState.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - loadState_actionPerformed(e); - } - }); - jMenu1.setMnemonic('I'); - jMenu1.setText("Input Alignment"); - DesktopMenubar.add(FileMenu); - DesktopMenubar.add(toolsMenu); - DesktopMenubar.add(HelpMenu); - DesktopMenubar.add(windowMenu); - FileMenu.addSeparator(); - FileMenu.add(jMenu1); - FileMenu.addSeparator(); - FileMenu.add(saveState); - FileMenu.add(loadState); - FileMenu.addSeparator(); - FileMenu.add(quit); - HelpMenu.add(aboutMenuItem); - HelpMenu.add(documentationMenuItem); - toolsMenu.add(preferences); - jMenu1.add(inputLocalFileMenuItem); - jMenu1.add(inputURLMenuItem); - jMenu1.add(inputTextboxMenuItem); - - } - - protected void inputLocalFileMenuItem_actionPerformed(ActionEvent e) - { } - - protected void inputURLMenuItem_actionPerformed(ActionEvent e) - { } - - protected void inputTextboxMenuItem_actionPerformed(ActionEvent e) - { } - - protected void quit_actionPerformed(ActionEvent e) - { } - - protected void aboutMenuItem_actionPerformed(ActionEvent e) - { } - - protected void documentationMenuItem_actionPerformed(ActionEvent e) - { } - - public void SaveState_actionPerformed(ActionEvent e) - { - - } - - protected void preferences_actionPerformed(ActionEvent e) - { - - } - - public void saveState_actionPerformed(ActionEvent e) - { - - } - - public void loadState_actionPerformed(ActionEvent e) - { - - } - - public void loadJalviewAlign_actionPerformed(ActionEvent e) - { - - } + public void loadState_actionPerformed(ActionEvent e) { + } + + public void loadJalviewAlign_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index b7cd2e8..5aa9db1 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -16,126 +16,100 @@ * 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 javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.*; -public class GFinder extends JPanel -{ - JLabel jLabel1 = new JLabel(); - protected JTextField textfield = new JTextField(); - protected JButton findAll = new JButton(); - protected JButton findNext = new JButton(); - JPanel jPanel1 = new JPanel(); - GridLayout gridLayout1 = new GridLayout(); - protected JButton createNewGroup = new JButton(); - public GFinder() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); +public class GFinder extends JPanel { + JLabel jLabel1 = new JLabel(); + protected JTextField textfield = new JTextField(); + protected JButton findAll = new JButton(); + protected JButton findNext = new JButton(); + JPanel jPanel1 = new JPanel(); + GridLayout gridLayout1 = new GridLayout(); + protected JButton createNewGroup = new JButton(); + + 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"); - jLabel1.setBounds(new Rectangle(3, 30, 34, 15)); - this.setLayout(null); - textfield.setFont(new java.awt.Font("Verdana", 0, 12)); - textfield.setText(""); - textfield.setBounds(new Rectangle(40, 27, 133, 21)); - textfield.addKeyListener(new java.awt.event.KeyAdapter() - { - public void keyTyped(KeyEvent e) - { - textfield_keyTyped(e); - } - }); - textfield.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(ActionEvent e) - { - textfield_actionPerformed(e); - } - }); - 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); - } - }); - jPanel1.setBounds(new Rectangle(180, 5, 141, 64)); - 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); - } - }); - jPanel1.add(findNext, null); - jPanel1.add(findAll, null); - jPanel1.add(createNewGroup, null); - this.add(textfield, null); - this.add(jLabel1, null); - this.add(jPanel1, null); - } - - protected void findNext_actionPerformed(ActionEvent e) - { - - } - - protected void findAll_actionPerformed(ActionEvent e) - { - - } + private void jbInit() throws Exception { + jLabel1.setFont(new java.awt.Font("Verdana", 0, 12)); + jLabel1.setText("Find"); + jLabel1.setBounds(new Rectangle(3, 30, 34, 15)); + this.setLayout(null); + textfield.setFont(new java.awt.Font("Verdana", 0, 12)); + textfield.setText(""); + textfield.setBounds(new Rectangle(40, 27, 133, 21)); + textfield.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(KeyEvent e) { + textfield_keyTyped(e); + } + }); + textfield.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(ActionEvent e) { + textfield_actionPerformed(e); + } + }); + 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); + } + }); + jPanel1.setBounds(new Rectangle(180, 5, 141, 64)); + 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); + } + }); + jPanel1.add(findNext, null); + jPanel1.add(findAll, null); + jPanel1.add(createNewGroup, null); + this.add(textfield, null); + this.add(jLabel1, null); + this.add(jPanel1, null); + } - protected void textfield_actionPerformed(ActionEvent e) - { - - } + protected void findNext_actionPerformed(ActionEvent e) { + } - void textfield_keyTyped(KeyEvent e) - { - findNext.setEnabled(true); - } + protected void findAll_actionPerformed(ActionEvent e) { + } - public void createNewGroup_actionPerformed(ActionEvent e) - { + protected void textfield_actionPerformed(ActionEvent e) { + } - } + void textfield_keyTyped(KeyEvent e) { + findNext.setEnabled(true); + } + public void createNewGroup_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GFontChooser.java b/src/jalview/jbgui/GFontChooser.java index 5966af5..4ca3b42 100755 --- a/src/jalview/jbgui/GFontChooser.java +++ b/src/jalview/jbgui/GFontChooser.java @@ -16,167 +16,138 @@ * 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 javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.*; -public class GFontChooser extends JPanel -{ - JLabel jLabel1 = new JLabel(); - protected JComboBox fontSize = new JComboBox(); - protected JComboBox fontStyle = new JComboBox(); - JLabel jLabel2 = new JLabel(); - JLabel jLabel3 = new JLabel(); - protected JComboBox fontName = new JComboBox(); - JButton ok = new JButton(); - JButton cancel = new JButton(); - JPanel jPanel1 = new JPanel(); - JPanel jPanel2 = new JPanel(); - JPanel jPanel3 = new JPanel(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - BorderLayout borderLayout3 = new BorderLayout(); - FlowLayout flowLayout1 = new FlowLayout(); - JButton defaultButton = new JButton(); - public GFontChooser() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); +public class GFontChooser extends JPanel { + JLabel jLabel1 = new JLabel(); + protected JComboBox fontSize = new JComboBox(); + protected JComboBox fontStyle = new JComboBox(); + JLabel jLabel2 = new JLabel(); + JLabel jLabel3 = new JLabel(); + protected JComboBox fontName = new JComboBox(); + JButton ok = new JButton(); + JButton cancel = new JButton(); + JPanel jPanel1 = new JPanel(); + JPanel jPanel2 = new JPanel(); + JPanel jPanel3 = new JPanel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + BorderLayout borderLayout3 = new BorderLayout(); + FlowLayout flowLayout1 = new FlowLayout(); + JButton defaultButton = new JButton(); + + public GFontChooser() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - } - private void jbInit() throws Exception - { - jLabel1.setFont(new java.awt.Font("Verdana", 0, 11)); - jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel1.setText("Font: "); - jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); - this.setLayout(flowLayout1); - 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_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_actionPerformed(e); - } - }); - jLabel2.setFont(new java.awt.Font("Verdana", 0, 11)); - jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel2.setText("Size: "); - jLabel2.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); - jLabel3.setFont(new java.awt.Font("Verdana", 0, 11)); - jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel3.setText("Style: "); - jLabel3.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); - fontName.setFont(new java.awt.Font("Verdana", 0, 11)); - fontName.setMaximumSize(new Dimension(32767, 32767)); - 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_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_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_actionPerformed(e); - } - }); - this.setBackground(Color.white); - jPanel1.setOpaque(false); - jPanel1.setLayout(borderLayout1); - jPanel2.setOpaque(false); - jPanel2.setLayout(borderLayout3); - jPanel3.setOpaque(false); - jPanel3.setLayout(borderLayout2); - flowLayout1.setAlignment(FlowLayout.CENTER); - flowLayout1.setVgap(5); - defaultButton.setText("Set as Default"); - defaultButton.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - defaultButton_actionPerformed(e); - } - }); - this.add(jPanel1, null); - jPanel1.add(jLabel1, BorderLayout.WEST); - jPanel1.add(fontName, BorderLayout.CENTER); - this.add(jPanel3, null); - this.add(jPanel2, null); - jPanel2.add(jLabel3, BorderLayout.WEST); - jPanel2.add(fontStyle, BorderLayout.CENTER); - jPanel3.add(jLabel2, BorderLayout.WEST); - jPanel3.add(fontSize, BorderLayout.CENTER); - this.add(ok, null); - this.add(cancel, null); - this.add(defaultButton); - } - - protected void ok_actionPerformed(ActionEvent e) - { - - } - - protected void cancel_actionPerformed(ActionEvent e) - { - - } - protected void fontName_actionPerformed(ActionEvent e) - { - - } + private void jbInit() throws Exception { + jLabel1.setFont(new java.awt.Font("Verdana", 0, 11)); + jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); + jLabel1.setText("Font: "); + jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); + this.setLayout(flowLayout1); + 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_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_actionPerformed(e); + } + }); + jLabel2.setFont(new java.awt.Font("Verdana", 0, 11)); + jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); + jLabel2.setText("Size: "); + jLabel2.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); + jLabel3.setFont(new java.awt.Font("Verdana", 0, 11)); + jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); + jLabel3.setText("Style: "); + jLabel3.setVerticalTextPosition(javax.swing.SwingConstants.CENTER); + fontName.setFont(new java.awt.Font("Verdana", 0, 11)); + fontName.setMaximumSize(new Dimension(32767, 32767)); + 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_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_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_actionPerformed(e); + } + }); + this.setBackground(Color.white); + jPanel1.setOpaque(false); + jPanel1.setLayout(borderLayout1); + jPanel2.setOpaque(false); + jPanel2.setLayout(borderLayout3); + jPanel3.setOpaque(false); + jPanel3.setLayout(borderLayout2); + flowLayout1.setAlignment(FlowLayout.CENTER); + flowLayout1.setVgap(5); + defaultButton.setText("Set as Default"); + defaultButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + defaultButton_actionPerformed(e); + } + }); + this.add(jPanel1, null); + jPanel1.add(jLabel1, BorderLayout.WEST); + jPanel1.add(fontName, BorderLayout.CENTER); + this.add(jPanel3, null); + this.add(jPanel2, null); + jPanel2.add(jLabel3, BorderLayout.WEST); + jPanel2.add(fontStyle, BorderLayout.CENTER); + jPanel3.add(jLabel2, BorderLayout.WEST); + jPanel3.add(fontSize, BorderLayout.CENTER); + this.add(ok, null); + this.add(cancel, null); + this.add(defaultButton); + } - protected void fontSize_actionPerformed(ActionEvent e) - { + protected void ok_actionPerformed(ActionEvent e) { + } - } + protected void cancel_actionPerformed(ActionEvent e) { + } - protected void fontStyle_actionPerformed(ActionEvent e) - { + protected void fontName_actionPerformed(ActionEvent e) { + } - } + protected void fontSize_actionPerformed(ActionEvent e) { + } - public void defaultButton_actionPerformed(ActionEvent e) - { + protected void fontStyle_actionPerformed(ActionEvent e) { + } - } + public void defaultButton_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GPCAPanel.java b/src/jalview/jbgui/GPCAPanel.java index 84e84c4..41d188e 100755 --- a/src/jalview/jbgui/GPCAPanel.java +++ b/src/jalview/jbgui/GPCAPanel.java @@ -15,102 +15,84 @@ * 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 java.awt.event.*; - -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); - } - } - 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 xCombobox_actionPerformed(ActionEvent e) - { - - } - - protected void yCombobox_actionPerformed(ActionEvent e) - { - - } - - protected void zCombobox_actionPerformed(ActionEvent e) - { - - } - -} +*/ +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 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); + } + } + + 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 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 e8167cf..96a1a40 100755 --- a/src/jalview/jbgui/GPairwiseAlignPanel.java +++ b/src/jalview/jbgui/GPairwiseAlignPanel.java @@ -15,58 +15,48 @@ * 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 javax.swing.*; -import java.awt.*; -import java.awt.event.*; - - -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 - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - } - 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_actionPerformed(e); - } - }); - this.add(scrollPane, BorderLayout.CENTER); - scrollPane.getViewport().add(textarea, null); - this.add(jPanel1, BorderLayout.SOUTH); - jPanel1.add(viewInEditorButton, null); - } - - protected void viewInEditorButton_actionPerformed(ActionEvent e) - { - - } - -} +*/ +package jalview.jbgui; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +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 { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + 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_actionPerformed(e); + } + }); + this.add(scrollPane, BorderLayout.CENTER); + scrollPane.getViewport().add(textarea, null); + this.add(jPanel1, BorderLayout.SOUTH); + jPanel1.add(viewInEditorButton, null); + } + + protected void viewInEditorButton_actionPerformed(ActionEvent e) { + } +} diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 1ead51c..2ab6edd 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -16,221 +16,193 @@ * 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 javax.swing.*; import java.awt.*; -import java.awt.event.ActionListener; import java.awt.event.ActionEvent; -import javax.swing.border.TitledBorder; +import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -public class GPreferences - extends JPanel -{ - public GPreferences() - { - try - { - jbInit(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private void jbInit() - throws Exception - { - this.setLayout(borderLayout1); - ok.setText("OK"); - 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_actionPerformed(e); - } - }); - visual.setLayout(null); - quality.setEnabled(false); - quality.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - quality.setHorizontalAlignment(SwingConstants.RIGHT); - quality.setHorizontalTextPosition(SwingConstants.LEFT); - quality.setSelected(true); - quality.setText("Quality"); - quality.setBounds(new Rectangle(248, 53, 81, 23)); - jPanel2.setBorder(titledBorder1); - jPanel2.setBounds(new Rectangle(9, 20, 442, 241)); - jPanel2.setLayout(null); - fullID.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fullID.setHorizontalAlignment(SwingConstants.RIGHT); - fullID.setHorizontalTextPosition(SwingConstants.LEFT); - fullID.setText("Full Sequence ID"); - fullID.setBounds(new Rectangle(9, 78, 129, 23)); - fullScreen.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fullScreen.setHorizontalAlignment(SwingConstants.RIGHT); - fullScreen.setHorizontalTextPosition(SwingConstants.LEFT); - fullScreen.setText("Maximise Window"); - fullScreen.setBounds(new Rectangle(5, 29, 132, 23)); - conservation.setEnabled(false); - conservation.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - conservation.setHorizontalAlignment(SwingConstants.RIGHT); - conservation.setHorizontalTextPosition(SwingConstants.LEFT); - conservation.setSelected(true); - conservation.setText("Conservation"); - conservation.setBounds(new Rectangle(137, 53, 113, 23)); - identity.setEnabled(false); - identity.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - identity.setHorizontalAlignment(SwingConstants.RIGHT); - identity.setHorizontalTextPosition(SwingConstants.LEFT); - identity.setSelected(true); - identity.setText("Consensus"); - identity.setBounds(new Rectangle(326, 53, 99, 23)); - annotations.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - annotations.setHorizontalAlignment(SwingConstants.RIGHT); - annotations.setHorizontalTextPosition(SwingConstants.LEFT); - 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_actionPerformed(e); - } - }); - jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel1.setText("Gap Symbol"); - jLabel1.setBounds(new Rectangle(41, 142, 76, 15)); - colour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - colour.setBounds(new Rectangle(121, 168, 154, 21)); - jLabel2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel2.setText("Colour"); - jLabel2.setBounds(new Rectangle(60, 172, 58, 15)); - jLabel3.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); - jLabel3.setText("Font"); - jLabel3.setBounds(new Rectangle(83, 114, 34, 15)); - fontSizeCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fontSizeCB.setBounds(new Rectangle(304, 109, 49, 21)); - fontStyleCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fontStyleCB.setBounds(new Rectangle(353, 109, 80, 21)); - fontNameCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - fontNameCB.setBounds(new Rectangle(121, 109, 183, 21)); - gapSymbolCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - 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) - { - jCheckBox1_actionPerformed(e); - } - }); - startupCheckbox.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); - startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT); - startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT); - 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) - { - startupFileTextfield_mouseClicked(); - } - }); - - jPanel2.add(annotations); - jPanel2.add(conservation); - jPanel2.add(quality); - jPanel2.add(fullID); - jPanel2.add(gapSymbolCB); - jPanel2.add(jLabel1); - jPanel2.add(fontNameCB); - jPanel2.add(jLabel2); - jPanel2.add(jLabel3); - jPanel2.add(colour); - jPanel2.add(fontSizeCB); - jPanel2.add(fontStyleCB); - jPanel2.add(identity); - jPanel2.add(fullScreen); - jPanel2.add(startupCheckbox); - jPanel2.add(startupFileTextfield); - jPanel1.add(ok); - jPanel1.add(cancel); - this.add(visaulTab, java.awt.BorderLayout.CENTER); - visaulTab.add(visual, "visual"); - visual.add(jPanel2); - this.add(jPanel1, java.awt.BorderLayout.SOUTH); - DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); - dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER); - gapSymbolCB.setRenderer(dlcr); - - } - - JTabbedPane visaulTab = new JTabbedPane(); - JPanel visual = new JPanel(); - JButton ok = new JButton(); - JButton cancel = new JButton(); - JPanel jPanel1 = new JPanel(); - BorderLayout borderLayout1 = new BorderLayout(); - protected JCheckBox quality = new JCheckBox(); - JPanel jPanel2 = new JPanel(); - TitledBorder titledBorder1 = new TitledBorder("Open new alignment"); - protected JCheckBox fullID = new JCheckBox(); - protected JCheckBox fullScreen = new JCheckBox(); - protected JCheckBox conservation = new JCheckBox(); - protected JCheckBox identity = new JCheckBox(); - protected JCheckBox annotations = new JCheckBox(); - JLabel jLabel1 = new JLabel(); - protected JComboBox colour = new JComboBox(); - JLabel jLabel2 = new JLabel(); - JLabel jLabel3 = new JLabel(); - protected JComboBox fontSizeCB = new JComboBox(); - protected JComboBox fontStyleCB = new JComboBox(); - protected JComboBox fontNameCB = new JComboBox(); - protected JComboBox gapSymbolCB = new JComboBox(); - protected JCheckBox startupCheckbox = new JCheckBox(); - protected JTextField startupFileTextfield = new JTextField(); - public void ok_actionPerformed(ActionEvent e) - { - - } - - public void cancel_actionPerformed(ActionEvent e) - { - - } +import javax.swing.*; +import javax.swing.border.TitledBorder; - public void annotations_actionPerformed(ActionEvent e) - { - } +public class GPreferences extends JPanel { + JTabbedPane visaulTab = new JTabbedPane(); + JPanel visual = new JPanel(); + JButton ok = new JButton(); + JButton cancel = new JButton(); + JPanel jPanel1 = new JPanel(); + BorderLayout borderLayout1 = new BorderLayout(); + protected JCheckBox quality = new JCheckBox(); + JPanel jPanel2 = new JPanel(); + TitledBorder titledBorder1 = new TitledBorder("Open new alignment"); + protected JCheckBox fullID = new JCheckBox(); + protected JCheckBox fullScreen = new JCheckBox(); + protected JCheckBox conservation = new JCheckBox(); + protected JCheckBox identity = new JCheckBox(); + protected JCheckBox annotations = new JCheckBox(); + JLabel jLabel1 = new JLabel(); + protected JComboBox colour = new JComboBox(); + JLabel jLabel2 = new JLabel(); + JLabel jLabel3 = new JLabel(); + protected JComboBox fontSizeCB = new JComboBox(); + protected JComboBox fontStyleCB = new JComboBox(); + protected JComboBox fontNameCB = new JComboBox(); + protected JComboBox gapSymbolCB = new JComboBox(); + protected JCheckBox startupCheckbox = new JCheckBox(); + protected JTextField startupFileTextfield = new JTextField(); + + public GPreferences() { + try { + jbInit(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } - public void jCheckBox1_actionPerformed(ActionEvent e) - { + private void jbInit() throws Exception { + this.setLayout(borderLayout1); + ok.setText("OK"); + 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_actionPerformed(e); + } + }); + visual.setLayout(null); + quality.setEnabled(false); + quality.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + quality.setHorizontalAlignment(SwingConstants.RIGHT); + quality.setHorizontalTextPosition(SwingConstants.LEFT); + quality.setSelected(true); + quality.setText("Quality"); + quality.setBounds(new Rectangle(248, 53, 81, 23)); + jPanel2.setBorder(titledBorder1); + jPanel2.setBounds(new Rectangle(9, 20, 442, 241)); + jPanel2.setLayout(null); + fullID.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fullID.setHorizontalAlignment(SwingConstants.RIGHT); + fullID.setHorizontalTextPosition(SwingConstants.LEFT); + fullID.setText("Full Sequence ID"); + fullID.setBounds(new Rectangle(9, 78, 129, 23)); + fullScreen.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fullScreen.setHorizontalAlignment(SwingConstants.RIGHT); + fullScreen.setHorizontalTextPosition(SwingConstants.LEFT); + fullScreen.setText("Maximise Window"); + fullScreen.setBounds(new Rectangle(5, 29, 132, 23)); + conservation.setEnabled(false); + conservation.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + conservation.setHorizontalAlignment(SwingConstants.RIGHT); + conservation.setHorizontalTextPosition(SwingConstants.LEFT); + conservation.setSelected(true); + conservation.setText("Conservation"); + conservation.setBounds(new Rectangle(137, 53, 113, 23)); + identity.setEnabled(false); + identity.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + identity.setHorizontalAlignment(SwingConstants.RIGHT); + identity.setHorizontalTextPosition(SwingConstants.LEFT); + identity.setSelected(true); + identity.setText("Consensus"); + identity.setBounds(new Rectangle(326, 53, 99, 23)); + annotations.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + annotations.setHorizontalAlignment(SwingConstants.RIGHT); + annotations.setHorizontalTextPosition(SwingConstants.LEFT); + 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_actionPerformed(e); + } + }); + jLabel1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); + jLabel1.setText("Gap Symbol"); + jLabel1.setBounds(new Rectangle(41, 142, 76, 15)); + colour.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + colour.setBounds(new Rectangle(121, 168, 154, 21)); + jLabel2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); + jLabel2.setText("Colour"); + jLabel2.setBounds(new Rectangle(60, 172, 58, 15)); + jLabel3.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + jLabel3.setHorizontalAlignment(SwingConstants.RIGHT); + jLabel3.setText("Font"); + jLabel3.setBounds(new Rectangle(83, 114, 34, 15)); + fontSizeCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fontSizeCB.setBounds(new Rectangle(304, 109, 49, 21)); + fontStyleCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fontStyleCB.setBounds(new Rectangle(353, 109, 80, 21)); + fontNameCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + fontNameCB.setBounds(new Rectangle(121, 109, 183, 21)); + gapSymbolCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + 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) { + jCheckBox1_actionPerformed(e); + } + }); + startupCheckbox.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT); + startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT); + 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) { + startupFileTextfield_mouseClicked(); + } + }); + + jPanel2.add(annotations); + jPanel2.add(conservation); + jPanel2.add(quality); + jPanel2.add(fullID); + jPanel2.add(gapSymbolCB); + jPanel2.add(jLabel1); + jPanel2.add(fontNameCB); + jPanel2.add(jLabel2); + jPanel2.add(jLabel3); + jPanel2.add(colour); + jPanel2.add(fontSizeCB); + jPanel2.add(fontStyleCB); + jPanel2.add(identity); + jPanel2.add(fullScreen); + jPanel2.add(startupCheckbox); + jPanel2.add(startupFileTextfield); + jPanel1.add(ok); + jPanel1.add(cancel); + this.add(visaulTab, java.awt.BorderLayout.CENTER); + visaulTab.add(visual, "visual"); + visual.add(jPanel2); + this.add(jPanel1, java.awt.BorderLayout.SOUTH); + + DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); + dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER); + gapSymbolCB.setRenderer(dlcr); + } - } + public void ok_actionPerformed(ActionEvent e) { + } + public void cancel_actionPerformed(ActionEvent e) { + } - public void startupFileTextfield_mouseClicked() - { + public void annotations_actionPerformed(ActionEvent e) { + } - } + public void jCheckBox1_actionPerformed(ActionEvent e) { + } + public void startupFileTextfield_mouseClicked() { + } } diff --git a/src/jalview/jbgui/GSliderPanel.java b/src/jalview/jbgui/GSliderPanel.java index 17fdb34..341263f 100755 --- a/src/jalview/jbgui/GSliderPanel.java +++ b/src/jalview/jbgui/GSliderPanel.java @@ -15,132 +15,111 @@ * 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 java.awt.event.*; - -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(); - protected JLabel label = new JLabel(); - JPanel jPanel1 = new JPanel(); - GridLayout gridLayout1 = new GridLayout(); - JPanel jPanel2 = new JPanel(); - protected JButton applyButton = new JButton(); - protected JButton undoButton = new JButton(); - FlowLayout flowLayout1 = new FlowLayout(); - protected JCheckBox allGroupsCheck = new JCheckBox(); - BorderLayout borderLayout1 = new BorderLayout(); - - public GSliderPanel() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - } - private void jbInit() throws Exception - { - this.setLayout(gridLayout1); - slider.setMajorTickSpacing(10); - slider.setMinorTickSpacing(1); - slider.setPaintTicks(true); - slider.setBackground(Color.white); - slider.setFont(new java.awt.Font("Verdana", 0, 11)); - slider.setDoubleBuffered(true); - valueField.setFont(new java.awt.Font("Verdana", 0, 11)); - valueField.setMinimumSize(new Dimension(6, 14)); - 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_actionPerformed(e); - } - }); - label.setFont(new java.awt.Font("Verdana", 0, 11)); - label.setOpaque(false); - label.setHorizontalAlignment(SwingConstants.CENTER); - label.setText("set this label text"); - jPanel1.setLayout(borderLayout1); - gridLayout1.setRows(2); - jPanel2.setLayout(flowLayout1); - 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_actionPerformed(e); - } - }); - undoButton.setEnabled(false); - 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_actionPerformed(e); - } - }); - allGroupsCheck.setEnabled(false); - 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_actionPerformed(e); - } - }); - this.setBackground(Color.white); - this.setPreferredSize(new Dimension(415, 84)); - jPanel2.setOpaque(false); - jPanel1.setOpaque(false); - this.add(jPanel2, null); - jPanel2.add(label, null); - jPanel2.add(applyButton, null); - jPanel2.add(undoButton, null);this.add(jPanel1, null); - jPanel1.add(slider, BorderLayout.WEST); - jPanel1.add(valueField, BorderLayout.CENTER); - jPanel1.add(allGroupsCheck, BorderLayout.EAST); - - } - - protected void valueField_actionPerformed(ActionEvent e) - { - - } - - protected void applyButton_actionPerformed(ActionEvent e) - { - - } - - protected void undoButton_actionPerformed(ActionEvent e) - { - - } - - protected void allGroupsCheck_actionPerformed(ActionEvent e) - { - - } - -} +*/ +package jalview.jbgui; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +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(); + protected JLabel label = new JLabel(); + JPanel jPanel1 = new JPanel(); + GridLayout gridLayout1 = new GridLayout(); + JPanel jPanel2 = new JPanel(); + protected JButton applyButton = new JButton(); + protected JButton undoButton = new JButton(); + FlowLayout flowLayout1 = new FlowLayout(); + protected JCheckBox allGroupsCheck = new JCheckBox(); + BorderLayout borderLayout1 = new BorderLayout(); + + public GSliderPanel() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void jbInit() throws Exception { + this.setLayout(gridLayout1); + slider.setMajorTickSpacing(10); + slider.setMinorTickSpacing(1); + slider.setPaintTicks(true); + slider.setBackground(Color.white); + slider.setFont(new java.awt.Font("Verdana", 0, 11)); + slider.setDoubleBuffered(true); + valueField.setFont(new java.awt.Font("Verdana", 0, 11)); + valueField.setMinimumSize(new Dimension(6, 14)); + 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_actionPerformed(e); + } + }); + label.setFont(new java.awt.Font("Verdana", 0, 11)); + label.setOpaque(false); + label.setHorizontalAlignment(SwingConstants.CENTER); + label.setText("set this label text"); + jPanel1.setLayout(borderLayout1); + gridLayout1.setRows(2); + jPanel2.setLayout(flowLayout1); + 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_actionPerformed(e); + } + }); + undoButton.setEnabled(false); + 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_actionPerformed(e); + } + }); + allGroupsCheck.setEnabled(false); + 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_actionPerformed(e); + } + }); + this.setBackground(Color.white); + this.setPreferredSize(new Dimension(415, 84)); + jPanel2.setOpaque(false); + jPanel1.setOpaque(false); + this.add(jPanel2, null); + jPanel2.add(label, null); + jPanel2.add(applyButton, null); + jPanel2.add(undoButton, null); + this.add(jPanel1, null); + jPanel1.add(slider, BorderLayout.WEST); + jPanel1.add(valueField, BorderLayout.CENTER); + jPanel1.add(allGroupsCheck, BorderLayout.EAST); + } + + protected void valueField_actionPerformed(ActionEvent e) { + } + + protected void applyButton_actionPerformed(ActionEvent e) { + } + + protected void undoButton_actionPerformed(ActionEvent e) { + } + + protected void allGroupsCheck_actionPerformed(ActionEvent e) { + } +} diff --git a/src/jalview/jbgui/GTreePanel.java b/src/jalview/jbgui/GTreePanel.java index 93bb850..5b8c6fa 100755 --- a/src/jalview/jbgui/GTreePanel.java +++ b/src/jalview/jbgui/GTreePanel.java @@ -16,202 +16,155 @@ * 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 java.awt.event.*; -public class GTreePanel extends JInternalFrame -{ - BorderLayout borderLayout1 = new BorderLayout(); - protected JScrollPane scrollPane = new JScrollPane(); - JMenuBar jMenuBar1 = new JMenuBar(); - JMenu jMenu1 = new JMenu(); - JMenuItem saveAsNewick = new JMenuItem(); - JMenuItem printMenu = new JMenuItem(); - JMenu jMenu2 = new JMenu(); - protected JMenuItem fontSize = new JMenuItem(); - protected JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem(); - protected JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem(); - protected JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem(); - protected 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); +import javax.swing.*; + + +public class GTreePanel extends JInternalFrame { + BorderLayout borderLayout1 = new BorderLayout(); + protected JScrollPane scrollPane = new JScrollPane(); + JMenuBar jMenuBar1 = new JMenuBar(); + JMenu jMenu1 = new JMenu(); + JMenuItem saveAsNewick = new JMenuItem(); + JMenuItem printMenu = new JMenuItem(); + JMenu jMenu2 = new JMenu(); + protected JMenuItem fontSize = new JMenuItem(); + protected JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem(); + protected JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem(); + protected 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); + } + + protected void printMenu_actionPerformed(ActionEvent e) { + } + + protected void fontSize_actionPerformed(ActionEvent e) { + } + + protected void distanceMenu_actionPerformed(ActionEvent e) { + } + + protected void bootstrapMenu_actionPerformed(ActionEvent e) { + } + + protected void fitToWindow_actionPerformed(ActionEvent e) { + } + + protected void pngTree_actionPerformed(ActionEvent e) { + } + + protected void epsTree_actionPerformed(ActionEvent e) { } - catch(Exception e) - { - e.printStackTrace(); + + protected void saveAsNewick_actionPerformed(ActionEvent e) { } - } - 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); - } - - - protected void printMenu_actionPerformed(ActionEvent e) - { - - } - - protected void fontSize_actionPerformed(ActionEvent e) - { - - } - - protected void distanceMenu_actionPerformed(ActionEvent e) - { - - } - - protected void bootstrapMenu_actionPerformed(ActionEvent e) - { - - } - - protected void fitToWindow_actionPerformed(ActionEvent e) - { - - } - - protected void pngTree_actionPerformed(ActionEvent e) - { - - } - - protected void epsTree_actionPerformed(ActionEvent e) - { - - } - - protected void saveAsNewick_actionPerformed(ActionEvent e) - { - - } - - protected void placeholdersMenu_actionPerformed(ActionEvent e) - { - - } - - public void textbox_actionPerformed(ActionEvent e) - { - - } + protected 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 4d62593..3cd9f51 100755 --- a/src/jalview/jbgui/GUserDefinedColours.java +++ b/src/jalview/jbgui/GUserDefinedColours.java @@ -16,125 +16,99 @@ * 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 javax.swing.*; import java.awt.*; import java.awt.event.*; +import javax.swing.*; -public class GUserDefinedColours extends JPanel -{ - protected JColorChooser colorChooser = new JColorChooser(); - protected JPanel buttonPanel = new JPanel(); - protected GridLayout gridLayout = new GridLayout(); - JPanel jPanel2 = new JPanel(); - protected JButton okButton = new JButton(); - protected JButton applyButton = new JButton(); - protected JButton loadbutton = new JButton(); - protected JButton savebutton = new JButton(); - protected JButton cancelButton = new JButton(); - FlowLayout flowLayout1 = new FlowLayout(); - public GUserDefinedColours() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); +public class GUserDefinedColours extends JPanel { + protected JColorChooser colorChooser = new JColorChooser(); + protected JPanel buttonPanel = new JPanel(); + protected GridLayout gridLayout = new GridLayout(); + JPanel jPanel2 = new JPanel(); + protected JButton okButton = new JButton(); + protected JButton applyButton = new JButton(); + protected JButton loadbutton = new JButton(); + protected JButton savebutton = new JButton(); + protected JButton cancelButton = new JButton(); + FlowLayout flowLayout1 = new FlowLayout(); + + public GUserDefinedColours() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } } - } - 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_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_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_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_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_actionPerformed(e); - } - }); - this.setBackground(new Color(212, 208, 223)); - jPanel2.setOpaque(false); - colorChooser.setOpaque(false); - this.add(colorChooser, null); - this.add(buttonPanel, null); - this.add(jPanel2, null); - jPanel2.add(okButton, null); - jPanel2.add(applyButton, null); - jPanel2.add(loadbutton, null); - jPanel2.add(savebutton, null); - jPanel2.add(cancelButton, null); - } - - - protected void okButton_actionPerformed(ActionEvent e) - { - - } - - protected void applyButton_actionPerformed(ActionEvent e) - { - } - - protected void loadbutton_actionPerformed(ActionEvent e) - { + 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_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_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_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_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_actionPerformed(e); + } + }); + this.setBackground(new Color(212, 208, 223)); + jPanel2.setOpaque(false); + colorChooser.setOpaque(false); + this.add(colorChooser, null); + this.add(buttonPanel, null); + this.add(jPanel2, null); + jPanel2.add(okButton, null); + jPanel2.add(applyButton, null); + jPanel2.add(loadbutton, null); + jPanel2.add(savebutton, null); + jPanel2.add(cancelButton, null); + } - } + protected void okButton_actionPerformed(ActionEvent e) { + } - protected void savebutton_actionPerformed(ActionEvent e) - { + protected void applyButton_actionPerformed(ActionEvent e) { + } - } + protected void loadbutton_actionPerformed(ActionEvent e) { + } - protected void cancelButton_actionPerformed(ActionEvent e) - { + protected void savebutton_actionPerformed(ActionEvent e) { + } - } + protected void cancelButton_actionPerformed(ActionEvent e) { + } } diff --git a/src/jalview/jbgui/GWebserviceInfo.java b/src/jalview/jbgui/GWebserviceInfo.java index 4d3aab6..54eab04 100755 --- a/src/jalview/jbgui/GWebserviceInfo.java +++ b/src/jalview/jbgui/GWebserviceInfo.java @@ -15,86 +15,80 @@ * 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 java.awt.event.*; - -public class GWebserviceInfo extends JPanel -{ - protected JTextArea infoText = new JTextArea(); - JScrollPane jScrollPane1 = new JScrollPane(); - JScrollPane jScrollPane2 = new JScrollPane(); - protected JTextArea progressText = new JTextArea(); - JPanel jPanel1 = new JPanel(); - BorderLayout borderLayout1 = new BorderLayout(); - BorderLayout borderLayout2 = new BorderLayout(); - protected JPanel titlePanel = new JPanel(); - BorderLayout borderLayout3 = new BorderLayout(); - JPanel jPanel2 = new JPanel(); - protected JButton cancel = new JButton(); - GridBagLayout gridBagLayout1 = new GridBagLayout(); - - public GWebserviceInfo() - { - try - { - jbInit(); - } - catch(Exception e) - { - e.printStackTrace(); - } - } - private void jbInit() throws Exception - { - infoText.setFont(new java.awt.Font("Verdana", 0, 10)); - infoText.setBorder(null); - infoText.setEditable(false); - infoText.setText(""); - infoText.setLineWrap(true); - infoText.setWrapStyleWord(true); - this.setLayout(borderLayout1); - progressText.setFont(new java.awt.Font("Verdana", 0, 10)); - progressText.setBorder(null); - progressText.setEditable(false); - progressText.setText(""); - progressText.setLineWrap(true); - progressText.setWrapStyleWord(true); - jPanel1.setLayout(borderLayout2); - titlePanel.setBackground(Color.white); - titlePanel.setPreferredSize(new Dimension(0, 60)); - titlePanel.setLayout(borderLayout3); - jScrollPane2.setBorder(null); - jScrollPane1.setBorder(null); - 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_actionPerformed(e); - } - }); - jPanel2.setLayout(gridBagLayout1); - jPanel2.setOpaque(false); - this.add(jScrollPane2, BorderLayout.CENTER); - this.add(jPanel1, BorderLayout.NORTH); - jPanel1.add(jScrollPane1, BorderLayout.CENTER); - jScrollPane1.getViewport().add(infoText, null); - jScrollPane2.getViewport().add(progressText, null); - jPanel1.add(titlePanel, BorderLayout.NORTH); - titlePanel.add(jPanel2, BorderLayout.EAST); - jPanel2.add(cancel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 - ,GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(24, 5, 21, 5), 0, 0)); - } - - protected void cancel_actionPerformed(ActionEvent e) - { - - } -} +*/ +package jalview.jbgui; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +public class GWebserviceInfo extends JPanel { + protected JTextArea infoText = new JTextArea(); + JScrollPane jScrollPane1 = new JScrollPane(); + JScrollPane jScrollPane2 = new JScrollPane(); + protected JTextArea progressText = new JTextArea(); + JPanel jPanel1 = new JPanel(); + BorderLayout borderLayout1 = new BorderLayout(); + BorderLayout borderLayout2 = new BorderLayout(); + protected JPanel titlePanel = new JPanel(); + BorderLayout borderLayout3 = new BorderLayout(); + JPanel jPanel2 = new JPanel(); + protected JButton cancel = new JButton(); + GridBagLayout gridBagLayout1 = new GridBagLayout(); + + public GWebserviceInfo() { + try { + jbInit(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void jbInit() throws Exception { + infoText.setFont(new java.awt.Font("Verdana", 0, 10)); + infoText.setBorder(null); + infoText.setEditable(false); + infoText.setText(""); + infoText.setLineWrap(true); + infoText.setWrapStyleWord(true); + this.setLayout(borderLayout1); + progressText.setFont(new java.awt.Font("Verdana", 0, 10)); + progressText.setBorder(null); + progressText.setEditable(false); + progressText.setText(""); + progressText.setLineWrap(true); + progressText.setWrapStyleWord(true); + jPanel1.setLayout(borderLayout2); + titlePanel.setBackground(Color.white); + titlePanel.setPreferredSize(new Dimension(0, 60)); + titlePanel.setLayout(borderLayout3); + jScrollPane2.setBorder(null); + jScrollPane1.setBorder(null); + 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_actionPerformed(e); + } + }); + jPanel2.setLayout(gridBagLayout1); + jPanel2.setOpaque(false); + this.add(jScrollPane2, BorderLayout.CENTER); + this.add(jPanel1, BorderLayout.NORTH); + jPanel1.add(jScrollPane1, BorderLayout.CENTER); + jScrollPane1.getViewport().add(infoText, null); + jScrollPane2.getViewport().add(progressText, null); + jPanel1.add(titlePanel, BorderLayout.NORTH); + titlePanel.add(jPanel2, BorderLayout.EAST); + jPanel2.add(cancel, + new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, + GridBagConstraints.SOUTH, GridBagConstraints.NONE, + new Insets(24, 5, 21, 5), 0, 0)); + } + + protected void cancel_actionPerformed(ActionEvent e) { + } +} diff --git a/src/jalview/math/Matrix.java b/src/jalview/math/Matrix.java index 3b93d6d..30c534b 100755 --- a/src/jalview/math/Matrix.java +++ b/src/jalview/math/Matrix.java @@ -16,576 +16,623 @@ * 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.math; import jalview.util.*; import java.io.*; -public class Matrix { - - /** - * SMJSPUBLIC - */ - public double[][] value; - public int rows; - public int cols; - public double[] d; // Diagonal - public double[] e; // off diagonal - - public Matrix(double[][] value, int rows, int cols) { - this.rows = rows; - this.cols = cols; - this.value = value; - } - - public Matrix transpose() { - double[][] out = new double[cols][rows]; - - for (int i = 0; i < cols; i++) { - for (int j = 0; j < rows ; j++) { - out[i][j] = value[j][i]; - } - } - 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++) { - Format.print(ps,"%8.2f",value[i][j]); - } - ps.println(); +public class Matrix { + /** + * SMJSPUBLIC + */ + public double[][] value; + public int rows; + public int cols; + public double[] d; // Diagonal + public double[] e; // off diagonal + + public Matrix(double[][] value, int rows, int cols) { + this.rows = rows; + this.cols = cols; + this.value = value; } - } + public Matrix transpose() { + double[][] out = new double[cols][rows]; - 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++ ) { - tmp[i][j] = 0.0; - - for (int k = 0; k < in.cols; k++) { - tmp[i][j] += in.value[i][k]*this.value[k][j]; + for (int i = 0; i < cols; i++) { + for (int j = 0; j < rows; j++) { + out[i][j] = value[j][i]; + } } - } + return new Matrix(out, cols, rows); } - return new Matrix(tmp,in.rows,this.cols); - } + 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]); + } - public double[] vectorPostMultiply(double[] in) { - double[] out = new double[in.length]; - for (int i = 0; i < in.length; i++) { - out[i] = 0.0; - for (int k=0; k < in.length; k++) { - out[i] += value[i][k] * in[k]; - } + ps.println(); + } } - return out; - } - 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++ ) { + public Matrix preMultiply(Matrix in) { + double[][] tmp = new double[in.rows][this.cols]; - out[i][j] = 0.0; + 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 < rows; k++) { - out[i][j] = out[i][j] + value[i][k]*in.value[k][j]; + for (int k = 0; k < in.cols; k++) { + tmp[i][j] += (in.value[i][k] * this.value[k][j]); + } + } } - } + return new Matrix(tmp, in.rows, this.cols); } - return new Matrix(out,this.cols,in.rows); - } - public Matrix copy() { - double[][] newmat = new double[rows][cols]; + public double[] vectorPostMultiply(double[] in) { + double[] out = new double[in.length]; - for (int i = 0; i < rows; i++) { - for (int j = 0; j < cols; j++) { - newmat[i][j] = value[i][j]; - } - } - return new Matrix(newmat,rows,cols); - } - - public void tred() { - int n = rows; - int l; - int k; - int j; - int i; - - double scale; - double hh; - double h; - double g; - double f; - - this.d = new double[rows]; - this.e = new double[rows]; - - for (i=n; i >= 2;i--) { - l=i-1; - h = 0.0; - scale = 0.0; - - if (l > 1) { - for (k=1;k<=l;k++) { - scale += Math.abs(value[i-1][k-1]); - } - if (scale == 0.0) { - e[i-1] = value[i-1][l-1]; - } 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) { - g = -1.0*Math.sqrt(h); - } else { - g = Math.sqrt(h); - } - e[i-1] = scale*g; - h -= f*g; - value[i-1][l-1] = f-g; - f=0.0; - 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++) { - g += value[j-1][k-1]*value[i-1][k-1]; - } - for (k=j+1; k<=l;k++) { - g+= value[k-1][j-1]*value[i-1][k-1]; - } - e[j-1] = g/h; - f+=e[j-1]*value[i-1][j-1]; - } - hh=f/(h+h); - 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++) { - value[j-1][k-1] -= (f*e[k-1]+g*value[i-1][k-1]); - } - } - } - } else { - e[i-1] = value[i-1][l-1]; - } - d[i-1] = h; - } - d[0] = 0.0; - e[0] = 0.0; - for (i=1;i<=n;i++) { - l=i-1; - if (d[i-1] != 0.0) { - for (j=1;j<=l;j++) { - g=0.0; - for (k=1;k<=l;k++) { - g+= value[i-1][k-1]*value[k-1][j-1]; - } - for (k=1;k<=l;k++) { - value[k-1][j-1] -= g*value[k-1][i-1]; - } - } - } - d[i-1] = value[i-1][i-1]; - value[i-1][i-1] = 1.0; - for (j=1;j<=l;j++) { - value[j-1][i-1] = 0.0; - value[i-1][j-1] = 0.0; - } - } - } - - public void tqli() { - int n = rows; - - int m; - int l; - int iter; - int i; - int k; - double s; - double r; - double p; - ; - double g; - double f; - double dd; - double c; - double b; - - for (i=2;i<=n;i++) { - e[i-2] = e[i-1]; - } - e[n-1] = 0.0; - for (l=1;l<=n;l++) { - iter=0; - 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) - break; - } - if (m != l) { - iter++; - if (iter == 30) { - System.err.print("Too many iterations in tqli"); - System.exit(0); // JBPNote - should this really be here ??? - } else { - // System.out.println("Iteration " + iter); - } - g=(d[l]-d[l-1])/(2.0*e[l-1]); - r = Math.sqrt((g*g) + 1.0); - g=d[m-1]-d[l-1]+e[l-1]/(g + sign(r,g)); - c = 1.0; - s = c; - p=0.0; - for (i=m-1;i>=l;i--) { - f = s*e[i-1]; - b = c*e[i-1]; - 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 { - s=f/g; - r = Math.sqrt((s*s)+1.0); - e[i] = g*r; - c = 1.0/r; - s *= c; - } - g=d[i] -p; - r=(d[i-1]-g)*s + 2.0*c*b; - p=s*r; - d[i] = g + p; - g = c * r - b; - for (k=1; k <= n; k++) { - f=value[k-1][i]; - value[k-1][i] = s*value[k-1][i-1] + c*f; - value[k-1][i-1] = c*value[k-1][i-1] - s*f; - } - } - d[l-1] = d[l-1] - p; - e[l-1] = g; - e[m-1] = 0.0; - } - } while ( m != l); - } - } - public void tred2() { - int n = rows; - int l; - int k; - int j; - int i; - - double scale; - double hh; - double h; - double g; - double f; - - this.d = new double[rows]; - this.e = new double[rows]; - - for (i=n-1; i >= 1;i--) { - l=i-1; - h = 0.0; - scale = 0.0; - - if (l > 0) { - for (k=0;k0) { - g = -1.0*Math.sqrt(h); - } else { - g = Math.sqrt(h); - } - e[i] = scale*g; - h -= f*g; - value[i][l] = f-g; - f=0.0; - for (j=0; j < l; j++) { - value[j][i] = value[i][j]/h; - g=0.0; - for (k= 0; k < j; k++) { - g += value[j][k]*value[i][k]; - } - for (k=j; k=l;i--) { - f = s*e[i-1]; - b = c*e[i-1]; - 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 { - s=f/g; - r = Math.sqrt((s*s)+1.0); - e[i] = g*r; - c = 1.0/r; - s *= c; - } - g=d[i] -p; - r=(d[i-1]-g)*s + 2.0*c*b; - p=s*r; - d[i] = g + p; - g = c * r - b; - for (k=1; k <= n; k++) { - f=value[k-1][i]; - value[k-1][i] = s*value[k-1][i-1] + c*f; - value[k-1][i-1] = c*value[k-1][i-1] - s*f; + for (int i = 0; i < in.length; i++) { + out[i] = 0.0; + + for (int k = 0; k < in.length; k++) { + out[i] += (value[i][k] * in[k]); } - } - d[l-1] = d[l-1] - p; - e[l-1] = g; - e[m-1] = 0.0; } - } while ( m != l); - } - } - public double sign(double a, double b) { - if (b < 0) { - return -Math.abs(a); - } else { - return Math.abs(a); + return out; } - } - public double[] getColumn(int n) { - double[] out = new double[rows]; - for (int i=0;i= 2; i--) { + l = i - 1; + h = 0.0; + scale = 0.0; + + if (l > 1) { + for (k = 1; k <= l; k++) { + scale += Math.abs(value[i - 1][k - 1]); + } + + if (scale == 0.0) { + e[i - 1] = value[i - 1][l - 1]; + } 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) { + g = -1.0 * Math.sqrt(h); + } else { + g = Math.sqrt(h); + } + + e[i - 1] = scale * g; + h -= (f * g); + value[i - 1][l - 1] = f - g; + f = 0.0; + + 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++) { + g += (value[j - 1][k - 1] * value[i - 1][k - 1]); + } + + for (k = j + 1; k <= l; k++) { + g += (value[k - 1][j - 1] * value[i - 1][k - 1]); + } + + e[j - 1] = g / h; + f += (e[j - 1] * value[i - 1][j - 1]); + } + + hh = f / (h + h); + + 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++) { + value[j - 1][k - 1] -= ((f * e[k - 1]) + + (g * value[i - 1][k - 1])); + } + } + } + } else { + e[i - 1] = value[i - 1][l - 1]; + } + d[i - 1] = h; + } - // This produces the tridiagonal transformation matrix - long tstart = System.currentTimeMillis(); - symm.tred(); - long tend = System.currentTimeMillis(); - //System.out.println("Time take for tred = " + (tend-tstart) + "ms"); - //System.out.println(" ---Tridiag transform matrix ---"); - //symm.print(System.out); - //System.out.println(); + d[0] = 0.0; + e[0] = 0.0; - //System.out.println(" --- D vector ---"); - //symm.printD(System.out); - //System.out.println(); - //System.out.println(" --- E vector ---"); - //symm.printE(System.out); - //System.out.println(); + for (i = 1; i <= n; i++) { + l = i - 1; + if (d[i - 1] != 0.0) { + for (j = 1; j <= l; j++) { + g = 0.0; - // Now produce the diagonalization matrix - tstart = System.currentTimeMillis(); - symm.tqli(); - tend = System.currentTimeMillis(); - //System.out.println("Time take for tqli = " + (tend-tstart) + " ms"); + for (k = 1; k <= l; k++) { + g += (value[i - 1][k - 1] * value[k - 1][j - 1]); + } - //System.out.println(" --- New diagonalization matrix ---"); - //symm.print(System.out); - //System.out.println(); + for (k = 1; k <= l; k++) { + value[k - 1][j - 1] -= (g * value[k - 1][i - 1]); + } + } + } - //System.out.println(" --- D vector ---"); - //symm.printD(System.out); - //System.out.println(); - //System.out.println(" --- E vector ---"); - //symm.printE(System.out); - //System.out.println(); + d[i - 1] = value[i - 1][i - 1]; + value[i - 1][i - 1] = 1.0; - //System.out.println(" --- First eigenvector --- "); - //double[] eigenv = symm.getColumn(0); - //for (int i=0; i < eigenv.length;i++) { - // Format.print(System.out,"%15.4f",eigenv[i]); - // } - //System.out.println(); + for (j = 1; j <= l; j++) { + value[j - 1][i - 1] = 0.0; + value[i - 1][j - 1] = 0.0; + } + } + } - //double[] neigenv = origsymm.vectorPostMultiply(eigenv); + public void tqli() { + int n = rows; + + int m; + int l; + int iter; + int i; + int k; + double s; + double r; + double p; + ; + + double g; + double f; + double dd; + double c; + double b; + + for (i = 2; i <= n; i++) { + e[i - 2] = e[i - 1]; + } - //for (int i=0; i < neigenv.length;i++) { - // Format.print(System.out,"%15.4f",neigenv[i]/symm.d[0]); - //} + e[n - 1] = 0.0; + + for (l = 1; l <= n; l++) { + iter = 0; + + 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) { + break; + } + } + + if (m != l) { + iter++; + + if (iter == 30) { + System.err.print("Too many iterations in tqli"); + System.exit(0); // JBPNote - should this really be here ??? + } else { + // System.out.println("Iteration " + iter); + } + + g = (d[l] - d[l - 1]) / (2.0 * e[l - 1]); + r = Math.sqrt((g * g) + 1.0); + g = d[m - 1] - d[l - 1] + (e[l - 1] / (g + sign(r, g))); + c = 1.0; + s = c; + p = 0.0; + + for (i = m - 1; i >= l; i--) { + f = s * e[i - 1]; + b = c * e[i - 1]; + + 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 { + s = f / g; + r = Math.sqrt((s * s) + 1.0); + e[i] = g * r; + c = 1.0 / r; + s *= c; + } + + g = d[i] - p; + r = ((d[i - 1] - g) * s) + (2.0 * c * b); + p = s * r; + d[i] = g + p; + g = (c * r) - b; + + for (k = 1; k <= n; k++) { + f = value[k - 1][i]; + value[k - 1][i] = (s * value[k - 1][i - 1]) + + (c * f); + value[k - 1][i - 1] = (c * value[k - 1][i - 1]) - + (s * f); + } + } + + d[l - 1] = d[l - 1] - p; + e[l - 1] = g; + e[m - 1] = 0.0; + } + } while (m != l); + } + } - //System.out.println(); - } + public void tred2() { + int n = rows; + int l; + int k; + int j; + int i; + + double scale; + double hh; + double h; + double g; + double f; + + this.d = new double[rows]; + this.e = new double[rows]; + + 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++) { + scale += Math.abs(value[i][k]); + } + + if (scale == 0.0) { + e[i] = value[i][l]; + } 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) { + g = -1.0 * Math.sqrt(h); + } else { + g = Math.sqrt(h); + } + + e[i] = scale * g; + h -= (f * g); + value[i][l] = f - g; + f = 0.0; + + for (j = 0; j < l; j++) { + value[j][i] = value[i][j] / h; + g = 0.0; + + for (k = 0; k < j; k++) { + g += (value[j][k] * value[i][k]); + } + + for (k = j; k < l; k++) { + g += (value[k][j] * value[i][k]); + } + + e[j] = g / h; + f += (e[j] * value[i][j]); + } + + hh = f / (h + h); + + for (j = 0; j < l; j++) { + f = value[i][j]; + g = e[j] - (hh * f); + e[j] = g; + + for (k = 0; k < j; k++) { + value[j][k] -= ((f * e[k]) + (g * value[i][k])); + } + } + } + } else { + e[i] = value[i][l]; + } -} + d[i] = h; + } + d[0] = 0.0; + e[0] = 0.0; + for (i = 0; i < n; i++) { + l = i - 1; + if (d[i] != 0.0) { + for (j = 0; j < l; j++) { + g = 0.0; + for (k = 0; k < l; k++) { + g += (value[i][k] * value[k][j]); + } + for (k = 0; k < l; k++) { + value[k][j] -= (g * value[k][i]); + } + } + } + d[i] = value[i][i]; + value[i][i] = 1.0; + for (j = 0; j < l; j++) { + value[j][i] = 0.0; + value[i][j] = 0.0; + } + } + } + public void tqli2() { + int n = rows; + + int m; + int l; + int iter; + int i; + int k; + double s; + double r; + double p; + ; + + double g; + double f; + double dd; + double c; + double b; + + for (i = 2; i <= n; i++) { + e[i - 2] = e[i - 1]; + } + e[n - 1] = 0.0; + + for (l = 1; l <= n; l++) { + iter = 0; + + 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) { + break; + } + } + + if (m != l) { + iter++; + + if (iter == 30) { + System.err.print("Too many iterations in tqli"); + System.exit(0); // JBPNote - same as above - not a graceful exit! + } else { + // System.out.println("Iteration " + iter); + } + + g = (d[l] - d[l - 1]) / (2.0 * e[l - 1]); + r = Math.sqrt((g * g) + 1.0); + g = d[m - 1] - d[l - 1] + (e[l - 1] / (g + sign(r, g))); + c = 1.0; + s = c; + p = 0.0; + + for (i = m - 1; i >= l; i--) { + f = s * e[i - 1]; + b = c * e[i - 1]; + + 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 { + s = f / g; + r = Math.sqrt((s * s) + 1.0); + e[i] = g * r; + c = 1.0 / r; + s *= c; + } + + g = d[i] - p; + r = ((d[i - 1] - g) * s) + (2.0 * c * b); + p = s * r; + d[i] = g + p; + g = (c * r) - b; + + for (k = 1; k <= n; k++) { + f = value[k - 1][i]; + value[k - 1][i] = (s * value[k - 1][i - 1]) + + (c * f); + value[k - 1][i - 1] = (c * value[k - 1][i - 1]) - + (s * f); + } + } + + d[l - 1] = d[l - 1] - p; + e[l - 1] = g; + e[m - 1] = 0.0; + } + } while (m != l); + } + } + public double sign(double a, double b) { + if (b < 0) { + return -Math.abs(a); + } else { + return Math.abs(a); + } + } + public double[] getColumn(int n) { + double[] out = new double[rows]; + 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++) { + Format.print(ps, "%15.4e", d[j]); + } + } + 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) { + 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++) { + in[i][j] = (double) Math.random(); + } + } + Matrix origmat = new Matrix(in, n, n); + + // System.out.println(" --- Original matrix ---- "); + /// origmat.print(System.out); + //System.out.println(); + //System.out.println(" --- transpose matrix ---- "); + Matrix trans = origmat.transpose(); + + //trans.print(System.out); + //System.out.println(); + //System.out.println(" --- OrigT * Orig ---- "); + Matrix symm = trans.postMultiply(origmat); + + //symm.print(System.out); + //System.out.println(); + // Copy the symmetric matrix for later + Matrix origsymm = symm.copy(); + + // This produces the tridiagonal transformation matrix + long tstart = System.currentTimeMillis(); + symm.tred(); + + long tend = System.currentTimeMillis(); + + //System.out.println("Time take for tred = " + (tend-tstart) + "ms"); + //System.out.println(" ---Tridiag transform matrix ---"); + //symm.print(System.out); + //System.out.println(); + //System.out.println(" --- D vector ---"); + //symm.printD(System.out); + //System.out.println(); + //System.out.println(" --- E vector ---"); + //symm.printE(System.out); + //System.out.println(); + // Now produce the diagonalization matrix + tstart = System.currentTimeMillis(); + symm.tqli(); + tend = System.currentTimeMillis(); + + //System.out.println("Time take for tqli = " + (tend-tstart) + " ms"); + //System.out.println(" --- New diagonalization matrix ---"); + //symm.print(System.out); + //System.out.println(); + //System.out.println(" --- D vector ---"); + //symm.printD(System.out); + //System.out.println(); + //System.out.println(" --- E vector ---"); + //symm.printE(System.out); + //System.out.println(); + //System.out.println(" --- First eigenvector --- "); + //double[] eigenv = symm.getColumn(0); + //for (int i=0; i < eigenv.length;i++) { + // Format.print(System.out,"%15.4f",eigenv[i]); + // } + //System.out.println(); + //double[] neigenv = origsymm.vectorPostMultiply(eigenv); + //for (int i=0; i < neigenv.length;i++) { + // Format.print(System.out,"%15.4f",neigenv[i]/symm.d[0]); + //} + //System.out.println(); + } +} diff --git a/src/jalview/math/RotatableMatrix.java b/src/jalview/math/RotatableMatrix.java index d9f4bd5..c0ec1c9 100755 --- a/src/jalview/math/RotatableMatrix.java +++ b/src/jalview/math/RotatableMatrix.java @@ -16,374 +16,241 @@ * 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.math; - - public class RotatableMatrix { + float[][] matrix; + float[] temp; + float[][] rot; - float matrix[][]; - - float[] temp; - - float[][] rot; - - - - public RotatableMatrix(int rows, int cols) { - - matrix = new float[rows][cols]; - - temp = new float[3]; - - rot = new float[3][3]; - - } - - - - public void addElement(int i, int j, float value) { - - matrix[i][j] = value; - - } - - - - public void print() { - - System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + matrix[0][2]); - - System.out.println(matrix[1][0] + " " + matrix[1][1] + " " + matrix[1][2]); - - System.out.println(matrix[2][0] + " " + matrix[2][1] + " " + matrix[2][2]); - - } - - - - 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') { - - + public RotatableMatrix(int rows, int cols) { + matrix = new float[rows][cols]; - rot[0][0] = (float)costheta; - - rot[0][1] = (float)-sintheta; - - rot[0][2] = (float)0.0; - - - - rot[1][0] = (float)sintheta; - - rot[1][1] = (float)costheta; - - rot[1][2] = (float)0.0; - - - - rot[2][0] = (float)0.0; - - rot[2][1] = (float)0.0; - - rot[2][2] = (float)1.0; - - - - preMultiply(rot); + temp = new float[3]; + rot = new float[3][3]; } - if (axis == 'x') { - - rot[0][0] = (float)1.0; - - rot[0][1] = (float)0.0; - - rot[0][2] = (float)0.0; - - - - rot[1][0] = (float)0.0; - - rot[1][1] = (float)costheta; - - rot[1][2] = (float)sintheta; - - - - rot[2][0] = (float)0.0; - - rot[2][1] = (float)-sintheta; - - rot[2][2] = (float)costheta; - - - - preMultiply(rot); - - - + public void addElement(int i, int j, float value) { + matrix[i][j] = value; } - if (axis == 'y') { - - rot[0][0] = (float)costheta; - - rot[0][1] = (float)0.0; - - rot[0][2] = (float)-sintheta; - - - - rot[1][0] = (float)0.0; - - rot[1][1] = (float)1.0; - - rot[1][2] = (float)0.0; - - - - rot[2][0] = (float)sintheta; - - rot[2][1] = (float)0.0; - - rot[2][2] = (float)costheta; - - - - preMultiply(rot); - + public void print() { + System.out.println(matrix[0][0] + " " + matrix[0][1] + " " + + matrix[0][2]); + System.out.println(matrix[1][0] + " " + matrix[1][1] + " " + + matrix[1][2]); + System.out.println(matrix[2][0] + " " + matrix[2][1] + " " + + matrix[2][2]); } + 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); - } - - - - public float[] vectorMultiply(float[] vect) { + if (axis == 'z') { + rot[0][0] = (float) costheta; - temp[0] = vect[0]; + rot[0][1] = (float) -sintheta; - temp[1] = vect[1]; + rot[0][2] = (float) 0.0; - temp[2] = vect[2]; + rot[1][0] = (float) sintheta; + rot[1][1] = (float) costheta; + rot[1][2] = (float) 0.0; - for (int i = 0; i < 3; i++) { + rot[2][0] = (float) 0.0; - temp[i] = matrix[i][0]*vect[0] + matrix[i][1]*vect[1] + matrix[i][2]*vect[2]; + rot[2][1] = (float) 0.0; - } - - - - vect[0] = temp[0]; - - vect[1] = temp[1]; - - vect[2] = temp[2]; - - - - return vect; + rot[2][2] = (float) 1.0; - } + preMultiply(rot); + } + if (axis == 'x') { + rot[0][0] = (float) 1.0; + rot[0][1] = (float) 0.0; - public void preMultiply(float mat[][]) { + rot[0][2] = (float) 0.0; - float tmp[][] = new float[3][3]; + rot[1][0] = (float) 0.0; + rot[1][1] = (float) costheta; + rot[1][2] = (float) sintheta; - for (int i = 0; i < 3 ; i++) { + rot[2][0] = (float) 0.0; - for (int j = 0; j < 3; j++ ) { + rot[2][1] = (float) -sintheta; - tmp[i][j] = mat[i][0]*matrix[0][j] + + rot[2][2] = (float) costheta; - mat[i][1]*matrix[1][j] + + preMultiply(rot); + } - mat[i][2]*matrix[2][j]; + if (axis == 'y') { + rot[0][0] = (float) costheta; - } + rot[0][1] = (float) 0.0; - } + rot[0][2] = (float) -sintheta; + rot[1][0] = (float) 0.0; + rot[1][1] = (float) 1.0; - for (int i = 0; i < 3 ; i++) { + rot[1][2] = (float) 0.0; - for (int j = 0; j < 3; j++ ) { + rot[2][0] = (float) sintheta; - matrix[i][j] = tmp[i][j]; + rot[2][1] = (float) 0.0; - } + rot[2][2] = (float) costheta; + preMultiply(rot); + } } - } - - - - public void postMultiply(float mat[][]) { - - float tmp[][] = new float[3][3]; + 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]); + } - for (int j = 0; j < 3; j++ ) { + vect[0] = temp[0]; - tmp[i][j] = matrix[i][0]*mat[0][j] + + vect[1] = temp[1]; - matrix[i][1]*mat[1][j] + - - matrix[i][2]*mat[2][j]; - - } + vect[2] = temp[2]; + return vect; } - - - for (int i = 0; i < 3 ; i++) { - - for (int j = 0; j < 3; j++ ) { - - matrix[i][j] = tmp[i][j]; - - } - + 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++) { + 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++) { + matrix[i][j] = tmp[i][j]; + } + } } - } - - - - public static void main(String[] args) { - - - - RotatableMatrix m = new RotatableMatrix(3,3); - - m.addElement(0,0,1); - - m.addElement(0,1,0); - - m.addElement(0,2,0); - - m.addElement(1,0,0); - - m.addElement(1,1,2); - - m.addElement(1,2,0); - - m.addElement(2,0,0); - - m.addElement(2,1,0); - - m.addElement(2,2,1); - - - - m.print(); - - - - RotatableMatrix n = new RotatableMatrix(3,3); - - n.addElement(0,0,2); - - n.addElement(0,1,1); - - n.addElement(0,2,1); - - n.addElement(1,0,2); - - n.addElement(1,1,1); + 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++) { + 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++) { + matrix[i][j] = tmp[i][j]; + } + } + } - n.addElement(1,2,1); + public static void main(String[] args) { + RotatableMatrix m = new RotatableMatrix(3, 3); - n.addElement(2,0,2); + m.addElement(0, 0, 1); - n.addElement(2,1,1); + m.addElement(0, 1, 0); - n.addElement(2,2,1); + m.addElement(0, 2, 0); + m.addElement(1, 0, 0); + m.addElement(1, 1, 2); - n.print(); + m.addElement(1, 2, 0); + m.addElement(2, 0, 0); + m.addElement(2, 1, 0); - //m.postMultiply(n.matrix); + m.addElement(2, 2, 1); - //m.print(); + m.print(); - // m.rotate(45,'z',new RotatableMatrix(3,3)); + RotatableMatrix n = new RotatableMatrix(3, 3); + n.addElement(0, 0, 2); + n.addElement(0, 1, 1); - float vect[] = new float[3]; + n.addElement(0, 2, 1); - vect[0] = 2; + n.addElement(1, 0, 2); - vect[1] = 4; + n.addElement(1, 1, 1); - vect[2] = 6; + n.addElement(1, 2, 1); + n.addElement(2, 0, 2); + n.addElement(2, 1, 1); - vect = m.vectorMultiply(vect); + n.addElement(2, 2, 1); - System.out.println(vect[0] + " " + vect[1] + " " + vect[2]); + n.print(); + //m.postMultiply(n.matrix); + //m.print(); + // m.rotate(45,'z',new RotatableMatrix(3,3)); + float[] vect = new float[3]; + vect[0] = 2; - } + vect[1] = 4; - public void setIdentity() { + vect[2] = 6; - matrix[0][0] = (float)1.0; + vect = m.vectorMultiply(vect); - matrix[1][1] = (float)1.0; + System.out.println(vect[0] + " " + vect[1] + " " + vect[2]); + } - matrix[2][2] = (float)1.0; + public void setIdentity() { + matrix[0][0] = (float) 1.0; - matrix[0][1] = (float)0.0; + matrix[1][1] = (float) 1.0; - matrix[0][2] = (float)0.0; + matrix[2][2] = (float) 1.0; - matrix[1][0] = (float)0.0; + matrix[0][1] = (float) 0.0; - matrix[1][2] = (float) 0.0; + matrix[0][2] = (float) 0.0; - matrix[2][0] = (float)0.0; + matrix[1][0] = (float) 0.0; - matrix[2][1] = (float)0.0; + matrix[1][2] = (float) 0.0; - } + matrix[2][0] = (float) 0.0; + matrix[2][1] = (float) 0.0; + } } - - - diff --git a/src/jalview/schemes/Blosum62ColourScheme.java b/src/jalview/schemes/Blosum62ColourScheme.java index 40243f2..9c720ee 100755 --- a/src/jalview/schemes/Blosum62ColourScheme.java +++ b/src/jalview/schemes/Blosum62ColourScheme.java @@ -16,53 +16,48 @@ * 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.util.*; import java.awt.*; -public class Blosum62ColourScheme extends ResidueColourScheme -{ - - public Blosum62ColourScheme() - { - super(); - } - - 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 { +import java.util.*; - int c = 0, - max_aa=0, - n=max.length(); - do { - c+=ResidueProperties.getBLOSUM62(max.substring(max_aa, max_aa+1), s); - } while (++max_aa0) - return new Color(204, 204, 255); - else - return Color.white; - } +public class Blosum62ColourScheme extends ResidueColourScheme { + public Blosum62ColourScheme() { + super(); } - else - 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); + + 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 8b0305d..186b98a 100755 --- a/src/jalview/schemes/BuriedColourScheme.java +++ b/src/jalview/schemes/BuriedColourScheme.java @@ -16,18 +16,18 @@ * 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 BuriedColourScheme extends ScoreColourScheme { - public BuriedColourScheme() { - super(ResidueProperties.buried,ResidueProperties.buriedmin,ResidueProperties.buriedmax); - } +public class BuriedColourScheme extends ScoreColourScheme { + public BuriedColourScheme() { + super(ResidueProperties.buried, ResidueProperties.buriedmin, + ResidueProperties.buriedmax); + } - public Color makeColour(float c) { - return new Color(0,(float)(1.0-c),c); - } + 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 bbca4de..17398fc 100755 --- a/src/jalview/schemes/ClustalxColourScheme.java +++ b/src/jalview/schemes/ClustalxColourScheme.java @@ -16,267 +16,259 @@ * 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.*; -public class ClustalxColourScheme extends ResidueColourScheme -{ - Hashtable[] cons; - int[][] cons2; - ConsensusColour[] colours; - ConsensusColour[] ResidueColour; - int size; - Consensus[] conses = new Consensus[32]; +import java.util.*; + + +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)); - + 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)); } - Vector colourTable = new Vector(); - - 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++) - for (int i=0; i < maxWidth;i++) - cons2[i][j] = 0; - - int res,i, 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()-119) - 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 == 4) - { - if (conses[27].isConserved(cons2, j, size)) - c = (Color) colhash.get("PINK"); + + public ClustalxColourScheme(Vector seqs, int maxWidth) { + resetClustalX(seqs, maxWidth); } + public void resetClustalX(Vector seqs, int maxWidth) { + cons2 = new int[maxWidth][24]; - return c; + int start = 0; - } -} + // Initialize the array + for (int j = 0; j < 24; j++) + for (int i = 0; i < maxWidth; i++) + cons2[i][j] = 0; -class ConsensusColour { + int res; + int i; + int j = 0; + String seq; - Consensus[] conses; - Color c; + while (j < seqs.size()) { + seq = ((SequenceI) seqs.elementAt(j)).getSequence(); - public ConsensusColour(Color c,Consensus[] conses) { - this.conses = conses; - // this.list = list; - this.c = c; - } -} + 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(); + } + cons2[i][res]++; + } + j++; + } + + 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; + } + int i = ((Integer) ResidueProperties.aaHash.get(s)).intValue(); + 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 == 4) { + if (conses[27].isConserved(cons2, j, size)) { + c = (Color) colhash.get("PINK"); + } + } + return c; + } +} +class ConsensusColour { + Consensus[] conses; + Color c; + public ConsensusColour(Color c, Consensus[] conses) { + this.conses = conses; + // this.list = list; + this.c = c; + } +} diff --git a/src/jalview/schemes/ColourSchemeI.java b/src/jalview/schemes/ColourSchemeI.java index 250cae5..2e28695 100755 --- a/src/jalview/schemes/ColourSchemeI.java +++ b/src/jalview/schemes/ColourSchemeI.java @@ -16,15 +16,17 @@ * 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.*; -public interface ColourSchemeI -{ - public Color findColour(String aa); - public Color findColour(String s,int j); - public void setConsensus(Vector v); + +public interface ColourSchemeI { + public Color findColour(String aa); + + public Color findColour(String s, int j); + + public void setConsensus(Vector v); } diff --git a/src/jalview/schemes/ColourSchemeProperty.java b/src/jalview/schemes/ColourSchemeProperty.java index a981549..6e7a711 100755 --- a/src/jalview/schemes/ColourSchemeProperty.java +++ b/src/jalview/schemes/ColourSchemeProperty.java @@ -16,133 +16,223 @@ * 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 ColourSchemeProperty -{ - public static final int CLUSTAL = 0; - public static final int BLOSUM = 1; - public static final int PID = 2; - public static final int ZAPPO = 3; - public static final int HYDROPHOBIC=4; - public static final int HELIX=5; - public static final int STRAND=6; - public static final int TURN = 7; - public static final int BURIED = 8; - public static final int NUCLEOTIDE = 9; - public static final int USER_DEFINED = 10; - public static final int NONE = 11; - - public static int getColourIndexFromName(String name) - { - int ret=11; - if(name.equalsIgnoreCase("Clustal")) - ret = CLUSTAL; - else if(name.equalsIgnoreCase("Blosum62")) - ret = BLOSUM; - else if(name.equalsIgnoreCase("% Identity")) - ret = PID; - else if(name.equalsIgnoreCase("Zappo")) - ret = ZAPPO; - else if(name.equalsIgnoreCase("Hydrophobic")) - ret = HYDROPHOBIC; - else if(name.equalsIgnoreCase("Helix Propensity")) - ret = HELIX; - else if(name.equalsIgnoreCase("Strand Propensity")) - ret = STRAND; - else if(name.equalsIgnoreCase("Turn Propensity")) - ret = TURN; - else if(name.equalsIgnoreCase("Buried Index")) - ret = BURIED; - else if(name.equalsIgnoreCase("Nucleotide")) - ret = NUCLEOTIDE; - else if(name.equalsIgnoreCase("User Defined")) - ret = USER_DEFINED; - - return ret; - } - - public static String getColourName(ColourSchemeI cs) - { - if(cs instanceof ConservationColourScheme) - cs = ((ConservationColourScheme)cs).cs; - - - int index = 11; - if(cs instanceof ClustalxColourScheme) - index = CLUSTAL; - else if(cs instanceof Blosum62ColourScheme) - index = BLOSUM; - else if(cs instanceof PIDColourScheme) - index = PID; - else if(cs instanceof ZappoColourScheme) - index = ZAPPO; - else if(cs instanceof HydrophobicColourScheme) - index = HYDROPHOBIC; - else if(cs instanceof HelixColourScheme) - index = HELIX; - else if(cs instanceof StrandColourScheme) - index = STRAND; - else if(cs instanceof TurnColourScheme) - index = TURN; - else if(cs instanceof BuriedColourScheme) - index = BURIED; - else if(cs instanceof NucleotideColourScheme) - index = NUCLEOTIDE; - else if(cs instanceof UserColourScheme) - index = USER_DEFINED; - - return getColourName(index); - } - - public static String getColourName(int index) - { - String ret=null; - switch(index) - { - case CLUSTAL: ret = "Clustal"; break; - case BLOSUM: ret = "Blosum62"; break; - case PID: ret = "% Identity"; break; - case ZAPPO: ret = "Zappo"; break; - case HYDROPHOBIC: ret="Hydrophobic";break; - case HELIX: ret="Helix Propensity";break; - case STRAND: ret="Strand Propensity";break; - case TURN: ret="Turn Propensity";break; - case BURIED: ret="Buried Index";break; - case NUCLEOTIDE:ret="Nucleotide"; break; - case USER_DEFINED:ret="User Defined";break; - default: ret = "None"; break; +public class ColourSchemeProperty { + public static final int CLUSTAL = 0; + public static final int BLOSUM = 1; + public static final int PID = 2; + public static final int ZAPPO = 3; + public static final int HYDROPHOBIC = 4; + public static final int HELIX = 5; + public static final int STRAND = 6; + public static final int TURN = 7; + public static final int BURIED = 8; + public static final int NUCLEOTIDE = 9; + public static final int USER_DEFINED = 10; + public static final int NONE = 11; + + public static int getColourIndexFromName(String name) { + int ret = 11; + + if (name.equalsIgnoreCase("Clustal")) { + ret = CLUSTAL; + } else if (name.equalsIgnoreCase("Blosum62")) { + ret = BLOSUM; + } else if (name.equalsIgnoreCase("% Identity")) { + ret = PID; + } else if (name.equalsIgnoreCase("Zappo")) { + ret = ZAPPO; + } else if (name.equalsIgnoreCase("Hydrophobic")) { + ret = HYDROPHOBIC; + } else if (name.equalsIgnoreCase("Helix Propensity")) { + ret = HELIX; + } else if (name.equalsIgnoreCase("Strand Propensity")) { + ret = STRAND; + } else if (name.equalsIgnoreCase("Turn Propensity")) { + ret = TURN; + } else if (name.equalsIgnoreCase("Buried Index")) { + ret = BURIED; + } else if (name.equalsIgnoreCase("Nucleotide")) { + ret = NUCLEOTIDE; + } else if (name.equalsIgnoreCase("User Defined")) { + ret = USER_DEFINED; + } + + return ret; + } + + public static String getColourName(ColourSchemeI cs) { + if (cs instanceof ConservationColourScheme) { + cs = ((ConservationColourScheme) cs).cs; + } + + int index = 11; + + if (cs instanceof ClustalxColourScheme) { + index = CLUSTAL; + } else if (cs instanceof Blosum62ColourScheme) { + index = BLOSUM; + } else if (cs instanceof PIDColourScheme) { + index = PID; + } else if (cs instanceof ZappoColourScheme) { + index = ZAPPO; + } else if (cs instanceof HydrophobicColourScheme) { + index = HYDROPHOBIC; + } else if (cs instanceof HelixColourScheme) { + index = HELIX; + } else if (cs instanceof StrandColourScheme) { + index = STRAND; + } else if (cs instanceof TurnColourScheme) { + index = TURN; + } else if (cs instanceof BuriedColourScheme) { + index = BURIED; + } else if (cs instanceof NucleotideColourScheme) { + index = NUCLEOTIDE; + } else if (cs instanceof UserColourScheme) { + index = USER_DEFINED; + } + + return getColourName(index); + } + + public static String getColourName(int index) { + String ret = null; + + switch (index) { + case CLUSTAL: + ret = "Clustal"; + + break; + + case BLOSUM: + ret = "Blosum62"; + + break; + + case PID: + ret = "% Identity"; + + break; + + case ZAPPO: + ret = "Zappo"; + + break; + + case HYDROPHOBIC: + ret = "Hydrophobic"; + + break; + + case HELIX: + ret = "Helix Propensity"; + + break; + + case STRAND: + ret = "Strand Propensity"; + + break; + + case TURN: + ret = "Turn Propensity"; + + break; + + case BURIED: + ret = "Buried Index"; + + break; + + case NUCLEOTIDE: + ret = "Nucleotide"; + + break; + + case USER_DEFINED: + ret = "User Defined"; + + break; + + default: + ret = "None"; + + break; + } + + return ret; } - return ret; - } - - public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, String name) - { - return getColour(al, getColourIndexFromName(name)); - } - - public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, int index) - { - ColourSchemeI cs = null; - switch(index) - { - case CLUSTAL: cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); break; - case BLOSUM: cs = new Blosum62ColourScheme(); break; - case PID: cs = new PIDColourScheme(); break; - case ZAPPO: cs = new ZappoColourScheme(); break; - case HYDROPHOBIC: cs = new HydrophobicColourScheme(); break; - case HELIX: cs = new HelixColourScheme(); break; - case STRAND: cs = new StrandColourScheme(); break; - case TURN: cs = new TurnColourScheme(); break; - case BURIED: cs = new BuriedColourScheme(); break; - case NUCLEOTIDE: cs = new NucleotideColourScheme(); break; - case USER_DEFINED: cs = new UserColourScheme(null); - break; - - default: break; + + public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, + String name) { + return getColour(al, getColourIndexFromName(name)); } - return cs; - } + public static ColourSchemeI getColour(jalview.datamodel.AlignmentI al, + int index) { + ColourSchemeI cs = null; + + switch (index) { + case CLUSTAL: + cs = new ClustalxColourScheme(al.getSequences(), al.getWidth()); + + break; + + case BLOSUM: + cs = new Blosum62ColourScheme(); + + break; + + case PID: + cs = new PIDColourScheme(); + + break; + + case ZAPPO: + cs = new ZappoColourScheme(); + + break; + + case HYDROPHOBIC: + cs = new HydrophobicColourScheme(); + + break; + + case HELIX: + cs = new HelixColourScheme(); + + break; + + case STRAND: + cs = new StrandColourScheme(); + + break; + + case TURN: + cs = new TurnColourScheme(); + + break; + + case BURIED: + cs = new BuriedColourScheme(); + + break; + + case NUCLEOTIDE: + cs = new NucleotideColourScheme(); + + break; + + case USER_DEFINED: + cs = new UserColourScheme(null); + + break; + + default: + break; + } + + return cs; + } } diff --git a/src/jalview/schemes/Consensus.java b/src/jalview/schemes/Consensus.java index 27c5906..8ca0223 100755 --- a/src/jalview/schemes/Consensus.java +++ b/src/jalview/schemes/Consensus.java @@ -16,62 +16,57 @@ * 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; - int[] mask; - double threshold; - String maskstr; - - public Consensus(String mask, double threshold) { - // this.id = id; - // this.mask = mask; + public Consensus(String mask, double threshold) { + // this.id = id; + // this.mask = mask; this.maskstr = mask; - setMask(mask); - this.threshold = threshold; - } + setMask(mask); + this.threshold = threshold; + } - public void setMask(String s) { - this.mask = setNums(s); - // 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++) - tot += cons2[col][mask[i]]; + // for (int i=0; i < mask.length; i++) { + // System.out.println(mask[i] + " " + ResidueProperties.aa[mask[i]]); + // } + } - if ( (double) tot > threshold * size / 100) - return true; + public boolean isConserved(int[][] cons2, int col, int size) { + int tot = 0; - return false; - } + for (int i = 0; i < mask.length; i++) + tot += cons2[col][mask[i]]; - int[] setNums(String s) - { - int [] out = new int[s.length()]; - int i = 0; - while (i < s.length()) - { - out[i] = ( (Integer) ResidueProperties.aaHash.get(s.substring(i, i + 1))).intValue(); - i++; + if ((double) tot > ((threshold * size) / 100)) { + return true; + } + return false; } - return out; - } + int[] setNums(String s) { + int[] out = new int[s.length()]; + int i = 0; + 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 8c3f694..bbc0edd 100755 --- a/src/jalview/schemes/ConservationColourScheme.java +++ b/src/jalview/schemes/ConservationColourScheme.java @@ -16,73 +16,87 @@ * 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 jalview.analysis.*; + +import java.awt.*; + import java.util.Vector; + public class ConservationColourScheme extends ResidueColourScheme { - public Conservation conserve; - public ColourSchemeI cs; - public int inc = 30; - - public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) - { - super(); - conserve = cons; - cs = oldcs; - } - - public void setConsensus(Vector consensus) - { - this.consensus = consensus; - if(cs!=null) - cs.setConsensus(consensus); - } - - public Color findColour(String s, int i) - { - Color c = Color.white; - if (cs == null) - return c; - - char ch = conserve.getConsSequence().getSequence().charAt(i); - if (ch == '*' || ch == '+') - { - c = cs.findColour(s, i); - } - else - { - int tmp = 10; - int t = 0; - if (!jalview.util.Comparison.isGap(ch)) - t = Integer.parseInt(ch + ""); - - c = cs.findColour(s, i); - - while (tmp >= t) - { - c = lighter(c, inc); - tmp--; - } - - } - - return c; - } - - - public Color lighter(Color c, int inc) { - int red = c.getRed(); - int blue = c.getBlue(); - int green = c.getGreen(); - - if (red < 255-inc) { red = red +inc;} else {red = 255;} - if (blue < 255-inc) { blue = blue +inc;} else {blue = 255;} - if (green < 255-inc) { green = green +inc;} else {green = 255;} - - return new Color(red,green,blue); - } + public Conservation conserve; + public ColourSchemeI cs; + public int inc = 30; + + public ConservationColourScheme(Conservation cons, ColourSchemeI oldcs) { + super(); + conserve = cons; + cs = oldcs; + } + + public void setConsensus(Vector consensus) { + this.consensus = consensus; + + if (cs != null) { + cs.setConsensus(consensus); + } + } + + public Color findColour(String s, int i) { + Color c = Color.white; + + if (cs == null) { + return c; + } + + char ch = conserve.getConsSequence().getSequence().charAt(i); + + if ((ch == '*') || (ch == '+')) { + c = cs.findColour(s, i); + } else { + int tmp = 10; + int t = 0; + + if (!jalview.util.Comparison.isGap(ch)) { + t = Integer.parseInt(ch + ""); + } + + c = cs.findColour(s, i); + + while (tmp >= t) { + c = lighter(c, inc); + tmp--; + } + } + + return c; + } + + public Color lighter(Color c, int inc) { + int red = c.getRed(); + int blue = c.getBlue(); + int green = c.getGreen(); + + if (red < (255 - inc)) { + red = red + inc; + } else { + red = 255; + } + + if (blue < (255 - inc)) { + blue = blue + inc; + } else { + blue = 255; + } + + if (green < (255 - inc)) { + green = green + inc; + } else { + green = 255; + } + return new Color(red, green, blue); + } } diff --git a/src/jalview/schemes/HelixColourScheme.java b/src/jalview/schemes/HelixColourScheme.java index 35e1a26..a25f014 100755 --- a/src/jalview/schemes/HelixColourScheme.java +++ b/src/jalview/schemes/HelixColourScheme.java @@ -16,19 +16,18 @@ * 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 e1eef48..eeb43a3 100755 --- a/src/jalview/schemes/HydrophobicColourScheme.java +++ b/src/jalview/schemes/HydrophobicColourScheme.java @@ -16,18 +16,18 @@ * 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 HydrophobicColourScheme extends ScoreColourScheme { - public HydrophobicColourScheme() { - super(ResidueProperties.hyd,ResidueProperties.hydmin,ResidueProperties.hydmax); - } +public class HydrophobicColourScheme extends ScoreColourScheme { + public HydrophobicColourScheme() { + super(ResidueProperties.hyd, ResidueProperties.hydmin, + ResidueProperties.hydmax); + } - public Color makeColour(float c) { - return new Color(c,(float)0.0,(float)1.0-c); - } + 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 0f2101e..0cca608 100755 --- a/src/jalview/schemes/NucleotideColourScheme.java +++ b/src/jalview/schemes/NucleotideColourScheme.java @@ -16,39 +16,30 @@ * 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 NucleotideColourScheme extends ResidueColourScheme -{ - public NucleotideColourScheme() { - super(ResidueProperties.nucleotide,0); - } - - - 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 - { - return colors[ ( (Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()]; - } - catch (Exception ex) - { - return Color.white; - } - else - return Color.white; - - } +public class NucleotideColourScheme extends ResidueColourScheme { + public NucleotideColourScheme() { + super(ResidueProperties.nucleotide, 0); + } + + 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 { + return colors[((Integer) (ResidueProperties.nucleotideHash.get(n))).intValue()]; + } catch (Exception ex) { + return Color.white; + } + } else { + return Color.white; + } + } } diff --git a/src/jalview/schemes/PIDColourScheme.java b/src/jalview/schemes/PIDColourScheme.java index 34c47ed..2535154 100755 --- a/src/jalview/schemes/PIDColourScheme.java +++ b/src/jalview/schemes/PIDColourScheme.java @@ -16,52 +16,52 @@ * 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.*; + + public class PIDColourScheme extends ResidueColourScheme { public Color[] pidColours; public float[] thresholds; - SequenceGroup group; public PIDColourScheme() { - this.pidColours = ResidueProperties.pidColours; - this.thresholds = ResidueProperties.pidThresholds; + this.pidColours = ResidueProperties.pidColours; + this.thresholds = ResidueProperties.pidThresholds; } + 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); - public Color findColour(String s, int j) { + double sc = 0; - if( threshold!=0 && !aboveThreshold(s,j)) - return Color.white; + if ((Integer.parseInt(hash.get("maxCount").toString()) != -1) && + hash.contains(s)) { + sc = (((Integer) hash.get(s)).intValue() * 100.0) / ((Integer) hash.get( + "size")).intValue(); - Color c = Color.white; - Hashtable hash = (Hashtable)consensus.elementAt(j); + // 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]; - 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() ; - // 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 e90e6cc..a688593 100755 --- a/src/jalview/schemes/ResidueColourScheme.java +++ b/src/jalview/schemes/ResidueColourScheme.java @@ -16,66 +16,64 @@ * 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.util.*; import java.awt.*; -public class ResidueColourScheme implements ColourSchemeI{ - Color [] colors; - int threshold = 0; - public Vector consensus; +import java.util.*; + + +public class ResidueColourScheme implements ColourSchemeI { + Color[] colors; + int threshold = 0; + public Vector consensus; public ResidueColourScheme(Color[] colors, int threshold) { - this.colors = colors; - this.threshold = threshold; + this.colors = colors; + this.threshold = threshold; } - public ResidueColourScheme() - { } + public ResidueColourScheme() { + } - public void setConsensus(Vector consensus) - { - this.consensus = consensus; + public void setConsensus(Vector consensus) { + this.consensus = consensus; } - public Color findColour(String aa) - { - return colors[((Integer)(ResidueProperties.aaHash.get(aa))).intValue()]; + 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)) - return colors[((Integer)(ResidueProperties.aaHash.get(s))).intValue()]; - else - return Color.white; - + if ((threshold == 0) || aboveThreshold(s, j)) { + return colors[((Integer) (ResidueProperties.aaHash.get(s))).intValue()]; + } else { + return Color.white; + } } public int getThreshold() { - return threshold; + return threshold; } public void setThreshold(int ct) { - threshold = ct; + threshold = ct; } - public boolean aboveThreshold(String s, int j) - { - Hashtable hash = (Hashtable)consensus.elementAt(j); - - if ( ( (Integer) hash.get("maxCount")).intValue() != -1 && hash.contains(s)) - { - //// resCount//////////////////// ///////////////seq count//////////// - double sc = ( (Integer) hash.get(s)).intValue() * 100.0 / ( (Integer) hash.get("size")).intValue(); + public boolean aboveThreshold(String s, int j) { + Hashtable hash = (Hashtable) consensus.elementAt(j); - if (sc >= threshold) - return true; + if ((((Integer) hash.get("maxCount")).intValue() != -1) && + hash.contains(s)) { + //// resCount//////////////////// ///////////////seq count//////////// + double sc = (((Integer) hash.get(s)).intValue() * 100.0) / ((Integer) hash.get( + "size")).intValue(); + if (sc >= threshold) { + return true; + } } - return false; + return false; } } diff --git a/src/jalview/schemes/ResidueProperties.java b/src/jalview/schemes/ResidueProperties.java index 002917b..552a463 100755 --- a/src/jalview/schemes/ResidueProperties.java +++ b/src/jalview/schemes/ResidueProperties.java @@ -16,1020 +16,1116 @@ * 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); + } + + 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)); + } - //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 double getHydmax() { - return hydmax; - } - public static double getHydmin() { - return hydmin; - } - public static double[] getHyd() { - return hyd; - } - //public static final double hydmax = 1.38; - //public static final double hydmin = -2.53; - - static final int[][] BLOSUM62 = { - //A R N D C Q E G H I L K M F P S T W Y V B Z X - - { 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 = { - // C T A G - - { 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 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); + 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)); } - return pog ; - } - - public static Color[] pidColours = { - midBlue, - new Color(153,153,255), - // Color.lightGray, - new Color(204,204,255), - }; - public static float[] pidThresholds = { - 80, - 60, - 40, - } ; - private ResidueProperties() {} - - 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 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; - } + + 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; } - return null; - } - 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); - } - public static Hashtable getChainColours() { - return chainColours; - } } diff --git a/src/jalview/schemes/ScoreColourScheme.java b/src/jalview/schemes/ScoreColourScheme.java index b6dc45b..12f252d 100755 --- a/src/jalview/schemes/ScoreColourScheme.java +++ b/src/jalview/schemes/ScoreColourScheme.java @@ -16,55 +16,53 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - package jalview.schemes; import java.awt.*; -public class ScoreColourScheme extends ResidueColourScheme { - public double min; - public double max; - public double[] scores; - - public ScoreColourScheme( double[] scores, - double min, - double max) { - super(); +public class ScoreColourScheme extends ResidueColourScheme { + public double min; + public double max; + public double[] scores; - this.scores = scores; - this.min = min; - this.max = max; - } + public ScoreColourScheme(double[] scores, double min, double max) { + super(); + this.scores = scores; + this.min = min; + this.max = max; + } - public Color findColour(String s,int j) - { + public Color findColour(String s, int j) { + if (threshold > 0) { + if (!aboveThreshold(s, j)) { + return Color.white; + } + } - if (threshold > 0) - { - if (!aboveThreshold(s,j)) - return Color.white; - } + float red = (float) (scores[((Integer) ResidueProperties.aaHash.get(s)).intValue()] - + (float) min) / (float) (max - min); - float red = (float)(scores[((Integer)ResidueProperties.aaHash.get(s)).intValue()] - - (float)min)/(float)(max - min); - if (red > 1.0f) - red = 1.0f; + if (red > 1.0f) { + red = 1.0f; + } - if (red < 0.0f) - red = 0.0f; + if (red < 0.0f) { + red = 0.0f; + } - char c = s.charAt(0); + char c = s.charAt(0); - if(jalview.util.Comparison.isGap((c))) - return Color.white; + if (jalview.util.Comparison.isGap((c))) { + return Color.white; + } - // This isn';t great - pool of colours in here? - return makeColour(red); + // This isn';t great - pool of colours in here? + return makeColour(red); } + public Color makeColour(float c) { - return new Color(c,(float)0.0,(float)1.0-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 466ae4f..717e6dc 100755 --- a/src/jalview/schemes/StrandColourScheme.java +++ b/src/jalview/schemes/StrandColourScheme.java @@ -16,20 +16,18 @@ * 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 StrandColourScheme extends ScoreColourScheme { - - public StrandColourScheme() { - super(ResidueProperties.strand,ResidueProperties.strandmin,ResidueProperties.strandmax); - } +public class StrandColourScheme extends ScoreColourScheme { + public StrandColourScheme() { + super(ResidueProperties.strand, ResidueProperties.strandmin, + ResidueProperties.strandmax); + } - public Color makeColour(float c) { - return new Color(c,c,(float)1.0-c); - } + 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 490425e..10277e9 100755 --- a/src/jalview/schemes/TaylorColourScheme.java +++ b/src/jalview/schemes/TaylorColourScheme.java @@ -16,13 +16,10 @@ * 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 TaylorColourScheme() { + super(ResidueProperties.taylor, 0); + } } diff --git a/src/jalview/schemes/TurnColourScheme.java b/src/jalview/schemes/TurnColourScheme.java index 2964bae..e86c44c 100755 --- a/src/jalview/schemes/TurnColourScheme.java +++ b/src/jalview/schemes/TurnColourScheme.java @@ -16,19 +16,18 @@ * 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 TurnColourScheme extends ScoreColourScheme { - public TurnColourScheme() { - super(ResidueProperties.turn,ResidueProperties.turnmin,ResidueProperties.turnmax); - } +public class TurnColourScheme extends ScoreColourScheme { + public TurnColourScheme() { + super(ResidueProperties.turn, ResidueProperties.turnmin, + ResidueProperties.turnmax); + } - public Color makeColour(float c) { - return new Color(c,1-c,1-c); - } + 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 b4decde..38a1291 100755 --- a/src/jalview/schemes/UserColourScheme.java +++ b/src/jalview/schemes/UserColourScheme.java @@ -16,20 +16,17 @@ * 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 Color[] getColours() - { - return colors; - } +public class UserColourScheme extends ResidueColourScheme { + 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 e042acb..2a439c0 100755 --- a/src/jalview/schemes/ZappoColourScheme.java +++ b/src/jalview/schemes/ZappoColourScheme.java @@ -16,12 +16,10 @@ * 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 ZappoColourScheme extends ResidueColourScheme { - - public ZappoColourScheme() { - super(ResidueProperties.color,0); - } + public ZappoColourScheme() { + super(ResidueProperties.color, 0); + } } diff --git a/src/jalview/util/BrowserLauncher.java b/src/jalview/util/BrowserLauncher.java index aef74d5..12d6f02 100755 --- a/src/jalview/util/BrowserLauncher.java +++ b/src/jalview/util/BrowserLauncher.java @@ -15,17 +15,18 @@ * 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; - +*/ +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 @@ -69,551 +70,698 @@ import java.lang.reflect.Method; * * @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. - */ - private static boolean loadedWithoutErrors; - - /** The com.apple.mrj.MRJFileUtils class */ - private static Class mrjFileUtilsClass; - - /** The com.apple.mrj.MRJOSType class */ - private static Class mrjOSTypeClass; - - /** The com.apple.MacOS.AEDesc class */ - private static Class aeDescClass; - - /** The <init>(int) method of com.apple.MacOS.AETarget */ - private static Constructor aeTargetConstructor; - - /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */ - private static Constructor appleEventConstructor; - - /** The <init>(String) method of com.apple.MacOS.AEDesc */ - private static Constructor aeDescConstructor; - - /** The findFolder method of com.apple.mrj.MRJFileUtils */ - private static Method findFolder; - - /** The getFileCreator method of com.apple.mrj.MRJFileUtils */ - private static Method getFileCreator; - - /** The getFileType method of com.apple.mrj.MRJFileUtils */ - private static Method getFileType; - - /** The openURL method of com.apple.mrj.MRJFileUtils */ - private static Method openURL; - - /** The makeOSType method of com.apple.MacOS.OSUtils */ - private static Method makeOSType; - - /** The putParameter method of com.apple.MacOS.AppleEvent */ - private static Method putParameter; - - /** The sendNoReply method of com.apple.MacOS.AppleEvent */ - private static Method sendNoReply; - - /** Actually an MRJOSType pointing to the System Folder on a Macintosh */ - private static Object kSystemFolderType; - - /** The keyDirectObject AppleEvent parameter type */ - private static Integer keyDirectObject; - - /** The kAutoGenerateReturnID AppleEvent code */ - private static Integer kAutoGenerateReturnID; - - /** The kAnyTransactionID AppleEvent code */ - private static Integer kAnyTransactionID; - - /** The linkage object required for JDirect 3 on Mac OS X. */ - private static Object linkage; - - /** 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 MRJ 2.0 */ - private static final int MRJ_2_0 = 0; - - /** JVM constant for MRJ 2.1 or later */ - private static final int MRJ_2_1 = 1; - - /** 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 3.1 */ - private static final int MRJ_3_1 = 4; - - /** JVM constant for any Windows NT JVM */ - private static final int WINDOWS_NT = 5; - - /** JVM constant for any Windows 9x JVM */ - private static final int WINDOWS_9x = 6; - - /** JVM constant for any other platform */ - private static final int OTHER = -1; - - /** - * 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 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 name for the AppleEvent type corresponding to a GetURL event. */ - private static final String GURL_EVENT = "GURL"; - - /** - * 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 second parameter for Runtime.exec() on Windows. */ - private static final String SECOND_WINDOWS_PARAMETER = "start"; - + */ +public class BrowserLauncher { /** - * 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 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; - - /** - * 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; - } - - 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(); - 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; - } - 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(); - 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; - } - 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; - } catch (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - return false; - } catch (InvocationTargetException ite) { - errorMessage = ite.getMessage(); - return false; - } catch (InstantiationException ie) { - errorMessage = ie.getMessage(); - return false; - } catch (IllegalAccessException iae) { - errorMessage = iae.getMessage(); - return false; - } - break; - case MRJ_3_1: - 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 (NoSuchMethodException nsme) { - errorMessage = nsme.getMessage(); - return false; - } - break; - default: - break; - } - 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; - } - 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; - } - case MRJ_2_1: - File systemFolder; - try { - systemFolder = (File) findFolder.invoke(null, new Object[] { kSystemFolderType }); - } catch (IllegalArgumentException iare) { - browser = null; - errorMessage = iare.getMessage(); - return browser; - } catch (IllegalAccessException iae) { - browser = null; - errorMessage = iae.getMessage(); - return browser; - } catch (InvocationTargetException ite) { - browser = null; - errorMessage = ite.getTargetException().getClass() + ": " + ite.getTargetException().getMessage(); - 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; - } - } - browser = null; - break; - case MRJ_3_0: - case MRJ_3_1: - browser = ""; // Return something non-null - break; - case WINDOWS_NT: - browser = "cmd.exe"; - break; - case WINDOWS_9x: - browser = "command.com"; - break; - case OTHER: - default: - browser = jalview.bin.Cache.applicationProperties.getProperty("jalview.browser"); - if (browser==null) { - // hope firefox exists :-/ - browser = "firefox"; - } - break; - } - 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); - } - 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; - 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 MRJ_3_1: - 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 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; - 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 - // JBPNote log debug - // System.out.println("Executing : "+browser+" "+url+"\n"); - Runtime.getRuntime().exec(new String[] { (String) browser, url }); - } - } catch (InterruptedException ie) { - throw new IOException("InterruptedException while launching browser: " + ie.getMessage()); - } - break; - default: - // This should never occur, but if it does, we'll try the simplest thing possible - Runtime.getRuntime().exec(new String[] { (String) browser, url }); - 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); - private native static int ICStop(int[] instance); - private native static int ICLaunchURL(int instance, byte[] hint, byte[] data, int len, - int[] selectionStart, int[] selectionEnd); -} + * 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. + */ + private static boolean loadedWithoutErrors; + + /** The com.apple.mrj.MRJFileUtils class */ + private static Class mrjFileUtilsClass; + + /** The com.apple.mrj.MRJOSType class */ + private static Class mrjOSTypeClass; + + /** The com.apple.MacOS.AEDesc class */ + private static Class aeDescClass; + + /** The <init>(int) method of com.apple.MacOS.AETarget */ + private static Constructor aeTargetConstructor; + + /** The <init>(int, int, int) method of com.apple.MacOS.AppleEvent */ + private static Constructor appleEventConstructor; + + /** The <init>(String) method of com.apple.MacOS.AEDesc */ + private static Constructor aeDescConstructor; + + /** The findFolder method of com.apple.mrj.MRJFileUtils */ + private static Method findFolder; + + /** The getFileCreator method of com.apple.mrj.MRJFileUtils */ + private static Method getFileCreator; + + /** The getFileType method of com.apple.mrj.MRJFileUtils */ + private static Method getFileType; + + /** The openURL method of com.apple.mrj.MRJFileUtils */ + private static Method openURL; + + /** The makeOSType method of com.apple.MacOS.OSUtils */ + private static Method makeOSType; + + /** The putParameter method of com.apple.MacOS.AppleEvent */ + private static Method putParameter; + + /** The sendNoReply method of com.apple.MacOS.AppleEvent */ + private static Method sendNoReply; + + /** Actually an MRJOSType pointing to the System Folder on a Macintosh */ + private static Object kSystemFolderType; + + /** The keyDirectObject AppleEvent parameter type */ + private static Integer keyDirectObject; + + /** The kAutoGenerateReturnID AppleEvent code */ + private static Integer kAutoGenerateReturnID; + + /** The kAnyTransactionID AppleEvent code */ + private static Integer kAnyTransactionID; + + /** The linkage object required for JDirect 3 on Mac OS X. */ + private static Object linkage; + + /** 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 MRJ 2.0 */ + private static final int MRJ_2_0 = 0; + + /** JVM constant for MRJ 2.1 or later */ + private static final int MRJ_2_1 = 1; + + /** 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 3.1 */ + private static final int MRJ_3_1 = 4; + + /** JVM constant for any Windows NT JVM */ + private static final int WINDOWS_NT = 5; + + /** JVM constant for any Windows 9x JVM */ + private static final int WINDOWS_9x = 6; + + /** JVM constant for any other platform */ + private static final int OTHER = -1; + + /** + * 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 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 name for the AppleEvent type corresponding to a GetURL event. */ + private static final String GURL_EVENT = "GURL"; + + /** + * 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 second parameter for Runtime.exec() on Windows. */ + private static final String SECOND_WINDOWS_PARAMETER = "start"; + + /** + * 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 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; + + /** + * 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; + } + + 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(); + + 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; + } + + 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(); + + 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; + } + + 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; + } catch (NoSuchMethodException nsme) { + errorMessage = nsme.getMessage(); + + return false; + } catch (InvocationTargetException ite) { + errorMessage = ite.getMessage(); + + return false; + } catch (InstantiationException ie) { + errorMessage = ie.getMessage(); + + return false; + } catch (IllegalAccessException iae) { + errorMessage = iae.getMessage(); + + return false; + } + + break; + + case MRJ_3_1: + + 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 (NoSuchMethodException nsme) { + errorMessage = nsme.getMessage(); + + return false; + } + + break; + + default: + break; + } + + 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; + } + + 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; + } + + case MRJ_2_1: + + File systemFolder; + + try { + systemFolder = (File) findFolder.invoke(null, + new Object[] { kSystemFolderType }); + } catch (IllegalArgumentException iare) { + browser = null; + errorMessage = iare.getMessage(); + + return browser; + } catch (IllegalAccessException iae) { + browser = null; + errorMessage = iae.getMessage(); + + return browser; + } catch (InvocationTargetException ite) { + browser = null; + errorMessage = ite.getTargetException().getClass() + ": " + + ite.getTargetException().getMessage(); + + 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; + } + } + + browser = null; + + break; + + case MRJ_3_0: + case MRJ_3_1: + browser = ""; // Return something non-null + + break; + + case WINDOWS_NT: + browser = "cmd.exe"; + + break; + + case WINDOWS_9x: + browser = "command.com"; + + break; + + case OTHER:default: + browser = jalview.bin.Cache.applicationProperties.getProperty( + "jalview.browser"); + + if (browser == null) { + // hope firefox exists :-/ + browser = "firefox"; + } + + break; + } + + 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); + } + + 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; + + 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 MRJ_3_1: + + 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 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; + + 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; + + default: + + // This should never occur, but if it does, we'll try the simplest thing possible + Runtime.getRuntime().exec(new String[] { (String) browser, url }); + + 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); + + private native static int ICStop(int[] instance); + + 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 320855a..8041d80 100755 --- a/src/jalview/util/Comparison.java +++ b/src/jalview/util/Comparison.java @@ -16,166 +16,165 @@ * 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 jalview.datamodel.*; + public class Comparison { + public static String GapChars = " .-"; - public static float compare(SequenceI ii, SequenceI jj) - { - return Comparison.compare(ii,jj,0,ii.getLength()-1); - } - /** - * this was supposed to be an ungapped pid calculation - * @param ii SequenceI - * @param jj SequenceI - * @param start int - * @param end int - * @return float - */ - 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))) - { - ilen--; - } - - while (jalview.util.Comparison.isGap(sj.charAt(start + jlen))) - { - jlen--; - } - - int count = 0; - int match = 0; - float pid = -1; - - 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))) { - match++; - } - count++; - } - pid = (float)match/(float)ilen * 100; - } else { - for (int j = 0; j < jlen; j++) { - if (si.substring(start + j,start + j+1).equals(sj.substring(start + j,start + j+1))) { - match++; - } - count++; - } - pid = (float)match/(float)jlen * 100; - } - - return pid; - } - - /** - * this is a gapped PID calculation - * - * @param s1 SequenceI - * @param s2 SequenceI - * @return float - */ - public static float PID(SequenceI s1 , SequenceI s2) - { - int len; - - if (s1.getSequence().length() > s2.getSequence().length()) - len = s1.getSequence().length(); - else - len = s2.getSequence().length(); - - - int bad = 0; - - for (int i = 0; i < len; i++) - { - char chr1; - char chr2; - - if (i < s1.getSequence().length()) - chr1 = s1.getSequence().charAt(i); - else - chr1 = '.'; - - - if (i < s2.getSequence().length()) - chr2 = s2.getSequence().charAt(i); - else - chr2 = '.'; - - - if (!(jalview.util.Comparison.isGap( chr1 )) && !(jalview.util.Comparison.isGap( chr2 ))) - { - if (chr1!=chr2) - bad++; - } + public static float compare(SequenceI ii, SequenceI jj) { + return Comparison.compare(ii, jj, 0, ii.getLength() - 1); } - return (float)100*(len-bad)/len; - } - - // Another pid with region specification - - public static float PID(SequenceI s1 , SequenceI s2, int start, int end) - { - int len; - - if (s1.getSequence().length() > s2.getSequence().length()) - len = s1.getSequence().length(); - else - len = s2.getSequence().length(); - - if (end jlen) { + for (int j = 0; j < jlen; j++) { + if (si.substring(start + j, start + j + 1).equals(sj.substring(start + + j, start + j + 1))) { + match++; + } + + count++; + } + + pid = (float) match / (float) ilen * 100; + } else { + for (int j = 0; j < jlen; j++) { + if (si.substring(start + j, start + j + 1).equals(sj.substring(start + + j, start + j + 1))) { + match++; + } + + count++; + } + + pid = (float) match / (float) jlen * 100; + } + + return pid; } - int bad = 0; - - for (int i = start; i < len; i++) - { - char chr1; - char chr2; - - if (i < s1.getSequence().length()) - chr1 = s1.getSequence().charAt(i); - else - chr1 = '.'; - - - if (i < s2.getSequence().length()) - chr2 = s2.getSequence().charAt(i); - else - chr2 = '.'; - - - if (!(jalview.util.Comparison.isGap( chr1 )) && !(jalview.util.Comparison.isGap( chr2 ))) - { - if (chr1!=chr2) - bad++; - } + /** + * this is a gapped PID calculation + * + * @param s1 SequenceI + * @param s2 SequenceI + * @return float + */ + public static float PID(SequenceI s1, SequenceI s2) { + int len; + + if (s1.getSequence().length() > s2.getSequence().length()) { + len = s1.getSequence().length(); + } else { + len = s2.getSequence().length(); + } + + int bad = 0; + + for (int i = 0; i < len; i++) { + char chr1; + char chr2; + + if (i < s1.getSequence().length()) { + chr1 = s1.getSequence().charAt(i); + } else { + chr1 = '.'; + } + + if (i < s2.getSequence().length()) { + chr2 = s2.getSequence().charAt(i); + } else { + chr2 = '.'; + } + + if (!(jalview.util.Comparison.isGap(chr1)) && + !(jalview.util.Comparison.isGap(chr2))) { + if (chr1 != chr2) { + bad++; + } + } + } + + return ((float) 100 * (len - bad)) / len; } - return (float)100*(len-bad)/len; - } - + // Another pid with region specification + public static float PID(SequenceI s1, SequenceI s2, int start, int end) { + int len; + + if (s1.getSequence().length() > s2.getSequence().length()) { + len = s1.getSequence().length(); + } else { + len = s2.getSequence().length(); + } + + if (end < len) { + len = end; + } + + 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++) { + char chr1; + char chr2; + + if (i < s1.getSequence().length()) { + chr1 = s1.getSequence().charAt(i); + } else { + chr1 = '.'; + } + + if (i < s2.getSequence().length()) { + chr2 = s2.getSequence().charAt(i); + } else { + chr2 = '.'; + } + + if (!(jalview.util.Comparison.isGap(chr1)) && + !(jalview.util.Comparison.isGap(chr2))) { + if (chr1 != chr2) { + bad++; + } + } + } + + return ((float) 100 * (len - bad)) / len; + } - public static String GapChars = " .-"; - public static boolean isGap(char c) - { - return (c != '.' && c != '-' && c != ' ') ? false : true; - } + 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 798dc8f..4c47f65 100755 --- a/src/jalview/util/Format.java +++ b/src/jalview/util/Format.java @@ -25,13 +25,126 @@ * @version 1.03 25 Oct 1997 * @author Cay Horstmann */ - - package jalview.util; import java.io.*; + public class Format { + private int width; + private int precision; + private String pre; + private String post; + private boolean leading_zeroes; + private boolean show_plus; + private boolean alternate; + private boolean show_space; + private boolean left_align; + private char fmt; // one of cdeEfgGiosxXos + + public Format(String s) { + width = 0; + precision = -1; + pre = ""; + post = ""; + leading_zeroes = false; + show_plus = false; + alternate = false; + show_space = false; + left_align = false; + fmt = ' '; + + int state = 0; + int length = s.length(); + int parse_state = 0; + + // 0 = prefix, 1 = flags, 2 = width, 3 = precision, + // 4 = format, 5 = end + int i = 0; + + while (parse_state == 0) { + if (i >= length) { + parse_state = 5; + } else if (s.charAt(i) == '%') { + if (i < (length - 1)) { + if (s.charAt(i + 1) == '%') { + pre = pre + '%'; + i++; + } else { + parse_state = 1; + } + } else { + throw new java.lang.IllegalArgumentException(); + } + } else { + pre = pre + s.charAt(i); + } + + i++; + } + + while (parse_state == 1) { + if (i >= length) { + parse_state = 5; + } else if (s.charAt(i) == ' ') { + show_space = true; + } else if (s.charAt(i) == '-') { + left_align = true; + } else if (s.charAt(i) == '+') { + show_plus = true; + } else if (s.charAt(i) == '0') { + leading_zeroes = true; + } else if (s.charAt(i) == '#') { + alternate = true; + } else { + parse_state = 2; + i--; + } + + i++; + } + + while (parse_state == 2) { + if (i >= length) { + parse_state = 5; + } else if (('0' <= s.charAt(i)) && (s.charAt(i) <= '9')) { + width = ((width * 10) + s.charAt(i)) - '0'; + i++; + } else if (s.charAt(i) == '.') { + parse_state = 3; + precision = 0; + i++; + } else { + parse_state = 4; + } + } + + while (parse_state == 3) { + if (i >= length) { + parse_state = 5; + } else if (('0' <= s.charAt(i)) && (s.charAt(i) <= '9')) { + precision = ((precision * 10) + s.charAt(i)) - '0'; + i++; + } else { + parse_state = 4; + } + } + + if (parse_state == 4) { + if (i >= length) { + parse_state = 5; + } else { + fmt = s.charAt(i); + } + + i++; + } + + if (i < length) { + post = s.substring(i, length); + } + } + /** * Formats the number following printf conventions. * Main limitation: Can only handle one format parameter at a time @@ -68,565 +181,525 @@ public class Format { * @exception IllegalArgumentException if bad format * */ + public static String getHexString(java.awt.Color color) { + String r; + String g; + String b; + r = Integer.toHexString(color.getRed()); + + if (r.length() < 2) { + r = "0" + r; + } - public static String getHexString(java.awt.Color color) - { - String r, g, b; - r = Integer.toHexString(color.getRed()); - if (r.length() < 2) - r = "0" + r; - g = Integer.toHexString(color.getGreen()); - if (g.length() < 2) - g = "0" + g; - b = Integer.toHexString(color.getBlue()); - if (b.length() < 2) - b = "0" + b; - - return r+g+b; - } - - - public Format(String s) { - width = 0; - precision = -1; - pre = ""; - post = ""; - leading_zeroes = false; - show_plus = false; - alternate = false; - show_space = false; - left_align = false; - fmt = ' '; - - int state = 0; - int length = s.length(); - int parse_state = 0; - // 0 = prefix, 1 = flags, 2 = width, 3 = precision, - // 4 = format, 5 = end - int i = 0; - - while (parse_state == 0) { - if (i >= length) - parse_state = 5; - else if (s.charAt(i) == '%') { - if (i < length - 1) { - if (s.charAt(i + 1) == '%') { - pre = pre + '%'; - i++; - } else - parse_state = 1; - } else - throw new java.lang.IllegalArgumentException(); - } else - pre = pre + s.charAt(i); - i++; + g = Integer.toHexString(color.getGreen()); + + if (g.length() < 2) { + g = "0" + g; + } + + b = Integer.toHexString(color.getBlue()); + + if (b.length() < 2) { + b = "0" + b; + } + + return r + g + b; } - while (parse_state == 1) { - if (i >= length) - parse_state = 5; - else if (s.charAt(i) == ' ') - show_space = true; - else if (s.charAt(i) == '-') - left_align = true; - else if (s.charAt(i) == '+') - show_plus = true; - else if (s.charAt(i) == '0') - leading_zeroes = true; - else if (s.charAt(i) == '#') - alternate = true; - else { - parse_state = 2; - i--; - } - i++; + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream + * @param fmt the format string + * @param x the double to print + */ + public static void print(java.io.PrintStream s, String fmt, double x) { + s.print(new Format(fmt).form(x)); } - while (parse_state == 2) { - if (i >= length) - parse_state = 5; - else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') { - width = width * 10 + s.charAt(i) - '0'; - i++; - } else if (s.charAt(i) == '.') { - parse_state = 3; - precision = 0; - i++; - } else - parse_state = 4; + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream + * @param fmt the format string + * @param x the long to print + */ + public static void print(java.io.PrintStream s, String fmt, long x) { + s.print(new Format(fmt).form(x)); } - while (parse_state == 3) { - if (i >= length) - parse_state = 5; - else if ('0' <= s.charAt(i) && s.charAt(i) <= '9') { - precision = precision * 10 + s.charAt(i) - '0'; - i++; - } else - parse_state = 4; + + /** + * prints a formatted number following printf conventions + * @param s a PrintStream + * @param fmt the format string + * @param x the character to + */ + public static void print(java.io.PrintStream s, String fmt, char x) { + s.print(new Format(fmt).form(x)); } - if (parse_state == 4) { - if (i >= length) - parse_state = 5; - else - fmt = s.charAt(i); - i++; + + /** + * prints a formatted number following printf conventions + * @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) { + s.print(new Format(fmt).form(x)); } - if (i < length) - post = s.substring(i, length); - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the double to print - */ - - public static void print(java.io.PrintStream s, String fmt, double x) { - s.print(new Format(fmt).form(x)); - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the long to print - */ - public static void print(java.io.PrintStream s, String fmt, long x) { - s.print(new Format(fmt).form(x)); - } - - /** - * prints a formatted number following printf conventions - * @param s a PrintStream - * @param fmt the format string - * @param x the character to - */ - - public static void print(java.io.PrintStream s, String fmt, char x) { - s.print(new Format(fmt).form(x)); - } - - /** - * prints a formatted number following printf conventions - * @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) { - s.print(new Format(fmt).form(x)); - } - - /** - * Converts a string of digits (decimal, octal or hex) to an integer - * @param s a string - * @return the numeric value of the prefix of s representing a base 10 integer - */ - - public static int atoi(String s) { - return (int)atol(s); - } - - /** - * Converts a string of digits (decimal, octal or hex) to a long integer - * @param s a string - * @return the numeric value of the prefix of s representing a base 10 integer - */ - - 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 + 1 < s.length() && (s.charAt(i + 1) == 'x' || s.charAt(i + 1) == 'X')) - return parseLong(s.substring(i + 2), 16); - else - return parseLong(s, 8); - } else - return parseLong(s, 10); - } - - private static long parseLong(String s, int base) { - int i = 0; - int sign = 1; - long r = 0; - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) - i++; - if (i < s.length() && s.charAt(i) == '-') { - sign = -1; - i++; - } else if (i < s.length() && s.charAt(i) == '+') { - i++; + + /** + * Converts a string of digits (decimal, octal or hex) to an integer + * @param s a string + * @return the numeric value of the prefix of s representing a base 10 integer + */ + public static int atoi(String s) { + return (int) atol(s); } - while (i < s.length()) { - char ch = s.charAt(i); - if ('0' <= ch && ch < '0' + base) - r = r * base + ch - '0'; - else if ('A' <= ch && ch < 'A' + base - 10) - r = r * base + ch - 'A' + 10 ; - else if ('a' <= ch && ch < 'a' + base - 10) - r = r * base + ch - 'a' + 10 ; - else - return r * sign; - i++; + + /** + * Converts a string of digits (decimal, octal or hex) to a long integer + * @param s a string + * @return the numeric value of the prefix of s representing a base 10 integer + */ + 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 + 1) < s.length()) && + ((s.charAt(i + 1) == 'x') || (s.charAt(i + 1) == 'X'))) { + return parseLong(s.substring(i + 2), 16); + } else { + return parseLong(s, 8); + } + } else { + return parseLong(s, 10); + } } - return r * sign; - } - - /** - * Converts a string of digits to an double - * @param s a string - */ - - public static double atof(String s) { - int i = 0; - int sign = 1; - double r = 0; // integer part - double f = 0; // fractional part - double p = 1; // exponent of fractional part - int state = 0; // 0 = int part, 1 = frac part - - while (i < s.length() && Character.isWhitespace(s.charAt(i))) - i++; - if (i < s.length() && s.charAt(i) == '-') { - sign = -1; - i++; - } else if (i < s.length() && s.charAt(i) == '+') { - i++; + + private static long parseLong(String s, int base) { + int i = 0; + int sign = 1; + long r = 0; + + while ((i < s.length()) && Character.isWhitespace(s.charAt(i))) + i++; + + if ((i < s.length()) && (s.charAt(i) == '-')) { + sign = -1; + i++; + } else if ((i < s.length()) && (s.charAt(i) == '+')) { + i++; + } + + while (i < s.length()) { + char ch = s.charAt(i); + + if (('0' <= ch) && (ch < ('0' + base))) { + r = ((r * base) + ch) - '0'; + } else if (('A' <= ch) && (ch < (('A' + base) - 10))) { + r = ((r * base) + ch) - 'A' + 10; + } else if (('a' <= ch) && (ch < (('a' + base) - 10))) { + r = ((r * base) + ch) - 'a' + 10; + } else { + return r * sign; + } + + i++; + } + + return r * sign; } - while (i < s.length()) { - char ch = s.charAt(i); - if ('0' <= ch && ch <= '9') { - if (state == 0) - r = r * 10 + ch - '0'; - else if (state == 1) { - p = p / 10; - r = r + p * (ch - '0'); - } - } else if (ch == '.') { - if (state == 0) - state = 1; - else - return sign * r; - } else if (ch == 'e' || ch == 'E') { - long e = (int)parseLong(s.substring(i + 1), 10); - return sign * r * Math.pow(10, e); - } else + + /** + * Converts a string of digits to an double + * @param s a string + */ + public static double atof(String s) { + int i = 0; + int sign = 1; + double r = 0; // integer part + double f = 0; // fractional part + double p = 1; // exponent of fractional part + int state = 0; // 0 = int part, 1 = frac part + + while ((i < s.length()) && Character.isWhitespace(s.charAt(i))) + i++; + + if ((i < s.length()) && (s.charAt(i) == '-')) { + sign = -1; + i++; + } else if ((i < s.length()) && (s.charAt(i) == '+')) { + i++; + } + + while (i < s.length()) { + char ch = s.charAt(i); + + if (('0' <= ch) && (ch <= '9')) { + if (state == 0) { + r = ((r * 10) + ch) - '0'; + } else if (state == 1) { + p = p / 10; + r = r + (p * (ch - '0')); + } + } else if (ch == '.') { + if (state == 0) { + state = 1; + } else { + return sign * r; + } + } else if ((ch == 'e') || (ch == 'E')) { + long e = (int) parseLong(s.substring(i + 1), 10); + + return sign * r * Math.pow(10, e); + } else { + return sign * r; + } + + i++; + } + return sign * r; - i++; } - return sign * r; - } - - /** - * Formats a double into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - * @exception IllegalArgumentException if bad argument - */ - - public String form(double x) { - String r; - if (precision < 0) - precision = 6; - int s = 1; - if (x < 0) { - x = -x; - s = -1; + + /** + * Formats a double into a string (like sprintf in C) + * @param x the number to format + * @return the formatted string + * @exception IllegalArgumentException if bad argument + */ + public String form(double x) { + String r; + + if (precision < 0) { + precision = 6; + } + + int s = 1; + + if (x < 0) { + x = -x; + s = -1; + } + + if (fmt == 'f') { + r = fixed_format(x); + } else if ((fmt == 'e') || (fmt == 'E') || (fmt == 'g') || + (fmt == 'G')) { + r = exp_format(x); + } else { + throw new java.lang.IllegalArgumentException(); + } + + return pad(sign(s, r)); } - if (fmt == 'f') - r = fixed_format(x); - else if (fmt == 'e' || fmt == 'E' || fmt == 'g' || fmt == 'G') - r = exp_format(x); - else - throw new java.lang.IllegalArgumentException(); - - return pad(sign(s, r)); - } - - /** - * Formats a long integer into a string (like sprintf in C) - * @param x the number to format - * @return the formatted string - */ - - public String form(long x) { - String r; - int s = 0; - if (fmt == 'd' || fmt == 'i') { - if (x < 0) { - r = ("" + x).substring(1); - s = -1; - } else { - r = "" + x; - s = 1; - } - } else if (fmt == 'o') - r = convert(x, 3, 7, "01234567"); - else if (fmt == 'x') - r = convert(x, 4, 15, "0123456789abcdef"); - else if (fmt == 'X') - r = convert(x, 4, 15, "0123456789ABCDEF"); - else - throw new java.lang.IllegalArgumentException(); - - return pad(sign(s, r)); - } - - /** - * Formats a character into a string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ - - public String form(char c) { - if (fmt != 'c') - throw new java.lang.IllegalArgumentException(); - - String r = "" + c; - return pad(r); - } - - /** - * Formats a string into a larger string (like sprintf in C) - * @param x the value to format - * @return the formatted string - */ - - public String form(String s) { - if (fmt != 's') - throw new java.lang.IllegalArgumentException(); - if (precision >= 0) - s = s.substring(0, precision); - return pad(s); - } - - - /** - * a test stub for the format class - */ - - public static void main(String[] a) { - double x = 1.23456789012; - double y = 123; - double z = 1.2345e30; - double w = 1.02; - double u = 1.234e-5; - int d = 0xCAFE; - Format.print(System.out, "x = |%f|\n", x); - Format.print(System.out, "u = |%20f|\n", u); - Format.print(System.out, "x = |% .5f|\n", x); - Format.print(System.out, "w = |%20.5f|\n", w); - Format.print(System.out, "x = |%020.5f|\n", x); - Format.print(System.out, "x = |%+20.5f|\n", x); - Format.print(System.out, "x = |%+020.5f|\n", x); - Format.print(System.out, "x = |% 020.5f|\n", x); - Format.print(System.out, "y = |%#+20.5f|\n", y); - Format.print(System.out, "y = |%-+20.5f|\n", y); - Format.print(System.out, "z = |%20.5f|\n", z); - - Format.print(System.out, "x = |%e|\n", x); - Format.print(System.out, "u = |%20e|\n", u); - Format.print(System.out, "x = |% .5e|\n", x); - Format.print(System.out, "w = |%20.5e|\n", w); - Format.print(System.out, "x = |%020.5e|\n", x); - Format.print(System.out, "x = |%+20.5e|\n", x); - Format.print(System.out, "x = |%+020.5e|\n", x); - Format.print(System.out, "x = |% 020.5e|\n", x); - Format.print(System.out, "y = |%#+20.5e|\n", y); - Format.print(System.out, "y = |%-+20.5e|\n", y); - - Format.print(System.out, "x = |%g|\n", x); - Format.print(System.out, "z = |%g|\n", z); - Format.print(System.out, "w = |%g|\n", w); - Format.print(System.out, "u = |%g|\n", u); - Format.print(System.out, "y = |%.2g|\n", y); - Format.print(System.out, "y = |%#.2g|\n", y); - - Format.print(System.out, "d = |%d|\n", d); - Format.print(System.out, "d = |%20d|\n", d); - Format.print(System.out, "d = |%020d|\n", d); - Format.print(System.out, "d = |%+20d|\n", d); - Format.print(System.out, "d = |% 020d|\n", d); - Format.print(System.out, "d = |%-20d|\n", d); - Format.print(System.out, "d = |%20.8d|\n", d); - Format.print(System.out, "d = |%x|\n", d); - Format.print(System.out, "d = |%20X|\n", d); - Format.print(System.out, "d = |%#20x|\n", d); - Format.print(System.out, "d = |%020X|\n", d); - Format.print(System.out, "d = |%20.8x|\n", d); - Format.print(System.out, "d = |%o|\n", d); - Format.print(System.out, "d = |%020o|\n", d); - Format.print(System.out, "d = |%#20o|\n", d); - Format.print(System.out, "d = |%#020o|\n", d); - Format.print(System.out, "d = |%20.12o|\n", d); - - Format.print(System.out, "s = |%-20s|\n", "Hello"); - Format.print(System.out, "s = |%-20c|\n", '!'); - - // regression test to confirm fix of reported bugs - - Format.print(System.out, "|%i|\n", Long.MIN_VALUE); - - Format.print(System.out, "|%6.2e|\n", 0.0); - Format.print(System.out, "|%6.2g|\n", 0.0); - - Format.print(System.out, "|%6.2f|\n", 9.99); - Format.print(System.out, "|%6.2f|\n", 9.999); - - Format.print(System.out, "|%6.0f|\n", 9.999); - } - - private static String repeat(char c, int n) { - if (n <= 0) - return ""; - StringBuffer s = new StringBuffer(n); - for (int i = 0; i < n; i++) - s.append(c); - return s.toString(); - } - - private static String convert(long x, int n, int m, String d) { - if (x == 0) - return "0"; - String r = ""; - while (x != 0) { - r = d.charAt((int)(x & m)) + r; - x = x >>> n; + + /** + * Formats a long integer into a string (like sprintf in C) + * @param x the number to format + * @return the formatted string + */ + public String form(long x) { + String r; + int s = 0; + + if ((fmt == 'd') || (fmt == 'i')) { + if (x < 0) { + r = ("" + x).substring(1); + s = -1; + } else { + r = "" + x; + s = 1; + } + } else if (fmt == 'o') { + r = convert(x, 3, 7, "01234567"); + } else if (fmt == 'x') { + r = convert(x, 4, 15, "0123456789abcdef"); + } else if (fmt == 'X') { + r = convert(x, 4, 15, "0123456789ABCDEF"); + } else { + throw new java.lang.IllegalArgumentException(); + } + + return pad(sign(s, r)); } - return r; - } - - private String pad(String r) { - String p = repeat(' ', width - r.length()); - if (left_align) - return pre + r + p + post; - else - return pre + p + r + post; - } - - private String sign(int s, String r) { - String p = ""; - if (s < 0) - p = "-"; - else if (s > 0) { - if (show_plus) - p = "+"; - else if (show_space) - p = " "; - } else { - if (fmt == 'o' && alternate && r.length() > 0 && r.charAt(0) != '0') - p = "0"; - else if (fmt == 'x' && alternate) - p = "0x"; - else if (fmt == 'X' && alternate) - p = "0X"; + + /** + * Formats a character into a string (like sprintf in C) + * @param x the value to format + * @return the formatted string + */ + public String form(char c) { + if (fmt != 'c') { + throw new java.lang.IllegalArgumentException(); + } + + String r = "" + c; + + return pad(r); } - int w = 0; - if (leading_zeroes) - w = width; - 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) { - boolean removeTrailing - = (fmt == 'G' || fmt == 'g') && !alternate; - // remove trailing zeroes and decimal point - - if (d > 0x7FFFFFFFFFFFFFFFL) - return exp_format(d); - if (precision == 0) - return (long)(d + 0.5) + (removeTrailing ? "" : "."); - - long whole = (long)d; - double fr = d - whole; // fractional part - if (fr >= 1 || fr < 0) - return exp_format(d); - - double factor = 1; - String leading_zeroes = ""; - for (int i = 1; i <= precision && factor <= 0x7FFFFFFFFFFFFFFFL; i++) { - factor *= 10; - leading_zeroes = leading_zeroes + "0"; + + /** + * Formats a string into a larger string (like sprintf in C) + * @param x the value to format + * @return the formatted string + */ + public String form(String s) { + if (fmt != 's') { + throw new java.lang.IllegalArgumentException(); + } + + if (precision >= 0) { + s = s.substring(0, precision); + } + + return pad(s); } - long l = (long) (factor * fr + 0.5); - if (l >= factor) { - l = 0; - whole++; - } // CSH 10-25-97 - - String z = leading_zeroes + l; - z = "." + z.substring(z.length() - precision, z.length()); - - if (removeTrailing) { - int t = z.length() - 1; - while (t >= 0 && z.charAt(t) == '0') - t--; - if (t >= 0 && z.charAt(t) == '.') - t--; - z = z.substring(0, t + 1); + + /** + * a test stub for the format class + */ + public static void main(String[] a) { + double x = 1.23456789012; + double y = 123; + double z = 1.2345e30; + double w = 1.02; + double u = 1.234e-5; + int d = 0xCAFE; + Format.print(System.out, "x = |%f|\n", x); + Format.print(System.out, "u = |%20f|\n", u); + Format.print(System.out, "x = |% .5f|\n", x); + Format.print(System.out, "w = |%20.5f|\n", w); + Format.print(System.out, "x = |%020.5f|\n", x); + Format.print(System.out, "x = |%+20.5f|\n", x); + Format.print(System.out, "x = |%+020.5f|\n", x); + Format.print(System.out, "x = |% 020.5f|\n", x); + Format.print(System.out, "y = |%#+20.5f|\n", y); + Format.print(System.out, "y = |%-+20.5f|\n", y); + Format.print(System.out, "z = |%20.5f|\n", z); + + Format.print(System.out, "x = |%e|\n", x); + Format.print(System.out, "u = |%20e|\n", u); + Format.print(System.out, "x = |% .5e|\n", x); + Format.print(System.out, "w = |%20.5e|\n", w); + Format.print(System.out, "x = |%020.5e|\n", x); + Format.print(System.out, "x = |%+20.5e|\n", x); + Format.print(System.out, "x = |%+020.5e|\n", x); + Format.print(System.out, "x = |% 020.5e|\n", x); + Format.print(System.out, "y = |%#+20.5e|\n", y); + Format.print(System.out, "y = |%-+20.5e|\n", y); + + Format.print(System.out, "x = |%g|\n", x); + Format.print(System.out, "z = |%g|\n", z); + Format.print(System.out, "w = |%g|\n", w); + Format.print(System.out, "u = |%g|\n", u); + Format.print(System.out, "y = |%.2g|\n", y); + Format.print(System.out, "y = |%#.2g|\n", y); + + Format.print(System.out, "d = |%d|\n", d); + Format.print(System.out, "d = |%20d|\n", d); + Format.print(System.out, "d = |%020d|\n", d); + Format.print(System.out, "d = |%+20d|\n", d); + Format.print(System.out, "d = |% 020d|\n", d); + Format.print(System.out, "d = |%-20d|\n", d); + Format.print(System.out, "d = |%20.8d|\n", d); + Format.print(System.out, "d = |%x|\n", d); + Format.print(System.out, "d = |%20X|\n", d); + Format.print(System.out, "d = |%#20x|\n", d); + Format.print(System.out, "d = |%020X|\n", d); + Format.print(System.out, "d = |%20.8x|\n", d); + Format.print(System.out, "d = |%o|\n", d); + Format.print(System.out, "d = |%020o|\n", d); + Format.print(System.out, "d = |%#20o|\n", d); + Format.print(System.out, "d = |%#020o|\n", d); + Format.print(System.out, "d = |%20.12o|\n", d); + + Format.print(System.out, "s = |%-20s|\n", "Hello"); + Format.print(System.out, "s = |%-20c|\n", '!'); + + // regression test to confirm fix of reported bugs + Format.print(System.out, "|%i|\n", Long.MIN_VALUE); + + Format.print(System.out, "|%6.2e|\n", 0.0); + Format.print(System.out, "|%6.2g|\n", 0.0); + + Format.print(System.out, "|%6.2f|\n", 9.99); + Format.print(System.out, "|%6.2f|\n", 9.999); + + Format.print(System.out, "|%6.0f|\n", 9.999); } - return whole + z; - } - - private String exp_format(double d) { - String f = ""; - int e = 0; - double dd = d; - double factor = 1; - if (d != 0) { - while (dd > 10) { - e++; - factor /= 10; - dd = dd / 10; - } - while (dd < 1) { - e--; - factor *= 10; - dd = dd * 10; - } + private static String repeat(char c, int n) { + if (n <= 0) { + return ""; + } + + StringBuffer s = new StringBuffer(n); + + for (int i = 0; i < n; i++) + s.append(c); + + return s.toString(); } - 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') - f = f + "e"; - else - f = f + "E"; - - String p = "000"; - if (e >= 0) { - f = f + "+"; - p = p + e; - } else { - f = f + "-"; - p = p + (-e); + + private static String convert(long x, int n, int m, String d) { + if (x == 0) { + return "0"; + } + + String r = ""; + + while (x != 0) { + r = d.charAt((int) (x & m)) + r; + x = x >>> n; + } + + return r; } - return f + p.substring(p.length() - 3, p.length()); - } - - private int width; - private int precision; - private String pre; - private String post; - private boolean leading_zeroes; - private boolean show_plus; - private boolean alternate; - private boolean show_space; - private boolean left_align; - private char fmt; // one of cdeEfgGiosxXos -} + private String pad(String r) { + String p = repeat(' ', width - r.length()); + + if (left_align) { + return pre + r + p + post; + } else { + return pre + p + r + post; + } + } + private String sign(int s, String r) { + String p = ""; + + if (s < 0) { + p = "-"; + } else if (s > 0) { + if (show_plus) { + p = "+"; + } else if (show_space) { + p = " "; + } + } else { + if ((fmt == 'o') && alternate && (r.length() > 0) && + (r.charAt(0) != '0')) { + p = "0"; + } else if ((fmt == 'x') && alternate) { + p = "0x"; + } else if ((fmt == 'X') && alternate) { + p = "0X"; + } + } + + int w = 0; + + if (leading_zeroes) { + w = width; + } 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) { + boolean removeTrailing = ((fmt == 'G') || (fmt == 'g')) && !alternate; + // remove trailing zeroes and decimal point + if (d > 0x7FFFFFFFFFFFFFFFL) { + return exp_format(d); + } + + if (precision == 0) { + return (long) (d + 0.5) + (removeTrailing ? "" : "."); + } + + long whole = (long) d; + double fr = d - whole; // fractional part + + if ((fr >= 1) || (fr < 0)) { + return exp_format(d); + } + + double factor = 1; + String leading_zeroes = ""; + + for (int i = 1; (i <= precision) && (factor <= 0x7FFFFFFFFFFFFFFFL); + i++) { + factor *= 10; + leading_zeroes = leading_zeroes + "0"; + } + + long l = (long) ((factor * fr) + 0.5); + + if (l >= factor) { + l = 0; + whole++; + } + // CSH 10-25-97 + String z = leading_zeroes + l; + z = "." + z.substring(z.length() - precision, z.length()); + if (removeTrailing) { + int t = z.length() - 1; + while ((t >= 0) && (z.charAt(t) == '0')) + t--; + + if ((t >= 0) && (z.charAt(t) == '.')) { + t--; + } + + z = z.substring(0, t + 1); + } + + return whole + z; + } + + private String exp_format(double d) { + String f = ""; + int e = 0; + double dd = d; + double factor = 1; + + if (d != 0) { + while (dd > 10) { + e++; + factor /= 10; + dd = dd / 10; + } + + while (dd < 1) { + e--; + factor *= 10; + dd = dd * 10; + } + } + + 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')) { + f = f + "e"; + } else { + f = f + "E"; + } + + String p = "000"; + + if (e >= 0) { + f = f + "+"; + p = p + e; + } else { + f = f + "-"; + p = p + (-e); + } + + return f + p.substring(p.length() - 3, p.length()); + } +} diff --git a/src/jalview/util/QuickSort.java b/src/jalview/util/QuickSort.java index 3624144..127b419 100755 --- a/src/jalview/util/QuickSort.java +++ b/src/jalview/util/QuickSort.java @@ -16,95 +16,90 @@ * 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 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 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 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); + if (p < r) { + q = stringPartition(arr, p, r, s); + stringSort(arr, p, q, s); + stringSort(arr, q + 1, r, s); + } } - } - public static void sort(float[] 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 = partition(arr,p,r,s); - sort(arr,p,q,s); - sort(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); + } } - } - - 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 674743e..3711db0 100755 --- a/src/jalview/ws/JPredClient.java +++ b/src/jalview/ws/JPredClient.java @@ -16,438 +16,379 @@ * 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 org.apache.axis.client.*; -import javax.xml.namespace.QName; -import java.util.*; +import ext.vamsas.*; + +import jalview.analysis.AlignSeq; + import jalview.datamodel.*; + import jalview.gui.*; -import javax.swing.*; -import java.util.*; + +import org.apache.axis.client.*; + import java.awt.*; -import jalview.analysis.AlignSeq; -import ext.vamsas.*; -public class JPredClient - extends WSClient -{ - ext.vamsas.JPredWS server; - String altitle = ""; - java.util.Hashtable SequenceInfo = null; - 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; - } - return true; +import java.util.*; + +import javax.swing.*; + +import javax.xml.namespace.QName; + + +public class JPredClient extends WSClient { + ext.vamsas.JPredWS server; + String altitle = ""; + java.util.Hashtable SequenceInfo = null; + + public JPredClient(String title, SequenceI[] msf) { + wsInfo = setWebService(); + + SequenceI seq = msf[0]; + altitle = "JNet prediction on " + seq.getName() + + " using alignment from " + title; + + 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); + + if (!locateWebService()) { + return; + } + + JPredThread jthread = new JPredThread(msf); + jthread.start(); } - public JPredClient(String title, SequenceI[] msf) - { - wsInfo = setWebService(); - SequenceI seq = msf[0]; - altitle = "JNet prediction on " + seq.getName() + - " using alignment from " + title; - - 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); - if (!locateWebService()) - return; - - 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; + } + + JPredThread jthread = new JPredThread(seq); + 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; + 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"; - SequenceInfo = jalview.analysis.SeqsetUtils.SeqCharacterHash(seq); + WebserviceInfo wsInfo = new WebserviceInfo(WebServiceJobTitle, + WebServiceReference); - if (!locateWebService()) - return; + 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; + } - JPredThread jthread = new JPredThread(seq); - jthread.start(); + 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())); - } - - 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)); - } - - 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")); - } + 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())); + } - if (result.isRunning()) - { - wsInfo.setStatus(WebserviceInfo.STATE_RUNNING); - } - else if (result.isQueued()) - { - wsInfo.setStatus(WebserviceInfo.STATE_QUEUING); + 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)); + } + + 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) { + } + } } - if (result.isFinished()) - { - parseResult(); - jobComplete = true; - jobsRunning--; + if (!(result.isJobFailed() || result.isServerError())) { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); + } else { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); } - else - { - wsInfo.setProgressText(OutputHeader + "\n" + result.getStatus()); - if (! (result.isJobFailed() || result.isServerError())) - { - try - { - Thread.sleep(5000); + } + + void StartJob() { + try { + if (msa != null) { + jobId = server.predictOnMsa(msa); + } else { + jobId = server.predict(sequence); } - catch (InterruptedException ex1) - { + + 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"); } - // 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) - { + } catch (Exception e) { + wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); + allowedServerExceptions = 0; + jobComplete = false; + wsInfo.appendProgressText("Failed to submit the prediction: " + + e.toString() + "\nJust close the window\n"); + System.err.println( + "JPredWS Client: Failed to submit the prediction\n" + + e.toString() + "\n"); + + // e.printStackTrace(); TODO: JBPNote DEBUG } - } } - if (! (result.isJobFailed() || result.isServerError())) - { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); - } - else - { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); + 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)); } - } - - 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); + + void parseResult() { + // OutputHeader = output.getText(); + if (result.isFailed()) { + OutputHeader += "Job failed.\n"; } - else - { - System.out.println(WsURL + " Job Id '" + jobId + "'"); + + if (result.getStatus() != null) { + OutputHeader += ("\n" + result.getStatus()); } - } - 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: " + - e.toString() + "\nJust close the window\n"); - System.err.println( - "JPredWS Client: Failed to submit the prediction\n" + - e.toString() + "\n"); - // e.printStackTrace(); TODO: JBPNote DEBUG - } - } - - 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)); - } - - 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; + 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 } - else - { - throw (new Exception("Unknown format 'format' for file : \n" + - result.getAligfile())); + + if (result.getAligfile() != null) { + OutputHeader += ("\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); + 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(); } - } - 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); + + if (!jalview.analysis.SeqsetUtils.SeqCharacterUnhash( + al.getSequenceAt(FirstSeq), SequenceInfo)) { + throw (new Exception( + "Couldn't recover sequence properties for JNet Query sequence!")); } - } - else - { - for (int j = 0; j < width; j++) - { - annotations[gapmap[j]] = new Annotation(preds[i].getCharAt(j) + - "", "", ' ', 0); + + 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")); } - } - - 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); + // 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++; + } - addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPB"), - "JnetpropB", "Jnet Beta Sheet Propensity", 0f,1f,1); + Hashtable scores = prediction.getScores(); - addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPC"), - "JnetpropC", "Jnet Coil Propensity", 0f,1f,1); - */ - AlignFrame af = new AlignFrame(al); + /* addFloatAnnotations(al, gapmap, (Vector)scores.get("JNETPROPH"), + "JnetpropH", "Jnet Helix Propensity", 0f,1f,1); - Desktop.addInternalFrame(af, - altitle, - AlignFrame.NEW_WINDOW_WIDTH, - AlignFrame.NEW_WINDOW_HEIGHT); - } - catch (Exception ex) - { - ex.printStackTrace(); - } + 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(); + } + } } - } +} diff --git a/src/jalview/ws/MsaWSClient.java b/src/jalview/ws/MsaWSClient.java index 32f5c43..b5e7938 100755 --- a/src/jalview/ws/MsaWSClient.java +++ b/src/jalview/ws/MsaWSClient.java @@ -15,339 +15,363 @@ * 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 org.apache.axis.client.*; -import javax.xml.namespace.QName; -import java.util.*; -import jalview.datamodel.*; -import jalview.gui.*; -import javax.swing.*; -import java.util.*; -import java.awt.*; -import jalview.analysis.AlignSeq; -import ext.vamsas.*; -import vamsas.objects.*; - - - - -public class MsaWSClient - extends WSClient -{ +*/ +package jalview.ws; + +import ext.vamsas.*; + +import jalview.analysis.AlignSeq; + +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. - */ - ext.vamsas.MuscleWS server; - // JBPNote Nasty object-global state setting methods shouldn't be allowed - private boolean setWebService(String MsaWSName) { - if (MsaWServices.info.containsKey(MsaWSName)) { - WebServiceName = MsaWSName; - String[] wsinfo = (String[]) MsaWServices.info.get(MsaWSName); - WsURL = wsinfo[0]; - WebServiceJobTitle = wsinfo[1]; - WebServiceReference = wsinfo[2]; - return true; - } else { - return false; - } - } - - private boolean locateWebService() { - // TODO: MuscleWS transmuted to generic MsaWS client - MuscleWSServiceLocator loc = new MuscleWSServiceLocator(); // Default - try { - this.server = (MuscleWS) loc.getMuscleWS(new java.net.URL(WsURL)); - ((MuscleWSSoapBindingStub) this.server).setTimeout(60000); // One minute timeout - } - catch (Exception ex) { - wsInfo.setProgressText("Serious! "+WebServiceName+" Service location failed\nfor URL :" - +WsURL+"\n"+ex.getMessage()); - wsInfo.setStatus(wsInfo.ERROR); - ex.printStackTrace(); - return false; - } - loc.getEngine().setOption("axis","1"); - return true; - } - - public MsaWSClient(String MsaWSName, String altitle, SequenceI[] msa, boolean submitGaps, boolean preserveOrder) - { - if (setWebService(MsaWSName)==false) { - JOptionPane.showMessageDialog(Desktop.desktop, "The Multiple Sequence Alignment Service named "+MsaWSName+" is unknown", - "Internal Jalview Error", JOptionPane.WARNING_MESSAGE); - return; - } - - wsInfo = new jalview.gui.WebserviceInfo(WebServiceJobTitle, WebServiceReference); - - if (!locateWebService()) - return; - - wsInfo.setProgressText(((submitGaps) ? "Re-alignment" : "Alignment")+" of "+altitle+"\nJob details\n"); - - MsaWSThread musclethread = new MsaWSThread(WebServiceName+" alignment of "+altitle, msa, submitGaps, preserveOrder); - wsInfo.setthisService(musclethread); - musclethread.start(); - } - - - protected class MsaWSThread extends Thread implements WSClientI - { - String ServiceName = WebServiceName; - - public boolean isCancellable() - { - return true; - } - - String OutputHeader; - vamsas.objects.simple.MsaResult result = null; - - vamsas.objects.simple.SequenceSet seqs = new vamsas.objects.simple. - SequenceSet(); - - Hashtable SeqNames = null; - boolean submitGaps = false,// default is to strip gaps from sequences - preserveOrder = true; // and always store and recover sequence order - - String jobId; - String alTitle; // name which will be used to form new alignment window. - int allowedServerExceptions = 3; // thread dies if too many exceptions. - MsaWSThread(String title, SequenceI[] msa, boolean subgaps, boolean presorder) - { - alTitle = title; - submitGaps = subgaps; - preserveOrder = presorder; - - OutputHeader = wsInfo.getProgressText(); - SeqNames = new Hashtable(); - vamsas.objects.simple.Sequence[] seqarray = new vamsas.objects.simple. - Sequence[msa.length]; - - for (int i = 0; i < msa.length; i++) - { - String newname = jalview.analysis.SeqsetUtils.unique_name(i); - // uniquify as we go - // TODO: JBPNote: this is a ubiquitous transformation - set of jalview seq objects to vamsas sequences with name preservation - SeqNames.put(newname, jalview.analysis.SeqsetUtils.SeqCharacterHash(msa[i])); - seqarray[i] = new vamsas.objects.simple.Sequence(); - seqarray[i].setId(newname); - seqarray[i].setSeq((submitGaps) ? msa[i].getSequence() - : AlignSeq.extractGaps(jalview.util.Comparison.GapChars, msa[i].getSequence())); - } - - this.seqs = new vamsas.objects.simple.SequenceSet(); - this.seqs.setSeqs(seqarray); - } - - boolean jobComplete = false; - - public void cancelJob() { - if (jobId!=null && !jobId.equals("") && !jobComplete) { - String cancelledMessage=""; - try { - vamsas.objects.simple.WsJobId cancelledJob = server.cancel(jobId); - 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) - { - // VALID UNSTOPPABLE JOB - cancelledMessage += - "Server cannot cancel this job. just close the window.\n"; - } - if (cancelledJob.getJobId() != null) - cancelledMessage += "[" + cancelledJob.getJobId() + "]"; - cancelledMessage +="\n"; - } catch (Exception exc) { - cancelledMessage +="\nProblems cancelling the job : Exception received...\n"+exc+"\n"; - exc.printStackTrace(); - } - wsInfo.setProgressText(OutputHeader + cancelledMessage+"\n"); - } 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() - { - - 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 - { - if (result.getStatus() != null) - wsInfo.setProgressText(OutputHeader + "\n" + result.getStatus()); - if (! (result.isJobFailed() || result.isServerError())) - { - Thread.sleep(5000); - // System.out.println("I'm alive "+seqid+" "+jobid); - } - else - { - break; - } - } - } - catch (Exception ex) - { - allowedServerExceptions--; - wsInfo.appendProgressText("\n" + ServiceName + " Server exception!\n" + - ex.getMessage()); - System.err.println(ServiceName + " Server exception: " + - ex.getMessage()); - // ex.printStackTrace(); JBPNote Debug - try - { - if (allowedServerExceptions>0) - Thread.sleep(5000); - } - catch (InterruptedException ex1) - { - } - - } - } - if (allowedServerExceptions == 0) - { - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); - } - else - { - if (! (result != null && (result.isJobFailed() || result.isServerError()))) - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_OK); - else - { - if (result.isFailed()) - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_ERROR); - if (result.isServerError()) - wsInfo.setStatus(WebserviceInfo.STATE_STOPPED_SERVERERROR); - } - } - } - void StartJob() - { - try - { - vamsas.objects.simple.WsJobId jobsubmit = server.align(seqs); - if (jobsubmit!=null && jobsubmit.getStatus()==1) { - jobId=jobsubmit.getJobId(); - System.out.println(WsURL+" Job Id '"+jobId+"'"); - } 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) - { - // TODO: JBPNote catch timeout or other fault types explicitly - // For unexpected errors - System.err.println(WebServiceName + " Client: Failed to submit the sequences for alignment.\n"+WsURL+" : " + - e.toString() + "\n"); - this.allowedServerExceptions=0; - wsInfo.setStatus(wsInfo.STATE_STOPPED_SERVERERROR); - wsInfo.appendProgressText("Server problems! "+e.toString()+"\nFailed to submit sequences for alignment. Just close the window\n"); - // e.printStackTrace(); // TODO: JBPNote DEBUG - } - } - - 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 jalview.datamodel.Sequence[] getVamsasAlignment(vamsas.objects.simple.Alignment valign) { - vamsas.objects.simple.Sequence[] seqs = valign.getSeqs().getSeqs(); - jalview.datamodel.Sequence[] msa = new jalview.datamodel.Sequence[seqs.length]; - for (int i=0, j=seqs.length; i

Title: MsaWServices

* @@ -30,32 +32,31 @@ import java.util.Hashtable; * * @author not attributable * @version 1.0 - */ + */ /** * TODO: MsaWServices will be set from properties and be dynamically discovered. - */ -public class MsaWServices { - public static Hashtable info; - static - { - info = new Hashtable(); - info.put("ClustalWS", - 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, submitted, June 1994." - }); - info.put("MuscleWS", - 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." - }); - }; -} + */ +public class MsaWServices { + public static Hashtable info; + + static { + info = new Hashtable(); + info.put("ClustalWS", + 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, submitted, June 1994." + }); + info.put("MuscleWS", + 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 1d03eab..506bd9b 100755 --- a/src/jalview/ws/WSClient.java +++ b/src/jalview/ws/WSClient.java @@ -15,28 +15,26 @@ * 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 { + /** -package jalview.ws; - -import jalview.gui.WebserviceInfo; - -public class WSClient -{ - public WSClient() - { - } - /** - - * MsaWSClient - * - * @param msa SequenceI[] - */ - - protected String WebServiceName; - protected String WebServiceJobTitle; - protected String WebServiceReference; - protected String WsURL; - protected WebserviceInfo wsInfo; - int jobsRunning = 0; -} +* 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 7bd4ab8..c2db8c1 100755 --- a/src/jalview/ws/WSClientI.java +++ b/src/jalview/ws/WSClientI.java @@ -15,12 +15,11 @@ * 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(); -} +*/ +package jalview.ws; + +public interface WSClientI { + boolean isCancellable(); + + void cancelJob(); +} diff --git a/src/vamsas/objects/simple/Alignment.java b/src/vamsas/objects/simple/Alignment.java index 177d373..574a1e9 100755 --- a/src/vamsas/objects/simple/Alignment.java +++ b/src/vamsas/objects/simple/Alignment.java @@ -3,8 +3,8 @@ * * This file was auto-generated from WSDL * by the Apache Axis 1.2RC2 Nov 16, 2004 (12:19:44 EST) WSDL2Java emitter. - */ - + */ + /* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle @@ -22,138 +22,147 @@ * 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 vamsas.objects.simple; - -public class Alignment extends vamsas.objects.simple.Object implements java.io.Serializable { - private java.lang.String gapchar; - private java.lang.String[] method; - private vamsas.objects.simple.SequenceSet seqs; - - public Alignment() { - } - - public Alignment( - java.lang.String gapchar, - java.lang.String[] method, - vamsas.objects.simple.SequenceSet seqs) { - this.gapchar = gapchar; - this.method = method; - this.seqs = seqs; - } - - +*/ +package vamsas.objects.simple; + +public class Alignment extends vamsas.objects.simple.Object + implements java.io.Serializable { + private java.lang.String gapchar; + private java.lang.String[] method; + private vamsas.objects.simple.SequenceSet seqs; + private java.lang.Object __equalsCalc = null; + private boolean __hashCodeCalc = false; + + public Alignment() { + } + + public Alignment(java.lang.String gapchar, java.lang.String[] method, + vamsas.objects.simple.SequenceSet seqs) { + this.gapchar = gapchar; + this.method = method; + this.seqs = seqs; + } + /** - * Gets the gapchar value for this Alignment. - * - * @return gapchar - */ - public java.lang.String getGapchar() { - return gapchar; - } - - + * Gets the gapchar value for this Alignment. + * + * @return gapchar + */ + public java.lang.String getGapchar() { + return gapchar; + } + /** - * Sets the gapchar value for this Alignment. - * - * @param gapchar - */ - public void setGapchar(java.lang.String gapchar) { - this.gapchar = gapchar; - } - - + * Sets the gapchar value for this Alignment. + * + * @param gapchar + */ + public void setGapchar(java.lang.String gapchar) { + this.gapchar = gapchar; + } + /** - * Gets the method value for this Alignment. - * - * @return method - */ - public java.lang.String[] getMethod() { - return method; - } - - + * Gets the method value for this Alignment. + * + * @return method + */ + public java.lang.String[] getMethod() { + return method; + } + /** - * Sets the method value for this Alignment. - * - * @param method - */ - public void setMethod(java.lang.String[] method) { - this.method = method; - } - - + * Sets the method value for this Alignment. + * + * @param method + */ + public void setMethod(java.lang.String[] method) { + this.method = method; + } + /** - * Gets the seqs value for this Alignment. - * - * @return seqs - */ - public vamsas.objects.simple.SequenceSet getSeqs() { - return seqs; - } - - + * Gets the seqs value for this Alignment. + * + * @return seqs + */ + public vamsas.objects.simple.SequenceSet getSeqs() { + return seqs; + } + /** - * Sets the seqs value for this Alignment. - * - * @param seqs - */ - public void setSeqs(vamsas.objects.simple.SequenceSet seqs) { - this.seqs = seqs; - } - - private java.lang.Object __equalsCalc = null; - public synchronized boolean equals(java.lang.Object obj) { - if (!(obj instanceof Alignment)) return false; - Alignment other = (Alignment) obj; - if (obj == null) return false; - if (this == obj) return true; - if (__equalsCalc != null) { - return (__equalsCalc == obj); - } - __equalsCalc = obj; - boolean _equals; - _equals = super.equals(obj) && - ((this.gapchar==null && other.getGapchar()==null) || - (this.gapchar!=null && - this.gapchar.equals(other.getGapchar()))) && - ((this.method==null && other.getMethod()==null) || - (this.method!=null && - java.util.Arrays.equals(this.method, other.getMethod()))) && - ((this.seqs==null && other.getSeqs()==null) || - (this.seqs!=null && - this.seqs.equals(other.getSeqs()))); - __equalsCalc = null; - return _equals; - } - - private boolean __hashCodeCalc = false; - public synchronized int hashCode() { - if (__hashCodeCalc) { - return 0; - } - __hashCodeCalc = true; - int _hashCode = super.hashCode(); - if (getGapchar() != null) { - _hashCode += getGapchar().hashCode(); - } - if (getMethod() != null) { - for (int i=0; - i