Java Rectangle Bounds getBounds(Shape s)

Here you can find the source of getBounds(Shape s)

Description

get Bounds

License

Open Source License

Declaration

public final static Rectangle getBounds(Shape s) 

Method Source Code

//package com.java2s;
/*//from  w w  w. j a  va2  s  .c  om
 *  Copyright 2007, Plutext Pty Ltd.
 *   
 *  This file is part of Docx4all.
    
Docx4all is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License 
as published by the Free Software Foundation.
    
Docx4all 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 Docx4all.  If not, see <http://www.gnu.org/licenses/>.
    
 */

import java.awt.Rectangle;
import java.awt.Shape;

public class Main {
    public final static Rectangle getBounds(Shape s) {
        //Prevent from constructing a new Rectangle object
        //if Shape s is already a Rectangle
        return (s instanceof Rectangle) ? (Rectangle) s : s.getBounds();
    }
}

Related

  1. encodeBounds(Rectangle rBounds)
  2. exportBounds(Frame theFame, Document doc)
  3. getBoundsInAncestor(Container ancestor, final Component comp, Rectangle bounds)
  4. getCenteredBoundsOn(Rectangle srcBounds, int width, int height)
  5. getLocalBounds(Component aComponent)
  6. getLocalBounds(Rectangle bounds, Container c)