List of usage examples for com.lowagie.text Rectangle getLeft
public float getLeft()
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Draw an elliptical interior with this color. * * @param rect rectangle in which ellipse should fit * @param color colour to use for filling */// w w w . j ava 2 s . co m public void fillEllipse(Rectangle rect, Color color) { template.saveState(); setFill(color); template.ellipse(origX + rect.getLeft(), origY + rect.getBottom(), origX + rect.getRight(), origY + rect.getTop()); template.fill(); template.restoreState(); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Move this rectangle to the specified bottom-left point. * * @param rect rectangle to move//from w w w .j a va2 s .co m * @param x new x origin * @param y new y origin */ public void moveRectangleTo(Rectangle rect, float x, float y) { float width = rect.getWidth(); float height = rect.getHeight(); rect.setLeft(x); rect.setBottom(y); rect.setRight(rect.getLeft() + width); rect.setTop(rect.getBottom() + height); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Translate this rectangle over the specified following distances. * * @param rect rectangle to move//from w ww. j a v a 2 s. co m * @param dx delta x * @param dy delta y */ public void translateRectangle(Rectangle rect, float dx, float dy) { float width = rect.getWidth(); float height = rect.getHeight(); rect.setLeft(rect.getLeft() + dx); rect.setBottom(rect.getBottom() + dy); rect.setRight(rect.getLeft() + dx + width); rect.setTop(rect.getBottom() + dy + height); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Draws the specified image with the first rectangle's bounds, clipping with the second one. * * @param img image//from w w w. j a v a2s . c o m * @param rect rectangle * @param clipRect clipping bounds * @param opacity opacity of the image (1 = opaque, 0= transparent) */ public void drawImage(Image img, Rectangle rect, Rectangle clipRect, float opacity) { try { template.saveState(); // opacity PdfGState state = new PdfGState(); state.setFillOpacity(opacity); state.setBlendMode(PdfGState.BM_NORMAL); template.setGState(state); // clipping code if (clipRect != null) { template.rectangle(clipRect.getLeft() + origX, clipRect.getBottom() + origY, clipRect.getWidth(), clipRect.getHeight()); template.clip(); template.newPath(); } template.addImage(img, rect.getWidth(), 0, 0, rect.getHeight(), origX + rect.getLeft(), origY + rect.getBottom()); } catch (DocumentException e) { log.warn("could not draw image", e); } finally { template.restoreState(); } }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
private float getAbsoluteX(float f, Rectangle rect) { return rect.getLeft() + f * rect.getWidth(); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Draw the specified geometry.//from w ww. j a va2s. c o m * * @param geometry geometry to draw * @param symbol symbol for geometry * @param fillColor fill colour * @param strokeColor stroke colour * @param lineWidth line width * @param clipRect clipping rectangle */ public void drawGeometry(Geometry geometry, SymbolInfo symbol, Color fillColor, Color strokeColor, float lineWidth, float[] dashArray, Rectangle clipRect) { template.saveState(); // clipping code if (clipRect != null) { template.rectangle(clipRect.getLeft() + origX, clipRect.getBottom() + origY, clipRect.getWidth(), clipRect.getHeight()); template.clip(); template.newPath(); } setStroke(strokeColor, lineWidth, dashArray); setFill(fillColor); drawGeometry(geometry, symbol); template.restoreState(); }
From source file:org.geomajas.plugin.print.component.PdfContext.java
License:Open Source License
/** * Converts an absolute rectangle to a relative one wrt to the current coordinate system. * * @param rect absolute rectangle/*w w w.j a v a2 s. c om*/ * @return relative rectangle */ public Rectangle toRelative(Rectangle rect) { return new Rectangle(rect.getLeft() - origX, rect.getBottom() - origY, rect.getRight() - origX, rect.getTop() - origY); }
From source file:org.geomajas.plugin.print.parser.RectangleConverter.java
License:Open Source License
@Override public String toString(Object obj) { Rectangle rectangle = (Rectangle) obj; if (obj == null) { return null; }//from w ww .ja v a2 s . c o m return rectangle.getLeft() + "," + rectangle.getBottom() + "," + rectangle.getRight() + "," + rectangle.getTop(); }
From source file:org.jaffa.modules.printing.services.FormPrintEngineIText.java
License:Open Source License
/** * Any work to start off printing the document * @throws FormPrintException Thrown if there is any form processing problems *///ww w. j a va 2 s.c o m protected void startDocument() throws FormPrintException { log.debug("startDocument:"); Rectangle r = m_templateReader.getPageSize(getCurrentTemplatePage()); log.debug("Page Size : t=" + r.getTop() + ",l=" + r.getLeft() + ",b=" + r.getBottom() + ",r=" + r.getRight() + ", rot=" + r.getRotation()); r = m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()); log.debug("Page Size w/Rot: t=" + r.getTop() + ",l=" + r.getLeft() + ",b=" + r.getBottom() + ",r=" + r.getRight() + ", rot=" + r.getRotation()); m_generatedDoc = new Document(m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage())); //m_generatedDoc = new Document(m_templateReader.getPageSize(getCurrentTemplatePage())); m_output = new ByteArrayOutputStream(); try { m_writer = PdfWriter.getInstance(m_generatedDoc, m_output); } catch (DocumentException e) { log.error("Error Creating Writer - " + e.getMessage(), e); throw new EngineProcessingException("Error Creating Writer - " + e.getMessage()); } if (getDocumentProperties() != null) { Properties dp = (Properties) getDocumentProperties().clone(); if (dp.getProperty(DOCUMENT_PROPERTY_TITLE) != null) { m_generatedDoc.addTitle(dp.getProperty(DOCUMENT_PROPERTY_TITLE)); dp.remove(DOCUMENT_PROPERTY_TITLE); } if (dp.getProperty(DOCUMENT_PROPERTY_SUBJECT) != null) { m_generatedDoc.addSubject(dp.getProperty(DOCUMENT_PROPERTY_SUBJECT)); dp.remove(DOCUMENT_PROPERTY_SUBJECT); } if (dp.getProperty(DOCUMENT_PROPERTY_KEYWORDS) != null) { m_generatedDoc.addKeywords(dp.getProperty(DOCUMENT_PROPERTY_KEYWORDS)); dp.remove(DOCUMENT_PROPERTY_KEYWORDS); } if (dp.getProperty(DOCUMENT_PROPERTY_CREATOR) != null) { m_generatedDoc.addCreator(dp.getProperty(DOCUMENT_PROPERTY_CREATOR, "Jaffa Print Engine")); dp.remove(DOCUMENT_PROPERTY_CREATOR); } if (dp.getProperty(DOCUMENT_PROPERTY_AUTHOR) != null) { m_generatedDoc.addAuthor(dp.getProperty(DOCUMENT_PROPERTY_AUTHOR)); dp.remove(DOCUMENT_PROPERTY_AUTHOR); } // loop through other properties and set them as header parameters for (Enumeration en = dp.elements(); en.hasMoreElements();) { Map.Entry e = (Map.Entry) en.nextElement(); if (e.getKey() != null && e.getValue() != null) m_generatedDoc.addHeader(e.getKey().toString(), e.getValue().toString()); } } m_generatedDoc.addCreationDate(); m_generatedDoc.open(); }
From source file:org.jaffa.modules.printing.services.FormPrintEngineIText.java
License:Open Source License
/** * Any work to start off printing a page of the document * m_currentPage will contain the page being printed, and * m_currentTemplatePage will contain the template page number to base this * new page on.//w ww .ja v a2 s.c o m * @throws FormPrintException Thrown if there is any form processing problems */ protected void startPage() throws FormPrintException { log.debug("startPage: Page=" + getCurrentPage()); Rectangle r = m_templateReader.getPageSize(getCurrentTemplatePage()); log.debug("Page Size : t=" + r.getTop() + ",l=" + r.getLeft() + ",b=" + r.getBottom() + ",r=" + r.getRight() + ", rot=" + r.getRotation()); r = m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()); log.debug("Page Size w/Rot: t=" + r.getTop() + ",l=" + r.getLeft() + ",b=" + r.getBottom() + ",r=" + r.getRight() + ", rot=" + r.getRotation()); // Get rotation quadrent 0..3 int q = (m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage()).getRotation() % 360) / 90; float tX = (q == 2 ? r.getTop() : 0) + (q == 3 ? r.getRight() : 0); float tY = (q == 1 ? r.getTop() : 0) + (q == 2 ? r.getRight() : 0); float sX = 1f, sY = 1f; double angle = -r.getRotation() * (Math.PI / 180f); double transformA = sX * Math.cos(angle); double transformB = sY * Math.sin(angle); double transformC = -sX * Math.sin(angle); double transformD = sY * Math.cos(angle); double transformE = tX; double transformF = tY; m_generatedDoc.setPageSize(m_templateReader.getPageSizeWithRotation(getCurrentTemplatePage())); //m_generatedDoc.setPageSize(m_templateReader.getPageSize(getCurrentTemplatePage()) ); /** * try { * m_generatedDoc.newPage(); * } catch (DocumentException e) { * log.error("Error Creating New Page - " + e.getMessage() ,e); * throw new EngineProcessingException("Error Creating New Page - " + e.getMessage()); * } **/ m_generatedDoc.newPage(); PdfImportedPage page = m_writer.getImportedPage(m_templateReader, getCurrentTemplatePage()); PdfContentByte cb = m_writer.getDirectContent(); //cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0); cb.addTemplate(page, (float) transformA, (float) transformB, (float) transformC, (float) transformD, (float) transformE, (float) transformF); log.debug("Matrix = [A=" + transformA + ", B=" + transformB + ", C=" + transformC + ", D=" + transformD + ", E=" + transformE + ", F=" + transformF + " ]"); }