Imported Classpath 0.18.

* sources.am, Makefile.in: Updated.
	* Makefile.am (nat_source_files): Removed natProxy.cc.
	* java/lang/reflect/natProxy.cc: Removed.
	* gnu/classpath/jdwp/VMFrame.java,
	gnu/classpath/jdwp/VMIdManager.java,
	gnu/classpath/jdwp/VMVirtualMachine.java,
	java/lang/reflect/VMProxy.java: New files.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC
	list.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/net/DefaultContentHandlerFactory.java (getContent):
	Remove ClasspathToolkit references.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/awt/xlib/XCanvasPeer.java: Add new peer methods.
	* gnu/awt/xlib/XFramePeer.java: Likewise.
	* gnu/awt/xlib/XGraphicsConfiguration.java: Likewise.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c.  Add
	classpath/native/jawt/jawt.c.
	* Makefile.in: Regenerate.
	* jawt.c: Remove file.
	* include/Makefile.am (tool_include__HEADERS): Remove jawt.h and
	jawt_md.h.  Add ../classpath/include/jawt.h and
	../classpath/include/jawt_md.h.
	* include/Makefile.in: Regenerate.
	* include/jawt.h: Regenerate.
	* include/jawt_md.h: Regenerate.

From-SVN: r104586
This commit is contained in:
Tom Tromey 2005-09-23 21:31:04 +00:00
parent 9b044d1951
commit 1ea63ef8be
544 changed files with 34724 additions and 14512 deletions

View file

