+ private AnnotationColours constructAnnotationColours(
+ AnnotationColourGradient acg, Vector userColours,
+ JalviewModelSequence jms)
+ {
+ AnnotationColours ac = new AnnotationColours();
+ ac.setAboveThreshold(acg.getAboveThreshold());
+ ac.setThreshold(acg.getAnnotationThreshold());
+ ac.setAnnotation(acg.getAnnotation());
+ if (acg.getBaseColour() instanceof jalview.schemes.UserColourScheme)
+ {
+ ac.setColourScheme(SetUserColourScheme(acg.getBaseColour(),
+ userColours, jms));
+ }
+ else
+ {
+ ac.setColourScheme(ColourSchemeProperty.getColourName(acg
+ .getBaseColour()));
+ }
+
+ ac.setMaxColour(acg.getMaxColour().getRGB());
+ ac.setMinColour(acg.getMinColour().getRGB());
+ ac.setPerSequence(acg.isSeqAssociated());
+ ac.setPredefinedColours(acg.isPredefinedColours());
+ return ac;
+ }
+
+ private void storeAlignmentAnnotation(AlignmentAnnotation[] aa,
+ IdentityHashMap groupRefs, AlignmentViewport av,
+ Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
+ {
+
+ for (int i = 0; i < aa.length; i++)
+ {
+ Annotation an = new Annotation();
+
+ if (aa[i].annotationId != null)
+ {
+ annotationIds.put(aa[i].annotationId, aa[i]);
+ }
+
+ an.setId(aa[i].annotationId);
+
+ an.setVisible(aa[i].visible);
+
+ an.setDescription(aa[i].description);
+
+ if (aa[i].sequenceRef != null)
+ {
+ // TODO later annotation sequenceRef should be the XML ID of the
+ // sequence rather than its display name
+ an.setSequenceRef(aa[i].sequenceRef.getName());
+ }
+ if (aa[i].groupRef != null)
+ {
+ Object groupIdr = groupRefs.get(aa[i].groupRef);
+ if (groupIdr == null)
+ {
+ // make a locally unique String
+ groupRefs.put(aa[i].groupRef,
+ groupIdr = ("" + System.currentTimeMillis()
+ + aa[i].groupRef.getName() + groupRefs.size()));
+ }
+ an.setGroupRef(groupIdr.toString());
+ }
+
+ // store all visualization attributes for annotation
+ an.setGraphHeight(aa[i].graphHeight);
+ an.setCentreColLabels(aa[i].centreColLabels);
+ an.setScaleColLabels(aa[i].scaleColLabel);
+ an.setShowAllColLabels(aa[i].showAllColLabels);
+ an.setBelowAlignment(aa[i].belowAlignment);
+
+ if (aa[i].graph > 0)
+ {
+ an.setGraph(true);
+ an.setGraphType(aa[i].graph);
+ an.setGraphGroup(aa[i].graphGroup);
+ if (aa[i].getThreshold() != null)
+ {
+ ThresholdLine line = new ThresholdLine();
+ line.setLabel(aa[i].getThreshold().label);
+ line.setValue(aa[i].getThreshold().value);
+ line.setColour(aa[i].getThreshold().colour.getRGB());
+ an.setThresholdLine(line);
+ }
+ }
+ else
+ {
+ an.setGraph(false);
+ }
+
+ an.setLabel(aa[i].label);
+
+ if (aa[i] == av.getAlignmentQualityAnnot()
+ || aa[i] == av.getAlignmentConservationAnnotation()
+ || aa[i] == av.getAlignmentConsensusAnnotation()
+ || aa[i].autoCalculated)
+ {
+ // new way of indicating autocalculated annotation -
+ an.setAutoCalculated(aa[i].autoCalculated);
+ }
+ if (aa[i].hasScore())
+ {
+ an.setScore(aa[i].getScore());
+ }
+
+ if (aa[i].getCalcId() != null)
+ {
+ calcIdSet.add(aa[i].getCalcId());
+ an.setCalcId(aa[i].getCalcId());
+ }
+ if (aa[i].hasProperties())
+ {
+ for (String pr : aa[i].getProperties())
+ {
+ Property prop = new Property();
+ prop.setName(pr);
+ prop.setValue(aa[i].getProperty(pr));
+ an.addProperty(prop);
+ }
+ }
+
+ AnnotationElement ae;
+ if (aa[i].annotations != null)
+ {
+ an.setScoreOnly(false);
+ for (int a = 0; a < aa[i].annotations.length; a++)
+ {
+ if ((aa[i] == null) || (aa[i].annotations[a] == null))
+ {
+ continue;
+ }
+
+ ae = new AnnotationElement();
+ if (aa[i].annotations[a].description != null)
+ {
+ ae.setDescription(aa[i].annotations[a].description);
+ }
+ if (aa[i].annotations[a].displayCharacter != null)
+ {
+ ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter);
+ }
+
+ if (!Float.isNaN(aa[i].annotations[a].value))
+ {
+ ae.setValue(aa[i].annotations[a].value);
+ }
+
+ ae.setPosition(a);
+ if (aa[i].annotations[a].secondaryStructure > ' ')
+ {
+ ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure
+ + "");
+ }
+
+ if (aa[i].annotations[a].colour != null
+ && aa[i].annotations[a].colour != java.awt.Color.black)
+ {
+ ae.setColour(aa[i].annotations[a].colour.getRGB());
+ }
+
+ an.addAnnotationElement(ae);
+ if (aa[i].autoCalculated)
+ {
+ // only write one non-null entry into the annotation row -
+ // sufficient to get the visualization attributes necessary to
+ // display data
+ continue;
+ }
+ }
+ }
+ else
+ {
+ an.setScoreOnly(true);
+ }
+ if (!storeDS || (storeDS && !aa[i].autoCalculated))
+ {
+ // skip autocalculated annotation - these are only provided for
+ // alignments
+ vamsasSet.addAnnotation(an);
+ }
+ }
+
+ }
+