List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:net.bull.javamelody.PdfRequestAndGraphDetailReport.java
License:Apache License
private void writeRequestValues(CounterRequest aRequest, boolean allChildHitsDisplayed) { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(aRequest.getMean())); addCell(integerFormat.format(aRequest.getMaximum())); addCell(integerFormat.format(aRequest.getStandardDeviation())); if (aRequest.getCpuTimeMean() >= 0) { addCell(integerFormat.format(aRequest.getCpuTimeMean())); } else {//from www . j a va 2 s. c o m addCell(""); } addCell(systemErrorFormat.format(aRequest.getSystemErrorPercentage())); if (allChildHitsDisplayed) { final boolean childHitsDisplayed = aRequest.hasChildHits(); if (childHitsDisplayed) { addCell(integerFormat.format(aRequest.getChildHitsMean())); } else { addCell(""); } if (childHitsDisplayed) { addCell(integerFormat.format(aRequest.getChildDurationsMean())); } else { addCell(""); } } }
From source file:net.bull.javamelody.PdfSessionInformationsReport.java
License:Apache License
private void writeSession(SessionInformations session) throws IOException, BadElementException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(session.getId());/* ww w . j a va2 s .c o m*/ defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(durationFormat.format(session.getLastAccess())); addCell(durationFormat.format(session.getAge())); addCell(expiryFormat.format(session.getExpirationDate())); addCell(integerFormat.format(session.getAttributeCount())); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); if (session.isSerializable()) { addCell(getString("oui")); } else { final Phrase non = new Phrase(getString("non"), severeCellFont); addCell(non); } defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); addCell(integerFormat.format(session.getSerializedSize())); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String remoteAddr = session.getRemoteAddr(); if (remoteAddr == null) { addCell(""); } else { addCell(remoteAddr); } defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); writeCountry(session); if (displayUser) { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final String remoteUser = session.getRemoteUser(); if (remoteUser == null) { addCell(""); } else { addCell(remoteUser); } } }
From source file:net.bull.javamelody.swing.print.MPdfWriter.java
License:Apache License
/** * Effectue le rendu de la liste./* w w w. j a va2 s .c o m*/ * * @param table * MBasicTable * @param datatable * Table * @throws BadElementException * e */ protected void renderList(final MBasicTable table, final Table datatable) throws BadElementException { final int columnCount = table.getColumnCount(); final int rowCount = table.getRowCount(); // data rows final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); // datatable.setDefaultCellGrayFill(0); Object value; String text; int horizontalAlignment; for (int k = 0; k < rowCount; k++) { for (int i = 0; i < columnCount; i++) { value = getValueAt(table, k, i); if (value instanceof Number || value instanceof Date) { horizontalAlignment = Element.ALIGN_RIGHT; } else if (value instanceof Boolean) { horizontalAlignment = Element.ALIGN_CENTER; } else { horizontalAlignment = Element.ALIGN_LEFT; } datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignment); text = getTextAt(table, k, i); datatable.addCell(new Phrase(8, text != null ? text : "", font)); } } }
From source file:net.sf.jasperreports.engine.export.AbstractPdfTextRenderer.java
License:Open Source License
/** * //from w ww . jav a 2 s. c o m */ public void initialize(JRPdfExporter pdfExporter, PdfContentByte pdfContentByte, JRPrintText text, int offsetX, int offsetY) { this.pdfExporter = pdfExporter; this.pdfContentByte = pdfContentByte; horizontalAlignment = Element.ALIGN_LEFT; leftOffsetFactor = 0f; rightOffsetFactor = 0f; //FIXMETAB 0.2f was a fair approximation switch (text.getHorizontalAlignmentValue()) { case JUSTIFIED: { horizontalAlignment = Element.ALIGN_JUSTIFIED_ALL; leftOffsetFactor = 0f; rightOffsetFactor = 0f; break; } case RIGHT: { if (text.getRunDirectionValue() == RunDirectionEnum.LTR) { horizontalAlignment = Element.ALIGN_RIGHT; } else { horizontalAlignment = Element.ALIGN_LEFT; } leftOffsetFactor = -0.2f; rightOffsetFactor = 0f; break; } case CENTER: { horizontalAlignment = Element.ALIGN_CENTER; leftOffsetFactor = -0.1f; rightOffsetFactor = 0.1f; break; } case LEFT: default: { if (text.getRunDirectionValue() == RunDirectionEnum.LTR) { horizontalAlignment = Element.ALIGN_LEFT; } else { horizontalAlignment = Element.ALIGN_RIGHT; } leftOffsetFactor = 0f; rightOffsetFactor = 0.2f; break; } } super.initialize(text, offsetX, offsetY); }
From source file:net.sf.jasperreports.engine.export.JRPdfExporter.java
License:LGPL
/** * *///from ww w.j ava 2s .co m protected void exportText(JRPrintText text) throws DocumentException { JRStyledText styledText = getStyledText(text, false); if (styledText == null) { return; } int textLength = styledText.length(); int x = text.getX() + getOffsetX(); int y = text.getY() + getOffsetY(); int width = text.getWidth(); int height = text.getHeight(); int topPadding = text.getLineBox().getTopPadding().intValue(); int leftPadding = text.getLineBox().getLeftPadding().intValue(); int bottomPadding = text.getLineBox().getBottomPadding().intValue(); int rightPadding = text.getLineBox().getRightPadding().intValue(); int xFillCorrection = 0; int yFillCorrection = 0; double angle = 0; switch (text.getRotation()) { case JRTextElement.ROTATION_LEFT: { y = text.getY() + getOffsetY() + text.getHeight(); xFillCorrection = 1; width = text.getHeight(); height = text.getWidth(); int tmpPadding = topPadding; topPadding = leftPadding; leftPadding = bottomPadding; bottomPadding = rightPadding; rightPadding = tmpPadding; angle = Math.PI / 2; break; } case JRTextElement.ROTATION_RIGHT: { x = text.getX() + getOffsetX() + text.getWidth(); yFillCorrection = -1; width = text.getHeight(); height = text.getWidth(); int tmpPadding = topPadding; topPadding = rightPadding; rightPadding = bottomPadding; bottomPadding = leftPadding; leftPadding = tmpPadding; angle = -Math.PI / 2; break; } case JRTextElement.ROTATION_UPSIDE_DOWN: { x = text.getX() + getOffsetX() + text.getWidth(); y = text.getY() + getOffsetY() + text.getHeight(); int tmpPadding = topPadding; topPadding = bottomPadding; bottomPadding = tmpPadding; tmpPadding = leftPadding; leftPadding = rightPadding; rightPadding = tmpPadding; angle = Math.PI; break; } case JRTextElement.ROTATION_NONE: default: { } } AffineTransform atrans = new AffineTransform(); atrans.rotate(angle, x, jasperPrint.getPageHeight() - y); pdfContentByte.transform(atrans); if (text.getMode() == JRElement.MODE_OPAQUE) { Color backcolor = text.getBackcolor(); pdfContentByte.setRGBColorFill(backcolor.getRed(), backcolor.getGreen(), backcolor.getBlue()); pdfContentByte.rectangle(x + xFillCorrection, jasperPrint.getPageHeight() - y + yFillCorrection, width, -height); pdfContentByte.fill(); } if (textLength > 0) { int horizontalAlignment = Element.ALIGN_LEFT; switch (text.getHorizontalAlignment()) { case JRAlignment.HORIZONTAL_ALIGN_LEFT: { if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) { horizontalAlignment = Element.ALIGN_LEFT; } else { horizontalAlignment = Element.ALIGN_RIGHT; } break; } case JRAlignment.HORIZONTAL_ALIGN_CENTER: { horizontalAlignment = Element.ALIGN_CENTER; break; } case JRAlignment.HORIZONTAL_ALIGN_RIGHT: { if (text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR) { horizontalAlignment = Element.ALIGN_RIGHT; } else { horizontalAlignment = Element.ALIGN_LEFT; } break; } case JRAlignment.HORIZONTAL_ALIGN_JUSTIFIED: { horizontalAlignment = Element.ALIGN_JUSTIFIED; break; } default: { horizontalAlignment = Element.ALIGN_LEFT; } } float verticalOffset = 0f; switch (text.getVerticalAlignment()) { case JRAlignment.VERTICAL_ALIGN_TOP: { verticalOffset = 0f; break; } case JRAlignment.VERTICAL_ALIGN_MIDDLE: { verticalOffset = (height - topPadding - bottomPadding - text.getTextHeight()) / 2f; break; } case JRAlignment.VERTICAL_ALIGN_BOTTOM: { verticalOffset = height - topPadding - bottomPadding - text.getTextHeight(); break; } default: { verticalOffset = 0f; } } ColumnText colText = new ColumnText(pdfContentByte); colText.setSimpleColumn(getPhrase(styledText, text), x + leftPadding, jasperPrint.getPageHeight() - y - topPadding - verticalOffset - text.getLeadingOffset(), //+ text.getLineSpacingFactor() * text.getFont().getSize(), x + width - rightPadding, jasperPrint.getPageHeight() - y - height + bottomPadding, 0, //text.getLineSpacingFactor(),// * text.getFont().getSize(), horizontalAlignment); colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize()); colText.setRunDirection( text.getRunDirection() == JRPrintText.RUN_DIRECTION_LTR ? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_RTL); colText.go(); } atrans = new AffineTransform(); atrans.rotate(-angle, x, jasperPrint.getPageHeight() - y); pdfContentByte.transform(atrans); /* */ exportBox(text.getLineBox(), text); }
From source file:nl.dykema.jxmlnote.report.pdf.PdfParagraph.java
License:Open Source License
protected int getAlign(XMLNoteParStyle st) { String align = st.align();/* ww w. jav a2 s . co m*/ if (align.equals(XMLNoteParStyle.ALIGN_LEFT)) { return Element.ALIGN_LEFT; } else if (align.equals(XMLNoteParStyle.ALIGN_RIGHT)) { return Element.ALIGN_RIGHT; } else if (align.equals(XMLNoteParStyle.ALIGN_CENTER)) { return Element.ALIGN_CENTER; } else if (align.equals(XMLNoteParStyle.ALIGN_CENTER)) { return Element.ALIGN_JUSTIFIED; } else { return Element.ALIGN_LEFT; } }
From source file:nl.dykema.jxmlnote.report.pdf.PdfParagraph.java
License:Open Source License
public Paragraph setAlignment(Report.Align a) { int align = Element.ALIGN_LEFT; if (a.equals(Report.Align.RIGHT)) { align = Element.ALIGN_RIGHT; } else if (a.equals(Report.Align.CENTER)) { align = Element.ALIGN_CENTER; } else if (a.equals(Report.Align.JUSTIFY)) { align = Element.ALIGN_JUSTIFIED; }/*from ww w. j a v a2s . c o m*/ super.setAlignment(align); return this; }
From source file:nl.dykema.jxmlnote.report.pdf.PdfReport.java
License:Open Source License
public int getPdfAlign(Report.Align a) { if (a.equals(Align.LEFT)) { return Element.ALIGN_LEFT; } else if (a.equals(Align.RIGHT)) { return Element.ALIGN_RIGHT; } else if (a.equals(Align.CENTER)) { return Element.ALIGN_CENTER; } else if (a.equals(Align.JUSTIFY)) { return Element.ALIGN_JUSTIFIED; } else {/* w ww . ja v a 2s.c o m*/ return Element.ALIGN_LEFT; } }
From source file:nl.dykema.jxmlnote.report.pdf.PdfReport.java
License:Open Source License
public int getAlign(AttributeSet s) { if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_LEFT) { return Element.ALIGN_LEFT; } else if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_CENTER) { return Element.ALIGN_CENTER; } else if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_RIGHT) { return Element.ALIGN_RIGHT; } else if (StyleConstants.getAlignment(s) == StyleConstants.ALIGN_JUSTIFIED) { return Element.ALIGN_JUSTIFIED; } else {//from www .java2 s.c o m return Element.ALIGN_LEFT; } }
From source file:open.dolphin.hiro.PrescriptionPDFMaker.java
private List<PdfPTable> createPrescriptionTbl2() { ClaimItem[] items;//from ww w .j a v a 2 s. c o m PdfPCell pcell, blank, numCell, amountCell; int num, cnt; double sum; // @009 ?????(?*) List<PdfPTable> preTblList = null; String admin, number; // @009 String classCode, amount, medicine; // @009 try { StringBuilder sb = new StringBuilder(); sb.append( "???????(??)??????????????\n"); sb.append( "?????????????????????????"); PdfPTable ptbl = new PdfPTable(9); // @009 ptbl.setWidthPercentage(100f); // @009 ???, ?, ??, ?, ??, , "(", , ")" float[] widthsP = { 14, 7, 52, 8, 15, 32, 2, 5, 9 }; ptbl.setWidths(widthsP); ptbl.getDefaultCell().setPadding(0f); preTblList = new ArrayList<PdfPTable>(); num = 1; //admin = ""; // @009 //number = ""; // @009 //amount = ""; // @009 ? numCell = new PdfPCell(new Paragraph("", min_8)); // @009 numCell.setBorderWidth(LINE_WIDTH_0); // @009 PdfPCell notes = new PdfPCell(new Paragraph("??", min_8)); notes.setBorderWidth(LINE_WIDTH_1); notes.setBorderWidthBottom(LINE_WIDTH_0); PdfPCell bracket = new PdfPCell(new Paragraph("", min_15)); bracket.setBorderWidth(LINE_WIDTH_0); bracket.setHorizontalAlignment(Element.ALIGN_RIGHT); bracket.setPadding(0f); PdfPCell notesDetail = new PdfPCell(new Paragraph(sb.toString(), min_6)); notesDetail.setBorderWidth(LINE_WIDTH_0); notesDetail.setColspan(5); PdfPCell bracketC = new PdfPCell(new Paragraph("", min_15)); bracketC.setBorderWidth(LINE_WIDTH_0); bracketC.setHorizontalAlignment(Element.ALIGN_LEFT); bracketC.setPadding(0f); bracketC.setColspan(2); for (Iterator<BundleMed> ite = pkg.getPriscriptionList().iterator(); ite.hasNext();) { BundleMed prescription = ite.next(); admin = prescription.getAdmin(); // @009 number = prescription.getBundleNumber(); // @009 ????=1 bundeNumber classCode = prescription.getClassCode(); // @009 221 etc items = prescription.getClaimItem(); //minagawa^ boolean genericIsOk = true; if (items != null) { for (ClaimItem i : items) { if (i.getCode().equals("099209903")) { genericIsOk = false; break; } } } genericIsOk = true; //minagawa4 if (ptbl.getRows().isEmpty()) { ptbl.addCell(notes); ptbl.addCell(bracket); ptbl.addCell(notesDetail); ptbl.addCell(bracketC); } // @001 2009/11/17 ? // items?null??????????????? // ???????????items ? null ?????? // if???????????(??????????) if (items != null) { boolean clearFlg = true; // @004 2010/02/26 ? // ********** @009 ********** //sum = 0; // ????? Font adminF = min_8; // boolean wrap = true; if (admin != null) { if (admin.length() > 17) { // ??17???4?? adminF = min_4; wrap = false; } else if (admin.length() > 11) { // ??11???6?? adminF = min_6; } } Font medicineF; // ?? // ********** @009 ********** // ??? ClaimItem iterate for (cnt = 0; cnt < items.length; cnt++) { //System.out.println("row size:" + ptbl.getRows().size()); // ?? if (!genericIsOk) { blank = new PdfPCell(new Paragraph("", min_8)); blank.setBorderWidth(LINE_WIDTH_0); blank.setBorderWidthRight(LINE_WIDTH_1); ptbl.addCell(blank); genericIsOk = true; } else { blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setBorderWidthRight(LINE_WIDTH_1); ptbl.addCell(blank); } if (ptbl.getRows().size() > 13) { // ?13??????????? blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setColspan(4); ptbl.addCell(blank); pcell = new PdfPCell(new Paragraph("???", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setColspan(5); ptbl.addCell(pcell); preTblList.add(ptbl); ptbl = new PdfPTable(9); ptbl.setWidthPercentage(100f); ptbl.setWidths(widthsP); ptbl.getDefaultCell().setPadding(0f); // ?? ptbl.addCell(notes); ptbl.addCell(bracket); ptbl.addCell(notesDetail); ptbl.addCell(bracketC); blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setBorderWidthRight(LINE_WIDTH_1); ptbl.addCell(blank); } if (cnt > 0) { // ?1????????? blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(blank); } else { // ?1?????? numCell = new PdfPCell(new Paragraph(num++ + ")", min_8)); numCell.setBorderWidth(LINE_WIDTH_0); setAlignRight(numCell); ptbl.addCell(numCell); // @004 2010/02/26 // ?1?????? false ?? if (!ClaimConst.COMMENT_CODE_0.equals(items[cnt].getCode())) { clearFlg = false; } // @004 2010/02/26 } // ********** @009 ********** amount = items[cnt].getNumber(); // System.out.println("??" + items[cnt].getName()); // System.out.println("?" + amount); //medicine = ""; medicine = items[cnt].getName(); // System.out.println("????" + medicine.length()); if (medicine.length() > 19) { // ????19???7?? medicineF = min_7; } else { // ????19???8??? medicineF = min_8; } // ********** @009 ********** if ((ClaimConst.SUBCLASS_CODE_ID.equals(items[cnt].getClassCodeSystem())) && ((String.valueOf(ClaimConst.YAKUZAI).equals(items[cnt].getClassCode())) || (String.valueOf(ClaimConst.ZAIRYO).equals(items[cnt].getClassCode())))) { pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getName()), medicineF)); // ?? ??? ???? pcell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(pcell); amountCell = new PdfPCell(new Paragraph(convertNVL(amount), min_8)); // ? setAlignRight(amountCell); amountCell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(amountCell); if (!(String.valueOf(ClaimConst.ZAIRYO).equals(items[cnt].getClassCode()))) { // ????? pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getUnit()), min_8)); // ?? pcell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(pcell); // ********** @009 ********** pcell = new PdfPCell(new Paragraph(admin, adminF)); // pcell.setBorderWidth(LINE_WIDTH_0); pcell.setNoWrap(wrap); ptbl.addCell(pcell); } else { blank = new PdfPCell(); blank.setColspan(2); blank.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(blank); } if (ClaimConst.RECEIPT_CODE_GAIYO.equals(classCode)) { pcell = new PdfPCell(new Paragraph("", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setColspan(3); ptbl.addCell(pcell); sum = Double.parseDouble(amount) * Double.parseDouble(number); DecimalFormat f = new DecimalFormat("####0.###"); // System.out.println("??" + sum); amountCell.getPhrase().clear(); amountCell.getPhrase().add(new Paragraph(String.valueOf(f.format(sum)), min_8)); // ? } else { // if ((number != null) && !("".equals(number))) { pcell = new PdfPCell(new Paragraph("(", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(pcell); pcell = new PdfPCell(new Paragraph(number, min_8)); pcell.setBorderWidth(LINE_WIDTH_0); setAlignRight(pcell); ptbl.addCell(pcell); //minagawa^ if (classCode.startsWith("22")) { // pcell = new PdfPCell(new Paragraph(")", min_8)); } else if (classCode.startsWith("21")) { // pcell = new PdfPCell(new Paragraph(")", min_8)); // } else if (classCode.startsWith("23")) { pcell = new PdfPCell(new Paragraph("", min_8)); } //minagawa$ pcell.setBorderWidth(LINE_WIDTH_0); setAlignRight(pcell); ptbl.addCell(pcell); } else { blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); blank.setColspan(3); ptbl.addCell(blank); } } // ********** @009 ********** } else { pcell = new PdfPCell(new Paragraph(convertNVL(items[cnt].getName()), min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setColspan(7); ptbl.addCell(pcell); } } // @004 2010/02/26 // ?? true ???? if (clearFlg && (admin == null)) { numCell.getPhrase().clear(); num--; } // @004 2010/02/26 } else { String stampName = prescription.getOrderName(); System.err.println("??" + stampName + "????????????"); StringBuilder b = new StringBuilder(); b.append("??").append(stampName) .append("?????????").append(System.getProperty(STR_LF)); System.err.println(b.toString()); } if (!ite.hasNext()) { blank = new PdfPCell(); blank.setBorderWidth(LINE_WIDTH_0); ptbl.addCell(blank); pcell = new PdfPCell(new Paragraph("", min_8)); pcell.setBorderWidth(LINE_WIDTH_0); pcell.setBorderWidthLeft(LINE_WIDTH_1); pcell.setPaddingLeft(30f); pcell.setColspan(8); ptbl.addCell(pcell); preTblList.add(ptbl); } } } catch (Exception e) { e.printStackTrace(System.err); } return preTblList; }