Search in sources :

Example 1 with ConstellationColor

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

the class TableVisualisation method addColumn.

public void addColumn(final String columnName, final int percentWidth) {
    final TableColumn<C, Object> column = new TableColumn<>(columnName);
    tableColumns.put(columnName, column);
    column.prefWidthProperty().bind(table.widthProperty().multiply(percentWidth / 100.0));
    column.setCellValueFactory(cellData -> new SimpleObjectProperty<>(translator.getCellData(cellData.getValue(), columnName)));
    column.setCellFactory(columnData -> new TableCell<C, Object>() {

        @Override
        public void updateItem(final Object item, final boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                this.setText(translator.getCellText(this.getTableRow().getItem(), item, columnName));
                final ConstellationColor color = translator.getCellColor(this.getTableRow().getItem(), item, columnName);
                this.setBackground(new Background(new BackgroundFill(color.getJavaFXColor(), CornerRadii.EMPTY, Insets.EMPTY)));
            }
        }
    });
    column.setSortable(true);
    table.getColumns().add(column);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) TableColumn(javafx.scene.control.TableColumn)

Example 2 with ConstellationColor

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

the class LayerByTimePlugin method read.

@Override
public void read(final GraphReadMethods rg, final PluginInteraction interaction, final PluginParameters parameters) throws PluginException, InterruptedException {
    // We have the dtAttr from the original wg: we should have been passed the label, but never mind.
    // We need to get the label from the original, so we can get the dtAttr for the copy.
    final String dtAttrOrig = parameters.getParameters().get(DATETIME_ATTRIBUTE_PARAMETER_ID).getStringValue();
    if (dtAttrOrig == null) {
        interaction.notify(PluginNotificationLevel.ERROR, "A date-time attribute must be specified.");
        return;
    }
    final int dtAttrOrigId = rg.getAttribute(GraphElementType.TRANSACTION, dtAttrOrig);
    if (dtAttrOrigId == Graph.NOT_FOUND) {
        interaction.notify(PluginNotificationLevel.ERROR, "A valid date-time attribute must be specified.");
        return;
    }
    Graph copy;
    try {
        final Plugin copyGraphPlugin = PluginRegistry.get(InteractiveGraphPluginRegistry.COPY_TO_NEW_GRAPH);
        final PluginParameters copyParams = copyGraphPlugin.createParameters();
        copyParams.getParameters().get(CopyToNewGraphPlugin.NEW_SCHEMA_NAME_PARAMETER_ID).setStringValue(rg.getSchema().getFactory().getName());
        copyParams.getParameters().get(CopyToNewGraphPlugin.COPY_ALL_PARAMETER_ID).setBooleanValue(true);
        copyParams.getParameters().get(CopyToNewGraphPlugin.COPY_KEYS_PARAMETER_ID).setBooleanValue(false);
        PluginExecution.withPlugin(copyGraphPlugin).withParameters(copyParams).executeNow(rg);
        copy = (Graph) copyParams.getParameters().get(CopyToNewGraphPlugin.NEW_GRAPH_OUTPUT_PARAMETER_ID).getObjectValue();
    } catch (final PluginException ex) {
        copy = null;
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    }
    if (copy == null) {
        // The copy failed, drop out now.
        return;
    }
    final Attribute dt = new GraphAttribute(rg, dtAttrOrigId);
    final WritableGraph wgcopy = copy.getWritableGraph("Layer by time", true);
    try {
        final int dtAttr = wgcopy.getAttribute(GraphElementType.TRANSACTION, dt.getName());
        final boolean useIntervals = parameters.getParameters().get(LAYER_BY_PARAMETER_ID).getStringValue().equals(INTERVAL_METHOD);
        final ZonedDateTime[] startEnd = parameters.getParameters().get(DATE_RANGE_PARAMETER_ID).getDateTimeRangeValue().getZonedStartEnd();
        final ZonedDateTime start = startEnd[0];
        final ZonedDateTime end = startEnd[1];
        final boolean isTransactionLayers = parameters.getParameters().get(TRANSACTION_AS_LAYER_PARAMETER_ID).getBooleanValue();
        // Establish new attributes.
        // Create and store graph attributes.
        final LayerName defaultName = new LayerName(Graph.NOT_FOUND, "Default");
        final int timeLayerAttr = wgcopy.addAttribute(GraphElementType.TRANSACTION, LayerNameAttributeDescription.ATTRIBUTE_NAME, LAYER_NAME, "time layer", defaultName, null);
        wgcopy.addAttribute(GraphElementType.GRAPH, IntegerAttributeDescription.ATTRIBUTE_NAME, NLAYERS, "The number of layers to layer by time", 1, null);
        final int txColorAttr = wgcopy.getAttribute(GraphElementType.TRANSACTION, "color");
        final int txGuideline = wgcopy.addAttribute(GraphElementType.TRANSACTION, BooleanAttributeDescription.ATTRIBUTE_NAME, "layer_guideline", "This transaction is a layer guideline", false, null);
        final ConstellationColor guidelineColor = ConstellationColor.getColorValue(0.25F, 0.25F, 0.25F, 1F);
        wgcopy.addAttribute(GraphElementType.VERTEX, IntegerAttributeDescription.ATTRIBUTE_NAME, ORIGINAL_ID_LABEL, "Original Node Id", -1, null);
        final List<Float> values = new ArrayList<>();
        final Map<Integer, List<Float>> remappedLayers = new HashMap<>();
        final Map<Integer, String> displayNames = new HashMap<>();
        if (useIntervals) {
            final int intervalUnit = LAYER_INTERVALS.get(parameters.getParameters().get(UNIT_PARAMETER_ID).getStringValue());
            final int intervalAmount = parameters.getParameters().get(AMOUNT_PARAMETER_ID).getIntegerValue();
            buildIntervals(wgcopy, values, remappedLayers, displayNames, dtAttr, start.toInstant(), end.toInstant(), intervalUnit, intervalAmount);
        } else {
            final int calendarUnit = BIN_CALENDAR_UNITS.get(parameters.getParameters().get(UNIT_PARAMETER_ID).getStringValue());
            final int binAmount = parameters.getParameters().get(AMOUNT_PARAMETER_ID).getIntegerValue();
            buildBins(wgcopy, values, remappedLayers, displayNames, dtAttr, start.toInstant(), end.toInstant(), calendarUnit, binAmount);
        }
        final boolean keepTxColors = parameters.getParameters().get(KEEP_TX_COLORS_PARAMETER_ID).getBooleanValue();
        final boolean drawTxGuides = parameters.getParameters().get(DRAW_TX_GUIDES_PARAMETER_ID).getBooleanValue();
        // Modify the copied graph to show our layers.
        int z = 0;
        float step = getWidth(wgcopy) / values.size();
        for (final Entry<Integer, List<Float>> entry : remappedLayers.entrySet()) {
            for (final Entry<Float, List<Integer>> currentLayer : transactionLayers.entrySet()) {
                if (entry.getValue().contains(currentLayer.getKey())) {
                    for (final int txId : currentLayer.getValue()) {
                        final float origLayer = currentLayer.getKey();
                        int newLayer = 0;
                        if (entry.getValue().contains(origLayer)) {
                            // Overwrite value
                            newLayer = entry.getKey();
                        }
                        final LayerName dn = new LayerName(newLayer, displayNames.get(newLayer));
                        wgcopy.setObjectValue(timeLayerAttr, txId, dn);
                        final float normLayer = newLayer / (remappedLayers.keySet().size() * 1F);
                        if (!keepTxColors) {
                            final Color heatmap = new Color(Color.HSBtoRGB((1 - normLayer) * 2F / 3F, 0.5F, 1));
                            final ConstellationColor color = ConstellationColor.getColorValue(heatmap.getRed() / 255F, heatmap.getGreen() / 255F, heatmap.getBlue() / 255F, 1F);
                            wgcopy.setObjectValue(txColorAttr, txId, color);
                        }
                        if (isTransactionLayers) {
                            transactionsAsLayers(wgcopy, txId, z, step);
                        } else {
                            nodesAsLayers(wgcopy, txId, newLayer);
                        }
                    }
                }
            }
            if (isTransactionLayers) {
                srcVxMap = dstVxMap;
                dstVxMap = new HashMap<>();
                z += step;
            }
        }
        // Remove any outstanding transactions flagged for deletion
        for (int txId = txToDelete.nextSetBit(0); txId >= 0; txId = txToDelete.nextSetBit(txId + 1)) {
            wgcopy.removeTransaction(txId);
        }
        // Get rid of all of the nodes that don't have any transactions.
        // By definition, the duplicates will have transactions between them, including the original layer
        // (because we just deleted transactions that belong in different layers, leaving only the transactions
        // that belong in the original layer).
        final List<Integer> vertices = new ArrayList<>();
        for (int position = 0; position < wgcopy.getVertexCount(); position++) {
            final int vertexId = wgcopy.getVertex(position);
            final int nTx = wgcopy.getVertexTransactionCount(vertexId);
            if (nTx == 0) {
                vertices.add(vertexId);
            }
        }
        vertices.stream().forEach(wgcopy::removeVertex);
        if (drawTxGuides) {
            interaction.setProgress(5, 6, "Draw guide lines", false);
            // We have to do this after the "remove node without transactions" step because we're adding more transactions.
            if (!isTransactionLayers && remappedLayers.keySet().size() > 1) {
                nodeIdToLayers.keySet().stream().forEach(origNodeId -> {
                    int prevNodeId = -1;
                    final BitSet layers = nodeIdToLayers.get(origNodeId);
                    for (int layer = layers.nextSetBit(0); layer >= 0; layer = layers.nextSetBit(layer + 1)) {
                        final int nodeId = layer == 0 ? origNodeId : nodeDups.get(String.format("%s/%s", origNodeId, layer));
                        if (prevNodeId != -1) {
                            final int sTxId = wgcopy.addTransaction(prevNodeId, nodeId, false);
                            wgcopy.setBooleanValue(txGuideline, sTxId, true);
                            wgcopy.setObjectValue(txColorAttr, sTxId, guidelineColor);
                            final LayerName dn = new LayerName(1107, "Guideline");
                            wgcopy.setObjectValue(timeLayerAttr, sTxId, dn);
                        }
                        prevNodeId = nodeId;
                    }
                });
            }
        }
    } finally {
        wgcopy.commit();
    }
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) HashMap(java.util.HashMap) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ArrayList(java.util.ArrayList) ZonedDateTime(java.time.ZonedDateTime) List(java.util.List) ArrayList(java.util.ArrayList) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) LayerName(au.gov.asd.tac.constellation.graph.schema.visual.attribute.objects.LayerName) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) BitSet(java.util.BitSet) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) CopyToNewGraphPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin) SimpleReadPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleReadPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 3 with ConstellationColor

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

