Search in sources :

Example 1 with GraphLabelsAndDecoratorsV0

use of au.gov.asd.tac.constellation.graph.schema.visual.attribute.compatibility.GraphLabelsAndDecoratorsV0 in project constellation by constellation-app.

the class VisualSchemaV1UpdateProvider method schemaUpdate.

@Override
protected void schemaUpdate(StoreGraph graph) {
    final int bottomLabelsAttribute = VisualConcept.GraphAttribute.BOTTOM_LABELS.ensure(graph);
    final int decoratorsAttribute = VisualConcept.GraphAttribute.DECORATORS.ensure(graph);
    final int topLabelsAttribute = VisualConcept.GraphAttribute.TOP_LABELS.ensure(graph);
    final int transactionLabelsAttribute = VisualConcept.GraphAttribute.TRANSACTION_LABELS.ensure(graph);
    VisualConcept.GraphAttribute.BLAZE_OPACITY.ensure(graph);
    VisualConcept.GraphAttribute.BLAZE_SIZE.ensure(graph);
    VisualConcept.GraphAttribute.CONNECTION_MODE.ensure(graph);
    VisualConcept.GraphAttribute.DRAW_FLAGS.ensure(graph);
    VisualConcept.GraphAttribute.NODE_COLOR_REFERENCE.ensure(graph);
    VisualConcept.GraphAttribute.TRANSACTION_COLOR_REFERENCE.ensure(graph);
    VisualConcept.GraphAttribute.VISIBLE_ABOVE_THRESHOLD.ensure(graph);
    VisualConcept.GraphAttribute.VISIBILITY_THRESHOLD.ensure(graph);
    final int labelsAndDecoratorsAttrId = graph.getAttribute(GraphElementType.META, LABELS_AND_DECORATORS_ATTRIBUTE_NAME);
    if (labelsAndDecoratorsAttrId != Graph.NOT_FOUND) {
        final GraphLabelsAndDecoratorsV0 labelsAndDecorators = graph.getObjectValue(labelsAndDecoratorsAttrId, 0);
        if (labelsAndDecorators != null) {
            final GraphLabelV0[] bottomLabels = labelsAndDecorators.getBottomLabels();
            List<au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel> newBottomLabels = new ArrayList<>();
            for (GraphLabelV0 bottomLabel : bottomLabels) {
                newBottomLabels.add(new au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel(bottomLabel.getLabel(), bottomLabel.getColor(), bottomLabel.getRadius()));
            }
            graph.setObjectValue(bottomLabelsAttribute, 0, new GraphLabels(newBottomLabels));
            final GraphLabelV0[] topLabels = labelsAndDecorators.getTopLabels();
            List<au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel> newTopLabels = new ArrayList<>();
            for (GraphLabelV0 topLabel : topLabels) {
                newTopLabels.add(new au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel(topLabel.getLabel(), topLabel.getColor(), topLabel.getRadius()));
            }
            graph.setObjectValue(topLabelsAttribute, 0, new GraphLabels(newTopLabels));
            final GraphLabelV0[] connectionLabels = labelsAndDecorators.getConnectionLabels();
            List<au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel> newConnectionLabels = new ArrayList<>();
            for (GraphLabelV0 connectionLabel : connectionLabels) {
                newConnectionLabels.add(new au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel(connectionLabel.getLabel(), connectionLabel.getColor(), connectionLabel.getRadius()));
            }
            graph.setObjectValue(transactionLabelsAttribute, 0, new GraphLabels(newConnectionLabels));
            final String[] decoratorAttributes = labelsAndDecorators.getDecoratorLabels();
            graph.setObjectValue(decoratorsAttribute, 0, new VertexDecorators(updateDecoratorAttr(decoratorAttributes[0]), updateDecoratorAttr(decoratorAttributes[1]), updateDecoratorAttr(decoratorAttributes[2]), updateDecoratorAttr(decoratorAttributes[3])));
        }
        graph.removeAttribute(labelsAndDecoratorsAttrId);
    }
    final int labelsTopAttrId = graph.getAttribute(GraphElementType.GRAPH, LABELS_TOP_ATTRIBUTE_NAME);
    if (labelsTopAttrId != Graph.NOT_FOUND) {
        final String[] labelsTop = graph.getStringValue(labelsTopAttrId, 0).split(",");
        final List<au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel> newTopLabels = new ArrayList<>();
        for (String topLabel : labelsTop) {
            newTopLabels.add(new au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel(topLabel, ConstellationColor.LIGHT_BLUE, 1));
        }
        graph.setObjectValue(topLabelsAttribute, 0, new GraphLabels(newTopLabels));
        graph.removeAttribute(labelsTopAttrId);
    }
    final int labelsBottomAttrId = graph.getAttribute(GraphElementType.GRAPH, LABELS_BOTTOM_ATTRIBUTE_NAME);
    if (labelsBottomAttrId != Graph.NOT_FOUND) {
        final String[] labelsBottom = graph.getStringValue(labelsBottomAttrId, 0).split(",");
        final List<au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel> newBottomLabels = new ArrayList<>();
        for (String bottomLabel : labelsBottom) {
            newBottomLabels.add(new au.gov.asd.tac.constellation.graph.schema.visual.GraphLabel(bottomLabel, ConstellationColor.LIGHT_BLUE, 1));
        }
        graph.setObjectValue(bottomLabelsAttribute, 0, new GraphLabels(newBottomLabels));
        graph.removeAttribute(labelsBottomAttrId);
    }
}
Also used : VertexDecorators(au.gov.asd.tac.constellation.graph.schema.visual.VertexDecorators) ArrayList(java.util.ArrayList) GraphLabelV0(au.gov.asd.tac.constellation.graph.schema.visual.attribute.compatibility.GraphLabelV0) GraphLabelsAndDecoratorsV0(au.gov.asd.tac.constellation.graph.schema.visual.attribute.compatibility.GraphLabelsAndDecoratorsV0) GraphLabels(au.gov.asd.tac.constellation.graph.schema.visual.GraphLabels)

Aggregations

GraphLabels (au.gov.asd.tac.constellation.graph.schema.visual.GraphLabels)1 VertexDecorators (au.gov.asd.tac.constellation.graph.schema.visual.VertexDecorators)1 GraphLabelV0 (au.gov.asd.tac.constellation.graph.schema.visual.attribute.compatibility.GraphLabelV0)1 GraphLabelsAndDecoratorsV0 (au.gov.asd.tac.constellation.graph.schema.visual.attribute.compatibility.GraphLabelsAndDecoratorsV0)1 ArrayList (java.util.ArrayList)1