@ -412,13 +412,25 @@ public class AWTKeyStroke implements Serializable
{
token = t.nextToken();
if ("shift".equals(token))
modifiers |= KeyEvent.SHIFT_DOWN_MASK;
{
modifiers |= KeyEvent.SHIFT_MASK;
modifiers |= KeyEvent.SHIFT_DOWN_MASK;
}
else if ("ctrl".equals(token) || "control".equals(token))
modifiers |= KeyEvent.CTRL_DOWN_MASK;
{
modifiers |= KeyEvent.CTRL_MASK;
modifiers |= KeyEvent.CTRL_DOWN_MASK;
}
else if ("meta".equals(token))
modifiers |= KeyEvent.META_DOWN_MASK;
{
modifiers |= KeyEvent.META_MASK;
modifiers |= KeyEvent.META_DOWN_MASK;
}
else if ("alt".equals(token))
modifiers |= KeyEvent.ALT_DOWN_MASK;
{
modifiers |= KeyEvent.ALT_MASK;
modifiers |= KeyEvent.ALT_DOWN_MASK;
}
else if ("button1".equals(token))
modifiers |= KeyEvent.BUTTON1_DOWN_MASK;
else if ("button2".equals(token))

File diff suppressed because it is too large Load diff

View file

@ -897,9 +897,21 @@ public abstract class Component
if(!isVisible())
{
this.visible = true;
if (peer != null)
peer.setVisible(true);
invalidate();
// Avoid NullPointerExceptions by creating a local reference.
ComponentPeer currentPeer=peer;
if (currentPeer != null)
currentPeer.setVisible(true);
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
{
currentParent.invalidate();
currentParent.repaint();
}
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
getToolkit().getSystemEventQueue().postEvent(ce);
@ -930,10 +942,23 @@ public abstract class Component
{
if (isVisible())
{
if (peer != null)
peer.setVisible(false);
// Avoid NullPointerExceptions by creating a local reference.
ComponentPeer currentPeer=peer;
if (currentPeer != null)
currentPeer.setVisible(false);
this.visible = false;
invalidate();
// Invalidate the parent if we have one. The component itself must
// not be invalidated. We also avoid NullPointerException with
// a local reference here.
Container currentParent = parent;
if (currentParent != null)
{
currentParent.invalidate();
currentParent.repaint();
}
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
getToolkit().getSystemEventQueue().postEvent(ce);
@ -963,10 +988,12 @@ public abstract class Component
*/
public void setForeground(Color c)
{
firePropertyChange("foreground", foreground, c);
if (peer != null)
peer.setForeground(c);
Color previous = foreground;
foreground = c;
firePropertyChange("foreground", previous, c);
}
/**
@ -992,7 +1019,7 @@ public abstract class Component
{
if (background != null)
return background;
return parent == null ? SystemColor.window : parent.getBackground();
return parent == null ? null : parent.getBackground();
}
/**
@ -1006,16 +1033,18 @@ public abstract class Component
public void setBackground(Color c)
{
// return if the background is already set to that color.
if (background != null && c != null)
if (background.equals(c))
return;
if ((c != null) && c.equals(background))
return;
// If c is null, inherit from closest ancestor whose bg is set.
if (c == null && parent != null)
c = parent.getBackground();
firePropertyChange("background", background, c);
if (peer != null && c != null)
peer.setBackground(c);
Color previous = background;
background = c;
firePropertyChange("background", previous, c);
}
/**
@ -1039,13 +1068,15 @@ public abstract class Component
*/
public Font getFont()
{
if (font != null)
return font;
Font f = font;
if (f != null)
return f;
if (parent != null)
return parent.getFont ();
Component p = parent;
if (p != null)
return p.getFont();
else
return new Font ("Dialog", Font.PLAIN, 12);
return new Font("Dialog", Font.PLAIN, 12);
}
/**
@ -1058,15 +1089,16 @@ public abstract class Component
*/
public void setFont(Font newFont)
{
if (font == newFont)
return;
Font oldFont = font;
font = newFont;
if (peer != null)
peer.setFont(font);
firePropertyChange("font", oldFont, newFont);
invalidate();
if((newFont != null && (font == null || !font.equals(newFont)))
|| newFont == null)
{
Font oldFont = font;
font = newFont;
if (peer != null)
peer.setFont(font);
firePropertyChange("font", oldFont, newFont);
invalidate();
}
}
/**
@ -1372,9 +1404,6 @@ public abstract class Component
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight() && isShowing ())
{
boolean shouldRepaintParent = false;
boolean shouldRepaintSelf = false;
if (parent != null)
{
Rectangle parentBounds = parent.getBounds();
@ -1384,14 +1413,11 @@ public abstract class Component
Rectangle newBounds = new Rectangle(parent.getX() + x,
parent.getY() + y,
width, height);
shouldRepaintParent = parentBounds.intersects(oldBounds);
shouldRepaintSelf = parentBounds.intersects(newBounds);
Rectangle destroyed = oldBounds.union(newBounds);
if (!destroyed.isEmpty())
parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
destroyed.height);
}
if (shouldRepaintParent && parent != null)
parent.repaint(oldx, oldy, oldwidth, oldheight);
if (shouldRepaintSelf)
repaint();
}
// Only post event if this component is visible and has changed size.
@ -1798,9 +1824,8 @@ public abstract class Component
*/
public void paint(Graphics g)
{
// Paint the heavyweight peer
if (!isLightweight() && peer != null)
peer.paint(g);
// This is a callback method and is meant to be overridden by subclasses
// that want to perform custom painting.
}
/**
@ -1816,10 +1841,20 @@ public abstract class Component
*
* @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)
{
if (!isLightweight())
// 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)
@ -1827,7 +1862,6 @@ public abstract class Component
else
g.clearRect(clip.x, clip.y, clip.width, clip.height);
}
paint(g);
}
@ -1854,7 +1888,14 @@ public abstract class Component
*/
public void repaint()
{
repaint(0, 0, 0, width, height);
if(!isShowing())
{
Component p = parent;
if (p != null)
p.repaint(0, getX(), getY(), width, height);
}
else
repaint(0, 0, 0, width, height);
}
/**
@ -1868,7 +1909,14 @@ public abstract class Component
*/
public void repaint(long tm)
{
repaint(tm, 0, 0, width, height);
if(!isShowing())
{
Component p = parent;
if (p != null)
p.repaint(tm, getX(), getY(), width, height);
}
else
repaint(tm, 0, 0, width, height);
}
/**
@ -1885,7 +1933,14 @@ public abstract class Component
*/
public void repaint(int x, int y, int w, int h)
{
repaint(0, x, y, w, h);
if(!isShowing())
{
Component p = parent;
if (p != null)
p.repaint(0, x + getX(), y + getY(), width, height);
}
else
repaint(0, x, y, w, h);
}
/**
@ -1903,14 +1958,18 @@ public abstract class Component
*/
public void repaint(long tm, int x, int y, int width, int height)
{
// Handle lightweight repainting by forwarding to native parent
if (isLightweight() && parent != null)
if(!isShowing())
{
if (parent != null)
parent.repaint(tm, x + getX(), y + getY(), width, height);
Component p = parent;
if (p != null)
p.repaint(tm, x + getX(), y + getY(), width, height);
}
else
{
ComponentPeer p = peer;
if (p != null)
p.repaint(tm, x, y, width, height);
}
else if (peer != null)
peer.repaint(tm, x, y, width, height);
}
/**
@ -1971,7 +2030,7 @@ public abstract class Component
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
{
if ((flags & (FRAMEBITS | ALLBITS)) != 0)
repaint ();
repaint();
else if ((flags & SOMEBITS) != 0)
{
if (incrementalDraw)
@ -1981,10 +2040,10 @@ public abstract class Component
long tm = redrawRate.longValue();
if (tm < 0)
tm = 0;
repaint (tm);
repaint(tm);
}
else
repaint (100);
repaint(100);
}
}
return (flags & (ALLBITS | ABORT | ERROR)) == 0;
@ -2282,8 +2341,6 @@ public abstract class Component
// Some subclasses in the AWT package need to override this behavior,
// hence the use of dispatchEventImpl().
dispatchEventImpl(e);
if (peer != null && ! e.consumed)
peer.handleEvent(e);
}
/**
@ -4183,6 +4240,10 @@ public abstract class Component
param.append(",translucent");
if (isDoubleBuffered())
param.append(",doublebuffered");
if (parent == null)
param.append(",parent==null");
else
param.append(",parent==").append(parent.getName());
return param.toString();
}
@ -4742,7 +4803,7 @@ p * <li>the set of backward traversal keys
* @param e the event to dispatch
*/
void dispatchEventImpl (AWTEvent e)
void dispatchEventImpl(AWTEvent e)
{
Event oldEvent = translateEvent (e);
@ -4776,8 +4837,12 @@ p * <li>the set of backward traversal keys
break;
}
}
processEvent (e);
if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE)
processEvent(e);
}
if (peer != null)
peer.handleEvent(e);
}
/**

View file

@ -42,6 +42,7 @@ import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
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;
import java.beans.PropertyChangeListener;
@ -59,7 +60,8 @@ import java.util.Iterator;
import java.util.Set;
import javax.accessibility.Accessible;
import javax.swing.SwingUtilities;
import gnu.java.awt.AWTUtilities;
/**
* A generic window toolkit object that acts as a container for other objects.
@ -338,8 +340,12 @@ public class Container extends Component
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);
@ -348,7 +354,8 @@ public class Container extends Component
}
}
invalidate();
// Invalidate the layout of the added component and its ancestors.
comp.invalidate();
if (component == null)
component = new Component[4]; // FIXME, better initial size?
@ -394,6 +401,9 @@ public class Container extends Component
ContainerEvent.COMPONENT_ADDED,
comp);
getToolkit().getSystemEventQueue().postEvent(ce);
// Repaint this container.
repaint();
}
}
}
@ -429,6 +439,9 @@ public class Container extends Component
ContainerEvent.COMPONENT_REMOVED,
r);
getToolkit().getSystemEventQueue().postEvent(ce);
// Repaint this container.
repaint();
}
}
}
@ -513,6 +526,11 @@ public class Container extends Component
public void invalidate()
{
super.invalidate();
if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
{
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
lm2.invalidateLayout(this);
}
}
/**
@ -534,6 +552,7 @@ public class Container extends Component
*/
void invalidateTree()
{
super.invalidate(); // Clean cached layout state.
for (int i = 0; i < ncomponents; i++)
{
Component comp = component[i];
@ -541,6 +560,12 @@ public class Container extends Component
if (comp instanceof Container)
((Container) comp).invalidateTree();
}
if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
{
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
lm2.invalidateLayout(this);
}
}
/**
@ -596,11 +621,15 @@ public class Container extends Component
public void setFont(Font f)
{
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();
if( (f != null && (font == null || !font.equals(f)))
|| f == null)
{
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();
}
}
/**
@ -622,10 +651,21 @@ public class Container extends Component
*/
public Dimension preferredSize()
{
if (layoutMgr != null)
return layoutMgr.preferredLayoutSize (this);
else
return super.preferredSize ();
synchronized(treeLock)
{
if(valid && prefSize != null)
return new Dimension(prefSize);
LayoutManager layout = getLayout();
if (layout != null)
{
Dimension layoutSize = layout.preferredLayoutSize(this);
if(valid)
prefSize = layoutSize;
return new Dimension(layoutSize);
}
else
return super.preferredSize ();
}
}
/**
@ -647,8 +687,15 @@ public class Container extends Component
*/
public Dimension minimumSize()
{
if (layoutMgr != null)
return layoutMgr.minimumLayoutSize (this);
if(valid && minSize != null)
return new Dimension(minSize);
LayoutManager layout = getLayout();
if (layout != null)
{
minSize = layout.minimumLayoutSize (this);
return minSize;
}
else
return super.minimumSize ();
}
@ -660,10 +707,15 @@ public class Container extends Component
*/
public Dimension getMaximumSize()
{
if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
if (valid && maxSize != null)
return new Dimension(maxSize);
LayoutManager layout = getLayout();
if (layout != null && layout instanceof LayoutManager2)
{
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
return lm2.maximumLayoutSize(this);
LayoutManager2 lm2 = (LayoutManager2) layout;
maxSize = lm2.maximumLayoutSize(this);
return maxSize;
}
else
return super.getMaximumSize();
@ -678,13 +730,7 @@ public class Container extends Component
*/
public float getAlignmentX()
{
if (layoutMgr instanceof LayoutManager2)
{
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
return lm2.getLayoutAlignmentX(this);
}
else
return super.getAlignmentX();
return super.getAlignmentX();
}
/**
@ -696,13 +742,7 @@ public class Container extends Component
*/
public float getAlignmentY()
{
if (layoutMgr instanceof LayoutManager2)
{
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
return lm2.getLayoutAlignmentY(this);
}
else
return super.getAlignmentY();
return super.getAlignmentY();
}
/**
@ -718,8 +758,7 @@ public class Container extends Component
{
if (!isShowing())
return;
// Paint self first.
super.paint(g);
// Visit heavyweights as well, in case they were
// erased when we cleared the background for this container.
visitChildren(g, GfxPaintVisitor.INSTANCE, false);
@ -733,10 +772,30 @@ public class Container extends Component
* drawn.
*
* @param g The graphics context for this update.
*
* @specnote The specification suggests that this method forwards the
* update() call to all its lightweight children. Tests show
* that this is not done either in the JDK. The exact behaviour
* seems to be that the background is cleared in heavyweight
* Containers, and all other containers
* directly call paint(), causing the (lightweight) children to
* be painted.
*/
public void update(Graphics g)
{
super.update(g);
// It seems that the JDK clears the background of containers like Panel
// and Window (within this method) but not of 'plain' Containers or
// JComponents. This could
// lead to the assumption that it only clears heavyweight containers.
// However that is not quite true. In a test with a custom Container
// that overrides isLightweight() to return false, the background is
// also not cleared. So we do a check on !(peer instanceof LightweightPeer)
// instead.
ComponentPeer p = peer;
if (p != null && !(p instanceof LightweightPeer))
g.clearRect(0, 0, getWidth(), getHeight());
paint(g);
}
/**
@ -1198,7 +1257,7 @@ public class Container extends Component
}
if (focusTraversalKeys == null)
focusTraversalKeys = new Set[3];
focusTraversalKeys = new Set[4];
keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
firePropertyChange (name, focusTraversalKeys[id], keystrokes);
@ -1465,12 +1524,8 @@ public class Container extends Component
for (int i = ncomponents - 1; i >= 0; --i)
{
Component comp = component[i];
// If we're visiting heavyweights as well,
// don't recurse into Containers here. This avoids
// painting the same nested child multiple times.
boolean applicable = comp.isVisible()
&& (comp.isLightweight()
|| !lightweightOnly && ! (comp instanceof Container));
&& (comp.isLightweight() || !lightweightOnly);
if (applicable)
visitChild(gfx, visitor, comp);
@ -1525,11 +1580,9 @@ public class Container extends Component
void dispatchEventImpl(AWTEvent e)
{
// Give lightweight dispatcher a chance to handle it.
if (eventTypeEnabled (e.id)
&& dispatcher != null
&& dispatcher.handleEvent (e))
if (dispatcher != null && dispatcher.handleEvent (e))
return;
if ((e.id <= ContainerEvent.CONTAINER_LAST
&& e.id >= ContainerEvent.CONTAINER_FIRST)
&& (containerListener != null
@ -1539,6 +1592,26 @@ public class Container extends Component
super.dispatchEventImpl(e);
}
/**
* Tests if this container has an interest in the given event id.
*
* @param eventId The event id to check.
*
* @return <code>true</code> if a listener for the event id exists or
* if the eventMask is set for the event id.
*
* @see java.awt.Component#eventTypeEnabled(int)
*/
boolean eventTypeEnabled(int eventId)
{
if(eventId <= ContainerEvent.CONTAINER_LAST
&& eventId >= ContainerEvent.CONTAINER_FIRST)
return containerListener != null
|| (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0;
else
return super.eventTypeEnabled(eventId);
}
// This is used to implement Component.transferFocus.
Component findNextFocusComponent(Component child)
{
@ -1603,12 +1676,11 @@ public class Container extends Component
// If we're not lightweight, and we just got a lightweight
// child, we need a lightweight dispatcher to feed it events.
if (! this.isLightweight())
{
if (dispatcher == null)
dispatcher = new LightweightDispatcher (this);
}
if (!this.isLightweight() && dispatcher == null)
dispatcher = new LightweightDispatcher (this);
if (dispatcher != null)
dispatcher.enableEvents(component[i].eventMask);
enableEvents(component[i].eventMask);
if (peer != null && !isLightweight ())
@ -1862,7 +1934,6 @@ public class Container extends Component
* rather than mimic it exactly we write something which does "roughly
* the same thing".
*/
class LightweightDispatcher implements Serializable
{
private static final long serialVersionUID = 5184291520170872969L;
@ -1870,10 +1941,8 @@ class LightweightDispatcher implements Serializable
private Cursor nativeCursor;
private long eventMask;
private transient Component mouseEventTarget;
private transient Component pressedComponent;
private transient Component lastComponentEntered;
private transient Component tempComponent;
private transient int pressCount;
LightweightDispatcher(Container c)
@ -1881,11 +1950,17 @@ class LightweightDispatcher implements Serializable
nativeContainer = c;
}
void acquireComponentForMouseEvent(MouseEvent me)
void enableEvents(long l)
{
eventMask |= l;
}
Component acquireComponentForMouseEvent(MouseEvent me)
{
int x = me.getX ();
int y = me.getY ();
Component mouseEventTarget = null;
// Find the candidate which should receive this event.
Component parent = nativeContainer;
Component candidate = null;
@ -1893,13 +1968,13 @@ class LightweightDispatcher implements Serializable
while (candidate == null && parent != null)
{
candidate =
SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
AWTUtilities.getDeepestComponentAt(parent, p.x, p.y);
if (candidate == null || (candidate.eventMask & me.getID()) == 0)
{
candidate = null;
p = SwingUtilities.convertPoint(parent, p.x, p.y, parent.parent);
parent = parent.parent;
}
{
candidate = null;
p = AWTUtilities.convertPoint(parent, p.x, p.y, parent.parent);
parent = parent.parent;
}
}
// If the only candidate we found was the native container itself,
@ -1915,25 +1990,24 @@ class LightweightDispatcher implements Serializable
{
// Old candidate could have been removed from
// the nativeContainer so we check first.
if (SwingUtilities.isDescendingFrom(lastComponentEntered, nativeContainer))
{
Point tp =
SwingUtilities.convertPoint(nativeContainer,
x, y, lastComponentEntered);
MouseEvent exited = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen (),
me.getModifiersEx (),
tp.x, tp.y,
me.getClickCount (),
me.isPopupTrigger (),
me.getButton ());
tempComponent = lastComponentEntered;
lastComponentEntered = null;
tempComponent.dispatchEvent(exited);
}
if (AWTUtilities.isDescendingFrom(lastComponentEntered,
nativeContainer))
{
Point tp = AWTUtilities.convertPoint(nativeContainer,
x, y, lastComponentEntered);
MouseEvent exited = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_EXITED,
me.getWhen (),
me.getModifiersEx (),
tp.x, tp.y,
me.getClickCount (),
me.isPopupTrigger (),
me.getButton ());
lastComponentEntered.dispatchEvent (exited);
}
lastComponentEntered = null;
}
// If we have a candidate, maybe enter it.
if (candidate != null)
{
@ -1942,10 +2016,10 @@ class LightweightDispatcher implements Serializable
&& candidate.isShowing()
&& candidate != nativeContainer
&& candidate != lastComponentEntered)
{
{
lastComponentEntered = mouseEventTarget;
Point cp = SwingUtilities.convertPoint(nativeContainer,
x, y, lastComponentEntered);
Point cp = AWTUtilities.convertPoint(nativeContainer,
x, y, lastComponentEntered);
MouseEvent entered = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_ENTERED,
me.getWhen (),
@ -1958,17 +2032,38 @@ class LightweightDispatcher implements Serializable
}
}
// Check which buttons where pressed except the last button that
// changed state.
int modifiers = me.getModifiersEx() & (MouseEvent.BUTTON1_DOWN_MASK
| MouseEvent.BUTTON2_DOWN_MASK
| MouseEvent.BUTTON3_DOWN_MASK);
switch(me.getButton())
{
case MouseEvent.BUTTON1:
modifiers &= ~MouseEvent.BUTTON1_DOWN_MASK;
break;
case MouseEvent.BUTTON2:
modifiers &= ~MouseEvent.BUTTON2_DOWN_MASK;
break;
case MouseEvent.BUTTON3:
modifiers &= ~MouseEvent.BUTTON3_DOWN_MASK;
break;
}
if (me.getID() == MouseEvent.MOUSE_RELEASED
|| me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
|| me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0
|| me.getID() == MouseEvent.MOUSE_DRAGGED)
// If any of the following events occur while a button is held down,
// they should be dispatched to the same component to which the
// original MOUSE_PRESSED event was dispatched:
// - MOUSE_RELEASED
// - MOUSE_PRESSED: another button pressed while the first is held down
// - MOUSE_DRAGGED
if (SwingUtilities.isDescendingFrom(pressedComponent, nativeContainer))
mouseEventTarget = pressedComponent;
{
// If any of the following events occur while a button is held down,
// they should be dispatched to the same component to which the
// original MOUSE_PRESSED event was dispatched:
// - MOUSE_RELEASED
// - MOUSE_PRESSED: another button pressed while the first is held
// down
// - MOUSE_DRAGGED
if (AWTUtilities.isDescendingFrom(pressedComponent, nativeContainer))
mouseEventTarget = pressedComponent;
}
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
{
// Don't dispatch CLICKED events whose target is not the same as the
@ -1978,6 +2073,7 @@ class LightweightDispatcher implements Serializable
else if (pressCount == 0)
pressedComponent = null;
}
return mouseEventTarget;
}
boolean handleEvent(AWTEvent e)
@ -1986,41 +2082,42 @@ class LightweightDispatcher implements Serializable
{
MouseEvent me = (MouseEvent) e;
acquireComponentForMouseEvent(me);
// Make the LightWeightDispatcher reentrant. This is necessary when
// a lightweight component does its own modal event queue.
Component mouseEventTarget = acquireComponentForMouseEvent(me);
// Avoid dispatching ENTERED and EXITED events twice.
if (mouseEventTarget != null
&& mouseEventTarget.isShowing()
&& e.getID() != MouseEvent.MOUSE_ENTERED
&& e.getID() != MouseEvent.MOUSE_EXITED)
{
MouseEvent newEvt =
SwingUtilities.convertMouseEvent(nativeContainer, me,
mouseEventTarget);
mouseEventTarget.dispatchEvent(newEvt);
switch (e.getID())
{
case MouseEvent.MOUSE_PRESSED:
if (pressCount++ == 0)
pressedComponent = mouseEventTarget;
break;
case MouseEvent.MOUSE_RELEASED:
// Clear our memory of the original PRESSED event, only if
// we're not expecting a CLICKED event after this. If
// there is a CLICKED event after this, it will do clean up.
if (--pressCount == 0
&& mouseEventTarget != pressedComponent)
pressedComponent = null;
break;
case MouseEvent.MOUSE_PRESSED:
if (pressCount++ == 0)
pressedComponent = mouseEventTarget;
break;
case MouseEvent.MOUSE_RELEASED:
// Clear our memory of the original PRESSED event, only if
// we're not expecting a CLICKED event after this. If
// there is a CLICKED event after this, it will do clean up.
if (--pressCount == 0
&& mouseEventTarget != pressedComponent)
pressedComponent = null;
break;
}
if (newEvt.isConsumed())
e.consume();
MouseEvent newEvt =
AWTUtilities.convertMouseEvent(nativeContainer, me,
mouseEventTarget);
mouseEventTarget.dispatchEvent(newEvt);
if (newEvt.isConsumed())
e.consume();
}
}
return e.isConsumed();
}
} // class LightweightDispatcher
}

