Java Utililty Methods Rectangle Create Parse

List of utility methods to do Rectangle Create Parse

  1. HOME
  2. Java
  3. R
  4. Rectangle Create Parse

Description

The list of methods to do Rectangle Create Parse are organized into topic(s).

Method

Rectangle decodeBounds(String sBounds)
Decode the comma separated values stored in sBounds.
int index;
int ii;
int theValue[] = new int[4];
String tmpString;
String restString = sBounds;
for (ii = 0; ii < 4; ii++) {
 theValue[ii] = 0;
try {
 for (ii = 0; ii < 4; ii++) {
 index = restString.indexOf(","); 
 if (index > 0) {
 tmpString = restString.substring(0, index);
 restString = restString.substring(index + 1);
 } else {
 tmpString = restString; 
 restString = null; 
 theValue[ii] = Integer.valueOf(tmpString).intValue();
} catch (Exception ee)
return new Rectangle(theValue[0], theValue[1], theValue[2], theValue[3]);
Rectangle getRectangle(Map bounds)
Extract a rectangle which has been serialised to JSON as x,y,w,h.
return new Rectangle(getInt(bounds, "x"), getInt(bounds, "y"), getInt(bounds, "width"),
 getInt(bounds, "height"));
Rectangle getRectangle(Preferences prefs, String sName, int iDefaultWidth, int iDefaultHeight)
reads a rectangle from the preferences
final Preferences node = prefs.node(sName);
final int x = node.getInt(PREFS_KEY_RECTANGLE_X, 0);
final int y = node.getInt(PREFS_KEY_RECTANGLE_Y, 0);
final int width = node.getInt(PREFS_KEY_RECTANGLE_WIDTH, iDefaultWidth);
final int height = node.getInt(PREFS_KEY_RECTANGLE_HEIGHT, iDefaultHeight);
return new Rectangle(x, y, width, height);
Rectangle getRectangle(Properties prop, final String key, final Rectangle def)
get Rectangle
try {
 final Rectangle result = new Rectangle();
 result.x = getInteger(prop, key.concat("-x"));
 result.y = getInteger(prop, key.concat("-y"));
 result.width = getInteger(prop, key.concat("-w"));
 result.height = getInteger(prop, key.concat("-h"));
 return result;
} catch (Exception e) {
...
Rectangle getRectangle(String rectStr)
Return a Rectangle from a string of "x,y,w,h".
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) {
...
Rectangle newRectangle(int x1, int y1, int x2, int y2)
creates a rectangle out of two points.
final int x = Math.min(x1, x2);
final int y = Math.min(y1, y2);
final int w = Math.abs(x1 - x2 + 1);
final int h = Math.abs(y1 - y2 + 1);
return new Rectangle(x, y, w, h);
String rectangleToString(Rectangle r)
rectangle To String
StringBuilder buf = new StringBuilder();
buf.append(String.valueOf(r.x));
buf.append(",");
buf.append(String.valueOf(r.y));
buf.append(",");
buf.append(String.valueOf(r.width));
buf.append(",");
buf.append(String.valueOf(r.height));
...
String rectangleToString(Rectangle r)
rectangle To String
return r.x + "," + r.y + "," + r.width + "," + r.height;
String rectangleToString(Rectangle rectangle)
Convert a Rectangle object to a comma separated string in the format of x,y,width,height.
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();
...
void storeBounds(String name, Window window)
Call this to record the fact that the window/dialog with the given name has moved.
dialogGeometries.put(name, window.getBounds());


AltStyle によって変換されたページ (->オリジナル) /