src/java.desktop/share/classes/sun/awt/SunToolkit.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,64 **** */ package sun.awt; import java.awt.*; - import static java.awt.RenderingHints.*; - import java.awt.dnd.*; - import java.awt.dnd.peer.DragSourceContextPeer; - import java.awt.peer.*; - import java.awt.event.WindowEvent; - import java.awt.event.KeyEvent; - import java.awt.image.*; - import java.awt.TrayIcon; - import java.awt.SystemTray; import java.awt.event.InputEvent; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; ! import java.security.PrivilegedAction; ! import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; - import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; - import sun.awt.datatransfer.DataTransferer; - import sun.util.logging.PlatformLogger; - import sun.misc.SoftCache; - import sun.font.FontDesignMetrics; import sun.awt.im.InputContext; ! import sun.awt.image.*; ! import sun.security.action.GetPropertyAction; import sun.security.action.GetBooleanAction; ! import java.lang.reflect.InvocationTargetException; ! import java.security.AccessController; public abstract class SunToolkit extends Toolkit implements ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider { // 8014718: logging has been removed from SunToolkit --- 24,78 ---- */ package sun.awt; import java.awt.*; import java.awt.event.InputEvent; + import java.awt.event.KeyEvent; + import java.awt.event.WindowEvent; + import java.awt.image.BufferedImage; + import java.awt.image.DataBuffer; + import java.awt.image.DataBufferInt; + import java.awt.image.ImageObserver; + import java.awt.image.ImageProducer; + import java.awt.image.Raster; + import java.awt.peer.FramePeer; + import java.awt.peer.KeyboardFocusManagerPeer; + import java.awt.peer.MouseInfoPeer; + import java.awt.peer.SystemTrayPeer; + import java.awt.peer.TrayIconPeer; import java.io.File; import java.io.IOException; import java.io.InputStream; + import java.lang.reflect.InvocationTargetException; import java.net.URL; ! import java.security.AccessController; ! import java.util.Collections; ! import java.util.Iterator; ! import java.util.Locale; ! import java.util.Map; ! import java.util.Vector; ! import java.util.WeakHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; import sun.awt.im.InputContext; ! import sun.awt.image.ByteArrayImageSource; ! import sun.awt.image.FileImageSource; ! import sun.awt.image.ImageRepresentation; ! import sun.awt.image.MultiResolutionImage; ! import sun.awt.image.MultiResolutionToolkitImage; ! import sun.awt.image.ToolkitImage; ! import sun.awt.image.URLImageSource; ! import sun.font.FontDesignMetrics; ! import sun.misc.SoftCache; import sun.security.action.GetBooleanAction; ! import sun.security.action.GetPropertyAction; ! import sun.util.logging.PlatformLogger; ! ! import static java.awt.RenderingHints.*; public abstract class SunToolkit extends Toolkit implements ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider { // 8014718: logging has been removed from SunToolkit
*** 132,216 **** public boolean useBufferPerWindow() { return false; } - public abstract WindowPeer createWindow(Window target) - throws HeadlessException; - - public abstract FramePeer createFrame(Frame target) - throws HeadlessException; - public abstract FramePeer createLightweightFrame(LightweightFrame target) throws HeadlessException; - public abstract DialogPeer createDialog(Dialog target) - throws HeadlessException; - - public abstract ButtonPeer createButton(Button target) - throws HeadlessException; - - public abstract TextFieldPeer createTextField(TextField target) - throws HeadlessException; - - public abstract ChoicePeer createChoice(Choice target) - throws HeadlessException; - - public abstract LabelPeer createLabel(Label target) - throws HeadlessException; - - public abstract ListPeer createList(java.awt.List target) - throws HeadlessException; - - public abstract CheckboxPeer createCheckbox(Checkbox target) - throws HeadlessException; - - public abstract ScrollbarPeer createScrollbar(Scrollbar target) - throws HeadlessException; - - public abstract ScrollPanePeer createScrollPane(ScrollPane target) - throws HeadlessException; - - public abstract TextAreaPeer createTextArea(TextArea target) - throws HeadlessException; - - public abstract FileDialogPeer createFileDialog(FileDialog target) - throws HeadlessException; - - public abstract MenuBarPeer createMenuBar(MenuBar target) - throws HeadlessException; - - public abstract MenuPeer createMenu(Menu target) - throws HeadlessException; - - public abstract PopupMenuPeer createPopupMenu(PopupMenu target) - throws HeadlessException; - - public abstract MenuItemPeer createMenuItem(MenuItem target) - throws HeadlessException; - - public abstract CheckboxMenuItemPeer createCheckboxMenuItem( - CheckboxMenuItem target) - throws HeadlessException; - - public abstract DragSourceContextPeer createDragSourceContextPeer( - DragGestureEvent dge) - throws InvalidDnDOperationException; - public abstract TrayIconPeer createTrayIcon(TrayIcon target) throws HeadlessException, AWTException; public abstract SystemTrayPeer createSystemTray(SystemTray target); public abstract boolean isTraySupported(); ! @SuppressWarnings("deprecation") ! public abstract FontPeer getFontPeer(String name, int style); ! ! public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen) ! throws AWTException; ! public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException; /** * The AWT lock is typically only used on Unix platforms to synchronize --- 146,166 ---- public boolean useBufferPerWindow() { return false; } public abstract FramePeer createLightweightFrame(LightweightFrame target) throws HeadlessException; public abstract TrayIconPeer createTrayIcon(TrayIcon target) throws HeadlessException, AWTException; public abstract SystemTrayPeer createSystemTray(SystemTray target); public abstract boolean isTraySupported(); ! @Override public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException; /** * The AWT lock is typically only used on Unix platforms to synchronize
*** 509,518 **** --- 459,469 ---- /* * Post AWTEvent of high priority. */ public static void postPriorityEvent(final AWTEvent e) { PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() { + @Override public void run() { AWTAccessor.getAWTEventAccessor().setPosted(e); ((Component)e.getSource()).dispatchEvent(e); } }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
*** 559,568 **** --- 510,520 ---- public static void executeOnEventHandlerThread(Object target, Runnable runnable, final long when) { executeOnEventHandlerThread( new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT) { + @Override public long getWhen() { return when; } }); }
*** 634,654 **** --- 586,609 ---- AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor(); return accessor.isDispatchThreadImpl(eq); } + @Override public Dimension getScreenSize() { return new Dimension(getScreenWidth(), getScreenHeight()); } protected abstract int getScreenWidth(); protected abstract int getScreenHeight(); + @Override @SuppressWarnings("deprecation") public FontMetrics getFontMetrics(Font font) { return FontDesignMetrics.getMetrics(font); } + @Override @SuppressWarnings("deprecation") public String[] getFontList() { String[] hardwiredFontList = { Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED, Font.DIALOG_INPUT
*** 658,675 **** // "Helvetica", "TimesRoman", "Courier", "ZapfDingbats" }; return hardwiredFontList; } - public PanelPeer createPanel(Panel target) { - return (PanelPeer)createComponent(target); - } - - public CanvasPeer createCanvas(Canvas target) { - return (CanvasPeer)createComponent(target); - } - /** * Disables erasing of background on the canvas before painting if * this is supported by the current toolkit. It is recommended to * call this method early, before the Canvas becomes displayable, * because some Toolkit implementations do not support changing --- 613,622 ----
*** 745,758 **** --- 692,707 ---- } return img; } } + @Override public Image getImage(String filename) { return getImageFromHash(this, filename); } + @Override public Image getImage(URL url) { return getImageFromHash(this, url); } protected Image getImageWithResolutionVariant(String fileName,
*** 782,814 **** --- 731,768 ---- return image; } } + @Override public Image createImage(String filename) { checkPermissions(filename); return createImage(new FileImageSource(filename)); } + @Override public Image createImage(URL url) { checkPermissions(url); return createImage(new URLImageSource(url)); } + @Override public Image createImage(byte[] data, int offset, int length) { return createImage(new ByteArrayImageSource(data, offset, length)); } + @Override public Image createImage(ImageProducer producer) { return new ToolkitImage(producer); } public static Image createImageWithResolutionVariant(Image image, Image resolutionVariant) { return new MultiResolutionToolkitImage(image, resolutionVariant); } + @Override public int checkImage(Image img, int w, int h, ImageObserver o) { if (!(img instanceof ToolkitImage)) { return ImageObserver.ALLBITS; }
*** 820,829 **** --- 774,784 ---- repbits = tkimg.getImageRep().check(o); } return (tkimg.check(o) | repbits) & checkResolutionVariant(img, w, h, o); } + @Override public boolean prepareImage(Image img, int w, int h, ImageObserver o) { if (w == 0 || h == 0) { return true; }
*** 1061,1070 **** --- 1016,1026 ---- Raster raster = bimage.getRaster(); DataBuffer buffer = raster.getDataBuffer(); return (DataBufferInt)buffer; } + @Override protected EventQueue getSystemEventQueueImpl() { return getSystemEventQueueImplPP(); } // Package private implementation
*** 1142,1159 **** --- 1098,1117 ---- * sun.awt.im.InputMethodWindow. * <p> * SunToolkit subclasses can override this method to return better input * method windows. */ + @Override public Window createInputMethodWindow(String title, InputContext context) { return new sun.awt.im.SimpleInputMethodWindow(title, context); } /** * Returns whether enableInputMethods should be set to true for peered * TextComponent instances on this platform. False by default. */ + @Override public boolean enableInputMethodsForTextComponent() { return false; } private static Locale startupLocale = null;
*** 1191,1207 **** } /** * Returns the default keyboard locale of the underlying operating system */ public Locale getDefaultKeyboardLocale() { return getStartupLocale(); } private static DefaultMouseInfoPeer mPeer = null; ! protected synchronized MouseInfoPeer getMouseInfoPeer() { if (mPeer == null) { mPeer = new DefaultMouseInfoPeer(); } return mPeer; } --- 1149,1167 ---- } /** * Returns the default keyboard locale of the underlying operating system */ + @Override public Locale getDefaultKeyboardLocale() { return getStartupLocale(); } private static DefaultMouseInfoPeer mPeer = null; ! @Override ! public synchronized MouseInfoPeer getMouseInfoPeer() { if (mPeer == null) { mPeer = new DefaultMouseInfoPeer(); } return mPeer; }
*** 1329,1346 **** --- 1289,1308 ---- } /** * Overridden in XToolkit and WToolkit */ + @Override public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) { return (modalityType == Dialog.ModalityType.MODELESS) || (modalityType == Dialog.ModalityType.APPLICATION_MODAL); } /** * Overridden in XToolkit and WToolkit */ + @Override public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) { return (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE); } ///////////////////////////////////////////////////////////////////////////
*** 1384,1400 **** --- 1346,1364 ---- void remove(ModalityListener listener) { listeners.removeElement(listener); } + @Override public void modalityPushed(ModalityEvent ev) { Iterator<ModalityListener> it = listeners.iterator(); while (it.hasNext()) { it.next().modalityPushed(ev); } } + @Override public void modalityPopped(ModalityEvent ev) { Iterator<ModalityListener> it = listeners.iterator(); while (it.hasNext()) { it.next().modalityPopped(ev); }
*** 1590,1599 **** --- 1554,1564 ---- queueEmpty = false; eventDispatched = false; synchronized(waitLock) { postEvent(AppContext.getAppContext(), new PeerEvent(getSystemEventQueueImpl(), null, PeerEvent.LOW_PRIORITY_EVENT) { + @Override public void dispatch() { // Here we block EDT. It could have some // events, it should have dispatched them by // now. So native requests could have been // generated. First, dispatch them. Then,