Java Rectangle Fit fits(Rectangle r)

Here you can find the source of fits(Rectangle r)

Description

fits

License

Open Source License

Parameter

Parameter Description
r - desired rectangle

Return

true if the rectangle will fit on the screen

Declaration

public static boolean fits(Rectangle r) 

Method Source Code


//package com.java2s;
/*/*w ww. j a va  2 s. c o  m*/
 * ADTPro - Apple Disk Transfer ProDOS
 * Copyright (C) 2006 by David Schmidt
 * david__schmidt at users.sourceforge.net
 *
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published by the 
 * Free Software Foundation; either version 2 of the License, or (at your 
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

import java.awt.*;

public class Main {
    /**
     * @param r - desired rectangle
     * @return true if the rectangle will fit on the screen
     */
    public static boolean fits(Rectangle r) {
        boolean ret = false;
        final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

        if (((r.x + r.width) <= screenSize.width) && ((r.y + r.height) <= screenSize.height)) {
            ret = true;
        }
        return ret;
    }
}

Related

  1. fitRectangle(Rectangle rect, Dimension d)
  2. fitRectangle(Rectangle rect, Rectangle target)
  3. fitRectangles(Dimension imageSize, Dimension size)
  4. fitRectInRect(Rectangle rect, Rectangle bounds)
  5. fits(Rectangle2D o1, Rectangle2D o2)
  6. fitsInside(Dimension2D dim, Rectangle2D rect)
  7. fitsRotated(Rectangle2D o1, Rectangle2D o2)
  8. reScale(Rectangle rect, int oldScale, int newScale)