List of usage examples for java.awt Rectangle Rectangle
public Rectangle(int x, int y, int width, int height)
From source file:Main.java
public static void dialogFullScreen(JDialog dialog) { dialog.setBounds(new Rectangle(0, 0, toolkit.getScreenSize().width, toolkit.getScreenSize().height)); }
From source file:Main.java
public static Rectangle getScreenSize() { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getScreenSize(); return new Rectangle(0, 0, d.width, d.height); }
From source file:Main.java
static Rectangle applyInsets(final Rectangle bounds, final Insets insets) { final int x = bounds.x + insets.left; final int y = bounds.y + insets.top; final int width = bounds.width - insets.left - insets.right; final int height = bounds.height - insets.top - insets.bottom; return new Rectangle(x, y, width, height); }
From source file:Java2DUtils.java
public static void setClip(Graphics g, int x, int y, int width, int height) { setClip(g, new Rectangle(x, y, width, height)); }
From source file:Main.java
/** * Centers a component on its parent.//from w ww.j av a 2 s . com * * @param component */ public static void centerInParent(Component component) { Container parent = component.getParent(); if (parent != null) { Rectangle parentBounds = parent.getBounds(); Rectangle dialogBounds = new Rectangle( (int) (parentBounds.getMinX() + parentBounds.getWidth() / 2 - component.getWidth() / 2), (int) (parentBounds.getMinY() + parentBounds.getHeight() / 2 - component.getHeight() / 2), component.getWidth(), component.getHeight()); //dialog.setBounds( dialogBounds ); component.setLocation(dialogBounds.x, dialogBounds.y); } }
From source file:Main.java
public static BufferedImage getStrokedImage(BufferedImage bi, Shape shape, int strokeWidth) { int w = bi.getWidth(); int h = bi.getHeight(); BufferedImage bib = new BufferedImage(w, h, bi.getType()); Graphics2D g = bib.createGraphics(); BasicStroke bs = new BasicStroke(strokeWidth); g.setStroke(bs);//from w w w.j ava 2 s. com Rectangle rect = new Rectangle(0, 0, w, h); TexturePaint tp = new TexturePaint(bi, rect); g.setPaint(tp); g.draw(shape); g.dispose(); return bib; }
From source file:Main.java
public static Rectangle bound(Point... points) { int smallestX = Integer.MAX_VALUE; int smallestY = Integer.MAX_VALUE; int largestX = Integer.MIN_VALUE; int largestY = Integer.MIN_VALUE; for (Point point : points) { if (point == null) { continue; }//from w ww . j ava 2s. c om if (point.x > largestX) largestX = point.x; if (point.y > largestY) largestY = point.y; if (point.x < smallestX) smallestX = point.x; if (point.y < smallestY) smallestY = point.y; } return new Rectangle(smallestX, smallestY, largestX - smallestX, largestY - smallestY); }
From source file:Main.java
public static Rectangle shrinkSize(Rectangle r, Insets insets) { if (insets != null) { r = new Rectangle(r.x + insets.left, r.y + insets.top, r.width - insets.left - insets.right, r.height - insets.top - insets.bottom); }/*from w w w .ja v a2 s . co m*/ if (r.width < 0) { r.width = 0; } if (r.height < 0) { r.height = 0; } return r; }
From source file:Main.java
public static Rectangle dialateRectangle(Rectangle r, int dx, int dy) { return new Rectangle(r.x - dx, r.y - dy, r.width + 2 * dx, r.height + 2 * dy); }
From source file:Main.java
public static TexturePaint createCheckerTexture(int cs, Color color) { int size = cs * cs; BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = img.createGraphics(); g2.setPaint(color);/*from w ww . j ava 2 s.c om*/ g2.fillRect(0, 0, size, size); for (int i = 0; i * cs < size; i++) { for (int j = 0; j * cs < size; j++) { if ((i + j) % 2 == 0) { g2.fillRect(i * cs, j * cs, cs, cs); } } } g2.dispose(); return new TexturePaint(img, new Rectangle(0, 0, size, size)); }