Search in sources :

Example 11 with SchemaVertexType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType in project constellation by constellation-app.

the class VertexTypeNodeProvider method isFilterMatchAnyChildNodes.

private boolean isFilterMatchAnyChildNodes(SchemaVertexType treeItem) {
    boolean found = false;
    final List<SchemaVertexType> children = vertexTypes.stream().filter(vertexType -> vertexType.getSuperType() == treeItem && vertexType != treeItem).collect(Collectors.toList());
    for (SchemaVertexType child : children) {
        found = isFilterMatchCurrentNodeOrAnyChildren(child);
        if (found) {
            break;
        }
    }
    return found;
}
Also used : Pos(javafx.geometry.Pos) StackPane(javafx.scene.layout.StackPane) GraphManagerListener(au.gov.asd.tac.constellation.graph.manager.GraphManagerListener) VBox(javafx.scene.layout.VBox) SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) StringUtils(org.apache.commons.lang3.StringUtils) BlendMode(javafx.scene.effect.BlendMode) Map(java.util.Map) ColorInput(javafx.scene.effect.ColorInput) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) SeparatorConstants(au.gov.asd.tac.constellation.utilities.text.SeparatorConstants) Blend(javafx.scene.effect.Blend) Set(java.util.Set) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) Objects(java.util.Objects) Platform(javafx.application.Platform) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) DataFormat(javafx.scene.input.DataFormat) RadioButton(javafx.scene.control.RadioButton) ObservableList(javafx.collections.ObservableList) ClipboardContent(javafx.scene.input.ClipboardContent) SchemaVertexTypeUtilities(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexTypeUtilities) ColumnConstraints(javafx.scene.layout.ColumnConstraints) TreeItem(javafx.scene.control.TreeItem) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TransferMode(javafx.scene.input.TransferMode) ArrayList(java.util.ArrayList) Graph(au.gov.asd.tac.constellation.graph.Graph) Dragboard(javafx.scene.input.Dragboard) Insets(javafx.geometry.Insets) ServiceProvider(org.openide.util.lookup.ServiceProvider) GridPane(javafx.scene.layout.GridPane) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) Node(javafx.scene.Node) ColorAdjust(javafx.scene.effect.ColorAdjust) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) ToggleGroup(javafx.scene.control.ToggleGroup) Tab(javafx.scene.control.Tab) ImageView(javafx.scene.image.ImageView) TreeCell(javafx.scene.control.TreeCell) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) Collections(java.util.Collections) Image(javafx.scene.image.Image) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)

Example 12 with SchemaVertexType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType in project constellation by constellation-app.

the class VertexTypeNodeProvider method createNode.

/**
 * Recursively create a tree of vertex types.
 * <p>
 * getSuperType() points to the parent. If getSuperType() points to itself,
 * the vertex type is a root.
 *
 * @param vxtype
 * @return
 */
private TreeItem<SchemaVertexType> createNode(final SchemaVertexType vxtype) {
    return new TreeItem<SchemaVertexType>(vxtype) {

        // We cache whether the vertextype is a leaf or not.
        private boolean isLeaf;

        // We do the children and leaf testing only once, and then set these
        // booleans to false so that we do not check again during this
        // run.
        private boolean isFirstTimeChildren = true;

        private boolean isFirstTimeLeaf = true;

        @Override
        public ObservableList<TreeItem<SchemaVertexType>> getChildren() {
            if (isFirstTimeChildren) {
                isFirstTimeChildren = false;
                super.getChildren().setAll(buildChildren(this));
            }
            return super.getChildren();
        }

        /**
         * A vertextype is not a leaf if another vertextype refers to it as
         * a supertype.
         *
         * @return
         */
        @Override
        public boolean isLeaf() {
            if (isFirstTimeLeaf) {
                isFirstTimeLeaf = false;
                isLeaf = false;
                if (getValue() != null) {
                    final boolean foundChild = vertexTypes.stream().anyMatch(vertexType -> vertexType.getSuperType() == getValue() && vertexType != getValue());
                    isLeaf = !foundChild;
                }
            }
            return isLeaf;
        }

        private ObservableList<TreeItem<SchemaVertexType>> buildChildren(final TreeItem<SchemaVertexType> item) {
            final SchemaVertexType value = item.getValue();
            final ObservableList<TreeItem<SchemaVertexType>> children = FXCollections.observableArrayList();
            if (value == null) {
                // Any vertextype that points to itself is in the root layer.
                for (final SchemaVertexType vertexType : vertexTypes) {
                    if ((vertexType.getSuperType() == vertexType) && (isFilterMatchCurrentNodeOrAnyChildren(vertexType) || filterText.getText().isEmpty())) {
                        children.add(createNode(vertexType));
                    }
                }
            } else {
                for (final SchemaVertexType vertexType : vertexTypes) {
                    if ((vertexType.getSuperType() == value && vertexType != value) && (isFilterMatchCurrentNodeOrAnyChildren(vertexType) || filterText.getText().isEmpty())) {
                        children.add(createNode(vertexType));
                    }
                }
            }
            return children;
        }
    };
}
Also used : SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) TreeItem(javafx.scene.control.TreeItem)

Example 13 with SchemaVertexType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType in project constellation by constellation-app.

the class CompleteGraphBuilderPlugin method updateParameters.

