java.awt.geom.Path2D#append ( )源码实例Demo

下面列出了java.awt.geom.Path2D#append ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pumpernickel   文件: ShapeSerializationWrapper.java
@Override
public Shape create() {
	int windingRule = ((Number) map.get(KEY_WINDING_RULE)).intValue();
	String pathStr = (String) map.get(KEY_PATH);
	Path2D returnValue = new Path2D.Double(windingRule);
	returnValue.append(ShapeStringUtils.createPathIterator(pathStr), false);

	// offer more targeted classes if possible:

	Rectangle rect = ShapeUtils.getRectangle(returnValue);
	if (rect != null)
		return rect;
	Rectangle2D rect2D = ShapeUtils.getRectangle2D(returnValue);
	if (rect2D != null)
		return rect2D;

	return returnValue;
}
 
源代码2 项目: workcraft   文件: VisualCreditComponent.java
@Override
public Shape getShape() {
    Path2D shape = new Path2D.Double();

    shape.moveTo(-0.5 * SIZE, -0.4 * SIZE);
    shape.lineTo(-0.5 * SIZE, +0.4 * SIZE);
    shape.lineTo(+0.5 * SIZE, +0.4 * SIZE);
    shape.lineTo(+0.5 * SIZE, -0.4 * SIZE);
    shape.closePath();

    shape.moveTo(0.0, -0.4 * SIZE);
    shape.lineTo(0.0, +0.4 * SIZE);

    double tokenSize = SIZE / 10.0;
    for (int i = 0; i < 4; i++) {
        shape.append(new Ellipse2D.Double(-0.2 * SIZE - 0.5 * tokenSize, -0.5 * tokenSize, tokenSize, tokenSize), false);
        shape.append(new Ellipse2D.Double(+0.2 * SIZE - 0.5 * tokenSize, -0.5 * tokenSize, tokenSize, tokenSize), false);
        tokenSize /= 3.0;
    }

    return shape;
}
 
源代码3 项目: consulo   文件: DividerPolygon.java
private void paint(Graphics2D g, int width) {
  GraphicsUtil.setupAntialiasing(g);


  if (!myApplied) {
    Shape upperCurve = makeCurve(width, myStart1, myStart2, true);
    Shape lowerCurve = makeCurve(width, myEnd1, myEnd2, false);

    Path2D path = new Path2D.Double();
    path.append(upperCurve, true);
    path.append(lowerCurve, true);
    g.setColor(myColor);
    g.fill(path);

    g.setColor(DiffUtil.getFramingColor(myColor));
    g.draw(upperCurve);
    g.draw(lowerCurve);
  }
  else {
    g.setColor(myColor);
    g.draw(makeCurve(width, myStart1 + 1, myStart2 + 1, true));
    g.draw(makeCurve(width, myStart1 + 2, myStart2 + 2, true));
    g.draw(makeCurve(width, myEnd1 + 1, myEnd2 + 1, false));
    g.draw(makeCurve(width, myEnd1 + 2, myEnd2 + 2, false));
  }
}
 
源代码4 项目: FlatLaf   文件: FlatUIUtils.java
private static void paintComponentBorderImpl( Graphics2D g, int x, int y, int width, int height,
	float focusWidth, float lineWidth, float arc )
{
	float x1 = x + focusWidth;
	float y1 = y + focusWidth;
	float width1 = width - focusWidth * 2;
	float height1 = height - focusWidth * 2;
	float arc2 = arc - (lineWidth * 2);

	Shape r1 = createComponentRectangle( x1, y1, width1, height1, arc );
	Shape r2 = createComponentRectangle(
		x1 + lineWidth, y1 + lineWidth,
		width1 - lineWidth * 2, height1 - lineWidth * 2, arc2 );

	Path2D border = new Path2D.Float( Path2D.WIND_EVEN_ODD );
	border.append( r1, false );
	border.append( r2, false );
	g.fill( border );
}
 
