Example usage for com.lowagie.text Element ALIGN_JUSTIFIED

List of usage examples for com.lowagie.text Element ALIGN_JUSTIFIED

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_JUSTIFIED.

Prototype

int ALIGN_JUSTIFIED

To view the source code for com.lowagie.text Element ALIGN_JUSTIFIED.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add (Palabras claves) keywords section.
 * /*from  ww  w  . jav  a 2s.  com*/
 * @param doc Document
 * @throws DocumentException if problem occurs during add
 */
private void addPalcla(Document doc) throws DocumentException {
    if (this.palcla != null && !(this.palcla.length() == 0)) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.keywords.palcla") + ". ", fontTitle));
        p.add(this.palcla);
        p.add(Chunk.NEWLINE);
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add (keywords) keywords section.//from  w  w w .j  a va  2 s .  c  o  m
 * 
 * @param doc Document
 * @throws DocumentException if problem occurs during add
 */
private void addKeyWord(Document doc) throws DocumentException {
    if (this.keywor != null && !(this.keywor.length() == 0)) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.keywords.keywor") + ". ", fontTitle));
        p.add(this.keywor);
        p.add(Chunk.NEWLINE);
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add "Discusion" section. /* w w w .  j  a v  a 2s.c om*/
 * 
 * @param doc Document
 * @throws DocumentException if problem occurs during add
 */
private void addDiscu(Document doc) throws DocumentException {
    if (exists(this.discu)) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.discu"), fontTitle));
        p.add(Chunk.NEWLINE);
        p.add(this.discu);
        p.add(Chunk.NEWLINE);
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add "Agradecimientos" section. /*from   w  w  w .ja va  2  s  . co m*/
 * 
 * @param doc Document
 * @throws DocumentException if problem occurs during add
 */
private void addAgrad(Document doc) throws DocumentException {
    if (exists(this.agrad)) {
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("rtf.agrad"), fontTitle));
        p.add(Chunk.NEWLINE);
        p.add(this.agrad);
        p.add(Chunk.NEWLINE);
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add resource citation section. This corresponds to combination of resource's citation and citation identifier.
 * /* www.  j  a  v a  2  s  .  c  o m*/
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addResourceCitation(Document doc, Eml eml) throws DocumentException {
    if (exists(eml.getCitation())) {
        // start new paragraph
        Paragraph p = new Paragraph();
        p.setAlignment(Element.ALIGN_JUSTIFIED);
        p.setFont(font);
        p.add(new Phrase(getText("eml.citation.citation") + ". ", fontTitle));
        //p.add(Chunk.NEWLINE);

        // add citation text
        if (exists(eml.getCitation().getCitation())) {
            p.add(eml.getCitation().getCitation().replace("\r\n", "\n"));
        }

        // add optional identifier attribute
        if (exists(eml.getCitation().getIdentifier())) {
            p.add(" ");
            p.add(eml.getCitation().getIdentifier());
        }

        // add new paragraph
        p.add(Chunk.NEWLINE);
        doc.add(p);
        p.clear();
    }
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add authors section.//  w  ww .jav  a  2  s.  c  o m
 * 
 * @param doc Document
 * @param eml EML
 * @throws DocumentException if problem occurs during add
 */
private void addAuthors(Document doc, Eml eml) throws DocumentException {
    // Creating set of authors with different names. (first names + last names).
    HashSet<Agent> tempAgents = new LinkedHashSet<Agent>();
    if (exists(eml.getResourceCreator()) && exists(eml.getResourceCreator().getLastName())) {
        tempAgents.add(eml.getResourceCreator());
    }
    if (exists(eml.getMetadataProvider()) && exists(eml.getMetadataProvider().getLastName())) {
        tempAgents.add(eml.getMetadataProvider());
    }
    tempAgents.addAll(eml.getAssociatedParties());

    // comparing and removing those repeated agents with same name and same address.
    Collection<Integer> toRemove = new ArrayList<Integer>();
    int counter = 0;
    for (Iterator<Agent> i = tempAgents.iterator(); i.hasNext(); counter++) {
        if (toRemove.contains(counter)) {
            i.next();
            i.remove();
        } else {
            Agent agentA = i.next();
            // when second iterator should be start
            boolean flag = false;
            int countTemp = 0;
            for (Iterator<Agent> j = tempAgents.iterator(); j.hasNext(); countTemp++) {
                Agent agentB = j.next();
                if (flag) {
                    if (equal(agentA.getLastName(), agentB.getLastName())
                            && equal(agentA.getFirstName(), agentB.getFirstName())
                            && equal(agentA.getAddress(), agentB.getAddress())) {
                        toRemove.add(countTemp);
                    }
                } else if (agentA.equals(agentB)) {
                    flag = true;
                }
            }
        }
    }

    Agent[] agentsArray = new Agent[tempAgents.size()];
    tempAgents.toArray(agentsArray);
    // Adding authors
    Paragraph p = new Paragraph();
    p.setFont(font);
    p.setAlignment(Element.ALIGN_CENTER);
    java.util.List<Agent> affiliations = new ArrayList<Agent>();
    int superScriptCounter = 1;
    for (int c = 0; c < agentsArray.length; c++) {
        if (exists(agentsArray[c].getLastName())) {
            if (c != 0) {
                p.add(", ");
            }
            // First Name and Last Name
            if (exists(agentsArray[c].getFirstName())) {
                p.add(agentsArray[c].getFirstName() + " ");
            }
            p.add(agentsArray[c].getLastName());
            // Looking for addresses and organisations of other authors
            // (superscripts should not be repeated).
            boolean isRepeated = false;
            // look into the affiliations array to find any previous repeated agent info.
            for (int index = 0; index < affiliations.size(); index++) {
                if (equal(agentsArray[c].getAddress(), affiliations.get(index).getAddress())
                        && equal(agentsArray[c].getOrganisation(), affiliations.get(index).getOrganisation())) {
                    p.add(createSuperScript(String.valueOf(index + 1)));
                    isRepeated = true;
                    break;
                }
            }
            // if the agent is not repeated.
            if (!isRepeated) {
                p.add(createSuperScript(String.valueOf(superScriptCounter)));
                affiliations.add(agentsArray[c]);
                superScriptCounter++;
            }
        }
    }
    doc.add(p);
    p.clear();
    doc.add(Chunk.NEWLINE);
    tempAgents.clear();
    // <AFFILIATIONS>
    p = new Paragraph();
    p.setFont(font);
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    for (int c = 0; c < affiliations.size(); c++) {
        if (c != 0) {
            p.add("; ");
        }
        p.add((c + 1) + " ");
        if (exists(affiliations.get(c).getOrganisation())) {
            p.add(affiliations.get(c).getOrganisation() + ", ");
        }
        if (exists(affiliations.get(c).getAddress().getAddress())) {
            p.add(affiliations.get(c).getAddress().getAddress() + ", ");
        }
        if (exists(affiliations.get(c).getAddress().getPostalCode())) {
            p.add(affiliations.get(c).getAddress().getPostalCode() + ", ");
        }
        if (exists(affiliations.get(c).getAddress().getCity())) {
            p.add(affiliations.get(c).getAddress().getCity());
        }
        if (exists(affiliations.get(c).getAddress().getCountry())) {
            VocabularyConcept concept = vocabManager.get(Constants.VOCAB_URI_COUNTRY)
                    .findConcept(affiliations.get(c).getAddress().getCountry());
            // write country in default language as matched from vocabulary or original value
            if (exists(concept)) {
                p.add(", " + WordUtils.capitalizeFully(concept.getPreferredTerm(DEFAULT_LANGUAGE).getTitle()));
            } else {
                p.add(", " + WordUtils.capitalizeFully(affiliations.get(c).getAddress().getCountry()));
            }
        }
    }
    doc.add(p);
    p.clear();
    doc.add(Chunk.NEWLINE);
    // <Corresponding Authors>
    p = new Paragraph();
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.add(new Phrase(getText("rtf.authors") + ": ", fontTitle));
    p.setFont(font);
    boolean isFirst = true;
    if (exists(eml.getResourceCreator())) {
        if (exists(eml.getResourceCreator().getFirstName())) {
            p.add(eml.getResourceCreator().getFirstName() + " ");
        }
        p.add(eml.getResourceCreator().getLastName());
        if (exists(eml.getResourceCreator().getEmail())) {
            p.add(" (" + eml.getResourceCreator().getEmail() + ")");
        }
        isFirst = false;
    }
    if (exists(eml.getMetadataProvider())) {
        boolean sameAsCreator = false;
        if (!isFirst) {
            sameAsCreator = equal(eml.getMetadataProvider().getAddress(), eml.getResourceCreator().getAddress())
                    && equal(eml.getMetadataProvider().getEmail(), eml.getResourceCreator().getEmail());
        }
        if (!sameAsCreator) {
            p.add(", ");
            if (exists(eml.getMetadataProvider().getFirstName())) {
                p.add(eml.getMetadataProvider().getFirstName() + " ");
            }
            p.add(eml.getMetadataProvider().getLastName());
            if (exists(eml.getMetadataProvider().getEmail())) {
                p.add(" (" + eml.getMetadataProvider().getEmail() + ")");
            }
        }
    }
    p.add(Chunk.NEWLINE);
    doc.add(p);
    p.clear();
}

From source file:org.gbif.ipt.task.Eml2Rtf.java

License:Apache License

/**
 * Add Citation statement://from   w w  w .j  a  va 2  s  . c o m
 * "Citation: Combination of authors, year of data paper publication (in parentheses), Title, Journal Name, Volume,
 * Issue number (in parentheses), and DOI of the data paper.
 * </p>
 * This section is intended to be manually entered by the author, following publication of the data paper.
 * 
 * @param doc Document
 * @throws DocumentException if problem occurs during add
 */
private void addCitations(Document doc) throws DocumentException {
    Paragraph p = new Paragraph();
    p.setAlignment(Element.ALIGN_JUSTIFIED);
    p.setFont(fontToComplete);
    p.add(new Phrase(getText("rtf.citations") + ". ", fontTitle));
    p.add(getText("rtf.citations.description"));
    p.add(Chunk.NEWLINE);
    doc.add(p);
    p.clear();
}

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 . com*/
 * @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 w  ww  .jav a2s . co 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  ww.  j a  va  2s.  c  o  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();
    }
}