List of usage examples for javafx.collections FXCollections observableArrayList
@SuppressWarnings("unchecked") public static <E> ObservableList<E> observableArrayList()
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXScopeListPane.java
public void setJavaFXDataCollection(Collection<ICFBamScopeObj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value;// w w w . jav a 2 s .c o m observableListOfScope = FXCollections.observableArrayList(); if (javafxDataCollection != null) { Iterator<ICFBamScopeObj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfScope.add(iter.next()); } observableListOfScope.sort(compareScopeByQualName); } if (dataTable != null) { dataTable.setItems(observableListOfScope); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
From source file:main.Content.java
public void setData(ObservableList<String> treeData) { temp = FXCollections.observableArrayList(); for (int i = 0; i < treeData.size(); i++) { String index = treeData.get(i).toString(); System.out.println(treeData.size()); index = index.substring(0, 4);/* w w w . j a va2 s.c o m*/ int parent = Integer.parseInt(index.substring(0, 1)); int id; if (index.charAt(3) == ' ') id = Integer.parseInt(index.substring(2, 3)); else id = Integer.parseInt(index.substring(2, 4)); for (int j = 0; j < data.size(); j++) { Activity tempData = data.get(j); if (tempData.getParentValue() == parent && tempData.getID() == id) { temp.add(tempData); break; } } } }
From source file:aajavafx.VisitorScheduleController.java
public ObservableList<String> getCustomer() throws IOException, JSONException { ObservableList<String> customerStrings = FXCollections.observableArrayList(); //customers.add(new CustomerProperty(1, "Johny", "Walker", "London", "1972-07-01", "7207012222")); Customers myCustomer = new Customers(); //Managers manager = new Managers(); Gson gson = new Gson(); JSONObject jo = new JSONObject(); JSONArray jsonArray = new JSONArray(IOUtils .toString(new URL("http://localhost:8080/MainServerREST/api/customers"), Charset.forName("UTF-8"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); myCustomer = gson.fromJson(jo.toString(), Customers.class); customers.add(myCustomer);/*from w w w. j a va 2 s. c o m*/ System.out.println(myCustomer.getCuId()); String s = myCustomer.getCuId() + ". " + myCustomer.getCuFirstname() + " " + myCustomer.getCuLastname(); customerStrings.add(s); } custStrings = customerStrings; return customerStrings; }
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())); }/*from w w w. ja v a 2 s .c o m*/ return visitorsProperty; }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
public void yearlyInOutToggled(ActionEvent actionEvent) { final NumberAxis xAxis = new NumberAxis(); final CategoryAxis yAxis = new CategoryAxis(); yAxis.setLabel("In/Out in Euro"); xAxis.setLabel("Year"); final BarChart<Number, String> barChart = new BarChart<>(xAxis, yAxis); barChart.setTitle("Yearly in/out"); chartFrame.setCenter(barChart);/* w ww .j ava 2s. c om*/ ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { Account account = accountCombo.getValue(); String accountLabel = getAccountLabel(account); XYChart.Series<Number, String> inSeries = new XYChart.Series<>(); inSeries.setName("In" + accountLabel); barChart.getData().add(inSeries); XYChart.Series<Number, String> outSeries = new XYChart.Series<>(); outSeries.setName("Out" + accountLabel); barChart.getData().add(outSeries); ValueRange<LocalDate> period = getTransactionOpRange(account, yearCombo.getValue()); if (period.isEmpty()) { return; } ObservableList<String> categories = FXCollections.observableArrayList(); for (int y = period.from().getYear(); y < period.to().getYear() + 6; y++) { categories.add(String.valueOf(y)); } yAxis.setCategories(categories); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { List<TransactionVolume> incomingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getYearlyIncomingVolumes(false) : transactionRepository.getYearlyIncomingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { incomingVolumes = incomingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : incomingVolumes) { XYChart.Data<Number, String> inData = new XYChart.Data<>(volume.getVolume(), String.valueOf(volume.getYear())); Platform.runLater(() -> { inSeries.getData().add(inData); StackPane node = (StackPane) inData.getNode(); node.getChildren().add( new Label(CurrencyFormat.getInstance().format(volume.getVolume()))); node.addEventHandler(MOUSE_CLICKED, event -> handleYearlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, ofYearDay(volume.getYear(), 1), event)); }); } List<TransactionVolume> outgoingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getYearlyOutgoingVolumes(false) : transactionRepository.getYearlyOutgoingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { outgoingVolumes = outgoingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : outgoingVolumes) { XYChart.Data<Number, String> outData = new XYChart.Data<>(volume.getVolume().abs(), String.valueOf(volume.getYear())); Platform.runLater(() -> { outSeries.getData().add(outData); StackPane node = (StackPane) outData.getNode(); node.getChildren().add( new Label(CurrencyFormat.getInstance().format(volume.getVolume()))); node.addEventHandler(MOUSE_CLICKED, event -> handleYearlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, ofYearDay(volume.getYear(), 1), event)); }); } return null; } }; } }; service.start(); } }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXEnumTagListPane.java
public void setJavaFXDataCollection(Collection<ICFBamEnumTagObj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value;/*from www .j av a2 s.c o m*/ observableListOfEnumTag = FXCollections.observableArrayList(); if (javafxDataCollection != null) { if (javafxSortByChain) { Iterator<ICFBamEnumTagObj> iter = javafxDataCollection.iterator(); ICFBamEnumTagObj head = null; while ((head == null) && iter.hasNext()) { head = iter.next(); if (null != head.getOptionalLookupPrev()) { head = null; } } if ((head == null) && (javafxDataCollection.size() > 0)) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Could not locate head of object chain"); } ICFBamEnumTagObj cur = head; while (cur != null) { observableListOfEnumTag.add(cur); cur = cur.getOptionalLookupNext(); } } else { Iterator<ICFBamEnumTagObj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfEnumTag.add(iter.next()); } observableListOfEnumTag.sort(compareEnumTagByQualName); } } if (dataTable != null) { dataTable.setItems(observableListOfEnumTag); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXPopTopDepListPane.java
public void setJavaFXDataCollection(Collection<ICFBamPopTopDepObj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value;//from ww w . j a v a 2 s.co m observableListOfPopTopDep = FXCollections.observableArrayList(); if (javafxDataCollection != null) { Iterator<ICFBamPopTopDepObj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfPopTopDep.add(iter.next()); } observableListOfPopTopDep.sort(comparePopTopDepByQualName); } if (dataTable != null) { dataTable.setItems(observableListOfPopTopDep); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
From source file:aajavafx.CustomerMedicineController.java
public ObservableList<CustomersTakesMedicines> getCustomersTakesMedicines() throws IOException, JSONException { ObservableList<CustomersTakesMedicines> ctMeds = FXCollections.observableArrayList(); //Managers manager = new Managers(); Gson gson = new Gson(); JSONObject jo = new JSONObject(); //........SSL Update CredentialsProvider provider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("EMPLOYEE", "password"); provider.setCredentials(AuthScope.ANY, credentials); HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); HttpGet get = new HttpGet("http://localhost:8080/MainServerREST/api/customersmedicines/"); HttpResponse response = client.execute(get); System.out.println("RESPONSE IS: " + response); //................... // JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(MedicineRootURL), Charset.forName("UTF-8"))); JSONArray jsonArray = new JSONArray( IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8"))); //JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(MedicineCustomerRootURL), Charset.forName("UTF-8"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { //get the main json object, which contains customer object, pk object, dosage, start date, schedule and medicine object jo = (JSONObject) jsonArray.getJSONObject(i); System.out.println("JSON OBJECT #" + i + " " + jo); //get the customer json sub-string JSONObject custObj = (JSONObject) jo.get("customers"); Customers customer = gson.fromJson(custObj.toString(), Customers.class); //get the primary key json sub-string JSONObject pkObj = (JSONObject) jo.get("customersTakesMedicinesPK"); CustomersTakesMedicinesPK ctmPK = gson.fromJson(pkObj.toString(), CustomersTakesMedicinesPK.class); //get the medicine json sub-string JSONObject medObj = (JSONObject) jo.get("medicines"); Medicines medicine = gson.fromJson(medObj.toString(), Medicines.class); //get the individual strings String dose = jo.getString("medDosage"); String startDate = jo.getString("medStartDate"); double schedule = jo.getDouble("medicationintakeschedule"); CustomersTakesMedicines cuTaMe = new CustomersTakesMedicines(ctmPK, dose, startDate, schedule); cuTaMe.setCustomers(customer);/* w ww . ja v a 2 s . c o m*/ cuTaMe.setMedicines(medicine); ctMeds.add(cuTaMe); } return ctMeds; }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXDelSubDep1ListPane.java
public void setJavaFXDataCollection(Collection<ICFBamDelSubDep1Obj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value;/* www . j av a2 s.c o m*/ observableListOfDelSubDep1 = FXCollections.observableArrayList(); if (javafxDataCollection != null) { Iterator<ICFBamDelSubDep1Obj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfDelSubDep1.add(iter.next()); } observableListOfDelSubDep1.sort(compareDelSubDep1ByQualName); } if (dataTable != null) { dataTable.setItems(observableListOfDelSubDep1); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }
From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamJavaFX.CFBamJavaFXPopSubDep1ListPane.java
public void setJavaFXDataCollection(Collection<ICFBamPopSubDep1Obj> value) { final String S_ProcName = "setJavaFXDataCollection"; javafxDataCollection = value;/*from ww w. j av a 2 s . c o m*/ observableListOfPopSubDep1 = FXCollections.observableArrayList(); if (javafxDataCollection != null) { Iterator<ICFBamPopSubDep1Obj> iter = javafxDataCollection.iterator(); while (iter.hasNext()) { observableListOfPopSubDep1.add(iter.next()); } observableListOfPopSubDep1.sort(comparePopSubDep1ByQualName); } if (dataTable != null) { dataTable.setItems(observableListOfPopSubDep1); // Hack from stackoverflow to fix JavaFX TableView refresh issue ((TableColumn) dataTable.getColumns().get(0)).setVisible(false); ((TableColumn) dataTable.getColumns().get(0)).setVisible(true); } }