源代码5 项目: consulo   文件: DiffDrawUtil.java
public static void drawCurveTrapezium(@Nonnull Graphics2D g,
                                      int x1, int x2,
                                      int start1, int end1,
                                      int start2, int end2,
                                      @Nullable Color fillColor,
                                      @Nullable Color borderColor) {
  Shape upperCurve = makeCurve(x1, x2, start1, start2, true);
  Shape lowerCurve = makeCurve(x1, x2, end1 + 1, end2 + 1, false);
  Shape lowerCurveBorder = makeCurve(x1, x2, end1, end2, false);

  if (fillColor != null) {
    Path2D path = new Path2D.Double();
    path.append(upperCurve, true);
    path.append(lowerCurve, true);

    g.setColor(fillColor);
    g.fill(path);
  }

  if (borderColor != null) {
    g.setColor(borderColor);
    g.draw(upperCurve);
    g.draw(lowerCurveBorder);
  }
}
 
源代码6 项目: training   文件: MyLineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        RoundRectangle2D.Float outer = new RoundRectangle2D.Float(x, y, width, height, radius, radius);
        RoundRectangle2D.Float inner = new RoundRectangle2D.Float(x + thickness, y + thickness, width - thickness * 2, height - thickness * 2, 10, 10);

        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码7 项目: TencentKona-8   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            float arc = .2f * offs;
            outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码8 项目: FlatLaf   文件: FlatTaskPaneUI.java
@Override
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
	if( color == null )
		return;

	FlatUIUtils.setRenderingHints( (Graphics2D) g );

	g.setColor( color );

	float lineWidth = UIScale.scale( 1f );
	Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
	path.append( new Rectangle2D.Float( x, y, width, height ), false );
	path.append( new Rectangle2D.Float( x + lineWidth, y, width - (lineWidth * 2), height - lineWidth ), false );
	((Graphics2D)g).fill( path );
}
 
源代码9 项目: openjdk-8-source   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            int arc = offs + size;
            outer = new RoundRectangle2D.Float(x, y, width, height, arc, arc);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码10 项目: FlatLaf   文件: FlatUIUtils.java
/**
 * Creates a not-filled rectangle shape with the given line width.
 */
public static Path2D createRectangle( float x, float y, float width, float height, float lineWidth ) {
	Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
	path.append( new Rectangle2D.Float( x, y, width, height ), false );
	path.append( new Rectangle2D.Float( x + lineWidth, y + lineWidth,
		width - (lineWidth * 2), height - (lineWidth * 2) ), false );
	return path;
}
 
源代码11 项目: pumpernickel   文件: ShapeUtils.java
public static Shape clone(Shape shape) {
	if (shape == null)
		return null;

	if (shape instanceof RectangularShape)
		return (Shape) ((RectangularShape) shape).clone();
	if (shape instanceof Line2D)
		return (Shape) ((Line2D) shape).clone();

	PathIterator pi = shape.getPathIterator(null);
	Path2D p = new Path2D.Float(pi.getWindingRule());
	p.append(pi, false);
	return p;
}
 
源代码12 项目: FlatLaf   文件: FlatFileViewHardDriveIcon.java
@Override
protected void paintIcon( Component c, Graphics2D g ) {
	/*
		<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
		  <path fill="#6E6E6E" fill-rule="evenodd" d="M2,6 L14,6 L14,10 L2,10 L2,6 Z M12,8 L12,9 L13,9 L13,8 L12,8 Z M10,8 L10,9 L11,9 L11,8 L10,8 Z"/>
		</svg>
	*/

	Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
	path.append( new Rectangle2D.Float( 2, 6, 12, 4 ), false );
	path.append( new Rectangle2D.Float( 12, 8, 1, 1 ), false );
	path.append( new Rectangle2D.Float( 10, 8, 1, 1 ), false );
	g.fill( path );
}
 
源代码13 项目: openjdk-8   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            int arc = offs + size;
            outer = new RoundRectangle2D.Float(x, y, width, height, arc, arc);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码14 项目: jdk8u-jdk   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            float arc = .2f * offs;
            outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码15 项目: openjdk-jdk9   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 *
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            float arc = .2f * offs;
            outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码16 项目: consulo   文件: DarculaSpinnerBorder.java
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  Graphics2D g2 = (Graphics2D)g.create();
  Rectangle r = new Rectangle(x, y, width, height);
  JBInsets.removeFrom(r, JBUI.insets(1));

  try {
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

    g2.translate(r.x, r.y);

    float lw = LW.getFloat();
    float bw = BW.getFloat();
    float arc = COMPONENT_ARC.getFloat();

    Object op = ((JComponent)c).getClientProperty("JComponent.outline");
    if (c.isEnabled() && op != null) {
      paintOutlineBorder(g2, r.width, r.height, arc, true, isFocused(c), Outline.valueOf(op.toString()));
    }
    else {
      if (isFocused(c)) {
        paintFocusBorder(g2, r.width, r.height, arc, true);
      }

      Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
      border.append(new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc), false);
      arc = arc > lw ? arc - lw : 0.0f;
      border.append(new RoundRectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2, arc, arc), false);

      g2.setColor(getOutlineColor(c.isEnabled(), isFocused(c)));
      g2.fill(border);
    }
  }
  finally {
    g2.dispose();
  }
}
 