View file

@ -38,8 +38,6 @@ exception statement from your version. */
package java.awt;
import gnu.java.awt.ClasspathToolkit;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
@ -78,10 +76,7 @@ public class EventQueue
private EventDispatchThread dispatchThread = new EventDispatchThread(this);
private boolean shutdown = false;
private long lastNativeQueueAccess = 0;
private long humanLatencyThreshold = 100;
synchronized void setShutdown (boolean b)
synchronized private void setShutdown (boolean b)
{
shutdown = b;
}
@ -94,8 +89,8 @@ public class EventQueue
// 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 (peekEvent() == null
&& ((ClasspathToolkit) Toolkit.getDefaultToolkit()).nativeQueueEmpty())
// FIXME: check somewhere that the native queue is empty
if (peekEvent() == null)
{
Frame[] frames = Frame.getFrames();
for (int i = 0; i < frames.length; ++i)
@ -127,50 +122,22 @@ public class EventQueue
{
if (next != null)
return next.getNextEvent();
ClasspathToolkit tk = ((ClasspathToolkit) Toolkit.getDefaultToolkit());
long curr = System.currentTimeMillis();
if (! tk.nativeQueueEmpty() &&
(curr - lastNativeQueueAccess > humanLatencyThreshold))
{
tk.iterateNativeQueue(this, false);
lastNativeQueueAccess = curr;
}
while (next_in == next_out)
{
// Only the EventDispatchThread associated with the top of the stack is
// allowed to get events from the native source; everyone else just
// waits on the head of the queue.
// 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 (isDispatchThread())
{
// We are not allowed to return null from this method, yet it
// is possible that we actually have run out of native events
// in the enclosing while() loop, and none of the native events
// happened to cause AWT events. We therefore ought to check
// the isShutdown() condition here, before risking a "native
// wait". If we check it before entering this function we may
// wait forever for events after the shutdown condition has
// arisen.
if (isShutdown())
throw new InterruptedException();
if (isShutdown())
throw new InterruptedException();
tk.iterateNativeQueue(this, true);
lastNativeQueueAccess = System.currentTimeMillis();
}
else
{
try
{
wait();
}
catch (InterruptedException ie)
{
}
}
wait();
}
AWTEvent res = queue[next_out];
@ -298,15 +265,6 @@ public class EventQueue
dispatchThread.start();
}
// Window events might represent the closing of a window, which
// might cause the end of the dispatch thread's life, so we'll wake
// it up here to give it a chance to check for shutdown.
if (!isDispatchThread()
|| (evt.getID() == WindowEvent.WINDOW_CLOSED)
|| (evt.getID() == WindowEvent.WINDOW_CLOSING))
((ClasspathToolkit) Toolkit.getDefaultToolkit()).wakeNativeQueue();
notify();
}
@ -478,7 +436,6 @@ public class EventQueue
next_in = 0;
next_out = 0;
((ClasspathToolkit) Toolkit.getDefaultToolkit()).wakeNativeQueue();
setShutdown(true);
dispatchThread = null;
this.notifyAll();

