List of usage examples for javafx.collections ObservableList add
boolean add(E e);
From source file:org.nmrfx.processor.gui.PropertyManager.java
void setPropSheet(int scriptIndex, String op) { currentIndex = -1;/* w w w .j a va2 s . co m*/ String trimOp = OperationInfo.trimOp(op); Pattern pattern = null; String opPars = ""; if (!op.equals("")) { opPars = op.substring(op.indexOf('(') + 1, op.length() - 1); pattern = Pattern.compile(patternString); } //System.out.println("set prop sheet " + scriptIndex + " " + op); ObservableList<PropertySheet.Item> newItems = FXCollections.observableArrayList(); for (PropertySheet.Item item : propItems) { if (item == null) { System.out.println("item null"); } else if (item.getCategory().equals(trimOp) && (pattern != null)) { boolean foundIt = false; Matcher matcher = pattern.matcher(opPars); while (matcher.find()) { if (matcher.groupCount() > 1) { String parName = matcher.group(1); if (item.getName().equals(parName)) { String parValue = matcher.group(2); foundIt = true; ((OperationItem) item).setFromString(parValue); } } } if (!foundIt) { ((OperationItem) item).setToDefault(); } newItems.add(item); } } currentIndex = scriptIndex; currentOp = trimOp; propertySheet.getItems().setAll(newItems); }
From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java
@SuppressWarnings("rawtypes") private void updateAdditionalData() { ObservableList<AdditionalData> addDataItems = FXCollections.observableArrayList(); // Done!// ww w . j a va 2 s . com additionalDataCombobox.setItems(addDataItems); // We can just about get away with doing this for around ADDITIONAL_DATA_CHANGE_COUNT_LIMIT changes. // if(dataset.getAllChanges().count() > ADDITIONAL_DATA_CHANGE_COUNT_LIMIT) return; // TODO: fix this by lazy-evaluating these durned lists. // 0. Summary. addDataItems.add(createSummaryAdditionalData()); // 1.5. Changes by name LOGGER.info("Creating changes by potential change additional data"); addDataItems.add(createChangesByPotentialChangeAdditionalData()); LOGGER.info("Finished changes by potential change additional data"); // 1. Changes by name /* LOGGER.info("Creating changes by name additional data"); addDataItems.add(createChangesByNameAdditionalData()); LOGGER.info("Finished changes by name additional data"); // 2. Data by name LOGGER.info("Creating data by name additional data"); addDataItems.add(createDataByNameAdditionalData()); LOGGER.info("Finished changes by name additional data"); */ // 3. Changes by subname //LOGGER.info("Creating changes by subnames additional data"); //addDataItems.add(createChangesBySubnamesAdditionalData()); //LOGGER.info("Finished changes by subname additional data"); // 4. Data in this dataset /* LOGGER.info("Creating data by name additional data"); addDataItems.add(createDataAdditionalData()); LOGGER.info("Finished changes by name additional data"); */ // 5. Properties //LOGGER.info("Creating properties additional data"); //addDataItems.add(createPropertiesAdditionalData()); //LOGGER.info("Finished properties additional data"); additionalDataCombobox.getSelectionModel().clearAndSelect(0); LOGGER.info("Finished updateAdditionalData()"); }
From source file:aajavafx.Schedule1Controller.java
public ObservableList<CustomerProperty> getUnsignedCustomers() throws IOException, JSONException { //Customers customers = new Customers(); EmployeeSchedule mySchedule = new EmployeeSchedule(); singleton = Singleton.getInstance(); Gson gson = new Gson(); ObservableList<CustomerProperty> customerPropertyCustomersSigned = FXCollections.observableArrayList(); ObservableList<CustomerProperty> customerPropertyAllCustomers = this.getCustomer(); JSONObject jo = new JSONObject(); 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/employeeschedule/date/" + getDate()); HttpResponse response = client.execute(get); System.out.println("RESPONSE IS: " + response); JSONArray jsonArray = new JSONArray( IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8"))); System.out.println("1 " + jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); mySchedule = gson.fromJson(jo.toString(), EmployeeSchedule.class); customerPropertyCustomersSigned.add(new CustomerProperty(mySchedule.getCustomersCuId().getCuId(), mySchedule.getCustomersCuId().getCuFirstname(), mySchedule.getCustomersCuId().getCuLastname(), mySchedule.getCustomersCuId().getCuPersonnummer())); }/*from www. j a v a2s.c om*/ for (int i = 0; i < customerPropertyAllCustomers.size(); i++) { for (int j = 0; j < customerPropertyCustomersSigned.size(); j++) { if (customerPropertyAllCustomers.get(i).getPersonnumer() .equals(customerPropertyCustomersSigned.get(j).getPersonnumer())) { customerPropertyAllCustomers.remove(i); } } } singleton.setList(customerPropertyAllCustomers); return customerPropertyAllCustomers; }
From source file:aajavafx.CustomerMedicineController.java
public ObservableList<Customers> getCustomer() throws IOException, JSONException { ObservableList<Customers> customers = FXCollections.observableArrayList(); Customers myCustomer = new Customers(); 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/customers"); HttpResponse response = client.execute(get); System.out.println("RESPONSE IS: " + response); //................ //JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(CustomersRootURL), Charset.forName("UTF-8"))); JSONArray jsonArray = new JSONArray( IOUtils.toString(response.getEntity().getContent(), 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 ww .j av a 2 s .c o m*/ return customers; }
From source file:core.AnnotationTask.java
public void addTweets(String fileName, ObservableList<Tweet> personData) { CSVReader cr;//from w w w. j a v a2s .c om try { cr = new CSVReader(new FileReader(fileName), '\t'); headerRow = cr.readNext(); HashMap<String, Integer> headers = new HashMap<String, Integer>(); for (int i = 0; i < headerRow.length; i++) { headers.put(headerRow[i], i); System.err.println("[" + i + "]=" + headerRow[i]); } HashMap<String, Integer> f_list = new HashMap<String, Integer>(); f_list.put("c_emo", headers.get("c_emo")); f_list.put("c_hash", headers.get("c_hash")); f_list.put("c_url", headers.get("c_url")); f_list.put("c_mention", headers.get("c_mention")); f_list.put("length", headers.get("length")); int i = 0; String[] tweetList; while ((tweetList = cr.readNext()) != null) { Tweet t = new Tweet(tweetList[headers.get("tweet_text")], tweetList[headers.get("sentiment")], i, tweetList, Double.parseDouble(tweetList[headers.get("prediction_prob")])); originalData.add(tweetList); for (String key : f_list.keySet()) { t.setFeature(key, Integer.parseInt(tweetList[f_list.get(key)])); } personData.add(t); i++; } } catch (IOException e) { e.printStackTrace(); } }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleContextMenuShowing(ContextMenuEvent event) { // Calculate the m/z value of the clicked point final double clickedX = event.getX(); XYPlot plot = chartNode.getChart().getXYPlot(); Rectangle2D chartArea = chartNode.getRenderingInfo().getPlotInfo().getDataArea(); RectangleEdge axisEdge = plot.getDomainAxisEdge(); ValueAxis domainAxis = plot.getDomainAxis(); final double clickedMz = domainAxis.java2DToValue(clickedX, chartArea, axisEdge); final double clickedMzWithShift = Math.abs(clickedMz - mzShift.get()); // Update the m/z shift menu item DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); setToMenuItem.setText("Set to " + mzFormat.format(clickedMz) + " m/z"); setToMenuItem.setUserData(clickedMz); // Update the Show XIC menu item showXICMenuItem.setText("Show XIC of " + mzFormat.format(clickedMzWithShift) + " m/z"); showXICMenuItem.setUserData(clickedMzWithShift); // Update the MS/MS menu findMSMSMenu.setText("Find MS/MS of " + mzFormat.format(clickedMzWithShift) + " m/z"); final ObservableList<MenuItem> msmsItems = findMSMSMenu.getItems(); msmsItems.clear();//from ww w . ja v a 2 s . c om MZmineProject project = MZmineCore.getCurrentProject(); for (RawDataFile file : project.getRawDataFiles()) { scans: for (MsScan scan : file.getScans()) { if (scan.getMsFunction().getMsLevel() == 1) continue; for (IsolationInfo isolation : scan.getIsolations()) { if (!isolation.getIsolationMzRange().contains(clickedMzWithShift)) continue; String menuLabel = MsScanUtils.createSingleLineMsScanDescription(scan, isolation); MenuItem msmsItem = new MenuItem(menuLabel); msmsItem.setOnAction(e -> MsSpectrumPlotModule.showNewSpectrumWindow(scan)); msmsItems.add(msmsItem); continue scans; } } } if (msmsItems.isEmpty()) { MenuItem noneItem = new MenuItem("None"); noneItem.setDisable(true); msmsItems.add(noneItem); } // Update the Remove... menu final ObservableList<MenuItem> rmItems = removeDatasetMenu.getItems(); rmItems.clear(); for (MsSpectrumDataSet dataset : datasets) { MenuItem msmsItem = new MenuItem(dataset.getName()); msmsItem.setOnAction(e -> datasets.remove(dataset)); rmItems.add(msmsItem); } removeDatasetMenu.setDisable(rmItems.isEmpty()); }
From source file:aajavafx.CustomerMedicineController.java
public ObservableList<Medicines> getMedicines() throws IOException, JSONException { ObservableList<Medicines> medicines = 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/medicines"); 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"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); Medicines medicine = gson.fromJson(jo.toString(), Medicines.class); System.out.println("JSON OBJECT #" + i + " " + jo); medicines.add(medicine); }/* w ww. j av a 2s .com*/ return medicines; }
From source file:fruitproject.FruitProject.java
private ObservableList<Map> generateDataInMap(String filename, List<String> addPairs1) { int max = 10; ObservableList<Map> allData = FXCollections.observableArrayList(); //JSON Scan//w w w. j a va 2 s . c o m File f = new File(filename); FileInputStream fis; try { fis = new FileInputStream(f); int content; String result = ""; while ((content = fis.read()) != -1) { // convert to char and display it //System.out.print((char) content); result = result + ((char) content); } JSONObject js = new JSONObject(result); String js1 = js.getString("title"); System.out.println(js1); JSONArray arr = js.getJSONArray("fruits"); //System.out.println(arr.get(0)); int i = 0; while (i < arr.length()) { Map<String, String> dataRow = new HashMap<>(); JSONObject farr = arr.getJSONObject(i); //System.out.println(farr.get("amount")); //System.out.println(farr.get("name")); String value1 = String.valueOf(farr.get("name")); String value2 = String.valueOf(farr.get("amount")); String value3 = String.valueOf(farr.get("amount")); dataRow.put(Column1MapKey, value1); dataRow.put(Column2MapKey, value2); dataRow.put(Column3MapKey, "REMOVE"); i++; allData.add(dataRow); rows++; } i = 0; while (i < (addPairs1.size())) { Map<String, String> dataRow = new HashMap<>(); dataRow.put(Column1MapKey, addPairs1.get(i)); dataRow.put(Column2MapKey, addPairs1.get(i + 1)); dataRow.put(Column3MapKey, "REMOVE"); i = i + 2; allData.add(dataRow); rows++; } fis.close(); } catch (Exception ex) { System.out.println(ex.toString()); } return allData; }
From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java
private void fillTableViewWithDatasetRows(TableView<DatasetRow> tableView) { // We need to precalculate. ObservableList<DatasetRow> rows = dataset.rowsProperty(); // Setup table. tableView.editableProperty().set(false); ObservableList<TableColumn<DatasetRow, ?>> cols = tableView.getColumns(); cols.clear();//from w w w. jav a2s .co m // Set up columns. TableColumn<DatasetRow, String> colRowName = new TableColumn<>("Name"); colRowName.setCellValueFactory((TableColumn.CellDataFeatures<DatasetRow, String> features) -> { DatasetRow row = features.getValue(); Set<Name> names = dataset.getNamesInRow(row); if (names.isEmpty()) { return new ReadOnlyStringWrapper("(None)"); } else { return new ReadOnlyStringWrapper( names.stream().map(n -> n.getFullName()).collect(Collectors.joining("; "))); } }); colRowName.setPrefWidth(100.0); cols.add(colRowName); // Create a column for every column here. dataset.getColumns().forEach((DatasetColumn col) -> { String colName = col.getName(); TableColumn<DatasetRow, String> colColumn = new TableColumn<>(colName); colColumn.setCellValueFactory((TableColumn.CellDataFeatures<DatasetRow, String> features) -> { DatasetRow row = features.getValue(); String val = row.get(colName); return new ReadOnlyStringWrapper(val == null ? "" : val); }); colColumn.setPrefWidth(100.0); cols.add(colColumn); }); // Set table items. tableView.itemsProperty().set(rows); // What if it's empty? tableView.setPlaceholder(new Label("No data contained in this dataset.")); }
From source file:aajavafx.DevicesController.java
public ObservableList<DevicesCustomerProperty> getDevicesCustomer() throws IOException, JSONException { ObservableList<DevicesCustomerProperty> devicesCustomers = FXCollections.observableArrayList(); 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/devicescustomers"); HttpResponse response = client.execute(get); System.out.println("RESPONSE IS: " + response); JSONArray jsonArray = new JSONArray( IOUtils.toString(response.getEntity().getContent(), Charset.forName("UTF-8"))); // ........... //JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(DevicesCustomerRootURL), Charset.forName("UTF-8"))); System.out.println(jsonArray); for (int i = 0; i < jsonArray.length(); i++) { jo = (JSONObject) jsonArray.getJSONObject(i); JSONObject jObj = (JSONObject) jo.get("customersCuId"); Customers customer = gson.fromJson(jObj.toString(), Customers.class); System.out.println("JSON OBJECT #" + i + " " + jo); String cuDevId = jo.getString("devId"); String cuDevName = jo.getString("devName"); devicesCustomers.add(new DevicesCustomerProperty(customer.getCuId(), customer.getCuFirstname(), customer.getCuLastname(), customer.getCuBirthdate(), customer.getCuAddress(), customer.getCuPersonnummer(), cuDevId, cuDevName)); }/*from w ww .java2 s .c o m*/ return devicesCustomers; }