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

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

源代码1 项目: consulo   文件: LinePainter2D.java
/**
 * Fills a polygon.
 *
 * @param g           the graphics
 * @param xPoints     the x polygon points
 * @param yPoints     the y polygon points
 * @param nPoints     the number of points
 * @param strokeType  the stroke type
 * @param strokeWidth the stroke width
 * @param valueAA     overrides current {@link RenderingHints#KEY_ANTIALIASING} to {@code valueAA}
 */
public static void fillPolygon(@Nonnull final Graphics2D g, double[] xPoints, double[] yPoints, int nPoints, StrokeType strokeType, double strokeWidth, @Nonnull Object valueAA) {
  // [tav] todo: mind strokeWidth and strokeType
  final Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
  path.moveTo(xPoints[0], yPoints[0]);
  for (int p = 1; p < nPoints; p++) {
    path.lineTo(xPoints[p], yPoints[p]);
  }
  path.closePath();
  PaintUtil.paintWithAA(g, valueAA, new Runnable() {
    @Override
    public void run() {
      g.fill(path);
    }
  });
}
 
源代码2 项目: MesquiteCore   文件: UnrootedTree.java
public Path2D nodePoly(int node) {
	int offset = (getNodeWidth()-getEdgeWidth())/2;
	int halfNodeWidth = getNodeWidth()/2;
	double startX =0;
	double startY =0;
		startX = x[node];
		startY= y[node]-offset;

	Path2D poly = new Path2D.Double();
	poly.moveTo(startX,startY);
	poly.lineTo(startX+halfNodeWidth,startY+halfNodeWidth);
	poly.lineTo(startX,startY+getNodeWidth());
	poly.lineTo(startX-halfNodeWidth,startY+halfNodeWidth);
	poly.lineTo(startX,startY);
	return poly;
}
 
源代码3 项目: Pixelitor   文件: Lissajous.java
@Override
protected Path2D createShape(int width, int height) {
    Path2D shape = new Path2D.Double();

    double cx = width * center.getRelativeX();
    double cy = height * center.getRelativeY();

    double aVal = a.getValueAsDouble();
    double bVal = b.getValueAsDouble();

    double w = width / 2.0;
    double h = height / 2.0;
    double dt = 2 * Math.PI / NUMBER_OF_STEPS;

    shape.moveTo(cx, cy);
    for (double t = 0; t < 2 * Math.PI; t += dt) {
        double x = w * FastMath.sin(aVal * t) + cx;
        double y = h * FastMath.sin(bVal * t) + cy;
        shape.lineTo(x, y);
    }
    shape.closePath();

    return shape;
}
 
源代码4 项目: audiveris   文件: AbstractBeamInter.java
/**
 * Define lookup area around the beam for potential stems
 *
 * @return the look up area
 */
private Area getLookupArea (Scale scale)
{
    final Line2D top = getBorder(VerticalSide.TOP);
    final Line2D bottom = getBorder(VerticalSide.BOTTOM);
    final int xOut = scale.toPixels(BeamStemRelation.getXOutGapMaximum(manual));
    final int yGap = scale.toPixels(BeamStemRelation.getYGapMaximum(manual));

    final Path2D lu = new Path2D.Double();
    double xMin = top.getX1() - xOut;
    double xMax = top.getX2() + xOut;
    Point2D topLeft = LineUtil.intersectionAtX(top, xMin);
    lu.moveTo(topLeft.getX(), topLeft.getY() - yGap);

    Point2D topRight = LineUtil.intersectionAtX(top, xMax);
    lu.lineTo(topRight.getX(), topRight.getY() - yGap);

    Point2D bottomRight = LineUtil.intersectionAtX(bottom, xMax);
    lu.lineTo(bottomRight.getX(), bottomRight.getY() + yGap);

    Point2D bottomLeft = LineUtil.intersectionAtX(bottom, xMin);
    lu.lineTo(bottomLeft.getX(), bottomLeft.getY() + yGap);
    lu.closePath();

    return new Area(lu);
}
 
源代码5 项目: rcrs-server   文件: CollapseSimulator.java
private java.awt.geom.Area areaToGeomArea(
		rescuecore2.standard.entities.Area area) {
	Path2D result = new Path2D.Double();
	Iterator<Edge> it = area.getEdges().iterator();
	Edge e = it.next();
	result.moveTo(e.getStartX(), e.getStartY());
	result.lineTo(e.getEndX(), e.getEndY());
	while (it.hasNext()) {
		e = it.next();
		result.lineTo(e.getEndX(), e.getEndY());
	}
	return new java.awt.geom.Area(result);
}
 