View file

@ -205,12 +205,12 @@ public class FlowLayout implements LayoutManager, Serializable
else if (align == TRAILING)
myalign = left_to_right ? RIGHT : LEFT;
if (myalign == LEFT)
x = ins.left + hgap;
if (myalign == RIGHT)
x = ins.left + (d.width - new_w) + hgap;
else if (myalign == CENTER)
x = ins.left + (d.width - new_w) / 2 + hgap;
else
x = ins.left + (d.width - new_w) + hgap;
else // LEFT and all other values of align.
x = ins.left + hgap;
for (int k = i; k < j; ++k)
{
@ -269,9 +269,9 @@ public class FlowLayout implements LayoutManager, Serializable
*/
public void setAlignment (int align)
{
if (align != LEFT && align != RIGHT && align != CENTER
&& align != LEADING && align != TRAILING)
throw new IllegalArgumentException ("invalid alignment: " + align);
// The JDK accepts invalid values and treats them as
// LEFT during layout, so do we. The invalid value is even stored,
// getAlignment() returns the same invalid value.
this.align = align;
}

View file

@ -353,9 +353,11 @@ private static final long serialVersionUID = -4206021311591459213L;
this(null, attrs);
}
/* This extra constructor is here to permit ClasspathToolkit and to build
a font with a "logical name" as well as attrs. */
public Font (String name, Map attrs)
/* This extra constructor is here to permit ClasspathToolkit and to
build a font with a "logical name" as well as attrs.
ClasspathToolkit.getFont(String,Map) uses reflection to call this
package-private constructor. */
Font (String name, Map attrs)
{
// If attrs is null, setting it to an empty HashMap will give this
// Font default attributes.

View file

@ -193,7 +193,8 @@ public abstract class FontMetrics implements java.io.Serializable
*/
public int charWidth(int ch)
{
return charWidth((char) ch);
char[] chars = Character.toChars(ch);
return charsWidth(chars, 0, chars.length);
}
/**
@ -235,7 +236,8 @@ public abstract class FontMetrics implements java.io.Serializable
public int charsWidth(char[] buf, int offset, int len)
{
int total_width = 0;
for (int i = offset; i < len; i++)
int endOffset = offset + len;
for (int i = offset; i < endOffset; i++)
total_width += charWidth(buf[i]);
return total_width;
}

View file

@ -401,20 +401,6 @@ remove(MenuComponent menu)
menuBar.remove(menu);
}
/**
* Notifies this frame that it should create its native peer.
*/
private static void fireDummyEvent()
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
// Do nothing here.
}
});
}
public void
addNotify()
{
@ -423,11 +409,6 @@ addNotify()
if (peer == null)
peer = getToolkit ().createFrame (this);
// We now know there's a Frame (us) with a live peer, so we can start the
// fundamental queue and dispatch thread, by inserting a dummy event.
if (parent != null && parent.isDisplayable())
fireDummyEvent();
super.addNotify();
}
@ -436,12 +417,6 @@ public void removeNotify()
if (menuBar != null)
menuBar.removeNotify();
super.removeNotify();
// By now we've been disconnected from the peer, and the peer set to
// null. This is formally the same as saying "we just became
// un-displayable", so we wake up the event queue with a dummy event to
// see if it's time to shut down.
fireDummyEvent();
}
/**

View file

@ -125,6 +125,22 @@ public abstract class GraphicsConfiguration
throw new AWTException("not implemented");
}
/**
* Returns a buffered volatile image optimized to this device, and
* with the given transparency. Because the buffer is volatile, it
* can be optimized by native graphics accelerators.
*
* @param w the width of the buffer
* @param h the height of the buffer
* @param transparency the transparency value for the buffer
* @return the buffered image, or null if none is supported
* @throws AWTException if the capabilities cannot be met
* @since 1.5
*/
public abstract VolatileImage createCompatibleVolatileImage(int width,
int height,
int transparency);
/**
* Returns a buffered image optimized to this device, and with the specified
* transparency, so that blitting can be supported in the buffered image.

View file

@ -192,16 +192,12 @@ public class GridBagLayout
if (clone.gridwidth == 0)
clone.gridwidth = GridBagConstraints.REMAINDER;
else if (clone.gridwidth < 0
&& clone.gridwidth != GridBagConstraints.REMAINDER
&& clone.gridwidth != GridBagConstraints.RELATIVE)
else if (clone.gridwidth < 0)
clone.gridwidth = 1;
if (clone.gridheight == 0)
clone.gridheight = GridBagConstraints.REMAINDER;
else if (clone.gridheight < 0
&& clone.gridheight != GridBagConstraints.REMAINDER
&& clone.gridheight != GridBagConstraints.RELATIVE)
else if (clone.gridheight < 0)
clone.gridheight = 1;
comptable.put (component, clone);
@ -913,7 +909,7 @@ public class GridBagLayout
sizes[start] = Math.max(sizes[start], size);
weights[start] = Math.max(weights[start], weight);
}
else
else if (span > 1)
{
int numOccupied = span;
int lastOccupied = -1;

View file

@ -215,12 +215,17 @@ getText()
public synchronized void
setText(String text)
{
this.text = text;
if (peer != null)
if ((this.text == null && text != null)
|| (this.text != null && ! this.text.equals(text)))
{
LabelPeer lp = (LabelPeer) peer;
lp.setText (text);
this.text = text;
if (peer != null)
{
LabelPeer lp = (LabelPeer) peer;
lp.setText (text);
}
invalidate();
}
}

View file

@ -163,6 +163,7 @@ List(int rows, boolean multipleMode)
{
this.rows = rows;
this.multipleMode = multipleMode;
selected = new int[0];
if (GraphicsEnvironment.isHeadless())
throw new HeadlessException ();

View file

@ -179,14 +179,11 @@ private transient ActionListener action_listeners;
*/
public boolean setCurrentAccessibleValue(Number number)
{
if (number.intValue() == 0)
{
setEnabled(false);
return false;
}
setEnabled(true);
return true;
boolean result = (number.intValue() != 0);
// this. is required by javac 1.3, otherwise it is confused with
// MenuItem.this.setEnabled.
this.setEnabled(result);
return result;
}
/* (non-Javadoc)

View file

@ -475,7 +475,7 @@ select(int selectionStart, int selectionEnd)
if (selectionEnd > text.length())
selectionEnd = text.length();
if (selectionStart > getSelectionEnd())
if (selectionStart > selectionEnd)
selectionStart = selectionEnd;
this.selectionStart = selectionStart;

View file

@ -790,6 +790,9 @@ public abstract class Toolkit
{
// Presumably the only reason this isn't abstract is for backwards
// compatibility? FIXME?
if (GraphicsEnvironment.isHeadless())
throw new HeadlessException("No custom cursor in an headless graphics "
+ "environment.");
return null;
}
@ -801,6 +804,9 @@ public abstract class Toolkit
*/
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
{
if (GraphicsEnvironment.isHeadless())
throw new HeadlessException("No best cursor size in an headless "
+ "graphics environment.");
return new Dimension (0,0);
}

