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


Java Path2D.WIND_NON_ZERO属性代码示例

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


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

示例1: createHexagonShape

/** Creates a hexagonal shape inscribed in the bounds given in the parameters. */
private Shape createHexagonShape(double x, double y, double width, double height) {
    GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
    double extend = height * NodeShape.HEX_EXTEND_RATIO;
    // stat at top left corner
    result.moveTo(x + extend, y);
    // to top right
    result.lineTo(x + width - extend, y);
    // to right
    result.lineTo(x + width, y + height / 2);
    // to bottom right
    result.lineTo(x + width - extend, y + height);
    // to bottom left
    result.lineTo(x + extend, y + height);
    // to left
    result.lineTo(x, y + height / 2);
    result.closePath();
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:JVertexView.java

示例2: getPath2D

Path2D.Float getPath2D() {
    // resolve reference:
    Path2D.Float p2d
        = (refPath2D != null) ? refPath2D.get() : null;

    // create a new Path2D ?
    if (p2d == null) {
        p2d = new Path2D.Float(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K

        // update weak reference:
        refPath2D = new WeakReference<Path2D.Float>(p2d);
    }
    // reset the path anyway:
    p2d.reset();
    return p2d;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:RendererContext.java

示例3: retracePath

private Path retracePath(final AStarNode startNode, final AStarNode targetNode) {
  final List<AStarNode> path = new ArrayList<>();
  AStarNode currentNode = targetNode.getPredecessor();

  while (currentNode != startNode) {
    path.add(currentNode);
    currentNode = currentNode.getPredecessor();
  }
  Collections.reverse(path);

  final Path2D path2D = new GeneralPath(Path2D.WIND_NON_ZERO);
  path2D.moveTo(startNode.getLocation().x, startNode.getLocation().y);

  final List<Point2D> pointsOfPath = new ArrayList<>();
  for (int i = 0; i < path.size(); i++) {
    final AStarNode current = path.get(i);
    final Point currentPoint = new Point(current.getLocation().x, current.getLocation().y);
    pointsOfPath.add(currentPoint);
    path2D.lineTo(currentPoint.x, currentPoint.y);
  }

  path2D.lineTo(targetNode.getLocation().x, targetNode.getLocation().y);

  return new Path(startNode.getLocation(), targetNode.getLocation(), path2D, pointsOfPath);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:25,代码来源:AStarPathFinder.java

示例4: createDiamondShape

/** Creates a diamond shape inscribed in the bounds given in the parameters. */
private Shape createDiamondShape(double x, double y, double width, double height) {
    GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
    result.moveTo(x + width / 2, y);
    result.lineTo(x + width, y + height / 2);
    result.lineTo(x + width / 2, y + height);
    result.lineTo(x, y + height / 2);
    result.closePath();
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:10,代码来源:JVertexView.java

示例5: getPath2D

Path2D.Double getPath2D() {
    // resolve reference:
    Path2D.Double p2d
        = (refPath2D != null) ? refPath2D.get() : null;

    // create a new Path2D ?
    if (p2d == null) {
        p2d = new Path2D.Double(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K

        // update weak reference:
        refPath2D = new WeakReference<Path2D.Double>(p2d);
    }
    // reset the path anyway:
    p2d.reset();
    return p2d;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DRendererContext.java

示例6: findDirectPath

public Path findDirectPath(final Point2D start, final Point2D target) {
  final Path2D path2D = new GeneralPath(Path2D.WIND_NON_ZERO);
  path2D.moveTo(start.getX(), start.getY());
  path2D.lineTo(target.getX(), target.getY());

  final List<Point2D> points = new ArrayList<>();
  points.add(start);
  points.add(target);
  return new Path(start, target, path2D, points);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:10,代码来源:PathFinder.java

示例7: createManhattanShape

/** Creates a shape for the {@link LineStyle#MANHATTAN} line style. */
protected Shape createManhattanShape() {
    int n = this.view.getPointCount();
    if (n > 1) {
        // Following block may modify static vars as side effect
        // (Flyweight Design)
        JEdgeView tmp = (JEdgeView) this.view;
        Point2D[] p = null;
        p = new Point2D[n];
        for (int i = 0; i < n; i++) {
            Point2D pt = tmp.getPoint(i);
            if (pt == null) {
                return null; // exit
            }
            p[i] = new Point2D.Double(pt.getX(), pt.getY());
        }

        // End of Side-Effect Block
        // Undo Possible MT-Side Effects
        if (this.view != tmp) {
            this.view = tmp;
            installAttributes(this.view);
        }
        // End of Undo
        if (this.view.sharedPath == null) {
            this.view.sharedPath = new GeneralPath(Path2D.WIND_NON_ZERO, n);
        } else {
            this.view.sharedPath.reset();
        }
        this.view.beginShape = this.view.lineShape = this.view.endShape = null;
        // first point
        Point2D p0 = p[0];
        // last point
        Point2D pe = p0;
        // second point
        Point2D p1 = null;
        // last point but one
        Point2D p2 = null;
        this.view.sharedPath.moveTo((float) p0.getX(), (float) p0.getY());
        for (int i = 1; i < n; i++) {
            // first move horizontally,
            float x = (float) p[i].getX();
            float y = (float) p[i - 1].getY();
            this.view.sharedPath.lineTo(x, y);
            p2 = pe;
            pe = new Point2D.Float(x, y);
            if (p1 == null) {
                p1 = pe;
            }
            // then move vertically, if needed
            if (p[i].getY() != y) {
                y = (float) p[i].getY();
                this.view.sharedPath.lineTo(x, y);
                p2 = pe;
                pe = new Point2D.Float(x, y);
            }
        }
        if (this.beginDeco != GraphConstants.ARROW_NONE) {
            this.view.beginShape = createLineEnd(this.beginSize, this.beginDeco, p1, p0);
        }
        if (this.endDeco != GraphConstants.ARROW_NONE) {
            this.view.endShape = createLineEnd(this.endSize, this.endDeco, p2, pe);
        }
        if (this.view.endShape == null && this.view.beginShape == null) {
            // With no end decorations the line shape is the same as the
            // shared path and memory
            this.view.lineShape = this.view.sharedPath;
        } else {
            this.view.lineShape = (GeneralPath) this.view.sharedPath.clone();
            if (this.view.endShape != null) {
                this.view.sharedPath.append(this.view.endShape, true);
            }
            if (this.view.beginShape != null) {
                this.view.sharedPath.append(this.view.beginShape, true);
            }
        }
        return this.view.sharedPath;
    }
    return null;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:80,代码来源:JEdgeView.java

示例8: FillAdapter

public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:DuctusRenderingEngine.java


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