home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- import netscape.util.ClassInfo;
- import netscape.util.Codable;
- import netscape.util.CodingException;
- import netscape.util.Decoder;
- import netscape.util.Encoder;
- import netscape.util.Vector;
-
- public class Size implements Codable {
- public int width;
- public int height;
- private static Vector _sizeCache = new Vector();
- private static boolean _cacheSizes = true;
- static final String WIDTH_KEY = "width";
- static final String HEIGHT_KEY = "height";
-
- public Size() {
- }
-
- public Size(int var1, int var2) {
- this.width = var1;
- this.height = var2;
- }
-
- public Size(Size var1) {
- this.width = var1.width;
- this.height = var1.height;
- }
-
- public boolean isEmpty() {
- return this.width == 0 || this.height == 0;
- }
-
- public String toString() {
- return "(" + this.width + ", " + this.height + ")";
- }
-
- public void sizeTo(int var1, int var2) {
- this.width = var1;
- this.height = var2;
- }
-
- public void sizeBy(int var1, int var2) {
- this.sizeTo(this.width + var1, this.height + var2);
- }
-
- public void union(Size var1) {
- if (this.width < var1.width) {
- this.width = var1.width;
- }
-
- if (this.height < var1.height) {
- this.height = var1.height;
- }
-
- }
-
- public boolean equals(Object var1) {
- if (!(var1 instanceof Size)) {
- return false;
- } else {
- Size var2 = (Size)var1;
- return var2.width == this.width && var2.height == this.height;
- }
- }
-
- public int hashCode() {
- return this.width ^ this.height;
- }
-
- public void describeClassInfo(ClassInfo var1) {
- var1.addClass("netscape.application.Size", 1);
- var1.addField("width", (byte)8);
- var1.addField("height", (byte)8);
- }
-
- public void encode(Encoder var1) throws CodingException {
- var1.encodeInt("width", this.width);
- var1.encodeInt("height", this.height);
- }
-
- public void decode(Decoder var1) throws CodingException {
- this.width = var1.decodeInt("width");
- this.height = var1.decodeInt("height");
- }
-
- public void finishDecoding() throws CodingException {
- }
-
- static Size newSize(int var0, int var1) {
- Vector var3 = _sizeCache;
- synchronized(var3){}
-
- Size var2;
- label47: {
- Size var5;
- try {
- if (_cacheSizes && !_sizeCache.isEmpty()) {
- var2 = (Size)_sizeCache.removeLastElement();
- break label47;
- }
-
- var5 = new Size(var0, var1);
- } catch (Throwable var7) {
- throw var7;
- }
-
- return var5;
- }
-
- var2.sizeTo(var0, var1);
- return var2;
- }
-
- static Size newSize(Size var0) {
- return var0 == null ? newSize(0, 0) : newSize(var0.width, var0.height);
- }
-
- static Size newSize() {
- return newSize(0, 0);
- }
-
- static void returnSize(Size var0) {
- if (_cacheSizes) {
- Vector var1 = _sizeCache;
- synchronized(var1){}
-
- try {
- if (_sizeCache.count() < 30) {
- _sizeCache.addElement(var0);
- }
- } catch (Throwable var3) {
- throw var3;
- }
-
- }
- }
-
- static void returnSizes(Vector var0) {
- if (var0 != null && _cacheSizes) {
- int var1 = var0.count();
-
- while(var1-- > 0) {
- returnSize((Size)var0.elementAt(var1));
- }
-
- var0.removeAllElements();
- }
- }
-
- static void setShouldCacheSizes(boolean var0) {
- Vector var1 = _sizeCache;
- synchronized(var1){}
-
- try {
- _cacheSizes = var0;
- if (!_cacheSizes) {
- _sizeCache.removeAllElements();
- }
- } catch (Throwable var3) {
- throw var3;
- }
-
- }
- }
-