*/
package jalview.api;
-import java.util.List;
-
import jalview.commands.CommandI;
-import jalview.schemes.ColourSchemeI;
/**
* Interface implemented by gui implementations managing a Jalview Alignment
void addHistoryItem(CommandI command);
- void setShowSeqFeatures(boolean show);
-
- void setMenusForViewport();
-
- void changeColour(ColourSchemeI cs);
-
- void hideColumns(List<int[]> colsToHide);
-
- void syncHiddenSequences();
}
--- /dev/null
+package jalview.api;
+
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
+import jalview.schemes.ColourSchemeI;
+
+public interface ComplexAlignFile
+{
+ public boolean isShowSeqFeatures();
+
+ public ColourSchemeI getColourScheme();
+
+ public ColumnSelection getColumnSelection();
+
+ public SequenceI[] getHiddenSequences();
+
+}
public AlignFrame(AlignmentI al, JalviewLite applet,
String title, boolean embedded, boolean addToDisplay)
{
+ this(al, null, null, applet, title, embedded, addToDisplay);
+ }
+
+ public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+ ColumnSelection columnSelection, JalviewLite applet,
+ String title, boolean embedded)
+ {
+ this(al, hiddenSeqs, columnSelection, applet, title, embedded, true);
+ }
+
+ public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+ ColumnSelection columnSelection, JalviewLite applet,
+ String title, boolean embedded, boolean addToDisplay)
+ {
if (applet != null)
{
jalviewServletURL = applet.getParameter("APPLICATION_URL");
}
}
viewport = new AlignViewport(al, applet);
+
+ if (hiddenSeqs != null && hiddenSeqs.length > 0)
+ {
+ viewport.hideSequence(hiddenSeqs);
+ viewport.setHasHiddenRows(true);
+ }
+ if (columnSelection != null)
+ {
+ viewport.setColumnSelection(columnSelection);
+ }
+
alignPanel = new AlignmentPanel(this, viewport);
avc = new jalview.controller.AlignViewController(this, viewport,
alignPanel);
{
this.splitFrame = sf;
}
-
- @Override
- public void setShowSeqFeatures(boolean b)
- {
- this.sequenceFeatures.setState(b);
- viewport.setShowSequenceFeatures(b);
- }
-
- @Override
- public void setMenusForViewport()
- {
- // setMenusFromViewport(viewport);
-
- }
-
- @Override
- public void hideColumns(List<int[]> colsToHide)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void syncHiddenSequences()
- {
- // TODO Auto-generated method stub
-
- }
}
import java.awt.event.MouseListener;
import jalview.analysis.AlignmentUtils;
+import jalview.api.ComplexAlignFile;
import jalview.bin.JalviewLite;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
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.ColourSchemeI;
import jalview.schemes.TCoffeeColourScheme;
import jalview.util.MessageManager;
}
if (newWindow)
{
- AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet,
- "Cut & Paste input - " + format, false);
- af.statusBar
- .setText(MessageManager
- .getString("label.successfully_pasted_annotation_to_alignment"));
+ AlignFrame af;
- if (source instanceof HtmlFile)
+ if (source instanceof ComplexAlignFile)
{
- ((HtmlFile) source).applySettingsToAlignmentView(af);
+ ColumnSelection colSel = ((ComplexAlignFile) source)
+ .getColumnSelection();
+ SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+ .getHiddenSequences();
+ boolean showSeqFeatures = ((ComplexAlignFile) source)
+ .isShowSeqFeatures();
+ ColourSchemeI cs = ((ComplexAlignFile) source).getColourScheme();
+ af = new AlignFrame(al, hiddenSeqs, colSel,
+ alignFrame.viewport.applet, "Cut & Paste input - "
+ + format, false);
+ af.getAlignViewport().setShowSequenceFeatures(showSeqFeatures);
+ af.changeColour(cs);
}
- else if (source instanceof JSONFile)
+ else
{
- ((JSONFile) source).applySettingsToAlignmentView(af);
+ af = new AlignFrame(al, alignFrame.viewport.applet,
+ "Cut & Paste input - " + format, false);
}
+
+ af.statusBar
+ .setText(MessageManager
+ .getString("label.successfully_pasted_annotation_to_alignment"));
}
else
{
RNA rna;
- private boolean hidden;
/**
* This annotation is displayed below the alignment but the positions are tied
return result;
}
- @Override
- public boolean isHidden()
- {
- return this.hidden;
- }
-
- @Override
- public void setHidden(Boolean hidden)
- {
- this.hidden = hidden;
- }
}
*/
public List<int[]> getInsertions();
- /**
- *
- * @return returns true if the sequence is hidden
- */
- public boolean isHidden();
-
- /**
- *
- * @param hidden
- * visibility status of the sequence
- */
- public void setHidden(Boolean hidden);
-
}
this(al, hiddenColumns, width, height, null);
}
+
/**
* Create alignment frame for al with hiddenColumns, a specific width and
* height, and specific sequenceId
init();
}
+ public AlignFrame(AlignmentI al, SequenceI[] hiddenSeqs,
+ ColumnSelection hiddenColumns, int width, int height)
+ {
+ setSize(width, height);
+
+ if (al.getDataset() == null)
+ {
+ al.setDataset(null);
+ }
+
+ viewport = new AlignViewport(al, hiddenColumns);
+
+ if (hiddenSeqs != null && hiddenSeqs.length > 0)
+ {
+ viewport.hideSequence(hiddenSeqs);
+ viewport.setHasHiddenRows(true);
+ }
+ alignPanel = new AlignmentPanel(this, viewport);
+ addAlignmentPanel(alignPanel, true);
+ init();
+ }
+
+
/**
* Make a new AlignFrame from existing alignmentPanels
*
}
}
- @Override
- public void hideColumns(List<int[]> colsToHide)
- {
- for (int[] colRange : colsToHide)
- {
- viewport.hideColumns(colRange[0], colRange[1]);
- }
-
- }
-
- @Override
- public void syncHiddenSequences()
- {
- 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());
- }
}
class PrintThread extends Thread
*/
package jalview.gui;
-import jalview.datamodel.Alignment;
-import jalview.io.FileParse;
-import jalview.io.FormatAdapter;
-import jalview.io.HtmlFile;
-import jalview.io.IdentifyFile;
-import jalview.io.JSONFile;
-import jalview.io.JalviewFileChooser;
-import jalview.io.JalviewFileView;
-import jalview.jbgui.GCutAndPasteTransfer;
-import jalview.util.MessageManager;
-
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
+import jalview.api.ComplexAlignFile;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
+import jalview.io.FileParse;
+import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GCutAndPasteTransfer;
+import jalview.schemes.ColourSchemeI;
+import jalview.util.MessageManager;
+
/**
* Cut'n'paste files into the desktop See JAL-1105
*
}
else
{
- AlignFrame af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
- af.currentFileFormat = format;
- Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
- af.statusBar.setText(MessageManager
- .getString("label.successfully_pasted_alignment_file"));
- if (source instanceof HtmlFile)
+ AlignFrame af;
+ if (source instanceof ComplexAlignFile)
{
- ((HtmlFile) source).applySettingsToAlignmentView(af);
+ ColumnSelection colSel = ((ComplexAlignFile) source)
+ .getColumnSelection();
+ SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+ .getHiddenSequences();
+ boolean showSeqFeatures = ((ComplexAlignFile) source)
+ .isShowSeqFeatures();
+ ColourSchemeI cs = ((ComplexAlignFile) source).getColourScheme();
+ af = new AlignFrame(al, hiddenSeqs, colSel,
+ AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+
+ af.getViewport().setShowSequenceFeatures(showSeqFeatures);
+ af.changeColour(cs);
+ // ((HtmlFile) source).applySettingsToAlignmentView(af);
}
- else if (source instanceof JSONFile)
+ // else if (source instanceof JSONFile)
+ // {
+ // ColumnSelection colSel = ((JSONFile) source).getColumnSelection();
+ // SequenceI[] hiddenSeqs = ((JSONFile) source).getHiddenSequences();
+ // boolean showSeqFeatures = ((HtmlFile) source).isShowSeqFeatures();
+ // ColourSchemeI cs = ((HtmlFile) source).getColourScheme();
+ // af = new AlignFrame(al, hiddenSeqs, colSel,
+ // AlignFrame.DEFAULT_WIDTH,
+ // AlignFrame.DEFAULT_HEIGHT);
+ // af.getViewport().setShowSequenceFeatures(showSeqFeatures);
+ // af.changeColour(cs);
+ // // ((JSONFile) source).applySettingsToAlignmentView(af);
+ // }
+ else
{
- ((JSONFile) source).applySettingsToAlignmentView(af);
+ af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
}
+ af.currentFileFormat = format;
+ Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+ af.statusBar.setText(MessageManager
+ .getString("label.successfully_pasted_alignment_file"));
try
{
else if (format.equals(JSONFile.FILE_DESC))
{
alignFile = new JSONFile(source);
- // ((JSONFile) afile).setViewport(viewport);
al = new Alignment(alignFile.getSeqsAsArray());
alignFile.addAnnotations(al);
alignFile.addSeqGroups(al);
*/
package jalview.io;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import jalview.api.ComplexAlignFile;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
import jalview.gui.Desktop;
import jalview.gui.Jalview2XML;
+import jalview.schemes.ColourSchemeI;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
public class FileLoader implements Runnable
{
String file;
}
else
{
- alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
-
- alignFrame.statusBar.setText(MessageManager.formatMessage(
- "label.successfully_loaded_file", new String[]
- { title }));
-
if (!protocol.equals(AppletFormatAdapter.PASTE))
{
alignFrame.setFileName(file, format);
}
- if (source instanceof HtmlFile)
+ if (source instanceof ComplexAlignFile)
{
- ((HtmlFile) source).applySettingsToAlignmentView(alignFrame);
+ ColumnSelection colSel = ((ComplexAlignFile) source)
+ .getColumnSelection();
+ SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
+ .getHiddenSequences();
+ boolean showSeqFeatures = ((ComplexAlignFile) source)
+ .isShowSeqFeatures();
+ ColourSchemeI cs = ((ComplexAlignFile) source)
+ .getColourScheme();
+ alignFrame = new AlignFrame(al, hiddenSeqs, colSel,
+ AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
+
+ alignFrame.getViewport().setShowSequenceFeatures(
+ showSeqFeatures);
+ alignFrame.changeColour(cs);
}
- else if (source instanceof JSONFile)
+ else
{
- ((JSONFile) source).applySettingsToAlignmentView(alignFrame);
+ alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH,
+ AlignFrame.DEFAULT_HEIGHT);
}
+ alignFrame.statusBar.setText(MessageManager.formatMessage(
+ "label.successfully_loaded_file", new String[]
+ { title }));
+
if (raiseGUI)
{
// add the window to the GUI
package jalview.io;
import java.io.IOException;
-import java.util.List;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
-import jalview.api.AlignViewControllerGuiI;
+import jalview.api.ComplexAlignFile;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SequenceI;
import jalview.schemes.ColourSchemeI;
-public class HtmlFile extends AlignFile
+public class HtmlFile extends AlignFile implements ComplexAlignFile
{
public static final String FILE_EXT = "html";
private boolean showSeqFeatures;
- private List<int[]> hiddenColumns;
+ private ColumnSelection columnSelection;
+
+ private SequenceI[] hiddenSequences;
public HtmlFile()
{
this.annotations = jsonFile.getAnnotations();
this.showSeqFeatures = jsonFile.isShowSeqFeatures();
this.colourScheme = jsonFile.getColourScheme();
- this.hiddenColumns = jsonFile.getHiddenColumns();
+ this.hiddenSequences = jsonFile.getHiddenSequences();
+ this.columnSelection = jsonFile.getColumnSelection();
} catch (Exception e)
{
e.printStackTrace();
}
}
- public void applySettingsToAlignmentView(AlignViewControllerGuiI avc)
- {
- avc.setShowSeqFeatures(isShowSeqFeatures());
- avc.changeColour(getColourScheme());
- avc.setMenusForViewport();
- avc.hideColumns(hiddenColumns);
- avc.syncHiddenSequences();
- }
@Override
public String print()
this.colourScheme = colourScheme;
}
+ public ColumnSelection getColumnSelection()
+ {
+ return columnSelection;
+ }
+
+ public void setColumnSelection(ColumnSelection columnSelection)
+ {
+ this.columnSelection = columnSelection;
+ }
+
+ public SequenceI[] getHiddenSequences()
+ {
+ return hiddenSequences;
+ }
+
+ public void setHiddenSequences(SequenceI[] hiddenSequences)
+ {
+ this.hiddenSequences = hiddenSequences;
+ }
+
}
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
-import jalview.api.AlignViewControllerGuiI;
import jalview.api.AlignViewportI;
+import jalview.api.ComplexAlignFile;
import jalview.api.FeatureRenderer;
import jalview.api.FeaturesDisplayedI;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenSequences;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.gui.AlignViewport;
import jalview.json.binding.v1.AlignmentAnnotationPojo;
import jalview.json.binding.v1.AlignmentPojo;
import jalview.json.binding.v1.AlignmentPojo.JalviewBioJsColorSchemeMapper;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-public class JSONFile extends AlignFile
+public class JSONFile extends AlignFile implements ComplexAlignFile
{
private ColourSchemeI colourScheme;
private List<int[]> hiddenColumns;
+ private ColumnSelection columnSelection;
+
private List<String> hiddenSeqRefs;
+ private ArrayList<SequenceI> hiddenSequences;
+
public JSONFile()
{
super();
return null;
}
- System.out.println("--- Hidden Sections ---");
// hidden column business
if (getViewport().hasHiddenColumns())
{
- System.out.print("Hidden Cols : ");
List<int[]> hiddenCols = getViewport().getColumnSelection()
.getHiddenColumns();
StringBuilder hiddenColsBuilder = new StringBuilder();
hiddenColsBuilder.deleteCharAt(0);
hiddenSections[0] = hiddenColsBuilder.toString();
- System.out.println(hiddenSections[0]);
}
// hidden rows/seqs business
parseHiddenCols(jvSettingsJsonObj);
}
+ hiddenSequences = new ArrayList<SequenceI>();
seqMap = new Hashtable<String, Sequence>();
for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
.hasNext();)
end);
if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
{
- seq.setHidden(true);
+ hiddenSequences.add(seq);
}
seqs.add(seq);
seqMap.put(seqUniqueId, seq);
public void parseHiddenCols(JSONObject jvSettingsJson)
{
- hiddenColumns = new ArrayList<int[]>();
+ // hiddenColumns = new ArrayList<int[]>();
String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
if(hiddenCols != null && !hiddenCols.isEmpty()){
+ columnSelection = new ColumnSelection();
String[] rangeStrings = hiddenCols.split(";");
for(String rangeString : rangeStrings){
String[] range = rangeString.split("-");
- hiddenColumns.add(new int[]
- { Integer.valueOf(range[0]), Integer.valueOf(range[1]) });
+ // hiddenColumns.add(new int[]
+ // { Integer.valueOf(range[0]), Integer.valueOf(range[1]) });
+ columnSelection.hideColumns(Integer.valueOf(range[0]),
+ Integer.valueOf(range[1]));
}
}
}
return jalviewColor;
}
- public void applySettingsToAlignmentView(AlignViewControllerGuiI avc)
+ public AlignViewportI getViewport(AlignmentI al)
{
- avc.setShowSeqFeatures(isShowSeqFeatures());
- avc.changeColour(getColourScheme());
- avc.setMenusForViewport();
- avc.hideColumns(hiddenColumns);
- avc.syncHiddenSequences();
+ AlignViewportI viewport = new AlignViewport(al, getColumnSelection());
+ viewport.setGlobalColourScheme(getColourScheme());
+ viewport.setShowSequenceFeatures(isShowSeqFeatures());
+ return viewport;
}
public String getGlobalColorScheme()
this.jsonExportSettings = jsonExportSettings;
}
+
public static String getJSONData(AlignViewportI av)
{
JSONFile jsonFile = new JSONFile();
return hiddenColumns;
}
+ public ColumnSelection getColumnSelection()
+ {
+ return columnSelection;
+ }
+
+ public void setColumnSelection(ColumnSelection columnSelection)
+ {
+ this.columnSelection = columnSelection;
+ }
+
+ public SequenceI[] getHiddenSequences()
+ {
+ if (hiddenSequences == null || hiddenSequences.isEmpty())
+ {
+ return new SequenceI[]
+ {};
+ }
+ synchronized (hiddenSequences)
+ {
+ return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
+ }
+ }
+
+ public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
+ {
+ this.hiddenSequences = hiddenSequences;
+ }
+
public class JSONExportSettings
{
private boolean exportSequence;