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


Java CubicCurve2D.Double方法代码示例

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


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

示例1: chopStart

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/** Chop the start of this curve. */
public void chopStart(double t) {
	int n = list.size();
	t = t * n;
	double di = StrictMath.floor(t);
	int i = (int) di;
	//
	if (i < 0)
		return;
	if (i >= n)
		list.clear();
	while (i > 0 && !list.isEmpty()) {
		list.remove(0);
		i--;
	}
	if (list.isEmpty()) {
		list.add(new CubicCurve2D.Double(startX = endX, startY = endY, endX, endY, endX, endY, endX, endY));
		return;
	}
	CubicCurve2D.Double tmp = new CubicCurve2D.Double();
	divide(t - di, list.get(0), new CubicCurve2D.Double(), tmp);
	list.get(0).setCurve(tmp);
	startX = tmp.x1;
	startY = tmp.y1;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:Curve.java

示例2: drawSmoothly

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/** Draws the given curve smoothly (assuming the curve is monotonic vertically) */
public void drawSmoothly(Curve curve) {
    final int smooth=15;
    double cx=0, cy=0, slope;
    for(int n=curve.list.size(), i=0; i<n; i++) {
        CubicCurve2D.Double c=new CubicCurve2D.Double(), c2=(i+1<n)?curve.list.get(i+1):null;
        c.setCurve(curve.list.get(i));
        if (i>0) { c.ctrlx1=cx; c.ctrly1=cy; }
        if (c2==null) { draw(c,false); return; }
        if ((c.x1<c.x2 && c2.x2<c2.x1) || (c.x1>c.x2 && c2.x2>c2.x1)) slope=0; else slope=(c2.x2-c.x1)/(c2.y2-c.y1);
        double tmp=c.y2-smooth, tmpx=c.x2-smooth*slope;
        if (tmp>c.ctrly1 && tmp<c.y2 && in(c.x1, tmpx, c.x2)) { c.ctrly2=tmp; c.ctrlx2=tmpx; }
        double tmp2=c2.y1+smooth, tmp2x=c2.x1+smooth*slope;
        if (tmp2>c2.y1 && tmp2<c2.ctrly2 && in(c2.x1, tmp2x, c2.x2)) { cy=tmp2; cx=tmp2x; } else { cy=c2.ctrly1; cx=c2.ctrlx1; }
        draw(c,false);
    }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:Artist.java

示例3: divide

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/**
 * Given 0<=t<=1 and an existing curve, divide it into two chunks and store
 * the two chunks into "first" and "second"
 */
public static void divide(double t, CubicCurve2D.Double curve, CubicCurve2D.Double first,
		CubicCurve2D.Double second) {
	// This algorithm uses de Casteljau's algorithm for chopping one bezier
	// curve into two bezier curves
	first.x1 = curve.x1;
	second.x2 = curve.x2;
	first.ctrlx1 = (1 - t) * curve.x1 + t * curve.ctrlx1;
	double x = (1 - t) * curve.ctrlx1 + t * curve.ctrlx2;
	second.ctrlx2 = (1 - t) * curve.ctrlx2 + t * curve.x2;
	first.ctrlx2 = (1 - t) * first.ctrlx1 + t * x;
	second.ctrlx1 = (1 - t) * x + t * second.ctrlx2;
	second.x1 = first.x2 = (1 - t) * first.ctrlx2 + t * second.ctrlx1;
	// now that we've computed the x coordinates, we now compute the y
	// coordinates
	first.y1 = curve.y1;
	second.y2 = curve.y2;
	first.ctrly1 = (1 - t) * curve.y1 + t * curve.ctrly1;
	double y = (1 - t) * curve.ctrly1 + t * curve.ctrly2;
	second.ctrly2 = (1 - t) * curve.ctrly2 + t * curve.y2;
	first.ctrly2 = (1 - t) * first.ctrly1 + t * y;
	second.ctrly1 = (1 - t) * y + t * second.ctrly2;
	second.y1 = first.y2 = (1 - t) * first.ctrly2 + t * second.ctrly1;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:28,代码来源:Curve.java

示例4: chopEnd

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/** Chop the end of this curve. */
public void chopEnd(double t) {
    int n=list.size();
    t=t*n;
    double di=StrictMath.floor(t);
    int i=(int)di;
    //
    if (i<0) list.clear();
    if (i>=n) return;
    while(i+1<list.size()) list.remove(i+1);
    if (list.isEmpty()) { endX=startX; endY=startY; list.add(new CubicCurve2D.Double(endX,endY, endX,endY, endX,endY, endX,endY)); return; }
    CubicCurve2D.Double tmp=new CubicCurve2D.Double();
    divide(t-di, list.get(i), tmp, new CubicCurve2D.Double());
    list.get(i).setCurve(tmp);
    endX=tmp.x2;
    endY=tmp.y2;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:Curve.java

示例5: test_drawCubicCurve

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/**
 * Draws random cubic curves within the given dimensions.
 *
 * @param g The Graphics2D object that is used to paint.
 * @param size The size of the canvas.
 */
private void test_drawCubicCurve(Graphics2D g, Dimension size)
{
  int maxTests = testSize;
  int minSize = 10;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < maxTests; i += 1)
    {
      setRandom(g, size);
      int x1 = (int) (Math.random() * (size.width - minSize));
      int y1 = (int) (Math.random() * (size.height - minSize));
      int xc1 = (int) (Math.random() * (size.width - minSize));
      int yc1 = (int) (Math.random() * (size.height - minSize));
      int xc2 = (int) (Math.random() * (size.width - minSize));
      int yc2 = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

      CubicCurve2D curve = new CubicCurve2D.Double(x1, y1, xc1, yc1, xc2,
                                                   yc2, x2, y2);
      g.draw(curve);
    }
  long endTime = System.currentTimeMillis();
  recordTest("draw(CubicCurve2D.Double) " + maxTests + " times",
             (endTime - startTime));
}
 
开发者ID:vilie,项目名称:javify,代码行数:32,代码来源:J2dBenchmark.java

示例6: paint

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
@Override
protected void paint (Graphics2D g,
                      Params p,
                      Point location,
                      Alignment alignment)
{
    Point loc = alignment.translatedPoint(TOP_LEFT, p.rect, location);

    CubicCurve2D curve = new CubicCurve2D.Double(
            loc.x,
            loc.y + p.rect.height,
            loc.x + ((3 * p.rect.width) / 10),
            loc.y + (p.rect.height / 5),
            loc.x + (p.rect.width / 2),
            loc.y,
            loc.x + p.rect.width,
            loc.y);

    // Slur
    g.draw(curve);
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:22,代码来源:SlurSymbol.java

示例7: test_drawCubicCurve

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/**
 * Draws random cubic curves within the given dimensions.
 * 
 * @param g The Graphics2D object that is used to paint.
 * @param size The size of the canvas.
 */
private void test_drawCubicCurve(Graphics2D g, Dimension size)
{
  int maxTests = testSize;
  int minSize = 10;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < maxTests; i += 1)
    {
      setRandom(g, size);
      int x1 = (int) (Math.random() * (size.width - minSize));
      int y1 = (int) (Math.random() * (size.height - minSize));
      int xc1 = (int) (Math.random() * (size.width - minSize));
      int yc1 = (int) (Math.random() * (size.height - minSize));
      int xc2 = (int) (Math.random() * (size.width - minSize));
      int yc2 = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

      CubicCurve2D curve = new CubicCurve2D.Double(x1, y1, xc1, yc1, xc2,
                                                   yc2, x2, y2);
      g.draw(curve);
    }
  long endTime = System.currentTimeMillis();
  recordTest("draw(CubicCurve2D.Double) " + maxTests + " times",
             (endTime - startTime));
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:32,代码来源:J2dBenchmark.java

示例8: getCurveAt

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
public CubicCurve2D getCurveAt(int i){
	if (i < 0 || i >= N() - 1 ) throw 
	new IndexOutOfBoundsException(
			 String.format("Interpolation Class: cannot " +
			 		       "retrieve curve with index : %d" , i));
	CubicCurve2D.Double cubic = new CubicCurve2D.Double(
												  get(i).getX(),
												  get(i).getY(),
												  cP[2*i].getX(),
												  cP[2*i].getY(),
												  cP[2*i+1].getX(),
												  cP[2*i+1].getY(), 
							                      get(i+1).getX(), 
							                      get(i+1).getY());
	return cubic;
}
 
开发者ID:asolis,项目名称:curveFitting,代码行数:17,代码来源:Interpolation.java

示例9: getCurves

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
public ArrayList<Shape> getCurves(){
	  ArrayList<Shape> s = new ArrayList<Shape>();
	
	  for (int i = 0; i < N()-1; i++)
	  {        	
		  CubicCurve2D.Double cubic = new CubicCurve2D.Double(get(i).getX(),
				  											  get(i).getY(),
				  											  cP[2*i].getX(),
															  cP[2*i].getY(),
															  cP[2*i+1].getX(),
															  cP[2*i+1].getY(), 
				                                              get(i+1).getX(), 
				                                              get(i+1).getY());
		  s.add(cubic);
	  }	    	  
        
      return s;
}
 
开发者ID:asolis,项目名称:curveFitting,代码行数:19,代码来源:Interpolation.java

示例10: manageRect

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
private DotPath manageRect(Rectangle2D start, Rectangle2D end) {
	final List<CubicCurve2D.Double> list = new ArrayList<CubicCurve2D.Double>(this.beziers);
	while (true) {
		if (BezierUtils.isCutting(list.get(0), start) == false) {
			throw new IllegalStateException();
		}
		if (BezierUtils.dist(list.get(0)) <= 1.0) {
			break;
		}
		final CubicCurve2D.Double left = new CubicCurve2D.Double();
		final CubicCurve2D.Double right = new CubicCurve2D.Double();
		list.get(0).subdivide(left, right);
		list.set(0, left);
		list.add(1, right);
		if (BezierUtils.isCutting(list.get(1), start)) {
			list.remove(0);
		}
	}
	return new DotPath(list);
}
 
开发者ID:Banno,项目名称:sbt-plantuml-plugin,代码行数:21,代码来源:DotPath.java

示例11: dup

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/** Make a deep copy of this Curve object. */
public Curve dup() {
	Curve ans = new Curve(startX, startY);
	ans.endX = endX;
	ans.endY = endY;
	for (CubicCurve2D.Double x : list) {
		CubicCurve2D.Double c = new CubicCurve2D.Double();
		c.setCurve(x);
		ans.list.add(c);
	}
	return ans;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:13,代码来源:Curve.java

示例12: getRegiao

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
@Override
public Shape getRegiao() {
    if (Regiao == null) {
        final int v1 = getHeight() / 3;
        final int h1 = getWidth() / 2;
        final int repo = v1 / 3;
        final int L = getLeft();
        final int T = getTop();
        final int TH = T + getHeight() - repo;
        final int LW = L + getWidth();

        CubicCurve2D c = new CubicCurve2D.Double();
        c.setCurve(LW, TH, LW - h1, TH - v1, L + h1, TH + v1, L, TH);
        CubicCurve2D c2 = new CubicCurve2D.Double();
        int v2 = v1 / 3;
        c2.setCurve(L, T + v2, L + h1, T + v1 + v2, LW - h1, T - v1 + v2, LW, T + v2);

        GeneralPath pa = new GeneralPath();
        pa.setWindingRule(GeneralPath.WIND_EVEN_ODD);
        pa.append(c2, true);
        pa.lineTo(LW, TH);
        pa.append(c, true);
        pa.lineTo(L,  T + v2);
        pa.closePath();
        
        Regiao = pa;
        int ptToMove = 3;
        this.reposicionePonto[ptToMove] = new Point(0, -repo);
        ptsToMove[ptToMove] = 1;
        ptToMove = 1;
        this.reposicionePonto[ptToMove] = new Point(0, repo);
        ptsToMove[ptToMove] = 1;
    }
    return Regiao;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:36,代码来源:FluxNota.java

示例13: dup

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
/** Make a deep copy of this Curve object. */
public Curve dup() {
    Curve ans = new Curve(startX, startY);
    ans.endX = endX;
    ans.endY = endY;
    for(CubicCurve2D.Double x:list) {
        CubicCurve2D.Double c = new CubicCurve2D.Double();
        c.setCurve(x);
        ans.list.add(c);
    }
    return ans;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:13,代码来源:Curve.java

示例14: getRegiaoNota

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
public Shape getRegiaoNota() {
    if (Regiao == null) {
        final int v1 = getHeight() / 3;
        final int h1 = getWidth() / 2;
        final int repo = v1 / 3;
        final int L = getLeft();
        final int T = getTop();
        final int TH = T + getHeight() - repo;
        final int LW = L + getWidth();
        CubicCurve2D c = new CubicCurve2D.Double();
        c.setCurve(LW, TH, LW - h1, TH - v1, L + h1, TH + v1, L, TH);
        CubicCurve2D c2 = new CubicCurve2D.Double();
        int v2 = v1 / 3;
        c2.setCurve(L, T + v2, L + h1, T + v1 + v2, LW - h1, T - v1 + v2, LW, T + v2);

        GeneralPath pa = new GeneralPath();
        pa.setWindingRule(GeneralPath.WIND_EVEN_ODD);
        pa.append(c2, true);
        pa.lineTo(LW, TH);
        pa.append(c, true);
        pa.lineTo(L,  T + v2);
        pa.closePath();

        Regiao = pa;
        int ptToMove = 3;
        this.reposicionePonto[ptToMove] = new Point(0, -repo);
        ptsToMove[ptToMove] = 1;
        ptToMove = 1;
        this.reposicionePonto[ptToMove] = new Point(0, repo);
        ptsToMove[ptToMove] = 1;
    }
    return Regiao;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:34,代码来源:LivreBase.java

示例15: main

import java.awt.geom.CubicCurve2D; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    CubicCurve2D c = new CubicCurve2D.Double(50.0, 300.0,
                                             150.0, 166.6666717529297,
                                             238.0, 456.66668701171875,
                                             350.0, 300.0);
    Rectangle2D r = new Rectangle2D.Double(260, 300, 10, 10);

    if (!c.intersects(r)) {
        throw new Exception("The rectangle is contained. " +
                            "intersects(Rectangle2D) should return true");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:IntersectsTest.java


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