001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexey A. Petrenko
019: * @version $Revision$
020: */package java.awt;
021:
022: import org.apache.harmony.awt.internal.nls.Messages;
023:
024: public abstract class GraphicsDevice {
025: private DisplayMode displayMode;
026:
027: private Window fullScreenWindow = null;
028:
029: /***************************************************************************
030: *
031: * Constants
032: *
033: ***************************************************************************/
034:
035: public static final int TYPE_IMAGE_BUFFER = 2;
036:
037: public static final int TYPE_PRINTER = 1;
038:
039: public static final int TYPE_RASTER_SCREEN = 0;
040:
041: /***************************************************************************
042: *
043: * Constructors
044: *
045: ***************************************************************************/
046:
047: protected GraphicsDevice() {
048: displayMode = new DisplayMode(0, 0,
049: DisplayMode.BIT_DEPTH_MULTI,
050: DisplayMode.REFRESH_RATE_UNKNOWN);
051: }
052:
053: /***************************************************************************
054: *
055: * Abstract methods
056: *
057: ***************************************************************************/
058:
059: public abstract GraphicsConfiguration[] getConfigurations();
060:
061: public abstract GraphicsConfiguration getDefaultConfiguration();
062:
063: public abstract String getIDstring();
064:
065: public abstract int getType();
066:
067: /***************************************************************************
068: *
069: * Public methods
070: *
071: ***************************************************************************/
072:
073: public int getAvailableAcceleratedMemory() {
074: return 0;
075: }
076:
077: public GraphicsConfiguration getBestConfiguration(
078: GraphicsConfigTemplate gct) {
079: return gct.getBestConfiguration(getConfigurations());
080: }
081:
082: public DisplayMode getDisplayMode() {
083: return displayMode;
084: }
085:
086: public DisplayMode[] getDisplayModes() {
087: DisplayMode[] dms = { displayMode };
088: return dms;
089: }
090:
091: public Window getFullScreenWindow() {
092: return fullScreenWindow;
093: }
094:
095: public boolean isDisplayChangeSupported() {
096: return false;
097: }
098:
099: public boolean isFullScreenSupported() {
100: return false;
101: }
102:
103: public void setDisplayMode(DisplayMode dm) {
104: if (!isDisplayChangeSupported()) {
105: // awt.122=Does not support display mode changes
106: throw new UnsupportedOperationException(Messages
107: .getString("awt.122")); //$NON-NLS-1$
108: }
109:
110: DisplayMode[] dms = getDisplayModes();
111: for (DisplayMode element : dms) {
112: if (element.equals(dm)) {
113: displayMode = dm;
114: return;
115: }
116: }
117: // awt.123=Unsupported display mode: {0}
118: throw new IllegalArgumentException(Messages.getString(
119: "awt.123", dm)); //$NON-NLS-1$
120: }
121:
122: public void setFullScreenWindow(Window w) {
123: if (w == null) {
124: fullScreenWindow = null;
125: return;
126: }
127:
128: fullScreenWindow = w;
129:
130: if (isFullScreenSupported()) {
131: w.enableInputMethods(false);
132: } else {
133: w.setSize(displayMode.getWidth(), displayMode.getHeight());
134: w.setLocation(0, 0);
135: }
136: w.setVisible(true);
137: w.setAlwaysOnTop(true);
138: }
139: }
|