|
From: <ls...@us...> - 2007-01-28 21:36:50
|
Revision: 3097
http://jnode.svn.sourceforge.net/jnode/?rev=3097&view=rev
Author: lsantha
Date: 2007-01-28 13:36:49 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Button.java
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/MenuBar.java
Modified: trunk/core/src/classpath/java/java/awt/Button.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Button.java 2007-01-28 20:52:02 UTC (rev 3096)
+++ trunk/core/src/classpath/java/java/awt/Button.java 2007-01-28 21:36:49 UTC (rev 3097)
@@ -352,11 +352,11 @@
*
* @since 1.3
*/
- public EventListener[] getListeners(Class listenerType)
+ public <T extends EventListener> T[] getListeners(Class<T> listenerType)
{
if (listenerType == ActionListener.class)
- return getActionListeners();
- return (EventListener[]) Array.newInstance(listenerType, 0);
+ return (T[]) getActionListeners();
+ return (T[]) Array.newInstance(listenerType, 0);
}
/*************************************************************************/
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-01-28 20:52:02 UTC (rev 3096)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-01-28 21:36:49 UTC (rev 3097)
@@ -2847,29 +2847,29 @@
* @see #getPropertyChangeListeners()
* @since 1.3
*/
- public EventListener[] getListeners(Class listenerType)
+ public <T extends EventListener> T[] getListeners(Class<T> listenerType)
{
if (listenerType == ComponentListener.class)
- return getComponentListeners();
+ return (T[]) getComponentListeners();
if (listenerType == FocusListener.class)
- return getFocusListeners();
+ return (T[]) getFocusListeners();
if (listenerType == HierarchyListener.class)
- return getHierarchyListeners();
+ return (T[]) getHierarchyListeners();
if (listenerType == HierarchyBoundsListener.class)
- return getHierarchyBoundsListeners();
+ return (T[]) getHierarchyBoundsListeners();
if (listenerType == KeyListener.class)
- return getKeyListeners();
+ return (T[]) getKeyListeners();
if (listenerType == MouseListener.class)
- return getMouseListeners();
+ return (T[]) getMouseListeners();
if (listenerType == MouseMotionListener.class)
- return getMouseMotionListeners();
+ return (T[]) getMouseMotionListeners();
if (listenerType == MouseWheelListener.class)
- return getMouseWheelListeners();
+ return (T[]) getMouseWheelListeners();
if (listenerType == InputMethodListener.class)
- return getInputMethodListeners();
+ return (T[]) getInputMethodListeners();
if (listenerType == PropertyChangeListener.class)
- return getPropertyChangeListeners();
- return (EventListener[]) Array.newInstance(listenerType, 0);
+ return (T[]) getPropertyChangeListeners();
+ return (T[]) Array.newInstance(listenerType, 0);
}
/**
Modified: trunk/core/src/classpath/java/java/awt/MenuBar.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/MenuBar.java 2007-01-28 20:52:02 UTC (rev 3096)
+++ trunk/core/src/classpath/java/java/awt/MenuBar.java 2007-01-28 21:36:49 UTC (rev 3097)
@@ -272,7 +272,7 @@
*
* @return a list of all shortcuts for the menus in this menu bar
*/
- public synchronized Enumeration shortcuts()
+ public synchronized Enumeration<MenuShortcut> shortcuts()
{
Vector shortcuts = new Vector();
Enumeration e = menus.elements();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-01-31 19:02:54
|
Revision: 3098
http://jnode.svn.sourceforge.net/jnode/?rev=3098&view=rev
Author: lsantha
Date: 2007-01-31 11:02:43 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Choice.java
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/Frame.java
trunk/core/src/classpath/java/java/awt/Label.java
trunk/core/src/classpath/java/java/awt/List.java
trunk/core/src/classpath/java/java/awt/Menu.java
trunk/core/src/classpath/java/java/awt/ScrollPane.java
trunk/core/src/classpath/java/java/awt/ScrollPaneAdjustable.java
trunk/core/src/classpath/java/java/awt/Scrollbar.java
trunk/core/src/classpath/java/java/awt/Window.java
Modified: trunk/core/src/classpath/java/java/awt/Choice.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Choice.java 2007-01-28 21:36:49 UTC (rev 3097)
+++ trunk/core/src/classpath/java/java/awt/Choice.java 2007-01-31 19:02:43 UTC (rev 3098)
@@ -1,5 +1,5 @@
/* Choice.java -- Java choice button widget.
- Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,35 +58,31 @@
public class Choice extends Component
implements ItemSelectable, Serializable, Accessible
{
-
-/*
- * Static Variables
+ /**
+ * The number used to generate the name returned by getName.
*/
+ private static transient long next_choice_number;
-// Serialization constant
-private static final long serialVersionUID = -4075310674757313071L;
+ // Serialization constant
+ private static final long serialVersionUID = -4075310674757313071L;
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
+ /**
* @serial A list of items for the choice box, which can be <code>null</code>.
* This is package-private to avoid an accessor method.
*/
-Vector pItems = new Vector();
+ Vector pItems = new Vector();
-/**
+ /**
* @serial The index of the selected item in the choice box.
*/
-private int selectedIndex = -1;
+ private int selectedIndex = -1;
-// Listener chain
-private ItemListener item_listeners;
+ /**
+ * ItemListener chain
+ */
+ private ItemListener item_listeners;
-/**
+ /**
* This class provides accessibility support for the
* combo box.
*
@@ -181,19 +177,12 @@
if (i < 0 || i >= pItems.size())
return false;
- Choice.this.processItemEvent(new ItemEvent(Choice.this,
- ItemEvent.ITEM_STATE_CHANGED,
- this, ItemEvent.SELECTED));
+ Choice.this.select( i );
+
return true;
}
}
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
/**
* Initializes a new instance of <code>Choice</code>.
*
@@ -206,56 +195,41 @@
throw new HeadlessException ();
}
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
+ /**
* Returns the number of items in the list.
*
* @return The number of items in the list.
*/
-public int
-getItemCount()
-{
+ public int getItemCount()
+ {
return countItems ();
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the number of items in the list.
*
* @return The number of items in the list.
*
* @deprecated This method is deprecated in favor of <code>getItemCount</code>.
*/
-public int
-countItems()
-{
- return(pItems.size());
-}
+ public int countItems()
+ {
+ return pItems.size();
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the item at the specified index in the list.
*
* @param index The index into the list to return the item from.
*
* @exception ArrayIndexOutOfBoundsException If the index is invalid.
*/
-public String
-getItem(int index)
-{
- return((String)pItems.elementAt(index));
-}
+ public String getItem(int index)
+ {
+ return (String)pItems.elementAt(index);
+ }
-/*************************************************************************/
-
-/**
+ /**
* Adds the specified item to this choice box.
*
* @param item The item to add.
@@ -264,45 +238,36 @@
*
* @since 1.1
*/
-public synchronized void
-add(String item)
-{
+ public synchronized void add(String item)
+ {
if (item == null)
throw new NullPointerException ("item must be non-null");
pItems.addElement(item);
- int i = pItems.size () - 1;
if (peer != null)
- {
- ChoicePeer cp = (ChoicePeer) peer;
- cp.add (item, i);
- }
- else if (selectedIndex == -1)
- select(0);
-}
+ ((ChoicePeer) peer).add(item, getItemCount() - 1);
-/*************************************************************************/
+ if (selectedIndex == -1)
+ select( 0 );
+ }
-/**
+ /**
* Adds the specified item to this choice box.
*
- * This method is oboslete since Java 2 platform 1.1. Please use @see add
- * instead.
+ * This method is oboslete since Java 2 platform 1.1. Please use
+ * {@link #add(String)} instead.
*
* @param item The item to add.
*
* @exception NullPointerException If the item's value is equal to null
*/
-public synchronized void
-addItem(String item)
-{
+ public synchronized void addItem(String item)
+ {
add(item);
-}
+ }
-/*************************************************************************/
-
-/** Inserts an item into this Choice. Existing items are shifted
+ /** Inserts an item into this Choice. Existing items are shifted
* upwards. If the new item is the only item, then it is selected.
* If the currently selected item is shifted, then the first item is
* selected. If the currently selected item is not shifted, then it
@@ -313,9 +278,8 @@
*
* @exception IllegalArgumentException If index is less than 0
*/
-public synchronized void
-insert(String item, int index)
-{
+ public synchronized void insert(String item, int index)
+ {
if (index < 0)
throw new IllegalArgumentException ("index may not be less then 0");
@@ -325,75 +289,61 @@
pItems.insertElementAt(item, index);
if (peer != null)
- {
- ChoicePeer cp = (ChoicePeer) peer;
- cp.add (item, index);
- }
- else if (selectedIndex == -1 || selectedIndex >= index)
+ ((ChoicePeer) peer).add (item, index);
+
+ if (selectedIndex == -1 || selectedIndex >= index)
select(0);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes the specified item from the choice box.
*
* @param item The item to remove.
*
* @exception IllegalArgumentException If the specified item doesn't exist.
*/
-public synchronized void
-remove(String item)
-{
+ public synchronized void remove(String item)
+ {
int index = pItems.indexOf(item);
if (index == -1)
throw new IllegalArgumentException ("item \""
+ item + "\" not found in Choice");
remove(index);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes the item at the specified index from the choice box.
*
* @param index The index of the item to remove.
*
* @exception IndexOutOfBoundsException If the index is not valid.
*/
-public synchronized void
-remove(int index)
-{
- if ((index < 0) || (index > getItemCount()))
- throw new IllegalArgumentException("Bad index: " + index);
-
+ public synchronized void remove(int index)
+ {
pItems.removeElementAt(index);
if (peer != null)
- {
- ChoicePeer cp = (ChoicePeer) peer;
- cp.remove (index);
- }
- else
- {
- if (getItemCount() == 0)
+ ((ChoicePeer) peer).remove( index );
+
+ if( getItemCount() == 0 )
selectedIndex = -1;
- else if (index == selectedIndex)
- select(0);
- }
+ else
+ {
+ if( selectedIndex > index )
+ selectedIndex--;
+ else if( selectedIndex == index )
+ selectedIndex = 0;
- if (selectedIndex > index)
- --selectedIndex;
-}
+ if( peer != null )
+ ((ChoicePeer)peer).select( selectedIndex );
+ }
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes all of the objects from this choice box.
*/
-public synchronized void
-removeAll()
-{
+ public synchronized void removeAll()
+ {
if (getItemCount() <= 0)
return;
@@ -406,197 +356,159 @@
}
selectedIndex = -1;
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the currently selected item, or null if no item is
* selected.
*
* @return The currently selected item.
*/
-public synchronized String
-getSelectedItem()
-{
+ public synchronized String getSelectedItem()
+ {
return (selectedIndex == -1
? null
: ((String)pItems.elementAt(selectedIndex)));
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns an array with one row containing the selected item.
*
* @return An array containing the selected item.
*/
-public synchronized Object[]
-getSelectedObjects()
-{
+ public synchronized Object[] getSelectedObjects()
+ {
if (selectedIndex == -1)
return null;
Object[] objs = new Object[1];
objs[0] = pItems.elementAt(selectedIndex);
- return(objs);
-}
+ return objs;
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the index of the selected item.
*
* @return The index of the selected item.
*/
-public int
-getSelectedIndex()
-{
- return(selectedIndex);
-}
+ public int getSelectedIndex()
+ {
+ return selectedIndex;
+ }
-/*************************************************************************/
-
-/**
+ /**
* Forces the item at the specified index to be selected.
*
* @param index The index of the row to make selected.
*
* @exception IllegalArgumentException If the specified index is invalid.
*/
-public synchronized void
-select(int index)
-{
+ public synchronized void select(int index)
+ {
if ((index < 0) || (index >= getItemCount()))
throw new IllegalArgumentException("Bad index: " + index);
- if (pItems.size() > 0) {
+ if( selectedIndex == index )
+ return;
+
selectedIndex = index;
- ChoicePeer cp = (ChoicePeer) peer;
- if (cp != null) {
- cp.select(index);
+ if( peer != null )
+ ((ChoicePeer)peer).select( index );
}
- }
-}
-/*************************************************************************/
-
-/**
+ /**
* Forces the named item to be selected.
*
* @param item The item to be selected.
*
* @exception IllegalArgumentException If the specified item does not exist.
*/
-public synchronized void
-select(String item)
-{
+ public synchronized void select(String item)
+ {
int index = pItems.indexOf(item);
- if (index >= 0)
- select(index);
-}
+ if( index >= 0 )
+ select( index );
+ }
-/*************************************************************************/
-
-/**
+ /**
* Creates the native peer for this object.
*/
-public void
-addNotify()
-{
+ public void addNotify()
+ {
if (peer == null)
peer = getToolkit ().createChoice (this);
super.addNotify ();
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Adds the specified listener to the list of registered listeners for
* this object.
*
* @param listener The listener to add.
*/
-public synchronized void
-addItemListener(ItemListener listener)
-{
+ public synchronized void addItemListener(ItemListener listener)
+ {
item_listeners = AWTEventMulticaster.add(item_listeners, listener);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes the specified listener from the list of registered listeners for
* this object.
*
* @param listener The listener to remove.
*/
-public synchronized void
-removeItemListener(ItemListener listener)
-{
+ public synchronized void removeItemListener(ItemListener listener)
+ {
item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes this event by invoking <code>processItemEvent()</code> if the
* event is an instance of <code>ItemEvent</code>, otherwise the event
* is passed to the superclass.
*
* @param event The event to process.
*/
-protected void
-processEvent(AWTEvent event)
-{
+ protected void processEvent(AWTEvent event)
+ {
if (event instanceof ItemEvent)
processItemEvent((ItemEvent)event);
else
super.processEvent(event);
-}
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
- if (e.id <= ItemEvent.ITEM_LAST
- && e.id >= ItemEvent.ITEM_FIRST
- && (item_listeners != null || (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
- processEvent(e);
- else
+ void dispatchEventImpl(AWTEvent e)
+ {
super.dispatchEventImpl(e);
-}
-/*************************************************************************/
+ if( e.id <= ItemEvent.ITEM_LAST && e.id >= ItemEvent.ITEM_FIRST &&
+ ( item_listeners != null ||
+ ( eventMask & AWTEvent.ITEM_EVENT_MASK ) != 0 ) )
+ processEvent(e);
+ }
-/**
+ /**
* Processes item event by dispatching to any registered listeners.
*
* @param event The event to process.
*/
-protected void
-processItemEvent(ItemEvent event)
-{
+ protected void processItemEvent(ItemEvent event)
+ {
int index = pItems.indexOf((String) event.getItem());
- // Don't call back into the peers when selecting index here
- if (event.getStateChange() == ItemEvent.SELECTED)
- this.selectedIndex = index;
if (item_listeners != null)
item_listeners.itemStateChanged(event);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns a debugging string for this object.
*
* @return A debugging string for this object.
*/
-protected String
-paramString()
-{
- return ("selectedIndex=" + selectedIndex + "," + super.paramString());
-}
+ protected String paramString()
+ {
+ return "selectedIndex=" + selectedIndex + "," + super.paramString();
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -608,7 +520,7 @@
*
* @since 1.3
*/
- public EventListener[] getListeners (Class listenerType)
+ public <T extends EventListener> T[] getListeners (Class<T> listenerType)
{
if (listenerType == ItemListener.class)
return AWTEventMulticaster.getListeners (item_listeners, listenerType);
@@ -639,4 +551,19 @@
accessibleContext = new AccessibleAWTChoice();
return accessibleContext;
}
-} // class Choice
+
+ /**
+ * Generate a unique name for this <code>Choice</code>.
+ *
+ * @return A unique name for this <code>Choice</code>.
+ */
+ String generateName()
+ {
+ return "choice" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_choice_number++;
+ }
+} // class Choice
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-01-28 21:36:49 UTC (rev 3097)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-01-31 19:02:43 UTC (rev 3098)
@@ -39,6 +39,10 @@
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;
@@ -70,6 +74,7 @@
import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
@@ -213,6 +218,12 @@
*/
static final Object treeLock = new String("AWT_TREE_LOCK");
+ /**
+ * The default maximum size.
+ */
+ private static final Dimension DEFAULT_MAX_SIZE
+ = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+
// Serialized fields from the serialization spec.
/**
@@ -427,6 +438,24 @@
Dimension minSize;
/**
+ * Flag indicating whether the minimum size for the component has been set
+ * by a call to {@link #setMinimumSize(Dimension)} with a non-null value.
+ */
+ boolean minSizeSet;
+
+ /**
+ * The maximum size for the component.
+ * @see #setMaximumSize(Dimension)
+ */
+ Dimension maxSize;
+
+ /**
+ * A flag indicating whether the maximum size for the component has been set
+ * by a call to {@link #setMaximumSize(Dimension)} with a non-null value.
+ */
+ boolean maxSizeSet;
+
+ /**
* Cached information on the preferred size. Should have been transient.
*
* @serial ignore
@@ -569,6 +598,17 @@
transient BufferStrategy bufferStrategy;
/**
+ * The number of hierarchy listeners of this container plus all of its
+ * children. This is needed for efficient handling of HierarchyEvents.
+ * These must be propagated to all child components with HierarchyListeners
+ * attached. To avoid traversal of the whole subtree, we keep track of
+ * the number of HierarchyListeners here and only walk the paths that
+ * actually have listeners.
+ */
+ int numHierarchyListeners;
+ int numHierarchyBoundsListeners;
+
+ /**
* true if requestFocus was called on this component when its
* top-level ancestor was not focusable.
*/
@@ -613,16 +653,19 @@
}
/**
- * Sets the name of this component to the specified name.
+ * Sets the name of this component to the specified name (this is a bound
+ * property with the name 'name').
*
- * @param name the new name of this component
+ * @param name the new name (<code>null</code> permitted).
* @see #getName()
* @since 1.1
*/
public void setName(String name)
{
nameExplicitlySet = true;
+ String old = this.name;
this.name = name;
+ firePropertyChange("name", old, name);
}
/**
@@ -659,6 +702,9 @@
public void setDropTarget(DropTarget dt)
{
this.dropTarget = dt;
+
+ if (peer != null)
+ dropTarget.addNotify(peer);
}
/**
@@ -1590,6 +1636,7 @@
*
* @return the component's preferred size
* @see #getMinimumSize()
+ * @see #setPreferredSize(Dimension)
* @see LayoutManager
*/
public Dimension getPreferredSize()
@@ -1600,7 +1647,7 @@
/**
* Sets the preferred size that will be returned by
* {@link #getPreferredSize()} always, and sends a
- * {@link java.beans.PropertyChangeEvent} (with the property name 'preferredSize') to
+ * {@link PropertyChangeEvent} (with the property name 'preferredSize') to
* all registered listeners.
*
* @param size the preferred size (<code>null</code> permitted).
@@ -1662,6 +1709,39 @@
}
/**
+ * Sets the minimum size that will be returned by {@link #getMinimumSize()}
+ * always, and sends a {@link PropertyChangeEvent} (with the property name
+ * 'minimumSize') to all registered listeners.
+ *
+ * @param size the minimum size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getMinimumSize()
+ */
+ public void setMinimumSize(Dimension size)
+ {
+ Dimension old = minSizeSet ? minSize : null;
+ minSize = size;
+ minSizeSet = (size != null);
+ firePropertyChange("minimumSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current minimum size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setMinimumSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isMinimumSizeSet()
+ {
+ return minSizeSet;
+ }
+
+ /**
* Returns the component's minimum size.
*
* @return the component's minimum size
@@ -1676,10 +1756,38 @@
}
/**
+ * The actual calculation is pulled out of minimumSize() so that
+ * we can call it from Container.preferredSize() and
+ * Component.preferredSizeImpl and avoid creating a
+ * new intermediate Dimension object.
+ *
+ * @return the minimum size of the component
+ */
+ Dimension minimumSizeImpl()
+ {
+ Dimension size = minSize;
+ if (size == null || !(valid || minSizeSet))
+ {
+ // We need to lock here, because the calculation depends on the
+ // component structure not changing.
+ synchronized (getTreeLock())
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ size = peer.minimumSize();
+ else
+ size = size();
+ }
+ }
+ return size;
+ }
+
+ /**
* Returns the component's maximum size.
*
* @return the component's maximum size
* @see #getMinimumSize()
+ * @see #setMaximumSize(Dimension)
* @see #getPreferredSize()
* @see LayoutManager
*/
@@ -1689,6 +1797,56 @@
}
/**
+ * This is pulled out from getMaximumSize(), so that we can access it
+ * from Container.getMaximumSize() without creating an additional
+ * intermediate Dimension object.
+ *
+ * @return the maximum size of the component
+ */
+ Dimension maximumSizeImpl()
+ {
+ Dimension size;
+ if (maxSizeSet)
+ size = maxSize;
+ else
+ size = DEFAULT_MAX_SIZE;
+ return size;
+ }
+
+ /**
+ * Sets the maximum size that will be returned by {@link #getMaximumSize()}
+ * always, and sends a {@link PropertyChangeEvent} (with the property name
+ * 'maximumSize') to all registered listeners.
+ *
+ * @param size the maximum size (<code>null</code> permitted).
+ *
+ * @since 1.5
+ *
+ * @see #getMaximumSize()
+ */
+ public void setMaximumSize(Dimension size)
+ {
+ Dimension old = maxSizeSet ? maxSize : null;
+ maxSize = size;
+ maxSizeSet = (size != null);
+ firePropertyChange("maximumSize", old, size);
+ }
+
+ /**
+ * Returns <code>true</code> if the current maximum size is not
+ * <code>null</code> and was set by a call to
+ * {@link #setMaximumSize(Dimension)}, otherwise returns <code>false</code>.
+ *
+ * @return A boolean.
+ *
+ * @since 1.5
+ */
+ public boolean isMaximumSizeSet()
+ {
+ return maxSizeSet;
+ }
+
+ /**
* Returns the preferred horizontal alignment of this component. The value
* returned will be between {@link #LEFT_ALIGNMENT} and
* {@link #RIGHT_ALIGNMENT}, inclusive.
@@ -1873,11 +2031,9 @@
}
/**
- * Updates this component. This is called in response to
- * <code>repaint</code>. This method fills the component with the
- * background color, then sets the foreground color of the specified
- * graphics context to the foreground color of this component and calls
- * the <code>paint()</code> method. The coordinates of the graphics are
+ * Updates this component. This is called for heavyweight components in
+ * response to {@link #repaint()}. The default implementation simply forwards
+ * to {@link #paint(Graphics)}. The coordinates of the graphics are
* relative to this component. Subclasses should call either
* <code>super.update(g)</code> or <code>paint(g)</code>.
*
@@ -1885,11 +2041,6 @@
*
* @see #paint(Graphics)
* @see #repaint()
- *
- * @specnote In contrast to what the spec says, tests show that the exact
- * behaviour is to clear the background on lightweight and
- * top-level components only. Heavyweight components are not
- * affected by this method and only call paint().
*/
public void update(Graphics g)
{
@@ -2004,10 +2155,7 @@
}
/**
- * Prints this component, including all sub-components. This method is
- * provided so that printing can be done in a different manner from
- * painting. However, the implementation in this class simply calls the
- * <code>paintAll()</code> method.
+ * Prints this component, including all sub-components.
*
* @param g the graphics context of the print device
*
@@ -2365,6 +2513,17 @@
}
/**
+ * By default, no old mouse events should be ignored.
+ * This can be overridden by subclasses.
+ *
+ * @return false, no mouse events are ignored.
+ */
+ static boolean ignoreOldMouseEvents()
+ {
+ return false;
+ }
+
+ /**
* AWT 1.0 event handler.
*
* This method simply calls handleEvent and returns the result.
@@ -2581,6 +2740,40 @@
}
/**
+ * Fires a HierarchyEvent or HierarchyChangeEvent on this component.
+ *
+ * @param id the event id
+ * @param changed the changed component
+ * @param parent the parent
+ * @param flags the event flags
+ */
+ void fireHierarchyEvent(int id, Component changed, Container parent,
+ long flags)
+ {
+ boolean enabled = false;
+ switch (id)
+ {
+ case HierarchyEvent.HIERARCHY_CHANGED:
+ enabled = hierarchyListener != null
+ || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0;
+ break;
+ case HierarchyEvent.ANCESTOR_MOVED:
+ case HierarchyEvent.ANCESTOR_RESIZED:
+ enabled = hierarchyBoundsListener != null
+ || (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0;
+ break;
+ default:
+ assert false : "Should not reach here";
+ }
+ if (enabled)
+ {
+ HierarchyEvent ev = new HierarchyEvent(this, id, changed, parent,
+ flags);
+ dispatchEvent(ev);
+ }
+ }
+
+ /**
* Adds the specified listener to this component. This is harmless if the
* listener is null, but if the listener has already been registered, it
* will now be registered twice.
@@ -3636,7 +3829,8 @@
* @see KeyboardFocusManager#UP_CYCLE_TRAVERSAL_KEYS
* @since 1.4
*/
- public void setFocusTraversalKeys(int id, Set keystrokes)
+ public void setFocusTraversalKeys(int id,
+ Set<? extends AWTKeyStroke> keystrokes)
{
if (keystrokes == null)
{
@@ -3728,14 +3922,14 @@
*
* @since 1.4
*/
- public Set getFocusTraversalKeys (int id)
+ public Set<AWTKeyStroke> getFocusTraversalKeys (int id)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException();
- Set s = null;
+ Set<AWTKeyStroke> s = null;
if (focusTraversalKeys != null)
s = focusTraversalKeys[id];
@@ -4740,8 +4934,7 @@
* {@link #applyComponentOrientation(ComponentOrientation)} affects the
* entire hierarchy.
*
- * @param o the new orientation
- * @throws NullPointerException if o is null
+ * @param o the new orientation (<code>null</code> is accepted)
* @see #getComponentOrientation()
*/
public void setComponentOrientation(ComponentOrientation o)
@@ -4756,7 +4949,7 @@
/**
* Determines the text layout orientation used by this component.
*
- * @return the component orientation
+ * @return the component orientation (this can be <code>null</code>)
* @see #setComponentOrientation(ComponentOrientation)
*/
public ComponentOrientation getComponentOrientation()
@@ -5046,7 +5239,7 @@
oldKey = Event.UP;
break;
default:
- oldKey = (int) ((KeyEvent) e).getKeyChar();
+ oldKey = ((KeyEvent) e).getKeyChar();
}
translated = new Event (target, when, oldID,
@@ -5089,11 +5282,10 @@
*
* @param e the event to dispatch
*/
-
void dispatchEventImpl(AWTEvent e)
{
- // This boolean tells us not to process focus events when the focus
- // opposite component is the same as the focus component.
+ // Update the component's knowledge about the size.
+ // Important: Please look at the big comment in ComponentReshapeEvent
boolean ignoreFocus =
(e instanceof FocusEvent &&
((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent());
@@ -5385,7 +5577,7 @@
*/
public void componentHidden(ComponentEvent event)
{
- if (!isShowing())
+ if (isShowing())
peer.hide();
}
}
Modified: trunk/core/src/classpath/java/java/awt/Container.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Container.java 2007-01-28 21:36:49 UTC (rev 3097)
+++ trunk/core/src/classpath/java/java/awt/Container.java 2007-01-31 19:02:43 UTC (rev 3098)
@@ -42,7 +42,9 @@
import java.awt.event.ComponentListener;
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;
@@ -68,10 +70,11 @@
*
* @author original author unknown
* @author Eric Blake (eb...@em...)
+ * @author Andrew John Hughes (gnu...@me...)
*
* @since 1.0
*
- * @status still missing 1.4 support
+ * @status still missing 1.4 support, some generics from 1.5
*/
public class Container extends Component
{
@@ -97,6 +100,13 @@
*/
boolean focusCycleRoot;
+ /**
+ * Indicates if this container provides a focus traversal policy.
+ *
+ * @since 1.5
+ */
+ private boolean focusTraversalPolicyProvider;
+
int containerSerializedDataVersion;
/* Anything else is non-serializable, and should be declared "transient". */
@@ -927,10 +937,10 @@
*
* @since 1.3
*/
- public EventListener[] getListeners(Class listenerT...
[truncated message content] |
|
From: <ls...@us...> - 2007-01-31 20:25:36
|
Revision: 3099
http://jnode.svn.sourceforge.net/jnode/?rev=3099&view=rev
Author: lsantha
Date: 2007-01-31 12:25:09 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/ContainerOrderFocusTraversalPolicy.java
trunk/core/src/classpath/java/java/awt/EventDispatchThread.java
trunk/core/src/classpath/java/java/awt/EventQueue.java
trunk/core/src/classpath/java/java/awt/LightweightDispatcher.java
trunk/core/src/classpath/java/java/awt/Window.java
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -1486,7 +1486,40 @@
}
}
- /**
+ /**
+ * Sends notification to interested listeners about resizing and/or moving
+ * the component. If this component has interested
+ * component listeners or the corresponding event mask enabled, then
+ * COMPONENT_MOVED and/or COMPONENT_RESIZED events are posted to the event
+ * queue.
+ *
+ * @param resized true if the component has been resized, false otherwise
+ * @param moved true if the component has been moved, false otherwise
+ */
+ void notifyReshape(boolean resized, boolean moved)
+ {
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ // Fire component event on this component.
+ if (moved)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_MOVED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ if (resized)
+ {
+ ComponentEvent ce = new ComponentEvent(this,
+ ComponentEvent.COMPONENT_RESIZED);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+ }
+
+ /**
* Sets the bounding rectangle for this component to the specified
* rectangle. Note that these coordinates are relative to the parent, not
* to the screen.
Modified: trunk/core/src/classpath/java/java/awt/Container.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Container.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/Container.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -1808,6 +1808,11 @@
}
}
+ /**
+ * Overridden to dispatch events to lightweight descendents.
+ *
+ * @param e the event to dispatch.
+ */
void dispatchEventImpl(AWTEvent e)
{
boolean dispatched =
@@ -1825,6 +1830,19 @@
}
/**
+ * This is called by the lightweight dispatcher to avoid recursivly
+ * calling into the lightweight dispatcher.
+ *
+ * @param e the event to dispatch
+ *
+ * @see LightweightDispatcher#redispatch(MouseEvent, Component, int)
+ */
+ void dispatchNoLightweight(AWTEvent e)
+ {
+ super.dispatchEventImpl(e);
+ }
+
+ /**
* Tests if this container has an interest in the given event id.
*
* @param eventId The event id to check.
@@ -1938,6 +1956,43 @@
parent.updateHierarchyListenerCount(type, delta);
}
+ /**
+ * Notifies interested listeners about resizing or moving the container.
+ * This performs the super behaviour (sending component events) and
+ * additionally notifies any hierarchy bounds listeners on child components.
+ *
+ * @param resized true if the component has been resized, false otherwise
+ * @param moved true if the component has been moved, false otherwise
+ */
+ void notifyReshape(boolean resized, boolean moved)
+ {
+ // Notify component listeners.
+ super.notifyReshape(resized, moved);
+
+ if (ncomponents > 0)
+ {
+ // Notify hierarchy bounds listeners.
+ if (resized)
+ {
+ for (int i = 0; i < getComponentCount(); i++)
+ {
+ Component child = getComponent(i);
+ child.fireHierarchyEvent(HierarchyEvent.ANCESTOR_RESIZED,
+ this, parent, 0);
+ }
+ }
+ if (moved)
+ {
+ for (int i = 0; i < getComponentCount(); i++)
+ {
+ Component child = getComponent(i);
+ child.fireHierarchyEvent(HierarchyEvent.ANCESTOR_MOVED,
+ this, parent, 0);
+ }
+ }
+ }
+ }
+
private void addNotifyContainerChildren()
{
synchronized (getTreeLock ())
Modified: trunk/core/src/classpath/java/java/awt/ContainerOrderFocusTraversalPolicy.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/ContainerOrderFocusTraversalPolicy.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/ContainerOrderFocusTraversalPolicy.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -346,29 +346,31 @@
|| !root.isDisplayable ())
return null;
- if (root.visible && root.isDisplayable() && root.enabled
- && root.focusable)
+ if (accept(root))
return root;
- Component[] componentArray = root.getComponents ();
-
- for (int i = 0; i < componentArray.length; i++)
+ int ncomponents = root.getComponentCount();
+ for (int i = 0; i < ncomponents; i++)
{
- Component component = componentArray [i];
-
- if (component.visible && component.isDisplayable() && component.enabled
- && component.focusable)
- return component;
-
- if (component instanceof Container)
+ Component component = root.getComponent(i);
+ if (component instanceof Container
+ && !((Container) component).isFocusCycleRoot())
{
- Component result = getFirstComponent ((Container) component);
-
- if (result != null
- && (result.visible && result.isDisplayable() && result.enabled && result.focusable))
- return result;
+ Component first = null;
+ Container cont = (Container) component;
+ if (cont.isFocusTraversalPolicyProvider())
+ {
+ FocusTraversalPolicy childPol = cont.getFocusTraversalPolicy();
+ first = childPol.getFirstComponent(cont);
}
+ else
+ first = getFirstComponent(cont);
+ if (first != null)
+ return first;
}
+ else if (accept(component))
+ return component;
+ }
return null;
}
Modified: trunk/core/src/classpath/java/java/awt/EventDispatchThread.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/EventDispatchThread.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/EventDispatchThread.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -73,6 +73,9 @@
// Ignore and use default.
}
setPriority(priority);
+
+ // Make sure that an event dispatch thread is never a daemon thread.
+ setDaemon(false);
}
public void run()
Modified: trunk/core/src/classpath/java/java/awt/EventQueue.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/EventQueue.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/EventQueue.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -39,6 +39,7 @@
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,6 +115,7 @@
private long lastWhen = System.currentTimeMillis();
private EventDispatchThread dispatchThread = new EventDispatchThread(this);
+ private boolean nativeLoopRunning = false;
private boolean shutdown = false;
// @vm-specific allow JNode access from VMAwtAPI
@@ -130,17 +132,19 @@
// 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;
- }
+
+ 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;
}
/**
@@ -169,22 +173,26 @@
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())
+ {
+ // 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;
- if (isShutdown())
+ // Interrupt the event dispatch thread.
throw new InterruptedException();
+ }
wait();
- res = getNextEventImpl(true);
+ res = getNextEventImpl(true);
}
return res;
@@ -298,6 +306,12 @@
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);
}
Modified: trunk/core/src/classpath/java/java/awt/LightweightDispatcher.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/LightweightDispatcher.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/LightweightDispatcher.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -38,7 +38,10 @@
package java.awt;
+import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.peer.LightweightPeer;
import java.util.WeakHashMap;
/**
@@ -49,7 +52,7 @@
*
* @author Roman Kennke (ke...@ai...)
*/
-class LightweightDispatcher
+final class LightweightDispatcher
{
/**
@@ -80,6 +83,11 @@
private Component lastTarget;
/**
+ * The current mouseEventTarget.
+ */
+ private Component mouseEventTarget;
+
+ /**
* Returns an instance of LightweightDispatcher for the current thread's
* thread group.
*
@@ -113,7 +121,7 @@
*
* @param event the event
*/
- public boolean dispatchEvent(AWTEvent event)
+ public boolean dispatchEvent(final AWTEvent event)
{
if (event instanceof MouseEvent && event.getSource() instanceof Window)
{
@@ -336,4 +344,138 @@
p.y -= offY;
return p;
}
+
+ /**
+ * Checks if the specified component would be interested in a mouse event.
+ *
+ * @param c the component to check
+ *
+ * @return <code>true</code> if the component has mouse listeners installed,
+ * <code>false</code> otherwise
+ */
+ private boolean isMouseListening(final Component c)
+ {
+ // Note: It is important to NOT check if the component is listening
+ // for a specific event (for instance, mouse motion events). The event
+ // gets dispatched to the component if the component is listening
+ // for ANY mouse event, even when the component is not listening for the
+ // specific type of event. There are applications that depend on this
+ // (sadly).
+ return c.mouseListener != null
+ || c.mouseMotionListener != null
+ || c.mouseWheelListener != null
+ || (c.eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0
+ || (c.eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0
+ || (c.eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0;
+ }
+
+ /**
+ * Tracks MOUSE_ENTERED and MOUSE_EXIT as well as MOUSE_MOVED and
+ * MOUSE_DRAGGED and creates synthetic MOUSE_ENTERED and MOUSE_EXITED for
+ * lightweight component.s
+ *
+ * @param target the current mouse event target
+ * @param ev the mouse event
+ */
+ private void trackEnterExit(final Component target, final MouseEvent ev)
+ {
+ int id = ev.getID();
+ if (target != lastTarget)
+ {
+ if (lastTarget != null)
+ redispatch(ev, lastTarget, MouseEvent.MOUSE_EXITED);
+ if (id == MouseEvent.MOUSE_EXITED)
+ ev.consume();
+ if (target != null)
+ redispatch(ev, target, MouseEvent.MOUSE_ENTERED);
+ if (id == MouseEvent.MOUSE_ENTERED)
+ ev.consume();
+ lastTarget = target;
+ }
+
+ }
+
+ /**
+ * Redispatches the specified mouse event to the specified target with the
+ * specified id.
+ *
+ * @param ev the mouse event
+ * @param target the new target
+ * @param id the new id
+ */
+ private void redispatch(MouseEvent ev, Component target, int id)
+ {
+ Component source = ev.getComponent();
+ if (target != null)
+ {
+ // Translate coordinates.
+ int x = ev.getX();
+ int y = ev.getY();
+ for (Component c = target; c != null && c != source; c = c.getParent())
+ {
+ x -= c.x;
+ y -= c.y;
+ }
+
+ // Retarget event.
+ MouseEvent retargeted;
+ if (id == MouseEvent.MOUSE_WHEEL)
+ {
+ MouseWheelEvent mwe = (MouseWheelEvent) ev;
+ retargeted = new MouseWheelEvent(target, id, ev.getWhen(),
+ ev.getModifiers()
+ | ev.getModifiersEx(), x, y,
+ ev.getClickCount(),
+ ev.isPopupTrigger(),
+ mwe.getScrollType(),
+ mwe.getScrollAmount(),
+ mwe.getWheelRotation());
+ }
+ else
+ {
+ retargeted = new MouseEvent(target, id, ev.getWhen(),
+ ev.getModifiers() | ev.getModifiersEx(),
+ x, y, ev.getClickCount(),
+ ev.isPopupTrigger(), ev.getButton());
+ }
+
+ if (target == source)
+ ((Container) target).dispatchNoLightweight(retargeted);
+ else
+ target.dispatchEvent(retargeted);
+ }
+ }
+
+ /**
+ * Determines if we are in the middle of a drag operation, that is, if
+ * any of the buttons is held down.
+ *
+ * @param ev the mouse event to check
+ *
+ * @return <code>true</code> if we are in the middle of a drag operation,
+ * <code>false</code> otherwise
+ */
+ private boolean isDragging(MouseEvent ev)
+ {
+ int mods = ev.getModifiersEx();
+ int id = ev.getID();
+ if (id == MouseEvent.MOUSE_PRESSED || id == MouseEvent.MOUSE_RELEASED)
+ {
+ switch (ev.getButton())
+ {
+ case MouseEvent.BUTTON1:
+ mods ^= InputEvent.BUTTON1_DOWN_MASK;
+ break;
+ case MouseEvent.BUTTON2:
+ mods ^= InputEvent.BUTTON2_DOWN_MASK;
+ break;
+ case MouseEvent.BUTTON3:
+ mods ^= InputEvent.BUTTON3_DOWN_MASK;
+ break;
+ }
+ }
+ return (mods & (InputEvent.BUTTON1_DOWN_MASK
+ | InputEvent.BUTTON2_DOWN_MASK
+ | InputEvent.BUTTON3_DOWN_MASK)) != 0;
+ }
}
Modified: trunk/core/src/classpath/java/java/awt/Window.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Window.java 2007-01-31 19:02:43 UTC (rev 3098)
+++ trunk/core/src/classpath/java/java/awt/Window.java 2007-01-31 20:25:09 UTC (rev 3099)
@@ -329,6 +329,15 @@
if (initialFocusOwner != null)
initialFocusOwner.requestFocusInWindow();
+ // Post WINDOW_OPENED 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);
+ }
shown = true;
}
}
@@ -413,11 +422,8 @@
public void toFront()
{
if (peer != null)
- {
- WindowPeer wp = (WindowPeer) peer;
- wp.toFront();
+ ( (WindowPeer) peer ).toFront();
}
- }
/**
* Returns the toolkit used to create this window.
@@ -1146,6 +1152,47 @@
this.focusableWindowState = focusableWindowState;
}
+ /**
+ * Check whether this Container is a focus cycle root.
+ * Returns always <code>true</code> as Windows are the
+ * root of the focus cycle.
+ *
+ * @return Always <code>true</code>.
+ *
+ * @since 1.4
+ */
+ public final boolean isFocusCycleRoot()
+ {
+ return true;
+ }
+
+ /**
+ * Set whether or not this Container is the root of a focus
+ * traversal cycle. Windows are the root of the focus cycle
+ * and therefore this method does nothing.
+ *
+ * @param focusCycleRoot ignored.
+ *
+ * @since 1.4
+ */
+ public final void setFocusCycleRoot(boolean focusCycleRoot)
+ {
+ // calls to the method are ignored
+ }
+
+ /**
+ * Returns the root container that owns the focus cycle where this
+ * component resides. Windows have no ancestors and this method
+ * returns always <code>null</code>.
+ *
+ * @return Always <code>null</code>.
+ * @since 1.4
+ */
+ public final Container getFocusCycleRootAncestor()
+ {
+ return null;
+ }
+
// setBoundsCallback is needed so that when a user moves a window,
// the Window's location can be updated without calling the peer's
// setBounds method. When a user moves a window the peer window's
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-01-31 21:51:51
|
Revision: 3100
http://jnode.svn.sourceforge.net/jnode/?rev=3100&view=rev
Author: lsantha
Date: 2007-01-31 13:51:44 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java
trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java
trunk/core/src/classpath/java/java/awt/TextArea.java
trunk/core/src/classpath/java/java/awt/TextComponent.java
trunk/core/src/classpath/java/java/awt/TextField.java
trunk/core/src/classpath/java/java/awt/Toolkit.java
Modified: trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -256,6 +256,95 @@
return false;
}
+ /**
+ * Handles FOCUS_GAINED events in {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ */
+ private boolean handleFocusGained(FocusEvent fe)
+ {
+ Component target = fe.getComponent ();
+
+ // If old focus owner != new focus owner, notify old focus
+ // owner that it has lost focus.
+ Component oldFocusOwner = getGlobalFocusOwner();
+ if (oldFocusOwner != null && oldFocusOwner != target)
+ {
+ FocusEvent lost = new FocusEvent(oldFocusOwner,
+ FocusEvent.FOCUS_LOST,
+ fe.isTemporary(), target);
+ oldFocusOwner.dispatchEvent(lost);
+ }
+
+ setGlobalFocusOwner (target);
+ if (target != getGlobalFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner (target);
+ if (target != getGlobalPermanentFocusOwner())
+ {
+ // Focus transfer was rejected, like when the target is not
+ // focusable.
+ dequeueKeyEvents(-1, target);
+ // FIXME: Restore focus somehow.
+ }
+ else
+ {
+ redispatchEvent(target, fe);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Handles FOCUS_LOST events for {@link #dispatchEvent(AWTEvent)}.
+ *
+ * @param fe the focus event
+ *
+ * @return if the event has been handled
+ */
+ private boolean handleFocusLost(FocusEvent fe)
+ {
+ Component currentFocus = getGlobalFocusOwner();
+ if (currentFocus != fe.getOppositeComponent())
+ {
+ setGlobalFocusOwner(null);
+ if (getGlobalFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to restore
+ // the focus.
+ }
+ else
+ {
+ if (! fe.isTemporary())
+ {
+ setGlobalPermanentFocusOwner(null);
+ if (getGlobalPermanentFocusOwner() != null)
+ {
+ // TODO: Is this possible? If so, then we should try to
+ // restore the focus.
+ }
+ else
+ {
+ fe.setSource(currentFocus);
+ redispatchEvent(currentFocus, fe);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
private boolean enqueueKeyEvent (KeyEvent e)
{
Iterator i = delayRequests.iterator ();
Modified: trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -561,7 +561,9 @@
* @see #UP_CYCLE_TRAVERSAL_KEYS
* @see #DOWN_CYCLE_TRAVERSAL_KEYS
*/
- public void setDefaultFocusTraversalKeys (int id, Set keystrokes)
+ public void setDefaultFocusTraversalKeys (int id,
+ Set<? extends AWTKeyStroke>
+ keystrokes)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
@@ -633,7 +635,7 @@
* @see #UP_CYCLE_TRAVERSAL_KEYS
* @see #DOWN_CYCLE_TRAVERSAL_KEYS
*/
- public Set getDefaultFocusTraversalKeys (int id)
+ public Set<AWTKeyStroke> getDefaultFocusTraversalKeys (int id)
{
if (id < FORWARD_TRAVERSAL_KEYS || id > DOWN_CYCLE_TRAVERSAL_KEYS)
throw new IllegalArgumentException ();
@@ -995,9 +997,9 @@
* @return A list of explicitly registered key event dispatchers.
* @see KeyboardFocusManager#addKeyEventDispatcher(java.awt.KeyEventDispatcher)
*/
- protected List getKeyEventDispatchers ()
+ protected List<KeyEventDispatcher> getKeyEventDispatchers ()
{
- return (List) keyEventDispatchers.clone ();
+ return (List<KeyEventDispatcher>) keyEventDispatchers.clone ();
}
/**
@@ -1052,9 +1054,9 @@
* @return A list of explicitly registered key event post processors.
* @see KeyboardFocusManager#addKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
*/
- protected List getKeyEventPostProcessors ()
+ protected List<KeyEventPostProcessor> getKeyEventPostProcessors ()
{
- return (List) keyEventPostProcessors.clone ();
+ return (List<KeyEventPostProcessor>) keyEventPostProcessors.clone ();
}
/**
@@ -1436,4 +1438,48 @@
}
}
}
+
+
+ /**
+ * Maps focus requests from heavyweight to lightweight components.
+ */
+ private static HashMap focusRequests = new HashMap();
+
+ /**
+ * Retargets focus events that come from the peer (which only know about
+ * heavyweight components) to go to the correct lightweight component
+ * if appropriate.
+ *
+ * @param ev the event to check
+ *
+ * @return the retargetted event
+ */
+ static AWTEvent retargetFocusEvent(AWTEvent ev)
+ {
+ if (ev instanceof FocusEvent)
+ {
+ FocusEvent fe = (FocusEvent) ev;
+ Component target = fe.getComponent();
+ if (focusRequests.containsKey(target))
+ {
+ Component lightweight = (Component) focusRequests.get(target);
+ ev = new FocusEvent(lightweight, fe.id, fe.isTemporary());
+ focusRequests.remove(target);
}
+ }
+ return ev;
+ }
+
+ /**
+ * Adds a lightweight focus request for a heavyweight component.
+ *
+ * @param heavyweight the heavyweight from which we will receive a focus
+ * event soon
+ * @param lightweight the lightweight that ultimately receives the request
+ */
+ static void addLightweightFocusRequest(Component heavyweight,
+ Component lightweight)
+ {
+ focusRequests.put(heavyweight, lightweight);
+ }
+}
Modified: trunk/core/src/classpath/java/java/awt/TextArea.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/TextArea.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/TextArea.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -125,9 +125,11 @@
* the specified text. Conceptually the <code>TextArea</code> has 0
* rows and 0 columns but its initial bounds are defined by its peer
* or by the container in which it is packed. Both horizontal and
- * veritcal scrollbars will be displayed.
+ * veritcal scrollbars will be displayed. The TextArea initially contains
+ * the specified text. If text specified as <code>null<code>, it will
+ * be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
*
* @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
*/
@@ -156,9 +158,10 @@
* Initialize a new instance of <code>TextArea</code> that can
* display the specified number of rows and columns of text, without
* the need to scroll. The TextArea initially contains the
- * specified text.
+ * specified text. If text specified as <code>null<code>, it will
+ * be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
*
@@ -174,9 +177,10 @@
* contains the specified text. The TextArea can display the
* specified number of rows and columns of text, without the need to
* scroll. This constructor allows specification of the scroll bar
- * display policy.
+ * display policy. The TextArea initially contains the specified text.
+ * If text specified as <code>null<code>, it will be set to "".
*
- * @param text The text to display in this text area.
+ * @param text The text to display in this text area (<code>null</code> permitted).
* @param rows The number of rows in this text area.
* @param columns The number of columns in this text area.
* @param scrollbarVisibility The scroll bar display policy. One of
@@ -192,17 +196,19 @@
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
- if (rows < 0 || columns < 0)
- throw new IllegalArgumentException ("Bad row or column value");
+ if (rows < 0)
+ this.rows = 0;
+ else
+ this.rows = rows;
- if (scrollbarVisibility != SCROLLBARS_BOTH
- && scrollbarVisibility != SCROLLBARS_VERTICAL_ONLY
- && scrollbarVisibility != SCROLLBARS_HORIZONTAL_ONLY
- && scrollbarVisibility != SCROLLBARS_NONE)
- throw new IllegalArgumentException ("Bad scrollbar visibility value");
+ if (columns < 0)
+ this.columns = 0;
+ else
+ this.columns = columns;
- this.rows = rows;
- this.columns = columns;
+ if (scrollbarVisibility < 0 || scrollbarVisibility > 4)
+ this.scrollbarVisibility = SCROLLBARS_BOTH;
+ else
this.scrollbarVisibility = scrollbarVisibility;
// TextAreas need to receive tab key events so we override the
@@ -278,11 +284,7 @@
}
/**
- * Retrieve the minimum size for this text area, considering the
- * text area's current row and column values. A text area's minimum
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the minimum size for this text area.
*
* @return The minimum size for this text field.
*/
@@ -292,11 +294,8 @@
}
/**
- * Retrieve the minimum size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's minimum size depends on the number of rows and columns of
- * text it would prefer to display, and on the size of the font in
- * which the text would be displayed.
+ * Retrieve the minimum size for this text area. If the minimum
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the minimum size
* calculation.
@@ -311,11 +310,7 @@
}
/**
- * Retrieve the minimum size for this text area, considering the
- * text area's current row and column values. A text area's minimum
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the minimum size for this text area.
*
* @return The minimum size for this text area.
*
@@ -328,11 +323,8 @@
}
/**
- * Retrieve the minimum size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's minimum size depends on the number of rows and columns of
- * text it would prefer to display, and on the size of the font in
- * which the text would be displayed.
+ * Retrieve the minimum size for this text area. If the minimum
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the minimum size
* calculation.
@@ -346,21 +338,18 @@
*/
public Dimension minimumSize (int rows, int columns)
{
+ if (isMinimumSizeSet())
+ return new Dimension(minSize);
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
- // Sun returns Dimension (0,0) in this case.
if (peer == null)
- return new Dimension (0, 0);
+ return new Dimension (getWidth(), getHeight());
return peer.getMinimumSize (rows, columns);
}
/**
- * Retrieve the preferred size for this text area, considering the
- * text area's current row and column values. A text area's preferred
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the preferred size for this text area.
*
* @return The preferred size for this text field.
*/
@@ -370,11 +359,8 @@
}
/**
- * Retrieve the preferred size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's preferred size depends on the number of rows and columns
- * of text it would prefer to display, and on the size of the font
- * in which the text would be displayed.
+ * Retrieve the preferred size for this text area. If the preferred
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the preferred size
* calculation.
@@ -389,11 +375,7 @@
}
/**
- * Retrieve the preferred size for this text area, considering the
- * text area's current row and column values. A text area's preferred
- * size depends on the number of rows and columns of text it would
- * prefer to display, and on the size of the font in which the text
- * would be displayed.
+ * Retrieve the preferred size for this text area.
*
* @return The preferred size for this text field.
*
@@ -406,11 +388,8 @@
}
/**
- * Retrieve the preferred size that this text area would have if its
- * row and column values were equal to those specified. A text
- * area's preferred size depends on the number of rows and columns
- * of text it would prefer to display, and on the size of the font
- * in which the text would be displayed.
+ * Retrieve the preferred size for this text area. If the preferred
+ * size has been set, then rows and columns are used in the calculation.
*
* @param rows The number of rows to use in the preferred size
* calculation.
@@ -424,11 +403,12 @@
*/
public Dimension preferredSize (int rows, int columns)
{
+ if (isPreferredSizeSet())
+ return new Dimension(prefSize);
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
-
- // Sun returns Dimension (0,0) in this case.
if (peer == null)
- return new Dimension (0, 0);
+ return new Dimension (getWidth(), getHeight());
return peer.getPreferredSize (rows, columns);
}
@@ -478,6 +458,8 @@
if (peer != null)
peer.insert (str, peer.getText().length ());
+ else
+ setText(getText() + str);
}
/**
@@ -504,11 +486,20 @@
*/
public void insertText (String str, int pos)
{
+ String tmp1 = null;
+ String tmp2 = null;
+
TextAreaPeer peer = (TextAreaPeer) getPeer ();
if (peer != null)
peer.insert (str, pos);
+ else
+ {
+ tmp1 = getText().substring(0, pos);
+ tmp2 = getText().substring(pos, getText().length());
+ setText(tmp1 + str + tmp2);
}
+ }
/**
* Replace a range of characters with the specified text. The
@@ -544,11 +535,20 @@
*/
public void replaceText (String str, int start, int end)
{
- TextAreaPeer peer = (TextAreaPeer) getPeer ();
+ String tmp1 = null;
+ String tmp2 = null;
+ TextAreaPeer peer = (TextAreaPeer) getPeer();
+
if (peer != null)
- peer.replaceRange (str, start, end);
+ peer.replaceRange(str, start, end);
+ else
+ {
+ tmp1 = getText().substring(0, start);
+ tmp2 = getText().substring(end, getText().length());
+ setText(tmp1 + str + tmp2);
}
+ }
/**
* Retrieve a debugging string for this text area.
Modified: trunk/core/src/classpath/java/java/awt/TextComponent.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/TextComponent.java 2007-01-31 20:25:09 UTC (rev 3099)
+++ trunk/core/src/classpath/java/java/awt/TextComponent.java 2007-01-31 21:51:44 UTC (rev 3100)
@@ -1,5 +1,5 @@
/* TextComponent.java -- Widgets for entering text
- Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -63,45 +63,36 @@
implements Serializable, Accessible
{
-/*
- * Static Variables
- */
+ private static final long serialVersionUID = -2214773872412987419L;
-// Constant for serialization
-private static final long serialVersionUID = -2214773872412987419L;
-
-/*
- * Instance Variables
- */
-
-/**
+ /**
* @serial Indicates whether or not this component is editable.
* This is package-private to avoid an accessor method.
*/
-boolean editable;
+ boolean editable;
-/**
+ /**
* @serial The starting position of the selected text region.
* This is package-private to avoid an accessor method.
*/
-int selectionStart;
+ int selectionStart;
-/**
+ /**
* @serial The ending position of the selected text region.
* This is package-private to avoid an accessor method.
*/
-int selectionEnd;
+ int selectionEnd;
-/**
+ /**
* @serial The text in the component
* This is package-private to avoid an accessor method.
*/
-String text;
+ String text;
-/**
+ /**
* A list of listeners that will receive events from this object.
*/
-protected transient TextListener textListener;
+ protected transient TextListener textListener;
protected class AccessibleAWTTextComponent
extends AccessibleAWTComponent
@@ -318,146 +309,121 @@
}
-/*************************************************************************/
-/*
- * Constructors
- */
-
-TextComponent(String text)
-{
+ TextComponent(String text)
+ {
+ if (text == null)
+ this.text = "";
+ else
this.text = text;
+
this.editable = true;
-}
+ }
-/*************************************************************************/
-/*
- * Instance Methods
- */
-
-/**
+ /**
* Returns the text in this component
*
* @return The text in this component.
*/
-public synchronized String
-getText()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized String getText()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
text = tcp.getText();
return(text);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the text in this component to the specified string.
*
* @param text The new text for this component.
*/
-public synchronized void
-setText(String text)
-{
+ public synchronized void setText(String text)
+ {
if (text == null)
text = "";
this.text = text;
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.setText(text);
setCaretPosition(0);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns a string that contains the text that is currently selected.
*
* @return The currently selected text region.
*/
-public synchronized String
-getSelectedText()
-{
+ public synchronized String getSelectedText()
+ {
String alltext = getText();
int start = getSelectionStart();
int end = getSelectionEnd();
return(alltext.substring(start, end));
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the starting position of the selected text region.
* If the text is not selected then caret position is returned.
*
* @return The starting position of the selected text region.
*/
-public synchronized int
-getSelectionStart()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized int getSelectionStart()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
selectionStart = tcp.getSelectionStart();
return(selectionStart);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the starting position of the selected region to the
* specified value. If the specified value is out of range, then it
* will be silently changed to the nearest legal value.
*
* @param selectionStart The new start position for selected text.
*/
-public synchronized void
-setSelectionStart(int selectionStart)
-{
- select(selectionStart, getSelectionEnd());
-}
+ public synchronized void setSelectionStart(int selectionStart)
+ {
+ select(selectionStart,
+ (getSelectionEnd() < selectionStart)
+ ? selectionStart : getSelectionEnd());
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the ending position of the selected text region.
* If the text is not selected, then caret position is returned
*
* @return The ending position of the selected text region.
*/
-public synchronized int
-getSelectionEnd()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized int getSelectionEnd()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
selectionEnd = tcp.getSelectionEnd();
return(selectionEnd);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the ending position of the selected region to the
* specified value. If the specified value is out of range, then it
* will be silently changed to the nearest legal value.
*
* @param selectionEnd The new start position for selected text.
*/
-public synchronized void
-setSelectionEnd(int selectionEnd)
-{
+ public synchronized void setSelectionEnd(int selectionEnd)
+ {
select(getSelectionStart(), selectionEnd);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* This method sets the selected text range to the text between the
* specified start and end positions. Illegal values for these
* positions are silently fixed.
@@ -465,9 +431,8 @@
* @param selectionStart The new start position for the selected text.
* @param selectionEnd The new end position for the selected text.
*/
-public synchronized void
-select(int selectionStart, int selectionEnd)
-{
+ public synchronized void select(int selectionStart, int selectionEnd)
+ {
if (selectionStart < 0)
selectionStart = 0;
@@ -483,42 +448,34 @@
this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd;
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.select(selectionStart, selectionEnd);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Selects all of the text in the component.
*/
-public synchronized void
-selectAll()
-{
+ public synchronized void selectAll()
+ {
select(0, getText().length());
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns the current caret position in the text.
*
* @return The caret position in the text.
*/
-public synchronized int
-getCaretPosition()
-{
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ public synchronized int getCaretPosition()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
return(tcp.getCaretPosition());
else
return(0);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets the caret position to the specified value.
*
* @param caretPosition The new caret position.
@@ -528,111 +485,90 @@
*
* @since 1.1
*/
-public synchronized void
-setCaretPosition(int caretPosition)
-{
+ public synchronized void setCaretPosition(int caretPosition)
+ {
if (caretPosition < 0)
- throw new IllegalArgumentException ();
+ throw new IllegalArgumentException();
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.setCaretPosition(caretPosition);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Tests whether or not this component's text can be edited.
*
* @return <code>true</code> if the text can be edited, <code>false</code>
* otherwise.
*/
-public boolean
-isEditable()
-{
+ public boolean isEditable()
+ {
return(editable);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Sets whether or not this component's text can be edited.
*
* @param editable <code>true</code> to enable editing of the text,
* <code>false</code> to disable it.
*/
-public synchronized void
-setEditable(boolean editable)
-{
+ public synchronized void setEditable(boolean editable)
+ {
this.editable = editable;
- TextComponentPeer tcp = (TextComponentPeer)getPeer();
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
if (tcp != null)
tcp.setEditable(editable);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Notifies the component that it should destroy its native peer.
*/
-public void
-removeNotify()
-{
+ public void removeNotify()
+ {
super.removeNotify();
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Adds a new listener to the list of text listeners for this
* component.
*
* @param listener The listener to be added.
*/
-public synchronized void
-addTextListener(TextListener listener)
-{
+ public synchronized void addTextListener(TextListener listener)
+ {
textListener = AWTEventMulticaster.add(textListener, listener);
enableEvents(AWTEvent.TEXT_EVENT_MASK);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Removes the specified listener from the list of listeners
* for this component.
*
* @param listener The listener to remove.
*/
-public synchronized void
-removeTextListener(TextListener listener)
-{
+ public synchronized void removeTextListener(TextListener listener)
+ {
textListener = AWTEventMulticaster.remove(textListener, listener);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes the specified event for this component. Text events are
* processed by calling the <code>processTextEvent()</code> method.
* All other events are passed to the superclass method.
*
* @param event The event to process.
*/
-protected void
-processEvent(AWTEvent event)
-{
+ protected void processEvent(AWTEvent event)
+ {
if (event instanceof TextEvent)
processTextEvent((TextEvent)event);
else
super.processEvent(event);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Processes the specified text event by dispatching it to any listeners
* that are registered. Note that this method will only be called
* if text event's are enabled. This will be true if there are any
@@ -641,16 +577,14 @@
*
* @param event The text event to process.
*/
-protected void
-processTextEvent(TextEvent event)
-{
+ protected void processTextEvent(TextEvent event)
+ {
if (textListener != null)
textListener.textValueChanged(event);
-}
+ }
-void
-dispatchEventImpl(AWTEvent e)
-{
+ void dispatchEventImpl(AWTEvent e)
+ {
if (e.id <= TextEvent.TEXT_LAST
&& e.id >= TextEvent.TEXT_FIRST
&& (textListener != null
@@ -658,20 +592,17 @@
processEvent(e);
else
super.dispatchEventImpl(e);
-}
+ }
-/*************************************************************************/
-
-/**
+ /**
* Returns a debugging string.
*
* @return A debugging string.
*/
-protected String
-paramString()
-{
+ protected String paramString()
+ {
return(getClass().getName() + "(text=" + getText() + ")");
-}
+ }
/**
* Returns an array of all the objects currently registered as FooListeners
@@ -681,20 +612,20 @@
* @exception ClassCastException If listenerType doesn't specify a class or
* interface that implements java.util.EventListener.
*/
- public EventListener[] getListeners (Class listenerType)
+ public <T extends EventListener> T[] getListeners(Class<T> listenerType)
{
if (listenerType == TextListener.class)
- return AWTEventMulticaster.getListeners (textListener, listenerType);
+ return AWTEventMulticaster.getListeners(textListener, listenerType);
- return super.getListeners (listenerType);
+ return super.getListeners(listenerType);
}
/**
* Returns all text listeners registered to this object.
*/
- public TextListener[] getTextListeners ()
+ public TextListener[] getTextListeners()
{
- return (TextListener[]) getListeners (TextListener.class)...
[truncated message content] |
|
From: <ls...@us...> - 2007-02-03 15:05:36
|
Revision: 3101
http://jnode.svn.sourceforge.net/jnode/?rev=3101&view=rev
Author: lsantha
Date: 2007-02-03 07:05:27 -0800 (Sat, 03 Feb 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/Window.java
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-01-31 21:51:44 UTC (rev 3100)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-02-03 15:05:27 UTC (rev 3101)
@@ -581,7 +581,7 @@
transient ComponentPeer peer;
/** The preferred component orientation. */
- transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN;
+ transient ComponentOrientation componentOrientation = ComponentOrientation.UNKNOWN;
/**
* The associated graphics configuration.
@@ -748,17 +748,24 @@
*/
public Toolkit getToolkit()
{
- if (peer != null)
+ // Only heavyweight peers can handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
{
- Toolkit tk = peer.getToolkit();
- if (tk != null)
- return tk;
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
- // Get toolkit for lightweight component.
- if (parent != null)
- return parent.getToolkit();
- return Toolkit.getDefaultToolkit();
+
+ Toolkit tk = null;
+ if (p != null)
+ {
+ tk = peer.getToolkit();
}
+ if (tk == null)
+ tk = Toolkit.getDefaultToolkit();
+ return tk;
+ }
/**
* Tests whether or not this component is valid. A invalid component needs
@@ -770,7 +777,9 @@
*/
public boolean isValid()
{
- return valid;
+ // Tests show that components are invalid as long as they are not showing, even after validate()
+ // has been called on them.
+ return peer != null && valid;
}
/**
@@ -814,10 +823,8 @@
*/
public boolean isShowing()
{
- if (! visible || peer == null)
- return false;
-
- return parent == null ? false : parent.isShowing();
+ Component par = parent;
+ return visible && peer != null && (par == null || par.isShowing());
}
/**
@@ -856,10 +863,18 @@
*/
public void enable()
{
- this.enabled = true;
- if (peer != null)
- peer.setEnabled (true);
+ if (! enabled)
+ {
+ // Need to lock the tree here, because the peers are involved.
+ synchronized (getTreeLock())
+ {
+ enabled = true;
+ ComponentPeer p = peer;
+ if (p != null)
+ p.enable();
}
+ }
+ }
/**
* Enables or disables this component.
@@ -883,10 +898,18 @@
*/
public void disable()
{
- this.enabled = false;
- if (peer != null)
- peer.setEnabled (false);
+ if (enabled)
+ {
+ // Need to lock the tree here, because the peers are involved.
+ synchronized (getTreeLock())
+ {
+ enabled = false;
+ ComponentPeer p = peer;
+ if (p != null)
+ p.disable();
}
+ }
+ }
/**
* Checks if this image is painted to an offscreen image buffer that is
@@ -1130,11 +1153,36 @@
return null;
}
- /**
+ /**
+ * Implementation of getFont(). This is pulled out of getFont() to prevent
+ * client programs from overriding this.
+ *
+ * @return the font of this component
+ */
+ private final Font getFontImpl()
+ {
+ Font f = font;
+ if (f == null)
+ {
+ Component p = parent;
+ if (p != null)
+ f = p.getFontImpl();
+ else
+ {
+ // It is important to return null here and not some kind of default
+ // font, otherwise the Swing UI would not install its fonts because
+ // it keeps non-UIResource fonts.
+ f = null;
+ }
+ }
+ return f;
+ }
+
+ /**
* Sets the font for this component to the specified font. This is a bound
* property.
*
- * @param newFont the new font for this component
+ * @param f the new font for this component
*
* @see #getFont()
*/
@@ -1729,11 +1777,39 @@
return prefSize;
}
+ /**
+ * The actual calculation is pulled out of preferredSize() so that
+ * we can call it from Container.preferredSize() and avoid creating a
+ * new intermediate Dimension object.
+ *
+ * @return the preferredSize of the component
+ */
+ Dimension preferredSizeImpl()
+ {
+ Dimension size = prefSize;
+ // Try to use a cached value.
+ if (size == null || !(valid || prefSizeSet))
+ {
+ // We need to lock here, because the calculation depends on the
+ // component structure not changing.
+ synchronized (getTreeLock())
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ size = peer.preferredSize();
+ else
+ size = minimumSizeImpl();
+ }
+ }
+ return size;
+ }
+
/**
* Returns the component's minimum size.
*
* @return the component's minimum size
* @see #getPreferredSize()
+ * @see #setMinimumSize(Dimension)
* @see LayoutManager
*/
public Dimension getMinimumSize()
@@ -1937,8 +2013,33 @@
*/
public void validate()
{
+ if (! valid)
+ {
+ // Synchronize on the tree here as this might change the layout
+ // of the hierarchy.
+ synchronized (getTreeLock())
+ {
+ // Create local variables for thread safety.
+ ComponentPeer p = peer;
+ if (p != null)
+ {
+ // Possibly update the peer's font.
+ Font newFont = getFont();
+ Font oldFont = peerFont;
+ // Only update when the font really changed.
+ if (newFont != oldFont
+ && (oldFont == null || ! oldFont.equals(newFont)))
+ {
+ p.setFont(newFont);
+ peerFont = newFont;
+ }
+ // Let the peer perform any layout.
+ p.layout();
+ }
+ }
valid = true;
}
+ }
/**
* Invalidates this component and all of its parent components. This will
@@ -1947,12 +2048,26 @@
*/
public void invalidate()
{
+ // Need to lock here, to avoid races and other ugly stuff when doing
+ // layout or structure changes in other threads.
+ synchronized (getTreeLock())
+ {
+ // Invalidate.
valid = false;
- prefSize = null;
+
+ // Throw away cached layout information.
+ if (! minSizeSet)
minSize = null;
+ if (! prefSizeSet)
+ prefSize = null;
+ if (! maxSizeSet)
+ maxSize = null;
+
+ // Also invalidate the parent, if it hasn't already been invalidated.
if (parent != null && parent.isValid())
parent.invalidate();
}
+ }
/**
* Returns a graphics object for this component. Returns <code>null</code>
@@ -1998,10 +2113,18 @@
*/
public FontMetrics getFontMetrics(Font font)
{
- return peer == null ? getToolkit().getFontMetrics(font)
- : peer.getFontMetrics(font);
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
+ return p == null ? getToolkit().getFontMetrics(font)
+ : p.getFontMetrics(font);
+ }
+
/**
* Sets the cursor for this component to the specified cursor. The cursor
* is displayed when the point is contained by the component, and the
@@ -2018,10 +2141,20 @@
public void setCursor(Cursor cursor)
{
this.cursor = cursor;
- if (peer != null)
- peer.setCursor(cursor);
+
+ // Only heavyweight peers handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
+ if (p != null)
+ p.setCursor(cursor);
+ }
+
/**
* Returns the cursor for this component. If not set, this is inherited
* from the parent, or from Cursor.getDefaultCursor().
@@ -2077,19 +2210,14 @@
*/
public void update(Graphics g)
{
- // Tests show that the clearing of the background is only done in
- // two cases:
- // - If the component is lightweight (yes this is in contrast to the spec).
- // or
- // - If the component is a toplevel container.
- if (isLightweight() || getParent() == null)
- {
- Rectangle clip = g.getClipBounds();
- if (clip == null)
- g.clearRect(0, 0, width, height);
- else
- g.clearRect(clip.x, clip.y, clip.width, clip.height);
- }
+ // Note 1: We used to clear the background here for lightweights and
+ // toplevel components. Tests show that this is not what the JDK does
+ // here. Note that there is some special handling and background
+ // clearing code in Container.update(Graphics).
+
+ // Note 2 (for peer implementors): The JDK doesn't seem call update() for
+ // toplevel components, even when an UPDATE event is sent (as a result
+ // of repaint).
paint(g);
}
@@ -2102,10 +2230,15 @@
*/
public void paintAll(Graphics g)
{
- if (! visible)
- return;
+ if (isShowing())
+ {
+ validate();
+ if (peer instanceof LightweightPeer)
paint(g);
+ else
+ peer.paint(g);
}
+ }
/**
* Repaint this entire component. The <code>update()</code> method
@@ -2165,13 +2298,44 @@
*/
public void repaint(long tm, int x, int y, int width, int height)
{
- if (isShowing())
+ // The repaint() call has previously been delegated to
+ // {@link ComponentPeer.repaint()}. Testing on the JDK using some
+ // dummy peers show that this methods is never called. I think it makes
+ // sense to actually perform the tasks below here, since it's pretty
+ // much peer independent anyway, and makes sure only heavyweights are
+ // bothered by this.
+ ComponentPeer p = peer;
+
+ // Let the nearest heavyweight parent handle repainting for lightweight
+ // components.
+ // We need to recursivly call repaint() on the parent here, since
+ // a (lightweight) parent component might have overridden repaint()
+ // to perform additional custom tasks.
+
+ if (p instanceof LightweightPeer)
{
- ComponentPeer p = peer;
- if (p != null)
- p.repaint(tm, x, y, width, height);
+ // We perform some boundary checking to restrict the paint
+ // region to this component.
+ if (parent != null)
+ {
+ int px = this.x + Math.max(0, x);
+ int py = this.y + Math.max(0, y);
+ int pw = Math.min(this.width, width);
+ int ph = Math.min(this.height, height);
+ parent.repaint(tm, px, py, pw, ph);
}
}
+ else
+ {
+ // Now send an UPDATE event to the heavyweight component that we've found.
+ if (isVisible() && p != null && width > 0 && height > 0)
+ {
+ PaintEvent pe = new PaintEvent(this, PaintEvent.UPDATE,
+ new Rectangle(x, y, width, height));
+ getToolkit().getSystemEventQueue().postEvent(pe);
+ }
+ }
+ }
/**
* Prints this component. This method is provided so that printing can be
@@ -2196,6 +2360,8 @@
*/
public void printAll(Graphics g)
{
+ if( peer != null )
+ peer.print( g );
paintAll(g);
}
@@ -2255,11 +2421,22 @@
*/
public Image createImage(ImageProducer producer)
{
+ // Only heavyweight peers can handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
+ }
+
// Sun allows producer to be null.
- if (peer != null)
- return peer.createImage(producer);
+ Image im;
+ if (p != null)
+ im = p.createImage(producer);
else
- return getToolkit().createImage(producer);
+ im = getToolkit().createImage(producer);
+ return im;
}
/**
@@ -2275,11 +2452,18 @@
Image returnValue = null;
if (!GraphicsEnvironment.isHeadless ())
{
- if (isLightweight () && parent != null)
- returnValue = parent.createImage (width, height);
- else if (peer != null)
- returnValue = peer.createImage (width, height);
+ // Only heavyweight peers can handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
+
+ if (p != null)
+ returnValue = p.createImage(width, height);
+ }
return returnValue;
}
@@ -2294,11 +2478,21 @@
*/
public VolatileImage createVolatileImage(int width, int height)
{
- if (peer != null)
- return peer.createVolatileImage(width, height);
- return null;
+ // Only heavyweight peers can handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
+ VolatileImage im = null;
+ if (p != null)
+ im = p.createVolatileImage(width, height);
+ return im;
+ }
+
/**
* Creates an image with the specified width and height for use in
* double buffering. Headless environments do not support images. The image
@@ -2315,11 +2509,21 @@
ImageCapabilities caps)
throws AWTException
{
- if (peer != null)
- return peer.createVolatileImage(width, height);
- return null;
+ // Only heavyweight peers can handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
+ VolatileImage im = null;
+ if (p != null)
+ im = peer.createVolatileImage(width, height);
+ return im;
+ }
+
/**
* Prepares the specified image for rendering on this component.
*
@@ -2347,10 +2551,21 @@
public boolean prepareImage(Image image, int width, int height,
ImageObserver observer)
{
- if (peer != null)
- return peer.prepareImage(image, width, height, observer);
+ // Only heavyweight peers handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
+ }
+
+ boolean retval;
+ if (p != null)
+ retval = p.prepareImage(image, width, height, observer);
else
- return getToolkit().prepareImage(image, width, height, observer);
+ retval = getToolkit().prepareImage(image, width, height, observer);
+ return retval;
}
/**
@@ -2384,11 +2599,23 @@
public int checkImage(Image image, int width, int height,
ImageObserver observer)
{
- if (peer != null)
- return peer.checkImage(image, width, height, observer);
- return getToolkit().checkImage(image, width, height, observer);
+ // Only heavyweight peers handle this.
+ ComponentPeer p = peer;
+ Component comp = this;
+ while (p instanceof LightweightPeer)
+ {
+ comp = comp.parent;
+ p = comp == null ? null : comp.peer;
}
+ int retval;
+ if (p != null)
+ retval = p.checkImage(image, width, height, observer);
+ else
+ retval = getToolkit().checkImage(image, width, height, observer);
+ return retval;
+ }
+
/**
* Sets whether paint messages delivered by the operating system should be
* ignored. This does not affect messages from AWT, except for those
@@ -4328,7 +4555,84 @@
return false;
}
- /**
+ /**
+ * Helper method for all 4 requestFocus variants.
+ *
+ * @param temporary indicates if the focus change is temporary
+ * @param focusWindow indicates if the window focus may be changed
+ *
+ * @return <code>false</code> if the request has been definitely denied,
+ * <code>true</code> otherwise
+ */
+ private boolean requestFocusImpl(boolean temporary, boolean focusWindow)
+ {
+ boolean retval = false;
+
+ // Don't try to focus non-focusable and non-visible components.
+ if (isFocusable() && isVisible())
+ {
+ ComponentPeer myPeer = peer;
+ if (peer != null)
+ {
+ // Find Window ancestor and find out if we're showing while
+ // doing this.
+ boolean showing = true;
+ Component window = this;
+ while (! (window instanceof Window))
+ {
+ if (! window.isVisible())
+ showing = false;
+ window = window.parent;
+ }
+ // Don't allow focus when there is no window or the window
+ // is not focusable.
+ if (window != null && ((Window) window).isFocusableWindow()
+ && showing)
+ {
+ // Search for nearest heavy ancestor (including this
+ // component).
+ Component heavyweightParent = this;
+ while (heavyweightParent.peer instanceof LightweightPeer)
+ heavyweightParent = heavyweightParent.parent;
+
+ // Don't allow focus on lightweight components without
+ // visible heavyweight ancestor
+ if (heavyweightParent != null && heavyweightParent.isVisible())
+ {
+ // Don't allow focus when heavyweightParent has no peer.
+ myPeer = heavyweightParent.peer;
+ if (myPeer != null)
+ {
+ // Register lightweight focus request.
+ if (heavyweightParent != this)
+ {
+ KeyboardFocusManager
+ .addLightweightFocusRequest(heavyweightParent,
+ this);
+ }
+
+ // Try to focus the component.
+ long time = EventQueue.getMostRecentEventTime();
+ boolean success = myPeer.requestFocus(this, temporary,
+ focusWindow,
+ time);
+ if (! success)
+ {
+ // Dequeue key events if focus request failed.
+ KeyboardFocusManager kfm =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.dequeueKeyEvents(time, this);
+ }
+ retval = success;
+ }
+ }
+ }
+ }
+ }
+ return retval;
+ }
+
+ /**
* Transfers focus to the next component in the focus traversal
* order, as though this were the current focus owner.
*
@@ -4972,10 +5276,9 @@
*/
public void setComponentOrientation(ComponentOrientation o)
{
- if (o == null)
- throw new NullPointerException();
- ComponentOrientation oldOrientation = orientation;
- orientation = o;
+
+ ComponentOrientation oldOrientation = componentOrientation;
+ componentOrientation = o;
firePropertyChange("componentOrientation", oldOrientation, o);
}
@@ -4987,7 +5290,7 @@
*/
public ComponentOrientation getComponentOrientation()
{
- return orientation;
+ return componentOrientation;
}
/**
@@ -5137,7 +5440,7 @@
if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
oldMods |= Event.ALT_MASK;
- if (e instanceof MouseEvent)
+ if (e instanceof MouseEvent && !ignoreOldMouseEvents())
{
if (id == MouseEvent.MOUSE_PRESSED)
oldID = Event.MOUSE_DOWN;
@@ -5471,6 +5774,26 @@
}
/**
+ * Returns <code>true</code> when this component and all of its ancestors
+ * are visible, <code>false</code> otherwise.
+ *
+ * @return <code>true</code> when this component and all of its ancestors
+ * are visible, <code>false</code> otherwise
+ */
+ boolean isHierarchyVisible()
+ {
+ boolean visible = isVisible();
+ Component comp = parent;
+ while (comp != null && visible)
+ {
+ comp = comp.parent;
+ if (comp != null)
+ visible = visible && comp.isVisible();
+ }
+ return visible;
+ }
+
+ /**
* This method is used to implement transferFocus(). CHILD is the child
* making the request. This is overridden by Container; when called for an
* ordinary component there is no child and so we always return null.
Modified: trunk/core/src/classpath/java/java/awt/Container.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Container.java 2007-01-31 21:51:44 UTC (rev 3100)
+++ trunk/core/src/classpath/java/java/awt/Container.java 2007-02-03 15:05:27 UTC (rev 3101)
@@ -215,10 +215,12 @@
*/
public Insets insets()
{
- if (peer == null)
- return new Insets (0, 0, 0, 0);
-
- return ((ContainerPeer) peer).getInsets ();
+ Insets i;
+ if (peer == null || peer instanceof LightweightPeer)
+ i = new Insets (0, 0, 0, 0);
+ else
+ i = ((ContainerPeer) peer).getInsets ();
+ return i;
}
/**
@@ -527,6 +529,7 @@
public void setLayout(LayoutManager mgr)
{
layoutMgr = mgr;
+ if (valid)
invalidate();
}
@@ -681,22 +684,26 @@
*/
public Dimension preferredSize()
{
- synchronized(treeLock)
+ Dimension size = prefSize;
+ // Try to return cached value if possible.
+ if (size == null || !(prefSizeSet || valid))
{
- if(valid && prefSize != null)
- return new Dimension(prefSize);
- LayoutManager layout = getLayout();
- if (layout != null)
+ // Need to lock here.
+ synchronized (getTreeLock())
{
- Dimension layoutSize = layout.preferredLayoutSize(this);
- if(valid)
- prefSize = layoutSize;
- return new Dimension(layoutSize);
- }
+ LayoutManager l = layoutMgr;
+ if (l != null)
+ prefSize = l.preferredLayoutSize(this);
else
- return super.preferredSize ();
+ prefSize = super.preferredSizeImpl();
+ size = prefSize;
}
}
+ if (size != null)
+ return new Dimension(size);
+ else
+ return size;
+ }
/**
* Returns the minimum size of this container.
@@ -717,17 +724,25 @@
*/
public Dimension minimumSize()
{
- if(valid && minSize != null)
- return new Dimension(minSize);
-
- LayoutManager layout = getLayout();
- if (layout != null)
+ Dimension size = minSize;
+ // Try to return cached value if possible.
+ if (size == null || !(minSizeSet || valid))
{
- minSize = layout.minimumLayoutSize (this);
- return minSize;
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l != null)
+ minSize = l.minimumLayoutSize(this);
+ else
+ minSize = super.minimumSizeImpl();
+ size = minSize;
}
+ }
+ if (size != null)
+ return new Dimension(size);
else
- return super.minimumSize ();
+ return size;
}
/**
@@ -737,18 +752,26 @@
*/
public Dimension getMaximumSize()
{
- if (valid && maxSize != null)
- return new Dimension(maxSize);
-
- LayoutManager layout = getLayout();
- if (layout != null && layout instanceof LayoutManager2)
+ Dimension size = maxSize;
+ // Try to return cached value if possible.
+ if (size == null || !(maxSizeSet || valid))
{
- LayoutManager2 lm2 = (LayoutManager2) layout;
- maxSize = lm2.maximumLayoutSize(this);
- return maxSize;
+ // Need to lock here.
+ synchronized (getTreeLock())
+ {
+ LayoutManager l = layoutMgr;
+ if (l instanceof LayoutManager2)
+ maxSize = ((LayoutManager2) l).maximumLayoutSize(this);
+ else {
+ maxSize = super.maximumSizeImpl();
}
+ size = maxSize;
+ }
+ }
+ if (size != null)
+ return new Dimension(size);
else
- return super.getMaximumSize();
+ return size;
}
/**
@@ -764,9 +787,12 @@
float alignmentX = 0.0F;
if (layout != null && layout instanceof LayoutManager2)
{
+ synchronized (getTreeLock())
+ {
LayoutManager2 lm2 = (LayoutManager2) layout;
alignmentX = lm2.getLayoutAlignmentX(this);
}
+ }
else
alignmentX = super.getAlignmentX();
return alignmentX;
@@ -785,9 +811,12 @@
float alignmentY = 0.0F;
if (layout != null && layout instanceof LayoutManager2)
{
+ synchronized (getTreeLock())
+ {
LayoutManager2 lm2 = (LayoutManager2) layout;
alignmentY = lm2.getLayoutAlignmentY(this);
}
+ }
else
alignmentY = super.getAlignmentY();
return alignmentY;
@@ -804,14 +833,11 @@
*/
public void paint(Graphics g)
{
- if (!isShowing())
- return;
-
- // Visit heavyweights if the background was cleared
- // for this container.
- visitChildren(g, GfxPaintVisitor.INSTANCE, !backCleared);
- backCleared = false;
+ if (isShowing())
+ {
+ visitChildren(g, GfxPaintVisitor.INSTANCE, true);
}
+ }
/**
* Updates this container. The implementation of this method in this
@@ -840,15 +866,16 @@
// that overrides isLightweight() to return false, the background is
// also not cleared. So we do a check on !(peer instanceof LightweightPeer)
// instead.
+ if (isShowing())
+ {
ComponentPeer p = peer;
- if (p != null && ! (p instanceof LightweightPeer))
+ if (! (p instanceof LightweightPeer))
{
g.clearRect(0, 0, getWidth(), getHeight());
- backCleared = true;
}
-
paint(g);
}
+ }
/**
* Prints this container. The implementation of this method in this
@@ -872,8 +899,8 @@
*/
public void paintComponents(Graphics g)
{
- paint(g);
- visitChildren(g, GfxPaintAllVisitor.INSTANCE, true);
+ if (isShowing())
+ visitChildren(g, GfxPaintAllVisitor.INSTANCE, false);
}
/**
@@ -1183,9 +1210,12 @@
*/
public void addNotify()
{
+ synchronized (getTreeLock())
+ {
super.addNotify();
addNotifyContainerChildren();
}
+ }
/**
* Called when this container is removed from its parent container to
@@ -1196,8 +1226,14 @@
{
synchronized (getTreeLock ())
{
- for (int i = 0; i < ncomponents; ++i)
- component[i].removeNotify();
+ int ncomps = ncomponents;
+ Component[] comps = component;
+ for (int i = ncomps - 1; i >= 0; --i)
+ {
+ Component comp = comps[i];
+ if (comp != null)
+ comp.removeNotify();
+ }
super.removeNotify();
}
}
@@ -1294,7 +1330,8 @@
*
* @since 1.4
*/
- public void setFocusTraversalKeys(int id, Set keystrokes)
+ public void setFocusTraversalKeys(int id,
+ Set<? extends AWTKeyStroke> keystrokes)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
@@ -1382,7 +1419,8 @@
if (focusTraversalKeys == null)
focusTraversalKeys = new Set[4];
- keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
+ keystrokes =
+ Collections.unmodifiableSet(new HashSet<AWTKeyStroke>(keystrokes));
firePropertyChange (name, focusTraversalKeys[id], keystrokes);
focusTraversalKeys[id] = keystrokes;
@@ -1400,7 +1438,7 @@
*
* @since 1.4
*/
- public Set getFocusTraversalKeys (int id)
+ public Set<AWTKeyStroke> getFocusTraversalKeys (int id)
{
if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
@@ -1641,8 +1679,17 @@
{
if (orientation == null)
throw new NullPointerException ();
+
+ setComponentOrientation(orientation);
+ for (int i = 0; i < ncomponents; i++)
+ {
+ if (component[i] instanceof Container)
+ ((Container) component[i]).applyComponentOrientation(orientation);
+ else
+ component[i].setComponentOrientation(orientation);
}
-
+ }
+
public void addPropertyChangeListener (PropertyChangeListener listener)
{
// TODO: Why is this overridden?
@@ -1692,6 +1739,8 @@
if (comp == this)
throw new IllegalArgumentException("cannot add component to itself");
+ synchronized (getTreeLock())
+ {
// FIXME: Implement reparenting.
if ( comp.getParent() != this)
throw new AssertionError("Reparenting is not implemented yet");
@@ -1712,6 +1761,7 @@
component[index] = comp;
}
}
+ }
/**
* Returns the Z ordering index of <code>comp</code>. If <code>comp</code>
@@ -1728,10 +1778,12 @@
*/
public final int getComponentZOrder(Component comp)
{
+ synchronized (getTreeLock())
+ {
int index = -1;
if (component != null)
{
- for (int i = 0; i < component.length; i++)
+ for (int i = 0; i < ncomponents; i++)
{
if (component[i] == comp)
{
@@ -1742,6 +1794,7 @@
}
return index;
}
+ }
// Hidden helper methods.
Modified: trunk/core/src/classpath/java/java/awt/Window.java
==========================...
[truncated message content] |
|
From: <ls...@us...> - 2007-02-03 18:44:50
|
Revision: 3102
http://jnode.svn.sourceforge.net/jnode/?rev=3102&view=rev
Author: lsantha
Date: 2007-02-03 10:44:48 -0800 (Sat, 03 Feb 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/Window.java
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-02-03 15:05:27 UTC (rev 3101)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-02-03 18:44:48 UTC (rev 3102)
@@ -971,18 +971,40 @@
// case lightweight components are not initially painted --
// Container.paint first calls isShowing () before painting itself
// and its children.
- if(!isVisible())
+ if(! visible)
{
- this.visible = true;
+ // Need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ visible = true;
// Avoid NullPointerExceptions by creating a local reference.
ComponentPeer currentPeer=peer;
if (currentPeer != null)
+ {
currentPeer.show();
+ // Fire HierarchyEvent.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED,
+ this, parent,
+ HierarchyEvent.SHOWING_CHANGED);
+
// The JDK repaints the component before invalidating the parent.
// So do we.
- if (isShowing() && isLightweight())
+ if (peer instanceof LightweightPeer)
repaint();
+ }
+
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ ComponentEvent ce =
+ new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
@@ -990,9 +1012,6 @@
if (currentParent != null)
currentParent.invalidate();
- ComponentEvent ce =
- new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
- getToolkit().getSystemEventQueue().postEvent(ce);
}
}
@@ -1018,29 +1037,47 @@
*/
public void hide()
{
- if (isVisible())
+ if (visible)
{
+ // Need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
+ visible = false;
+
// Avoid NullPointerExceptions by creating a local reference.
ComponentPeer currentPeer=peer;
if (currentPeer != null)
- currentPeer.setVisible(false);
- boolean wasShowing = isShowing();
- this.visible = false;
+ {
+ currentPeer.hide();
- // The JDK repaints the component before invalidating the parent.
- // So do we.
- if (wasShowing)
+ // Fire hierarchy event.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED,
+ this, parent,
+ HierarchyEvent.SHOWING_CHANGED);
+ // The JDK repaints the component before invalidating the
+ // parent. So do we. This only applies for lightweights.
+ if (peer instanceof LightweightPeer)
repaint();
- // Invalidate the parent if we have one. The component itself must
+ }
+
+ // Only post an event if this component actually has a listener
+ // or has this event explicitly enabled.
+ if (componentListener != null
+ || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0)
+ {
+ ComponentEvent ce =
+ new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
+ getToolkit().getSystemEventQueue().postEvent(ce);
+ }
+ }
+
+ // Invalidate the parent if we have one. The component itself need
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
currentParent.invalidate();
- ComponentEvent ce =
- new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
- getToolkit().getSystemEventQueue().postEvent(ce);
}
}
@@ -3935,19 +3972,38 @@
*/
public void addNotify()
{
+ // We need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
if (peer == null)
peer = getToolkit().createComponent(this);
else if (parent != null && parent.isLightweight())
new HeavyweightInLightweightListener(parent);
- /* Now that all the children has gotten their peers, we should
- have the event mask needed for this component and its
- lightweight subcomponents. */
+ // Now that all the children has gotten their peers, we should
+ // have the event mask needed for this component and its
+ //lightweight subcomponents.
peer.setEventMask(eventMask);
- /* We do not invalidate here, but rather leave that job up to
- the peer. For efficiency, the peer can choose not to
- invalidate if it is happy with the current dimensions,
- etc. */
+
+ // We used to leave the invalidate() to the peer. However, I put it
+ // back here for 2 reasons: 1) The RI does call invalidate() from
+ // addNotify(); 2) The peer shouldn't be bother with validation too
+ // much.
+ invalidate();
+
+ if (dropTarget != null)
+ dropTarget.addNotify(peer);
+
+ // Fetch the peerFont for later installation in validate().
+ peerFont = getFont();
+
+ // Notify hierarchy listeners.
+ long flags = HierarchyEvent.DISPLAYABILITY_CHANGED;
+ if (isHierarchyVisible())
+ flags |= HierarchyEvent.SHOWING_CHANGED;
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, this, parent,
+ flags);
}
+ }
/**
* Called to inform this component is has been removed from its
@@ -3960,6 +4016,9 @@
*/
public void removeNotify()
{
+ // We need to lock the tree here to avoid races and inconsistencies.
+ synchronized (getTreeLock())
+ {
// We null our peer field before disposing of it, such that if we're
// not the event dispatch thread and the dispatch thread is awoken by
// the dispose call, there will be no race checking the peer's null
@@ -3967,12 +4026,21 @@
ComponentPeer tmp = peer;
peer = null;
+ peerFont = null;
if (tmp != null)
{
tmp.hide();
tmp.dispose();
}
+
+ // Notify hierarchy listeners.
+ long flags = HierarchyEvent.DISPLAYABILITY_CHANGED;
+ if (isHierarchyVisible())
+ flags |= HierarchyEvent.SHOWING_CHANGED;
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, this, parent,
+ flags);
}
+ }
/**
* AWT 1.0 GOT_FOCUS event handler. This method is meant to be
Modified: trunk/core/src/classpath/java/java/awt/Container.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Container.java 2007-02-03 15:05:27 UTC (rev 3101)
+++ trunk/core/src/classpath/java/java/awt/Container.java 2007-02-03 18:44:48 UTC (rev 3102)
@@ -39,7 +39,6 @@
package java.awt;
-import java.awt.event.ComponentListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.HierarchyEvent;
@@ -90,12 +89,7 @@
Dimension maxSize;
- /**
- * Keeps track if the Container was cleared during a paint/update.
- */
- private boolean backCleared;
-
- /**
+ /*
* @since 1.4
*/
boolean focusCycleRoot;
@@ -333,24 +327,7 @@
// we are.
if (comp.parent != null)
comp.parent.remove(comp);
- comp.parent = this;
- if (peer != null)
- {
- // Notify the component that it has a new parent.
- comp.addNotify();
-
- if (comp.isLightweight ())
- {
- enableEvents (comp.eventMask);
- if (!isLightweight ())
- enableEvents (AWTEvent.PAINT_EVENT_MASK);
- }
- }
-
- // Invalidate the layout of the added component and its ancestors.
- comp.invalidate();
-
if (component == null)
component = new Component[4]; // FIXME, better initial size?
@@ -374,6 +351,31 @@
++ncomponents;
}
+ // Give the new component a parent.
+ comp.parent = this;
+
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = comp.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ childHierarchyListeners);
+ int childHierarchyBoundsListeners = comp.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ childHierarchyListeners);
+
+ // Invalidate the layout of this container.
+ if (valid)
+ invalidate();
+
+ // Create the peer _after_ the component has been added, so that
+ // the peer gets to know about the component hierarchy.
+ if (peer != null)
+ {
+ // Notify the component that it has a new parent.
+ comp.addNotify();
+ }
+
// Notify the layout manager.
if (layoutMgr != null)
{
@@ -394,14 +396,20 @@
// Also, the event was posted to the event queue. A Mauve test shows
// that this event is not delivered using the event queue and it is
// also sent when the container is not showing.
+ if (containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
+ {
ContainerEvent ce = new ContainerEvent(this,
ContainerEvent.COMPONENT_ADDED,
comp);
- ContainerListener[] listeners = getContainerListeners();
- for (int i = 0; i < listeners.length; i++)
- listeners[i].componentAdded(ce);
+ dispatchEvent(ce);
}
+
+ // Notify hierarchy listeners.
+ comp.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, comp,
+ this, HierarchyEvent.PARENT_CHANGED);
}
+ }
/**
* Removes the component at the specified index from this container.
@@ -412,33 +420,48 @@
{
synchronized (getTreeLock ())
{
+ if (index < 0 || index >= ncomponents)
+ throw new ArrayIndexOutOfBoundsException();
+
Component r = component[index];
+ if (peer != null)
+ r.removeNotify();
- ComponentListener[] list = r.getComponentListeners();
- for (int j = 0; j < list.length; j++)
- r.removeComponentListener(list[j]);
+ if (layoutMgr != null)
+ layoutMgr.removeLayoutComponent(r);
- r.removeNotify();
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = r.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -childHierarchyListeners);
+ int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ -childHierarchyListeners);
+ r.parent = null;
+
System.arraycopy(component, index + 1, component, index,
ncomponents - index - 1);
component[--ncomponents] = null;
+ if (valid)
invalidate();
- if (layoutMgr != null)
- layoutMgr.removeLayoutComponent(r);
-
- r.parent = null;
-
- if (isShowing ())
+ if (containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
{
// Post event to notify of removing the component.
ContainerEvent ce = new ContainerEvent(this,
ContainerEvent.COMPONENT_REMOVED,
r);
- getToolkit().getSystemEventQueue().postEvent(ce);
+ dispatchEvent(ce);
}
+
+ // Notify hierarchy listeners.
+ r.fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r,
+ this, HierarchyEvent.PARENT_CHANGED);
}
}
@@ -477,14 +500,13 @@
// super.removeAll() ).
// By doing it this way, user code cannot prevent the correct
// removal of components.
- for ( int index = 0; index < ncomponents; index++)
+ while (ncomponents > 0)
{
- Component r = component[index];
+ ncomponents--;
+ Component r = component[ncomponents];
+ component[ncomponents] = null;
- ComponentListener[] list = r.getComponentListeners();
- for (int j = 0; j < list.length; j++)
- r.removeComponentListener(list[j]);
-
+ if (peer != null)
r.removeNotify();
if (layoutMgr != null)
@@ -492,21 +514,37 @@
r.parent = null;
- if (isShowing ())
+ // Send ContainerEvent if necessary.
+ if (containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0)
{
// Post event to notify of removing the component.
ContainerEvent ce
= new ContainerEvent(this,
ContainerEvent.COMPONENT_REMOVED,
r);
-
- getToolkit().getSystemEventQueue().postEvent(ce);
+ dispatchEvent(ce);
}
- }
-
+
+ // Update the counter for Hierarchy(Bounds)Listeners.
+ int childHierarchyListeners = r.numHierarchyListeners;
+ if (childHierarchyListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -childHierarchyListeners);
+ int childHierarchyBoundsListeners = r.numHierarchyBoundsListeners;
+ if (childHierarchyBoundsListeners > 0)
+ updateHierarchyListenerCount(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ -childHierarchyListeners);
+
+
+ // Send HierarchyEvent if necessary.
+ fireHierarchyEvent(HierarchyEvent.HIERARCHY_CHANGED, r, this,
+ HierarchyEvent.PARENT_CHANGED);
+
+ }
+
+ if (valid)
invalidate();
-
- ncomponents = 0;
}
}
@@ -571,11 +609,20 @@
*/
public void validate()
{
+ ComponentPeer p = peer;
+ if (! valid && p != null)
+ {
+ ContainerPeer cPeer = null;
+ if (p instanceof ContainerPeer)
+ cPeer = (ContainerPeer) peer;
synchronized (getTreeLock ())
{
- if (! isValid() && peer != null)
- {
+ if (cPeer != null)
+ cPeer.beginValidate();
validateTree();
+ valid = true;
+ if (cPeer != null)
+ cPeer.endValidate();
}
}
}
@@ -585,19 +632,18 @@
*/
void invalidateTree()
{
- super.invalidate(); // Clean cached layout state.
+ synchronized (getTreeLock())
+ {
for (int i = 0; i < ncomponents; i++)
{
Component comp = component[i];
- comp.invalidate();
if (comp instanceof Container)
((Container) comp).invalidateTree();
+ else if (comp.valid)
+ comp.invalidate();
}
-
- if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
- {
- LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
- lm2.invalidateLayout(this);
+ if (valid)
+ invalidate();
}
}
@@ -607,60 +653,52 @@
*/
protected void validateTree()
{
- if (valid)
- return;
-
+ if (!valid)
+ {
ContainerPeer cPeer = null;
- if (peer != null && ! (peer instanceof LightweightPeer))
+ if (peer instanceof ContainerPeer)
{
cPeer = (ContainerPeer) peer;
- cPeer.beginValidate();
+ cPeer.beginLayout();
}
- for (int i = 0; i < ncomponents; ++i)
- {
- Component comp = component[i];
-
- if (comp.getPeer () == null)
- comp.addNotify();
- }
-
doLayout ();
for (int i = 0; i < ncomponents; ++i)
{
Component comp = component[i];
- if (! comp.isValid())
+ if (comp instanceof Container && ! (comp instanceof Window)
+ && ! comp.valid)
{
- if (comp instanceof Container)
- {
((Container) comp).validateTree();
}
else
{
- component[i].validate();
+ comp.validate();
}
}
+
+ if (cPeer != null)
+ {
+ cPeer = (ContainerPeer) peer;
+ cPeer.endLayout();
}
+ }
/* children will call invalidate() when they are layed out. It
is therefore important that valid is not set to true
until after the children have been layed out. */
valid = true;
- if (cPeer != null)
- cPeer.endValidate();
}
public void setFont(Font f)
{
- if( (f != null && (font == null || !font.equals(f)))
- || f == null)
+ Font oldFont = getFont();
+ super.setFont(f);
+ Font newFont = getFont();
+ if (newFont != oldFont && (oldFont == null || ! oldFont.equals(newFont)))
{
- super.setFont(f);
- // FIXME: Although it might make more sense to invalidate only
- // those children whose font == null, Sun invalidates all children.
- // So we'll do the same.
invalidateTree();
}
}
@@ -922,8 +960,13 @@
*/
public synchronized void addContainerListener(ContainerListener listener)
{
- containerListener = AWTEventMulticaster.add(containerListener, listener);
+ if (listener != null)
+ {
+ containerListener = AWTEventMulticaster.add(containerListener,
+ listener);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified container listener from this object's list of
@@ -1853,6 +1896,7 @@
bounds.height);
try
{
+ g2.setFont(comp.getFont());
visitor.visit(comp, g2);
}
finally
@@ -2053,15 +2097,9 @@
for (int i = ncomponents; --i >= 0; )
{
component[i].addNotify();
- if (component[i].isLightweight ())
- {
- enableEvents(component[i].eventMask);
- if (peer != null && !isLightweight ())
- enableEvents (AWTEvent.PAINT_EVENT_MASK);
}
}
}
- }
/**
* Deserialize this Container:
Modified: trunk/core/src/classpath/java/java/awt/Window.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Window.java 2007-02-03 15:05:27 UTC (rev 3101)
+++ trunk/core/src/classpath/java/java/awt/Window.java 2007-02-03 18:44:48 UTC (rev 3102)
@@ -393,11 +393,17 @@
component[i].removeNotify();
this.removeNotify();
- // Post a WINDOW_CLOSED event.
- WindowEvent we = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
- getToolkit().getSystemEventQueue().postEvent(we);
+ // 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);
}
}
+ }
/**
* Sends this window to the back so that all other windows display in
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-02-03 20:51:03
|
Revision: 3103
http://jnode.svn.sourceforge.net/jnode/?rev=3103&view=rev
Author: lsantha
Date: 2007-02-03 12:51:00 -0800 (Sat, 03 Feb 2007)
Log Message:
-----------
Classpath patches.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/Window.java
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-02-03 18:44:48 UTC (rev 3102)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-02-03 20:51:00 UTC (rev 3103)
@@ -1180,14 +1180,7 @@
*/
public Font getFont()
{
- Font f = font;
- if (f != null)
- return f;
-
- Component p = parent;
- if (p != null)
- return p.getFont();
- return null;
+ return getFontImpl();
}
/**
@@ -1223,19 +1216,45 @@
*
* @see #getFont()
*/
- public void setFont(Font newFont)
+ public void setFont(Font f)
{
- if((newFont != null && (font == null || !font.equals(newFont)))
- || newFont == null)
+ Font oldFont;
+ Font newFont;
+ // Synchronize on the tree because getFontImpl() relies on the hierarchy
+ // not beeing changed.
+ synchronized (getTreeLock())
{
- Font oldFont = font;
- font = newFont;
- if (peer != null)
- peer.setFont(font);
+ // Synchronize on this here to guarantee thread safety wrt to the
+ // property values.
+ synchronized (this)
+ {
+ oldFont = font;
+ font = f;
+ newFont = f;
+ }
+ // Create local variable here for thread safety.
+ ComponentPeer p = peer;
+ if (p != null)
+ {
+ // The peer receives the real font setting, which can depend on
+ // the parent font when this component's font has been set to null.
+ f = getFont();
+ if (f != null)
+ {
+ p.setFont(f);
+ peerFont = f;
+ }
+ }
+ }
+
+ // Fire property change event.
firePropertyChange("font", oldFont, newFont);
+
+ // Invalidate when necessary as font changes can change the size of the
+ // component.
+ if (valid)
invalidate();
}
- }
/**
* Tests if the font was explicitly set, or just inherited from the parent.
@@ -1521,55 +1540,50 @@
*/
public void reshape(int x, int y, int width, int height)
{
+ // We need to lock the tree here, otherwise we risk races and
+ // inconsistencies.
+ synchronized (getTreeLock())
+ {
int oldx = this.x;
int oldy = this.y;
int oldwidth = this.width;
int oldheight = this.height;
- if (this.x == x && this.y == y && this.width == width
- && this.height == height)
- return;
+ boolean resized = oldwidth != width || oldheight != height;
+ boolean moved = oldx != x || oldy != y;
- invalidate();
-
+ if (resized || moved)
+ {
+ // Update the fields.
this.x = x;
this.y = y;
this.width = width;
this.height = height;
- if (peer != null)
- peer.setBounds (x, y, width, height);
- // Erase old bounds and repaint new bounds for lightweights.
- if (isLightweight() && isShowing())
+ if (peer != null)
{
- if (parent != null)
- {
- Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth,
- oldheight);
- Rectangle newBounds = new Rectangle(x, y, width, height);
- Rectangle destroyed = oldBounds.union(newBounds);
- if (!destroyed.isEmpty())
- parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
- destroyed.height);
+ peer.setBounds (x, y, width, height);
+ if (resized)
+ invalidate();
+ if (parent != null && parent.valid)
+ parent.invalidate();
}
- }
- // Only post event if this component is visible and has changed size.
- if (isShowing ()
- && (oldx != x || oldy != y))
+ // Send some events to interested listeners.
+ notifyReshape(resized, moved);
+
+ // Repaint this component and the parent if appropriate.
+ if (parent != null && peer instanceof LightweightPeer
+ && isShowing())
{
- ComponentEvent ce = new ComponentEvent(this,
- ComponentEvent.COMPONENT_MOVED);
- getToolkit().getSystemEventQueue().postEvent(ce);
+ // The parent repaints the area that we occupied before.
+ parent.repaint(oldx, oldy, oldwidth, oldheight);
+ // This component repaints the area that we occupy now.
+ repaint();
}
- if (isShowing ()
- && (oldwidth != width || oldheight != height))
- {
- ComponentEvent ce = new ComponentEvent(this,
- ComponentEvent.COMPONENT_RESIZED);
- getToolkit().getSystemEventQueue().postEvent(ce);
}
}
+ }
/**
* Sends notification to interested listeners about resizing and/or moving
@@ -1804,15 +1818,10 @@
*/
public Dimension preferredSize()
{
- if (prefSize == null)
- {
- if (peer == null)
- prefSize = minimumSize();
- else
- prefSize = peer.getPreferredSize();
+ // Create a new Dimension object, so that the application doesn't mess
+ // with the actual values.
+ return new Dimension(preferredSizeImpl());
}
- return prefSize;
- }
/**
* The actual calculation is pulled out of preferredSize() so that
@@ -1895,10 +1904,9 @@
*/
public Dimension minimumSize()
{
- if (minSize == null)
- minSize = (peer != null ? peer.getMinimumSize()
- : new Dimension(width, height));
- return minSize;
+ // Create a new Dimension object, so that the application doesn't mess
+ // with the actual values.
+ return new Dimension(minimumSizeImpl());
}
/**
@@ -1939,7 +1947,7 @@
*/
public Dimension getMaximumSize()
{
- return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+ return new Dimension(maximumSizeImpl());
}
/**
@@ -2854,10 +2862,13 @@
*/
public synchronized void addComponentListener(ComponentListener listener)
{
- componentListener = AWTEventMulticaster.add(componentListener, listener);
- if (componentListener != null)
- enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
+ if (listener != null)
+ {
+ componentListener = AWTEventMulticaster.add(componentListener,
+ listener);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -2902,10 +2913,12 @@
*/
public synchronized void addFocusListener(FocusListener listener)
{
+ if (listener != null)
+ {
focusListener = AWTEventMulticaster.add(focusListener, listener);
- if (focusListener != null)
- enableEvents(AWTEvent.FOCUS_EVENT_MASK);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -2949,10 +2962,21 @@
*/
public synchronized void addHierarchyListener(HierarchyListener listener)
{
- hierarchyListener = AWTEventMulticaster.add(hierarchyListener, listener);
- if (hierarchyListener != null)
- enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);
+ if (listener != null)
+ {
+ hierarchyListener = AWTEventMulticaster.add(hierarchyListener,
+ listener);
+ newEventsOnly = true;
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ 1);
}
+ }
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -2967,7 +2991,16 @@
public synchronized void removeHierarchyListener(HierarchyListener listener)
{
hierarchyListener = AWTEventMulticaster.remove(hierarchyListener, listener);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyListeners--;
+ if (parent != null)
+ parent.updateHierarchyListenerCount(AWTEvent.HIERARCHY_EVENT_MASK,
+ -1);
}
+ }
/**
* Returns an array of all specified listeners registered on this component.
@@ -2998,11 +3031,22 @@
public synchronized void
addHierarchyBoundsListener(HierarchyBoundsListener listener)
{
+ if (listener != null)
+ {
hierarchyBoundsListener =
AWTEventMulticaster.add(hierarchyBoundsListener, listener);
- if (hierarchyBoundsListener != null)
- enableEvents(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
+ newEventsOnly = true;
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyBoundsListeners++;
+ if (parent != null)
+ parent.updateHierarchyListenerCount
+ (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, 1);
}
+ }
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -3019,7 +3063,17 @@
{
hierarchyBoundsListener =
AWTEventMulticaster.remove(hierarchyBoundsListener, listener);
+
+ // Need to lock the tree, otherwise we might end up inconsistent.
+ synchronized (getTreeLock())
+ {
+ numHierarchyBoundsListeners--;
+ if (parent != null)
+ parent.updateHierarchyListenerCount
+ (AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK,
+ -1);
}
+ }
/**
* Returns an array of all specified listeners registered on this component.
@@ -3083,10 +3137,12 @@
*/
public synchronized void addKeyListener(KeyListener listener)
{
+ if (listener != null)
+ {
keyListener = AWTEventMulticaster.add(keyListener, listener);
- if (keyListener != null)
- enableEvents(AWTEvent.KEY_EVENT_MASK);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -3130,10 +3186,12 @@
*/
public synchronized void addMouseListener(MouseListener listener)
{
+ if (listener != null)
+ {
mouseListener = AWTEventMulticaster.add(mouseListener, listener);
- if (mouseListener != null)
- enableEvents(AWTEvent.MOUSE_EVENT_MASK);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -3177,10 +3235,13 @@
*/
public synchronized void addMouseMotionListener(MouseMotionListener listener)
{
- mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, listener);
- if (mouseMotionListener != null)
- enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
+ if (listener != null)
+ {
+ mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener,
+ listener);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -3226,10 +3287,13 @@
*/
public synchronized void addMouseWheelListener(MouseWheelListener listener)
{
- mouseWheelListener = AWTEventMulticaster.add(mouseWheelListener, listener);
- if (mouseWheelListener != null)
- enableEvents(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
+ if (listener != null)
+ {
+ mouseWheelListener = AWTEventMulticaster.add(mouseWheelListener,
+ listener);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -3276,10 +3340,13 @@
*/
public synchronized void addInputMethodListener(InputMethodListener listener)
{
- inputMethodListener = AWTEventMulticaster.add(inputMethodListener, listener);
- if (inputMethodListener != null)
- enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
+ if (listener != null)
+ {
+ inputMethodListener = AWTEventMulticaster.add(inputMethodListener,
+ listener);
+ newEventsOnly = true;
}
+ }
/**
* Removes the specified listener from the component. This is harmless if
@@ -3445,19 +3512,42 @@
*/
protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
{
+ AWTEvent coalesced = null;
switch (existingEvent.id)
{
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
// Just drop the old (intermediate) event and return the new one.
- return newEvent;
+ MouseEvent me1 = (MouseEvent) existingEvent;
+ MouseEvent me2 = (MouseEvent) newEvent;
+ if (me1.getModifiers() == me2.getModifiers())
+ coalesced = newEvent;
+ break;
case PaintEvent.PAINT:
case PaintEvent.UPDATE:
- return coalescePaintEvents((PaintEvent) existingEvent,
- (PaintEvent) newEvent);
+ // For heavyweights the EventQueue should ask the peer.
+ if (peer == null || peer instanceof LightweightPeer)
+ {
+ PaintEvent pe1 = (PaintEvent) existingEvent;
+ PaintEvent pe2 = (PaintEvent) newEvent;
+ Rectangle r1 = pe1.getUpdateRect();
+ Rectangle r2 = pe2.getUpdateRect();
+ if (r1.contains(r2))
+ coalesced = existingEvent;
+ else if (r2.contains(r1))
+ coalesced = newEvent;
+ }
+ else
+ {
+ // Replace the event and let the heavyweight figure out the expanding
+ // of the repaint area.
+ coalesced = newEvent;
+ }
+ break;
default:
- return null;
+ coalesced = null;
}
+ return coalesced;
}
/**
Modified: trunk/core/src/classpath/java/java/awt/Container.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Container.java 2007-02-03 18:44:48 UTC (rev 3102)
+++ trunk/core/src/classpath/java/java/awt/Container.java 2007-02-03 20:51:00 UTC (rev 3103)
@@ -87,9 +87,7 @@
Component[] component;
LayoutManager layoutMgr;
- Dimension maxSize;
-
- /*
+ /**
* @since 1.4
*/
boolean focusCycleRoot;
@@ -1912,16 +1910,18 @@
*/
void dispatchEventImpl(AWTEvent e)
{
- boolean dispatched =
- LightweightDispatcher.getInstance().dispatchEvent(e);
- if (! dispatched)
+ LightweightDispatcher dispatcher = LightweightDispatcher.getInstance();
+ if (! isLightweight() && dispatcher.dispatchEvent(e))
{
- if ((e.id <= ContainerEvent.CONTAINER_LAST
- && e.id >= ContainerEvent.CONTAINER_FIRST)
- && (containerListener != null
- || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
- processEvent(e);
+ // Some lightweight descendent got this event dispatched. Consume
+ // it and let the peer handle it.
+ e.consume();
+ ComponentPeer p = peer;
+ if (p != null)
+ p.handleEvent(e);
+ }
else
+ {
super.dispatchEventImpl(e);
}
}
Modified: trunk/core/src/classpath/java/java/awt/Window.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Window.java 2007-02-03 18:44:48 UTC (rev 3102)
+++ trunk/core/src/classpath/java/java/awt/Window.java 2007-02-03 20:51:00 UTC (rev 3103)
@@ -286,8 +286,6 @@
{
synchronized (getTreeLock())
{
- if (parent != null && ! parent.isDisplayable())
- parent.addNotify();
if (peer == null)
addNotify();
@@ -529,8 +527,12 @@
*/
public synchronized void addWindowListener(WindowListener listener)
{
+ if (listener != null)
+ {
+ newEventsOnly = true;
windowListener = AWTEventMulticaster.add(windowListener, listener);
}
+ }
/**
* Removes the specified listener from the list of
@@ -586,9 +588,14 @@
*/
public void addWindowFocusListener (WindowFocusListener wfl)
{
- windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl);
+ if (wfl != null)
+ {
+ newEventsOnly = true;
+ windowFocusListener = AWTEventMulticaster.add (windowFocusListener,
+ wfl);
}
-
+ }
+
/**
* Adds the specified listener to this window.
*
@@ -596,9 +603,14 @@
*/
public void addWindowStateListener (WindowStateListener wsl)
{
- windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl);
+ if (wsl != null)
+ {
+ newEventsOnly = true;
+ windowStateListener = AWTEventMulticaster.add (windowStateListener,
+ wsl);
}
-
+ }
+
/**
* Removes the specified listener from this window.
*/
@@ -636,17 +648,11 @@
void dispatchEventImpl(AWTEvent e)
{
- // Make use of event id's in order to avoid multiple instanceof tests.
- if (e.id <= WindowEvent.WINDOW_LAST
- && e.id >= WindowEvent.WINDOW_FIRST
- && (windowListener != null
- || windowFocusListener != null
- || windowStateListener != null
- || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
- processEvent(e);
- else if (e.id == ComponentEvent.COMPONENT_RESIZED)
+ if (e.getID() == ComponentEvent.COMPONENT_RESIZED)
+ {
+ invalidate();
validate ();
- else
+ }
super.dispatchEventImpl(e);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-07-07 12:38:29
|
Revision: 3354
http://jnode.svn.sourceforge.net/jnode/?rev=3354&view=rev
Author: lsantha
Date: 2007-07-07 05:38:26 -0700 (Sat, 07 Jul 2007)
Log Message:
-----------
Openjdk integration.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/Dialog.java
trunk/core/src/classpath/java/java/awt/EventQueue.java
trunk/core/src/classpath/java/java/awt/Font.java
trunk/core/src/classpath/java/java/awt/FontMetrics.java
trunk/core/src/classpath/java/java/awt/GraphicsConfiguration.java
trunk/core/src/classpath/java/java/awt/PopupMenu.java
trunk/core/src/classpath/java/java/awt/Toolkit.java
trunk/core/src/classpath/java/java/awt/Window.java
trunk/core/src/classpath/java/java/awt/event/MouseEvent.java
trunk/core/src/classpath/java/java/awt/font/GraphicAttribute.java
trunk/core/src/classpath/java/java/awt/font/TextAttribute.java
trunk/core/src/classpath/java/java/awt/font/TransformAttribute.java
trunk/core/src/classpath/java/java/awt/geom/AffineTransform.java
trunk/core/src/classpath/java/java/awt/geom/GeneralPath.java
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-07-07 12:37:26 UTC (rev 3353)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-07-07 12:38:26 UTC (rev 3354)
@@ -6095,7 +6095,274 @@
peer.hide();
}
}
-
+
+ //jnode openjdk
+ /**
+ * Enumeration of the common ways the baseline of a component can
+ * change as the size changes. The baseline resize behavior is
+ * primarily for layout managers that need to know how the
+ * position of the baseline changes as the component size changes.
+ * In general the baseline resize behavior will be valid for sizes
+ * greater than or equal to the minimum size (the actual minimum
+ * size; not a developer specified minimum size). For sizes
+ * smaller than the minimum size the baseline may change in a way
+ * other than the baseline resize behavior indicates. Similarly,
+ * as the size approaches <code>Integer.MAX_VALUE</code> and/or
+ * <code>Short.MAX_VALUE</code> the baseline may change in a way
+ * other than the baseline resize behavior indicates.
+ *
+ * @see #getBaselineResizeBehavior
+ * @see #getBaseline(int,int)
+ * @since 1.6
+ */
+ public enum BaselineResizeBehavior {
+ /**
+ * Indicates the baseline remains fixed relative to the
+ * y-origin. That is, <code>getBaseline</code> returns
+ * the same value regardless of the height or width. For example, a
+ * <code>JLabel</code> containing non-empty text with a
+ * vertical alignment of <code>TOP</code> should have a
+ * baseline type of <code>CONSTANT_ASCENT</code>.
+ */
+ CONSTANT_ASCENT,
+
+ /**
+ * Indicates the baseline remains fixed relative to the height
+ * and does not change as the width is varied. That is, for
+ * any height H the difference between H and
+ * <code>getBaseline(w, H)</code> is the same. For example, a
+ * <code>JLabel</code> containing non-empty text with a
+ * vertical alignment of <code>BOTTOM</code> should have a
+ * baseline type of <code>CONSTANT_DESCENT</code>.
+ */
+ CONSTANT_DESCENT,
+
+ /**
+ * Indicates the baseline remains a fixed distance from
+ * the center of the component. That is, for any height H the
+ * difference between <code>getBaseline(w, H)</code> and
+ * <code>H / 2</code> is the same (plus or minus one depending upon
+ * rounding error).
+ * <p>
+ * Because of possible rounding errors it is recommended
+ * you ask for the baseline with two consecutive heights and use
+ * the return value to determine if you need to pad calculations
+ * by 1. The following shows how to calculate the baseline for
+ * any height:
+ * <pre>
+ * Dimension preferredSize = component.getPreferredSize();
+ * int baseline = getBaseline(preferredSize.width,
+ * preferredSize.height);
+ * int nextBaseline = getBaseline(preferredSize.width,
+ * preferredSize.height + 1);
+ * // Amount to add to height when calculating where baseline
+ * // lands for a particular height:
+ * int padding = 0;
+ * // Where the baseline is relative to the mid point
+ * int baselineOffset = baseline - height / 2;
+ * if (preferredSize.height % 2 == 0 &&
+ * baseline != nextBaseline) {
+ * padding = 1;
+ * }
+ * else if (preferredSize.height % 2 == 1 &&
+ * baseline == nextBaseline) {
+ * baselineOffset--;
+ * padding = 1;
+ * }
+ * // The following calculates where the baseline lands for
+ * // the height z:
+ * int calculatedBaseline = (z + padding) / 2 + baselineOffset;
+ * </pre>
+ */
+ CENTER_OFFSET,
+
+ /**
+ * Indicates the baseline resize behavior can not be expressed using
+ * any of the other constants. This may also indicate the baseline
+ * varies with the width of the component. This is also returned
+ * by components that do not have a baseline.
+ */
+ OTHER
+ }
+
+ /**
+ * Returns the baseline. The baseline is measured from the top of
+ * the component. This method is primarily meant for
+ * <code>LayoutManager</code>s to align components along their
+ * baseline. A return value less than 0 indicates this component
+ * does not have a reasonable baseline and that
+ * <code>LayoutManager</code>s should not align this component on
+ * its baseline.
+ * <p>
+ * The default implementation returns -1. Subclasses that support
+ * baseline should override appropriately. If a value >= 0 is
+ * returned, then the component has a valid baseline for any
+ * size >= the minimum size and <code>getBaselineResizeBehavior</code>
+ * can be used to determine how the baseline changes with size.
+ *
+ * @param width the width to get the baseline for
+ * @param height the height to get the baseline for
+ * @return the baseline or < 0 indicating there is no reasonable
+ * baseline
+ * @throws IllegalArgumentException if width or height is < 0
+ * @see #getBaselineResizeBehavior
+ * @see java.awt.FontMetrics
+ * @since 1.6
+ */
+ public int getBaseline(int width, int height) {
+ if (width < 0 || height < 0) {
+ throw new IllegalArgumentException(
+ "Width and height must be >= 0");
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the <code>Window</code> ancestor of the component.
+ * @return Window ancestor of the component or component by itself if it is Window;
+ * null, if component is not a part of window hierarchy
+ */
+ Window getContainingWindow() {
+ return getContainingWindow(this);
+ }
+ /**
+ * Returns the <code>Window</code> ancestor of the component <code>comp</code>.
+ * @return Window ancestor of the component or component by itself if it is Window;
+ * null, if component is not a part of window hierarchy
+ */
+ static Window getContainingWindow(Component comp) {
+ while (comp != null && !(comp instanceof Window)) {
+ comp = comp.getParent();
+ }
+
+ return (Window)comp;
+ }
+
+ /**
+ * Translates absolute coordinates into coordinates in the coordinate
+ * space of this component.
+ */
+ Point pointRelativeToComponent(Point absolute) {
+ Point compCoords = getLocationOnScreen();
+ return new Point(absolute.x - compCoords.x,
+ absolute.y - compCoords.y);
+ }
+
+ /**
+ * Returns an enum indicating how the baseline of the component
+ * changes as the size changes. This method is primarily meant for
+ * layout managers and GUI builders.
+ * <p>
+ * The default implementation returns
+ * <code>BaselineResizeBehavior.OTHER</code>. Subclasses that have a
+ * baseline should override appropriately. Subclasses should
+ * never return <code>null</code>; if the baseline can not be
+ * calculated return <code>BaselineResizeBehavior.OTHER</code>. Callers
+ * should first ask for the baseline using
+ * <code>getBaseline</code> and if a value >= 0 is returned use
+ * this method. It is acceptable for this method to return a
+ * value other than <code>BaselineResizeBehavior.OTHER</code> even if
+ * <code>getBaseline</code> returns a value less than 0.
+ *
+ * @return an enum indicating how the baseline changes as the component
+ * size changes
+ * @see #getBaseline(int, int)
+ * @since 1.6
+ */
+ public BaselineResizeBehavior getBaselineResizeBehavior() {
+ return BaselineResizeBehavior.OTHER;
+ }
+
+ /**
+ * Returns the position of the mouse pointer in this <code>Component</code>'s
+ * coordinate space if the <code>Component</code> is directly under the mouse
+ * pointer, otherwise returns <code>null</code>.
+ * If the <code>Component</code> is not showing on the screen, this method
+ * returns <code>null</code> even if the mouse pointer is above the area
+ * where the <code>Component</code> would be displayed.
+ * If the <code>Component</code> is partially or fully obscured by other
+ * <code>Component</code>s or native windows, this method returns a non-null
+ * value only if the mouse pointer is located above the unobscured part of the
+ * <code>Component</code>.
+ * <p>
+ * For <code>Container</code>s it returns a non-null value if the mouse is
+ * above the <code>Container</code> itself or above any of its descendants.
+ * Use {@link Container#getMousePosition(boolean)} if you need to exclude children.
+ * <p>
+ * Sometimes the exact mouse coordinates are not important, and the only thing
+ * that matters is whether a specific <code>Component</code> is under the mouse
+ * pointer. If the return value of this method is <code>null</code>, mouse
+ * pointer is not directly above the <code>Component</code>.
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
+ * @see #isShowing
+ * @see Container#getMousePosition
+ * @return mouse coordinates relative to this <code>Component</code>, or null
+ * @since 1.5
+ */
+ public Point getMousePosition() throws HeadlessException {
+ if (GraphicsEnvironment.isHeadless()) {
+ throw new HeadlessException();
+ }
+
+ PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction() {
+ public Object run() {
+ return MouseInfo.getPointerInfo();
+ }
+ }
+ );
+
+ synchronized (getTreeLock()) {
+ Component inTheSameWindow = findUnderMouseInWindow(pi);
+ if (!isSameOrAncestorOf(inTheSameWindow, true)) {
+ return null;
+ }
+ return pointRelativeToComponent(pi.getLocation());
+ }
+ }
+ /**
+ * Assuming that mouse location is stored in PointerInfo passed
+ * to this method, it finds a Component that is in the same
+ * Window as this Component and is located under the mouse pointer.
+ * If no such Component exists, null is returned.
+ * NOTE: this method should be called under the protection of
+ * tree lock, as it is done in Component.getMousePosition() and
+ * Container.getMousePosition(boolean).
+ */
+ Component findUnderMouseInWindow(PointerInfo pi) {
+ if (!isShowing()) {
+ return null;
+ }
+ Window win = getContainingWindow();
+ if (!Toolkit.getDefaultToolkit().getMouseInfoPeer().isWindowUnderMouse(win)) {
+ return null;
+ }
+ final boolean INCLUDE_DISABLED = true;
+ Point relativeToWindow = win.pointRelativeToComponent(pi.getLocation());
+ Component inTheSameWindow = win.findComponentAt(relativeToWindow.x,
+ relativeToWindow.y,
+ INCLUDE_DISABLED);
+ return inTheSameWindow;
+ }
+
+ boolean isSameOrAncestorOf(Component comp, boolean allowChildren) {
+ return this == comp || (allowChildren && isParentOf(comp));
+ }
+ /**
+ * Check if this component is the child of this container or its children.
+ * Note: this function acquires treeLock
+ * Note: this function traverses children tree only in one Window.
+ * @param comp a component in test, must not be null
+ */
+ private boolean isParentOf(Component comp) {
+ synchronized(getTreeLock()) {
+ while (comp != null && comp != this && !(comp instanceof Window)) {
+ comp = comp.getParent();
+ }
+ return (comp == this);
+ }
+ }
/**
* This class provides accessibility support for subclasses of container.
*
Modified: trunk/core/src/classpath/java/java/awt/Container.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Container.java 2007-07-07 12:37:26 UTC (rev 3353)
+++ trunk/core/src/classpath/java/java/awt/Container.java 2007-07-07 12:38:26 UTC (rev 3354)
@@ -2338,4 +2338,124 @@
}
} // class AccessibleContainerHandler
} // class AccessibleAWTContainer
+
+ //jnode openjdk
+
+ /**
+ * Returns the position of the mouse pointer in this <code>Container</code>'s
+ * coordinate space if the <code>Container</code> is under the mouse pointer,
+ * otherwise returns <code>null</code>.
+ * This method is similar to {@link Component#getMousePosition()} with the exception
+ * that it can take the <code>Container</code>'s children into account.
+ * If <code>allowChildren</code> is <code>false</code>, this method will return
+ * a non-null value only if the mouse pointer is above the <code>Container</code>
+ * directly, not above the part obscured by children.
+ * If <code>allowChildren</code> is <code>true</code>, this method returns
+ * a non-null value if the mouse pointer is above <code>Container</code> or any
+ * of its descendants.
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
+ * @param allowChildren true if children should be taken into account
+ * @see Component#getMousePosition
+ * @return mouse coordinates relative to this <code>Component</code>, or null
+ * @since 1.5
+ */
+ public Point getMousePosition(boolean allowChildren) throws HeadlessException {
+ if (GraphicsEnvironment.isHeadless()) {
+ throw new HeadlessException();
+ }
+ PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction() {
+ public Object run() {
+ return MouseInfo.getPointerInfo();
+ }
+ }
+ );
+ synchronized (getTreeLock()) {
+ Component inTheSameWindow = findUnderMouseInWindow(pi);
+ if (isSameOrAncestorOf(inTheSameWindow, allowChildren)) {
+ return pointRelativeToComponent(pi.getLocation());
+ }
+ return null;
+ }
+ }
+
+
+
+ /**
+ * Private version of findComponentAt which has a controllable
+ * behavior. Setting 'ignoreEnabled' to 'false' bypasses disabled
+ * Components during the search. This behavior is used by the
+ * lightweight cursor support in sun.awt.GlobalCursorManager.
+ * The cursor code calls this function directly via native code.
+ *
+ * The addition of this feature is temporary, pending the
+ * adoption of new, public API which exports this feature.
+ */
+ final Component findComponentAt(int x, int y, boolean ignoreEnabled)
+ {
+ if (isRecursivelyVisible()){
+ return findComponentAtImpl(x, y, ignoreEnabled);
+ }
+ return null;
+ }
+
+ /**
+ * Determines whether this component will be displayed on the screen.
+ * @return <code>true</code> if the component and all of its ancestors
+ * until a toplevel window or null parent are visible,
+ * <code>false</code> otherwise
+ */
+ boolean isRecursivelyVisible() {
+ return visible && (parent == null || parent.isRecursivelyVisible());
+ }
+
+ final Component findComponentAtImpl(int x, int y, boolean ignoreEnabled){
+ if (!(contains(x, y) && visible && (ignoreEnabled || enabled))) {
+ return null;
+ }
+ int ncomponents = this.ncomponents;
+ Component component[] = this.component;
+
+ // Two passes: see comment in sun.awt.SunGraphicsCallback
+ for (int i = 0 ; i < ncomponents ; i++) {
+ Component comp = component[i];
+ if (comp != null &&
+ !(comp.peer instanceof LightweightPeer)) {
+ if (comp instanceof Container) {
+ comp = ((Container)comp).findComponentAtImpl(x - comp.x,
+ y - comp.y,
+ ignoreEnabled);
+ } else {
+ comp = comp.locate(x - comp.x, y - comp.y);
+ }
+ if (comp != null && comp.visible &&
+ (ignoreEnabled || comp.enabled))
+ {
+ return comp;
+ }
+ }
+ }
+ for (int i = 0 ; i < ncomponents ; i++) {
+ Component comp = component[i];
+ if (comp != null &&
+ comp.peer instanceof LightweightPeer) {
+ if (comp instanceof Container) {
+ comp = ((Container)comp).findComponentAtImpl(x - comp.x,
+ y - comp.y,
+ ignoreEnabled);
+ } else {
+ comp = comp.locate(x - comp.x, y - comp.y);
+ }
+ if (comp != null && comp.visible &&
+ (ignoreEnabled || comp.enabled))
+ {
+ return comp;
+ }
+ }
+ }
+ return this;
+ }
+
+
} // class Container
Modified: trunk/core/src/classpath/java/java/awt/Dialog.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Dialog.java 2007-07-07 12:37:26 UTC (rev 3353)
+++ trunk/core/src/classpath/java/java/awt/Dialog.java 2007-07-07 12:38:26 UTC (rev 3354)
@@ -552,4 +552,113 @@
{
return next_dialog_number++;
}
+
+ //jnode openjdk
+/**
+ * Modal dialogs block all input to some top-level windows.
+ * Whether a particular window is blocked depends on dialog's type
+ * of modality; this is called the "scope of blocking". The
+ * <code>ModalityType</code> enum specifies modal types and their
+ * associated scopes.
+ *
+ * @see Dialog#getModalityType
+ * @see Dialog#setModalityType
+ * @see Toolkit#isModalityTypeSupported
+ *
+ * @since 1.6
+ */
+ public static enum ModalityType {
+ /**
+ * <code>MODELESS</code> dialog doesn't block any top-level windows.
+ */
+ MODELESS,
+ /**
+ * A <code>DOCUMENT_MODAL</code> dialog blocks input to all top-level windows
+ * from the same document except those from its own child hierarchy.
+ * A document is a top-level window without an owner. It may contain child
+ * windows that, together with the top-level window are treated as a single
+ * solid document. Since every top-level window must belong to some
+ * document, its root can be found as the top-nearest window without an owner.
+ */
+ DOCUMENT_MODAL,
+ /**
+ * An <code>APPLICATION_MODAL</code> dialog blocks all top-level windows
+ * from the same Java application except those from its own child hierarchy.
+ * If there are several applets launched in a browser, they can be
+ * treated either as separate applications or a single one. This behavior
+ * is implementation-dependent.
+ */
+ APPLICATION_MODAL,
+ /**
+ * A <code>TOOLKIT_MODAL</code> dialog blocks all top-level windows run
+ * from the same toolkit except those from its own child hierarchy. If there
+ * are several applets launched in a browser, all of them run with the same
+ * toolkit; thus, a toolkit-modal dialog displayed by an applet may affect
+ * other applets and all windows of the browser instance which embeds the
+ * Java runtime environment for this toolkit.
+ * Special <code>AWTPermission</code> "toolkitModality" must be granted to use
+ * toolkit-modal dialogs. If a <code>TOOLKIT_MODAL</code> dialog is being created
+ * and this permission is not granted, a <code>SecurityException</code> will be
+ * thrown, and no dialog will be created. If a modality type is being changed
+ * to <code>TOOLKIT_MODAL</code> and this permission is not granted, a
+ * <code>SecurityException</code> will be thrown, and the modality type will
+ * be left unchanged.
+ */
+ TOOLKIT_MODAL
+ };
+
+ /**
+ * Default modality type for modal dialogs. The default modality type is
+ * <code>APPLICATION_MODAL</code>. Calling the oldstyle <code>setModal(true)</code>
+ * is equal to <code>setModalityType(DEFAULT_MODALITY_TYPE)</code>.
+ *
+ * @see java.awt.Dialog.ModalityType
+ * @see java.awt.Dialog#setModal
+ *
+ * @since 1.6
+ */
+ public final static ModalityType DEFAULT_MODALITY_TYPE = ModalityType.APPLICATION_MODAL;
+
+ /**
+ * Any top-level window can be marked not to be blocked by modal
+ * dialogs. This is called "modal exclusion". This enum specifies
+ * the possible modal exclusion types.
+ *
+ * @see Window#getModalExclusionType
+ * @see Window#setModalExclusionType
+ * @see Toolkit#isModalExclusionTypeSupported
+ *
+ * @since 1.6
+ */
+ public static enum ModalExclusionType {
+ /**
+ * No modal exclusion.
+ */
+ NO_EXCLUDE,
+ /**
+ * <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
+ * won't be blocked by any application-modal dialogs. Also, it isn't
+ * blocked by document-modal dialogs from outside of its child hierarchy.
+ */
+ APPLICATION_EXCLUDE,
+ /**
+ * <code>TOOLKIT_EXCLUDE</code> indicates that a top-level window
+ * won't be blocked by application-modal or toolkit-modal dialogs. Also,
+ * it isn't blocked by document-modal dialogs from outside of its
+ * child hierarchy.
+ * The "toolkitModality" <code>AWTPermission</code> must be granted
+ * for this exclusion. If an exclusion property is being changed to
+ * <code>TOOLKIT_EXCLUDE</code> and this permission is not granted, a
+ * <code>SecurityEcxeption</code> will be thrown, and the exclusion
+ * property will be left unchanged.
+ */
+ TOOLKIT_EXCLUDE
+ };
+
+ /**
+ * @since 1.6
+ */
+ private final static ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE =
+ ModalExclusionType.APPLICATION_EXCLUDE;
+
}
Modified: trunk/core/src/classpath/java/java/awt/EventQueue.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/EventQueue.java 2007-07-07 12:37:26 UTC (rev 3353)
+++ trunk/core/src/classpath/java/java/awt/EventQueue.java 2007-07-07 12:38:26 UTC (rev 3354)
@@ -49,6 +49,7 @@
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
import java.lang.reflect.InvocationTargetException;
+import java.lang.ref.WeakReference;
import java.util.EmptyStackException;
/* Written using on-line Java 2 Platform Standard Edition v1.3 API
@@ -665,4 +666,46 @@
return System.currentTimeMillis();
return eq.lastWhen;
}
+
+ //jnode openjdk
+ static void setCurrentEventAndMostRecentTime(AWTEvent e) {
+ Toolkit.getEventQueue().setCurrentEventAndMostRecentTimeImpl(e);
+ }
+ private synchronized void setCurrentEventAndMostRecentTimeImpl(AWTEvent e)
+ {
+ if (Thread.currentThread() != dispatchThread) {
+ return;
+ }
+
+ currentEvent = e;
+
+ // This series of 'instanceof' checks should be replaced with a
+ // polymorphic type (for example, an interface which declares a
+ // getWhen() method). However, this would require us to make such
+ // a type public, or to place it in sun.awt. Both of these approaches
+ // have been frowned upon. So for now, we hack.
+ //
+ // In tiger, we will probably give timestamps to all events, so this
+ // will no longer be an issue.
+ long mostRecentEventTime2 = Long.MIN_VALUE;
+ if (e instanceof InputEvent) {
+ InputEvent ie = (InputEvent)e;
+ mostRecentEventTime2 = ie.getWhen();
+ } else if (e instanceof InputMethodEvent) {
+ InputMethodEvent ime = (InputMethodEvent)e;
+ mostRecentEventTime2 = ime.getWhen();
+ } else if (e instanceof ActionEvent) {
+ ActionEvent ae = (ActionEvent)e;
+ mostRecentEventTime2 = ae.getWhen();
+ } else if (e instanceof InvocationEvent) {
+ InvocationEvent ie = (InvocationEvent)e;
+ mostRecentEventTime2 = ie.getWhen();
+ }
+ mostRecentEventTime = Math.max(mostRecentEventTime, mostRecentEventTime2);
+ }
+ /*
+ * The time stamp of the last dispatched InputEvent or ActionEvent.
+ */
+ private long mostRecentEventTime = System.currentTimeMillis();
+
}
Modified: trunk/core/src/classpath/java/java/awt/Font.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Font.java 2007-07-07 12:37:26 UTC (rev 3353)
+++ trunk/core/src/classpath/java/java/awt/Font.java 2007-07-07 12:38:26 UTC (rev 3354)
@@ -61,6 +61,31 @@
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;
+import sun.font.Font2DHandle;
+import sun.font.AttributeValues;
+import static sun.font.EAttribute.EFONT;
+import static sun.font.EAttribute.EFAMILY;
+import static sun.font.EAttribute.EWEIGHT;
+import static sun.font.EAttribute.EWIDTH;
+import static sun.font.EAttribute.EPOSTURE;
+import static sun.font.EAttribute.ESIZE;
+import static sun.font.EAttribute.ETRANSFORM;
+import static sun.font.EAttribute.ESUPERSCRIPT;
+import static sun.font.EAttribute.ETRACKING;
+import static sun.font.EAttribute.ECHAR_REPLACEMENT;
+import static sun.font.EAttribute.EFOREGROUND;
+import static sun.font.EAttribute.EBACKGROUND;
+import static sun.font.EAttribute.EUNDERLINE;
+import static sun.font.EAttribute.ESTRIKETHROUGH;
+import static sun.font.EAttribute.ERUN_DIRECTION;
+import static sun.font.EAttribute.EBIDI_EMBEDDING;
+import static sun.font.EAttribute.EJUSTIFICATION;
+import static sun.font.EAttribute.EINPUT_METHOD_HIGHLIGHT;
+import static sun.font.EAttribute.EINPUT_METHOD_UNDERLINE;
+import static sun.font.EAttribute.ESWAP_COLORS;
+import static sun.font.EAttribute.ENUMERIC_SHAPING;
+import static sun.font.EAttribute.EKERNING;
+import static sun.font.EAttribute.ELIGATURES;
/**
* This class represents a windowing system font.
@@ -103,7 +128,49 @@
public static final int HANGING_BASELINE = 2;
- /**
+ //jnode openjdk
+ /**
+ * A String constant for the canonical family name of the
+ * logical font "Dialog". It is useful in Font construction
+ * to provide compile-time verification of the name.
+ * @since 1.6
+ */
+ public static final String DIALOG = "Dialog";
+
+ /**
+ * A String constant for the canonical family name of the
+ * logical font "DialogInput". It is useful in Font construction
+ * to provide compile-time verification of the name.
+ * @since 1.6
+ */
+ public static final String DIALOG_INPUT = "DialogInput";
+
+ /**
+ * A String constant for the canonical family name of the
+ * logical font "SansSerif". It is useful in Font construction
+ * to provide compile-time verification of the name.
+ * @since 1.6
+ */
+ public static final String SANS_SERIF = "SansSerif";
+
+ /**
+ * A String constant for the canonical family name of the
+ * logical font "Serif". It is useful in Font construction
+ * to provid...
[truncated message content] |
|
From: <ls...@us...> - 2007-07-07 12:52:39
|
Revision: 3358
http://jnode.svn.sourceforge.net/jnode/?rev=3358&view=rev
Author: lsantha
Date: 2007-07-07 05:52:37 -0700 (Sat, 07 Jul 2007)
Log Message:
-----------
Openjdk integration.
Removed Paths:
-------------
trunk/core/src/classpath/java/java/awt/RenderingHints.java
trunk/core/src/classpath/java/java/awt/font/FontRenderContext.java
Deleted: trunk/core/src/classpath/java/java/awt/RenderingHints.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/RenderingHints.java 2007-07-07 12:47:46 UTC (rev 3357)
+++ trunk/core/src/classpath/java/java/awt/RenderingHints.java 2007-07-07 12:52:37 UTC (rev 3358)
@@ -1,804 +0,0 @@
-/* RenderingHints.java --
- Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.awt;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A collection of (key, value) items that provide 'hints' for the
- * {@link java.awt.Graphics2D} rendering pipeline. Because these
- * items are hints only, they may be ignored by a particular
- * {@link java.awt.Graphics2D} implementation.
- *
- * @author Rolf W. Rasmussen (ro...@ii...)
- * @author Eric Blake (eb...@em...)
- */
-public class RenderingHints
- implements Map<Object,Object>, Cloneable
-{
- /**
- * The base class used to represent keys.
- */
- public abstract static class Key
- {
- private final int key;
-
- /**
- * Creates a new key.
- *
- * @param privateKey the private key.
- */
- protected Key(int privateKey)
- {
- key = privateKey;
- }
-
- /**
- * Returns <code>true</code> if the specified value is compatible with
- * this key, and <code>false</code> otherwise.
- *
- * @param value the value (<code>null</code> permitted).
- *
- * @return A boolean.
- */
- public abstract boolean isCompatibleValue(Object value);
-
- /**
- * Returns the private key for this instance.
- *
- * @return The private key.
- */
- protected final int intKey()
- {
- return key;
- }
-
- /**
- * Returns a hash code for the key.
- *
- * @return A hash code.
- */
- public final int hashCode()
- {
- return System.identityHashCode(this);
- }
-
- /**
- * Checks this key for equality with an arbitrary object.
- *
- * @param other the object (<code>null</code> permitted)
- *
- * @return A boolean.
- */
- public final boolean equals(Object other)
- {
- return this == other;
- }
- } // class Key
-
- private static final class KeyImpl extends Key
- {
- final String description;
- final Object v1;
- final Object v2;
- final Object v3;
-
- KeyImpl(int privateKey, String description,
- Object v1, Object v2, Object v3)
- {
- super(privateKey);
- this.description = description;
- this.v1 = v1;
- this.v2 = v2;
- this.v3 = v3;
- }
-
- /**
- * Returns <code>true</code> if the specified value is compatible with
- * this key, and <code>false</code> otherwise.
- *
- * @param value the value (<code>null</code> permitted).
- *
- * @return A boolean.
- */
- public boolean isCompatibleValue(Object value)
- {
- return value == v1 || value == v2 || value == v3;
- }
-
- /**
- * Returns a string representation of the key.
- *
- * @return A string.
- */
- public String toString()
- {
- return description;
- }
- } // class KeyImpl
-
- private HashMap hintMap = new HashMap();
-
- /**
- * A key for the 'antialiasing' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_ANTIALIAS_OFF}</td>
- * <td>Render without antialiasing (better speed).</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_ANTIALIAS_ON}</td>
- * <td>Render with antialiasing (better quality).</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_ANTIALIAS_DEFAULT}</td>
- * <td>Use the default value for antialiasing.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_ANTIALIASING;
-
- /**
- * This value is for use with the {@link #KEY_ANTIALIASING} key.
- */
- public static final Object VALUE_ANTIALIAS_ON
- = "Antialiased rendering mode";
-
- /**
- * This value is for use with the {@link #KEY_ANTIALIASING} key.
- */
- public static final Object VALUE_ANTIALIAS_OFF
- = "Nonantialiased rendering mode";
-
- /**
- * This value is for use with the {@link #KEY_ANTIALIASING} key.
- */
- public static final Object VALUE_ANTIALIAS_DEFAULT
- = "Default antialiasing rendering mode";
-
- /**
- * A key for the 'rendering' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_RENDER_SPEED}</td>
- * <td>Prefer speed over quality when rendering.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_RENDER_QUALITY}</td>
- * <td>Prefer quality over speed when rendering.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_RENDER_DEFAULT}</td>
- * <td>Use the default value for quality vs. speed when rendering.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_RENDERING;
-
- /**
- * This value is for use with the {@link #KEY_RENDERING} key.
- */
- public static final Object VALUE_RENDER_SPEED
- = "Fastest rendering methods";
-
- /**
- * This value is for use with the {@link #KEY_RENDERING} key.
- */
- public static final Object VALUE_RENDER_QUALITY
- = "Highest quality rendering methods";
-
- /**
- * This value is for use with the {@link #KEY_RENDERING} key.
- */
- public static final Object VALUE_RENDER_DEFAULT
- = "Default rendering methods";
-
- /**
- * A key for the 'dithering' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_DITHER_DISABLE}</td>
- * <td>Disable dithering.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_DITHER_ENABLE}</td>
- * <td>Enable dithering.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_DITHER_DEFAULT}</td>
- * <td>Use the default value for dithering.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_DITHERING;
-
- /**
- * This value is for use with the {@link #KEY_DITHERING} key.
- */
- public static final Object VALUE_DITHER_DISABLE
- = "Nondithered rendering mode";
-
- /**
- * This value is for use with the {@link #KEY_DITHERING} key.
- */
- public static final Object VALUE_DITHER_ENABLE
- = "Dithered rendering mode";
-
- /**
- * This value is for use with the {@link #KEY_DITHERING} key.
- */
- public static final Object VALUE_DITHER_DEFAULT
- = "Default dithering mode";
-
- /**
- * A key for the 'text antialiasing' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_TEXT_ANTIALIAS_ON}</td>
- * <td>Render text with antialiasing (better quality usually).</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_TEXT_ANTIALIAS_OFF}</td>
- * <td>Render test without antialiasing (better speed).</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_TEXT_ANTIALIAS_DEFAULT}</td>
- * <td>Use the default value for text antialiasing.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_TEXT_ANTIALIASING;
-
- /**
- * This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
- */
- public static final Object VALUE_TEXT_ANTIALIAS_ON
- = "Antialiased text mode";
-
- /**
- * This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
- */
- public static final Object VALUE_TEXT_ANTIALIAS_OFF
- = "Nonantialiased text mode";
-
- /**
- * This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
- */
- public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT
- = "Default antialiasing text mode";
-
- /**
- * A key for the 'fractional metrics' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_FRACTIONALMETRICS_OFF}</td>
- * <td>Render text with fractional metrics off.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_FRACTIONALMETRICS_ON}</td>
- * <td>Render text with fractional metrics on.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_FRACTIONALMETRICS_DEFAULT}</td>
- * <td>Use the default value for fractional metrics.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_FRACTIONALMETRICS;
-
- /**
- * This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
- */
- public static final Object VALUE_FRACTIONALMETRICS_OFF
- = "Integer text metrics mode";
-
- /**
- * This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
- */
- public static final Object VALUE_FRACTIONALMETRICS_ON
- = "Fractional text metrics mode";
-
- /**
- * This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
- */
- public static final Object VALUE_FRACTIONALMETRICS_DEFAULT
- = "Default fractional text metrics mode";
-
- /**
- * A key for the 'interpolation' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR}</td>
- * <td>Use nearest neighbour interpolation.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_INTERPOLATION_BILINEAR}</td>
- * <td>Use bilinear interpolation.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_INTERPOLATION_BICUBIC}</td>
- * <td>Use bicubic interpolation.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_INTERPOLATION;
-
- /**
- * This value is for use with the {@link #KEY_INTERPOLATION} key.
- */
- public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR
- = "Nearest Neighbor image interpolation mode";
-
- /**
- * This value is for use with the {@link #KEY_INTERPOLATION} key.
- */
- public static final Object VALUE_INTERPOLATION_BILINEAR
- = "Bilinear image interpolation mode";
-
- /**
- * This value is for use with the {@link #KEY_INTERPOLATION} key.
- */
- public static final Object VALUE_INTERPOLATION_BICUBIC
- = "Bicubic image interpolation mode";
-
- /**
- * A key for the 'alpha interpolation' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_ALPHA_INTERPOLATION_SPEED}</td>
- * <td>Prefer speed over quality.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_ALPHA_INTERPOLATION_QUALITY}</td>
- * <td>Prefer quality over speed.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_ALPHA_INTERPOLATION_DEFAULT}</td>
- * <td>Use the default setting.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_ALPHA_INTERPOLATION;
-
- /**
- * This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
- */
- public static final Object VALUE_ALPHA_INTERPOLATION_SPEED
- = "Fastest alpha blending methods";
-
- /**
- * This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
- */
- public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY
- = "Highest quality alpha blending methods";
-
- /**
- * This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
- */
- public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT
- = "Default alpha blending methods";
-
- /**
- * A key for the 'color rendering' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_COLOR_RENDER_SPEED}</td>
- * <td>Prefer speed over quality.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_COLOR_RENDER_QUALITY}</td>
- * <td>Prefer quality over speed.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_COLOR_RENDER_DEFAULT}</td>
- * <td>Use the default setting.</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_COLOR_RENDERING;
-
- /**
- * This value is for use with the {@link #KEY_COLOR_RENDERING} key.
- */
- public static final Object VALUE_COLOR_RENDER_SPEED
- = "Fastest color rendering mode";
-
- /**
- * This value is for use with the {@link #KEY_COLOR_RENDERING} key.
- */
- public static final Object VALUE_COLOR_RENDER_QUALITY
- = "Highest quality color rendering mode";
-
- /**
- * This value is for use with the {@link #KEY_COLOR_RENDERING} key.
- */
- public static final Object VALUE_COLOR_RENDER_DEFAULT
- = "Default color rendering mode";
-
- /**
- * A key for the 'stroke control' hint. Permitted values are:
- * <p>
- * <table>
- * <tr>
- * <td>{@link #VALUE_STROKE_DEFAULT}</td>
- * <td>Use the default setting.</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_STROKE_NORMALIZE}</td>
- * <td>XXX</td>
- * </tr>
- * <tr>
- * <td>{@link #VALUE_STROKE_PURE}</td>
- * <td>XXX</td>
- * </tr>
- * </table>
- */
- public static final Key KEY_STROKE_CONTROL;
-
- /**
- * This value is for use with the {@link #KEY_STROKE_CONTROL} key.
- */
- public static final Object VALUE_STROKE_DEFAULT
- = "Default stroke normalization";
-
- /**
- * This value is for use with the {@link #KEY_STROKE_CONTROL} key.
- */
- public static final Object VALUE_STROKE_NORMALIZE
- = "Normalize strokes for consistent rendering";
-
- /**
- * This value is for use with the {@link #KEY_STROKE_CONTROL} key.
- */
- public static final Object VALUE_STROKE_PURE
- = "Pure stroke conversion for accurate paths";
-
- static
- {
- KEY_ANTIALIASING = new KeyImpl(1, "Global antialiasing enable key",
- VALUE_ANTIALIAS_ON,
- VALUE_ANTIALIAS_OFF,
- VALUE_ANTIALIAS_DEFAULT);
- KEY_RENDERING = new KeyImpl(2, "Global rendering quality key",
- VALUE_RENDER_SPEED,
- VALUE_RENDER_QUALITY,
- VALUE_RENDER_DEFAULT);
- KEY_DITHERING = new KeyImpl(3, "Dithering quality key",
- VALUE_DITHER_DISABLE,
- VALUE_DITHER_ENABLE,
- VALUE_DITHER_DEFAULT);
- KEY_TEXT_ANTIALIASING
- = new KeyImpl(4, "Text-specific antialiasing enable key",
- VALUE_TEXT_ANTIALIAS_ON,
- VALUE_TEXT_ANTIALIAS_OFF,
- VALUE_TEXT_ANTIALIAS_DEFAULT);
- KEY_FRACTIONALMETRICS = new KeyImpl(5, "Fractional metrics enable key",
- VALUE_FRACTIONALMETRICS_OFF,
- VALUE_FRACTIONALMETRICS_ON,
- VALUE_FRACTIONALMETRICS_DEFAULT);
- KEY_INTERPOLATION = new KeyImpl(6, "Image interpolation method key",
- VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
- VALUE_INTERPOLATION_BILINEAR,
- VALUE_INTERPOLATION_BICUBIC);
- KEY_ALPHA_INTERPOLATION
- = new KeyImpl(7, "Alpha blending interpolation method key",
- VALUE_ALPHA_INTERPOLATION_SPEED,
- VALUE_ALPHA_INTERPOLATION_QUALITY,
- VALUE_ALPHA_INTERPOLATION_DEFAULT);
- KEY_COLOR_RENDERING = new KeyImpl(8, "Color rendering quality key",
- VALUE_COLOR_RENDER_SPEED,
- VALUE_COLOR_RENDER_QUALITY,
- VALUE_COLOR_RENDER_DEFAULT);
- KEY_STROKE_CONTROL = new KeyImpl(9, "Stroke normalization control key",
- VALUE_STROKE_DEFAULT,
- VALUE_STROKE_NORMALIZE,
- VALUE_STROKE_PURE);
- }
-
- /**
- * Creates a new collection of hints containing all the (key, value) pairs
- * in the specified map.
- *
- * @param init a map containing a collection of hints (<code>null</code>
- * permitted).
- */
- public RenderingHints(Map<Key,?> init)
- {
- if (init != null)
- putAll(init);
- }
-
- /**
- * Creates a new collection containing a single (key, value) pair.
- *
- * @param key the key.
- * @param value the value.
- */
- public RenderingHints(Key key, Object value)
- {
- put(key, value);
- }
-
- /**
- * Returns the number of hints in the collection.
- *
- * @return The number of hints.
- */
- public int size()
- {
- return hintMap.size();
- }
-
- /**
- * Returns <code>true</code> if there are no hints in the collection,
- * and <code>false</code> otherwise.
- *
- * @return A boolean.
- */
- public boolean isEmpty()
- {
- return hintMap.isEmpty();
- }
-
- /**
- * Returns <code>true</code> if the collection of hints contains the
- * specified key, and <code>false</code> otherwise.
- *
- * @param key the key (<code>null</code> not permitted).
- *
- * @return A boolean.
- *
- * @throws NullPointerException if <code>key</code> is <code>null</code>.
- * @throws ClassCastException if <code>key</code> is not a {@link Key}.
- */
- public boolean containsKey(Object key)
- {
- if (key == null)
- throw new NullPointerException();
- // don't remove the cast, it is necessary to throw the required exception
- return hintMap.containsKey((Key) key);
- }
-
- /**
- * Returns <code>true</code> if the collection of hints contains the
- * specified value, and <code>false</code> otherwise.
- *
- * @param value the value.
- *
- * @return A boolean.
- */
- public boolean containsValue(Object value)
- {
- return hintMap.containsValue(value);
- }
-
- /**
- * Returns the value associated with the specified key, or <code>null</code>
- * if there is no value defined for the key.
- *
- * @param key the key (<code>null</code> permitted).
- *
- * @return The value (possibly <code>null</code>).
- *
- * @throws ClassCastException if <code>key</code> is not a {@link Key}.
- *
- * @see #containsKey(Object)
- */
- public Object get(Object key)
- {
- // don't remove the cast, it is necessary to throw the required exception
- return hintMap.get((Key) key);
- }
-
- /**
- * Adds a (key, value) pair to the collection of hints (if the
- * collection already contains the specified key, then the
- * value is updated).
- *
- * @param key the key.
- * @param value the value.
- *
- * @return the previous value of the key or <code>null</code> if the key
- * didn't have a value yet.
- */
- public Object put(Object key, Object value)
- {
- if (key == null || value == null)
- throw new NullPointerException();
- if (! ((Key) key).isCompatibleValue(value))
- throw new IllegalArgumentException();
- return hintMap.put(key, value);
- }
-
- /**
- * Adds all the hints from a collection to this collection.
- *
- * @param hints the hint collection.
- */
- public void add(RenderingHints hints)
- {
- hintMap.putAll(hints);
- }
-
- /**
- * Clears all the hints from this collection.
- */
- public void clear()
- {
- hintMap.clear();
- }
-
- /**
- * Removes a hint from the collection.
- *
- * @param key the key.
- *
- * @return The value that was associated with the key, or <code>null</code> if
- * the key was not part of the collection
- *
- * @throws ClassCastException if the key is not a subclass of
- * {@link RenderingHints.Key}.
- */
- public Object remove(Object key)
- {
- // don't remove the (Key) cast, it is necessary to throw the exception
- // required by the spec
- return hintMap.remove((Key) key);
- }
-
- /**
- * Adds a collection of (key, value) pairs to the collection.
- *
- * @param m a map containing (key, value) items.
- *
- * @throws ClassCastException if the map contains a key that is not
- * a subclass of {@link RenderingHints.Key}.
- * @throws IllegalArgumentException if the map contains a value that is
- * not compatible with its key.
- */
- public void putAll(Map<?,?> m)
- {
- // preprocess map to generate appropriate exceptions
- Iterator iterator = m.keySet().iterator();
- while (iterator.hasNext())
- {
- Key key = (Key) iterator.next();
- if (!key.isCompatibleValue(m.get(key)))
- throw new IllegalArgumentException();
- }
- // map is OK, update
- hintMap.putAll(m);
- }
-
- /**
- * Returns a set containing the keys from this collection.
- *
- * @return A set of keys.
- */
- public Set<Object> keySet()
- {
- return hintMap.keySet();
- }
-
- /**
- * Returns a collection of the values from this hint collection. The
- * collection is backed by the <code>RenderingHints</code> instance,
- * so updates to one will affect the other.
- *
- * @return A collection of values.
- */
- public Collection<Object> values()
- {
- return hintMap.values();
- }
-
- /**
- * Returns a set of entries from the collection.
- *
- * @return A set of entries.
- */
- public Set<Map.Entry<Object,Object>> entrySet()
- {
- return Collections.unmodifiableSet(hintMap.entrySet());
- }
-
- /**
- * Checks this collection for equality with an arbitrary object.
- *
- * @param o the object (<code>null</code> permitted)
- *
- * @return A boolean.
- */
- public boolean equals(Object o)
- {
- return hintMap.equals(o);
- }
-
- /**
- * Returns a hash code for the collection of hints.
- *
- * @return A hash code.
- */
- public int hashCode()
- {
- return hintMap.hashCode();
- }
-
- /**
- * Creates a clone of this instance.
- *
- * @return A clone.
- */
- public Object clone()
- {
- try
- {
- RenderingHints copy = (RenderingHints) super.clone();
- copy.hintMap = (HashMap) hintMap.clone();
- return copy;
- }
- catch (CloneNotSupportedException e)
- {
- throw (Error) new InternalError().initCause(e); // Impossible
- }
- }
-
- /**
- * Returns a string representation of this instance.
- *
- * @return A string.
- */
- public String toString()
- {
- return hintMap.toString();
- }
-} // class RenderingHints
Deleted: trunk/core/src/classpath/java/java/awt/font/FontRenderContext.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/font/FontRenderContext.java 2007-07-07 12:47:46 UTC (rev 3357)
+++ trunk/core/src/classpath/java/java/awt/font/FontRenderContext.java 2007-07-07 12:52:37 UTC (rev 3358)
@@ -1,138 +0,0 @@
-/* FontRenderContext.java
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.awt.font;
-
-import java.awt.geom.AffineTransform;
-
-/**
- * @author Michael Koch
- */
-public class FontRenderContext
-{
- private AffineTransform affineTransform;
- private boolean isAntiAliased;
- private boolean usesFractionalMetrics;
-
- /**
- * Construct a new <code>FontRenderContext</code>.
- */
- protected FontRenderContext()
- {
- // Do nothing here.
- }
-
- /**
- * Construct a new <code>FontRenderContext</code>.
- */
- public FontRenderContext (AffineTransform tx, boolean isAntiAliased,
- boolean usesFractionalMetrics)
- {
- if (tx != null
- && !tx.isIdentity ())
- {
- this.affineTransform = new AffineTransform (tx);
- }
-
- this.isAntiAliased = isAntiAliased;
- this.usesFractionalMetrics = usesFractionalMetrics;
- }
-
- public boolean equals (Object obj)
- {
- if (! (obj instanceof FontRenderContext))
- return false;
-
- return equals ((FontRenderContext) obj);
- }
-
- public boolean equals (FontRenderContext rhs)
- {
- if (rhs == null)
- return false;
-
- if (affineTransform == null && rhs.affineTransform != null
- || affineTransform != null && rhs.affineTransform == null)
- return false;
-
- return ((affineTransform == rhs.affineTransform
- || affineTransform.equals (rhs.getTransform ()))
- && isAntiAliased == rhs.isAntiAliased ()
- && usesFractionalMetrics == rhs.usesFractionalMetrics ());
- }
-
-
- /**
- * Retrieves the affine transform for scaling typographical points
- * to raster pixels.
- *
- * @return a clone of the transform object.
- */
- public AffineTransform getTransform ()
- {
- if (affineTransform == null)
- return new AffineTransform ();
- else
- return new AffineTransform (affineTransform);
- }
-
-
- /**
- * Returns the hash code of the font render context.
- */
- public int hashCode ()
- {
- int code = ( isAntiAliased ? 1 : 0 ) + ( usesFractionalMetrics ? 2 : 0 );
-
- if( affineTransform != null && !affineTransform.isIdentity() )
- code ^= affineTransform.hashCode();
-
- return code;
- }
-
- public boolean isAntiAliased ()
- {
- return isAntiAliased;
- }
-
- public boolean usesFractionalMetrics ()
- {
- return usesFractionalMetrics;
- }
-}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-08-11 14:33:16
|
Revision: 3387
http://jnode.svn.sourceforge.net/jnode/?rev=3387&view=rev
Author: lsantha
Date: 2007-08-11 07:32:55 -0700 (Sat, 11 Aug 2007)
Log Message:
-----------
Openjdk integration.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/AWTKeyStroke.java
trunk/core/src/classpath/java/java/awt/AlphaComposite.java
Modified: trunk/core/src/classpath/java/java/awt/AWTKeyStroke.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/AWTKeyStroke.java 2007-08-11 13:49:36 UTC (rev 3386)
+++ trunk/core/src/classpath/java/java/awt/AWTKeyStroke.java 2007-08-11 14:32:55 UTC (rev 3387)
@@ -92,8 +92,8 @@
/** The largest the keystroke cache can grow. */
private static final int MAX_CACHE_SIZE = 2048;
- /** Prune stale entries. */
- protected boolean removeEldestEntry(Entry<AWTKeyStroke,AWTKeyStroke>
+ /** Prune stale entries. */ //jnode openjdk
+ protected boolean removeEldestEntry(Map.Entry<AWTKeyStroke,AWTKeyStroke>
eldest)
{
return size() > MAX_CACHE_SIZE;
Modified: trunk/core/src/classpath/java/java/awt/AlphaComposite.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/AlphaComposite.java 2007-08-11 13:49:36 UTC (rev 3386)
+++ trunk/core/src/classpath/java/java/awt/AlphaComposite.java 2007-08-11 14:32:55 UTC (rev 3387)
@@ -43,6 +43,7 @@
import java.awt.image.ColorModel;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.HashMap;
/**
*
@@ -61,7 +62,7 @@
private static final int MAX_CACHE_SIZE = 2048;
/** Prune stale entries. */
- protected boolean removeEldestEntry(Entry eldest)
+ protected boolean removeEldestEntry(Map.Entry eldest) //jnode openjdk
{
return size() > MAX_CACHE_SIZE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2007-08-27 17:41:11
|
Revision: 3415
http://jnode.svn.sourceforge.net/jnode/?rev=3415&view=rev
Author: lsantha
Date: 2007-08-25 12:27:54 -0700 (Sat, 25 Aug 2007)
Log Message:
-----------
Openjdk integration.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/peer/ComponentPeer.java
trunk/core/src/classpath/java/java/awt/peer/FramePeer.java
Modified: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2007-08-25 19:26:55 UTC (rev 3414)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2007-08-25 19:27:54 UTC (rev 3415)
@@ -4173,7 +4173,7 @@
*/
public boolean isFocusTraversable()
{
- return enabled && visible && (peer == null || isLightweight() || peer.isFocusTraversable());
+ return enabled && visible && (peer == null || isLightweight() || peer.isFocusable());
}
/**
Modified: trunk/core/src/classpath/java/java/awt/peer/ComponentPeer.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/peer/ComponentPeer.java 2007-08-25 19:26:55 UTC (rev 3414)
+++ trunk/core/src/classpath/java/java/awt/peer/ComponentPeer.java 2007-08-25 19:27:54 UTC (rev 3415)
@@ -64,6 +64,15 @@
*/
public interface ComponentPeer
{
+ //jnode openjdk
+ public static final int SET_LOCATION = 1,
+ SET_SIZE = 2,
+ SET_BOUNDS = 3,
+ SET_CLIENT_SIZE = 4,
+ RESET_OPERATION = 5,
+ NO_EMBEDDED_CHECK = (1 << 14),
+ DEFAULT_OPERATION = SET_BOUNDS;
+
/**
* Returns the construction status of the specified image. This is called
* by {@link Component#checkImage(Image, int, int, ImageObserver)}.
@@ -200,14 +209,6 @@
/**
* Returns <code>true</code> if the component can receive keyboard input
- * focus. This is called from {@link Component#isFocusTraversable()}.
- *
- * @specnote Part of the earlier 1.1 API, replaced by isFocusable().
- */
- boolean isFocusTraversable();
-
- /**
- * Returns <code>true</code> if the component can receive keyboard input
* focus. This is called from {@link Component#isFocusable()}.
*/
boolean isFocusable();
Modified: trunk/core/src/classpath/java/java/awt/peer/FramePeer.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/peer/FramePeer.java 2007-08-25 19:26:55 UTC (rev 3414)
+++ trunk/core/src/classpath/java/java/awt/peer/FramePeer.java 2007-08-25 19:27:54 UTC (rev 3415)
@@ -71,5 +71,7 @@
* @since 1.5
*/
void setBoundsPrivate(int x, int y, int width, int height);
+ //jnode openjdk
+ Rectangle getBoundsPrivate();
} // interface FramePeer
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ls...@us...> - 2008-03-16 20:00:43
|
Revision: 3845
http://jnode.svn.sourceforge.net/jnode/?rev=3845&view=rev
Author: lsantha
Date: 2008-03-16 13:00:41 -0700 (Sun, 16 Mar 2008)
Log Message:
-----------
OpenJDK AWT & Swing integration.
Modified Paths:
--------------
trunk/core/src/classpath/java/java/awt/Toolkit.java
Removed Paths:
-------------
trunk/core/src/classpath/java/java/awt/AWTEvent.java
trunk/core/src/classpath/java/java/awt/Component.java
trunk/core/src/classpath/java/java/awt/Container.java
trunk/core/src/classpath/java/java/awt/DefaultKeyboardFocusManager.java
trunk/core/src/classpath/java/java/awt/Dialog.java
trunk/core/src/classpath/java/java/awt/Frame.java
trunk/core/src/classpath/java/java/awt/LightweightDispatcher.java
trunk/core/src/classpath/java/java/awt/Window.java
Deleted: trunk/core/src/classpath/java/java/awt/AWTEvent.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/AWTEvent.java 2008-03-16 13:55:01 UTC (rev 3844)
+++ trunk/core/src/classpath/java/java/awt/AWTEvent.java 2008-03-16 20:00:41 UTC (rev 3845)
@@ -1,570 +0,0 @@
-
-/* AWTEvent.java -- the root event in AWT
- Copyright (C) 1999, 2000, 2002, 2005 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.awt;
-
-import java.awt.event.*;
-import java.util.EventObject;
-import java.lang.reflect.Field;
-
-/**
- * AWTEvent is the root event class for all AWT events in the JDK 1.1 event
- * model. It supersedes the Event class from JDK 1.0. Subclasses outside of
- * the java.awt package should have IDs greater than RESERVED_ID_MAX.
- *
- * <p>Event masks defined here are used by components in
- * <code>enableEvents</code> to select event types not selected by registered
- * listeners. Event masks are appropriately set when registering on
- * components.
- *
- * @author Warren Levy (wa...@cy...)
- * @author Aaron M. Renn (ar...@ur...)
- * @since 1.1
- * @status updated to 1.4
- */
-public abstract class AWTEvent extends EventObject
-{
- /**
- * Compatible with JDK 1.1+.
- */
- private static final long serialVersionUID = -1825314779160409405L;
-
- transient boolean focusManagerIsDispatching = false;
- transient boolean isPosted;
- /**
- * The ID of the event.
- *
- * @see #getID()
- * @see #AWTEvent(Object, int)
- * @serial the identifier number of this event
- */
- protected int id;
-
- /**
- * Indicates if the event has been consumed. False mean it is passed to
- * the peer, true means it has already been processed. Semantic events
- * generated by low-level events always have the value true.
- *
- * @see #consume()
- * @see #isConsumed()
- * @serial whether the event has been consumed
- */
- protected boolean consumed;
-
- /**
- * Used for implementing a simple linked list in EventQueue.
- */
- transient AWTEvent queueNext;
-
- /**
- * Who knows? It's in the serial version.
- *
- * @serial No idea what this is for.
- */
- byte[] bdata;
-
- /**
- * Indicates if this event is dispatched by the KeyboardFocusManager.
- */
- boolean isFocusManagerEvent = false;
-
- /** Mask for selecting component events. */
- public static final long COMPONENT_EVENT_MASK = 0x00001;
-
- /** Mask for selecting container events. */
- public static final long CONTAINER_EVENT_MASK = 0x00002;
-
- /** Mask for selecting component focus events. */
- public static final long FOCUS_EVENT_MASK = 0x00004;
-
- /** Mask for selecting keyboard events. */
- public static final long KEY_EVENT_MASK = 0x00008;
-
- /** Mask for mouse button events. */
- public static final long MOUSE_EVENT_MASK = 0x00010;
-
- /** Mask for mouse motion events. */
- public static final long MOUSE_MOTION_EVENT_MASK = 0x00020;
-
- /** Mask for window events. */
- public static final long WINDOW_EVENT_MASK = 0x00040;
-
- /** Mask for action events. */
- public static final long ACTION_EVENT_MASK = 0x00080;
-
- /** Mask for adjustment events. */
- public static final long ADJUSTMENT_EVENT_MASK = 0x00100;
-
- /** Mask for item events. */
- public static final long ITEM_EVENT_MASK = 0x00200;
-
- /** Mask for text events. */
- public static final long TEXT_EVENT_MASK = 0x00400;
-
- /**
- * Mask for input method events.
- * @since 1.3
- */
- public static final long INPUT_METHOD_EVENT_MASK = 0x00800;
-
- /**
- * Mask if input methods are enabled. Package visible only.
- */
- static final long INPUT_ENABLED_EVENT_MASK = 0x01000;
-
- /**
- * Mask for paint events.
- * @since 1.3
- */
- public static final long PAINT_EVENT_MASK = 0x02000;
-
- /**
- * Mask for invocation events.
- * @since 1.3
- */
- public static final long INVOCATION_EVENT_MASK = 0x04000;
-
- /**
- * Mask for hierarchy events.
- * @since 1.3
- */
- public static final long HIERARCHY_EVENT_MASK = 0x08000;
-
- /**
- * Mask for hierarchy bounds events.
- * @since 1.3
- */
- public static final long HIERARCHY_BOUNDS_EVENT_MASK = 0x10000;
-
- /**
- * Mask for mouse wheel events.
- * @since 1.4
- */
- public static final long MOUSE_WHEEL_EVENT_MASK = 0x20000;
-
- /**
- * Mask for window state events.
- * @since 1.4
- */
- public static final long WINDOW_STATE_EVENT_MASK = 0x40000;
-
- /**
- * Mask for window focus events.
- * @since 1.4
- */
- public static final long WINDOW_FOCUS_EVENT_MASK = 0x80000;
-
- /**
- * This is the highest number for event ids that are reserved for use by
- * the AWT system itself. Subclasses outside of java.awt should use higher
- * ids.
- */
- public static final int RESERVED_ID_MAX = 1999;
-
-
- /**
- * Initializes a new AWTEvent from the old Java 1.0 event object.
- *
- * @param event the old-style event
- * @throws NullPointerException if event is null
- */
- public AWTEvent(Event event)
- {
- this(event.target, event.id);
- consumed = event.consumed;
- }
-
- /**
- * Create an event on the specified source object and id.
- *
- * @param source the object that caused the event
- * @param id the event id
- * @throws IllegalArgumentException if source is null
- */
- public AWTEvent(Object source, int id)
- {
- super(source);
- this.id = id;
- }
-
- /**
- * Retarget the event, such as converting a heavyweight component to a
- * lightweight child of the original. This is not for general use, but
- * is for event targeting systems like KeyboardFocusManager.
- *
- * @param source the new source
- */
- public void setSource(Object source)
- {
- this.source = source;
- }
-
- /**
- * Returns the event type id.
- *
- * @return the id number of this event
- */
- public int getID()
- {
- return id;
- }
-
- /**
- * Create a string that represents this event in the format
- * <code>classname[eventstring] on sourcecomponentname</code>.
- *
- * @return a string representing this event
- */
- public String toString ()
- {
- String src;
- if (source instanceof Component)
- src = ((Component) source).getName();
- else if (source instanceof MenuComponent)
- src = ((MenuComponent) source).getName();
- else if (source != null)
- src = source.toString();
- else
- src = "null";
- String string = getClass ().getName () + "[" + paramString () + "] on "
- + src;
- return string;
- }
-
- /**
- * Returns a string representation of the state of this event. It may be
- * empty, but must not be null; it is implementation defined.
- *
- * @return a string representation of this event
- */
- public String paramString()
- {
- return "";
- }
-
- /**
- * Consumes this event so that it will not be processed in the default
- * manner.
- */
- protected void consume()
- {
- consumed = true;
- }
-
- /**
- * Tests whether not not this event has been consumed. A consumed event
- * is not processed in the default manner.
- *
- * @return true if this event has been consumed
- */
- protected boolean isConsumed()
- {
- return consumed;
- }
-
- /**
- * Converts an event id to the appropriate event mask.
- *
- * @param id the event id
- *
- * @return the event mask for the specified id
- */
- static long eventIdToMask(int id)
- {
- long mask = 0;
- switch (id)
- {
- case ActionEvent.ACTION_PERFORMED:
- mask = ACTION_EVENT_MASK;
- break;
- case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
- mask = ADJUSTMENT_EVENT_MASK;
- break;
- case ComponentEvent.COMPONENT_MOVED:
- case ComponentEvent.COMPONENT_RESIZED:
- case ComponentEvent.COMPONENT_SHOWN:
- case ComponentEvent.COMPONENT_HIDDEN:
- mask = COMPONENT_EVENT_MASK;
- break;
- case ContainerEvent.COMPONENT_ADDED:
- case ContainerEvent.COMPONENT_REMOVED:
- mask = CONTAINER_EVENT_MASK;
- break;
- case FocusEvent.FOCUS_GAINED:
- case FocusEvent.FOCUS_LOST:
- mask = FOCUS_EVENT_MASK;
- break;
- case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
- case InputMethodEvent.CARET_POSITION_CHANGED:
- mask = INPUT_METHOD_EVENT_MASK;
- break;
- case InvocationEvent.INVOCATION_DEFAULT:
- mask = INVOCATION_EVENT_MASK;
- break;
- case ItemEvent.ITEM_STATE_CHANGED:
- mask = ITEM_EVENT_MASK;
- break;
- case KeyEvent.KEY_TYPED:
- case KeyEvent.KEY_PRESSED:
- case KeyEvent.KEY_RELEASED:
- mask = KEY_EVENT_MASK;
- break;
- case MouseEvent.MOUSE_CLICKED:
- case MouseEvent.MOUSE_PRESSED:
- case MouseEvent.MOUSE_RELEASED:
- mask = MOUSE_EVENT_MASK;
- break;
- case MouseEvent.MOUSE_MOVED:
- case MouseEvent.MOUSE_ENTERED:
- case MouseEvent.MOUSE_EXITED:
- case MouseEvent.MOUSE_DRAGGED:
- mask = MOUSE_MOTION_EVENT_MASK;
- break;
- case MouseEvent.MOUSE_WHEEL:
- mask = MOUSE_WHEEL_EVENT_MASK;
- break;
- case PaintEvent.PAINT:
- case PaintEvent.UPDATE:
- mask = PAINT_EVENT_MASK;
- break;
- case TextEvent.TEXT_VALUE_CHANGED:
- mask = TEXT_EVENT_MASK;
- break;
- case WindowEvent.WINDOW_OPENED:
- case WindowEvent.WINDOW_CLOSING:
- case WindowEvent.WINDOW_CLOSED:
- case WindowEvent.WINDOW_ICONIFIED:
- case WindowEvent.WINDOW_DEICONIFIED:
- case WindowEvent.WINDOW_ACTIVATED:
- case WindowEvent.WINDOW_DEACTIVATED:
- mask = WINDOW_EVENT_MASK;
- break;
- case WindowEvent.WINDOW_GAINED_FOCUS:
- case WindowEvent.WINDOW_LOST_FOCUS:
- mask = WINDOW_FOCUS_EVENT_MASK;
- break;
- case WindowEvent.WINDOW_STATE_CHANGED:
- mask = WINDOW_STATE_EVENT_MASK;
- break;
- default:
- mask = 0;
- }
- return mask;
- }
-
- //jnode openjdk
-/**
- * Converts a new event to an old one (used for compatibility).
- * If the new event cannot be converted (because no old equivalent
- * exists) then this returns null.
- *
- * Note: this method is here instead of in each individual new
- * event class in java.awt.event because we don't want to make
- * it public and it needs to be called from java.awt.
- */
- Event convertToOld() {
- Object src = getSource();
- int newid = id;
-
- switch(id) {
- case KeyEvent.KEY_PRESSED:
- case KeyEvent.KEY_RELEASED:
- KeyEvent ke = (KeyEvent)this;
- if (ke.isActionKey()) {
- newid = (id == KeyEvent.KEY_PRESSED?
- Event.KEY_ACTION : Event.KEY_ACTION_RELEASE);
- }
- int keyCode = ke.getKeyCode();
- if (keyCode == KeyEvent.VK_SHIFT ||
- keyCode == KeyEvent.VK_CONTROL ||
- keyCode == KeyEvent.VK_ALT) {
- return null; // suppress modifier keys in old event model.
- }
- // no mask for button1 existed in old Event - strip it out
- return new Event(src, ke.getWhen(), newid, 0, 0,
- Event.getOldEventKey(ke),
- (ke.getModifiers() & ~InputEvent.BUTTON1_MASK));
-
- case MouseEvent.MOUSE_PRESSED:
- case MouseEvent.MOUSE_RELEASED:
- case MouseEvent.MOUSE_MOVED:
- case MouseEvent.MOUSE_DRAGGED:
- case MouseEvent.MOUSE_ENTERED:
- case MouseEvent.MOUSE_EXITED:
- MouseEvent me = (MouseEvent)this;
- // no mask for button1 existed in old Event - strip it out
- Event olde = new Event(src, me.getWhen(), newid,
- me.getX(), me.getY(), 0,
- (me.getModifiers() & ~InputEvent.BUTTON1_MASK));
- olde.clickCount = me.getClickCount();
- return olde;
-
- case FocusEvent.FOCUS_GAINED:
- return new Event(src, Event.GOT_FOCUS, null);
-
- case FocusEvent.FOCUS_LOST:
- return new Event(src, Event.LOST_FOCUS, null);
-
- case WindowEvent.WINDOW_CLOSING:
- case WindowEvent.WINDOW_ICONIFIED:
- case WindowEvent.WINDOW_DEICONIFIED:
- return new Event(src, newid, null);
-
- case ComponentEvent.COMPONENT_MOVED:
- if (src instanceof Frame || src instanceof Dialog) {
- Point p = ((Component)src).getLocation();
- return new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0);
- }
- break;
-
- case ActionEvent.ACTION_PERFORMED:
- ActionEvent ae = (ActionEvent)this;
- String cmd;
- if (src instanceof Button) {
- cmd = ((Button)src).getLabel();
- } else if (src instanceof MenuItem) {
- cmd = ((MenuItem)src).getLabel();
- } else {
- cmd = ae.getActionCommand();
- }
- return new Event(src, 0, newid, 0, 0, 0, ae.getModifiers(), cmd);
-
- case ItemEvent.ITEM_STATE_CHANGED:
- ItemEvent ie = (ItemEvent)this;
- Object arg;
- if (src instanceof List) {
- newid = (ie.getStateChange() == ItemEvent.SELECTED?
- Event.LIST_SELECT : Event.LIST_DESELECT);
- arg = ie.getItem();
- } else {
- newid = Event.ACTION_EVENT;
- if (src instanceof Choice) {
- arg = ie.getItem();
-
- } else { // Checkbox
- arg = Boolean.valueOf(ie.getStateChange() == ItemEvent.SELECTED);
- }
- }
- return new Event(src, newid, arg);
-
- case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
- AdjustmentEvent aje = (AdjustmentEvent)this;
- switch(aje.getAdjustmentType()) {
- case AdjustmentEvent.UNIT_INCREMENT:
- newid = Event.SCROLL_LINE_DOWN;
- break;
- case AdjustmentEvent.UNIT_DECREMENT:
- newid = Event.SCROLL_LINE_UP;
- break;
- case AdjustmentEvent.BLOCK_INCREMENT:
- newid = Event.SCROLL_PAGE_DOWN;
- break;
- case AdjustmentEvent.BLOCK_DECREMENT:
- newid = Event.SCROLL_PAGE_UP;
- break;
- case AdjustmentEvent.TRACK:
- if (aje.getValueIsAdjusting()) {
- newid = Event.SCROLL_ABSOLUTE;
- }
- else {
- newid = Event.SCROLL_END;
- }
- break;
- default:
- return null;
- }
- return new Event(src, newid, Integer.valueOf(aje.getValue()));
-
- default:
- }
- return null;
- }
- /**
- * The pseudo event mask for enabling input methods.
- * We're using one bit in the eventMask so we don't need
- * a separate field inputMethodsEnabled.
- */
- final static long INPUT_METHODS_ENABLED_MASK = 0x1000;
-
- /**
- * Copies all private data from this event into that.
- * Space is allocated for the copied data that will be
- * freed when the that is finalized. Upon completion,
- * this event is not changed.
- */
- void copyPrivateDataInto(AWTEvent that) {
- that.bdata = this.bdata;
- // Copy canAccessSystemClipboard value from this into that.
- if (this instanceof InputEvent && that instanceof InputEvent) {
- Field field = get_InputEvent_CanAccessSystemClipboard();
- if (field != null) {
- try {
- boolean b = field.getBoolean(this);
- field.setBoolean(that, b);
- } catch(IllegalAccessException e) {
- }
- }
- }
- }
-
- private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
- if (inputEvent_CanAccessSystemClipboard_Field == null) {
- inputEvent_CanAccessSystemClipboard_Field =
- (Field)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- Field field = null;
- try {
- field = InputEvent.class.
- getDeclaredField("canAccessSystemClipboard");
- field.setAccessible(true);
- return field;
- } catch (SecurityException e) {
- } catch (NoSuchFieldException e) {
- }
- return null;
- }
- });
- }
-
- return inputEvent_CanAccessSystemClipboard_Field;
- }
- // security stuff
- private static Field inputEvent_CanAccessSystemClipboard_Field = null;
-} // class AWTEvent
Deleted: trunk/core/src/classpath/java/java/awt/Component.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Component.java 2008-03-16 13:55:01 UTC (rev 3844)
+++ trunk/core/src/classpath/java/java/awt/Component.java 2008-03-16 20:00:41 UTC (rev 3845)
@@ -1,7928 +0,0 @@
-/* Component.java -- a graphics component
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006
- Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.awt;
-
-//import gnu.java.awt.dnd.peer.gtk.GtkDropTargetContextPeer;
-
-import java.awt.dnd.DropTarget;
-import java.awt.event.*;
-import java.awt.im.InputContext;
-import java.awt.im.InputMethodRequests;
-import java.awt.image.BufferStrategy;
-import java.awt.image.ColorModel;
-import java.awt.image.ImageObserver;
-import java.awt.image.ImageProducer;
-import java.awt.image.VolatileImage;
-import java.awt.peer.ComponentPeer;
-import java.awt.peer.LightweightPeer;
-import java.awt.peer.ContainerPeer;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.Collections;
-import java.util.EventListener;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Set;
-import java.util.Vector;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleComponent;
-import javax.accessibility.AccessibleContext;
-import javax.accessibility.AccessibleRole;
-import javax.accessibility.AccessibleState;
-import javax.accessibility.AccessibleStateSet;
-import sun.awt.*;
-import sun.awt.im.CompositionArea;
-import sun.awt.dnd.SunDropTargetEvent;
-import sun.java2d.SunGraphics2D;
-
-/**
- * The root of all evil. All graphical representations are subclasses of this
- * giant class, which is designed for screen display and user interaction.
- * This class can be extended directly to build a lightweight component (one
- * not associated with a native window); lightweight components must reside
- * inside a heavyweight window.
- *
- * <p>This class is Serializable, which has some big implications. A user can
- * save the state of all graphical components in one VM, and reload them in
- * another. Note that this class will only save Serializable listeners, and
- * ignore the rest, without causing any serialization exceptions. However, by
- * making a listener serializable, and adding it to another element, you link
- * in that entire element to the state of this component. To get around this,
- * use the idiom shown in the example below - make listeners non-serializable
- * in inner classes, rather than using this object itself as the listener, if
- * external objects do not need to save the state of this object.
- *
- * <pre>
- * import java.awt.*;
- * import java.awt.event.*;
- * import java.io.Serializable;
- * class MyApp implements Serializable
- * {
- * BigObjectThatShouldNotBeSerializedWithAButton bigOne;
- * // Serializing aButton will not suck in an instance of MyApp, with its
- * // accompanying field bigOne.
- * Button aButton = new Button();
- * class MyActionListener implements ActionListener
- * {
- * public void actionPerformed(ActionEvent e)
- * {
- * System.out.println("Hello There");
- * }
- * }
- * MyApp()
- * {
- * aButton.addActionListener(new MyActionListener());
- * }
- * }
- * </pre>
- *
- * <p>Status: Incomplete. The event dispatch mechanism is implemented. All
- * other methods defined in the J2SE 1.3 API javadoc exist, but are mostly
- * incomplete or only stubs; except for methods relating to the Drag and
- * Drop, Input Method, and Accessibility frameworks: These methods are
- * present but commented out.
- *
- * @author original author unknown
- * @author Eric Blake (eb...@em...)
- * @since 1.0
- * @status still missing 1.4 support
- */
-public abstract class Component
- implements ImageObserver, MenuContainer, Serializable
-{
- // Word to the wise - this file is huge. Search for '\f' (^L) for logical
- // sectioning by fields, public API, private API, and nested classes.
-
-
- /**
- * Compatible with JDK 1.0+.
- */
- private static final long serialVersionUID = -7644114512714619750L;
-
- /**
- * Constant returned by the <code>getAlignmentY</code> method to indicate
- * that the component wishes to be aligned to the top relative to
- * other components.
- *
- * @see #getAlignmentY()
- */
- public static final float TOP_ALIGNMENT = 0;
-
- /**
- * Constant returned by the <code>getAlignmentY</code> and
- * <code>getAlignmentX</code> methods to indicate
- * that the component wishes to be aligned to the center relative to
- * other components.
- *
- * @see #getAlignmentX()
- * @see #getAlignmentY()
- */
- public static final float CENTER_ALIGNMENT = 0.5f;
-
- /**
- * Constant returned by the <code>getAlignmentY</code> method to indicate
- * that the component wishes to be aligned to the bottom relative to
- * other components.
- *
- * @see #getAlignmentY()
- */
- public static final float BOTTOM_ALIGNMENT = 1;
-
- /**
- * Constant returned by the <code>getAlignmentX</code> method to indicate
- * that the component wishes to be aligned to the right relative to
- * other components.
- *
- * @see #getAlignmentX()
- */
- public static final float RIGHT_ALIGNMENT = 1;
-
- /**
- * Constant returned by the <code>getAlignmentX</code> method to indicate
- * that the component wishes to be aligned to the left relative to
- * other components.
- *
- * @see #getAlignmentX()
- */
- public static final float LEFT_ALIGNMENT = 0;
-
- /**
- * Make the treelock a String so that it can easily be identified
- * in debug dumps. We clone the String in order to avoid a conflict in
- * the unlikely event that some other package uses exactly the same string
- * as a lock object.
- */
- static final Object LOCK = new String("AWT_TREE_LOCK");
-
- /**
- * The default maximum size.
- */
- private static final Dimension DEFAULT_MAX_SIZE
- = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
-
- // Serialized fields from the serialization spec.
-
- /**
- * The x position of the component in the parent's coordinate system.
- *
- * @see #getLocation()
- * @serial the x position
- */
- int x;
-
- /**
- * The y position of the component in the parent's coordinate system.
- *
- * @see #getLocation()
- * @serial the y position
- */
- int y;
-
- /**
- * The component width.
- *
- * @see #getSize()
- * @serial the width
- */
- int width;
-
- /**
- * The component height.
- *
- * @see #getSize()
- * @serial the height
- */
- int height;
-
- /**
- * The foreground color for the component. This may be null.
- *
- * @see #getForeground()
- * @see #setForeground(Color)
- * @serial the foreground color
- */
- Color foreground;
-
- /**
- * The background color for the component. This may be null.
- *
- * @see #getBackground()
- * @see #setBackground(Color)
- * @serial the background color
- */
- Color background;
-
- /**
- * The default font used in the component. This may be null.
- *
- * @see #getFont()
- * @see #setFont(Font)
- * @serial the font
- */
- Font font;
-
- /**
- * The font in use by the peer, or null if there is no peer.
- *
- * @serial the peer's font
- */
- Font peerFont;
-
- /**
- * The cursor displayed when the pointer is over this component. This may
- * be null.
- *
- * @see #getCursor()
- * @see #setCursor(Cursor)
- */
- Cursor cursor;
-
- /**
- * The locale for the component.
- *
- * @see #getLocale()
- * @see #setLocale(Locale)
- */
- Locale locale = Locale.getDefault ();
-
- /**
- * True if the object should ignore repaint events (usually because it is
- * not showing).
- *
- * @see #getIgnoreRepaint()
- * @see #setIgnoreRepaint(boolean)
- * @serial true to ignore repaints
- * @since 1.4
- */
- boolean ignoreRepaint;
-
- /**
- * True when the object is visible (although it is only showing if all
- * ancestors are likewise visible). For component, this defaults to true.
- *
- * @see #isVisible()
- * @see #setVisible(boolean)
- * @serial true if visible
- */
- boolean visible = true;
-
- /**
- * True if the object is enabled, meaning it can interact with the user.
- * For component, this defaults to true.
- *
- * @see #isEnabled()
- * @see #setEnabled(boolean)
- * @serial true if enabled
- */
- boolean ena...
[truncated message content] |
|
From: <ls...@us...> - 2008-03-16 20:25:31
|
Revision: 3856
http://jnode.svn.sourceforge.net/jnode/?rev=3856&view=rev
Author: lsantha
Date: 2008-03-16 13:25:30 -0700 (Sun, 16 Mar 2008)
Log Message:
-----------
OpenJDK AWT & Swing integration.
Removed Paths:
-------------
trunk/core/src/classpath/java/java/awt/Event.java
trunk/core/src/classpath/java/java/awt/EventDispatchThread.java
trunk/core/src/classpath/java/java/awt/EventQueue.java
trunk/core/src/classpath/java/java/awt/KeyboardFocusManager.java
Deleted: trunk/core/src/classpath/java/java/awt/Event.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/Event.java 2008-03-16 20:23:32 UTC (rev 3855)
+++ trunk/core/src/classpath/java/java/awt/Event.java 2008-03-16 20:25:30 UTC (rev 3856)
@@ -1,263 +0,0 @@
-/* Copyright (C) 1999, 2000, 2002 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.awt;
-
-import java.awt.event.KeyEvent;
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status: Believed complete and correct.
- */
-
-public class Event implements java.io.Serializable
-{
- static final long serialVersionUID = 5488922509400504703L;
-
- public static final int SHIFT_MASK = 1;
- public static final int CTRL_MASK = 2;
- public static final int META_MASK = 4;
- public static final int ALT_MASK = 8;
-
- public static final int ACTION_EVENT = 1001;
- public static final int BACK_SPACE = 8;
- public static final int CAPS_LOCK = 1022;
- public static final int DELETE = 127;
- public static final int DOWN = 1005;
- public static final int END = 1001;
- public static final int ENTER = 10;
- public static final int ESCAPE = 27;
- public static final int F1 = 1008;
- public static final int F10 = 1017;
- public static final int F11 = 1018;
- public static final int F12 = 1019;
- public static final int F2 = 1009;
- public static final int F3 = 1010;
- public static final int F4 = 1011;
- public static final int F5 = 1012;
- public static final int F6 = 1013;
- public static final int F7 = 1014;
- public static final int F8 = 1015;
- public static final int F9 = 1016;
- public static final int GOT_FOCUS = 1004;
- public static final int HOME = 1000;
- public static final int INSERT = 1025;
- public static final int KEY_ACTION = 403;
- public static final int KEY_ACTION_RELEASE = 404;
- public static final int KEY_PRESS = 401;
- public static final int KEY_RELEASE = 402;
- public static final int LEFT = 1006;
- public static final int LIST_DESELECT = 702;
- public static final int LIST_SELECT = 701;
- public static final int LOAD_FILE = 1002;
- public static final int LOST_FOCUS = 1005;
- public static final int MOUSE_DOWN = 501;
- public static final int MOUSE_DRAG = 506;
- public static final int MOUSE_ENTER = 504;
- public static final int MOUSE_EXIT = 505;
- public static final int MOUSE_MOVE = 503;
- public static final int MOUSE_UP = 502;
- public static final int NUM_LOCK = 1023;
- public static final int PAUSE = 1024;
- public static final int PGDN = 1003;
- public static final int PGUP = 1002;
- public static final int PRINT_SCREEN = 1020;
- public static final int RIGHT = 1007;
- public static final int SAVE_FILE = 1003;
- public static final int SCROLL_ABSOLUTE = 605;
- public static final int SCROLL_BEGIN = 606;
- public static final int SCROLL_END = 607;
- public static final int SCROLL_LINE_DOWN = 602;
- public static final int SCROLL_LINE_UP = 601;
- public static final int SCROLL_LOCK = 1021;
- public static final int SCROLL_PAGE_DOWN = 604;
- public static final int SCROLL_PAGE_UP = 603;
- public static final int TAB = 9;
- public static final int UP = 1004;
- public static final int WINDOW_DEICONIFY = 204;
- public static final int WINDOW_DESTROY = 201;
- public static final int WINDOW_EXPOSE = 202;
- public static final int WINDOW_ICONIFY = 203;
- public static final int WINDOW_MOVED = 205;
-
- public Object arg;
- public int clickCount;
- boolean consumed; // Required by serialization spec.
- public Event evt;
- public int id;
- public int key;
- public int modifiers;
- public Object target;
- public long when;
- public int x;
- public int y;
-
- public Event (Object target, int id, Object arg)
- {
- this.id = id;
- this.target = target;
- this.arg = arg;
- }
-
- public Event (Object target, long when, int id, int x, int y, int key,
- int modifiers)
- {
- this.target = target;
- this.when = when;
- this.id = id;
- this.x = x;
- this.y = y;
- this.key = key;
- this.modifiers = modifiers;
- }
-
- public Event (Object target, long when, int id, int x, int y, int key,
- int modifiers, Object arg)
- {
- this (target, when, id, x, y, key, modifiers);
- this.arg = arg;
- }
-
- public boolean controlDown ()
- {
- return ((modifiers & CTRL_MASK) == 0 ? false : true);
- }
-
- public boolean metaDown ()
- {
- return ((modifiers & META_MASK) == 0 ? false : true);
- }
-
- protected String paramString ()
- {
- return "id=" + id + ",x=" + x + ",y=" + y
- + ",target=" + target + ",arg=" + arg;
- }
-
- public boolean shiftDown()
- {
- return ((modifiers & SHIFT_MASK) == 0 ? false : true);
- }
-
- public String toString()
- {
- return getClass().getName() + "[" + paramString() + "]";
- }
-
- public void translate (int x, int y)
- {
- this.x += x;
- this.y += y;
- }
-
- //jnode openjdk
-/*
- * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
- * available only for backwards compatilibility. It has been replaced
- * by the <code>AWTEvent</code> class and its subclasses.
- * <p>
- * Returns the integer key-code associated with the key in this event,
- * as described in java.awt.Event.
- */
-static int getOldEventKey(KeyEvent e) {
- int keyCode = e.getKeyCode();
- for (int i = 0; i < actionKeyCodes.length; i++) {
- if (actionKeyCodes[i][0] == keyCode) {
- return actionKeyCodes[i][1];
- }
- }
- return (int)e.getKeyChar();
-}
-
-/* table for mapping old Event action keys to KeyEvent virtual keys. */
-private static final int actionKeyCodes[][] = {
-/* virtual key action key */
- { KeyEvent.VK_HOME, Event.HOME },
- { KeyEvent.VK_END, Event.END },
- { KeyEvent.VK_PAGE_UP, Event.PGUP },
- { KeyEvent.VK_PAGE_DOWN, Event.PGDN },
- { KeyEvent.VK_UP, Event.UP },
- { KeyEvent.VK_DOWN, Event.DOWN },
- { KeyEvent.VK_LEFT, Event.LEFT },
- { KeyEvent.VK_RIGHT, Event.RIGHT },
- { KeyEvent.VK_F1, Event.F1 },
- { KeyEvent.VK_F2, Event.F2 },
- { KeyEvent.VK_F3, Event.F3 },
- { KeyEvent.VK_F4, Event.F4 },
- { KeyEvent.VK_F5, Event.F5 },
- { KeyEvent.VK_F6, Event.F6 },
- { KeyEvent.VK_F7, Event.F7 },
- { KeyEvent.VK_F8, Event.F8 },
- { KeyEvent.VK_F9, Event.F9 },
- { KeyEvent.VK_F10, Event.F10 },
- { KeyEvent.VK_F11, Event.F11 },
- { KeyEvent.VK_F12, Event.F12 },
- { KeyEvent.VK_PRINTSCREEN, Event.PRINT_SCREEN },
- { KeyEvent.VK_SCROLL_LOCK, Event.SCROLL_LOCK },
- { KeyEvent.VK_CAPS_LOCK, Event.CAPS_LOCK },
- { KeyEvent.VK_NUM_LOCK, Event.NUM_LOCK },
- { KeyEvent.VK_PAUSE, Event.PAUSE },
- { KeyEvent.VK_INSERT, Event.INSERT }
-};
-
- /*
- * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
- * available only for backwards compatilibility. It has been replaced
- * by the <code>AWTEvent</code> class and its subclasses.
- * <p>
- * Returns a new KeyEvent char which corresponds to the int key
- * of this old event.
- */
- char getKeyEventChar() {
- for (int i = 0; i < actionKeyCodes.length; i++) {
- if (actionKeyCodes[i][1] == key) {
- return KeyEvent.CHAR_UNDEFINED;
- }
- }
- return (char)key;
- }
-
- /**
- * <b>NOTE:</b> The <code>Event</code> class is obsolete and is
- * available only for backwards compatilibility. It has been replaced
- * by the <code>AWTEvent</code> class and its subclasses.
- */
- boolean isConsumed() {
- return consumed;
- }
-}
Deleted: trunk/core/src/classpath/java/java/awt/EventDispatchThread.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/EventDispatchThread.java 2008-03-16 20:23:32 UTC (rev 3855)
+++ trunk/core/src/classpath/java/java/awt/EventDispatchThread.java 2008-03-16 20:25:30 UTC (rev 3856)
@@ -1,117 +0,0 @@
-/* EventDispatchThread.java -
- Copyright (C) 2000, 2002, 2004 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.awt;
-
-/**
- * @author Bryce McKinlay
- * @status believed complete, but untested.
- */
-class EventDispatchThread extends Thread
-{
- /**
- * The default priority when no property has been set.
- */
- private static final int DEFAULT_PRIORITY = NORM_PRIORITY + 1;
-
- private static int dispatchThreadNum;
-
- private EventQueue queue;
-
- EventDispatchThread(EventQueue queue)
- {
- super();
- setName("AWT-EventQueue-" + ++dispatchThreadNum);
- this.queue = queue;
-
- int priority = DEFAULT_PRIORITY;
- try
- {
- String priorityString =
- System.getProperty("gnu.awt.dispatchthread.priority");
- if (priorityString != null)
- {
- priority = Integer.parseInt(priorityString);
- }
- }
- catch (NumberFormatException ex)
- {
- // Ignore and use default.
- }
- setPriority(priority);
-
- // Make sure that an event dispatch thread is never a daemon thread.
- setDaemon(false);
- }
-
- public void run()
- {
- while (true)
- {
- try
- {
- AWTEvent evt = queue.getNextEvent();
-
- KeyboardFocusManager manager;
- manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
-
- // Try to dispatch this event to the current keyboard focus
- // manager. It will dispatch all FocusEvents, all
- // WindowEvents related to focus, and all KeyEvents,
- // returning true. Otherwise, it returns false and we
- // dispatch the event normally.
- if (!manager.dispatchEvent (evt))
- queue.dispatchEvent(evt);
- }
- catch (ThreadDeath death)
- {
- // If someone wants to kill us, let them.
- return;
- }
- catch (InterruptedException ie)
- {
- // We are interrupted when we should finish executing
- return;
- }
- catch (Throwable x)
- {
- System.err.println("Exception during event dispatch:");
- x.printStackTrace(System.err);
- }
- }
- }
-}
Deleted: trunk/core/src/classpath/java/java/awt/EventQueue.java
===================================================================
--- trunk/core/src/classpath/java/java/awt/EventQueue.java 2008-03-16 20:23:32 UTC (rev 3855)
+++ trunk/core/src/classpath/java/java/awt/EventQueue.java 2008-03-16 20:25:30 UTC (rev 3856)
@@ -1,759 +0,0 @@
-/* EventQueue.java --
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.awt;
-
-import gnu.java.awt.LowPriorityEvent;
-import gnu.java.awt.peer.NativeEventLoopRunningEvent;
-
-import java.awt.event.*;
-import java.awt.peer.ComponentPeer;
-import java.awt.peer.LightweightPeer;
-import java.lang.reflect.InvocationTargetException;
-import java.util.EmptyStackException;
-
-/* Written using on-line Java 2 Platform Standard Edition v1.3 API
- * Specification, as well as "The Java Class Libraries", 2nd edition
- * (Addison-Wesley, 1998).
- * Status: Believed complete, but untested.
- */
-
-/**
- * This class manages a queue of <code>AWTEvent</code> objects that
- * are posted to it. The AWT system uses only one event queue for all
- * events.
- *
- * @author Bryce McKinlay
- * @author Aaron M. Renn (ar...@ur...)
- */
-public class EventQueue
-{
- /**
- * Indicates events that are processed with normal priority. This is normally
- * all events except PaintEvents.
- */
- private static final int NORM_PRIORITY = 0;
-
- /**
- * Indicates events that are processed with lowes priority. This is normally
- * all PaintEvents and LowPriorityEvents.
- */
- private static final int LOW_PRIORITY = 1;
-
- /**
- * Implements the actual queue. EventQueue has 2 internal queues for
- * different priorities:
- * 1 PaintEvents are always dispatched with low priority.
- * 2. All other events are dispatched with normal priority.
- *
- * This makes sure that the actual painting (output) is performed _after_ all
- * available input has been processed and that the paint regions are
- * coalesced as much as possible.
- */
- private class Queue
- {
- /**
- * The first item in the queue. This is where events are popped from.
- */
- AWTEvent queueHead;
-
- /**
- * The last item. This is where events are posted to.
- */
- AWTEvent queueTail;
- }
-
- /**
- * The three internal event queues.
- *
- * @see Queue
- */
- private Queue[] queues;
-
- private EventQueue next;
- private EventQueue prev;
- private AWTEvent currentEvent;
- private long lastWhen = System.currentTimeMillis();
-
- private EventDispatchThread dispatchThread = new EventDispatchThread(this);
- private boolean nativeLoopRunning = false;
- private boolean shutdown = false;
-
- // @vm-specific allow JNode access from VMAwtAPI
- synchronized void setShutdown (boolean b)
- //synchronized private void setShutdown (boolean b)
- {
- 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
-
- 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;
- }
-
- /**
- * Initializes a new instance of <code>EventQueue</code>.
- */
- public EventQueue()
- {
- queues = new Queue[2];
- queues[NORM_PRIORITY] = new Queue();
- queues[LOW_PRIORITY] = new Queue();
- }
-
- /**
- * Returns the next event in the queue. This method will block until
- * an event is available or until the thread is interrupted.
- *
- * @return The next event in the queue.
- *
- * @exception InterruptedException If this thread is interrupted while
- * waiting for an event to be posted to the queue.
- */
- public synchronized AWTEvent getNextEvent()
- throws InterruptedException
- {
- if (next != null)
- return next.getNextEvent();
-
- AWTEvent res = getNextEventImpl(true);
-
- while (res == null)
- {
- if (isShutdown())
- {
- // 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);
- }
-
- return res;
- }
-
- /**
- * Fetches and possibly removes the next event from the internal queues.
- * This method returns immediately. When all queues are empty, this returns
- * <code>null</code>:
- *
- * @param remove <true> when the event should be removed from the queue,
- * <code>false</code> otherwise
- *
- * @return the next event or <code>null</code> when all internal queues
- * are empty
- */
- private AWTEvent getNextEventImpl(boolean remove)
- {
- AWTEvent next = null;
- for (int i = 0; i < queues.length && next == null; i++)
- {
- Queue q = queues[i];
- if (q.queueHead != null)
- {
- // Got an event, remove it.
- next = q.queueHead;
- if (remove)
- {
- // Unlink event from the queue.
- q.queueHead = next.queueNext;
- if (q.queueHead == null)
- q.queueTail = null;
- next.queueNext = null;
- }
- }
- }
- return next;
- }
-
- /**
- * Returns the next event in the queue without removing it from the queue.
- * This method will block until an event is available or until the thread
- * is interrupted.
- *
- * @return The next event in the queue.
- * @specnote Does not block. Returns null if there are no events on the
- * queue.
- */
- public synchronized AWTEvent peekEvent()
- {
- if (next != null)
- return next.peekEvent();
-
- return getNextEventImpl(false);
- }
-
- /**
- * Returns the next event in the queue that has the specified id
- * without removing it from the queue.
- * This method will block until an event is available or until the thread
- * is interrupted.
- *
- * @param id The event id to return.
- *
- * @return The next event in the queue.
- *
- * @specnote Does not block. Returns null if there are no matching events
- * on the queue.
- */
- public synchronized AWTEvent peekEvent(int id)
- {
- if (next != null)
- return next.peekEvent(id);
-
- AWTEvent evt = null;
- for (int i = 0; i < queues.length && evt == null; i++)
- {
- Queue q = queues[i];
- evt = q.queueHead;
- while (evt != null && evt.id != id)
- evt = evt.queueNext;
- // At this point we either have found an event (evt != null -> exit
- // for loop), or we have found no event (evt == null -> search next
- // internal queue).
- }
- return evt;
- }
-
- /**
- * Posts a new event to the queue.
- *
- * @param evt The event to post to the queue.
- *
- * @exception NullPointerException If event is null.
- */
- public void postEvent(AWTEvent evt)
- {
- postEventImpl(evt);
- }
-
- /**
- * Sorts events to their priority and calls
- * {@link #postEventImpl(AWTEvent, int)}.
- *
- * @param evt the event to post
- */
- private synchronized final void postEventImpl(AWTEvent evt)
- {
- int priority = NORM_PRIORITY;
- if (evt instanceof PaintEvent || evt instanceof LowPriorityEvent)
- 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);
- }
-
- /**
- * Actually performs the event posting. This is needed because the
- * RI doesn't use the public postEvent() method when transferring events
- * between event queues in push() and pop().
- *
- * @param evt the event to post
- * @param priority the priority of the event
- */
- private final void postEventImpl(AWTEvent evt, int priority)
- {
- if (evt == null)
- throw new NullPointerException();
-
- if (next != null)
- {
- next.postEvent(evt);
- return;
- }
-
- Object source = evt.getSource();
-
- Queue q = queues[priority];
- if (source instanceof Component)
- {
- // For PaintEvents, ask the ComponentPeer to coalesce the event
- // when the component is heavyweight.
- Component comp = (Component) source;
- ComponentPeer peer = comp.peer;
- if (peer != null && evt instanceof PaintEvent
- && ! (peer instanceof LightweightPeer))
- peer.coalescePaintEvent((PaintEvent) evt);
-
- // Check for any events already on the queue with the same source
- // and ID.
- AWTEvent previous = null;
- for (AWTEvent qevt = q.queueHead; qevt != null; qevt = qevt.queueNext)
- {
- Object src = qevt.getSource();
- if (qevt.id == evt.id && src == comp)
- {
- // If there are, call coalesceEvents on the source component
- // to see if they can be combined.
- Component srccmp = (Component) src;
- AWTEvent coalescedEvt = srccmp.coalesceEvents(qevt, evt);
- if (coalescedEvt != null)
- {
- // Yes. Replace the existing event with the combined event.
- if (qevt != coalescedEvt)
- {
- if (previous != null)
- {
- assert previous.queueNext == qevt;
- previous.queueNext = coalescedEvt;
- }
- else
- {
- assert q.queueHead == qevt;
- q.queueHead = coalescedEvt;
- }
- coalescedEvt.queueNext = qevt.queueNext;
- if (q.queueTail == qevt)
- q.queueTail = coalescedEvt;
- qevt.queueNext = null;
- }
- return;
- }
- }
- previous = qevt;
- }
- }
-
- if (q.queueHead == null)
- {
- // We have an empty queue. Set this event both as head and as tail.
- q.queueHead = evt;
- q.queueTail = evt;
- }
- else
- {
- // Note: queueTail should not be null here.
- q.queueTail.queueNext = evt;
- q.queueTail = evt;
- }
-
- if (dispatchThread == null || !dispatchThread.isAlive())
- {
- dispatchThread = new EventDispatchThread(this);
- dispatchThread.start();
- }
-
- notify();
- }
-
- /**
- * Causes runnable to have its run method called in the dispatch thread of the
- * EventQueue. This will happen after all pending events are processed. The
- * call blocks until this has happened. This method will throw an Error if
- * called from the event dispatcher thread.
- *
- * @exception InterruptedException If another thread has interrupted
- * this thread.
- * @exception InvocationTargetException If an exception is thrown when running
- * runnable.
- *
- * @since 1.2
- */
- public static void invokeAndWait(Runnable runnable)
- throws InterruptedException, InvocationTargetException
- {
- if (isDispatchThread ())
- throw new Error("Can't call invokeAndWait from event dispatch thread");
-
- EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- Object notifyObject = new Object();
-
- InvocationEvent ie =
- new InvocationEvent(eq, runnable, notifyObject, true);
-
- synchronized (notifyObject)
- {
- eq.postEvent(ie);
- notifyObject.wait();
- }
-
- Exception exception;
-
- if ((exception = ie.getException()) != null)
- throw new InvocationTargetException(exception);
- }
-
- /**
- * This arranges for runnable to have its run method called in the
- * dispatch thread of the EventQueue. This will happen after all
- * pending events are processed.
- *
- * @since 1.2
- */
- public static void invokeLater(Runnable runnable)
- {
- EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
-
- InvocationEvent ie =
- new InvocationEvent(eq, runnable, null, false);
-
- eq.postEvent(ie);
- }
-
- /**
- * Return true if the current thread is the current AWT event dispatch
- * thread.
- */
- public static boolean isDispatchThread()
- {
- EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
-
- /* Find last EventQueue in chain */
- while (eq.next != null)
- eq = eq.next;
-
- return (Thread.currentThread() == eq.dispatchThread);
- }
-
- /**
- * Return the event currently being dispatched by the event
- * dispatch thread. If the current thread is not the event
- * dispatch thread, this method returns null.
- *
- * @since 1.4
- */
- public static AWTEvent getCurrentEvent()
- {
- EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- Thread ct = Thread.currentThread();
-
- /* Find out if this t...
[truncated message content] |
|
From: <ls...@us...> - 2008-03-24 18:56:00
|
Revision: 3870
http://jnode.svn.sourceforge.net/jnode/?rev=3870&view=rev
Author: lsantha
Date: 2008-03-24 11:55:57 -0700 (Mon, 24 Mar 2008)
Log Message:
-----------
OpenJDK integration.
Removed Paths:
-------------
trunk/core/src/classpath/java/java/awt/color/
trunk/core/src/classpath/java/java/awt/image/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|