java.awt.geom.RectangularShape#setFrame ( )源码实例Demo

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

源代码1 项目: ghidra   文件: Callout.java
private void paintCalloutCircularImage(Graphics2D g, CalloutComponentInfo calloutInfo,
		RectangularShape shape) {

	//
	// First draw the background circle that will sit beneath the image, to create a 
	// ring around the image
	//
	g.setColor(CALLOUT_SHAPE_COLOR);
	g.fill(shape);

	// 
	// Now, make the image a bit smaller, so that the background is a ring around the image
	//
	int offset = 3;
	Rectangle sr = shape.getBounds(); // shape rectangle
	Rectangle ir = new Rectangle(); // image rectangle
	ir.x = sr.x + offset;
	ir.y = sr.y + offset;
	ir.width = sr.width - (2 * offset);
	ir.height = sr.height - (2 * offset);

	shape.setFrame(ir); // change the size for the image

	Dimension imageSize = ir.getSize();
	Image foregroundImage =
		createMagnifiedImage(g.getDeviceConfiguration(), imageSize, calloutInfo, shape);

	shape.setFrame(sr); // restore

	g.drawImage(foregroundImage, ir.x, ir.y, null);
}
 
源代码2 项目: littleluck   文件: LuckShapeBorder.java
public void paintBorder(Component c,
                        Graphics g,
                        int x,
                        int y,
                        int width,
                        int height)
{
    Graphics2D g2d = (Graphics2D) g;

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

    RectangularShape shape = getBorderShape(c);

    if(shape != null)
    {
        shape.setFrame(x, y, width - 1, height - 1);

        if(!isFocusGained(c))
        {
            // 非焦点状态下
            g2d.setColor(normalColor);

            g2d.draw(shape);
        }
        else
        {
            // 获取焦点状态下
            g2d.setColor(outShadowColor);

            g2d.draw(shape);

            g2d.setColor(innerShadowColor);

            g2d.drawRect(x + 2, y + 2, width - 5, height - 5);

            g2d.setColor(focusColor);

            shape.setFrame(x + 1, y + 1, width - 3, height - 3);

            g2d.draw(shape);
        }
    }

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
}
 
源代码3 项目: pentaho-reporting   文件: ShapeTransform.java
/**
 * Resizes a rectangle. This works for real rectangles and produces funny results for RoundRects etc ..
 *
 * @param rectangularShape
 *          the rectangle
 * @param width
 *          the new width of the rectangle
 * @param height
 *          the new height of the rectangle.
 * @return the resized rectangle.
 */
public static Shape resizeRect( final RectangularShape rectangularShape, final double width, final double height ) {
  final RectangularShape retval = (RectangularShape) rectangularShape.clone();
  retval.setFrame( retval.getX(), retval.getY(), width, height );
  return retval;
}