View file

@ -155,6 +155,9 @@ public class Window extends Container implements Accessible
}
}
});
GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration();
}
Window(GraphicsConfiguration gc)
@ -619,6 +622,8 @@ public class Window extends Container implements Accessible
|| windowStateListener != null
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
processEvent(e);
else if (e.id == ComponentEvent.COMPONENT_RESIZED)
validate ();
else
super.dispatchEventImpl(e);
}
@ -741,7 +746,25 @@ public class Window extends Container implements Accessible
if (activeWindow == this)
return manager.getFocusOwner ();
else
return windowFocusOwner;
return null;
}
/**
* Returns the child component of this window that would receive
* focus if this window were to become focused. If the window
* already has the top-level focus, then this method returns the
* same component as getFocusOwner. If no child component has
* requested focus within the window, then the initial focus owner
* is returned. If this is a non-focusable window, this method
* returns null.
*
* @return the child component of this window that most recently had
* the focus, or <code>null</code>
* @since 1.4
*/
public Component getMostRecentFocusOwner ()
{
return windowFocusOwner;
}
/**
@ -1070,44 +1093,6 @@ public class Window extends Container implements Accessible
this.focusableWindowState = focusableWindowState;
}
// 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
// location is updated automatically and the windowing system sends
// a message back to the application informing it of its updated
// dimensions. We must update the AWT Window class with these new
// dimensions. But we don't want to call the peer's setBounds
// method, because the peer's dimensions have already been updated.
// (Under X, having this method prevents Configure event loops when
// moving windows: Component.setBounds -> peer.setBounds ->
// postConfigureEvent -> Component.setBounds -> ... In some cases
// Configure event loops cause windows to jitter back and forth
// continuously).
void setBoundsCallback (int x, int y, int w, int h)
{
if (this.x == x && this.y == y && width == w && height == h)
return;
invalidate();
boolean resized = width != w || height != h;
boolean moved = this.x != x || this.y != y;
this.x = x;
this.y = y;
width = w;
height = h;
if (resized && isShowing ())
{
ComponentEvent ce =
new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
if (moved && isShowing ())
{
ComponentEvent ce =
new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED);
getToolkit().getSystemEventQueue().postEvent(ce);
}
}
/**
* Generate a unique name for this window.
*

View file

@ -1,5 +1,5 @@
/* Clipboard.java -- Class for transferring data via cut and paste.
Copyright (C) 1999, 2001 Free Software Foundation, Inc.
Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -38,16 +38,21 @@ exception statement from your version. */
package java.awt.datatransfer;
import java.io.IOException;
import java.util.ArrayList;
/**
* This class allows data to be transferred using a cut and paste type
* mechanism.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Mark J. Wielaard (mark@klomp.org)
*/
public class Clipboard
{
/**
* The data being transferred.
* The data currently on this clipboard. For use by
* subclasses. Also returned by the public method getContents().
*/
protected Transferable contents;
@ -57,7 +62,10 @@ public class Clipboard
protected ClipboardOwner owner;
// The clipboard name
private String name;
private final String name;
// The flavor listeners (most likely small).
private final ArrayList listeners = new ArrayList(3);
/**
* Initializes a new instance of <code>Clipboard</code> with the
@ -81,7 +89,8 @@ public class Clipboard
/**
* Returns the contents of the clipboard.
*
* @param requestor The object requesting the contents.
* @param requestor The object requesting the contents. This
* implementation ignores this parameter.
*
* @exception IllegalStateException If the clipboard is currently unavailable
*/
@ -91,24 +100,108 @@ public class Clipboard
}
/**
* Sets the content and owner of this clipboard.
* If the given owner is different from the current owner
* then lostOwnership is called on the current owner.
* XXX - is this called with the old or new contents.
* Sets the content and owner of this clipboard. If the given owner
* is different from the current owner then <code>lostOwnership()</code>
* is called on the current owner with the old contents of the given
* clipboard.
*
* @param contents The new clipboard contents.
* @param owner The new clipboard owner
*
* @exception IllegalStateException If the clipboard is currently unavailable
*/
public synchronized void setContents(Transferable contents, ClipboardOwner owner)
public synchronized void setContents(Transferable contents,
ClipboardOwner owner)
{
if (this.owner != owner)
if (this.owner != null)
this.owner.lostOwnership(this, contents);
this.owner = owner;
Transferable oldContents = getContents(null);
this.contents = contents;
if (this.owner != owner)
{
ClipboardOwner oldOwner = this.owner;
this.owner = owner;
if (oldOwner != null)
oldOwner.lostOwnership(this, oldContents);
}
FlavorListener[] fs = getFlavorListeners();
if (fs.length > 0)
{
// We are a bit optimistic here. We assume DataFlavors will be
// given in the same order. If the number of flavors is
// different or the order of the DataFlavors in the list then
// fire a change event.
boolean newFlavors = ((contents != null && oldContents == null)
|| (contents == null && oldContents != null));
if (!newFlavors && contents != null && oldContents != null)
{
DataFlavor[] df1 = contents.getTransferDataFlavors();
DataFlavor[] df2 = oldContents.getTransferDataFlavors();
newFlavors = df1.length != df2.length;
for (int i = 0; !newFlavors && i < df1.length; i++)
newFlavors = !df1[i].equals(df2[i]);
}
if (newFlavors)
{
FlavorEvent e = new FlavorEvent(this);
for (int i = 0; i < fs.length; i++)
fs[i].flavorsChanged(e);
}
}
}
public DataFlavor[] getAvailableDataFlavors()
{
Transferable c = getContents(null);
if (c == null)
return new DataFlavor[0];
else
return c.getTransferDataFlavors();
}
public boolean isDataFlavorAvailable(DataFlavor flavor)
{
DataFlavor[] fs = getAvailableDataFlavors();
for (int i = 0; i < fs.length; i++)
if (flavor.equals(fs[i]))
return true;
return false;
}
public Object getData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException
{
Transferable c = getContents(null);
if (c == null)
throw new UnsupportedFlavorException(flavor);
else
return c.getTransferData(flavor);
}
public void addFlavorListener(FlavorListener listener)
{
synchronized(listeners)
{
listeners.add(listener);
}
}
public void removeFlavorListener(FlavorListener listener)
{
synchronized(listeners)
{
listeners.remove(listener);
}
}
public FlavorListener[] getFlavorListeners()
{
synchronized(listeners)
{
return (FlavorListener[])
listeners.toArray(new FlavorListener[listeners.size()]);
}
}
}

