Here you can find the source of getRectangle(String rectStr)
Parameter | Description |
---|---|
rectStr | Rectangle as a comma delimited String. |
public static Rectangle getRectangle(String rectStr)
//package com.java2s; /*// w ww. j a v a2 s . c o m * JOGRE (Java Online Gaming Real-time Engine) - API * Copyright (C) 2004 Bob Marks (marksie531@yahoo.com) * http://jogre.sourceforge.org * * 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.Rectangle; import java.util.StringTokenizer; public class Main { /** * Return a Rectangle from a string of "x,y,w,h". Where (x,y) is the * upper left hand corner, and w,h is the width & height. * * @param rectStr Rectangle as a comma delimited String. * @return A Rectangle decoded from the String. */ public static Rectangle getRectangle(String rectStr) { try { StringTokenizer st = new StringTokenizer(rectStr, ","); int x = Integer.parseInt(st.nextToken().trim()); int y = Integer.parseInt(st.nextToken().trim()); int w = Integer.parseInt(st.nextToken().trim()); int h = Integer.parseInt(st.nextToken().trim()); return new Rectangle(x, y, w, h); } catch (Exception e) { return null; } } }