List of usage examples for javafx.collections ObservableList add
boolean add(E e);
From source file:de.bayern.gdi.gui.Controller.java
private void setCrsAndExtent(WFSMeta.Feature feature) { wmsWfsMapHandler.setExtend(feature.getBBox()); ArrayList<String> list = new ArrayList<>(); list.add(feature.getDefaultCRS());//from w w w. j a va 2 s . com list.addAll(feature.getOtherCRSs()); ObservableList<CRSModel> crsList = FXCollections.observableArrayList(); for (String crsStr : list) { try { String newcrsStr = crsStr; String seperator = null; if (newcrsStr.contains("::")) { seperator = "::"; } else if (newcrsStr.contains("/")) { seperator = "/"; } if (seperator != null) { newcrsStr = "EPSG:" + newcrsStr.substring(newcrsStr.lastIndexOf(seperator) + seperator.length(), newcrsStr.length()); } CoordinateReferenceSystem crs = CRS.decode(newcrsStr); CRSModel crsm = new CRSModel(crs); crsm.setOldName(crsStr); crsList.add(crsm); } catch (FactoryException e) { log.error(e.getMessage(), e); } } if (!crsList.isEmpty()) { this.referenceSystemChooser.setItems(crsList); CRSModel crsm = crsList.get(0); try { CoordinateReferenceSystem initCRS = CRS.decode(INITIAL_CRS_DISPLAY); CRSModel initCRSM = new CRSModel(initCRS); for (int i = 0; i < crsList.size(); i++) { if (crsList.get(i).equals(initCRSM)) { crsm = crsList.get(i); break; } } } catch (FactoryException e) { log.error(e.getMessage(), e); } this.referenceSystemChooser.setValue(crsm); } }
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);// ww w .j a v a 2 s . c o m cuTaMe.setMedicines(medicine); ctMeds.add(cuTaMe); } return ctMeds; }
From source file:org.beryx.viewreka.fxapp.Viewreka.java
public void openFile(File file) { if (file != null && file.isFile()) { String filePath = file.getAbsolutePath(); ObservableList<Tab> tabs = projectTabPane.getTabs(); if (project != null) { if (file.toURI().normalize().equals(project.getScriptUri().normalize())) { menuTabBindingSourceCode.showTab(); return; }// w w w . java2 s . c o m ProjectSettings projectSettings = project.getProjectSettingsManager().getSettings(); List<String> openFiles = getOpenFiles(projectSettings); int index = openFiles.indexOf(filePath); if (index >= 0) { if (index >= tabs.size()) { Dialogs.error("Open File error", "Internal error: invalid index (" + index + ") for already open file."); } else { Tab tab = tabs.get(index); if (!filePath.equals(getData(tab).getFilePath())) { Dialogs.error("Open File error", "Internal error: already open file not found at the expected index " + index + "."); } else { projectTabPane.getSelectionModel().select(index); } } return; } } if (file.length() > MAX_TEXT_FILE_LENGTH) { Dialogs.error("Open File error", "File too big (" + file.length() + " bytes)."); return; } if (isProbablyBinary(file)) { if (!Dialogs.confirmYesNo("Open File", "This seems to be a binary file.", "Are you sure you want to open this file?")) { return; } } try { CodeAreaTab codeAreaTab = CodeAreaTab.fromFile(file); tabs.add(codeAreaTab); projectTabPane.getSelectionModel().select(codeAreaTab); if (project != null) { ProjectSettings projectSettings = project.getProjectSettingsManager().getSettings(); List<String> openFiles = getOpenFiles(projectSettings); openFiles.add(filePath); codeAreaTab.setOnCloseRequest(ev -> { if (!tryClose(codeAreaTab)) ev.consume(); }); } } catch (IOException e) { Dialogs.error("Open File error", "Cannot open file '" + filePath + "'", e); return; } } }
From source file:gmailclientfx.controllers.SpamController.java
public void fetchSpam() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacFrom.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); spamTable.setItems(data);//from ww w . ja v a 2 s. co m spamTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = spamTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder spam = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Junk".equals(att)) { spam = f; } } } spam.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) spam .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "SPAM"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) spam .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "SPAM"); data.add(msg); } spam.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(SpamController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gmailclientfx.controllers.PoslaneController.java
public void fetchPoslane() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacTo.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); poslaneTable.setItems(data);/*from w w w . ja va 2s . co m*/ poslaneTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = poslaneTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder poslane = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Sent".equals(att)) { poslane = f; } } } poslane.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) poslane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "SENT"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) poslane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "SENT"); data.add(msg); } poslane.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(PoslaneController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gmailclientfx.controllers.InboxController.java
public void fetchInbox() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacPosiljatelj.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); Platform.runLater(() -> {/*from w w w. ja va 2 s . c o m*/ inboxTable.setItems(data); }); inboxTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = inboxTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_WRITE); int getSeenCount = inbox.getMessageCount(); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfileItem.FLAGS); fp.add(FetchProfileItem.CONTENT_INFO); fp.add("X-mailer"); MimeMessage[] seenMessages = (MimeMessage[]) inbox .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "INBOX"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) inbox .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "INBOX"); data.add(msg); } inbox.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gmailclientfx.controllers.ObrisaneController.java
public void fetchObrisane() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacFrom.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); obrisaneTable.setItems(data);//from w ww.ja v a 2 s .co m obrisaneTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = obrisaneTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder obrisane = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Trash".equals(att)) { obrisane = f; } } } obrisane.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) obrisane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "DELETED"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) obrisane .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "DELETED"); data.add(msg); } obrisane.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(ObrisaneController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gmailclientfx.controllers.NedovrseneController.java
public void fetchNedovrsene() { ObservableList<MyMessage> data = FXCollections.observableArrayList(); stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId")); stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject")); stupacTo.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender")); stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived")); nedovrseneTable.setItems(data);//from ww w .j a v a 2 s . c o m nedovrseneTable.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MyMessage selectedMsg = nedovrseneTable.getSelectionModel().getSelectedItem(); PregledEmailaHelper.setMsg(selectedMsg); try { Parent root; FXMLLoader loader = new FXMLLoader(); loader.setLocation( getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml")); root = loader.load(); Stage stage = new Stage(); stage.setScene(new Scene(root)); stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - " + PregledEmailaHelper.getMsg().getSender()); stage.show(); PregledEmailaController pgec = loader.getController(); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { pgec.bodyWebViewEngine.load(null); System.out.println("Closing form!"); } }); } catch (IOException ex) { Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex); } } } }); try { IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(), GmailClient.getAccesToken(), true); Folder nedovrsene = null; Folder[] folders = store.getDefaultFolder().list("*"); for (Folder f : folders) { IMAPFolder imapFolder = (IMAPFolder) f; for (String att : imapFolder.getAttributes()) { if ("\\Drafts".equals(att)) { nedovrsene = f; } } } nedovrsene.open(Folder.READ_WRITE); MimeMessage[] seenMessages = (MimeMessage[]) nedovrsene .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true)); for (int i = 0; i < seenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "DRAFT"); data.add(msg); } MimeMessage[] unseenMessages = (MimeMessage[]) nedovrsene .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false)); for (int i = 0; i < unseenMessages.length; i++) { MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "DRAFT"); data.add(msg); } nedovrsene.close(false); store.close(); } catch (Exception ex) { Logger.getLogger(NedovrseneController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.chart.SwingChart.java
/** * Series edition// ww w. jav a 2 s . c om * @param series Series to edit */ void editSeries(final Series series) { String[] style = series.getStyle().split(";"); String strColor = "black"; final TextField editWidth = new TextField(); String tempS = "null"; for (String e : style) { if (e.contains("color: ")) { strColor = e.replace("color: ", ""); } else if (e.contains("width: ")) { editWidth.setText(e.replace("width: ", "")); } else if (e.contains("shape: ")) { tempS = e.replace("shape: ", ""); } } final String symbol = tempS; final List<SeriesShape> symbolList = new ArrayList<>(); final ObservableList<SeriesShape> symbolListModel; final ListView<SeriesShape> comboSymbol = new ListView(); symbolList.add(new SeriesShape("null", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("crux", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(strColor))); symbolListModel = FXCollections.observableList(symbolList); comboSymbol.setItems(symbolListModel); comboSymbol.setCellFactory(new Callback<ListView<SeriesShape>, ListCell<SeriesShape>>() { @Override public ListCell<SeriesShape> call(ListView<SeriesShape> p) { ListCell<SeriesShape> cell = new ListCell<SeriesShape>() { @Override protected void updateItem(SeriesShape t, boolean bln) { super.updateItem(t, bln); if (t != null) { setText(""); setGraphic(t.getShapeGraphic()); } } }; return cell; } }); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } final ColorPicker colorPicker = new ColorPicker(javafx.scene.paint.Color.web(strColor)); colorPicker.setOnAction((ActionEvent t) -> { String sc = colorPicker.getValue().toString(); symbolListModel.clear(); symbolListModel.add(new SeriesShape("null", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("crux", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(sc))); comboSymbol.setItems(symbolListModel); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } }); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Series"), 0, 0); grid.add(new Label(series.getKey().toString()), 1, 0); grid.add(new Label("Color"), 0, 1); grid.add(colorPicker, 1, 1); grid.add(new Label("Width"), 0, 2); grid.add(editWidth, 1, 2); grid.add(new Label("Shape"), 0, 3); grid.add(comboSymbol, 1, 3); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { String strColor = colorPicker.getValue().toString(); String strWidth = editWidth.getText(); double dWidth = Double.valueOf(strWidth); String strSimbolo = "null"; SeriesShape simb = new SeriesShape(comboSymbol.getSelectionModel().getSelectedItem().toString(), javafx.scene.paint.Color.web(strColor)); XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(series.getAxisIndex()); renderer.setSeriesPaint(series.getSeriesIndex(), scene2awtColor(colorPicker.getValue())); try { if (Double.valueOf(strWidth) > 0) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), true); renderer.setSeriesStroke(series.getSeriesIndex(), new BasicStroke(Integer.valueOf(strWidth))); } else { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), false); } } catch (NumberFormatException ex) { } if (simb.getName().contains("null")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), false); renderer.setSeriesShape(series.getSeriesIndex(), null); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), true); renderer.setSeriesShape(series.getSeriesIndex(), simb.getShapeAWT()); if (simb.getName().contains("empty")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), false); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), true); } } series.setStyle( "color: " + strColor + ";width: " + editWidth.getText() + ";shape: " + strSimbolo + ";"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { if (((Label) nn).getText().equals(series.getKey().toString())) { ((Label) nn).setGraphic(simb.getShapeGraphic()); } } } } } return true; } }.show(); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsModel.java
public void readReports() { int start = getData().size() - 1; if (start < 0) { start = 0;/* ww w .j a v a 2 s.c om*/ } int count = reports_loaded; ObservableList<ReportRow> rows = FXCollections.observableArrayList(new ArrayList<>()); String baseDir = ReportGenerator.getReportsFolder(); File reportsDir = new File(baseDir); if (reportsDir.exists()) { String[] directories = reportsDir.list((current, name) -> new File(current, name).isDirectory()); Arrays.sort(directories, Collections.reverseOrder()); int index = 0; for (int i = 0; i < directories.length; i++) { String reportDay = directories[i]; File reportsDay = new File(baseDir + "/" + reportDay); String[] directories2 = reportsDay.list((current, name) -> new File(current, name).isDirectory()); // Convert to ints for ordering Integer[] int_directories = new Integer[directories2.length]; for (int j = 0; j < directories2.length; j++) { try { int_directories[j] = Integer.parseInt(directories2[j]); } catch (Exception ex) { context.send(BasicConfig.MODULE_MESSAGE, new LogMessage(getClass(), Level.DEBUG, bundle.getString("incorrectReport") + ": " + directories2[j])); int_directories[j] = -1; } } Arrays.sort(int_directories, Collections.reverseOrder()); if (index + directories2.length >= start) { String[] available_formats = { "html", "xml", "json", "pdf" }; for (int j = 0; j < int_directories.length; j++) { if (int_directories[j] < 0) continue; String reportDir = String.valueOf(int_directories[j]); if (index >= start && index < start + count) { ReportRow rr = null; File reportXml = new File(baseDir + "/" + reportDay + "/" + reportDir + "/summary.xml"); File reportJson = new File( baseDir + "/" + reportDay + "/" + reportDir + "/summary.json"); File reportHtml = new File( baseDir + "/" + reportDay + "/" + reportDir + "/report.html"); File reportPdf = new File(baseDir + "/" + reportDay + "/" + reportDir + "/report.pdf"); if (reportXml.exists() && reportXml.length() > 0) { rr = ReportRow.createRowFromXml(reportDay, reportXml, getBundle()); } if (rr == null && reportJson.exists() && reportJson.length() > 0) { rr = ReportRow.createRowFromJson(reportDay, reportJson, getBundle()); } if (rr == null && reportHtml.exists() && reportHtml.length() > 0) { rr = ReportRow.createRowFromHtml(reportDay, reportHtml, getBundle()); } if (rr == null && reportPdf.exists() && reportPdf.length() > 0) { rr = ReportRow.createRowFromPdf(reportDay, reportPdf, getBundle()); } if (rr != null) { // Add formats for (String format : available_formats) { File report; if (format == "json" || format == "xml") { report = new File( baseDir + "/" + reportDay + "/" + reportDir + "/summary." + format); } else { report = new File( baseDir + "/" + reportDay + "/" + reportDir + "/report." + format); } if (report.exists() && report.length() > 0) { rr.addFormat(format, report.getPath()); } } // Add mets File folder = new File(baseDir + "/" + reportDay + "/" + reportDir + "/"); if (folder.exists() && folder.isDirectory()) { String[] filter = { "mets.xml" }; Collection<File> childs = FileUtils.listFiles(folder, filter, false); if (childs.size() > 0) { rr.addFormat("mets", folder.getPath()); } } rows.add(rr); index++; } // Check if all done if (i == directories.length - 1 && j == directories2.length - 1) { all_reports_loaded = true; } } else { index++; } } } else { index += directories2.length; } } } data.addAll(rows); }