View file

@ -49,6 +49,7 @@ import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.rmi.Remote;
/**
* This class represents a particular data format used for transferring
@ -127,10 +128,9 @@ static
javaFileListFlavor
= new DataFlavor(java.util.List.class,
"application/x-java-file-list; class=java.util.List",
"Java File List");
// javaFileListFlavor.mimeType = "application/x-java-file-list";
imageFlavor
= new DataFlavor(java.awt.Image.class,
"Java Image");
@ -335,7 +335,8 @@ getRepresentationClassFromMime(String mimeString, ClassLoader classLoader)
public
DataFlavor(String mimeType, String humanPresentableName)
{
this (getRepresentationClassFromMime (mimeType, null), humanPresentableName);
this (getRepresentationClassFromMime (mimeType, null),
mimeType, humanPresentableName);
}
/*************************************************************************/
@ -426,17 +427,15 @@ getPrimaryType()
public String
getSubType()
{
int idx = mimeType.indexOf("/");
if (idx == -1)
return("");
int start = mimeType.indexOf("/");
if (start == -1)
return "";
String subtype = mimeType.substring(idx + 1);
idx = subtype.indexOf(" ");
if (idx == -1)
return(subtype);
int end = mimeType.indexOf(";", start + 1);
if (end == -1)
return mimeType.substring(start + 1);
else
return(subtype.substring(0, idx));
return mimeType.substring(start + 1, end);
}
/*************************************************************************/
@ -480,6 +479,9 @@ getParameter(String paramName, String mimeString)
public String
getParameter(String paramName)
{
if ("humanPresentableName".equals(paramName))
return getHumanPresentableName();
return getParameter(paramName, mimeType);
}
@ -500,21 +502,28 @@ setHumanPresentableName(String humanPresentableName)
/**
* Tests the MIME type of this object for equality against the specified
* MIME type.
* MIME type. Ignores parameters.
*
* @param mimeType The MIME type to test against.
*
* @return <code>true</code> if the MIME type is equal to this object's
* MIME type, <code>false</code> otherwise.
* MIME type (ignoring parameters), <code>false</code> otherwise.
*
* @exception NullPointerException If mimeType is null.
*/
public boolean
isMimeTypeEqual(String mimeType)
{
// FIXME: Need to handle default attributes and parameters
String mime = getMimeType();
int i = mime.indexOf(";");
if (i != -1)
mime = mime.substring(0, i);
return(this.mimeType.equals(mimeType));
i = mimeType.indexOf(";");
if (i != -1)
mimeType = mimeType.substring(0, i);
return mime.equals(mimeType);
}
/*************************************************************************/
@ -599,8 +608,7 @@ isRepresentationClassSerializable()
public boolean
isRepresentationClassRemote()
{
// FIXME: Implement
throw new RuntimeException("Not implemented");
return Remote.class.isAssignableFrom (representationClass);
}
/*************************************************************************/
@ -852,12 +860,11 @@ readExternal(ObjectInput stream) throws IOException, ClassNotFoundException
public String
toString()
{
return("DataFlavor[representationClass="
+ representationClass.getName()
+ ",mimeType="
+ mimeType
+ "humanPresentableName="
+ humanPresentableName);
return(getClass().getName()
+ "[representationClass=" + getRepresentationClass().getName()
+ ",mimeType=" + getMimeType()
+ ",humanPresentableName=" + getHumanPresentableName()
+ "]");
}
/*************************************************************************/

