Java Code Examples for java.awt.geom.Path2D#transform()

The following examples show how to use java.awt.geom.Path2D#transform() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorTriangle.java    From darklaf with MIT License 6 votes vote down vote up
protected Shape calculateTriangleShape(final double x, final double y, final int size, final int outerSize,
                                       final AffineTransform transform) {
    double diameter = (size - 2 * outerSize);
    double radius = diameter / 2.0;
    double sideLength = Math.cos(Math.PI / 6.0) * diameter;
    double height = (SQRT3 / 2.0) * sideLength;

    double upperX = radius + x + outerSize;
    double upperY = y + outerSize;

    Path2D trianglePath = new Path2D.Float(Path2D.WIND_EVEN_ODD);
    trianglePath.moveTo(upperX, upperY);
    trianglePath.lineTo(upperX - sideLength / 2.0, upperY + height);
    trianglePath.lineTo(upperX + sideLength / 2.0, upperY + height);
    trianglePath.closePath();
    trianglePath.transform(transform);
    return trianglePath;
}
 
Example 2
Source File: StarPolygon.java    From pumpernickel with MIT License 6 votes vote down vote up
protected Path2D createPath2D() {
	float r1 = getRadius1();
	float r2 = getRadius2();
	int k = getNumberOfPoints();

	Point2D[] points = new Point2D[2 * k];
	for (int a = 0; a < k; a++) {
		double theta1 = 2 * Math.PI / k * a - Math.PI / 2;
		double theta2 = 2 * Math.PI / k * (a + .5) - Math.PI / 2;
		points[2 * a + 0] = new Point2D.Double(r1 * Math.cos(theta1),
				r1 * Math.sin(theta1));
		points[2 * a + 1] = new Point2D.Double(r2 * Math.cos(theta2),
				r2 * Math.sin(theta2));
	}
	Path2D p = new Path2D.Float();
	p.moveTo(points[0].getX(), points[0].getY());
	for (int a = 1; a < points.length; a++) {
		p.lineTo(points[a].getX(), points[a].getY());
	}
	p.closePath();
	p.transform(AffineTransform.getTranslateInstance(getCenterX(),
			getCenterY()));
	return p;
}
 
Example 3
Source File: GlyphVectorSerializationWrapper.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public Shape getOutline(float x, float y) {
	Path2D sum = new Path2D.Float();
	for (GlyphElement e : glyphs) {
		Shape s = e.outline.create();
		sum.append(s, false);
	}
	sum.transform(AffineTransform.getTranslateInstance(x, y));
	return sum;

}
 
Example 4
Source File: IfcTools2D.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Path2D enlargeSlightlyInPlace(Path2D path2d) {
	AffineTransform aLittleLarger = new AffineTransform();
	double centerX = path2d.getBounds2D().getCenterX();
	double centerY = path2d.getBounds2D().getCenterY();
	aLittleLarger.translate(centerX, centerY);
	aLittleLarger.scale(1.01, 1.01);
	aLittleLarger.translate(-centerX, -centerY);

	path2d.transform(aLittleLarger);
	return path2d;
}
 
