List of usage examples for java.awt.geom Point2D.Float getY
public abstract double getY();
From source file:org.apache.pdfbox.pdmodel.font.PDSimpleFont.java
/** * This will draw a string on a canvas using the font. * * @param g2d The graphics to draw onto. * @param at The transformation matrix with all information for scaling and shearing of the font. * @param x The x coordinate to draw at. * @param y The y coordinate to draw at. * @param glyphs The GlyphVector containing the glyphs to be drawn. * *//*from w ww . j a v a 2 s . c o m*/ protected void writeFont(final Graphics2D g2d, final AffineTransform at, final float x, final float y, final GlyphVector glyphs) { // check if we have a rotation if (!at.isIdentity()) { try { AffineTransform atInv = at.createInverse(); // do only apply the size of the transform, rotation will be realized by rotating the graphics, // otherwise the hp printers will not render the font // apply the transformation to the graphics, which should be the same as applying the // transformation itself to the text g2d.transform(at); // translate the coordinates Point2D.Float newXy = new Point2D.Float(x, y); atInv.transform(new Point2D.Float(x, y), newXy); g2d.drawGlyphVector(glyphs, (float) newXy.getX(), (float) newXy.getY()); // restore the original transformation g2d.transform(atInv); } catch (NoninvertibleTransformException e) { LOG.error("Error in " + getClass().getName() + ".writeFont", e); } } else { g2d.drawGlyphVector(glyphs, x, y); } }
From source file:org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.java
/** * This is the public method for setting the appearance stream. * * @param apValue the String value which the appearance should represent * @throws IOException If there is an error creating the stream. *///from ww w .j av a2s . c o m public void setAppearanceValue(String apValue) throws IOException { value = apValue; for (PDAnnotationWidget widget : field.getWidgets()) { PDRectangle rect = widget.getRectangle(); if (rect == null) { widget.getCOSObject().removeItem(COSName.AP); LOG.warn("widget of field " + field.getFullyQualifiedName() + " has no rectangle, no appearance stream created"); continue; } PDFormFieldAdditionalActions actions = field.getActions(); // in case all tests fail the field will be formatted by acrobat // when it is opened. See FreedomExpressions.pdf for an example of this. if (actions == null || actions.getF() == null || widget.getCOSObject().getDictionaryObject(COSName.AP) != null) { PDAppearanceDictionary appearanceDict = widget.getAppearance(); if (appearanceDict == null) { appearanceDict = new PDAppearanceDictionary(); widget.setAppearance(appearanceDict); } PDAppearanceEntry appearance = appearanceDict.getNormalAppearance(); // TODO support appearances other than "normal" PDAppearanceStream appearanceStream; if (appearance.isStream()) { appearanceStream = appearance.getAppearanceStream(); } else { appearanceStream = new PDAppearanceStream(field.getAcroForm().getDocument()); // Calculate the entries for the bounding box and the transformation matrix // settings for the appearance stream int rotation = resolveRotation(widget); Matrix matrix = Matrix.getRotateInstance(Math.toRadians(rotation), 0, 0); Point2D.Float point2D = matrix.transformPoint(rect.getWidth(), rect.getHeight()); PDRectangle bbox = new PDRectangle(Math.abs((float) point2D.getX()), Math.abs((float) point2D.getY())); appearanceStream.setBBox(bbox); appearanceStream.setMatrix(calculateMatrix(bbox, rotation)); appearanceStream.setFormType(1); appearanceStream.setResources(new PDResources()); appearanceDict.setNormalAppearance(appearanceStream); // TODO support appearances other than "normal" } /* * Adobe Acrobat always recreates the complete appearance stream if there is an appearance characteristics * entry (the widget dictionaries MK entry). In addition if there is no content yet also create the appearance * stream from the entries. * */ if (widget.getAppearanceCharacteristics() != null || appearanceStream.getContentStream().getLength() == 0) { initializeAppearanceContent(widget, appearanceStream); } setAppearanceContent(widget, appearanceStream); } } }
From source file:org.mapfish.print.map.renderers.BitmapMapRenderer.java
private boolean isTileVisible(float x, float y, long w, long h, AffineTransform bitmapTransformer, Transformer transformer) { GeometryFactory gf = new GeometryFactory(); Polygon page = gf.createPolygon(gf.createLinearRing(new Coordinate[] { new Coordinate(transformer.getPaperPosX(), transformer.getPaperPosY()), new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(), transformer.getPaperPosY()), new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(), transformer.getPaperPosY() + transformer.getPaperH()), new Coordinate(transformer.getPaperPosX(), transformer.getPaperPosY() + transformer.getPaperH()), new Coordinate(transformer.getPaperPosX(), transformer.getPaperPosY()), }), null); Point2D.Float ll = new Point2D.Float(); Point2D.Float lr = new Point2D.Float(); Point2D.Float ur = new Point2D.Float(); Point2D.Float ul = new Point2D.Float(); bitmapTransformer.transform(new Point2D.Float(x, y), ll); bitmapTransformer.transform(new Point2D.Float(x + w, y), lr); bitmapTransformer.transform(new Point2D.Float(x + w, y + h), ur); bitmapTransformer.transform(new Point2D.Float(x, y + h), ul); Polygon tile = gf// w w w .j a va 2s .c o m .createPolygon( gf.createLinearRing(new Coordinate[] { new Coordinate(ll.getX(), ll.getY()), new Coordinate(lr.getX(), lr.getY()), new Coordinate(ur.getX(), ur.getY()), new Coordinate(ul.getX(), ul.getY()), new Coordinate(ll.getX(), ll.getY()), }), null); return page.intersects(tile); }
From source file:org.mapfish.print.map.renderers.BitmapTileRenderer.java
private boolean isTileVisible(double x, double y, long w, long h, AffineTransform bitmapTransformer, Transformer transformer) { GeometryFactory gf = new GeometryFactory(); Polygon page = gf.createPolygon(gf.createLinearRing(new Coordinate[] { new Coordinate(transformer.getPaperPosX(), transformer.getPaperPosY()), new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(), transformer.getPaperPosY()), new Coordinate(transformer.getPaperPosX() + transformer.getPaperW(), transformer.getPaperPosY() + transformer.getPaperH()), new Coordinate(transformer.getPaperPosX(), transformer.getPaperPosY() + transformer.getPaperH()), new Coordinate(transformer.getPaperPosX(), transformer.getPaperPosY()), }), null); Point2D.Float ll = new Point2D.Float(); Point2D.Float lr = new Point2D.Float(); Point2D.Float ur = new Point2D.Float(); Point2D.Float ul = new Point2D.Float(); bitmapTransformer.transform(new Point2D.Float((float) x, (float) y), ll); bitmapTransformer.transform(new Point2D.Float((float) x + w, (float) y), lr); bitmapTransformer.transform(new Point2D.Float((float) x + w, (float) y + h), ur); bitmapTransformer.transform(new Point2D.Float((float) x, (float) y + h), ul); Polygon tile = gf//from w w w. j av a 2 s. co m .createPolygon( gf.createLinearRing(new Coordinate[] { new Coordinate(ll.getX(), ll.getY()), new Coordinate(lr.getX(), lr.getY()), new Coordinate(ur.getX(), ur.getY()), new Coordinate(ul.getX(), ul.getY()), new Coordinate(ll.getX(), ll.getY()), }), null); return page.intersects(tile); }