From: Jim Procter Date: Fri, 23 Jan 2015 08:59:19 +0000 (+0000) Subject: JAL-1628 drop getShowAnnotation accessor in favour of isShowAnnotation in AlignViewpo... X-Git-Tag: Jalview_2_9~108^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8d6b113f475c6b5916f7685cfd289e054d95a9ee;p=jalview.git JAL-1628 drop getShowAnnotation accessor in favour of isShowAnnotation in AlignViewportI and change method signature for printing annotation files to allow view (for column selection) and alignment object to be accessed --- diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 1c9d112..760f52d 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -231,4 +231,18 @@ public interface AlignViewportI void setShowSequenceFeatures(boolean b); + /** + * + * @param flag + * indicating if annotation panel shown below alignment + * + */ + void setShowAnnotation(boolean b); + + /** + * flag indicating if annotation panel shown below alignment + * + * @return + */ + boolean isShowAnnotation(); } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 9fb91ed..2a80e1e 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1200,11 +1200,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, public String outputAnnotations(boolean displayTextbox) { - String annotation = new AnnotationFile().printAnnotations( - viewport.showAnnotation ? viewport.getAlignment() - .getAlignmentAnnotation() : null, viewport - .getAlignment().getGroups(), ((Alignment) viewport - .getAlignment()).alignmentProperties); + String annotation = new AnnotationFile() + .printAnnotationsForView(viewport); if (displayTextbox) { diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 0206c46..b19e54f 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1305,11 +1305,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void exportAnnotations_actionPerformed(ActionEvent e) { - new AnnotationExporter().exportAnnotations(alignPanel, - viewport.isShowAnnotation() ? viewport.getAlignment() - .getAlignmentAnnotation() : null, viewport - .getAlignment().getGroups(), ((Alignment) viewport - .getAlignment()).alignmentProperties); + new AnnotationExporter().exportAnnotations(alignPanel); } @Override diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index b8f575f..4df9a62 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -138,7 +138,6 @@ public class AlignViewport extends AlignmentViewport implements Color textColour = Color.black; Color textColour2 = Color.white; - private boolean rightAlignIds = false; private AnnotationColumnChooser annotationColumnSelectionState; /** @@ -1235,22 +1234,6 @@ public class AlignViewport extends AlignmentViewport implements this.showAutocalculatedAbove = showAutocalculatedAbove; } - - public boolean isShowAnnotation() - { - return super.isShowAnnotation(); - } - - public boolean isRightAlignIds() - { - return rightAlignIds; - } - - public void setRightAlignIds(boolean rightAlignIds) - { - this.rightAlignIds = rightAlignIds; - } - public AnnotationColumnChooser getAnnotationColumnSelectionState() { return annotationColumnSelectionState; diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index e859fb1..6517e70 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -122,7 +122,7 @@ public class AlignmentPanel extends GAlignmentPanel implements setScrollValues(0, 0); - setAnnotationVisible(av.getShowAnnotation()); + setAnnotationVisible(av.isShowAnnotation()); hscroll.addAdjustmentListener(this); vscroll.addAdjustmentListener(this); @@ -729,7 +729,7 @@ public class AlignmentPanel extends GAlignmentPanel implements getSeqPanel().seqCanvas.fastPaint(scrollX, scrollY); getScalePanel().repaint(); - if (av.getShowAnnotation() && scrollX != 0) + if (av.isShowAnnotation() && scrollX != 0) { getAnnotationPanel().fastPaint(scrollX); } @@ -1249,7 +1249,7 @@ public class AlignmentPanel extends GAlignmentPanel implements } } - else if (av.getShowAnnotation()) + else if (av.isShowAnnotation()) { height += getAnnotationPanel().adjustPanelHeight() + 3; } diff --git a/src/jalview/gui/AnnotationExporter.java b/src/jalview/gui/AnnotationExporter.java index e43c06b..df6f9eb 100644 --- a/src/jalview/gui/AnnotationExporter.java +++ b/src/jalview/gui/AnnotationExporter.java @@ -21,7 +21,6 @@ package jalview.gui; import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.SequenceGroup; import jalview.io.AnnotationFile; import jalview.io.FeaturesFile; import jalview.io.JalviewFileChooser; @@ -33,8 +32,6 @@ import java.awt.Color; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Hashtable; -import java.util.List; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -62,11 +59,9 @@ public class AnnotationExporter extends JPanel boolean features = true; - AlignmentAnnotation[] annotations; + private AlignmentAnnotation[] annotations; - List sequenceGroups; - - Hashtable alignmentProperties; + private boolean wholeView; public AnnotationExporter() { @@ -93,17 +88,29 @@ public class AnnotationExporter extends JPanel frame.setTitle(MessageManager.getString("label.export_features")); } - public void exportAnnotations(AlignmentPanel ap, - AlignmentAnnotation[] annotations, List list, - Hashtable alProperties) + public void exportAnnotations(AlignmentPanel ap) { this.ap = ap; + annotations = ap.av.isShowAnnotation() ? null : ap.av.getAlignment() + .getAlignmentAnnotation(); + wholeView = true; + startExportAnnotation(); + } + + public void exportAnnotations(AlignmentPanel alp, + AlignmentAnnotation[] toExport) + { + ap = alp; + annotations = toExport; + wholeView = false; + startExportAnnotation(); + } + + private void startExportAnnotation() + { features = false; GFFFormat.setVisible(false); CSVFormat.setVisible(true); - this.annotations = annotations; - this.sequenceGroups = list; - this.alignmentProperties = alProperties; frame.setTitle(MessageManager.getString("label.export_annotations")); } @@ -121,36 +128,7 @@ public class AnnotationExporter extends JPanel if (value == JalviewFileChooser.APPROVE_OPTION) { - String text = MessageManager.getString("label.no_features_on_alignment"); - if (features) - { - if (GFFFormat.isSelected()) - { - text = new FeaturesFile().printGFFFormat(ap.av.getAlignment() - .getDataset().getSequencesArray(), ap - .getFeatureRenderer().getDisplayedFeatureCols(), true, - ap.av.isShowNpFeats());// ap.av.featuresDisplayed//); - } - else - { - text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment() - .getDataset().getSequencesArray(), ap - .getFeatureRenderer().getDisplayedFeatureCols(), true, - ap.av.isShowNpFeats()); // ap.av.featuresDisplayed); - } - } - else - { - if (CSVFormat.isSelected()) - { - text = new AnnotationFile().printCSVAnnotations(annotations); - } - else - { - text = new AnnotationFile().printAnnotations(annotations, - sequenceGroups, alignmentProperties); - } - } + String text = getFileContents(); try { @@ -168,25 +146,26 @@ public class AnnotationExporter extends JPanel close_actionPerformed(null); } - public void toTextbox_actionPerformed(ActionEvent e) + private String getFileContents() { - String text = MessageManager.getString("label.no_features_on_alignment"); + String text = MessageManager + .getString("label.no_features_on_alignment"); if (features) { if (GFFFormat.isSelected()) { text = new FeaturesFile().printGFFFormat(ap.av.getAlignment() .getDataset().getSequencesArray(), ap.getFeatureRenderer() - .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); + .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats());// ap.av.featuresDisplayed//); } else { text = new FeaturesFile().printJalviewFormat(ap.av.getAlignment() .getDataset().getSequencesArray(), ap.getFeatureRenderer() - .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); + .getDisplayedFeatureCols(), true, ap.av.isShowNpFeats()); // ap.av.featuresDisplayed); } } - else if (!features) + else { if (CSVFormat.isSelected()) { @@ -194,14 +173,26 @@ public class AnnotationExporter extends JPanel } else { - text = new AnnotationFile().printAnnotations(annotations, - sequenceGroups, alignmentProperties); + if (wholeView) + { + text = new AnnotationFile().printAnnotationsForView(ap.av); + } + else + { + text = new AnnotationFile().printAnnotations(annotations, null, + null); + } } } - + return text; + } + public void toTextbox_actionPerformed(ActionEvent e) + { CutAndPasteTransfer cap = new CutAndPasteTransfer(); + try { + String text = getFileContents(); cap.setText(text); Desktop.addInternalFrame( cap, @@ -309,5 +300,4 @@ public class AnnotationExporter extends JPanel JPanel jPanel3 = new JPanel(); FlowLayout flowLayout1 = new FlowLayout(); - } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index 501df8a..97499c9 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -249,7 +249,7 @@ public class AnnotationLabels extends JPanel implements MouseListener, { new AnnotationExporter().exportAnnotations(ap, new AlignmentAnnotation[] - { aa[selectedRow] }, null, null); + { aa[selectedRow] }); } else if (evt.getActionCommand().equals(COPYCONS_SEQ)) { diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 5d11901..c96b717 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1125,7 +1125,7 @@ public class Jalview2XML view.setFontSize(av.font.getSize()); view.setFontStyle(av.font.getStyle()); view.setRenderGaps(av.renderGaps); - view.setShowAnnotation(av.getShowAnnotation()); + view.setShowAnnotation(av.isShowAnnotation()); view.setShowBoxes(av.getShowBoxes()); view.setShowColourText(av.getColourText()); view.setShowFullId(av.getShowJVSuffix()); diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index c25d7af..6834e76 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -1691,4 +1691,18 @@ public class AnnotationFile } return sp.toString(); } + + public String printAnnotationsForView(AlignViewportI viewport) + { + return printAnnotations(viewport.isShowAnnotation() ? viewport + .getAlignment().getAlignmentAnnotation() : null, viewport + .getAlignment().getGroups(), viewport.getAlignment() + .getProperties()); + } + + public String printAnnotationsForAlignment(AlignmentI al) + { + return printAnnotations(al.getAlignmentAnnotation(), al.getGroups(), + al.getProperties()); + } } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 98b8d64..daea70d 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1751,37 +1751,26 @@ public abstract class AlignmentViewport implements AlignViewportI private boolean rightAlignIds = false; - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public boolean getShowAnnotation() - { - return isShowAnnotation(); - } - /** - * DOCUMENT ME! - * - * @param b - * DOCUMENT ME! - */ + @Override public void setShowAnnotation(boolean b) { showAnnotation = b; } + @Override public boolean isShowAnnotation() { return showAnnotation; } + @Override public boolean isRightAlignIds() { return rightAlignIds; } + @Override public void setRightAlignIds(boolean rightAlignIds) { this.rightAlignIds = rightAlignIds; diff --git a/src/jalview/ws/rest/params/AnnotationFile.java b/src/jalview/ws/rest/params/AnnotationFile.java index 0268c35..1820182 100644 --- a/src/jalview/ws/rest/params/AnnotationFile.java +++ b/src/jalview/ws/rest/params/AnnotationFile.java @@ -73,9 +73,8 @@ public class AnnotationFile extends InputType if (format.equals(JVANNOT)) { return new StringBody( - new jalview.io.AnnotationFile().printAnnotations( - al.getAlignmentAnnotation(), al.getGroups(), - al.getProperties())); + new jalview.io.AnnotationFile() + .printAnnotationsForAlignment(al)); } else { diff --git a/test/jalview/ws/jabaws/DisorderAnnotExportImport.java b/test/jalview/ws/jabaws/DisorderAnnotExportImport.java index db7d505..1e47800 100644 --- a/test/jalview/ws/jabaws/DisorderAnnotExportImport.java +++ b/test/jalview/ws/jabaws/DisorderAnnotExportImport.java @@ -20,11 +20,9 @@ */ package jalview.ws.jabaws; -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.List; - +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.io.AnnotationFile; @@ -34,6 +32,9 @@ import jalview.ws.jws2.AADisorderClient; import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.jabaws2.Jws2Instance; +import java.util.ArrayList; +import java.util.List; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -124,9 +125,8 @@ public class DisorderAnnotExportImport { String aligfileout = new FormatAdapter().formatSequences("PFAM", al.getSequencesArray()); - String anfileout = new AnnotationFile().printAnnotations( - al.getAlignmentAnnotation(), al.getGroups(), - al.getProperties()); + String anfileout = new AnnotationFile() + .printAnnotationsForAlignment(al); assertTrue( "Test " + testname diff --git a/test/jalview/ws/jabaws/JpredJabaStructExportImport.java b/test/jalview/ws/jabaws/JpredJabaStructExportImport.java index f0b8f99..1e920e0 100644 --- a/test/jalview/ws/jabaws/JpredJabaStructExportImport.java +++ b/test/jalview/ws/jabaws/JpredJabaStructExportImport.java @@ -186,9 +186,8 @@ public class JpredJabaStructExportImport String aligfileout = new FormatAdapter().formatSequences("PFAM", al.getSequencesArray()); - String anfileout = new AnnotationFile().printAnnotations( - al.getAlignmentAnnotation(), al.getGroups(), - al.getProperties()); + String anfileout = new AnnotationFile() + .printAnnotationsForAlignment(al); assertTrue( "Test " + testname diff --git a/test/jalview/ws/jabaws/RNAStructExportImport.java b/test/jalview/ws/jabaws/RNAStructExportImport.java index 9a723ca..cf86d18 100644 --- a/test/jalview/ws/jabaws/RNAStructExportImport.java +++ b/test/jalview/ws/jabaws/RNAStructExportImport.java @@ -137,9 +137,8 @@ public class RNAStructExportImport String aligfileout = new FormatAdapter().formatSequences("PFAM", al.getSequencesArray()); - String anfileout = new AnnotationFile().printAnnotations( - al.getAlignmentAnnotation(), al.getGroups(), - al.getProperties()); + String anfileout = new AnnotationFile() + .printAnnotationsForAlignment(al); assertTrue( "Test " + testname