/** * Computes the bounding rectangle for this line segment. The rectangle has a rotation 0 degrees * with respect to the coordinate system that the line system is in. For example, if a line segment * is 5 unit long and sits at a 37 degree angle from horizontal, the bounding rectangle will have * origin of the lower left hand end point of the segment, with width = 4 and height = 3. * @return the bounding rectangle */ public Rectangle getBoundingRectangle(){ float x1 = getStartPoint().get(Vector.I1); float y1 = getStartPoint().get(Vector.I2); float x2 = getEndPoint().get(Vector.I1); float y2 = getEndPoint().get(Vector.I2); return new Rectangle(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x2-x1), Math.abs(y2-y1)); }
public CharacterRenderInfo(TextRenderInfo tri) { super(tri == null ? "" : tri.getText(), tri == null ? null : getLocation(tri)); if (tri == null) throw new IllegalArgumentException("TextRenderInfo argument is not nullable."); // determine bounding box float x0 = tri.getDescentLine().getStartPoint().get(0); float y0 = tri.getDescentLine().getStartPoint().get(1); float h = tri.getAscentLine().getStartPoint().get(1) - tri.getDescentLine().getStartPoint().get(1); float w = Math.abs(tri.getBaseline().getStartPoint().get(0) - tri.getBaseline().getEndPoint().get(0)); this.boundingBox = new Rectangle(x0, y0, w, h); }
public ITextChunkLocation createLocation(TextRenderInfo renderInfo, LineSegment baseline) { return new TextChunkLocationDefaultImp(baseline.getStartPoint(), baseline.getEndPoint(), renderInfo.getSingleSpaceWidth()); } });
private static ITextChunkLocation getLocation(TextRenderInfo tri) { LineSegment baseline = tri.getBaseline(); return new TextChunkLocationDefaultImp(baseline.getStartPoint(), baseline.getEndPoint(), tri.getSingleSpaceWidth()); }
@Override public boolean accept(IEventData data, EventType type) { if (type.equals(EventType.RENDER_TEXT)) { TextRenderInfo renderInfo = (TextRenderInfo) data; LineSegment segment = renderInfo.getBaseline(); Vector startPoint = segment.getStartPoint(); Vector endPoint = segment.getEndPoint(); float x1 = startPoint.get(Vector.I1); float y1 = startPoint.get(Vector.I2); float x2 = endPoint.get(Vector.I1); float y2 = endPoint.get(Vector.I2); return filterRect == null || filterRect.intersectsLine(x1, y1, x2, y2); } else { return false; } } }
Vector start = segment.getStartPoint(); Vector end = segment.getEndPoint();
Vector mergedStart = new Vector(Math.min(lastTextChunk.getLocation().getStartLocation().get(0), segment.getStartPoint().get(0)), Math.min(lastTextChunk.getLocation().getStartLocation().get(1), segment.getStartPoint().get(1)), Math.min(lastTextChunk.getLocation().getStartLocation().get(2), segment.getStartPoint().get(2))); Vector mergedEnd = new Vector(Math.max(lastTextChunk.getLocation().getEndLocation().get(0), segment.getEndPoint().get(0)), Math.max(lastTextChunk.getLocation().getEndLocation().get(1), segment.getEndPoint().get(1)),