源代码6 项目: workcraft   文件: ConnectionTool.java
@Override
public void drawInUserSpace(GraphEditor editor, Graphics2D g) {
    if ((firstNode != null) && (currentPoint != null)) {
        g.setStroke(new BasicStroke((float) editor.getViewport().pixelSizeInUserSpace().getX()));
        Path2D path = new Path2D.Double();
        path.moveTo(firstPoint.getX(), firstPoint.getY());
        for (Point2D point : controlPoints) {
            path.lineTo(point.getX(), point.getY());
        }
        path.lineTo(currentPoint.getX(), currentPoint.getY());
        if (currentNode == null) {
            g.setColor(incompleteConnectionColor);
            g.draw(path);
        } else {
            try {
                VisualModel model = editor.getModel();
                if (directedArcs) {
                    model.validateConnection(firstNode, currentNode);
                } else {
                    model.validateUndirectedConnection(firstNode, currentNode);
                }
                g.setColor(validConnectionColor);
                g.draw(path);
            } catch (InvalidConnectionException e) {
                showIssue(editor, e.getMessage());
                g.setColor(invalidConnectionColor);
                g.draw(path);
            }
        }
    }
}
 
源代码7 项目: FlatLaf   文件: FlatUIUtils.java
/**
 * Creates a open or closed path for the given points.
 */
public static Path2D createPath( boolean close, double... points ) {
	Path2D path = new Path2D.Float();
	path.moveTo( points[0], points[1] );
	for( int i = 2; i < points.length; i += 2 )
		path.lineTo( points[i], points[i + 1] );
	if( close )
		path.closePath();
	return path;
}
 
源代码8 项目: workcraft   文件: VisualEntryEvent.java
@Override
public Shape getShape() {
    double size = VisualCommonSettings.getNodeSize();
    double w2 = 0.04 * size;
    double s2 = 0.25 * size;
    Path2D shape = new Path2D.Double();
    shape.moveTo(0.0 - w2, +s2);
    shape.lineTo(0.0 + w2, +s2);
    shape.lineTo(0.0 + w2, -s2);
    shape.lineTo(0.0 - w2, -s2);
    return shape;
}
 
源代码9 项目: Forsythia   文件: GridOverlayPainter.java
private Path2D getPath2D(List<DPoint> points){
Path2D path2d=new Path2D.Double();
DPoint p=points.get(0);
path2d.moveTo(p.x,p.y);
int s=points.size();
for(int i=1;i<s;i++){
  p=points.get(i);
  path2d.lineTo(p.x,p.y);}
return path2d;}
 
源代码10 项目: flutter-intellij   文件: FrameRenderingDisplay.java
@Override
protected void paintComponent(Graphics g) {
  super.paintComponent(g);

  final Rectangle bounds = getBounds();
  final int height = bounds.height;

  if (height <= 20) {
    return;
  }

  final Graphics2D g2 = (Graphics2D)g;

  final float msPerPixel = (2.0f * 1000000.0f / 60.0f) / height;
  final float y = displayRefreshRateManager.getTargetMicrosPerFrame() / msPerPixel;
  final Stroke oldStroke = g2.getStroke();
  try {
    g2.setStroke(STROKE);
    final Path2D path = new Path2D.Float();
    // Slight left indent to allow space for [targetFrameTimeLabel].
    path.moveTo(34, height - y);
    path.lineTo(bounds.width, height - y);
    g2.draw(path);
  }
  finally {
    g2.setStroke(oldStroke);
  }
}
 
