@Override public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { if (dstPt == null) dstPt = new Point2D.Double(); dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
Graphics2D g = ...; Point2D loc = ...; Font font = Font.getFont("Helvetica-bold-italic"); FontRenderContext frc = g.getFontRenderContext(); TextLayout layout = new TextLayout("This is a string", font, frc); layout.draw(g, (float)loc.getX(), (float)loc.getY()); Rectangle2D bounds = layout.getBounds(); bounds.setRect(bounds.getX()+loc.getX(), bounds.getY()+loc.getY(), bounds.getWidth(), bounds.getHeight()); g.draw(bounds);
position.getCategoryAnchor()); TextBlock block = tick.getLabel(); block.draw(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); Shape bounds = block.calculateBounds(g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getLabelAnchor(), (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getAngle()); if (plotState != null && plotState.getOwner() != null) { r.add(r.getMaxX() + r.getWidth()/2, r.getCenterY()); r.add(r.getMinX() - r.getWidth()/2, r.getCenterY()); r.add(r.getCenterX(), r.getMinY() - r.getHeight()/2); r.add(r.getCenterX(), r.getMaxX() + r.getHeight()/2);
void addToRing(Point2D p) { if (ringPath == null) { ringPath = new GeneralPath(GeneralPath.WIND_EVEN_ODD); ringPath.moveTo((float) p.getX(), (float) p.getY()); } else { ringPath.lineTo((float) p.getX(), (float) p.getY()); } }
GeneralPath gp = new GeneralPath(); gp.moveTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 20); gp.lineTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 2); g.setColor(portTypeColor(input.getType())); g.setStroke(CONNECTION_STROKE); paintConnectionLine(g, (int) topLeft.getX(), (int) topLeft.getY(), r.x + portX + 4, r.y - 2);
g2.drawString(nodeStr, (float) (nodeTab + start.getX()), (float) (start.getY() + nodeAscent)); if (t.isLeaf()) { return nodeWidth; double childStartX = start.getX() + childTab; double childStartY = start.getY() + layerHeight; double lineStartX = start.getX() + nodeCenter; double lineStartY = start.getY() + nodeHeight * (1.0 + belowLineSkip); double lineEndY = lineStartY + nodeHeight * parentSkip; double cWidth = paintTree(child, new Point2D.Double(childStartX, childStartY), g2, fM); g2.draw(new Line2D.Double(lineStartX, lineStartY, lineEndX, lineEndY)); childStartX += cWidth; if (i < t.children().length - 1) {
GlyphVector glyphVector = font.createGlyphVector(frc, text); GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; / (float) glyphVector.getLogicalBounds().getWidth() : 1.0f; float height = (float) glyphVector.getLogicalBounds().getHeight(); float nextAdvance = 0; Shape glyph = glyphVector.getGlyphOutline(currentChar); Point2D p = glyphVector.getGlyphPosition(currentChar); float px = (float) p.getX(); float py = (float) p.getY(); float x = lastX + next * dx * r; float y = lastY + next * dy * r;
/** * Placeholder interface to preserve parameter references in client code. * * @deprecated Please use {@link WarpTransform2DProvider} */ static interface Provider { ParameterDescriptor<Integer> DEGREE = WarpTransform2DProvider.DEGREE; ParameterDescriptorGroup PARAMETERS = WarpTransform2DProvider.PARAMETERS; ParameterDescriptor<Float> POST_SCALE_X = WarpTransform2DProvider.POST_SCALE_X; ParameterDescriptor<Float> POST_SCALE_Y = WarpTransform2DProvider.POST_SCALE_Y; ParameterDescriptor<Float> PRE_SCALE_X = WarpTransform2DProvider.PRE_SCALE_X; ParameterDescriptor<Float> PRE_SCALE_Y = WarpTransform2DProvider.PRE_SCALE_Y; ParameterDescriptor<?> X_COEFFS = WarpTransform2DProvider.X_COEFFS; ParameterDescriptor<?> Y_COEFFS = WarpTransform2DProvider.Y_COEFFS; }
final GeneralPath path = new GeneralPath(); final double xp = pt.getX() + x; final double yp = pt.getY() + y; visible.ensureVisible(xp, yp); if (first) { g2d.setColor(mapper.getMappedColor(param.getColor())); DriverLineG2d.manageStroke(param, g2d); g2d.draw(path);
/** * Get the visual advance associated with the current glyph. * This is the distance from the location of the glyph to * the rightmost part of the glyph. */ protected float getCharWidth(int gvIdx) { Rectangle2D lcBound = gv.getGlyphVisualBounds(gvIdx).getBounds2D(); Point2D lcLoc = gv.getGlyphPosition(gvIdx); return (float)(lcBound.getX()+lcBound.getWidth()- lcLoc.getX()); } }
/** * Contains. * * @param rectangle * the rectangle * @param p * the p * @return true, if successful */ public static boolean contains(final Rectangle2D rectangle, final Point2D p) { return rectangle.getX() <= p.getX() && rectangle.getY() <= p.getY() && rectangle.getX() + rectangle.getWidth() >= p.getX() && rectangle.getY() + rectangle.getHeight() >= p.getY(); }
@Override public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Double(); } dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
/** * Creates a shape representing a point. * * @param point * the location of the point * @return a shape */ public Shape createPoint(Point2D point) { GeneralPath path = new GeneralPath(); path.moveTo((float) (point.getX()), (float) (point.getY() - size / 2)); path.lineTo((float) (point.getX() + size / 2), (float) (point.getY() + size / 2)); path.lineTo((float) (point.getX() - size / 2), (float) (point.getY() + size / 2)); path.lineTo((float) (point.getX()), (float) (point.getY() - size / 2)); return path; }
public ExtremityCircleCross(Point2D p1) { this.px = p1.getX() - radius; this.py = p1.getY() - radius; this.dest = new Point2D.Double(p1.getX(), p1.getY()); }
graphics.setStroke(ms2d.getStroke()); graphics.setComposite(ms2d.getContourComposite()); graphics.draw(transformedShape); alignedRect = new Rectangle2D.Double( Math.round(anchorPoint.getX()), Math.round(anchorPoint.getY()), cornerRect.getWidth(), cornerRect.getHeight()); } else { 0.0, 0.0, cornerRect.getWidth(), cornerRect.getHeight());
g2.drawString(nodeStr, (float) (nodeTab + start.getX()), (float) (start.getY() + nodeAscent)); g2.setColor(curColor); double layerMultiplier = (1.0 + belowLineSkip + aboveLineSkip + parentSkip); double layerHeight = nodeHeight * layerMultiplier; if (t.isLeaf()) { yieldOffsets[leafCtr++] = (float) (nodeTab + start.getX()); return nodeWidth; double childStartX = start.getX() + childTab; double childStartY = start.getY() + layerHeight; double lineStartX = start.getX() + nodeCenter; double lineStartY = start.getY() + nodeHeight * (1.0 + belowLineSkip); double lineEndY = lineStartY + nodeHeight * parentSkip; if(matchedParts != null && matchedParts.contains(child)) { Point2D.Double coord = new Point2D.Double(childStartX, childStartY); matchedPartCoordinates.add(coord); cWidth = paintTree(child, coord, g2, fM, matchedColor); if(((CoreLabel) child.label()).containsKey(CoreAnnotations.DoAnnotation.class)) col = (((CoreLabel) child.label()).get(CoreAnnotations.DoAnnotation.class)) ? tdiffColor : defaultColor; cWidth = paintTree(child, new Point2D.Double(childStartX, childStartY), g2, fM, col); g2.draw(new Line2D.Double(lineStartX, lineStartY, lineEndX, lineEndY)); childStartX += cWidth; if (i < t.children().length - 1) {
public static Shape getDonutSliceShape( Rectangle2D pieBounds, double thickness, double start, double extent) { thickness = thickness / 2; GeneralPath generalPath = new GeneralPath(); GeneralPath dummy = new GeneralPath(); // used to find arc endpoints double x = pieBounds.getX(); double y = pieBounds.getY(); double width = pieBounds.getWidth(); double height = pieBounds.getHeight(); Shape outer = new Arc2D.Double(x, y, width, height, start, extent, Arc2D.OPEN); double wt = width * thickness; double ht = height * thickness; Shape inner = new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start + extent, -extent, Arc2D.OPEN); generalPath.append(outer, false); dummy.append( new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start, extent, Arc2D.OPEN), false); Point2D point = dummy.getCurrentPoint(); if (point != null) { generalPath.lineTo(point.getX(), point.getY()); } generalPath.append(inner, false); dummy.append(new Arc2D.Double(x, y, width, height, start + extent, -extent, Arc2D.OPEN), false); point = dummy.getCurrentPoint(); generalPath.lineTo(point.getX(), point.getY()); return generalPath; }