Example usage for com.lowagie.text Rectangle NO_BORDER

List of usage examples for com.lowagie.text Rectangle NO_BORDER

Introduction

In this page you can find the example usage for com.lowagie.text Rectangle NO_BORDER.

Prototype

int NO_BORDER

To view the source code for com.lowagie.text Rectangle NO_BORDER.

Click Source Link

Document

This represents a rectangle without borders.

Usage

From source file:org.areasy.common.doclet.document.elements.CellNoBorderNoPadding.java

License:Open Source License

/**
 * Creates a PdfPCell with a border and a padding of 6.
 *
 * @param data The cell content./*w  ww . ja  va 2 s .com*/
 */
public CellNoBorderNoPadding(Phrase data) {
    super(data);
    super.setBorder(Rectangle.NO_BORDER);
    super.setPadding(0);
}

From source file:org.areasy.common.doclet.document.elements.CellNoBorderNoPadding.java

License:Open Source License

/**
 * Creates a PdfPCell with a border and a padding of 6.
 *
 * @param data The cell content.//from ww  w .  jav  a2  s.c o m
 */
public CellNoBorderNoPadding(Paragraph data) {
    super(data);
    super.setBorder(Rectangle.NO_BORDER);
    super.setPadding(0);
}

From source file:org.areasy.common.doclet.document.elements.CellNoBorderWithPadding.java

License:Open Source License

/**
 * Creates a PdfPCell with a given padding and
 * an additional wrapping Phrase for the given Phrase.
 *
 * @param padding The padding for the PdfPCell
 * @param data    The content for the cell
 *//*from  ww  w . j  a  va 2 s .  co  m*/
public CellNoBorderWithPadding(int padding, Phrase data) {
    super(data);
    super.setBorder(Rectangle.NO_BORDER);
    super.setPadding(padding);
}

From source file:org.areasy.common.doclet.document.elements.CellNoBorderWithPadding.java

License:Open Source License

public CellNoBorderWithPadding(int padding, PdfPTable table) {
    super(table);
    super.setBorder(Rectangle.NO_BORDER);
    super.setPadding(padding);
}

From source file:org.areasy.common.doclet.document.elements.CellNoBorderWithPadding.java

License:Open Source License

public CellNoBorderWithPadding(int padding, List list) {
    super();// w  w  w  .j  a  va 2s.co  m
    super.addElement(list);
    super.setBorder(Rectangle.NO_BORDER);
    super.setPadding(padding);
}

From source file:org.areasy.common.doclet.document.Members.java

License:Open Source License

/**
 * Prints member information.//from   w w w. j  a  v a2s. c om
 *
 * @param declaration      The modifiers ("public static final..").
 * @param returnType       Phrase with the return type text (might be
 *                         a hyperlink)
 * @param parms            Parameters of a method or constructor, null for a field.
 * @param thrownExceptions Exceptions of a method, null for a field or constructor.
 * @param isFirst          True if it is the first field/method/constructor in the list.
 * @param isField          True if it is a field.
 * @param isConstructor    True if it is a constructor.
 * @throws Exception
 */