View file

@ -49,7 +49,7 @@ import javax.swing.Scrollable;
/**
* This event is generated for a mouse wheel rotation. The wheel (the middle
* mouse button on most modern mice) can be rotated towards or away from the
* user, and is ofteh used for scrolling.
* user, and is often used for scrolling.
*
* <p>Because of the special use for scrolling components, MouseWheelEvents
* often affect a different component than the one located at the point of

View file

@ -80,6 +80,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
*/
public void setHints(int flags)
{
if (consumer != null)
consumer.setHints(flags);
}
@ -100,6 +101,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
@ -120,6 +122,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}

View file

@ -1,5 +1,5 @@
/* ConvolveOp.java --
Copyright (C) 2004 Free Software Foundation -- ConvolveOp
Copyright (C) 2004, 2005 Free Software Foundation -- ConvolveOp
This file is part of GNU Classpath.
@ -177,11 +177,13 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
}
/**
* Returns (a clone of) the convolution kernel.
*
* @return The convolution kernel.
*/
public Kernel getKernel()
{
return kernel;
return (Kernel) kernel.clone();
}
/* (non-Javadoc)
@ -189,8 +191,6 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest) {
if (src.numBands != dest.numBands)
throw new ImagingOpException(null);
if (src == dest)
throw new IllegalArgumentException();
if (src.getWidth() < kernel.getWidth() ||
@ -199,6 +199,8 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
if (dest == null)
dest = createCompatibleDestRaster(src);
else if (src.numBands != dest.numBands)
throw new ImagingOpException(null);
// Deal with bottom edge
if (edge == EDGE_ZERO_FILL)

View file

@ -79,6 +79,7 @@ public class CropImageFilter extends ImageFilter
*/
public void setDimensions(int width, int height)
{
if (consumer != null)
consumer.setDimensions(this.width, this.height);
}
@ -93,7 +94,8 @@ public class CropImageFilter extends ImageFilter
public void setProperties(Hashtable props)
{
props.put("filters", "CropImageFilter");
consumer.setProperties(props);
if (consumer != null)
consumer.setProperties(props);
}
/**
@ -130,9 +132,10 @@ public class CropImageFilter extends ImageFilter
cropped[i * bounds.width + j] = pixels[start + bounds.x + j];
}
consumer.setPixels(bounds.x, bounds.y,
bounds.width, bounds.height,
model, cropped, 0, bounds.width);
if (consumer != null)
consumer.setPixels(0, 0,
bounds.width, bounds.height,
model, cropped, 0, bounds.width);
}
}
@ -170,9 +173,10 @@ public class CropImageFilter extends ImageFilter
cropped[i * bounds.width + j] = pixels[start + bounds.x + j];
}
consumer.setPixels(bounds.x, bounds.y,
bounds.width, bounds.height,
model, cropped, 0, bounds.width);
if (consumer != null)
consumer.setPixels(0, 0,
bounds.width, bounds.height,
model, cropped, 0, bounds.width);
}
}

View file

@ -348,9 +348,24 @@ public class DirectColorModel extends PackedColorModel
{
return getComponents(getPixelFromArray(pixel), components, offset);
}
/**
* Creates a <code>WriteableRaster</code> that has a <code>SampleModel</code>
* that is compatible with this <code>ColorModel</code>.
*
* @param w the width of the writeable raster to create
* @param h the height of the writeable raster to create
*
* @throws IllegalArgumentException if <code>w</code> or <code>h</code>
* is less than or equal to zero
*/
public final WritableRaster createCompatibleWritableRaster(int w, int h)
{
// Sun also makes this check here.
if(w <= 0 || h <= 0)
throw new IllegalArgumentException("width (=" + w + ") and height (="
+ h + ") must be > 0");
SampleModel sm = createCompatibleSampleModel(w, h);
Point origin = new Point(0, 0);
return Raster.createWritableRaster(sm, origin);
@ -418,3 +433,4 @@ public class DirectColorModel extends PackedColorModel
return super.toString();
}
}

View file

@ -125,6 +125,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
*/
public void setDimensions(int width, int height)
{
if (consumer != null)
consumer.setDimensions(width, height);
}
@ -137,7 +138,8 @@ public class ImageFilter implements ImageConsumer, Cloneable
public void setProperties(Hashtable props)
{
props.put("filters", "ImageFilter");
consumer.setProperties(props);
if (consumer != null)
consumer.setProperties(props);
}
/**
@ -149,6 +151,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
* @see ColorModel */
public void setColorModel(ColorModel model)
{
if (consumer != null)
consumer.setColorModel(model);
}
@ -164,6 +167,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
*/
public void setHints(int flags)
{
if (consumer != null)
consumer.setHints(flags);
}
@ -184,6 +188,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
@ -204,6 +209,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
@ -215,6 +221,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
*/
public void imageComplete(int status)
{
if (consumer != null)
consumer.imageComplete(status);
}
}

View file

