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


Java Path2D.moveTo方法代码示例

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


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

示例1: drawPolyline

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/**
 * Draws a sequence of connected lines defined by
 * arrays of <i>x</i> and <i>y</i> coordinates.
 * Each pair of (<i>x</i>,&nbsp;<i>y</i>) coordinates defines a point.
 * The figure is not closed if the first point
 * differs from the last point.
 * @param       xPoints an array of <i>x</i> points
 * @param       yPoints an array of <i>y</i> points
 * @param       nPoints the total number of points
 * @see         java.awt.Graphics#drawPolygon(int[], int[], int)
 * @since       1.1
 */
public void drawPolyline(int xPoints[], int yPoints[],
                         int nPoints) {

    if (nPoints == 2) {
        draw(new Line2D.Float(xPoints[0], yPoints[0],
                              xPoints[1], yPoints[1]));
    } else if (nPoints > 2) {
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD, nPoints);
        path.moveTo(xPoints[0], yPoints[0]);
        for(int i = 1; i < nPoints; i++) {
            path.lineTo(xPoints[i], yPoints[i]);
        }
        draw(path);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:PathGraphics.java

示例2: makeEllipse

import java.awt.geom.Path2D; //导入方法依赖的package包/类
public Path2D makeEllipse(Complex G1, Complex G2, int m, double xOffset, double yOffset) {
	Path2D path = new Path2D.Float();
	int recPoints = Math.max(minReconstructionSamples, G.length * 3);
	for (int i = 0; i < recPoints; i++) {
		double t = (double) i / recPoints;
		Complex p1 = this.getEllipsePoint(G1, G2, m, t);
		double xt = p1.re();
		double yt = p1.im();
		if (i == 0) {
			path.moveTo(xt + xOffset, yt + yOffset);
		}
		else {
			path.lineTo(xt + xOffset, yt + yOffset);
		}
	}
	path.closePath();
	return path;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:19,代码来源:FourierDescriptor.java

示例3: convertPolylineToPath

import java.awt.geom.Path2D; //导入方法依赖的package包/类
public static Path2D convertPolylineToPath(final IMapObject mapObject) {
  if (mapObject == null || mapObject.getPolyline() == null || mapObject.getPolyline().getPoints().isEmpty()) {
    return null;
  }

  Path2D path = new Path2D.Float();
  path.moveTo(mapObject.getLocation().getX(), mapObject.getLocation().getY());
  for (int i = 1; i < mapObject.getPolyline().getPoints().size(); i++) {
    Point2D point = mapObject.getPolyline().getPoints().get(i);
    path.lineTo(mapObject.getLocation().getX() + point.getX(), mapObject.getLocation().getY() + point.getY());
  }

  return path;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:15,代码来源:MapUtilities.java

示例4: retracePath

import java.awt.geom.Path2D; //导入方法依赖的package包/类
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,代码行数:26,代码来源:AStarPathFinder.java

示例5: drawArrow

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private Path2D drawArrow(int x1, int y1, int x2, int y2) {
  Path2D context = new Path2D.Float();
  int headlen = 10;   // length of head in pixels
  double angle = Math.atan2(y2 - y1, x2 - x1);
  context.moveTo(x1, y1);
  context.lineTo(x2, y2);
  context.lineTo(x2 - headlen * Math.cos(angle - Math.PI / 6), y2 - headlen * Math.sin(angle - Math.PI / 6));
  context.moveTo(x2, y2);
  context.lineTo(x2 - headlen * Math.cos(angle + Math.PI / 6), y2 - headlen * Math.sin(angle + Math.PI / 6));
  context.closePath();
  return context;
}
 
开发者ID:onprom,项目名称:onprom,代码行数:13,代码来源:ResourceConnection.java

示例6: renderCurvePath

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private Shape renderCurvePath(int[] xPoints, int[] yPoints) {
    Path2D path = new Path2D.Double();
    path.moveTo(xPoints[0], yPoints[0]);

    int curveIndex;
    for (curveIndex = 0; curveIndex <= xPoints.length - 3; curveIndex += 3) {
        path.curveTo(xPoints[curveIndex], yPoints[curveIndex], xPoints[curveIndex + 1], yPoints[curveIndex + 1], xPoints[curveIndex + 2], yPoints[curveIndex + 2]);
    }

    if (xPoints.length >= 3 && xPoints.length - curveIndex == 2) {
        path.curveTo(xPoints[xPoints.length - 3], yPoints[xPoints.length - 3], xPoints[xPoints.length - 2], yPoints[xPoints.length - 2], xPoints[xPoints.length - 1], yPoints[xPoints.length - 1]);
    } else {
        path.lineTo(xPoints[xPoints.length - 1], yPoints[xPoints.length - 1]);
    }

    return path;
}
 
开发者ID:defano,项目名称:jmonet,代码行数:18,代码来源:CurveTool.java

示例7: main

import java.awt.geom.Path2D; //导入方法依赖的package包/类
public static void main(final String[] args) {
    final Path2D path1 = new Path2D.Double(Path2D.WIND_EVEN_ODD, 0);
    path1.moveTo(10, 10);
    path1.lineTo(20, 20);
    final Path2D path2 = new Path2D.Float(Path2D.WIND_EVEN_ODD, 0);
    path2.moveTo(10, 10);
    path2.lineTo(20, 20);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:EmptyCapacity.java

示例8: makePolygon

import java.awt.geom.Path2D; //导入方法依赖的package包/类
@Deprecated
public static Roi makePolygon(Point2D[] points, double strokeWidth, Color color) {
	Path2D poly = new Path2D.Double();
	if (points.length > 0) {
		poly.moveTo(points[0].getX(), points[0].getY());
		for (int i = 1; i < points.length; i++) {
			poly.lineTo(points[i].getX(), points[i].getY());
		}
		poly.closePath();
	}
	Roi shapeRoi = new ShapeRoi(poly);
	shapeRoi.setStrokeWidth(strokeWidth);
	shapeRoi.setStrokeColor(color);
	return shapeRoi;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:16,代码来源:RoiUtils.java

示例9: makeFourierPairsReconstruction

import java.awt.geom.Path2D; //导入方法依赖的package包/类
/**
 * Reconstructs the shape obtained from FD-pairs 0,...,Mp as a polygon (path).
 * 
 * @param Mp number of Fourier coefficient pairs
 * @return reconstructed shape
 */
public Path2D makeFourierPairsReconstruction(int Mp) {
	int M = G.length;
	Mp = Math.min(Mp, M/2);
	int recPoints = Math.max(minReconstructionSamples, G.length * 3);
	Path2D path = new Path2D.Float();
	for (int i = 0; i < recPoints; i++) {
		double t = (double) i / recPoints;
		Complex pt = new Complex(getCoefficient(0));	// assumes that coefficient 0 is never scaled
		// calculate a particular reconstruction point 
		for (int m = 1; m <= Mp; m++) {
			Complex ep = getEllipsePoint(getCoefficient(-m), getCoefficient(m), m, t);
			pt = pt.add(ep.mult(reconstructionScale));
		}
		double xt = pt.re(); 
		double yt = pt.im(); 
		if (i == 0) {
			path.moveTo(xt, yt);
		}
		else {
			path.lineTo(xt, yt);
		}
	}
	path.closePath();
	return path;
}
 
开发者ID:imagingbook,项目名称:imagingbook-common,代码行数:32,代码来源:FourierDescriptor.java

示例10: drawPolylineGOOD

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private void drawPolylineGOOD(Graphics2D g2d,
                              int[] x2Points, int[] y2Points) {

    Path2D polyline =
        new Path2D.Float(Path2D.WIND_EVEN_ODD, x2Points.length);

    polyline.moveTo(x2Points[0], y2Points[0]);

    for (int index = 1; index < x2Points.length; index++) {
            polyline.lineTo(x2Points[index], y2Points[index]);
    }
    g2d.draw(polyline);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:PolylinePrintingTest.java

示例11: renderLightSource

import java.awt.geom.Path2D; //导入方法依赖的package包/类
private void renderLightSource(final Graphics2D g, final LightSource light, final double longerDimension) {
  final Point2D lightCenter = light.getDimensionCenter();

  final Area lightArea = new Area(light.getLightShape());
  if (light.getLightShapeType().equals(LightSource.RECTANGLE)) {
    g.setColor(light.getColor());
    g.fill(lightArea);
    return;
  }

  // cut the light area where shadow Boxes are (this simulates light falling
  // into and out of rooms)
  for (final StaticShadow col : this.environment.getStaticShadows()) {
    if (!GeometricUtilities.shapeIntersects(light.getLightShape(), col.getBoundingBox())) {
      continue;
    }
    final Area boxInLight = new Area(col.getBoundingBox());
    boxInLight.intersect(lightArea);

    final Line2D[] bounds = GeometricUtilities.getLines(col.getBoundingBox());
    for (final Line2D line : bounds) {
      final Vector2D lineVector = new Vector2D(line.getP1(), line.getP2());
      final Vector2D lightVector = new Vector2D(lightCenter, line.getP1());

      if (light.getDimensionCenter().getY() < line.getY1() && light.getDimensionCenter().getY() < line.getY2() && col.getBoundingBox().contains(light.getDimensionCenter()) || lineVector.normalVector().dotProduct(lightVector) >= 0) {
        continue;
      }

      final Path2D shadowParallelogram = new Path2D.Double();
      final Point2D shadowPoint1 = GeometricUtilities.project(lightCenter, line.getP1(), longerDimension);
      final Point2D shadowPoint2 = GeometricUtilities.project(lightCenter, line.getP2(), longerDimension);

      // construct a shape from our points
      shadowParallelogram.moveTo(line.getP1().getX(), line.getP1().getY());
      shadowParallelogram.lineTo(shadowPoint1.getX(), shadowPoint1.getY());
      shadowParallelogram.lineTo(shadowPoint2.getX(), shadowPoint2.getY());
      shadowParallelogram.lineTo(line.getP2().getX(), line.getP2().getY());
      shadowParallelogram.closePath();

      final Area shadowArea = new Area(shadowParallelogram);
      if (light.getDimensionCenter().getY() < col.getBoundingBox().getMaxY() && !col.getBoundingBox().contains(light.getDimensionCenter())) {
        shadowArea.add(boxInLight);
      }
      shadowArea.intersect(lightArea);
      lightArea.subtract(shadowArea);
    }
  }

  final Paint oldPaint = g.getPaint();

  // render parts that lie within the shadow with a gradient from the light
  // color to transparent
  final Area lightRadiusArea = new Area(light.getLightShape());
  final Color[] transColors = new Color[] { new Color(light.getColor().getRed(), light.getColor().getGreen(), light.getColor().getBlue(), light.getBrightness()), new Color(light.getColor().getRed(), light.getColor().getGreen(), light.getColor().getBlue(), 0) };
  try {
    g.setPaint(new RadialGradientPaint(new Point2D.Double(lightRadiusArea.getBounds2D().getCenterX(), lightRadiusArea.getBounds2D().getCenterY()), (float) (lightRadiusArea.getBounds2D().getWidth() / 2), new float[] { 0.0f, 1.00f }, transColors));
  } catch (final Exception e) {
    g.setColor(light.getColor());
  }
  g.fill(lightArea);
  g.setPaint(oldPaint);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:63,代码来源:AmbientLight.java

示例12: draw

import java.awt.geom.Path2D; //导入方法依赖的package包/类
@Override
public void draw(Graphics2D g) {
	float wrap = (float)map.getWrap();
	
	//get the limits of the displayed map
	Rectangle2D rect = map.getClipRect2D();
	double xmin = rect.getMinX();
	double xmax = rect.getMaxX();
	
	Projection proj = map.getProjection();
	Point2D.Double pt = new Point2D.Double();
	pt.x = getStartLon();
	pt.y = getStartLat();
	Point2D.Double p_start = (Point2D.Double) proj.getMapXY(pt);

	if( wrap>0f ) {
		while( p_start.x <= xmin ){p_start.x+=wrap;}
		while( p_start.x >= xmax ){p_start.x-=wrap;}
	}
	
	pt.x = getEndLon();
	pt.y = getEndLat();
	Point2D.Double p_end = (Point2D.Double) proj.getMapXY(pt);

	if( wrap>0f ) {
		while( p_end.x <= xmin ){p_end.x+=wrap;}
		while( p_end.x > wrap + xmin ){p_end.x-=wrap;}
	}
	
	//draw the shortest line - either p_start.x to p_end.x or the x+wrap values. 
	if ( ((p_start.x - p_end.x) * (p_start.x - p_end.x)) > 
		((p_start.x - (p_end.x + wrap)) * (p_start.x - (p_end.x + wrap))) )  {p_end.x += wrap;}
	if ( ((p_start.x - p_end.x) * (p_start.x - p_end.x)) > 
	(((p_start.x + wrap) - p_end.x) * ((p_start.x + wrap) - p_end.x)) )  {p_start.x += wrap;}
	
	if (lineNum == 1) g.setColor( Color.RED ); 
	else g.setColor( Color.black );
	
	double zoom = map.getZoom();
	g.setStroke( new BasicStroke( 2f/(float)zoom ));

   	double arr_size = 6./zoom;
   	double sq_size = 6./zoom;
       double dx = p_end.x - p_start.x, dy = p_end.y - p_start.y;
       double angle = Math.atan2(dy, dx);
       double len = Math.sqrt(dx*dx + dy*dy);

       AffineTransform at = g.getTransform(); 
       g.translate(p_start.x, p_start.y);
       g.rotate(angle);

       //draw the line
       g.draw(new Line2D.Double(0, 0, len, 0));
       //draw the arrow
       Path2D arrow = new Path2D.Double();
       double xpts[] = {len/3d, len/3d-arr_size, len/3d-arr_size, len/3d};
       double ypts[] = {0, -arr_size, arr_size, 0};
       arrow.moveTo(xpts[0], ypts[0]);
       arrow.lineTo(xpts[1], ypts[1]);
       arrow.lineTo(xpts[2], ypts[2]);
       arrow.closePath();
	if (lineNum == 1) g.setColor( Color.ORANGE ); 
	else g.setColor( Color.ORANGE );
       g.fill(arrow);
	if (lineNum == 1) g.setColor( Color.RED ); 
	else g.setColor( Color.black );
       //draw squares at the end points
       Rectangle2D startSq = new Rectangle2D.Double(0d-sq_size/2d, 0d-sq_size/2d, sq_size, sq_size);
       Rectangle2D endSq = new Rectangle2D.Double(len-sq_size/2d, 0d-sq_size/2d,  sq_size, sq_size);
       g.fill(startSq);
       g.fill(endSq);

       g.setTransform(at);
       
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:76,代码来源:SurveyLine.java

示例13: getShape

import java.awt.geom.Path2D; //导入方法依赖的package包/类
@Override
public Shape getShape() {
  Path2D shape = new Path2D.Float();
  int xDiff = Math.abs(getSuperclass().getCenterX() - getSubclass().getCenterX());
  int yDiff = Math.abs(getSuperclass().getCenterY() - getSubclass().getCenterY());
  if (xDiff > 2 * yDiff) {
    if (getSuperclass().getStartX() > getSubclass().getEndX()) {
      trianglePosition = Position.LEFT;
      shape.moveTo(getSuperclass().getStartX(), getSuperclass().getCenterY());
      shape.lineTo(getSuperclass().getStartX() - cos30,
        getSuperclass().getCenterY() - sin30);
      shape.lineTo(getSuperclass().getStartX() - cos30,
        getSuperclass().getCenterY() - sinNeg30);
      shape.lineTo(getSuperclass().getStartX(), getSuperclass().getCenterY());
    } else if (getSuperclass().getEndX() < getSubclass().getStartX()) {
      trianglePosition = Position.RIGHT;
      shape.moveTo(getSuperclass().getEndX(), getSuperclass().getCenterY());
      shape.lineTo(getSuperclass().getEndX() + cos30,
        getSuperclass().getCenterY() + sin30);
      shape.lineTo(getSuperclass().getEndX() + cos30,
        getSuperclass().getCenterY() + sinNeg30);
      shape.lineTo(getSuperclass().getEndX(), getSuperclass().getCenterY());
    }
  } else {
    if (getSuperclass().getStartY() > getSubclass().getEndY()) {
      trianglePosition = Position.TOP;
      shape.moveTo(getSuperclass().getCenterX(), getSuperclass().getStartY());
      shape.lineTo(getSuperclass().getCenterX() - sin30,
        getSuperclass().getStartY() - cos30);// 30°
      shape.lineTo(getSuperclass().getCenterX() - sinNeg30,
        getSuperclass().getStartY() - cosNeg30);// 30°
      shape.lineTo(getSuperclass().getCenterX(), getSuperclass().getStartY());
    } else {
      trianglePosition = Position.BOTTOM;
      shape.moveTo(getSuperclass().getCenterX(), getSuperclass().getEndY());
      shape.lineTo(getSuperclass().getCenterX() + sin30,
        getSuperclass().getEndY() + cos30);// 30°
      shape.lineTo(getSuperclass().getCenterX() + sinNeg30,
        getSuperclass().getEndY() + cosNeg30);// 30°
      shape.lineTo(getSuperclass().getCenterX(), getSuperclass().getEndY());
    }
  }
  try {
    shape.closePath();
  } catch (IllegalPathStateException e) {
    return super.getShape();
  }
  shape.append(super.getShape(), false);
  return shape;
}
 
开发者ID:onprom,项目名称:onprom,代码行数:51,代码来源:Inheritance.java

示例14: addMove

import java.awt.geom.Path2D; //导入方法依赖的package包/类
static Path2D addMove(Path2D p2d) {
    p2d.moveTo(1.0, 0.5);
    return p2d;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:Path2DCopyConstructor.java

示例15: addMove

import java.awt.geom.Path2D; //导入方法依赖的package包/类
static void addMove(Path2D p2d, int i) {
    p2d.moveTo(1.0 * i, 0.5 * i);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:4,代码来源:Path2DGrow.java


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