diff options
author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
commit | 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/java/awt | |
parent | 7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff) | |
download | gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/awt')
56 files changed, 2245 insertions, 2010 deletions
diff --git a/libjava/classpath/java/awt/BorderLayout.java b/libjava/classpath/java/awt/BorderLayout.java index adf2ebf65f6..1b67c01cfcb 100644 --- a/libjava/classpath/java/awt/BorderLayout.java +++ b/libjava/classpath/java/awt/BorderLayout.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.awt; + /** * This class implements a layout manager that positions components * in certain sectors of the parent container. @@ -229,6 +230,12 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable private int vgap; + // Some constants for use with calcSize(). + private static final int MIN = 0; + private static final int MAX = 1; + private static final int PREF = 2; + + /** * Initializes a new instance of <code>BorderLayout</code> with no * horiztonal or vertical gaps between components. @@ -423,7 +430,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable */ public float getLayoutAlignmentX(Container parent) { - return(parent.getAlignmentX()); + return 0.5F; } /** @@ -438,7 +445,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable */ public float getLayoutAlignmentY(Container parent) { - return(parent.getAlignmentY()); + return 0.5F; } /** @@ -449,7 +456,7 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable */ public void invalidateLayout(Container parent) { - // FIXME: Implement this properly! + // Nothing to do here. } /** @@ -560,7 +567,8 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable } /** - * FIXME: Document me! + * This is a convenience method to set the bounds on a component. + * If the indicated component is null, nothing is done. */ private void setBounds(Component comp, int x, int y, int w, int h) { @@ -569,12 +577,6 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable comp.setBounds(x, y, w, h); } - // FIXME: Maybe move to top of file. - // Some constants for use with calcSize(). - private static final int MIN = 0; - private static final int MAX = 1; - private static final int PREF = 2; - private Dimension calcCompSize(Component comp, int what) { if (comp == null || !comp.isVisible()) @@ -660,4 +662,112 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable return(new Dimension(width, height)); } } + + /** + * Return the component at the indicated location, or null if no component + * is at that location. The constraints argument must be one of the + * location constants specified by this class. + * @param constraints the location + * @return the component at that location, or null + * @throws IllegalArgumentException if the constraints argument is not + * recognized + * @since 1.5 + */ + public Component getLayoutComponent(Object constraints) + { + if (constraints == CENTER) + return center; + if (constraints == NORTH) + return north; + if (constraints == EAST) + return east; + if (constraints == SOUTH) + return south; + if (constraints == WEST) + return west; + if (constraints == PAGE_START) + return firstLine; + if (constraints == PAGE_END) + return lastLine; + if (constraints == LINE_START) + return firstItem; + if (constraints == LINE_END) + return lastItem; + throw new IllegalArgumentException("constraint " + constraints + + " is not recognized"); + } + + /** + * Return the component at the specified location, which must be one + * of the absolute constants such as CENTER or SOUTH. The container's + * orientation is used to map this location to the correct corresponding + * component, so for instance in a right-to-left container, a request + * for the EAST component could return the LINE_END component. This will + * return null if no component is available at the given location. + * @param container the container whose orientation is used + * @param constraints the absolute location of the component + * @return the component at the location, or null + * @throws IllegalArgumentException if the constraint is not recognized + */ + public Component getLayoutComponent(Container container, Object constraints) + { + ComponentOrientation orient = container.getComponentOrientation(); + if (constraints == CENTER) + return center; + // Note that we don't support vertical layouts. + if (constraints == NORTH) + return north; + if (constraints == SOUTH) + return south; + if (constraints == WEST) + { + // Note that relative layout takes precedence. + if (orient.isLeftToRight()) + return firstItem == null ? west : firstItem; + return lastItem == null ? west : lastItem; + } + if (constraints == EAST) + { + // Note that relative layout takes precedence. + if (orient.isLeftToRight()) + return lastItem == null ? east : lastItem; + return firstItem == null ? east : firstItem; + } + throw new IllegalArgumentException("constraint " + constraints + + " is not recognized"); + } + + /** + * Return the constraint corresponding to a component in this layout. + * If the component is null, or is not in this layout, returns null. + * Otherwise, this will return one of the constraint constants defined + * in this class. + * @param c the component + * @return the constraint, or null + * @since 1.5 + */ + public Object getConstraints(Component c) + { + if (c == null) + return null; + if (c == center) + return CENTER; + if (c == north) + return NORTH; + if (c == east) + return EAST; + if (c == south) + return SOUTH; + if (c == west) + return WEST; + if (c == firstLine) + return PAGE_START; + if (c == lastLine) + return PAGE_END; + if (c == firstItem) + return LINE_START; + if (c == lastItem) + return LINE_END; + return null; + } } diff --git a/libjava/classpath/java/awt/Button.java b/libjava/classpath/java/awt/Button.java index 90be1e5b111..e788d824ee1 100644 --- a/libjava/classpath/java/awt/Button.java +++ b/libjava/classpath/java/awt/Button.java @@ -98,6 +98,8 @@ private transient ActionListener action_listeners; protected class AccessibleAWTButton extends AccessibleAWTComponent implements AccessibleAction, AccessibleValue { + public static final long serialVersionUID = -5932203980244017102L; + protected AccessibleAWTButton() { // Do nothing here. diff --git a/libjava/classpath/java/awt/Canvas.java b/libjava/classpath/java/awt/Canvas.java index fe2f854847a..b599582ba93 100644 --- a/libjava/classpath/java/awt/Canvas.java +++ b/libjava/classpath/java/awt/Canvas.java @@ -292,8 +292,8 @@ public class Canvas * * @since 1.4 */ - public void createBufferStrategy(int numBuffers, - BufferCapabilities caps) + public void createBufferStrategy(int numBuffers, BufferCapabilities caps) + throws AWTException { if (numBuffers < 1) throw new IllegalArgumentException("Canvas.createBufferStrategy: number" @@ -305,15 +305,7 @@ public class Canvas // a flipping strategy was requested if (caps.isPageFlipping()) - { - try - { - bufferStrategy = new CanvasFlipBufferStrategy(numBuffers); - } - catch (AWTException e) - { - } - } + bufferStrategy = new CanvasFlipBufferStrategy(numBuffers); else bufferStrategy = new CanvasBltBufferStrategy(numBuffers, true); } diff --git a/libjava/classpath/java/awt/Checkbox.java b/libjava/classpath/java/awt/Checkbox.java index cd39ad43617..93f60924723 100644 --- a/libjava/classpath/java/awt/Checkbox.java +++ b/libjava/classpath/java/awt/Checkbox.java @@ -392,6 +392,11 @@ Checkbox(String label, boolean state, CheckboxGroup group) this.label = label; this.state = state; this.group = group; + + if ( state && group != null ) + { + group.setSelectedCheckbox(this); + } } /*************************************************************************/ @@ -610,8 +615,10 @@ dispatchEventImpl(AWTEvent e) protected String paramString() { - return ("label=" + label + ",state=" + state + ",group=" + group - + "," + super.paramString()); + // Note: We cannot add the checkbox group information here because this + // would trigger infinite recursion when CheckboxGroup.toString() is + // called and the box is in its selected state. + return ("label=" + label + ",state=" + state + "," + super.paramString()); } /** diff --git a/libjava/classpath/java/awt/CheckboxMenuItem.java b/libjava/classpath/java/awt/CheckboxMenuItem.java index 5e446b84c8b..197065f6535 100644 --- a/libjava/classpath/java/awt/CheckboxMenuItem.java +++ b/libjava/classpath/java/awt/CheckboxMenuItem.java @@ -335,6 +335,8 @@ paramString() implements AccessibleAction, AccessibleValue { // I think the base class provides the necessary implementation + + private static final long serialVersionUID = -1122642964303476L; } /** diff --git a/libjava/classpath/java/awt/Choice.java b/libjava/classpath/java/awt/Choice.java index 5075ea92d83..df93c5b0742 100644 --- a/libjava/classpath/java/awt/Choice.java +++ b/libjava/classpath/java/awt/Choice.java @@ -565,6 +565,10 @@ processEvent(AWTEvent event) protected void processItemEvent(ItemEvent event) { + int index = pItems.indexOf((String) event.getItem()); + // Don't call back into the peers when selecting index here + if (event.getStateChange() == ItemEvent.SELECTED) + this.selectedIndex = index; if (item_listeners != null) item_listeners.itemStateChanged(event); } diff --git a/libjava/classpath/java/awt/Color.java b/libjava/classpath/java/awt/Color.java index 4ad46d0c07c..b0312924170 100644 --- a/libjava/classpath/java/awt/Color.java +++ b/libjava/classpath/java/awt/Color.java @@ -762,7 +762,7 @@ public class Color implements Paint, Serializable if (max == 0) array[1] = 0; else - array[1] = (max - min) / max; + array[1] = ((float) (max - min)) / ((float) max); // Calculate hue. if (array[1] == 0) array[0] = 0; diff --git a/libjava/classpath/java/awt/ColorPaintContext.java b/libjava/classpath/java/awt/ColorPaintContext.java index 759ba9d8734..82a78f63fb5 100644 --- a/libjava/classpath/java/awt/ColorPaintContext.java +++ b/libjava/classpath/java/awt/ColorPaintContext.java @@ -63,7 +63,7 @@ class ColorPaintContext implements PaintContext /** * Create the context for a given color. * - * @param c The solid color to use. + * @param colorRGB The solid color to use. */ ColorPaintContext(int colorRGB) { @@ -74,7 +74,7 @@ class ColorPaintContext implements PaintContext * Create the context for a given color. * * @param cm The color model of this context. - * @param c The solid color to use. + * @param colorRGB The solid color to use. */ ColorPaintContext(ColorModel cm,int colorRGB) { diff --git a/libjava/classpath/java/awt/Component.java b/libjava/classpath/java/awt/Component.java index 0ae1ffa7d0b..9b389e21ed4 100644 --- a/libjava/classpath/java/awt/Component.java +++ b/libjava/classpath/java/awt/Component.java @@ -587,6 +587,7 @@ public abstract class Component */ protected Component() { + // Nothing to do here. } /** @@ -720,8 +721,9 @@ public abstract class Component /** * Tests if the component is displayable. It must be connected to a native - * screen resource, and all its ancestors must be displayable. A containment - * hierarchy is made displayable when a window is packed or made visible. + * screen resource. This reduces to checking that peer is not null. A + * containment hierarchy is made displayable when a window is packed or + * made visible. * * @return true if the component is displayable * @see Container#add(Component) @@ -733,9 +735,7 @@ public abstract class Component */ public boolean isDisplayable() { - if (parent != null) - return parent.isDisplayable(); - return false; + return peer != null; } /** @@ -763,7 +763,7 @@ public abstract class Component if (! visible || peer == null) return false; - return parent == null ? true : parent.isShowing(); + return parent == null ? false : parent.isShowing(); } /** @@ -902,15 +902,16 @@ public abstract class Component if (currentPeer != null) currentPeer.setVisible(true); + // The JDK repaints the component before invalidating the parent. + // So do we. + if (isShowing()) + repaint(); // 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(); - } + currentParent.invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN); @@ -946,18 +947,19 @@ public abstract class Component ComponentPeer currentPeer=peer; if (currentPeer != null) currentPeer.setVisible(false); - + boolean wasShowing = isShowing(); this.visible = false; - + + // The JDK repaints the component before invalidating the parent. + // So do we. + if (wasShowing) + repaint(); // 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(); - } + currentParent.invalidate(); ComponentEvent ce = new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); @@ -976,7 +978,7 @@ public abstract class Component { if (foreground != null) return foreground; - return parent == null ? SystemColor.windowText : parent.getForeground(); + return parent == null ? null : parent.getForeground(); } /** @@ -1075,8 +1077,9 @@ public abstract class Component Component p = parent; if (p != null) return p.getFont(); - else - return new Font("Dialog", Font.PLAIN, 12); + if (peer != null) + return peer.getGraphics().getFont(); + return null; } /** @@ -1402,17 +1405,14 @@ public abstract class Component peer.setBounds (x, y, width, height); // Erase old bounds and repaint new bounds for lightweights. - if (isLightweight() && isShowing ()) + if (isLightweight() && isShowing()) { 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); + Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth, + oldheight); + Rectangle newBounds = new Rectangle(x, y, width, height); Rectangle destroyed = oldBounds.union(newBounds); if (!destroyed.isEmpty()) parent.repaint(0, destroyed.x, destroyed.y, destroyed.width, @@ -1646,7 +1646,7 @@ public abstract class Component */ public Dimension getMaximumSize() { - return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); + return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE); } /** @@ -1720,7 +1720,7 @@ public abstract class Component valid = false; prefSize = null; minSize = null; - if (parent != null && parent.valid) + if (parent != null && parent.isValid()) parent.invalidate(); } @@ -1736,11 +1736,8 @@ public abstract class Component if (peer != null) { Graphics gfx = peer.getGraphics(); - if (gfx != null) - return gfx; - // create graphics for lightweight: - Container parent = getParent(); - if (parent != null) + // Create peer for lightweights. + if (gfx == null && parent != null) { gfx = parent.getGraphics(); Rectangle bounds = getBounds(); @@ -1748,6 +1745,8 @@ public abstract class Component gfx.translate(bounds.x, bounds.y); return gfx; } + gfx.setFont(font); + return gfx; } return null; } @@ -1887,7 +1886,7 @@ public abstract class Component * @see #repaint(long, int, int, int, int) */ public void repaint() - { + { if(!isShowing()) { Component p = parent; @@ -3481,7 +3480,10 @@ public abstract class Component ComponentPeer tmp = peer; peer = null; if (tmp != null) - tmp.dispose(); + { + tmp.hide(); + tmp.dispose(); + } } /** @@ -3807,13 +3809,16 @@ public abstract class Component { synchronized (getTreeLock ()) { - // Find this Component's top-level ancestor. - Container parent = getParent (); - + // Find this Component's top-level ancestor. + Container parent = (this instanceof Container) ? (Container) this + : getParent(); while (parent != null && !(parent instanceof Window)) parent = parent.getParent (); + if (parent == null) + return; + Window toplevel = (Window) parent; if (toplevel.isFocusableWindow ()) { @@ -4241,9 +4246,9 @@ public abstract class Component if (isDoubleBuffered()) param.append(",doublebuffered"); if (parent == null) - param.append(",parent==null"); + param.append(",parent=null"); else - param.append(",parent==").append(parent.getName()); + param.append(",parent=").append(parent.getName()); return param.toString(); } @@ -5567,6 +5572,7 @@ p * <li>the set of backward traversal keys */ protected AccessibleAWTComponentHandler() { + // Nothing to do here. } /** @@ -5598,6 +5604,7 @@ p * <li>the set of backward traversal keys */ public void componentMoved(ComponentEvent e) { + // Nothing to do here. } /** @@ -5607,6 +5614,7 @@ p * <li>the set of backward traversal keys */ public void componentResized(ComponentEvent e) { + // Nothing to do here. } } // class AccessibleAWTComponentHandler @@ -5624,6 +5632,7 @@ p * <li>the set of backward traversal keys */ protected AccessibleAWTFocusHandler() { + // Nothing to do here. } /** diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java index 13d32f87f39..4676895bf64 100644 --- a/libjava/classpath/java/awt/Container.java +++ b/libjava/classpath/java/awt/Container.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.awt; +import java.awt.event.ComponentListener; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.event.KeyEvent; @@ -394,17 +395,20 @@ public class Container extends Component layoutMgr.addLayoutComponent(null, comp); } - if (isShowing ()) - { - // Post event to notify of adding the component. - ContainerEvent ce = new ContainerEvent(this, - ContainerEvent.COMPONENT_ADDED, - comp); - getToolkit().getSystemEventQueue().postEvent(ce); - - // Repaint this container. - repaint(); - } + // We previously only sent an event when this container is showing. + // Also, the event was posted to the event queue. A Mauve test shows + // that this event is not delivered using the event queue and it is + // also sent when the container is not showing. + ContainerEvent ce = new ContainerEvent(this, + ContainerEvent.COMPONENT_ADDED, + comp); + ContainerListener[] listeners = getContainerListeners(); + for (int i = 0; i < listeners.length; i++) + listeners[i].componentAdded(ce); + + // Repaint this container. + repaint(comp.getX(), comp.getY(), comp.getWidth(), + comp.getHeight()); } } @@ -419,6 +423,10 @@ public class Container extends Component { Component r = component[index]; + ComponentListener[] list = r.getComponentListeners(); + for (int j = 0; j < list.length; j++) + r.removeComponentListener(list[j]); + r.removeNotify(); System.arraycopy(component, index + 1, component, index, @@ -730,7 +738,16 @@ public class Container extends Component */ public float getAlignmentX() { - return super.getAlignmentX(); + LayoutManager layout = getLayout(); + float alignmentX = 0.0F; + if (layout != null && layout instanceof LayoutManager2) + { + LayoutManager2 lm2 = (LayoutManager2) layout; + alignmentX = lm2.getLayoutAlignmentX(this); + } + else + alignmentX = super.getAlignmentX(); + return alignmentX; } /** @@ -742,7 +759,16 @@ public class Container extends Component */ public float getAlignmentY() { - return super.getAlignmentY(); + LayoutManager layout = getLayout(); + float alignmentY = 0.0F; + if (layout != null && layout instanceof LayoutManager2) + { + LayoutManager2 lm2 = (LayoutManager2) layout; + alignmentY = lm2.getLayoutAlignmentY(this); + } + else + alignmentY = super.getAlignmentY(); + return alignmentY; } /** @@ -1047,6 +1073,53 @@ public class Container extends Component return this; } } + + /** + * Finds the visible child component that contains the specified position. + * The top-most child is returned in the case where there is overlap. + * If the top-most child is transparent and has no MouseListeners attached, + * we discard it and return the next top-most component containing the + * specified position. + * @param x the x coordinate + * @param y the y coordinate + * @return null if the <code>this</code> does not contain the position, + * otherwise the top-most component (out of this container itself and + * its descendants) meeting the criteria above. + */ + Component findComponentForMouseEventAt(int x, int y) + { + synchronized (getTreeLock()) + { + if (!contains(x, y)) + return null; + + for (int i = 0; i < ncomponents; ++i) + { + // Ignore invisible children... + if (!component[i].isVisible()) + continue; + + int x2 = x - component[i].x; + int y2 = y - component[i].y; + // We don't do the contains() check right away because + // findComponentAt would redundantly do it first thing. + if (component[i] instanceof Container) + { + Container k = (Container) component[i]; + Component r = k.findComponentForMouseEventAt(x2, y2); + if (r != null) + return r; + } + else if (component[i].contains(x2, y2)) + return component[i]; + } + + //don't return transparent components with no MouseListeners + if (this.getMouseListeners().length == 0) + return null; + return this; + } + } public Component findComponentAt(Point p) { @@ -1955,6 +2028,30 @@ class LightweightDispatcher implements Serializable eventMask |= l; } + /** + * Returns the deepest visible descendent of parent that contains the + * specified location and that is not transparent and MouseListener-less. + * @param parent the root component to begin the search + * @param x the x coordinate + * @param y the y coordinate + * @return null if <code>parent</code> doesn't contain the location, + * parent if parent is not a container or has no child that contains the + * location, otherwise the appropriate component from the conditions + * above. + */ + Component getDeepestComponentForMouseEventAt ( + Component parent, int x, int y) + { + if (parent == null || (! parent.contains(x, y))) + return null; + + if (! (parent instanceof Container)) + return parent; + + Container c = (Container) parent; + return c.findComponentForMouseEventAt(x, y); + } + Component acquireComponentForMouseEvent(MouseEvent me) { int x = me.getX (); @@ -1968,7 +2065,7 @@ class LightweightDispatcher implements Serializable while (candidate == null && parent != null) { candidate = - AWTUtilities.getDeepestComponentAt(parent, p.x, p.y); + getDeepestComponentForMouseEventAt(parent, p.x, p.y); if (candidate == null || (candidate.eventMask & me.getID()) == 0) { candidate = null; @@ -2069,7 +2166,10 @@ class LightweightDispatcher implements Serializable // Don't dispatch CLICKED events whose target is not the same as the // target for the original PRESSED event. if (candidate != pressedComponent) - mouseEventTarget = null; + { + mouseEventTarget = null; + pressCount = 0; + } else if (pressCount == 0) pressedComponent = null; } @@ -2107,7 +2207,7 @@ class LightweightDispatcher implements Serializable pressedComponent = null; break; } - + MouseEvent newEvt = AWTUtilities.convertMouseEvent(nativeContainer, me, mouseEventTarget); diff --git a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java index f53cc5ef04d..bce6352a900 100644 --- a/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java +++ b/libjava/classpath/java/awt/DefaultKeyboardFocusManager.java @@ -146,8 +146,8 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager */ private AWTKeyStroke waitForKeyStroke = null; - /** The {@link java.util.SortedSet} of current {@link - #EventDelayRequest}s. */ + /** The {@link java.util.SortedSet} of current + * {@link EventDelayRequest}s. */ private SortedSet delayRequests = new TreeSet (); public DefaultKeyboardFocusManager () diff --git a/libjava/classpath/java/awt/Dialog.java b/libjava/classpath/java/awt/Dialog.java index d3eb975a86d..7e5e7215aac 100644 --- a/libjava/classpath/java/awt/Dialog.java +++ b/libjava/classpath/java/awt/Dialog.java @@ -519,6 +519,8 @@ paramString() protected class AccessibleAWTDialog extends AccessibleAWTWindow { + private static final long serialVersionUID = 4837230331833941201L; + public AccessibleRole getAccessibleRole() { return AccessibleRole.DIALOG; diff --git a/libjava/classpath/java/awt/EventQueue.java b/libjava/classpath/java/awt/EventQueue.java index 15b6e1e7afd..235ad2ac17c 100644 --- a/libjava/classpath/java/awt/EventQueue.java +++ b/libjava/classpath/java/awt/EventQueue.java @@ -42,7 +42,6 @@ import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.InputMethodEvent; import java.awt.event.InvocationEvent; -import java.awt.event.WindowEvent; import java.lang.reflect.InvocationTargetException; import java.util.EmptyStackException; diff --git a/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java index 5de94586e2c..2e4c9f61c68 100644 --- a/libjava/classpath/java/awt/Font.java +++ b/libjava/classpath/java/awt/Font.java @@ -50,6 +50,7 @@ import java.awt.geom.Rectangle2D; import java.awt.peer.FontPeer; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; import java.io.Serializable; import java.text.AttributedCharacterIterator; import java.text.CharacterIterator; @@ -69,39 +70,35 @@ import java.util.StringTokenizer; public class Font implements Serializable { -/* - * Static Variables - */ - -/** - * Constant indicating a "plain" font. - */ -public static final int PLAIN = 0; + /** + * Constant indicating a "plain" font. + */ + public static final int PLAIN = 0; -/** - * Constant indicating a "bold" font. - */ -public static final int BOLD = 1; + /** + * Constant indicating a "bold" font. + */ + public static final int BOLD = 1; -/** - * Constant indicating an "italic" font. - */ -public static final int ITALIC = 2; + /** + * Constant indicating an "italic" font. + */ + public static final int ITALIC = 2; -/** - * Constant indicating the baseline mode characteristic of Roman. - */ -public static final int ROMAN_BASELINE = 0; + /** + * Constant indicating the baseline mode characteristic of Roman. + */ + public static final int ROMAN_BASELINE = 0; -/** - * Constant indicating the baseline mode characteristic of Chinese. - */ -public static final int CENTER_BASELINE = 1; + /** + * Constant indicating the baseline mode characteristic of Chinese. + */ + public static final int CENTER_BASELINE = 1; -/** - * Constant indicating the baseline mode characteristic of Devanigri. - */ -public static final int HANGING_BASELINE = 2; + /** + * Constant indicating the baseline mode characteristic of Devanigri. + */ + public static final int HANGING_BASELINE = 2; /** @@ -170,1145 +167,1138 @@ public static final int HANGING_BASELINE = 2; protected String name; /** - * The size of this font in pixels. + * The size of this font in points, rounded. * * @since 1.0 */ protected int size; /** + * The size of this font in points. + * + * @since 1.0 + */ + protected float pointSize; + + /** * The style of this font -- PLAIN, BOLD, ITALIC or BOLD+ITALIC. * * @since 1.0 */ protected int style; -// Serialization constant -private static final long serialVersionUID = -4206021311591459213L; +//Serialization constant + private static final long serialVersionUID = -4206021311591459213L; // The ClasspathToolkit-provided peer which implements this font - private ClasspathFontPeer peer; - -/*************************************************************************/ + private transient ClasspathFontPeer peer; -/* - * Static Methods - */ -/** - * Creates a <code>Font</code> object from the specified string, which - * is in one of the following formats: - * <p> - * <ul> - * <li>fontname-style-pointsize - * <li>fontname-style - * <li>fontname-pointsize - * <li>fontname - * </ul> - * <p> - * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default - * style if none is specified is PLAIN. The default size if none - * is specified is 12. - * - * @param fontspec a string specifying the required font (<code>null</code> - * permitted, interpreted as 'Dialog-PLAIN-12'). - * - * @return A font. - */ - public static Font decode (String fontspec) -{ - if (fontspec == null) - fontspec = "Dialog-PLAIN-12"; - String name = null; - int style = PLAIN; - int size = 12; - - StringTokenizer st = new StringTokenizer(fontspec, "- "); - while (st.hasMoreTokens()) - { - String token = st.nextToken(); - if (name == null) - { - name = token; - continue; - } - - if (token.toUpperCase().equals("BOLD")) - { - style = BOLD; - continue; - } - if (token.toUpperCase().equals("ITALIC")) - { - style = ITALIC; - continue; - } - if (token.toUpperCase().equals("BOLDITALIC")) - { + /** + * Creates a <code>Font</code> object from the specified string, which + * is in one of the following formats: + * <p> + * <ul> + * <li>fontname-style-pointsize + * <li>fontname-style + * <li>fontname-pointsize + * <li>fontname + * </ul> + * <p> + * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default + * style if none is specified is PLAIN. The default size if none + * is specified is 12. + * + * @param fontspec a string specifying the required font (<code>null</code> + * permitted, interpreted as 'Dialog-PLAIN-12'). + * + * @return A font. + */ + public static Font decode(String fontspec) + { + if (fontspec == null) + fontspec = "Dialog-PLAIN-12"; + String name = null; + int style = PLAIN; + int size = 12; + + StringTokenizer st = new StringTokenizer(fontspec, "- "); + while (st.hasMoreTokens()) + { + String token = st.nextToken(); + if (name == null) + { + name = token; + continue; + } + + if (token.toUpperCase().equals("BOLD")) + { + style = BOLD; + continue; + } + if (token.toUpperCase().equals("ITALIC")) + { + style = ITALIC; + continue; + } + if (token.toUpperCase().equals("BOLDITALIC")) + { style = BOLD | ITALIC; - continue; - } - - int tokenval = 0; - try - { - tokenval = Integer.parseInt(token); - } - catch(NumberFormatException e) - { - // Ignored. - } + continue; + } + + int tokenval = 0; + try + { + tokenval = Integer.parseInt(token); + } + catch (NumberFormatException e) + { + // Ignored. + } if (tokenval != 0) size = tokenval; } HashMap attrs = new HashMap(); - ClasspathFontPeer.copyStyleToAttrs (style, attrs); - ClasspathFontPeer.copySizeToAttrs (size, attrs); + ClasspathFontPeer.copyStyleToAttrs(style, attrs); + ClasspathFontPeer.copySizeToAttrs(size, attrs); - return getFontFromToolkit (name, attrs); -} + return getFontFromToolkit(name, attrs); + } /* These methods delegate to the toolkit. */ - protected static ClasspathToolkit tk () + static ClasspathToolkit tk() { - return (ClasspathToolkit)(Toolkit.getDefaultToolkit ()); + return (ClasspathToolkit) Toolkit.getDefaultToolkit(); } /* Every factory method in Font should eventually call this. */ - protected static Font getFontFromToolkit (String name, Map attribs) + static Font getFontFromToolkit(String name, Map attribs) { - return tk ().getFont (name, attribs); + return tk().getFont(name, attribs); } /* Every Font constructor should eventually call this. */ - protected static ClasspathFontPeer getPeerFromToolkit (String name, Map attrs) + static ClasspathFontPeer getPeerFromToolkit(String name, Map attrs) { - return tk ().getClasspathFontPeer (name, attrs); + return tk().getClasspathFontPeer(name, attrs); } -/*************************************************************************/ - -/** - * Returns a <code>Font</code> object from the passed property name. - * - * @param propname The name of the system property. - * @param defval Value to use if the property is not found. - * - * @return The requested font, or <code>default</code> if the property - * not exist or is malformed. - */ - public static Font getFont (String propname, Font defval) -{ - String propval = System.getProperty(propname); - if (propval != null) - return decode (propval); + /** + * Returns a <code>Font</code> object from the passed property name. + * + * @param propname The name of the system property. + * @param defval Value to use if the property is not found. + * + * @return The requested font, or <code>default</code> if the property + * not exist or is malformed. + */ + public static Font getFont(String propname, Font defval) + { + String propval = System.getProperty(propname); + if (propval != null) + return decode(propval); return defval; -} - -/*************************************************************************/ - -/** - * Returns a <code>Font</code> object from the passed property name. - * - * @param propname The name of the system property. - * - * @return The requested font, or <code>null</code> if the property - * not exist or is malformed. - */ - public static Font getFont (String propname) -{ - return getFont (propname, (Font)null); -} - -/*************************************************************************/ + } -/* - * Constructors - */ + /** + * Returns a <code>Font</code> object from the passed property name. + * + * @param propname The name of the system property. + * + * @return The requested font, or <code>null</code> if the property + * not exist or is malformed. + */ + public static Font getFont(String propname) + { + return getFont(propname, (Font) null); + } -/** - * Initializes a new instance of <code>Font</code> with the specified - * attributes. - * - * @param name The name of the font. - * @param style The font style. - * @param size The font point size. - */ - - public Font (String name, int style, int size) + /** + * Initializes a new instance of <code>Font</code> with the specified + * attributes. + * + * @param name The name of the font. + * @param style The font style. + * @param size The font point size. + */ + public Font(String name, int style, int size) { HashMap attrs = new HashMap(); - ClasspathFontPeer.copyStyleToAttrs (style, attrs); - ClasspathFontPeer.copySizeToAttrs (size, attrs); - this.peer = getPeerFromToolkit (name, attrs); + ClasspathFontPeer.copyStyleToAttrs(style, attrs); + ClasspathFontPeer.copySizeToAttrs(size, attrs); + this.peer = getPeerFromToolkit(name, attrs); + this.size = size; + this.pointSize = (float) size; + if (name != null) + this.name = name; + else + this.name = peer.getName(this); } - public Font (Map attrs) + public Font(Map attrs) { this(null, 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) + 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. if (attrs == null) attrs = new HashMap(); - this.peer = getPeerFromToolkit (name, attrs); + peer = getPeerFromToolkit(name, attrs); + size = (int) peer.getSize(this); + pointSize = peer.getSize(this); + if (name != null) + this.name = name; + else + this.name = peer.getName(this); } -/*************************************************************************/ - -/* - * Instance Methods - */ - -/** + /** * Returns the logical name of the font. A logical name is the name the * font was constructed with. It may be the name of a logical font (one * of 6 required names in all java environments) or it may be a face * name. - * - * @return The logical name of the font. - * - * @see #getFamily() - * @see #getFontName() - */ + * + * @return The logical name of the font. + * + * @see #getFamily() + * @see #getFontName() + */ public String getName () -{ - return peer.getName (this); -} - -/*************************************************************************/ - -/** - * Returns the style of the font. - * - * @return The font style. - */ - public int getSize () -{ - return (int) peer.getSize (this); -} - - public float getSize2D () -{ - return peer.getSize (this); -} - -/*************************************************************************/ - -/** - * Tests whether or not this is a plain font. This will be true if - * and only if neither the bold nor the italics style is set. - * - * @return <code>true</code> if this is a plain font, <code>false</code> - * otherwise. - */ - public boolean isPlain () -{ - return peer.isPlain (this); -} + { + return peer.getName(this); + } -/*************************************************************************/ + /** + * Returns the size of the font, in typographics points (1/72 of an inch), + * rounded to an integer. + * + * @return The font size + */ + public int getSize() + { + return size; + } -/** - * Tests whether or not this font is bold. - * - * @return <code>true</code> if this font is bold, <code>false</code> - * otherwise. - */ - public boolean isBold () -{ - return peer.isBold (this); -} + /** + * Returns the size of the font, in typographics points (1/72 of an inch). + * + * @return The font size + */ + public float getSize2D() + { + return pointSize; + } -/*************************************************************************/ + /** + * Tests whether or not this is a plain font. This will be true if + * and only if neither the bold nor the italics style is set. + * + * @return <code>true</code> if this is a plain font, <code>false</code> + * otherwise. + */ + public boolean isPlain() + { + return peer.isPlain(this); + } -/** - * Tests whether or not this font is italic. - * - * @return <code>true</code> if this font is italic, <code>false</code> - * otherwise. - */ - public boolean isItalic () -{ - return peer.isItalic (this); -} + /** + * Tests whether or not this font is bold. + * + * @return <code>true</code> if this font is bold, <code>false</code> + * otherwise. + */ + public boolean isBold() + { + return peer.isBold(this); + } -/*************************************************************************/ + /** + * Tests whether or not this font is italic. + * + * @return <code>true</code> if this font is italic, <code>false</code> + * otherwise. + */ + public boolean isItalic() + { + return peer.isItalic(this); + } -/** + /** * Returns the family name of this font. A family name describes a design * or "brand name" (such as Helvetica or Palatino). It is less specific * than a font face name (such as Helvetica Bold). - * - * @return A string containing the font family name. - * - * @since 1.2 - * - * @see #getName() - * @see #getFontName() - * @see GraphicsEnvironment#getAvailableFontFamilyNames() - */ - public String getFamily () -{ - return peer.getFamily (this); -} + * + * @return A string containing the font family name. + * + * @since 1.2 + * + * @see #getName() + * @see #getFontName() + * @see GraphicsEnvironment#getAvailableFontFamilyNames() + */ + public String getFamily() + { + return peer.getFamily(this); + } -/** - * Returns integer code representing the sum of style flags of this font, a - * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}. - * - * @return code representing the style of this font. - * - * @see #isPlain() - * @see #isBold() - * @see #isItalic() - */ - public int getStyle () -{ - return peer.getStyle (this); -} + /** + * Returns integer code representing the sum of style flags of this font, a + * combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}. + * + * @return code representing the style of this font. + * + * @see #isPlain() + * @see #isBold() + * @see #isItalic() + */ + public int getStyle() + { + return peer.getStyle(this); + } -/** - * Checks if specified character maps to a glyph in this font. - * - * @param c The character to check. - * - * @return Whether the character has a corresponding glyph in this font. - * - * @since 1.2 - */ - public boolean canDisplay (char c) -{ - return peer.canDisplay (this, c); -} + /** + * Checks if specified character maps to a glyph in this font. + * + * @param c The character to check. + * + * @return Whether the character has a corresponding glyph in this font. + * + * @since 1.2 + */ + public boolean canDisplay(char c) + { + return peer.canDisplay(this, c); + } -/** - * Checks how much of a given string can be mapped to glyphs in - * this font. - * - * @param s The string to check. - * - * @return The index of the first character in <code>s</code> which cannot - * be converted to a glyph by this font, or <code>-1</code> if all - * characters can be mapped to glyphs. - * - * @since 1.2 - */ - public int canDisplayUpTo (String s) -{ - return peer.canDisplayUpTo (this, new StringCharacterIterator (s), - 0, s.length () - 1); -} + /** + * Checks how much of a given string can be mapped to glyphs in + * this font. + * + * @param s The string to check. + * + * @return The index of the first character in <code>s</code> which cannot + * be converted to a glyph by this font, or <code>-1</code> if all + * characters can be mapped to glyphs. + * + * @since 1.2 + */ + public int canDisplayUpTo(String s) + { + return peer.canDisplayUpTo(this, new StringCharacterIterator(s), + 0, s.length() - 1); + } -/** - * Checks how much of a given sequence of text can be mapped to glyphs in - * this font. - * - * @param text Array containing the text to check. - * @param start Position of first character to check in <code>text</code>. - * @param limit Position of last character to check in <code>text</code>. - * - * @return The index of the first character in the indicated range which - * cannot be converted to a glyph by this font, or <code>-1</code> if all - * characters can be mapped to glyphs. - * - * @since 1.2 - * - * @throws IndexOutOfBoundsException if the range [start, limit] is - * invalid in <code>text</code>. - */ + /** + * Checks how much of a given sequence of text can be mapped to glyphs in + * this font. + * + * @param text Array containing the text to check. + * @param start Position of first character to check in <code>text</code>. + * @param limit Position of last character to check in <code>text</code>. + * + * @return The index of the first character in the indicated range which + * cannot be converted to a glyph by this font, or <code>-1</code> if all + * characters can be mapped to glyphs. + * + * @since 1.2 + * + * @throws IndexOutOfBoundsException if the range [start, limit] is + * invalid in <code>text</code>. + */ public int canDisplayUpTo (char[] text, int start, int limit) -{ - return peer.canDisplayUpTo - (this, new StringCharacterIterator (new String (text)), start, limit); -} + { + return peer.canDisplayUpTo(this, + new StringCharacterIterator(new String (text)), + start, limit); + } -/** - * Checks how much of a given sequence of text can be mapped to glyphs in - * this font. - * - * @param i Iterator over the text to check. - * @param start Position of first character to check in <code>i</code>. - * @param limit Position of last character to check in <code>i</code>. - * - * @return The index of the first character in the indicated range which - * cannot be converted to a glyph by this font, or <code>-1</code> if all - * characters can be mapped to glyphs. - * - * @since 1.2 - * - * @throws IndexOutOfBoundsException if the range [start, limit] is - * invalid in <code>i</code>. - */ - public int canDisplayUpTo (CharacterIterator i, int start, int limit) -{ - return peer.canDisplayUpTo (this, i, start, limit); -} + /** + * Checks how much of a given sequence of text can be mapped to glyphs in + * this font. + * + * @param i Iterator over the text to check. + * @param start Position of first character to check in <code>i</code>. + * @param limit Position of last character to check in <code>i</code>. + * + * @return The index of the first character in the indicated range which + * cannot be converted to a glyph by this font, or <code>-1</code> if all + * characters can be mapped to glyphs. + * + * @since 1.2 + * + * @throws IndexOutOfBoundsException if the range [start, limit] is + * invalid in <code>i</code>. + */ + public int canDisplayUpTo(CharacterIterator i, int start, int limit) + { + return peer.canDisplayUpTo(this, i, start, limit); + } -/** - * Creates a new font with point size 1 and {@link #PLAIN} style, - * reading font data from the provided input stream. The resulting font - * can have further fonts derived from it using its - * <code>deriveFont</code> method. - * - * @param fontFormat Integer code indicating the format the font data is - * in.Currently this can only be {@link #TRUETYPE_FONT}. - * @param is {@link InputStream} from which font data will be read. This - * stream is not closed after font data is extracted. - * - * @return A new {@link Font} of the format indicated. - * - * @throws IllegalArgumentException if <code>fontType</code> is not - * recognized. - * @throws FontFormatException if data in InputStream is not of format - * indicated. - * @throws IOException if insufficient data is present on InputStream. - * - * @since 1.3 - */ - public static Font createFont (int fontFormat, InputStream is) - throws FontFormatException, IOException -{ - return tk().createFont (fontFormat, is); -} + /** + * Creates a new font with point size 1 and {@link #PLAIN} style, + * reading font data from the provided input stream. The resulting font + * can have further fonts derived from it using its + * <code>deriveFont</code> method. + * + * @param fontFormat Integer code indicating the format the font data is + * in.Currently this can only be {@link #TRUETYPE_FONT}. + * @param is {@link InputStream} from which font data will be read. This + * stream is not closed after font data is extracted. + * + * @return A new {@link Font} of the format indicated. + * + * @throws IllegalArgumentException if <code>fontType</code> is not + * recognized. + * @throws FontFormatException if data in InputStream is not of format + * indicated. + * @throws IOException if insufficient data is present on InputStream. + * + * @since 1.3 + */ + public static Font createFont (int fontFormat, InputStream is) + throws FontFormatException, IOException + { + return tk().createFont(fontFormat, is); + } -/** - * Maps characters to glyphs in a one-to-one relationship, returning a new - * {@link GlyphVector} with a mapped glyph for each input character. This - * sort of mapping is often sufficient for some scripts such as Roman, but - * is inappropriate for scripts with special shaping or contextual layout - * requirements such as Arabic, Indic, Hebrew or Thai. - * - * @param ctx The rendering context used for precise glyph placement. - * @param str The string to convert to Glyphs. - * - * @return A new {@link GlyphVector} containing glyphs mapped from str, - * through the font's cmap table. - * - * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) - */ - public GlyphVector createGlyphVector (FontRenderContext ctx, String str) -{ - return peer.createGlyphVector (this, ctx, new StringCharacterIterator (str)); -} + /** + * Maps characters to glyphs in a one-to-one relationship, returning a new + * {@link GlyphVector} with a mapped glyph for each input character. This + * sort of mapping is often sufficient for some scripts such as Roman, but + * is inappropriate for scripts with special shaping or contextual layout + * requirements such as Arabic, Indic, Hebrew or Thai. + * + * @param ctx The rendering context used for precise glyph placement. + * @param str The string to convert to Glyphs. + * + * @return A new {@link GlyphVector} containing glyphs mapped from str, + * through the font's cmap table. + * + * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) + */ + public GlyphVector createGlyphVector(FontRenderContext ctx, String str) + { + return peer.createGlyphVector(this, ctx, new StringCharacterIterator(str)); + } -/** - * Maps characters to glyphs in a one-to-one relationship, returning a new - * {@link GlyphVector} with a mapped glyph for each input character. This - * sort of mapping is often sufficient for some scripts such as Roman, but - * is inappropriate for scripts with special shaping or contextual layout - * requirements such as Arabic, Indic, Hebrew or Thai. - * - * @param ctx The rendering context used for precise glyph placement. - * @param i Iterator over the text to convert to glyphs. - * - * @return A new {@link GlyphVector} containing glyphs mapped from str, - * through the font's cmap table. - * - * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) - */ - public GlyphVector createGlyphVector (FontRenderContext ctx, CharacterIterator i) -{ - return peer.createGlyphVector (this, ctx, i); -} + /** + * Maps characters to glyphs in a one-to-one relationship, returning a new + * {@link GlyphVector} with a mapped glyph for each input character. This + * sort of mapping is often sufficient for some scripts such as Roman, but + * is inappropriate for scripts with special shaping or contextual layout + * requirements such as Arabic, Indic, Hebrew or Thai. + * + * @param ctx The rendering context used for precise glyph placement. + * @param i Iterator over the text to convert to glyphs. + * + * @return A new {@link GlyphVector} containing glyphs mapped from str, + * through the font's cmap table. + * + * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) + */ + public GlyphVector createGlyphVector(FontRenderContext ctx, + CharacterIterator i) + { + return peer.createGlyphVector(this, ctx, i); + } -/** - * Maps characters to glyphs in a one-to-one relationship, returning a new - * {@link GlyphVector} with a mapped glyph for each input character. This - * sort of mapping is often sufficient for some scripts such as Roman, but - * is inappropriate for scripts with special shaping or contextual layout - * requirements such as Arabic, Indic, Hebrew or Thai. - * - * @param ctx The rendering context used for precise glyph placement. - * @param chars Array of characters to convert to glyphs. - * - * @return A new {@link GlyphVector} containing glyphs mapped from str, - * through the font's cmap table. - * - * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) - */ - public GlyphVector createGlyphVector (FontRenderContext ctx, char[] chars) -{ - return peer.createGlyphVector - (this, ctx, new StringCharacterIterator (new String (chars))); -} + /** + * Maps characters to glyphs in a one-to-one relationship, returning a new + * {@link GlyphVector} with a mapped glyph for each input character. This + * sort of mapping is often sufficient for some scripts such as Roman, but + * is inappropriate for scripts with special shaping or contextual layout + * requirements such as Arabic, Indic, Hebrew or Thai. + * + * @param ctx The rendering context used for precise glyph placement. + * @param chars Array of characters to convert to glyphs. + * + * @return A new {@link GlyphVector} containing glyphs mapped from str, + * through the font's cmap table. + * + * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) + */ + public GlyphVector createGlyphVector(FontRenderContext ctx, char[] chars) + { + return peer.createGlyphVector(this, ctx, + new StringCharacterIterator(new String(chars))); + } -/** - * Extracts a sequence of glyphs from a font, returning a new {@link - * GlyphVector} with a mapped glyph for each input glyph code. - * - * @param ctx The rendering context used for precise glyph placement. - * @param glyphCodes Array of characters to convert to glyphs. - * - * @return A new {@link GlyphVector} containing glyphs mapped from str, - * through the font's cmap table. - * - * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) - * - * @specnote This method is documented to perform character-to-glyph - * conversions, in the Sun documentation, but its second parameter name is - * "glyphCodes" and it is not clear to me why it would exist if its - * purpose was to transport character codes inside integers. I assume it - * is mis-documented in the Sun documentation. - */ - - public GlyphVector createGlyphVector (FontRenderContext ctx, int[] glyphCodes) -{ - return peer.createGlyphVector (this, ctx, glyphCodes); -} + /** + * Extracts a sequence of glyphs from a font, returning a new {@link + * GlyphVector} with a mapped glyph for each input glyph code. + * + * @param ctx The rendering context used for precise glyph placement. + * @param glyphCodes Array of characters to convert to glyphs. + * + * @return A new {@link GlyphVector} containing glyphs mapped from str, + * through the font's cmap table. + * + * @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) + * + * @specnote This method is documented to perform character-to-glyph + * conversions, in the Sun documentation, but its second parameter name is + * "glyphCodes" and it is not clear to me why it would exist if its + * purpose was to transport character codes inside integers. I assume it + * is mis-documented in the Sun documentation. + */ + public GlyphVector createGlyphVector(FontRenderContext ctx, int[] glyphCodes) + { + return peer.createGlyphVector(this, ctx, glyphCodes); + } -/** - * Produces a new {@link Font} based on the current font, adjusted to a - * new size and style. - * - * @param style The style of the newly created font. - * @param size The size of the newly created font. - * - * @return A clone of the current font, with the specified size and style. - * - * @since 1.2 - */ - public Font deriveFont (int style, float size) -{ - return peer.deriveFont (this, style, size); -} + /** + * Produces a new {@link Font} based on the current font, adjusted to a + * new size and style. + * + * @param style The style of the newly created font. + * @param size The size of the newly created font. + * + * @return A clone of the current font, with the specified size and style. + * + * @since 1.2 + */ + public Font deriveFont(int style, float size) + { + return peer.deriveFont(this, style, size); + } -/** - * Produces a new {@link Font} based on the current font, adjusted to a - * new size. - * - * @param size The size of the newly created font. - * - * @return A clone of the current font, with the specified size. - * - * @since 1.2 - */ - public Font deriveFont (float size) -{ - return peer.deriveFont (this, size); -} + /** + * Produces a new {@link Font} based on the current font, adjusted to a + * new size. + * + * @param size The size of the newly created font. + * + * @return A clone of the current font, with the specified size. + * + * @since 1.2 + */ + public Font deriveFont(float size) + { + return peer.deriveFont(this, size); + } -/** - * Produces a new {@link Font} based on the current font, adjusted to a - * new style. - * - * @param style The style of the newly created font. - * - * @return A clone of the current font, with the specified style. - * - * @since 1.2 - */ - public Font deriveFont (int style) -{ - return peer.deriveFont (this, style); -} + /** + * Produces a new {@link Font} based on the current font, adjusted to a + * new style. + * + * @param style The style of the newly created font. + * + * @return A clone of the current font, with the specified style. + * + * @since 1.2 + */ + public Font deriveFont(int style) + { + return peer.deriveFont(this, style); + } -/** - * Produces a new {@link Font} based on the current font, adjusted to a - * new style and subjected to a new affine transformation. - * - * @param style The style of the newly created font. - * @param a The transformation to apply. - * - * @return A clone of the current font, with the specified style and - * transform. - * - * @throws IllegalArgumentException If transformation is - * <code>null</code>. - * - * @since 1.2 - */ - public Font deriveFont (int style, AffineTransform a) -{ + /** + * Produces a new {@link Font} based on the current font, adjusted to a + * new style and subjected to a new affine transformation. + * + * @param style The style of the newly created font. + * @param a The transformation to apply. + * + * @return A clone of the current font, with the specified style and + * transform. + * + * @throws IllegalArgumentException If transformation is + * <code>null</code>. + * + * @since 1.2 + */ + public Font deriveFont(int style, AffineTransform a) + { if (a == null) - throw new IllegalArgumentException ("Affine transformation is null"); + throw new IllegalArgumentException("Affine transformation is null"); - return peer.deriveFont (this, style, a); -} + return peer.deriveFont(this, style, a); + } -/** - * Produces a new {@link Font} based on the current font, subjected - * to a new affine transformation. - * - * @param a The transformation to apply. - * - * @return A clone of the current font, with the specified transform. - * - * @throws IllegalArgumentException If transformation is - * <code>null</code>. - * - * @since 1.2 - */ - public Font deriveFont (AffineTransform a) -{ + /** + * Produces a new {@link Font} based on the current font, subjected + * to a new affine transformation. + * + * @param a The transformation to apply. + * + * @return A clone of the current font, with the specified transform. + * + * @throws IllegalArgumentException If transformation is + * <code>null</code>. + * + * @since 1.2 + */ + public Font deriveFont(AffineTransform a) + { if (a == null) - throw new IllegalArgumentException ("Affine transformation is null"); + throw new IllegalArgumentException("Affine transformation is null"); - return peer.deriveFont (this, a); -} + return peer.deriveFont(this, a); + } -/** - * Produces a new {@link Font} based on the current font, adjusted to a - * new set of attributes. - * - * @param attributes Attributes of the newly created font. - * - * @return A clone of the current font, with the specified attributes. - * - * @since 1.2 - */ - public Font deriveFont (Map attributes) -{ - return peer.deriveFont (this, attributes); -} + /** + * Produces a new {@link Font} based on the current font, adjusted to a + * new set of attributes. + * + * @param attributes Attributes of the newly created font. + * + * @return A clone of the current font, with the specified attributes. + * + * @since 1.2 + */ + public Font deriveFont(Map attributes) + { + return peer.deriveFont(this, attributes); + } -/** - * Returns a map of chracter attributes which this font currently has set. - * - * @return A map of chracter attributes which this font currently has set. - * - * @see #getAvailableAttributes() - * @see java.text.AttributedCharacterIterator.Attribute - * @see java.awt.font.TextAttribute - */ - public Map getAttributes () -{ - return peer.getAttributes (this); -} + /** + * Returns a map of chracter attributes which this font currently has set. + * + * @return A map of chracter attributes which this font currently has set. + * + * @see #getAvailableAttributes() + * @see java.text.AttributedCharacterIterator.Attribute + * @see java.awt.font.TextAttribute + */ + public Map getAttributes() + { + return peer.getAttributes(this); + } -/** - * Returns an array of chracter attribute keys which this font understands. - * - * @return An array of chracter attribute keys which this font understands. - * - * @see #getAttributes() - * @see java.text.AttributedCharacterIterator.Attribute - * @see java.awt.font.TextAttribute - */ + /** + * Returns an array of chracter attribute keys which this font understands. + * + * @return An array of chracter attribute keys which this font understands. + * + * @see #getAttributes() + * @see java.text.AttributedCharacterIterator.Attribute + * @see java.awt.font.TextAttribute + */ public AttributedCharacterIterator.Attribute[] getAvailableAttributes() -{ - return peer.getAvailableAttributes (this); -} + { + return peer.getAvailableAttributes(this); + } -/** - * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link - * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline - * this font will measure baseline offsets for, when presenting glyph - * metrics for a given character. - * - * Baseline offsets describe the position of a glyph relative to an - * invisible line drawn under, through the center of, or over a line of - * rendered text, respectively. Different scripts use different baseline - * modes, so clients should not assume all baseline offsets in a glyph - * vector are from a common baseline. - * - * @param c The character code to select a baseline mode for. - * - * @return The baseline mode which would be used in a glyph associated - * with the provided character. - * - * @since 1.2 - * - * @see LineMetrics#getBaselineOffsets() - */ - public byte getBaselineFor (char c) -{ - return peer.getBaselineFor (this, c); -} + /** + * Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link + * #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline + * this font will measure baseline offsets for, when presenting glyph + * metrics for a given character. + * + * Baseline offsets describe the position of a glyph relative to an + * invisible line drawn under, through the center of, or over a line of + * rendered text, respectively. Different scripts use different baseline + * modes, so clients should not assume all baseline offsets in a glyph + * vector are from a common baseline. + * + * @param c The character code to select a baseline mode for. + * + * @return The baseline mode which would be used in a glyph associated + * with the provided character. + * + * @since 1.2 + * + * @see LineMetrics#getBaselineOffsets() + */ + public byte getBaselineFor(char c) + { + return peer.getBaselineFor(this, c); + } -/** - * Returns the family name of this font. A family name describes a - * typographic style (such as Helvetica or Palatino). It is more specific - * than a logical font name (such as Sans Serif) but less specific than a - * font face name (such as Helvetica Bold). - * - * @param lc The locale in which to describe the name of the font family. - * - * @return A string containing the font family name, localized for the - * provided locale. - * - * @since 1.2 - * - * @see #getName() - * @see #getFontName() - * @see GraphicsEnvironment#getAvailableFontFamilyNames() - * @see Locale - */ - public String getFamily (Locale lc) -{ - return peer.getFamily (this, lc); -} + /** + * Returns the family name of this font. A family name describes a + * typographic style (such as Helvetica or Palatino). It is more specific + * than a logical font name (such as Sans Serif) but less specific than a + * font face name (such as Helvetica Bold). + * + * @param lc The locale in which to describe the name of the font family. + * + * @return A string containing the font family name, localized for the + * provided locale. + * + * @since 1.2 + * + * @see #getName() + * @see #getFontName() + * @see GraphicsEnvironment#getAvailableFontFamilyNames() + * @see Locale + */ + public String getFamily(Locale lc) + { + return peer.getFamily(this, lc); + } -/** - * Returns a font appropriate for the given attribute set. - * - * @param attributes The attributes required for the new font. - * - * @return A new Font with the given attributes. - * - * @since 1.2 - * - * @see java.awt.font.TextAttribute - */ - public static Font getFont (Map attributes) -{ - return getFontFromToolkit (null, attributes); -} + /** + * Returns a font appropriate for the given attribute set. + * + * @param attributes The attributes required for the new font. + * + * @return A new Font with the given attributes. + * + * @since 1.2 + * + * @see java.awt.font.TextAttribute + */ + public static Font getFont(Map attributes) + { + return getFontFromToolkit(null, attributes); + } -/** - * Returns the font face name of the font. A font face name describes a - * specific variant of a font family (such as Helvetica Bold). It is more - * specific than both a font family name (such as Helvetica) and a logical - * font name (such as Sans Serif). - * - * @return The font face name of the font. - * - * @since 1.2 - * - * @see #getName() - * @see #getFamily() - */ - public String getFontName () -{ - return peer.getFontName (this); -} + /** + * Returns the font face name of the font. A font face name describes a + * specific variant of a font family (such as Helvetica Bold). It is more + * specific than both a font family name (such as Helvetica) and a logical + * font name (such as Sans Serif). + * + * @return The font face name of the font. + * + * @since 1.2 + * + * @see #getName() + * @see #getFamily() + */ + public String getFontName() + { + return peer.getFontName(this); + } -/** - * Returns the font face name of the font. A font face name describes a - * specific variant of a font family (such as Helvetica Bold). It is more + /** + * Returns the font face name of the font. A font face name describes a + * specific variant of a font family (such as Helvetica Bold). It is more * specific than both a font family name (such as Helvetica). - * - * @param lc The locale in which to describe the name of the font face. - * - * @return A string containing the font face name, localized for the - * provided locale. - * - * @since 1.2 - * - * @see #getName() - * @see #getFamily() - */ - public String getFontName (Locale lc) -{ - return peer.getFontName (this, lc); -} + * + * @param lc The locale in which to describe the name of the font face. + * + * @return A string containing the font face name, localized for the + * provided locale. + * + * @since 1.2 + * + * @see #getName() + * @see #getFamily() + */ + public String getFontName(Locale lc) + { + return peer.getFontName(this, lc); + } -/** - * Returns the italic angle of this font, a measurement of its slant when - * style is {@link #ITALIC}. The precise meaning is the inverse slope of a - * caret line which "best measures" the font's italic posture. - * - * @return The italic angle. - * - * @see java.awt.font.TextAttribute#POSTURE - */ - public float getItalicAngle () -{ - return peer.getItalicAngle (this); -} + /** + * Returns the italic angle of this font, a measurement of its slant when + * style is {@link #ITALIC}. The precise meaning is the inverse slope of a + * caret line which "best measures" the font's italic posture. + * + * @return The italic angle. + * + * @see java.awt.font.TextAttribute#POSTURE + */ + public float getItalicAngle() + { + return peer.getItalicAngle(this); + } -/** - * Returns a {@link LineMetrics} object constructed with the specified - * text and {@link FontRenderContext}. - * - * @param text The string to calculate metrics from. - * @param begin Index of first character in <code>text</code> to measure. - * @param limit Index of last character in <code>text</code> to measure. - * @param rc Context for calculating precise glyph placement and hints. - * - * @return A new {@link LineMetrics} object. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>text</code>. - */ + /** + * Returns a {@link LineMetrics} object constructed with the specified + * text and {@link FontRenderContext}. + * + * @param text The string to calculate metrics from. + * @param begin Index of first character in <code>text</code> to measure. + * @param limit Index of last character in <code>text</code> to measure. + * @param rc Context for calculating precise glyph placement and hints. + * + * @return A new {@link LineMetrics} object. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>text</code>. + */ public LineMetrics getLineMetrics(String text, int begin, int limit, FontRenderContext rc) -{ - return peer.getLineMetrics (this, new StringCharacterIterator (text), - begin, limit, rc); -} + { + return peer.getLineMetrics(this, new StringCharacterIterator(text), + begin, limit, rc); + } -/** - * Returns a {@link LineMetrics} object constructed with the specified - * text and {@link FontRenderContext}. - * - * @param chars The string to calculate metrics from. - * @param begin Index of first character in <code>text</code> to measure. - * @param limit Index of last character in <code>text</code> to measure. - * @param rc Context for calculating precise glyph placement and hints. - * - * @return A new {@link LineMetrics} object. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>chars</code>. - */ + /** + * Returns a {@link LineMetrics} object constructed with the specified + * text and {@link FontRenderContext}. + * + * @param chars The string to calculate metrics from. + * @param begin Index of first character in <code>text</code> to measure. + * @param limit Index of last character in <code>text</code> to measure. + * @param rc Context for calculating precise glyph placement and hints. + * + * @return A new {@link LineMetrics} object. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>chars</code>. + */ public LineMetrics getLineMetrics(char[] chars, int begin, int limit, FontRenderContext rc) -{ - return peer.getLineMetrics (this, new StringCharacterIterator (new String(chars)), - begin, limit, rc); -} + { + return peer.getLineMetrics(this, + new StringCharacterIterator(new String(chars)), + begin, limit, rc); + } -/** - * Returns a {@link LineMetrics} object constructed with the specified - * text and {@link FontRenderContext}. - * - * @param ci The string to calculate metrics from. - * @param begin Index of first character in <code>text</code> to measure. - * @param limit Index of last character in <code>text</code> to measure. - * @param rc Context for calculating precise glyph placement and hints. - * - * @return A new {@link LineMetrics} object. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>ci</code>. - */ - public LineMetrics getLineMetrics (CharacterIterator ci, int begin, - int limit, FontRenderContext rc) -{ - return peer.getLineMetrics (this, ci, begin, limit, rc); -} + /** + * Returns a {@link LineMetrics} object constructed with the specified + * text and {@link FontRenderContext}. + * + * @param ci The string to calculate metrics from. + * @param begin Index of first character in <code>text</code> to measure. + * @param limit Index of last character in <code>text</code> to measure. + * @param rc Context for calculating precise glyph placement and hints. + * + * @return A new {@link LineMetrics} object. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>ci</code>. + */ + public LineMetrics getLineMetrics(CharacterIterator ci, int begin, + int limit, FontRenderContext rc) + { + return peer.getLineMetrics(this, ci, begin, limit, rc); + } -/** - * Returns the maximal bounding box of all the bounding boxes in this - * font, when the font's bounding boxes are evaluated in a given {@link - * FontRenderContext} - * - * @param rc Context in which to evaluate bounding boxes. - * - * @return The maximal bounding box. - */ - public Rectangle2D getMaxCharBounds (FontRenderContext rc) -{ - return peer.getMaxCharBounds (this, rc); -} + /** + * Returns the maximal bounding box of all the bounding boxes in this + * font, when the font's bounding boxes are evaluated in a given {@link + * FontRenderContext} + * + * @param rc Context in which to evaluate bounding boxes. + * + * @return The maximal bounding box. + */ + public Rectangle2D getMaxCharBounds(FontRenderContext rc) + { + return peer.getMaxCharBounds(this, rc); + } -/** - * Returns the glyph code this font uses to represent missing glyphs. This - * code will be present in glyph vectors when the font was unable to - * locate a glyph to represent a particular character code. - * - * @return The missing glyph code. - * - * @since 1.2 - */ - public int getMissingGlyphCode () -{ - return peer.getMissingGlyphCode (this); -} + /** + * Returns the glyph code this font uses to represent missing glyphs. This + * code will be present in glyph vectors when the font was unable to + * locate a glyph to represent a particular character code. + * + * @return The missing glyph code. + * + * @since 1.2 + */ + public int getMissingGlyphCode() + { + return peer.getMissingGlyphCode(this); + } -/** - * Returns the overall number of glyphs in this font. This number is one - * more than the greatest glyph code used in any glyph vectors this font - * produces. In other words, glyph codes are taken from the range - * <code>[ 0, getNumGlyphs() - 1 ]</code>. - * - * @return The number of glyphs in this font. - * - * @since 1.2 - */ - public int getNumGlyphs () -{ - return peer.getMissingGlyphCode (this); -} + /** + * Returns the overall number of glyphs in this font. This number is one + * more than the greatest glyph code used in any glyph vectors this font + * produces. In other words, glyph codes are taken from the range + * <code>[ 0, getNumGlyphs() - 1 ]</code>. + * + * @return The number of glyphs in this font. + * + * @since 1.2 + */ + public int getNumGlyphs() + { + return peer.getMissingGlyphCode(this); + } -/** - * Returns the PostScript Name of this font. - * - * @return The PostScript Name of this font. - * - * @since 1.2 - * - * @see #getName() - * @see #getFamily() - * @see #getFontName() - */ - public String getPSName () -{ - return peer.getPostScriptName (this); -} + /** + * Returns the PostScript Name of this font. + * + * @return The PostScript Name of this font. + * + * @since 1.2 + * + * @see #getName() + * @see #getFamily() + * @see #getFontName() + */ + public String getPSName() + { + return peer.getPostScriptName(this); + } -/** - * Returns the logical bounds of the specified string when rendered with this - * font in the specified {@link FontRenderContext}. This box will include the - * glyph origin, ascent, advance, height, and leading, but may not include all - * diacritics or accents. To get the complete visual bounding box of all the - * glyphs in a run of text, use the {@link TextLayout#getBounds} method of - * {@link TextLayout}. - * - * @param str The string to measure. - * @param frc The context in which to make the precise glyph measurements. - * - * @return A bounding box covering the logical bounds of the specified text. - * - * @see #createGlyphVector(FontRenderContext, String) - */ - public Rectangle2D getStringBounds (String str, FontRenderContext frc) -{ - return getStringBounds (str, 0, str.length () - 1, frc); -} + /** + * Returns the logical bounds of the specified string when rendered with this + * font in the specified {@link FontRenderContext}. This box will include the + * glyph origin, ascent, advance, height, and leading, but may not include all + * diacritics or accents. To get the complete visual bounding box of all the + * glyphs in a run of text, use the {@link TextLayout#getBounds} method of + * {@link TextLayout}. + * + * @param str The string to measure. + * @param frc The context in which to make the precise glyph measurements. + * + * @return A bounding box covering the logical bounds of the specified text. + * + * @see #createGlyphVector(FontRenderContext, String) + */ + public Rectangle2D getStringBounds(String str, FontRenderContext frc) + { + return getStringBounds(str, 0, str.length() - 1, frc); + } -/** - * Returns the logical bounds of the specified string when rendered with this - * font in the specified {@link FontRenderContext}. This box will include the - * glyph origin, ascent, advance, height, and leading, but may not include all - * diacritics or accents. To get the complete visual bounding box of all the - * glyphs in a run of text, use the {@link TextLayout#getBounds} method of - * {@link TextLayout}. - * - * @param str The string to measure. - * @param begin Index of the first character in <code>str</code> to measure. - * @param limit Index of the last character in <code>str</code> to measure. - * @param frc The context in which to make the precise glyph measurements. - * - * @return A bounding box covering the logical bounds of the specified text. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>str</code>. - * - * @since 1.2 - * - * @see #createGlyphVector(FontRenderContext, String) - */ - public Rectangle2D getStringBounds (String str, int begin, - int limit, FontRenderContext frc) -{ - return peer.getStringBounds (this, new StringCharacterIterator(str), begin, limit, frc); -} + /** + * Returns the logical bounds of the specified string when rendered with this + * font in the specified {@link FontRenderContext}. This box will include the + * glyph origin, ascent, advance, height, and leading, but may not include all + * diacritics or accents. To get the complete visual bounding box of all the + * glyphs in a run of text, use the {@link TextLayout#getBounds} method of + * {@link TextLayout}. + * + * @param str The string to measure. + * @param begin Index of the first character in <code>str</code> to measure. + * @param limit Index of the last character in <code>str</code> to measure. + * @param frc The context in which to make the precise glyph measurements. + * + * @return A bounding box covering the logical bounds of the specified text. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>str</code>. + * + * @since 1.2 + * + * @see #createGlyphVector(FontRenderContext, String) + */ + public Rectangle2D getStringBounds(String str, int begin, + int limit, FontRenderContext frc) + { + return peer.getStringBounds(this, new StringCharacterIterator(str), begin, + limit, frc); + } -/** - * Returns the logical bounds of the specified string when rendered with this - * font in the specified {@link FontRenderContext}. This box will include the - * glyph origin, ascent, advance, height, and leading, but may not include all - * diacritics or accents. To get the complete visual bounding box of all the - * glyphs in a run of text, use the {@link TextLayout#getBounds} method of - * {@link TextLayout}. - * - * @param ci The text to measure. - * @param begin Index of the first character in <code>ci</code> to measure. - * @param limit Index of the last character in <code>ci</code> to measure. - * @param frc The context in which to make the precise glyph measurements. - * - * @return A bounding box covering the logical bounds of the specified text. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>ci</code>. - * - * @since 1.2 - * - * @see #createGlyphVector(FontRenderContext, CharacterIterator) - */ - public Rectangle2D getStringBounds (CharacterIterator ci, int begin, - int limit, FontRenderContext frc) -{ - return peer.getStringBounds (this, ci, begin, limit, frc); -} + /** + * Returns the logical bounds of the specified string when rendered with this + * font in the specified {@link FontRenderContext}. This box will include the + * glyph origin, ascent, advance, height, and leading, but may not include all + * diacritics or accents. To get the complete visual bounding box of all the + * glyphs in a run of text, use the {@link TextLayout#getBounds} method of + * {@link TextLayout}. + * + * @param ci The text to measure. + * @param begin Index of the first character in <code>ci</code> to measure. + * @param limit Index of the last character in <code>ci</code> to measure. + * @param frc The context in which to make the precise glyph measurements. + * + * @return A bounding box covering the logical bounds of the specified text. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>ci</code>. + * + * @since 1.2 + * + * @see #createGlyphVector(FontRenderContext, CharacterIterator) + */ + public Rectangle2D getStringBounds(CharacterIterator ci, int begin, + int limit, FontRenderContext frc) + { + return peer.getStringBounds(this, ci, begin, limit, frc); + } -/** - * Returns the logical bounds of the specified string when rendered with this - * font in the specified {@link FontRenderContext}. This box will include the - * glyph origin, ascent, advance, height, and leading, but may not include all - * diacritics or accents. To get the complete visual bounding box of all the - * glyphs in a run of text, use the {@link TextLayout#getBounds} method of - * {@link TextLayout}. - * - * @param chars The text to measure. - * @param begin Index of the first character in <code>ci</code> to measure. - * @param limit Index of the last character in <code>ci</code> to measure. - * @param frc The context in which to make the precise glyph measurements. - * - * @return A bounding box covering the logical bounds of the specified text. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>chars</code>. - * - * @since 1.2 - * - * @see #createGlyphVector(FontRenderContext, char[]) - */ - public Rectangle2D getStringBounds (char[] chars, int begin, - int limit, FontRenderContext frc) -{ - return peer.getStringBounds (this, new StringCharacterIterator (new String (chars)), - begin, limit, frc); -} + /** + * Returns the logical bounds of the specified string when rendered with this + * font in the specified {@link FontRenderContext}. This box will include the + * glyph origin, ascent, advance, height, and leading, but may not include all + * diacritics or accents. To get the complete visual bounding box of all the + * glyphs in a run of text, use the {@link TextLayout#getBounds} method of + * {@link TextLayout}. + * + * @param chars The text to measure. + * @param begin Index of the first character in <code>ci</code> to measure. + * @param limit Index of the last character in <code>ci</code> to measure. + * @param frc The context in which to make the precise glyph measurements. + * + * @return A bounding box covering the logical bounds of the specified text. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>chars</code>. + * + * @since 1.2 + * + * @see #createGlyphVector(FontRenderContext, char[]) + */ + public Rectangle2D getStringBounds(char[] chars, int begin, + int limit, FontRenderContext frc) + { + return peer.getStringBounds(this, + new StringCharacterIterator(new String(chars)), + begin, limit, frc); + } -/** - * Returns a copy of the affine transformation this font is currently - * subject to, if any. - * - * @return The current transformation. - */ - public AffineTransform getTransform () -{ - return peer.getTransform (this); -} + /** + * Returns a copy of the affine transformation this font is currently + * subject to, if any. + * + * @return The current transformation. + */ + public AffineTransform getTransform() + { + return peer.getTransform(this); + } -/** - * Indicates whether this font's line metrics are uniform. A font may be - * composed of several "subfonts", each covering a different code range, - * and each with their own line metrics. A font with no subfonts, or - * subfonts with identical line metrics, is said to have "uniform" line - * metrics. - * - * @return Whether this font has uniform line metrics. - * - * @see LineMetrics - * @see #getLineMetrics(String, FontRenderContext) - */ - public boolean hasUniformLineMetrics () -{ - return peer.hasUniformLineMetrics (this); -} + /** + * Indicates whether this font's line metrics are uniform. A font may be + * composed of several "subfonts", each covering a different code range, + * and each with their own line metrics. A font with no subfonts, or + * subfonts with identical line metrics, is said to have "uniform" line + * metrics. + * + * @return Whether this font has uniform line metrics. + * + * @see LineMetrics + * @see #getLineMetrics(String, FontRenderContext) + */ + public boolean hasUniformLineMetrics() + { + return peer.hasUniformLineMetrics(this); + } -/** - * Indicates whether this font is subject to a non-identity affine - * transformation. - * - * @return <code>true</code> iff the font has a non-identity affine - * transformation applied to it. - */ - public boolean isTransformed () -{ - return peer.isTransformed (this); -} + /** + * Indicates whether this font is subject to a non-identity affine + * transformation. + * + * @return <code>true</code> iff the font has a non-identity affine + * transformation applied to it. + */ + public boolean isTransformed() + { + return peer.isTransformed(this); + } -/** - * Produces a glyph vector representing a full layout fo the specified - * text in this font. Full layouts may include complex shaping and - * reordering operations, for scripts such as Arabic or Hindi. - * - * Bidirectional (bidi) layout is not performed in this method; text - * should have its bidi direction specified with one of the flags {@link - * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}. - * - * Some types of layout (notably Arabic glyph shaping) may examine context - * characters beyond the bounds of the indicated range, in order to select - * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and - * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra - * context areas from being examined, for instance if they contain invalid - * characters. - * - * @param frc Context in which to perform the layout. - * @param chars Text to perform layout on. - * @param start Index of first character to perform layout on. - * @param limit Index of last character to perform layout on. - * @param flags Combination of flags controlling layout. - * - * @return A new {@link GlyphVector} representing the specified text. - * - * @throws IndexOutOfBoundsException if the range [begin, limit] is - * invalid in <code>chars</code>. - */ - public GlyphVector layoutGlyphVector (FontRenderContext frc, - char[] chars, int start, - int limit, int flags) -{ - return peer.layoutGlyphVector (this, frc, chars, start, limit, flags); -} + /** + * Produces a glyph vector representing a full layout fo the specified + * text in this font. Full layouts may include complex shaping and + * reordering operations, for scripts such as Arabic or Hindi. + * + * Bidirectional (bidi) layout is not performed in this method; text + * should have its bidi direction specified with one of the flags {@link + * #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}. + * + * Some types of layout (notably Arabic glyph shaping) may examine context + * characters beyond the bounds of the indicated range, in order to select + * an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and + * {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra + * context areas from being examined, for instance if they contain invalid + * characters. + * + * @param frc Context in which to perform the layout. + * @param chars Text to perform layout on. + * @param start Index of first character to perform layout on. + * @param limit Index of last character to perform layout on. + * @param flags Combination of flags controlling layout. + * + * @return A new {@link GlyphVector} representing the specified text. + * + * @throws IndexOutOfBoundsException if the range [begin, limit] is + * invalid in <code>chars</code>. + */ + public GlyphVector layoutGlyphVector(FontRenderContext frc, + char[] chars, int start, + int limit, int flags) + { + return peer.layoutGlyphVector(this, frc, chars, start, limit, flags); + } -/** - * Returns a native peer object for this font. - * - * @return A native peer object for this font. - * - * @deprecated - */ - public FontPeer getPeer () -{ + /** + * Returns a native peer object for this font. + * + * @return A native peer object for this font. + * + * @deprecated + */ + public FontPeer getPeer() + { return peer; -} + } -/** - * Returns a hash value for this font. - * - * @return A hash for this font. - */ + /** + * Returns a hash value for this font. + * + * @return A hash for this font. + */ public int hashCode() -{ + { return this.toString().hashCode(); -} - - -/** - * Tests whether or not the specified object is equal to this font. This - * will be true if and only if: - * <P> - * <ul> - * <li>The object is not <code>null</code>. - * <li>The object is an instance of <code>Font</code>. - * <li>The object has the same names, style, size, and transform as this object. - * </ul> - * - * @return <code>true</code> if the specified object is equal to this - * object, <code>false</code> otherwise. - */ -public boolean -equals(Object obj) -{ - if (obj == null) - return(false); + } - if (!(obj instanceof Font)) - return(false); - Font f = (Font)obj; + /** + * Tests whether or not the specified object is equal to this font. This + * will be true if and only if: + * <P> + * <ul> + * <li>The object is not <code>null</code>. + * <li>The object is an instance of <code>Font</code>. + * <li>The object has the same names, style, size, and transform as this object. + * </ul> + * + * @return <code>true</code> if the specified object is equal to this + * object, <code>false</code> otherwise. + */ + public boolean equals(Object obj) + { + if (obj == null) + return false; - return (f.getName ().equals (this.getName ()) && - f.getFamily ().equals (this.getFamily ()) && - f.getFontName ().equals (this.getFontName ()) && - f.getTransform ().equals (this.getTransform ()) && - f.getSize() == this.getSize() && - f.getStyle() == this.getStyle()); -} + if (! (obj instanceof Font)) + return false; -/*************************************************************************/ + Font f = (Font) obj; -/** - * Returns a string representation of this font. - * - * @return A string representation of this font. - */ -public String -toString() -{ - String styleString = ""; - - switch (getStyle ()) - { - case 0: - styleString = "plain"; - break; - case 1: - styleString = "bold"; - break; - case 2: - styleString = "italic"; - break; - default: - styleString = "unknown"; - } + return (f.getName().equals(this.getName()) + && f.getFamily().equals(this.getFamily()) + && f.getFontName().equals(this.getFontName()) + && f.getTransform().equals(this.getTransform ()) + && f.getSize() == this.getSize() + && f.getStyle() == this.getStyle()); + } - return getClass ().getName () - + "[family=" + getFamily () - + ",name=" + getFontName () - + ",style=" + styleString - + ",size=" + getSize () + "]"; -} + /** + * Returns a string representation of this font. + * + * @return A string representation of this font. + */ + public String toString() + { + String styleString = ""; + + switch (getStyle()) + { + case 0: + styleString = "plain"; + break; + case 1: + styleString = "bold"; + break; + case 2: + styleString = "italic"; + break; + default: + styleString = "unknown"; + } + + return getClass().getName() + + "[family=" + getFamily () + + ",name=" + getFontName () + + ",style=" + styleString + + ",size=" + getSize () + "]"; + } /** @@ -1331,8 +1321,22 @@ toString() */ public LineMetrics getLineMetrics(String str, FontRenderContext frc) { - return getLineMetrics (str, 0, str.length () - 1, frc); + return getLineMetrics(str, 0, str.length() - 1, frc); } -} // class Font + /** + * Reads the normal fields from the stream and then constructs the + * peer from the style and size through getPeerFromToolkit(). + */ + private void readObject(ObjectInputStream ois) + throws IOException, ClassNotFoundException + { + ois.defaultReadObject(); + + HashMap attrs = new HashMap(); + ClasspathFontPeer.copyStyleToAttrs(style, attrs); + ClasspathFontPeer.copySizeToAttrs(size, attrs); + peer = getPeerFromToolkit(name, attrs); + } +} diff --git a/libjava/classpath/java/awt/FontMetrics.java b/libjava/classpath/java/awt/FontMetrics.java index 6dd73ec2560..91866462fee 100644 --- a/libjava/classpath/java/awt/FontMetrics.java +++ b/libjava/classpath/java/awt/FontMetrics.java @@ -362,6 +362,18 @@ public abstract class FontMetrics implements java.io.Serializable rc = gRC; return font.getLineMetrics(chars, begin, limit, rc); } + + /** + * Returns the bounds of the largest character in a Graphics context. + * @param context the Graphics context object. + * @return a <code>Rectangle2D</code> representing the bounds + */ + public Rectangle2D getMaxCharBounds(Graphics context) + { + if( context instanceof Graphics2D ) + return font.getMaxCharBounds(((Graphics2D)context).getFontRenderContext()); + return font.getMaxCharBounds( gRC ); + } /** * Returns a {@link LineMetrics} object constructed with the @@ -424,4 +436,13 @@ public abstract class FontMetrics implements java.io.Serializable return gRC; } + + /** + * Returns if the font has uniform line metrics. + * @see Font#hasUniformLineMetrics() + */ + public boolean hasUniformLineMetrics() + { + return font.hasUniformLineMetrics(); + } } diff --git a/libjava/classpath/java/awt/Frame.java b/libjava/classpath/java/awt/Frame.java index 05c938496e0..d6651f83e40 100644 --- a/libjava/classpath/java/awt/Frame.java +++ b/libjava/classpath/java/awt/Frame.java @@ -591,6 +591,8 @@ public static Frame[] getFrames() protected class AccessibleAWTFrame extends AccessibleAWTWindow { + private static final long serialVersionUID = -6172960752956030250L; + public AccessibleRole getAccessibleRole() { return AccessibleRole.FRAME; diff --git a/libjava/classpath/java/awt/Graphics.java b/libjava/classpath/java/awt/Graphics.java index ff26190e5f0..a28ca7e428c 100644 --- a/libjava/classpath/java/awt/Graphics.java +++ b/libjava/classpath/java/awt/Graphics.java @@ -42,726 +42,595 @@ import java.awt.image.ImageObserver; import java.text.AttributedCharacterIterator; /** - * This is the abstract superclass of classes for drawing to graphics - * devices such as the screen or printers. - * - * @author Aaron M. Renn (arenn@urbanophile.com) - * @author Warren Levy (warrenl@cygnus.com) - */ -public abstract class Graphics -{ - -/* - * Instance Variables - */ - -/*************************************************************************/ - -/* - * Constructors - */ - -/** - * Default constructor for subclasses. - */ -protected -Graphics() -{ -} - -/*************************************************************************/ - -/* - * Instance Methods + * This is the abstract superclass of classes for drawing to graphics + * devices such as the screen or printers. + * + * @author Aaron M. Renn (arenn@urbanophile.com) + * @author Warren Levy (warrenl@cygnus.com) */ - -/** - * Returns a copy of this <code>Graphics</code> object. - * - * @return A copy of this object. - */ -public abstract Graphics -create(); - -/*************************************************************************/ - -/** - * Returns a copy of this <code>Graphics</code> object. The origin point - * will be translated to the point (x, y) and the cliping rectangle set - * to the intersection of the clipping rectangle in this object and the - * rectangle specified by the parameters to this method. - * - * @param x The new X coordinate of the clipping region rect. - * @param y The new Y coordinate of the clipping region rect. - * @param width The width of the clipping region intersect rectangle. - * @param height The height of the clipping region intersect rectangle. - * - * @return A copy of this object, modified as specified. - */ -public Graphics -create(int x, int y, int width, int height) +public abstract class Graphics { - Graphics g = create(); - - g.translate(x, y); - // FIXME: I'm not sure if this will work. Are the old clip rect bounds - // translated above? - g.clipRect(0, 0, width, height); - return(g); -} - -/*************************************************************************/ - -/** - * Translates this context so that its new origin point is the point - * (x, y). - * - * @param x The new X coordinate of the origin. - * @param y The new Y coordinate of the origin. - */ -public abstract void -translate(int x, int y); - -/*************************************************************************/ - -/** - * Returns the current color for this object. - * - * @return The color for this object. - */ -public abstract Color -getColor(); - -/*************************************************************************/ - -/** - * Sets the current color for this object. - * - * @param color The new color. - */ -public abstract void -setColor(Color color); - -/*************************************************************************/ - -/** - * Sets this context into "paint" mode, where the target pixels are - * completely overwritten when drawn on. - */ -public abstract void -setPaintMode(); - -/*************************************************************************/ - -/** - * Sets this context info "XOR" mode, where the targe pixles are - * XOR-ed when drawn on. - * - * @param color The color to XOR against. - */ -public abstract void -setXORMode(Color color); + /** + * Default constructor for subclasses. + */ + protected + Graphics() + { + } + + /** + * Returns a copy of this <code>Graphics</code> object. + * + * @return A copy of this object. + */ + public abstract Graphics create(); + + /** + * Returns a copy of this <code>Graphics</code> object. The origin point + * will be translated to the point (x, y) and the cliping rectangle set + * to the intersection of the clipping rectangle in this object and the + * rectangle specified by the parameters to this method. + * + * @param x The new X coordinate of the clipping region rect. + * @param y The new Y coordinate of the clipping region rect. + * @param width The width of the clipping region intersect rectangle. + * @param height The height of the clipping region intersect rectangle. + * + * @return A copy of this object, modified as specified. + */ + public Graphics create(int x, int y, int width, int height) + { + Graphics g = create(); + + g.translate(x, y); + // FIXME: I'm not sure if this will work. Are the old clip rect bounds + // translated above? + g.clipRect(0, 0, width, height); + + return(g); + } + + /** + * Translates this context so that its new origin point is the point + * (x, y). + * + * @param x The new X coordinate of the origin. + * @param y The new Y coordinate of the origin. + */ + public abstract void translate(int x, int y); + + /** + * Returns the current color for this object. + * + * @return The color for this object. + */ + public abstract Color getColor(); + + /** + * Sets the current color for this object. + * + * @param color The new color. + */ + public abstract void setColor(Color color); + + /** + * Sets this context into "paint" mode, where the target pixels are + * completely overwritten when drawn on. + */ + public abstract void setPaintMode(); + + /** + * Sets this context info "XOR" mode, where the targe pixles are + * XOR-ed when drawn on. + * + * @param color The color to XOR against. + */ + public abstract void setXORMode(Color color); -/*************************************************************************/ - -/** - * Returns the current font for this graphics context. - * - * @return The current font. - */ -public abstract Font -getFont(); - -/*************************************************************************/ - -/** - * Sets the font for this graphics context to the specified value. - * - * @param font The new font. - */ -public abstract void -setFont(Font font); - -/*************************************************************************/ - -/** - * Returns the font metrics for the current font. - * - * @return The font metrics for the current font. - */ -public FontMetrics -getFontMetrics() -{ - return(getFontMetrics(getFont())); -} - -/*************************************************************************/ - -/** - * Returns the font metrics for the specified font. - * - * @param font The font to return metrics for. - * - * @return The requested font metrics. - */ -public abstract FontMetrics -getFontMetrics(Font font); - -/*************************************************************************/ - -/** - * Returns the bounding rectangle of the clipping region for this - * graphics context. - * - * @return The bounding rectangle for the clipping region. - */ -public abstract Rectangle -getClipBounds(); - -/*************************************************************************/ - -/** - * Returns the bounding rectangle of the clipping region for this - * graphics context. - * - * @return The bounding rectangle for the clipping region. - * - * @deprecated This method is deprecated in favor of - * <code>getClipBounds()</code>. - */ -public Rectangle -getClipRect() -{ - return(getClipBounds()); -} - -/*************************************************************************/ - -/** - * Sets the clipping region to the intersection of the current clipping - * region and the rectangle determined by the specified parameters. - * - * @param x The X coordinate of the upper left corner of the intersect rect. - * @param y The Y coordinate of the upper left corner of the intersect rect. - * @param width The width of the intersect rect. - * @param height The height of the intersect rect. - */ -public abstract void -clipRect(int x, int y, int width, int height); - -/*************************************************************************/ - -/** - * Sets the clipping region to the rectangle determined by the specified - * parameters. - * - * @param x The X coordinate of the upper left corner of the rect. - * @param y The Y coordinate of the upper left corner of the rect. - * @param width The width of the rect. - * @param height The height of the rect. - */ -public abstract void -setClip(int x, int y, int width, int height); - -/*************************************************************************/ - -/** - * Returns the current clipping region as a <code>Shape</code> object. - * - * @return The clipping region as a <code>Shape</code>. - */ -public abstract Shape -getClip(); - -/*************************************************************************/ - -/** - * Sets the clipping region to the specified <code>Shape</code>. - * - * @param clip The new clipping region. - */ -public abstract void -setClip(Shape clip); - -/*************************************************************************/ - -/** - * Copies the specified rectangle to the specified offset location. - * - * @param x The X coordinate of the upper left corner of the copy rect. - * @param y The Y coordinate of the upper left corner of the copy rect. - * @param width The width of the copy rect. - * @param height The height of the copy rect. - * @param dx The offset from the X value to start drawing. - * @param dy The offset from the Y value to start drawing. - */ -public abstract void -copyArea(int x, int y, int width, int height, int dx, int dy); - -/*************************************************************************/ - -/** - * Draws a line between the two specified points. - * - * @param x1 The X coordinate of the first point. - * @param y1 The Y coordinate of the first point. - * @param x2 The X coordinate of the second point. - * @param y2 The Y coordinate of the second point. - */ -public abstract void -drawLine(int x1, int y1, int x2, int y2); - -/*************************************************************************/ - -/** - * Fills the area bounded by the specified rectangle. - * - * @param x The X coordinate of the upper left corner of the fill rect. - * @param y The Y coordinate of the upper left corner of the fill rect. - * @param width The width of the fill rect. - * @param height The height of the fill rect. - */ -public abstract void -fillRect(int x, int y, int width, int height); - -/*************************************************************************/ - -/** - * Draws the outline of the specified rectangle. - * - * @param x The X coordinate of the upper left corner of the draw rect. - * @param y The Y coordinate of the upper left corner of the draw rect. - * @param width The width of the draw rect. - * @param height The height of the draw rect. - */ -public void -drawRect(int x, int y, int width, int height) -{ - int x1 = x; - int y1 = y; - int x2 = x + width; - int y2 = y + height; - drawLine(x1, y1, x2, y1); - drawLine(x2, y1, x2, y2); - drawLine(x2, y2, x1, y2); - drawLine(x1, y2, x1, y1); -} - -/*************************************************************************/ - -/** - * Clears the specified rectangle. - * - * @param x The X coordinate of the upper left corner of the clear rect. - * @param y The Y coordinate of the upper left corner of the clear rect. - * @param width The width of the clear rect. - * @param height The height of the clear rect. - */ -public abstract void -clearRect(int x, int y, int width, int height); - -/*************************************************************************/ - -/** - * Draws the outline of the specified rectangle with rounded cornders. - * - * @param x The X coordinate of the upper left corner of the draw rect. - * @param y The Y coordinate of the upper left corner of the draw rect. - * @param width The width of the draw rect. - * @param height The height of the draw rect. - * @param arcWidth The width of the corner arcs. - * @param arcHeight The height of the corner arcs. - */ -public abstract void -drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); - -/*************************************************************************/ - -/** - * Fills the specified rectangle with rounded cornders. - * - * @param x The X coordinate of the upper left corner of the fill rect. - * @param y The Y coordinate of the upper left corner of the fill rect. - * @param width The width of the fill rect. - * @param height The height of the fill rect. - * @param arcWidth The width of the corner arcs. - * @param arcHeight The height of the corner arcs. - */ -public abstract void -fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight); - -/*************************************************************************/ - -public void -draw3DRect(int x, int y, int width, int height, boolean raised) -{ - Color color = getColor(); - Color tl = color.brighter(); - Color br = color.darker(); + /** + * Returns the current font for this graphics context. + * + * @return The current font. + */ + public abstract Font getFont(); + + /** + * Sets the font for this graphics context to the specified value. + * + * @param font The new font. + */ + public abstract void setFont(Font font); + + /** + * Returns the font metrics for the current font. + * + * @return The font metrics for the current font. + */ + public FontMetrics getFontMetrics() + { + return getFontMetrics(getFont()); + } + + /** + * Returns the font metrics for the specified font. + * + * @param font The font to return metrics for. + * + * @return The requested font metrics. + */ + public abstract FontMetrics getFontMetrics(Font font); + + /** + * Returns the bounding rectangle of the clipping region for this + * graphics context. + * + * @return The bounding rectangle for the clipping region. + */ + public abstract Rectangle getClipBounds(); + + /** + * Returns the bounding rectangle of the clipping region for this + * graphics context. + * + * @return The bounding rectangle for the clipping region. + * + * @deprecated This method is deprecated in favor of + * <code>getClipBounds()</code>. + */ + public Rectangle getClipRect() + { + return getClipBounds(); + } + + /** + * Sets the clipping region to the intersection of the current clipping + * region and the rectangle determined by the specified parameters. + * + * @param x The X coordinate of the upper left corner of the intersect rect. + * @param y The Y coordinate of the upper left corner of the intersect rect. + * @param width The width of the intersect rect. + * @param height The height of the intersect rect. + */ + public abstract void clipRect(int x, int y, int width, int height); + + /** + * Sets the clipping region to the rectangle determined by the specified + * parameters. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ + public abstract void setClip(int x, int y, int width, int height); + + /** + * Returns the current clipping region as a <code>Shape</code> object. + * + * @return The clipping region as a <code>Shape</code>. + */ + public abstract Shape getClip(); + + /** + * Sets the clipping region to the specified <code>Shape</code>. + * + * @param clip The new clipping region. + */ + public abstract void setClip(Shape clip); + + /** + * Copies the specified rectangle to the specified offset location. + * + * @param x The X coordinate of the upper left corner of the copy rect. + * @param y The Y coordinate of the upper left corner of the copy rect. + * @param width The width of the copy rect. + * @param height The height of the copy rect. + * @param dx The offset from the X value to start drawing. + * @param dy The offset from the Y value to start drawing. + */ + public abstract void copyArea(int x, int y, int width, int height, int dx, + int dy); + + /** + * Draws a line between the two specified points. + * + * @param x1 The X coordinate of the first point. + * @param y1 The Y coordinate of the first point. + * @param x2 The X coordinate of the second point. + * @param y2 The Y coordinate of the second point. + */ + public abstract void drawLine(int x1, int y1, int x2, int y2); + + /** + * Fills the area bounded by the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + */ + public abstract void fillRect(int x, int y, int width, int height); + + /** + * Draws the outline of the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + */ + public void drawRect(int x, int y, int width, int height) + { + int x1 = x; + int y1 = y; + int x2 = x + width; + int y2 = y + height; + drawLine(x1, y1, x2, y1); + drawLine(x2, y1, x2, y2); + drawLine(x2, y2, x1, y2); + drawLine(x1, y2, x1, y1); + } + + /** + * Clears the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the clear rect. + * @param y The Y coordinate of the upper left corner of the clear rect. + * @param width The width of the clear rect. + * @param height The height of the clear rect. + */ + public abstract void clearRect(int x, int y, int width, int height); + + /** + * Draws the outline of the specified rectangle with rounded cornders. + * + * @param x The X coordinate of the upper left corner of the draw rect. + * @param y The Y coordinate of the upper left corner of the draw rect. + * @param width The width of the draw rect. + * @param height The height of the draw rect. + * @param arcWidth The width of the corner arcs. + * @param arcHeight The height of the corner arcs. + */ + public abstract void drawRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight); + + /** + * Fills the specified rectangle with rounded cornders. + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + * @param arcWidth The width of the corner arcs. + * @param arcHeight The height of the corner arcs. + */ + public abstract void fillRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight); + + public void draw3DRect(int x, int y, int width, int height, boolean raised) + { + Color color = getColor(); + Color tl = color.brighter(); + Color br = color.darker(); - if (!raised) - { - Color tmp = tl; - tl = br; - br = tmp; - } + if (!raised) + { + Color tmp = tl; + tl = br; + br = tmp; + } - int x1 = x; - int y1 = y; - int x2 = x + width; - int y2 = y + height; + int x1 = x; + int y1 = y; + int x2 = x + width; + int y2 = y + height; - setColor(tl); - drawLine(x1, y1, x2, y1); - drawLine(x1, y2, x1, y1); - setColor(br); - drawLine(x2, y1, x2, y2); - drawLine(x2, y2, x1, y2); - setColor(color); -} - -/** - * Fills the specified rectangle with a 3D effect - * - * @param x The X coordinate of the upper left corner of the fill rect. - * @param y The Y coordinate of the upper left corner of the fill rect. - * @param width The width of the fill rect. - * @param height The height of the fill rect. - * @param raised <code>true</code> if the rectangle appears raised, - * <code>false</code> if it should appear etched. - */ -public void -fill3DRect(int x, int y, int width, int height, boolean raised) -{ - fillRect(x, y, width, height); - draw3DRect(x, y, width-1, height-1, raised); -} - -/*************************************************************************/ - -/** - * Draws an oval that just fits within the specified rectangle. - * - * @param x The X coordinate of the upper left corner of the rect. - * @param y The Y coordinate of the upper left corner of the rect. - * @param width The width of the rect. - * @param height The height of the rect. - */ -public abstract void -drawOval(int x, int y, int width, int height); - -/*************************************************************************/ - -/** - * Fills an oval that just fits within the specified rectangle. - * - * @param x The X coordinate of the upper left corner of the rect. - * @param y The Y coordinate of the upper left corner of the rect. - * @param width The width of the rect. - * @param height The height of the rect. - */ -public abstract void -fillOval(int x, int y, int width, int height); - -/*************************************************************************/ - -/** - * Draws an arc using the specified bounding rectangle and the specified - * angle parameter. The arc is centered at the center of the rectangle. - * The arc starts at the arcAngle position and extend for arcAngle - * degrees. The degree origin is at the 3 o'clock position. - * - * @param x The X coordinate of the upper left corner of the rect. - * @param y The Y coordinate of the upper left corner of the rect. - * @param width The width of the rect. - * @param height The height of the rect. - * @param arcStart The beginning angle of the arc. - * @param arcAngle The extent of the arc. - */ -public abstract void -drawArc(int x, int y, int width, int height, int arcStart, int arcAngle); - -/*************************************************************************/ - -/** - * Fills the arc define by the specified bounding rectangle and the specified - * angle parameter. The arc is centered at the center of the rectangle. - * The arc starts at the arcAngle position and extend for arcAngle - * degrees. The degree origin is at the 3 o'clock position. - * - * @param x The X coordinate of the upper left corner of the rect. - * @param y The Y coordinate of the upper left corner of the rect. - * @param width The width of the rect. - * @param height The height of the rect. - * @param arcStart The beginning angle of the arc. - * @param arcAngle The extent of the arc. - */ -public abstract void -fillArc(int x, int y, int width, int height, int arcStart, int arcAngle); - -/*************************************************************************/ - -/** - * Draws a series of interconnected lines determined by the arrays - * of corresponding x and y coordinates. - * - * @param xPoints The X coordinate array. - * @param yPoints The Y coordinate array. - * @param npoints The number of points to draw. - */ -public abstract void -drawPolyline(int xPoints[], int yPoints[], int npoints); - -/*************************************************************************/ - -/** - * Draws a series of interconnected lines determined by the arrays - * of corresponding x and y coordinates. The figure is closed if necessary - * by connecting the first and last points. - * - * @param xPoints The X coordinate array. - * @param yPoints The Y coordinate array. - * @param npoints The number of points to draw. - */ -public abstract void -drawPolygon(int xPoints[], int yPoints[], int npoints); - -/*************************************************************************/ - -/** - * Draws the specified polygon. - * - * @param polygon The polygon to draw. - */ -public void -drawPolygon(Polygon polygon) -{ - drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); -} - -/*************************************************************************/ - -/** - * Fills the polygon determined by the arrays - * of corresponding x and y coordinates. - * - * @param xPoints The X coordinate array. - * @param yPoints The Y coordinate array. - * @param npoints The number of points to draw. - */ -public abstract void -fillPolygon(int xPoints[], int yPoints[], int npoints); - -/*************************************************************************/ - -/** - * Fills the specified polygon - * - * @param polygon The polygon to fill. - */ -public void -fillPolygon(Polygon polygon) -{ - fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); -} - -/*************************************************************************/ - -/** - * Draws the specified string starting at the specified point. - * - * @param string The string to draw. - * @param x The X coordinate of the point to draw at. - * @param y The Y coordinate of the point to draw at. - */ -public abstract void -drawString(String string, int x, int y); - -public abstract void drawString (AttributedCharacterIterator ci, int x, int y); - -/*************************************************************************/ - -/** - * Draws the specified characters starting at the specified point. - * - * @param data The array of characters to draw. - * @param offset The offset into the array to start drawing characters from. - * @param length The number of characters to draw. - * @param x The X coordinate of the point to draw at. - * @param y The Y coordinate of the point to draw at. - */ -public void -drawChars(char data[], int offset, int length, int x, int y) -{ - drawString(new String(data, offset, length), x, y); -} - -public void -drawBytes(byte[] data, int offset, int length, int x, int y) -{ - String str = new String(data, offset, length); - drawString(str, x, y); -} - -/*************************************************************************/ - -/** - * Draws all of the image that is available and returns. If the image - * is not completely loaded, <code>false</code> is returned and - * the specified iamge observer is notified as more data becomes - * available. - * - * @param image The image to draw. - * @param x The X coordinate of the point to draw at. - * @param y The Y coordinate of the point to draw at. - * @param observer The image observer to notify as data becomes available. - * - * @return <code>true</code> if all the image data is available, - * <code>false</code> otherwise. - */ -public abstract boolean -drawImage(Image image, int x, int y, ImageObserver observer); + setColor(tl); + drawLine(x1, y1, x2, y1); + drawLine(x1, y2, x1, y1); + setColor(br); + drawLine(x2, y1, x2, y2); + drawLine(x2, y2, x1, y2); + setColor(color); + } + + /** + * Fills the specified rectangle with a 3D effect + * + * @param x The X coordinate of the upper left corner of the fill rect. + * @param y The Y coordinate of the upper left corner of the fill rect. + * @param width The width of the fill rect. + * @param height The height of the fill rect. + * @param raised <code>true</code> if the rectangle appears raised, + * <code>false</code> if it should appear etched. + */ + public void fill3DRect(int x, int y, int width, int height, boolean raised) + { + fillRect(x, y, width, height); + draw3DRect(x, y, width-1, height-1, raised); + } + + /** + * Draws an oval that just fits within the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ + public abstract void drawOval(int x, int y, int width, int height); + + /** + * Fills an oval that just fits within the specified rectangle. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + */ + public abstract void fillOval(int x, int y, int width, int height); + + /** + * Draws an arc using the specified bounding rectangle and the specified + * angle parameter. The arc is centered at the center of the rectangle. + * The arc starts at the arcAngle position and extend for arcAngle + * degrees. The degree origin is at the 3 o'clock position. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + * @param arcStart The beginning angle of the arc. + * @param arcAngle The extent of the arc. + */ + public abstract void drawArc(int x, int y, int width, int height, + int arcStart, int arcAngle); + + /** + * Fills the arc define by the specified bounding rectangle and the specified + * angle parameter. The arc is centered at the center of the rectangle. + * The arc starts at the arcAngle position and extend for arcAngle + * degrees. The degree origin is at the 3 o'clock position. + * + * @param x The X coordinate of the upper left corner of the rect. + * @param y The Y coordinate of the upper left corner of the rect. + * @param width The width of the rect. + * @param height The height of the rect. + * @param arcStart The beginning angle of the arc. + * @param arcAngle The extent of the arc. + */ + public abstract void fillArc(int x, int y, int width, int height, + int arcStart, int arcAngle); + + /** + * Draws a series of interconnected lines determined by the arrays + * of corresponding x and y coordinates. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ + public abstract void drawPolyline(int xPoints[], int yPoints[], int npoints); + + /** + * Draws a series of interconnected lines determined by the arrays + * of corresponding x and y coordinates. The figure is closed if necessary + * by connecting the first and last points. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ + public abstract void drawPolygon(int xPoints[], int yPoints[], int npoints); + + /** + * Draws the specified polygon. + * + * @param polygon The polygon to draw. + */ + public void drawPolygon(Polygon polygon) + { + drawPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); + } + + /** + * Fills the polygon determined by the arrays + * of corresponding x and y coordinates. + * + * @param xPoints The X coordinate array. + * @param yPoints The Y coordinate array. + * @param npoints The number of points to draw. + */ + public abstract void fillPolygon(int xPoints[], int yPoints[], int npoints); + + /** + * Fills the specified polygon + * + * @param polygon The polygon to fill. + */ + public void fillPolygon(Polygon polygon) + { + fillPolygon(polygon.xpoints, polygon.ypoints, polygon.npoints); + } + + /** + * Draws the specified string starting at the specified point. + * + * @param string The string to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ + public abstract void drawString(String string, int x, int y); + + public abstract void drawString (AttributedCharacterIterator ci, int x, + int y); + + /** + * Draws the specified characters starting at the specified point. + * + * @param data The array of characters to draw. + * @param offset The offset into the array to start drawing characters from. + * @param length The number of characters to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + */ + public void drawChars(char data[], int offset, int length, int x, int y) + { + drawString(new String(data, offset, length), x, y); + } + + public void drawBytes(byte[] data, int offset, int length, int x, int y) + { + String str = new String(data, offset, length); + drawString(str, x, y); + } + + /** + * Draws all of the image that is available and returns. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ + public abstract boolean drawImage(Image image, int x, int y, + ImageObserver observer); -/*************************************************************************/ - -/** - * Draws all of the image that is available and returns. The image - * is scaled to fit in the specified rectangle. If the image - * is not completely loaded, <code>false</code> is returned and - * the specified iamge observer is notified as more data becomes - * available. - * - * @param image The image to draw. - * @param x The X coordinate of the point to draw at. - * @param y The Y coordinate of the point to draw at. - * @param width The width of the rectangle to draw in. - * @param height The height of the rectangle to draw in. - * @param observer The image observer to notify as data becomes available. - * - * @return <code>true</code> if all the image data is available, - * <code>false</code> otherwise. - */ -public abstract boolean -drawImage(Image image, int x, int y, int width, int height, - ImageObserver observer); + /** + * Draws all of the image that is available and returns. The image + * is scaled to fit in the specified rectangle. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param width The width of the rectangle to draw in. + * @param height The height of the rectangle to draw in. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ + public abstract boolean drawImage(Image image, int x, int y, int width, + int height, ImageObserver observer); -/*************************************************************************/ - -/** - * Draws all of the image that is available and returns. If the image - * is not completely loaded, <code>false</code> is returned and - * the specified iamge observer is notified as more data becomes - * available. - * - * @param image The image to draw. - * @param x The X coordinate of the point to draw at. - * @param y The Y coordinate of the point to draw at. - * @param bgcolor The background color to use for the image. - * @param observer The image observer to notify as data becomes available. - * - * @return <code>true</code> if all the image data is available, - * <code>false</code> otherwise. - */ -public abstract boolean -drawImage(Image image, int x, int y, Color bgcolor, ImageObserver observer); + /** + * Draws all of the image that is available and returns. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param bgcolor The background color to use for the image. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ + public abstract boolean drawImage(Image image, int x, int y, Color bgcolor, + ImageObserver observer); -/*************************************************************************/ - -/** - * Draws all of the image that is available and returns. The image - * is scaled to fit in the specified rectangle. If the image - * is not completely loaded, <code>false</code> is returned and - * the specified iamge observer is notified as more data becomes - * available. - * - * @param image The image to draw. - * @param x The X coordinate of the point to draw at. - * @param y The Y coordinate of the point to draw at. - * @param width The width of the rectangle to draw in. - * @param height The height of the rectangle to draw in. - * @param bgcolor The background color to use for the image. - * @param observer The image observer to notify as data becomes available. - * - * @return <code>true</code> if all the image data is available, - * <code>false</code> otherwise. - */ -public abstract boolean -drawImage(Image image, int x, int y, int width, int height, Color bgcolor, - ImageObserver observer); - -/*************************************************************************/ - -/** - * FIXME: Write Javadocs for this when you understand it. - */ -public abstract boolean -drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, - int sx2, int sy2, ImageObserver observer); - -/*************************************************************************/ - -/** - * FIXME: Write Javadocs for this when you understand it. - */ -public abstract boolean -drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, - int sx2, int sy2, Color bgcolor, ImageObserver observer); - -/*************************************************************************/ - -/** - * Free any resources held by this graphics context immediately instead - * of waiting for the object to be garbage collected and finalized. - */ -public abstract void -dispose(); - -/*************************************************************************/ - -/** - * Frees the resources held by this graphics context when it is - * garbage collected. - */ -public void -finalize() -{ - dispose(); -} - -/*************************************************************************/ - -/** - * Returns a string representation of this object. - * - * @return A string representation of this object. - */ -public String -toString() -{ - return getClass ().getName () + "[font=" + getFont () + ",color=" + getColor () + "]"; -} - -public boolean -hitClip(int x, int y, int width, int height) -{ - throw new UnsupportedOperationException("not implemented yet"); -} - -public Rectangle -getClipBounds(Rectangle r) -{ - Rectangle clipBounds = getClipBounds(); + /** + * Draws all of the image that is available and returns. The image + * is scaled to fit in the specified rectangle. If the image + * is not completely loaded, <code>false</code> is returned and + * the specified iamge observer is notified as more data becomes + * available. + * + * @param image The image to draw. + * @param x The X coordinate of the point to draw at. + * @param y The Y coordinate of the point to draw at. + * @param width The width of the rectangle to draw in. + * @param height The height of the rectangle to draw in. + * @param bgcolor The background color to use for the image. + * @param observer The image observer to notify as data becomes available. + * + * @return <code>true</code> if all the image data is available, + * <code>false</code> otherwise. + */ + public abstract boolean drawImage(Image image, int x, int y, int width, + int height, Color bgcolor, + ImageObserver observer); + + /** + * FIXME: Write Javadocs for this when you understand it. + */ + public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2, + int dy2, int sx1, int sy1, int sx2, + int sy2, ImageObserver observer); + + /** + * FIXME: Write Javadocs for this when you understand it. + */ + public abstract boolean drawImage(Image image, int dx1, int dy1, int dx2, + int dy2, int sx1, int sy1, int sx2, + int sy2, Color bgcolor, + ImageObserver observer); + + /** + * Free any resources held by this graphics context immediately instead + * of waiting for the object to be garbage collected and finalized. + */ + public abstract void dispose(); + + /** + * Frees the resources held by this graphics context when it is + * garbage collected. + */ + public void finalize() + { + dispose(); + } + + /** + * Returns a string representation of this object. + * + * @return A string representation of this object. + */ + public String toString() + { + return getClass ().getName () + "[font=" + getFont () + ",color=" + + getColor () + "]"; + } + + /** + * Returns <code>true</code> if the specified rectangle intersects with the + * current clip, <code>false</code> otherwise. + * + * @param x the X coordinate of the upper left corner of the test rectangle + * @param y the Y coordinate of the upper left corner of the test rectangle + * @param width the width of the upper left corner of the test rectangle + * @param height the height of the upper left corner of the test rectangle + * @return <code>true</code> if the specified rectangle intersects with the + * current clip, <code>false</code> otherwise + */ + public boolean hitClip(int x, int y, int width, int height) + { + return getClip().intersects(x, y, width, height); + } + + public Rectangle getClipBounds(Rectangle r) + { + Rectangle clipBounds = getClipBounds(); - if (r == null) - return clipBounds; - - r.x = clipBounds.x; - r.y = clipBounds.y; - r.width = clipBounds.width; - r.height = clipBounds.height; - return r; + if (r == null) + return clipBounds; + + r.x = clipBounds.x; + r.y = clipBounds.y; + r.width = clipBounds.width; + r.height = clipBounds.height; + return r; + } } - -} // class Graphics - diff --git a/libjava/classpath/java/awt/GraphicsConfiguration.java b/libjava/classpath/java/awt/GraphicsConfiguration.java index 069d7414b3d..1526ad3cfc0 100644 --- a/libjava/classpath/java/awt/GraphicsConfiguration.java +++ b/libjava/classpath/java/awt/GraphicsConfiguration.java @@ -130,11 +130,10 @@ public abstract class GraphicsConfiguration * 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 width the width of the buffer + * @param height 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, diff --git a/libjava/classpath/java/awt/GridBagLayout.java b/libjava/classpath/java/awt/GridBagLayout.java index 7f9ab249b6d..083c0b7a7a3 100644 --- a/libjava/classpath/java/awt/GridBagLayout.java +++ b/libjava/classpath/java/awt/GridBagLayout.java @@ -705,17 +705,20 @@ public class GridBagLayout if (lastInCol.containsKey(new Integer(x))) { Component lastComponent = (Component) lastInRow.get(new Integer(x)); - GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent); - - if (lastConstraints.gridheight == GridBagConstraints.RELATIVE) + if (lastComponent != null) { - constraints.gridy = max_y - 1; - break; - } - else - { - constraints.gridy = Math.max (constraints.gridy, - lastConstraints.gridy + Math.max (1, lastConstraints.gridheight)); + GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent); + + if (lastConstraints.gridheight == GridBagConstraints.RELATIVE) + { + constraints.gridy = max_y - 1; + break; + } + else + { + constraints.gridy = Math.max (constraints.gridy, + lastConstraints.gridy + Math.max (1, lastConstraints.gridheight)); + } } } } diff --git a/libjava/classpath/java/awt/Image.java b/libjava/classpath/java/awt/Image.java index b657ad007d9..93c2c479024 100644 --- a/libjava/classpath/java/awt/Image.java +++ b/libjava/classpath/java/awt/Image.java @@ -38,7 +38,9 @@ exception statement from your version. */ package java.awt; +import java.awt.image.AreaAveragingScaleFilter; import java.awt.image.FilteredImageSource; +import java.awt.image.ImageFilter; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; import java.awt.image.ReplicateScaleFilter; @@ -141,7 +143,6 @@ public abstract class Image * This method is only valid for off-screen objects. * * @return a graphics context object for an off-screen object - * @see Graphics#getcreateImage(int, int) */ public abstract Graphics getGraphics(); @@ -179,20 +180,25 @@ public abstract class Image */ public Image getScaledInstance(int width, int height, int flags) { + ImageFilter filter; switch (flags) { case SCALE_DEFAULT: case SCALE_FAST: case SCALE_REPLICATE: - ImageProducer producer = - new FilteredImageSource(this.getSource(), - new ReplicateScaleFilter(width, height)); - return Toolkit.getDefaultToolkit().createImage(producer); - case SCALE_SMOOTH: + filter = new ReplicateScaleFilter(width, height); + break; case SCALE_AREA_AVERAGING: + filter = new AreaAveragingScaleFilter(width, height); + break; + case SCALE_SMOOTH: + throw new Error("SCALE_SMOOTH: not implemented"); default: - throw new Error("not implemented"); + throw new Error("Unknown flag or not implemented: " + flags); } + + ImageProducer producer = new FilteredImageSource(getSource(), filter); + return Toolkit.getDefaultToolkit().createImage(producer); } /** diff --git a/libjava/classpath/java/awt/KeyboardFocusManager.java b/libjava/classpath/java/awt/KeyboardFocusManager.java index f64618477bd..371ea9bdf8a 100644 --- a/libjava/classpath/java/awt/KeyboardFocusManager.java +++ b/libjava/classpath/java/awt/KeyboardFocusManager.java @@ -39,6 +39,7 @@ exception statement from your version. */ package java.awt; import java.applet.Applet; +import java.awt.FocusTraversalPolicy; import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; import java.awt.event.WindowEvent; @@ -213,7 +214,7 @@ public abstract class KeyboardFocusManager currentFocusOwners */ private static Map currentFocusCycleRoots = new HashMap (); - /** The default {@link FocusTraveralPolicy} that focus-managing + /** The default {@link FocusTraversalPolicy} that focus-managing {@link Container}s will use to define their initial focus traversal policy. */ private FocusTraversalPolicy defaultPolicy; @@ -287,7 +288,7 @@ public abstract class KeyboardFocusManager KeyboardFocusManager manager; if (m == null) - manager = createFocusManager(); + manager = new DefaultKeyboardFocusManager(); else manager = m; @@ -295,46 +296,6 @@ public abstract class KeyboardFocusManager } /** - * Creates a KeyboardFocusManager. The exact class is determined by the - * system property 'gnu.java.awt.FocusManager'. If this is not set, - * we default to DefaultKeyboardFocusManager. - */ - private static KeyboardFocusManager createFocusManager() - { - String fmClassName = System.getProperty("gnu.java.awt.FocusManager", - "java.awt.DefaultKeyboardFocusManager"); - try - { - Class fmClass = Class.forName(fmClassName); - KeyboardFocusManager fm = (KeyboardFocusManager) fmClass.newInstance(); - return fm; - } - catch (ClassNotFoundException ex) - { - System.err.println("The class " + fmClassName + " cannot be found."); - System.err.println("Check the setting of the system property"); - System.err.println("gnu.java.awt.FocusManager"); - return null; - } - catch (InstantiationException ex) - { - System.err.println("The class " + fmClassName + " cannot be"); - System.err.println("instantiated."); - System.err.println("Check the setting of the system property"); - System.err.println("gnu.java.awt.FocusManager"); - return null; - } - catch (IllegalAccessException ex) - { - System.err.println("The class " + fmClassName + " cannot be"); - System.err.println("accessed."); - System.err.println("Check the setting of the system property"); - System.err.println("gnu.java.awt.FocusManager"); - return null; - } - } - - /** * Retrieve the {@link Component} that has the keyboard focus, or * null if the focus owner was not set by a thread in the current * {@link java.lang.ThreadGroup}. @@ -1364,11 +1325,11 @@ public abstract class KeyboardFocusManager * * @return a global object set by the current ThreadGroup, or null * - * @see getFocusOwner - * @see getPermanentFocusOwner - * @see getFocusedWindow - * @see getActiveWindow - * @see getCurrentFocusCycleRoot + * @see #getFocusOwner() + * @see #getPermanentFocusOwner() + * @see #getFocusedWindow() + * @see #getActiveWindow() + * @see #getCurrentFocusCycleRoot() */ private Object getObject (Map globalMap) { @@ -1388,11 +1349,11 @@ public abstract class KeyboardFocusManager * @throws SecurityException if this is not the keyboard focus * manager associated with the current {@link java.lang.ThreadGroup} * - * @see getGlobalFocusOwner - * @see getGlobalPermanentFocusOwner - * @see getGlobalFocusedWindow - * @see getGlobalActiveWindow - * @see getGlobalCurrentFocusCycleRoot + * @see #getGlobalFocusOwner() + * @see #getGlobalPermanentFocusOwner() + * @see #getGlobalFocusedWindow() + * @see #getGlobalActiveWindow() + * @see #getGlobalCurrentFocusCycleRoot() */ private Object getGlobalObject (Map globalMap) { @@ -1432,11 +1393,11 @@ public abstract class KeyboardFocusManager * @param newObject the object to set * @param property the property that will change * - * @see setGlobalFocusOwner - * @see setGlobalPermanentFocusOwner - * @see setGlobalFocusedWindow - * @see setGlobalActiveWindow - * @see setGlobalCurrentFocusCycleRoot + * @see #setGlobalFocusOwner(Component) + * @see #setGlobalPermanentFocusOwner(Component) + * @see #setGlobalFocusedWindow(Window) + * @see #setGlobalActiveWindow(Window) + * @see #setGlobalCurrentFocusCycleRoot(Container) */ private void setGlobalObject (Map globalMap, Object newObject, diff --git a/libjava/classpath/java/awt/List.java b/libjava/classpath/java/awt/List.java index ab7d359633e..00636a0224f 100644 --- a/libjava/classpath/java/awt/List.java +++ b/libjava/classpath/java/awt/List.java @@ -1088,18 +1088,23 @@ paramString() protected class AccessibleAWTList extends AccessibleAWTComponent implements AccessibleSelection, ItemListener, ActionListener { + private static final long serialVersionUID = 7924617370136012829L; + protected class AccessibleAWTListChild extends AccessibleAWTComponent implements Accessible { - private int index; + private static final long serialVersionUID = 4412022926028300317L; + + // Field names are fixed by serialization spec. private List parent; + private int indexInParent; public AccessibleAWTListChild(List parent, int indexInParent) { this.parent = parent; - index = indexInParent; + this.indexInParent = indexInParent; if (parent == null) - index = -1; + this.indexInParent = -1; } /* (non-Javadoc) @@ -1118,14 +1123,14 @@ paramString() public AccessibleStateSet getAccessibleStateSet() { AccessibleStateSet states = super.getAccessibleStateSet(); - if (parent.isIndexSelected(index)) + if (parent.isIndexSelected(indexInParent)) states.add(AccessibleState.SELECTED); return states; } public int getAccessibleIndexInParent() { - return index; + return indexInParent; } } diff --git a/libjava/classpath/java/awt/Menu.java b/libjava/classpath/java/awt/Menu.java index 56ceccfc542..13ebb5211be 100644 --- a/libjava/classpath/java/awt/Menu.java +++ b/libjava/classpath/java/awt/Menu.java @@ -441,6 +441,8 @@ paramString() */ protected class AccessibleAWTMenu extends AccessibleAWTMenuItem { + private static final long serialVersionUID = 5228160894980069094L; + protected AccessibleAWTMenu() { } diff --git a/libjava/classpath/java/awt/MenuComponent.java b/libjava/classpath/java/awt/MenuComponent.java index ec6980e10ca..375d08436e0 100644 --- a/libjava/classpath/java/awt/MenuComponent.java +++ b/libjava/classpath/java/awt/MenuComponent.java @@ -1157,7 +1157,7 @@ protected abstract class AccessibleAWTMenuComponent * the appropriate information. * * @param color the new color to use for the background. - * @see getBackground() + * @see #getBackground() */ public void setBackground(Color color) { @@ -1217,7 +1217,7 @@ protected abstract class AccessibleAWTMenuComponent * * @param enabled true if the component should be enabled, * false otherwise. - * @see #getEnabled() + * @see #isEnabled() */ public void setEnabled(boolean enabled) { diff --git a/libjava/classpath/java/awt/MenuItem.java b/libjava/classpath/java/awt/MenuItem.java index 58dcb674146..3e39d118a05 100644 --- a/libjava/classpath/java/awt/MenuItem.java +++ b/libjava/classpath/java/awt/MenuItem.java @@ -108,6 +108,8 @@ private transient ActionListener action_listeners; extends MenuComponent.AccessibleAWTMenuComponent implements AccessibleAction, AccessibleValue { + private static final long serialVersionUID = -217847831945965825L; + /** Constructor */ public AccessibleAWTMenuItem() { diff --git a/libjava/classpath/java/awt/Point.java b/libjava/classpath/java/awt/Point.java index 492749b8dc3..31b72e2cc75 100644 --- a/libjava/classpath/java/awt/Point.java +++ b/libjava/classpath/java/awt/Point.java @@ -226,6 +226,10 @@ public class Point extends Point2D implements Serializable */ public boolean equals(Object obj) { + // NOTE: No special hashCode() method is required for this class, + // as this equals() implementation is functionally equivalent to + // super.equals(), which does define a proper hashCode(). + if (! (obj instanceof Point2D)) return false; Point2D p = (Point2D) obj; diff --git a/libjava/classpath/java/awt/Polygon.java b/libjava/classpath/java/awt/Polygon.java index a72522cb089..403c336cde5 100644 --- a/libjava/classpath/java/awt/Polygon.java +++ b/libjava/classpath/java/awt/Polygon.java @@ -544,7 +544,6 @@ public class Polygon implements Shape, Serializable * the positive X, or Y axis, within a given interval. * * @return the winding number. - * @see #condensed * @see #contains(double, double) */ private int evaluateCrossings(double x, double y, boolean useYaxis, diff --git a/libjava/classpath/java/awt/PopupMenu.java b/libjava/classpath/java/awt/PopupMenu.java index 90d48d903b9..540fffda718 100644 --- a/libjava/classpath/java/awt/PopupMenu.java +++ b/libjava/classpath/java/awt/PopupMenu.java @@ -140,6 +140,8 @@ show(Component component, int x, int y) protected class AccessibleAWTPopupMenu extends AccessibleAWTMenu { + private static final long serialVersionUID = -4282044795947239955L; + protected AccessibleAWTPopupMenu() { } diff --git a/libjava/classpath/java/awt/Rectangle.java b/libjava/classpath/java/awt/Rectangle.java index 0f21d495cd8..c4ba6ba1488 100644 --- a/libjava/classpath/java/awt/Rectangle.java +++ b/libjava/classpath/java/awt/Rectangle.java @@ -727,6 +727,10 @@ public class Rectangle extends Rectangle2D implements Shape, Serializable */ public boolean equals(Object obj) { + // NOTE: No special hashCode() method is required for this class, + // as this equals() implementation is functionally equivalent to + // super.equals(), which does define a proper hashCode(). + if (! (obj instanceof Rectangle2D)) return false; Rectangle2D r = (Rectangle2D) obj; diff --git a/libjava/classpath/java/awt/ScrollPane.java b/libjava/classpath/java/awt/ScrollPane.java index b3ecc59fcd5..525d9d3e7da 100644 --- a/libjava/classpath/java/awt/ScrollPane.java +++ b/libjava/classpath/java/awt/ScrollPane.java @@ -401,7 +401,7 @@ setScrollPosition(int x, int y) public void addNotify() { - if (!isDisplayable ()) + if (peer != null) return; setPeer((ComponentPeer)getToolkit().createScrollPane(this)); @@ -592,6 +592,8 @@ paramString() protected class AccessibleAWTScrollPane extends AccessibleAWTContainer { + private static final long serialVersionUID = 6100703663886637L; + public AccessibleRole getAccessibleRole() { return AccessibleRole.SCROLL_PANE; diff --git a/libjava/classpath/java/awt/ScrollPaneAdjustable.java b/libjava/classpath/java/awt/ScrollPaneAdjustable.java index cfca19b4423..bec5b5106de 100644 --- a/libjava/classpath/java/awt/ScrollPaneAdjustable.java +++ b/libjava/classpath/java/awt/ScrollPaneAdjustable.java @@ -87,12 +87,16 @@ public class ScrollPaneAdjustable public void addAdjustmentListener (AdjustmentListener listener) { - AWTEventMulticaster.add (adjustmentListener, listener); + if (listener == null) + return; + adjustmentListener = AWTEventMulticaster.add (adjustmentListener, listener); } public void removeAdjustmentListener (AdjustmentListener listener) { - AWTEventMulticaster.remove (adjustmentListener, listener); + if (listener == null) + return; + adjustmentListener = AWTEventMulticaster.remove (adjustmentListener, listener); } public AdjustmentListener[] getAdjustmentListeners () diff --git a/libjava/classpath/java/awt/TextArea.java b/libjava/classpath/java/awt/TextArea.java index d422d3306d2..b04cdc89204 100644 --- a/libjava/classpath/java/awt/TextArea.java +++ b/libjava/classpath/java/awt/TextArea.java @@ -603,6 +603,8 @@ public class TextArea extends TextComponent implements java.io.Serializable protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent { + private static final long serialVersionUID = 3472827823632144419L; + protected AccessibleAWTTextArea() { } diff --git a/libjava/classpath/java/awt/TextComponent.java b/libjava/classpath/java/awt/TextComponent.java index 60e72fcb5cb..f08e59c9fc9 100644 --- a/libjava/classpath/java/awt/TextComponent.java +++ b/libjava/classpath/java/awt/TextComponent.java @@ -107,6 +107,8 @@ protected transient TextListener textListener; extends AccessibleAWTComponent implements AccessibleText, TextListener { + private static final long serialVersionUID = 3631432373506317811L; + // Constructor // Adds a listener for tracking caret changes public AccessibleAWTTextComponent() diff --git a/libjava/classpath/java/awt/TextField.java b/libjava/classpath/java/awt/TextField.java index 4d62d024aad..3302a2eff89 100644 --- a/libjava/classpath/java/awt/TextField.java +++ b/libjava/classpath/java/awt/TextField.java @@ -523,6 +523,8 @@ paramString() protected class AccessibleAWTTextField extends AccessibleAWTTextComponent { + private static final long serialVersionUID = 6219164359235943158L; + protected AccessibleAWTTextField() { } diff --git a/libjava/classpath/java/awt/Window.java b/libjava/classpath/java/awt/Window.java index 1689d03706b..f8a620daebd 100644 --- a/libjava/classpath/java/awt/Window.java +++ b/libjava/classpath/java/awt/Window.java @@ -101,6 +101,8 @@ public class Window extends Container implements Accessible protected class AccessibleAWTWindow extends AccessibleAWTContainer { + private static final long serialVersionUID = 4215068635060671780L; + public AccessibleRole getAccessibleRole() { return AccessibleRole.WINDOW; @@ -278,14 +280,14 @@ public class Window extends Container implements Accessible */ public void show() { + synchronized (getTreeLock()) + { if (parent != null && !parent.isDisplayable()) parent.addNotify(); if (peer == null) addNotify(); // Show visible owned windows. - synchronized (getTreeLock()) - { Iterator e = ownedWindows.iterator(); while(e.hasNext()) { @@ -302,14 +304,13 @@ public class Window extends Container implements Accessible // synchronous access to ownedWindows there. e.remove(); } - } validate(); super.show(); toFront(); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager (); manager.setGlobalFocusedWindow (this); - + if (!shown) { FocusTraversalPolicy policy = getFocusTraversalPolicy (); @@ -323,6 +324,7 @@ public class Window extends Container implements Accessible shown = true; } + } } public void hide() @@ -346,13 +348,6 @@ public class Window extends Container implements Accessible super.hide(); } - public boolean isDisplayable() - { - if (super.isDisplayable()) - return true; - return peer != null; - } - /** * Destroys any resources associated with this window. This includes * all components in the window and all owned top-level windows. @@ -808,20 +803,81 @@ public class Window extends Container implements Accessible return isVisible(); } - public void setLocationRelativeTo (Component c) + public void setLocationRelativeTo(Component c) { - if (c == null || !c.isShowing ()) + int x = 0; + int y = 0; + + if (c == null || !c.isShowing()) { - int x = 0; - int y = 0; - - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment (); - Point center = ge.getCenterPoint (); + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + Point center = ge.getCenterPoint(); x = center.x - (width / 2); y = center.y - (height / 2); - setLocation (x, y); } - // FIXME: handle case where component is non-null. + else + { + int cWidth = c.getWidth(); + int cHeight = c.getHeight(); + Dimension screenSize = getToolkit().getScreenSize(); + + x = c.getLocationOnScreen().x; + y = c.getLocationOnScreen().y; + + // If bottom of component is cut off, window placed + // on the left or the right side of component + if ((y + cHeight) > screenSize.height) + { + // If the right side of the component is closer to the center + if ((screenSize.width / 2 - x) <= 0) + { + if ((x - width) >= 0) + x -= width; + else + x = 0; + } + else + { + if ((x + cWidth + width) <= screenSize.width) + x += cWidth; + else + x = screenSize.width - width; + } + + y = screenSize.height - height; + } + else if (cWidth > width || cHeight > height) + { + // If right side of component is cut off + if ((x + width) > screenSize.width) + x = screenSize.width - width; + // If left side of component is cut off + else if (x < 0) + x = 0; + else + x += (cWidth - width) / 2; + + y += (cHeight - height) / 2; + } + else + { + // If right side of component is cut off + if ((x + width) > screenSize.width) + x = screenSize.width - width; + // If left side of component is cut off + else if (x < 0 || (x - (width - cWidth) / 2) < 0) + x = 0; + else + x -= (width - cWidth) / 2; + + if ((y - (height - cHeight) / 2) > 0) + y -= (height - cHeight) / 2; + else + y = 0; + } + } + + setLocation(x, y); } /** @@ -938,8 +994,8 @@ public class Window extends Container implements Accessible * * @since 1.4 */ - public void createBufferStrategy(int numBuffers, - BufferCapabilities caps) + public void createBufferStrategy(int numBuffers, BufferCapabilities caps) + throws AWTException { if (numBuffers < 1) throw new IllegalArgumentException("Window.createBufferStrategy: number" @@ -951,15 +1007,7 @@ public class Window extends Container implements Accessible // a flipping strategy was requested if (caps.isPageFlipping()) - { - try - { - bufferStrategy = new WindowFlipBufferStrategy(numBuffers); - } - catch (AWTException e) - { - } - } + bufferStrategy = new WindowFlipBufferStrategy(numBuffers); else bufferStrategy = new WindowBltBufferStrategy(numBuffers, true); } diff --git a/libjava/classpath/java/awt/color/ICC_Profile.java b/libjava/classpath/java/awt/color/ICC_Profile.java index 75f55a1dacb..1072cd694db 100644 --- a/libjava/classpath/java/awt/color/ICC_Profile.java +++ b/libjava/classpath/java/awt/color/ICC_Profile.java @@ -324,11 +324,11 @@ public class ICC_Profile implements Serializable * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray * may be returned if appropriate. * - * @throws IllegalArgumentException if the profile data is an invalid - * v2 profile. - * * @param data - the profile data * @return An ICC_Profile object + * + * @throws IllegalArgumentException if the profile data is an invalid + * v2 profile. */ public static ICC_Profile getInstance(byte[] data) { @@ -373,12 +373,12 @@ public class ICC_Profile implements Serializable * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray * may be returned if appropriate. * + * @param filename - the file name of the profile file. + * @return An ICC_Profile object + * * @throws IllegalArgumentException if the profile data is an invalid * v2 profile. * @throws IOException if the file could not be read. - * - * @param filename - the file name of the profile file. - * @return An ICC_Profile object */ public static ICC_Profile getInstance(String filename) throws IOException @@ -400,12 +400,12 @@ public class ICC_Profile implements Serializable * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray * may be returned if appropriate. * + * @param in - the input stream to read the profile from. + * @return An ICC_Profile object + * * @throws IllegalArgumentException if the profile data is an invalid * v2 profile. * @throws IOException if the stream could not be read. - * - * @param in - the input stream to read the profile from. - * @return An ICC_Profile object */ public static ICC_Profile getInstance(InputStream in) throws IOException diff --git a/libjava/classpath/java/awt/event/InputEvent.java b/libjava/classpath/java/awt/event/InputEvent.java index 8f9aed611f8..28cd9018599 100644 --- a/libjava/classpath/java/awt/event/InputEvent.java +++ b/libjava/classpath/java/awt/event/InputEvent.java @@ -197,17 +197,28 @@ public abstract class InputEvent extends ComponentEvent private final long when; /** - * The modifiers in effect for this event. Package visible for use by - * subclasses. The old style (bitmask 0x3f) should not be mixed with the - * new style (bitmasks 0xffffffc0). + * The old-style modifiers in effect for this event. Package visible + * for use by subclasses. The old style (bitmask 0x3f) should not be + * mixed with the new style (bitmasks 0xffffffc0). * * @see #getModifiers() * @see MouseEvent - * @serial the modifier state, stored in the new style + * @serial the modifier state, stored in the old style */ int modifiers; /** + * The new-style modifiers in effect for this event. Package visible + * for use by subclasses. The old style (bitmask 0x3f) should not be + * mixed with the new style (bitmasks 0xffffffc0). + * + * @see #getModifiersEx() + * @see MouseEvent + * @serial the modifier state, stored in the new style + */ + int modifiersEx; + + /** * Initializes a new instance of <code>InputEvent</code> with the specified * source, id, timestamp, and modifiers. Note that an invalid id leads to * unspecified results. @@ -222,7 +233,8 @@ public abstract class InputEvent extends ComponentEvent { super(source, id); this.when = when; - this.modifiers = EventModifier.extend(modifiers); + this.modifiers = modifiers & EventModifier.OLD_MASK; + this.modifiersEx = modifiers & EventModifier.NEW_MASK; } /** @@ -232,7 +244,8 @@ public abstract class InputEvent extends ComponentEvent */ public boolean isShiftDown() { - return (modifiers & SHIFT_DOWN_MASK) != 0; + return ((modifiers & SHIFT_MASK) != 0) + || ((modifiersEx & SHIFT_DOWN_MASK) != 0); } /** @@ -243,7 +256,8 @@ public abstract class InputEvent extends ComponentEvent */ public boolean isControlDown() { - return (modifiers & CTRL_DOWN_MASK) != 0; + return ((modifiers & CTRL_MASK) != 0) + || ((modifiersEx & CTRL_DOWN_MASK) != 0); } /** @@ -253,7 +267,8 @@ public abstract class InputEvent extends ComponentEvent */ public boolean isMetaDown() { - return (modifiers & META_DOWN_MASK) != 0; + return ((modifiers & META_MASK) != 0) + || ((modifiersEx & META_DOWN_MASK) != 0); } /** @@ -263,7 +278,8 @@ public abstract class InputEvent extends ComponentEvent */ public boolean isAltDown() { - return (modifiers & ALT_DOWN_MASK) != 0; + return ((modifiers & ALT_MASK) != 0) + || ((modifiersEx & ALT_DOWN_MASK) != 0); } /** @@ -274,7 +290,8 @@ public abstract class InputEvent extends ComponentEvent */ public boolean isAltGraphDown() { - return (modifiers & ALT_GRAPH_DOWN_MASK) != 0; + return ((modifiers & ALT_GRAPH_MASK) != 0) + || ((modifiersEx & ALT_GRAPH_DOWN_MASK) != 0); } /** @@ -300,7 +317,7 @@ public abstract class InputEvent extends ComponentEvent */ public int getModifiers() { - return EventModifier.revert(modifiers); + return modifiers; } /** @@ -321,7 +338,7 @@ public abstract class InputEvent extends ComponentEvent */ public int getModifiersEx() { - return modifiers; + return modifiersEx; } /** diff --git a/libjava/classpath/java/awt/event/InvocationEvent.java b/libjava/classpath/java/awt/event/InvocationEvent.java index 75feb62bd94..6f39d6b9130 100644 --- a/libjava/classpath/java/awt/event/InvocationEvent.java +++ b/libjava/classpath/java/awt/event/InvocationEvent.java @@ -107,6 +107,13 @@ public class InvocationEvent extends AWTEvent implements ActiveEvent private Exception exception; /** + * This is the caught Throwable thrown in the <code>run()</code> method. + * It is null if throwables are ignored, the run method hasn't completed, + * or there were no throwables thrown. + */ + private Throwable throwable; + + /** * The timestamp when this event was created. * * @see #getWhen() @@ -183,9 +190,11 @@ public class InvocationEvent extends AWTEvent implements ActiveEvent { runnable.run(); } - catch (Exception e) + catch (Throwable t) { - exception = e; + throwable = t; + if (t instanceof Exception) + exception = (Exception)t; } else runnable.run(); @@ -211,6 +220,18 @@ public class InvocationEvent extends AWTEvent implements ActiveEvent } /** + * Returns a throwable caught while executing the Runnable's run() method. + * Null if none was thrown or if this InvocationEvent doesn't catch + * throwables. + * @return the caught Throwable + * @since 1.5 + */ + public Throwable getThrowable() + { + return throwable; + } + + /** * Gets the timestamp of when this event was created. * * @return the timestamp of this event diff --git a/libjava/classpath/java/awt/event/KeyEvent.java b/libjava/classpath/java/awt/event/KeyEvent.java index a40a8e15c04..d4b93ba3e0b 100644 --- a/libjava/classpath/java/awt/event/KeyEvent.java +++ b/libjava/classpath/java/awt/event/KeyEvent.java @@ -1735,6 +1735,6 @@ public class KeyEvent extends InputEvent throws IOException, ClassNotFoundException { s.defaultReadObject(); - modifiers = EventModifier.extend(modifiers); + modifiersEx = EventModifier.extend(modifiers) & EventModifier.NEW_MASK; } } // class KeyEvent diff --git a/libjava/classpath/java/awt/event/MouseEvent.java b/libjava/classpath/java/awt/event/MouseEvent.java index 249c3d112e4..3e0fecacf94 100644 --- a/libjava/classpath/java/awt/event/MouseEvent.java +++ b/libjava/classpath/java/awt/event/MouseEvent.java @@ -42,6 +42,7 @@ import gnu.java.awt.EventModifier; import java.awt.Component; import java.awt.Point; +import java.awt.PopupMenu; import java.io.IOException; import java.io.ObjectInputStream; @@ -227,6 +228,12 @@ public class MouseEvent extends InputEvent else if ((modifiers & BUTTON3_MASK) != 0) this.button = BUTTON3; } + // clear the mouse button modifier masks if this is a button + // release event. + if (id == MOUSE_RELEASED) + this.modifiersEx &= ~(BUTTON1_DOWN_MASK + | BUTTON2_DOWN_MASK + | BUTTON3_DOWN_MASK); } /** @@ -392,17 +399,9 @@ public class MouseEvent extends InputEvent s.append("unknown type,("); } s.append(x).append(',').append(y).append("),button=").append(button); - if ((modifiers & EventModifier.NEW_MASK) != 0) - { - int mod = modifiers; - if ((mod & (ALT_DOWN_MASK | BUTTON2_DOWN_MASK)) != 0) - mod |= ALT_DOWN_MASK | BUTTON2_DOWN_MASK; - if ((mod & (META_DOWN_MASK | BUTTON3_DOWN_MASK)) != 0) - mod |= META_DOWN_MASK | BUTTON3_DOWN_MASK; - s.append(",modifiers=").append(getModifiersExText(mod)); - } - if (modifiers != 0) - s.append(",extModifiers=").append(getModifiersExText(modifiers)); + // FIXME: need a mauve test for this method + if (modifiersEx != 0) + s.append(",extModifiers=").append(getModifiersExText(modifiersEx)); return s.append(",clickCount=").append(clickCount).toString(); } @@ -426,7 +425,7 @@ public class MouseEvent extends InputEvent button = BUTTON2; else if ((modifiers & BUTTON3_MASK) != 0) button = BUTTON3; - modifiers = EventModifier.extend(modifiers); + modifiersEx = EventModifier.extend(modifiers) & EventModifier.NEW_MASK; } } } // class MouseEvent diff --git a/libjava/classpath/java/awt/geom/Area.java b/libjava/classpath/java/awt/geom/Area.java index 7a0fac43a34..ad20b535f68 100644 --- a/libjava/classpath/java/awt/geom/Area.java +++ b/libjava/classpath/java/awt/geom/Area.java @@ -1215,7 +1215,7 @@ public class Area implements Shape, Cloneable * @param t1 - global parametric value of the first curve's starting point * @param t2 - global parametric value of the second curve's starting point * @param w1 - global parametric length of curve 1 - * @param c1 - global parametric length of curve 2 + * @param w2 - global parametric length of curve 2 * * The final four parameters are for keeping track of the parametric * value of the curve. For a full curve t = 0, w = 1, w is halved with diff --git a/libjava/classpath/java/awt/geom/GeneralPath.java b/libjava/classpath/java/awt/geom/GeneralPath.java index f54855874dc..15fb8aba811 100644 --- a/libjava/classpath/java/awt/geom/GeneralPath.java +++ b/libjava/classpath/java/awt/geom/GeneralPath.java @@ -558,7 +558,8 @@ public final class GeneralPath implements Shape, Cloneable * Constructs a new iterator for enumerating the segments of a * GeneralPath. * - * @param at an affine transformation for projecting the returned + * @param path the path to enumerate + * @param transform an affine transformation for projecting the returned * points, or <code>null</code> to return the original points * without any mapping. */ diff --git a/libjava/classpath/java/awt/im/InputContext.java b/libjava/classpath/java/awt/im/InputContext.java index c0505e7e98b..0bb107e36d1 100644 --- a/libjava/classpath/java/awt/im/InputContext.java +++ b/libjava/classpath/java/awt/im/InputContext.java @@ -49,6 +49,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.text.AttributedCharacterIterator.Attribute; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; @@ -334,7 +335,7 @@ public class InputContext /** * Starts a reconversion operation in the current input method. The input - * method gets theh text to reconvert from the client component, using + * method gets the text to reconvert from the client component, using * {@link InputMethodRequests#getSelectedText(Attribute[])}. Then the * composed and committed text produced by the operation is sent back to * the client using a sequence of InputMethodRequests. diff --git a/libjava/classpath/java/awt/im/InputMethodHighlight.java b/libjava/classpath/java/awt/im/InputMethodHighlight.java index 0d664b19366..6fbe42fe549 100644 --- a/libjava/classpath/java/awt/im/InputMethodHighlight.java +++ b/libjava/classpath/java/awt/im/InputMethodHighlight.java @@ -37,6 +37,9 @@ exception statement from your version. */ package java.awt.im; +import java.awt.Toolkit; +import java.text.Annotation; +import java.text.AttributedCharacterIterator; import java.util.Map; /** @@ -53,7 +56,7 @@ import java.util.Map; * text segments. * * @author Eric Blake (ebb9@email.byu.edu) - * @see AttributedCharacterIterators + * @see AttributedCharacterIterator * @see Annotation * @since 1.2 * @status updated to 1.4 diff --git a/libjava/classpath/java/awt/im/InputMethodRequests.java b/libjava/classpath/java/awt/im/InputMethodRequests.java index d50ec33c5c8..0423358cc53 100644 --- a/libjava/classpath/java/awt/im/InputMethodRequests.java +++ b/libjava/classpath/java/awt/im/InputMethodRequests.java @@ -37,8 +37,10 @@ exception statement from your version. */ package java.awt.im; +import java.awt.Component; import java.awt.Rectangle; import java.awt.font.TextHitInfo; +import java.awt.event.InputMethodListener; import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator.Attribute; diff --git a/libjava/classpath/java/awt/im/spi/InputMethod.java b/libjava/classpath/java/awt/im/spi/InputMethod.java index 840d193a8d8..ebe4508418e 100644 --- a/libjava/classpath/java/awt/im/spi/InputMethod.java +++ b/libjava/classpath/java/awt/im/spi/InputMethod.java @@ -38,7 +38,11 @@ exception statement from your version. */ package java.awt.im.spi; import java.awt.AWTEvent; +import java.awt.Component; import java.awt.Rectangle; +import java.awt.im.InputContext; +import java.awt.im.InputMethodRequests; +import java.text.AttributedCharacterIterator.Attribute; import java.util.Locale; /** @@ -152,8 +156,8 @@ public interface InputMethod * Notify this input method of changes in the client window. This is called * when notifications are enabled (see {@link * InputMethodContext#enableClientWindowNotification(InputMethod, boolean)}, - * if {@link #removeNotify(Component)} has not been called. The following - * situations trigger a notification:<ul> + * if {@link InputContext#removeNotify(Component)} has not been called. + * The following situations trigger a notification:<ul> * <li>The client window changes in location, size, visibility, * iconification, or is closed.</li> * <li>When enabling client notification (or on the first activation after @@ -202,7 +206,7 @@ public interface InputMethod /** * Notify the input method that a client component has been removed from its * hierarchy, or that input method support has been disabled. This is - * called by {@link InputContext#removeNotify()}, and only when the input + * called by {@link InputContext#removeNotify(Component)}, and only when the input * method is inactive. */ void removeNotify(); diff --git a/libjava/classpath/java/awt/im/spi/InputMethodContext.java b/libjava/classpath/java/awt/im/spi/InputMethodContext.java index 43bee8d8617..17ec4f8f7ee 100644 --- a/libjava/classpath/java/awt/im/spi/InputMethodContext.java +++ b/libjava/classpath/java/awt/im/spi/InputMethodContext.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.awt.im.spi; +import java.awt.HeadlessException; +import java.awt.Rectangle; import java.awt.Window; import java.awt.font.TextHitInfo; import java.awt.im.InputMethodRequests; @@ -113,7 +115,7 @@ public interface InputMethodContext extends InputMethodRequests /** * Sets whether notification of the client window's location and state should * be enabled for the input method. When enabled, the input method's - * {@link #notifyClientWindowChange(Rectangle)} method is called. + * {@link InputMethod#notifyClientWindowChange(Rectangle)} method is called. * Notification is automatically disabled when the input method is disposed. * * @param inputMethod the method to change status of diff --git a/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java b/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java index 093d7319217..d234e5c57f3 100644 --- a/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java +++ b/libjava/classpath/java/awt/im/spi/InputMethodDescriptor.java @@ -39,6 +39,7 @@ package java.awt.im.spi; import java.awt.AWTException; import java.awt.Image; +import java.awt.im.InputContext; import java.util.Locale; /** @@ -57,7 +58,7 @@ public interface InputMethodDescriptor * also by country and variant), via * {@link InputContext#selectInputMethod(Locale)}. The returned list should * ignore pass-through locales, so it is usually a subset of locales for - * which {@link InputMethod#setContext(Locale)} returns true. If + * which {@link InputMethod#setLocale(Locale)} returns true. If * {@link #hasDynamicLocaleList()} returns true, this is called each time * information is needed, allowing dynamic addition or removal of supported * locales. diff --git a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java index 194d483d962..6333ce9e7f9 100644 --- a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java +++ b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java @@ -45,7 +45,7 @@ package java.awt.image; * points should give the desired results although Sun does not * specify what the exact algorithm should be. * <br> - * Currently this filter does nothing and needs to be implemented. + * FIXME: Currently this filter does nothing and needs to be implemented. * * @author C. Brian Jones (cbj@gnu.org) */ diff --git a/libjava/classpath/java/awt/image/BufferedImage.java b/libjava/classpath/java/awt/image/BufferedImage.java index 124b81368e2..3cabfbde692 100644 --- a/libjava/classpath/java/awt/image/BufferedImage.java +++ b/libjava/classpath/java/awt/image/BufferedImage.java @@ -1,5 +1,5 @@ /* BufferedImage.java -- - Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation + Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. @@ -48,9 +48,7 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.Transparency; import java.awt.color.ColorSpace; -import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.Vector; /** @@ -64,7 +62,7 @@ import java.util.Vector; * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) */ public class BufferedImage extends Image - implements WritableRenderedImage + implements WritableRenderedImage, Transparency { public static final int TYPE_CUSTOM = 0, TYPE_INT_RGB = 1, @@ -690,4 +688,16 @@ public class BufferedImage extends Image observers.remove (to); } + + /** + * Return the transparency type. + * + * @return One of {@link #OPAQUE}, {@link #BITMASK}, or {@link #TRANSLUCENT}. + * @see Transparency#getTransparency() + * @since 1.5 + */ + public int getTransparency() + { + return colorModel.getTransparency(); + } } diff --git a/libjava/classpath/java/awt/image/ColorModel.java b/libjava/classpath/java/awt/image/ColorModel.java index 1ebcb98a76b..1ced2a04366 100644 --- a/libjava/classpath/java/awt/image/ColorModel.java +++ b/libjava/classpath/java/awt/image/ColorModel.java @@ -609,7 +609,7 @@ public abstract class ColorModel implements Transparency * @param obj Array of TransferType or null. * * @return pixel value encoded according to the color model. - * @throws ArrayIndexOutOfBounds + * @throws ArrayIndexOutOfBoundsException * @throws ClassCastException * @since 1.4 */ diff --git a/libjava/classpath/java/awt/image/ComponentSampleModel.java b/libjava/classpath/java/awt/image/ComponentSampleModel.java index 953f63c1ea1..5cf06e4a17f 100644 --- a/libjava/classpath/java/awt/image/ComponentSampleModel.java +++ b/libjava/classpath/java/awt/image/ComponentSampleModel.java @@ -63,8 +63,11 @@ public class ComponentSampleModel extends SampleModel protected int[] bandOffsets; protected int[] bankIndices; - // FIXME: Should we really shadow the numBands in the superclass? - //protected int numBands; + /** + * Number of bands in the image described. + * @specnote This field shadows the protected numBands in SampleModel. + */ + protected int numBands; /** Used when creating data buffers. */ protected int numBanks; @@ -100,6 +103,7 @@ public class ComponentSampleModel extends SampleModel this.bandOffsets = bandOffsets; this.bankIndices = bankIndices; + this.numBands = bandOffsets.length; this.numBanks = 0; for (int b=0; b<bankIndices.length; b++) diff --git a/libjava/classpath/java/awt/image/ImageConsumer.java b/libjava/classpath/java/awt/image/ImageConsumer.java index e1834c3978f..fc5ed11e5ca 100644 --- a/libjava/classpath/java/awt/image/ImageConsumer.java +++ b/libjava/classpath/java/awt/image/ImageConsumer.java @@ -75,7 +75,7 @@ public interface ImageConsumer * most one call to <code>setPixels</code> for any single pixel. * * @see #setHints - * @see #setPixels + * @see #setPixels(int, int, int, int, ColorModel, int[], int, int) */ int SINGLEPASS = 8; diff --git a/libjava/classpath/java/awt/image/PackedColorModel.java b/libjava/classpath/java/awt/image/PackedColorModel.java index 894e6e66fda..b60230fa70d 100644 --- a/libjava/classpath/java/awt/image/PackedColorModel.java +++ b/libjava/classpath/java/awt/image/PackedColorModel.java @@ -90,11 +90,7 @@ public abstract class PackedColorModel extends ColorModel return bitsPerComponent; } - /** Initializes the masks. - * - * @return an array containing the number of bits per color - * component. - */ + /** Initializes the masks. */ private void initMasks(int[] colorMaskArray, int alphaMask) { int numComponents = colorMaskArray.length; diff --git a/libjava/classpath/java/awt/image/SampleModel.java b/libjava/classpath/java/awt/image/SampleModel.java index 257e30a5bd5..1159662223c 100644 --- a/libjava/classpath/java/awt/image/SampleModel.java +++ b/libjava/classpath/java/awt/image/SampleModel.java @@ -47,7 +47,8 @@ public abstract class SampleModel /** Height of image described. */ protected int height; - /** Number of bands in the image described. */ + /** Number of bands in the image described. Package-private here, + shadowed by ComponentSampleModel. */ protected int numBands; /** diff --git a/libjava/classpath/java/awt/print/PrinterJob.java b/libjava/classpath/java/awt/print/PrinterJob.java index e61ab61bc77..e1aeabc3e62 100644 --- a/libjava/classpath/java/awt/print/PrinterJob.java +++ b/libjava/classpath/java/awt/print/PrinterJob.java @@ -169,8 +169,11 @@ public abstract class PrinterJob /** * Prints the page with given attributes. */ - public abstract void print (PrintRequestAttributeSet attributes) - throws PrinterException; + public void print (PrintRequestAttributeSet attributes) + throws PrinterException + { + print (); + } /** * Displays a dialog box to the user which allows the print job |