public static void printMember(String declaration, Phrase returnType, ProgramElementDoc commentDoc,
        Parameter[] parms, ClassDoc[] thrownExceptions, boolean isFirst, boolean isField, boolean isConstructor,
        boolean isDeprecated, Phrase deprecatedPhrase, Object constantValue) throws Exception {
    String name = commentDoc.name();

    State.setCurrentMember(State.getCurrentClass() + "." + name);
    State.setCurrentDoc(commentDoc);

    // Returns the text, resolving any "inheritDoc" inline tags
    String commentText = DocletUtility.getComment(commentDoc);

    // TODO: The following line may set the wrong page number
    //      in the index, when the member gets printed on a
    //      new page completely (because it is in one table).
    // Solution unknown yet. Probably split up table.
    Doclet.getIndex().addToMemberList(State.getCurrentMember());

    // Prepare list of exceptions (if it throws any)
    String throwsText = "throws";
    int parmsColumn = declaration.length() + (name.length() - throwsText.length());

    // First output text line (declaration of method and first parameter or "()" ).
    // This first line is a special case because the class name is bold,
    // while the rest is regular plain text, so it must be built using three Chunks.
    Paragraph declarationParagraph = new Paragraph((float) 10.0);

    // left part / declaration ("public static..")
    Chunk leftPart = new Chunk(declaration, Fonts.getFont(CODE_FONT, 10));

    declarationParagraph.add(leftPart);

    if (returnType != null) {
        // left middle part / declaration ("public static..")
        declarationParagraph.add(returnType);
        declarationParagraph.add(new Chunk(" ", Fonts.getFont(CODE_FONT, 10)));
        parmsColumn = 2;
    }

    // right middle part / bold class name
    declarationParagraph.add(new Chunk(name, Fonts.getFont(CODE_FONT, BOLD, 10)));

    if (!isField) {
        // 1st parameter or empty brackets

        if ((parms != null) && (parms.length > 0)) {
            Phrase wholePhrase = new Phrase("(", Fonts.getFont(CODE_FONT, 10));
            // create link for parameter type
            wholePhrase.add(PDFUtility.getParameterTypePhrase(parms[0], 10));
            // then normal text for parameter name
            wholePhrase.add(" " + parms[0].name());
            if (parms.length > 1) {
                wholePhrase.add(",");
            } else {
                wholePhrase.add(")");
            }

            // In order to have the parameter types in the bookmark,
            // make the current state text more detailled
            String txt = State.getCurrentMethod() + "(";
            for (int i = 0; i < parms.length; i++) {
                if (i > 0)
                    txt = txt + ",";
                txt = txt + DocletUtility.getParameterType(parms[i]);
            }

            txt = txt + ")";
            State.setCurrentMethod(txt);

            // right part / parameter and brackets
            declarationParagraph.add(wholePhrase);

        } else {
            String lastPart = "()";
            State.setCurrentMethod(State.getCurrentMethod() + lastPart);

            // right part / parameter and brackets
            declarationParagraph.add(new Chunk(lastPart, Fonts.getFont(CODE_FONT, 10)));
        }

    }

    float[] widths = { (float) 6.0, (float) 94.0 };
    PdfPTable table = new PdfPTable(widths);
    table.setWidthPercentage((float) 100);

    // Before the first constructor or method, create a coloured title bar
    if (isFirst) {
        PdfPCell colorTitleCell = null;

        // Some empty space...
        Document.add(new Paragraph((float) 6.0, " "));

        if (isConstructor)
            colorTitleCell = new CustomPdfPCell("Constructors");
        else if (isField)
            colorTitleCell = new CustomPdfPCell("Fields");
        else
            colorTitleCell = new CustomPdfPCell("Methods");

        colorTitleCell.setColspan(2);
        table.addCell(colorTitleCell);
    }

    // Method name (large, first line of a method description block)
    Phrase linkPhrase = Destinations.createDestination(commentDoc.name(), commentDoc,
            Fonts.getFont(TEXT_FONT, BOLD, 14));
    Paragraph nameTitle = new Paragraph(linkPhrase);
    PdfPCell nameCell = new CellNoBorderNoPadding(nameTitle);

    if (isFirst)
        nameCell.setPaddingTop(10);
    else
        nameCell.setPaddingTop(0);

    nameCell.setPaddingBottom(8);
    nameCell.setColspan(1);

    // Create nested table in order to try to prevent the stuff inside
    // this table from being ripped appart over a page break. The method
    // name and the declaration/parm/exception line(s) should always be
    // together, because everything else just looks bad
    PdfPTable linesTable = new PdfPTable(1);
    linesTable.addCell(nameCell);
    linesTable.addCell(new CellNoBorderNoPadding(declarationParagraph));

    if (!isField) {
        // Set up following declaration lines
        Paragraph[] params = PDFUtility.createParameters(parmsColumn, parms);
        Paragraph[] exceps = PDFUtility.createExceptions(parmsColumn, thrownExceptions);

        for (int i = 0; i < params.length; i++) {
            linesTable.addCell(new CellNoBorderNoPadding(params[i]));
        }

        for (int i = 0; i < exceps.length; i++) {
            linesTable.addCell(new CellNoBorderNoPadding(exceps[i]));
        }
    }

    // Create cell for inserting the nested table into the outer table
    PdfPCell cell = new PdfPCell(linesTable);
    cell.setPadding(5);
    cell.setBorder(Rectangle.NO_BORDER);
    cell.setColspan(2);
    table.addCell(cell);

    // The empty, left cell (the invisible indentation column)
    State.setContinued(true);

    PdfPCell leftCell = PDFUtility.createElementCell(5, new Phrase("", Fonts.getFont(TEXT_FONT, BOLD, 6)));
    PdfPCell spacingCell = new PdfPCell();
    spacingCell.setFixedHeight((float) 8.0);
    spacingCell.setBorder(Rectangle.NO_BORDER);
    table.addCell(spacingCell);
    table.addCell(spacingCell);

    // The descriptive method explanation text

    if (isDeprecated) {
        Phrase commentPhrase = new Phrase();
        commentPhrase
                .add(new Phrase(AbstractConfiguration.LB_DEPRECATED_TAG, Fonts.getFont(TEXT_FONT, BOLD, 10)));
        commentPhrase.add(deprecatedPhrase);
        table.addCell(leftCell);
        table.addCell(PDFUtility.createElementCell(0, commentPhrase));

        commentPhrase = new Phrase();
        commentPhrase.add(Chunk.NEWLINE);
        table.addCell(leftCell);
        table.addCell(PDFUtility.createElementCell(0, commentPhrase));
    }

    Element[] objs = HtmlParserWrapper.createPdfObjects(commentText);

    if (objs.length == 1) {
        table.addCell(leftCell);
        table.addCell(PDFUtility.createElementCell(0, objs[0]));
    } else {
        table.addCell(leftCell);
        table.addCell(PDFUtility.createElementCell(0, Element.ALIGN_LEFT, objs));
    }

    // TODO: FORMAT THIS CONSTANT VALUE OUTPUT CORRECTLY

    if (isField) {
        if (constantValue != null) {
            // Add 2nd comment line (left cell empty, right cell text)
            Chunk valueTextChunk = new Chunk("Constant value: ", Fonts.getFont(TEXT_FONT, PLAIN, 10));
            Chunk valueContentChunk = new Chunk(constantValue.toString(), Fonts.getFont(CODE_FONT, BOLD, 10));
            Phrase constantValuePhrase = new Phrase("");
            constantValuePhrase.add(valueTextChunk);
            constantValuePhrase.add(valueContentChunk);
            table.addCell(leftCell);
            table.addCell(PDFUtility.createElementCell(0, constantValuePhrase));
        }
    }

    // Add whole method block to document
    Document.add(table);
}

