modules/controls/src/main/java/javafx/scene/control/skin/ColorPalette.java

Print this page




 170             focusedSquare.requestFocus();
 171         }
 172 
 173         hoverSquare.rectangle.setFill(focusedSquare.rectangle.getFill());
 174 
 175         Bounds b = square.localToScene(square.getLayoutBounds());
 176 
 177         double x = b.getMinX();
 178         double y = b.getMinY();
 179 
 180         double xAdjust;
 181         double scaleAdjust = hoverSquare.getScaleX() == 1.0 ? 0 : hoverSquare.getWidth() / 4.0;
 182 
 183         if (colorPicker.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT) {
 184             x = focusedSquare.getLayoutX();
 185             xAdjust = -focusedSquare.getWidth() + scaleAdjust;
 186         } else {
 187             xAdjust = focusedSquare.getWidth() / 2.0 + scaleAdjust;
 188         }
 189 
 190         hoverSquare.setLayoutX(snapPosition(x) - xAdjust);
 191         hoverSquare.setLayoutY(snapPosition(y) - focusedSquare.getHeight() / 2.0 + (hoverSquare.getScaleY() == 1.0 ? 0 : focusedSquare.getHeight() / 4.0));
 192     }
 193 
 194     private void buildCustomColors() {
 195         final ObservableList<Color> customColors = colorPicker.getCustomColors();
 196         customColorNumber = customColors.size();
 197 
 198         customColorGrid.getChildren().clear();
 199         if (customColors.isEmpty()) {
 200             customColorLabel.setVisible(false);
 201             customColorLabel.setManaged(false);
 202             customColorGrid.setVisible(false);
 203             customColorGrid.setManaged(false);
 204             return;
 205         } else {
 206             customColorLabel.setVisible(true);
 207             customColorLabel.setManaged(true);
 208             customColorGrid.setVisible(true);
 209             customColorGrid.setManaged(true);
 210             if (contextMenu == null) {
 211                 MenuItem item = new MenuItem(getColorPickerString("removeColor"));




 170             focusedSquare.requestFocus();
 171         }
 172 
 173         hoverSquare.rectangle.setFill(focusedSquare.rectangle.getFill());
 174 
 175         Bounds b = square.localToScene(square.getLayoutBounds());
 176 
 177         double x = b.getMinX();
 178         double y = b.getMinY();
 179 
 180         double xAdjust;
 181         double scaleAdjust = hoverSquare.getScaleX() == 1.0 ? 0 : hoverSquare.getWidth() / 4.0;
 182 
 183         if (colorPicker.getEffectiveNodeOrientation() == NodeOrientation.RIGHT_TO_LEFT) {
 184             x = focusedSquare.getLayoutX();
 185             xAdjust = -focusedSquare.getWidth() + scaleAdjust;
 186         } else {
 187             xAdjust = focusedSquare.getWidth() / 2.0 + scaleAdjust;
 188         }
 189 
 190         hoverSquare.setLayoutX(snapPositionX(x) - xAdjust);
 191         hoverSquare.setLayoutY(snapPositionY(y) - focusedSquare.getHeight() / 2.0 + (hoverSquare.getScaleY() == 1.0 ? 0 : focusedSquare.getHeight() / 4.0));
 192     }
 193 
 194     private void buildCustomColors() {
 195         final ObservableList<Color> customColors = colorPicker.getCustomColors();
 196         customColorNumber = customColors.size();
 197 
 198         customColorGrid.getChildren().clear();
 199         if (customColors.isEmpty()) {
 200             customColorLabel.setVisible(false);
 201             customColorLabel.setManaged(false);
 202             customColorGrid.setVisible(false);
 203             customColorGrid.setManaged(false);
 204             return;
 205         } else {
 206             customColorLabel.setVisible(true);
 207             customColorLabel.setManaged(true);
 208             customColorGrid.setVisible(true);
 209             customColorGrid.setManaged(true);
 210             if (contextMenu == null) {
 211                 MenuItem item = new MenuItem(getColorPickerString("removeColor"));