Debian Codegraph @

src/com/jidesoft/awt/geom/Insets2D.java

raw
1 /*
2 * @(#)Insets2D.java
3 *
4 * 2002 - 2012 JIDE Software Incorporated. All rights reserved.
5 * Copyright (c) 2005 - 2012 Catalysoft Limited. All rights reserved.
6 */
7 package com.jidesoft.awt.geom;
8
9 import java.io.Serializable;
10
11 /**
12 * Similar to java.awt.Insets, but with doubles for the top, left, bottom, right values.
13 * This means that instances of this class can be used for setting proportionally sized insets
14 * which are better for components that should retain their shape and overall appearance when they
15 * are re-sized.
16 *
17 * @see java.awt.Insets
18 */
19 public abstract class Insets2D implements Serializable {
20
21 private static final long serialVersionUID = -7723331225837606159L;
22
23 /**
24 * Returns the inset from the top in double precision
25 * @return the inset from the top in double precision
26 */
27 public abstract double getTop();
28
29 /**
30 * Returns the inset from the left in double precision
31 * @return the inset from the left in double precision
32 */
33 public abstract double getLeft();
34
35 /**
36 * Returns the inset from the bottom in double precision
37 * @return the inset from the bottom in double precision
38 */
39 public abstract double getBottom();
40
41 /**
42 * Returns the inset from the right in double precision
43 * @return the inset from the right in double precision
44 */
45 public abstract double getRight();
46
47 /**
48 * An Insets2D instance specified with double precision
49 */
50 public static class Double extends Insets2D implements Serializable {
51
52 private static final long serialVersionUID = 4310600205031805311L;
53
54 /**
55 * The inset from the top
56 */
57 public double top;
58
59 /**
60 * The inset from the left
61 */
62 public double left;
63
64 /**
65 * The inset from the bottom
66 */
67 public double bottom;
68
69 /**
70 * The inset from the right
71 */
72 public double right;
73
74 /**
75 * Construct an Insets2D instance using double precision
76 * @param top the inset from the top
77 * @param left the inset from the left
78 * @param bottom the inset from the bottom
79 * @param right the inset from the right
80 */
81 public Double(double top, double left, double bottom, double right) {
82 this.top = top;
83 this.left = left;
84 this.bottom = bottom;
85 this.right = right;
86 }
87
88 /**
89 * Sets the insets
90 * @param top the inset from the top
91 * @param left the inset from the left
92 * @param bottom the inset from the bottom
93 * @param right the inset from the right
94 */
95 public void set(double top, double left, double bottom, double right) {
96 this.top = top;
97 this.left = left;
98 this.bottom = bottom;
99 this.right = right;
100 }
101
102 /**
103 * {@inheritDoc}
104 */
105 public double getBottom() {
106 return bottom;
107 }
108
109 /**
110 * {@inheritDoc}
111 */
112 public double getLeft() {
113 return left;
114 }
115
116 /**
117 * {@inheritDoc}
118 */
119 public double getRight() {
120 return right;
121 }
122
123 /**
124 * {@inheritDoc}
125 */
126 public double getTop() {
127 return top;
128 }
129
130 }
131
132 /**
133 * An Insets2D instance specified with float precision
134 */
135 public static class Float extends Insets2D implements Serializable {
136
137 private static final long serialVersionUID = 4796948322194231916L;
138
139 public float top, left, bottom, right;
140
141 /**
142 * Construct an Insets2D instance using float precision
143 * @param top the inset from the top
144 * @param left the inset from the left
145 * @param bottom the inset from the bottom
146 * @param right the inset from the right
147 */
148 public Float(float top, float left, float bottom, float right) {
149 this.top = top;
150 this.left = left;
151 this.bottom = bottom;
152 this.right = right;
153 }
154
155 /**
156 * Sets the insets with float precision
157 * @param top the inset from the top
158 * @param left the inset from the left
159 * @param bottom the inset from the bottom
160 * @param right the inset from the right
161 */
162 public void set(float top, float left, float bottom, float right) {
163 this.top = top;
164 this.left = left;
165 this.bottom = bottom;
166 this.right = right;
167 }
168
169 /**
170 * {@inheritDoc}
171 */
172 public double getBottom() {
173 return (double) bottom;
174 }
175
176 /**
177 * {@inheritDoc}
178 */
179 public double getLeft() {
180 return (double) left;
181 }
182
183 /**
184 * {@inheritDoc}
185 */
186 public double getRight() {
187 return (double) right;
188 }
189
190 /**
191 * {@inheritDoc}
192 */
193 public double getTop() {
194 return (double) top;
195 }
196
197 }
198 }