From source file:org.areasy.common.doclet.document.Summary.java

License:Open Source License

/**
 * Prints inner classes summaries.// ww w. j  av  a 2  s.  co m
 *
 * @param name
 * @param destination
 * @param isDeprecated
 * @param deprecatedPhrase
 * @param mainTable
 * @throws Exception
 */
private static void printInnerClass(String name, String destination, boolean isDeprecated,
        Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception {

    Element[] objs = HtmlParserWrapper.createPdfObjects(name);

    PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase);

    PdfPTable anotherinnertable = new PdfPTable(1);
    anotherinnertable.setWidthPercentage(100f);
    anotherinnertable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    PdfPTable innerTable = addDeclaration("class", null);

    // right part of the table
    PdfPCell cell = PDFUtility.createElementCell(2,
            new LinkPhrase(destination, name, Fonts.getFont(CODE_FONT, 9)));
    cell.setPaddingTop((float) 2.0);
    cell.setPaddingLeft((float) 7.0);
    anotherinnertable.addCell(cell);
    anotherinnertable.addCell(commentsTable);

    innerTable.addCell(anotherinnertable);
    mainTable.addCell(innerTable);
}

From source file:org.areasy.common.doclet.document.Summary.java

License:Open Source License

/**
 * Prints field summaries./*from   w  w  w.j  av  a 2s.co m*/
 * @param constantValue
 * @param isDeprecated
 * @param deprecatedPhrase
 * @param mainTable
 * @throws Exception
 */
private static void printField(FieldDoc fieldDoc, Object constantValue, boolean isDeprecated,
        Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception {

    String name = fieldDoc.name();
    String modifier = fieldDoc.modifiers();
    String commentText = DocletUtility.getFirstSentence(fieldDoc);
    String destination = fieldDoc.qualifiedName();

    Element[] objs = HtmlParserWrapper.createPdfObjects(commentText);

    PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase);

    if (constantValue != null) {
        // Add 2nd comment line (left cell empty, right cell text)
        commentsTable.addCell(new Phrase(""));
        Chunk valueTextChunk = new Chunk("Value: ", Fonts.getFont(TEXT_FONT, PLAIN, 10));
        Chunk valueContentChunk = new Chunk(constantValue.toString(), Fonts.getFont(CODE_FONT, BOLD, 10));
        Phrase constantValuePhrase = new Phrase("");
        constantValuePhrase.add(valueTextChunk);
        constantValuePhrase.add(valueContentChunk);
        commentsTable.addCell(constantValuePhrase);
    }

    PdfPTable anotherinnertable = new PdfPTable(1);
    anotherinnertable.setWidthPercentage(100f);
    anotherinnertable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    PdfPTable innerTable = addDeclaration(modifier, null);

    // Link to field
    LinkPhrase linkPhrase = new LinkPhrase(destination, name, Fonts.getFont(CODE_FONT, 9));

    // right part of the table
    PdfPCell cell = PDFUtility.createElementCell(2, linkPhrase);
    cell.setPaddingTop((float) 2.0);
    cell.setPaddingLeft((float) 7.0);
    anotherinnertable.addCell(cell);
    anotherinnertable.addCell(commentsTable);

    innerTable.addCell(anotherinnertable);
    mainTable.addCell(innerTable);
}

