1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17/** 18 * @author Alexey A. Petrenko 19 * @version $Revision$ 20 */ 21 22package java.awt; 23 24/** 25 * The DisplayMode class contains the bit depth, height, width and refresh rate 26 * of a GraphicsDevice. 27 * 28 * @since Android 1.0 29 */ 30public final class DisplayMode { 31 32 /** 33 * The width. 34 */ 35 private final int width; 36 37 /** 38 * The height. 39 */ 40 private final int height; 41 42 /** 43 * The bit depth. 44 */ 45 private final int bitDepth; 46 47 /** 48 * The refresh rate. 49 */ 50 private final int refreshRate; 51 52 /** 53 * The Constant Value BIT_DEPTH_MULTI indicates the bit depth 54 */ 55 56 public static final int BIT_DEPTH_MULTI = -1; 57 58 /** 59 * The Constant REFRESH_RATE_UNKNOWN indicates the refresh rate. 60 */ 61 public static final int REFRESH_RATE_UNKNOWN = 0; 62 63 /** 64 * Creates a new DisplayMode object with the specified parameters. 65 * 66 * @param width 67 * the width of the display. 68 * @param height 69 * the height of the display. 70 * @param bitDepth 71 * the bit depth of the display. 72 * @param refreshRate 73 * the refresh rate of the display. 74 */ 75 76 public DisplayMode(int width, int height, int bitDepth, int refreshRate) { 77 this.width = width; 78 this.height = height; 79 this.bitDepth = bitDepth; 80 this.refreshRate = refreshRate; 81 } 82 83 /** 84 * Compares if this DisplayMode is equal to the specified object or not. 85 * 86 * @param dm 87 * the Object to be compared. 88 * @return true, if the specified object is a DisplayMode with the same data 89 * values as this DisplayMode, false otherwise. 90 */ 91 92 @Override 93 public boolean equals(Object dm) { 94 if (dm instanceof DisplayMode) { 95 return equals((DisplayMode)dm); 96 } 97 return false; 98 } 99 100 /** 101 * Compares if this DisplayMode is equal to the specified DisplayMode object 102 * or not. 103 * 104 * @param dm 105 * the DisplayMode to be compared. 106 * @return true, if all of the data values of this DisplayMode are equal to 107 * the values of the specified DisplayMode object, false otherwise. 108 */ 109 public boolean equals(DisplayMode dm) { 110 if (dm == null) { 111 return false; 112 } 113 if (dm.bitDepth != bitDepth) { 114 return false; 115 } 116 if (dm.refreshRate != refreshRate) { 117 return false; 118 } 119 if (dm.width != width) { 120 return false; 121 } 122 if (dm.height != height) { 123 return false; 124 } 125 return true; 126 } 127 128 /** 129 * Gets the bit depth of the DisplayMode, returns BIT_DEPTH_MULTI value if 130 * multiple bit depths are supported in this display mode. 131 * 132 * @return the bit depth of the DisplayMode. 133 */ 134 public int getBitDepth() { 135 return bitDepth; 136 } 137 138 /** 139 * Gets the height of the DisplayMode. 140 * 141 * @return the height of the DisplayMode. 142 */ 143 public int getHeight() { 144 return height; 145 } 146 147 /** 148 * Gets the refresh rate of the DisplayMode, returns REFRESH_RATE_UNKNOWN 149 * value if the information is not available. 150 * 151 * @return the refresh rate of the DisplayMode. 152 */ 153 public int getRefreshRate() { 154 return refreshRate; 155 } 156 157 /** 158 * Gets the width of the DisplayMode. 159 * 160 * @return the width of the DisplayMode. 161 */ 162 public int getWidth() { 163 return width; 164 } 165} 166