Search in sources :

Example 46 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class CreateVertexTypePlugin method edit.

@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException {
    final String name = parameters.getStringValue(NAME_PARAMETER_ID);
    if (name == null) {
        throw new IllegalArgumentException("A name must be supplied");
    }
    final String description = parameters.getStringValue(DESCRIPTION_PARAMETER_ID);
    if (description == null) {
        throw new IllegalArgumentException("A description must be supplied");
    }
    final ConstellationColor color = parameters.getColorValue(COLOR_PARAMETER_ID);
    final String fgIconName = parameters.getStringValue(FG_ICON_PARAMETER_ID);
    final ConstellationIcon foregroundIcon = IconManager.getIcon(fgIconName);
    final String bgIconName = parameters.getStringValue(BG_ICON_PARAMETER_ID);
    final ConstellationIcon backgroundIcon = IconManager.getIcon(bgIconName);
    final String dregex = parameters.getStringValue(DETECTION_REGEX_PARAMETER_ID);
    final Pattern detectionRegex = dregex != null ? Pattern.compile(dregex, Pattern.CASE_INSENSITIVE) : null;
    final String vregex = parameters.getStringValue(VALIDATION_REGEX_PARAMETER_ID);
    final Pattern validationRegex = vregex != null ? Pattern.compile(vregex, Pattern.CASE_INSENSITIVE) : null;
    final String stype = parameters.getStringValue(SUPER_TYPE_PARAMETER_ID);
    final SchemaVertexType superType = stype != null ? SchemaVertexTypeUtilities.getType(stype) : null;
    final String otype = parameters.getStringValue(OVERRIDDEN_TYPE_PARAMETER_ID);
    final SchemaVertexType overridenType = otype != null ? SchemaVertexTypeUtilities.getType(otype) : null;
    final boolean incomplete = parameters.getBooleanValue(INCOMPLETE_PARAMETER_ID);
    final Map<String, String> properties = null;
    final SchemaVertexType svt = new SchemaVertexType(name, description, color, foregroundIcon, backgroundIcon, detectionRegex, validationRegex, superType, overridenType, properties, incomplete);
    SchemaVertexTypeUtilities.addCustomType(svt, true);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Pattern(java.util.regex.Pattern) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) ConstellationIcon(au.gov.asd.tac.constellation.utilities.icon.ConstellationIcon)

Example 47 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class Scatter3dArranger method getFloatValueFromObject.

private float getFloatValueFromObject(final Object attributeValue, final boolean logarithmic) {
    if (attributeValue == null) {
        return 0.0F;
    }
    if (attributeValue instanceof Float) {
        return scaleValue((float) attributeValue, logarithmic);
    }
    if (attributeValue instanceof Double) {
        return scaleValue((float) attributeValue, logarithmic);
    }
    if (attributeValue instanceof String) {
        String val = (String) attributeValue;
        float finalVal = 0.0F;
        float multiplier = 1;
        for (int i = 0; i < val.length(); i++) {
            char ch = val.charAt(i);
            float chVal = (float) ch;
            finalVal += ((float) chVal) * multiplier;
            multiplier /= 26;
        }
        return scaleValue(finalVal, logarithmic);
    }
    if (attributeValue instanceof Integer) {
        float ret = (Integer) attributeValue;
        return scaleValue(ret, logarithmic);
    }
    if (attributeValue instanceof ConstellationColor) {
        ConstellationColor color = (ConstellationColor) attributeValue;
        float red = color.getRed() / 256;
        float green = color.getGreen() / 256;
        float blue = color.getBlue() / 256;
        return scaleValue((red + green + blue) * 100, logarithmic);
    }
    if (attributeValue instanceof ZonedDateTime) {
        ZonedDateTime c = (ZonedDateTime) attributeValue;
        float year = c.getYear();
        float month = c.getMonthValue();
        float monthDay = c.getDayOfMonth();
        float hour = c.getHour();
        float minute = c.getMinute();
        return scaleValue((year - 2010) + month / 12 + monthDay / (366) + hour / (366 * 24) + minute / (366 * 24 * 60), logarithmic);
    }
    if (attributeValue instanceof RawData) {
        String s = ((RawData) attributeValue).toString();
        return getFloatValueFromObject(s, logarithmic);
    }
    return 0.0F;
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) RawData(au.gov.asd.tac.constellation.graph.schema.analytic.attribute.objects.RawData) ZonedDateTime(java.time.ZonedDateTime)

