01: /*
02: * $Id: ImageInfo.java,v 1.2 2007/12/20 18:17:41 rbair Exp $
03: *
04: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
05: * Santa Clara, California 95054, U.S.A. All rights reserved.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20: */
21:
22: package com.sun.pdfview;
23:
24: import java.awt.geom.Rectangle2D;
25: import java.awt.Color;
26:
27: public class ImageInfo {
28: int width;
29: int height;
30: Rectangle2D clip;
31: Color bgColor;
32:
33: public ImageInfo(int width, int height, Rectangle2D clip) {
34: this (width, height, clip, Color.WHITE);
35: }
36:
37: public ImageInfo(int width, int height, Rectangle2D clip,
38: Color bgColor) {
39: this .width = width;
40: this .height = height;
41: this .clip = clip;
42: this .bgColor = bgColor;
43: }
44:
45: // a hashcode that uses width, height and clip to generate its number
46: @Override
47: public int hashCode() {
48: int code = (width ^ height << 16);
49:
50: if (clip != null) {
51: code ^= ((int) clip.getWidth() | (int) clip.getHeight()) << 8;
52: code ^= ((int) clip.getMinX() | (int) clip.getMinY());
53: }
54:
55: return code;
56: }
57:
58: // an equals method that compares values
59: @Override
60: public boolean equals(Object o) {
61: if (!(o instanceof ImageInfo)) {
62: return false;
63: }
64:
65: ImageInfo ii = (ImageInfo) o;
66:
67: if (width != ii.width || height != ii.height) {
68: return false;
69: } else if (clip != null && ii.clip != null) {
70: return clip.equals(ii.clip);
71: } else if (clip == null && ii.clip == null) {
72: return true;
73: } else {
74: return false;
75: }
76: }
77: }
|