Here you can find the source of rectangleToString(Rectangle rectangle)
x,y,width,height
.
Parameter | Description |
---|---|
rectangle | rectangle |
public static String rectangleToString(Rectangle rectangle)
//package com.java2s; /*//w w w . j a va2 s . co m * Adito * * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ import java.awt.Rectangle; public class Main { /** * Convert a {@link Rectangle} object to a comma separated string in the * format of <code>x,y,width,height</code>. Suitable for storing * rectangles in property files, XML files etc. * * @param rectangle rectangle * @return comman separated string x,y,width,height */ public static String rectangleToString(Rectangle rectangle) { StringBuffer buf = new StringBuffer(String.valueOf(rectangle.x)); buf.append(','); buf.append(String.valueOf(rectangle.y)); buf.append(','); buf.append(String.valueOf(rectangle.width)); buf.append(','); buf.append(String.valueOf(rectangle.height)); return buf.toString(); } }