Java Code Examples for java.awt.geom.RectangularShape#setFrame()

The following examples show how to use java.awt.geom.RectangularShape#setFrame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Callout.java    From ghidra with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: LuckShapeBorder.java    From littleluck with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example 3
Source File: ShapeTransform.java    From pentaho-reporting with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * 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;
}