Source Code Cross Referenced for DisplayMode.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.awt;
027
028        /**
029         * The <code>DisplayMode</code> class encapsulates the bit depth, height,
030         * width, and refresh rate of a <code>GraphicsDevice</code>. The ability to 
031         * change graphics device's display mode is platform- and 
032         * configuration-dependent and may not always be available 
033         * (see {@link GraphicsDevice#isDisplayChangeSupported}).
034         * <p>
035         * For more information on full-screen exclusive mode API, see the
036         * <a href="http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html">
037         * Full-Screen Exclusive Mode API Tutorial</a>.
038         *
039         * @see GraphicsDevice
040         * @see GraphicsDevice#isDisplayChangeSupported
041         * @see GraphicsDevice#getDisplayModes
042         * @see GraphicsDevice#setDisplayMode
043         * @author Michael Martak
044         * @since 1.4
045         */
046        public final class DisplayMode {
047
048            private Dimension size;
049            private int bitDepth;
050            private int refreshRate;
051
052            /**
053             * Create a new display mode object with the supplied parameters.
054             * @param width the width of the display, in pixels
055             * @param height the height of the display, in pixels
056             * @param bitDepth the bit depth of the display, in bits per
057             *        pixel.  This can be <code>BIT_DEPTH_MULTI</code> if multiple
058             *        bit depths are available.
059             * @param refreshRate the refresh rate of the display, in hertz.
060             *        This can be <code>REFRESH_RATE_UNKNOWN</code> if the
061             *        information is not available.
062             * @see #BIT_DEPTH_MULTI
063             * @see #REFRESH_RATE_UNKNOWN
064             */
065            public DisplayMode(int width, int height, int bitDepth,
066                    int refreshRate) {
067                this .size = new Dimension(width, height);
068                this .bitDepth = bitDepth;
069                this .refreshRate = refreshRate;
070            }
071
072            /**
073             * Returns the height of the display, in pixels.
074             * @return the height of the display, in pixels
075             */
076            public int getHeight() {
077                return size.height;
078            }
079
080            /**
081             * Returns the width of the display, in pixels.
082             * @return the width of the display, in pixels
083             */
084            public int getWidth() {
085                return size.width;
086            }
087
088            /**
089             * Value of the bit depth if multiple bit depths are supported in this
090             * display mode.
091             * @see #getBitDepth
092             */
093            public final static int BIT_DEPTH_MULTI = -1;
094
095            /**
096             * Returns the bit depth of the display, in bits per pixel.  This may be
097             * <code>BIT_DEPTH_MULTI</code> if multiple bit depths are supported in
098             * this display mode.
099             *
100             * @return the bit depth of the display, in bits per pixel.
101             * @see #BIT_DEPTH_MULTI
102             */
103            public int getBitDepth() {
104                return bitDepth;
105            }
106
107            /**
108             * Value of the refresh rate if not known.
109             * @see #getRefreshRate
110             */
111            public final static int REFRESH_RATE_UNKNOWN = 0;
112
113            /**
114             * Returns the refresh rate of the display, in hertz.  This may be
115             * <code>REFRESH_RATE_UNKNOWN</code> if the information is not available.
116             *
117             * @return the refresh rate of the display, in hertz.
118             * @see #REFRESH_RATE_UNKNOWN
119             */
120            public int getRefreshRate() {
121                return refreshRate;
122            }
123
124            /**
125             * Returns whether the two display modes are equal.
126             * @return whether the two display modes are equal
127             */
128            public boolean equals(DisplayMode dm) {
129                if (dm == null) {
130                    return false;
131                }
132                return (getHeight() == dm.getHeight()
133                        && getWidth() == dm.getWidth()
134                        && getBitDepth() == dm.getBitDepth() && getRefreshRate() == dm
135                        .getRefreshRate());
136            }
137
138            /**
139             * {@inheritDoc}
140             */
141            public boolean equals(Object dm) {
142                if (dm instanceof  DisplayMode) {
143                    return equals((DisplayMode) dm);
144                } else {
145                    return false;
146                }
147            }
148
149            /**
150             * {@inheritDoc}
151             */
152            public int hashCode() {
153                return getWidth() + getHeight() + getBitDepth() * 7
154                        + getRefreshRate() * 13;
155            }
156
157        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.