private void renderBracket(double[] pt0,double[] pt1){
  double 
    dforeward=GD.getDirection_PointPoint(pt0[0],pt0[1],pt1[0],pt1[1]),
    dbackward=GD.normalizeDirection(dforeward-GD.PI),
    dout=GD.normalizeDirection(dforeward+GD.HALFPI);
  double[] 
    b0p0=GD.getPoint_PointDirectionInterval(pt0[0],pt0[1],dout,FISHBRACKETOFFSET),
    b0p1=GD.getPoint_PointDirectionInterval(b0p0[0],b0p0[1],dout,FISHBRACKETSPAN0),
    b0p2=GD.getPoint_PointDirectionInterval(b0p1[0],b0p1[1],dforeward,FISHBRACKETSPAN1),
    b1p0=GD.getPoint_PointDirectionInterval(pt1[0],pt1[1],dout,FISHBRACKETOFFSET),
    b1p1=GD.getPoint_PointDirectionInterval(b1p0[0],b1p0[1],dout,FISHBRACKETSPAN0),
    b1p2=GD.getPoint_PointDirectionInterval(b1p1[0],b1p1[1],dbackward,FISHBRACKETSPAN1);
  //
  graphics.setStroke(createStroke(STROKETHICKNESS2*imagescale));
  Path2D path=new Path2D.Double();
  path.moveTo(b0p0[0],b0p0[1]);
  path.lineTo(b0p1[0],b0p1[1]);
  path.lineTo(b0p2[0],b0p2[1]);
  graphics.draw(path);
  path=new Path2D.Double();
  path.moveTo(b1p0[0],b1p0[1]);
  path.lineTo(b1p1[0],b1p1[1]);
  path.lineTo(b1p2[0],b1p2[1]);
  graphics.draw(path);
  
  
  
}
 
源代码12 项目: ET_Redux   文件: AbstractRawDataView.java
/**
 *
 * @param g2d
 */
protected void paintFractionExcludedColor(Graphics2D g2d) {
    Paint savePaint = g2d.getPaint();
    Path2D excludedFractionLine = new Path2D.Double();
    excludedFractionLine.moveTo(mapX(shiftAquiredTimeIndex + myOnPeakNormalizedAquireTimes[0]), mapY(myOnPeakData[0]));
    for (int i = 0; i < myOnPeakData.length; i++) {
        excludedFractionLine.lineTo(mapX(shiftAquiredTimeIndex + myOnPeakNormalizedAquireTimes[i]), mapY(myOnPeakData[i]));
    }
    g2d.setPaint(EXCLUDED_COLOR);
    g2d.draw(excludedFractionLine);
    g2d.setPaint(savePaint);
}
 
源代码13 项目: javaGeom   文件: GeneralPath2D.java
public void updatePath(Path2D path) {
	path.lineTo(p.x(), p.y());
}
 
源代码14 项目: ET_Redux   文件: KwikiDateSensitivityPanel.java
private void DrawDateBars(
            ValueModel[] dates,
            Graphics2D g2d,
            double rangeX,
            double rangeY,
            int offset,
            Color borderColor,
            Color fillColor) {

        int barWidth = 10;


        for (int i = 0; i < dates.length; i++) {
            if (getShowDates()[i]) {
                int bottomBar = offset + 44 - i * 22;

                double lowerDate = //
                        dates[i].getValue().//
                        subtract(new BigDecimal(2.0).//
                        multiply(dates[i].getOneSigmaAbs())).//
                        movePointLeft(6).doubleValue();

                double upperDate = //
                        dates[i].getValue().//
                        add(new BigDecimal(2.0).//
                        multiply(dates[i].getOneSigmaAbs())).//
                        movePointLeft(6).doubleValue();

                double twoSigma = //
                        new BigDecimal(2.0).//
                        multiply(dates[i].getOneSigmaAbs()).//
                        movePointLeft(6).doubleValue();

                g2d.setStroke(new BasicStroke(1f));

                Path2D origDateLow = new Path2D.Double (Path2D.WIND_NON_ZERO);
                Path2D origDateHigh = new Path2D.Double (Path2D.WIND_NON_ZERO);

                // lower left
                origDateLow.moveTo(//
                        (float) MapX(lowerDate, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar, getMaxY(), rangeY, getHeight()));
                origDateLow.lineTo(//
                        (float) MapX(lowerDate + twoSigma, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar, getMaxY(), rangeY, getHeight()));
                origDateLow.lineTo(//
                        (float) MapX(lowerDate + twoSigma, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar + barWidth, getMaxY(), rangeY, getHeight()));
                origDateLow.lineTo(//
                        (float) MapX(lowerDate, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar + barWidth, getMaxY(), rangeY, getHeight()));
                origDateLow.closePath();
                g2d.setColor(fillColor);//lightRed);
                g2d.fill(origDateLow);

                // lower left
                origDateHigh.moveTo(//
                        (float) MapX(lowerDate + twoSigma, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar, getMaxY(), rangeY, getHeight()));
                origDateHigh.lineTo(//
                        (float) MapX(upperDate, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar, getMaxY(), rangeY, getHeight()));
                origDateHigh.lineTo(//
                        (float) MapX(upperDate, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar + barWidth, getMaxY(), rangeY, getHeight()));
                origDateHigh.lineTo(//
                        (float) MapX(lowerDate + twoSigma, getMinX(), rangeX, getWidth()),
                        (float) MapY(bottomBar + barWidth, getMaxY(), rangeY, getHeight()));
                origDateHigh.closePath();
                g2d.setColor(fillColor);//lightGreen);
                g2d.fill(origDateHigh);

                g2d.setColor(borderColor);
                g2d.draw(origDateLow);
                g2d.draw(origDateHigh);

                // draw date string
//                String dateString =//
//                        dates[i].formatValueAndTwoSigmaForPublicationSigDigMode(//
//                        dates[i].getUncertaintyType(),
//                        -6, 2);
//
//                g2d.setFont(new Font("Monospaced", Font.BOLD, 10));
//
//                g2d.drawString(
//                        dateString,
//                        (float) MapX(lowerDate + twoSigma, getMinX(), rangeX, getWidth()) - 20f,
//                        (float) MapY(bottomBar, getMaxY(), rangeY, getHeight()) - 1f);

            }
        }
    }
 