Example 5
Source File: Path2DCopyConstructor.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 6
Source File: Path2DCopyConstructor.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 7
Source File: Path2DCopyConstructor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 8
Source File: Path2DCopyConstructor.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 9
Source File: Path2DCopyConstructor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 10
Source File: Path2DCopyConstructor.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 11
Source File: Path2DCopyConstructor.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 12
Source File: Path2DCopyConstructor.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 13
Source File: Path2DCopyConstructor.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
Example 14
Source File: MSynthPainter.java    From swift-k with Apache License 2.0 4 votes vote down vote up
@Override
public void paintArrowButtonForeground(SynthContext context, Graphics g, int x, int y, int w, int h, int direction) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(SELECTED);
    switch (direction) {
        case SwingConstants.NORTH:
            g2.fillRoundRect(x, y, w, h + 4, 5, 5);
            g2.setColor(Color.BLACK);
            g2.fillRect(x, y + h, w, 4);
            break;
        case SwingConstants.SOUTH:
            g2.fillRoundRect(x, y - 4, w, h + 4, 5, 5);
            g2.setColor(Color.BLACK);
            g2.fillRect(x, y - 4, w, 4);
            break;
        case SwingConstants.WEST:
            g2.fillRoundRect(x, y, w + 4, h, 5, 5);
            g2.setColor(Color.BLACK);
            g2.fillRect(x + w, y, 4, h);
            break;
        case SwingConstants.EAST:
            g2.fillRoundRect(x - 4, y, w + 4, h, 5, 5);
            g2.setColor(Color.BLACK);
            g2.fillRect(x - 4, y, 4, h);
            break;
    }
    
    
    g2.setColor(ACCENT);
    Path2D p = new Path2D.Double();
    p.moveTo(4, 0);
    p.lineTo(8, 6);
    p.lineTo(0, 6);
    p.closePath();
    
    switch (direction) {
        case SwingConstants.NORTH:
            // no transform
            break;
        case SwingConstants.SOUTH:
            p.transform(AffineTransform.getRotateInstance(Math.PI, 4, 4));
            break;
        case SwingConstants.WEST:
            p.transform(AffineTransform.getRotateInstance(-Math.PI / 2, 4, 4));
            break;
        case SwingConstants.EAST:
            p.transform(AffineTransform.getRotateInstance(Math.PI / 2, 4, 4));
            break;
    }
    
    p.transform(AffineTransform.getTranslateInstance((w - 8) / 2.0, (h - 7) / 2.0));
    g2.fill(p);
}
 
Example 15
Source File: SinglePointRenderer.java    From mil-sym-java with Apache License 2.0 4 votes vote down vote up
private ShapeInfo CreateFeintDummyIndicator(String symbolID, Rectangle2D symbolBounds, Rectangle2D echelonBounds )
{
    Path2D sFeint = new Path2D.Double();
    ShapeInfo siFeint = null;
    //float dash[] = {5.0f};
    float dash[] = {6.0f, 4.0f};
    //Shape sFeint = null;
    //dashed stroke
    float width = 2.0f;

    try
    {
        if(symbolBounds != null && symbolBounds.getWidth()<20)
        {
            width = 1.0f;
            dash[0] = 5.0f;
            dash[1] = 3.0f;
        }
        
        Stroke stroke = new BasicStroke(width,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);

        Point2D left = new Point2D.Double(symbolBounds.getX(), symbolBounds.getY());

        Point2D top = null;//new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .75));

        Point2D right = new Point2D.Double(symbolBounds.getX() + symbolBounds.getWidth(), symbolBounds.getY());

        String affiliation = symbolID.substring(1, 2);
                    if(affiliation.equals("F") ||
                            affiliation.equals("A") ||
                            affiliation.equals("D") ||
                            affiliation.equals("M") ||
                            affiliation.equals("J") ||
                            affiliation.equals("K"))
                    {
                        top = new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .75));
                    }
                    else
                    {
                        top = new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .54));

                    }

        Line2D leftLine = new Line2D.Double(left, top);
        Line2D rightLine = new Line2D.Double(top, right);
        sFeint.append(leftLine, false);
        sFeint.append(rightLine, false);

        if(echelonBounds != null && sFeint.intersects(echelonBounds))
        {
            //move it above echelon and add some breathing room
            sFeint.transform(AffineTransform.getTranslateInstance(0, -echelonBounds.getHeight()-2));
        }

        siFeint = new ShapeInfo(sFeint);
        siFeint.setLineColor(Color.BLACK);
        siFeint.setStroke(stroke);
        siFeint.setShapeType(ShapeInfo.SHAPE_TYPE_UNIT_DISPLAY_MODIFIER);
    }
    catch(Exception exc)
    {
        ErrorLogger.LogException(_className, "CreateFeintDummyIndicator()", exc);
    }
    return siFeint;
}