use of javafx.scene.layout.Background in project uPMT by coco35700.
the class MainViewTransformations method addPaneOnDragListener.
/*
* Listener du panel qu'il y a entre plusieurs moment
* */
public static void addPaneOnDragListener(DropPane p, Main main) {
p.setOnDragExited(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent event) {
p.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
}
});
p.setOnDragOver(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
// setting the drag autorizations
boolean cond = true;
MomentExperience draggedMoment = null;
try {
draggedMoment = (MomentExperience) Serializer.deserialize((byte[]) event.getDragboard().getContent(MomentExpVBox.df));
int pos = p.getCol();
int i = ((Integer) event.getDragboard().getContent(MomentExpVBox.realCol));
if (draggedMoment != null) {
if (!draggedMoment.hasParent()) {
// int pos = main.getGrid().getChildren().indexOf(p)/2;
if (p.hasMomentParent()) {
if (p.getMomentParent().getMoment().equals(draggedMoment))
cond = false;
else if (p.getMomentParent().isAChildOf(draggedMoment))
cond = false;
} else
cond = ((pos - i) > 1) || ((pos - i) < 0);
// System.out.println("pos-i="+(pos-i)+" -- 1 < "+(pos-i)+" < 0 ?"+cond);
} else {
if (p.hasMomentParent()) {
if (p.getMomentParent().getMoment().getID() == draggedMoment.getParentID()) {
cond = ((pos - i) > 1) || ((pos - i) < 0);
}
} else
cond = true;
}
} else
cond = false;
} catch (Exception e) {
// System.out.println("null");
}
// System.out.println(Math.abs(i - pos));
if ((event.getDragboard().getString().equals("ajoutMoment")) || (event.getDragboard().getString().equals("moveMoment") && cond)) {
event.acceptTransferModes(TransferMode.ANY);
// p.setBackground(new Background(new BackgroundFill(Color.GRAY, CornerRadii.EMPTY, Insets.EMPTY)));
p.onDragOver(event.getDragboard().getString());
}
event.consume();
}
});
p.setOnDragDropped(new EventHandler<DragEvent>() {
public void handle(DragEvent event) {
p.onDragExited();
if (main.getCurrentDescription().getNumberOfMoments() == 0) {
p.emptyProjectPane();
}
// int pos = main.getGrid().getColumnIndex(p)/2;
int pos = p.getCol();
if (event.getDragboard().getString().equals("ajoutMoment")) {
AddMomentCommand cmd = null;
MomentExperience moment = moment = new MomentExperience();
if (event.getDragboard().getContent(DataFormat.HTML) != null) {
moment.setDescripteme((String) event.getDragboard().getContent(DataFormat.HTML));
}
if (p.hasMomentParent())
cmd = new AddMomentCommand(pos, moment, p.getMomentParent().getMoment(), main);
else
cmd = new AddMomentCommand(pos, moment, main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
}
if (event.getDragboard().getString().equals("moveMoment")) {
// System.out.println("Panel, move a moment in index "+pos);
MomentExperience serial = null;
try {
serial = (MomentExperience) Serializer.deserialize((byte[]) event.getDragboard().getContent(MomentExpVBox.df));
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
}
if (p.hasMomentParent()) {
MoveMomentToMomentCommand cmd = new MoveMomentToMomentCommand(serial, p.getMomentParent().getMoment(), pos, main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
} else {
MoveMomentCommand cmd = new MoveMomentCommand(serial, pos, main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
}
}
// p.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
event.consume();
}
});
p.setOnDragExited(new EventHandler<DragEvent>() {
@Override
public void handle(DragEvent arg0) {
p.onDragExited();
if (main.getCurrentDescription().getNumberOfMoments() == 0) {
p.emptyProjectPane();
}
}
});
}
use of javafx.scene.layout.Background in project CST-135 by psradke.
the class FinalSale method start.
@Override
public void start(Stage primaryStage) throws Exception {
// Background image
BackgroundImage backImg = new BackgroundImage(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/FinalSaleBackground.png", 810, 720, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
// PANE CREATION
// Home and Back Buttons Pane
GridPane buttons = new GridPane();
buttons.setHgap(10);
buttons.setVgap(10);
buttons.setPadding(new Insets(0, 10, 0, 10));
// TableView Cart Pane
GridPane cartView = new GridPane();
cartView.setHgap(9);
cartView.setVgap(9);
cartView.setOpacity(0.9);
cartView.setPadding(new Insets(0, 10, 0, 10));
// Delete and Purchase Buttons Pane
GridPane buttons2 = new GridPane();
buttons2.setHgap(10);
buttons2.setVgap(10);
buttons2.setPadding(new Insets(0, 10, 0, 10));
// Main Pane for arrangement
VBox vBox = new VBox();
vBox.setPadding(new Insets(10, 10, 10, 10));
vBox.getChildren().addAll(buttons, cartView, buttons2);
// Background Pane
StackPane root = new StackPane();
root.setMaxSize(800, 610);
root.setMinSize(800, 610);
root.setBackground(new Background(backImg));
root.setPadding(new Insets(0, 10, 0, 10));
root.getChildren().add(vBox);
// BUTTON CREATION
// Home Button
Button home = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/HomeButton.png")));
home.setBackground(Background.EMPTY);
home.setMaxSize(5, 10);
home.setMinSize(5, 10);
buttons.add(home, 9, 2);
// home.setOnAction(e -> {
// homePage.setScene(scene);
// });
// Back Button
Button back = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/NavigationButtons/BackButton.png")));
back.setBackground(Background.EMPTY);
back.setMaxSize(5, 10);
back.setMinSize(5, 10);
buttons.add(back, 64, 2);
back.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Back");
}
});
// Purchase Button
Button purchase = new Button("", new ImageView(new Image("file:src/DispenserDesign/Background&ButtonImages/FinalSalePage/Purchase.png")));
purchase.setBackground(Background.EMPTY);
purchase.setMaxSize(5, 10);
purchase.setMinSize(5, 10);
buttons2.add(purchase, 36, 11);
purchase.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Purcahse");
}
});
// Delete Button
// Button delete = new Button("Delete Product");
// delete.setOnAction(e -> deleteClicked());
// CREATE TABLE FOR DISPLAYING CART
TableView<Product> table;
// Name column
TableColumn<Product, String> nameCol = new TableColumn<>("Name");
nameCol.setMinWidth(150);
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
// Price column
TableColumn<Product, Double> priceCol = new TableColumn<>("Price");
priceCol.setMinWidth(20);
priceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
// Weight column
TableColumn<Product, Double> weightCol = new TableColumn<>("Weight");
weightCol.setMinWidth(50);
weightCol.setCellValueFactory(new PropertyValueFactory<>("weight"));
// Quantity column
TableColumn<Product, Double> quantityCol = new TableColumn<>("Quantity");
quantityCol.setMinWidth(20);
quantityCol.setCellValueFactory(new PropertyValueFactory<>("quantity"));
table = new TableView<>();
table.setItems(getProduct());
table.setBackground(Background.EMPTY);
table.setMaxSize(620, 313);
table.setMinSize(620, 313);
table.getColumns().addAll(nameCol, priceCol, weightCol, quantityCol);
cartView.add(table, 7, 18);
Scene scene = new Scene(root, 800, 710);
primaryStage.setTitle("Checkout");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
use of javafx.scene.layout.Background in project JFoenix by jfoenixadmin.
the class JFXTextAreaSkinAndroid method layoutChildren.
@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
super.layoutChildren(x, y, w, h);
final double height = getSkinnable().getHeight();
linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
linesWrapper.layoutPrompt(x, y, w, h);
errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
linesWrapper.updateLabelFloatLayout();
if (invalid) {
invalid = false;
// set the default background of text area viewport to white
Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
// reapply css of scroll pane in case set by the user
viewPort.applyCss();
errorContainer.invalid(w);
// focus
linesWrapper.invalid();
}
}
use of javafx.scene.layout.Background in project JFoenix by jfoenixadmin.
the class JFXTextAreaSkin method layoutChildren.
@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
super.layoutChildren(x, y, w, h);
final double height = getSkinnable().getHeight();
linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
linesWrapper.layoutPrompt(x, y, w, h);
errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h);
linesWrapper.updateLabelFloatLayout();
if (invalid) {
invalid = false;
// set the default background of text area viewport to white
Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));
// reapply css of scroll pane in case set by the user
viewPort.applyCss();
errorContainer.invalid(w);
// focus
linesWrapper.invalid();
}
}
use of javafx.scene.layout.Background in project JFoenix by jfoenixadmin.
the class PromptLinesWrapper method updateFocusColor.
public void updateFocusColor() {
Paint paint = control.getFocusColor();
focusedLine.setBackground(paint == null ? Background.EMPTY : new Background(new BackgroundFill(paint, CornerRadii.EMPTY, Insets.EMPTY)));
}
Aggregations