From 6951479b7dc56bd022ce2c370b7f88b5571004fd Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 25 Apr 2007 11:47:48 +0000 Subject: [PATCH] AlignmentAnnotation: added annotation score attribute and allowed for annotation[] array to be null --- schemas/vamsas.xsd | 166 ++-- src/jalview/analysis/Dna.java | 32 +- src/jalview/appletgui/AnnotationLabels.java | 728 ++++++++--------- src/jalview/commands/EditCommand.java | 6 +- src/jalview/datamodel/AlignmentAnnotation.java | 48 +- src/jalview/gui/AnnotationLabels.java | 2 +- src/jalview/gui/Jalview2XML.java | 80 +- src/jalview/io/AnnotationFile.java | 2 +- src/jalview/schemabinding/version2/Annotation.java | 106 +++ .../version2/AnnotationDescriptor.java | 82 ++ .../schemabinding/version2/StructureState.java | 830 ++++++++++---------- .../version2/StructureStateDescriptor.java | 822 +++++++++---------- 12 files changed, 1582 insertions(+), 1322 deletions(-) diff --git a/schemas/vamsas.xsd b/schemas/vamsas.xsd index 4cc56b3..1a24509 100755 --- a/schemas/vamsas.xsd +++ b/schemas/vamsas.xsd @@ -1,82 +1,84 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index 836c39e..5096ae8 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -197,28 +197,36 @@ public class Dna { if (annotations[i].autoCalculated) { continue; } - - aSize = aslen; // aa alignment width. - jalview.datamodel.Annotation[] anots = - new jalview.datamodel.Annotation[aSize]; - for (a = 0; a < aSize; a++) + aSize = aslen; // aa alignment width. + jalview.datamodel.Annotation[] anots = + (annotations[i].annotations==null) + ? null : + new jalview.datamodel.Annotation[aSize]; + if (anots!=null) { - // process through codon map. - if (codons[a]!=null && codons[a][0]==(codons[a][2]-2)) + for (a = 0; a < aSize; a++) { - pos = codons[a][0]; - if (annotations[i].annotations[pos] == null - || annotations[i].annotations[pos] == null) - continue; + // process through codon map. + if (codons[a]!=null && codons[a][0]==(codons[a][2]-2)) + { + pos = codons[a][0]; + if (annotations[i].annotations[pos] == null + || annotations[i].annotations[pos] == null) + continue; - anots[a] = new Annotation(annotations[i].annotations[pos]); + anots[a] = new Annotation(annotations[i].annotations[pos]); + } } } jalview.datamodel.AlignmentAnnotation aa = new jalview.datamodel.AlignmentAnnotation(annotations[i].label, annotations[i].description, anots); + if (annotations[i].hasScore) + { + aa.setScore(annotations[i].getScore()); + } al.addAnnotation(aa); } } diff --git a/src/jalview/appletgui/AnnotationLabels.java b/src/jalview/appletgui/AnnotationLabels.java index a952f9d..1884a08 100755 --- a/src/jalview/appletgui/AnnotationLabels.java +++ b/src/jalview/appletgui/AnnotationLabels.java @@ -1,364 +1,364 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 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.*; - -public class AnnotationLabels - extends Panel implements ActionListener, MouseListener, MouseMotionListener -{ - Image image; - boolean active = false; - AlignmentPanel ap; - AlignViewport av; - boolean resizing = false; - int oldY, mouseX; - - static String ADDNEW = "Add New Row"; - static String EDITNAME = "Edit Label/Description"; - static String HIDE = "Hide This Row"; - static String SHOWALL = "Show All Hidden Rows"; - static String OUTPUT_TEXT = "Show Values In Textbox"; - static String COPYCONS_SEQ = "Copy Consensus Sequence"; - - int scrollOffset = 0; - int selectedRow = -1; - - Tooltip tooltip; - - public AnnotationLabels(AlignmentPanel ap) - { - this.ap = ap; - this.av = ap.av; - setLayout(null); - addMouseListener(this); - addMouseMotionListener(this); - } - - public AnnotationLabels(AlignViewport av) - { - this.av = av; - } - - public void setScrollOffset(int y) - { - scrollOffset = y; - repaint(); - } - - int getSelectedRow(int y) - { - int row = -1; - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - - if (aa == null) - { - return row; - } - - int height = 0; - for (int i = 0; i < aa.length; i++) - { - if (!aa[i].visible) - { - continue; - } - - height += aa[i].height; - if (y < height) - { - row = i; - break; - } - } - - return row; - } - - public void actionPerformed(ActionEvent evt) - { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - - if (evt.getActionCommand().equals(ADDNEW)) - { - AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", - null, - new Annotation[ap.av.alignment.getWidth()]); - - if (!editLabelDescription(newAnnotation)) - { - return; - } - - ap.av.alignment.addAnnotation(newAnnotation); - ap.av.alignment.setAnnotationIndex(newAnnotation, 0); - } - else if (evt.getActionCommand().equals(EDITNAME)) - { - editLabelDescription(aa[selectedRow]); - } - else if (evt.getActionCommand().equals(HIDE)) - { - aa[selectedRow].visible = false; - } - 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(false, ap.alignFrame); - Frame frame = new Frame(); - frame.add(cap); - jalview.bin.JalviewLite.addFrame(frame, - ap.alignFrame.getTitle() + " - " + - aa[selectedRow].label, 500, 100); - cap.setText(aa[selectedRow].toString()); - } - else if (evt.getActionCommand().equals(COPYCONS_SEQ)) - { - SequenceI cons = av.getConsensusSeq(); - if (cons != null) - { - copy_annotseqtoclipboard(cons); - } - - } - ap.annotationPanel.adjustPanelHeight(); - setSize(getSize().width, ap.annotationPanel.getSize().height); - ap.validate(); - ap.paintAlignment(true); - } - - boolean editLabelDescription(AlignmentAnnotation annotation) - { - EditNameDialog dialog = new EditNameDialog( - annotation.label, - annotation.description, - " Annotation Label", - "Annotation Description", - ap.alignFrame, - "Edit Annotation Name / Description", - 500, 100); - - if (dialog.accept) - { - annotation.label = dialog.getName(); - annotation.description = dialog.getDescription(); - repaint(); - return true; - } - else - return false; - - } - - public void mouseMoved(MouseEvent evt) - { - int row = getSelectedRow(evt.getY() - scrollOffset); - - if (row > -1) - { - if (tooltip == null) - { - tooltip = new Tooltip(ap.av.alignment. - getAlignmentAnnotation()[row]. - description, - this); - } - else - { - tooltip.setTip(ap.av.alignment. - getAlignmentAnnotation()[row].description); - } - } - else if (tooltip != null) - { - tooltip.setTip(""); - } - - } - - public void mouseDragged(MouseEvent evt) - {} - - public void mouseClicked(MouseEvent evt) - {} - - public void mouseReleased(MouseEvent evt) - {} - - public void mouseEntered(MouseEvent evt) - {} - - public void mouseExited(MouseEvent evt) - {} - - public void mousePressed(MouseEvent evt) - { - selectedRow = getSelectedRow(evt.getY() - scrollOffset); - - AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); - - PopupMenu popup = new PopupMenu("Annotations"); - - MenuItem item = new MenuItem(ADDNEW); - item.addActionListener(this); - popup.add(item); - item = new MenuItem(EDITNAME); - item.addActionListener(this); - popup.add(item); - item = new MenuItem(HIDE); - item.addActionListener(this); - popup.add(item); - item = new MenuItem(SHOWALL); - item.addActionListener(this); - popup.add(item); - this.add(popup); - item = new MenuItem(OUTPUT_TEXT); - item.addActionListener(this); - popup.add(item); - - if (aa[selectedRow] == ap.av.consensus) - { - popup.addSeparator(); - final CheckboxMenuItem cbmi = new CheckboxMenuItem( - "Ignore Gaps In Consensus", - ap.av.getIgnoreGapsConsensus()); - - cbmi.addItemListener(new ItemListener() - { - public void itemStateChanged(ItemEvent e) - { - ap.av.setIgnoreGapsConsensus(cbmi.getState()); - ap.paintAlignment(true); - } - }); - popup.add(cbmi); - item = new MenuItem(COPYCONS_SEQ); - item.addActionListener(this); - popup.add(item); - } - - popup.show(this, evt.getX(), evt.getY()); - - } - - /** - * DOCUMENT ME! - * - * @param e DOCUMENT ME! - */ - protected void copy_annotseqtoclipboard(SequenceI sq) - { - if (sq == null || sq.getLength() < 1) - { - return; - } - jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer(); - jalview.appletgui.AlignFrame.copiedSequences.append(sq.getName() + "\t" + - sq.getStart() + "\t" + - sq.getEnd() + "\t" + - sq.getSequenceAsString() + "\n"); - if (av.hasHiddenColumns) - { - jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector(); - for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) - { - int[] region = (int[]) - av.getColumnSelection().getHiddenColumns().elementAt(i); - - jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement(new int[] - {region[0], - region[1]}); - } - } - } - - public void update(Graphics g) - { - paint(g); - } - - public void paint(Graphics g) - { - int w = getSize().width; - if (image == null || w != image.getWidth(this)) - { - image = createImage(w, ap.annotationPanel.getSize().height); - } - - drawComponent(image.getGraphics(), w); - g.drawImage(image, 0, 0, this); - } - - public void drawComponent(Graphics g, int width) - { - g.setFont(av.getFont()); - FontMetrics fm = g.getFontMetrics(av.getFont()); - g.setColor(Color.white); - g.fillRect(0, 0, getSize().width, getSize().height); - - g.translate(0, scrollOffset); - g.setColor(Color.black); - - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int y = g.getFont().getSize(); - int x = 0; - - if (aa != null) - { - for (int i = 0; i < aa.length; i++) - { - if (!aa[i].visible) - { - continue; - } - - x = width - fm.stringWidth(aa[i].label) - 3; - - if (aa[i].graph > 0) - { - y += (aa[i].height / 3); - } - - g.drawString(aa[i].label, x, y); - - if (aa[i].graph > 0) - { - y += (2 * aa[i].height / 3); - } - else - { - y += aa[i].height; - } - } - } - } - -} +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2007 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.*; + +public class AnnotationLabels + extends Panel implements ActionListener, MouseListener, MouseMotionListener +{ + Image image; + boolean active = false; + AlignmentPanel ap; + AlignViewport av; + boolean resizing = false; + int oldY, mouseX; + + static String ADDNEW = "Add New Row"; + static String EDITNAME = "Edit Label/Description"; + static String HIDE = "Hide This Row"; + static String SHOWALL = "Show All Hidden Rows"; + static String OUTPUT_TEXT = "Show Values In Textbox"; + static String COPYCONS_SEQ = "Copy Consensus Sequence"; + + int scrollOffset = 0; + int selectedRow = -1; + + Tooltip tooltip; + + public AnnotationLabels(AlignmentPanel ap) + { + this.ap = ap; + this.av = ap.av; + setLayout(null); + addMouseListener(this); + addMouseMotionListener(this); + } + + public AnnotationLabels(AlignViewport av) + { + this.av = av; + } + + public void setScrollOffset(int y) + { + scrollOffset = y; + repaint(); + } + + int getSelectedRow(int y) + { + int row = -1; + AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); + + if (aa == null) + { + return row; + } + + int height = 0; + for (int i = 0; i < aa.length; i++) + { + if (!aa[i].visible) + { + continue; + } + + height += aa[i].height; + if (y < height) + { + row = i; + break; + } + } + + return row; + } + + public void actionPerformed(ActionEvent evt) + { + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + + if (evt.getActionCommand().equals(ADDNEW)) + { + AlignmentAnnotation newAnnotation = new AlignmentAnnotation("", + null, + new Annotation[ap.av.alignment.getWidth()]); + + if (!editLabelDescription(newAnnotation)) + { + return; + } + + ap.av.alignment.addAnnotation(newAnnotation); + ap.av.alignment.setAnnotationIndex(newAnnotation, 0); + } + else if (evt.getActionCommand().equals(EDITNAME)) + { + editLabelDescription(aa[selectedRow]); + } + else if (evt.getActionCommand().equals(HIDE)) + { + aa[selectedRow].visible = false; + } + else if (evt.getActionCommand().equals(SHOWALL)) + { + for (int i = 0; i < aa.length; i++) + { + aa[i].visible = (aa[i].annotations==null) ? false : true; + } + } + else if (evt.getActionCommand().equals(OUTPUT_TEXT)) + { + CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame); + Frame frame = new Frame(); + frame.add(cap); + jalview.bin.JalviewLite.addFrame(frame, + ap.alignFrame.getTitle() + " - " + + aa[selectedRow].label, 500, 100); + cap.setText(aa[selectedRow].toString()); + } + else if (evt.getActionCommand().equals(COPYCONS_SEQ)) + { + SequenceI cons = av.getConsensusSeq(); + if (cons != null) + { + copy_annotseqtoclipboard(cons); + } + + } + ap.annotationPanel.adjustPanelHeight(); + setSize(getSize().width, ap.annotationPanel.getSize().height); + ap.validate(); + ap.paintAlignment(true); + } + + boolean editLabelDescription(AlignmentAnnotation annotation) + { + EditNameDialog dialog = new EditNameDialog( + annotation.label, + annotation.description, + " Annotation Label", + "Annotation Description", + ap.alignFrame, + "Edit Annotation Name / Description", + 500, 100); + + if (dialog.accept) + { + annotation.label = dialog.getName(); + annotation.description = dialog.getDescription(); + repaint(); + return true; + } + else + return false; + + } + + public void mouseMoved(MouseEvent evt) + { + int row = getSelectedRow(evt.getY() - scrollOffset); + + if (row > -1) + { + if (tooltip == null) + { + tooltip = new Tooltip(ap.av.alignment. + getAlignmentAnnotation()[row]. + description, + this); + } + else + { + tooltip.setTip(ap.av.alignment. + getAlignmentAnnotation()[row].description); + } + } + else if (tooltip != null) + { + tooltip.setTip(""); + } + + } + + public void mouseDragged(MouseEvent evt) + {} + + public void mouseClicked(MouseEvent evt) + {} + + public void mouseReleased(MouseEvent evt) + {} + + public void mouseEntered(MouseEvent evt) + {} + + public void mouseExited(MouseEvent evt) + {} + + public void mousePressed(MouseEvent evt) + { + selectedRow = getSelectedRow(evt.getY() - scrollOffset); + + AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation(); + + PopupMenu popup = new PopupMenu("Annotations"); + + MenuItem item = new MenuItem(ADDNEW); + item.addActionListener(this); + popup.add(item); + item = new MenuItem(EDITNAME); + item.addActionListener(this); + popup.add(item); + item = new MenuItem(HIDE); + item.addActionListener(this); + popup.add(item); + item = new MenuItem(SHOWALL); + item.addActionListener(this); + popup.add(item); + this.add(popup); + item = new MenuItem(OUTPUT_TEXT); + item.addActionListener(this); + popup.add(item); + + if (aa[selectedRow] == ap.av.consensus) + { + popup.addSeparator(); + final CheckboxMenuItem cbmi = new CheckboxMenuItem( + "Ignore Gaps In Consensus", + ap.av.getIgnoreGapsConsensus()); + + cbmi.addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + ap.av.setIgnoreGapsConsensus(cbmi.getState()); + ap.paintAlignment(true); + } + }); + popup.add(cbmi); + item = new MenuItem(COPYCONS_SEQ); + item.addActionListener(this); + popup.add(item); + } + + popup.show(this, evt.getX(), evt.getY()); + + } + + /** + * DOCUMENT ME! + * + * @param e DOCUMENT ME! + */ + protected void copy_annotseqtoclipboard(SequenceI sq) + { + if (sq == null || sq.getLength() < 1) + { + return; + } + jalview.appletgui.AlignFrame.copiedSequences = new StringBuffer(); + jalview.appletgui.AlignFrame.copiedSequences.append(sq.getName() + "\t" + + sq.getStart() + "\t" + + sq.getEnd() + "\t" + + sq.getSequenceAsString() + "\n"); + if (av.hasHiddenColumns) + { + jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector(); + for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); i++) + { + int[] region = (int[]) + av.getColumnSelection().getHiddenColumns().elementAt(i); + + jalview.appletgui.AlignFrame.copiedHiddenColumns.addElement(new int[] + {region[0], + region[1]}); + } + } + } + + public void update(Graphics g) + { + paint(g); + } + + public void paint(Graphics g) + { + int w = getSize().width; + if (image == null || w != image.getWidth(this)) + { + image = createImage(w, ap.annotationPanel.getSize().height); + } + + drawComponent(image.getGraphics(), w); + g.drawImage(image, 0, 0, this); + } + + public void drawComponent(Graphics g, int width) + { + g.setFont(av.getFont()); + FontMetrics fm = g.getFontMetrics(av.getFont()); + g.setColor(Color.white); + g.fillRect(0, 0, getSize().width, getSize().height); + + g.translate(0, scrollOffset); + g.setColor(Color.black); + + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + int y = g.getFont().getSize(); + int x = 0; + + if (aa != null) + { + for (int i = 0; i < aa.length; i++) + { + if (!aa[i].visible) + { + continue; + } + + x = width - fm.stringWidth(aa[i].label) - 3; + + if (aa[i].graph > 0) + { + y += (aa[i].height / 3); + } + + g.drawString(aa[i].label, x, y); + + if (aa[i].graph > 0) + { + y += (2 * aa[i].height / 3); + } + else + { + y += aa[i].height; + } + } + } + } + +} diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 4cd5992..ce88127 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -472,7 +472,11 @@ public class EditCommand } int tSize = 0; - + if (annotations[a].annotations == null) + { + // nothing to edit here ? + continue; + } aSize = annotations[a].annotations.length; if (insert) { diff --git a/src/jalview/datamodel/AlignmentAnnotation.java b/src/jalview/datamodel/AlignmentAnnotation.java index 16f8fb8..3ad05ea 100755 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@ -54,8 +54,15 @@ public class AlignmentAnnotation /** DOCUMENT ME!! */ public float graphMax; + /** + * Score associated with label and description. + */ public float score; - + /** + * flag indicating if annotation has a score. + */ + public boolean hasScore=false; + public GraphLine threshold; // Graphical hints and tips @@ -216,6 +223,11 @@ public class AlignmentAnnotation * if appropriate. */ private void validateRangeAndDisplay() { + if (annotations==null) + { + visible=false; // try to prevent renderer from displaying. + return; // this is a non-annotation row annotation - ie a sequence score. + } int graphType = graph; float min = graphMin; float max = graphMax; @@ -459,7 +471,10 @@ public class AlignmentAnnotation { return; } - + if (annotations==null) + { + return; + } sequenceMapping = new java.util.Hashtable(); sequenceRef = seqRef; @@ -489,6 +504,11 @@ public class AlignmentAnnotation if (sequenceRef==null) return; + if (annotations==null) + { + return; + } + int a = 0, aSize = sequenceRef.getLength(); if (aSize == 0) @@ -580,4 +600,28 @@ public class AlignmentAnnotation sequenceRef = null; } } + + /** + * @return the score + */ + public float getScore() + { + return score; + } + + /** + * @param score the score to set + */ + public void setScore(float score) + { + this.score = score; + } + /** + * + * @return true if annotation has an associated score + */ + public boolean hasScore() + { + return hasScore; + } } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index e7e3970..ccbebd5 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -193,7 +193,7 @@ public class AnnotationLabels { for (int i = 0; i < aa.length; i++) { - if (!aa[i].visible) + if (!aa[i].visible && aa[i].annotations!=null) { dif += aa[i].height; aa[i].visible = true; diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index eda5eac..f0551e8 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -530,32 +530,40 @@ public class Jalview2XML } an.setLabel(aa[i].label); - + if (aa[i].hasScore()) + { + an.setScore(aa[i].getScore()); + } AnnotationElement ae; - - for (int a = 0; a < aa[i].annotations.length; a++) + if (aa[i].annotations!=null) { - if ( (aa[i] == null) || (aa[i].annotations[a] == null)) + an.setScoreOnly(false); + for (int a = 0; a < aa[i].annotations.length; a++) { - continue; - } + if ((aa[i] == null) || (aa[i].annotations[a] == null)) + { + continue; + } - ae = new AnnotationElement(); - ae.setDescription(aa[i].annotations[a].description); - ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter); - ae.setValue(aa[i].annotations[a].value); - ae.setPosition(a); - ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure + - ""); + ae = new AnnotationElement(); + ae.setDescription(aa[i].annotations[a].description); + ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter); + ae.setValue(aa[i].annotations[a].value); + ae.setPosition(a); + ae + .setSecondaryStructure(aa[i].annotations[a].secondaryStructure + + ""); - if (aa[i].annotations[a].colour != java.awt.Color.black) - { - ae.setColour(aa[i].annotations[a].colour.getRGB()); - } + if (aa[i].annotations[a].colour != java.awt.Color.black) + { + ae.setColour(aa[i].annotations[a].colour.getRGB()); + } - an.addAnnotationElement(ae); + an.addAnnotationElement(ae); + } + } else { + an.setScoreOnly(true); } - vamsasSet.addAnnotation(an); } } @@ -1310,21 +1318,24 @@ public class Jalview2XML } AnnotationElement[] ae = an[i].getAnnotationElement(); - jalview.datamodel.Annotation[] anot = new jalview.datamodel.Annotation[ - al.getWidth()]; + jalview.datamodel.Annotation[] anot = null; + if (!an[i].getScoreOnly()) + { + anot = new jalview.datamodel.Annotation[ + al.getWidth()]; - for (int aa = 0; aa < ae.length && aa < anot.length; aa++) - { - anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa]. - getDisplayCharacter(), - ae[aa].getDescription(), - ae[aa].getSecondaryStructure().length() == 0 ? ' ' : - ae[aa].getSecondaryStructure().charAt(0), - ae[aa].getValue()); - anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa]. - getColour()); + for (int aa = 0; aa < ae.length && aa < anot.length; aa++) + { + anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa]. + getDisplayCharacter(), + ae[aa].getDescription(), + ae[aa].getSecondaryStructure().length() == 0 ? ' ' : + ae[aa].getSecondaryStructure().charAt(0), + ae[aa].getValue()); + anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa]. + getColour()); + } } - jalview.datamodel.AlignmentAnnotation jaa = null; if (an[i].getGraph()) @@ -1365,7 +1376,10 @@ public class Jalview2XML ); al.findName(an[i].getSequenceRef()).addAlignmentAnnotation(jaa); } - + if (an[i].hasScore()) + { + jaa.setScore(an[i].getScore()); + } al.addAnnotation(jaa); } } diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index 12c128a..ef95458 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -54,7 +54,7 @@ public class AnnotationFile { row = annotations[i]; - if (!row.visible) + if (!row.visible && row.annotations!=null) { continue; } diff --git a/src/jalview/schemabinding/version2/Annotation.java b/src/jalview/schemabinding/version2/Annotation.java index 61f9413..9eb6907 100755 --- a/src/jalview/schemabinding/version2/Annotation.java +++ b/src/jalview/schemabinding/version2/Annotation.java @@ -86,6 +86,26 @@ public class Annotation implements java.io.Serializable { private java.lang.String _id; /** + * Field _scoreOnly + */ + private boolean _scoreOnly = false; + + /** + * keeps track of state for field: _scoreOnly + */ + private boolean _has_scoreOnly; + + /** + * Field _score + */ + private float _score; + + /** + * keeps track of state for field: _score + */ + private boolean _has_score; + + /** * Field _annotationElementList */ private java.util.Vector _annotationElementList; @@ -184,6 +204,24 @@ public class Annotation implements java.io.Serializable { } //-- void deleteGraphType() /** + * Method deleteScore + * + */ + public void deleteScore() + { + this._has_score= false; + } //-- void deleteScore() + + /** + * Method deleteScoreOnly + * + */ + public void deleteScoreOnly() + { + this._has_scoreOnly= false; + } //-- void deleteScoreOnly() + + /** * Method enumerateAnnotationElement * * @@ -321,6 +359,28 @@ public class Annotation implements java.io.Serializable { } //-- java.lang.String getLabel() /** + * Returns the value of field 'score'. + * + * @return float + * @return the value of field 'score'. + */ + public float getScore() + { + return this._score; + } //-- float getScore() + + /** + * Returns the value of field 'scoreOnly'. + * + * @return boolean + * @return the value of field 'scoreOnly'. + */ + public boolean getScoreOnly() + { + return this._scoreOnly; + } //-- boolean getScoreOnly() + + /** * Returns the value of field 'sequenceRef'. * * @return String @@ -391,6 +451,30 @@ public class Annotation implements java.io.Serializable { } //-- boolean hasGraphType() /** + * Method hasScore + * + * + * + * @return boolean + */ + public boolean hasScore() + { + return this._has_score; + } //-- boolean hasScore() + + /** + * Method hasScoreOnly + * + * + * + * @return boolean + */ + public boolean hasScoreOnly() + { + return this._has_scoreOnly; + } //-- boolean hasScoreOnly() + + /** * Method isValid * * @@ -569,6 +653,28 @@ public class Annotation implements java.io.Serializable { } //-- void setLabel(java.lang.String) /** + * Sets the value of field 'score'. + * + * @param score the value of field 'score'. + */ + public void setScore(float score) + { + this._score = score; + this._has_score = true; + } //-- void setScore(float) + + /** + * Sets the value of field 'scoreOnly'. + * + * @param scoreOnly the value of field 'scoreOnly'. + */ + public void setScoreOnly(boolean scoreOnly) + { + this._scoreOnly = scoreOnly; + this._has_scoreOnly = true; + } //-- void setScoreOnly(boolean) + + /** * Sets the value of field 'sequenceRef'. * * @param sequenceRef the value of field 'sequenceRef'. diff --git a/src/jalview/schemabinding/version2/AnnotationDescriptor.java b/src/jalview/schemabinding/version2/AnnotationDescriptor.java index 34047b3..e0061ae 100755 --- a/src/jalview/schemabinding/version2/AnnotationDescriptor.java +++ b/src/jalview/schemabinding/version2/AnnotationDescriptor.java @@ -301,6 +301,88 @@ public class AnnotationDescriptor extends org.exolab.castor.xml.util.XMLClassDes fieldValidator.setValidator(typeValidator); } desc.setValidator(fieldValidator); + //-- _scoreOnly + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_scoreOnly", "scoreOnly", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Annotation target = (Annotation) object; + if(!target.hasScoreOnly()) + return null; + return (target.getScoreOnly() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Annotation target = (Annotation) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteScoreOnly(); + return; + } + target.setScoreOnly( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _scoreOnly + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _score + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(float.class, "_score", "score", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + Annotation target = (Annotation) object; + if(!target.hasScore()) + return null; + return new java.lang.Float(target.getScore()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + Annotation target = (Annotation) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteScore(); + return; + } + target.setScore( ((java.lang.Float)value).floatValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _score + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + FloatValidator typeValidator = new FloatValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); //-- initialize element descriptors //-- _annotationElementList diff --git a/src/jalview/schemabinding/version2/StructureState.java b/src/jalview/schemabinding/version2/StructureState.java index be826fc..3e913cb 100644 --- a/src/jalview/schemabinding/version2/StructureState.java +++ b/src/jalview/schemabinding/version2/StructureState.java @@ -1,415 +1,415 @@ -/* - * This class was automatically generated with - * Castor 0.9.6, using an XML - * Schema. - * $Id$ - */ - -package jalview.schemabinding.version2; - - //---------------------------------/ - //- 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 StructureState. - * - * @version $Revision$ $Date$ - */ -public class StructureState implements java.io.Serializable { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * internal content storage - */ - private java.lang.String _content = ""; - - /** - * Field _visible - */ - private boolean _visible; - - /** - * keeps track of state for field: _visible - */ - private boolean _has_visible; - - /** - * Field _xpos - */ - private int _xpos; - - /** - * keeps track of state for field: _xpos - */ - private boolean _has_xpos; - - /** - * Field _ypos - */ - private int _ypos; - - /** - * keeps track of state for field: _ypos - */ - private boolean _has_ypos; - - /** - * Field _width - */ - private int _width; - - /** - * keeps track of state for field: _width - */ - private boolean _has_width; - - /** - * Field _height - */ - private int _height; - - /** - * keeps track of state for field: _height - */ - private boolean _has_height; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public StructureState() { - super(); - setContent(""); - } //-- jalview.schemabinding.version2.StructureState() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method deleteHeight - * - */ - public void deleteHeight() - { - this._has_height= false; - } //-- void deleteHeight() - - /** - * Method deleteVisible - * - */ - public void deleteVisible() - { - this._has_visible= false; - } //-- void deleteVisible() - - /** - * Method deleteWidth - * - */ - public void deleteWidth() - { - this._has_width= false; - } //-- void deleteWidth() - - /** - * Method deleteXpos - * - */ - public void deleteXpos() - { - this._has_xpos= false; - } //-- void deleteXpos() - - /** - * Method deleteYpos - * - */ - public void deleteYpos() - { - this._has_ypos= false; - } //-- void deleteYpos() - - /** - * Returns the value of field 'content'. The field 'content' - * has the following description: internal content storage - * - * @return String - * @return the value of field 'content'. - */ - public java.lang.String getContent() - { - return this._content; - } //-- java.lang.String getContent() - - /** - * Returns the value of field 'height'. - * - * @return int - * @return the value of field 'height'. - */ - public int getHeight() - { - return this._height; - } //-- int getHeight() - - /** - * Returns the value of field 'visible'. - * - * @return boolean - * @return the value of field 'visible'. - */ - public boolean getVisible() - { - return this._visible; - } //-- boolean getVisible() - - /** - * Returns the value of field 'width'. - * - * @return int - * @return the value of field 'width'. - */ - public int getWidth() - { - return this._width; - } //-- int getWidth() - - /** - * Returns the value of field 'xpos'. - * - * @return int - * @return the value of field 'xpos'. - */ - public int getXpos() - { - return this._xpos; - } //-- int getXpos() - - /** - * Returns the value of field 'ypos'. - * - * @return int - * @return the value of field 'ypos'. - */ - public int getYpos() - { - return this._ypos; - } //-- int getYpos() - - /** - * Method hasHeight - * - * - * - * @return boolean - */ - public boolean hasHeight() - { - return this._has_height; - } //-- boolean hasHeight() - - /** - * Method hasVisible - * - * - * - * @return boolean - */ - public boolean hasVisible() - { - return this._has_visible; - } //-- boolean hasVisible() - - /** - * Method hasWidth - * - * - * - * @return boolean - */ - public boolean hasWidth() - { - return this._has_width; - } //-- boolean hasWidth() - - /** - * Method hasXpos - * - * - * - * @return boolean - */ - public boolean hasXpos() - { - return this._has_xpos; - } //-- boolean hasXpos() - - /** - * Method hasYpos - * - * - * - * @return boolean - */ - public boolean hasYpos() - { - return this._has_ypos; - } //-- boolean hasYpos() - - /** - * Method isValid - * - * - * - * @return boolean - */ - public boolean isValid() - { - try { - validate(); - } - catch (org.exolab.castor.xml.ValidationException vex) { - return false; - } - return true; - } //-- boolean isValid() - - /** - * Method marshal - * - * - * - * @param out - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, out); - } //-- void marshal(java.io.Writer) - - /** - * Method marshal - * - * - * - * @param handler - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - - Marshaller.marshal(this, handler); - } //-- void marshal(org.xml.sax.ContentHandler) - - /** - * Sets the value of field 'content'. The field 'content' has - * the following description: internal content storage - * - * @param content the value of field 'content'. - */ - public void setContent(java.lang.String content) - { - this._content = content; - } //-- void setContent(java.lang.String) - - /** - * Sets the value of field 'height'. - * - * @param height the value of field 'height'. - */ - public void setHeight(int height) - { - this._height = height; - this._has_height = true; - } //-- void setHeight(int) - - /** - * Sets the value of field 'visible'. - * - * @param visible the value of field 'visible'. - */ - public void setVisible(boolean visible) - { - this._visible = visible; - this._has_visible = true; - } //-- void setVisible(boolean) - - /** - * Sets the value of field 'width'. - * - * @param width the value of field 'width'. - */ - public void setWidth(int width) - { - this._width = width; - this._has_width = true; - } //-- void setWidth(int) - - /** - * Sets the value of field 'xpos'. - * - * @param xpos the value of field 'xpos'. - */ - public void setXpos(int xpos) - { - this._xpos = xpos; - this._has_xpos = true; - } //-- void setXpos(int) - - /** - * Sets the value of field 'ypos'. - * - * @param ypos the value of field 'ypos'. - */ - public void setYpos(int ypos) - { - this._ypos = ypos; - this._has_ypos = true; - } //-- void setYpos(int) - - /** - * Method unmarshal - * - * - * - * @param reader - * @return Object - */ - public static java.lang.Object unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (jalview.schemabinding.version2.StructureState) Unmarshaller.unmarshal(jalview.schemabinding.version2.StructureState.class, reader); - } //-- java.lang.Object unmarshal(java.io.Reader) - - /** - * Method validate - * - */ - public void validate() - throws org.exolab.castor.xml.ValidationException - { - org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); - validator.validate(this); - } //-- void validate() - -} +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.schemabinding.version2; + + //---------------------------------/ + //- 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 StructureState. + * + * @version $Revision$ $Date$ + */ +public class StructureState implements java.io.Serializable { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * internal content storage + */ + private java.lang.String _content = ""; + + /** + * Field _visible + */ + private boolean _visible; + + /** + * keeps track of state for field: _visible + */ + private boolean _has_visible; + + /** + * Field _xpos + */ + private int _xpos; + + /** + * keeps track of state for field: _xpos + */ + private boolean _has_xpos; + + /** + * Field _ypos + */ + private int _ypos; + + /** + * keeps track of state for field: _ypos + */ + private boolean _has_ypos; + + /** + * Field _width + */ + private int _width; + + /** + * keeps track of state for field: _width + */ + private boolean _has_width; + + /** + * Field _height + */ + private int _height; + + /** + * keeps track of state for field: _height + */ + private boolean _has_height; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public StructureState() { + super(); + setContent(""); + } //-- jalview.schemabinding.version2.StructureState() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method deleteHeight + * + */ + public void deleteHeight() + { + this._has_height= false; + } //-- void deleteHeight() + + /** + * Method deleteVisible + * + */ + public void deleteVisible() + { + this._has_visible= false; + } //-- void deleteVisible() + + /** + * Method deleteWidth + * + */ + public void deleteWidth() + { + this._has_width= false; + } //-- void deleteWidth() + + /** + * Method deleteXpos + * + */ + public void deleteXpos() + { + this._has_xpos= false; + } //-- void deleteXpos() + + /** + * Method deleteYpos + * + */ + public void deleteYpos() + { + this._has_ypos= false; + } //-- void deleteYpos() + + /** + * Returns the value of field 'content'. The field 'content' + * has the following description: internal content storage + * + * @return String + * @return the value of field 'content'. + */ + public java.lang.String getContent() + { + return this._content; + } //-- java.lang.String getContent() + + /** + * Returns the value of field 'height'. + * + * @return int + * @return the value of field 'height'. + */ + public int getHeight() + { + return this._height; + } //-- int getHeight() + + /** + * Returns the value of field 'visible'. + * + * @return boolean + * @return the value of field 'visible'. + */ + public boolean getVisible() + { + return this._visible; + } //-- boolean getVisible() + + /** + * Returns the value of field 'width'. + * + * @return int + * @return the value of field 'width'. + */ + public int getWidth() + { + return this._width; + } //-- int getWidth() + + /** + * Returns the value of field 'xpos'. + * + * @return int + * @return the value of field 'xpos'. + */ + public int getXpos() + { + return this._xpos; + } //-- int getXpos() + + /** + * Returns the value of field 'ypos'. + * + * @return int + * @return the value of field 'ypos'. + */ + public int getYpos() + { + return this._ypos; + } //-- int getYpos() + + /** + * Method hasHeight + * + * + * + * @return boolean + */ + public boolean hasHeight() + { + return this._has_height; + } //-- boolean hasHeight() + + /** + * Method hasVisible + * + * + * + * @return boolean + */ + public boolean hasVisible() + { + return this._has_visible; + } //-- boolean hasVisible() + + /** + * Method hasWidth + * + * + * + * @return boolean + */ + public boolean hasWidth() + { + return this._has_width; + } //-- boolean hasWidth() + + /** + * Method hasXpos + * + * + * + * @return boolean + */ + public boolean hasXpos() + { + return this._has_xpos; + } //-- boolean hasXpos() + + /** + * Method hasYpos + * + * + * + * @return boolean + */ + public boolean hasYpos() + { + return this._has_ypos; + } //-- boolean hasYpos() + + /** + * Method isValid + * + * + * + * @return boolean + */ + public boolean isValid() + { + try { + validate(); + } + catch (org.exolab.castor.xml.ValidationException vex) { + return false; + } + return true; + } //-- boolean isValid() + + /** + * Method marshal + * + * + * + * @param out + */ + public void marshal(java.io.Writer out) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, out); + } //-- void marshal(java.io.Writer) + + /** + * Method marshal + * + * + * + * @param handler + */ + public void marshal(org.xml.sax.ContentHandler handler) + throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + + Marshaller.marshal(this, handler); + } //-- void marshal(org.xml.sax.ContentHandler) + + /** + * Sets the value of field 'content'. The field 'content' has + * the following description: internal content storage + * + * @param content the value of field 'content'. + */ + public void setContent(java.lang.String content) + { + this._content = content; + } //-- void setContent(java.lang.String) + + /** + * Sets the value of field 'height'. + * + * @param height the value of field 'height'. + */ + public void setHeight(int height) + { + this._height = height; + this._has_height = true; + } //-- void setHeight(int) + + /** + * Sets the value of field 'visible'. + * + * @param visible the value of field 'visible'. + */ + public void setVisible(boolean visible) + { + this._visible = visible; + this._has_visible = true; + } //-- void setVisible(boolean) + + /** + * Sets the value of field 'width'. + * + * @param width the value of field 'width'. + */ + public void setWidth(int width) + { + this._width = width; + this._has_width = true; + } //-- void setWidth(int) + + /** + * Sets the value of field 'xpos'. + * + * @param xpos the value of field 'xpos'. + */ + public void setXpos(int xpos) + { + this._xpos = xpos; + this._has_xpos = true; + } //-- void setXpos(int) + + /** + * Sets the value of field 'ypos'. + * + * @param ypos the value of field 'ypos'. + */ + public void setYpos(int ypos) + { + this._ypos = ypos; + this._has_ypos = true; + } //-- void setYpos(int) + + /** + * Method unmarshal + * + * + * + * @param reader + * @return Object + */ + public static java.lang.Object unmarshal(java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException + { + return (jalview.schemabinding.version2.StructureState) Unmarshaller.unmarshal(jalview.schemabinding.version2.StructureState.class, reader); + } //-- java.lang.Object unmarshal(java.io.Reader) + + /** + * Method validate + * + */ + public void validate() + throws org.exolab.castor.xml.ValidationException + { + org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator(); + validator.validate(this); + } //-- void validate() + +} diff --git a/src/jalview/schemabinding/version2/StructureStateDescriptor.java b/src/jalview/schemabinding/version2/StructureStateDescriptor.java index 998d373..e7a5a4d 100644 --- a/src/jalview/schemabinding/version2/StructureStateDescriptor.java +++ b/src/jalview/schemabinding/version2/StructureStateDescriptor.java @@ -1,411 +1,411 @@ -/* - * This class was automatically generated with - * Castor 0.9.6, using an XML - * Schema. - * $Id$ - */ - -package jalview.schemabinding.version2; - - //---------------------------------/ - //- Imported classes and packages -/ -//---------------------------------/ - -import org.exolab.castor.mapping.AccessMode; -import org.exolab.castor.xml.TypeValidator; -import org.exolab.castor.xml.XMLFieldDescriptor; -import org.exolab.castor.xml.validators.*; - -/** - * Class StructureStateDescriptor. - * - * @version $Revision$ $Date$ - */ -public class StructureStateDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { - - - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field nsPrefix - */ - private java.lang.String nsPrefix; - - /** - * Field nsURI - */ - private java.lang.String nsURI; - - /** - * Field xmlName - */ - private java.lang.String xmlName; - - /** - * Field identity - */ - private org.exolab.castor.xml.XMLFieldDescriptor identity; - - - //----------------/ - //- Constructors -/ - //----------------/ - - public StructureStateDescriptor() { - super(); - nsURI = "www.jalview.org"; - xmlName = "structureState"; - org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; - org.exolab.castor.xml.XMLFieldHandler handler = null; - org.exolab.castor.xml.FieldValidator fieldValidator = null; - //-- _content - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); - desc.setImmutable(true); - handler = (new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - StructureState target = (StructureState) object; - return target.getContent(); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - StructureState target = (StructureState) object; - target.setContent( (java.lang.String) value); - } - catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance( java.lang.Object parent ) { - return null; - } - } ); - desc.setHandler(handler); - addFieldDescriptor(desc); - - //-- validation code for: _content - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - StringValidator typeValidator = new StringValidator(); - typeValidator.setWhiteSpace("preserve"); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize attribute descriptors - - //-- _visible - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_visible", "visible", org.exolab.castor.xml.NodeType.Attribute); - handler = (new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - StructureState target = (StructureState) object; - if(!target.hasVisible()) - return null; - return (target.getVisible() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - StructureState target = (StructureState) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteVisible(); - return; - } - target.setVisible( ((java.lang.Boolean)value).booleanValue()); - } - catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance( java.lang.Object parent ) { - return null; - } - } ); - desc.setHandler(handler); - addFieldDescriptor(desc); - - //-- validation code for: _visible - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - BooleanValidator typeValidator = new BooleanValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _xpos - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_xpos", "xpos", org.exolab.castor.xml.NodeType.Attribute); - handler = (new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - StructureState target = (StructureState) object; - if(!target.hasXpos()) - return null; - return new java.lang.Integer(target.getXpos()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - StructureState target = (StructureState) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteXpos(); - return; - } - target.setXpos( ((java.lang.Integer)value).intValue()); - } - catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance( java.lang.Object parent ) { - return null; - } - } ); - desc.setHandler(handler); - addFieldDescriptor(desc); - - //-- validation code for: _xpos - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - IntegerValidator typeValidator= new IntegerValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _ypos - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_ypos", "ypos", org.exolab.castor.xml.NodeType.Attribute); - handler = (new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - StructureState target = (StructureState) object; - if(!target.hasYpos()) - return null; - return new java.lang.Integer(target.getYpos()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - StructureState target = (StructureState) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteYpos(); - return; - } - target.setYpos( ((java.lang.Integer)value).intValue()); - } - catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance( java.lang.Object parent ) { - return null; - } - } ); - desc.setHandler(handler); - addFieldDescriptor(desc); - - //-- validation code for: _ypos - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - IntegerValidator typeValidator= new IntegerValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _width - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_width", "width", org.exolab.castor.xml.NodeType.Attribute); - handler = (new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - StructureState target = (StructureState) object; - if(!target.hasWidth()) - return null; - return new java.lang.Integer(target.getWidth()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - StructureState target = (StructureState) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteWidth(); - return; - } - target.setWidth( ((java.lang.Integer)value).intValue()); - } - catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance( java.lang.Object parent ) { - return null; - } - } ); - desc.setHandler(handler); - addFieldDescriptor(desc); - - //-- validation code for: _width - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - IntegerValidator typeValidator= new IntegerValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- _height - desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_height", "height", org.exolab.castor.xml.NodeType.Attribute); - handler = (new org.exolab.castor.xml.XMLFieldHandler() { - public java.lang.Object getValue( java.lang.Object object ) - throws IllegalStateException - { - StructureState target = (StructureState) object; - if(!target.hasHeight()) - return null; - return new java.lang.Integer(target.getHeight()); - } - public void setValue( java.lang.Object object, java.lang.Object value) - throws IllegalStateException, IllegalArgumentException - { - try { - StructureState target = (StructureState) object; - // if null, use delete method for optional primitives - if (value == null) { - target.deleteHeight(); - return; - } - target.setHeight( ((java.lang.Integer)value).intValue()); - } - catch (java.lang.Exception ex) { - throw new IllegalStateException(ex.toString()); - } - } - public java.lang.Object newInstance( java.lang.Object parent ) { - return null; - } - } ); - desc.setHandler(handler); - addFieldDescriptor(desc); - - //-- validation code for: _height - fieldValidator = new org.exolab.castor.xml.FieldValidator(); - { //-- local scope - IntegerValidator typeValidator= new IntegerValidator(); - fieldValidator.setValidator(typeValidator); - } - desc.setValidator(fieldValidator); - //-- initialize element descriptors - - } //-- jalview.schemabinding.version2.StructureStateDescriptor() - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method getAccessMode - * - * - * - * @return AccessMode - */ - public org.exolab.castor.mapping.AccessMode getAccessMode() - { - return null; - } //-- org.exolab.castor.mapping.AccessMode getAccessMode() - - /** - * Method getExtends - * - * - * - * @return ClassDescriptor - */ - public org.exolab.castor.mapping.ClassDescriptor getExtends() - { - return null; - } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() - - /** - * Method getIdentity - * - * - * - * @return FieldDescriptor - */ - public org.exolab.castor.mapping.FieldDescriptor getIdentity() - { - return identity; - } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() - - /** - * Method getJavaClass - * - * - * - * @return Class - */ - public java.lang.Class getJavaClass() - { - return jalview.schemabinding.version2.StructureState.class; - } //-- java.lang.Class getJavaClass() - - /** - * Method getNameSpacePrefix - * - * - * - * @return String - */ - public java.lang.String getNameSpacePrefix() - { - return nsPrefix; - } //-- java.lang.String getNameSpacePrefix() - - /** - * Method getNameSpaceURI - * - * - * - * @return String - */ - public java.lang.String getNameSpaceURI() - { - return nsURI; - } //-- java.lang.String getNameSpaceURI() - - /** - * Method getValidator - * - * - * - * @return TypeValidator - */ - public org.exolab.castor.xml.TypeValidator getValidator() - { - return this; - } //-- org.exolab.castor.xml.TypeValidator getValidator() - - /** - * Method getXMLName - * - * - * - * @return String - */ - public java.lang.String getXMLName() - { - return xmlName; - } //-- java.lang.String getXMLName() - -} +/* + * This class was automatically generated with + * Castor 0.9.6, using an XML + * Schema. + * $Id$ + */ + +package jalview.schemabinding.version2; + + //---------------------------------/ + //- Imported classes and packages -/ +//---------------------------------/ + +import org.exolab.castor.mapping.AccessMode; +import org.exolab.castor.xml.TypeValidator; +import org.exolab.castor.xml.XMLFieldDescriptor; +import org.exolab.castor.xml.validators.*; + +/** + * Class StructureStateDescriptor. + * + * @version $Revision$ $Date$ + */ +public class StructureStateDescriptor extends org.exolab.castor.xml.util.XMLClassDescriptorImpl { + + + //--------------------------/ + //- Class/Member Variables -/ + //--------------------------/ + + /** + * Field nsPrefix + */ + private java.lang.String nsPrefix; + + /** + * Field nsURI + */ + private java.lang.String nsURI; + + /** + * Field xmlName + */ + private java.lang.String xmlName; + + /** + * Field identity + */ + private org.exolab.castor.xml.XMLFieldDescriptor identity; + + + //----------------/ + //- Constructors -/ + //----------------/ + + public StructureStateDescriptor() { + super(); + nsURI = "www.jalview.org"; + xmlName = "structureState"; + org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null; + org.exolab.castor.xml.XMLFieldHandler handler = null; + org.exolab.castor.xml.FieldValidator fieldValidator = null; + //-- _content + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_content", "PCDATA", org.exolab.castor.xml.NodeType.Text); + desc.setImmutable(true); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + return target.getContent(); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + target.setContent( (java.lang.String) value); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _content + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + StringValidator typeValidator = new StringValidator(); + typeValidator.setWhiteSpace("preserve"); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize attribute descriptors + + //-- _visible + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Boolean.TYPE, "_visible", "visible", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + if(!target.hasVisible()) + return null; + return (target.getVisible() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteVisible(); + return; + } + target.setVisible( ((java.lang.Boolean)value).booleanValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _visible + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + BooleanValidator typeValidator = new BooleanValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _xpos + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_xpos", "xpos", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + if(!target.hasXpos()) + return null; + return new java.lang.Integer(target.getXpos()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteXpos(); + return; + } + target.setXpos( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _xpos + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _ypos + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_ypos", "ypos", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + if(!target.hasYpos()) + return null; + return new java.lang.Integer(target.getYpos()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteYpos(); + return; + } + target.setYpos( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _ypos + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _width + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_width", "width", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + if(!target.hasWidth()) + return null; + return new java.lang.Integer(target.getWidth()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteWidth(); + return; + } + target.setWidth( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _width + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- _height + desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.Integer.TYPE, "_height", "height", org.exolab.castor.xml.NodeType.Attribute); + handler = (new org.exolab.castor.xml.XMLFieldHandler() { + public java.lang.Object getValue( java.lang.Object object ) + throws IllegalStateException + { + StructureState target = (StructureState) object; + if(!target.hasHeight()) + return null; + return new java.lang.Integer(target.getHeight()); + } + public void setValue( java.lang.Object object, java.lang.Object value) + throws IllegalStateException, IllegalArgumentException + { + try { + StructureState target = (StructureState) object; + // if null, use delete method for optional primitives + if (value == null) { + target.deleteHeight(); + return; + } + target.setHeight( ((java.lang.Integer)value).intValue()); + } + catch (java.lang.Exception ex) { + throw new IllegalStateException(ex.toString()); + } + } + public java.lang.Object newInstance( java.lang.Object parent ) { + return null; + } + } ); + desc.setHandler(handler); + addFieldDescriptor(desc); + + //-- validation code for: _height + fieldValidator = new org.exolab.castor.xml.FieldValidator(); + { //-- local scope + IntegerValidator typeValidator= new IntegerValidator(); + fieldValidator.setValidator(typeValidator); + } + desc.setValidator(fieldValidator); + //-- initialize element descriptors + + } //-- jalview.schemabinding.version2.StructureStateDescriptor() + + + //-----------/ + //- Methods -/ + //-----------/ + + /** + * Method getAccessMode + * + * + * + * @return AccessMode + */ + public org.exolab.castor.mapping.AccessMode getAccessMode() + { + return null; + } //-- org.exolab.castor.mapping.AccessMode getAccessMode() + + /** + * Method getExtends + * + * + * + * @return ClassDescriptor + */ + public org.exolab.castor.mapping.ClassDescriptor getExtends() + { + return null; + } //-- org.exolab.castor.mapping.ClassDescriptor getExtends() + + /** + * Method getIdentity + * + * + * + * @return FieldDescriptor + */ + public org.exolab.castor.mapping.FieldDescriptor getIdentity() + { + return identity; + } //-- org.exolab.castor.mapping.FieldDescriptor getIdentity() + + /** + * Method getJavaClass + * + * + * + * @return Class + */ + public java.lang.Class getJavaClass() + { + return jalview.schemabinding.version2.StructureState.class; + } //-- java.lang.Class getJavaClass() + + /** + * Method getNameSpacePrefix + * + * + * + * @return String + */ + public java.lang.String getNameSpacePrefix() + { + return nsPrefix; + } //-- java.lang.String getNameSpacePrefix() + + /** + * Method getNameSpaceURI + * + * + * + * @return String + */ + public java.lang.String getNameSpaceURI() + { + return nsURI; + } //-- java.lang.String getNameSpaceURI() + + /** + * Method getValidator + * + * + * + * @return TypeValidator + */ + public org.exolab.castor.xml.TypeValidator getValidator() + { + return this; + } //-- org.exolab.castor.xml.TypeValidator getValidator() + + /** + * Method getXMLName + * + * + * + * @return String + */ + public java.lang.String getXMLName() + { + return xmlName; + } //-- java.lang.String getXMLName() + +} -- 1.7.10.2