private static void writeGraphics(GraphicModel model, Attributes attributes) {
List<GraphicLayer> layers = model.getLayers();
Sequence annotationSeq = attributes.newSequence(Tag.GraphicAnnotationSequence, layers.size());
Sequence layerSeq = attributes.newSequence(Tag.GraphicLayerSequence, layers.size());
for (int i = 0; i < layers.size(); i++) {
GraphicLayer layer = layers.get(i);
if (layer.getSerializable()) {
String layerName = layer.getType().name();
List<Graphic> graphics = getGraphicsByLayer(model, layer.getUuid());
Attributes l = new Attributes(2);
l.setString(Tag.GraphicLayer, VR.CS, layerName);
l.setInt(Tag.GraphicLayerOrder, VR.IS, i);
float[] lab = PresentationStateReader
.colorToLAB(Optional.ofNullable(MeasureTool.viewSetting.getLineColor()).orElse(Color.YELLOW));
if (lab != null) {
l.setInt(Tag.GraphicLayerRecommendedDisplayCIELabValue, VR.US, CIELab.convertToDicomLab(lab));
}
l.setString(Tag.GraphicLayerDescription, VR.LO, layer.toString());
layerSeq.add(l);
Attributes a = new Attributes(2);
a.setString(Tag.GraphicLayer, VR.CS, layerName);
Sequence graphicSeq = a.newSequence(Tag.GraphicObjectSequence, graphics.size());
Sequence textSeq = a.newSequence(Tag.TextObjectSequence, graphics.size());
for (Graphic graphic : graphics) {
buildDicomGraphic(graphic, graphicSeq, textSeq);
}
annotationSeq.add(a);
}
}
}