本文整理匯總了Java中java.awt.geom.GeneralPath.closePath方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneralPath.closePath方法的具體用法?Java GeneralPath.closePath怎麽用?Java GeneralPath.closePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.GeneralPath
的用法示例。
在下文中一共展示了GeneralPath.closePath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createHexagonShape
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/** Creates a hexagonal shape inscribed in the bounds given in the parameters. */
private Shape createHexagonShape(double x, double y, double width, double height) {
GeneralPath result = new GeneralPath(Path2D.WIND_NON_ZERO, 5);
double extend = height * NodeShape.HEX_EXTEND_RATIO;
// stat at top left corner
result.moveTo(x + extend, y);
// to top right
result.lineTo(x + width - extend, y);
// to right
result.lineTo(x + width, y + height / 2);
// to bottom right
result.lineTo(x + width - extend, y + height);
// to bottom left
result.lineTo(x + extend, y + height);
// to left
result.lineTo(x, y + height / 2);
result.closePath();
return result;
}
示例2: XYAreaRenderer2
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Constructs a new renderer.
*
* @param labelGenerator the tool tip generator to use. <code>null</code>
* is none.
* @param urlGenerator the URL generator (null permitted).
*/
public XYAreaRenderer2(XYToolTipGenerator labelGenerator,
XYURLGenerator urlGenerator) {
super();
this.showOutline = false;
setBaseToolTipGenerator(labelGenerator);
setURLGenerator(urlGenerator);
GeneralPath area = new GeneralPath();
area.moveTo(0.0f, -4.0f);
area.lineTo(3.0f, -2.0f);
area.lineTo(4.0f, 4.0f);
area.lineTo(-4.0f, 4.0f);
area.lineTo(-3.0f, -2.0f);
area.closePath();
this.legendArea = area;
}
示例3: getWindow
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Returns the shape for the window for this dial. Some dial layers will
* request that their drawing be clipped within this window.
*
* @param frame the reference frame (<code>null</code> not permitted).
*
* @return The shape of the dial's window.
*/
public Shape getWindow(Rectangle2D frame) {
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius, this.innerRadius);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius, this.outerRadius);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle, this.extent,
Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ this.extent, - this.extent, Arc2D.OPEN);
GeneralPath p = new GeneralPath();
Point2D point1 = inner.getStartPoint();
p.moveTo((float) point1.getX(), (float) point1.getY());
p.append(inner, true);
p.append(outer, true);
p.closePath();
return p;
}
示例4: drawGlassEffect
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Draws the glass effect
*/
public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) {
double size = 0.4;
canvas.getGraphics()
.setPaint(new GradientPaint((float) state.getX(), (float) state.getY(),
new Color(1, 1, 1, 0.9f), (float) (state.getX()),
(float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f)));
float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1)
* canvas.getScale() / 2);
GeneralPath path = new GeneralPath();
path.moveTo((float) state.getX() - sw, (float) state.getY() - sw);
path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size));
path.quadTo((float) (state.getX() + state.getWidth() * 0.5),
(float) (state.getY() + state.getHeight() * 0.7),
(float) (state.getX() + state.getWidth() + sw),
(float) (state.getY() + state.getHeight() * size));
path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw);
path.closePath();
canvas.getGraphics().fill(path);
}
示例5: filledPolygon
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Draws a polygon with the vertices
* (<em>x</em><sub>0</sub>, <em>y</em><sub>0</sub>),
* (<em>x</em><sub>1</sub>, <em>y</em><sub>1</sub>), ...,
* (<em>x</em><sub><em>n</em>–1</sub>, <em>y</em><sub><em>n</em>–1</sub>).
*
* @param x an array of all the <em>x</em>-coordinates of the polygon
* @param y an array of all the <em>y</em>-coordinates of the polygon
* @throws IllegalArgumentException unless {@code x[]} and {@code y[]}
* are of the same length
*/
public static void filledPolygon(double[] x, double[] y) {
if (x == null) throw new IllegalArgumentException();
if (y == null) throw new IllegalArgumentException();
int n1 = x.length;
int n2 = y.length;
if (n1 != n2) throw new IllegalArgumentException("arrays must be of the same length");
int n = n1;
GeneralPath path = new GeneralPath();
path.moveTo((float) scaleX(x[0]), (float) scaleY(y[0]));
for (int i = 0; i < n; i++)
path.lineTo((float) scaleX(x[i]), (float) scaleY(y[i]));
path.closePath();
offscreen.fill(path);
draw();
}
示例6: 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;
}
示例7: paintArrowEnd
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Малює кінець стрілки.
*
* @param g Область для виводу стрілки.
* @param x Координата x кінця стрілки.
* @param y Координата y кінця стрілки.
* @param type Напрямок направленості стрілки, MovingPanel.RIGHT,...
*/
public void paintArrowEnd(final Graphics2D g, double x1, double y1,
final double xD, final double yD, int type) {
final float x = (float) xD;
final float y = (float) yD;
final GeneralPath t = new GeneralPath(Path2D.WIND_EVEN_ODD, 3);
t.moveTo(x, y);
final float arrowWidth = (float) movingArea
.getIDoubleOrdinate(ARROW_WIDTH);
final float arrowHeight = (float) movingArea
.getIDoubleOrdinate(ARROW_HEIGHT);
type = MovingPanel.getOpposite(type);
switch (type) {
case MovingPanel.BOTTOM: {
t.lineTo(x - arrowWidth, y - arrowHeight);
t.lineTo(x + arrowWidth, y - arrowHeight);
}
break;
case MovingPanel.RIGHT: {
t.lineTo(x - arrowHeight, y - arrowWidth);
t.lineTo(x - arrowHeight, y + arrowWidth);
}
break;
case MovingPanel.TOP: {
t.lineTo(x - arrowWidth, y + arrowHeight);
t.lineTo(x + arrowWidth, y + arrowHeight);
}
break;
case MovingPanel.LEFT: {
t.lineTo(x + arrowHeight, y - arrowWidth);
t.lineTo(x + arrowHeight, y + arrowWidth);
}
break;
}
t.closePath();
g.fill(t);
}
示例8: getOuterWindow
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
protected Shape getOuterWindow(Rectangle2D frame) {
double radiusMargin = 0.02;
double angleMargin = 1.5;
Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame,
this.innerRadius - radiusMargin, this.innerRadius
- radiusMargin);
Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame,
this.outerRadius + radiusMargin, this.outerRadius
+ radiusMargin);
Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle
- angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN);
Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle
+ angleMargin + this.extent, - this.extent - 2 * angleMargin,
Arc2D.OPEN);
GeneralPath p = new GeneralPath();
Point2D point1 = inner.getStartPoint();
p.moveTo((float) point1.getX(), (float) point1.getY());
p.append(inner, true);
p.append(outer, true);
p.closePath();
return p;
}
示例9: generateClipPath
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Generates the clip path.
*
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath generateClipPath(Rectangle2D dataArea,
ValueAxis horizontalAxis,
ValueAxis verticalAxis) {
GeneralPath generalPath = new GeneralPath();
double transX = horizontalAxis.valueToJava2D(
this.xValue[0], dataArea, RectangleEdge.BOTTOM
);
double transY = verticalAxis.valueToJava2D(
this.yValue[0], dataArea, RectangleEdge.LEFT
);
generalPath.moveTo((float) transX, (float) transY);
for (int k = 0; k < this.yValue.length; k++) {
transX = horizontalAxis.valueToJava2D(
this.xValue[k], dataArea, RectangleEdge.BOTTOM
);
transY = verticalAxis.valueToJava2D(
this.yValue[k], dataArea, RectangleEdge.LEFT
);
generalPath.lineTo((float) transX, (float) transY);
}
generalPath.closePath();
return generalPath;
}
示例10: makePoly
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
private Shape makePoly(int xPoints[], int yPoints[],
int nPoints, boolean close) {
GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
if (nPoints > 0) {
gp.moveTo(xPoints[0], yPoints[0]);
for (int i = 1; i < nPoints; i++) {
gp.lineTo(xPoints[i], yPoints[i]);
}
if (close) {
gp.closePath();
}
}
return gp;
}
示例11: createBarShape
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
private static GeneralPath createBarShape() {
GeneralPath barShape = new GeneralPath();
barShape.moveTo(0, 0);
barShape.lineTo(0, -5);
barShape.lineTo(5, -5);
barShape.lineTo(5, 0);
barShape.lineTo(5, -15);
barShape.lineTo(10, -15);
barShape.lineTo(10, 0);
barShape.lineTo(10, -10);
barShape.lineTo(15, -10);
barShape.lineTo(15, 0);
barShape.closePath();
return barShape;
}
示例12: paintComponent
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
GeneralPath arrow = new GeneralPath();
int w, h;
switch (direction) {
case SwingConstants.SOUTH:
h = 2;
w = 4;
arrow.moveTo(getWidth() / 2 - w, getHeight() / 2);
arrow.lineTo(getWidth() / 2 + w, getHeight() / 2);
arrow.lineTo(getWidth() / 2, getHeight() / 2 + 2 * h);
arrow.closePath();
break;
case SwingConstants.EAST:
h = 4;
w = 2;
arrow.moveTo(getWidth() / 2 - w, getHeight() / 2 - h);
arrow.lineTo(getWidth() / 2 + w, getHeight() / 2);
arrow.lineTo(getWidth() / 2 - w, getHeight() / 2 + h);
arrow.closePath();
break;
default:
throw new IllegalArgumentException("Illegal direction: " + direction);
}
if (isEnabled()) {
g.setColor(Color.BLACK);
} else {
g.setColor(Color.GRAY);
}
((Graphics2D) g).fill(arrow);
}
示例13: selectLasso
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
Selects the area represented by poly
*/
void selectLasso(XYGraph xyg) {
GeneralPath path = new GeneralPath();
for (int i=0; i<poly.npoints; i++){
Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
else path.lineTo((float)point.getX(), (float) point.getY());
}
path.closePath();
Rectangle2D r = path.getBounds();
int n = 0;
while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
n++;
}
if (n>=x.length) return;
table.getSelectionModel().setValueIsAdjusting(true);
table.clearSelection();
for (int i = n; i < x.length; i++) {
if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
table.getSelectionModel().addSelectionInterval(i, i);
}
}
table.getSelectionModel().setValueIsAdjusting(false);
unDrawLasso(xyg);
if (table.getSelectedRow() != -1)
table.ensureIndexIsVisible(table.getSelectedRow());
}
示例14: drawOutline
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
* Draws the outline for the plot.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param dataArea the area inside the axes.
*/
public void drawOutline(Graphics2D g2, CategoryPlot plot,
Rectangle2D dataArea) {
float x0 = (float) dataArea.getX();
float x1 = x0 + (float) Math.abs(this.xOffset);
float x3 = (float) dataArea.getMaxX();
float x2 = x3 - (float) Math.abs(this.xOffset);
float y0 = (float) dataArea.getMaxY();
float y1 = y0 - (float) Math.abs(this.yOffset);
float y3 = (float) dataArea.getMinY();
float y2 = y3 + (float) Math.abs(this.yOffset);
GeneralPath clip = new GeneralPath();
clip.moveTo(x0, y0);
clip.lineTo(x0, y2);
clip.lineTo(x1, y3);
clip.lineTo(x3, y3);
clip.lineTo(x3, y1);
clip.lineTo(x2, y0);
clip.closePath();
// put an outline around the data area...
Stroke outlineStroke = plot.getOutlineStroke();
Paint outlinePaint = plot.getOutlinePaint();
if ((outlineStroke != null) && (outlinePaint != null)) {
g2.setStroke(outlineStroke);
g2.setPaint(outlinePaint);
g2.draw(clip);
}
}
示例15: paintComponent
import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
SecureRandom random = new SecureRandom();
int[] xPoints = {55, 67, 109, 73, 83, 55, 27, 37, 1, 43};
int[] yPoints = {0, 36, 36, 54, 96, 72, 96, 54, 36, 36};
Graphics2D g2d = (Graphics2D) g;
GeneralPath star = new GeneralPath(); // create GeneralPath object
// set the initial coordinate of the General Path
star.moveTo(xPoints[0], yPoints[0]);
// create the star--this does not draw the star
for (int count = 1; count < xPoints.length; count++)
star.lineTo(xPoints[count], yPoints[count]);
star.closePath(); // close the shape
g2d.translate(150, 150); // translate the origin to (150, 150)
// rotate around origin and draw stars in random colors
for (int count = 1; count <= 20; count++)
{
g2d.rotate(Math.PI / 10.0); // rotate coordinate system
// set random drawing color
g2d.setColor(new Color(random.nextInt(256),
random.nextInt(256), random.nextInt(256)));
g2d.fill(star); // draw filled star
}
}