List of usage examples for javafx.stage FileChooser FileChooser
FileChooser
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
@FXML private void onActionButtonSaveCanopyAnalyzerDirections(ActionEvent event) { ChoiceDialog<String> choiceDialog = new ChoiceDialog<>(); choiceDialog.getItems().addAll("OBJ", "CSV (spherical coordinates)", "CSV (cartesian coordinates)"); choiceDialog.setSelectedItem("OBJ"); choiceDialog.setTitle("Output format"); choiceDialog.setContentText("Choose the output format"); Optional<String> result = choiceDialog.showAndWait(); if (result.isPresent()) { String format = result.get(); boolean csv = (format.equals("CSV (spherical coordinates)") || format.equals("CSV (cartesian coordinates)")); boolean cartesian = format.equals("CSV (cartesian coordinates)") && csv; FileChooser fc = new FileChooser(); File selectedFile = fc.showSaveDialog(stage); if (selectedFile != null) { LAI2xxx lAi2xxx = new LAI2200( comboboxChooseCanopyAnalyzerSampling.getSelectionModel().getSelectedItem(), LAI2xxx.ViewCap.CAP_360, new boolean[] { false, false, false, false, false }); lAi2xxx.computeDirections(); Vector3f[] directions = lAi2xxx.getDirections(); try (BufferedWriter writer = new BufferedWriter(new FileWriter(selectedFile))) { if (csv) { if (cartesian) { writer.write("X_cartesian Y_cartesian Z_cartesian\n"); } else { writer.write("azimut elevation\n"); }//from w w w .j a v a 2 s. c om } SphericalCoordinates sc = new SphericalCoordinates(); for (Vector3f direction : directions) { if (csv) { if (cartesian) { writer.write(direction.x + " " + direction.y + " " + direction.z + "\n"); } else { sc.toSpherical(new Vector3d(direction)); writer.write(sc.getAzimut() + " " + sc.getZenith() + "\n"); } } else { writer.write("v " + direction.x + " " + direction.y + " " + direction.z + "\n"); } } } catch (IOException ex) { showErrorDialog(ex); } } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @throws InterruptedException Exception interruption *//*from www .j a va2 s.c om*/ private static void panoramiquesAjouter() throws InterruptedException { FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilterImage = new FileChooser.ExtensionFilter( "Fichiers Image (JPG,BMP,TIFF)", "*.jpg", "*.bmp", "*.tif"); FileChooser.ExtensionFilter extFilterJpeg = new FileChooser.ExtensionFilter("Fichiers JPEG (*.jpg)", "*.jpg"); FileChooser.ExtensionFilter extFilterBmp = new FileChooser.ExtensionFilter("Fichiers BMP (*.bmp)", "*.bmp"); FileChooser.ExtensionFilter extFilterTiff = new FileChooser.ExtensionFilter("Fichiers TIFF (*.tif)", "*.tif"); File fileRepert = new File(getStrCurrentDir() + File.separator); fileChooser.setInitialDirectory(fileRepert); fileChooser.getExtensionFilters().addAll(extFilterJpeg, extFilterTiff, extFilterBmp, extFilterImage); List<File> listFichiers = fileChooser.showOpenMultipleDialog(null); if (listFichiers != null) { getApAttends().setVisible(true); mbarPrincipal.setDisable(true); bbarPrincipal.setDisable(true); hbBarreBouton.setDisable(true); pbarAvanceChargement.setProgress(-1); tpEnvironnement.setDisable(true); int i = 0; File[] fileLstFich1 = new File[listFichiers.size()]; String[] typeFich1 = new String[listFichiers.size()]; for (File fileFichier : listFichiers) { fileLstFich1[i] = fileFichier; i++; } int iNb = i; lblDragDrop.setVisible(false); Task taskTraitementChargeFichiers; taskTraitementChargeFichiers = tskChargeListeFichiers(fileLstFich1, iNb); Thread thrChargeFichiers = new Thread(taskTraitementChargeFichiers); thrChargeFichiers.setDaemon(true); thrChargeFichiers.start(); } }
From source file:snpviewer.SnpViewer.java
public void writeSavedRegionsToFile() { if (savedRegions.size() < 1) { Dialogs.showErrorDialog(null, "No Saved Regions exist to write!", "No Saved Regions", "SnpViewer"); return;/* ww w .java 2 s . com*/ } final int flanks = 10; FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("Excel (*.xlsx)", "*.xlsx"); fileChooser.getExtensionFilters().add(extFilter); fileChooser.setTitle("Write regions to Excel file (.xlsx)..."); File rFile = fileChooser.showSaveDialog(mainWindow); if (rFile == null) { return; } else if (!rFile.getName().endsWith(".xlsx")) { rFile = new File(rFile.getAbsolutePath() + ".xlsx"); } final File regionFile = rFile; final Task<Boolean> writeTask = new Task() { @Override protected Boolean call() throws Exception { try { updateProgress(-1, -1); BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(regionFile)); Workbook wb = new XSSFWorkbook(); //first create a summary sheet of all regions Sheet sheet = wb.createSheet(); Row row = null; int rowNo = 0; int sheetNo = 0; wb.setSheetName(sheetNo++, "Summary"); row = sheet.createRow(rowNo++); String header[] = { "Coordinates", "rsIDs", "Size (Mb)" }; for (int col = 0; col < header.length; col++) { Cell cell = row.createCell(col); cell.setCellValue(header[col]); } for (int i = 0; i < savedRegions.size(); i++) { row = sheet.createRow(rowNo++); int col = 0; Cell cell = row.createCell(col++); cell.setCellValue("chr" + savedRegions.get(i).getCoordinateString()); cell = row.createCell(col++); cell.setCellValue(savedRegions.get(i).getIdLine()); cell = row.createCell(col++); double mB = (double) savedRegions.get(i).getLength() / 1000000; cell.setCellValue(mB); } ArrayList<SnpFile> bothFiles = new ArrayList<>(); bothFiles.addAll(affFiles); bothFiles.addAll(unFiles); String prevChrom = new String(); double prog = 0; double total = savedRegions.size() * bothFiles.size() * 2; updateProgress(prog, total); int regCounter = 0; for (RegionSummary reg : savedRegions) { updateMessage("Writing region " + ++regCounter + " of " + savedRegions.size()); //create a sheet for each chromosome if (!reg.getChromosome().equalsIgnoreCase(prevChrom)) { if (!prevChrom.isEmpty()) { CellRangeAddress[] regions = { new CellRangeAddress(0, rowNo, 2, 2 + bothFiles.size()) }; SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting(); ConditionalFormattingRule rule1 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"AA\""); PatternFormatting fill1 = rule1.createPatternFormatting(); fill1.setFillBackgroundColor(IndexedColors.LIGHT_GREEN.index); fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND); ConditionalFormattingRule rule2 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"BB\""); PatternFormatting fill2 = rule2.createPatternFormatting(); fill2.setFillBackgroundColor(IndexedColors.PALE_BLUE.index); fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); ConditionalFormattingRule rule3 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"AB\""); PatternFormatting fill3 = rule3.createPatternFormatting(); fill3.setFillBackgroundColor(IndexedColors.ROSE.index); fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND); sheetCF.addConditionalFormatting(regions, rule3, rule2); sheetCF.addConditionalFormatting(regions, rule1); } rowNo = 0; sheet = wb.createSheet(); wb.setSheetName(sheetNo++, reg.getChromosome()); prevChrom = reg.getChromosome(); } else {//pad regions with an empty line rowNo++; } TreeMap<Integer, HashMap<String, String>> coordMap = new TreeMap(); /*coordmap - key is position, key of hashmap * is input filename and value call */ HashMap<Integer, String> coordToId = new HashMap<>(); //coordinate to rs ID try { for (SnpFile f : bothFiles) { updateProgress(prog++, total); if (isCancelled()) { return false; } List<SnpFile.SnpLine> lines = f.getSnpsInRegion(reg.getChromosome(), reg.getStartPos(), reg.getEndPos(), flanks); for (SnpFile.SnpLine snpLine : lines) { if (isCancelled()) { return false; } Integer coord = snpLine.getPosition(); if (!coordMap.containsKey(coord)) { coordMap.put(coord, new HashMap<String, String>()); } String filename = f.inputFile.getName(); String rsId = snpLine.getId(); String call = snpLine.getCall(); coordMap.get(coord).put(filename, call); coordToId.put(coord, rsId); } } row = sheet.createRow(rowNo++); Cell cell = row.createCell(0); cell.setCellValue(reg.getCoordinateString()); row = sheet.createRow(rowNo++); cell = row.createCell(0); cell.setCellValue(reg.getIdLine()); int col = 0; row = sheet.createRow(rowNo++); cell = row.createCell(col++); cell.setCellValue("Position"); cell = row.createCell(col++); cell.setCellValue("rsID"); for (SnpFile f : bothFiles) { updateProgress(prog++, total); cell = row.createCell(col++); if (f.getSampleName() != null && !f.getSampleName().isEmpty()) { cell.setCellValue(f.getSampleName()); } else { cell.setCellValue(f.inputFile.getName()); } } for (Entry current : coordMap.entrySet()) { if (isCancelled()) { return false; } col = 0; Integer coord = (Integer) current.getKey(); row = sheet.createRow(rowNo++); cell = row.createCell(col++); cell.setCellValue(coord); cell = row.createCell(col++); cell.setCellValue(coordToId.get(coord)); HashMap<String, String> fileToCall = (HashMap<String, String>) current.getValue(); for (SnpFile f : bothFiles) { cell = row.createCell(col++); if (fileToCall.containsKey(f.inputFile.getName())) { cell.setCellValue(fileToCall.get(f.inputFile.getName())); } else { cell.setCellValue("-"); } } } } catch (Exception ex) { return false; } } CellRangeAddress[] regions = { new CellRangeAddress(0, rowNo, 2, 2 + bothFiles.size()) }; SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting(); ConditionalFormattingRule rule1 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"AA\""); PatternFormatting fill1 = rule1.createPatternFormatting(); fill1.setFillBackgroundColor(IndexedColors.LIGHT_GREEN.index); fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND); ConditionalFormattingRule rule2 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"BB\""); PatternFormatting fill2 = rule2.createPatternFormatting(); fill2.setFillBackgroundColor(IndexedColors.PALE_BLUE.index); fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); ConditionalFormattingRule rule3 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"AB\""); PatternFormatting fill3 = rule3.createPatternFormatting(); fill3.setFillBackgroundColor(IndexedColors.ROSE.index); fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND); sheetCF.addConditionalFormatting(regions, rule3, rule2); sheetCF.addConditionalFormatting(regions, rule1); wb.write(out); updateProgress(total, total); out.close(); } catch (IOException | NumberFormatException ex) { ex.printStackTrace(); return false; } return true; } };//end of task setProgressMode(true); progressBar.progressProperty().bind(writeTask.progressProperty()); progressMessage.textProperty().bind(writeTask.messageProperty()); writeTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { if (e.getSource().getValue() == true) { Dialogs.showInformationDialog(null, "Saved regions written " + "to file " + "(" + regionFile.getName() + ")successfully", "Regions Written", "SNP Viewer"); } else { Dialogs.showErrorDialog(null, "Region write failed.", "Write Failed", "SNP Viewer"); } setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.progressProperty().set(0); progressMessage.textProperty().unbind(); progressMessage.setText(""); progressTitle.setText(""); } }); writeTask.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.progressProperty().set(0); progressMessage.textProperty().unbind(); progressMessage.setText(""); progressTitle.setText("Region write failed!"); Dialogs.showErrorDialog(null, "Error writing region to file\n", "Region write error", "SNP Viewer", e.getSource().getException()); } }); writeTask.setOnCancelled(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { progressMessage.setText("Region write cancelled"); progressTitle.setText("Cancelled"); setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.progressProperty().set(0); Dialogs.showErrorDialog(null, "Error writing region to file\n", "Region write error", "SNP Viewer"); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { writeTask.cancel(); } }); progressTitle.setText("Writing regions to .xlsx file"); new Thread(writeTask).start(); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *///www. j av a 2s . com private static void planAjouter() { FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilterJpeg = new FileChooser.ExtensionFilter("Fichiers JPEG (*.jpg)", "*.jpg"); FileChooser.ExtensionFilter extFilterBmp = new FileChooser.ExtensionFilter("Fichiers BMP (*.bmp)", "*.bmp"); FileChooser.ExtensionFilter extFilterPng = new FileChooser.ExtensionFilter("Fichiers PNG (*.png)", "*.png"); File repert = new File(getStrCurrentDir() + File.separator); fileChooser.setInitialDirectory(repert); fileChooser.getExtensionFilters().addAll(extFilterJpeg, extFilterPng, extFilterBmp); File fileFichierPlan = fileChooser.showOpenDialog(null); if (fileFichierPlan != null) { getPlans()[getiNombrePlans()] = new Plan(); getPlans()[getiNombrePlans()].setStrImagePlan(fileFichierPlan.getName()); getPlans()[getiNombrePlans()].setStrLienPlan(fileFichierPlan.getAbsolutePath()); File fileRepertoirePlan = new File(getStrRepertTemp() + File.separator + "images"); if (!fileRepertoirePlan.exists()) { fileRepertoirePlan.mkdirs(); } try { copieFichierRepertoire(fileFichierPlan.getAbsolutePath(), fileRepertoirePlan.getAbsolutePath()); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } getGestionnairePlan().ajouterPlan(); setiNombrePlans(getiNombrePlans() + 1); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @throws IOException Exception d'entre sortie * @throws InterruptedException Exception interruption *///from w w w. ja va 2s . com private static void projetCharge() throws IOException, InterruptedException { if (!bRepertSauveChoisi) { setStrRepertoireProjet(getStrCurrentDir()); } ButtonType reponse = null; ButtonType buttonTypeOui = new ButtonType(rbLocalisation.getString("main.oui")); ButtonType buttonTypeNon = new ButtonType(rbLocalisation.getString("main.non")); ButtonType buttonTypeAnnule = new ButtonType(rbLocalisation.getString("main.annuler")); if (!isbDejaSauve()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setHeaderText(null); alert.setTitle(rbLocalisation.getString("main.dialog.chargeProjet")); alert.setContentText(rbLocalisation.getString("main.dialog.chargeProjetMessage")); alert.getButtonTypes().clear(); alert.getButtonTypes().setAll(buttonTypeOui, buttonTypeNon, buttonTypeAnnule); Optional<ButtonType> actReponse = alert.showAndWait(); reponse = actReponse.get(); } if (reponse == buttonTypeOui) { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } if ((reponse == buttonTypeOui) || (reponse == buttonTypeNon) || (reponse == null)) { panePanoramique.getChildren().clear(); panePanoramique.getChildren().add(ivImagePanoramique); getApAttends().setVisible(true); mbarPrincipal.setDisable(true); bbarPrincipal.setDisable(true); hbBarreBouton.setDisable(true); tpEnvironnement.setDisable(true); setbDejaSauve(true); FileChooser fcRepertChoix = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("fichier panoVisu (*.pvu)", "*.pvu"); fcRepertChoix.getExtensionFilters().add(extFilter); File fileRepert = new File(getStrRepertoireProjet() + File.separator); fcRepertChoix.setInitialDirectory(fileRepert); fileProjet = null; fileProjet = fcRepertChoix.showOpenDialog(getStPrincipal()); if (fileProjet != null) { getStPrincipal().setTitle( "Panovisu v" + strNumVersion.split("-")[0] + " : " + fileProjet.getAbsolutePath()); lblDragDrop.setVisible(false); setStrRepertoireProjet(fileProjet.getParent()); ajouteFichierHisto(fileProjet.getAbsolutePath()); bRepertSauveChoisi = true; deleteDirectory(getStrRepertTemp()); String strRepertPanovisu = getStrRepertTemp() + File.separator + "panovisu"; File fileRptPanovisu = new File(strRepertPanovisu); fileRptPanovisu.mkdirs(); copieRepertoire(getStrRepertAppli() + File.separator + "panovisu", strRepertPanovisu); mnuPanoramique.setDisable(false); btnMnuPanoramique.setDisable(false); ivAjouterPano.setDisable(false); ivAjouterPano.setOpacity(1.0); ivSauveProjet.setDisable(false); ivSauveProjet.setOpacity(1.0); ivVisiteGenere.setDisable(false); ivVisiteGenere.setOpacity(1.0); getVbChoixPanoramique().setVisible(false); mniSauveProjet.setDisable(false); mniSauveSousProjet.setDisable(false); mniVisiteGenere.setDisable(false); setiNumPoints(0); setiNumImages(0); setiNombreDiapo(0); diaporamas = new Diaporama[100]; setiNumHTML(0); ivImagePanoramique.setImage(null); cbListeChoixPanoramique.getItems().clear(); try { String strTexte; try (BufferedReader brFichierPVU = new BufferedReader( new InputStreamReader(new FileInputStream(fileProjet), "UTF-8"))) { strTexte = ""; String strLigneTexte; setiNombrePanoramiquesFichier(0); while ((strLigneTexte = brFichierPVU.readLine()) != null) { if (strLigneTexte.contains("Panoramique=>")) { setiNombrePanoramiquesFichier(getiNombrePanoramiquesFichier() + 1); } strTexte += strLigneTexte + "\n"; } } Task taskAnalysePVU; taskAnalysePVU = tskAnalyseFichierPVU(strTexte); Thread thrAnalysePVU = new Thread(taskAnalysePVU); thrAnalysePVU.setDaemon(true); thrAnalysePVU.start(); } catch (FileNotFoundException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:snpviewer.SnpViewer.java
public void writeRegionToFile(final String chromosome, final double start, final double end) { /* get coordinates of selection and report back * write SNPs in region to file//from w w w.j ava 2 s . c o m */ FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("Excel (*.xlsx)", "*.xlsx"); fileChooser.getExtensionFilters().add(extFilter); fileChooser.setTitle("Write region to Excel file (.xlsx)..."); File rFile = fileChooser.showSaveDialog(mainWindow); if (rFile == null) { return; } else if (!rFile.getName().endsWith(".xlsx")) { rFile = new File(rFile.getAbsolutePath() + ".xlsx"); } final File regionFile = rFile; final Task<Boolean> writeTask = new Task() { @Override protected Boolean call() throws Exception { try { updateProgress(-1, -1); ArrayList<SnpFile> bothFiles = new ArrayList<>(); bothFiles.addAll(affFiles); bothFiles.addAll(unFiles); TreeMap<Integer, HashMap<String, String>> coordMap = new TreeMap(); /*coordmap - key is position, key of hashmap * is input filename and value call */ HashMap<Integer, String> coordToId = new HashMap<>(); double progress = 0; double total = bothFiles.size() * 5; try { BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(regionFile)); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(); int rowNo = 0; Row row = sheet.createRow(rowNo++); for (SnpFile f : bothFiles) { if (isCancelled()) { return false; } updateProgress(++progress, total); updateMessage("Reading region in " + f.inputFile.getName()); List<SnpFile.SnpLine> lines = f.getSnpsInRegion(chromosome, (int) start, (int) end); for (SnpFile.SnpLine snpLine : lines) { if (isCancelled()) { return false; } Integer coord = snpLine.getPosition(); if (!coordMap.containsKey(coord)) { coordMap.put(coord, new HashMap<String, String>()); } String filename = f.inputFile.getName(); String rsId = snpLine.getId(); String call = snpLine.getCall(); coordMap.get(coord).put(filename, call); coordToId.put(coord, rsId); } } Cell cell = row.createCell(0); cell.setCellValue( "chr" + chromosome + ":" + coordMap.firstKey() + "-" + coordMap.lastKey()); row = sheet.createRow(rowNo++); cell = row.createCell(0); cell.setCellValue( coordToId.get(coordMap.firstKey()) + ";" + coordToId.get(coordMap.lastKey())); row = sheet.createRow(rowNo++); int colNo = 0; cell = row.createCell(colNo++); cell.setCellValue("Position"); cell = row.createCell(colNo++); cell.setCellValue("rsID"); for (SnpFile f : bothFiles) { cell = row.createCell(colNo++); if (f.getSampleName() != null && f.getSampleName().length() > 0) { cell.setCellValue(f.getSampleName()); } else { cell.setCellValue(f.getInputFileName()); } } progress = coordMap.size(); total = 5 * coordMap.size(); updateMessage("Writing region to file..."); for (Entry current : coordMap.entrySet()) { if (isCancelled()) { return false; } progress += 4; updateProgress(progress, total); row = sheet.createRow(rowNo++); colNo = 0; Integer coord = (Integer) current.getKey(); cell = row.createCell(colNo++); cell.setCellValue(coord); String rsId = coordToId.get(coord); cell = row.createCell(colNo++); cell.setCellValue(rsId); HashMap<String, String> fileToCall = (HashMap<String, String>) current.getValue(); for (SnpFile f : bothFiles) { cell = row.createCell(colNo++); if (fileToCall.containsKey(f.inputFile.getName())) { cell.setCellValue(fileToCall.get(f.inputFile.getName())); } else { cell.setCellValue("-"); } } } CellRangeAddress[] regions = { new CellRangeAddress(0, rowNo, 2, 2 + bothFiles.size()) }; SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting(); ConditionalFormattingRule rule1 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"AA\""); PatternFormatting fill1 = rule1.createPatternFormatting(); fill1.setFillBackgroundColor(IndexedColors.LIGHT_GREEN.index); fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND); ConditionalFormattingRule rule2 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"BB\""); PatternFormatting fill2 = rule2.createPatternFormatting(); fill2.setFillBackgroundColor(IndexedColors.PALE_BLUE.index); fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND); ConditionalFormattingRule rule3 = sheetCF .createConditionalFormattingRule(ComparisonOperator.EQUAL, "\"AB\""); PatternFormatting fill3 = rule3.createPatternFormatting(); fill3.setFillBackgroundColor(IndexedColors.ROSE.index); fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND); sheetCF.addConditionalFormatting(regions, rule3, rule2); sheetCF.addConditionalFormatting(regions, rule1); wb.write(out); out.close(); return true; } catch (IOException ex) { return false; } } catch (Exception ex) { return false; } } };//end of task setProgressMode(true); progressBar.progressProperty().bind(writeTask.progressProperty()); progressMessage.textProperty().bind(writeTask.messageProperty()); writeTask.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { if (e.getSource().getValue() == true) { Dialogs.showInformationDialog(null, "Region written to file " + "(" + regionFile.getName() + ") successfully", "Region Written", "SNP Viewer"); } else { Dialogs.showErrorDialog(null, "Region write failed.", "Write Failed", "SNP Viewer"); } setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.progressProperty().set(0); progressMessage.textProperty().unbind(); progressMessage.setText(""); progressTitle.setText(""); } }); writeTask.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.progressProperty().set(0); progressMessage.textProperty().unbind(); progressMessage.setText(""); progressTitle.setText("Region write failed!"); Dialogs.showErrorDialog(null, "Error writing region to file\n", "Region write error", "SNP Viewer", e.getSource().getException()); } }); writeTask.setOnCancelled(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent e) { progressMessage.setText("Region write cancelled"); progressTitle.setText("Cancelled"); setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.progressProperty().set(0); Dialogs.showErrorDialog(null, "Error writing region to file\n", "Region write error", "SNP Viewer"); } }); cancelButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { writeTask.cancel(); } }); progressTitle.setText("Writing region to .xlsx file"); new Thread(writeTask).start(); }
From source file:editeurpanovisu.EditeurPanovisu.java
private void panoAjouteImage(double X, double Y) { if (X > 0 && X < imagePanoramique.getFitWidth()) { valideHS();//from ww w .j a v a2 s .co m dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - pano.getLayoutY() - 115; double longitude, latitude; double largeur = imagePanoramique.getFitWidth(); String chLong, chLat; longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; Circle point = new Circle(mouseX, mouseY, 5); point.setFill(Color.BLUE); point.setStroke(Color.YELLOW); point.setId("img" + numImages); point.setCursor(Cursor.DEFAULT); pano.getChildren().add(point); Tooltip t = new Tooltip("image n " + (numImages + 1)); t.setStyle(tooltipStyle); Tooltip.install(point, t); // File repert; if (repertHSImages.equals("")) { repert = new File(currentDir + File.separator); } else { repert = new File(repertHSImages); } FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilterImages = new FileChooser.ExtensionFilter( "Fichiers Images (jpg, bmp, png)", "*.jpg", "*.bmp", "*.png"); fileChooser.setInitialDirectory(repert); fileChooser.getExtensionFilters().addAll(extFilterImages); File fichierImage = fileChooser.showOpenDialog(null); if (fichierImage != null) { repertHSImages = fichierImage.getParent(); numImages++; HotspotImage HS = new HotspotImage(); HS.setLongitude(longitude); HS.setLatitude(latitude); HS.setUrlImage(fichierImage.getAbsolutePath()); HS.setLienImg(fichierImage.getName()); HS.setInfo(fichierImage.getName().split("\\.")[0]); File repertImage = new File(repertTemp + File.separator + "images"); if (!repertImage.exists()) { repertImage.mkdirs(); } try { copieFichierRepertoire(fichierImage.getAbsolutePath(), repertImage.getAbsolutePath()); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } panoramiquesProjet[panoActuel].addHotspotImage(HS); retireAffichageHotSpots(); Pane affHS1 = affichageHS(listePano(panoActuel), panoActuel); affHS1.setId("labels"); outils.getChildren().add(affHS1); } else { String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); Node pt = (Node) pano.lookup("#img" + chPoint); pano.getChildren().remove(pt); } valideHS(); point.setOnDragDetected((MouseEvent me1) -> { point.setFill(Color.YELLOW); point.setStroke(Color.BLUE); dragDrop = true; me1.consume(); }); point.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } point.setCenterX(XX + imagePanoramique.getLayoutX()); double YY = me1.getY(); if (YY < 0) { YY = 0; } if (YY > imagePanoramique.getFitHeight()) { YY = imagePanoramique.getFitHeight(); } point.setCenterY(YY); me1.consume(); }); point.setOnMouseReleased((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); double X1 = me1.getSceneX(); double Y1 = me1.getSceneY(); double mouseX1 = X1 - imagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > imagePanoramique.getFitWidth()) { mouseX1 = imagePanoramique.getFitWidth(); } double mouseY1 = Y1 - pano.getLayoutY() - 109; if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > imagePanoramique.getFitHeight()) { mouseY1 = imagePanoramique.getFitHeight(); } double longit, lat; double larg = imagePanoramique.getFitWidth(); longit = 360.0f * mouseX1 / larg - 180; lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f; panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLatitude(lat); panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLongitude(longit); point.setFill(Color.BLUE); point.setStroke(Color.YELLOW); me1.consume(); }); point.setOnMouseClicked((MouseEvent me1) -> { if (me1.isControlDown()) { dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); Node pt; pt = (Node) pano.lookup("#img" + chPoint); pano.getChildren().remove(pt); for (int o = numeroPoint + 1; o < numImages; o++) { pt = (Node) pano.lookup("#img" + Integer.toString(o)); pt.setId("img" + Integer.toString(o - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); numImages--; panoramiquesProjet[panoActuel].removeHotspotImage(numeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); } valideHS(); me1.consume(); }); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @throws IOException Exception d'entre sortie *//* ww w .j a v a2 s. c om*/ private static void projetSauve() throws IOException { if (!bRepertSauveChoisi) { setStrRepertoireProjet(getStrCurrentDir()); } if (fileProjet == null) { FileChooser fcRepertChoix = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("fichier panoVisu (*.pvu)", "*.pvu"); fcRepertChoix.getExtensionFilters().add(extFilter); File repert = new File(getStrRepertoireProjet() + File.separator); fcRepertChoix.setInitialDirectory(repert); fileProjet = fcRepertChoix.showSaveDialog(null); } if (fileProjet != null) { sauveFichierProjet(); ajouteFichierHisto(fileProjet.getAbsolutePath()); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @throws IOException Exception d'entre sortie *//*w w w .ja va2s .c o m*/ private static void projetSauveSous() throws IOException { if (!bRepertSauveChoisi) { setStrRepertoireProjet(getStrCurrentDir()); } FileChooser fcRepertChoix = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("fichier panoVisu (*.pvu)", "*.pvu"); fcRepertChoix.getExtensionFilters().add(extFilter); File fileRepert = new File(getStrRepertoireProjet() + File.separator); fcRepertChoix.setInitialDirectory(fileRepert); fileProjet = fcRepertChoix.showSaveDialog(null); if (fileProjet != null) { sauveFichierProjet(); ajouteFichierHisto(fileProjet.getAbsolutePath()); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * */// w ww .j a v a 2s . c om private void modeleSauver() throws IOException { File fichTemplate; FileChooser repertChoix = new FileChooser(); FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("fichier Modle panoVisu (*.tpl)", "*.tpl"); repertChoix.getExtensionFilters().add(extFilter); File repert = new File(repertAppli + File.separator + "templates"); if (!repert.exists()) { repert.mkdirs(); } repertChoix.setInitialDirectory(repert); fichTemplate = repertChoix.showSaveDialog(null); if (fichTemplate != null) { String contenuFichier = gestionnaireInterface.getTemplate(); fichTemplate.setWritable(true); FileWriter fw = new FileWriter(fichTemplate); try (BufferedWriter bw = new BufferedWriter(fw)) { bw.write(contenuFichier); } Dialogs.create().title("Sauvegarde du fichier de Modle") .message("Votre modle bien t sauvegard").showInformation(); } }