Java examples for 2D Graphics:Rectangle
Convert Rectangle2D to Rectangle
//package com.java2s; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; public class Main { public static Rectangle toRectangle(Rectangle2D b) { if (b == null) { return null; }/*from w ww . j a va 2s . c o m*/ if (b instanceof Rectangle) { return (Rectangle) b; } else { return new Rectangle((int) b.getX(), (int) b.getY(), (int) b.getWidth(), (int) b.getHeight()); } } }