當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneralPath.curveTo方法代碼示例

本文整理匯總了Java中java.awt.geom.GeneralPath.curveTo方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneralPath.curveTo方法的具體用法?Java GeneralPath.curveTo怎麽用?Java GeneralPath.curveTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.GeneralPath的用法示例。


在下文中一共展示了GeneralPath.curveTo方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConnectionSpline

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * Creates a spline connector shape from one {@link Point2D} to another.
 *
 * @param from
 *            the starting point
 * @param to
 *            the end point
 * @return the shape representing the connection, never {@code null}
 */
public static Shape createConnectionSpline(final Point2D from, final Point2D to) {
	if (from == null || to == null) {
		throw new IllegalArgumentException("from and to must not be null!");
	}

	int delta = 10;
	GeneralPath connector = new GeneralPath();
	connector.moveTo(from.getX() + 1, from.getY());
	double cx = (from.getX() + to.getX()) / 2;
	double cy = (from.getY() + to.getY()) / 2;
	if (to.getX() >= from.getX() + 2 * delta) {
		connector.curveTo(cx, from.getY(), cx, from.getY(), cx, cy);
		connector.curveTo(cx, to.getY(), cx, to.getY(), to.getX() - 1, to.getY());
	} else {
		connector.curveTo(from.getX() + delta, from.getY(), from.getX() + delta, cy, cx, cy);
		connector.curveTo(to.getX() - delta, cy, to.getX() - delta, to.getY(), to.getX() - 1, to.getY());
	}
	return connector;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:29,代碼來源:ProcessDrawUtils.java

示例2: paintIcon

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    int w = getIconWidth();
    int h = getIconHeight();

    GeneralPath path = new GeneralPath();
    path.moveTo(0, h / 2);
    double segment = w / 3d;
    path.curveTo(segment, -h * 0.3, 2 * segment, h * 1.3, w, h / 2);

    Graphics2D g2 = (Graphics2D) g.create();
    g2.translate(x, y);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setColor(c.getForeground());
    g2.setStroke(new BasicStroke(thickness));
    g2.draw(path);
    g2.dispose();
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:20,代碼來源:ThicknessIcon.java

示例3: createShape

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * 
 */
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state)
{
	Rectangle temp = state.getRectangle();
	int x = temp.x;
	int y = temp.y;
	int w = temp.width;
	int h = temp.height;
	GeneralPath path = new GeneralPath();

	path.moveTo((float) (x + 0.25 * w), (float) (y + 0.25 * h));
	path.curveTo((float) (x + 0.05 * w), (float) (y + 0.25 * h), x,
			(float) (y + 0.5 * h), (float) (x + 0.16 * w),
			(float) (y + 0.55 * h));
	path.curveTo(x, (float) (y + 0.66 * h), (float) (x + 0.18 * w),
			(float) (y + 0.9 * h), (float) (x + 0.31 * w),
			(float) (y + 0.8 * h));
	path.curveTo((float) (x + 0.4 * w), (y + h), (float) (x + 0.7 * w),
			(y + h), (float) (x + 0.8 * w), (float) (y + 0.8 * h));
	path.curveTo((x + w), (float) (y + 0.8 * h), (x + w),
			(float) (y + 0.6 * h), (float) (x + 0.875 * w),
			(float) (y + 0.5 * h));
	path.curveTo((x + w), (float) (y + 0.3 * h), (float) (x + 0.8 * w),
			(float) (y + 0.1 * h), (float) (x + 0.625 * w),
			(float) (y + 0.2 * h));
	path.curveTo((float) (x + 0.5 * w), (float) (y + 0.05 * h),
			(float) (x + 0.3 * w), (float) (y + 0.05 * h),
			(float) (x + 0.25 * w), (float) (y + 0.25 * h));
	path.closePath();

	return path;
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:35,代碼來源:mxCloudShape.java

示例4: createShape

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
 * 
 */
public Shape createShape(mxGraphics2DCanvas canvas, mxCellState state) {
  Rectangle temp = state.getRectangle();
  int x = temp.x;
  int y = temp.y;
  int w = temp.width;
  int h = temp.height;
  GeneralPath path = new GeneralPath();

  path.moveTo((float) (x + 0.25 * w), (float) (y + 0.25 * h));
  path.curveTo((float) (x + 0.05 * w), (float) (y + 0.25 * h), x, (float) (y + 0.5 * h),
      (float) (x + 0.16 * w), (float) (y + 0.55 * h));
  path.curveTo(x, (float) (y + 0.66 * h), (float) (x + 0.18 * w), (float) (y + 0.9 * h),
      (float) (x + 0.31 * w), (float) (y + 0.8 * h));
  path.curveTo((float) (x + 0.4 * w), (y + h), (float) (x + 0.7 * w), (y + h),
      (float) (x + 0.8 * w), (float) (y + 0.8 * h));
  path.curveTo((x + w), (float) (y + 0.8 * h), (x + w), (float) (y + 0.6 * h),
      (float) (x + 0.875 * w), (float) (y + 0.5 * h));
  path.curveTo((x + w), (float) (y + 0.3 * h), (float) (x + 0.8 * w), (float) (y + 0.1 * h),
      (float) (x + 0.625 * w), (float) (y + 0.2 * h));
  path.curveTo((float) (x + 0.5 * w), (float) (y + 0.05 * h), (float) (x + 0.3 * w),
      (float) (y + 0.05 * h), (float) (x + 0.25 * w), (float) (y + 0.25 * h));
  path.closePath();

  return path;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:29,代碼來源:mxCloudShape.java

示例5: getRegiaoComentario

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
public Shape getRegiaoComentario() {
    if (Regiao == null) {

        GeneralPath pa = new GeneralPath();
        pa.setWindingRule(GeneralPath.WIND_NON_ZERO);

        Rectangle rec = getBounds();
        int tam = Math.min(rec.width / 6, rec.height / 6);
        int curv = tam / 4;
        int lw = rec.x + rec.width;
        int[] px = new int[]{rec.x, lw - tam, lw, lw, rec.x};
        int[] py = new int[]{rec.y, rec.y, rec.y + tam, rec.y + rec.height, rec.y + rec.height};
        Polygon po = new Polygon(px, py, 5);
        pa.append(po, true);
        pa.moveTo(lw - tam, rec.y);
        pa.curveTo(lw - tam, rec.y, lw - tam + curv, rec.y + curv, lw - tam, rec.y + tam - (1));
        pa.moveTo(lw - tam, rec.y + tam - (1));
        pa.lineTo(lw, rec.y + tam);
        pa.closePath();
        Regiao = pa;
    }
    return Regiao;
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:24,代碼來源:LivreBase.java

示例6: paintSelection

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
protected void paintSelection(Graphics2D g2, int w, int h) {
    GeneralPath path = new GeneralPath();
    w = w-16;
    path.moveTo(8, h/2);
    path.curveTo(8+w/3, 6, 8+(2*w)/3, h, 8+w, h/2);

    g2.setColor(selectorPanel.getForeground());
    g2.setStroke(getSelectedValue());
    g2.draw(path);
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:12,代碼來源:StrokeSelectorButton.java

示例7: paintBorder

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {

	width--;
	height--;

	Graphics2D g2 = (Graphics2D) g.create();
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	GeneralPath border = new GeneralPath();
	// top left
	border.moveTo(x + cornerSize, y);
	border.lineTo(x + width - cornerSize, y);
	// top right
	border.curveTo(x + width - cornerSize, y, x + width, y, x + width, y + cornerSize);
	border.lineTo(x + width, y + height - cornerSize);
	// bottom right
	border.curveTo(x + width, y + height, x + width, y + height, x + width - cornerSize, y + height);
	border.lineTo(x + cornerSize, y + height);
	// bottom left
	border.curveTo(x, y + height, x, y + height, x, y + height - cornerSize);
	border.lineTo(x, y + cornerSize);
	// top left again
	border.curveTo(x, y, x, y, x + cornerSize, y);

	if (headerHeight > 0) {
		if (height <= headerHeight + cornerSize) {
			g2.setColor(color);
			g2.fill(border);
		} else {
			g2.setColor(c.getBackground());
			g2.fill(border);

			GeneralPath header = new GeneralPath();
			// top left
			header.moveTo(x + cornerSize, y);
			header.lineTo(x + width - cornerSize, y);
			// top right
			header.curveTo(x + width - cornerSize, y, x + width, y, x + width, y + cornerSize);
			header.lineTo(x + width, y + headerHeight);
			header.lineTo(x, y + headerHeight);
			header.lineTo(x, y + cornerSize);
			// top left again
			header.curveTo(x, y, x, y, x + cornerSize, y);
			g2.setColor(color);
			g2.fill(header);
		}
	}

	g2.setColor(color);
	g2.draw(border);

	g2.dispose();
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:55,代碼來源:RapidBorder.java


注:本文中的java.awt.geom.GeneralPath.curveTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。