List of usage examples for javafx.collections FXCollections observableArrayList
@SuppressWarnings("unchecked") public static <E> ObservableList<E> observableArrayList()
From source file:aajavafx.MedicinesController.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(response.getEntity().getContent(), Charset.forName("UTF-8"))); // ........... //JSONArray jsonArray = new JSONArray(IOUtils.toString(new URL(MedicineRootURL), 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);/*from w ww .j a v a2s. c om*/ } return medicines; }
From source file:aajavafx.VisitorController.java
/** * Initializes the controller class./* w ww. ja va 2 s. c om*/ */ @Override public void initialize(URL url, ResourceBundle rb) { //instead of invisible, make the text fields locked for editing at first visitorIDField.setEditable(false); firstNameField.setEditable(false); lastNameField.setEditable(false); emailField.setEditable(false); phoneNumberField.setEditable(false); companyBox.setDisable(true); errorLabel.setVisible(false); visitorIDColumn.setCellValueFactory(cellData -> cellData.getValue().visIdProperty()); firstNameColumn.setCellValueFactory(cellData -> cellData.getValue().visFirstnameProperty()); lastNameColumn.setCellValueFactory(cellData -> cellData.getValue().visLastnameProperty()); emailColumn.setCellValueFactory(cellData -> cellData.getValue().visEmailProperty()); phoneColumn.setCellValueFactory(cellData -> cellData.getValue().visPhoneProperty()); companyIDColumn.setCellValueFactory(cellData -> cellData.getValue().companyCompIdProperty().asObject()); try { //Populate table getCompanyList(); tableVisitors.setItems(getVisitors()); ObservableList<String> companyList = FXCollections.observableArrayList(); for (Company c : companies) { companyList.add(c.getCompName()); } companyBox.setItems(companyList); companyBox.getItems().add("Add company"); } catch (IOException ex) { Logger.getLogger(VisitorController.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(VisitorController.class.getName()).log(Level.SEVERE, null, ex); } tableVisitors.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -> { if (newSelection != null) { visitorIDField.setText("" + newSelection.visIdProperty().getValue()); firstNameField.setText(newSelection.getVisFirstname()); lastNameField.setText(newSelection.getVisLastname()); emailField.setText(newSelection.getVisEmail()); phoneNumberField.setText(newSelection.getVisPhone()); companyBox.setValue(getCompanyNameFromID(newSelection.getCompanyCompId())); } }); }
From source file:magicdeckmanager.card.CardManager.java
public ObservableList<PieChart.Data> getManaDistPieChartData(DeckData deckData) { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); final List<String> main = deckData.getMain(); Map<Color, Integer> colorDistribution = new HashMap<>(); Integer totalManaCost = 0;/*from ww w.j av a2 s.c o m*/ for (String cardName : main) { Card card = getCardFromName(cardName); if (!card.isLand()) { totalManaCost += card.cmc; final ManaCost manaCost = card.getManaCost(); final List<ManaPart> cost = manaCost.getCost(); addManaPartsToColorDistribution(cost, colorDistribution); } } for (Map.Entry<Color, Integer> entrySet : colorDistribution.entrySet()) { Color key = entrySet.getKey(); Integer value = entrySet.getValue(); double percent = (value.doubleValue() / totalManaCost.doubleValue()); percent *= 100; Integer percentInteger = (int) Math.round(percent); final String percentString = key.toString() + " " + percentInteger.toString() + "%"; pieChartData.add(new PieChart.Data(percentString, value)); } return pieChartData; }
From source file:com.gmail.frogocomics.schematic.gui.Main.java
@Override public void start(Stage primaryStage) throws Exception { this.primaryStage = primaryStage; this.root = new GridPane(); this.primaryScene = new Scene(this.root, 1000, 600, Color.AZURE); Label title = new Label("Schematic Utilities"); title.setId("schematic-utilities"); title.setPrefWidth(this.primaryScene.getWidth() + 500); this.root.add(title, 0, 0); filesSelected.setId("files-selected"); this.root.add(filesSelected, 0, 1); Region spacer1 = new Region(); spacer1.setPrefWidth(30);//from ww w. j av a 2 s . c o m spacer1.setPrefHeight(30); Region spacer2 = new Region(); spacer2.setPrefWidth(30); spacer2.setPrefHeight(30); Region spacer3 = new Region(); spacer3.setPrefWidth(30); spacer3.setPrefHeight(250); Region spacer4 = new Region(); spacer4.setPrefWidth(1000); spacer4.setPrefHeight(10); Region spacer5 = new Region(); spacer5.setPrefWidth(30); spacer5.setPrefHeight(30); Region spacer6 = new Region(); spacer6.setPrefWidth(1000); spacer6.setPrefHeight(10); Region spacer7 = new Region(); spacer7.setPrefWidth(1000); spacer7.setPrefHeight(100); Region spacer8 = new Region(); spacer8.setPrefWidth(30); spacer8.setPrefHeight(30); this.root.add(spacer4, 0, 3); listView.setId("schematic-list"); listView.setEditable(false); listView.setPrefWidth(500); listView.setPrefHeight(250); this.root.add(new HBox(spacer3, listView), 0, 4); uploadFiles.setPadding(new Insets(5, 5, 5, 5)); uploadFiles.setPrefWidth(120); uploadFiles.setPrefHeight(30); uploadFiles.setOnAction((event) -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select schematic(s)"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("MCEdit Schematic File", "*.schematic"), new FileChooser.ExtensionFilter("Biome World Object Version 2", "*.bo2")); List<File> selectedFiles = fileChooser.showOpenMultipleDialog(this.primaryStage); if (selectedFiles != null) { if (selectedFiles.size() == 1) { filesSelected.setText("There is currently 1 file selected"); } else { filesSelected.setText( "There are currently " + String.valueOf(selectedFiles.size()) + " files selected"); } ObservableList<SchematicLocation> selectedSchematicFiles = FXCollections.observableArrayList(); selectedSchematicFiles.addAll(selectedFiles.stream().map(f -> new SchematicLocation(f, f.getName())) .collect(Collectors.toList())); listView.setItems(selectedSchematicFiles); this.schematics = selectedSchematicFiles; } }); this.root.add(new HBox(spacer1, uploadFiles, spacer2, new Label("Only .schematic files are allowed at this point!")), 0, 2); editing.setPadding(new Insets(5, 5, 5, 5)); editing.setPrefWidth(240); editing.setPrefHeight(30); editing.setDisable(true); editing.setOnAction(event -> this.primaryStage.setScene(Editing.getScene())); this.root.add(new HBox(spacer8, editing), 0, 8); loadSchematics.setPadding(new Insets(5, 5, 5, 5)); loadSchematics.setPrefWidth(120); loadSchematics.setPrefHeight(30); loadSchematics.setOnAction(event -> { if (this.schematics != null) { ((Runnable) () -> { for (SchematicLocation location : this.schematics) { if (FilenameUtils.isExtension(location.getLocation().getName(), "schematic")) { try { Schematics.schematics.add(McEditSchematicObject.load(location.getLocation())); } catch (ParseException | ClassicNotSupportedException | IOException e) { e.printStackTrace(); } } else if (FilenameUtils.isExtension(location.getLocation().getName(), "bo2")) { try { Schematics.schematics.add(BiomeWorldV2Object.load(location.getLocation())); } catch (IOException e) { e.printStackTrace(); } } } }).run(); loadSchematics.setDisable(true); uploadFiles.setDisable(true); listView.setDisable(true); editing.setDisable(false); } }); this.root.add(spacer6, 0, 5); this.root.add(new HBox(spacer5, loadSchematics), 0, 6); this.root.add(spacer7, 0, 7); this.primaryScene.getStylesheets() .add("https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800"); this.primaryScene.getStylesheets().add(new File("style.css").toURI().toURL().toExternalForm()); this.primaryStage.setScene(this.primaryScene); this.primaryStage.setResizable(false); this.primaryStage.setTitle("Schematic Utilities - by frogocomics"); this.primaryStage.show(); }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.SlideshowOrganizerImpl.java
private void refreshSlideshowList() { int selectedIndex = slideshowList.getSelectionModel().getSelectedIndex(); ObservableList<Slideshow> slideshows = slideshowList.getItems(); slideshowList.setItems(FXCollections.observableArrayList()); slideshowList.setItems(slideshows);/*from w w w . j ava 2 s . c om*/ slideshowList.getSelectionModel().select(selectedIndex); }
From source file:org.sleuthkit.autopsy.imageanalyzer.datamodel.DrawableFile.java
public ObservableList<Pair<DrawableAttribute<?>, ? extends Object>> getAttributesList() { final ObservableList<Pair<DrawableAttribute<?>, ? extends Object>> attributeList = FXCollections .observableArrayList();/*from w ww .ja v a2s . c o m*/ for (DrawableAttribute<?> attr : DrawableAttribute.getValues()) { attributeList.add(new Pair<>(attr, attr.getValue(this))); } return attributeList; }
From source file:ch.unibas.fittingwizard.presentation.fitting.FitResultPage.java
public FitResultPage(MoleculeRepository moleculeRepository, FitRepository fitRepository, Visualization visualization, ExportFitWorkflow exportFitWorkflow, RunVmdDisplayWorkflow vmdDisplayWorkflow) { super(visualization, "MTP and LJ Fit result"); this.moleculeRepository = moleculeRepository; this.fitRepository = fitRepository; this.exportFitWorkflow = exportFitWorkflow; this.vmdDisplayWorkflow = vmdDisplayWorkflow; setupTable();//from w ww . j av a 2 s. com lj_attype.setCellValueFactory(new PropertyValueFactory<>("attype")); lj_epsilon.setCellValueFactory(new PropertyValueFactory<>("epsilon")); lj_sigma.setCellValueFactory(new PropertyValueFactory<>("sigma")); lj_attype.setCellFactory(TextFieldTableCell.forTableColumn()); lj_epsilon.setCellFactory(TextFieldTableCell.forTableColumn()); lj_sigma.setCellFactory(TextFieldTableCell.forTableColumn()); this.lj_gridValues = FXCollections.observableArrayList(); this.lj_gridValues.add( new ljparams("HCarCarCar", "-0.046", String.format("%.4f", 2 * 1.1000 / Math.pow(2.0, 1.0 / 6.0)))); this.lj_gridValues.add(new ljparams("BrCarCarCar", "-0.420", String.format("%.4f", 2 * 2.0700 / Math.pow(2.0, 1.0 / 6.0)))); this.lj_gridValues.add(new ljparams("CarCarCarBr", "-0.070", String.format("%.4f", 2 * 1.9924 / Math.pow(2.0, 1.0 / 6.0)))); this.lj_gridValues.add( new ljparams("CarCarCarH", "-0.070", String.format("%.4f", 2 * 1.9924 / Math.pow(2.0, 1.0 / 6.0)))); this.lj_table.getItems().setAll(lj_gridValues); }
From source file:com.ggvaidya.scinames.ui.DatasetDiffController.java
private ObservableList<String> getComparisonStatRowHeaders() { ObservableList<String> rowHeader = FXCollections.observableArrayList(); rowHeader.add("Number of rows"); rowHeader.add("Number of columns"); rowHeader.add("Number of names recognized"); rowHeader.add("Number of names in rows"); rowHeader.add("Number of binomial names recognized"); rowHeader.add("Number of binomial names in rows"); rowHeader.add("Number of changes"); Project project = datasetDiffView.getProjectView().getProject(); rowHeader.addAll(project.getChanges().map(ch -> ch.getType()).distinct().sorted() .map(type -> "Number of changes of type '" + type.getType() + "'").collect(Collectors.toList())); return rowHeader; }