List of usage examples for java.awt Desktop isDesktopSupported
public static boolean isDesktopSupported()
From source file:Clavis.Windows.WShedule.java
public void createXLSDocument(String nome, String[][] valores) { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(nome); HSSFRow row;/*from ww w . j av a2s . co m*/ HSSFCell cell; for (int i = 0; i < valores.length; i++) { row = sheet.createRow(i); for (int j = 0; j < valores[i].length; j++) { cell = row.createCell(j); cell.setCellValue(valores[i][j]); if (valores[i][j] != null) { sheet.setColumnWidth(j, 255 * valores[i][j].length() + 4); CellUtil.setAlignment(cell, wb, CellStyle.ALIGN_CENTER); } } } wb.setPrintArea(0, 0, valores[0].length, 0, valores.length); sheet.getPrintSetup().setPaperSize(XSSFPrintSetup.A4_PAPERSIZE); FileOutputStream out; String sfile = new File("").getAbsolutePath() + System.getProperty("file.separator") + nome; File file = new File(sfile); if (!file.exists()) { try { file.createNewFile(); } catch (IOException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); } } if (file.canWrite()) { try { out = new FileOutputStream(file); } catch (FileNotFoundException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); out = null; } if (out != null) { try { wb.write(out); out.close(); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(file); } else { Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, painelcor, lingua.translate("Nota"), 400, 200, lingua.translate("O documento \"doc.xls\" foi criado na pasta raiz do programa") + ".", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); } } catch (IOException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:UserInfo_Frame.java
private void btn_openFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_openFileActionPerformed try {//from w w w . java 2 s . co m File Selection = new File(Jtreevar); if (Selection.exists()) { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(Selection); } else { JOptionPane.showMessageDialog(this, "Awt Desktop is not supported", "Error", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(this, "File does not exist", "Error", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception e) { e.printStackTrace(); } }
From source file:sdf_manager.ExporterSiteHTML.java
/** * * @return//from ww w. ja v a 2s . co m */ public Document processDatabase() { OutputStream os = null; Session session = HibernateUtil.getSessionFactory().openSession(); try { SDF_Util.getProperties(); DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Iterator itrSites = this.sitecodes.iterator(); int flush = 0; ExporterSiteHTML.log.info("Parsing sitecodes..."); Document doc = docBuilder.newDocument(); Element sdfs = doc.createElement("sdfs"); doc.appendChild(sdfs); while (itrSites.hasNext()) { Element sdf = doc.createElement("sdf"); Element siteIdentification = doc.createElement("siteIdentification"); Site site = (Site) session.get(Site.class, (String) itrSites.next()); // results.get(i); siteIdentification.appendChild(doc.createElement("siteType")) .appendChild(doc.createTextNode(fmt(site.getSiteType(), "siteType"))); siteIdentification.appendChild(doc.createElement("siteCode")) .appendChild(doc.createTextNode(fmt(site.getSiteCode().toUpperCase(), "siteCode"))); ExporterSiteHTML.log.info("Parsing sitecode:::" + site.getSiteCode()); siteIdentification.appendChild(doc.createElement("siteName")) .appendChild(doc.createTextNode(fmt(site.getSiteName(), "siteName"))); if (site.getSiteCompDate() != null) { siteIdentification.appendChild(doc.createElement("compilationDate")) .appendChild(doc.createTextNode( fmt(SDF_Util.getFormatDateToXML(site.getSiteCompDate()), "compilationDate"))); } if (site.getSiteUpdateDate() != null) { siteIdentification.appendChild(doc.createElement("updateDate")).appendChild(doc.createTextNode( fmt(SDF_Util.getFormatDateToXML(site.getSiteUpdateDate()), "updateDate"))); } Resp resp = site.getResp(); if (resp != null) { Element respNode = doc.createElement("respondent"); respNode.appendChild(doc.createElement("name")) .appendChild(doc.createTextNode(fmt(resp.getRespName(), "respName"))); if (resp.getRespAddressArea() != null && !resp.getRespAddressArea().equals("")) { Element addresElem = doc.createElement("address"); // THE NAME DOES NOT MATCH THEIR RESPECTIVES addresElem.appendChild(doc.createElement("adminUnit")) .appendChild(doc.createTextNode(fmt(resp.getRespAdminUnit(), "adminUnit"))); addresElem.appendChild(doc.createElement("thoroughfare")) .appendChild(doc.createTextNode(fmt(resp.getRespLocatorName(), "locatorName"))); addresElem.appendChild(doc.createElement("locatorDesignator")) .appendChild(doc.createTextNode(fmt(resp.getRespThoroughFare(), "thoroughfare"))); addresElem.appendChild(doc.createElement("postCode")) .appendChild(doc.createTextNode(fmt(resp.getRespAddressArea(), "addressArea"))); addresElem.appendChild(doc.createElement("postName")) .appendChild(doc.createTextNode(fmt(resp.getRespPostName(), "postName"))); addresElem.appendChild(doc.createElement("addressArea")) .appendChild(doc.createTextNode(fmt(resp.getRespPostCode(), "postCode"))); addresElem.appendChild(doc.createElement("locatorName")).appendChild( doc.createTextNode(fmt(resp.getRespLocatorDesig(), "locatorDesignator"))); respNode.appendChild(addresElem); } else { Element addresElem = doc.createElement("address"); addresElem.appendChild(doc.createElement("addressArea")) .appendChild(doc.createTextNode(fmt(resp.getRespAddress(), "addressArea"))); respNode.appendChild(addresElem); } respNode.appendChild(doc.createElement("email")) .appendChild(doc.createTextNode(fmt(resp.getRespEmail(), "respEmail"))); siteIdentification.appendChild(respNode); } if (SDF_ManagerApp.isEmeraldMode()) { XmlGenerationUtils.appendDateElement(site.getSiteProposedAsciDate(), siteIdentification, "asciProposalDate", doc); if (site.getSiteProposedAsciDate() == null) { XmlGenerationUtils.appendDateElement(XmlGenerationUtils.nullDate(), siteIdentification, "asciProposalDate", doc); } XmlGenerationUtils.appendDateElement(site.getSiteConfirmedCandidateAsciDate(), siteIdentification, "asciConfirmedCandidateDate", doc); XmlGenerationUtils.appendDateElement(site.getSiteConfirmedAsciDate(), siteIdentification, "asciConfirmationDate", doc); XmlGenerationUtils.appendDateElement(site.getSiteDesignatedAsciDate(), siteIdentification, "asciDesignationDate", doc); siteIdentification.appendChild(doc.createElement("asciLegalReference")) .appendChild(doc.createTextNode(fmt(site.getSiteAsciLegalRef(), "asciLegalReference"))); } else { if (site.getSiteSpaDate() != null) { siteIdentification.appendChild(doc.createElement("spaClassificationDate")).appendChild( doc.createTextNode(fmt(SDF_Util.getFormatDateToXML(site.getSiteSpaDate()), "spaClassificationDate"))); } else { siteIdentification.appendChild(doc.createElement("spaClassificationDate")) .appendChild(doc.createTextNode(fmt("0000-00", "spaClassificationDate"))); } siteIdentification.appendChild(doc.createElement("spaLegalReference")) .appendChild(doc.createTextNode(fmt(site.getSiteSpaLegalRef(), "spaLegalReference"))); if (site.getSiteSciPropDate() != null) { siteIdentification.appendChild(doc.createElement("sciProposalDate")).appendChild( doc.createTextNode(fmt(SDF_Util.getFormatDateToXML(site.getSiteSciPropDate()), "sciProposalDate"))); } if (site.getSiteSciConfDate() != null) { siteIdentification.appendChild(doc.createElement("sciConfirmationDate")).appendChild( doc.createTextNode(fmt(SDF_Util.getFormatDateToXML(site.getSiteSciConfDate()), "sciConfirmationDate"))); } if (site.getSiteSacDate() != null) { siteIdentification.appendChild(doc.createElement("sacDesignationDate")).appendChild( doc.createTextNode(fmt(SDF_Util.getFormatDateToXML(site.getSiteSacDate()), "sacDesignationDate"))); } siteIdentification.appendChild(doc.createElement("sacLegalReference")) .appendChild(doc.createTextNode(fmt(site.getSiteSacLegalRef(), "sacLegalReference"))); } siteIdentification.appendChild(doc.createElement("explanations")) .appendChild(doc.createTextNode(fmt(site.getSiteExplanations(), "explanations"))); sdf.appendChild(siteIdentification); /**************LOCATION***************/ Element location = doc.createElement("siteLocation"); location.appendChild(doc.createElement("longitude")) .appendChild(doc.createTextNode(fmt(site.getSiteLongitude(), "longitude"))); location.appendChild(doc.createElement("latitude")) .appendChild(doc.createTextNode(fmt(site.getSiteLatitude(), "latitude"))); location.appendChild(doc.createElement("area")) .appendChild(doc.createTextNode(fmt(site.getSiteArea(), "area"))); location.appendChild(doc.createElement("marineAreaPercentage")) .appendChild(doc.createTextNode(fmt(site.getSiteMarineArea(), "marineArea"))); location.appendChild(doc.createElement("siteLength")) .appendChild(doc.createTextNode(fmt(site.getSiteLength(), "siteLength"))); /*regions*/ Element regions = doc.createElement("adminRegions"); Set siteRegions = site.getRegions(); Iterator itr = siteRegions.iterator(); while (itr.hasNext()) { Region r = (Region) itr.next(); Element rElem = doc.createElement("region"); rElem.appendChild(doc.createElement("code")) .appendChild(doc.createTextNode(fmt(r.getRegionCode(), "regionCode"))); //descomentado--> adaptar nuevo xml rElem.appendChild(doc.createElement("name")) .appendChild(doc.createTextNode(fmt(r.getRegionName(), "regionName"))); regions.appendChild(rElem); } //adaptacion al nuevo xml location.appendChild(regions); /*bioregions*/ Element biogeoRegions = doc.createElement("biogeoRegions"); Set siteBioRegions = site.getSiteBiogeos(); if (!(siteBioRegions.isEmpty())) { Iterator itbr = siteBioRegions.iterator(); while (itbr.hasNext()) { SiteBiogeo s = (SiteBiogeo) itbr.next(); Element biogeoElement = doc.createElement("biogeoRegions"); Biogeo b = s.getBiogeo(); //this XMl doesn't need validate, so it's better to use bioregion name instead bioregion code biogeoElement.appendChild(doc.createElement("code")) .appendChild(doc.createTextNode(fmt(b.getBiogeoName(), "bioRegionCode"))); biogeoElement.appendChild(doc.createElement("percentage")) .appendChild(doc.createTextNode(fmt(s.getBiogeoPercent(), "biogeoPercent"))); location.appendChild(biogeoElement); } } sdf.appendChild(location); /********ECOLOGICAL INFORMATION***********/ //adptacion nuevo XML Element ecologicalInformation = doc.createElement("ecologicalInformation"); /************HABITATS****************/ Element habitatsTypes = doc.createElement("habitatTypes"); Set siteHabs = site.getHabitats(); itr = siteHabs.iterator(); while (itr.hasNext()) { Habitat h = (Habitat) itr.next(); Element hElem = doc.createElement("habitatType"); hElem.appendChild(doc.createElement("code")) .appendChild(doc.createTextNode(fmt(h.getHabitatCode(), "habitatCode"))); hElem.appendChild(doc.createElement("priorityFormOfHabitatType")).appendChild( doc.createTextNode(fmt(toBoolean(h.getHabitatPriority()), "habitatPriority"))); hElem.appendChild(doc.createElement("nonPresenceInSite")) .appendChild(doc.createTextNode(fmt(toBoolean(h.getHabitatNp()), "habitatNp"))); hElem.appendChild(doc.createElement("coveredArea")) .appendChild(doc.createTextNode(fmt(h.getHabitatCoverHa(), "habitatCover"))); hElem.appendChild(doc.createElement("caves")) .appendChild(doc.createTextNode(fmt(h.getHabitatCaves(), "habitatCaves"))); hElem.appendChild(doc.createElement("observationDataQuality")) .appendChild(doc.createTextNode(fmt(h.getHabitatDataQuality(), "habitatDataQuality"))); hElem.appendChild(doc.createElement("representativity")).appendChild( doc.createTextNode(fmt(h.getHabitatRepresentativity(), "habitatRepresentativity"))); hElem.appendChild(doc.createElement("relativeSurface")) .appendChild(doc.createTextNode(fmt(h.getHabitatRelativeSurface(), "relativeSurface"))); hElem.appendChild(doc.createElement("conservation")).appendChild( doc.createTextNode(fmt(h.getHabitatConservation(), "habitatConservation"))); hElem.appendChild(doc.createElement("global")) .appendChild(doc.createTextNode(fmt(h.getHabitatGlobal(), "habitatGlobal"))); habitatsTypes.appendChild(hElem); } ecologicalInformation.appendChild(habitatsTypes); /************SPECIES****************/ Element specieses = doc.createElement("species"); Set siteSpecies = site.getSpecieses(); itr = siteSpecies.iterator(); while (itr.hasNext()) { Species s = (Species) itr.next(); Element sElem = doc.createElement("speciesPopulation"); sElem.appendChild(doc.createElement("speciesGroup")) .appendChild(doc.createTextNode(fmt(s.getSpeciesGroup(), "speciesGroup"))); sElem.appendChild(doc.createElement("speciesCode")) .appendChild(doc.createTextNode(fmt(s.getSpeciesCode(), "speciesCode"))); sElem.appendChild(doc.createElement("scientificName")) .appendChild(doc.createTextNode(fmt(s.getSpeciesName(), "speciesName"))); sElem.appendChild(doc.createElement("sensitiveInfo")).appendChild( doc.createTextNode(fmt(toBoolean(s.getSpeciesSensitive()), "speciesSensitive"))); sElem.appendChild(doc.createElement("nonPresenceInSite")) .appendChild(doc.createTextNode(fmt(toBoolean(s.getSpeciesNp()), "speciesNP"))); sElem.appendChild(doc.createElement("populationType")) .appendChild(doc.createTextNode(fmtToLowerCase(s.getSpeciesType(), "speciesType"))); Element popElem = doc.createElement("populationSize"); popElem.appendChild(doc.createElement("lowerBound")) .appendChild(doc.createTextNode(fmt(s.getSpeciesSizeMin(), "speciesSizeMin"))); popElem.appendChild(doc.createElement("upperBound")) .appendChild(doc.createTextNode(fmt(s.getSpeciesSizeMax(), "speciesSizeMax"))); popElem.appendChild(doc.createElement("countingUnit")) .appendChild(doc.createTextNode(fmt(s.getSpeciesUnit(), "speciesUnit"))); sElem.appendChild(popElem); if (s.getSpeciesCategory() != null) { if (!("").equals(s.getSpeciesCategory().toString())) { sElem.appendChild(doc.createElement("abundanceCategory")).appendChild( doc.createTextNode(fmtToUpperCase(s.getSpeciesCategory(), "speciesCategory"))); } } sElem.appendChild(doc.createElement("dataQuality")) .appendChild(doc.createTextNode(fmt(s.getSpeciesDataQuality(), "speciesQuality"))); // sElem.appendChild(doc.createElement("observationDataQuality")).appendChild(doc.createTextNode(fmt(s.getSpeciesDataQuality(), "speciesQuality"))); sElem.appendChild(doc.createElement("population")) .appendChild(doc.createTextNode(fmt(s.getSpeciesPopulation(), "speciesPopulation"))); sElem.appendChild(doc.createElement("conservation")).appendChild( doc.createTextNode(fmt(s.getSpeciesConservation(), "speciesConservation"))); sElem.appendChild(doc.createElement("isolation")) .appendChild(doc.createTextNode(fmt(s.getSpeciesIsolation(), "speciesIsolation"))); sElem.appendChild(doc.createElement("global")) .appendChild(doc.createTextNode(fmt(s.getSpeciesGlobal(), "speciesGlobal"))); specieses.appendChild(sElem); } siteSpecies = site.getOtherSpecieses(); itr = siteSpecies.iterator(); while (itr.hasNext()) { OtherSpecies s = (OtherSpecies) itr.next(); Element sElem = doc.createElement("speciesPopulation"); sElem.appendChild(doc.createElement("speciesGroup")) .appendChild(doc.createTextNode(fmt(s.getOtherSpeciesGroup(), "ospeciesGroup"))); sElem.appendChild(doc.createElement("speciesCode")) .appendChild(doc.createTextNode(fmt(s.getOtherSpeciesCode(), "ospeciesCode"))); sElem.appendChild(doc.createElement("scientificName")) .appendChild(doc.createTextNode(fmt(s.getOtherSpeciesName(), "ospeciesName"))); sElem.appendChild(doc.createElement("sensitiveInfo")).appendChild( doc.createTextNode(fmt(toBoolean(s.getOtherSpeciesSensitive()), "ospeciesSensitive"))); if (s.getOtherSpeciesNp() != null) { if (!(("").equals(s.getOtherSpeciesNp().toString()))) { sElem.appendChild(doc.createElement("nonPresenceInSite")).appendChild( doc.createTextNode(fmt(toBoolean(s.getOtherSpeciesNp()), "ospeciesNP"))); } } Element popElem = doc.createElement("populationSize"); popElem.appendChild(doc.createElement("lowerBound")) .appendChild(doc.createTextNode(fmt(s.getOtherSpeciesSizeMin(), "speciesSizeMin"))); popElem.appendChild(doc.createElement("upperBound")) .appendChild(doc.createTextNode(fmt(s.getOtherSpeciesSizeMax(), "speciesSizeMax"))); popElem.appendChild(doc.createElement("countingUnit")) .appendChild(doc.createTextNode(fmt(s.getOtherSpeciesUnit(), "speciesUnit"))); sElem.appendChild(popElem); if (s.getOtherSpeciesCategory() != null) { if (!(("").equals(s.getOtherSpeciesCategory().toString()))) { sElem.appendChild(doc.createElement("abundanceCategory")).appendChild( doc.createTextNode(fmt(s.getOtherSpeciesCategory(), "ospeciesCategory"))); } } //modificar porque es un tree primero es motivations y despues el nodo motivation (solo en el caso que haya motivations es other species en caso contrario //es species if (s.getOtherSpeciesMotivation() != null && !(("").equals(s.getOtherSpeciesMotivation()))) { Element sElemMot = doc.createElement("motivations"); String strMotivation = s.getOtherSpeciesMotivation(); StringTokenizer st2 = new StringTokenizer(strMotivation, ","); while (st2.hasMoreElements()) { String mot = (String) st2.nextElement(); sElemMot.appendChild(doc.createElement("motivation")) .appendChild(doc.createTextNode(fmt(mot, "ospeciesMotivation"))); sElem.appendChild(sElemMot); } } specieses.appendChild(sElem); } ecologicalInformation.appendChild(specieses); sdf.appendChild(ecologicalInformation); /**************DESCRIPTION***********************/ Element description = doc.createElement("siteDescription"); Set classes = site.getHabitatClasses(); itr = classes.iterator(); while (itr.hasNext()) { HabitatClass h = (HabitatClass) itr.next(); Element cElem = doc.createElement("habitatClass"); cElem.appendChild(doc.createElement("code")) .appendChild(doc.createTextNode(fmt(h.getHabitatClassCode(), "habitatClassCode"))); cElem.appendChild(doc.createElement("coveragePercentage")) .appendChild(doc.createTextNode(fmt(h.getHabitatClassCover(), "habitatClassCover"))); description.appendChild(cElem); } description.appendChild(doc.createElement("otherSiteCharacteristics")).appendChild( doc.createTextNode(fmt(site.getSiteCharacteristics(), "otherSiteCharacteristics"))); description.appendChild(doc.createElement("qualityAndImportance")) .appendChild(doc.createTextNode(fmt(site.getSiteQuality(), "qualityAndImportance"))); Element impacts = doc.createElement("impacts"); Set siteImpacts = site.getImpacts(); itr = siteImpacts.iterator(); while (itr.hasNext()) { Element iElem = doc.createElement("impact"); Impact im = (Impact) itr.next(); iElem.appendChild(doc.createElement("code")) .appendChild(doc.createTextNode(fmt(im.getImpactCode(), "impactCode"))); iElem.appendChild(doc.createElement("rank")) .appendChild(doc.createTextNode(fmt(im.getImpactRank(), "impactRank"))); if (im.getImpactPollutionCode() != null) { if (!("").equals(im.getImpactPollutionCode().toString())) { iElem.appendChild(doc.createElement("pollutionCode")).appendChild( doc.createTextNode(fmt(im.getImpactPollutionCode(), "impactPollution"))); } } iElem.appendChild(doc.createElement("occurrence")) .appendChild(doc.createTextNode(fmt(im.getImpactOccurrence(), "impactOccurrece"))); String impacType = ""; if (im.getImpactType() != null) { if (("P").equals(im.getImpactType().toString())) { impacType = "Positive"; } else { impacType = "Negative"; } } iElem.appendChild(doc.createElement("natureOfImpact")) .appendChild(doc.createTextNode(fmt(impacType, "natureOfImpact"))); impacts.appendChild(iElem); } description.appendChild(impacts); Element ownership = doc.createElement("ownership"); Set owners = site.getSiteOwnerships(); itr = owners.iterator(); while (itr.hasNext()) { SiteOwnership o = (SiteOwnership) itr.next(); Ownership o2 = o.getOwnership(); Element oElem = doc.createElement("ownershipPart"); oElem.appendChild(doc.createElement("ownershiptype")) .appendChild(doc.createTextNode(fmt(o2.getOwnershipCode(), "ownershipType"))); oElem.appendChild(doc.createElement("percent")) .appendChild(doc.createTextNode(fmt(o.getOwnershipPercent(), "ownershipPercent"))); ownership.appendChild(oElem); } description.appendChild(ownership); Element documentation = doc.createElement("documentation"); Doc docObj = site.getDoc(); if (docObj != null) { documentation.appendChild(doc.createElement("description")) .appendChild(doc.createTextNode(fmt(docObj.getDocDescription(), "docDescription"))); Set docLinks = docObj.getDocLinks(); itr = docLinks.iterator(); Element links = doc.createElement("links"); while (itr.hasNext()) { DocLink docLink = (DocLink) itr.next(); links.appendChild(doc.createElement("link")) .appendChild(doc.createTextNode(fmt(docLink.getDocLinkUrl(), "linkURL"))); } documentation.appendChild(links); description.appendChild(documentation); } sdf.appendChild(description); /********PROTECTION**********/ Element protection = doc.createElement("siteProtection"); Element natDesigs = doc.createElement("nationalDesignations"); Set dsigs = site.getNationalDtypes(); itr = dsigs.iterator(); while (itr.hasNext()) { NationalDtype dtype = (NationalDtype) itr.next(); Element nElem = doc.createElement("nationalDesignation"); nElem.appendChild(doc.createElement("designationCode")) .appendChild(doc.createTextNode(fmt(dtype.getNationalDtypeCode(), "dtypecode"))); nElem.appendChild(doc.createElement("cover")) .appendChild(doc.createTextNode(fmt(dtype.getNationalDtypeCover(), "dtypecover"))); natDesigs.appendChild(nElem); } protection.appendChild(natDesigs); Set rels = site.getSiteRelations(); if (!rels.isEmpty()) { Element relations = doc.createElement("relations"); Element nationalRelations = doc.createElement("nationalRelationships"); Element internationalRelations = doc.createElement("internationalRelationships"); itr = rels.iterator(); while (itr.hasNext()) { SiteRelation rel = (SiteRelation) itr.next(); Element rElem; Character scope = rel.getSiteRelationScope(); if (("N").equals(scope.toString())) { rElem = doc.createElement("nationalRelationship"); rElem.appendChild(doc.createElement("designationCode")).appendChild( doc.createTextNode(fmt(rel.getSiteRelationCode(), "relationCode"))); nationalRelations.appendChild(rElem); } else if (("I").equals(scope.toString())) { rElem = doc.createElement("internationalRelationship"); rElem.appendChild(doc.createElement("convention")).appendChild( doc.createTextNode(fmt(rel.getSiteRelationConvention(), "relationConvention"))); internationalRelations.appendChild(rElem); } else { // log("Relation type undefined, ignoring relation: " + scope.toString()); continue; } rElem.appendChild(doc.createElement("siteName")).appendChild( doc.createTextNode(fmt(rel.getSiteRelationSitename(), "relationSite"))); rElem.appendChild(doc.createElement("type")) .appendChild(doc.createTextNode(fmt(rel.getSiteRelationType(), "relationType"))); rElem.appendChild(doc.createElement("cover")) .appendChild(doc.createTextNode(fmt(rel.getSiteRelationCover(), "relationCover"))); } relations.appendChild(nationalRelations); relations.appendChild(internationalRelations); protection.appendChild(relations); } protection.appendChild(doc.createElement("siteDesignationAdditional")) .appendChild(doc.createTextNode(fmt(site.getSiteDesignation(), "siteDesignation"))); sdf.appendChild(protection); /******************MANAGEMENT************************/ Element mgmtElem = doc.createElement("siteManagement"); Mgmt mgmt = site.getMgmt(); if (mgmt != null) { // Management Body Set bodies = mgmt.getMgmtBodies(); itr = bodies.iterator(); Element bodiesElem = doc.createElement("managementBodies"); while (itr.hasNext()) { MgmtBody bodyObj = (MgmtBody) itr.next(); Element bElem = doc.createElement("managementBody"); bElem.appendChild(doc.createElement("organisation")) .appendChild(doc.createTextNode(fmt(bodyObj.getMgmtBodyOrg(), "mgmtBodyOrg"))); //if el campo addressunestructured esta vacio entonces addres es un tipo complejo (implementar) en caso contrario if (bodyObj.getMgmtBodyAddressArea() != null && !bodyObj.getMgmtBodyAddressArea().equals("")) { Element addresElem = doc.createElement("address"); addresElem.appendChild(doc.createElement("adminUnit")).appendChild( doc.createTextNode(fmt(bodyObj.getMgmtBodyAdminUnit(), "adminUnit") + " ")); addresElem.appendChild(doc.createElement("locatorDesignator")).appendChild(doc .createTextNode(fmt(bodyObj.getMgmtBodyThroughFare(), "thoroughfare") + " ")); addresElem.appendChild(doc.createElement("locatorName")).appendChild(doc.createTextNode( fmt(bodyObj.getMgmtBodyLocatorDesignator(), "locatorDesignator") + " ")); addresElem.appendChild(doc.createElement("addressArea")).appendChild( doc.createTextNode(fmt(bodyObj.getMgmtBodyPostCode(), "postCode") + " ")); addresElem.appendChild(doc.createElement("postName")).appendChild( doc.createTextNode(fmt(bodyObj.getMgmtBodyPostName(), "postName") + " ")); addresElem.appendChild(doc.createElement("postCode")).appendChild(doc .createTextNode(fmt(bodyObj.getMgmtBodyAddressArea(), "addressArea") + " ")); addresElem.appendChild(doc.createElement("thoroughfare")).appendChild(doc .createTextNode(fmt(bodyObj.getMgmtBodyLocatorName(), "locatorName") + " ")); bElem.appendChild(addresElem); } else { Element addresElem = doc.createElement("address"); addresElem.appendChild(doc.createElement("addressArea")).appendChild( doc.createTextNode(fmt(bodyObj.getMgmtBodyAddress(), "addressArea"))); bElem.appendChild(addresElem); } bElem.appendChild(doc.createElement("email")) .appendChild(doc.createTextNode(fmt(bodyObj.getMgmtBodyEmail(), "mgmtBodyMail"))); bodiesElem.appendChild(bElem); } mgmtElem.appendChild(bodiesElem); // Management Plan Character status = mgmt.getMgmtStatus(); Element mgmtExists = (Element) mgmtElem.appendChild(doc.createElement("exists")); if (status != null) { mgmtExists .appendChild(doc.createTextNode(fmt(Character.toUpperCase(status), "mgmtExists"))); } Set plans = mgmt.getMgmtPlans(); itr = plans.iterator(); Element plansElem = doc.createElement("managementPlans"); plansElem.appendChild(mgmtExists); while (itr.hasNext()) { MgmtPlan planObj = (MgmtPlan) itr.next(); Element pElem = doc.createElement("managementPlan"); pElem.appendChild(doc.createElement("name")) .appendChild(doc.createTextNode(fmt(planObj.getMgmtPlanName(), "mgmtPlanName"))); pElem.appendChild(doc.createElement("url")) .appendChild(doc.createTextNode(fmt(planObj.getMgmtPlanUrl(), "mgmtPlanUrl"))); plansElem.appendChild(pElem); } mgmtElem.appendChild(plansElem); mgmtElem.appendChild(doc.createElement("conservationMeasures")).appendChild( doc.createTextNode(fmt(mgmt.getMgmtConservMeasures(), "conservationMeasures"))); } sdf.appendChild(mgmtElem); Map map = site.getMap(); Element mapElem = doc.createElement("map"); if (map != null) { mapElem.appendChild(doc.createElement("InspireID")) .appendChild(doc.createTextNode(fmt(map.getMapInspire(), "mapInspireID"))); Boolean bMap; if (map.getMapPdf() != null && map.getMapPdf().equals(Short.valueOf("1"))) { bMap = true; } else { bMap = false; } mapElem.appendChild(doc.createElement("pdfProvided")) .appendChild(doc.createTextNode(fmt(bMap, "mapPDF"))); mapElem.appendChild(doc.createElement("mapReference")) .appendChild(doc.createTextNode(fmt(map.getMapReference(), "mapRef"))); } sdf.appendChild(mapElem); if (flush++ % 100 == 0) { session.clear(); } sdfs.appendChild(sdf); } //All the data is stored in the node instead of the document. Source source = new DOMSource(doc); // File file = new File(this.fileName); File file = new File("xsl" + File.separator + this.siteCode + ".html"); Result result = new StreamResult(file.toURI().getPath()); TransformerFactory tFactory = TransformerFactory.newInstance(); String xslFileName = SDF_ManagerApp.isEmeraldMode() ? "EmeraldSiteXSL.xsl" : "SiteXSL.xsl"; Source xsl = new StreamSource("." + File.separator + "xsl" + File.separator + xslFileName); Templates template = tFactory.newTemplates(xsl); Transformer transformer = template.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "siteName name otherSiteCharacteristics" + " qualityAndImportance selectiveBasis derogationJustification comments " + "location licensedJustification licensingAuthority licenseValidFrom licenseValidUntil otherType " + "method activity reason"); transformer.transform(source, result); String pdfPath = new File("").getAbsolutePath() + File.separator + "xsl" + File.separator + this.siteCode + ".pdf"; // File inputFile = new File(this.fileName); File inputFile = new File("xsl" + File.separator + this.siteCode + ".html"); os = new FileOutputStream(new File(pdfPath)); ITextRenderer renderer = new ITextRenderer(); FontFactory.register("resources/fonts"); renderer.setDocument(inputFile); renderer.layout(); renderer.createPDF(os); Desktop desktop = null; // Before more Desktop API is used, first check // whether the API is supported by this particular // virtual machine (VM) on this particular host. if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); Desktop.getDesktop().open(file); } return null; } catch (TransformerConfigurationException e) { ExporterSiteHTML.log .error("A TransformerConfigurationException has occurred in processDatabase. Error Message:::" + e.getMessage()); return null; } catch (TransformerException e) { ExporterSiteHTML.log.error( "A TransformerException has occurred in processDatabase. Error Message:::" + e.getMessage()); return null; } catch (FileNotFoundException e) { ExporterSiteHTML.log.error( "A FileNotFoundException has occurred in processDatabase. Error Message:::" + e.getMessage()); return null; } catch (IOException e) { ExporterSiteHTML.log .error("An IOException has occurred in processDatabase. Error Message:::" + e.getMessage()); return null; } catch (Exception e) { ExporterSiteHTML.log.error( "A general exception has occurred in processDatabase. Error Message:::" + e.getMessage()); return null; } finally { IOUtils.closeQuietly(os); session.close(); } }
From source file:editeurpanovisu.EditeurPanovisu.java
private void genereVisite() throws IOException { if (!repertSauveChoisi) { repertoireProjet = currentDir;//from www .j av a2 s. c o m } if (!dejaSauve) { projetSauve(); } if (dejaSauve) { deleteDirectory(repertTemp + "/panovisu/images"); File imagesRepert = new File(repertTemp + "/panovisu/images"); if (!imagesRepert.exists()) { imagesRepert.mkdirs(); } File boutonRepert = new File(repertTemp + "/panovisu/images/navigation"); if (!boutonRepert.exists()) { boutonRepert.mkdirs(); } File boussoleRepert = new File(repertTemp + "/panovisu/images/boussoles"); if (!boussoleRepert.exists()) { boussoleRepert.mkdirs(); } copieDirectory(repertAppli + File.separator + "panovisu/images/boussoles", boussoleRepert.getAbsolutePath()); File planRepert = new File(repertTemp + "/panovisu/images/plan"); if (!planRepert.exists()) { planRepert.mkdirs(); } copieDirectory(repertAppli + File.separator + "panovisu/images/plan", planRepert.getAbsolutePath()); File reseauRepert = new File(repertTemp + "/panovisu/images/reseaux"); if (!reseauRepert.exists()) { reseauRepert.mkdirs(); } copieDirectory(repertAppli + File.separator + "panovisu/images/reseaux", reseauRepert.getAbsolutePath()); File interfaceRepert = new File(repertTemp + "/panovisu/images/interface"); if (!interfaceRepert.exists()) { interfaceRepert.mkdirs(); } copieDirectory(repertAppli + File.separator + "panovisu/images/interface", interfaceRepert.getAbsolutePath()); File MARepert = new File(repertTemp + "/panovisu/images/MA"); if (!MARepert.exists()) { MARepert.mkdirs(); } File hotspotsRepert = new File(repertTemp + "/panovisu/images/hotspots"); if (!hotspotsRepert.exists()) { hotspotsRepert.mkdirs(); } copieFichierRepertoire(repertAppli + File.separator + "panovisu" + File.separator + "images" + File.separator + "aide_souris.png", repertTemp + "/panovisu/images"); copieFichierRepertoire(repertAppli + File.separator + "panovisu" + File.separator + "images" + File.separator + "fermer.png", repertTemp + "/panovisu/images"); copieFichierRepertoire(repertAppli + File.separator + "panovisu" + File.separator + "images" + File.separator + "precedent.png", repertTemp + "/panovisu/images"); copieFichierRepertoire(repertAppli + File.separator + "panovisu" + File.separator + "images" + File.separator + "suivant.png", repertTemp + "/panovisu/images"); for (int i = 0; i < gestionnaireInterface.nombreImagesBouton - 1; i++) { ReadWriteImage.writePng(gestionnaireInterface.nouveauxBoutons[i], boutonRepert.getAbsolutePath() + File.separator + gestionnaireInterface.nomImagesBoutons[i], false, 0.f); } ReadWriteImage.writePng( gestionnaireInterface.nouveauxBoutons[gestionnaireInterface.nombreImagesBouton - 1], hotspotsRepert.getAbsolutePath() + File.separator + "hotspot.png", false, 0.f); ReadWriteImage.writePng(gestionnaireInterface.nouveauxBoutons[gestionnaireInterface.nombreImagesBouton], hotspotsRepert.getAbsolutePath() + File.separator + "hotspotImage.png", false, 0.f); ReadWriteImage.writePng(gestionnaireInterface.nouveauxMasque, MARepert.getAbsolutePath() + File.separator + "MA.png", false, 0.f); File xmlRepert = new File(repertTemp + File.separator + "xml"); if (!xmlRepert.exists()) { xmlRepert.mkdirs(); } File cssRepert = new File(repertTemp + File.separator + "css"); if (!cssRepert.exists()) { cssRepert.mkdirs(); } File jsRepert = new File(repertTemp + File.separator + "js"); if (!jsRepert.exists()) { jsRepert.mkdirs(); } String contenuFichier; File xmlFile; String chargeImages = ""; for (int i = 0; i < nombrePanoramiques; i++) { String fPano = "panos/" + panoramiquesProjet[i].getNomFichier() .substring(panoramiquesProjet[i].getNomFichier().lastIndexOf(File.separator) + 1, panoramiquesProjet[i].getNomFichier().length()) .split("\\.")[0]; if (panoramiquesProjet[i].getTypePanoramique().equals(Panoramique.CUBE)) { fPano = fPano.substring(0, fPano.length() - 2); chargeImages += " images[" + i + "]=\"" + fPano + "_f.jpg\"\n"; chargeImages += " images[" + i + "]=\"" + fPano + "_b.jpg\"\n"; chargeImages += " images[" + i + "]=\"" + fPano + "_u.jpg\"\n"; chargeImages += " images[" + i + "]=\"" + fPano + "_d.jpg\"\n"; chargeImages += " images[" + i + "]=\"" + fPano + "_r.jpg\"\n"; chargeImages += " images[" + i + "]=\"" + fPano + "_l.jpg\"\n"; } else { chargeImages += " images[" + i + "]=\"" + fPano + ".jpg\"\n"; } String affInfo = (panoramiquesProjet[i].isAfficheInfo()) ? "oui" : "non"; String affTitre = (gestionnaireInterface.bAfficheTitre) ? "oui" : "non"; double regX; double zN; if (panoramiquesProjet[i].getTypePanoramique().equals(Panoramique.SPHERE)) { regX = Math.round(((panoramiquesProjet[i].getLookAtX() - 180) % 360) * 10) / 10; zN = Math.round(((panoramiquesProjet[i].getZeroNord() - 180) % 360) * 10) / 10; } else { regX = Math.round(((panoramiquesProjet[i].getLookAtX() + 90) % 360) * 10) / 10; zN = Math.round(((panoramiquesProjet[i].getZeroNord() + 90) % 360) * 10) / 10; } int rouge = (int) (Color.valueOf(gestionnaireInterface.couleurDiaporama).getRed() * 255.d); int bleu = (int) (Color.valueOf(gestionnaireInterface.couleurDiaporama).getBlue() * 255.d); int vert = (int) (Color.valueOf(gestionnaireInterface.couleurDiaporama).getGreen() * 255.d); String coulDiapo = "rgba(" + rouge + "," + vert + "," + bleu + "," + gestionnaireInterface.diaporamaOpacite + ")"; Color coulTitre = Color.valueOf(gestionnaireInterface.couleurFondTitre); rouge = (int) (coulTitre.getRed() * 255.d); bleu = (int) (coulTitre.getBlue() * 255.d); vert = (int) (coulTitre.getGreen() * 255.d); String coulFondTitre = "rgba(" + rouge + "," + vert + "," + bleu + "," + gestionnaireInterface.titreOpacite + ")"; contenuFichier = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!--\n" + " Visite gnre par l'diteur panoVisu \n" + "\n" + " Cration L.LANG le monde 360 : http://lemondea360.fr\n" + "-->\n" + "\n" + "\n" + "<scene>\n" + " <pano \n" + " image=\"" + fPano + "\"\n" + " titre=\"" + panoramiquesProjet[i].getTitrePanoramique() + "\"\n" + " titrePolice=\"" + gestionnaireInterface.titrePoliceNom + "\"\n" + " titreTaillePolice=\"" + Math.round(Double.parseDouble(gestionnaireInterface.titrePoliceTaille)) + "px\"\n" + " titreTaille=\"" + Math.round(gestionnaireInterface.titreTaille) + "%\"\n" + " titreFond=\"" + coulFondTitre + "\"\n" + " titreCouleur=\"" + gestionnaireInterface.couleurTitre + "\"\n" // + " titreOpacite=\"" + gestionnaireInterface.titreOpacite + "\"\n" + " diaporamaCouleur=\"" + coulDiapo + "\"\n" + " type=\"" + panoramiquesProjet[i].getTypePanoramique() + "\"\n" + " multiReso=\"oui\"\n" + " nombreNiveaux=\"" + panoramiquesProjet[i].getNombreNiveaux() + "\"\n" + " zeroNord=\"" + zN + "\"\n" + " regardX=\"" + regX + "\"\n" + " regardY=\"" + Math.round(panoramiquesProjet[i].getLookAtY() * 10) / 10 + "\"\n" + " affinfo=\"" + affInfo + "\"\n" + " afftitre=\"" + affTitre + "\"\n" + " />\n" + " <!--Dfinition de la Barre de navigation-->\n" + " <boutons \n" + " styleBoutons=\"navigation\"\n" + " couleur=\"rgba(255,255,255,0)\"\n" + " bordure=\"rgba(255,255,255,0)\"\n" + " deplacements=\"" + gestionnaireInterface.toggleBarreDeplacements + "\" \n" + " zoom=\"" + gestionnaireInterface.toggleBarreZoom + "\" \n" + " outils=\"" + gestionnaireInterface.toggleBarreOutils + "\"\n" + " fs=\"" + gestionnaireInterface.toggleBoutonFS + "\" \n" + " souris=\"" + gestionnaireInterface.toggleBoutonSouris + "\" \n" + " rotation=\"" + gestionnaireInterface.toggleBoutonRotation + "\" \n" + " positionX=\"" + gestionnaireInterface.positionBarre.split(":")[1] + "\"\n" + " positionY=\"" + gestionnaireInterface.positionBarre.split(":")[0] + "\" \n" + " dX=\"" + gestionnaireInterface.dXBarre + "\" \n" + " dY=\"" + gestionnaireInterface.dYBarre + "\"\n" + " espacement=\"" + Math.round(gestionnaireInterface.espacementBoutons) + "\"\n" + " visible=\"" + gestionnaireInterface.toggleBarreVisibilite + "\"\n" + " />\n"; if (gestionnaireInterface.bAfficheBoussole) { String SAiguille = (gestionnaireInterface.bAiguilleMobileBoussole) ? "oui" : "non"; contenuFichier += "<!-- Boussole -->\n" + " <boussole \n" + " affiche=\"oui\"\n" + " image=\"" + gestionnaireInterface.imageBoussole + "\"\n" + " taille=\"" + gestionnaireInterface.tailleBoussole + "\"\n" + " positionY=\"" + gestionnaireInterface.positionBoussole.split(":")[0] + "\"\n" + " positionX=\"" + gestionnaireInterface.positionBoussole.split(":")[1] + "\"\n" + " opacite=\"" + gestionnaireInterface.opaciteBoussole + "\"\n" + " dX=\"" + gestionnaireInterface.dXBoussole + "\"\n" + " dY=\"" + gestionnaireInterface.dYBoussole + "\"\n" + " aiguille=\"" + SAiguille + "\"\n" + " />\n"; } if (gestionnaireInterface.bAfficheMenuContextuel) { String SPrecSuiv = (gestionnaireInterface.bAffichePrecSuivMC) ? "oui" : "non"; String SPlanet = (gestionnaireInterface.bAffichePlanetNormalMC) ? "oui" : "non"; String SPers1 = (gestionnaireInterface.bAffichePersMC1) ? "oui" : "non"; String SPers2 = (gestionnaireInterface.bAffichePersMC2) ? "oui" : "non"; contenuFichier += "<!-- MenuContextuel -->\n" + " <menuContextuel \n" + " affiche=\"oui\"\n" + " precSuiv=\"" + SPrecSuiv + "\"\n" + " planete=\"" + SPlanet + "\"\n" + " pers1=\"" + SPers1 + "\"\n" + " lib1=\"" + gestionnaireInterface.stPersLib1 + "\"\n" + " url1=\"" + gestionnaireInterface.stPersURL1 + "\"\n" + " pers2=\"" + SPers2 + "\"\n" + " lib2=\"" + gestionnaireInterface.stPersLib2 + "\"\n" + " url2=\"" + gestionnaireInterface.stPersURL2 + "\"\n" + " />\n"; } if (gestionnaireInterface.bSuivantPrecedent) { int panoPrecedent = (i == nombrePanoramiques - 1) ? 0 : i + 1; int panoSuivant = (i == 0) ? nombrePanoramiques - 1 : i - 1; String nomPano = panoramiquesProjet[panoSuivant].getNomFichier(); String strPanoSuivant = "xml/" + nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf(".")) + ".xml"; nomPano = panoramiquesProjet[panoPrecedent].getNomFichier(); String strPanoPrecedent = "xml/" + nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf(".")) + ".xml"; contenuFichier += "<!-- Bouton Suivant Precedent -->\n" + " <suivantPrecedent\n" + " suivant=\"" + strPanoSuivant + "\" \n" + " precedent=\"" + strPanoPrecedent + "\" \n" + " /> \n" + ""; } if (gestionnaireInterface.bAfficheMasque) { String SNavigation = (gestionnaireInterface.bMasqueNavigation) ? "oui" : "non"; String SBoussole = (gestionnaireInterface.bMasqueBoussole) ? "oui" : "non"; String STitre = (gestionnaireInterface.bMasqueTitre) ? "oui" : "non"; String splan = (gestionnaireInterface.bMasquePlan) ? "oui" : "non"; String SReseaux = (gestionnaireInterface.bMasqueReseaux) ? "oui" : "non"; String SVignettes = (gestionnaireInterface.bMasqueVignettes) ? "oui" : "non"; contenuFichier += "<!-- Bouton de Masquage -->\n" + " <marcheArret \n" + " affiche=\"oui\"\n" + " image=\"MA.png\"\n" + " taille=\"" + gestionnaireInterface.tailleMasque + "\"\n" + " positionY=\"" + gestionnaireInterface.positionMasque.split(":")[0] + "\"\n" + " positionX=\"" + gestionnaireInterface.positionMasque.split(":")[1] + "\"\n" + " opacite=\"" + gestionnaireInterface.opaciteMasque + "\"\n" + " dX=\"" + gestionnaireInterface.dXMasque + "\"\n" + " dy=\"" + gestionnaireInterface.dYMasque + "\"\n" + " navigation=\"" + SNavigation + "\"\n" + " boussole=\"" + SBoussole + "\"\n" + " titre=\"" + STitre + "\"\n" + " plan=\"" + splan + "\"\n" + " reseaux=\"" + SReseaux + "\"\n" + " vignettes=\"" + SVignettes + "\"\n" + " />\n"; } if (gestionnaireInterface.bAfficheReseauxSociaux) { String STwitter = (gestionnaireInterface.bReseauxSociauxTwitter) ? "oui" : "non"; String SGoogle = (gestionnaireInterface.bReseauxSociauxGoogle) ? "oui" : "non"; String SFacebook = (gestionnaireInterface.bReseauxSociauxFacebook) ? "oui" : "non"; String SEmail = (gestionnaireInterface.bReseauxSociauxEmail) ? "oui" : "non"; contenuFichier += "<!-- Rseaux Sociaux -->\n" + " <reseauxSociaux \n" + " affiche=\"oui\"\n" + " taille=\"" + gestionnaireInterface.tailleReseauxSociaux + "\"\n" + " positionY=\"" + gestionnaireInterface.positionReseauxSociaux.split(":")[0] + "\"\n" + " positionX=\"" + gestionnaireInterface.positionReseauxSociaux.split(":")[1] + "\"\n" + " opacite=\"" + gestionnaireInterface.opaciteReseauxSociaux + "\"\n" + " dX=\"" + gestionnaireInterface.dXReseauxSociaux + "\"\n" + " dY=\"" + gestionnaireInterface.dYReseauxSociaux + "\"\n" + " twitter=\"" + STwitter + "\"\n" + " google=\"" + SGoogle + "\"\n" + " facebook=\"" + SFacebook + "\"\n" + " email=\"" + SEmail + "\"\n" + " />\n"; } if (gestionnaireInterface.bAfficheVignettes) { String SAfficheVignettes = (gestionnaireInterface.bAfficheVignettes) ? "oui" : "non"; contenuFichier += "<!-- Barre des vignettes -->" + " <vignettes \n" + " affiche=\"" + SAfficheVignettes + "\"\n" + " tailleImage=\"" + gestionnaireInterface.tailleImageVignettes + "\"\n" + " fondCouleur=\"" + gestionnaireInterface.couleurFondVignettes + "\"\n" + " texteCouleur=\"" + gestionnaireInterface.couleurTexteVignettes + "\"\n" + " opacite=\"" + gestionnaireInterface.opaciteVignettes + "\"\n" + " position=\"" + gestionnaireInterface.positionVignettes + "\"\n" + " >\n"; for (int j = 0; j < nombrePanoramiques; j++) { String nomPano = panoramiquesProjet[j].getNomFichier(); String nFichier = nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf(".")) + "Vignette.jpg"; String nXML = nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf(".")) + ".xml"; ReadWriteImage.writeJpeg(panoramiquesProjet[j].getVignettePanoramique(), repertTemp + "/panos/" + nFichier, 1.0f, false, 0.0f); contenuFichier += " <imageVignette \n" + " image=\"panos/" + nFichier + "\"\n" + " xml=\"xml/" + nXML + "\"\n" + " />\n"; } contenuFichier += " </vignettes> \n" + ""; } contenuFichier += " <!--Dfinition des hotspots--> \n" + " <hotspots>\n"; for (int j = 0; j < panoramiquesProjet[i].getNombreHotspots(); j++) { HotSpot HS = panoramiquesProjet[i].getHotspot(j); double longit; if (panoramiquesProjet[i].getTypePanoramique().equals(Panoramique.SPHERE)) { longit = HS.getLongitude() - 180; } else { longit = HS.getLongitude() + 90; } String txtAnime = (HS.isAnime()) ? "true" : "false"; contenuFichier += " <point \n" + " type=\"panoramique\"\n" + " long=\"" + longit + "\"\n" + " lat=\"" + HS.getLatitude() + "\"\n" + " image=\"panovisu/images/hotspots/hotspot.png\"\n" + " xml=\"xml/" + HS.getFichierXML() + "\"\n" + " info=\"" + HS.getInfo() + "\"\n" + " anime=\"" + txtAnime + "\"\n" + " />\n"; } for (int j = 0; j < panoramiquesProjet[i].getNombreHotspotImage(); j++) { HotspotImage HS = panoramiquesProjet[i].getHotspotImage(j); double longit; if (panoramiquesProjet[i].getTypePanoramique().equals(Panoramique.SPHERE)) { longit = HS.getLongitude() - 180; } else { longit = HS.getLongitude() + 90; } String txtAnime = (HS.isAnime()) ? "true" : "false"; contenuFichier += " <point \n" + " type=\"image\"\n" + " long=\"" + longit + "\"\n" + " lat=\"" + HS.getLatitude() + "\"\n" + " image=\"panovisu/images/hotspots/hotspotImage.png\"\n" + " img=\"images/" + HS.getLienImg() + "\"\n" + " info=\"" + HS.getInfo() + "\"\n" + " anime=\"" + txtAnime + "\"\n" + " />\n"; } contenuFichier += " </hotspots>\n"; contenuFichier += "\n" + "<!-- Dfinition des images de fond -->\n" + "\n"; if (gestionnaireInterface.nombreImagesFond > 0) { for (int ii = 0; ii < gestionnaireInterface.nombreImagesFond; ii++) { ImageFond imgFond = gestionnaireInterface.imagesFond[ii]; String strImgFond = "images/" + imgFond.getFichierImage().substring( imgFond.getFichierImage().lastIndexOf(File.separator) + 1, imgFond.getFichierImage().length()); String SMasquable = (imgFond.isMasquable()) ? "oui" : "non"; contenuFichier += " <imageFond\n" + " fichier=\"" + strImgFond + "\"\n" + " posX=\"" + imgFond.getPosX() + "\" \n" + " posY=\"" + imgFond.getPosY() + "\" \n" + " offsetX=\"" + imgFond.getOffsetX() + "\" \n" + " offsetY=\"" + imgFond.getOffsetY() + "\" \n" + " tailleX=\"" + imgFond.getTailleX() + "\" \n" + " tailleY=\"" + imgFond.getTailleY() + "\" \n" + " opacite=\"" + imgFond.getOpacite() + "\" \n" + " masquable=\"" + SMasquable + "\" \n" + " url=\"" + imgFond.getUrl() + "\" \n" + " infobulle=\"" + imgFond.getInfobulle() + "\" \n" + " />\n" + ""; } } if (gestionnaireInterface.bAffichePlan && panoramiquesProjet[i].isAffichePlan()) { int numPlan = panoramiquesProjet[i].getNumeroPlan(); Plan planPano = plans[numPlan]; rouge = (int) (gestionnaireInterface.couleurFondPlan.getRed() * 255.d); bleu = (int) (gestionnaireInterface.couleurFondPlan.getBlue() * 255.d); vert = (int) (gestionnaireInterface.couleurFondPlan.getGreen() * 255.d); String SAfficheRadar = (gestionnaireInterface.bAfficheRadar) ? "oui" : "non"; String coulFond = "rgba(" + rouge + "," + vert + "," + bleu + "," + gestionnaireInterface.opacitePlan + ")"; contenuFichier += " <plan\n" + " affiche=\"oui\" \n" + " image=\"images/" + planPano.getImagePlan() + "\"\n" + " largeur=\"" + gestionnaireInterface.largeurPlan + "\"\n" + " position=\"" + gestionnaireInterface.positionPlan + "\"\n" + " couleurFond=\"" + coulFond + "\"\n" + " couleurTexte=\"#" + gestionnaireInterface.txtCouleurTextePlan + "\"\n" + " nord=\"" + planPano.getDirectionNord() + "\"\n" + " boussolePosition=\"" + planPano.getPosition() + "\"\n" + " boussoleX=\"" + planPano.getPositionX() + "\"\n" + " boussoleY=\"" + planPano.getPositionX() + "\"\n" + " radarAffiche=\"" + SAfficheRadar + "\"\n" + " radarTaille=\"" + Math.round(gestionnaireInterface.tailleRadar) + "\"\n" + " radarCouleurFond=\"#" + gestionnaireInterface.txtCouleurFondRadar + "\"\n" + " radarCouleurLigne=\"#" + gestionnaireInterface.txtCouleurLigneRadar + "\"\n" + " radarOpacite=\"" + Math.round(gestionnaireInterface.opaciteRadar * 100.d) / 100.d + "\"\n" + " >\n"; for (int iPoint = 0; iPoint < planPano.getNombreHotspots(); iPoint++) { double posX = planPano.getHotspot(iPoint).getLongitude() * gestionnaireInterface.largeurPlan; double posY = planPano.getHotspot(iPoint).getLatitude() * planPano.getHauteurPlan() * gestionnaireInterface.largeurPlan / planPano.getLargeurPlan(); if (planPano.getHotspot(iPoint).getNumeroPano() == i) { contenuFichier += " <pointPlan\n" + " positX=\"" + posX + "\"\n" + " positY=\"" + posY + "\"\n" + " xml=\"actif\"\n" + " /> \n"; } else { contenuFichier += " <pointPlan\n" + " positX=\"" + posX + "\"\n" + " positY=\"" + posY + "\"\n" + " xml=\"xml/" + planPano.getHotspot(iPoint).getFichierXML() + "\"\n" + " texte=\"" + planPano.getHotspot(iPoint).getInfo() + "\"\n" + " /> \n"; } } contenuFichier += " </plan>\n"; } contenuFichier += "</scene>\n"; String fichierPano = panoramiquesProjet[i].getNomFichier(); String nomXMLFile = fichierPano .substring(fichierPano.lastIndexOf(File.separator) + 1, fichierPano.length()) .split("\\.")[0] + ".xml"; xmlFile = new File(xmlRepert + File.separator + nomXMLFile); xmlFile.setWritable(true); FileWriter fw = new FileWriter(xmlFile); try (BufferedWriter bw = new BufferedWriter(fw)) { bw.write(contenuFichier); } } Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); int hauteur = (int) tailleEcran.getHeight() - 200; String titreVis = "Panovisu - visualiseur 100% html5 (three.js)"; TextArea tfVisite = (TextArea) paneChoixPanoramique.lookup("#titreVisite"); if (!tfVisite.getText().equals("")) { titreVis = tfVisite.getText() + " - " + titreVis; } String fPano1 = "panos/niveau0/" + panoramiquesProjet[0].getNomFichier().substring( panoramiquesProjet[0].getNomFichier().lastIndexOf(File.separator) + 1, panoramiquesProjet[0].getNomFichier().length()); String fichierHTML = "<!DOCTYPE html>\n" + "<html lang=\"fr\">\n" + " <head>\n" + " <title>" + titreVis + "</title>\n" + " <meta charset=\"utf-8\">\n" + " <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0\">\n" + " <link rel=\"stylesheet\" media=\"screen\" href=\"panovisu/libs/jqueryMenu/jquery.contextMenu.css\" type=\"text/css\"/>\n" + " <meta property=\"og:title\" content=\"" + titreVis + "\" />\n" + " <meta property=\"og:description\" content=\"Une page cre avec panoVisu Editeur : 100% Libre 100% HTML5\" />\n" + " <meta property=\"og:image\" content=\"" + fPano1 + "\" />" + " </head>\n" + " <body>\n" + " <header>\n" + "\n" + " </header>\n" + " <article style=\"height : " + hauteur + "px;\">\n" + " <div id=\"pano\">\n" + " </div>\n" + " </article>\n" + " <script src=\"panovisu/panovisuInit.js\"></script>\n" + " <script src=\"panovisu/panovisu.js\"></script>\n" + " <script>\n" + "\n" + " $(function() {\n" + " $(window).resize(function(){\n" + " $(\"article\").height($(window).height()-10);\n" + " $(\"#pano\").height($(window).height()-10);\n" + " })\n" + " $(\"article\").height($(window).height()-10);\n" + " $(\"#pano\").height($(window).height()-10);\n" + " ajoutePano({\n" + " langue : \"" + locale.toString() + "\",\n" + " panoramique: \"pano\",\n" + " minFOV: 35,\n" + " maxFOV: 120,\n" + " fenX: \"100%\",\n" + " fenY: \"100%\",\n" + " xml: \"xml/PANO.xml\"\n" + " });\n" + " $(\".reseauSocial-twitter\").on(\"click\", function() {\n" + " window.open(\n" + " \"https://twitter.com/share?url=\" + document.location.href\n" + " );\n" + " return false;\n" + " });\n" + " $(\".reseauSocial-fb\").on(\"click\", function() {\n" + " window.open(\n" + " \"http://www.facebook.com/share.php?u=\" + document.location.href\n" + " );\n" + " return false;\n" + " });\n" + " $(\".reseauSocial-google\").on(\"click\", function() {\n" + " window.open(\n" + " \"https://plus.google.com/share?url=\" + document.location.href + \"&hl=fr\"\n" + " );\n" + " return false;\n" + " });\n" + " $(\".reseauSocial-email\").attr(\"href\",\"mailto:?body=\" + document.location.href + \"&hl=fr\");\n" // + " images=new Array();\n" // + chargeImages // + " prechargeImages(images); \n \n" + " });\n" + " </script>\n" + " </body>\n" + "</html>\n"; if (panoEntree.equals("")) { fichierHTML = fichierHTML .replace("PANO", panoramiquesProjet[0].getNomFichier() .substring(panoramiquesProjet[0].getNomFichier().lastIndexOf(File.separator) + 1, panoramiquesProjet[0].getNomFichier().length()) .split("\\.")[0]); } else { fichierHTML = fichierHTML.replace("PANO", panoEntree); } File fichIndexHTML = new File(repertTemp + File.separator + "index.html"); fichIndexHTML.setWritable(true); FileWriter fw1 = new FileWriter(fichIndexHTML); try (BufferedWriter bw1 = new BufferedWriter(fw1)) { bw1.write(fichierHTML); } DirectoryChooser repertChoix = new DirectoryChooser(); repertChoix.setTitle("Choix du repertoire de sauvegarde de la visite"); File repert = new File(EditeurPanovisu.repertoireProjet); repertChoix.setInitialDirectory(repert); File repertVisite = repertChoix.showDialog(null); String nomRepertVisite = repertVisite.getAbsolutePath(); copieDirectory(repertTemp, nomRepertVisite); Dialogs.create().title("Gnration de la visite") .message("Votre visite a bien t gnr dans le rpertoire : " + nomRepertVisite) .showInformation(); if (Desktop.isDesktopSupported()) { if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { Desktop dt = Desktop.getDesktop(); File fIndex = new File(nomRepertVisite + File.separator + "index.html"); dt.browse(fIndex.toURI()); } } } else { Dialogs.create().title("Gnration de la visite") .message("Votre visite n'a pu tre gnre, votre fichier n'tant pas sauvegard") .showError(); } }
From source file:org.kuali.test.creator.TestCreator.java
public void showHelp(ActionEvent e) { if (Desktop.isDesktopSupported()) { try {//from w ww .ja va2s . co m File file = new File(getConfiguration().getRepositoryLocation() + Constants.HELP_FILE_PATH); if (StringUtils.isNotBlank(getConfiguration().getPdfViewerPath())) { Runtime.getRuntime().exec(getConfiguration().getPdfViewerPath() + " " + file.getPath()); } else { Desktop.getDesktop().open(file); } } catch (Exception ex) { LOG.warn("Error ocurred opening help PDF file - " + ex.toString()); } } }
From source file:org.jajuk.util.UtilSystem.java
/** * Return whether the Desktop BROWSE action is actually supported * Note this bug : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6486393 * under KDE : isSupported returns true but we get an exception when actually browsing * //w w w . j a v a 2 s. c o m * @return true, if checks if is browser supported */ public static boolean isBrowserSupported() { // value stored for perf if (browserSupported != null) { return browserSupported; } // In server UT mode, just return false if (GraphicsEnvironment.isHeadless()) { return false; } else { if (Desktop.isDesktopSupported()) { // If under Linux, check if we're under KDE because of a sun bug, // see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6486393 and #1612 if (isUnderLinux() && isUnderKDE()) { return false; } else { return (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)); } } else { return false; } } }
From source file:com.freedomotic.jfrontend.MainWindow.java
private void mnuTutorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuTutorialActionPerformed String url = "http://freedomotic-user-manual.readthedocs.io/"; if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { try { URI uri = new URI(url); // url is a string containing the URL desktop.browse(uri);/* w w w. jav a 2s. c o m*/ } catch (IOException | URISyntaxException ex) { LOG.error(ex.getLocalizedMessage()); } } } else { //open popup with link JOptionPane.showMessageDialog(this, i18n.msg("goto") + url); } }
From source file:GUI.GraphicalInterface.java
private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null; String homepage = "https://sourceforge.net/projects/grafcom/"; if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { try {//from w ww .j av a2 s . co m desktop.browse(java.net.URI.create(homepage)); } catch (IOException e) { System.out.println("Error occured while opening Project homepage at SourceForge.net"); } } }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
/** * Initializes the controller class./*from ww w . j a v a 2 s . c o m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { this.resourceBundle = rb; viewer3DPanelController.setResourceBundle(rb); initStrings(rb); colorPickerSeries.valueProperty().addListener(new ChangeListener<javafx.scene.paint.Color>() { @Override public void changed(ObservableValue<? extends javafx.scene.paint.Color> observable, javafx.scene.paint.Color oldValue, javafx.scene.paint.Color newValue) { if (listViewVoxelsFilesChart.getSelectionModel().getSelectedItems().size() == 1) { listViewVoxelsFilesChart.getSelectionModel().getSelectedItem().getSeriesParameters() .setColor(new Color((float) newValue.getRed(), (float) newValue.getGreen(), (float) newValue.getBlue(), 1.0f)); } } }); comboboxScript.getItems().setAll("Daniel script"); vboxWeighting.disableProperty().bind(checkboxEnableWeighting.selectedProperty().not()); checkboxEnableWeighting.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue && textAreaWeighting.getText().isEmpty()) { int selectedVoxTab = tabPaneVoxelisation.getSelectionModel().getSelectedIndex(); if (selectedVoxTab == 0) { //ALS fillWeightingData(EchoesWeightParams.DEFAULT_ALS_WEIGHTING); } else if (selectedVoxTab == 1) { //TLS fillWeightingData(EchoesWeightParams.DEFAULT_TLS_WEIGHTING); } } } }); /*comboboxTransMode.getItems().setAll(1, 2, 3); comboboxTransMode.getSelectionModel().selectFirst(); comboboxPathLengthMode.getItems().setAll("A", "B"); comboboxPathLengthMode.getSelectionModel().selectFirst();*/ helpButtonNaNsCorrection.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { helpButtonNaNsCorrectionController.showHelpDialog(resourceBundle.getString("help_NaNs_correction")); } }); helpButtonAutoBBox.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { helpButtonAutoBBoxController.showHelpDialog(resourceBundle.getString("help_bbox")); } }); helpButtonHemiPhoto.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { helpButtonHemiPhotoController.showHelpDialog(resourceBundle.getString("help_hemiphoto")); } }); buttonHelpEmptyShotsFilter.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { buttonHelpEmptyShotsFilterController .showHelpDialog(resourceBundle.getString("help_empty_shots_filter")); } }); /*work around, the divider positions values are defined in the fxml, but when the window is initialized the values are lost*/ Platform.runLater(new Runnable() { @Override public void run() { splitPaneMain.setDividerPositions(0.75f); splitPaneVoxelization.setDividerPositions(0.45f); } }); initValidationSupport(); initPostProcessTab(); listViewTransmittanceMapSensorPositions.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); listViewTaskList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); MenuItem menuItemPadValue1m = new MenuItem("1m voxel size"); addMenuItemPadValue(menuItemPadValue1m, 3.536958f); MenuItem menuItemPadValue2m = new MenuItem("2m voxel size"); addMenuItemPadValue(menuItemPadValue2m, 2.262798f); MenuItem menuItemPadValue3m = new MenuItem("3m voxel size"); addMenuItemPadValue(menuItemPadValue3m, 1.749859f); MenuItem menuItemPadValue4m = new MenuItem("4m voxel size"); addMenuItemPadValue(menuItemPadValue4m, 1.3882959f); MenuItem menuItemPadValue5m = new MenuItem("5m voxel size"); addMenuItemPadValue(menuItemPadValue5m, 1.0848f); menuButtonAdvisablePADMaxValues.getItems().addAll(menuItemPadValue1m, menuItemPadValue2m, menuItemPadValue3m, menuItemPadValue4m, menuItemPadValue5m); fileChooserSaveCanopyAnalyserOutputFile = new FileChooserContext(); fileChooserSaveCanopyAnalyserCfgFile = new FileChooserContext(); fileChooserSaveTransmittanceSimCfgFile = new FileChooserContext(); fileChooserOpenCanopyAnalyserInputFile = new FileChooserContext(); listViewCanopyAnalyzerSensorPositions.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); ContextMenu contextMenuProductsList = new ContextMenu(); MenuItem openImageItem = new MenuItem(RS_STR_OPEN_IMAGE); openImageItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedFile = listViewProductsFiles.getSelectionModel().getSelectedItem(); showImage(selectedFile); } }); Menu menuEdit = new Menu(RS_STR_EDIT); MenuItem menuItemEditVoxels = new MenuItem("Remove voxels (delete key)"); MenuItem menuItemFitToContent = new MenuItem("Fit to content"); MenuItem menuItemCrop = new MenuItem("Crop"); menuEdit.getItems().setAll(menuItemEditVoxels, menuItemFitToContent, menuItemCrop); menuItemFitToContent.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { fitVoxelSpaceToContent(selectedItem); } } }); menuItemEditVoxels.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { editVoxelSpace(selectedItem); } } }); menuItemCrop.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { try { voxelSpaceCroppingFrameController.setVoxelFile(selectedItem); voxelSpaceCroppingFrame.show(); } catch (Exception ex) { showErrorDialog(ex); } } } }); Menu menuExport = new Menu(RS_STR_EXPORT); MenuItem menuItemExportDartMaket = new MenuItem("Dart (maket.txt)"); MenuItem menuItemExportDartPlots = new MenuItem("Dart (plots.xml)"); MenuItem menuItemExportMeshObj = new MenuItem("Mesh (*.obj)"); menuItemExportDartMaket.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { exportDartMaket(selectedItem); } } }); menuItemExportDartPlots.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { exportDartPlots(selectedItem); } } }); menuItemExportMeshObj.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { exportMeshObj(selectedItem); } } }); menuExport.getItems().setAll(menuItemExportDartMaket, menuItemExportDartPlots, menuItemExportMeshObj); MenuItem menuItemInfo = new MenuItem(RS_STR_INFO); menuItemInfo.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Alert alert = new Alert(AlertType.INFORMATION); File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { VoxelFileReader reader; try { reader = new VoxelFileReader(selectedItem); VoxelSpaceInfos voxelSpaceInfos = reader.getVoxelSpaceInfos(); alert.setTitle("Information"); alert.setHeaderText("Voxel space informations"); alert.setContentText(voxelSpaceInfos.toString()); alert.show(); } catch (Exception ex) { showErrorDialog(ex); } } } }); final MenuItem menuItemOpenContainingFolder = new MenuItem(RS_STR_OPEN_CONTAINING_FOLDER); menuItemOpenContainingFolder.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { final File selectedItem = listViewProductsFiles.getSelectionModel().getSelectedItem(); if (selectedItem != null) { if (Desktop.isDesktopSupported()) { new Thread(() -> { try { Desktop.getDesktop().open(selectedItem.getParentFile()); } catch (IOException ex) { logger.error("Cannot open directory " + selectedItem); } }).start(); } } } }); listViewProductsFiles.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { @Override public void handle(ContextMenuEvent event) { if (listViewProductsFiles.getSelectionModel().getSelectedIndices().size() == 1) { File selectedFile = listViewProductsFiles.getSelectionModel().getSelectedItem(); String extension = FileManager.getExtension(selectedFile); switch (extension) { case ".png": case ".bmp": case ".jpg": contextMenuProductsList.getItems().setAll(openImageItem, menuItemOpenContainingFolder); contextMenuProductsList.show(listViewProductsFiles, event.getScreenX(), event.getScreenY()); break; case ".vox": default: if (VoxelFileReader.isFileAVoxelFile(selectedFile)) { contextMenuProductsList.getItems().setAll(menuItemInfo, menuItemOpenContainingFolder, menuEdit, menuExport); contextMenuProductsList.show(listViewProductsFiles, event.getScreenX(), event.getScreenY()); } } } } }); ContextMenu contextMenuLidarScanEdit = new ContextMenu(); MenuItem editItem = new MenuItem("Edit"); editItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { filterFrameController.setFilters("Reflectance", "Deviation", "Amplitude"); filterFrame.show(); filterFrame.setOnHidden(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { if (filterFrameController.getFilter() != null) { ObservableList<LidarScan> items = listViewHemiPhotoScans.getSelectionModel() .getSelectedItems(); for (LidarScan scan : items) { scan.filters.add(filterFrameController.getFilter()); } } } }); } }); contextMenuLidarScanEdit.getItems().add(editItem); listViewHemiPhotoScans.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); listViewHemiPhotoScans.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() { @Override public void handle(ContextMenuEvent event) { contextMenuLidarScanEdit.show(listViewHemiPhotoScans, event.getScreenX(), event.getScreenY()); } }); /**LAD tab initialization**/ comboboxLADChoice.getItems().addAll(LeafAngleDistribution.Type.UNIFORM, LeafAngleDistribution.Type.SPHERIC, LeafAngleDistribution.Type.ERECTOPHILE, LeafAngleDistribution.Type.PLANOPHILE, LeafAngleDistribution.Type.EXTREMOPHILE, LeafAngleDistribution.Type.PLAGIOPHILE, LeafAngleDistribution.Type.HORIZONTAL, LeafAngleDistribution.Type.VERTICAL, LeafAngleDistribution.Type.ELLIPSOIDAL, LeafAngleDistribution.Type.ELLIPTICAL, LeafAngleDistribution.Type.TWO_PARAMETER_BETA); comboboxLADChoice.getSelectionModel().select(LeafAngleDistribution.Type.SPHERIC); comboboxLADChoice.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<LeafAngleDistribution.Type>() { @Override public void changed(ObservableValue<? extends LeafAngleDistribution.Type> observable, LeafAngleDistribution.Type oldValue, LeafAngleDistribution.Type newValue) { if (newValue == LeafAngleDistribution.Type.TWO_PARAMETER_BETA || newValue == LeafAngleDistribution.Type.ELLIPSOIDAL) { hboxTwoBetaParameters.setVisible(true); if (newValue == LeafAngleDistribution.Type.ELLIPSOIDAL) { labelLADBeta.setVisible(false); } else { labelLADBeta.setVisible(true); } } else { hboxTwoBetaParameters.setVisible(false); } } }); ToggleGroup ladTypeGroup = new ToggleGroup(); radiobuttonLADHomogeneous.setToggleGroup(ladTypeGroup); radiobuttonLADLocalEstimation.setToggleGroup(ladTypeGroup); /**CHART panel initialization**/ ToggleGroup profileChartType = new ToggleGroup(); radiobuttonPreDefinedProfile.setToggleGroup(profileChartType); radiobuttonFromVariableProfile.setToggleGroup(profileChartType); ToggleGroup profileChartRelativeHeightType = new ToggleGroup(); radiobuttonHeightFromAboveGround.setToggleGroup(profileChartRelativeHeightType); radiobuttonHeightFromBelowCanopy.setToggleGroup(profileChartRelativeHeightType); comboboxFromVariableProfile.disableProperty().bind(radiobuttonPreDefinedProfile.selectedProperty()); comboboxPreDefinedProfile.disableProperty().bind(radiobuttonFromVariableProfile.selectedProperty()); hboxMaxPADVegetationProfile.visibleProperty().bind(radiobuttonPreDefinedProfile.selectedProperty()); listViewVoxelsFilesChart.getSelectionModel().selectedIndexProperty() .addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { if (listViewVoxelsFilesChart.getSelectionModel().getSelectedItems().size() > 1) { colorPickerSeries.setDisable(true); } else if (listViewVoxelsFilesChart.getSelectionModel().getSelectedItems().size() == 1) { VoxelFileChart selectedItem = listViewVoxelsFilesChart.getSelectionModel() .getSelectedItem(); Color selectedItemColor = selectedItem.getSeriesParameters().getColor(); colorPickerSeries.setDisable(false); colorPickerSeries.setValue(new javafx.scene.paint.Color( selectedItemColor.getRed() / 255.0, selectedItemColor.getGreen() / 255.0, selectedItemColor.getBlue() / 255.0, 1.0)); if (newValue.intValue() >= 0) { textfieldLabelVoxelFileChart.setText( listViewVoxelsFilesChart.getItems().get(newValue.intValue()).label); } } } }); textfieldLabelVoxelFileChart.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (listViewVoxelsFilesChart.getSelectionModel().getSelectedIndex() >= 0) { listViewVoxelsFilesChart.getSelectionModel().getSelectedItem().label = newValue; } } }); listViewVoxelsFilesChart.getItems().addListener(new ListChangeListener<VoxelFileChart>() { @Override public void onChanged(ListChangeListener.Change<? extends VoxelFileChart> c) { while (c.next()) { } if (c.wasAdded() && c.getAddedSize() == c.getList().size()) { try { VoxelFileReader reader = new VoxelFileReader(c.getList().get(0).file); String[] columnNames = reader.getVoxelSpaceInfos().getColumnNames(); comboboxFromVariableProfile.getItems().clear(); comboboxFromVariableProfile.getItems().addAll(columnNames); comboboxFromVariableProfile.getSelectionModel().selectFirst(); } catch (Exception ex) { logger.error("Cannot read voxel file", ex); } } } }); anchorpaneQuadrats.disableProperty().bind(checkboxMakeQuadrats.selectedProperty().not()); comboboxSelectAxisForQuadrats.getItems().addAll("X", "Y", "Z"); comboboxSelectAxisForQuadrats.getSelectionModel().select(1); comboboxPreDefinedProfile.getItems().addAll("Vegetation (PAD)"); comboboxPreDefinedProfile.getSelectionModel().selectFirst(); radiobuttonSplitCountForQuadrats.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { textFieldSplitCountForQuadrats.setDisable(!newValue); textFieldLengthForQuadrats.setDisable(newValue); } }); ToggleGroup chartMakeQuadratsSplitType = new ToggleGroup(); radiobuttonLengthForQuadrats.setToggleGroup(chartMakeQuadratsSplitType); radiobuttonSplitCountForQuadrats.setToggleGroup(chartMakeQuadratsSplitType); /**Virtual measures panel initialization**/ comboboxHemiPhotoBitmapOutputMode.getItems().addAll("Pixel", "Color"); comboboxHemiPhotoBitmapOutputMode.getSelectionModel().selectFirst(); ToggleGroup virtualMeasuresChoiceGroup = new ToggleGroup(); toggleButtonLAI2000Choice.setToggleGroup(virtualMeasuresChoiceGroup); toggleButtonLAI2200Choice.setToggleGroup(virtualMeasuresChoiceGroup); comboboxChooseCanopyAnalyzerSampling.getItems().setAll(500, 4000, 10000); comboboxChooseCanopyAnalyzerSampling.getSelectionModel().selectFirst(); initEchoFiltering(); data = FXCollections.observableArrayList(); tableViewSimulationPeriods.setItems(data); tableViewSimulationPeriods.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); comboboxChooseDirectionsNumber.getItems().addAll(1, 6, 16, 46, 136, 406); comboboxChooseDirectionsNumber.getSelectionModel().select(4); ToggleGroup scannerPositionsMode = new ToggleGroup(); /*radiobuttonScannerPosSquaredArea.setToggleGroup(scannerPositionsMode); radiobuttonScannerPosFile.setToggleGroup(scannerPositionsMode);*/ tableColumnPeriod.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<SimulationPeriod, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<SimulationPeriod, String> param) { return new SimpleStringProperty(param.getValue().getPeriod().toString()); } }); tableColumnClearness.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<SimulationPeriod, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<SimulationPeriod, String> param) { return new SimpleStringProperty(String.valueOf(param.getValue().getClearnessCoefficient())); } }); checkboxMultiFiles.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { anchorpaneBoundingBoxParameters.setDisable(newValue); } }); hboxGenerateBitmapFiles.disableProperty().bind(checkboxGenerateBitmapFile.selectedProperty().not()); hboxGenerateTextFile.disableProperty().bind(checkboxGenerateTextFile.selectedProperty().not()); fileChooserOpenConfiguration = new FileChooser(); fileChooserOpenConfiguration.setTitle("Choose configuration file"); fileChooserSaveConfiguration = new FileChooserContext("cfg.xml"); fileChooserSaveConfiguration.fc.setTitle("Choose output file"); fileChooserOpenInputFileALS = new FileChooser(); fileChooserOpenInputFileALS.setTitle("Open input file"); fileChooserOpenInputFileALS.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Shot files", "*.sht"), new ExtensionFilter("Text Files", "*.txt"), new ExtensionFilter("Las Files", "*.las", "*.laz")); fileChooserOpenTrajectoryFileALS = new FileChooser(); fileChooserOpenTrajectoryFileALS.setTitle("Open trajectory file"); fileChooserOpenTrajectoryFileALS.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Text Files", "*.txt")); fileChooserOpenOutputFileALS = new FileChooser(); fileChooserOpenOutputFileALS.setTitle("Choose output file"); fileChooserOpenInputFileTLS = new FileChooserContext(); fileChooserOpenInputFileTLS.fc.setTitle("Open input file"); fileChooserOpenInputFileTLS.fc.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Text Files", "*.txt"), new ExtensionFilter("Rxp Files", "*.rxp"), new ExtensionFilter("Project Rsp Files", "*.rsp")); directoryChooserOpenOutputPathTLS = new DirectoryChooser(); directoryChooserOpenOutputPathTLS.setTitle("Choose output path"); directoryChooserOpenOutputPathALS = new DirectoryChooser(); directoryChooserOpenOutputPathALS.setTitle("Choose output path"); fileChooserSaveOutputFileTLS = new FileChooser(); fileChooserSaveOutputFileTLS.setTitle("Save voxel file"); fileChooserSaveTransmittanceTextFile = new FileChooser(); fileChooserSaveTransmittanceTextFile.setTitle("Save text file"); directoryChooserSaveTransmittanceBitmapFile = new DirectoryChooser(); directoryChooserSaveTransmittanceBitmapFile.setTitle("Choose output directory"); fileChooserSaveHemiPhotoOutputBitmapFile = new FileChooserContext("*.png"); fileChooserSaveHemiPhotoOutputBitmapFile.fc.setTitle("Save bitmap file"); directoryChooserSaveHemiPhotoOutputBitmapFile = new DirectoryChooser(); directoryChooserSaveHemiPhotoOutputBitmapFile.setTitle("Choose bitmap files output directory"); directoryChooserSaveHemiPhotoOutputTextFile = new DirectoryChooser(); directoryChooserSaveHemiPhotoOutputTextFile.setTitle("Choose text files output directory"); fileChooserSaveHemiPhotoOutputTextFile = new FileChooser(); fileChooserSaveHemiPhotoOutputTextFile.setTitle("Save text file"); fileChooserOpenVoxelFile = new FileChooser(); fileChooserOpenVoxelFile.setTitle("Open voxel file"); fileChooserOpenVoxelFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Voxel Files", "*.vox")); fileChooserOpenPopMatrixFile = new FileChooser(); fileChooserOpenPopMatrixFile.setTitle("Choose matrix file"); fileChooserOpenPopMatrixFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Text Files", "*.txt")); fileChooserOpenSopMatrixFile = new FileChooser(); fileChooserOpenSopMatrixFile.setTitle("Choose matrix file"); fileChooserOpenSopMatrixFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Text Files", "*.txt")); fileChooserOpenVopMatrixFile = new FileChooser(); fileChooserOpenVopMatrixFile.setTitle("Choose matrix file"); fileChooserOpenVopMatrixFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Text Files", "*.txt")); fileChooserOpenPonderationFile = new FileChooser(); fileChooserOpenPonderationFile.setTitle("Choose ponderation file"); fileChooserOpenPonderationFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Text Files", "*.txt")); fileChooserOpenDTMFile = new FileChooser(); fileChooserOpenDTMFile.setTitle("Choose DTM file"); fileChooserOpenDTMFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("DTM Files", "*.asc")); fileChooserOpenPointCloudFile = new FileChooser(); fileChooserOpenPointCloudFile.setTitle("Choose point cloud file"); fileChooserOpenPointCloudFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("TXT Files", "*.txt")); fileChooserOpenMultiResVoxelFile = new FileChooser(); fileChooserOpenMultiResVoxelFile.setTitle("Choose voxel file"); fileChooserOpenMultiResVoxelFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Voxel Files", "*.vox")); fileChooserOpenOutputFileMultiRes = new FileChooser(); fileChooserOpenOutputFileMultiRes.setTitle("Save voxel file"); fileChooserAddTask = new FileChooser(); fileChooserAddTask.setTitle("Choose parameter file"); fileChooserAddTask.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("XML Files", "*.xml")); fileChooserSaveDartFile = new FileChooser(); fileChooserSaveDartFile.setTitle("Save dart file (.maket)"); fileChooserSaveDartFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Maket File", "*.maket")); fileChooserOpenOutputFileMerging = new FileChooser(); fileChooserOpenOutputFileMerging.setTitle("Choose voxel file"); fileChooserOpenOutputFileMerging.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("Voxel Files", "*.vox")); fileChooserOpenScriptFile = new FileChooser(); fileChooserOpenScriptFile.setTitle("Choose script file"); fileChooserSaveGroundEnergyOutputFile = new FileChooser(); fileChooserSaveGroundEnergyOutputFile.setTitle("Save ground energy file"); fileChooserOpenPointsPositionFile = new FileChooser(); fileChooserOpenPointsPositionFile.setTitle("Choose points file"); fileChooserOpenPointsPositionFile.getExtensionFilters().addAll(new ExtensionFilter("All Files", "*"), new ExtensionFilter("TXT Files", "*.txt")); try { viewCapsSetupFrame = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/ViewCapsSetupFrame.fxml")); Parent root = loader.load(); viewCapsSetupFrameController = loader.getController(); viewCapsSetupFrame.setScene(new Scene(root)); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/FilteringPaneComponent.fxml")); anchorPaneEchoFilteringRxp = loader.load(); filteringPaneController = loader.getController(); filteringPaneController.setFiltersNames("Reflectance", "Amplitude", "Deviation"); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } try { positionImporterFrame = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/PositionImporterFrame.fxml")); Parent root = loader.load(); positionImporterFrameController = loader.getController(); positionImporterFrame.setScene(new Scene(root)); positionImporterFrameController.setStage(positionImporterFrame); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } try { voxelSpaceCroppingFrame = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VoxelSpaceCroppingFrame.fxml")); Parent root = loader.load(); voxelSpaceCroppingFrameController = loader.getController(); voxelSpaceCroppingFrame.setScene(new Scene(root)); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } try { attributsImporterFrame = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/AttributsImporterFrame.fxml")); Parent root = loader.load(); attributsImporterFrameController = loader.getController(); attributsImporterFrame.setScene(new Scene(root)); attributsImporterFrameController.setStage(attributsImporterFrame); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } try { textFileParserFrameController = TextFileParserFrameController.getInstance(); } catch (Exception ex) { logger.error("Cannot load fxml file", ex); } try { transformationFrameController = TransformationFrameController.getInstance(); transformationFrame = transformationFrameController.getStage(); } catch (Exception ex) { logger.error("Cannot load fxml file", ex); } updaterFrame = new Stage(); try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/update/UpdaterFrame.fxml")); Parent root = loader.load(); updaterFrameController = loader.getController(); updaterFrame.setScene(new Scene(root)); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } riscanProjectExtractor = new RiscanProjectExtractor(); ptxProjectExtractor = new PTXProjectExtractor(); ptgProjectExtractor = new PTGProjectExtractor(); dateChooserFrame = new Stage(); try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/DateChooserFrame.fxml")); Parent root = loader.load(); dateChooserFrameController = loader.getController(); dateChooserFrame.setScene(new Scene(root)); dateChooserFrameController.setStage(dateChooserFrame); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } comboboxModeALS.getItems().addAll(RS_STR_INPUT_TYPE_LAS, RS_STR_INPUT_TYPE_LAZ, /*RS_STR_INPUT_TYPE_XYZ, */RS_STR_INPUT_TYPE_SHOTS); comboboxModeALS.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (newValue.equals(RS_STR_INPUT_TYPE_SHOTS)) { alsVoxValidationSupport.registerValidator(textFieldTrajectoryFileALS, false, Validators.unregisterValidator); } else { alsVoxValidationSupport.registerValidator(textFieldTrajectoryFileALS, false, Validators.fileExistValidator); } } }); comboboxModeTLS.getItems().setAll("Rxp scan", "Rsp project", "PTX", "PTG"/*, RS_STR_INPUT_TYPE_XYZ, RS_STR_INPUT_TYPE_SHOTS*/); comboboxGroundEnergyOutputFormat.getItems().setAll("txt", "png"); comboboxLaserSpecification.getItems().addAll(LaserSpecification.getPresets()); comboboxLaserSpecification.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<LaserSpecification>() { @Override public void changed(ObservableValue<? extends LaserSpecification> observable, LaserSpecification oldValue, LaserSpecification newValue) { DecimalFormatSymbols symb = new DecimalFormatSymbols(); symb.setDecimalSeparator('.'); DecimalFormat formatter = new DecimalFormat("#####.######", symb); textFieldBeamDiameterAtExit.setText(formatter.format(newValue.getBeamDiameterAtExit())); textFieldBeamDivergence.setText(formatter.format(newValue.getBeamDivergence())); } }); comboboxLaserSpecification.getSelectionModel().select(LaserSpecification.LMS_Q560); comboboxLaserSpecification.disableProperty().bind(checkboxCustomLaserSpecification.selectedProperty()); textFieldBeamDiameterAtExit.disableProperty() .bind(checkboxCustomLaserSpecification.selectedProperty().not()); textFieldBeamDivergence.disableProperty().bind(checkboxCustomLaserSpecification.selectedProperty().not()); listViewProductsFiles.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); listViewProductsFiles.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { int size = listViewProductsFiles.getSelectionModel().getSelectedIndices().size(); if (size == 1) { viewer3DPanelController .updateCurrentVoxelFile(listViewProductsFiles.getSelectionModel().getSelectedItem()); } } }); listViewTaskList.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { int size = listViewTaskList.getSelectionModel().getSelectedIndices().size(); if (size == 1) { buttonLoadSelectedTask.setDisable(false); } else { buttonLoadSelectedTask.setDisable(true); } buttonExecute.setDisable(size == 0); } }); resetMatrices(); calculateMatrixFrame = new Stage(); try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/CalculateMatrixFrame.fxml")); Parent root = loader.load(); calculateMatrixFrameController = loader.getController(); calculateMatrixFrameController.setStage(calculateMatrixFrame); Scene scene = new Scene(root); calculateMatrixFrame.setScene(scene); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } filterFrame = new Stage(); try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/FilterFrame.fxml")); Parent root = loader.load(); filterFrameController = loader.getController(); filterFrameController.setStage(filterFrame); filterFrameController.setFilters("Angle"); filterFrame.setScene(new Scene(root)); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/export/ObjExporterDialog.fxml")); Parent root = loader.load(); objExporterController = loader.getController(); Stage s = new Stage(); objExporterController.setStage(s); s.setScene(new Scene(root)); } catch (IOException ex) { logger.error("Cannot load fxml file", ex); } textFieldResolution.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { voxelSpacePanelVoxelizationController.setResolution(Float.valueOf(newValue)); } }); textFieldResolution.textProperty().addListener(voxelSpacePanelVoxelizationController.getChangeListener()); checkboxUseDTMFilter.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (checkboxUseDTMFilter.isSelected()) { buttonOpenDTMFile.setDisable(false); textfieldDTMPath.setDisable(false); textfieldDTMValue.setDisable(false); checkboxApplyVOPMatrix.setDisable(false); labelDTMValue.setDisable(false); labelDTMPath.setDisable(false); } else { buttonOpenDTMFile.setDisable(true); textfieldDTMPath.setDisable(true); textfieldDTMValue.setDisable(true); checkboxApplyVOPMatrix.setDisable(true); labelDTMValue.setDisable(true); labelDTMPath.setDisable(true); } } }); checkboxUseVopMatrix.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { buttonSetVOPMatrix.setDisable(!newValue); } }); checkboxUsePopMatrix.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { checkBoxUseDefaultPopMatrix.setDisable(false); buttonOpenPopMatrixFile.setDisable(false); } else { checkBoxUseDefaultPopMatrix.setDisable(true); buttonOpenPopMatrixFile.setDisable(true); } } }); checkboxUseSopMatrix.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { checkBoxUseDefaultSopMatrix.setDisable(false); buttonOpenSopMatrixFile.setDisable(false); } else { checkBoxUseDefaultSopMatrix.setDisable(true); buttonOpenSopMatrixFile.setDisable(true); } } }); checkboxCalculateGroundEnergy.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { anchorPaneGroundEnergyParameters.setDisable(false); } else { anchorPaneGroundEnergyParameters.setDisable(true); } } }); listviewRxpScans.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<LidarScan>() { @Override public void changed(ObservableValue<? extends LidarScan> observable, LidarScan oldValue, LidarScan newValue) { if (newValue != null) { sopMatrix = newValue.matrix; updateResultMatrix(); } } }); comboboxModeTLS.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { switch (newValue.intValue()) { case 1: case 2: case 3: listviewRxpScans.setDisable(false); checkboxMergeAfter.setDisable(false); textFieldMergedFileName.setDisable(false); disableSopMatrixChoice(false); labelTLSOutputPath.setText("Output path"); break; default: listviewRxpScans.setDisable(true); checkboxMergeAfter.setDisable(true); textFieldMergedFileName.setDisable(true); //disableSopMatrixChoice(true); labelTLSOutputPath.setText("Output file"); } if (newValue.intValue() == 0 || newValue.intValue() == 1) { checkboxEmptyShotsFilter.setDisable(false); } else { checkboxEmptyShotsFilter.setDisable(true); } } }); tabPaneVoxelisation.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { switch (newValue.intValue()) { case 1: disableSopMatrixChoice(false); disablePopMatrixChoice(false); checkboxEmptyShotsFilter.setDisable(false); break; default: disableSopMatrixChoice(true); disablePopMatrixChoice(true); checkboxEmptyShotsFilter.setDisable(true); } switch (newValue.intValue()) { case 0: checkboxCalculateGroundEnergy.setDisable(false); if (checkboxCalculateGroundEnergy.isSelected()) { anchorPaneGroundEnergyParameters.setDisable(true); checkboxCalculateGroundEnergy.setDisable(false); } anchorPaneEchoFiltering.getChildren().set(0, anchorPaneEchoFilteringClassifications); //anchorPaneEchoFilteringClassifications.setVisible(true); anchorpaneBoundingBoxParameters.setDisable(checkboxMultiFiles.isSelected()); hboxAutomaticBBox.setDisable(false); break; default: anchorPaneGroundEnergyParameters.setDisable(true); checkboxCalculateGroundEnergy.setDisable(true); anchorPaneEchoFiltering.getChildren().set(0, anchorPaneEchoFilteringRxp); //anchorPaneEchoFilteringClassifications.setVisible(false); anchorpaneBoundingBoxParameters.setDisable(false); hboxAutomaticBBox.setDisable(true); } } }); int availableCores = Runtime.getRuntime().availableProcessors(); sliderRSPCoresToUse.setMin(1); sliderRSPCoresToUse.setMax(availableCores); sliderRSPCoresToUse.setValue(availableCores); textFieldInputFileALS.setOnDragOver(DragAndDropHelper.dragOverEvent); textFieldTrajectoryFileALS.setOnDragOver(DragAndDropHelper.dragOverEvent); textFieldOutputFileALS.setOnDragOver(DragAndDropHelper.dragOverEvent); textFieldInputFileTLS.setOnDragOver(DragAndDropHelper.dragOverEvent); textFieldOutputFileMerging.setOnDragOver(DragAndDropHelper.dragOverEvent); textfieldDTMPath.setOnDragOver(DragAndDropHelper.dragOverEvent); textFieldOutputFileGroundEnergy.setOnDragOver(DragAndDropHelper.dragOverEvent); listViewTaskList.setOnDragOver(DragAndDropHelper.dragOverEvent); listViewProductsFiles.setOnDragOver(DragAndDropHelper.dragOverEvent); textfieldVoxelFilePathTransmittance.setOnDragOver(DragAndDropHelper.dragOverEvent); textfieldOutputTextFilePath.setOnDragOver(DragAndDropHelper.dragOverEvent); textfieldOutputBitmapFilePath.setOnDragOver(DragAndDropHelper.dragOverEvent); textFieldInputFileALS.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles() && db.getFiles().size() == 1) { success = true; for (File file : db.getFiles()) { if (file != null) { textFieldInputFileALS.setText(file.getAbsolutePath()); selectALSInputMode(file); } } } event.setDropCompleted(success); event.consume(); } }); textFieldTrajectoryFileALS.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles() && db.getFiles().size() == 1) { success = true; for (File file : db.getFiles()) { if (file != null) { onTrajectoryFileChoosed(file); } } } event.setDropCompleted(success); event.consume(); } }); textFieldInputFileTLS.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles() && db.getFiles().size() == 1) { success = true; for (File file : db.getFiles()) { if (file != null) { onInputFileTLSChoosed(file); } } } event.setDropCompleted(success); event.consume(); } }); setDragDroppedSingleFileEvent(textFieldOutputFileALS); setDragDroppedSingleFileEvent(textFieldOutputFileMerging); setDragDroppedSingleFileEvent(textfieldDTMPath); setDragDroppedSingleFileEvent(textFieldOutputFileGroundEnergy); setDragDroppedSingleFileEvent(textfieldVoxelFilePathTransmittance); setDragDroppedSingleFileEvent(textfieldOutputTextFilePath); setDragDroppedSingleFileEvent(textfieldOutputBitmapFilePath); listViewTaskList.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; for (File file : db.getFiles()) { addFileToTaskList(file); } } event.setDropCompleted(success); event.consume(); } }); listViewProductsFiles.setOnDragDropped(new EventHandler<DragEvent>() { @Override public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasFiles()) { success = true; for (File file : db.getFiles()) { addFileToProductsList(file); } } event.setDropCompleted(success); event.consume(); } }); listViewProductsFiles.setOnDragDetected(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { Dragboard db = listViewProductsFiles.startDragAndDrop(TransferMode.COPY); ClipboardContent content = new ClipboardContent(); content.putFiles(listViewProductsFiles.getSelectionModel().getSelectedItems()); db.setContent(content); event.consume(); } }); addPointcloudFilterComponent(); checkboxUsePointcloudFilter.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { hBoxPointCloudFiltering.setDisable(!newValue); ObservableList<Node> list = vBoxPointCloudFiltering.getChildren(); for (Node n : list) { if (n instanceof PointCloudFilterPaneComponent) { PointCloudFilterPaneComponent panel = (PointCloudFilterPaneComponent) n; panel.disableContent(!newValue); } } buttonAddPointcloudFilter.setDisable(!newValue); } }); //displayGThetaAllDistributions(); }
From source file:com.freedomotic.jfrontend.MainWindow.java
/** * /* w ww. j a v a2s . c o m*/ */ private void openGoogleForm() {//GEN-FIRST:event_jMenuItem1ActionPerformed // TODO add your handling code here: String url = "https://goo.gl/CC65By"; if (Desktop.isDesktopSupported()) { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(java.awt.Desktop.Action.BROWSE)) { try { URI uri = new URI(url); // url is a string containing the URL desktop.browse(uri); } catch (IOException | URISyntaxException ex) { LOG.error(ex.getLocalizedMessage()); } } } else { //open popup with link JOptionPane.showMessageDialog(this, i18n.msg("goto") + url); } }