the class AttributeEditorPanel method createAttributeTitlePane.

/**
 * Creates individual TitledPane within header title panes.
 *
 * @param attribute the attribute to display.
 * @param values the different values available for the attribute.
 * @param longestTitledWidth the width of the longest title in the pane.
 * @param hidden is the pane currently hidden.
 * @return a new TitledPane.
 */
public TitledPane createAttributeTitlePane(final AttributeData attribute, final Object[] values, final double longestTitledWidth, final boolean hidden) {
    final String attributeTitle = attribute.getAttributeName();
    final int spacing = 5;
    final int buttonSize = 45;
    final GridPane gridPane = new GridPane();
    gridPane.setHgap(spacing);
    final double titleWidth = longestTitledWidth + spacing;
    final AttributeTitledPane attributePane;
    if (!attribute.isKey()) {
        attributePane = new AttributeTitledPane(e -> deleteAttributeAction(attribute.getElementType(), attributeTitle), e -> modifyAttributeAction(attribute));
    } else {
        attributePane = new AttributeTitledPane();
    }
    attributePane.setHidden(hidden);
    gridPane.prefWidthProperty().bind(attributePane.widthProperty());
    if (attribute.getDataType().equals(ZonedDateTimeAttributeDescription.ATTRIBUTE_NAME)) {
        attributePane.addMenuItem("Update time-zone of selection", e -> updateTimeZoneAction(attribute));
    }
    final boolean multiValue = values != null && values.length > 1;
    if (attribute.isKey()) {
        final String colour;
        if (hidden) {
            final ConstellationColor hiddenColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.HIDDEN_ATTRIBUTE_COLOUR, HIDDEN_ATTRIBUTE_COLOUR));
            final ConstellationColor keyColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.PRIMARY_KEY_ATTRIBUTE_COLOUR, PRIMARY_KEY_ATTRIBUTE_COLOUR));
            colour = (ConstellationColor.getColorValue(hiddenColour.getRed() * 0.5F + keyColour.getRed() * 0.5F, hiddenColour.getGreen() * 0.5F + keyColour.getGreen() * 0.5F, hiddenColour.getBlue() * 0.5F + keyColour.getBlue() * 0.5F, 1F)).getHtmlColor();
        } else {
            colour = prefs.get(AttributePreferenceKey.PRIMARY_KEY_ATTRIBUTE_COLOUR, PRIMARY_KEY_ATTRIBUTE_COLOUR);
        }
        attributePane.setStyle(JavafxStyleManager.CSS_BASE_STYLE_PREFIX + colour + SeparatorConstants.SEMICOLON);
    } else if (!attribute.isSchema()) {
        final String colour;
        if (hidden) {
            final ConstellationColor hiddenColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.HIDDEN_ATTRIBUTE_COLOUR, HIDDEN_ATTRIBUTE_COLOUR));
            final ConstellationColor customColour = ConstellationColor.fromHtmlColor(prefs.get(AttributePreferenceKey.CUSTOM_ATTRIBUTE_COLOUR, CUSTOM_ATTRIBUTE_COLOUR));
            colour = (ConstellationColor.getColorValue(hiddenColour.getRed() * 0.5F + customColour.getRed() * 0.5F, hiddenColour.getGreen() * 0.5F + customColour.getGreen() * 0.5F, hiddenColour.getBlue() * 0.5F + customColour.getBlue() * 0.5F, 1F)).getHtmlColor();
        } else {
            colour = prefs.get(AttributePreferenceKey.CUSTOM_ATTRIBUTE_COLOUR, CUSTOM_ATTRIBUTE_COLOUR);
        }
        attributePane.setStyle(JavafxStyleManager.CSS_BASE_STYLE_PREFIX + colour + SeparatorConstants.SEMICOLON);
    } else if (hidden) {
        final String hiddenColour = prefs.get(AttributePreferenceKey.HIDDEN_ATTRIBUTE_COLOUR, HIDDEN_ATTRIBUTE_COLOUR);
        attributePane.setStyle(JavafxStyleManager.CSS_BASE_STYLE_PREFIX + hiddenColour + SeparatorConstants.SEMICOLON);
    } else {
        final String schemaColour = prefs.get(AttributePreferenceKey.SCHEMA_ATTRIBUTE_COLOUR, SCHEMA_ATTRIBUTE_COLOUR);
        attributePane.setStyle(JavafxStyleManager.CSS_BASE_STYLE_PREFIX + schemaColour + SeparatorConstants.SEMICOLON);
    }
    if (!multiValue) {
        attributePane.setCollapsible(false);
    } else {
        createMultiValuePane(attribute, attributePane, values);
    }
    final Text attributeTitleText = createAttributeTitleLabel(attributeTitle);
    attributeTitleText.getStyleClass().add("attributeName");
    attributeTitleText.setTextAlignment(TextAlignment.RIGHT);
    // Value TextField
    final Node attributeValueNode = createAttributeValueNode(values, attribute, attributePane, multiValue);
    // Edit Button
    final Button editButton = new Button("Edit");
    editButton.setAlignment(Pos.CENTER);
    editButton.setMinWidth(buttonSize);
    final AttributeValueEditorFactory<?> editorFactory = AttributeValueEditorFactory.getEditFactory(attribute.getDataType());
    if (editorFactory == null || values == null) {
        editButton.setDisable(true);
    } else {
        editButton.setOnMouseClicked(event -> getEditValueHandler(attribute, editorFactory, values));
        attributeValueNode.setOnMouseClicked(event -> {
            if (event.getButton() == MouseButton.PRIMARY && event.isStillSincePress()) {
                getEditValueHandler(attribute, editorFactory, values);
            }
        });
    }
    // If we don't do anything here, right-clicking on the Node will produce two context menus:
    // the one the Node has by default, and the one we added to the AttributeTitledPane.
    // We'll consume the context menu event so it doesn't bubble up to the TitledPane.
    // Ditto for the button.
    attributeValueNode.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, Event::consume);
    editButton.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, Event::consume);
    // Title
    final ColumnConstraints titleConstraint = new ColumnConstraints(titleWidth);
    titleConstraint.setHalignment(HPos.RIGHT);
    // Value
    final ColumnConstraints valueConstraint = new ColumnConstraints();
    valueConstraint.setHalignment(HPos.CENTER);
    valueConstraint.setHgrow(Priority.ALWAYS);
    valueConstraint.setFillWidth(true);
    // EditButton
    final ColumnConstraints editConstraint = new ColumnConstraints(buttonSize);
    editConstraint.setHalignment(HPos.RIGHT);
    gridPane.getColumnConstraints().addAll(titleConstraint, valueConstraint, editConstraint);
    gridPane.add(attributeTitleText, 0, 0);
    gridPane.add(attributeValueNode, 1, 0);
    gridPane.add(editButton, 2, 0);
    attributePane.setAlignment(Pos.CENTER_RIGHT);
    attributePane.setGraphic(gridPane);
    attributePane.setTooltip(new Tooltip(attribute.getAttributeDescription()));
    attributePane.setExpanded(attribute.isKeepExpanded());
    attributePane.setOnDragDetected(event -> {
        final Dragboard db = attributePane.startDragAndDrop(TransferMode.COPY);
        final ClipboardContent content = new ClipboardContent();
        final String data = String.format("%s:%s", attribute.getElementType().getShortLabel(), attribute.getAttributeName());
        content.put(ATTRIBUTE_NAME_DATA_FORMAT, data);
        content.putString(String.format("Attribute.Name=%s", data));
        db.setContent(content);
        event.consume();
    });
    return attributePane;
}
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) GridPane(javafx.scene.layout.GridPane) ColumnConstraints(javafx.scene.layout.ColumnConstraints) ClipboardContent(javafx.scene.input.ClipboardContent) Node(javafx.scene.Node) Tooltip(javafx.scene.control.Tooltip) Text(javafx.scene.text.Text) MouseButton(javafx.scene.input.MouseButton) Button(javafx.scene.control.Button) ToggleButton(javafx.scene.control.ToggleButton) Event(javafx.event.Event) KeyEvent(javafx.scene.input.KeyEvent) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) MouseEvent(javafx.scene.input.MouseEvent) ActionEvent(javafx.event.ActionEvent) Dragboard(javafx.scene.input.Dragboard)