源代码15 项目: mil-sym-java   文件: Ellipse.java
public ArrayList<GeoPoint>getEllipsePoints()
      {
GeoEllipse e = new GeoEllipse(pivot, _semiMajor * 2, _semiMinor * 2, maxDistanceMeters,
		flatnessDistanceMeters, limit);
              
              float[] coords = new float[2];
              int type=0;
              POINT2 pt0=new POINT2(pivot.x,pivot.y),pt=null;
              POINT2 pt1=null;
              double R=0;
              ref<double[]> a12 = new ref(), a21 = new ref();
              double x=0,y=0,x1=0,y1=0;
              //test arbitray rotation angle                
              double rotation=_rotation;
              //navigation is clockwise from 0. 0 is true north
              rotation=90-rotation;
              //if(rotation == 0 || _semiMajor==_semiMinor)
                  //return e;                
              ArrayList<GeoPoint>pts=new ArrayList();
              for (PathIterator i = e.getPathIterator(null); !i.isDone(); i.next()) {
                  type = i.currentSegment(coords);
                  pt1=new POINT2(coords[0],coords[1]);
                  R=mdlGeodesic.geodesic_distance(pt0, pt1, a12, a21);
                  //x=R*Math.cos(a12.value[0]*Math.PI/180d);
                  //y=R*Math.sin(a12.value[0]*Math.PI/180d);                  
                  //rotate the points
                  //x1=x*Math.cos(rotation*Math.PI/180d)-y*Math.sin(rotation*Math.PI/180d);
                  //y1=x*Math.sin(rotation*Math.PI/180d)+y*Math.cos(rotation*Math.PI/180d);
                  if(!(_semiMajor == _semiMinor))
                      pt=mdlGeodesic.geodesic_coordinate(pt0, R, a12.value[0]-rotation);
                  else
                      pt=pt1;
                  pts.add(new GeoPoint(pt.x,pt.y));                    
              }
              //clear the path
              Path2D path=e.getPath();
              path.reset();
              //rebuild the path with the rotated points
              for(int j=0;j<pts.size();j++)
              {
                  x=pts.get(j).x;
                  y=pts.get(j).y;
                  if(j==0)
                      path.moveTo(x, y);
                  else
                      path.lineTo(x, y);
              }
return pts;            
      }
 
源代码16 项目: TencentKona-8   文件: Path2DCopyConstructor.java
static Path2D addLines(Path2D p2d) {
    for (int i = 0; i < 10; i++) {
        p2d.lineTo(1.1 * i, 2.3 * i);
    }
    return p2d;
}
 
源代码17 项目: TencentKona-8   文件: Path2DGrow.java
static void addLine(Path2D p2d, int i) {
    p2d.lineTo(1.1 * i, 2.3 * i);
}
 
源代码18 项目: ET_Redux   文件: RawCountsDataViewForShrimp.java
/**
 *
 * @param g2d
 */
