13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.awt;
27
28 import java.awt.*;
29 import java.awt.event.InputEvent;
30 import java.awt.event.KeyEvent;
31 import java.awt.event.WindowEvent;
32 import java.awt.image.BufferedImage;
33 import java.awt.image.DataBuffer;
34 import java.awt.image.DataBufferInt;
35 import java.awt.image.ImageObserver;
36 import java.awt.image.ImageProducer;
37 import java.awt.image.Raster;
38 import java.awt.peer.FramePeer;
39 import java.awt.peer.KeyboardFocusManagerPeer;
40 import java.awt.peer.MouseInfoPeer;
41 import java.awt.peer.SystemTrayPeer;
42 import java.awt.peer.TrayIconPeer;
43 import java.io.File;
44 import java.io.IOException;
45 import java.io.InputStream;
46 import java.lang.reflect.InvocationTargetException;
47 import java.net.URL;
48 import java.security.AccessController;
49 import java.util.ArrayList;
50 import java.util.Collections;
51 import java.util.Iterator;
52 import java.util.Locale;
543 throw new InvocationTargetException(eventThrowable);
544 }
545 }
546
547 /*
548 * Returns true if the calling thread is the event dispatch thread
549 * contained within AppContext which associated with the given target.
550 * Use this call to ensure that a given task is being executed
551 * (or not being) on the event dispatch thread for the given target.
552 */
553 public static boolean isDispatchThreadForAppContext(Object target) {
554 AppContext appContext = targetToAppContext(target);
555 EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
556
557 AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor();
558 return accessor.isDispatchThreadImpl(eq);
559 }
560
561 @Override
562 public Dimension getScreenSize() {
563 return new Dimension(getScreenWidth(), getScreenHeight());
564 }
565 protected abstract int getScreenWidth();
566 protected abstract int getScreenHeight();
567
568 @Override
569 @SuppressWarnings("deprecation")
570 public FontMetrics getFontMetrics(Font font) {
571 return FontDesignMetrics.getMetrics(font);
572 }
573
574 @Override
575 @SuppressWarnings("deprecation")
576 public String[] getFontList() {
577 String[] hardwiredFontList = {
578 Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED,
579 Font.DIALOG_INPUT
580
581 // -- Obsolete font names from 1.0.2. It was decided that
582 // -- getFontList should not return these old names:
583 // "Helvetica", "TimesRoman", "Courier", "ZapfDingbats"
584 };
585 return hardwiredFontList;
586 }
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.awt;
27
28 import java.awt.*;
29 import java.awt.event.InputEvent;
30 import java.awt.event.KeyEvent;
31 import java.awt.event.WindowEvent;
32 import java.awt.image.BufferedImage;
33 import java.awt.image.ColorModel;
34 import java.awt.image.DataBuffer;
35 import java.awt.image.DataBufferInt;
36 import java.awt.image.ImageObserver;
37 import java.awt.image.ImageProducer;
38 import java.awt.image.Raster;
39 import java.awt.peer.FramePeer;
40 import java.awt.peer.KeyboardFocusManagerPeer;
41 import java.awt.peer.MouseInfoPeer;
42 import java.awt.peer.SystemTrayPeer;
43 import java.awt.peer.TrayIconPeer;
44 import java.io.File;
45 import java.io.IOException;
46 import java.io.InputStream;
47 import java.lang.reflect.InvocationTargetException;
48 import java.net.URL;
49 import java.security.AccessController;
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.Iterator;
53 import java.util.Locale;
544 throw new InvocationTargetException(eventThrowable);
545 }
546 }
547
548 /*
549 * Returns true if the calling thread is the event dispatch thread
550 * contained within AppContext which associated with the given target.
551 * Use this call to ensure that a given task is being executed
552 * (or not being) on the event dispatch thread for the given target.
553 */
554 public static boolean isDispatchThreadForAppContext(Object target) {
555 AppContext appContext = targetToAppContext(target);
556 EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
557
558 AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor();
559 return accessor.isDispatchThreadImpl(eq);
560 }
561
562 @Override
563 public Dimension getScreenSize() {
564 return GraphicsEnvironment.getLocalGraphicsEnvironment()
565 .getDefaultScreenDevice().getDefaultConfiguration()
566 .getBounds().getSize();
567 }
568
569 @Override
570 public ColorModel getColorModel() throws HeadlessException {
571 return GraphicsEnvironment.getLocalGraphicsEnvironment()
572 .getDefaultScreenDevice().getDefaultConfiguration()
573 .getColorModel();
574 }
575
576 @Override
577 @SuppressWarnings("deprecation")
578 public FontMetrics getFontMetrics(Font font) {
579 return FontDesignMetrics.getMetrics(font);
580 }
581
582 @Override
583 @SuppressWarnings("deprecation")
584 public String[] getFontList() {
585 String[] hardwiredFontList = {
586 Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED,
587 Font.DIALOG_INPUT
588
589 // -- Obsolete font names from 1.0.2. It was decided that
590 // -- getFontList should not return these old names:
591 // "Helvetica", "TimesRoman", "Courier", "ZapfDingbats"
592 };
593 return hardwiredFontList;
594 }
|