@ -131,6 +131,9 @@ public class PixelGrabber implements ImageConsumer
public PixelGrabber(ImageProducer ip, int x, int y, int w, int h,
int pix[], int off, int scansize)
{
if (ip == null)
throw new NullPointerException("The ImageProducer must not be null.");
this.ip = ip;
this.x = x;
this.y = y;
@ -179,6 +182,10 @@ public class PixelGrabber implements ImageConsumer
boolean forceRGB)
{
this.ip = img.getSource();
if (this.ip == null)
throw new NullPointerException("The ImageProducer must not be null.");
this.x = x;
this.y = y;
width = w;
@ -209,7 +216,15 @@ public class PixelGrabber implements ImageConsumer
{
public void run ()
{
ip.startProduction (PixelGrabber.this);
try
{
ip.startProduction (PixelGrabber.this);
}
catch (Exception ex)
{
ex.printStackTrace();
imageComplete(ImageConsumer.IMAGEABORTED);
}
}
};
grabberThread.start ();
@ -601,7 +616,8 @@ public class PixelGrabber implements ImageConsumer
consumerStatus = status;
setObserverStatus ();
grabbing = false;
ip.removeConsumer (this);
if (ip != null)
ip.removeConsumer (this);
notifyAll ();
}

View file

@ -79,10 +79,12 @@ public abstract class RGBImageFilter extends ImageFilter
if( ( model instanceof IndexColorModel) && canFilterIndexColorModel ) {
newmodel = filterIndexColorModel( (IndexColorModel) model );
consumer.setColorModel(newmodel);
if (consumer != null)
consumer.setColorModel(newmodel);
}
else {
consumer.setColorModel(ColorModel.getRGBdefault());
if (consumer != null)
consumer.setColorModel(ColorModel.getRGBdefault());
}
}
@ -178,6 +180,7 @@ public abstract class RGBImageFilter extends ImageFilter
{
if(model == origmodel && (model instanceof IndexColorModel) && canFilterIndexColorModel)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
}
else
@ -185,7 +188,8 @@ public abstract class RGBImageFilter extends ImageFilter
int intPixels[] =
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, intPixels, offset, scansize );
consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), intPixels, offset, scansize);
if (consumer != null)
consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), intPixels, offset, scansize);
}
}
@ -209,6 +213,7 @@ public abstract class RGBImageFilter extends ImageFilter
{
if(model == origmodel && (model instanceof IndexColorModel) && canFilterIndexColorModel)
{
if (consumer != null)
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
}
else
@ -216,7 +221,8 @@ public abstract class RGBImageFilter extends ImageFilter
//FIXME: Store the filtered pixels in a separate temporary buffer?
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, pixels, offset, scansize );
consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), pixels, offset, scansize);
if (consumer != null)
consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), pixels, offset, scansize);
}
}

View file

@ -124,7 +124,8 @@ public class ReplicateScaleFilter extends ImageFilter
destHeight = (int) (height * ((double) destWidth / srcWidth));
}
consumer.setDimensions(destWidth, destHeight);
if (consumer != null)
consumer.setDimensions(destWidth, destHeight);
}
/**
@ -136,7 +137,8 @@ public class ReplicateScaleFilter extends ImageFilter
public void setProperties(Hashtable props)
{
props.put("filters", "ReplicateScaleFilter");
consumer.setProperties(props);
if (consumer != null)
consumer.setProperties(props);
}
/**
@ -165,9 +167,10 @@ public class ReplicateScaleFilter extends ImageFilter
model, pixels, offset, scansize,
rx, ry, destScansize);
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
if (consumer != null)
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
}
/**
@ -196,9 +199,10 @@ public class ReplicateScaleFilter extends ImageFilter
model, pixels, offset, scansize,
rx, ry, destScansize);
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
if (consumer != null)
consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
(int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
model, destPixels, 0, destScansize);
}
private byte[] replicatePixels(int srcx, int srcy, int srcw, int srch,

View file

@ -51,6 +51,7 @@ import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
@ -184,4 +185,48 @@ public interface ComponentPeer
* @since 1.2
*/
void destroyBuffers();
/**
* Get the bounds of this component peer.
*
* @return component peer bounds
* @since 1.5
*/
Rectangle getBounds();
/**
* Reparent this component under another container.
*
* @param parent
* @since 1.5
*/
void reparent(ContainerPeer parent);
/**
* Set the bounds of this component peer.
*
* @param x the new x co-ordinate
* @param y the new y co-ordinate
* @param width the new width
* @param height the new height
* @param z the new stacking level
* @since 1.5
*/
void setBounds (int x, int y, int width, int height, int z);
/**
* Check if this component supports being reparented.
*
* @return true if this component can be reparented,
* false otherwise.
* @since 1.5
*/
boolean isReparentSupported();
/**
* Layout this component peer.
*
* @since 1.5
*/
void layout();
}

View file

@ -54,6 +54,31 @@ public interface ContainerPeer extends ComponentPeer
void endLayout();
boolean isPaintPending();
/**
* Check if this container peer can be restacked.
*
* @return true if this container peer supports being restacked, false otherwise
* @since 1.5
*/
boolean isRestackSupported();
/**
* Cancel a pending paint event on a region of this container.
*
* @param x the x co-ordinate of the region
* @param y the y co-ordinate of the region
* @param width the width of the region
* @param height the height of the region
* @since 1.5
*/
void cancelPendingPaint(int x, int y, int width, int height);
/**
* Restack the component peers in this container peer.
*
* @since 1.5
*/
void restack();
} // interface ContainerPeer

View file

@ -51,5 +51,25 @@ public interface FramePeer extends WindowPeer
int getState();
void setState(int state);
void setMaximizedBounds(Rectangle r);
/**
* Check if this frame peer supports being restacked.
*
* @return true if this frame peer can be restacked,
* false otherwise
* @since 1.5
*/
boolean isRestackSupported();
/**
* Sets the bounds of this frame peer.
*
* @param x the new x co-ordinate
* @param y the new y co-ordinate
* @param width the new width
* @param height the new height
* @since 1.5
*/
void setBoundsPrivate(int x, int y, int width, int height);
} // interface FramePeer

View file

@ -42,6 +42,7 @@ import java.awt.Menu;
public interface MenuBarPeer extends MenuComponentPeer
{
void addMenu(Menu m);
void addHelpMenu(Menu menu);
void delMenu(int index);
} // interface MenuBarPeer

View file

@ -38,8 +38,18 @@ exception statement from your version. */
package java.awt.peer;
import java.awt.Font;
public interface MenuComponentPeer
{
void dispose();
/**
* Set the font on this menu component peer.
*
* @param font the new font
* @since 1.5
*/
void setFont (Font font);
} // interface MenuComponentPeer

View file

@ -43,6 +43,7 @@ import java.awt.MenuItem;
public interface MenuPeer extends MenuItemPeer
{
void addItem (MenuItem item);
void addSeparator ();
void delItem (int index);
}

View file

@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt.peer;
import java.awt.Rectangle;
import java.awt.im.InputMethodRequests;
public interface TextComponentPeer extends ComponentPeer
{
@ -53,5 +54,13 @@ public interface TextComponentPeer extends ComponentPeer
int getIndexAtPoint(int x, int y);
Rectangle getCharacterBounds(int pos);
long filterEvents(long filter);
/**
* Retrieve this text component peer's input method requests.
*
* @return the input method requests made by this text component peer
* @since 1.5
*/
InputMethodRequests getInputMethodRequests();
} // interface TextComponentPeer

View file

@ -42,5 +42,19 @@ public interface WindowPeer extends ContainerPeer
{
void toBack();
void toFront();
/**
* FIXME: unknown.
* @since 1.5
*/
void updateAlwaysOnTop();
/**
* Request that this window peer be given the window focus.
*
* @return true if the window received focus, false otherwise
* @since 1.5
*/
boolean requestWindowFocus();
} // interface WindowPeer