public void updateSelection(Color color) { setFocusedSquare(null); for (ColorSquare c : colorPickerGrid.getSquares()) { if (c.rectangle.getFill().equals(color)) { setFocusedSquare(c); return; } } // check custom colors for (Node n : customColorGrid.getChildren()) { ColorSquare c = (ColorSquare) n; if (c.rectangle.getFill().equals(color)) { setFocusedSquare(c); return; } } }
if (!dragDetected && event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 1) { if (!isEmpty) { Color fill = (Color) rectangle.getFill(); colorPicker.setValue(fill); colorPicker.fireEvent(new ActionEvent());
(int) t.getY() / (SQUARE_SIZE + 1), NUM_OF_ROWS - 1); int index = xIndex + yIndex * NUM_OF_COLUMNS; colorPicker.setValue((Color) squares.get(index).rectangle.getFill()); updateSelection(colorPicker.getValue()); });
private void setFocusedSquare(ColorSquare square) { hoverSquare.setVisible(square != null); if (square == focusedSquare) { return; } focusedSquare = square; hoverSquare.setVisible(focusedSquare != null); if (focusedSquare == null) { return; } if (!focusedSquare.isFocused()) { focusedSquare.requestFocus(); } hoverSquare.rectangle.setFill(focusedSquare.rectangle.getFill()); Bounds b = square.localToScene(square.getLayoutBounds()); double x = b.getMinX(); double y = b.getMinY(); double xAdjust; double scaleAdjust = hoverSquare.getScaleX() == 1.0 ? 0 : hoverSquare.getWidth() / 4.0; if (colorPicker.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT) { x = focusedSquare.getLayoutX(); xAdjust = -focusedSquare.getWidth() + scaleAdjust; } else { xAdjust = focusedSquare.getWidth() / 2.0 + scaleAdjust; } hoverSquare.setLayoutX(snapPosition(x) - xAdjust); hoverSquare.setLayoutY(snapPosition(y) - focusedSquare.getHeight() / 2.0 + (hoverSquare.getScaleY() == 1.0 ? 0 : focusedSquare .getHeight() / 4.0)); }
/** * {@inheritDoc} */ @Override public Paint getTextBackground() { return _rect.getFill(); }
public void updateSelection(Color color) { setFocusedSquare(null); for (ColorSquare c : colorPickerGrid.getSquares()) { if (c.rectangle.getFill().equals(color)) { setFocusedSquare(c); return; } } // check custom colors for (Node n : customColorGrid.getChildren()) { ColorSquare c = (ColorSquare) n; if (c.rectangle.getFill().equals(color)) { setFocusedSquare(c); return; } } }
}); hover.visibleProperty().addListener((obs2, ov, nv) -> { if (nv && rectH.getFill().equals(Color.TRANSPARENT)) { Platform.runLater(() -> rectH.setFill(redLine));
if (!dragDetected && event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 1) { if (!isEmpty) { Color fill = (Color) rectangle.getFill(); colorPicker.setValue(fill); colorPicker.fireEvent(new ActionEvent());
this.paint.set(t.getFill()); } else { this.paint.set(null);
this.paint.set(t.getFill()); } else { this.paint.set(null);
(int) t.getY() / (SQUARE_SIZE + 1), NUM_OF_ROWS - 1); int index = xIndex + yIndex * NUM_OF_COLUMNS; colorPicker.setValue((Color) squares.get(index).rectangle.getFill()); updateSelection(colorPicker.getValue()); });
private void setFocusedSquare(ColorSquare square) { hoverSquare.setVisible(square != null); if (square == focusedSquare) { return; } focusedSquare = square; hoverSquare.setVisible(focusedSquare != null); if (focusedSquare == null) { return; } if (!focusedSquare.isFocused()) { focusedSquare.requestFocus(); } hoverSquare.rectangle.setFill(focusedSquare.rectangle.getFill()); Bounds b = square.localToScene(square.getLayoutBounds()); double x = b.getMinX(); double y = b.getMinY(); double xAdjust; double scaleAdjust = hoverSquare.getScaleX() == 1.0 ? 0 : hoverSquare.getWidth() / 4.0; if (colorPicker.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT) { x = focusedSquare.getLayoutX(); xAdjust = -focusedSquare.getWidth() + scaleAdjust; } else { xAdjust = focusedSquare.getWidth() / 2.0 + scaleAdjust; } hoverSquare.setLayoutX(snapPosition(x) - xAdjust); hoverSquare.setLayoutY(snapPosition(y) - focusedSquare.getHeight() / 2.0 + (hoverSquare.getScaleY() == 1.0 ? 0 : focusedSquare .getHeight() / 4.0)); }
this.paint.set(linearGradientPreview.getFill()); };
this.paint.set(radialGradientPreview.getFill()); };
this.paint.set(radialGradientPreview.getFill()); };
this.paint.set(linearGradientPreview.getFill()); };