*/
package jalview.gui;
-import java.awt.Rectangle;
-import java.io.BufferedReader;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-
-import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.exolab.castor.xml.Marshaller;
-import org.exolab.castor.xml.Unmarshaller;
-
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.AlignedCodonFrame;
import jalview.ws.params.AutoCalcSetting;
import jalview.ws.params.WsParamSetI;
+import java.awt.Rectangle;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import org.exolab.castor.xml.Marshaller;
+import org.exolab.castor.xml.Unmarshaller;
+
/**
* Write out the current jalview desktop state as a Jalview XML stream.
*
{
final SequenceI jds = jal.getSequenceAt(i);
final SequenceI jdatasq = jds.getDatasetSequence() == null ? jds
- : jds
- .getDatasetSequence();
+ : jds.getDatasetSequence();
String id = seqHash(jds);
if (seqRefIds.get(id) != null)
if (jds.getSequenceFeatures() != null)
{
- jalview.datamodel.SequenceFeature[] sf = jds
- .getSequenceFeatures();
+ jalview.datamodel.SequenceFeature[] sf = jds.getSequenceFeatures();
int index = 0;
while (index < sf.length)
{
}
}
- saveRnaViewers(jout, jseq, jds, viewIds, storeDS);
+ saveRnaViewers(jout, jseq, jds, viewIds, ap, storeDS);
jms.addJSeq(jseq);
}
}
}
-// {
-// AlcodonFrame alc = new AlcodonFrame();
-// vamsasSet.addAlcodonFrame(alc);
-// for (int p = 0; p < acf.aaWidth; p++)
-// {
-// Alcodon cmap = new Alcodon();
-// if (acf.codons[p] != null)
-// {
-// // Null codons indicate a gapped column in the translated peptide
-// // alignment.
-// cmap.setPos1(acf.codons[p][0]);
-// cmap.setPos2(acf.codons[p][1]);
-// cmap.setPos3(acf.codons[p][2]);
-// }
-// alc.addAlcodon(cmap);
-// }
-// if (acf.getProtMappings() != null
-// && acf.getProtMappings().length > 0)
-// {
-// SequenceI[] dnas = acf.getdnaSeqs();
-// jalview.datamodel.Mapping[] pmaps = acf.getProtMappings();
-// for (int m = 0; m < pmaps.length; m++)
-// {
-// AlcodMap alcmap = new AlcodMap();
-// alcmap.setDnasq(seqHash(dnas[m]));
-// alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null,
-// false));
-// alc.addAlcodMap(alcmap);
-// }
-// }
+ // {
+ // AlcodonFrame alc = new AlcodonFrame();
+ // vamsasSet.addAlcodonFrame(alc);
+ // for (int p = 0; p < acf.aaWidth; p++)
+ // {
+ // Alcodon cmap = new Alcodon();
+ // if (acf.codons[p] != null)
+ // {
+ // // Null codons indicate a gapped column in the translated peptide
+ // // alignment.
+ // cmap.setPos1(acf.codons[p][0]);
+ // cmap.setPos2(acf.codons[p][1]);
+ // cmap.setPos3(acf.codons[p][2]);
+ // }
+ // alc.addAlcodon(cmap);
+ // }
+ // if (acf.getProtMappings() != null
+ // && acf.getProtMappings().length > 0)
+ // {
+ // SequenceI[] dnas = acf.getdnaSeqs();
+ // jalview.datamodel.Mapping[] pmaps = acf.getProtMappings();
+ // for (int m = 0; m < pmaps.length; m++)
+ // {
+ // AlcodMap alcmap = new AlcodMap();
+ // alcmap.setDnasq(seqHash(dnas[m]));
+ // alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null,
+ // false));
+ // alc.addAlcodMap(alcmap);
+ // }
+ // }
}
}
if (sg.cs instanceof jalview.schemes.UserColourScheme)
{
- jGroup.setColour(setUserColourScheme(sg.cs, userColours,
- jms));
+ jGroup.setColour(setUserColourScheme(sg.cs, userColours, jms));
}
else
{
- jGroup
- .setColour(ColourSchemeProperty.getColourName(sg.cs));
+ jGroup.setColour(ColourSchemeProperty.getColourName(sg.cs));
}
}
else if (sg.cs instanceof jalview.schemes.AnnotationColourGradient)
}
else if (sg.cs instanceof jalview.schemes.UserColourScheme)
{
- jGroup
- .setColour(setUserColourScheme(sg.cs, userColours, jms));
+ jGroup.setColour(setUserColourScheme(sg.cs, userColours, jms));
}
else
{
else
{
setting.setColour(ap.getSeqPanel().seqCanvas
- .getFeatureRenderer()
- .getColour(renderOrder[ro]).getRGB());
+ .getFeatureRenderer().getColour(renderOrder[ro])
+ .getRGB());
}
setting.setDisplay(av.getFeaturesDisplayed().isVisible(
* @param jseq
* @param jds
* @param viewIds
+ * @param ap
* @param storeDataset
*/
protected void saveRnaViewers(JarOutputStream jout, JSeq jseq,
- final SequenceI jds, List<String> viewIds, boolean storeDataset)
+ final SequenceI jds, List<String> viewIds, AlignmentPanel ap,
+ boolean storeDataset)
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
for (int f = frames.length - 1; f > -1; f--)
if (frames[f] instanceof AppVarna)
{
AppVarna varna = (AppVarna) frames[f];
- if (varna.isListeningFor(jds))
+ /*
+ * link the sequence to every viewer that is showing it and is linked to
+ * its alignment panel
+ */
+ if (varna.isListeningFor(jds) && ap == varna.getAlignmentPanel())
{
- /*
- * link the sequence to every viewer that is showing it
- */
String viewId = varna.getViewId();
RnaViewer rna = new RnaViewer();
rna.setViewId(viewId);
{
String varnaStateFile = varna.getStateInfo(model.rna);
- jarEntryName = RNA_PREFIX + viewId + "_"
- + nextCounter();
+ jarEntryName = RNA_PREFIX + viewId + "_" + nextCounter();
copyFileToJar(jout, varnaStateFile, jarEntryName);
rnaSessions.put(model, jarEntryName);
}
private void storeAlignmentAnnotation(AlignmentAnnotation[] aa,
IdentityHashMap<SequenceGroup, String> groupRefs,
- AlignmentViewport av,
- Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
+ AlignmentViewport av, Set<String> calcIdSet, boolean storeDS,
+ SequenceSet vamsasSet)
{
for (int i = 0; i < aa.length; i++)
if (groupIdr == null)
{
// make a locally unique String
- groupRefs.put(annotation.groupRef,
+ groupRefs.put(
+ annotation.groupRef,
groupIdr = ("" + System.currentTimeMillis()
- + annotation.groupRef.getName() + groupRefs.size()));
+ + annotation.groupRef.getName() + groupRefs
+ .size()));
}
an.setGroupRef(groupIdr.toString());
}
});
} catch (Exception x)
{
-
+ System.err.println("Error loading alignment: " + x.getMessage());
}
}
return af;
.entrySet())
{
AlignFrame af = candidate.getValue();
- if (!addedToSplitFrames.contains(af)) {
+ if (!addedToSplitFrames.contains(af))
+ {
Viewport view = candidate.getKey();
Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(),
view.getHeight());
// set visiblity for other annotation in this view
String annotationId = annotation.getId();
- if (annotationId != null
- && annotationIds.containsKey(annotationId))
+ if (annotationId != null && annotationIds.containsKey(annotationId))
{
AlignmentAnnotation jda = annotationIds.get(annotationId);
// in principle Visible should always be true for annotation displayed
SequenceGroup sg = new SequenceGroup(seqs, jGroup.getName(), cs,
jGroup.getDisplayBoxes(), jGroup.getDisplayText(),
- jGroup.getColourText(), jGroup.getStart(),
- jGroup.getEnd());
+ jGroup.getColourText(), jGroup.getStart(), jGroup.getEnd());
sg.setOutlineColour(new java.awt.Color(jGroup.getOutlineColour()));
if (jGroup.getId() != null && groupAnnotRefs.size() > 0)
{
// re-instate unique group/annotation row reference
- List<AlignmentAnnotation> jaal = groupAnnotRefs
- .get(jGroup.getId());
+ List<AlignmentAnnotation> jaal = groupAnnotRefs.get(jGroup
+ .getId());
if (jaal != null)
{
for (AlignmentAnnotation jaa : jaal)
if (addAnnotSchemeGroup)
{
// reconstruct the annotation colourscheme
- sg.cs = constructAnnotationColour(
- jGroup.getAnnotationColours(), null, al, jms, false);
+ sg.cs = constructAnnotationColour(jGroup.getAnnotationColours(),
+ null, al, jms, false);
}
}
}
for (int i = 0; i < jseq.getRnaViewerCount(); i++)
{
RnaViewer viewer = jseq.getRnaViewer(i);
- AppVarna appVarna = findOrCreateVarnaViewer(viewer, uniqueSetSuffix,
- ap);
+ AppVarna appVarna = findOrCreateVarnaViewer(viewer,
+ uniqueSetSuffix, ap);
for (int j = 0; j < viewer.getSecondaryStructureCount(); j++)
{
String sessionState = ss.getViewerState();
String tempStateFile = copyJarEntry(jprovider, sessionState,
"varna");
- RnaModel rna = new RnaModel(rnaTitle, ann, seq, null, gapped,
- tempStateFile);
- appVarna.addModel(rna, rnaTitle);
+ RnaModel rna = new RnaModel(rnaTitle, ann, seq, null, gapped);
+ appVarna.addModelSession(rna, rnaTitle, tempStateFile);
}
- appVarna.setSelectedIndex(viewer.getSelectedRna());
+ appVarna.setInitialSelection(viewer.getSelectedRna());
}
}
}
* viewer not found - make it
*/
RnaViewerModel model = new RnaViewerModel(postLoadId,
- viewer.getTitle(), viewer.getXpos(),
- viewer.getYpos(), viewer.getWidth(), viewer.getHeight(),
+ viewer.getTitle(), viewer.getXpos(), viewer.getYpos(),
+ viewer.getWidth(), viewer.getHeight(),
viewer.getDividerLocation());
AppVarna varna = new AppVarna(model, ap);
* @param af
* @param jprovider
*/
- protected void createChimeraViewer(Entry<String, StructureViewerModel> viewerData,
- AlignFrame af,
+ protected void createChimeraViewer(
+ Entry<String, StructureViewerModel> viewerData, AlignFrame af,
jarInputStreamProvider jprovider)
{
StructureViewerModel data = viewerData.getValue();
- String chimeraSessionFile = data.getStateData();
+ String chimeraSessionFile = data.getStateData();
/*
* Copy Chimera session from jar entry "viewer_"+viewId to a temporary file
String newViewId = viewerData.getKey();
ChimeraViewFrame cvf = new ChimeraViewFrame(chimeraSessionFile,
- af.alignPanel, pdbArray,
- seqsArray, colourByChimera, colourBySequence, newViewId);
+ af.alignPanel, pdbArray, seqsArray, colourByChimera,
+ colourBySequence, newViewId);
cvf.setSize(data.getWidth(), data.getHeight());
cvf.setLocation(data.getX(), data.getY());
}
newFileLoc.append(";");
}
- if (newFileLoc.length() > 0)
+ if (newFileLoc.length() == 0)
+ {
+ return;
+ }
+ int histbug = newFileLoc.indexOf("history = ");
+ if (histbug > -1)
{
- int histbug = newFileLoc.indexOf("history = ");
+ /*
+ * change "history = [true|false];" to "history = [1|0];"
+ */
histbug += 10;
int diff = histbug == -1 ? -1 : newFileLoc.indexOf(";", histbug);
String val = (diff == -1) ? null : newFileLoc
.substring(histbug, diff);
if (val != null && val.length() >= 4)
{
- if (val.contains("e"))
+ if (val.contains("e")) // eh? what can it be?
{
if (val.trim().equals("true"))
{
newFileLoc.replace(histbug, diff, val);
}
}
+ }
final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames
.size()]);
}
}
af.setMenusFromViewport(af.viewport);
-
+
// TODO: we don't need to do this if the viewport is aready visible.
/*
* Add the AlignFrame to the desktop (it may be 'gathered' later), unless it
}
}
}
-
+
return result;
}