Here you can find the source of flip(Dimension view, Rectangle rect, int direction)
public static Rectangle flip(Dimension view, Rectangle rect, int direction)
//package com.java2s; /*//from w ww. j a v a 2 s . c om * Copyright (c) 2014 tabletoptool.com team. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * rptools.com team - initial implementation * tabletoptool.com team - further development */ import java.awt.Dimension; import java.awt.Rectangle; public class Main { 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); } }