The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame^] | 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 | |
| 22 | package java.awt; |
| 23 | |
| 24 | import org.apache.harmony.awt.internal.nls.Messages; |
| 25 | |
| 26 | /** |
| 27 | * The GraphicsDevice class describes the graphics devices (such as screens or |
| 28 | * printers) which are available in a particular graphics environment. Many |
| 29 | * GraphicsDevice instances can be associated with a single GraphicsEnvironment. |
| 30 | * Each GraphicsDevice has one or more GraphicsConfiguration objects which |
| 31 | * specify the different configurations and modes of GraphicsDevice. |
| 32 | * |
| 33 | * @since Android 1.0 |
| 34 | */ |
| 35 | public abstract class GraphicsDevice { |
| 36 | |
| 37 | /** |
| 38 | * The display mode. |
| 39 | */ |
| 40 | private DisplayMode displayMode; |
| 41 | |
| 42 | // ???AWT |
| 43 | // private Window fullScreenWindow = null; |
| 44 | |
| 45 | /** |
| 46 | * The Constant TYPE_IMAGE_BUFFER indicates a image buffer device. |
| 47 | */ |
| 48 | |
| 49 | public static final int TYPE_IMAGE_BUFFER = 2; |
| 50 | |
| 51 | /** |
| 52 | * The Constant TYPE_PRINTER indicates a printer device. |
| 53 | */ |
| 54 | public static final int TYPE_PRINTER = 1; |
| 55 | |
| 56 | /** |
| 57 | * The Constant TYPE_RASTER_SCREEN indicates a raster screen device. |
| 58 | */ |
| 59 | public static final int TYPE_RASTER_SCREEN = 0; |
| 60 | |
| 61 | /** |
| 62 | * Constructor is not to be used directly as this class is abstract. |
| 63 | */ |
| 64 | protected GraphicsDevice() { |
| 65 | displayMode = new DisplayMode(0, 0, DisplayMode.BIT_DEPTH_MULTI, |
| 66 | DisplayMode.REFRESH_RATE_UNKNOWN); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns an array of GraphicsConfiguration objects associated with the |
| 71 | * GraphicsDevice. |
| 72 | * |
| 73 | * @return an array of GraphicsConfiguration objects associated with the |
| 74 | * GraphicsDevice. |
| 75 | */ |
| 76 | public abstract GraphicsConfiguration[] getConfigurations(); |
| 77 | |
| 78 | /** |
| 79 | * Gets the default configuration for the GraphicsDevice. |
| 80 | * |
| 81 | * @return the default GraphicsConfiguration object for the GraphicsDevice. |
| 82 | */ |
| 83 | public abstract GraphicsConfiguration getDefaultConfiguration(); |
| 84 | |
| 85 | /** |
| 86 | * Gets the String identifier which associated with the GraphicsDevice in |
| 87 | * the GraphicsEnvironment. |
| 88 | * |
| 89 | * @return the String identifier of the GraphicsDevice in the |
| 90 | * GraphicsEnvironment. |
| 91 | */ |
| 92 | public abstract String getIDstring(); |
| 93 | |
| 94 | /** |
| 95 | * Gets the type of this GraphicsDevice: TYPE_IMAGE_BUFFER, TYPE_PRINTER or |
| 96 | * TYPE_RASTER_SCREEN. |
| 97 | * |
| 98 | * @return the type of this GraphicsDevice: TYPE_IMAGE_BUFFER, TYPE_PRINTER |
| 99 | * or TYPE_RASTER_SCREEN. |
| 100 | */ |
| 101 | public abstract int getType(); |
| 102 | |
| 103 | /** |
| 104 | * Returns the number of bytes available in accelerated memory on this |
| 105 | * device. |
| 106 | * |
| 107 | * @return the number of bytes available accelerated memory. |
| 108 | */ |
| 109 | public int getAvailableAcceleratedMemory() { |
| 110 | return 0; |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | * ???AWT public GraphicsConfiguration |
| 115 | * getBestConfiguration(GraphicsConfigTemplate gct) { return |
| 116 | * gct.getBestConfiguration(getConfigurations()); } |
| 117 | */ |
| 118 | |
| 119 | /** |
| 120 | * Gets the current display mode of the GraphicsDevice. |
| 121 | * |
| 122 | * @return the current display mode of the GraphicsDevice. |
| 123 | */ |
| 124 | public DisplayMode getDisplayMode() { |
| 125 | return displayMode; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * Gets an array of display modes available in this GraphicsDevice. |
| 130 | * |
| 131 | * @return an array of display modes available in this GraphicsDevice. |
| 132 | */ |
| 133 | public DisplayMode[] getDisplayModes() { |
| 134 | DisplayMode[] dms = { |
| 135 | displayMode |
| 136 | }; |
| 137 | return dms; |
| 138 | } |
| 139 | |
| 140 | /* |
| 141 | * ???AWT public Window getFullScreenWindow() { return fullScreenWindow; } |
| 142 | */ |
| 143 | |
| 144 | /** |
| 145 | * Returns true if this GraphicsDevice supports low-level display changes. |
| 146 | * |
| 147 | * @return true, if this GraphicsDevice supports low-level display changes; |
| 148 | * false otherwise. |
| 149 | */ |
| 150 | public boolean isDisplayChangeSupported() { |
| 151 | return false; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Returns true if this GraphicsDevice supports full screen mode. |
| 156 | * |
| 157 | * @return true, if this GraphicsDevice supports full screen mode, false |
| 158 | * otherwise. |
| 159 | */ |
| 160 | public boolean isFullScreenSupported() { |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | // an array of display modes available in this GraphicsDevice. |
| 165 | |
| 166 | /** |
| 167 | * Sets the display mode of this GraphicsDevice. |
| 168 | * |
| 169 | * @param dm |
| 170 | * the new display mode of this GraphicsDevice. |
| 171 | */ |
| 172 | public void setDisplayMode(DisplayMode dm) { |
| 173 | if (!isDisplayChangeSupported()) { |
| 174 | // awt.122=Does not support display mode changes |
| 175 | throw new UnsupportedOperationException(Messages.getString("awt.122")); //$NON-NLS-1$ |
| 176 | } |
| 177 | |
| 178 | DisplayMode[] dms = getDisplayModes(); |
| 179 | for (DisplayMode element : dms) { |
| 180 | if (element.equals(dm)) { |
| 181 | displayMode = dm; |
| 182 | return; |
| 183 | } |
| 184 | } |
| 185 | // awt.123=Unsupported display mode: {0} |
| 186 | throw new IllegalArgumentException(Messages.getString("awt.123", dm)); //$NON-NLS-1$ |
| 187 | } |
| 188 | |
| 189 | /* |
| 190 | * ???AWT public void setFullScreenWindow(Window w) { if (w == null) { |
| 191 | * fullScreenWindow = null; return; } fullScreenWindow = w; if |
| 192 | * (isFullScreenSupported()) { w.enableInputMethods(false); } else { |
| 193 | * w.setSize(displayMode.getWidth(), displayMode.getHeight()); |
| 194 | * w.setLocation(0, 0); } w.setVisible(true); w.setAlwaysOnTop(true); } |
| 195 | */ |
| 196 | } |