Java Rectangle rectangleResize(Rectangle rect, int width, int height)

Here you can find the source of rectangleResize(Rectangle rect, int width, int height)

Description

rectangle Resize

License

Open Source License

Declaration

public static Rectangle rectangleResize(Rectangle rect, int width, int height) 

Method Source Code

//package com.java2s;
/*************************************************************************
    /*w ww .  j av a  2 s .c  o m*/
Copyright (C) 2009 Grandite
    
This file is part of Open ModelSphere.
    
Open ModelSphere 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 3 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 
or see http://www.gnu.org/licenses/.
    
You can redistribute and/or modify this particular file even under the
terms of the GNU Lesser General Public License (LGPL) as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
    
You should have received a copy of the GNU Lesser General Public License 
(LGPL) along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
or see http://www.gnu.org/licenses/.
    
You can reach Grandite at: 
    
20-1220 Lebourgneuf Blvd.
Quebec, QC
Canada  G2K 2G4
    
or
    
open-modelsphere@grandite.com
    
 **********************************************************************/

import java.awt.*;

public class Main {
    public static Rectangle rectangleResize(Rectangle rect, int width, int height) {
        return new Rectangle(rect.x + (rect.width - width) / 2, rect.y + (rect.height - height) / 2, width, height);
    }
}

Related

  1. interpolate(Rectangle r1, Rectangle r2, float f)
  2. mergeRects(Set prev, Set current)
  3. normalizeRect(Rectangle rect)
  4. randomRectangle(int minW, int maxW, int minH, int maxH)
  5. randomSquare(int minW, int maxW)
  6. rectCollide(final Rectangle a, final Rectangle b)
  7. rectDistance(final Rectangle r, final Rectangle q)
  8. rectFromArray(Rectangle2D aRectangle, double[] pts)
  9. rectFromRect2D(Rectangle2D rect)