源代码17 项目: consulo   文件: DarculaUIUtil.java
@SuppressWarnings("SuspiciousNameCombination")
public static void doPaint(Graphics2D g, int width, int height, float arc, boolean symmetric) {
  float bw = UIUtil.isUnderDefaultMacTheme() ? JBUI.scale(3) : BW.getFloat();
  float lw = UIUtil.isUnderDefaultMacTheme() ? JBUI.scale(UIUtil.isRetina(g) ? 0.5f : 1.0f) : LW.getFloat();

  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

  float outerArc = arc > 0 ? arc + bw - JBUI.scale(2f) : bw;
  float rightOuterArc = symmetric ? outerArc : JBUI.scale(6f);
  Path2D outerRect = new Path2D.Float(Path2D.WIND_EVEN_ODD);
  outerRect.moveTo(width - rightOuterArc, 0);
  outerRect.quadTo(width, 0, width, rightOuterArc);
  outerRect.lineTo(width, height - rightOuterArc);
  outerRect.quadTo(width, height, width - rightOuterArc, height);
  outerRect.lineTo(outerArc, height);
  outerRect.quadTo(0, height, 0, height - outerArc);
  outerRect.lineTo(0, outerArc);
  outerRect.quadTo(0, 0, outerArc, 0);
  outerRect.closePath();

  bw += lw;
  float rightInnerArc = symmetric ? outerArc : JBUI.scale(7f);
  Path2D innerRect = new Path2D.Float(Path2D.WIND_EVEN_ODD);
  innerRect.moveTo(width - rightInnerArc, bw);
  innerRect.quadTo(width - bw, bw, width - bw, rightInnerArc);
  innerRect.lineTo(width - bw, height - rightInnerArc);
  innerRect.quadTo(width - bw, height - bw, width - rightInnerArc, height - bw);
  innerRect.lineTo(outerArc, height - bw);
  innerRect.quadTo(bw, height - bw, bw, height - outerArc);
  innerRect.lineTo(bw, outerArc);
  innerRect.quadTo(bw, bw, outerArc, bw);
  innerRect.closePath();

  Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
  path.append(outerRect, false);
  path.append(innerRect, false);
  g.fill(path);
}
 
源代码18 项目: Java8CN   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            float arc = .2f * offs;
            outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码19 项目: JDKSourceCode1.8   文件: LineBorder.java
/**
 * Paints the border for the specified component with the
 * specified position and size.
 * @param c the component for which this border is being painted
 * @param g the paint graphics
 * @param x the x position of the painted border
 * @param y the y position of the painted border
 * @param width the width of the painted border
 * @param height the height of the painted border
 */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    if ((this.thickness > 0) && (g instanceof Graphics2D)) {
        Graphics2D g2d = (Graphics2D) g;

        Color oldColor = g2d.getColor();
        g2d.setColor(this.lineColor);

        Shape outer;
        Shape inner;

        int offs = this.thickness;
        int size = offs + offs;
        if (this.roundedCorners) {
            float arc = .2f * offs;
            outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
            inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
        }
        else {
            outer = new Rectangle2D.Float(x, y, width, height);
            inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
        }
        Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        path.append(outer, false);
        path.append(inner, false);
        g2d.fill(path);
        g2d.setColor(oldColor);
    }
}
 
源代码20 项目: sis   文件: ShapeUtilitiesViewer.java
/**
 * Append the given point to the given path.
 */
private static void addPoint(final Path2D addTo, final double x, final double y) {
    addTo.append(new Ellipse2D.Double(x - POINT_RADIUS, y - POINT_RADIUS, 2*POINT_RADIUS, 2*POINT_RADIUS), false);
}