java.awt.geom.Path2D#transform ( )源码实例Demo

下面列出了java.awt.geom.Path2D#transform ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: darklaf   文件: ColorTriangle.java
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;
}
 
源代码2 项目: pumpernickel   文件: StarPolygon.java
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;
}
 
@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;

}
 
源代码4 项目: BIMserver   文件: IfcTools2D.java
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;
}
 
源代码5 项目: dragonwell8_jdk   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码6 项目: TencentKona-8   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码7 项目: jdk8u60   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码8 项目: openjdk-jdk8u   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码10 项目: openjdk-jdk9   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码11 项目: jdk8u-jdk   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码12 项目: hottub   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码13 项目: jdk8u_jdk   文件: Path2DCopyConstructor.java
static void testTransform(Path2D pathA) {
    pathA.transform(at);
    log("testTransform: passed.");
}
 
源代码14 项目: swift-k   文件: MSynthPainter.java
@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);
}
 
源代码15 项目: mil-sym-java   文件: SinglePointRenderer.java
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;
}