Example 4 with ConstellationColor

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

the class ColorPropertyEditor method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    if ("OK".equals(e.getActionCommand())) {
        final Color color = chooser.getColor();
        final ConstellationColor cv = ConstellationColor.fromJavaColor(color);
        setValue(cv);
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor)

Example 5 with ConstellationColor

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

the class ColorPropertyEditor method paintValue.

@Override
public void paintValue(final Graphics g, final Rectangle r) {
    final ConstellationColor cv = (ConstellationColor) getValue();
    if (cv != null) {
        final Color gcolor = g.getColor();
        final Color color = new Color(cv.getRed(), cv.getGreen(), cv.getBlue(), cv.getAlpha());
        int px = 0;
        g.drawRect(r.x, r.y + r.height / 2 - 5, 10, 10);
        g.setColor(color);
        g.fillRect(r.x + 1, r.y + r.height / 2 - 4, 9, 9);
        px = 18;
        final String text = cv.getName() != null ? cv.getName() : String.format("r=%s g=%s b=%s a=%s", formatFloat(cv.getRed()), formatFloat(cv.getGreen()), formatFloat(cv.getBlue()), formatFloat(cv.getAlpha()));
        ((Graphics2D) g).setRenderingHints(IconUtilities.getHints());
        final FontMetrics fm = g.getFontMetrics();
        g.setColor(gcolor);
        g.drawString(text, r.x + px, r.y + (r.height - fm.getHeight()) / 2 + fm.getAscent());
    } else {
        final int px = 0;
        ((Graphics2D) g).setRenderingHints(IconUtilities.getHints());
        final FontMetrics fm = g.getFontMetrics();
        g.setColor(MULTIPLE_COLOR);
        g.drawString("«multiple selection»", r.x + px, r.y + (r.height - fm.getHeight()) / 2 + fm.getAscent());
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) FontMetrics(java.awt.FontMetrics) Color(java.awt.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graphics2D(java.awt.Graphics2D)

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