当前位置: 首页>>代码示例>>Java>>正文


Java Arc2D.getHeight方法代码示例

本文整理汇总了Java中java.awt.geom.Arc2D.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Arc2D.getHeight方法的具体用法?Java Arc2D.getHeight怎么用?Java Arc2D.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.Arc2D的用法示例。


在下文中一共展示了Arc2D.getHeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cloneShape

import java.awt.geom.Arc2D; //导入方法依赖的package包/类
/**
 * Clone's the shape provided.
 * 
 * @param aShape shape to be cloned
 * 
 * @return a cloned version of the provided shape
 */
public Shape cloneShape(final Shape aShape) {
    if (aShape instanceof Rectangle2D) {
        return new PBounds((Rectangle2D) aShape);
    }
    else if (aShape instanceof Ellipse2D) {
        final Ellipse2D e2 = (Ellipse2D) aShape;
        return new Ellipse2D.Double(e2.getX(), e2.getY(), e2.getWidth(), e2.getHeight());
    }
    else if (aShape instanceof Arc2D) {
        final Arc2D a2 = (Arc2D) aShape;
        return new Arc2D.Double(a2.getX(), a2.getY(), a2.getWidth(), a2.getHeight(), a2.getAngleStart(), a2
                .getAngleExtent(), a2.getArcType());
    }
    else if (aShape instanceof RoundRectangle2D) {
        final RoundRectangle2D r2 = (RoundRectangle2D) aShape;
        return new RoundRectangle2D.Double(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight(), r2.getArcWidth(),
                r2.getArcHeight());
    }
    else if (aShape instanceof Line2D) {
        final Line2D l2 = (Line2D) aShape;
        return new Line2D.Double(l2.getP1(), l2.getP2());
    }
    else {
        final GeneralPath aPath = new GeneralPath();
        aPath.append(aShape, false);
        return aPath;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:36,代码来源:PSWTPath.java

示例2: computeOutSlope

import java.awt.geom.Arc2D; //导入方法依赖的package包/类
/**
 * Returns dx/dy for the out slope.
 */
private double[] computeOutSlope(double[] curr, int currSegType,
                                 double[] next, int nextSegType){

    Point2D currEndPoint = getSegmentTerminatingPoint(curr, currSegType);

    double dx = 0, dy = 0;

    switch(nextSegType){
    case PathIterator.SEG_CLOSE:
        // Should not happen at this point, because all close
        // segments have been replaced by lineTo segments.
        break;
    case PathIterator.SEG_CUBICTO:
    case PathIterator.SEG_LINETO:
    case PathIterator.SEG_QUADTO:
        // If the next segment is a line, quad or cubic curve.
        // the slope is about equal to that of the line from
        // curEndPoint and the first control point
        dx = next[0] - currEndPoint.getX();
        dy = next[1] - currEndPoint.getY();
        break;
    case ExtendedPathIterator.SEG_ARCTO: {
        // If the current segment is an ARCTO then we build the
        // arc and ask for it's end angle and get the tangent there.
        boolean large   = (next[3]!=0.);
        boolean goLeft = (next[4]!=0.);
        Arc2D arc = ExtendedGeneralPath.computeArc
            (currEndPoint.getX(), currEndPoint.getY(),
             next[0], next[1], next[2],
             large, goLeft, next[5], next[6]);
        double theta = arc.getAngleStart();
        theta = Math.toRadians(theta);
        dx = -arc.getWidth()/2.0*Math.sin(theta);
        dy = arc.getHeight()/2.0*Math.cos(theta);
        // System.out.println("Out Theta:  " + Math.toDegrees(theta) +
        //                    " Dx/Dy: " + dx + "/" + dy);
        if (next[2] != 0) {
            double ang = Math.toRadians(-next[2]);
            double sinA = Math.sin(ang);
            double cosA = Math.cos(ang);
            double tdx = dx*cosA - dy*sinA;
            double tdy = dx*sinA + dy*cosA;
            dx = tdx;
            dy = tdy;
        }
        // System.out.println("    Rotate: " + next[2] +
        //                    " Dx/Dy: " + dx + "/" + dy);

        if (goLeft) {
            dx = -dx;
        } else {
            dy = -dy;
        }
        // System.out.println("    GoLeft? " + goLeft +
        //                    " Dx/Dy: " + dx + "/" + dy);
    }
        break;
    case PathIterator.SEG_MOVETO:
        // Cannot compute the out slope
    default:
        return null;
    }

    if (dx == 0 && dy == 0) {
        return null;
    }

    return normalize(new double[] { dx, dy });
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:73,代码来源:MarkerShapePainter.java


注:本文中的java.awt.geom.Arc2D.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。