Example 48 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class AttributeEditorPanel method createColourMenuItem.

private MenuItem createColourMenuItem(final String itemName, final String correspondingPreference, final Color color) {
    final HBox schemaMenuNode = new HBox(CELL_ITEM_SPACING);
    final MenuItem schemaMenuItem = new MenuItem(null, schemaMenuNode);
    final Rectangle schemaMenuRect = new Rectangle(20, 20);
    final Text schemaMenuText = new Text(itemName);
    schemaMenuText.setStyle("-fx-fill: white; -fx-font-smoothing-type:lcd;");
    schemaMenuNode.getChildren().addAll(schemaMenuRect, schemaMenuText);
    schemaMenuRect.setFill(color);
    schemaMenuRect.setStroke(Color.LIGHTGREY);
    schemaMenuItem.setOnAction(e -> {
        final EditOperation editOperation = value -> prefs.put(correspondingPreference, ((ConstellationColor) value).getHtmlColor());
        // return type of createEditor will actually be AbstractEditor<ConstellationColor>
        @SuppressWarnings("unchecked") final AbstractEditor<ConstellationColor> editor = ((AbstractEditorFactory<ConstellationColor>) AttributeValueEditorFactory.getEditFactory(ColorAttributeDescription.ATTRIBUTE_NAME)).createEditor(editOperation, String.format("for %s", itemName), ConstellationColor.fromFXColor(color));
        final AttributeEditorDialog dialog = new AttributeEditorDialog(false, editor);
        dialog.showDialog();
    });
    return schemaMenuItem;
}
Also used : HPos(javafx.geometry.HPos) StackPane(javafx.scene.layout.StackPane) SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) ScrollPane(javafx.scene.control.ScrollPane) Map(java.util.Map) ZonedDateTimeAttributeDescription(au.gov.asd.tac.constellation.graph.attribute.ZonedDateTimeAttributeDescription) ZoneOffset(java.time.ZoneOffset) ValueValidator(au.gov.asd.tac.constellation.graph.attribute.interaction.ValueValidator) UserInterfaceIconProvider(au.gov.asd.tac.constellation.utilities.icon.UserInterfaceIconProvider) EditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.EditOperation) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) Event(javafx.event.Event) Set(java.util.Set) Rectangle(javafx.scene.shape.Rectangle) KeyEvent(javafx.scene.input.KeyEvent) ZoneId(java.time.ZoneId) Platform(javafx.application.Platform) PluginInfo(au.gov.asd.tac.constellation.plugins.PluginInfo) AbstractEditorFactory(au.gov.asd.tac.constellation.views.attributeeditor.editors.AbstractEditorFactory) ModifyAttributeEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.ModifyAttributeEditOperation) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) AttributeValueTranslator(au.gov.asd.tac.constellation.graph.attribute.interaction.AttributeValueTranslator) StringProperty(javafx.beans.property.StringProperty) NbPreferences(org.openide.util.NbPreferences) CreateAttributeEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.CreateAttributeEditOperation) GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) MouseButton(javafx.scene.input.MouseButton) AttributeValueEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.AttributeValueEditOperation) ColumnConstraints(javafx.scene.layout.ColumnConstraints) ColorAttributeDescription(au.gov.asd.tac.constellation.graph.schema.visual.attribute.ColorAttributeDescription) AttributeValueEditorFactory(au.gov.asd.tac.constellation.views.attributeeditor.editors.AttributeValueEditorFactory) FXCollections(javafx.collections.FXCollections) TooltipPane(au.gov.asd.tac.constellation.utilities.tooltip.TooltipPane) TreeSet(java.util.TreeSet) TransferMode(javafx.scene.input.TransferMode) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) Graph(au.gov.asd.tac.constellation.graph.Graph) Dragboard(javafx.scene.input.Dragboard) DefaultGetter(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.DefaultGetter) PluginTags(au.gov.asd.tac.constellation.plugins.templates.PluginTags) TextAlignment(javafx.scene.text.TextAlignment) StringUtilities(au.gov.asd.tac.constellation.utilities.text.StringUtilities) GridPane(javafx.scene.layout.GridPane) Color(javafx.scene.paint.Color) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) TitledPane(javafx.scene.control.TitledPane) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Node(javafx.scene.Node) SchemaConcept(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConcept) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) Preferences(java.util.prefs.Preferences) Menu(javafx.scene.control.Menu) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) SelectionMode(javafx.scene.control.SelectionMode) TreeMap(java.util.TreeMap) ImageView(javafx.scene.image.ImageView) ObservableValue(javafx.beans.value.ObservableValue) Button(javafx.scene.control.Button) TimeZoneEditorFactory(au.gov.asd.tac.constellation.views.attributeeditor.editors.TimeZoneEditorFactory) Pos(javafx.geometry.Pos) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ListCell(javafx.scene.control.ListCell) SimpleEditPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin) CheckMenuItem(javafx.scene.control.CheckMenuItem) PluginType(au.gov.asd.tac.constellation.plugins.PluginType) VBox(javafx.scene.layout.VBox) PrimaryKeyEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyEditOperation) KeyCombination(javafx.scene.input.KeyCombination) ContextMenu(javafx.scene.control.ContextMenu) AbstractAttributeInteraction(au.gov.asd.tac.constellation.graph.attribute.interaction.AbstractAttributeInteraction) PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) SeparatorConstants(au.gov.asd.tac.constellation.utilities.text.SeparatorConstants) TimeZone(java.util.TimeZone) Collection(java.util.Collection) Text(javafx.scene.text.Text) Priority(javafx.scene.layout.Priority) List(java.util.List) ToggleButton(javafx.scene.control.ToggleButton) DataFormat(javafx.scene.input.DataFormat) Entry(java.util.Map.Entry) ClipboardContent(javafx.scene.input.ClipboardContent) JavafxStyleManager(au.gov.asd.tac.constellation.utilities.javafx.JavafxStyleManager) ListSelectionEditor(au.gov.asd.tac.constellation.views.attributeeditor.editors.ListSelectionEditorFactory.ListSelectionEditor) UpdateTimeZonePlugin(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.UpdateTimeZonePlugin) ListView(javafx.scene.control.ListView) AttributeEditor(au.gov.asd.tac.constellation.views.attributeeditor.editors.AttributeEditorFactory.AttributeEditor) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) ClipboardUtilities(au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.ClipboardUtilities) HashSet(java.util.HashSet) FontUtilities(au.gov.asd.tac.constellation.utilities.font.FontUtilities) Insets(javafx.geometry.Insets) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) Tooltip(javafx.scene.control.Tooltip) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute) SchemaConceptUtilities(au.gov.asd.tac.constellation.graph.schema.concept.SchemaConceptUtilities) KeyCode(javafx.scene.input.KeyCode) PrimaryKeyDefaultGetter(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyDefaultGetter) MenuBar(javafx.scene.control.MenuBar) AbstractEditor(au.gov.asd.tac.constellation.views.attributeeditor.editors.AbstractEditorFactory.AbstractEditor) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) AttributeEditorFactory(au.gov.asd.tac.constellation.views.attributeeditor.editors.AttributeEditorFactory) ListSelectionEditorFactory(au.gov.asd.tac.constellation.views.attributeeditor.editors.ListSelectionEditorFactory) ActionEvent(javafx.event.ActionEvent) Collections(java.util.Collections) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) HBox(javafx.scene.layout.HBox) Rectangle(javafx.scene.shape.Rectangle) CheckMenuItem(javafx.scene.control.CheckMenuItem) MenuItem(javafx.scene.control.MenuItem) Text(javafx.scene.text.Text) AbstractEditorFactory(au.gov.asd.tac.constellation.views.attributeeditor.editors.AbstractEditorFactory) EditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.EditOperation) ModifyAttributeEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.ModifyAttributeEditOperation) CreateAttributeEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.CreateAttributeEditOperation) AttributeValueEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.AttributeValueEditOperation) PrimaryKeyEditOperation(au.gov.asd.tac.constellation.views.attributeeditor.editors.operations.PrimaryKeyEditOperation)

