diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-06-16 22:16:36 +0000 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2006-06-16 22:16:36 +0000 |
commit | 3e9551811aacd78ea129d036ddb612bc72b705e2 (patch) | |
tree | 3225e5d210881ac15e9c805f8288aece752d4e10 /java | |
parent | 4d765e74147311885fb6c17c0e66a30f10d7e09e (diff) | |
download | classpath-3e9551811aacd78ea129d036ddb612bc72b705e2.tar.gz |
2006-06-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD --> generics-branch for
2006/06/11 to 2006/06/16.
Diffstat (limited to 'java')
-rw-r--r-- | java/awt/BasicStroke.java | 2 | ||||
-rw-r--r-- | java/awt/Component.java | 18 | ||||
-rw-r--r-- | java/awt/FileDialog.java | 52 | ||||
-rw-r--r-- | java/awt/Font.java | 9 | ||||
-rw-r--r-- | java/awt/Shape.java | 12 | ||||
-rw-r--r-- | java/awt/TextComponent.java | 13 | ||||
-rw-r--r-- | java/awt/font/LineBreakMeasurer.java | 165 | ||||
-rw-r--r-- | java/awt/font/TextLayout.java | 4 | ||||
-rw-r--r-- | java/awt/geom/GeneralPath.java | 4 | ||||
-rw-r--r-- | java/awt/image/PixelGrabber.java | 7 | ||||
-rw-r--r-- | java/io/File.java | 3 | ||||
-rw-r--r-- | java/lang/Thread.java | 2 | ||||
-rw-r--r-- | java/lang/management/ManagementFactory.java | 25 | ||||
-rw-r--r-- | java/lang/management/ManagementPermission.java | 132 | ||||
-rw-r--r-- | java/lang/management/RuntimeMXBean.java | 6 |
15 files changed, 385 insertions, 69 deletions
diff --git a/java/awt/BasicStroke.java b/java/awt/BasicStroke.java index 3e259216f..cb8ef49ae 100644 --- a/java/awt/BasicStroke.java +++ b/java/awt/BasicStroke.java @@ -260,7 +260,7 @@ public class BasicStroke implements Stroke */ public Shape createStrokedShape(Shape s) { - PathIterator pi = s.getPathIterator( new AffineTransform() ); + PathIterator pi = s.getPathIterator(null); if( dash == null ) return solidStroke( pi ); diff --git a/java/awt/Component.java b/java/awt/Component.java index 65ac80373..26df1554f 100644 --- a/java/awt/Component.java +++ b/java/awt/Component.java @@ -1739,9 +1739,8 @@ public abstract class Component if (gfx == null && parent != null) { gfx = parent.getGraphics(); - Rectangle bounds = getBounds(); - gfx.setClip(bounds); - gfx.translate(bounds.x, bounds.y); + gfx.clipRect(getX(), getY(), getWidth(), getHeight()); + gfx.translate(getX(), getY()); return gfx; } gfx.setFont(font); @@ -2319,6 +2318,17 @@ public abstract class Component } /** + * By default, no old mouse events should be ignored. + * This can be overridden by subclasses. + * + * @return false, no mouse events are ignored. + */ + static boolean ignoreOldMouseEvents() + { + return false; + } + + /** * AWT 1.0 event handler. * * This method simply calls handleEvent and returns the result. @@ -4866,7 +4876,7 @@ p * <li>the set of backward traversal keys if ((mods & InputEvent.ALT_DOWN_MASK) != 0) oldMods |= Event.ALT_MASK; - if (e instanceof MouseEvent) + if (e instanceof MouseEvent && !ignoreOldMouseEvents()) { if (id == MouseEvent.MOUSE_PRESSED) oldID = Event.MOUSE_DOWN; diff --git a/java/awt/FileDialog.java b/java/awt/FileDialog.java index 7f2723e7e..f02d06be2 100644 --- a/java/awt/FileDialog.java +++ b/java/awt/FileDialog.java @@ -101,6 +101,58 @@ private int mode; * Constructors */ + /** + * Initializes a new instance of <code>FileDialog</code> with the specified + * parent. This dialog will have no title and will be for loading a file. + * + * @param parent The parent dialog for this. + * + * @since 1.5 + */ + public FileDialog(Dialog parent) + { + this(parent, "", LOAD); + } + + /** + * Initialized a new instance of <code>FileDialog</code> with the + * specified parent and title. This dialog will be for opening a file. + * + * @param parent The parent dialog for this. + * @param title The title for this dialog. + * + * @since 1.5 + */ + public FileDialog(Dialog parent, String title) + { + this(parent, title, LOAD); + } + + /** + * Initialized a new instance of <code>FileDialog</code> with the specified + * parent, title, and mode. + * + * @param parent The parent dialog for this. + * @param title The title for this dialog. + * @param mode The mode of the dialog, either <code>LOAD</code> or + * <code>SAVE</code>. + * @throws IllegalArgumentException - if illegal mode, if + * GraphicsEnvironment.isHeadless or if parent is null. + * + * @since 1.5 + */ + public FileDialog(Dialog parent, String title, int mode) + { + super(parent, title, true); + + // Other IllegalArgumentException cases are taken care of in Window.java + if (mode != LOAD && mode != SAVE) + throw new IllegalArgumentException ( + "Mode argument must be either LOAD or SAVE"); + + setMode(mode); + } + /** * Initializes a new instance of <code>FileDialog</code> with the * specified parent. This dialog will have no title and will be for diff --git a/java/awt/Font.java b/java/awt/Font.java index ceff55878..46b65d79c 100644 --- a/java/awt/Font.java +++ b/java/awt/Font.java @@ -115,7 +115,14 @@ public class Font implements Serializable * @since 1.3 */ public static final int TRUETYPE_FONT = 0; - + + /** + * Indicates to <code>createFont</code> that the supplied font data + * is in Type1 format. + * + * @since 1.5 + */ + public static final int TYPE1_FONT = 1; /** * A flag for <code>layoutGlyphVector</code>, indicating that the diff --git a/java/awt/Shape.java b/java/awt/Shape.java index bd8a43435..d76bbaba6 100644 --- a/java/awt/Shape.java +++ b/java/awt/Shape.java @@ -1,5 +1,5 @@ /* Shape.java -- the classic Object-Oriented shape interface - Copyright (C) 1999, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -176,7 +176,8 @@ public interface Shape * not required, that the Shape isolate iterations from future changes to * the boundary, and document this fact. * - * @param transform an optional transform to apply to the iterator + * @param transform an optional transform to apply to the + * iterator (<code>null</code> permitted). * @return a new iterator over the boundary * @since 1.2 */ @@ -185,7 +186,7 @@ public interface Shape /** * Return an iterator along the flattened version of the shape boundary. * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE points are returned in the - * iterator. The flatness paramter controls how far points are allowed to + * iterator. The flatness parameter controls how far points are allowed to * differ from the real curve; although a limit on accuracy may cause this * parameter to be enlarged if needed. * @@ -194,10 +195,11 @@ public interface Shape * use. It is recommended, but not required, that the Shape isolate * iterations from future changes to the boundary, and document this fact. * - * @param transform an optional transform to apply to the iterator + * @param transform an optional transform to apply to the + * iterator (<code>null</code> permitted). * @param flatness the maximum distance for deviation from the real boundary * @return a new iterator over the boundary * @since 1.2 */ PathIterator getPathIterator(AffineTransform transform, double flatness); -} // interface Shape +} diff --git a/java/awt/TextComponent.java b/java/awt/TextComponent.java index 84f773011..db4cc2beb 100644 --- a/java/awt/TextComponent.java +++ b/java/awt/TextComponent.java @@ -734,8 +734,17 @@ paramString() return null; } - - + /** + * All old mouse events for this component should + * be ignored. + * + * @return true to ignore all old mouse events. + */ + static boolean + ignoreOldMouseEvents() + { + return true; + } } // class TextComponent diff --git a/java/awt/font/LineBreakMeasurer.java b/java/awt/font/LineBreakMeasurer.java index 14985b44c..c2a6d45d9 100644 --- a/java/awt/font/LineBreakMeasurer.java +++ b/java/awt/font/LineBreakMeasurer.java @@ -1,5 +1,5 @@ /* LineBreakMeasurer.java - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,84 +38,161 @@ exception statement from your version. */ package java.awt.font; -import gnu.classpath.NotImplementedException; - import java.text.AttributedCharacterIterator; +import java.text.AttributedString; import java.text.BreakIterator; +import java.awt.font.TextLayout; +import java.awt.font.FontRenderContext; +import java.awt.Shape; public final class LineBreakMeasurer { - private AttributedCharacterIterator ci; + private AttributedCharacterIterator text; + private int position; private FontRenderContext frc; - private BreakIterator bi; + private TextLayout totalLayout; + private int numChars; - /** - * Constructs a <code>LineBreakMeasurer</code> object. - */ - public LineBreakMeasurer (AttributedCharacterIterator text, - FontRenderContext frc) + public LineBreakMeasurer(AttributedCharacterIterator text, + BreakIterator breakIter, FontRenderContext frc) { - this (text, null, frc); + this.text = text; + this.frc = frc; + position = 0; + totalLayout = new TextLayout(text, frc); + numChars = totalLayout.getCharacterCount(); } - /** - * Constructs a <code>LineBreakMeasurer</code> object. - */ - public LineBreakMeasurer (AttributedCharacterIterator text, - BreakIterator breakIter, FontRenderContext frc) + public LineBreakMeasurer(AttributedCharacterIterator text, + FontRenderContext frc) { - this.ci = text; - this.bi = breakIter; + this.text = text; this.frc = frc; + position = 0; + totalLayout = new TextLayout(text, frc); + numChars = totalLayout.getCharacterCount(); } - public void deleteChar (AttributedCharacterIterator newParagraph, - int deletePos) - throws NotImplementedException + public void deleteChar(AttributedCharacterIterator newParagraph, + int deletePos) { - throw new Error ("not implemented"); + totalLayout = new TextLayout(newParagraph, frc); + if( deletePos < 0 || deletePos > totalLayout.getCharacterCount() ) + throw new NullPointerException("Invalid deletePos:"+deletePos); + numChars = totalLayout.getCharacterCount(); + text = newParagraph; + position = 0; } - public int getPosition () + public void insertChar(AttributedCharacterIterator newParagraph, + int insertPos) { - return ci.getIndex (); + totalLayout = new TextLayout(newParagraph, frc); + if( insertPos < 0 || insertPos > totalLayout.getCharacterCount() ) + throw new NullPointerException("Invalid insertPos:"+insertPos); + numChars = totalLayout.getCharacterCount(); + text = newParagraph; + position = 0; } - public void insertChar (AttributedCharacterIterator newParagraph, - int insertPos) - throws NotImplementedException + public TextLayout nextLayout(float wrappingWidth) { - throw new Error ("not implemented"); + return nextLayout( wrappingWidth, numChars, false ); } - public TextLayout nextLayout (float wrappingWidth) - throws NotImplementedException + public TextLayout nextLayout(float wrappingWidth, int offsetLimit, + boolean requireNextWord) { - throw new Error ("not implemented"); + int next = nextOffset( wrappingWidth, offsetLimit, requireNextWord ); + AttributedCharacterIterator aci = (new AttributedString( text, + position, next ) + ).getIterator(); + position = next; + return new TextLayout( aci, frc ); } - public TextLayout nextLayout (float wrappingWidth, int offsetLimit, - boolean requireNextWord) - throws NotImplementedException + public int nextOffset(float wrappingWidth) { - throw new Error ("not implemented"); + return nextOffset( wrappingWidth, numChars, false ); } - public int nextOffset (float wrappingWidth) - throws NotImplementedException + public int nextOffset(float wrappingWidth, int offsetLimit, + boolean requireNextWord) { - throw new Error ("not implemented"); + Shape s = totalLayout.getBlackBoxBounds( position, offsetLimit ); + double remainingLength = s.getBounds2D().getWidth(); + + int guessOffset = (int)( ( (double)wrappingWidth / (double)remainingLength) + * ( (double)numChars - (double)position ) ); + guessOffset += position; + if( guessOffset > offsetLimit ) + guessOffset = offsetLimit; + + s = totalLayout.getBlackBoxBounds( position, guessOffset ); + double guessLength = s.getBounds2D().getWidth(); + + boolean makeSmaller = ( guessLength > wrappingWidth ); + int inc = makeSmaller ? -1 : 1; + boolean keepGoing = true; + + do + { + guessOffset = guessOffset + inc; + if( guessOffset <= position || guessOffset > offsetLimit ) + { + keepGoing = false; + } + else + { + s = totalLayout.getBlackBoxBounds( position, guessOffset ); + guessLength = s.getBounds2D().getWidth(); + if( makeSmaller && ( guessLength <= wrappingWidth) ) + keepGoing = false; + if( !makeSmaller && ( guessLength >= wrappingWidth) ) + keepGoing = false; + } + } + while( keepGoing ); + + if( !makeSmaller ) + guessOffset--; + + if( guessOffset >= offsetLimit ) + return offsetLimit; + + text.setIndex( guessOffset ); + if( !requireNextWord ) + { + char c = text.previous(); + while( !Character.isWhitespace( c ) && c != '-' && + guessOffset > position ) + { + guessOffset--; + c = text.previous(); + } + } + else + { + char c = text.next(); + while( !Character.isWhitespace( c ) && c != '-' && + guessOffset < offsetLimit ) + { + guessOffset++; + c = text.next(); + } + } + + return guessOffset; } - public int nextOffset (float wrappingWidth, int offsetLimit, - boolean requireNextWord) - throws NotImplementedException + public void setPosition(int newPosition) { - throw new Error ("not implemented"); + position = newPosition; } - public void setPosition (int newPosition) + public int getPosition() { - ci.setIndex (newPosition); + return position; } } + diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java index 6bae3facd..a55aab235 100644 --- a/java/awt/font/TextLayout.java +++ b/java/awt/font/TextLayout.java @@ -43,13 +43,11 @@ import gnu.classpath.NotImplementedException; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Shape; -import java.awt.Toolkit; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; import java.text.AttributedCharacterIterator; -import java.text.AttributedString; import java.text.Bidi; import java.util.Map; @@ -85,7 +83,7 @@ public final class TextLayout implements Cloneable /** * The default caret policy. */ - static TextLayout.CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy(); + public static final TextLayout.CaretPolicy DEFAULT_CARET_POLICY = new CaretPolicy(); /** * Constructs a TextLayout. diff --git a/java/awt/geom/GeneralPath.java b/java/awt/geom/GeneralPath.java index 123833b11..0dcc116ed 100644 --- a/java/awt/geom/GeneralPath.java +++ b/java/awt/geom/GeneralPath.java @@ -247,10 +247,12 @@ public final class GeneralPath implements Shape, Cloneable /** * Closes the current subpath by drawing a line - * back to the point of the last moveTo. + * back to the point of the last moveTo, unless the path is already closed. */ public void closePath() { + if (index >= 1 && types[index - 1] == PathIterator.SEG_CLOSE) + return; ensureSize(index + 1); types[index] = PathIterator.SEG_CLOSE; xpoints[index] = xpoints[subpath]; diff --git a/java/awt/image/PixelGrabber.java b/java/awt/image/PixelGrabber.java index 9dc872642..fc5e0efc0 100644 --- a/java/awt/image/PixelGrabber.java +++ b/java/awt/image/PixelGrabber.java @@ -112,7 +112,8 @@ public class PixelGrabber implements ImageConsumer * in the grab rectangle will be stored at * <code>pix[(n - y) * scansize + (m - x) + off]</code>. * - * @param ip the ImageProducer from which to grab pixels + * @param ip the ImageProducer from which to grab pixels. This can + * be null. * @param x the x coordinate of the grab rectangle's top-left pixel, * specified relative to the top-left corner of the image produced * by <code>ip</code> @@ -131,9 +132,6 @@ public class PixelGrabber implements ImageConsumer public PixelGrabber(ImageProducer ip, int x, int y, int w, int h, int pix[], int off, int scansize) { - if (ip == null) - throw new NullPointerException("The ImageProducer must not be null."); - this.ip = ip; this.x = x; this.y = y; @@ -222,7 +220,6 @@ public class PixelGrabber implements ImageConsumer } catch (Exception ex) { - ex.printStackTrace(); imageComplete(ImageConsumer.IMAGEABORTED); } } diff --git a/java/io/File.java b/java/io/File.java index 36cfa24ea..09f1ce9b5 100644 --- a/java/io/File.java +++ b/java/io/File.java @@ -542,7 +542,8 @@ public class File implements Serializable, Comparable<File> /** * This method returns a <code>String</code> the represents this file's * parent. <code>null</code> is returned if the file has no parent. The - * parent is determined via a simple operation which removes the + * parent is determined via a simple operation which removes the name + * after the last file separator character, as determined by the platform. * * @return The parent directory of this file */ diff --git a/java/lang/Thread.java b/java/lang/Thread.java index e5a654c1b..e039b4703 100644 --- a/java/lang/Thread.java +++ b/java/lang/Thread.java @@ -1205,7 +1205,7 @@ public class Thread implements Runnable * @author Andrew John Hughes <gnu_andrew@member.fsf.org> * @since 1.5 * @see Thread#getUncaughtExceptionHandler() - * @see Thread#setUncaughtExceptionHander(java.lang.Thread.UncaughtExceptionHandler) + * @see Thread#setUncaughtExceptionHandler(UncaughtExceptionHandler) * @see Thread#getDefaultUncaughtExceptionHandler() * @see * Thread#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler) diff --git a/java/lang/management/ManagementFactory.java b/java/lang/management/ManagementFactory.java index d070f719c..b3db1b96d 100644 --- a/java/lang/management/ManagementFactory.java +++ b/java/lang/management/ManagementFactory.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.lang.management; import gnu.java.lang.management.OperatingSystemMXBeanImpl; +import gnu.java.lang.management.RuntimeMXBeanImpl; /** * <p> @@ -65,6 +66,16 @@ public class ManagementFactory private static OperatingSystemMXBean osBean; /** + * The runtime management bean. + */ + private static RuntimeMXBean runtimeBean; + + /** + * Private constructor to prevent instance creation. + */ + private ManagementFactory() {} + + /** * Returns the operating system management bean for the * operating system on which the virtual machine is running. * @@ -78,4 +89,18 @@ public class ManagementFactory return osBean; } + /** + * Returns the runtime management bean for the + * running virtual machine. + * + * @return an instance of {@link RuntimeMXBean} for + * this virtual machine. + */ + public static RuntimeMXBean getRuntimeMXBean() + { + if (runtimeBean == null) + runtimeBean = new RuntimeMXBeanImpl(); + return runtimeBean; + } + } diff --git a/java/lang/management/ManagementPermission.java b/java/lang/management/ManagementPermission.java new file mode 100644 index 000000000..0e6bd0612 --- /dev/null +++ b/java/lang/management/ManagementPermission.java @@ -0,0 +1,132 @@ +/* ManagementPermission.java - Permissions for system management. + Copyright (C) 2006 Free Software Foundation + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + +package java.lang.management; + +import java.security.BasicPermission; + +/** + * <p> + * Represents the permission to view or modify the data + * which forms part of the system management interfaces. + * Calls to methods of the system management beans, + * provided by the {@link ManagementFactory}, may perform + * checks against the current {@link java.lang.SecurityManager} + * (if any) before allowing the operation to proceed. + * Instances of this object are supplied to the + * {@link java.lang.SecurityManager} in order to perform + * these checks. It is not normal for instances of this + * class to be created outside the use of the + * {@link java.lang.SecurityManager}. + * </p> + * <p> + * This object can represent two types of management + * permission: + * </p> + * <ul> + * <li><strong>monitor</strong> — this allows access + * to information such as the arguments supplied to the + * virtual machine, the currently loaded classes and the + * stack traces of running threads. Malicious code may + * use this to obtain information about the system and + * exploit any vulnerabilities found.</li> + * <li><strong>control</strong> — this allows the + * information stored by the management beans to be altered. + * For example, additional debugging information (such + * as class loading traces) may be turned on or memory + * usage limits changed. Malicious code could use + * this to alter the behaviour of the system.</li> + * </ul> + * + * @author Andrew John Hughes (gnu_andrew@member.fsf.org) + * @since 1.5 + */ +public final class ManagementPermission + extends BasicPermission +{ + + /** + * Compatible with JDK 1.5 + */ + private static final long serialVersionUID = 1897496590799378737L; + + /** + * Constructs a new <code>ManagementPermission</code> + * for one of the two permission targets, "monitor" + * and "control". + * + * @param name the name of the permission this instance + * should represent; either "monitor" or + * "control". + * @throws IllegalArgumentException if the name is not + * either "monitor" + * or "control". + */ + public ManagementPermission(String name) + { + super(name); + if (!(name.equals("monitor") || name.equals("control"))) + throw new IllegalArgumentException("Invalid permission."); + } + + /** + * Constructs a new <code>ManagementPermission</code> + * for one of the two permission targets, "monitor" + * and "control". Actions are not supported, so + * this value should be either <code>null</code> + * or the empty string. + * + * @param name the name of the permission this instance + * should represent; either "monitor" or + * "control". + * @param actions either <code>null</code> or the + * empty string. + * @throws IllegalArgumentException if the name is not + * either "monitor" + * or "control", or + * a value for actions + * is specified. + */ + public ManagementPermission(String name, String actions) + { + this(name); + if (!(actions == null || actions.equals(""))) + throw new IllegalArgumentException("Invalid actions."); + } + +} + diff --git a/java/lang/management/RuntimeMXBean.java b/java/lang/management/RuntimeMXBean.java index c572394f8..59b6d0eb1 100644 --- a/java/lang/management/RuntimeMXBean.java +++ b/java/lang/management/RuntimeMXBean.java @@ -140,7 +140,11 @@ public interface RuntimeMXBean * virtual machine. It may include a number of system * attributes and may differ between instances of the * same virtual machine (for example, it might include - * the process identifier). + * the process identifier or the host name of the machine + * on which it is running). The intention is that this + * name refers to the precise entity that the other data + * supplied by this bean refers to, rather than the VM + * in general. * * @return the name of this virtual machine. */ |