From ecdc53f0d45b7533878cef236fff851ea64ef9a9 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 10 Jun 2015 15:19:01 +0100 Subject: [PATCH] JAL-1641 updated applet version --- src/jalview/api/AlignViewportI.java | 12 ++++++---- src/jalview/appletgui/AlignFrame.java | 11 +++++---- src/jalview/appletgui/AlignViewport.java | 16 +++++++++++-- src/jalview/appletgui/CutAndPasteTransfer.java | 24 ++++++++++++++++---- src/jalview/gui/AlignFrame.java | 6 +++++ src/jalview/gui/AlignViewport.java | 11 +++++++++ src/jalview/io/JSONFile.java | 29 ++++++++++++++++-------- src/jalview/viewmodel/AlignmentViewport.java | 5 ++++ 8 files changed, 90 insertions(+), 24 deletions(-) diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index b4d2592..34ee209 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -20,6 +20,11 @@ */ package jalview.api; +import java.awt.Color; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + import jalview.analysis.Conservation; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -31,11 +36,6 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.schemes.ColourSchemeI; -import java.awt.Color; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - /** * @author jimp * @@ -377,4 +377,6 @@ public interface AlignViewportI extends ViewStyleI public void setFeatureRenderer(FeatureRenderer featureRenderer); + public boolean isIncludeHiddenRegion(); + } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index ee64dda..1b1a5b8 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1313,7 +1313,11 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage( "label.alignment_output_command", new Object[] { e.getActionCommand() }), 600, 500); - cap.setText(new AppletFormatAdapter().formatSequences( + + FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer(); + viewport.setFeatureRenderer(fr); + viewport.setIncludeHiddenRegion(false); + cap.setText(new AppletFormatAdapter(viewport).formatSequences( e.getActionCommand(), viewport.getAlignment(), viewport.getShowJVSuffix())); } @@ -4182,9 +4186,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, @Override public void setShowSeqFeatures(boolean b) { - // showSeqFeatures.setSelected(b); - // viewport.setShowSequenceFeatures(b); - + this.sequenceFeatures.setState(b); + viewport.setShowSequenceFeatures(b); } @Override diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index ef17215..607dc05 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -20,6 +20,8 @@ */ package jalview.appletgui; +import java.awt.Font; + import jalview.analysis.NJTree; import jalview.api.AlignViewportI; import jalview.api.FeatureRenderer; @@ -39,8 +41,6 @@ import jalview.structure.StructureSelectionManager; import jalview.structure.VamsasSource; import jalview.viewmodel.AlignmentViewport; -import java.awt.Font; - public class AlignViewport extends AlignmentViewport implements SelectionSource, VamsasSource, CommandListener { @@ -60,6 +60,8 @@ public class AlignViewport extends AlignmentViewport implements private FeatureRenderer featureRenderer; + private boolean includeHiddenRegion = true; + public void finalize() { applet = null; @@ -483,4 +485,14 @@ public class AlignViewport extends AlignmentViewport implements } + public boolean isIncludeHiddenRegion() + { + return includeHiddenRegion; + } + + public void setIncludeHiddenRegion(boolean includeHiddenRegion) + { + this.includeHiddenRegion = includeHiddenRegion; + } + } diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index d33e0cc..5b699a6 100644 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -41,7 +41,10 @@ import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.io.AnnotationFile; import jalview.io.AppletFormatAdapter; +import jalview.io.FileParse; +import jalview.io.HtmlFile; import jalview.io.IdentifyFile; +import jalview.io.JSONFile; import jalview.io.NewickFile; import jalview.io.TCoffeeScoreFile; import jalview.schemes.TCoffeeColourScheme; @@ -60,6 +63,8 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, AlignFrame alignFrame; + FileParse source = null; + public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame) { try @@ -163,7 +168,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, } else if (alignFrame != null) { - loadAlignment(text, newWindow); + loadAlignment(text, newWindow, alignFrame.getAlignViewport()); } // TODO: dialog should indicate if data was parsed correctly or not - see @@ -212,16 +217,18 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, * @param text * @param newWindow */ - protected void loadAlignment(String text, boolean newWindow) + protected void loadAlignment(String text, boolean newWindow, + AlignViewport viewport) { Alignment al = null; String format = new IdentifyFile().Identify(text, AppletFormatAdapter.PASTE); + AppletFormatAdapter afa = new AppletFormatAdapter(viewport); try { - al = new AppletFormatAdapter().readFile(text, - AppletFormatAdapter.PASTE, format); + al = afa.readFile(text, AppletFormatAdapter.PASTE, format); + source = afa.getAlignFile(); } catch (java.io.IOException ex) { ex.printStackTrace(); @@ -247,6 +254,15 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, af.statusBar .setText(MessageManager .getString("label.successfully_pasted_annotation_to_alignment")); + + if (source instanceof HtmlFile) + { + ((HtmlFile) source).applySettingsToAlignmentView(af); + } + else if (source instanceof JSONFile) + { + ((JSONFile) source).applySettingsToAlignmentView(af); + } } else { diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 6481855..b646d5b 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1250,11 +1250,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, alignmentToExport = viewport.getAlignment(); alignmentStartEnd = getStartEnd(alignmentStartEnd, viewport .getColumnSelection().getHiddenColumns()); + viewport.setIncludeHiddenRegion(false); } else { // export all region including visible alignmentToExport = hiddenSeqs.getFullAlignment(); + viewport.setIncludeHiddenRegion(true); } } @@ -6126,13 +6128,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { AlignmentI al = viewport.getAlignment(); HiddenSequences hiddenSeqs = al.getHiddenSequences(); + boolean hasHiddenRows = false; for (SequenceI seq : al.getSequencesArray()) { if (seq.isHidden()) { hiddenSeqs.hideSequence(seq); + hasHiddenRows = true; } } + viewport.setHasHiddenRows(hasHiddenRows); + firePropertyChange("alignment", null, al.getSequences()); } } diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index 8ecf19d..2224021 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -99,6 +99,7 @@ public class AlignViewport extends AlignmentViewport implements private FeatureRenderer featureRenderer; + private boolean includeHiddenRegion = true; String viewName; /* @@ -1051,4 +1052,14 @@ public class AlignViewport extends AlignmentViewport implements { this.featureRenderer = featureRenderer; } + + public boolean isIncludeHiddenRegion() + { + return includeHiddenRegion; + } + + public void setIncludeHiddenRegion(boolean includeHiddenRegion) + { + this.includeHiddenRegion = includeHiddenRegion; + } } diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index dca59a3..8882f97 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -164,12 +164,18 @@ public class JSONFile extends AlignFile String.valueOf(showSeqFeatures)); String[] hiddenSections = exportHiddenSections(); - if (hiddenSections != null) + if (hiddenSections != null && getViewport().isIncludeHiddenRegion()) { - jsonAlignmentPojo.getAppSettings().put("hiddenCols", - String.valueOf(hiddenSections[0])); - jsonAlignmentPojo.getAppSettings().put("hiddenSeqs", - String.valueOf(hiddenSections[1])); + if (hiddenSections[0] != null) + { + jsonAlignmentPojo.getAppSettings().put("hiddenCols", + String.valueOf(hiddenSections[0])); + } + if (hiddenSections[1] != null) + { + jsonAlignmentPojo.getAppSettings().put("hiddenSeqs", + String.valueOf(hiddenSections[1])); + } } } @@ -250,13 +256,14 @@ public class JSONFile extends AlignFile // hidden rows/seqs business HiddenSequences hiddenSeqsObj = getViewport().getAlignment() .getHiddenSequences(); - if (hiddenSeqsObj == null) + if (hiddenSeqsObj == null || hiddenSeqsObj.hiddenSequences == null) { return hiddenSections; } SequenceI[] hiddenSeqs = hiddenSeqsObj.hiddenSequences; System.out.print("Hidden Seqs : "); + // if(hiddenSeqs != null){ StringBuilder hiddenSeqsBuilder = new StringBuilder(); for (SequenceI hiddenSeq : hiddenSeqs) { @@ -266,11 +273,13 @@ public class JSONFile extends AlignFile } } if (hiddenSeqsBuilder.length() > 0) - { + { hiddenSeqsBuilder.deleteCharAt(0); - } + } hiddenSections[1] = hiddenSeqsBuilder.toString(); System.out.println(hiddenSections[1]); + // } + return hiddenSections; } @@ -286,6 +295,8 @@ public class JSONFile extends AlignFile SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null : seq.getDatasetSequence().getSequenceFeatures(); + seqFeatures = (seqFeatures == null) ? seq.getSequenceFeatures() + : seqFeatures; if (seqFeatures == null) { continue; @@ -395,7 +406,7 @@ public class JSONFile extends AlignFile int end = Integer.valueOf(sequence.get("end").toString()); Sequence seq = new Sequence(sequenceName, sequcenceString, start, end); - if (hiddenSeqRefs.contains(seqUniqueId)) + if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId)) { seq.setHidden(true); } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 302b0ef..399347b 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1063,6 +1063,11 @@ public abstract class AlignmentViewport implements AlignViewportI, return hasHiddenRows; } + public void setHasHiddenRows(boolean hasHiddenRows) + { + this.hasHiddenRows = hasHiddenRows; + } + protected SequenceGroup selectionGroup; public void setSequenceSetId(String newid) -- 1.7.10.2