diff options
Diffstat (limited to 'java/awt')
-rw-r--r-- | java/awt/CardLayout.java | 7 | ||||
-rw-r--r-- | java/awt/Component.java | 17 | ||||
-rw-r--r-- | java/awt/Container.java | 62 | ||||
-rw-r--r-- | java/awt/Dialog.java | 21 | ||||
-rw-r--r-- | java/awt/EventQueue.java | 73 | ||||
-rw-r--r-- | java/awt/FileDialog.java | 28 | ||||
-rw-r--r-- | java/awt/Frame.java | 19 | ||||
-rw-r--r-- | java/awt/LightweightDispatcher.java | 4 | ||||
-rw-r--r-- | java/awt/ScrollPane.java | 34 | ||||
-rw-r--r-- | java/awt/ScrollPaneAdjustable.java | 26 | ||||
-rw-r--r-- | java/awt/Scrollbar.java | 70 | ||||
-rw-r--r-- | java/awt/Toolkit.java | 2 | ||||
-rw-r--r-- | java/awt/Window.java | 168 | ||||
-rw-r--r-- | java/awt/datatransfer/DataFlavor.java | 3 | ||||
-rw-r--r-- | java/awt/font/TextLayout.java | 13 | ||||
-rw-r--r-- | java/awt/image/BufferedImage.java | 59 | ||||
-rw-r--r-- | java/awt/image/ColorModel.java | 8 | ||||
-rw-r--r-- | java/awt/image/Raster.java | 7 | ||||
-rw-r--r-- | java/awt/image/WritableRaster.java | 5 |
19 files changed, 404 insertions, 222 deletions
diff --git a/java/awt/CardLayout.java b/java/awt/CardLayout.java index 7b733c821..2e3feece8 100644 --- a/java/awt/CardLayout.java +++ b/java/awt/CardLayout.java @@ -225,6 +225,8 @@ public class CardLayout implements LayoutManager2, Serializable */ public Dimension maximumLayoutSize (Container target) { + if (target == null) + return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); // The JCL says that this returns Integer.MAX_VALUE for both // dimensions. But that just seems wrong to me. return getSize (target, MAX); @@ -423,7 +425,10 @@ public class CardLayout implements LayoutManager2, Serializable if (choice >= 0) break; - } + } else + { + comps[i].setVisible(true); + } } if (choice >= 0 && choice < num) diff --git a/java/awt/Component.java b/java/awt/Component.java index 7688e2618..82c81c7a0 100644 --- a/java/awt/Component.java +++ b/java/awt/Component.java @@ -41,6 +41,8 @@ package java.awt; //import gnu.java.awt.dnd.peer.gtk.GtkDropTargetContextPeer; +import gnu.java.awt.ComponentReshapeEvent; + import java.awt.dnd.DropTarget; import java.awt.event.ActionEvent; import java.awt.event.AdjustmentEvent; @@ -5699,6 +5701,21 @@ p * <li>the set of backward traversal keys */ void dispatchEventImpl(AWTEvent e) { + // Update the component's knowledge about the size. + // Important: Please look at the big comment in ComponentReshapeEvent + // to learn why we did it this way. If you change this code, make + // sure that the peer->AWT bounds update still works. + // (for instance: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29448 ) + if (e instanceof ComponentReshapeEvent) + { + ComponentReshapeEvent reshape = (ComponentReshapeEvent) e; + x = reshape.x; + y = reshape.y; + width = reshape.width; + height = reshape.height; + return; + } + // Retarget focus events before dispatching it to the KeyboardFocusManager // in order to handle lightweight components properly. boolean dispatched = false; diff --git a/java/awt/Container.java b/java/awt/Container.java index 3d460baaf..83d9f7b78 100644 --- a/java/awt/Container.java +++ b/java/awt/Container.java @@ -43,6 +43,7 @@ import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.event.HierarchyEvent; import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; import java.awt.peer.LightweightPeer; @@ -606,11 +607,20 @@ public class Container extends Component */ public void validate() { - synchronized (getTreeLock ()) + ComponentPeer p = peer; + if (! valid && p != null) { - if (! isValid() && peer != null) + ContainerPeer cPeer = null; + if (p instanceof ContainerPeer) + cPeer = (ContainerPeer) peer; + synchronized (getTreeLock ()) { + if (cPeer != null) + cPeer.beginValidate(); validateTree(); + valid = true; + if (cPeer != null) + cPeer.endValidate(); } } } @@ -641,36 +651,36 @@ public class Container extends Component */ protected void validateTree() { - if (valid) - return; - - ContainerPeer cPeer = null; - if (peer instanceof ContainerPeer) - { - cPeer = (ContainerPeer) peer; - cPeer.beginValidate(); - } - - doLayout (); - for (int i = 0; i < ncomponents; ++i) + if (!valid) { - Component comp = component[i]; - - if (comp instanceof Container && ! (comp instanceof Window) - && ! comp.valid) + ContainerPeer cPeer = null; + if (peer instanceof ContainerPeer) { - ((Container) comp).validateTree(); + cPeer = (ContainerPeer) peer; + cPeer.beginLayout(); } - else + + doLayout (); + for (int i = 0; i < ncomponents; ++i) { - comp.validate(); + Component comp = component[i]; + + if (comp instanceof Container && ! (comp instanceof Window) + && ! comp.valid) + { + ((Container) comp).validateTree(); + } + else + { + comp.validate(); + } } - } - if (peer instanceof ContainerPeer) - { - cPeer = (ContainerPeer) peer; - cPeer.endValidate(); + if (cPeer != null) + { + cPeer = (ContainerPeer) peer; + cPeer.endLayout(); + } } /* children will call invalidate() when they are layed out. It diff --git a/java/awt/Dialog.java b/java/awt/Dialog.java index 55c3371e6..7df2f523c 100644 --- a/java/awt/Dialog.java +++ b/java/awt/Dialog.java @@ -97,6 +97,11 @@ public class Dialog extends Window private EventQueue eq2 = null; /** + * The number used to generate the name returned by getName. + */ + private static transient long next_dialog_number; + + /** * Initializes a new instance of <code>Dialog</code> with the specified * parent, that is resizable and not modal, and which has no title. * @@ -190,6 +195,7 @@ public class Dialog extends Window visible = false; setLayout(new BorderLayout()); + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } /** @@ -273,6 +279,7 @@ public class Dialog extends Window visible = false; setLayout(new BorderLayout()); + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } /** @@ -530,5 +537,19 @@ public class Dialog extends Window accessibleContext = new AccessibleAWTDialog(); return accessibleContext; } + + /** + * Generate a unique name for this <code>Dialog</code>. + * + * @return A unique name for this <code>Dialog</code>. + */ + String generateName() + { + return "dialog" + getUniqueLong(); + } + private static synchronized long getUniqueLong() + { + return next_dialog_number++; + } } diff --git a/java/awt/EventQueue.java b/java/awt/EventQueue.java index e1f109098..0b6e03efa 100644 --- a/java/awt/EventQueue.java +++ b/java/awt/EventQueue.java @@ -39,6 +39,7 @@ exception statement from your version. */ package java.awt; import gnu.java.awt.LowPriorityEvent; +import gnu.java.awt.peer.NativeEventLoopRunningEvent; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; @@ -114,31 +115,25 @@ public class EventQueue private long lastWhen = System.currentTimeMillis(); private EventDispatchThread dispatchThread = new EventDispatchThread(this); - private boolean shutdown = false; + private boolean nativeLoopRunning = false; - synchronized private void setShutdown (boolean b) + private boolean isShutdown () { - shutdown = b; - } - - synchronized boolean isShutdown () - { - if (shutdown) - return true; - // This is the exact self-shutdown condition specified in J2SE: // http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html - - // FIXME: check somewhere that the native queue is empty - if (peekEvent() == null) - { - Frame[] frames = Frame.getFrames(); - for (int i = 0; i < frames.length; ++i) - if (frames[i].isDisplayable()) - return false; - return true; - } - return false; + + if (nativeLoopRunning) + return false; + + if (peekEvent() != null) + return false; + + Frame[] frames = Frame.getFrames(); + for (int i = 0; i < frames.length; ++i) + if (frames[i].isDisplayable()) + return false; + + return true; } /** @@ -167,19 +162,23 @@ public class EventQueue return next.getNextEvent(); AWTEvent res = getNextEventImpl(true); + while (res == null) { - // We are not allowed to return null from this method, yet it - // is possible that we actually have run out of native events - // in the enclosing while() loop, and none of the native events - // happened to cause AWT events. We therefore ought to check - // the isShutdown() condition here, before risking a "native - // wait". If we check it before entering this function we may - // wait forever for events after the shutdown condition has - // arisen. - if (isShutdown()) - throw new InterruptedException(); + { + // Explicitly set dispathThread to null. If we don't do + // this, there is a race condition where dispatchThread + // can be != null even after the event dispatch thread has + // stopped running. If that happens, then the + // dispatchThread == null check in postEventImpl will + // fail, and a new event dispatch thread will not be + // created, leaving invokeAndWaits waiting indefinitely. + dispatchThread = null; + + // Interrupt the event dispatch thread. + throw new InterruptedException(); + } wait(); res = getNextEventImpl(true); @@ -296,6 +295,12 @@ public class EventQueue priority = LOW_PRIORITY; // TODO: Maybe let Swing RepaintManager events also be processed with // low priority. + if (evt instanceof NativeEventLoopRunningEvent) + { + nativeLoopRunning = ((NativeEventLoopRunningEvent) evt).isRunning(); + notify(); + return; + } postEventImpl(evt, priority); } @@ -576,11 +581,11 @@ public class EventQueue ex.printStackTrace(); } } - prev = null; - setShutdown(true); + // Tell our EventDispatchThread that it can end + // execution. + dispatchThread.interrupt(); dispatchThread = null; - this.notifyAll(); } } } diff --git a/java/awt/FileDialog.java b/java/awt/FileDialog.java index f02d06be2..21117700d 100644 --- a/java/awt/FileDialog.java +++ b/java/awt/FileDialog.java @@ -95,6 +95,11 @@ private FilenameFilter filter; */ private int mode; +/** + * The number used to generate the name returned by getName. + */ +private static transient long next_file_dialog_number; + /*************************************************************************/ /* @@ -300,7 +305,11 @@ getFile() public synchronized void setFile(String file) { - this.file = file; + if ("".equals(file)) + this.file = null; + else + this.file = file; + if (peer != null) { FileDialogPeer f = (FileDialogPeer) peer; @@ -366,5 +375,22 @@ paramString() ",mode=" + mode + "," + super.paramString()); } +/** + * Generate a unique name for this <code>FileDialog</code>. + * + * @return A unique name for this <code>FileDialog</code>. + */ +String +generateName() +{ + return "filedlg" + getUniqueLong(); +} + +private static synchronized long +getUniqueLong() +{ + return next_file_dialog_number++; +} + } // class FileDialog diff --git a/java/awt/Frame.java b/java/awt/Frame.java index e0c0d1ff3..d5cc7f531 100644 --- a/java/awt/Frame.java +++ b/java/awt/Frame.java @@ -488,7 +488,10 @@ public class Frame extends Window implements MenuContainer private static void noteFrame(Frame f) { - weakFrames.add(new WeakReference(f)); + synchronized (weakFrames) + { + weakFrames.add(new WeakReference(f)); + } } public static Frame[] getFrames() @@ -536,8 +539,7 @@ public class Frame extends Window implements MenuContainer public int getState() { - // FIXME: State might have changed in the peer... Must check. - return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL; + return (getExtendedState() & ICONIFIED) != 0 ? ICONIFIED : NORMAL; } /** @@ -545,7 +547,13 @@ public class Frame extends Window implements MenuContainer */ public void setExtendedState(int state) { - this.state = state; + if (getToolkit().isFrameStateSupported(state)) + { + this.state = state; + FramePeer p = (FramePeer) peer; + if (p != null) + p.setState(state); + } } /** @@ -553,6 +561,9 @@ public class Frame extends Window implements MenuContainer */ public int getExtendedState() { + FramePeer p = (FramePeer) peer; + if (p != null) + state = p.getState(); return state; } diff --git a/java/awt/LightweightDispatcher.java b/java/awt/LightweightDispatcher.java index 4360f592d..04196bd77 100644 --- a/java/awt/LightweightDispatcher.java +++ b/java/awt/LightweightDispatcher.java @@ -160,6 +160,8 @@ final class LightweightDispatcher if (isDragging(ev)) redispatch(ev, mouseEventTarget, id); break; + case MouseEvent.MOUSE_WHEEL: + redispatch(ev, mouseEventTarget, id); } ev.consume(); } @@ -314,7 +316,7 @@ final class LightweightDispatcher retargeted = new MouseEvent(target, id, ev.getWhen(), ev.getModifiers() | ev.getModifiersEx(), x, y, ev.getClickCount(), - ev.isPopupTrigger()); + ev.isPopupTrigger(), ev.getButton()); } if (target == source) diff --git a/java/awt/ScrollPane.java b/java/awt/ScrollPane.java index 65ce484b8..6d7994dab 100644 --- a/java/awt/ScrollPane.java +++ b/java/awt/ScrollPane.java @@ -393,7 +393,7 @@ setScrollPosition(int x, int y) h.setValue(x); if (v != null) v.setValue(y); - + ScrollPanePeer spp = (ScrollPanePeer)getPeer(); if (spp != null) spp.setScrollPosition(x, y); @@ -453,7 +453,7 @@ removeNotify() if ((list != null) && (list.length > 0)) remove(list[0]); - super.addImpl(component, constraints, -1); + super.addImpl(component, constraints, index); doLayout(); } @@ -518,11 +518,12 @@ layout() * not have layout managers. * * @param layoutManager Ignored + * @throws AWTError Always throws this error when called. */ public final void setLayout(LayoutManager layoutManager) { - return; + throw new AWTError("ScrollPane controls layout"); } /*************************************************************************/ @@ -553,16 +554,37 @@ paramString() + getX() + "," + getY() + "," + getWidth() + "x" + getHeight() + "," - + "ScrollPosition=(" + scrollPosition.getX() + "," - + scrollPosition.getY() + ")," + + getIsValidString() + "," + + "ScrollPosition=(" + scrollPosition.x + "," + + scrollPosition.y + ")," + "Insets=(" + insets.top + "," + insets.left + "," + insets.bottom + "," + insets.right + ")," - + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + "," + + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicyString() + "," + "wheelScrollingEnabled=" + isWheelScrollingEnabled(); } +private String +getScrollbarDisplayPolicyString() +{ + if (getScrollbarDisplayPolicy() == 0) + return "as-needed"; + else if (getScrollbarDisplayPolicy() == 1) + return "always"; + else + return "never"; +} + +private String +getIsValidString() +{ + if (isValid()) + return "valid"; + else + return "invalid"; +} + /** * Tells whether or not an event is enabled. * diff --git a/java/awt/ScrollPaneAdjustable.java b/java/awt/ScrollPaneAdjustable.java index 21b58c36e..6ce79b1f6 100644 --- a/java/awt/ScrollPaneAdjustable.java +++ b/java/awt/ScrollPaneAdjustable.java @@ -145,14 +145,26 @@ public class ScrollPaneAdjustable this.blockIncrement = blockIncrement; } - public void setMaximum (int maximum) + /** + * This method should never be called. + * + * @param maximum The maximum value to be set. + * @throws AWTError Always throws this error when called. + */ + public void setMaximum (int maximum) throws AWTError { - this.maximum = maximum; + throw new AWTError("Can be set by scrollpane only"); } + /** + * This method should never be called. + * + * @param minimum The minimum value to be set. + * @throws AWTError Always throws this error when called. + */ public void setMinimum (int minimum) { - this.minimum = minimum; + throw new AWTError("Can be set by scrollpane only"); } public void setUnitIncrement (int unitIncrement) @@ -171,9 +183,15 @@ public class ScrollPaneAdjustable maximum = value; } + /** + * This method should never be called. + * + * @param visibleAmount The visible amount to be set. + * @throws AWTError Always throws this error when called. + */ public void setVisibleAmount (int visibleAmount) { - this.visibleAmount = visibleAmount; + throw new AWTError("Can be set by scrollpane only"); } public String paramString () diff --git a/java/awt/Scrollbar.java b/java/awt/Scrollbar.java index ef8d6d59e..0cba512f6 100644 --- a/java/awt/Scrollbar.java +++ b/java/awt/Scrollbar.java @@ -341,17 +341,22 @@ public class Scrollbar extends Component implements Accessible, Adjustable public synchronized void setValues(int value, int visibleAmount, int minimum, int maximum) { - if (maximum < minimum) - maximum = minimum; + if (visibleAmount <= 0) + visibleAmount = 1; + + if (maximum <= minimum) + maximum = minimum + 1; if (value < minimum) value = minimum; - if (value > maximum) - value = maximum; - if (visibleAmount > maximum - minimum) visibleAmount = maximum - minimum; + + // According to documentation, the actual maximum + // value is (maximum - visibleAmount) + if (value > maximum - visibleAmount) + value = maximum - visibleAmount; ScrollbarPeer peer = (ScrollbarPeer) getPeer(); if (peer != null @@ -362,30 +367,7 @@ public class Scrollbar extends Component implements Accessible, Adjustable this.value = value; this.visibleAmount = visibleAmount; this.minimum = minimum; - this.maximum = maximum; - - int range = maximum - minimum; - if (lineIncrement > range) - { - if (range == 0) - lineIncrement = 1; - else - lineIncrement = range; - - if (peer != null) - peer.setLineIncrement(lineIncrement); - } - - if (pageIncrement > range) - { - if (range == 0) - pageIncrement = 1; - else - pageIncrement = range; - - if (peer != null) - peer.setPageIncrement(pageIncrement); - } + this.maximum = maximum; } /** @@ -437,19 +419,13 @@ public class Scrollbar extends Component implements Accessible, Adjustable { if (lineIncrement < 0) throw new IllegalArgumentException("Unit increment less than zero."); - - int range = maximum - minimum; - if (lineIncrement > range) - { - if (range == 0) - lineIncrement = 1; - else - lineIncrement = range; - } - - if (lineIncrement == this.lineIncrement) + + if (lineIncrement == 0) + lineIncrement = 1; + + if (lineIncrement == this.lineIncrement) return; - + this.lineIncrement = lineIncrement; ScrollbarPeer peer = (ScrollbarPeer) getPeer(); @@ -507,15 +483,9 @@ public class Scrollbar extends Component implements Accessible, Adjustable if (pageIncrement < 0) throw new IllegalArgumentException("Block increment less than zero."); - int range = maximum - minimum; - if (pageIncrement > range) - { - if (range == 0) - pageIncrement = 1; - else - pageIncrement = range; - } - + if (pageIncrement == 0) + pageIncrement = 1; + if (pageIncrement == this.pageIncrement) return; diff --git a/java/awt/Toolkit.java b/java/awt/Toolkit.java index d2c5f390e..9eb4da216 100644 --- a/java/awt/Toolkit.java +++ b/java/awt/Toolkit.java @@ -550,7 +550,7 @@ public abstract class Toolkit * * @throws AWTError If the toolkit cannot be loaded. */ - public static Toolkit getDefaultToolkit() + public static synchronized Toolkit getDefaultToolkit() { if (toolkit != null) return toolkit; diff --git a/java/awt/Window.java b/java/awt/Window.java index 7a3092f81..41dff5577 100644 --- a/java/awt/Window.java +++ b/java/awt/Window.java @@ -362,15 +362,15 @@ public class Window extends Container implements Accessible component[i].removeNotify(); this.removeNotify(); - // Post WINDOW_CLOSED from here. - if (windowListener != null - || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0) - { - WindowEvent ev = new WindowEvent(this, - WindowEvent.WINDOW_OPENED); - Toolkit tk = Toolkit.getDefaultToolkit(); - tk.getSystemEventQueue().postEvent(ev); - } + // Post WINDOW_CLOSED from here. + if (windowListener != null + || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0) + { + WindowEvent ev = new WindowEvent(this, + WindowEvent.WINDOW_CLOSED); + Toolkit tk = Toolkit.getDefaultToolkit(); + tk.getSystemEventQueue().postEvent(ev); + } } } @@ -498,7 +498,11 @@ public class Window extends Container implements Accessible */ public synchronized void addWindowListener(WindowListener listener) { - windowListener = AWTEventMulticaster.add(windowListener, listener); + if (listener != null) + { + newEventsOnly = true; + windowListener = AWTEventMulticaster.add(windowListener, listener); + } } /** @@ -555,7 +559,12 @@ public class Window extends Container implements Accessible */ public void addWindowFocusListener (WindowFocusListener wfl) { - windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl); + if (wfl != null) + { + newEventsOnly = true; + windowFocusListener = AWTEventMulticaster.add (windowFocusListener, + wfl); + } } /** @@ -565,7 +574,12 @@ public class Window extends Container implements Accessible */ public void addWindowStateListener (WindowStateListener wsl) { - windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl); + if (wsl != null) + { + newEventsOnly = true; + windowStateListener = AWTEventMulticaster.add (windowStateListener, + wsl); + } } /** @@ -624,7 +638,28 @@ public class Window extends Container implements Accessible protected void processEvent(AWTEvent evt) { if (evt instanceof WindowEvent) - processWindowEvent((WindowEvent) evt); + { + WindowEvent we = (WindowEvent) evt; + switch (evt.getID()) + { + case WindowEvent.WINDOW_OPENED: + case WindowEvent.WINDOW_CLOSED: + case WindowEvent.WINDOW_CLOSING: + case WindowEvent.WINDOW_ICONIFIED: + case WindowEvent.WINDOW_DEICONIFIED: + case WindowEvent.WINDOW_ACTIVATED: + case WindowEvent.WINDOW_DEACTIVATED: + processWindowEvent(we); + break; + case WindowEvent.WINDOW_GAINED_FOCUS: + case WindowEvent.WINDOW_LOST_FOCUS: + processWindowFocusEvent(we); + break; + case WindowEvent.WINDOW_STATE_CHANGED: + processWindowStateEvent(we); + break; + } + } else super.processEvent(evt); } @@ -639,54 +674,35 @@ public class Window extends Container implements Accessible */ protected void processWindowEvent(WindowEvent evt) { - int id = evt.getID(); - - if (id == WindowEvent.WINDOW_GAINED_FOCUS - || id == WindowEvent.WINDOW_LOST_FOCUS) - processWindowFocusEvent (evt); - else if (id == WindowEvent.WINDOW_STATE_CHANGED) - processWindowStateEvent (evt); - else + if (windowListener != null) { - if (windowListener != null) - { - switch (evt.getID()) - { - case WindowEvent.WINDOW_ACTIVATED: - windowListener.windowActivated(evt); - break; - - case WindowEvent.WINDOW_CLOSED: - windowListener.windowClosed(evt); - break; - - case WindowEvent.WINDOW_CLOSING: - windowListener.windowClosing(evt); - break; - - case WindowEvent.WINDOW_DEACTIVATED: - windowListener.windowDeactivated(evt); - break; - - case WindowEvent.WINDOW_DEICONIFIED: - windowListener.windowDeiconified(evt); - break; - - case WindowEvent.WINDOW_ICONIFIED: - windowListener.windowIconified(evt); - break; - - case WindowEvent.WINDOW_OPENED: - windowListener.windowOpened(evt); - break; - - default: - break; - } - } + switch (evt.getID()) + { + case WindowEvent.WINDOW_ACTIVATED: + windowListener.windowActivated(evt); + break; + case WindowEvent.WINDOW_CLOSED: + windowListener.windowClosed(evt); + break; + case WindowEvent.WINDOW_CLOSING: + windowListener.windowClosing(evt); + break; + case WindowEvent.WINDOW_DEACTIVATED: + windowListener.windowDeactivated(evt); + break; + case WindowEvent.WINDOW_DEICONIFIED: + windowListener.windowDeiconified(evt); + break; + case WindowEvent.WINDOW_ICONIFIED: + windowListener.windowIconified(evt); + break; + case WindowEvent.WINDOW_OPENED: + windowListener.windowOpened(evt); + break; + } } } - + /** * Identifies if this window is active. The active window is a Frame or * Dialog that has focus or owns the active window. @@ -1231,6 +1247,42 @@ public class Window extends Container implements Accessible return "win" + getUniqueLong(); } + /** + * Overridden to handle WindowEvents. + * + * @return <code>true</code> when the specified event type is enabled, + * <code>false</code> otherwise + */ + boolean eventTypeEnabled(int type) + { + boolean enabled = false; + switch (type) + { + case WindowEvent.WINDOW_OPENED: + case WindowEvent.WINDOW_CLOSED: + case WindowEvent.WINDOW_CLOSING: + case WindowEvent.WINDOW_ICONIFIED: + case WindowEvent.WINDOW_DEICONIFIED: + case WindowEvent.WINDOW_ACTIVATED: + case WindowEvent.WINDOW_DEACTIVATED: + enabled = ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0) + || windowListener != null; + break; + case WindowEvent.WINDOW_GAINED_FOCUS: + case WindowEvent.WINDOW_LOST_FOCUS: + enabled = ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0) + || windowFocusListener != null; + break; + case WindowEvent.WINDOW_STATE_CHANGED: + enabled = ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0) + || windowStateListener != null; + break; + default: + enabled = super.eventTypeEnabled(type); + } + return enabled; + } + private static synchronized long getUniqueLong() { return next_window_number++; diff --git a/java/awt/datatransfer/DataFlavor.java b/java/awt/datatransfer/DataFlavor.java index 63a00db13..d31c7065f 100644 --- a/java/awt/datatransfer/DataFlavor.java +++ b/java/awt/datatransfer/DataFlavor.java @@ -338,8 +338,7 @@ public class DataFlavor implements java.io.Externalizable, Cloneable // Do some simple validity checks String type = getPrimaryType() + "/" + getSubType(); - if (type.indexOf(' ') != -1 - || type.indexOf('=') != -1 + if (type.indexOf('=') != -1 || type.indexOf(';') != -1) throw new IllegalArgumentException(mimeType); diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java index 435e21f30..0fe4c0f73 100644 --- a/java/awt/font/TextLayout.java +++ b/java/awt/font/TextLayout.java @@ -88,6 +88,12 @@ public final class TextLayout implements Cloneable private boolean hasWhitespace = false; /** + * The {@link Bidi} object that is used for reordering and by + * {@link #getCharacterLevel(int)}. + */ + private Bidi bidi; + + /** * The default caret policy. */ public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy(); @@ -107,7 +113,7 @@ public final class TextLayout implements Cloneable if( Bidi.requiresBidi( string.toCharArray(), 0, string.length() ) ) { - Bidi bidi = new Bidi( string, leftToRight ? + bidi = new Bidi( string, leftToRight ? Bidi.DIRECTION_LEFT_TO_RIGHT : Bidi.DIRECTION_RIGHT_TO_LEFT ); int rc = bidi.getRunCount(); @@ -436,9 +442,10 @@ public final class TextLayout implements Cloneable } public byte getCharacterLevel (int index) - throws NotImplementedException { - throw new Error ("not implemented"); + if( bidi == null ) + return (byte)( leftToRight ? 0 : 1 ); + return (byte)bidi.getLevelAt( index ); } public float getDescent () diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java index 0a78bf223..ef3141d0e 100644 --- a/java/awt/image/BufferedImage.java +++ b/java/awt/image/BufferedImage.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.awt.image; +import gnu.java.awt.Buffers; import gnu.java.awt.ComponentDataBlitOp; import java.awt.Graphics; @@ -129,12 +130,12 @@ public class BufferedImage extends Image * <li>{@link #TYPE_BYTE_INDEXED}</li> * </ul> * - * @param w the width (must be > 0). - * @param h the height (must be > 0). + * @param width the width (must be > 0). + * @param height the height (must be > 0). * @param type the image type (see the list of valid types above). * - * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is - * less than or equal to zero. + * @throws IllegalArgumentException if <code>width</code> or + * <code>height</code> is less than or equal to zero. * @throws IllegalArgumentException if <code>type</code> is not one of the * specified values. */ @@ -161,8 +162,11 @@ public class BufferedImage extends Image width, height, 3, width * 3, new int[]{ 2, 1, 0 } ); - cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 ); - break; + cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + false, false, + BufferedImage.OPAQUE, + DataBuffer.TYPE_BYTE); + break; case BufferedImage.TYPE_INT_ARGB: case BufferedImage.TYPE_INT_ARGB_PRE: @@ -172,18 +176,25 @@ public class BufferedImage extends Image 0x0000FF00, 0x000000FF, 0xFF000000 } ); - cm = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 ); + if (premultiplied) + cm = new DirectColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), + 32, 0xff0000, 0xff00, 0xff, 0xff000000, + true, + Buffers.smallestAppropriateTransferType(32)); + else + cm = new DirectColorModel( 32, 0xff0000, 0xff00, 0xff, 0xff000000 ); break; case BufferedImage.TYPE_4BYTE_ABGR: case BufferedImage.TYPE_4BYTE_ABGR_PRE: - sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_INT, - width, height, - new int[]{ 0x000000FF, - 0xFF000000, - 0x00FF0000, - 0x0000FF00 } ); - cm = new DirectColorModel( 32, 0xff, 0xff00, 0xff0000, 0xff000000 ); + sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, + width, height, + 4, 4*width, + new int[]{3, 2, 1, 0}); + cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + true, premultiplied, + BufferedImage.TRANSLUCENT, + DataBuffer.TYPE_BYTE); break; case BufferedImage.TYPE_INT_BGR: @@ -192,24 +203,24 @@ public class BufferedImage extends Image new int[]{ 0x000000FF, 0x0000FF00, 0x00FF0000 } ) ; - cm = new DirectColorModel( 32, 0xff, 0xff00, 0xff0000 ); - break; + cm = new DirectColorModel( 24, 0xff, 0xff00, 0xff0000 ); + break; case BufferedImage.TYPE_USHORT_565_RGB: sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT, width, height, - new int[]{ 0x0000001F, - 0x000007E0, - 0x0000F800 } ) ; - cm = new DirectColorModel( 16, 0x1F, 0x7E0, 0xf800 ); + new int[]{ 0xF800, + 0x7E0, + 0x1F } ) ; + cm = new DirectColorModel( 16, 0xF800, 0x7E0, 0x1F ); break; case BufferedImage.TYPE_USHORT_555_RGB: sm = new SinglePixelPackedSampleModel( DataBuffer.TYPE_USHORT, width, height, - new int[]{ 0x0000001F, - 0x000003E0, - 0x00007C00 } ) ; - cm = new DirectColorModel( 15, 0x1F, 0x3E0, 0x7c00 ); + new int[]{ 0x7C00, + 0x3E0, + 0x1F } ) ; + cm = new DirectColorModel( 15, 0x7C00, 0x3E0, 0x1F ); break; case BufferedImage.TYPE_BYTE_INDEXED: diff --git a/java/awt/image/ColorModel.java b/java/awt/image/ColorModel.java index ea3d1b64c..e2873c5d7 100644 --- a/java/awt/image/ColorModel.java +++ b/java/awt/image/ColorModel.java @@ -624,8 +624,12 @@ public abstract class ColorModel implements Transparency return cspace; } - public abstract ColorModel coerceData(WritableRaster raster, - boolean isAlphaPremultiplied); + public ColorModel coerceData(WritableRaster raster, + boolean isAlphaPremultiplied) + { + // This method should always be overridden, but is not abstract. + throw new UnsupportedOperationException(); + } protected void coerceDataWorker(WritableRaster raster, boolean isAlphaPremultiplied) diff --git a/java/awt/image/Raster.java b/java/awt/image/Raster.java index 160f8be8b..d63e156f6 100644 --- a/java/awt/image/Raster.java +++ b/java/awt/image/Raster.java @@ -511,9 +511,10 @@ public class Raster int height, int childMinX, int childMinY, int[] bandList) { - /* FIXME: Throw RasterFormatException if child bounds extends - beyond the bounds of this raster. */ - + if (parentX < minX || parentX + width > minX + this.width + || parentY < minY || parentY + height > minY + this.height) + throw new RasterFormatException("Child raster extends beyond parent"); + SampleModel sm = (bandList == null) ? sampleModel : sampleModel.createSubsetSampleModel(bandList); diff --git a/java/awt/image/WritableRaster.java b/java/awt/image/WritableRaster.java index 473c6fe41..d2ea4a8aa 100644 --- a/java/awt/image/WritableRaster.java +++ b/java/awt/image/WritableRaster.java @@ -136,8 +136,9 @@ public class WritableRaster extends Raster { // This mirrors the code from the super class - // FIXME: Throw RasterFormatException if child bounds extends - // beyond the bounds of this raster. + if (parentX < minX || parentX + w > minX + width + || parentY < minY || parentY + h > minY + height) + throw new RasterFormatException("Child raster extends beyond parent"); SampleModel sm = (bandList == null) ? sampleModel : |