List of usage examples for com.lowagie.text Paragraph setAlignment
public void setAlignment(String alignment)
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add Dataset Description section. The "Dataset description" describes the DwC-A being published by the IPT. * If there is no data uploaded/published through the IPT, and no "External links", then that means * only the metadata is being published and no "Dataset" and "Dataset description" sections will appear at all. * /*from ww w. j a va2 s. c om*/ * @param doc Document * @param resource Resource * @throws DocumentException if problem occurs during add */ private void addDatasetDescriptions(Document doc, Resource resource) throws DocumentException { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); Eml eml = resource.getEml(); // If there is data uploaded/published through the IPT if (resource.hasMappedData()) { /* p.add(new Phrase(getText("rtf.datasets"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); */ p.add(new Phrase(getText("rtf.datasets.description"), fontTitle)); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.url.dataset") + ". ", fontTitle)); p.add(getText("rtf.datasets.url.dataset.text")); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.ipt") + ". ", fontTitle)); p.add(" "); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.portal") + ". ", fontTitle)); p.add(" "); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.portal.gbif") + ". ", fontTitle)); p.add(" "); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.object") + ". ", fontTitle)); p.add(getText("rtf.datasets.dwca") + " " + eml.getTitle()); p.add(Chunk.NEWLINE); VocabularyConcept vocabConcept = vocabManager.get(Constants.VOCAB_URI_LANGUAGE) .findConcept(eml.getLanguage()); p.add(new Phrase(getText("rtf.language") + ". ", fontTitle)); if (exists(vocabConcept)) { p.add(vocabConcept.getPreferredTerm("es").getTitle()); } else { p.add(getText("rtf.unknown")); } p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.character") + ". ", fontTitle)); p.add("UTF-8"); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.url.file") + ". ", fontTitle)); p.add(getText("rtf.datasets.url.file.text")); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.format") + ". ", fontTitle)); p.add(getText("rtf.datasets.dwca.format")); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.format.version") + ". ", fontTitle)); p.add("1.0");//* p.add(Chunk.NEWLINE); /* p.add(new Phrase(getText("rtf.datasets.distribution") + ". ", fontTitle)); String dwcaLink = appConfig.getBaseUrl() + "/archive.do?r=" + resource.getShortname(); Anchor distributionLink = new Anchor(dwcaLink, fontLink); distributionLink.setReference(dwcaLink); p.add(distributionLink); p.add(Chunk.NEWLINE); */ if (exists(eml.getHierarchyLevel())) { p.add(new Phrase(getText("rtf.metadata.level") + ". ", fontTitle)); p.add(WordUtils.capitalizeFully(eml.getHierarchyLevel())); p.add(Chunk.NEWLINE); } if (exists(eml.getPubDate())) { p.add(new Phrase(getText("rtf.publication") + ". ", fontTitle)); SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); p.add(f.format(eml.getPubDate())); p.add(Chunk.NEWLINE); } // if (exists(eml.getMetadataLanguage())) { Vocabulary vocab = vocabManager.get(Constants.VOCAB_URI_LANGUAGE); VocabularyConcept vocabConceptP = vocab.findConcept(eml.getMetadataLanguage()); if (exists(vocabConceptP)) { p.add(new Phrase(getText("rtf.metadata.language") + ". ", fontTitle)); p.add(vocabConceptP.getPreferredTerm("es").getTitle()); p.add(Chunk.NEWLINE); } } if (exists(eml.getDateStamp())) { p.add(new Phrase(getText("rtf.metadata.creation") + ". ", fontTitle)); SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); p.add(f.format(eml.getDateStamp())); p.add(Chunk.NEWLINE); } // if (exists(eml.getIntellectualRights())) { p.add(new Phrase(getText("rtf.license") + ". ", fontTitle)); p.add(eml.getIntellectualRights().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); } doc.add(p); } else { // If no data is uploaded/published through the IPT but there are one or more "External links" if (!eml.getPhysicalData().isEmpty()) { p.add(new Phrase(getText("rtf.datasets"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.datasets.description"), fontTitle)); p.add(Chunk.NEWLINE); p.add(getText("rtf.datasets.noPublished")); p.add(Chunk.NEWLINE); VocabularyConcept vocabConcept = vocabManager.get(Constants.VOCAB_URI_LANGUAGE) .findConcept(eml.getLanguage()); p.add(new Phrase(getText("rtf.language") + ": ", fontTitle)); if (exists(vocabConcept)) { p.add(vocabConcept.getPreferredTerm(DEFAULT_LANGUAGE).getTitle()); } else { p.add(getText("rtf.unknown")); } p.add(Chunk.NEWLINE); if (exists(eml.getIntellectualRights())) { p.add(new Phrase(getText("rtf.license") + ": ", fontTitle)); p.add(eml.getIntellectualRights()); p.add(Chunk.NEWLINE); } doc.add(p); } } // Add external datasets addExternalLinks(doc, eml); p.clear(); }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add external links section.//from ww w . ja v a 2 s. c o m * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addExternalLinks(Document doc, Eml eml) throws DocumentException { if (!eml.getPhysicalData().isEmpty()) { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.dtasets.external"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); for (PhysicalData data : eml.getPhysicalData()) { p.add(new Phrase(getText("rtf.datasets.description"), fontTitle)); p.add(Chunk.NEWLINE); if (exists(data.getName())) { p.add(new Phrase(getText("rtf.datasets.object") + ": ", fontTitle)); p.add(data.getName()); p.add(Chunk.NEWLINE); } if (exists(data.getCharset())) { p.add(new Phrase(getText("rtf.datasets.character") + ": ", fontTitle)); p.add(data.getCharset()); p.add(Chunk.NEWLINE); } if (exists(data.getFormat())) { p.add(new Phrase(getText("rtf.datasets.format") + ": ", fontTitle)); p.add(data.getFormat()); p.add(Chunk.NEWLINE); } if (exists(data.getFormatVersion())) { p.add(new Phrase(getText("rtf.datasets.format.version") + ": ", fontTitle)); p.add(data.getFormatVersion()); p.add(Chunk.NEWLINE); } if (exists(data.getDistributionUrl())) { p.add(new Phrase(getText("rtf.datasets.distribution") + ": ", fontTitle)); Anchor distributionLink = new Anchor(data.getDistributionUrl(), fontLink); distributionLink.setReference(data.getDistributionUrl()); p.add(distributionLink); p.add(Chunk.NEWLINE); } p.add(Chunk.NEWLINE); } doc.add(p); p.clear(); } }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add general description section.//from w w w. ja v a 2s . co m * * @throws DocumentException if problem occurs during add */ private void addGeneralDescription(Document doc, Eml eml) throws DocumentException { if (exists(eml.getPurpose()) || exists(eml.getAdditionalInfo())) { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.generalDesciption"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); if (exists(eml.getPurpose())) { p.add(new Phrase(getText("rtf.purpose") + ". ", fontTitle)); p.add(eml.getPurpose().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); } /* if (exists(eml.getAdditionalInfo())) { p.add(new Phrase("Additional information" + ": ", fontTitle)); p.add(eml.getAdditionalInfo().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); } */ doc.add(p); p.clear(); } }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add keywords section./*from ww w. ja v a 2 s . c o m*/ * * @param doc Document * @param keys keywords Strings * @throws DocumentException if problem occurs during add */ private void addKeywords(Document doc, String keys) throws DocumentException { if (keys != null && !(keys.length() == 0)) { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.keywords") + ": ", fontTitle)); p.add(keys); p.add(Chunk.NEWLINE); doc.add(p); p.clear(); } }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add metadata description section./* w w w.j a v a 2 s . c o m*/ * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addMetadataDescriptions(Document doc, Eml eml) throws DocumentException { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); if (exists(eml.getMetadataLanguage())) { Vocabulary vocab = vocabManager.get(Constants.VOCAB_URI_LANGUAGE); VocabularyConcept vocabConcept = vocab.findConcept(eml.getMetadataLanguage()); if (exists(vocabConcept)) { p.add(new Phrase(getText("rtf.metadata.language") + ": ", fontTitle)); p.add(vocabConcept.getPreferredTerm("es").getTitle()); p.add(Chunk.NEWLINE); } } if (exists(eml.getHierarchyLevel())) { p.add(new Phrase(getText("rtf.metadata.level") + ": ", fontTitle)); p.add(WordUtils.capitalizeFully(eml.getHierarchyLevel())); p.add(Chunk.NEWLINE); } if (exists(eml.getDateStamp())) { p.add(new Phrase(getText("rtf.metadata.creation") + ": ", fontTitle)); SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); p.add(f.format(eml.getDateStamp())); p.add(Chunk.NEWLINE); } if (exists(eml.getMetadataLocale())) { VocabularyConcept vocabConcept = vocabManager.get(Constants.VOCAB_URI_LANGUAGE) .findConcept(eml.getMetadataLocale().getLanguage()); if (exists(vocabConcept)) { p.add(new Phrase(getText("rtf.metadata.locale") + ": ", fontTitle)); p.add(vocabConcept.getPreferredTerm("es").getTitle()); p.add(Chunk.NEWLINE); } } doc.add(p); p.clear(); }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add methods section./*from www . ja va 2 s .c om*/ * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addMethods(Document doc, Eml eml) throws DocumentException { if (exists(eml.getMethodSteps()) && !eml.getMethodSteps().isEmpty() || exists(eml.getStudyExtent()) || exists(eml.getStudyExtent()) || exists(eml.getStudyExtent())) { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.methods"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); if (exists(eml.getStudyExtent())) { p.add(new Phrase(getText("rtf.methods.studyExtent"), fontTitle)); p.add(Chunk.NEWLINE); p.add(eml.getStudyExtent().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); } if (exists(eml.getStudyExtent())) { p.add(new Phrase(getText("rtf.methods.sampling"), fontTitle)); p.add(Chunk.NEWLINE); p.add(eml.getSampleDescription().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); } if (exists(eml.getQualityControl())) { p.add(new Phrase(getText("rtf.methods.quality"), fontTitle)); p.add(Chunk.NEWLINE); p.add(eml.getQualityControl().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); } if (eml.getMethodSteps().size() == 1) { p.add(new Phrase(getText("rtf.methods.description"), fontTitle)); p.add(Chunk.NEWLINE); p.add(eml.getMethodSteps().get(0).replace("\r\n", "\n")); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); } else if (eml.getMethodSteps().size() > 1) { p.add(new Phrase(getText("rtf.methods.description") + ". ", fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); List list = new List(List.UNORDERED, 0); list.setIndentationLeft(20); for (String method : eml.getMethodSteps()) { list.add(new ListItem(method.replace("\r\n", "\n"), font)); } p.add(list); } doc.add(p); p.clear(); } }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add "Resultados" section.//from ww w . j av a2 s . c o m * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addResul(Document doc) throws DocumentException { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.results"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); doc.add(p); p.clear(); }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add natural collections section.//from w w w . j a v a 2 s.c o m * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addNaturalCollections(Document doc, Eml eml) throws DocumentException { if (exists(eml.getParentCollectionId()) || exists(eml.getCollectionName()) || exists(eml.getCollectionId()) || !eml.getTemporalCoverages().isEmpty() || exists(eml.getSpecimenPreservationMethod()) || !eml.getJgtiCuratorialUnits().isEmpty()) { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.collections.description"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); if (exists(eml.getCollectionName())) { p.add(new Phrase(getText("rtf.collections.name") + ". ", fontTitle)); p.add(eml.getCollectionName()); p.add(Chunk.NEWLINE); } if (exists(eml.getCollectionId())) { p.add(new Phrase(getText("rtf.collections.identifier") + ". ", fontTitle)); p.add(eml.getCollectionId()); p.add(Chunk.NEWLINE); } if (exists(eml.getParentCollectionId())) { p.add(new Phrase(getText("rtf.collections.parent") + ". ", fontTitle)); p.add(eml.getParentCollectionId()); p.add(Chunk.NEWLINE); } if (exists(eml.getSpecimenPreservationMethod())) { p.add(new Phrase(getText("rtf.collections.specimen") + ". ", fontTitle)); VocabularyConcept vocabConcept = vocabManager.get(Constants.VOCAB_URI_PRESERVATION_METHOD) .findConcept(eml.getSpecimenPreservationMethod()); // write preservation method in default language as matched from vocabulary or original value if (exists(vocabConcept)) { p.add(vocabConcept.getPreferredTerm(DEFAULT_LANGUAGE).getTitle()); } else { p.add(eml.getSpecimenPreservationMethod().replace("\r\n", "\n")); } p.add(Chunk.NEWLINE); } for (TemporalCoverage coverage : eml.getTemporalCoverages()) { if (coverage.getType() == TemporalCoverageType.FORMATION_PERIOD) { p.add(new Phrase(getText("rtf.collections.formatPeriod") + ". ", fontTitle)); p.add(coverage.getFormationPeriod()); p.add(Chunk.NEWLINE); } } for (TemporalCoverage coverage : eml.getTemporalCoverages()) { if (coverage.getType() == TemporalCoverageType.LIVING_TIME_PERIOD) { p.add(new Phrase(getText("rtf.collections.livingPeriod") + ". ", fontTitle)); p.add(coverage.getLivingTimePeriod()); p.add(Chunk.NEWLINE); } } for (JGTICuratorialUnit unit : eml.getJgtiCuratorialUnits()) { p.add(new Phrase(getText("rtf.collections.curatorial") + ". ", fontTitle)); if (unit.getType() == JGTICuratorialUnitType.COUNT_RANGE) { p.add("Entre " + unit.getRangeStart() + " y " + unit.getRangeEnd()); } if (unit.getType() == JGTICuratorialUnitType.COUNT_WITH_UNCERTAINTY) { p.add(unit.getRangeMean() + " " + getText("rtf.collections.curatorial.text") + " " + unit.getUncertaintyMeasure()); } p.add(" (" + unit.getUnitType() + ")"); p.add(Chunk.NEWLINE); } if (!p.isEmpty()) { doc.add(p); } p.clear(); } }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add paragraph to Document.//ww w . j a va 2s . co m * * @param doc Document * @param text text of paragraph * @param font Font to be used * @param spacing number of spaces before the paragraph * @param alignType alignment of the paragraph * @throws DocumentException if problem occurs during add */ private void addPara(Document doc, String text, Font font, int spacing, int alignType) throws DocumentException { Paragraph p = new Paragraph(text, font); if (spacing != 0) { p.setSpacingBefore(spacing); } if (alignType != 0) { p.setAlignment(alignType); } doc.add(p); p.clear(); }
From source file:org.gbif.ipt.task.Eml2Rtf.java
License:Apache License
/** * Add project data section./*from w ww .j av a2s . com*/ * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addProjectData(Document doc, Eml eml) throws DocumentException { if (exists(eml.getProject().getTitle()) || exists(eml.getProject().getPersonnel().getFirstName()) || exists(eml.getProject().getFunding()) || exists(eml.getProject().getStudyAreaDescription().getDescriptorValue()) || exists(eml.getProject().getDesignDescription())) { Map<String, String> roles = vocabManager.getI18nVocab(Constants.VOCAB_URI_ROLES, "es", false); String role = ""; if (exists(eml.getProject().getPersonnel().getRole())) { role = " (" + roles.get(eml.getProject().getPersonnel().getRole()) + ")"; } Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); p.add(new Phrase(getText("rtf.project.details"), fontTitle)); p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); if (exists(eml.getProject().getTitle())) { p.add(new Phrase(getText("rtf.project.title") + ". ", fontTitle)); p.add(eml.getProject().getTitle()); p.add(Chunk.NEWLINE); } p.add(new Phrase(getText("rtf.project.personnel") + ". ", fontTitle)); if (exists(eml.getProject().getPersonnel().getFirstName())) { p.add(eml.getProject().getPersonnel().getFirstName() + " " + eml.getProject().getPersonnel().getLastName() + role); p.add(Chunk.NEWLINE); } if (exists(eml.getProject().getFunding())) { p.add(new Phrase(getText("rtf.project.funding") + ". ", fontTitle)); p.add(eml.getProject().getFunding().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); } if (exists(eml.getProject().getStudyAreaDescription().getDescriptorValue())) { p.add(new Phrase(getText("rtf.project.area") + ". ", fontTitle)); p.add(eml.getProject().getStudyAreaDescription().getDescriptorValue().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); } if (exists(eml.getProject().getDesignDescription())) { p.add(Chunk.NEWLINE); p.add(new Phrase(getText("rtf.project.design"), fontTitle)); p.add(Chunk.NEWLINE); p.add(eml.getProject().getDesignDescription().replace("\r\n", "\n")); p.add(Chunk.NEWLINE); } doc.add(p); p.clear(); } }