Java Rectangle flip(Dimension view, Rectangle rect, int direction)

Here you can find the source of flip(Dimension view, Rectangle rect, int direction)

Description

flip

License

Open Source License

Declaration

public static Rectangle flip(Dimension view, Rectangle rect, int direction) 

Method Source Code

//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);
    }
}

Related

  1. computeDifference(Rectangle rectA, Rectangle rectB)
  2. expand(final Rectangle rect, final int expansion)
  3. expand(Rectangle rect, int amount)
  4. expand(Rectangle rectangle, int expansion)
  5. firstSmallerThanSecond(java.awt.Rectangle first, java.awt.Rectangle second)
  6. formatRect(Rectangle rc)
  7. formatRectangle(Rectangle rect)
  8. getAbsoluteRectangle(Rectangle rect)
  9. getFrameOrientations(Rectangle parent)