*/
package jalview.gui;
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Vector;
-
-import javax.swing.ButtonGroup;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JColorChooser;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPopupMenu;
-import javax.swing.JRadioButtonMenuItem;
-
import jalview.analysis.AAFrequency;
import jalview.analysis.AlignmentAnnotationUtils;
import jalview.analysis.AlignmentUtils;
import jalview.util.MessageManager;
import jalview.util.UrlLink;
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Vector;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
+
/**
* DOCUMENT ME!
*
throws java.io.IOException
{
Alignment al;
- // if (format.equals(JSONFile.FILE_DESC))
- // {
- // // afile = new HtmlFile(inFile, type);
- // al = new Alignment(afile.getSeqsAsArray());
- // afile.addAnnotations(al);
- // }
- // else
- // {
+ if (format.equals(JSONFile.FILE_DESC))
+ {
+ afile = new JSONFile(inFile, type);
+ al = new Alignment(afile.getSeqsAsArray());
+ afile.addAnnotations(al);
+ for (SequenceGroup sg : afile.getSeqGroups())
+ {
+ al.addGroup(sg);
+ }
+ }
+ else
+ {
al = super.readFile(inFile, type, format);
- // }
-
- afile.addSeqGroups(al);
- afile.addAnnotations(al);
+ }
return al;
}
throws java.io.IOException
{
Alignment al;
- // if (format.equals(JSONFile.FILE_DESC))
- // {
- // // afile = new HtmlFile(source);
- // al = new Alignment(afile.getSeqsAsArray());
- // afile.addAnnotations(al);
- // }
- // else
- // {
+ if (format.equals(JSONFile.FILE_DESC))
+ {
+ afile = new JSONFile(source);
+ al = new Alignment(afile.getSeqsAsArray());
+ afile.addAnnotations(al);
+ afile.addSeqGroups(al);
+ }
+ else
+ {
al = (Alignment) super.readFromFile(source, format);
- // }
- afile.addSeqGroups(al);
- afile.addAnnotations(al);
+ }
return al;
}
private FeaturesDisplayedI displayedFeatures;
- // private AlignmentI al;
-
private AlignmentViewport av;
private jalview.api.FeatureRenderer fr;
this.fr = Desktop.getCurrentAlignFrame().alignPanel
.cloneFeatureRenderer();
displayedFeatures = av.getFeaturesDisplayed();
+ jsonAlignmentPojo
+ .setShowSeqFeatures(Desktop.getCurrentAlignFrame().showSeqFeatures
+ .isSelected());
}
jsonAlignmentPojo.setJalviewVersion(jalviewVersion);
jsonAlignmentPojo.setWebStartUrl(webStartLaunchServletUrl);
- System.out.println(">>>>>>>>>>>>>> found grps : " + seqGroups.size());
if (seqGroups.size() > 0)
{
ArrayList<SequenceGrpPojo> sequenceGroupsPojo = new ArrayList<SequenceGrpPojo>();
for (SequenceGroup seqGrp : seqGroups)
{
- System.out.println(">>>>>>>>>>>> grp : " + seqGrp.getName());
SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
seqGrpPojo.setGroupName(seqGrp.getName());
seqGrpPojo.setColourScheme(ColourSchemeProperty
seqGrpPojo.setEndRes(seqGrp.getEndRes());
seqGrpPojo.setStartRes(seqGrp.getStartRes());
seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved());
- jsonAlignmentPojo.getSequenceGroups().add(seqGrpPojo);
for(SequenceI seq : seqGrp.getSequences()){
seqGrpPojo.getSeqsHash().add(seq.getName() + "_" + seq.hashCode());
}
- // sequenceGroupsPojo.add(seqGrpPojo);
+ jsonAlignmentPojo.getSequenceGroups().add(seqGrpPojo);
}
}
+
for (AlignmentAnnotation annot : annotations)
{
AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj.get("sequenceGroups");
String jsColourScheme = (String) alignmentJsonObj
.get("globalColorScheme");
- System.out.println(">>>>>>>>>>>>>>>> global cs : " + jsColourScheme);
+ Boolean showFeatures = Boolean.valueOf(alignmentJsonObj.get(
+ "showSeqFeatures").toString());
cs = getJalviewColorScheme(jsColourScheme);
seqMap = new Hashtable<String, Sequence>();
Desktop.setCurrentGlobalColourScheme(cs);
+ Desktop.setCurrentSeqFeaturesVisible(showFeatures);
for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
.hasNext();)
{
seqMap.put(seqUniqueId, seq);
}
- // for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator();
- // seqGrpIter
- // .hasNext();)
- // {
- // JSONObject seqGrpObj = seqGrpIter.next();
- // String grpName = seqGrpObj.get("groupName").toString();
- // String colourScheme = seqGrpObj.get("colourScheme").toString();
- // String description = (seqGrpObj.get("description") == null) ? null
- // : seqGrpObj.get("description").toString();
- // boolean displayBoxes = Boolean.valueOf(seqGrpObj
- // .get("displayBoxes").toString());
- // boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
- // .toString());
- // boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
- // .toString());
- // boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
- // "showNonconserved").toString());
- // int startRes = Integer
- // .valueOf(seqGrpObj.get("startRes").toString());
- // int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
- // JSONArray seqsHashArray = (JSONArray) seqGrpObj.get("seqsHash");
- //
- // ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
- // if (seqsHashArray.size() > 0)
- // {
- // Iterator<String> seqHashIter = seqsHashArray.iterator();
- //
- // while (seqHashIter.hasNext())
- // {
- // String seqHash = seqHashIter.next();
- // Sequence sequence = seqMap.get(seqHash);
- // if (sequence != null)
- // {
- // grpSeqs.add(sequence);
- // }
- // // System.out.println(">>>>>>>>>>>>>>>>>>>>>>> seqHash : "
- // // + seqHash);
- // }
- // }
- // System.out.println(">>>>>>>>>>>>>>>>>> scheme string : "
- // + colourScheme);
- // ColourSchemeI scheme = getJalviewColorScheme(colourScheme);
- // System.out.println(">>>>>>>>>>>>>>>>>> scheme: " + scheme);
- // SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, scheme,
- // displayBoxes, displayText, colourText, startRes, endRes);
- // this.seqGroups.add(seqGrp);
- //
- // }
+ for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
+ .hasNext();)
+ {
+ JSONObject seqGrpObj = seqGrpIter.next();
+ String grpName = seqGrpObj.get("groupName").toString();
+ String colourScheme = seqGrpObj.get("colourScheme").toString();
+ String description = (seqGrpObj.get("description") == null) ? null
+ : seqGrpObj.get("description").toString();
+ boolean displayBoxes = Boolean.valueOf(seqGrpObj
+ .get("displayBoxes").toString());
+ boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
+ .toString());
+ boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
+ .toString());
+ boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
+ "showNonconserved").toString());
+ int startRes = Integer
+ .valueOf(seqGrpObj.get("startRes").toString());
+ int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
+ JSONArray seqsHashArray = (JSONArray) seqGrpObj.get("seqsHash");
+
+ ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
+ if (seqsHashArray.size() > 0)
+ {
+ Iterator<String> seqHashIter = seqsHashArray.iterator();
+ while (seqHashIter.hasNext())
+ {
+ String seqHash = seqHashIter.next();
+ Sequence sequence = seqMap.get(seqHash);
+ if (sequence != null)
+ {
+ grpSeqs.add(sequence);
+ }
+ }
+ }
+ ColourSchemeI scheme = getJalviewColorScheme(colourScheme);
+ SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, scheme,
+ displayBoxes, displayText, colourText, startRes, endRes);
+ seqGrp.setShowNonconserved(showNonconserved);
+ seqGrp.setDescription(description);
+ this.seqGroups.add(seqGrp);
+
+ }
for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
Long begin = (Long) jsonFeature.get("xStart");
Long end = (Long) jsonFeature.get("xEnd");
String type = (String) jsonFeature.get("type");
- // String color = (String) jsonFeature.get("fillColor");
+ String color = (String) jsonFeature.get("fillColor");
String featureGrp = (String) jsonFeature.get("featureGroup");
String descripiton = (String) jsonFeature.get("description");
Float score = Float.valueOf(jsonFeature.get("score").toString());
public void LoadAlignmentFeatures(AlignFrame af)
{
- af.setShowSeqFeatures(true);
- af.changeColour(cs);
+ af.setShowSeqFeatures(Desktop.isCurrentSeqFeaturesVisible());
+ af.changeColour(Desktop.getCurrentGlobalColourScheme());
af.setMenusForViewport();
}