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


Java QuadCurve2D类代码示例

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


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

示例1: createTopTabShape

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
 * Creates the shape for a top tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rTop
 * @param addBottom
 *            if {@code false}, the bottom line below the tab will not be added to the shape
 * @return
 */
private static Path2D createTopTabShape(int x, int y, int w, int h, double rTop, boolean addBottom) {
	Path2D path = new Path2D.Double();
	path.append(new Line2D.Double(x, y + h - 1, x, y + rTop), true);

	QuadCurve2D curve = new QuadCurve2D.Double(x, y + rTop, x, y, x + rTop, y);
	path.append(curve, true);

	path.append(new Line2D.Double(x + rTop, y, x + w - rTop, y), true);

	curve = new QuadCurve2D.Double(x + w - rTop, y, x + w, y, x + w, y + rTop);
	path.append(curve, true);

	path.append(new Line2D.Double(x + w, y + rTop, x + w, y + h), true);

	if (addBottom) {
		path.append(new Line2D.Double(x + w, y + h - 1, x, y + h - 1), true);
	}
	return path;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:32,代码来源:TabbedPaneUI.java

示例2: createLeftTabShape

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
 * Creates the shape for a left tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rLeft
 * @param addSide
 *            if {@code false}, the closing side line right of the tab will not be added to the
 *            shape
 * @return
 */
private static Path2D createLeftTabShape(int x, int y, int w, int h, double rLeft, boolean addSide) {
	Path2D path = new Path2D.Double();
	path.append(new Line2D.Double(x + w, y + h, x + rLeft, y + h), true);

	QuadCurve2D curve = new QuadCurve2D.Double(x + rLeft, y + h, x, y + h, x, y + h - rLeft);
	path.append(curve, true);

	path.append(new Line2D.Double(x, y + h - rLeft, x, y + rLeft), true);

	curve = new QuadCurve2D.Double(x, y + rLeft, x, y, x + rLeft, y);
	path.append(curve, true);

	path.append(new Line2D.Double(x + rLeft, y, x + w, y), true);

	if (addSide) {
		path.append(new Line2D.Double(x + w, y, x + w, y + h - 1), true);
	}
	return path;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:33,代码来源:TabbedPaneUI.java

示例3: contains

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
    * @see ring.gui.vis2.Visel#contains(double, double)
    */
public boolean contains(double x, double y) {
	if (shape instanceof QuadCurve2D) {
		QuadCurve2D curve = (QuadCurve2D) shape;
		
		return (
			Line2D.ptLineDist(
				curve.getX1(),
				curve.getY1(),
				curve.getCtrlX(),
				curve.getCtrlY(),
				x,
				y
			) < 5 || Line2D.ptLineDist(
				curve.getX2(),
				curve.getY2(),
				curve.getCtrlX(),
				curve.getCtrlY(),
				x,
				y
			) < 5
		);
	}
	return shape.contains(new Point2D.Double(x,y));
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:28,代码来源:CurvedLineVisel.java

示例4: getHorizontalParams

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:Order3.java

示例5: createCoulombIcon

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
private static ImageIcon createCoulombIcon( Color color ) {
    final int w = 20;
    final int h = 20;
    BufferedImage bi = new BufferedImage( w, h, BufferedImage.TYPE_INT_ARGB );
    Graphics2D g2 = bi.createGraphics();
    g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    QuadCurve2D curve1 = new QuadCurve2D.Double();
    QuadCurve2D curve2 = new QuadCurve2D.Double();
    curve1.setCurve( 0, 4, 8, 5, 7, 16 );
    curve2.setCurve( 10, 16, 11, 5, 17, 4 );
    g2.setStroke( ICON_STROKE );
    g2.setPaint( color );
    g2.draw( curve1 );
    g2.draw( curve2 );
    return new ImageIcon( bi );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:BSWellComboBox.java

示例6: getHorizontalParams

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
public static int getHorizontalParams(double c0, double cp0,
			double cp1, double c1,
			double ret[]) {
		if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
			return 0;
		}
		c1 -= cp1;
		cp1 -= cp0;
		cp0 -= c0;
		ret[0] = cp0;
		ret[1] = (cp1 - cp0) * 2;
		ret[2] = (c1 - cp1 - cp1 + cp0);
		int numroots = QuadCurve2D.solveQuadratic(ret, ret);
		int j = 0;
		for (int i = 0; i < numroots; i++) {
			double t = ret[i];
//			No splits at t==0 and t==1
			if (t > 0 && t < 1) {
				if (j < i) {
					ret[j] = t;
				}
				j++;
			}
		}
		return j;
	}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:27,代码来源:Order3X.java

示例7: getMinMax

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
private void getMinMax(double p1, double p2,
                       double p3, double p4,
                       double [] minMax) {
    if (p4 > p1){
        minMax[0] = p1; minMax[1] = p4;
    } else {
        minMax[0] = p4; minMax[1] = p1;
    }

    double c0 = 3*(p2-p1);
    double c1 = 6*(p3-p2);
    double c2 = 3*(p4-p3);
    double [] eqn = { c0, c1-2*c0, c2-c1+c0 };
    int roots = QuadCurve2D.solveQuadratic(eqn);
    for (int r=0; r<roots; r++) {
        double tv = eqn[r];
        if ((tv <= 0) || (tv >= 1)) continue;
        tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
                3*tv*(1-tv)*(1-tv)*p2 +
                3*tv*tv*(1-tv)*p3 +
                tv*tv*tv*p4);
        if      (tv < minMax[0]) minMax[0] = tv;
        else if (tv > minMax[1]) minMax[1] = tv;
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:26,代码来源:Cubic.java

示例8: test_drawQuadCurve

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
 * Draws random quadratic 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_drawQuadCurve(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 xc = (int) (Math.random() * (size.width - minSize));
      int yc = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

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

示例9: getDisplacedSegments

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
 * Get the "top" and "bottom" segments of a given segment.
 * First array element is p0 + normal, second is p0 - normal.
 */
public Segment[] getDisplacedSegments(double radius)
{
  this.radius = radius;
  double x0 = P1.getX();
  double y0 = P1.getY();
  double x1 = cp.getX();
  double y1 = cp.getY();
  double x2 = P2.getX();
  double y2 = P2.getY();

  QuadCurve2D left = new QuadCurve2D.Double();
  QuadCurve2D right = new QuadCurve2D.Double();
  QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2);
  orig.subdivide(left, right);

  QuadSegment s1 = offsetSubdivided(left, true);
  QuadSegment s2 = offsetSubdivided(left, false);

  s1.add( offsetSubdivided(right, true) );
  s2.add( offsetSubdivided(right, false) );

  return new Segment[]{s1, s2};
}
 
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:QuadSegment.java

示例10: dibujar

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
 * Implementacion del metodo abstracto de la clase padre. Dibuja la figura
 * en el grafico pasado como parametro.
 *
 * @param g Graphics donde se desea dibujar la figura.
 */
@Override
public void dibujar(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    //Variable que nos sirve para reestablecer la forma original posteriormente
    AffineTransform actual = g2.getTransform();

    //Aplicamos la transformacion del objeto si la tiene
    if (!this.transformaciones.isIdentity()) {
        g2.transform(this.transformaciones);
    }

    QuadCurve2D quad = new QuadCurve2D.Double(this.puntoInicial.x, this.puntoInicial.y, this.ptoControl.x, this.ptoControl.y, this.puntoFinal.x, this.puntoFinal.y);

    g2.setStroke(this.cg.getEstiloLinea());

    //Dibujamos la linea
    g2.setColor(this.cg.getColorLinea());
    g2.draw(quad);

    //Recuperamos la forma original que tenia antes de la transformacion
    g2.setTransform(actual);
}
 
开发者ID:sephierot,项目名称:paintmultimedia,代码行数:30,代码来源:Curva1Dibujable.java

示例11: test_drawQuadCurve

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
/**
 * Draws random quadratic 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_drawQuadCurve(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 xc = (int) (Math.random() * (size.width - minSize));
      int yc = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

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

示例12: getCurvedLine

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
protected QuadCurve2D getCurvedLine(int index) {
  double x1 = from.drawx;
  double x2 = to.drawx;
  double y1 = from.drawy;
  double y2 = to.drawy;
  double midx = calculateMidPointBetween(x1, x2);
  double midy = calculateMidPointBetween(y1, y2);
  
  int weight = index / 2;
  if (index % 2 == 1) {
    weight++;
    weight = -weight;
  }
  Dimension offset = calculateOffset(x1, x2, y1, y2, LOADING * weight);
  QuadCurve2D curve = new QuadCurve2D.Double(x1, y1,
      midx-offset.width, midy+offset.height,
      x2, y2);
  return curve;
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:20,代码来源:TMAbstractEdge.java

示例13: paintClouds

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
private void paintClouds(Graphics2D g, Graphics2D gstroke, double x0,
		double y0, double x1, double y1, double distanceToConvexHull) {
	// System.out.println("double=" + x0+ ", double=" + y0+ ", double=" +
	// x1+ ", double=" + y1);
	double x2, y2, dx, dy;
	dx = x1 - x0;
	dy = y1 - y0;
	double length = Math.sqrt(dx * dx + dy * dy);
	// nothing to do for length zero.
	if (length == 0f)
		return;
	double dxn, dyn;
	dxn = dx / length;
	dyn = dy / length;
	x2 = x0 + .5f * dx - distanceToConvexHull * dyn;
	y2 = y0 + .5f * dy + distanceToConvexHull * dxn;
	// System.out.println("Line from " + x0+ ", " +y0+ ", " +x2+ ", " +y2+
	// ", " +x1+ ", " +y1+".");
	Shape shape = new QuadCurve2D.Double(x0, y0, x2, y2, x1, y1);
	g.fill(shape);
	gstroke.draw(shape);
}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:23,代码来源:CloudView.java

示例14: findCubicZeros

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
private static int findCubicZeros(double zeros[], double cur, double cp0,
		double cp1, double end) {
	// The polynomial form of the Cubic is:
	// eqn[0] = cur;
	// eqn[1] = (cp0 - cur) * 3.0;
	// eqn[2] = (cp1 - cp0 - cp0 + cur) * 3.0;
	// eqn[3] = end + (cp0 - cp1) * 3.0 - cur;
	// Since we want the derivative, we can calculate it in one step:
	zeros[0] = (cp0 - cur) * 3.0;
	zeros[1] = (cp1 - cp0 - cp0 + cur) * 6.0;
	zeros[2] = (end + (cp0 - cp1) * 3.0 - cur) * 3.0;
	int num = QuadCurve2D.solveQuadratic(zeros);
	int ret = 0;
	for (int i = 0; i < num; i++) {
		double t = zeros[i];
		if (t > 0 && t < 1) {
			zeros[ret] = t;
			ret++;
		}
	}
	return ret;
}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:23,代码来源:PathBBox.java

示例15: paint

import java.awt.geom.QuadCurve2D; //导入依赖的package包/类
@Override
void paint(Graphics2D g) {
    Point prevCtrl = pointList.get(0);
    Point currCtrl = pointList.get(1);
    Point pt1 = new Point((prevCtrl.x+currCtrl.x)/2, (prevCtrl.y+currCtrl.y)/2);
    g.drawLine(prevCtrl.x, prevCtrl.y, pt1.x, pt1.y);
    if (pointList.size()>2) for (int i = 2; i < pointList.size(); i++) {
        Point nextCtrl = pointList.get(i);
        Point pt2 = new Point((currCtrl.x+nextCtrl.x)/2, (currCtrl.y+nextCtrl.y)/2);
        QuadCurve2D.Double s = new QuadCurve2D.Double(pt1.x, pt1.y, currCtrl.x, currCtrl.y, pt2.x, pt2.y);
        g.draw(s);
        currCtrl = nextCtrl;
        pt1 = pt2;
    }
    g.drawLine(pt1.x, pt1.y, currCtrl.x, currCtrl.y);
}
 
开发者ID:hlg,项目名称:billie,代码行数:17,代码来源:Java2dFactory.java


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