aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/awt/Component.java403
-rw-r--r--libjava/java/awt/Container.java12
-rw-r--r--libjava/java/awt/DefaultKeyboardFocusManager.java34
-rw-r--r--libjava/java/awt/Event.java3
-rw-r--r--libjava/java/awt/Font.java5
-rw-r--r--libjava/java/awt/Frame.java95
-rw-r--r--libjava/java/awt/GridBagLayout.java2
-rw-r--r--libjava/java/awt/KeyboardFocusManager.java5
-rw-r--r--libjava/java/awt/Panel.java63
-rw-r--r--libjava/java/awt/ScrollPane.java26
-rw-r--r--libjava/java/awt/Window.java50
-rw-r--r--libjava/java/awt/image/BufferedImage.java54
-rw-r--r--libjava/java/awt/image/ByteLookupTable.java162
-rw-r--r--libjava/java/awt/image/ColorModel.java5
-rw-r--r--libjava/java/awt/image/Kernel.java136
-rw-r--r--libjava/java/awt/image/LookupTable.java109
-rw-r--r--libjava/java/awt/image/MemoryImageSource.java45
-rw-r--r--libjava/java/awt/image/RGBImageFilter.java4
-rw-r--r--libjava/java/awt/image/ShortLookupTable.java162
19 files changed, 1215 insertions, 160 deletions
diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java
index f3153da..5cb792b 100644
--- a/libjava/java/awt/Component.java
+++ b/libjava/java/awt/Component.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt;
import java.awt.dnd.DropTarget;
+import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
@@ -48,6 +49,7 @@ import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
+import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.MouseEvent;
@@ -1175,30 +1177,7 @@ public abstract class Component
*/
public void move(int x, int y)
{
- int oldx = this.x;
- int oldy = this.y;
-
- if (this.x == x && this.y == y)
- return;
- invalidate ();
- this.x = x;
- this.y = y;
- if (peer != null)
- peer.setBounds (x, y, width, height);
-
- // Erase old bounds and repaint new bounds for lightweights.
- if (isLightweight() && width != 0 && height !=0)
- {
- parent.repaint(oldx, oldy, width, height);
- repaint();
- }
-
- if (oldx != x || oldy != y)
- {
- ComponentEvent ce = new ComponentEvent(this,
- ComponentEvent.COMPONENT_MOVED);
- getToolkit().getSystemEventQueue().postEvent(ce);
- }
+ setBounds(x, y, this.width, this.height);
}
/**
@@ -1262,32 +1241,7 @@ public abstract class Component
*/
public void resize(int width, int height)
{
- int oldwidth = this.width;
- int oldheight = this.height;
-
- if (this.width == width && this.height == height)
- return;
- invalidate ();
- 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())
- {
- if (oldwidth != 0 && oldheight != 0 && parent != null)
- parent.repaint(x, y, oldwidth, oldheight);
- if (width != 0 && height != 0)
- repaint();
- }
-
- if (oldwidth != width || oldheight != height)
- {
- ComponentEvent ce =
- new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
- getToolkit().getSystemEventQueue().postEvent(ce);
- }
+ setBounds(this.x, this.y, width, height);
}
/**
@@ -1395,9 +1349,25 @@ public abstract class Component
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight())
{
- if (oldwidth != 0 && oldheight != 0 && parent != null)
+ boolean shouldRepaintParent = false;
+ boolean shouldRepaintSelf = false;
+
+ if (parent != null)
+ {
+ Rectangle parentBounds = parent.getBounds();
+ Rectangle oldBounds = new Rectangle(parent.getX() + oldx,
+ parent.getY() + oldy,
+ oldwidth, oldheight);
+ Rectangle newBounds = new Rectangle(parent.getX() + x,
+ parent.getY() + y,
+ width, height);
+ shouldRepaintParent = parentBounds.intersects(oldBounds);
+ shouldRepaintSelf = parentBounds.intersects(newBounds);
+ }
+
+ if (shouldRepaintParent)
parent.repaint(oldx, oldy, oldwidth, oldheight);
- if (width != 0 && height != 0)
+ if (shouldRepaintSelf)
repaint();
}
@@ -2255,14 +2225,17 @@ public abstract class Component
}
/**
- * AWT 1.0 event dispatcher.
+ * AWT 1.0 event delivery.
*
- * @param e the event to dispatch
+ * Deliver an AWT 1.0 event to this Component. This method simply
+ * calls {@link #postEvent}.
+ *
+ * @param e the event to deliver
* @deprecated use {@link #dispatchEvent(AWTEvent)} instead
*/
public void deliverEvent(Event e)
{
- // XXX Add backward compatibility handling.
+ postEvent (e);
}
/**
@@ -2284,16 +2257,24 @@ public abstract class Component
}
/**
- * AWT 1.0 event dispatcher.
+ * AWT 1.0 event handler.
*
- * @param e the event to dispatch
- * @return false: since the method was deprecated, the return has no meaning
+ * This method simply calls handleEvent and returns the result.
+ *
+ * @param e the event to handle
+ * @return the result of handling <code>e</code>
* @deprecated use {@link #dispatchEvent(AWTEvent)} instead
*/
public boolean postEvent(Event e)
{
- // XXX Add backward compatibility handling.
- return false;
+ boolean handled = handleEvent (e);
+
+ if (!handled)
+ // FIXME: need to translate event coordinates to parent's
+ // coordinate space.
+ handled = getParent ().postEvent (e);
+
+ return handled;
}
/**
@@ -3170,20 +3151,61 @@ public abstract class Component
}
/**
- * AWT 1.0 event processor.
+ * AWT 1.0 event handler.
+ *
+ * This method calls one of the event-specific handler methods. For
+ * example for key events, either {@link #keyDown (Event evt, int
+ * key)} or {@link keyUp (Event evt, int key)} is called. A derived
+ * component can override one of these event-specific methods if it
+ * only needs to handle certain event types. Otherwise it can
+ * override handleEvent itself and handle any event.
*
* @param evt the event to handle
- * @return false: since the method was deprecated, the return has no meaning
+ * @return true if the event was handled, false otherwise
* @deprecated use {@link #processEvent(AWTEvent)} instead
*/
public boolean handleEvent(Event evt)
{
- // XXX Add backward compatibility handling.
+ switch (evt.id)
+ {
+ // Handle key events.
+ case Event.KEY_ACTION:
+ case Event.KEY_PRESS:
+ return keyDown (evt, evt.key);
+ case Event.KEY_ACTION_RELEASE:
+ case Event.KEY_RELEASE:
+ return keyUp (evt, evt.key);
+
+ // Handle mouse events.
+ case Event.MOUSE_DOWN:
+ return mouseDown (evt, evt.x, evt.y);
+ case Event.MOUSE_UP:
+ return mouseUp (evt, evt.x, evt.y);
+ case Event.MOUSE_MOVE:
+ return mouseMove (evt, evt.x, evt.y);
+ case Event.MOUSE_DRAG:
+ return mouseDrag (evt, evt.x, evt.y);
+ case Event.MOUSE_ENTER:
+ return mouseEnter (evt, evt.x, evt.y);
+ case Event.MOUSE_EXIT:
+ return mouseExit (evt, evt.x, evt.y);
+
+ // Handle focus events.
+ case Event.GOT_FOCUS:
+ return gotFocus (evt, evt.arg);
+ case Event.LOST_FOCUS:
+ return lostFocus (evt, evt.arg);
+
+ // Handle action event.
+ case Event.ACTION_EVENT:
+ return action (evt, evt.arg);
+ }
+ // Unknown event.
return false;
}
/**
- * AWT 1.0 mouse event.
+ * AWT 1.0 mouse event handler.
*
* @param evt the event to handle
* @param x the x coordinate, ignored
@@ -3686,7 +3708,20 @@ public abstract class Component
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
- eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED));
+ synchronized (eq)
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
+ if (currentFocusOwner != null)
+ {
+ eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+ false, this));
+ eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false,
+ currentFocusOwner));
+ }
+ else
+ eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false));
+ }
}
}
else
@@ -3759,9 +3794,25 @@ public abstract class Component
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
+ synchronized (eq)
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
+ if (currentFocusOwner != null)
+ {
+ eq.postEvent (new FocusEvent(currentFocusOwner,
+ FocusEvent.FOCUS_LOST,
+ temporary, this));
+ eq.postEvent (new FocusEvent(this,
+ FocusEvent.FOCUS_GAINED,
+ temporary,
+ currentFocusOwner));
+ }
+ else
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
}
}
+ }
else
// FIXME: need to add a focus listener to our top-level
// ancestor, so that we can post this event when it becomes
@@ -3852,7 +3903,8 @@ public abstract class Component
// Check if top-level ancestor is currently focused window.
if (focusedWindow == toplevel)
{
- if (peer != null)
+ if (peer != null
+ && !(this instanceof Window))
// This call will cause a FOCUS_GAINED event to be
// posted to the system event queue if the native
// windowing system grants the focus request.
@@ -3863,9 +3915,21 @@ public abstract class Component
// lightweight component. In either case we want to
// post a FOCUS_GAINED event.
EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
+ synchronized (eq)
+ {
+ Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
+ if (currentFocusOwner != null)
+ {
+ eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+ temporary, this));
+ eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary,
+ currentFocusOwner));
+ }
+ else
eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, temporary));
}
}
+ }
else
return false;
}
@@ -4041,8 +4105,8 @@ public abstract class Component
String name = getName();
if (name != null)
param.append(name).append(",");
- param.append(width).append("x").append(height).append("+").append(x)
- .append("+").append(y);
+ param.append(x).append(",").append(y).append(",").append(width)
+ .append("x").append(height);
if (! isValid())
param.append(",invalid");
if (! isVisible())
@@ -4410,13 +4474,212 @@ p * <li>the set of backward traversal keys
}
/**
- * Implementation of dispatchEvent. Allows trusted package classes to
- * dispatch additional events first.
+ * Translate an AWT 1.1 event ({@link AWTEvent}) into an AWT 1.0
+ * event ({@link Event}).
+ *
+ * @param e an AWT 1.1 event to translate
+ *
+ * @return an AWT 1.0 event representing e
+ */
+ private Event translateEvent (AWTEvent e)
+ {
+ Component target = (Component) e.getSource ();
+ Event translated = null;
+
+ if (e instanceof InputEvent)
+ {
+ InputEvent ie = (InputEvent) e;
+ long when = ie.getWhen ();
+
+ int oldID = 0;
+ int id = e.getID ();
+
+ int oldMods = 0;
+ int mods = ie.getModifiers ();
+
+ if ((mods & InputEvent.BUTTON2_MASK) != 0)
+ oldMods |= Event.META_MASK;
+ else if ((mods & InputEvent.BUTTON3_MASK) != 0)
+ oldMods |= Event.ALT_MASK;
+
+ if ((mods & (InputEvent.SHIFT_MASK | InputEvent.SHIFT_DOWN_MASK)) != 0)
+ oldMods |= Event.SHIFT_MASK;
+
+ if ((mods & (InputEvent.CTRL_MASK | InputEvent.CTRL_DOWN_MASK)) != 0)
+ oldMods |= Event.CTRL_MASK;
+
+ if ((mods & (InputEvent.META_MASK | InputEvent.META_DOWN_MASK)) != 0)
+ oldMods |= Event.META_MASK;
+
+ if ((mods & (InputEvent.ALT_MASK | InputEvent.ALT_DOWN_MASK)) != 0)
+ oldMods |= Event.ALT_MASK;
+
+ if (e instanceof MouseEvent)
+ {
+ if (id == MouseEvent.MOUSE_PRESSED)
+ oldID = Event.MOUSE_DOWN;
+ else if (id == MouseEvent.MOUSE_RELEASED)
+ oldID = Event.MOUSE_UP;
+ else if (id == MouseEvent.MOUSE_MOVED)
+ oldID = Event.MOUSE_MOVE;
+ else if (id == MouseEvent.MOUSE_DRAGGED)
+ oldID = Event.MOUSE_DRAG;
+ else if (id == MouseEvent.MOUSE_ENTERED)
+ oldID = Event.MOUSE_ENTER;
+ else if (id == MouseEvent.MOUSE_EXITED)
+ oldID = Event.MOUSE_EXIT;
+ else
+ // No analogous AWT 1.0 mouse event.
+ return null;
+
+ MouseEvent me = (MouseEvent) e;
+
+ translated = new Event (target, when, oldID,
+ me.getX (), me.getY (), 0, oldMods);
+ }
+ else if (e instanceof KeyEvent)
+ {
+ if (id == KeyEvent.KEY_PRESSED)
+ oldID = Event.KEY_PRESS;
+ else if (e.getID () == KeyEvent.KEY_RELEASED)
+ oldID = Event.KEY_RELEASE;
+ else
+ // No analogous AWT 1.0 key event.
+ return null;
+
+ int oldKey = 0;
+ int newKey = ((KeyEvent) e).getKeyCode ();
+ switch (newKey)
+ {
+ case KeyEvent.VK_BACK_SPACE:
+ oldKey = Event.BACK_SPACE;
+ break;
+ case KeyEvent.VK_CAPS_LOCK:
+ oldKey = Event.CAPS_LOCK;
+ break;
+ case KeyEvent.VK_DELETE:
+ oldKey = Event.DELETE;
+ break;
+ case KeyEvent.VK_DOWN:
+ case KeyEvent.VK_KP_DOWN:
+ oldKey = Event.DOWN;
+ break;
+ case KeyEvent.VK_END:
+ oldKey = Event.END;
+ break;
+ case KeyEvent.VK_ENTER:
+ oldKey = Event.ENTER;
+ break;
+ case KeyEvent.VK_ESCAPE:
+ oldKey = Event.ESCAPE;
+ break;
+ case KeyEvent.VK_F1:
+ oldKey = Event.F1;
+ break;
+ case KeyEvent.VK_F10:
+ oldKey = Event.F10;
+ break;
+ case KeyEvent.VK_F11:
+ oldKey = Event.F11;
+ break;
+ case KeyEvent.VK_F12:
+ oldKey = Event.F12;
+ break;
+ case KeyEvent.VK_F2:
+ oldKey = Event.F2;
+ break;
+ case KeyEvent.VK_F3:
+ oldKey = Event.F3;
+ break;
+ case KeyEvent.VK_F4:
+ oldKey = Event.F4;
+ break;
+ case KeyEvent.VK_F5:
+ oldKey = Event.F5;
+ break;
+ case KeyEvent.VK_F6:
+ oldKey = Event.F6;
+ break;
+ case KeyEvent.VK_F7:
+ oldKey = Event.F7;
+ break;
+ case KeyEvent.VK_F8:
+ oldKey = Event.F8;
+ break;
+ case KeyEvent.VK_F9:
+ oldKey = Event.F9;
+ break;
+ case KeyEvent.VK_HOME:
+ oldKey = Event.HOME;
+ break;
+ case KeyEvent.VK_INSERT:
+ oldKey = Event.INSERT;
+ break;
+ case KeyEvent.VK_LEFT:
+ case KeyEvent.VK_KP_LEFT:
+ oldKey = Event.LEFT;
+ break;
+ case KeyEvent.VK_NUM_LOCK:
+ oldKey = Event.NUM_LOCK;
+ break;
+ case KeyEvent.VK_PAUSE:
+ oldKey = Event.PAUSE;
+ break;
+ case KeyEvent.VK_PAGE_DOWN:
+ oldKey = Event.PGDN;
+ break;
+ case KeyEvent.VK_PAGE_UP:
+ oldKey = Event.PGUP;
+ break;
+ case KeyEvent.VK_PRINTSCREEN:
+ oldKey = Event.PRINT_SCREEN;
+ break;
+ case KeyEvent.VK_RIGHT:
+ case KeyEvent.VK_KP_RIGHT:
+ oldKey = Event.RIGHT;
+ break;
+ case KeyEvent.VK_SCROLL_LOCK:
+ oldKey = Event.SCROLL_LOCK;
+ break;
+ case KeyEvent.VK_TAB:
+ oldKey = Event.TAB;
+ break;
+ case KeyEvent.VK_UP:
+ case KeyEvent.VK_KP_UP:
+ oldKey = Event.UP;
+ break;
+ default:
+ oldKey = newKey;
+ }
+
+ translated = new Event (target, when, oldID,
+ 0, 0, oldKey, oldMods);
+ }
+ }
+ else if (e instanceof ActionEvent)
+ translated = new Event (target, Event.ACTION_EVENT,
+ ((ActionEvent) e).getActionCommand ());
+
+ return translated;
+ }
+
+ /**
+ * Implementation of dispatchEvent. Allows trusted package classes
+ * to dispatch additional events first. This implementation first
+ * translates <code>e</code> to an AWT 1.0 event and sends the
+ * result to {@link #postEvent}. If the AWT 1.0 event is not
+ * handled, and events of type <code>e</code> are enabled for this
+ * component, e is passed on to {@link #processEvent}.
*
* @param e the event to dispatch
*/
void dispatchEventImpl(AWTEvent e)
{
+ Event oldEvent = translateEvent (e);
+
+ if (oldEvent != null)
+ postEvent (oldEvent);
+
if (eventTypeEnabled (e.id))
processEvent(e);
}
diff --git a/libjava/java/awt/Container.java b/libjava/java/awt/Container.java
index ffd81b4..6c70e94 100644
--- a/libjava/java/awt/Container.java
+++ b/libjava/java/awt/Container.java
@@ -856,6 +856,16 @@ public class Container extends Component
*/
public void deliverEvent(Event e)
{
+ if (!handleEvent (e))
+ {
+ synchronized (getTreeLock ())
+ {
+ Component parent = getParent ();
+
+ if (parent != null)
+ parent.deliverEvent (e);
+ }
+ }
}
/**
@@ -1027,7 +1037,7 @@ public class Container extends Component
{
String param = super.paramString();
if (layoutMgr != null)
- param = param + "," + layoutMgr.getClass().getName();
+ param = param + ",layout=" + layoutMgr.getClass().getName();
return param;
}
diff --git a/libjava/java/awt/DefaultKeyboardFocusManager.java b/libjava/java/awt/DefaultKeyboardFocusManager.java
index c4dd7ea..d4c8bdd 100644
--- a/libjava/java/awt/DefaultKeyboardFocusManager.java
+++ b/libjava/java/awt/DefaultKeyboardFocusManager.java
@@ -162,16 +162,41 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
Component target = (Component) e.getSource ();
- if (e.id == FocusEvent.FOCUS_GAINED
- && !(target instanceof Window))
+ if (e.id == FocusEvent.FOCUS_GAINED)
{
if (((FocusEvent) e).isTemporary ())
setGlobalFocusOwner (target);
else
setGlobalPermanentFocusOwner (target);
}
+ else if (e.id == FocusEvent.FOCUS_LOST)
+ {
+ // We need to set the window's focus owner here; we can't
+ // set it when the window loses focus because by that time
+ // the previous focus owner has already lost focus
+ // (FOCUS_LOST events are delivered before
+ // WINDOW_LOST_FOCUS events).
+
+ // Find the target Component's top-level ancestor.
+ Container parent = target.getParent ();
+
+ while (parent != null
+ && !(parent instanceof Window))
+ parent = parent.getParent ();
+
+ Window toplevel = parent == null ?
+ (Window) target : (Window) parent;
+
+ Component focusOwner = getFocusOwner ();
+ if (focusOwner != null)
+ toplevel.setFocusOwner (focusOwner);
+
+ if (((FocusEvent) e).isTemporary ())
+ setGlobalFocusOwner (null);
+ else
+ setGlobalPermanentFocusOwner (null);
+ }
- if (!(target instanceof Window))
target.dispatchEvent (e);
return true;
@@ -192,6 +217,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
// processKeyEvent checks if this event represents a focus
// traversal key stroke.
Component focusOwner = getGlobalPermanentFocusOwner ();
+
+ if (focusOwner != null)
processKeyEvent (focusOwner, (KeyEvent) e);
if (e.isConsumed ())
@@ -230,6 +257,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager
{
Component focusOwner = getGlobalPermanentFocusOwner ();
+ if (focusOwner != null)
focusOwner.dispatchEvent (e);
// Loop through all registered KeyEventPostProcessors, giving
diff --git a/libjava/java/awt/Event.java b/libjava/java/awt/Event.java
index 79be0e8..57e7c79 100644
--- a/libjava/java/awt/Event.java
+++ b/libjava/java/awt/Event.java
@@ -163,7 +163,8 @@ public class Event implements java.io.Serializable
protected String paramString ()
{
- return "id=" + id + ",x=" + x + ",y=" + y + "target=" + target;
+ return "id=" + id + ",x=" + x + ",y=" + y
+ + ",target=" + target + ",arg=" + arg;
}
public boolean shiftDown()
diff --git a/libjava/java/awt/Font.java b/libjava/java/awt/Font.java
index 4c70c73..6a35147 100644
--- a/libjava/java/awt/Font.java
+++ b/libjava/java/awt/Font.java
@@ -1268,10 +1268,9 @@ toString()
return(getClass().getName()
+ "(logical=" + getName ()
+ ",family=" + getFamily ()
- + ",face=" + getFontName ()
+ + ",name=" + getFontName ()
+ ",style=" + getStyle ()
- + ",size=" + getSize ()
- + ",transform=" + getTransform () + ")");
+ + ",size=" + getSize ());
}
diff --git a/libjava/java/awt/Frame.java b/libjava/java/awt/Frame.java
index c92585a..dd8cdeb 100644
--- a/libjava/java/awt/Frame.java
+++ b/libjava/java/awt/Frame.java
@@ -50,11 +50,6 @@ import java.util.Vector;
*/
public class Frame extends Window implements MenuContainer
{
-
-/*
- * Static Variables
- */
-
/**
* Constant for the default cursor.
* @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
@@ -148,12 +143,6 @@ public static final int NORMAL = 0;
// Serialization version constant
private static final long serialVersionUID = 2673458971256075116L;
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
/**
* @serial The version of the class data being serialized
* // FIXME: what is this value?
@@ -208,11 +197,10 @@ private String title = "";
*/
private boolean undecorated = false;
-/*************************************************************************/
-
/*
- * Constructors
+ * The number used to generate the name returned by getName.
*/
+ private static transient long next_frame_number = 0;
/**
* Initializes a new instance of <code>Frame</code> that is not visible
@@ -224,8 +212,6 @@ Frame()
this("");
}
-/*************************************************************************/
-
/**
* Initializes a new instance of <code>Frame</code> that is not visible
* and has the specified title.
@@ -256,12 +242,6 @@ Frame(String title, GraphicsConfiguration gc)
visible = false;
}
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
/**
* Returns this frame's title string.
*
@@ -273,8 +253,6 @@ getTitle()
return(title);
}
-/*************************************************************************/
-
/*
* Sets this frame's title to the specified value.
*
@@ -288,8 +266,6 @@ setTitle(String title)
((FramePeer) peer).setTitle(title);
}
-/*************************************************************************/
-
/**
* Returns this frame's icon.
*
@@ -302,8 +278,6 @@ getIconImage()
return(icon);
}
-/*************************************************************************/
-
/**
* Sets this frame's icon to the specified value.
*
@@ -317,8 +291,6 @@ setIconImage(Image icon)
((FramePeer) peer).setIconImage(icon);
}
-/*************************************************************************/
-
/**
* Returns this frame's menu bar.
*
@@ -331,8 +303,6 @@ getMenuBar()
return(menuBar);
}
-/*************************************************************************/
-
/**
* Sets this frame's menu bar.
*
@@ -352,8 +322,6 @@ setMenuBar(MenuBar menuBar)
this.menuBar = menuBar;
}
-/*************************************************************************/
-
/**
* Tests whether or not this frame is resizable. This will be
* <code>true</code> by default.
@@ -367,8 +335,6 @@ isResizable()
return(resizable);
}
-/*************************************************************************/
-
/**
* Sets the resizability of this frame to the specified value.
*
@@ -383,8 +349,6 @@ setResizable(boolean resizable)
((FramePeer) peer).setResizable(resizable);
}
-/*************************************************************************/
-
/**
* Returns the cursor type of the cursor for this window. This will
* be one of the constants in this class.
@@ -399,8 +363,6 @@ getCursorType()
return(getCursor().getType());
}
-/*************************************************************************/
-
/**
* Sets the cursor for this window to the specified type. The specified
* type should be one of the constants in this class.
@@ -415,8 +377,6 @@ setCursor(int type)
setCursor(new Cursor(type));
}
-/*************************************************************************/
-
/**
* Removes the specified component from this frame's menu.
*
@@ -428,8 +388,6 @@ remove(MenuComponent menu)
menuBar.remove(menu);
}
-/*************************************************************************/
-
/**
* Notifies this frame that it should create its native peer.
*/
@@ -450,17 +408,40 @@ public void removeNotify()
super.removeNotify();
}
-/*************************************************************************/
-
/**
* Returns a debugging string describing this window.
*
* @return A debugging string describing this window.
*/
-protected String
-paramString()
+ protected String paramString ()
{
- return(getClass().getName());
+ String title = getTitle ();
+
+ String resizable = "";
+ if (isResizable ())
+ resizable = ",resizable";
+
+ String state = "";
+ switch (getState ())
+ {
+ case NORMAL:
+ state = ",normal";
+ break;
+ case ICONIFIED:
+ state = ",iconified";
+ break;
+ case MAXIMIZED_BOTH:
+ state = ",maximized-both";
+ break;
+ case MAXIMIZED_HORIZ:
+ state = ",maximized-horiz";
+ break;
+ case MAXIMIZED_VERT:
+ state = ",maximized-vert";
+ break;
+ }
+
+ return super.paramString () + ",title=" + title + resizable + state;
}
public static Frame[]
@@ -553,5 +534,19 @@ getFrames()
this.undecorated = undecorated;
}
-} // class Frame
+ /**
+ * Generate a unique name for this frame.
+ *
+ * @return A unique name for this frame.
+ */
+ String generateName ()
+ {
+ return "frame" + getUniqueLong ();
+ }
+
+ private static synchronized long getUniqueLong ()
+ {
+ return next_frame_number++;
+ }
+}
diff --git a/libjava/java/awt/GridBagLayout.java b/libjava/java/awt/GridBagLayout.java
index b98359c..1239f2c 100644
--- a/libjava/java/awt/GridBagLayout.java
+++ b/libjava/java/awt/GridBagLayout.java
@@ -340,7 +340,7 @@ public class GridBagLayout
if (components.length == 0)
return;
- GridBagLayoutInfo info = getLayoutInfo (parent, MINSIZE);
+ GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
if (info.cols == 0 && info.rows == 0)
return;
layoutInfo = info;
diff --git a/libjava/java/awt/KeyboardFocusManager.java b/libjava/java/awt/KeyboardFocusManager.java
index 8ebd9e171..e82c0d4 100644
--- a/libjava/java/awt/KeyboardFocusManager.java
+++ b/libjava/java/awt/KeyboardFocusManager.java
@@ -246,7 +246,10 @@ public abstract class KeyboardFocusManager
*/
public Component getFocusOwner ()
{
- return (Component) getObject (currentFocusOwners);
+ Component owner = (Component) getObject (currentFocusOwners);
+ if (owner == null)
+ owner = (Component) getObject (currentPermanentFocusOwners);
+ return owner;
}
/**
diff --git a/libjava/java/awt/Panel.java b/libjava/java/awt/Panel.java
index b84c0d0..dbe3228 100644
--- a/libjava/java/awt/Panel.java
+++ b/libjava/java/awt/Panel.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package java.awt;
+import java.awt.event.PaintEvent;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleRole;
@@ -62,6 +63,19 @@ public class Panel extends Container implements Accessible
/** The cached accessible context. */
private transient AccessibleContext context;
+ /** Flag set when the first system-requested paint event is
+ dispatched. */
+ private transient boolean initialSystemUpdateDone;
+
+ /** Flag set when the first application-requested paint event is
+ consumed. */
+ private transient boolean initialUpdateConsumed;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_panel_number = 0;
+
/**
* Initializes a new instance of <code>Panel</code> that has a default
* layout manager of <code>FlowLayout</code>.
@@ -84,6 +98,36 @@ public class Panel extends Container implements Accessible
}
/**
+ * Consume initial application-requested paint event if it has not
+ * already been consumed, and if the initial system-requested paint
+ * event has not already been handled. Otherwise, call
+ * super.dispatchEventImpl. These extra steps are required to
+ * prevent a Panel from being painted twice when it is initially
+ * shown.
+ *
+ * @param e the event to dispatch
+ */
+ void dispatchEventImpl (AWTEvent e)
+ {
+ if (e instanceof PaintEvent)
+ {
+ if (e.id == PaintEvent.UPDATE)
+ {
+ if (!initialUpdateConsumed
+ && !initialSystemUpdateDone)
+ {
+ e.consume ();
+ initialUpdateConsumed = true;
+ }
+ }
+ else if (e.id == PaintEvent.PAINT)
+ initialSystemUpdateDone = true;
+ }
+ else
+ super.dispatchEventImpl (e);
+ }
+
+ /**
* Notifies this object to create its native peer.
*
* @see #isDisplayable()
@@ -141,5 +185,20 @@ public class Panel extends Container implements Accessible
{
return AccessibleRole.PANEL;
}
- } // class AccessibleAWTPanel
-} // class Panel
+ }
+
+ /**
+ * Generate a unique name for this panel.
+ *
+ * @return A unique name for this panel.
+ */
+ String generateName ()
+ {
+ return "panel" + getUniqueLong ();
+ }
+
+ private static synchronized long getUniqueLong ()
+ {
+ return next_panel_number++;
+ }
+}
diff --git a/libjava/java/awt/ScrollPane.java b/libjava/java/awt/ScrollPane.java
index b772bee..457df0c 100644
--- a/libjava/java/awt/ScrollPane.java
+++ b/libjava/java/awt/ScrollPane.java
@@ -157,6 +157,9 @@ ScrollPane(int scrollbarDisplayPolicy)
}
wheelScrollingEnabled = true;
+
+ // Default size.
+ setSize(100,100);
}
/*************************************************************************/
@@ -400,6 +403,15 @@ addNotify()
setPeer((ComponentPeer)getToolkit().createScrollPane(this));
super.addNotify();
+
+ Component[] list = getComponents();
+ if (list != null && list.length > 0 && ! (list[0] instanceof Panel))
+ {
+ Panel panel = new Panel();
+ panel.setLayout(new BorderLayout());
+ panel.add(list[0], BorderLayout.CENTER);
+ add(panel);
+ }
}
/*************************************************************************/
@@ -527,7 +539,19 @@ printComponents(Graphics graphics)
public String
paramString()
{
- return(getClass().getName());
+ Insets insets = getInsets();
+ return getName() + ","
+ + getX() + ","
+ + getY() + ","
+ + getWidth() + "x" + getHeight() + ","
+ + "ScrollPosition=(" + scrollPosition.getX() + ","
+ + scrollPosition.getY() + "),"
+ + "Insets=(" + insets.top + ","
+ + insets.left + ","
+ + insets.bottom + ","
+ + insets.right + "),"
+ + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + ","
+ + "wheelScrollingEnabled=" + isWheelScrollingEnabled();
}
/**
diff --git a/libjava/java/awt/Window.java b/libjava/java/awt/Window.java
index 7fa471e..7397a1c 100644
--- a/libjava/java/awt/Window.java
+++ b/libjava/java/awt/Window.java
@@ -39,6 +39,8 @@ exception statement from your version. */
package java.awt;
import java.awt.event.ComponentEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.awt.event.WindowListener;
@@ -85,6 +87,8 @@ public class Window extends Container implements Accessible
private transient boolean shown;
+ private transient Component windowFocusOwner;
+
/**
* This (package access) constructor is used by subclasses that want
* to build windows that do not have parents. Eg. toplevel
@@ -98,6 +102,33 @@ public class Window extends Container implements Accessible
// cycle roots.
focusCycleRoot = true;
setLayout(new BorderLayout());
+
+ addWindowFocusListener (new WindowAdapter ()
+ {
+ public void windowGainedFocus (WindowEvent event)
+ {
+ if (windowFocusOwner != null)
+ {
+ // FIXME: move this section and the other similar
+ // sections in Component into a separate method.
+ EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
+ synchronized (eq)
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();
+ if (currentFocusOwner != null)
+ {
+ eq.postEvent (new FocusEvent (currentFocusOwner, FocusEvent.FOCUS_LOST,
+ false, windowFocusOwner));
+ eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED,
+ false, currentFocusOwner));
+ }
+ else
+ eq.postEvent (new FocusEvent (windowFocusOwner, FocusEvent.FOCUS_GAINED, false));
+ }
+ }
+ }
+ });
}
Window(GraphicsConfiguration gc)
@@ -658,8 +689,22 @@ public class Window extends Container implements Accessible
// The currently-focused Component belongs to the active Window.
if (activeWindow == this)
return manager.getFocusOwner ();
+ else
+ return windowFocusOwner;
+ }
- return null;
+ /**
+ * Set the focus owner for this window. This method is used to
+ * remember which component was focused when this window lost
+ * top-level focus, so that when it regains top-level focus the same
+ * child component can be refocused.
+ *
+ * @param windowFocusOwner the component in this window that owns
+ * the focus.
+ */
+ void setFocusOwner (Component windowFocusOwner)
+ {
+ this.windowFocusOwner = windowFocusOwner;
}
/**
@@ -671,8 +716,7 @@ public class Window extends Container implements Accessible
*/
public boolean postEvent(Event e)
{
- // FIXME
- return false;
+ return handleEvent (e);
}
/**
diff --git a/libjava/java/awt/image/BufferedImage.java b/libjava/java/awt/image/BufferedImage.java
index 547301d..b18779a 100644
--- a/libjava/java/awt/image/BufferedImage.java
+++ b/libjava/java/awt/image/BufferedImage.java
@@ -47,6 +47,8 @@ import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.util.Hashtable;
import java.util.Vector;
+import java.util.HashSet;
+import java.util.Iterator;
import gnu.java.awt.ComponentDataBlitOp;
/**
@@ -442,7 +444,57 @@ public class BufferedImage extends Image
public ImageProducer getSource()
{
- throw new UnsupportedOperationException("not implemented");
+ return new ImageProducer() {
+
+ HashSet consumers = new HashSet();
+
+ public void addConsumer(ImageConsumer ic)
+ {
+ consumers.add(ic);
+ }
+
+ public boolean isConsumer(ImageConsumer ic)
+ {
+ return consumers.contains(ic);
+ }
+
+ public void removeConsumer(ImageConsumer ic)
+ {
+ consumers.remove(ic);
+ }
+
+ public void startProduction(ImageConsumer ic)
+ {
+ int x = 0;
+ int y = 0;
+ int width = getWidth();
+ int height = getHeight();
+ int stride = width;
+ int offset = 0;
+ int[] pixels = getRGB(x, y,
+ width, height,
+ (int[])null, offset, stride);
+ ColorModel model = getColorModel();
+
+ consumers.add(ic);
+
+ Iterator i = consumers.iterator();
+ while(i.hasNext())
+ {
+ ImageConsumer c = (ImageConsumer) i.next();
+ c.setHints(ImageConsumer.SINGLEPASS);
+ c.setDimensions(getWidth(), getHeight());
+ c.setPixels(x, y, width, height, model, pixels, offset, stride);
+ c.imageComplete(ImageConsumer.STATICIMAGEDONE);
+ }
+ }
+
+ public void requestTopDownLeftRightResend(ImageConsumer ic)
+ {
+ startProduction(ic);
+ }
+
+ };
}
public Vector getSources()
diff --git a/libjava/java/awt/image/ByteLookupTable.java b/libjava/java/awt/image/ByteLookupTable.java
new file mode 100644
index 0000000..572f6e9
--- /dev/null
+++ b/libjava/java/awt/image/ByteLookupTable.java
@@ -0,0 +1,162 @@
+/* ByteLookupTable.java -- Java class for a pixel translation table.
+ Copyright (C) 2004 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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.image;
+
+/**
+ * ByteLookupTable represents translation arrays for pixel values. It wraps
+ * one or more data arrays for each layer (or component) in an image, such as
+ * Alpha, R, G, and B. When doing translation, the offset is subtracted from
+ * the pixel values to allow a subset of an array to be used.
+ *
+ * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
+ * @version 1.0
+ */
+public class ByteLookupTable extends LookupTable
+{
+ // Array of translation tables.
+ private byte data[][];
+
+ /**
+ * Creates a new <code>ByteLookupTable</code> instance.
+ *
+ * Offset is subtracted from pixel values when looking up in the translation
+ * tables. If data.length is one, the same table is applied to all pixel
+ * components.
+ *
+ * @param offset Offset to be subtracted.
+ * @param data Array of lookup tables.
+ * @exception IllegalArgumentException if offset < 0 or data.length < 1.
+ */
+ public ByteLookupTable(int offset, byte[][] data)
+ throws IllegalArgumentException
+ {
+ super(offset, data.length);
+ this.data = data;
+ }
+
+ /**
+ * Creates a new <code>ByteLookupTable</code> instance.
+ *
+ * Offset is subtracted from pixel values when looking up in the translation
+ * table. The same table is applied to all pixel components.
+ *
+ * @param offset Offset to be subtracted.
+ * @param data Lookup table for all components.
+ * @exception IllegalArgumentException if offset < 0.
+ */
+ public ByteLookupTable(int offset, byte[] data)
+ throws IllegalArgumentException
+ {
+ super(offset, 1);
+ this.data = new byte[][] {data};
+ }
+
+ /** Return the lookup tables. */
+ public final byte[][] getTable()
+ {
+ return data;
+ }
+
+ /**
+ * Return translated values for a pixel.
+ *
+ * For each value in the pixel src, use the value minus offset as an index
+ * in the component array and copy the value there to the output for the
+ * component. If dest is null, the output is a new array, otherwise the
+ * translated values are written to dest. Dest can be the same array as
+ * src.
+ *
+ * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+ * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+ * translation arrays.
+ *
+ * @param src Component values of a pixel.
+ * @param dest Destination array for values, or null.
+ * @return Translated values for the pixel.
+ */
+ public int[] lookupPixel(int[] src, int[] dst)
+ throws ArrayIndexOutOfBoundsException
+ {
+ if (dst == null)
+ dst = new int[numComponents];
+
+ if (data.length == 1)
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[0][src[i] - offset];
+ else
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[i][src[i] - offset];
+
+ return dst;
+ }
+
+ /**
+ * Return translated values for a pixel.
+ *
+ * For each value in the pixel src, use the value minus offset as an index
+ * in the component array and copy the value there to the output for the
+ * component. If dest is null, the output is a new array, otherwise the
+ * translated values are written to dest. Dest can be the same array as
+ * src.
+ *
+ * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+ * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+ * translation arrays.
+ *
+ * @param src Component values of a pixel.
+ * @param dest Destination array for values, or null.
+ * @return Translated values for the pixel.
+ */
+ public byte[] lookupPixel(byte[] src, byte[] dst)
+ throws ArrayIndexOutOfBoundsException
+ {
+ if (dst == null)
+ dst = new byte[numComponents];
+
+ if (data.length == 1)
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[0][((int)src[i]) - offset];
+ else
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[i][((int)src[i]) - offset];
+
+ return dst;
+
+ }
+}
diff --git a/libjava/java/awt/image/ColorModel.java b/libjava/java/awt/image/ColorModel.java
index c73f4fd..87ab942 100644
--- a/libjava/java/awt/image/ColorModel.java
+++ b/libjava/java/awt/image/ColorModel.java
@@ -37,6 +37,7 @@ exception statement from your version. */
package java.awt.image;
+import java.util.Arrays;
import java.awt.Point;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
@@ -551,8 +552,8 @@ public abstract class ColorModel implements Transparency
(transferType == o.transferType) &&
(transparency == o.transparency) &&
(hasAlpha == o.hasAlpha) &&
- (isAlphaPremultiplied == isAlphaPremultiplied) &&
- (bits.equals(o.bits)) &&
+ (isAlphaPremultiplied == o.isAlphaPremultiplied) &&
+ Arrays.equals(bits, o.bits) &&
(cspace.equals(o.cspace));
}
diff --git a/libjava/java/awt/image/Kernel.java b/libjava/java/awt/image/Kernel.java
new file mode 100644
index 0000000..27d6ddd
--- /dev/null
+++ b/libjava/java/awt/image/Kernel.java
@@ -0,0 +1,136 @@
+/* Kernel.java -- Java class for an image processing kernel
+ Copyright (C) 2004 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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.image;
+
+/**
+ * Kernel represents an image processing kernel. It gets used to hold
+ * convolution filters among other purposes. It stores an array of float
+ * values representing a 2-dimensional array in row-major order.
+ *
+ * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
+ * @version 1.0
+ */
+public class Kernel implements Cloneable
+{
+ private final int width;
+ private final int height;
+ private final float[] data;
+
+ /**
+ * Creates a new <code>Kernel</code> instance.
+ *
+ * @param width The 2D width of data.
+ * @param height The 2D height of data.
+ * @param data The source data array.
+ * @exception IllegalArgumentException if width * height < data.length.
+ */
+ public Kernel(int width, int height, float[] data)
+ throws IllegalArgumentException
+ {
+ this.width = width;
+ this.height = height;
+ if (data.length < width * height || width < 0 || height < 0)
+ throw new IllegalArgumentException();
+ this.data = new float[width * height];
+ System.arraycopy(data, 0, this.data, 0, width * height);
+ }
+
+ /**
+ * Return the X origin: (width - 1) / 2
+ */
+ public final int getXOrigin()
+ {
+ return (width - 1) / 2;
+ }
+
+ /**
+ * Return the Y origin: (height - 1) / 2
+ */
+ public final int getYOrigin()
+ {
+ return (height - 1) / 2;
+ }
+
+ /**
+ * @return The kernel width.
+ */
+ public final int getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * @return The kernel height.
+ */
+ public final int getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Return the kernel data.
+ *
+ * If data is null, allocates a new array and returns it. Otherwise, the
+ * kernel values are copied into data.
+ *
+ * @param data Array to copy values into, or null.
+ * @return The array with copied values.
+ * @exception IllegalArgumentException if data != null and too small.
+ */
+ public final float[] getKernelData(float[] data)
+ throws IllegalArgumentException
+ {
+ if (data == null)
+ return (float[])this.data.clone();
+
+ if (data.length < this.data.length)
+ throw new IllegalArgumentException();
+
+ System.arraycopy(this.data, 0, data, 0, this.data.length);
+ return data;
+ }
+
+ /**
+ * @return a clone of this Kernel.
+ */
+ public Object clone()
+ {
+ return new Kernel(width, height, data);
+ }
+}
diff --git a/libjava/java/awt/image/LookupTable.java b/libjava/java/awt/image/LookupTable.java
new file mode 100644
index 0000000..eb89795
--- /dev/null
+++ b/libjava/java/awt/image/LookupTable.java
@@ -0,0 +1,109 @@
+/* LookupTable.java -- Java class for a pixel translation table.
+ Copyright (C) 2004 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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.image;
+
+/**
+ * LookupTable represents translation arrays for pixel values. It wraps one
+ * or more data arrays for each layer (or component) in an image, such as
+ * Alpha, R, G, and B. When doing translation, the offset is subtracted from
+ * the pixel values to allow a subset of an array to be used.
+ *
+ * @see ByteLookupTable
+ * @see ShortLookupTable
+ *
+ * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
+ * @version 1.0
+ */
+public abstract class LookupTable
+{
+ // Not protected since that's part of the public API.
+ int offset;
+ int numComponents;
+
+ /**
+ * Creates a new <code>LookupTable</code> instance.
+ *
+ * If numComponents is 1, the same translation table is used for all pixel
+ * components.
+ *
+ * @param offset Offset to be subtracted.
+ * @param numComponents Number of image components.
+ * @exception IllegalArgumentException if offset < 0 or numComponents < 1.
+ */
+ protected LookupTable(int offset, int numComponents)
+ throws IllegalArgumentException
+ {
+ if (offset < 0 || numComponents < 1)
+ throw new IllegalArgumentException();
+ this.offset = offset;
+ this.numComponents = numComponents;
+ }
+
+ /** Return the number of components. */
+ public int getNumComponents()
+ {
+ return numComponents;
+ }
+
+ /** Return the offset. */
+ public int getOffset()
+ {
+ return offset;
+ }
+
+
+ /**
+ * Return translated values for a pixel.
+ *
+ * For each value in the pixel src, use the value minus offset as an index
+ * in the component array and copy the value there to the output for the
+ * component. If dest is null, the output is a new array, otherwise the
+ * translated values are written to dest. Dest can be the same array as
+ * src.
+ *
+ * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+ * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+ * translation arrays.
+ *
+ * @param src Component values of a pixel.
+ * @param dest Destination array for values, or null.
+ * @return Translated values for the pixel.
+ */
+ public abstract int[] lookupPixel(int[] src, int[] dest);
+}
diff --git a/libjava/java/awt/image/MemoryImageSource.java b/libjava/java/awt/image/MemoryImageSource.java
index d861199..ddd5800 100644
--- a/libjava/java/awt/image/MemoryImageSource.java
+++ b/libjava/java/awt/image/MemoryImageSource.java
@@ -41,6 +41,7 @@ package java.awt.image;
import java.awt.Image;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Vector;
public class MemoryImageSource implements ImageProducer
{
@@ -49,7 +50,8 @@ public class MemoryImageSource implements ImageProducer
private int pixeli[], width, height, offset, scansize;
private byte pixelb[];
private ColorModel cm;
- private Hashtable props, consumers = new Hashtable();
+ private Hashtable props = new Hashtable();
+ private Vector consumers = new Vector();
/**
Constructs an ImageProducer from memory
@@ -126,10 +128,10 @@ public class MemoryImageSource implements ImageProducer
* <code>ImageProducer</code>.
*/
public synchronized void addConsumer(ImageConsumer ic) {
- if (consumers.containsKey(ic))
+ if (consumers.contains(ic))
return;
- consumers.put(ic, ic);
+ consumers.addElement(ic);
}
/**
@@ -137,7 +139,7 @@ public class MemoryImageSource implements ImageProducer
* already registered with this <code>ImageProducer</code>.
*/
public synchronized boolean isConsumer(ImageConsumer ic) {
- if (consumers.containsKey(ic))
+ if (consumers.contains(ic))
return true;
return false;
}
@@ -147,7 +149,7 @@ public class MemoryImageSource implements ImageProducer
* registered consumers for this <code>ImageProducer</code>.
*/
public synchronized void removeConsumer(ImageConsumer ic) {
- consumers.remove(ic);
+ consumers.removeElement(ic);
}
/**
@@ -157,16 +159,16 @@ public class MemoryImageSource implements ImageProducer
* registered consumers.
*/
public void startProduction(ImageConsumer ic) {
- if (!(consumers.containsKey(ic))) {
- consumers.put(ic, ic);
+ if (!(consumers.contains(ic))) {
+ consumers.addElement(ic);
}
- Enumeration e = consumers.elements();
- for( ; e.hasMoreElements(); ) {
- ic = (ImageConsumer)e.nextElement();
+
+ Vector list = (Vector) consumers.clone();
+ for(int i = 0; i < list.size(); i++) {
+ ic = (ImageConsumer) list.elementAt(i);
sendPicture( ic );
- ic.imageComplete( ImageConsumer.SINGLEFRAME );
+ ic.imageComplete( ImageConsumer.STATICIMAGEDONE );
}
-
}
/**
@@ -210,9 +212,9 @@ public class MemoryImageSource implements ImageProducer
{
if( animated == true ) {
ImageConsumer ic;
- Enumeration e = consumers.elements();
- for( ; e.hasMoreElements(); ) {
- ic = (ImageConsumer)e.nextElement();
+ Vector list = (Vector) consumers.clone();
+ for(int i = 0; i < list.size(); i++) {
+ ic = (ImageConsumer) list.elementAt(i);
sendPicture( ic );
ic.imageComplete( ImageConsumer.SINGLEFRAME );
}
@@ -227,6 +229,7 @@ public class MemoryImageSource implements ImageProducer
ic.setProperties( props );
}
ic.setDimensions(width, height);
+ ic.setColorModel(cm);
if( pixeli != null ) {
ic.setPixels( 0, 0, width, height, cm, pixeli, offset, scansize );
} else {
@@ -249,9 +252,9 @@ public class MemoryImageSource implements ImageProducer
newPixels();
} else {
ImageConsumer ic;
- Enumeration e = consumers.elements();
- for( ; e.hasMoreElements(); ) {
- ic = (ImageConsumer)e.nextElement();
+ Vector list = (Vector) consumers.clone();
+ for(int i = 0; i < list.size(); i++) {
+ ic = (ImageConsumer) list.elementAt(i);
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );
@@ -294,9 +297,9 @@ public class MemoryImageSource implements ImageProducer
newPixels();
} else {
ImageConsumer ic;
- Enumeration e = consumers.elements();
- for( ; e.hasMoreElements(); ) {
- ic = (ImageConsumer)e.nextElement();
+ Vector list = (Vector) consumers.clone();
+ for(int i = 0; i < list.size(); i++) {
+ ic = (ImageConsumer) list.elementAt(i);
ic.setHints( ImageConsumer.TOPDOWNLEFTRIGHT );
if( props != null ) {
ic.setProperties( props );
diff --git a/libjava/java/awt/image/RGBImageFilter.java b/libjava/java/awt/image/RGBImageFilter.java
index 5718024..819580e 100644
--- a/libjava/java/awt/image/RGBImageFilter.java
+++ b/libjava/java/awt/image/RGBImageFilter.java
@@ -79,6 +79,10 @@ public abstract class RGBImageFilter extends ImageFilter
if( ( model instanceof IndexColorModel) && canFilterIndexColorModel ) {
newmodel = filterIndexColorModel( (IndexColorModel) model );
+ consumer.setColorModel(newmodel);
+ }
+ else {
+ consumer.setColorModel(ColorModel.getRGBdefault());
}
}
diff --git a/libjava/java/awt/image/ShortLookupTable.java b/libjava/java/awt/image/ShortLookupTable.java
new file mode 100644
index 0000000..223d03b
--- /dev/null
+++ b/libjava/java/awt/image/ShortLookupTable.java
@@ -0,0 +1,162 @@
+/* ShortLookupTable.java -- Java class for a pixel translation table.
+ Copyright (C) 2004 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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.image;
+
+/**
+ * ShortLookupTable represents translation arrays for pixel values. It wraps
+ * one or more data arrays for each layer (or component) in an image, such as
+ * Alpha, R, G, and B. When doing translation, the offset is subtracted from
+ * the pixel values to allow a subset of an array to be used.
+ *
+ * @author <a href="mailto:jlquinn@optonline.net">Jerry Quinn</a>
+ * @version 1.0
+ */
+public class ShortLookupTable extends LookupTable
+{
+ // Array of translation tables.
+ private short data[][];
+
+ /**
+ * Creates a new <code>ShortLookupTable</code> instance.
+ *
+ * Offset is subtracted from pixel values when looking up in the translation
+ * tables. If data.length is one, the same table is applied to all pixel
+ * components.
+ *
+ * @param offset Offset to be subtracted.
+ * @param data Array of lookup tables.
+ * @exception IllegalArgumentException if offset < 0 or data.length < 1.
+ */
+ public ShortLookupTable(int offset, short[][] data)
+ throws IllegalArgumentException
+ {
+ super(offset, data.length);
+ this.data = data;
+ }
+
+ /**
+ * Creates a new <code>ShortLookupTable</code> instance.
+ *
+ * Offset is subtracted from pixel values when looking up in the translation
+ * table. The same table is applied to all pixel components.
+ *
+ * @param offset Offset to be subtracted.
+ * @param data Lookup table for all components.
+ * @exception IllegalArgumentException if offset < 0.
+ */
+ public ShortLookupTable(int offset, short[] data)
+ throws IllegalArgumentException
+ {
+ super(offset, 1);
+ this.data = new short[][] {data};
+ }
+
+ /** Return the lookup tables. */
+ public final short[][] getTable()
+ {
+ return data;
+ }
+
+ /**
+ * Return translated values for a pixel.
+ *
+ * For each value in the pixel src, use the value minus offset as an index
+ * in the component array and copy the value there to the output for the
+ * component. If dest is null, the output is a new array, otherwise the
+ * translated values are written to dest. Dest can be the same array as
+ * src.
+ *
+ * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+ * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+ * translation arrays.
+ *
+ * @param src Component values of a pixel.
+ * @param dest Destination array for values, or null.
+ * @return Translated values for the pixel.
+ */
+ public int[] lookupPixel(int[] src, int[] dst)
+ throws ArrayIndexOutOfBoundsException
+ {
+ if (dst == null)
+ dst = new int[numComponents];
+
+ if (data.length == 1)
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[0][src[i] - offset];
+ else
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[i][src[i] - offset];
+
+ return dst;
+ }
+
+ /**
+ * Return translated values for a pixel.
+ *
+ * For each value in the pixel src, use the value minus offset as an index
+ * in the component array and copy the value there to the output for the
+ * component. If dest is null, the output is a new array, otherwise the
+ * translated values are written to dest. Dest can be the same array as
+ * src.
+ *
+ * For example, if the pixel src is [2, 4, 3], and offset is 1, the output
+ * is [comp1[1], comp2[3], comp3[2]], where comp1, comp2, and comp3 are the
+ * translation arrays.
+ *
+ * @param src Component values of a pixel.
+ * @param dest Destination array for values, or null.
+ * @return Translated values for the pixel.
+ */
+ public short[] lookupPixel(short[] src, short[] dst)
+ throws ArrayIndexOutOfBoundsException
+ {
+ if (dst == null)
+ dst = new short[numComponents];
+
+ if (data.length == 1)
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[0][((int)src[i]) - offset];
+ else
+ for (int i=0; i < src.length; i++)
+ dst[i] = data[i][((int)src[i]) - offset];
+
+ return dst;
+
+ }
+}