use of javafx.geometry.Bounds in project fxexperience2 by EricCanull.
the class ColorPickerControl method initialize.
/**
* Private
*/
private void initialize() {
final FXMLLoader loader = new FXMLLoader();
//NOI18N
loader.setLocation(ColorPickerControl.class.getResource("/fxml/FXMLColorPicker.fxml"));
loader.setController(this);
loader.setRoot(this);
try {
loader.load();
} catch (IOException ex) {
Logger.getLogger(ColorPickerControl.class.getName()).log(Level.SEVERE, null, ex);
}
assert hue_slider != null;
assert picker_region != null;
assert hue_textfield != null;
assert saturation_textfield != null;
assert brightness_textfield != null;
assert alpha_textfield != null;
assert red_textfield != null;
assert green_textfield != null;
assert blue_textfield != null;
assert alpha_slider != null;
// Make the grad for hue slider
hue_slider.setStyle(makeHueSliderCSS());
// Investigate why height + width listeners do not work
// Indeed, the picker_handle_stackpane bounds may still be null at this point
// UPDATE BELOW TO BE CALLED ONCE ONLY AT DISPLAY TIME
picker_region.boundsInParentProperty().addListener((ov, oldb, newb) -> {
picker_scrollpane.setHvalue(0.5);
picker_scrollpane.setVvalue(0.5);
// Init time only
final Paint paint = paintPickerController.getPaintProperty();
if (paint instanceof Color) {
updateUI((Color) paint);
} else if (paint instanceof LinearGradient || paint instanceof RadialGradient) {
final GradientPicker gradientPicker = paintPickerController.getGradientPicker();
final GradientPickerStop gradientPickerStop = gradientPicker.getSelectedStop();
// Update the color preview with the color of the selected stop
if (gradientPickerStop != null) {
updateUI(gradientPickerStop.getColor());
}
}
});
final ChangeListener<Boolean> onHSBFocusedChange = (ov, oldValue, newValue) -> {
if (newValue == false) {
// Update UI
final Color color = updateUI_OnHSBChange();
// Update model
setPaintProperty(color);
}
};
final ChangeListener<Boolean> onRGBFocusedChange = (ov, oldValue, newValue) -> {
if (newValue == false) {
// Update UI
final Color color = updateUI_OnRGBChange();
// Update model
setPaintProperty(color);
}
};
final ChangeListener<Boolean> onHexaFocusedChange = (ov, oldValue, newValue) -> {
if (newValue == false) {
try {
// Update UI
final Color color = updateUI_OnHexaChange();
// Update model
setPaintProperty(color);
} catch (IllegalArgumentException iae) {
handleHexaException();
}
}
};
// TextField ON FOCUS LOST event handler
hue_textfield.focusedProperty().addListener(onHSBFocusedChange);
saturation_textfield.focusedProperty().addListener(onHSBFocusedChange);
brightness_textfield.focusedProperty().addListener(onHSBFocusedChange);
alpha_textfield.focusedProperty().addListener(onHSBFocusedChange);
red_textfield.focusedProperty().addListener(onRGBFocusedChange);
green_textfield.focusedProperty().addListener(onRGBFocusedChange);
blue_textfield.focusedProperty().addListener(onRGBFocusedChange);
hexa_textfield.focusedProperty().addListener(onHexaFocusedChange);
// Slider ON VALUE CHANGE event handler
hue_slider.valueProperty().addListener((ov, oldValue, newValue) -> {
if (updating == true) {
return;
}
double hue = newValue.doubleValue();
// retrieve HSB TextFields values
double saturation = Double.valueOf(saturation_textfield.getText()) / 100.0;
double brightness = Double.valueOf(brightness_textfield.getText()) / 100.0;
double alpha = Double.valueOf(alpha_textfield.getText());
// Update UI
final Color color = updateUI(hue, saturation, brightness, alpha);
// Update model
setPaintProperty(color);
});
alpha_slider.valueProperty().addListener((ov, oldValue, newValue) -> {
if (updating == true) {
return;
}
double alpha = newValue.doubleValue();
// retrieve HSB TextFields values
double hue = Double.valueOf(hue_textfield.getText());
double saturation = Double.valueOf(saturation_textfield.getText()) / 100.0;
double brightness = Double.valueOf(brightness_textfield.getText()) / 100.0;
// Update UI
final Color color = updateUI(hue, saturation, brightness, alpha);
// Update model
setPaintProperty(color);
});
final ChangeListener<Boolean> liveUpdateListener = (ov, oldValue, newValue) -> paintPickerController.setLiveUpdate(newValue);
picker_region.pressedProperty().addListener(liveUpdateListener);
hue_slider.pressedProperty().addListener(liveUpdateListener);
alpha_slider.pressedProperty().addListener(liveUpdateListener);
}
use of javafx.geometry.Bounds in project jphp by jphp-compiler.
the class DnDTabPaneSkin method tabPane_handleDragOver.
@SuppressWarnings("all")
void tabPane_handleDragOver(Pane tabHeaderArea, Pane headersRegion, DragEvent event) {
Tab draggedTab = DRAGGED_TAB;
if (draggedTab == null) {
return;
}
// Consume the drag in any case
event.consume();
double x = event.getX() - headersRegion.getBoundsInParent().getMinX();
Node referenceNode = null;
DropType type = DropType.AFTER;
for (Node n : headersRegion.getChildren()) {
Bounds b = n.getBoundsInParent();
if (b.getMaxX() > x) {
if (b.getMinX() + b.getWidth() / 2 > x) {
referenceNode = n;
type = DropType.BEFORE;
} else {
referenceNode = n;
type = DropType.AFTER;
}
break;
}
}
if (referenceNode == null && headersRegion.getChildren().size() > 0) {
referenceNode = headersRegion.getChildren().get(headersRegion.getChildren().size() - 1);
type = DropType.AFTER;
}
if (referenceNode != null) {
try {
// $NON-NLS-1$
Field field = referenceNode.getClass().getDeclaredField("tab");
field.setAccessible(true);
Tab tab = (Tab) field.get(referenceNode);
boolean noMove = false;
if (tab == draggedTab) {
noMove = true;
} else if (type == DropType.BEFORE) {
int idx = getSkinnable().getTabs().indexOf(tab);
if (idx > 0) {
if (getSkinnable().getTabs().get(idx - 1) == draggedTab) {
noMove = true;
}
}
} else {
int idx = getSkinnable().getTabs().indexOf(tab);
if (idx + 1 < getSkinnable().getTabs().size()) {
if (getSkinnable().getTabs().get(idx + 1) == draggedTab) {
noMove = true;
}
}
}
if (noMove) {
efx_dragFeedback(draggedTab, null, null, DropType.NONE);
return;
}
Bounds b = referenceNode.getBoundsInLocal();
b = referenceNode.localToScene(b);
b = getSkinnable().sceneToLocal(b);
efx_dragFeedback(draggedTab, tab, b, type);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
event.acceptTransferModes(TransferMode.MOVE);
} else {
efx_dragFeedback(draggedTab, null, null, DropType.NONE);
}
}
use of javafx.geometry.Bounds in project jphp by jphp-compiler.
the class GameEntity2D method getHeight.
public double getHeight() {
if (height >= 0)
return height;
Bounds bounds = node.getBoundsInParent();
double height = bounds.getHeight();
return height <= 0 ? 1 : height;
}
use of javafx.geometry.Bounds in project jphp by jphp-compiler.
the class UXNode method setAnchorFlags.
@Setter
public void setAnchorFlags(ArrayMemory value) {
Parent parent = getWrappedObject().getParent();
Bounds parentBounds = parent == null ? null : parent.getLayoutBounds();
if (parent == null) {
return;
}
Effect effect = getWrappedObject().getEffect();
getWrappedObject().setEffect(null);
Bounds bounds = getBoundsInParent();
Border border = parent instanceof Region ? ((Region) parent).getBorder() : null;
Insets borderInsets = border == null ? Insets.EMPTY : border.getInsets();
if (value.containsKey("left")) {
boolean left = value.valueOfIndex("left").toBoolean();
if (left) {
setLeftAnchor(DoubleMemory.valueOf(bounds.getMinX() - borderInsets.getLeft()));
} else {
setLeftAnchor(Memory.NULL);
}
}
if (value.containsKey("top")) {
boolean top = value.valueOfIndex("top").toBoolean();
if (top) {
setTopAnchor(DoubleMemory.valueOf(bounds.getMinY() - borderInsets.getTop()));
} else {
setTopAnchor(Memory.NULL);
}
}
if (value.containsKey("right")) {
boolean right = value.valueOfIndex("right").toBoolean();
if (right) {
setRightAnchor(DoubleMemory.valueOf(parentBounds.getWidth() - bounds.getMaxX() - borderInsets.getRight()));
} else {
setRightAnchor(Memory.NULL);
}
}
if (value.containsKey("bottom")) {
boolean bottom = value.valueOfIndex("bottom").toBoolean();
if (bottom) {
setBottomAnchor(DoubleMemory.valueOf(parentBounds.getHeight() - bounds.getMaxY() - borderInsets.getBottom()));
} else {
setBottomAnchor(Memory.NULL);
}
}
getWrappedObject().setEffect(effect);
}
use of javafx.geometry.Bounds in project jphp by jphp-compiler.
the class UXPopupWindow method showByNode.
@Signature
public void showByNode(Node node, int offsetX, int offsetY) {
Bounds screen = node.localToScreen(node.getLayoutBounds());
getWrappedObject().show(node.getScene().getWindow(), screen.getMinX() + offsetX, screen.getMinY() + offsetY);
}
Aggregations