@Override
public void paint(Graphics2D g2d) {
    super.paint(g2d);

    Path2D pointTrace = new Path2D.Double(Path2D.WIND_NON_ZERO);
    pointTrace.moveTo(mapX(myOnPeakNormalizedAquireTimes[0]), mapY(myOnPeakData[0]));
    for (int i = 0; i < myOnPeakData.length; i++) {
        // line tracing through points
        pointTrace.lineTo(mapX(myOnPeakNormalizedAquireTimes[i]), mapY(myOnPeakData[i]));
        g2d.setStroke(new BasicStroke(0.5f));
        g2d.setPaint(determineDataColor(i, Color.GRAY));
        g2d.draw(pointTrace);

        Shape intensity = new java.awt.geom.Ellipse2D.Double( //
                mapX(myOnPeakNormalizedAquireTimes[i]) - 1, mapY(myOnPeakData[i]) - 1, 2, 2);
        g2d.setStroke(new BasicStroke(1.5f));
        g2d.setPaint(determineDataColor(i, Color.black));
        g2d.draw(intensity);

        // uncertainty
        Shape plusMinusOneSigma = new Line2D.Double(//
                mapX(myOnPeakNormalizedAquireTimes[i]),// 
                mapY(myOnPeakData[i] - myOnPeakOneSigmas[i]),//
                mapX(myOnPeakNormalizedAquireTimes[i]),// 
                mapY(myOnPeakData[i] + myOnPeakOneSigmas[i]));
        g2d.setStroke(new BasicStroke(1.0f));
        g2d.draw(plusMinusOneSigma);

        // tips of uncertainty
        Shape plusOneSigmaTip = new Line2D.Double(//
                mapX(myOnPeakNormalizedAquireTimes[i]) - 1,// 
                mapY(myOnPeakData[i] + myOnPeakOneSigmas[i]),//
                mapX(myOnPeakNormalizedAquireTimes[i]) + 1,// 
                mapY(myOnPeakData[i] + myOnPeakOneSigmas[i]));

        Shape minusOneSigmaTip = new Line2D.Double(//
                mapX(myOnPeakNormalizedAquireTimes[i]) - 1,// 
                mapY(myOnPeakData[i] - myOnPeakOneSigmas[i]),//
                mapX(myOnPeakNormalizedAquireTimes[i]) + 1,// 
                mapY(myOnPeakData[i] - myOnPeakOneSigmas[i]));

        g2d.setStroke(new BasicStroke(1.0f));
        g2d.draw(plusOneSigmaTip);
        g2d.draw(minusOneSigmaTip);

    }
}
 
源代码19 项目: jdk8u60   文件: Path2DCopyConstructor.java
static Path2D addLines(Path2D p2d) {
    for (int i = 0; i < 10; i++) {
        p2d.lineTo(1.1 * i, 2.3 * i);
    }
    return p2d;
}
 
源代码20 项目: jasperreports   文件: AbstractShapeCustomizer.java
/**
 * Uses the points to build a polyline
 * 
 * @param baseShape the points of the polyline
 * @return a polyline shape or null if it can't be build from the current configuration
 */
protected Shape buildPolyline(ShapePoints baseShape)
{
	Path2D path = null;
	List<Point> points = baseShape.getPoints();
	if (points != null && !points.isEmpty())
	{
		float scaleFactorX = 1.0f;
		float scaleFactorY = 1.0f;

		Rectangle2D bounds = getBounds(baseShape);
		Integer width = getWidth();
		Integer height = getHeight();
		if (width != null) {
			scaleFactorX = (float)(width / bounds.getWidth());
		}
		if (height != null) {
			scaleFactorY = (float)(height / bounds.getHeight());
		}

		path = new Path2D.Double();

		if (points.size() > 1)
		{
			Point offset = getOffset(bounds);
			Point point = points.get(0);

			path.moveTo(
				(point.getX() - offset.getX()) * scaleFactorX, 
				(point.getY() - offset.getY()) * scaleFactorY
				);
			for (int i = 1; i < points.size(); i++)
			{
				point = points.get(i);
				path.lineTo(
					(point.getX() - offset.getX()) * scaleFactorX, 
					(point.getY() - offset.getY()) * scaleFactorY
					);
			}
		}
	}
	return path;
}