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


Java GeneralPath.closePath方法代碼示例

本文整理匯總了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;
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:20,代碼來源:JVertexView.java

示例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;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:XYAreaRenderer2.java

示例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;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:StandardDialFrame.java

示例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);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:26,代碼來源:mxLabelShape.java

示例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();
}
 
開發者ID:Lxinyuelxy,項目名稱:Princeton_Algorithms,代碼行數:27,代碼來源:StdDraw.java

示例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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:29,代碼來源:mxCloudShape.java

示例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);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:46,代碼來源:ArrowPainter.java

示例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;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:StandardDialFrame.java

示例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;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:36,代碼來源:ClipPath.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:PixelToShapeConverter.java

示例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;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:16,代碼來源:PlotInstanceLegendCreator.java

示例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);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:34,代碼來源:ArrowButton.java

示例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());
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:36,代碼來源:PDBDataSetGraph.java

示例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);
    }

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:40,代碼來源:LineRenderer3D.java

示例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
   } 
}
 
開發者ID:cleitonferreira,項目名稱:LivroJavaComoProgramar10Edicao,代碼行數:36,代碼來源:Shapes2JPanel.java


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