From source file:org.areasy.common.doclet.document.Summary.java

License:Open Source License

/**
 * Prints constructor summaries./*ww  w  .j a v  a 2  s  .  c  o m*/
 * @param isDeprecated
 * @param deprecatedPhrase
 * @param mainTable
 * @throws Exception
 */
private static void printConstructor(ConstructorDoc constructorDoc, boolean isDeprecated,
        Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception {

    String name = constructorDoc.name();
    String modifier = constructorDoc.modifiers();
    String commentText = DocletUtility.getFirstSentence(constructorDoc);
    String destination = constructorDoc.qualifiedName() + constructorDoc.signature();
    Parameter[] parms = constructorDoc.parameters();

    Element[] objs = HtmlParserWrapper.createPdfObjects(commentText);

    PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase);

    PdfPTable anotherinnertable = new PdfPTable(1);
    anotherinnertable.setWidthPercentage(100f);
    anotherinnertable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    // Link to constructor
    Font constructorFont = Fonts.getFont(CODE_FONT, 9);
    Phrase phrase = new Phrase("", constructorFont);
    phrase.add(new LinkPhrase(destination, name, constructorFont));

    phrase.add("(");
    if ((parms != null) && (parms.length > 0)) {
        for (int i = 0; i < parms.length; i++) {
            phrase.add(PDFUtility.getParameterTypePhrase(parms[i], 9));
            phrase.add(" ");
            phrase.add(parms[i].name());
            if (i != (parms.length - 1)) {
                phrase.add(", ");
            }
        }
    }
    phrase.add(")");

    PdfPCell cell = PDFUtility.createElementCell(2, phrase);
    cell.setPaddingLeft((float) 7.0);
    anotherinnertable.addCell(cell);
    anotherinnertable.addCell(commentsTable);

    PdfPTable innerTable = addDeclaration(modifier, null);
    innerTable.addCell(anotherinnertable);

    mainTable.addCell(innerTable);
}

From source file:org.areasy.common.doclet.document.Summary.java

License:Open Source License

/**
 * Prints the summary tables for a method.
 * @param modifier//from   w w w . j av  a 2s.co  m
 * @param returnType
 * @param isDeprecated
 * @param deprecatedPhrase
 * @param mainTable
 * @throws Exception
 */
private static void printMethod(MethodDoc methodDoc, String modifier, Phrase returnType, boolean isDeprecated,
        Phrase deprecatedPhrase, PdfPTable mainTable) throws Exception {

    String name = methodDoc.name();
    String destination = methodDoc.qualifiedName() + methodDoc.signature();
    String commentText = DocletUtility.getFirstSentence(methodDoc);
    Parameter[] parms = methodDoc.parameters();

    // Create inner table for both columns (left column already filled in)
    PdfPTable rowTable = addDeclaration(modifier, returnType);

    // Inner table with 1st sentence of javadoc of this method.
    // We use a table in order to be able to create two cells
    // in it (1st an empty one for intendation)

    Element[] objs = HtmlParserWrapper.createPdfObjects(commentText);
    // Phrase descPhr = new Phrase();

    PdfPTable commentsTable = createColumnsAndDeprecated(objs, isDeprecated, deprecatedPhrase);

    // Table with 1 column and 2 rows (row 1 is parameters etc.,
    // row 2 is the description
    PdfPTable rightColumnInnerTable = new PdfPTable(1);

    rightColumnInnerTable.setWidthPercentage(100f);
    rightColumnInnerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    // Link to method
    Font methodFont = Fonts.getFont(CODE_FONT, 9);
    Phrase phrase = new Phrase("", methodFont);
    phrase.add(new LinkPhrase(destination, name, methodFont));
    phrase.add("(");
    if ((parms != null) && (parms.length > 0)) {
        for (int i = 0; i < parms.length; i++) {
            phrase.add(PDFUtility.getParameterTypePhrase(parms[i], 9));
            phrase.add(" ");
            phrase.add(parms[i].name());
            if (i != (parms.length - 1)) {
                phrase.add(", ");
            }
        }
    }
    phrase.add(")");

    PdfPCell cell = PDFUtility.createElementCell(2, phrase);
    cell.setPaddingLeft((float) 7.0);
    rightColumnInnerTable.addCell(cell);
    rightColumnInnerTable.addCell(commentsTable);

    // Now fill in right column as well
    rowTable.addCell(rightColumnInnerTable);

    // And add inner table to main summary table as a new row
    mainTable.addCell(rowTable);
}