List of usage examples for javafx.collections ObservableList add
boolean add(E e);
From source file:aajavafx.VisitorController.java
public ObservableList<VisitorsProperty> getVisitors() throws IOException, JSONException { Visitors myVisitors = new Visitors(); Gson gson = new Gson(); ObservableList<VisitorsProperty> visitorsProperty = FXCollections.observableArrayList(); JSONObject jo = new JSONObject(); JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(VisitorsRootURL), Charset.forName("UTF-8"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); myVisitors = gson.fromJson(jo.toString(), Visitors.class); System.out.println(myVisitors.getVisId()); visitorsProperty.add(new VisitorsProperty(myVisitors.getVisId(), myVisitors.getVisFirstname(), myVisitors.getVisLastname(), myVisitors.getVisEmail(), myVisitors.getVisPhone(), myVisitors.getCompanyCompId().getCompId())); }// w w w . ja v a2 s.co m return visitorsProperty; }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void animateHide(Runnable onFinishedHandler) { Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); double duration = getDuration(200); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); if (type.animationType == AnimationType.SlideDownFromCenterTop) { double endY = -gridPane.getHeight(); keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), endY, interpolator))); timeline.setOnFinished(e -> onFinishedHandler.run()); timeline.play();//from w ww. jav a2 s.co m } else if (type.animationType == AnimationType.ScaleFromCenter) { double endScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator))); } else if (type.animationType == AnimationType.ScaleYFromCenter) { gridPane.setRotationAxis(Rotate.X_AXIS); gridPane.getScene().setCamera(new PerspectiveCamera()); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator))); } else if (type.animationType == AnimationType.ScaleDownToCenter) { double endScale = 0.1; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator))); } else if (type.animationType == AnimationType.FadeInAtCenter) { keyFrames.add( new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator))); } timeline.setOnFinished(e -> onFinishedHandler.run()); timeline.play(); }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void animateDisplay() { gridPane.setOpacity(0);/*w w w .jav a 2 s. c o m*/ Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); double duration = getDuration(400); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); if (type.animationType == AnimationType.SlideDownFromCenterTop) { double startY = -gridPane.getHeight(); keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), startY, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator))); } else if (type.animationType == AnimationType.ScaleFromCenter) { double startScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), startScale, interpolator), new KeyValue(gridPane.scaleYProperty(), startScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.ScaleYFromCenter) { double startYScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleYProperty(), startYScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.ScaleDownToCenter) { double startScale = 1.1; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), startScale, interpolator), new KeyValue(gridPane.scaleYProperty(), startScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.FadeInAtCenter) { keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); } timeline.play(); }
From source file:com.mycompany.songbitmaven.RecommendationController.java
public void loadTable() { ObservableList<SongInfo> tracks = FXCollections.observableArrayList(); TableColumn nameColumn = new TableColumn("Name"); nameColumn.setMinWidth(250);//from w ww . j a v a 2 s . com nameColumn.setCellValueFactory(new PropertyValueFactory<SongInfo, String>("name")); TableColumn artistColumn = new TableColumn("Artist"); artistColumn.setMinWidth(250); artistColumn.setCellValueFactory(new PropertyValueFactory<SongInfo, String>("artist")); table.getColumns().setAll(nameColumn, artistColumn); tracks.clear(); for (int i = 0; i < recommendations.size(); i++) { recommendations.get(i).updateArtist(); tracks.add(recommendations.get(i)); } table.setItems(tracks); }
From source file:com.rockhoppertech.symchords.fx.SymChordsController.java
void updatePatternList() { int limit = 7; int size = 6; List<int[]> patterns = null; if (this.model.getMIDITrack() != null) { size = model.getMIDITrack().size(); patterns = PatternFactory.getPatterns(size, size); } else {// www .j av a 2s . co m patterns = PatternFactory.getPatterns(limit, size); } ObservableList<int[]> items = FXCollections.observableArrayList(); this.patternListView.setItems(items); for (int[] a : patterns) { items.add(a); } }
From source file:jduagui.Controller.java
private TreeItem<File> createNode(final File f) { return new TreeItem<File>(f) { private boolean isLeaf; private boolean isFirstTimeChildren = true; private boolean isFirstTimeLeaf = true; @Override/* w w w .j a v a2 s.c om*/ public ObservableList<TreeItem<File>> getChildren() { if (isFirstTimeChildren) { isFirstTimeChildren = false; super.getChildren().setAll(buildChildren(this)); } return super.getChildren(); } @Override public boolean isLeaf() { if (isFirstTimeLeaf) { isFirstTimeLeaf = false; File f = (File) getValue(); isLeaf = f.isFile(); } return isLeaf; } private ObservableList<TreeItem<File>> buildChildren(TreeItem<File> TreeItem) { File f = TreeItem.getValue(); if (f != null && f.isDirectory() && (!f.getAbsolutePath().equals("/proc/"))) { File[] files = f.listFiles(); if (files != null) { ObservableList<TreeItem<File>> children = FXCollections.observableArrayList(); for (File childFile : files) { children.add(createNode(childFile)); } return children; } } return FXCollections.emptyObservableList(); } }; }
From source file:aajavafx.VisitorScheduleController.java
public ObservableList<VisitorScheduleProperty> getVisitorSchedules() throws IOException, JSONException { VisitorSchedule vs = new VisitorSchedule(); VisitorSchedulePK VisitorSchedulePK = new VisitorSchedulePK(); Gson gson = new Gson(); ObservableList<VisitorScheduleProperty> vsProperty = FXCollections.observableArrayList(); JSONObject jo = new JSONObject(); JSONArray jsonArray = new JSONArray( IOUtils.toString(new URL(VisitorScheduleRootURL), Charset.forName("UTF-8"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); vs = gson.fromJson(jo.toString(), VisitorSchedule.class); System.out.println("VIS ID: " + vs.getVisitorSchedulePK().getVisitorsVisId()); vsProperty.add(new VisitorScheduleProperty(vs.getVisitorSchedulePK().getVisSchId(), vs.getVisitorSchedulePK().getVisitorsVisId(), vs.getVisitorSchedulePK().getCustomersCuId(), vs.getVisitStartDate(), vs.getVisitStartTime(), vs.getVisitEndTime(), vs.getVisRepetitionCircle(), vs.getVisitHash())); }// www. jav a2 s .c o m return vsProperty; }
From source file:com.rockhoppertech.symchords.fx.SymChordsController.java
@FXML void initialize() { assert IntervalsTextField != null : "fx:id=\"IntervalsTextField\" was not injected: check your FXML file 'symchords.fxml'."; assert baseOctaveCombo != null : "fx:id=\"baseOctaveCombo\" was not injected: check your FXML file 'symchords.fxml'."; assert basePitchCombo != null : "fx:id=\"basePitchCombo\" was not injected: check your FXML file 'symchords.fxml'."; assert octavesSlider != null : "fx:id=\"octavesSlider\" was not injected: check your FXML file 'symchords.fxml'."; assert patternTextField != null : "fx:id=\"patternTextField\" was not injected: check your FXML file 'symchords.fxml'."; assert relationshipGroup != null : "fx:id=\"relationshipGroup\" was not injected: check your FXML file 'symchords.fxml'."; assert relativeRadio != null : "fx:id=\"relativeRadio\" was not injected: check your FXML file 'symchords.fxml'."; assert unitSlider != null : "fx:id=\"unitSlider\" was not injected: check your FXML file 'symchords.fxml'."; grandStaff.setFontSize(24d);//from w w w . ja v a 2s . co m grandStaff.drawShapes(); patternStaff.setFontSize(24d); patternStaff.drawShapes(); baseOctaveCombo.getSelectionModel().select(5); basePitchCombo.getSelectionModel().select(0); pitchProperty.bindBidirectional(pitchSlider.valueProperty()); // sliderText.setText(Math.round(pitchSlider.getValue()) + ""); PitchFormat.getInstance().setWidth(4); sliderText.setText(PitchFormat.getInstance().format((int) pitchSlider.getValue())); pitchSlider.valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) { if (newValue == null) { sliderText.setText(""); return; } basePitchCombo.setValue(PitchFormat.getPitchString(newValue.intValue())); baseOctaveCombo.setValue("" + newValue.intValue() / 12); sliderText.setText(PitchFormat.getInstance().format(newValue.intValue())); // sliderText.setText(Math.round(newValue.intValue()) + ""); } }); basePitchCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue) { int pitch = PitchFactory.getPitch(newValue + "0").getMidiNumber(); int oct = Integer.parseInt(baseOctaveCombo.getSelectionModel().getSelectedItem()); pitchProperty.set(pitch + (oct * 12)); } }); baseOctaveCombo.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> ov, String oldValue, String newValue) { int oct = Integer.parseInt(newValue); int pitch = PitchFactory.getPitch(basePitchCombo.getSelectionModel().getSelectedItem() + "0") .getMidiNumber(); pitchProperty.set(pitch + (oct * 12)); } }); // java 8 // basePitchCombo.getSelectionModel().selectedItemProperty().addListener( // (ObservableValue<? extends String> ov, String oldValue, String // newValue) -> { // int pitch = Integer.parseInt(newValue); // int oct = // Integer.parseInt(baseOctaveCombo.getSelectionModel().getSelectedItem()); // pitchProperty.set(pitch + oct); // }); // baseOctaveCombo.getSelectionModel().selectedItemProperty().addListener( // (ObservableValue<? extends String> ov, String oldValue, String // newValue) -> { // int oct = Integer.parseInt(newValue); // int pitch = // Integer.parseInt(basePitchCombo.getSelectionModel().getSelectedItem()); // pitchProperty.set(pitch + oct); // }); model = new SymModel(); model.absoluteProperty().bind(this.absoluteRadio.selectedProperty()); // model.relativeProperty().bind(this.relativeRadio.selectedProperty()); model.basePitchProperty().bind(this.pitchProperty); model.nOctavesProperty().bind(this.octavesSlider.valueProperty()); model.unitProperty().bind(this.unitSlider.valueProperty()); // set up initial value ObservableList<Integer> ol = FXCollections.observableArrayList(); ol.add(1); setIntervals(ol); // now handle input. turn the string into an array. this.IntervalsTextField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) { String[] a = newValue.split("\\s+"); ObservableList<Integer> ol = FXCollections.observableArrayList(); for (final String ss : a) { ol.add(Integer.parseInt(ss)); } setIntervals(ol); } }); model.intervalsProperty().bind(this.intervalsProperty); this.resetPattern(); this.patternTextField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue) { logger.debug("new value '{}'", newValue); newValue = newValue.replaceAll("\\{", ""); newValue = newValue.replaceAll("\\}", ""); newValue = newValue.replaceAll(",", " "); logger.debug("new value '{}'", newValue); String[] a = newValue.split("\\s+"); ObservableList<Integer> ol = FXCollections.observableArrayList(); for (final String ss : a) { ol.add(Integer.parseInt(ss)); } // setIntervals(ol); } }); patternListView.setCellFactory(new Callback<ListView<int[]>, ListCell<int[]>>() { @Override public ListCell<int[]> call(ListView<int[]> list) { return new PatternListCell(); } }); updatePatternList(); patternListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<int[]>() { @Override public void changed(ObservableValue<? extends int[]> observable, int[] oldValue, int[] newValue) { pattern = newValue; patternCalculate(); patternTextField.setText(ArrayUtils.toString(pattern)); } }); setupDragonDrop(); trackList.setCellFactory(new Callback<ListView<MIDITrack>, ListCell<MIDITrack>>() { @Override public ListCell<MIDITrack> call(ListView<MIDITrack> list) { return new TrackListCell(); } }); trackList.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<MIDITrack>() { @Override public void changed(ObservableValue<? extends MIDITrack> observable, MIDITrack oldValue, MIDITrack newValue) { model.setMIDITrack(newValue); // SymParams params = model.getParamsForTrack(newValue); SymParams params = (SymParams) newValue.getUserData(); logger.debug("params {}", params); if (params != null) { int pitch = params.getBasePitch() % 12; String ps = PitchFormat.getPitchString(pitch); basePitchCombo.setValue(ps); String oct = "" + params.getBasePitch() / 12; baseOctaveCombo.setValue(oct); String intervals = ListUtils.asIntString(params.getIntervals()); IntervalsTextField.setText(intervals); octavesSlider.setValue(params.getnOctaves()); unitSlider.setValue(params.getUnit()); relativeRadio.setSelected(params.isRelative()); absoluteRadio.setSelected(!params.isRelative()); } } }); model.midiTrackProperty().addListener(new ChangeListener<MIDITrack>() { @Override public void changed(ObservableValue<? extends MIDITrack> arg0, MIDITrack arg1, MIDITrack newTrack) { if (durationModifierCB.isSelected()) { modifierValuesTextField.setText(MIDITrack.getDurationsAsString(newTrack)); } if (pitchModifierCB.isSelected()) { modifierValuesTextField.setText(MIDITrack.getPitchesMIDINumbersAsString(newTrack)); } if (startBeatModifierCB.isSelected()) { modifierValuesTextField.setText(MIDITrack.getStartBeatsAsString(newTrack)); } logger.debug("midi track property changed {}", newTrack); grandStaff.setTrack(newTrack); grandStaff.drawShapes(); } }); }
From source file:retsys.client.controller.PurchaseOrderConfirmController.java
private void populateData(PurchaseOrder po) { po_no.setText(po.getId().toString()); po_date.setValue(LocalDateTime.ofInstant(po.getDate().toInstant(), ZoneId.systemDefault()).toLocalDate()); po_no.setText(po.getId().toString()); delivery_address.setText(po.getDeliveryAddress()); vendor.setText(po.getVendor().getName() + " (ID:" + po.getVendor().getId() + ")"); project.setText(po.getProject().getName() + " (ID:" + po.getProject().getId() + ")"); ObservableList<POItem> items = FXCollections.observableArrayList(); Iterator detailsIt = po.getPurchaseOrderDetail().iterator(); while (detailsIt.hasNext()) { PurchaseOrderDetail detail = (PurchaseOrderDetail) detailsIt.next(); Item item = detail.getItem();/*w w w.j ava 2 s. c o m*/ int id = item.getId(); String site = item.getSite(); String name = item.getName(); String brand = item.getBrand(); String model = null; Double quantity = detail.getQuantity(); Boolean confirm = "Y".equals(detail.getConfirm()); items.add(new POItem(detail.getId(), site, name + " (ID:" + id + ")", brand, model, quantity, confirm, detail.getReceivedDate())); } poDetail.setItems(items); System.out.println(po.getAudit()); populateAuditValues(po); }