Here you can find the source of verticalParallelogram(Point2D top, Point2D bottom, double width)
Parameter | Description |
---|---|
top | top point of median line |
bottom | bottom point of median line |
width | total width |
public static Area verticalParallelogram(Point2D top, Point2D bottom, double width)
//package com.java2s; // GNU Affero General Public License as published by the Free Software Foundation, either version import java.awt.geom.Area; import java.awt.geom.Path2D; import java.awt.geom.Point2D; public class Main { /**/*from ww w. jav a 2s .c om*/ * Create a parallelogram mostly vertical, where top and bottom sides are short and * horizontal. * This is most useful for stems. * <p> * Nota: the defining points are meant to be the extrema points * <b>inside</b> the parallelogram. * * @param top top point of median line * @param bottom bottom point of median line * @param width total width * @return the created area */ public static Area verticalParallelogram(Point2D top, Point2D bottom, double width) { final double dx = width / 2; // Half width final Path2D path = new Path2D.Double(); path.moveTo(top.getX() - dx, top.getY()); // Upper left path.lineTo(top.getX() + dx + 1, top.getY()); // Upper right path.lineTo(bottom.getX() + dx + 1, bottom.getY() + 1); // Lower right path.lineTo(bottom.getX() - dx, bottom.getY() + 1); // Lower left path.closePath(); return new Area(path); } }