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 Rectangle flip(Dimension view, Rectangle rect, int direction) { boolean flipHorizontal = (direction & 1) == 1; boolean flipVertical = (direction & 2) == 2; int x = flipHorizontal ? view.width - (rect.x + rect.width) : rect.x; int y = flipVertical ? view.height - (rect.y + rect.height) : rect.y; System.out.println(rect + " - " + new Rectangle(x, y, rect.width, rect.height)); return new Rectangle(x, y, rect.width, rect.height); }
From source file:org.jfree.graphics2d.demo.ImageTest.java
private static void drawClipTest(Graphics2D g2) { g2.translate(10, 20);/* www . j a v a 2 s. c o m*/ g2.setColor(Color.RED); g2.fillRect(10, 10, 100, 100); g2.clip(new Rectangle(0, 0, 60, 60)); g2.setPaint(Color.BLUE); g2.fillRect(10, 10, 100, 100); g2.setClip(null); g2.setPaint(Color.GREEN); g2.fillRect(60, 60, 50, 50); }
From source file:Main.java
/** * Scales the given rectangle by the given scale factor. * * @param rect The rectangle to scale. * @param scaleFactor The factor to scale by. * @return The scaled rectangle.//w ww . j a v a 2s. c om */ public static Rectangle scaleRectangle(Rectangle rect, float scaleFactor) { return new Rectangle(Math.round(rect.x * scaleFactor), Math.round(rect.y * scaleFactor), Math.round(rect.width * scaleFactor), Math.round(rect.height * scaleFactor)); }
From source file:Main.java
public void paint(Graphics g) { Rectangle r = new Rectangle(50, 50, 100, 100); Rectangle r1 = new Rectangle(100, 100, 75, 75); g.drawRect(r.x, r.y, r.width, r.height); g.drawRect(r1.x, r1.y, r1.width, r1.height); Rectangle r2 = r.intersection(r1); System.out.println(r2);//from w w w .ja v a 2s .c o m g.fillRect(r2.x, r2.y, r2.width, r2.height); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(10, 10, 50, 40); r = r.union(new Rectangle(20, 20, 60, 60)); g2.fill(r);/*from ww w. j ava 2s .c om*/ }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(100, 100, 200, 200); g2.fill(r);//from w w w . ja v a 2 s .co m System.out.println(r.height); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(100, 100, 200, 200); g2.fill(r);/*from w w w . j av a 2 s . com*/ System.out.println(r.getSize()); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(10, 10, 50, 40); System.out.println(r.equals(new Rectangle(20, 20, 60, 60))); g2.fill(r);//from ww w . j a va 2s .c om }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(100, 100, 200, 200); g2.fill(r);/*from w w w . ja v a2 s . co m*/ System.out.println(r.getBounds2D()); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(100, 100, 200, 200); g2.fill(r);//from w w w . jav a 2 s. c om System.out.println(r.getY()); }