本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}