@SuppressWarnings("unchecked") public void bind(final ObjectProperty<?> property, final String propertyName, Class<?> type) { String value = props.getProperty(propertyName); if (value != null) { if (type.getName().equals(Color.class.getName())) { ((ObjectProperty<Color>) property).set(Color.valueOf(value)); } else if (type.getName().equals(String.class.getName())) { ((ObjectProperty<String>) property).set(value); } else { ((ObjectProperty<Object>) property).set(value); } } property.addListener( o -> { props.setProperty(propertyName, property.getValue().toString()); }); }
@FXML public void loadGame(ActionEvent event) { Stage newStage = new Stage(); if (event.getSource() == loadButton) { loadData = LoadSaveGame.load(); if (loadData != null) { Controller.loaded = true; GameController.numPasses = (int) Controller.loadData.get(4); // GameController.landButton.setDisable(true); try { gameRoot = FXMLLoader.load(getClass().getResource("UIFiles/MainMap.fxml")); gameScene = new Scene(gameRoot); Parent startWindow = FXMLLoader.load(getClass().getResource("UIFiles/playerStart.fxml")); startScene = new Scene(startWindow); } catch (IOException e) { e.printStackTrace(); } newStage.setScene(gameScene); newStage.setTitle("Game Screen"); newStage.show(); GridPane grid = (GridPane) gameRoot; landPlots = (Land[][]) loadData.get(0); level = (String) loadData.get(1); players = (Player[]) loadData.get(3); for (Player player : players) { for (Land land : player.getLandOwned()) { landPlots[land.getCol()][land.getRow()].setOwner(player); } } if (grid != null) { for (Land[] landArray : landPlots) { for (Land land : landArray) { if (land.isOwned()) { Player owner = land.getOwner(); Rectangle color = new Rectangle(); color.setFill(Color.valueOf(owner.getColor())); color.setHeight(25); color.setWidth(25); color.setOpacity(1); GridPane.setHalignment(color, HPos.LEFT); GridPane.setValignment(color, VPos.TOP); grid.add(color, land.getCol(), land.getRow()); if (land.hasMule()) { Image mulePic = new Image("gameConfig/UIFiles/Media/aMule.png"); ImageView muleView = new ImageView(); muleView.setImage(mulePic); muleView.setFitWidth(50); muleView.setPreserveRatio(true); GridPane.setHalignment(muleView, HPos.LEFT); GridPane.setValignment(muleView, VPos.CENTER); muleView.setId(String.valueOf(land.getCol()) + String.valueOf(land.getRow())); grid.add(muleView, land.getCol(), land.getRow()); } } } } } numPlayer = players.length; Turns turns = new Turns(players); turns.setRounds((int) loadData.get(5)); GameController.beginTurn(); } else { Controller.loaded = false; } } }
public class JFXToggleButtonSkin extends ToggleButtonSkin { private final AnchorPane main = new AnchorPane(); private Line line; private final int startX = 16; private final int endX = 52; private final int startY = 12; private Circle circle; private final int circleRadius = 8; private Circle innerCircle; private StackPane circles = new StackPane(); private final int strokeWidth = 2; private final Color unToggledColor = Color.valueOf("#5A5A5A"); private Color toggledColor; private JFXRippler rippler; private Timeline transition; private boolean invalid = true; public JFXToggleButtonSkin(JFXToggleButton toggleButton) { super(toggleButton); // hide the togg le button toggleButton.setStyle("-fx-background-color:TRANSPARENT"); line = new Line(startX, startY, endX, startY); line.setStroke(unToggledColor); line.setStrokeWidth(1); circle = new Circle(startX - circleRadius, startY, circleRadius); circle.setFill(Color.TRANSPARENT); circle.setStroke(unToggledColor); circle.setStrokeWidth(strokeWidth); innerCircle = new Circle(startX - circleRadius, startY, 0); innerCircle.setStrokeWidth(0); StackPane circlePane = new StackPane(); circlePane.getChildren().add(circle); circlePane.getChildren().add(innerCircle); circlePane.setPadding(new Insets(15)); rippler = new JFXRippler(circlePane, RipplerMask.CIRCLE, RipplerPos.BACK); circles.getChildren().add(rippler); main.getChildren().add(line); main.getChildren().add(circles); main.setCursor(Cursor.HAND); AnchorPane.setTopAnchor(circles, -12.0); AnchorPane.setLeftAnchor(circles, -15.0); getSkinnable() .selectedProperty() .addListener( (o, oldVal, newVal) -> { rippler.setRipplerFill(newVal ? unToggledColor : toggledColor); transition.setRate(newVal ? 1 : -1); transition.play(); }); updateChildren(); } @Override protected void updateChildren() { super.updateChildren(); if (main != null) { getChildren().remove(0); getChildren().add(main); } } @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { if (invalid) { toggledColor = (Color) ((JFXToggleButton) getSkinnable()).getToggleColor(); transition = getToggleTransition(); innerCircle.setFill(toggledColor); innerCircle.setStroke(toggledColor); rippler.setRipplerFill(toggledColor); invalid = false; } } private Timeline getToggleTransition() { return new Timeline( new KeyFrame( Duration.ZERO, new KeyValue(circles.translateXProperty(), 0, Interpolator.LINEAR), new KeyValue(line.strokeProperty(), unToggledColor, Interpolator.EASE_BOTH), new KeyValue(innerCircle.strokeWidthProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(innerCircle.radiusProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame( Duration.millis(30), new KeyValue(circles.translateXProperty(), 0, Interpolator.LINEAR), new KeyValue(line.strokeProperty(), unToggledColor, Interpolator.EASE_BOTH)), new KeyFrame( Duration.millis(70), new KeyValue( circles.translateXProperty(), endX - startX + 2 * circleRadius, Interpolator.LINEAR), new KeyValue(line.strokeProperty(), toggledColor, Interpolator.EASE_BOTH)), new KeyFrame( Duration.millis(100), new KeyValue(innerCircle.radiusProperty(), circleRadius, Interpolator.EASE_BOTH), new KeyValue(innerCircle.strokeWidthProperty(), strokeWidth, Interpolator.EASE_BOTH))); } }
private void display() { // create labels and textfields Label lbl_klantNaam = new Label("Klant naam:"); lbl_klantNaam.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_klantID = new Label("Klant email:"); lbl_klantID.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_klantAdres = new Label("Klant adres:"); lbl_klantAdres.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_factuurNummer = new Label("Factuur nummer:"); lbl_factuurNummer.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_factuurDatum = new Label("Factuur datum:"); lbl_factuurDatum.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_debiteurenNummer = new Label("Debiteuren nummer:"); lbl_debiteurenNummer.setTextFill((Color.valueOf("#FFFC00"))); String klantHeleNaam = klantVoornaam + " " + klantAchternaam; Label lbl_DklantNaam = new Label(klantHeleNaam); lbl_DklantNaam.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_DklantID = new Label(order.getKlantEmail()); lbl_DklantID.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_DklantAdres = new Label(order.getFactuurAdres()); lbl_DklantAdres.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_DfactuurNummer = new Label(Integer.toString(order.getOrderID())); lbl_DfactuurNummer.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_DfactuurDatum = new Label(order.getOrderDatum().toString()); lbl_DfactuurDatum.setTextFill((Color.valueOf("#FFFC00"))); Label lbl_DdebiteurenNummer = new Label(Integer.toString(debiteurenNummer)); lbl_DdebiteurenNummer.setTextFill((Color.valueOf("#FFFC00"))); TextField tf_wijnnaam = new TextField(); TextField tf_prijs = new TextField(); table.setEditable(true); TableColumn<OrderRegel, Integer> codeCol = new TableColumn<>("Nr"); codeCol.setCellValueFactory(new PropertyValueFactory<>("orderRegelID")); TableColumn<OrderRegel, Integer> aantalCol = new TableColumn("Aantal"); aantalCol.setCellValueFactory(new PropertyValueFactory<>("aantal")); TableColumn<OrderRegel, Integer> wijnCol = new TableColumn("Wijn serie nr"); wijnCol.setCellValueFactory(new PropertyValueFactory<>("wijnID")); TableColumn<OrderRegel, String> naamCol = new TableColumn("Naam"); naamCol.setCellValueFactory(new PropertyValueFactory<>("wijnNaam")); TableColumn<OrderRegel, Integer> jaartalCol = new TableColumn("Jaartal"); jaartalCol.setCellValueFactory(new PropertyValueFactory<>("wijnJaartal")); TableColumn<OrderRegel, Integer> perflesCol = new TableColumn("Per fles"); perflesCol.setCellValueFactory(new PropertyValueFactory<>("wijnPrijs")); TableColumn<OrderRegel, Double> bedragCol = new TableColumn("Bedrag"); bedragCol.setCellValueFactory(new PropertyValueFactory<>("totaalPrijs")); table = new TableView<>(); ObservableList<OrderRegel> orders = FXCollections.observableArrayList(orderController.getAlleOrderRegels(order.getOrderID())); table.setItems(orders); table.getColumns().addAll(wijnCol, naamCol, jaartalCol, aantalCol, perflesCol, bedragCol); // topbox items title = new Label("Lions-club Oegstgeest/Warmond"); title.setId("title"); title.setTextFill(Color.web("#FFCF03")); title.autosize(); icon = new ImageView(new Image("/images/icon.png")); icon.setPreserveRatio(true); icon.autosize(); // buttons cancel = new Button("Terug"); cancel.setOnAction( e -> new BestellingOverzichtView(new OrderController(), new KlantController())); Button exporteer = new Button("Exporteer naar PDF"); exporteer.setOnAction( e -> { factuurGenerator = new FactuurGenerator(klantController.getKlantByOrder(order), order, orders); factuurGenerator.factuur(); Alert alert = new Alert(AlertType.INFORMATION); alert.setHeaderText(null); alert.setTitle("Exporteer naar PDF"); alert.setContentText("De factuur is succesvol ge�xporteerd. "); alert.showAndWait(); }); // add elements to panes topBox.getChildren().addAll(icon, title); topBox.setAlignment(Pos.CENTER); centerBox.getChildren().add(form); centerBox.getChildren().add(table); form.addColumn( 0, lbl_klantNaam, lbl_klantID, lbl_klantAdres, lbl_factuurNummer, lbl_factuurDatum, lbl_debiteurenNummer); form.addColumn( 1, lbl_DklantNaam, lbl_DklantID, lbl_DklantAdres, lbl_DfactuurNummer, lbl_DfactuurDatum, lbl_DdebiteurenNummer); form.addColumn(2, exporteer); bottomBox.getChildren().add(cancel); bottomBox.getChildren().add(exporteer); mainPane.setTop(topBox); mainPane.setCenter(centerBox); mainPane.setBottom(bottomBox); stage.setScene(scene); }
private void mSpriteSelect(Sprite sprite, DInfo dinfo) { sprite.setEffect(new Shadow(4.0f, Color.valueOf(dinfo.get(K_COLOR)))); }
/** Creates Duty Elements in the Graphic. */ private void createDienstElementGraphic() { // Sortierung des Planes ArrayList<String> orderList = new ArrayList<String>(); ArrayList<Integer> listInt = new ArrayList<Integer>(); ArrayList<Integer> match = new ArrayList<Integer>(); ArrayList<Integer> orderedDuty = new ArrayList<Integer>(); boolean idChange = true; String dutyBefore = null; for (int i = 0; i < this.dienstplan.getDutyelement().size(); i++) { if (idChange) { orderList.add(this.dienstplan.getDutyelement().get(i).getDepTime()); dutyBefore = this.dienstplan.getDutyelement().get(i).getDutyID(); idChange = false; } if (!this.dienstplan.getDutyelement().get(i).getDutyID().equals(dutyBefore)) { idChange = true; i = i - 1; } } for (int i = 0; i < orderList.size(); i++) { StringSplitter ss = new StringSplitter(); int[] zeit = new int[2]; zeit = ss.intParse(orderList.get(i)); int startHour = zeit[0]; int startMin = zeit[1]; listInt.add((startHour * 100) + startMin); match.add((startHour * 100) + startMin); } // Sortierung (Bubble Sort) boolean unsortiert = true; int temp; while (unsortiert) { unsortiert = false; for (int i = 0; i < listInt.size() - 1; i++) if (listInt.get(i) > listInt.get(i + 1)) { temp = listInt.get(i); listInt.set(i, listInt.get(i + 1)); listInt.set(i + 1, temp); unsortiert = true; } } for (int i = 0; i < listInt.size(); i++) { temp = listInt.get(i); for (int j = 0; j < match.size(); j++) { if (match.get(j) == temp) { int index = j; boolean auslassen = false; for (int j2 = 0; j2 < orderedDuty.size(); j2++) { if (index == orderedDuty.get(j2)) { auslassen = true; } } if (auslassen == false) { orderedDuty.add(j); } } } } double abstandNetz = (this.canvas.getWidth() - 30) / (this.endzeitVar - this.startzeitVar); // Auslesen der Blockanzahl for (int j = 0; j < this.dienstplan.getDuty().size(); j++) { // Variablen zur Prüfung der ersten Stunde int changeHour = 100; int changeMin = 100; Boolean anfangDienst = true; // Auslesen Blockelementanzahl for (int i = 0; i < this.dienstplan.getDutyelement().size(); i++) { // Abgleich mit den Werten if (dienstplan .getDutyelement() .get(i) .getDutyID() .equals(dienstplan.getDuty().get(orderedDuty.get(j)).getId())) { // Auslesen der Zeit als Integer StringSplitter ss = new StringSplitter(); int[] zeit = new int[2]; zeit = ss.intParse(this.dienstplan.getDutyelement().get(i).getDepTime()); int startHour = zeit[0]; int startMin = zeit[1]; // Prüfung der ersten Stunde if (anfangDienst == true && startHour < changeHour) { changeHour = startHour; changeMin = startMin; anfangDienst = false; } if (startHour < changeHour) { startHour = startHour + 24; } if (startHour == changeHour && startMin < changeMin) { startHour = startHour + 24; } // Belegung der Pixelwerte if (this.startzeitVar <= startHour) { int stundenDifferenz = startHour - this.startzeitVar; int startPixelX = (int) ((stundenDifferenz * abstandNetz) + ((abstandNetz / 60) * startMin)); int startPixelY = 15 + (j * this.breite); int fahrtDauer = 0; // Berrechnen der Dauer zwischen der Abfahrt und der // Ankunft String depTime = this.dienstplan.getDutyelement().get(i).getDepTime(); String arrtime = this.dienstplan.getDutyelement().get(i).getArrTime(); SimpleDateFormat format = new SimpleDateFormat("HH:mm"); Date date1 = null; Date date2 = null; try { date1 = format.parse(depTime); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { date2 = format.parse(arrtime); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } long differenz = date2.getTime() - date1.getTime(); // Über 0 Uhr if (date2.getTime() < date1.getTime()) { differenz = date2.getTime() - date1.getTime() + 86400000; } differenz = (differenz / 1000) / 60; fahrtDauer = (int) (differenz * (abstandNetz / 60)); // Färben der Elemente switch (this.dienstplan.getDutyelement().get(i).getElementType()) { case 1: // Servicefahrt gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(0))); break; case 2: // Leerfahrt Haltestellen gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(1))); break; case 3: // Fahrt ins Depot gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(2))); break; case 4: // Fahrt aus dem Depot gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(3))); break; case 5: // Vorbereitung gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(4))); break; case 6: // Nachbereitung gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(5))); break; case 7: // Transfer gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(6))); break; case 8: // Pause gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(7))); break; case 9: // Warten gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(8))); break; case 10: // LayoverTime gc.setFill(javafx.scene.paint.Color.valueOf(this.colors.get(9))); break; } // Malen der Elemente this.gc.fillRoundRect(startPixelX, startPixelY, fahrtDauer, breite / 2, 20, 10); this.gc.strokeRoundRect(startPixelX, startPixelY, fahrtDauer, breite / 2, 20, 10); // Szenarien if (this.szenarienAktiv && dienstplan.getFahrplanID() == this.fahrplanID) { double delay; for (int k = 0; k < this.szenario.getPrimeDelay().size(); k++) { if (this.szenario .getPrimeDelay() .get(k) .getServiceJourneyID() .equals(dienstplan.getDutyelement().get(i).getServiceJourneyID())) { delay = (abstandNetz / 60) * (this.szenario.getPrimeDelay().get(k).getDelay() / 60); gc.setStroke(Color.RED); gc.setFill(Color.RED); gc.setLineWidth(2); gc.strokeRoundRect( startPixelX, startPixelY - breite / 10, fahrtDauer + delay, breite / 1.5, 20, 10); } } gc.setStroke(Color.BLACK); gc.setLineWidth(1); } // Beschriftet die Elemente if (beschriftungCheck) { if (fahrtDauer > 30) { this.gc.setFill(Color.BLACK); this.gc.setFont(new Font("Arial", 12)); this.gc.fillText( String.valueOf(dienstplan.getDutyelement().get(i).getId()), startPixelX - 3 + (fahrtDauer / 5), startPixelY + 1 + breite / 3); } } } } } } }
{ put(0, javafx.scene.paint.Color.YELLOW); put(20, javafx.scene.paint.Color.ORANGE); put(21, javafx.scene.paint.Color.WHITE); put(22, javafx.scene.paint.Color.WHITE); put(23, javafx.scene.paint.Color.WHITE); put(24, javafx.scene.paint.Color.WHITE); put(25, javafx.scene.paint.Color.WHITE); put(26, javafx.scene.paint.Color.WHITE); put(27, javafx.scene.paint.Color.WHITE); put(28, javafx.scene.paint.Color.WHITE); put(29, javafx.scene.paint.Color.WHITE); put(30, javafx.scene.paint.Color.valueOf("0xffa07a")); put(31, javafx.scene.paint.Color.valueOf("0xffa07a")); put(32, javafx.scene.paint.Color.WHITE); put(33, javafx.scene.paint.Color.WHITE); put(34, javafx.scene.paint.Color.WHITE); put(35, javafx.scene.paint.Color.GRAY); put(36, javafx.scene.paint.Color.valueOf("0xff00ff")); put(37, javafx.scene.paint.Color.valueOf("0xff00ff")); put(38, javafx.scene.paint.Color.WHITE); put(39, javafx.scene.paint.Color.WHITE); put(40, javafx.scene.paint.Color.valueOf("0xff6347")); put(41, javafx.scene.paint.Color.valueOf("0xff6347")); put(42, javafx.scene.paint.Color.valueOf("0xff6347")); put(43, javafx.scene.paint.Color.valueOf("0xff6347")); put(44, javafx.scene.paint.Color.valueOf("0xff6347")); put(45, javafx.scene.paint.Color.valueOf("0xff6347")); put(46, javafx.scene.paint.Color.valueOf("0xff6347")); put(47, javafx.scene.paint.Color.valueOf("0xff6347")); put(48, javafx.scene.paint.Color.valueOf("0xff6347")); put(49, javafx.scene.paint.Color.valueOf("0xff6347")); put(50, javafx.scene.paint.Color.valueOf("0x40e0d0")); put(51, javafx.scene.paint.Color.valueOf("0x40e0d0")); put(52, javafx.scene.paint.Color.valueOf("0x40e0d0")); put(53, javafx.scene.paint.Color.valueOf("0x40e0d0")); put(54, javafx.scene.paint.Color.valueOf("0x40e0d0")); put(55, javafx.scene.paint.Color.WHITE); put(56, javafx.scene.paint.Color.WHITE); put(57, javafx.scene.paint.Color.WHITE); put(58, javafx.scene.paint.Color.WHITE); put(59, javafx.scene.paint.Color.WHITE); put(60, javafx.scene.paint.Color.BLUE); put(61, javafx.scene.paint.Color.BLUE); put(62, javafx.scene.paint.Color.BLUE); put(63, javafx.scene.paint.Color.BLUE); put(64, javafx.scene.paint.Color.BLUE); put(65, javafx.scene.paint.Color.BLUE); put(66, javafx.scene.paint.Color.BLUE); put(67, javafx.scene.paint.Color.BLUE); put(68, javafx.scene.paint.Color.BLUE); put(69, javafx.scene.paint.Color.BLUE); put(70, javafx.scene.paint.Color.GREEN); put(71, javafx.scene.paint.Color.GREEN); put(72, javafx.scene.paint.Color.GREEN); put(73, javafx.scene.paint.Color.GREEN); put(74, javafx.scene.paint.Color.GREEN); put(75, javafx.scene.paint.Color.GREEN); put(76, javafx.scene.paint.Color.GREEN); put(77, javafx.scene.paint.Color.GREEN); put(78, javafx.scene.paint.Color.GREEN); put(79, javafx.scene.paint.Color.GREEN); put(80, javafx.scene.paint.Color.RED); put(81, javafx.scene.paint.Color.RED); put(82, javafx.scene.paint.Color.RED); put(83, javafx.scene.paint.Color.RED); put(84, javafx.scene.paint.Color.RED); put(85, javafx.scene.paint.Color.RED); put(86, javafx.scene.paint.Color.RED); put(87, javafx.scene.paint.Color.RED); put(88, javafx.scene.paint.Color.RED); put(89, javafx.scene.paint.Color.RED); put(90, javafx.scene.paint.Color.WHITE); put(91, javafx.scene.paint.Color.WHITE); put(92, javafx.scene.paint.Color.WHITE); put(93, javafx.scene.paint.Color.WHITE); put(94, javafx.scene.paint.Color.WHITE); put(95, javafx.scene.paint.Color.WHITE); put(96, javafx.scene.paint.Color.WHITE); put(97, javafx.scene.paint.Color.WHITE); put(98, javafx.scene.paint.Color.WHITE); put(99, javafx.scene.paint.Color.WHITE); }