01: /*
02: This file is part of BORG.
03:
04: BORG is free software; you can redistribute it and/or modify
05: it under the terms of the GNU General Public License as published by
06: the Free Software Foundation; either version 2 of the License, or
07: (at your option) any later version.
08:
09: BORG is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU General Public License for more details.
13:
14: You should have received a copy of the GNU General Public License
15: along with BORG; if not, write to the Free Software
16: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: Copyright 2003 by Mike Berger
19: */
20: package net.sf.borg.ui;
21:
22: // this class contains information about a View's location, size, and if it is maximized
23: // it contains methods to convert this data to and from a String - to be used as a preference string
24: public class ViewSize {
25:
26: private int x = -1;
27: private int y = -1;
28: private int width = -1;
29: private int height = -1;
30: private boolean maximized = false;
31:
32: public ViewSize() {
33: }
34:
35: public int getHeight() {
36: return height;
37: }
38:
39: public void setHeight(int height) {
40: this .height = height;
41: }
42:
43: public boolean isMaximized() {
44: return maximized;
45: }
46:
47: public void setMaximized(boolean maximized) {
48: this .maximized = maximized;
49: }
50:
51: public int getWidth() {
52: return width;
53: }
54:
55: public void setWidth(int width) {
56: this .width = width;
57: }
58:
59: public int getX() {
60: return x;
61: }
62:
63: public void setX(int x) {
64: this .x = x;
65: }
66:
67: public int getY() {
68: return y;
69: }
70:
71: public void setY(int y) {
72: this .y = y;
73: }
74:
75: static public ViewSize fromString(String s) {
76: ViewSize vs = new ViewSize();
77: String toks[] = s.split(",");
78: vs.x = Integer.parseInt(toks[0]);
79: vs.y = Integer.parseInt(toks[1]);
80: vs.width = Integer.parseInt(toks[2]);
81: vs.height = Integer.parseInt(toks[3]);
82: if (toks[4].equals("Y"))
83: vs.maximized = true;
84: else
85: vs.maximized = false;
86:
87: return (vs);
88: }
89:
90: public String toString() {
91: return (Integer.toString(x) + "," + Integer.toString(y) + ","
92: + Integer.toString(width) + ","
93: + Integer.toString(height) + "," + ((maximized == true) ? "Y"
94: : "N"));
95: }
96: }
|