@Override
public void updateParameters(final Graph graph, final PluginParameters parameters) {
    final List<String> nAttributes = new ArrayList<>();
    final List<String> tAttributes = new ArrayList<>();
    final List<String> nChoices = new ArrayList<>();
    final List<String> tChoices = new ArrayList<>();
    if (graph != null) {
        final Set<Class<? extends SchemaConcept>> concepts = graph.getSchema().getFactory().getRegisteredConcepts();
        final Collection<SchemaVertexType> nodeTypes = SchemaVertexTypeUtilities.getTypes(concepts);
        for (final SchemaVertexType type : nodeTypes) {
            nAttributes.add(type.getName());
        }
        nAttributes.sort(String::compareTo);
        final Collection<SchemaTransactionType> transactionTypes = SchemaTransactionTypeUtilities.getTypes(concepts);
        for (final SchemaTransactionType type : transactionTypes) {
            tAttributes.add(type.getName());
        }
        tAttributes.sort(String::compareTo);
        nChoices.add(nAttributes.get(0));
        tChoices.add(tAttributes.get(0));
    }
    if (parameters != null && parameters.getParameters() != null) {
        // NODE_TYPES_PARAMETER will always be of type MultiChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> nAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(NODE_TYPES_PARAMETER_ID);
        // TRANSACTION_TYPES_PARAMETER will always be of type MultiChoiceParameter
        @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> tAttribute = (PluginParameter<MultiChoiceParameterValue>) parameters.getParameters().get(TRANSACTION_TYPES_PARAMETER_ID);
        MultiChoiceParameterType.setOptions(nAttribute, nAttributes);
        MultiChoiceParameterType.setOptions(tAttribute, tAttributes);
        MultiChoiceParameterType.setChoices(nAttribute, nChoices);
        MultiChoiceParameterType.setChoices(tAttribute, tChoices);
    }
}
Also used : SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)

Example 14 with SchemaVertexType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType in project constellation by constellation-app.

the class SchemaElementTypeNGTest method testGetColor.

/**
 * Test of getColor method, of class SchemaElementType.
 */
@Test
public void testGetColor() {
    SchemaElementType<SchemaVertexType> instance = SchemaVertexType.unknownType();
    ConstellationColor expResult = ConstellationColor.GREY;
    ConstellationColor result = instance.getColor();
    assertEquals(result, expResult);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) Test(org.testng.annotations.Test)

Example 15 with SchemaVertexType

use of au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType in project constellation by constellation-app.

the class GetTypeDescription method callService.

@Override
public void callService(final PluginParameters parameters, final InputStream in, final OutputStream out) throws IOException {
    final String typeName = parameters.getStringValue(TYPE_PARAMETER_ID);
    if (!SchemaVertexTypeUtilities.getDefaultType().equals(SchemaVertexTypeUtilities.getType(typeName))) {
        final SchemaVertexType vertexType = SchemaVertexTypeUtilities.getType(typeName);
        final ObjectMapper mapper = new ObjectMapper();
        final ObjectNode root = mapper.createObjectNode();
        root.put("name", vertexType.getName());
        if (vertexType.getDescription() != null) {
            root.put("description", vertexType.getDescription());
        }
        if (vertexType.getColor() != null) {
            root.put("color", vertexType.getColor().toString());
        }
        if (vertexType.getForegroundIcon() != null) {
            root.put("foregroundIcon", vertexType.getForegroundIcon().toString());
        }
        if (vertexType.getBackgroundIcon() != null) {
            root.put("backgroundIcon", vertexType.getBackgroundIcon().toString());
        }
        if (vertexType.getDetectionRegex() != null) {
            root.put("detectionRegex", vertexType.getDetectionRegex().pattern());
        }
        if (vertexType.getValidationRegex() != null) {
            root.put("validationRegex", vertexType.getValidationRegex().pattern());
        }
        root.put("properties", vertexType.getProperties().toString());
        root.put("super_type", vertexType.getSuperType().getName());
        root.put("top_level_type", vertexType.getTopLevelType().getName());
        root.put("hierarchy", vertexType.getHierachy());
        mapper.writeValue(out, root);
    } else if (!SchemaTransactionTypeUtilities.getDefaultType().equals(SchemaTransactionTypeUtilities.getType(typeName))) {
        final SchemaTransactionType transactionType = SchemaTransactionTypeUtilities.getType(typeName);
        final ObjectMapper mapper = new ObjectMapper();
        final ObjectNode root = mapper.createObjectNode();
        root.put("name", transactionType.getName());
        if (transactionType.getDescription() != null) {
            root.put("description", transactionType.getDescription());
        }
        if (transactionType.getColor() != null) {
            root.put("color", transactionType.getColor().toString());
        }
        if (transactionType.getStyle() != null) {
            root.put("style", transactionType.getStyle().toString());
        }
        if (transactionType.isDirected() != null) {
            root.put("directed", transactionType.isDirected().toString());
        }
        root.put("properties", transactionType.getProperties().toString());
        root.put("super_type", transactionType.getSuperType().getName());
        root.put("top_level_type", transactionType.getTopLevelType().getName());
        root.put("hierarchy", transactionType.getHierachy());
        mapper.writeValue(out, root);
    } else {
        throw new IllegalArgumentException(String.format("The type '%s' is unknown.", typeName));
    }
}
Also used : SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)30 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)9 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)8 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)6 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)6 Map (java.util.Map)6 SchemaConcept (au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept)5 SchemaVertexTypeUtilities (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexTypeUtilities)5 List (java.util.List)5 Test (org.testng.annotations.Test)5 Graph (au.gov.asd.tac.constellation.graph.Graph)4 AnalyticConcept (au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept)4 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)4 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)4 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)3 SchemaTransactionTypeUtilities (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionTypeUtilities)3 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)3 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)3 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)3