1 7 8 package java.awt; 9 10 18 public final class DisplayMode { 19 20 private Dimension size; 21 private int bitDepth; 22 private int refreshRate; 23 24 37 public DisplayMode(int width, int height, int bitDepth, int refreshRate) { 38 this.size = new Dimension (width, height); 39 this.bitDepth = bitDepth; 40 this.refreshRate = refreshRate; 41 } 42 43 46 public int getHeight() { 47 return size.height; 48 } 49 50 53 public int getWidth() { 54 return size.width; 55 } 56 57 62 public final static int BIT_DEPTH_MULTI = -1; 63 69 public int getBitDepth() { 70 return bitDepth; 71 } 72 73 77 public final static int REFRESH_RATE_UNKNOWN = 0; 78 83 public int getRefreshRate() { 84 return refreshRate; 85 } 86 87 90 public boolean equals(DisplayMode dm) { 91 if (dm == null) { 92 return false; 93 } 94 return (getHeight() == dm.getHeight() 95 && getWidth() == dm.getWidth() 96 && getBitDepth() == dm.getBitDepth() 97 && getRefreshRate() == dm.getRefreshRate()); 98 } 99 100 103 public boolean equals(Object dm) { 104 if (dm instanceof DisplayMode ) { 105 return equals((DisplayMode )dm); 106 } else { 107 return false; 108 } 109 } 110 111 114 public int hashCode() { 115 return getWidth() + getHeight() + getBitDepth() * 7 116 + getRefreshRate() * 13; 117 } 118 119 } 120 | Popular Tags |