Example 49 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class AdvancedSearchPlugin method searchAsColor.

/**
 * This function checks to see if a graph elements color attribute matches
 * the criteria specified by the ColourCriteriaValues.
 *
 * @param values the color criteriaValues
 * @param attributeInt the int of the attribute
 * @param currElement the currentElement
 * @param graph the current graph
 * @return
 */
private boolean searchAsColor(final FindCriteriaValues values, final int attributeInt, final int currElement, final GraphWriteMethods graph) {
    final ColourCriteriaValues colorValues = (ColourCriteriaValues) values;
    final ConstellationColor color = graph.getObjectValue(attributeInt, currElement);
    boolean matches = false;
    // if the color of the attribute matches the users color matches = true
    if (colorValues.getFilter().equals(IS) && colorValues.getColorValue().equals(color)) {
        matches = true;
    // if the color of the attribute doesnt match the users color matches = true
    } else if (colorValues.getFilter().equals(IS_NOT) && !colorValues.getColorValue().equals(color)) {
        matches = true;
    }
    return matches;
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) ColourCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues)

Example 50 with ConstellationColor

use of au.gov.asd.tac.constellation.utilities.color.ConstellationColor in project constellation by constellation-app.

the class NebulaDataObject method open.

@Override
public void open() {
    final Properties props = new Properties();
    try (final FileReader reader = new FileReader(getPrimaryFile().getPath())) {
        props.load(reader);
    } catch (final IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    }
    // Generate a color for the nebula marker.
    // First, see if the user has specified a color in the nebula file.
    Color c = null;
    final String cname = props.getProperty("colour") != null ? props.getProperty("colour") : props.getProperty("color");
    if (cname != null) {
        ConstellationColor cv = ConstellationColor.fromHtmlColor(cname);
        if (cv == null) {
            cv = ConstellationColor.getColorValue(cname);
        }
        if (cv != null) {
            c = cv.getJavaColor();
        }
    }
    // Therefore, we track the random colors as we create them,
    if (c == null) {
        c = NEBULA_COLOR.get(getPrimaryFile().getPath());
    }
    // Otherwise, create a random color for this nebula.
    if (c == null) {
        final float h = new SecureRandom().nextFloat();
        c = Color.getHSBColor(h, 0.5F, 0.95F);
        NEBULA_COLOR.put(getPrimaryFile().getPath(), c);
    }
    for (final Enumeration<DataObject> i = getFolder().children(); i.hasMoreElements(); ) {
        final DataObject dobj = i.nextElement();
        if (dobj instanceof GraphDataObject) {
            final GraphDataObject gdo = (GraphDataObject) dobj;
            gdo.setNebulaDataObject(this);
            gdo.setNebulaColor(c);
            GraphOpener.getDefault().openGraph(gdo);
        }
    }
    // Because we haven't registered an editor, a TopComponent won't open for this file (which is good).
    // However, the recent files stuff works by watching for opening TopComponents (which is bad).
    // So, do it manually.
    // FileObject.getPath() returns a path containing "/"; we need to convert it to local separators for RecentFiles.
    final String path = new File(getPrimaryFile().getPath()).getAbsolutePath();
    RecentFiles.addFile(path);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) MultiDataObject(org.openide.loaders.MultiDataObject) DataObject(org.openide.loaders.DataObject) GraphDataObject(au.gov.asd.tac.constellation.graph.file.GraphDataObject) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) GraphDataObject(au.gov.asd.tac.constellation.graph.file.GraphDataObject) SecureRandom(java.security.SecureRandom) FileReader(java.io.FileReader) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File)

Aggregations

ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)67 ArrayList (java.util.ArrayList)13 Test (org.testng.annotations.Test)11 Color (java.awt.Color)9 BitSet (java.util.BitSet)9 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)8 IOException (java.io.IOException)7 Graph (au.gov.asd.tac.constellation.graph.Graph)6 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)6 List (java.util.List)6 File (java.io.File)5 HashMap (java.util.HashMap)5 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)4 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)4 Camera (au.gov.asd.tac.constellation.utilities.camera.Camera)4 Matrix44f (au.gov.asd.tac.constellation.utilities.graphics.Matrix44f)4 VisualAccess (au.gov.asd.tac.constellation.utilities.visual.VisualAccess)4 GLRenderableUpdateTask (au.gov.asd.tac.constellation.visual.opengl.renderer.GLRenderable.GLRenderableUpdateTask)4 TextureUnits (au.gov.asd.tac.constellation.visual.opengl.renderer.TextureUnits)4