Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942
This commit is contained in:
parent
27079765d0
commit
8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
|
@ -39,6 +39,19 @@ exception statement from your version. */
|
|||
|
||||
package java.awt;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.InputMethodEvent;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.PaintEvent;
|
||||
import java.awt.event.TextEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
|
@ -275,4 +288,94 @@ public abstract class AWTEvent extends EventObject
|
|||
{
|
||||
return consumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an event id to the appropriate event mask.
|
||||
*
|
||||
* @param id the event id
|
||||
*
|
||||
* @return the event mask for the specified id
|
||||
*/
|
||||
static long eventIdToMask(int id)
|
||||
{
|
||||
long mask = 0;
|
||||
switch (id)
|
||||
{
|
||||
case ActionEvent.ACTION_PERFORMED:
|
||||
mask = ACTION_EVENT_MASK;
|
||||
break;
|
||||
case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
|
||||
mask = ADJUSTMENT_EVENT_MASK;
|
||||
break;
|
||||
case ComponentEvent.COMPONENT_MOVED:
|
||||
case ComponentEvent.COMPONENT_RESIZED:
|
||||
case ComponentEvent.COMPONENT_SHOWN:
|
||||
case ComponentEvent.COMPONENT_HIDDEN:
|
||||
mask = COMPONENT_EVENT_MASK;
|
||||
break;
|
||||
case ContainerEvent.COMPONENT_ADDED:
|
||||
case ContainerEvent.COMPONENT_REMOVED:
|
||||
mask = CONTAINER_EVENT_MASK;
|
||||
break;
|
||||
case FocusEvent.FOCUS_GAINED:
|
||||
case FocusEvent.FOCUS_LOST:
|
||||
mask = FOCUS_EVENT_MASK;
|
||||
break;
|
||||
case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
|
||||
case InputMethodEvent.CARET_POSITION_CHANGED:
|
||||
mask = INPUT_METHOD_EVENT_MASK;
|
||||
break;
|
||||
case InvocationEvent.INVOCATION_DEFAULT:
|
||||
mask = INVOCATION_EVENT_MASK;
|
||||
break;
|
||||
case ItemEvent.ITEM_STATE_CHANGED:
|
||||
mask = ITEM_EVENT_MASK;
|
||||
break;
|
||||
case KeyEvent.KEY_TYPED:
|
||||
case KeyEvent.KEY_PRESSED:
|
||||
case KeyEvent.KEY_RELEASED:
|
||||
mask = KEY_EVENT_MASK;
|
||||
break;
|
||||
case MouseEvent.MOUSE_CLICKED:
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
mask = MOUSE_EVENT_MASK;
|
||||
break;
|
||||
case MouseEvent.MOUSE_MOVED:
|
||||
case MouseEvent.MOUSE_ENTERED:
|
||||
case MouseEvent.MOUSE_EXITED:
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
mask = MOUSE_MOTION_EVENT_MASK;
|
||||
break;
|
||||
case MouseEvent.MOUSE_WHEEL:
|
||||
mask = MOUSE_WHEEL_EVENT_MASK;
|
||||
break;
|
||||
case PaintEvent.PAINT:
|
||||
case PaintEvent.UPDATE:
|
||||
mask = PAINT_EVENT_MASK;
|
||||
break;
|
||||
case TextEvent.TEXT_VALUE_CHANGED:
|
||||
mask = TEXT_EVENT_MASK;
|
||||
break;
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
mask = WINDOW_EVENT_MASK;
|
||||
break;
|
||||
case WindowEvent.WINDOW_GAINED_FOCUS:
|
||||
case WindowEvent.WINDOW_LOST_FOCUS:
|
||||
mask = WINDOW_FOCUS_EVENT_MASK;
|
||||
break;
|
||||
case WindowEvent.WINDOW_STATE_CHANGED:
|
||||
mask = WINDOW_STATE_EVENT_MASK;
|
||||
break;
|
||||
default:
|
||||
mask = 0;
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
} // class AWTEvent
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* BasicStroke.java --
|
||||
Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -41,38 +41,89 @@ package java.awt;
|
|||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* STUB CLASS ONLY
|
||||
* A general purpose {@link Stroke} implementation that can represent a wide
|
||||
* variety of line styles for use with subclasses of {@link Graphics2D}.
|
||||
* <p>
|
||||
* The line cap and join styles can be set using the options illustrated
|
||||
* here:
|
||||
* <p>
|
||||
* <img src="doc-files/capjoin.png" width="350" height="180"
|
||||
* alt="Illustration of line cap and join styles" />
|
||||
* <p>
|
||||
* A dash array can be used to specify lines with alternating opaque and
|
||||
* transparent sections.
|
||||
*/
|
||||
public class BasicStroke implements Stroke
|
||||
{
|
||||
/**
|
||||
* Indicates a mitered line join style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int JOIN_MITER = 0;
|
||||
|
||||
/**
|
||||
* Indicates a rounded line join style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int JOIN_ROUND = 1;
|
||||
|
||||
/**
|
||||
* Indicates a bevelled line join style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int JOIN_BEVEL = 2;
|
||||
|
||||
/**
|
||||
* Indicates a flat line cap style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int CAP_BUTT = 0;
|
||||
|
||||
/**
|
||||
* Indicates a rounded line cap style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int CAP_ROUND = 1;
|
||||
|
||||
/**
|
||||
* Indicates a square line cap style. See the class overview for an
|
||||
* illustration.
|
||||
*/
|
||||
public static final int CAP_SQUARE = 2;
|
||||
|
||||
/** The stroke width. */
|
||||
private final float width;
|
||||
|
||||
/** The line cap style. */
|
||||
private final int cap;
|
||||
|
||||
/** The line join style. */
|
||||
private final int join;
|
||||
|
||||
/** The miter limit. */
|
||||
private final float limit;
|
||||
|
||||
/** The dash array. */
|
||||
private final float[] dash;
|
||||
|
||||
/** The dash phase. */
|
||||
private final float phase;
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given attributes.
|
||||
*
|
||||
* @param width May not be negative .
|
||||
* @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
||||
* @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
||||
* @param miterlimit the limit to trim the miter join. The miterlimit must be
|
||||
* @param width the line width (>= 0.0f).
|
||||
* @param cap the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
|
||||
* @param join the line join style (one of {@link #JOIN_ROUND},
|
||||
* {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
|
||||
* @param miterlimit the limit to trim the miter join. The miterlimit must be
|
||||
* greater than or equal to 1.0f.
|
||||
* @param dash The array representing the dashing pattern. There must be at
|
||||
* least one non-zero entry.
|
||||
* @param dashPhase is negative and dash is not null.
|
||||
*
|
||||
* @exception IllegalArgumentException If one input parameter doesn't meet
|
||||
* @throws IllegalArgumentException If one input parameter doesn't meet
|
||||
* its needs.
|
||||
*/
|
||||
public BasicStroke(float width, int cap, int join, float miterlimit,
|
||||
|
@ -122,15 +173,17 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given attributes.
|
||||
*
|
||||
* @param width The width of the BasicStroke. May not be negative .
|
||||
* @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
||||
* @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
||||
* @param width the line width (>= 0.0f).
|
||||
* @param cap the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
|
||||
* @param join the line join style (one of {@link #JOIN_ROUND},
|
||||
* {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
|
||||
* @param miterlimit the limit to trim the miter join. The miterlimit must be
|
||||
* greater than or equal to 1.0f.
|
||||
*
|
||||
* @exception IllegalArgumentException If one input parameter doesn't meet
|
||||
* @throws IllegalArgumentException If one input parameter doesn't meet
|
||||
* its needs.
|
||||
*/
|
||||
public BasicStroke(float width, int cap, int join, float miterlimit)
|
||||
|
@ -139,15 +192,17 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given attributes.
|
||||
* The miter limit defaults to <code>10.0</code>.
|
||||
*
|
||||
* @param width The width of the BasicStroke. May not be nehative.
|
||||
* @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
||||
* @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
||||
* @param width the line width (>= 0.0f).
|
||||
* @param cap the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND} or {@link #CAP_SQUARE}).
|
||||
* @param join the line join style (one of {@link #JOIN_ROUND},
|
||||
* {@link #JOIN_BEVEL}, or {@link #JOIN_MITER}).
|
||||
*
|
||||
* @exception IllegalArgumentException If one input parameter doesn't meet
|
||||
* @throws IllegalArgumentException If one input parameter doesn't meet
|
||||
* its needs.
|
||||
* @exception IllegalArgumentException FIXME
|
||||
*/
|
||||
public BasicStroke(float width, int cap, int join)
|
||||
{
|
||||
|
@ -155,11 +210,17 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
*
|
||||
* @param width The width of the BasicStroke.
|
||||
* Creates a new <code>BasicStroke</code> instance with the given line
|
||||
* width. The default values are:
|
||||
* <ul>
|
||||
* <li>line cap style: {@link #CAP_SQUARE};</li>
|
||||
* <li>line join style: {@link #JOIN_MITER};</li>
|
||||
* <li>miter limit: <code>10.0f</code>.
|
||||
* </ul>
|
||||
*
|
||||
* @exception IllegalArgumentException If width is negative.
|
||||
* @param width the line width (>= 0.0f).
|
||||
*
|
||||
* @throws IllegalArgumentException If <code>width</code> is negative.
|
||||
*/
|
||||
public BasicStroke(float width)
|
||||
{
|
||||
|
@ -167,43 +228,92 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a basic stroke.
|
||||
* Creates a new <code>BasicStroke</code> instance. The default values are:
|
||||
* <ul>
|
||||
* <li>line width: <code>1.0f</code>;</li>
|
||||
* <li>line cap style: {@link #CAP_SQUARE};</li>
|
||||
* <li>line join style: {@link #JOIN_MITER};</li>
|
||||
* <li>miter limit: <code>10.0f</code>.
|
||||
* </ul>
|
||||
*/
|
||||
public BasicStroke()
|
||||
{
|
||||
this(1, CAP_SQUARE, JOIN_MITER, 10, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a shape representing the stroked outline of the given shape.
|
||||
* THIS METHOD IS NOT YET IMPLEMENTED.
|
||||
*
|
||||
* @param s the shape.
|
||||
*/
|
||||
public Shape createStrokedShape(Shape s)
|
||||
{
|
||||
// FIXME: Implement this
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the line width.
|
||||
*
|
||||
* @return The line width.
|
||||
*/
|
||||
public float getLineWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a code indicating the line cap style (one of {@link #CAP_BUTT},
|
||||
* {@link #CAP_ROUND}, {@link #CAP_SQUARE}).
|
||||
*
|
||||
* @return A code indicating the line cap style.
|
||||
*/
|
||||
public int getEndCap()
|
||||
{
|
||||
return cap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a code indicating the line join style (one of {@link #JOIN_BEVEL},
|
||||
* {@link #JOIN_MITER} or {@link #JOIN_ROUND}).
|
||||
*
|
||||
* @return A code indicating the line join style.
|
||||
*/
|
||||
public int getLineJoin()
|
||||
{
|
||||
return join;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the miter limit.
|
||||
*
|
||||
* @return The miter limit.
|
||||
*/
|
||||
public float getMiterLimit()
|
||||
{
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dash array, which defines the length of alternate opaque and
|
||||
* transparent sections in lines drawn with this stroke. If
|
||||
* <code>null</code>, a continuous line will be drawn.
|
||||
*
|
||||
* @return The dash array (possibly <code>null</code>).
|
||||
*/
|
||||
public float[] getDashArray()
|
||||
{
|
||||
return dash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dash phase for the stroke. This is the offset from the start
|
||||
* of a path at which the pattern defined by {@link #getDashArray()} is
|
||||
* rendered.
|
||||
*
|
||||
* @return The dash phase.
|
||||
*/
|
||||
public float getDashPhase()
|
||||
{
|
||||
return phase;
|
||||
|
@ -215,6 +325,8 @@ public class BasicStroke implements Stroke
|
|||
* (converted to <code>int</code> first with
|
||||
* <code>Float.floatToIntBits()</code> if the value is a
|
||||
* <code>float</code>).
|
||||
*
|
||||
* @return The hash code.
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
|
@ -233,9 +345,18 @@ public class BasicStroke implements Stroke
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given Object is an instance of BasicStroke
|
||||
* and the width, cap, join, limit, dash array and phase are all
|
||||
* equal.
|
||||
* Compares this <code>BasicStroke</code> for equality with an arbitrary
|
||||
* object. This method returns <code>true</code> if and only if:
|
||||
* <ul>
|
||||
* <li><code>o</code> is an instanceof <code>BasicStroke</code>;<li>
|
||||
* <li>this object has the same width, line cap style, line join style,
|
||||
* miter limit, dash array and dash phase as <code>o</code>.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param o the object (<code>null</code> permitted).
|
||||
*
|
||||
* @return <code>true</code> if this stroke is equal to <code>o</code> and
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
|
@ -245,4 +366,4 @@ public class BasicStroke implements Stroke
|
|||
return width == s.width && cap == s.cap && join == s.join
|
||||
&& limit == s.limit && Arrays.equals(dash, s.dash) && phase == s.phase;
|
||||
}
|
||||
} // class BasicStroke
|
||||
}
|
||||
|
|
|
@ -460,27 +460,30 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Lays out the specified container according to the constraints
|
||||
* in this object.
|
||||
*
|
||||
* Lays out the specified container according to the constraints in this
|
||||
* object.
|
||||
*
|
||||
* @param target The container to lay out.
|
||||
*/
|
||||
public void layoutContainer(Container target)
|
||||
{
|
||||
synchronized (target.getTreeLock ())
|
||||
synchronized (target.getTreeLock())
|
||||
{
|
||||
Insets i = target.getInsets();
|
||||
int top = i.top;
|
||||
int bottom = target.height - i.bottom;
|
||||
int left = i.left;
|
||||
int right = target.width - i.right;
|
||||
|
||||
ComponentOrientation orient = target.getComponentOrientation ();
|
||||
boolean left_to_right = orient.isLeftToRight ();
|
||||
boolean left_to_right = target.getComponentOrientation().isLeftToRight();
|
||||
|
||||
Component my_north = north;
|
||||
Component my_east = east;
|
||||
Component my_south = south;
|
||||
Component my_west = west;
|
||||
|
||||
// Note that we currently don't handle vertical layouts. Neither
|
||||
// does JDK 1.3.
|
||||
// Note that we currently don't handle vertical layouts.
|
||||
// Neither does JDK 1.3.
|
||||
if (firstLine != null)
|
||||
my_north = firstLine;
|
||||
if (lastLine != null)
|
||||
|
@ -500,65 +503,42 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
my_west = lastItem;
|
||||
}
|
||||
|
||||
Dimension c = calcCompSize(center, PREF);
|
||||
Dimension n = calcCompSize(my_north, PREF);
|
||||
Dimension s = calcCompSize(my_south, PREF);
|
||||
Dimension e = calcCompSize(my_east, PREF);
|
||||
Dimension w = calcCompSize(my_west, PREF);
|
||||
int targetWidth = target.getWidth();
|
||||
int targetHeight = target.getHeight();
|
||||
if (my_north != null)
|
||||
{
|
||||
Dimension n = calcCompSize(my_north, PREF);
|
||||
my_north.setBounds(left, top, right - left, n.height);
|
||||
top += n.height + vgap;
|
||||
}
|
||||
|
||||
/*
|
||||
<-> hgap <-> hgap
|
||||
+----------------------------+ }
|
||||
|t | } i.top
|
||||
| +----------------------+ | --- y1 }
|
||||
| |n | |
|
||||
| +----------------------+ | } vgap
|
||||
| +---+ +----------+ +---+ | --- y2 } }
|
||||
| |w | |c | |e | | } hh
|
||||
| +---+ +----------+ +---+ | } vgap }
|
||||
| +----------------------+ | --- y3 }
|
||||
| |s | |
|
||||
| +----------------------+ | }
|
||||
| | } i.bottom
|
||||
+----------------------------+ }
|
||||
|x1 |x2 |x3
|
||||
<---------------------->
|
||||
<--> ww <-->
|
||||
i.left i.right
|
||||
*/
|
||||
if (my_south != null)
|
||||
{
|
||||
Dimension s = calcCompSize(my_south, PREF);
|
||||
my_south.setBounds(left, bottom - s.height, right - left, s.height);
|
||||
bottom -= s.height + vgap;
|
||||
}
|
||||
|
||||
int x1 = i.left;
|
||||
int x2 = x1 + w.width + (w.width == 0 ? 0 : hgap);
|
||||
int x3;
|
||||
if (targetWidth <= i.right + e.width)
|
||||
x3 = x2 + w.width + (w.width == 0 ? 0 : hgap);
|
||||
else
|
||||
x3 = targetWidth - i.right - e.width;
|
||||
int ww = targetWidth - i.right - i.left;
|
||||
if (my_east != null)
|
||||
{
|
||||
Dimension e = calcCompSize(my_east, PREF);
|
||||
my_east.setBounds(right - e.width, top, e.width, bottom - top);
|
||||
right -= e.width + hgap;
|
||||
}
|
||||
|
||||
int y1 = i.top;
|
||||
int y2 = y1 + n.height + (n.height == 0 ? 0 : vgap);
|
||||
int midh = Math.max(e.height, Math.max(w.height, c.height));
|
||||
int y3;
|
||||
if (targetHeight <= i.bottom + s.height)
|
||||
y3 = y2 + midh + vgap;
|
||||
else
|
||||
y3 = targetHeight - i.bottom - s.height;
|
||||
int hh = y3-y2-(s.height == 0 ? 0 : vgap);
|
||||
if (my_west != null)
|
||||
{
|
||||
Dimension w = calcCompSize(my_west, PREF);
|
||||
my_west.setBounds(left, top, w.width, bottom - top);
|
||||
left += w.width + hgap;
|
||||
}
|
||||
|
||||
setBounds(center, x2, y2, x3-x2-(w.width == 0 ? 0 : hgap), hh);
|
||||
setBounds(my_north, x1, y1, ww, n.height);
|
||||
setBounds(my_south, x1, y3, ww, s.height);
|
||||
setBounds(my_west, x1, y2, w.width, hh);
|
||||
setBounds(my_east, x3, y2, e.width, hh);
|
||||
if (center != null)
|
||||
center.setBounds(left, top, right - left, bottom - top);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this layout manager.
|
||||
*
|
||||
*
|
||||
* @return A string representation of this object.
|
||||
*/
|
||||
public String toString()
|
||||
|
@ -566,20 +546,9 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if (comp == null)
|
||||
return;
|
||||
comp.setBounds(x, y, w, h);
|
||||
}
|
||||
|
||||
private Dimension calcCompSize(Component comp, int what)
|
||||
{
|
||||
if (comp == null || !comp.isVisible())
|
||||
if (comp == null || ! comp.isVisible())
|
||||
return new Dimension(0, 0);
|
||||
if (what == MIN)
|
||||
return comp.getMinimumSize();
|
||||
|
@ -589,12 +558,12 @@ public class BorderLayout implements LayoutManager2, java.io.Serializable
|
|||
}
|
||||
|
||||
/**
|
||||
* This is a helper function used to compute the various sizes for
|
||||
* this layout.
|
||||
* This is a helper function used to compute the various sizes for this
|
||||
* layout.
|
||||
*/
|
||||
private Dimension calcSize(Container target, int what)
|
||||
{
|
||||
synchronized (target.getTreeLock ())
|
||||
synchronized (target.getTreeLock())
|
||||
{
|
||||
Insets ins = target.getInsets();
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
/**
|
||||
* Cause the first component in the container to be displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void first (Container parent)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
/**
|
||||
* Cause the last component in the container to be displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void last (Container parent)
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
* this current card is the last one in the deck, the first
|
||||
* component is displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void next (Container parent)
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
* If this current card is the first one in the deck, the last
|
||||
* component is displayed.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
*/
|
||||
public void previous (Container parent)
|
||||
{
|
||||
|
@ -321,13 +321,19 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
|
||||
/**
|
||||
* Cause the named component to be shown. If the component name is
|
||||
* unknown, this method does nothing.
|
||||
* unknown or <code>null</code>, this method does nothing.
|
||||
*
|
||||
* @param parent The parent container
|
||||
* @param name The name of the component to show
|
||||
* @param parent The parent container, not <code>null</code>.
|
||||
* @param name The name of the component to show
|
||||
*/
|
||||
public void show (Container parent, String name)
|
||||
{
|
||||
if (name == null)
|
||||
return;
|
||||
|
||||
if (parent.getLayout() != this)
|
||||
throw new IllegalArgumentException("parent's layout is not this CardLayout");
|
||||
|
||||
Object target = tab.get (name);
|
||||
if (target != null)
|
||||
{
|
||||
|
@ -362,9 +368,15 @@ public class CardLayout implements LayoutManager2, Serializable
|
|||
*
|
||||
* @param parent The parent container
|
||||
* @param what The type of goto: FIRST, LAST, NEXT or PREV
|
||||
*
|
||||
* @throws IllegalArgumentException if parent has not this
|
||||
* CardLayout set as its layout.
|
||||
*/
|
||||
private void gotoComponent (Container parent, int what)
|
||||
{
|
||||
if (parent.getLayout() != this)
|
||||
throw new IllegalArgumentException("parent's layout is not this CardLayout");
|
||||
|
||||
synchronized (parent.getTreeLock ())
|
||||
{
|
||||
int num = parent.ncomponents;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Checkbox.java -- An AWT checkbox widget
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -459,11 +460,14 @@ getState()
|
|||
public synchronized void
|
||||
setState(boolean state)
|
||||
{
|
||||
this.state = state;
|
||||
if (peer != null)
|
||||
if (this.state != state)
|
||||
{
|
||||
CheckboxPeer cp = (CheckboxPeer) peer;
|
||||
cp.setState (state);
|
||||
this.state = state;
|
||||
if (peer != null)
|
||||
{
|
||||
CheckboxPeer cp = (CheckboxPeer) peer;
|
||||
cp.setState (state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,10 +603,15 @@ void
|
|||
dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
if (e.id <= ItemEvent.ITEM_LAST
|
||||
&& e.id >= ItemEvent.ITEM_FIRST
|
||||
&& (item_listeners != null
|
||||
|| (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
&& e.id >= ItemEvent.ITEM_FIRST)
|
||||
{
|
||||
ItemEvent ie = (ItemEvent) e;
|
||||
int itemState = ie.getStateChange();
|
||||
setState(itemState == ItemEvent.SELECTED ? true : false);
|
||||
if (item_listeners != null
|
||||
|| (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0)
|
||||
processEvent(e);
|
||||
}
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
|
|
@ -468,15 +468,16 @@ getSelectedIndex()
|
|||
public synchronized void
|
||||
select(int index)
|
||||
{
|
||||
if ((index < 0) || (index > getItemCount()))
|
||||
if ((index < 0) || (index >= getItemCount()))
|
||||
throw new IllegalArgumentException("Bad index: " + index);
|
||||
|
||||
this.selectedIndex = index;
|
||||
if (peer != null)
|
||||
{
|
||||
if (pItems.size() > 0) {
|
||||
selectedIndex = index;
|
||||
ChoicePeer cp = (ChoicePeer) peer;
|
||||
cp.select (index);
|
||||
}
|
||||
if (cp != null) {
|
||||
cp.select(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -573,18 +574,6 @@ processItemEvent(ItemEvent event)
|
|||
item_listeners.itemStateChanged(event);
|
||||
}
|
||||
|
||||
void
|
||||
dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
if (e.id <= ItemEvent.ITEM_LAST
|
||||
&& e.id >= ItemEvent.ITEM_FIRST
|
||||
&& (item_listeners != null
|
||||
|| (eventMask & AWTEvent.ITEM_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Component.java -- a graphics component
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006
|
||||
Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -40,6 +41,7 @@ package java.awt;
|
|||
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
|
@ -900,7 +902,7 @@ public abstract class Component
|
|||
// Avoid NullPointerExceptions by creating a local reference.
|
||||
ComponentPeer currentPeer=peer;
|
||||
if (currentPeer != null)
|
||||
currentPeer.setVisible(true);
|
||||
currentPeer.show();
|
||||
|
||||
// The JDK repaints the component before invalidating the parent.
|
||||
// So do we.
|
||||
|
@ -1388,18 +1390,20 @@ public abstract class Component
|
|||
int oldy = this.y;
|
||||
int oldwidth = this.width;
|
||||
int oldheight = this.height;
|
||||
|
||||
if (this.x == x && this.y == y
|
||||
&& this.width == width && this.height == height)
|
||||
|
||||
if (this.x == x && this.y == y && this.width == width
|
||||
&& this.height == height)
|
||||
return;
|
||||
invalidate ();
|
||||
|
||||
invalidate();
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
if (peer != null)
|
||||
peer.setBounds (x, y, width, height);
|
||||
|
||||
|
||||
// Erase old bounds and repaint new bounds for lightweights.
|
||||
if (isLightweight() && isShowing())
|
||||
{
|
||||
|
@ -1598,16 +1602,18 @@ public abstract class Component
|
|||
public Dimension preferredSize()
|
||||
{
|
||||
if (prefSize == null)
|
||||
if (peer == null)
|
||||
return new Dimension(width, height);
|
||||
else
|
||||
prefSize = peer.getPreferredSize();
|
||||
{
|
||||
if (peer == null)
|
||||
prefSize = minimumSize();
|
||||
else
|
||||
prefSize = peer.getPreferredSize();
|
||||
}
|
||||
return prefSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the component's minimum size.
|
||||
*
|
||||
*
|
||||
* @return the component's minimum size
|
||||
* @see #getPreferredSize()
|
||||
* @see LayoutManager
|
||||
|
@ -1882,8 +1888,7 @@ public abstract class Component
|
|||
*/
|
||||
public void repaint()
|
||||
{
|
||||
if (isShowing())
|
||||
repaint(0, 0, 0, width, height);
|
||||
repaint(0, 0, 0, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1897,8 +1902,7 @@ public abstract class Component
|
|||
*/
|
||||
public void repaint(long tm)
|
||||
{
|
||||
if (isShowing())
|
||||
repaint(tm, 0, 0, width, height);
|
||||
repaint(tm, 0, 0, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1915,8 +1919,7 @@ public abstract class Component
|
|||
*/
|
||||
public void repaint(int x, int y, int w, int h)
|
||||
{
|
||||
if (isShowing())
|
||||
repaint(0, x, y, w, h);
|
||||
repaint(0, x, y, w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2308,6 +2311,10 @@ public abstract class Component
|
|||
*/
|
||||
public final void dispatchEvent(AWTEvent e)
|
||||
{
|
||||
Event oldEvent = translateEvent(e);
|
||||
if (oldEvent != null)
|
||||
postEvent (oldEvent);
|
||||
|
||||
// Some subclasses in the AWT package need to override this behavior,
|
||||
// hence the use of dispatchEventImpl().
|
||||
dispatchEventImpl(e);
|
||||
|
@ -3419,10 +3426,11 @@ public abstract class Component
|
|||
}
|
||||
|
||||
/**
|
||||
* Called to inform this component it has been added to a container.
|
||||
* A native peer - if any - is created at this time. This method is
|
||||
* called automatically by the AWT system and should not be called by
|
||||
* user level code.
|
||||
* Called when the parent of this Component is made visible or when
|
||||
* the Component is added to an already visible Container and needs
|
||||
* to be shown. A native peer - if any - is created at this
|
||||
* time. This method is called automatically by the AWT system and
|
||||
* should not be called by user level code.
|
||||
*
|
||||
* @see #isDisplayable()
|
||||
* @see #removeNotify()
|
||||
|
@ -3431,6 +3439,8 @@ public abstract class Component
|
|||
{
|
||||
if (peer == null)
|
||||
peer = getToolkit().createComponent(this);
|
||||
else if (parent != null && parent.isLightweight())
|
||||
new HeavyweightInLightweightListener(parent);
|
||||
/* Now that all the children has gotten their peers, we should
|
||||
have the event mask needed for this component and its
|
||||
lightweight subcomponents. */
|
||||
|
@ -4480,6 +4490,109 @@ p * <li>the set of backward traversal keys
|
|||
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, byte oldValue,
|
||||
byte newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Byte(oldValue),
|
||||
new Byte(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, char oldValue,
|
||||
char newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Character(oldValue),
|
||||
new Character(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, short oldValue,
|
||||
short newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Short(oldValue),
|
||||
new Short(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, long oldValue,
|
||||
long newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Long(oldValue),
|
||||
new Long(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, float oldValue,
|
||||
float newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Float(oldValue),
|
||||
new Float(newValue));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Report a change in a bound property to any registered property listeners.
|
||||
*
|
||||
* @param propertyName the property that changed
|
||||
* @param oldValue the old property value
|
||||
* @param newValue the new property value
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void firePropertyChange(String propertyName, double oldValue,
|
||||
double newValue)
|
||||
{
|
||||
if (changeSupport != null)
|
||||
changeSupport.firePropertyChange(propertyName, new Double(oldValue),
|
||||
new Double(newValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text layout orientation of this component. New components default
|
||||
* to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects only
|
||||
|
@ -4597,7 +4710,7 @@ p * <li>the set of backward traversal keys
|
|||
*/
|
||||
static Event translateEvent (AWTEvent e)
|
||||
{
|
||||
Component target = (Component) e.getSource ();
|
||||
Object target = e.getSource ();
|
||||
Event translated = null;
|
||||
|
||||
if (e instanceof InputEvent)
|
||||
|
@ -4770,6 +4883,25 @@ p * <li>the set of backward traversal keys
|
|||
0, 0, oldKey, oldMods);
|
||||
}
|
||||
}
|
||||
else if (e instanceof AdjustmentEvent)
|
||||
{
|
||||
AdjustmentEvent ae = (AdjustmentEvent) e;
|
||||
int type = ae.getAdjustmentType();
|
||||
int oldType;
|
||||
if (type == AdjustmentEvent.BLOCK_DECREMENT)
|
||||
oldType = Event.SCROLL_PAGE_UP;
|
||||
else if (type == AdjustmentEvent.BLOCK_INCREMENT)
|
||||
oldType = Event.SCROLL_PAGE_DOWN;
|
||||
else if (type == AdjustmentEvent.TRACK)
|
||||
oldType = Event.SCROLL_ABSOLUTE;
|
||||
else if (type == AdjustmentEvent.UNIT_DECREMENT)
|
||||
oldType = Event.SCROLL_LINE_UP;
|
||||
else if (type == AdjustmentEvent.UNIT_INCREMENT)
|
||||
oldType = Event.SCROLL_LINE_DOWN;
|
||||
else
|
||||
oldType = type;
|
||||
translated = new Event(target, oldType, new Integer(ae.getValue()));
|
||||
}
|
||||
else if (e instanceof ActionEvent)
|
||||
translated = new Event (target, Event.ACTION_EVENT,
|
||||
((ActionEvent) e).getActionCommand ());
|
||||
|
@ -4790,16 +4922,16 @@ p * <li>the set of backward traversal keys
|
|||
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
Event oldEvent = translateEvent (e);
|
||||
// Give toolkit a chance to dispatch the event
|
||||
// to globally registered listeners.
|
||||
Toolkit.getDefaultToolkit().globalDispatchEvent(e);
|
||||
|
||||
// This boolean tells us not to process focus events when the focus
|
||||
// opposite component is the same as the focus component.
|
||||
boolean ignoreFocus =
|
||||
(e instanceof FocusEvent &&
|
||||
((FocusEvent)e).getComponent() == ((FocusEvent)e).getOppositeComponent());
|
||||
|
||||
if (oldEvent != null)
|
||||
postEvent (oldEvent);
|
||||
|
||||
if (eventTypeEnabled (e.id))
|
||||
{
|
||||
// the trick we use to communicate between dispatch and redispatch
|
||||
|
@ -4925,16 +5057,6 @@ p * <li>the set of backward traversal keys
|
|||
Rectangle r1 = queuedEvent.getUpdateRect();
|
||||
Rectangle r2 = newEvent.getUpdateRect();
|
||||
Rectangle union = r1.union(r2);
|
||||
|
||||
int r1a = r1.width * r1.height;
|
||||
int r2a = r2.width * r2.height;
|
||||
int ua = union.width * union.height;
|
||||
|
||||
if (ua > (r1a+r2a)*2)
|
||||
return null;
|
||||
/* The 2 factor should maybe be reconsidered. Perhaps 3/2
|
||||
would be better? */
|
||||
|
||||
newEvent.setUpdateRect(union);
|
||||
return newEvent;
|
||||
}
|
||||
|
@ -5014,9 +5136,76 @@ p * <li>the set of backward traversal keys
|
|||
s.writeObject(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Nested classes.
|
||||
|
||||
/**
|
||||
* This class fixes the bounds for a Heavyweight component that
|
||||
* is placed inside a Lightweight container. When the lightweight is
|
||||
* moved or resized, setBounds for the lightweight peer does nothing.
|
||||
* Therefore, it was never moved on the screen. This class is
|
||||
* attached to the lightweight, and it adjusts the position and size
|
||||
* of the peer when notified.
|
||||
* This is the same for show and hide.
|
||||
*/
|
||||
class HeavyweightInLightweightListener
|
||||
implements ComponentListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor. Adds component listener to lightweight parent.
|
||||
*
|
||||
* @param parent - the lightweight container.
|
||||
*/
|
||||
public HeavyweightInLightweightListener(Container parent)
|
||||
{
|
||||
parent.addComponentListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is resized.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the resize
|
||||
*/
|
||||
public void componentResized(ComponentEvent event)
|
||||
{
|
||||
// Nothing to do here, componentMoved will be called.
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is moved.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the move
|
||||
*/
|
||||
public void componentMoved(ComponentEvent event)
|
||||
{
|
||||
if (peer != null)
|
||||
peer.setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is made visible.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the visibility
|
||||
*/
|
||||
public void componentShown(ComponentEvent event)
|
||||
{
|
||||
if (isShowing())
|
||||
peer.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the component is hidden.
|
||||
*
|
||||
* @param event the <code>ComponentEvent</code> indicating the visibility
|
||||
*/
|
||||
public void componentHidden(ComponentEvent event)
|
||||
{
|
||||
if (!isShowing())
|
||||
peer.hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides accessibility support for subclasses of container.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Container.java -- parent container class in AWT
|
||||
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation
|
||||
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -42,12 +43,10 @@ import java.awt.event.ComponentListener;
|
|||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.ContainerListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.peer.ComponentPeer;
|
||||
import java.awt.peer.ContainerPeer;
|
||||
import java.awt.peer.LightweightPeer;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
@ -62,8 +61,6 @@ import java.util.Set;
|
|||
|
||||
import javax.accessibility.Accessible;
|
||||
|
||||
import gnu.java.awt.AWTUtilities;
|
||||
|
||||
/**
|
||||
* A generic window toolkit object that acts as a container for other objects.
|
||||
* Components are tracked in a list, and new elements are at the end of the
|
||||
|
@ -88,10 +85,13 @@ public class Container extends Component
|
|||
Component[] component;
|
||||
LayoutManager layoutMgr;
|
||||
|
||||
LightweightDispatcher dispatcher;
|
||||
|
||||
Dimension maxSize;
|
||||
|
||||
/**
|
||||
* Keeps track if the Container was cleared during a paint/update.
|
||||
*/
|
||||
private boolean backCleared;
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
|
@ -101,7 +101,6 @@ public class Container extends Component
|
|||
|
||||
/* Anything else is non-serializable, and should be declared "transient". */
|
||||
transient ContainerListener containerListener;
|
||||
transient PropertyChangeSupport changeSupport;
|
||||
|
||||
/** The focus traversal policy that determines how focus is
|
||||
transferred between this Container and its children. */
|
||||
|
@ -186,25 +185,6 @@ public class Container extends Component
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps the components at position i and j, in the container.
|
||||
*/
|
||||
|
||||
protected void swapComponents (int i, int j)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
{
|
||||
if (i < 0
|
||||
|| i >= component.length
|
||||
|| j < 0
|
||||
|| j >= component.length)
|
||||
throw new ArrayIndexOutOfBoundsException ();
|
||||
Component tmp = component[i];
|
||||
component[i] = component[j];
|
||||
component[j] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the insets for this container, which is the space used for
|
||||
* borders, the margin, etc.
|
||||
|
@ -385,6 +365,8 @@ public class Container extends Component
|
|||
// Notify the layout manager.
|
||||
if (layoutMgr != null)
|
||||
{
|
||||
// If we have a LayoutManager2 the constraints are "real",
|
||||
// otherwise they are the "name" of the Component to add.
|
||||
if (layoutMgr instanceof LayoutManager2)
|
||||
{
|
||||
LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
|
||||
|
@ -393,7 +375,7 @@ public class Container extends Component
|
|||
else if (constraints instanceof String)
|
||||
layoutMgr.addLayoutComponent((String) constraints, comp);
|
||||
else
|
||||
layoutMgr.addLayoutComponent(null, comp);
|
||||
layoutMgr.addLayoutComponent("", comp);
|
||||
}
|
||||
|
||||
// We previously only sent an event when this container is showing.
|
||||
|
@ -428,8 +410,7 @@ public class Container extends Component
|
|||
for (int j = 0; j < list.length; j++)
|
||||
r.removeComponentListener(list[j]);
|
||||
|
||||
if (r.isShowing())
|
||||
r.removeNotify();
|
||||
r.removeNotify();
|
||||
|
||||
System.arraycopy(component, index + 1, component, index,
|
||||
ncomponents - index - 1);
|
||||
|
@ -777,16 +758,17 @@ public class Container extends Component
|
|||
* a superclass method so that lightweight components are properly
|
||||
* drawn.
|
||||
*
|
||||
* @param g The graphics context for this paint job.
|
||||
* @param g - The graphics context for this paint job.
|
||||
*/
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
if (!isShowing())
|
||||
return;
|
||||
|
||||
// Visit heavyweights as well, in case they were
|
||||
// erased when we cleared the background for this container.
|
||||
visitChildren(g, GfxPaintVisitor.INSTANCE, false);
|
||||
// Visit heavyweights if the background was cleared
|
||||
// for this container.
|
||||
visitChildren(g, GfxPaintVisitor.INSTANCE, !backCleared);
|
||||
backCleared = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -817,8 +799,11 @@ public class Container extends Component
|
|||
// also not cleared. So we do a check on !(peer instanceof LightweightPeer)
|
||||
// instead.
|
||||
ComponentPeer p = peer;
|
||||
if (p != null && !(p instanceof LightweightPeer))
|
||||
g.clearRect(0, 0, getWidth(), getHeight());
|
||||
if (p != null && ! (p instanceof LightweightPeer))
|
||||
{
|
||||
g.clearRect(0, 0, getWidth(), getHeight());
|
||||
backCleared = true;
|
||||
}
|
||||
|
||||
paint(g);
|
||||
}
|
||||
|
@ -1557,28 +1542,105 @@ public class Container extends Component
|
|||
if (orientation == null)
|
||||
throw new NullPointerException ();
|
||||
}
|
||||
|
||||
|
||||
public void addPropertyChangeListener (PropertyChangeListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
|
||||
if (changeSupport == null)
|
||||
changeSupport = new PropertyChangeSupport (this);
|
||||
|
||||
changeSupport.addPropertyChangeListener (listener);
|
||||
// TODO: Why is this overridden?
|
||||
super.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener (String name,
|
||||
|
||||
public void addPropertyChangeListener (String propertyName,
|
||||
PropertyChangeListener listener)
|
||||
{
|
||||
if (listener == null)
|
||||
return;
|
||||
|
||||
if (changeSupport == null)
|
||||
changeSupport = new PropertyChangeSupport (this);
|
||||
// TODO: Why is this overridden?
|
||||
super.addPropertyChangeListener(propertyName, listener);
|
||||
}
|
||||
|
||||
changeSupport.addPropertyChangeListener (name, listener);
|
||||
|
||||
/**
|
||||
* Sets the Z ordering for the component <code>comp</code> to
|
||||
* <code>index</code>. Components with lower Z order paint above components
|
||||
* with higher Z order.
|
||||
*
|
||||
* @param comp the component for which to change the Z ordering
|
||||
* @param index the index to set
|
||||
*
|
||||
* @throws NullPointerException if <code>comp == null</code>
|
||||
* @throws IllegalArgumentException if comp is an ancestor of this container
|
||||
* @throws IllegalArgumentException if <code>index</code> is not in
|
||||
* <code>[0, getComponentCount()]</code> for moving between
|
||||
* containers or <code>[0, getComponentCount() - 1]</code> for moving
|
||||
* inside this container
|
||||
* @throws IllegalArgumentException if <code>comp == this</code>
|
||||
* @throws IllegalArgumentException if <code>comp</code> is a
|
||||
* <code>Window</code>
|
||||
*
|
||||
* @see #getComponentZOrder(Component)
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public final void setComponentZOrder(Component comp, int index)
|
||||
{
|
||||
if (comp == null)
|
||||
throw new NullPointerException("comp must not be null");
|
||||
if (comp instanceof Container && ((Container) comp).isAncestorOf(this))
|
||||
throw new IllegalArgumentException("comp must not be an ancestor of "
|
||||
+ "this");
|
||||
if (comp instanceof Window)
|
||||
throw new IllegalArgumentException("comp must not be a Window");
|
||||
|
||||
if (comp == this)
|
||||
throw new IllegalArgumentException("cannot add component to itself");
|
||||
|
||||
// FIXME: Implement reparenting.
|
||||
if ( comp.getParent() != this)
|
||||
throw new AssertionError("Reparenting is not implemented yet");
|
||||
else
|
||||
{
|
||||
// Find current component index.
|
||||
int currentIndex = getComponentZOrder(comp);
|
||||
if (currentIndex < index)
|
||||
{
|
||||
System.arraycopy(component, currentIndex + 1, component,
|
||||
currentIndex, index - currentIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.arraycopy(component, index, component, index + 1,
|
||||
currentIndex - index);
|
||||
}
|
||||
component[index] = comp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Z ordering index of <code>comp</code>. If <code>comp</code>
|
||||
* is not a child component of this Container, this returns <code>-1</code>.
|
||||
*
|
||||
* @param comp the component for which to query the Z ordering
|
||||
*
|
||||
* @return the Z ordering index of <code>comp</code> or <code>-1</code> if
|
||||
* <code>comp</code> is not a child of this Container
|
||||
*
|
||||
* @see #setComponentZOrder(Component, int)
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public final int getComponentZOrder(Component comp)
|
||||
{
|
||||
int index = -1;
|
||||
if (component != null)
|
||||
{
|
||||
for (int i = 0; i < component.length; i++)
|
||||
{
|
||||
if (component[i] == comp)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
// Hidden helper methods.
|
||||
|
@ -1600,17 +1662,17 @@ public class Container extends Component
|
|||
private void visitChildren(Graphics gfx, GfxVisitor visitor,
|
||||
boolean lightweightOnly)
|
||||
{
|
||||
synchronized (getTreeLock ())
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
for (int i = ncomponents - 1; i >= 0; --i)
|
||||
{
|
||||
Component comp = component[i];
|
||||
boolean applicable = comp.isVisible()
|
||||
&& (comp.isLightweight() || !lightweightOnly);
|
||||
|
||||
&& (comp.isLightweight() || ! lightweightOnly);
|
||||
|
||||
if (applicable)
|
||||
visitChild(gfx, visitor, comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1631,10 +1693,9 @@ public class Container extends Component
|
|||
Component comp)
|
||||
{
|
||||
Rectangle bounds = comp.getBounds();
|
||||
|
||||
|
||||
if(!gfx.hitClip(bounds.x,bounds.y, bounds.width, bounds.height))
|
||||
return;
|
||||
|
||||
Graphics g2 = gfx.create(bounds.x, bounds.y, bounds.width,
|
||||
bounds.height);
|
||||
try
|
||||
|
@ -1649,17 +1710,18 @@ public class Container extends Component
|
|||
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
// Give lightweight dispatcher a chance to handle it.
|
||||
if (dispatcher != null && dispatcher.handleEvent (e))
|
||||
return;
|
||||
|
||||
if ((e.id <= ContainerEvent.CONTAINER_LAST
|
||||
&& e.id >= ContainerEvent.CONTAINER_FIRST)
|
||||
&& (containerListener != null
|
||||
|| (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
boolean dispatched =
|
||||
LightweightDispatcher.getInstance().dispatchEvent(e);
|
||||
if (! dispatched)
|
||||
{
|
||||
if ((e.id <= ContainerEvent.CONTAINER_LAST
|
||||
&& e.id >= ContainerEvent.CONTAINER_FIRST)
|
||||
&& (containerListener != null
|
||||
|| (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1743,15 +1805,6 @@ public class Container extends Component
|
|||
component[i].addNotify();
|
||||
if (component[i].isLightweight ())
|
||||
{
|
||||
|
||||
// If we're not lightweight, and we just got a lightweight
|
||||
// child, we need a lightweight dispatcher to feed it events.
|
||||
if (!this.isLightweight() && dispatcher == null)
|
||||
dispatcher = new LightweightDispatcher (this);
|
||||
|
||||
if (dispatcher != null)
|
||||
dispatcher.enableEvents(component[i].eventMask);
|
||||
|
||||
enableEvents(component[i].eventMask);
|
||||
if (peer != null && !isLightweight ())
|
||||
enableEvents (AWTEvent.PAINT_EVENT_MASK);
|
||||
|
@ -1998,229 +2051,3 @@ public class Container extends Component
|
|||
} // class AccessibleContainerHandler
|
||||
} // class AccessibleAWTContainer
|
||||
} // class Container
|
||||
|
||||
/**
|
||||
* There is a helper class implied from stack traces called
|
||||
* LightweightDispatcher, but since it is not part of the public API,
|
||||
* rather than mimic it exactly we write something which does "roughly
|
||||
* the same thing".
|
||||
*/
|
||||
class LightweightDispatcher implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 5184291520170872969L;
|
||||
private Container nativeContainer;
|
||||
private Cursor nativeCursor;
|
||||
private long eventMask;
|
||||
|
||||
private transient Component pressedComponent;
|
||||
private transient Component lastComponentEntered;
|
||||
private transient int pressCount;
|
||||
|
||||
LightweightDispatcher(Container c)
|
||||
{
|
||||
nativeContainer = c;
|
||||
}
|
||||
|
||||
void enableEvents(long l)
|
||||
{
|
||||
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 ();
|
||||
int y = me.getY ();
|
||||
|
||||
Component mouseEventTarget = null;
|
||||
// Find the candidate which should receive this event.
|
||||
Component parent = nativeContainer;
|
||||
Component candidate = null;
|
||||
Point p = me.getPoint();
|
||||
while (candidate == null && parent != null)
|
||||
{
|
||||
candidate = getDeepestComponentForMouseEventAt(parent, p.x, p.y);
|
||||
if (candidate == null || (candidate.eventMask & me.getID()) == 0)
|
||||
{
|
||||
candidate = null;
|
||||
p = AWTUtilities.convertPoint(parent, p.x, p.y, parent.parent);
|
||||
parent = parent.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// If the only candidate we found was the native container itself,
|
||||
// don't dispatch any event at all. We only care about the lightweight
|
||||
// children here.
|
||||
if (candidate == nativeContainer)
|
||||
candidate = null;
|
||||
|
||||
// If our candidate is new, inform the old target we're leaving.
|
||||
if (lastComponentEntered != null
|
||||
&& lastComponentEntered.isShowing()
|
||||
&& lastComponentEntered != candidate)
|
||||
{
|
||||
// Old candidate could have been removed from
|
||||
// the nativeContainer so we check first.
|
||||
if (AWTUtilities.isDescendingFrom(lastComponentEntered,
|
||||
nativeContainer))
|
||||
{
|
||||
Point tp = AWTUtilities.convertPoint(nativeContainer,
|
||||
x, y, lastComponentEntered);
|
||||
MouseEvent exited = new MouseEvent (lastComponentEntered,
|
||||
MouseEvent.MOUSE_EXITED,
|
||||
me.getWhen (),
|
||||
me.getModifiersEx (),
|
||||
tp.x, tp.y,
|
||||
me.getClickCount (),
|
||||
me.isPopupTrigger (),
|
||||
me.getButton ());
|
||||
lastComponentEntered.dispatchEvent (exited);
|
||||
}
|
||||
lastComponentEntered = null;
|
||||
}
|
||||
|
||||
// If we have a candidate, maybe enter it.
|
||||
if (candidate != null)
|
||||
{
|
||||
mouseEventTarget = candidate;
|
||||
if (candidate.isLightweight()
|
||||
&& candidate.isShowing()
|
||||
&& candidate != nativeContainer
|
||||
&& candidate != lastComponentEntered)
|
||||
{
|
||||
lastComponentEntered = mouseEventTarget;
|
||||
Point cp = AWTUtilities.convertPoint(nativeContainer,
|
||||
x, y, lastComponentEntered);
|
||||
MouseEvent entered = new MouseEvent (lastComponentEntered,
|
||||
MouseEvent.MOUSE_ENTERED,
|
||||
me.getWhen (),
|
||||
me.getModifiersEx (),
|
||||
cp.x, cp.y,
|
||||
me.getClickCount (),
|
||||
me.isPopupTrigger (),
|
||||
me.getButton ());
|
||||
lastComponentEntered.dispatchEvent (entered);
|
||||
}
|
||||
}
|
||||
|
||||
// Check which buttons where pressed except the last button that
|
||||
// changed state.
|
||||
int modifiers = me.getModifiersEx() & (MouseEvent.BUTTON1_DOWN_MASK
|
||||
| MouseEvent.BUTTON2_DOWN_MASK
|
||||
| MouseEvent.BUTTON3_DOWN_MASK);
|
||||
switch(me.getButton())
|
||||
{
|
||||
case MouseEvent.BUTTON1:
|
||||
modifiers &= ~MouseEvent.BUTTON1_DOWN_MASK;
|
||||
break;
|
||||
case MouseEvent.BUTTON2:
|
||||
modifiers &= ~MouseEvent.BUTTON2_DOWN_MASK;
|
||||
break;
|
||||
case MouseEvent.BUTTON3:
|
||||
modifiers &= ~MouseEvent.BUTTON3_DOWN_MASK;
|
||||
break;
|
||||
}
|
||||
|
||||
if (me.getID() == MouseEvent.MOUSE_RELEASED
|
||||
|| me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0
|
||||
|| me.getID() == MouseEvent.MOUSE_DRAGGED)
|
||||
{
|
||||
// If any of the following events occur while a button is held down,
|
||||
// they should be dispatched to the same component to which the
|
||||
// original MOUSE_PRESSED event was dispatched:
|
||||
// - MOUSE_RELEASED: This is important for correct dragging
|
||||
// behaviour, otherwise the release goes to an arbitrary component
|
||||
// outside of the dragged component. OTOH, if there is no mouse
|
||||
// drag while the mouse is pressed, the component under the mouse
|
||||
// is the same as the previously pressed component anyway.
|
||||
// - MOUSE_PRESSED: another button pressed while the first is held
|
||||
// down
|
||||
// - MOUSE_DRAGGED
|
||||
if (AWTUtilities.isDescendingFrom(pressedComponent, nativeContainer))
|
||||
mouseEventTarget = pressedComponent;
|
||||
}
|
||||
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
|
||||
{
|
||||
// Don't dispatch CLICKED events whose target is not the same as the
|
||||
// target for the original PRESSED event.
|
||||
if (candidate != pressedComponent)
|
||||
{
|
||||
mouseEventTarget = null;
|
||||
pressCount = 0;
|
||||
}
|
||||
else if (pressCount == 0)
|
||||
pressedComponent = null;
|
||||
}
|
||||
return mouseEventTarget;
|
||||
}
|
||||
|
||||
boolean handleEvent(AWTEvent e)
|
||||
{
|
||||
if (e instanceof MouseEvent)
|
||||
{
|
||||
MouseEvent me = (MouseEvent) e;
|
||||
|
||||
// Make the LightWeightDispatcher reentrant. This is necessary when
|
||||
// a lightweight component does its own modal event queue.
|
||||
Component mouseEventTarget = acquireComponentForMouseEvent(me);
|
||||
|
||||
// Avoid dispatching ENTERED and EXITED events twice.
|
||||
if (mouseEventTarget != null
|
||||
&& mouseEventTarget.isShowing()
|
||||
&& e.getID() != MouseEvent.MOUSE_ENTERED
|
||||
&& e.getID() != MouseEvent.MOUSE_EXITED)
|
||||
{
|
||||
switch (e.getID())
|
||||
{
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
if (pressCount++ == 0)
|
||||
pressedComponent = mouseEventTarget;
|
||||
break;
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
// Clear our memory of the original PRESSED event, only if
|
||||
// we're not expecting a CLICKED event after this. If
|
||||
// there is a CLICKED event after this, it will do clean up.
|
||||
if (--pressCount == 0
|
||||
&& mouseEventTarget != pressedComponent)
|
||||
{
|
||||
pressedComponent = null;
|
||||
pressCount = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
MouseEvent newEvt =
|
||||
AWTUtilities.convertMouseEvent(nativeContainer, me,
|
||||
mouseEventTarget);
|
||||
mouseEventTarget.dispatchEvent(newEvt);
|
||||
|
||||
if (newEvt.isConsumed())
|
||||
e.consume();
|
||||
}
|
||||
}
|
||||
|
||||
return e.isConsumed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,6 +219,8 @@ public class Cursor implements java.io.Serializable
|
|||
|
||||
public String toString()
|
||||
{
|
||||
return (this.getClass() + "[" + getName() + "]");
|
||||
return (this.getClass()
|
||||
+ "[type=" + getType()
|
||||
+ ",name=" + getName() + "]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Frame.java -- AWT toplevel window
|
||||
Copyright (C) 1999, 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -57,143 +58,156 @@ import javax.accessibility.AccessibleStateSet;
|
|||
*/
|
||||
public class Frame extends Window implements MenuContainer
|
||||
{
|
||||
/**
|
||||
* Constant for the default cursor.
|
||||
* @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cross-hair cursor.
|
||||
* @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
|
||||
/**
|
||||
* Constant for the default cursor.
|
||||
*
|
||||
* @deprecated Replaced by <code>Cursor.DEFAULT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int DEFAULT_CURSOR = Cursor.DEFAULT_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cursor over a text field.
|
||||
* @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
|
||||
/**
|
||||
* Constant for a cross-hair cursor.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.CROSSHAIR_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int CROSSHAIR_CURSOR = Cursor.CROSSHAIR_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cursor to display while waiting for an action to complete.
|
||||
* @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
|
||||
*/
|
||||
public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
|
||||
/**
|
||||
* Constant for a cursor over a text field.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.TEXT_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int TEXT_CURSOR = Cursor.TEXT_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over SW corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
|
||||
/**
|
||||
* Constant for a cursor to display while waiting for an action to complete.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.WAIT_CURSOR</code>.
|
||||
*/
|
||||
public static final int WAIT_CURSOR = Cursor.WAIT_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over SE corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over SW corner of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.SW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SW_RESIZE_CURSOR = Cursor.SW_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over NW corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over SE corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.SE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int SE_RESIZE_CURSOR = Cursor.SE_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over NE corner of window decorations.
|
||||
* @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over NW corner of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.NW_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NW_RESIZE_CURSOR = Cursor.NW_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over N edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over NE corner of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.NE_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int NE_RESIZE_CURSOR = Cursor.NE_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over S edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over N edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.N_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int N_RESIZE_CURSOR = Cursor.N_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over E edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over S edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.S_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int S_RESIZE_CURSOR = Cursor.S_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Cursor used over W edge of window decorations.
|
||||
* @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
|
||||
/**
|
||||
* Cursor used over E edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.E_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int E_RESIZE_CURSOR = Cursor.E_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a hand cursor.
|
||||
* @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
|
||||
/**
|
||||
* Cursor used over W edge of window decorations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.W_RESIZE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int W_RESIZE_CURSOR = Cursor.W_RESIZE_CURSOR;
|
||||
|
||||
/**
|
||||
* Constant for a cursor used during window move operations.
|
||||
* @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
|
||||
/**
|
||||
* Constant for a hand cursor.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.HAND_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int HAND_CURSOR = Cursor.HAND_CURSOR;
|
||||
|
||||
public static final int ICONIFIED = 1;
|
||||
public static final int MAXIMIZED_BOTH = 6;
|
||||
public static final int MAXIMIZED_HORIZ = 2;
|
||||
public static final int MAXIMIZED_VERT = 4;
|
||||
public static final int NORMAL = 0;
|
||||
/**
|
||||
* Constant for a cursor used during window move operations.
|
||||
*
|
||||
* @deprecated Use <code>Cursor.MOVE_CURSOR</code> instead.
|
||||
*/
|
||||
public static final int MOVE_CURSOR = Cursor.MOVE_CURSOR;
|
||||
|
||||
// Serialization version constant
|
||||
private static final long serialVersionUID = 2673458971256075116L;
|
||||
public static final int ICONIFIED = 1;
|
||||
public static final int MAXIMIZED_BOTH = 6;
|
||||
public static final int MAXIMIZED_HORIZ = 2;
|
||||
public static final int MAXIMIZED_VERT = 4;
|
||||
public static final int NORMAL = 0;
|
||||
|
||||
/**
|
||||
* @serial The version of the class data being serialized
|
||||
* // FIXME: what is this value?
|
||||
*/
|
||||
private int frameSerializedDataVersion;
|
||||
//Serialization version constant
|
||||
private static final long serialVersionUID = 2673458971256075116L;
|
||||
|
||||
/**
|
||||
* @serial Image used as the icon when this frame is minimized.
|
||||
*/
|
||||
private Image icon;
|
||||
/**
|
||||
* @serial The version of the class data being serialized
|
||||
* FIXME: what is this value?
|
||||
*/
|
||||
private int frameSerializedDataVersion;
|
||||
|
||||
/**
|
||||
* @serial Constant used by the JDK Motif peer set. Not used in
|
||||
* this implementation.
|
||||
*/
|
||||
private boolean mbManagement;
|
||||
/**
|
||||
* @serial Image used as the icon when this frame is minimized.
|
||||
*/
|
||||
private Image icon;
|
||||
|
||||
/**
|
||||
* @serial The menu bar for this frame.
|
||||
*/
|
||||
//private MenuBar menuBar = new MenuBar();
|
||||
private MenuBar menuBar;
|
||||
/**
|
||||
* @serial Constant used by the JDK Motif peer set. Not used in
|
||||
* this implementation.
|
||||
*/
|
||||
private boolean mbManagement;
|
||||
|
||||
/**
|
||||
* @serial A list of other top-level windows owned by this window.
|
||||
*/
|
||||
Vector ownedWindows = new Vector();
|
||||
/**
|
||||
* @serial The menu bar for this frame.
|
||||
*/
|
||||
private MenuBar menuBar;
|
||||
|
||||
/**
|
||||
* @serial Indicates whether or not this frame is resizable.
|
||||
*/
|
||||
private boolean resizable = true;
|
||||
/**
|
||||
* @serial A list of other top-level windows owned by this window.
|
||||
*/
|
||||
Vector ownedWindows = new Vector();
|
||||
|
||||
/**
|
||||
* @serial The state of this frame.
|
||||
* // FIXME: What are the values here?
|
||||
* This is package-private to avoid an accessor method.
|
||||
*/
|
||||
int state;
|
||||
/**
|
||||
* @serial Indicates whether or not this frame is resizable.
|
||||
*/
|
||||
private boolean resizable = true;
|
||||
|
||||
/**
|
||||
* @serial The title of the frame.
|
||||
*/
|
||||
private String title = "";
|
||||
/**
|
||||
* @serial The state of this frame.
|
||||
* // FIXME: What are the values here?
|
||||
* This is package-private to avoid an accessor method.
|
||||
*/
|
||||
int state;
|
||||
|
||||
/**
|
||||
* @serial The title of the frame.
|
||||
*/
|
||||
private String title = "";
|
||||
|
||||
/**
|
||||
* Maximized bounds for this frame.
|
||||
|
@ -210,223 +224,235 @@ private String title = "";
|
|||
*/
|
||||
private static transient long next_frame_number;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has no title.
|
||||
*/
|
||||
public
|
||||
Frame()
|
||||
{
|
||||
this("");
|
||||
noteFrame(this);
|
||||
}
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has no title.
|
||||
*/
|
||||
public Frame()
|
||||
{
|
||||
this("");
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has the specified title.
|
||||
*
|
||||
* @param title The title of this frame.
|
||||
*/
|
||||
public
|
||||
Frame(String title)
|
||||
{
|
||||
super();
|
||||
this.title = title;
|
||||
// Top-level frames are initially invisible.
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
/**
|
||||
* Initializes a new instance of <code>Frame</code> that is not visible
|
||||
* and has the specified title.
|
||||
*
|
||||
* @param title the title of this frame
|
||||
*/
|
||||
public Frame(String title)
|
||||
{
|
||||
super();
|
||||
this.title = title;
|
||||
// Top-level frames are initially invisible.
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
public
|
||||
Frame(GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
public Frame(GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
public
|
||||
Frame(String title, GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
setTitle(title);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
public Frame(String title, GraphicsConfiguration gc)
|
||||
{
|
||||
super(gc);
|
||||
setTitle(title);
|
||||
visible = false;
|
||||
noteFrame(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this frame's title string.
|
||||
*
|
||||
* @return This frame's title string.
|
||||
*/
|
||||
public String
|
||||
getTitle()
|
||||
{
|
||||
return(title);
|
||||
}
|
||||
/**
|
||||
* Returns this frame's title string.
|
||||
*
|
||||
* @return this frame's title string
|
||||
*/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets this frame's title to the specified value.
|
||||
*
|
||||
* @param title The new frame title.
|
||||
*/
|
||||
public synchronized void
|
||||
setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setTitle(title);
|
||||
}
|
||||
/**
|
||||
* Sets this frame's title to the specified value.
|
||||
*
|
||||
* @param title the new frame title
|
||||
*/
|
||||
public synchronized void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setTitle(title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this frame's icon.
|
||||
*
|
||||
* @return This frame's icon, or <code>null</code> if this frame does not
|
||||
* have an icon.
|
||||
*/
|
||||
public Image
|
||||
getIconImage()
|
||||
{
|
||||
return(icon);
|
||||
}
|
||||
/**
|
||||
* Returns this frame's icon.
|
||||
*
|
||||
* @return this frame's icon, or <code>null</code> if this frame does not
|
||||
* have an icon
|
||||
*/
|
||||
public Image getIconImage()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this frame's icon to the specified value.
|
||||
*
|
||||
* @icon The new icon for this frame.
|
||||
*/
|
||||
public synchronized void
|
||||
setIconImage(Image icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setIconImage(icon);
|
||||
}
|
||||
/**
|
||||
* Sets this frame's icon to the specified value.
|
||||
*
|
||||
* @icon the new icon for this frame
|
||||
*/
|
||||
public synchronized void setIconImage(Image icon)
|
||||
{
|
||||
this.icon = icon;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setIconImage(icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this frame's menu bar.
|
||||
*
|
||||
* @return This frame's menu bar, or <code>null</code> if this frame
|
||||
* does not have a menu bar.
|
||||
*/
|
||||
public MenuBar
|
||||
getMenuBar()
|
||||
{
|
||||
return(menuBar);
|
||||
}
|
||||
/**
|
||||
* Returns this frame's menu bar.
|
||||
*
|
||||
* @return this frame's menu bar, or <code>null</code> if this frame
|
||||
* does not have a menu bar
|
||||
*/
|
||||
public MenuBar getMenuBar()
|
||||
{
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this frame's menu bar.
|
||||
*
|
||||
* @param menuBar The new menu bar for this frame.
|
||||
*/
|
||||
public synchronized void
|
||||
setMenuBar(MenuBar menuBar)
|
||||
{
|
||||
if (peer != null)
|
||||
/**
|
||||
* Sets this frame's menu bar. Removes any existing menu bar. If the
|
||||
* given menu bar is part of another frame it will be removed from
|
||||
* that frame.
|
||||
*
|
||||
* @param menuBar the new menu bar for this frame
|
||||
*/
|
||||
public synchronized void setMenuBar(MenuBar menuBar)
|
||||
{
|
||||
if (this.menuBar != null)
|
||||
this.menuBar.removeNotify();
|
||||
remove(this.menuBar);
|
||||
|
||||
this.menuBar = menuBar;
|
||||
if (menuBar != null)
|
||||
{
|
||||
MenuContainer parent = menuBar.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(menuBar);
|
||||
menuBar.setParent(this);
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.addNotify();
|
||||
invalidateTree();
|
||||
((FramePeer) peer).setMenuBar(menuBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not this frame is resizable. This will be
|
||||
* <code>true</code> by default.
|
||||
*
|
||||
* @return <code>true</code> if this frame is resizable, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
public boolean isResizable()
|
||||
{
|
||||
return resizable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resizability of this frame to the specified value.
|
||||
*
|
||||
* @param resizable <code>true</code> to make the frame resizable,
|
||||
* <code>false</code> to make it non-resizable
|
||||
*/
|
||||
public synchronized void setResizable(boolean resizable)
|
||||
{
|
||||
this.resizable = resizable;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setResizable(resizable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cursor type of the cursor for this window. This will
|
||||
* be one of the constants in this class.
|
||||
*
|
||||
* @return the cursor type for this frame
|
||||
*
|
||||
* @deprecated Use <code>Component.getCursor()</code> instead.
|
||||
*/
|
||||
public int getCursorType()
|
||||
{
|
||||
return getCursor().getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor for this window to the specified type. The specified
|
||||
* type should be one of the constants in this class.
|
||||
*
|
||||
* @param type the cursor type
|
||||
*
|
||||
* @deprecated Use <code>Component.setCursor(Cursor)</code> instead.
|
||||
*/
|
||||
public void setCursor(int type)
|
||||
{
|
||||
setCursor(new Cursor(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified menu component from this frame. If it is
|
||||
* the current MenuBar it is removed from the frame. If it is a
|
||||
* Popup it is removed from this component. If it is any other menu
|
||||
* component it is ignored.
|
||||
*
|
||||
* @param menu the menu component to remove
|
||||
*/
|
||||
public void remove(MenuComponent menu)
|
||||
{
|
||||
if (menu == menuBar)
|
||||
{
|
||||
if (menuBar != null)
|
||||
{
|
||||
if (peer != null)
|
||||
{
|
||||
((FramePeer) peer).setMenuBar(null);
|
||||
menuBar.removeNotify();
|
||||
}
|
||||
menuBar.setParent(null);
|
||||
}
|
||||
menuBar = null;
|
||||
}
|
||||
else
|
||||
super.remove(menu);
|
||||
}
|
||||
|
||||
public void addNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.addNotify();
|
||||
invalidateTree ();
|
||||
((FramePeer) peer).setMenuBar(menuBar);
|
||||
if (peer == null)
|
||||
peer = getToolkit ().createFrame (this);
|
||||
|
||||
super.addNotify();
|
||||
}
|
||||
this.menuBar = menuBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not this frame is resizable. This will be
|
||||
* <code>true</code> by default.
|
||||
*
|
||||
* @return <code>true</code> if this frame is resizable, <code>false</code>
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean
|
||||
isResizable()
|
||||
{
|
||||
return(resizable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resizability of this frame to the specified value.
|
||||
*
|
||||
* @param resizable <code>true</code> to make the frame resizable,
|
||||
* <code>false</code> to make it non-resizable.
|
||||
*/
|
||||
public synchronized void
|
||||
setResizable(boolean resizable)
|
||||
{
|
||||
this.resizable = resizable;
|
||||
if (peer != null)
|
||||
((FramePeer) peer).setResizable(resizable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cursor type of the cursor for this window. This will
|
||||
* be one of the constants in this class.
|
||||
*
|
||||
* @return The cursor type for this frame.
|
||||
*
|
||||
* @deprecated Use <code>Component.getCursor()</code> instead.
|
||||
*/
|
||||
public int
|
||||
getCursorType()
|
||||
{
|
||||
return(getCursor().getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cursor for this window to the specified type. The specified
|
||||
* type should be one of the constants in this class.
|
||||
*
|
||||
* @param type The cursor type.
|
||||
*
|
||||
* @deprecated Use <code>Component.setCursor(Cursor)</code> instead.
|
||||
*/
|
||||
public void
|
||||
setCursor(int type)
|
||||
{
|
||||
setCursor(new Cursor(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified component from this frame's menu.
|
||||
*
|
||||
* @param menu The menu component to remove.
|
||||
*/
|
||||
public void
|
||||
remove(MenuComponent menu)
|
||||
{
|
||||
menuBar.remove(menu);
|
||||
}
|
||||
|
||||
public void
|
||||
addNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.addNotify();
|
||||
if (peer == null)
|
||||
peer = getToolkit ().createFrame (this);
|
||||
|
||||
super.addNotify();
|
||||
}
|
||||
|
||||
public void removeNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.removeNotify();
|
||||
super.removeNotify();
|
||||
}
|
||||
public void removeNotify()
|
||||
{
|
||||
if (menuBar != null)
|
||||
menuBar.removeNotify();
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a debugging string describing this window.
|
||||
*
|
||||
* @return A debugging string describing this window.
|
||||
* @return a debugging string describing this window
|
||||
*/
|
||||
protected String paramString ()
|
||||
protected String paramString()
|
||||
{
|
||||
String title = getTitle ();
|
||||
String title = getTitle();
|
||||
|
||||
String resizable = "";
|
||||
if (isResizable ())
|
||||
|
@ -455,17 +481,17 @@ public void removeNotify()
|
|||
return super.paramString () + ",title=" + title + resizable + state;
|
||||
}
|
||||
|
||||
private static ArrayList weakFrames = new ArrayList();
|
||||
private static ArrayList weakFrames = new ArrayList();
|
||||
|
||||
private static void noteFrame(Frame f)
|
||||
{
|
||||
weakFrames.add(new WeakReference(f));
|
||||
}
|
||||
private static void noteFrame(Frame f)
|
||||
{
|
||||
weakFrames.add(new WeakReference(f));
|
||||
}
|
||||
|
||||
public static Frame[] getFrames()
|
||||
{
|
||||
int n = 0;
|
||||
synchronized (weakFrames)
|
||||
public static Frame[] getFrames()
|
||||
{
|
||||
int n = 0;
|
||||
synchronized (weakFrames)
|
||||
{
|
||||
Iterator i = weakFrames.iterator();
|
||||
while (i.hasNext())
|
||||
|
@ -490,32 +516,31 @@ public static Frame[] getFrames()
|
|||
return frames;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setState (int state)
|
||||
public void setState(int state)
|
||||
{
|
||||
int current_state = getExtendedState ();
|
||||
|
||||
if (state == NORMAL
|
||||
&& (current_state & ICONIFIED) != 0)
|
||||
setExtendedState (current_state | ICONIFIED);
|
||||
setExtendedState(current_state | ICONIFIED);
|
||||
|
||||
if (state == ICONIFIED
|
||||
&& (current_state & ~ICONIFIED) == 0)
|
||||
setExtendedState (current_state & ~ICONIFIED);
|
||||
setExtendedState(current_state & ~ICONIFIED);
|
||||
}
|
||||
|
||||
public int getState ()
|
||||
public int getState()
|
||||
{
|
||||
/* FIXME: State might have changed in the peer... Must check. */
|
||||
|
||||
// FIXME: State might have changed in the peer... Must check.
|
||||
return (state & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public void setExtendedState (int state)
|
||||
public void setExtendedState(int state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
@ -523,7 +548,7 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public int getExtendedState ()
|
||||
public int getExtendedState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
@ -531,7 +556,7 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* @since 1.4
|
||||
*/
|
||||
public void setMaximizedBounds (Rectangle maximizedBounds)
|
||||
public void setMaximizedBounds(Rectangle maximizedBounds)
|
||||
{
|
||||
this.maximizedBounds = maximizedBounds;
|
||||
}
|
||||
|
@ -539,11 +564,11 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* Returns the maximized bounds of this frame.
|
||||
*
|
||||
* @return the maximized rectangle, may be null.
|
||||
* @return the maximized rectangle, may be null
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public Rectangle getMaximizedBounds ()
|
||||
public Rectangle getMaximizedBounds()
|
||||
{
|
||||
return maximizedBounds;
|
||||
}
|
||||
|
@ -553,7 +578,7 @@ public static Frame[] getFrames()
|
|||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public boolean isUndecorated ()
|
||||
public boolean isUndecorated()
|
||||
{
|
||||
return undecorated;
|
||||
}
|
||||
|
@ -562,14 +587,14 @@ public static Frame[] getFrames()
|
|||
* Disables or enables decorations for this frame. This method can only be
|
||||
* called while the frame is not displayable.
|
||||
*
|
||||
* @exception IllegalComponentStateException If this frame is displayable.
|
||||
* @throws IllegalComponentStateException if this frame is displayable
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public void setUndecorated (boolean undecorated)
|
||||
public void setUndecorated(boolean undecorated)
|
||||
{
|
||||
if (isDisplayable ())
|
||||
throw new IllegalComponentStateException ();
|
||||
if (isDisplayable())
|
||||
throw new IllegalComponentStateException();
|
||||
|
||||
this.undecorated = undecorated;
|
||||
}
|
||||
|
@ -577,14 +602,14 @@ public static Frame[] getFrames()
|
|||
/**
|
||||
* Generate a unique name for this frame.
|
||||
*
|
||||
* @return A unique name for this frame.
|
||||
* @return a unique name for this frame
|
||||
*/
|
||||
String generateName ()
|
||||
String generateName()
|
||||
{
|
||||
return "frame" + getUniqueLong ();
|
||||
return "frame" + getUniqueLong();
|
||||
}
|
||||
|
||||
private static synchronized long getUniqueLong ()
|
||||
private static synchronized long getUniqueLong()
|
||||
{
|
||||
return next_frame_number++;
|
||||
}
|
||||
|
@ -617,10 +642,9 @@ public static Frame[] getFrames()
|
|||
*/
|
||||
public AccessibleContext getAccessibleContext()
|
||||
{
|
||||
/* Create the context if this is the first request */
|
||||
// Create the context if this is the first request.
|
||||
if (accessibleContext == null)
|
||||
accessibleContext = new AccessibleAWTFrame();
|
||||
return accessibleContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -99,12 +99,32 @@ public class Insets implements Cloneable, Serializable
|
|||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the contents of this Insets object to the specified values.
|
||||
*
|
||||
* @param top the top inset
|
||||
* @param left the left inset
|
||||
* @param bottom the bottom inset
|
||||
* @param right the right inset
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void set(int top, int left, int bottom, int right)
|
||||
{
|
||||
this.top = top;
|
||||
this.left = left;
|
||||
this.bottom = bottom;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether this object is equal to the specified object. The other
|
||||
* object must be an instance of Insets with identical field values.
|
||||
*
|
||||
* @param obj the object to test against
|
||||
* @return true if the specified object is equal to this one
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
|
200
libjava/classpath/java/awt/LightweightDispatcher.java
Normal file
200
libjava/classpath/java/awt/LightweightDispatcher.java
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* LightweightDispatcher.java -- Dispatches mouse events to lightweights
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package java.awt;
|
||||
|
||||
import gnu.java.awt.AWTUtilities;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* Redispatches mouse events to lightweight components. The native peers know
|
||||
* nothing about the lightweight components and thus mouse events are always
|
||||
* targetted at Windows or heavyweight components. This class listenes directly
|
||||
* on the eventqueue and dispatches mouse events to lightweight components.
|
||||
*
|
||||
* @author Roman Kennke (kennke@aicas.com)
|
||||
*/
|
||||
class LightweightDispatcher
|
||||
{
|
||||
|
||||
/**
|
||||
* Maps thread groups to lightweight dispatcher instances. We need to
|
||||
* have one instance per thread group so that 2 or more applets or otherwise
|
||||
* separated applications (like in OSGI) do not interfer with each other.
|
||||
*/
|
||||
private static WeakHashMap instances = new WeakHashMap();
|
||||
|
||||
/**
|
||||
* The component that is the start of a mouse dragging. All MOUSE_DRAGGED
|
||||
* events that follow the initial press must have the source set to this,
|
||||
* as well as the MOUSE_RELEASED event following the dragging.
|
||||
*/
|
||||
private Component dragTarget;
|
||||
|
||||
/**
|
||||
* The last mouse event target. If the target changes, additional
|
||||
* MOUSE_ENTERED and MOUSE_EXITED events must be dispatched.
|
||||
*/
|
||||
private Component lastTarget;
|
||||
|
||||
/**
|
||||
* Returns an instance of LightweightDispatcher for the current thread's
|
||||
* thread group.
|
||||
*
|
||||
* @return an instance of LightweightDispatcher for the current thread's
|
||||
* thread group
|
||||
*/
|
||||
static LightweightDispatcher getInstance()
|
||||
{
|
||||
Thread t = Thread.currentThread();
|
||||
ThreadGroup tg = t.getThreadGroup();
|
||||
LightweightDispatcher instance = (LightweightDispatcher) instances.get(tg);
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new LightweightDispatcher();
|
||||
instances.put(tg, instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new LightweightDispatcher. This is private to prevent access
|
||||
* from outside. Use {@link #getInstance()} instead.
|
||||
*/
|
||||
private LightweightDispatcher()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives notification if a mouse event passes along the eventqueue.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
public boolean dispatchEvent(AWTEvent event)
|
||||
{
|
||||
boolean dispatched = false;
|
||||
if (event instanceof MouseEvent && event.getSource() instanceof Window)
|
||||
{
|
||||
MouseEvent mouseEvent = (MouseEvent) event;
|
||||
handleMouseEvent(mouseEvent);
|
||||
dispatched = true;
|
||||
}
|
||||
return dispatched;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles all mouse events that are targetted at toplevel containers
|
||||
* (Window instances) and dispatches them to the correct lightweight child.
|
||||
*
|
||||
* @param ev the mouse event
|
||||
*/
|
||||
private void handleMouseEvent(MouseEvent ev)
|
||||
{
|
||||
Window window = (Window) ev.getSource();
|
||||
Component target = window.findComponentAt(ev.getX(), ev.getY());
|
||||
if (target != null && target.isLightweight())
|
||||
{
|
||||
// Dispatch additional MOUSE_EXITED and MOUSE_ENTERED if event target
|
||||
// is different from the last event target.
|
||||
if (target != lastTarget)
|
||||
{
|
||||
if (lastTarget != null)
|
||||
{
|
||||
Point p1 = AWTUtilities.convertPoint(window, ev.getX(),
|
||||
ev.getY(), lastTarget);
|
||||
MouseEvent mouseExited =
|
||||
new MouseEvent(lastTarget, MouseEvent.MOUSE_EXITED,
|
||||
ev.getWhen(), ev.getModifiers(), p1.x, p1.y,
|
||||
ev.getClickCount(), ev.isPopupTrigger());
|
||||
lastTarget.dispatchEvent(mouseExited);
|
||||
}
|
||||
Point p = AWTUtilities.convertPoint(window, ev.getX(), ev.getY(),
|
||||
target);
|
||||
MouseEvent mouseEntered =
|
||||
new MouseEvent(target, MouseEvent.MOUSE_ENTERED, ev.getWhen(),
|
||||
ev.getModifiers(), p.x, p.y, ev.getClickCount(),
|
||||
ev.isPopupTrigger());
|
||||
target.dispatchEvent(mouseEntered);
|
||||
}
|
||||
|
||||
switch (ev.getID())
|
||||
{
|
||||
case MouseEvent.MOUSE_PRESSED:
|
||||
dragTarget = target;
|
||||
break;
|
||||
case MouseEvent.MOUSE_RELEASED:
|
||||
if (dragTarget != null)
|
||||
target = dragTarget;
|
||||
dragTarget = null;
|
||||
break;
|
||||
case MouseEvent.MOUSE_CLICKED:
|
||||
// When we receive a MOUSE_CLICKED, we set the target to the
|
||||
// previous target, which must have been a MOUSE_RELEASED event.
|
||||
// This is necessary for the case when the MOUSE_RELEASED has
|
||||
// caused the original target (like an internal component) go
|
||||
// away.
|
||||
target = lastTarget;
|
||||
break;
|
||||
case MouseEvent.MOUSE_DRAGGED:
|
||||
target = dragTarget;
|
||||
break;
|
||||
default:
|
||||
// Do nothing in other cases.
|
||||
break;
|
||||
}
|
||||
|
||||
lastTarget = target;
|
||||
|
||||
Point targetCoordinates =
|
||||
AWTUtilities.convertPoint(window, ev.getX(), ev.getY(), target);
|
||||
int dx = targetCoordinates.x - ev.getX();
|
||||
int dy = targetCoordinates.y - ev.getY();
|
||||
ev.translatePoint(dx, dy);
|
||||
ev.setSource(target);
|
||||
target.dispatchEvent(ev);
|
||||
|
||||
// We reset the event, so that the normal event dispatching is not
|
||||
// influenced by this modified event.
|
||||
ev.setSource(window);
|
||||
ev.translatePoint(-dx, -dy);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* Menu.java -- A Java AWT Menu
|
||||
Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -220,15 +220,16 @@ getItem(int index)
|
|||
public MenuItem
|
||||
add(MenuItem item)
|
||||
{
|
||||
MenuContainer parent = item.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(item);
|
||||
|
||||
items.addElement(item);
|
||||
if (item.parent != null)
|
||||
{
|
||||
item.parent.remove(item);
|
||||
}
|
||||
item.parent = this;
|
||||
item.setParent(this);
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
item.addNotify();
|
||||
MenuPeer mp = (MenuPeer) peer;
|
||||
mp.addItem(item);
|
||||
}
|
||||
|
@ -266,26 +267,33 @@ insert(MenuItem item, int index)
|
|||
if (index < 0)
|
||||
throw new IllegalArgumentException("Index is less than zero");
|
||||
|
||||
MenuPeer peer = (MenuPeer) getPeer();
|
||||
if (peer == null)
|
||||
return;
|
||||
|
||||
int count = getItemCount ();
|
||||
|
||||
if (index >= count)
|
||||
peer.addItem (item);
|
||||
add(item);
|
||||
else
|
||||
{
|
||||
for (int i = count - 1; i >= index; i--)
|
||||
peer.delItem (i);
|
||||
MenuContainer parent = item.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(item);
|
||||
|
||||
items.insertElementAt(item, index);
|
||||
item.setParent(this);
|
||||
|
||||
peer.addItem (item);
|
||||
MenuPeer peer = (MenuPeer) getPeer();
|
||||
if (peer == null)
|
||||
return;
|
||||
|
||||
for (int i = count - 1; i >= index; i--)
|
||||
peer.delItem(i);
|
||||
|
||||
item.addNotify();
|
||||
peer.addItem(item);
|
||||
|
||||
for (int i = index; i < count; i++)
|
||||
peer.addItem ((MenuItem) items.elementAt (i));
|
||||
peer.addItem((MenuItem) items.elementAt (i));
|
||||
}
|
||||
|
||||
items.insertElementAt(item, index);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -344,11 +352,15 @@ insertSeparator(int index)
|
|||
public synchronized void
|
||||
remove(int index)
|
||||
{
|
||||
items.removeElementAt(index);
|
||||
MenuItem item = (MenuItem) items.remove(index);
|
||||
|
||||
MenuPeer mp = (MenuPeer)getPeer();
|
||||
MenuPeer mp = (MenuPeer) getPeer();
|
||||
if (mp != null)
|
||||
mp.delItem(index);
|
||||
{
|
||||
mp.delItem(index);
|
||||
item.removeNotify();
|
||||
}
|
||||
item.setParent(null);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
@ -393,14 +405,21 @@ removeAll()
|
|||
public void
|
||||
addNotify()
|
||||
{
|
||||
MenuPeer peer = (MenuPeer) getPeer();
|
||||
if (peer == null)
|
||||
peer = getToolkit().createMenu(this);
|
||||
{
|
||||
peer = getToolkit().createMenu(this);
|
||||
setPeer(peer);
|
||||
}
|
||||
|
||||
Enumeration e = items.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
MenuItem mi = (MenuItem)e.nextElement();
|
||||
mi.addNotify();
|
||||
}
|
||||
peer.addItem(mi);
|
||||
}
|
||||
|
||||
super.addNotify ();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* MenuBar.java -- An AWT menu bar class
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,7 +40,6 @@ exception statement from your version. */
|
|||
package java.awt;
|
||||
|
||||
import java.awt.peer.MenuBarPeer;
|
||||
import java.awt.peer.MenuComponentPeer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Enumeration;
|
||||
|
@ -60,364 +60,311 @@ public class MenuBar extends MenuComponent
|
|||
implements MenuContainer, Serializable, Accessible
|
||||
{
|
||||
|
||||
/*
|
||||
* Static Variables
|
||||
*/
|
||||
|
||||
// Serialization Constant
|
||||
private static final long serialVersionUID = -4930327919388951260L;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* @serial The menu used for providing help information
|
||||
*/
|
||||
private Menu helpMenu;
|
||||
|
||||
/**
|
||||
* @serial The menus contained in this menu bar.
|
||||
*/
|
||||
private Vector menus = new Vector();
|
||||
//Serialization Constant
|
||||
private static final long serialVersionUID = -4930327919388951260L;
|
||||
|
||||
/**
|
||||
* The accessible context for this component.
|
||||
*
|
||||
* @see #getAccessibleContext()
|
||||
* @serial ignored.
|
||||
* @serial The menu used for providing help information
|
||||
*/
|
||||
private transient AccessibleContext accessibleContext;
|
||||
private Menu helpMenu;
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* @serial The menus contained in this menu bar.
|
||||
*/
|
||||
private Vector menus = new Vector();
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>MenuBar</code>.
|
||||
*
|
||||
* @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
|
||||
*/
|
||||
public
|
||||
MenuBar()
|
||||
{
|
||||
if (GraphicsEnvironment.isHeadless())
|
||||
throw new HeadlessException ();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the help menu for this menu bar. This may be <code>null</code>.
|
||||
*
|
||||
* @return The help menu for this menu bar.
|
||||
*/
|
||||
public Menu
|
||||
getHelpMenu()
|
||||
{
|
||||
return(helpMenu);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets the help menu for this menu bar.
|
||||
*
|
||||
* @param menu The new help menu for this menu bar.
|
||||
*/
|
||||
public synchronized void
|
||||
setHelpMenu(Menu menu)
|
||||
{
|
||||
if (helpMenu != null)
|
||||
{
|
||||
helpMenu.removeNotify ();
|
||||
helpMenu.parent = null;
|
||||
}
|
||||
helpMenu = menu;
|
||||
|
||||
if (menu.parent != null)
|
||||
menu.parent.remove (menu);
|
||||
menu.parent = this;
|
||||
|
||||
MenuBarPeer peer = (MenuBarPeer) getPeer ();
|
||||
if (peer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
peer.addHelpMenu (menu);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Add a menu to this MenuBar. If the menu has already has a
|
||||
* parent, it is first removed from its old parent before being
|
||||
* added.
|
||||
*
|
||||
* @param menu The menu to add.
|
||||
*
|
||||
* @return The menu that was added.
|
||||
*/
|
||||
public synchronized Menu
|
||||
add(Menu menu)
|
||||
{
|
||||
if (menu.parent != null)
|
||||
menu.parent.remove (menu);
|
||||
|
||||
menu.parent = this;
|
||||
menus.addElement(menu);
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
}
|
||||
|
||||
return(menu);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Removes the menu at the specified index.
|
||||
*
|
||||
* @param index The index of the menu to remove from the menu bar.
|
||||
*/
|
||||
public synchronized void
|
||||
remove(int index)
|
||||
{
|
||||
Menu m = (Menu) menus.get (index);
|
||||
menus.remove (index);
|
||||
m.removeNotify ();
|
||||
m.parent = null;
|
||||
|
||||
if (peer != null)
|
||||
{
|
||||
MenuBarPeer mp = (MenuBarPeer) peer;
|
||||
mp.delMenu (index);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Removes the specified menu from the menu bar.
|
||||
*
|
||||
* @param menu The menu to remove from the menu bar.
|
||||
*/
|
||||
public void
|
||||
remove(MenuComponent menu)
|
||||
{
|
||||
int index = menus.indexOf(menu);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
remove(index);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return The number of elements in the menu bar.
|
||||
*/
|
||||
public int
|
||||
getMenuCount()
|
||||
{
|
||||
return countMenus ();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return The number of elements in the menu bar.
|
||||
*
|
||||
* @deprecated This method is deprecated in favor of <code>getMenuCount()</code>.
|
||||
*/
|
||||
public int
|
||||
countMenus()
|
||||
{
|
||||
return menus.size () + (getHelpMenu () == null ? 0 : 1);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the menu at the specified index.
|
||||
*
|
||||
* @param index the index of the menu
|
||||
*
|
||||
* @return The requested menu.
|
||||
*
|
||||
* @exception ArrayIndexOutOfBoundsException If the index is not valid.
|
||||
*/
|
||||
public Menu
|
||||
getMenu(int index)
|
||||
{
|
||||
return((Menu)menus.elementAt(index));
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Creates this object's native peer.
|
||||
*/
|
||||
public void
|
||||
addNotify()
|
||||
{
|
||||
if (getPeer() == null)
|
||||
setPeer((MenuComponentPeer)getToolkit().createMenuBar(this));
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
/**
|
||||
* Initializes a new instance of <code>MenuBar</code>.
|
||||
*
|
||||
* @throws HeadlessException if GraphicsEnvironment.isHeadless() is true
|
||||
*/
|
||||
public MenuBar()
|
||||
{
|
||||
Menu mi = (Menu)e.nextElement();
|
||||
mi.addNotify();
|
||||
if (GraphicsEnvironment.isHeadless())
|
||||
throw new HeadlessException();
|
||||
}
|
||||
if (helpMenu != null)
|
||||
|
||||
/**
|
||||
* Returns the help menu for this menu bar. This may be <code>null</code>.
|
||||
*
|
||||
* @return the help menu for this menu bar
|
||||
*/
|
||||
public Menu getHelpMenu()
|
||||
{
|
||||
helpMenu.addNotify();
|
||||
((MenuBarPeer) peer).addHelpMenu(helpMenu);
|
||||
return helpMenu;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Destroys this object's native peer.
|
||||
*/
|
||||
public void
|
||||
removeNotify()
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
/**
|
||||
* Sets the help menu for this menu bar.
|
||||
*
|
||||
* @param menu the new help menu for this menu bar
|
||||
*/
|
||||
public synchronized void setHelpMenu(Menu menu)
|
||||
{
|
||||
Menu mi = (Menu) e.nextElement();
|
||||
mi.removeNotify();
|
||||
MenuBarPeer myPeer = (MenuBarPeer) getPeer ();
|
||||
|
||||
if (helpMenu != null)
|
||||
{
|
||||
if (myPeer != null)
|
||||
helpMenu.removeNotify();
|
||||
helpMenu.setParent(null);
|
||||
}
|
||||
helpMenu = menu;
|
||||
|
||||
MenuContainer parent = menu.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(menu);
|
||||
menu.setParent(this);
|
||||
|
||||
if (myPeer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
myPeer.addHelpMenu(menu);
|
||||
}
|
||||
}
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Add a menu to this MenuBar. If the menu has already has a
|
||||
* parent, it is first removed from its old parent before being
|
||||
* added.
|
||||
*
|
||||
* @param menu the menu to add
|
||||
*
|
||||
* @return the menu that was added
|
||||
*/
|
||||
public synchronized Menu add(Menu menu)
|
||||
{
|
||||
MenuBarPeer myPeer = (MenuBarPeer) getPeer ();
|
||||
|
||||
/**
|
||||
* Returns a list of all shortcuts for the menus in this menu bar.
|
||||
*
|
||||
* @return A list of all shortcuts for the menus in this menu bar.
|
||||
*/
|
||||
public synchronized Enumeration
|
||||
shortcuts()
|
||||
{
|
||||
Vector shortcuts = new Vector();
|
||||
Enumeration e = menus.elements();
|
||||
MenuContainer parent = menu.getParent();
|
||||
if (parent != null)
|
||||
parent.remove(menu);
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu)e.nextElement();
|
||||
if (menu.getShortcut() != null)
|
||||
shortcuts.addElement(menu.getShortcut());
|
||||
}
|
||||
menus.addElement(menu);
|
||||
menu.setParent(this);
|
||||
|
||||
return(shortcuts.elements());
|
||||
}
|
||||
if (myPeer != null)
|
||||
{
|
||||
menu.addNotify();
|
||||
myPeer.addMenu(menu);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Removes the menu at the specified index.
|
||||
*
|
||||
* @param index the index of the menu to remove from the menu bar
|
||||
*/
|
||||
public synchronized void remove(int index)
|
||||
{
|
||||
Menu m = (Menu) menus.remove(index);
|
||||
MenuBarPeer mp = (MenuBarPeer) getPeer();
|
||||
|
||||
/**
|
||||
* Returns the menu item for the specified shortcut, or <code>null</code>
|
||||
* if no such item exists.
|
||||
*
|
||||
* @param shortcut The shortcut to return the menu item for.
|
||||
*
|
||||
* @return The menu item for the specified shortcut.
|
||||
*/
|
||||
public MenuItem
|
||||
getShortcutMenuItem(MenuShortcut shortcut)
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
if (mp != null)
|
||||
m.removeNotify();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu)e.nextElement();
|
||||
MenuShortcut s = menu.getShortcut();
|
||||
if ((s != null) && (s.equals(shortcut)))
|
||||
return(menu);
|
||||
}
|
||||
m.setParent(null);
|
||||
|
||||
return(null);
|
||||
}
|
||||
if (mp != null)
|
||||
mp.delMenu(index);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Removes the specified menu from the menu bar.
|
||||
*
|
||||
* @param menu the menu to remove from the menu bar
|
||||
*/
|
||||
public void remove(MenuComponent menu)
|
||||
{
|
||||
int index = menus.indexOf(menu);
|
||||
if (index == -1)
|
||||
return;
|
||||
|
||||
/**
|
||||
* Deletes the specified menu shortcut.
|
||||
*
|
||||
* @param shortcut The shortcut to delete.
|
||||
*/
|
||||
public void
|
||||
deleteShortcut(MenuShortcut shortcut)
|
||||
{
|
||||
MenuItem it;
|
||||
// This is a slow implementation, but it probably doesn't matter.
|
||||
while ((it = getShortcutMenuItem (shortcut)) != null)
|
||||
it.deleteShortcut ();
|
||||
}
|
||||
remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AccessibleContext associated with this <code>MenuBar</code>.
|
||||
* The context is created, if necessary.
|
||||
*
|
||||
* @return the associated context
|
||||
*/
|
||||
public AccessibleContext getAccessibleContext()
|
||||
{
|
||||
/* Create the context if this is the first request */
|
||||
if (accessibleContext == null)
|
||||
accessibleContext = new AccessibleAWTMenuBar();
|
||||
return accessibleContext;
|
||||
}
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return the number of elements in the menu bar
|
||||
*/
|
||||
public int getMenuCount()
|
||||
{
|
||||
return countMenus();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides accessibility support for AWT menu bars.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
*/
|
||||
protected class AccessibleAWTMenuBar
|
||||
extends AccessibleAWTMenuComponent
|
||||
{
|
||||
/**
|
||||
* Returns the number of elements in this menu bar.
|
||||
*
|
||||
* @return the number of elements in the menu bar
|
||||
*
|
||||
* @deprecated This method is deprecated in favor of
|
||||
* <code>getMenuCount()</code>.
|
||||
*/
|
||||
public int countMenus()
|
||||
{
|
||||
return menus.size() + (getHelpMenu() == null ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu at the specified index.
|
||||
*
|
||||
* @param index the index of the menu
|
||||
*
|
||||
* @return the requested menu
|
||||
*
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is not valid
|
||||
*/
|
||||
public Menu getMenu(int index)
|
||||
{
|
||||
return (Menu) menus.elementAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates this object's native peer.
|
||||
*/
|
||||
public void addNotify()
|
||||
{
|
||||
MenuBarPeer peer = (MenuBarPeer) getPeer();
|
||||
if (peer == null)
|
||||
{
|
||||
peer = getToolkit().createMenuBar(this);
|
||||
setPeer(peer);
|
||||
}
|
||||
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu mi = (Menu)e.nextElement();
|
||||
mi.addNotify();
|
||||
peer.addMenu(mi);
|
||||
}
|
||||
|
||||
if (helpMenu != null)
|
||||
{
|
||||
helpMenu.addNotify();
|
||||
peer.addHelpMenu(helpMenu);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys this object's native peer.
|
||||
*/
|
||||
public void removeNotify()
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu mi = (Menu) e.nextElement();
|
||||
mi.removeNotify();
|
||||
}
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all shortcuts for the menus in this menu bar.
|
||||
*
|
||||
* @return a list of all shortcuts for the menus in this menu bar
|
||||
*/
|
||||
public synchronized Enumeration shortcuts()
|
||||
{
|
||||
Vector shortcuts = new Vector();
|
||||
Enumeration e = menus.elements();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu)e.nextElement();
|
||||
if (menu.getShortcut() != null)
|
||||
shortcuts.addElement(menu.getShortcut());
|
||||
}
|
||||
|
||||
return shortcuts.elements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu item for the specified shortcut, or <code>null</code>
|
||||
* if no such item exists.
|
||||
*
|
||||
* @param shortcut the shortcut to return the menu item for
|
||||
*
|
||||
* @return the menu item for the specified shortcut
|
||||
*/
|
||||
public MenuItem getShortcutMenuItem(MenuShortcut shortcut)
|
||||
{
|
||||
Enumeration e = menus.elements();
|
||||
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
Menu menu = (Menu) e.nextElement();
|
||||
MenuShortcut s = menu.getShortcut();
|
||||
if ((s != null) && s.equals(shortcut))
|
||||
return menu;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified menu shortcut.
|
||||
*
|
||||
* @param shortcut the shortcut to delete
|
||||
*/
|
||||
public void deleteShortcut(MenuShortcut shortcut)
|
||||
{
|
||||
MenuItem it;
|
||||
// This is a slow implementation, but it probably doesn't matter.
|
||||
while ((it = getShortcutMenuItem (shortcut)) != null)
|
||||
it.deleteShortcut();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the AccessibleContext associated with this <code>MenuBar</code>.
|
||||
* The context is created, if necessary.
|
||||
*
|
||||
* @return the associated context
|
||||
*/
|
||||
public AccessibleContext getAccessibleContext()
|
||||
{
|
||||
// Create the context if this is the first request.
|
||||
if (accessibleContext == null)
|
||||
accessibleContext = new AccessibleAWTMenuBar();
|
||||
return accessibleContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides accessibility support for AWT menu bars.
|
||||
*
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
*/
|
||||
protected class AccessibleAWTMenuBar
|
||||
extends AccessibleAWTMenuComponent
|
||||
{
|
||||
|
||||
/**
|
||||
* Compatible with JDK 1.4.2 revision 5
|
||||
*/
|
||||
private static final long serialVersionUID = -8577604491830083815L;
|
||||
/**
|
||||
* Compatible with JDK 1.4.2 revision 5
|
||||
*/
|
||||
private static final long serialVersionUID = -8577604491830083815L;
|
||||
|
||||
/**
|
||||
* This is the default constructor, which simply calls the default
|
||||
* constructor of the superclass.
|
||||
*/
|
||||
protected AccessibleAWTMenuBar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessible role relating to the menu bar.
|
||||
*
|
||||
* @return <code>AccessibleRole.MENU_BAR</code>
|
||||
*/
|
||||
public AccessibleRole getAccessibleRole()
|
||||
{
|
||||
return AccessibleRole.MENU_BAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the default constructor, which simply calls the default
|
||||
* constructor of the superclass.
|
||||
*/
|
||||
protected AccessibleAWTMenuBar()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the accessible role relating to the menu bar.
|
||||
*
|
||||
* @return <code>AccessibleRole.MENU_BAR</code>.
|
||||
*/
|
||||
public AccessibleRole getAccessibleRole()
|
||||
{
|
||||
return AccessibleRole.MENU_BAR;
|
||||
}
|
||||
|
||||
} // class AccessibleAWTMenuBar
|
||||
|
||||
} // class MenuBar
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
/* Scrollbar.java -- AWT Scrollbar widget
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
@ -593,13 +593,33 @@ public class Scrollbar extends Component implements Accessible, Adjustable
|
|||
adjustment_listeners.adjustmentValueChanged(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Package private method to determine whether to call
|
||||
* processEvent() or not. Will handle events from peer and update
|
||||
* the current value.
|
||||
*/
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
if (e.id <= AdjustmentEvent.ADJUSTMENT_LAST
|
||||
&& e.id >= AdjustmentEvent.ADJUSTMENT_FIRST
|
||||
&& (adjustment_listeners != null
|
||||
|| (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
&& e.id >= AdjustmentEvent.ADJUSTMENT_FIRST)
|
||||
{
|
||||
AdjustmentEvent ae = (AdjustmentEvent) e;
|
||||
boolean adjusting = ae.getValueIsAdjusting();
|
||||
if (adjusting)
|
||||
setValueIsAdjusting(true);
|
||||
try
|
||||
{
|
||||
setValue(((AdjustmentEvent) e).getValue());
|
||||
if (adjustment_listeners != null
|
||||
|| (eventMask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0)
|
||||
processEvent(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (adjusting)
|
||||
setValueIsAdjusting(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
|
|
@ -397,6 +397,7 @@ addNotify()
|
|||
return;
|
||||
|
||||
setPeer((ComponentPeer)getToolkit().createTextField(this));
|
||||
super.addNotify();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
|
|
@ -39,6 +39,8 @@ exception statement from your version. */
|
|||
|
||||
package java.awt;
|
||||
|
||||
import gnu.java.awt.peer.GLightweightPeer;
|
||||
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.dnd.DragGestureEvent;
|
||||
import java.awt.dnd.DragGestureListener;
|
||||
|
@ -46,6 +48,7 @@ import java.awt.dnd.DragGestureRecognizer;
|
|||
import java.awt.dnd.DragSource;
|
||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.AWTEventListenerProxy;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.im.InputMethodHighlight;
|
||||
import java.awt.image.ColorModel;
|
||||
|
@ -76,6 +79,7 @@ import java.awt.peer.WindowPeer;
|
|||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -113,11 +117,18 @@ public abstract class Toolkit
|
|||
protected final PropertyChangeSupport desktopPropsSupport
|
||||
= new PropertyChangeSupport(this);
|
||||
|
||||
/**
|
||||
* All registered AWTEventListener objects. This is package private, so the
|
||||
* event queue can efficiently access this list.
|
||||
*/
|
||||
AWTEventListenerProxy[] awtEventListeners;
|
||||
|
||||
/**
|
||||
* Default constructor for subclasses.
|
||||
*/
|
||||
public Toolkit()
|
||||
{
|
||||
awtEventListeners = new AWTEventListenerProxy[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +360,7 @@ public abstract class Toolkit
|
|||
*/
|
||||
protected LightweightPeer createComponent(Component target)
|
||||
{
|
||||
return new gnu.java.awt.peer.GLightweightPeer (target);
|
||||
return new GLightweightPeer(target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,7 +473,7 @@ public abstract class Toolkit
|
|||
*/
|
||||
public Insets getScreenInsets(GraphicsConfiguration gc)
|
||||
{
|
||||
return null;
|
||||
return new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -965,33 +976,230 @@ public abstract class Toolkit
|
|||
return desktopPropsSupport.getPropertyChangeListeners(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an AWTEventListener to this toolkit. This listener is informed about
|
||||
* all events that pass the eventqueue that match the specified
|
||||
* <code>evenMask</code>. The <code>eventMask</code> is an ORed combination
|
||||
* of event masks as defined in {@link AWTEvent}.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @param listener the listener to add
|
||||
* @param eventMask the event mask of event types which the listener is
|
||||
* interested in
|
||||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
* @see #getAWTEventListeners()
|
||||
* @see #getAWTEventListeners(long)
|
||||
* @see #removeAWTEventListener(AWTEventListener)
|
||||
*/
|
||||
public void addAWTEventListener(AWTEventListener listener, long eventMask)
|
||||
{
|
||||
// SecurityManager s = System.getSecurityManager();
|
||||
// if (s != null)
|
||||
// s.checkPermission(AWTPermission("listenToAllAWTEvents"));
|
||||
// FIXME
|
||||
}
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
public void removeAWTEventListener(AWTEventListener listener)
|
||||
{
|
||||
// FIXME
|
||||
// Go through the list and check if the requested listener is already
|
||||
// registered.
|
||||
boolean found = false;
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
AWTEventListenerProxy proxy = awtEventListeners[i];
|
||||
if (proxy.getListener() == listener)
|
||||
{
|
||||
found = true;
|
||||
// Modify the proxies event mask to include the new event mask.
|
||||
AWTEventListenerProxy newProxy =
|
||||
new AWTEventListenerProxy(proxy.getEventMask() | eventMask,
|
||||
listener);
|
||||
awtEventListeners[i] = newProxy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If that listener was not found, then add it.
|
||||
if (! found)
|
||||
{
|
||||
AWTEventListenerProxy proxy =
|
||||
new AWTEventListenerProxy(eventMask, listener);
|
||||
AWTEventListenerProxy[] newArray =
|
||||
new AWTEventListenerProxy[awtEventListeners.length + 1];
|
||||
System.arraycopy(awtEventListeners, 0, newArray, 0,
|
||||
awtEventListeners.length);
|
||||
newArray[newArray.length - 1] = proxy;
|
||||
awtEventListeners = newArray;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an AWT event listener from this toolkit. This listener is no
|
||||
* longer informed of any event types it was registered in.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @param listener the listener to remove
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @see #addAWTEventListener(AWTEventListener, long)
|
||||
* @see #getAWTEventListeners()
|
||||
* @see #getAWTEventListeners(long)
|
||||
*/
|
||||
public void removeAWTEventListener(AWTEventListener listener)
|
||||
{
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
|
||||
// Find the index of the listener.
|
||||
int index = -1;
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
AWTEventListenerProxy proxy = awtEventListeners[i];
|
||||
if (proxy.getListener() == listener)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy over the arrays and leave out the removed element.
|
||||
if (index != -1)
|
||||
{
|
||||
AWTEventListenerProxy[] newArray =
|
||||
new AWTEventListenerProxy[awtEventListeners.length - 1];
|
||||
if (index > 0)
|
||||
System.arraycopy(awtEventListeners, 0, newArray, 0, index);
|
||||
if (index < awtEventListeners.length - 1)
|
||||
System.arraycopy(awtEventListeners, index + 1, newArray, index,
|
||||
awtEventListeners.length - index - 1);
|
||||
awtEventListeners = newArray;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered AWT event listeners. This method returns a copy of
|
||||
* the listener array, so that application cannot trash the listener list.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @return all registered AWT event listeners
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
* @since 1.4
|
||||
*
|
||||
* @see #addAWTEventListener(AWTEventListener, long)
|
||||
* @see #removeAWTEventListener(AWTEventListener)
|
||||
* @see #getAWTEventListeners(long)
|
||||
*/
|
||||
public AWTEventListener[] getAWTEventListeners()
|
||||
{
|
||||
return null;
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
// Create a copy of the array.
|
||||
AWTEventListener[] copy = new AWTEventListener[awtEventListeners.length];
|
||||
System.arraycopy(awtEventListeners, 0, copy, 0, awtEventListeners.length);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered AWT event listeners that listen for events with
|
||||
* the specified <code>eventMask</code>. This method returns a copy of
|
||||
* the listener array, so that application cannot trash the listener list.
|
||||
*
|
||||
* If a security manager is installed, it is asked first if an
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code> is allowed.
|
||||
* This may result in a <code>SecurityException</code> beeing thrown.
|
||||
*
|
||||
* It is not recommended to use this kind of notification for normal
|
||||
* applications. It is intended solely for the purpose of debugging and to
|
||||
* support special facilities.
|
||||
*
|
||||
* @param mask the event mask
|
||||
*
|
||||
* @throws SecurityException if there is a <code>SecurityManager</code> that
|
||||
* doesn't grant
|
||||
* <code>AWTPermission("listenToAllAWTEvents")</code>
|
||||
*
|
||||
*
|
||||
* @since 1.4
|
||||
*
|
||||
* @see #addAWTEventListener(AWTEventListener, long)
|
||||
* @see #removeAWTEventListener(AWTEventListener)
|
||||
* @see #getAWTEventListeners()
|
||||
*/
|
||||
public AWTEventListener[] getAWTEventListeners(long mask)
|
||||
{
|
||||
return null;
|
||||
// First we must check the security permissions.
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
|
||||
|
||||
// Create a copy of the array with only the requested listeners in it.
|
||||
ArrayList l = new ArrayList(awtEventListeners.length);
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
if ((awtEventListeners[i].getEventMask() & mask) != 0)
|
||||
l.add(awtEventListeners[i]);
|
||||
}
|
||||
|
||||
return (AWTEventListener[] ) l.toArray(new AWTEventListener[l.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dispatches events to listeners registered to this Toolkit. This is called
|
||||
* by {@link Component#dispatchEventImpl(AWTEvent)} in order to dispatch
|
||||
* events globally.
|
||||
*
|
||||
* @param ev the event to dispatch
|
||||
*/
|
||||
void globalDispatchEvent(AWTEvent ev)
|
||||
{
|
||||
// We do not use the accessor methods here because they create new
|
||||
// arrays each time. We must be very efficient, so we access this directly.
|
||||
for (int i = 0; i < awtEventListeners.length; ++i)
|
||||
{
|
||||
AWTEventListenerProxy proxy = awtEventListeners[i];
|
||||
if ((proxy.getEventMask() & AWTEvent.eventIdToMask(ev.getID())) != 0)
|
||||
proxy.eventDispatched(ev);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -281,50 +281,53 @@ 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.
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while(e.hasNext())
|
||||
{
|
||||
Window w = (Window)(((Reference) e.next()).get());
|
||||
if (w != null)
|
||||
{
|
||||
if (w.isVisible())
|
||||
w.getPeer().setVisible(true);
|
||||
}
|
||||
else
|
||||
// Remove null weak reference from ownedWindows.
|
||||
// Unfortunately this can't be done in the Window's
|
||||
// finalize method because there is no way to guarantee
|
||||
// synchronous access to ownedWindows there.
|
||||
e.remove();
|
||||
}
|
||||
validate();
|
||||
super.show();
|
||||
toFront();
|
||||
|
||||
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
|
||||
manager.setGlobalFocusedWindow (this);
|
||||
|
||||
if (!shown)
|
||||
{
|
||||
FocusTraversalPolicy policy = getFocusTraversalPolicy ();
|
||||
Component initialFocusOwner = null;
|
||||
if (parent != null && ! parent.isDisplayable())
|
||||
parent.addNotify();
|
||||
if (peer == null)
|
||||
addNotify();
|
||||
|
||||
if (policy != null)
|
||||
initialFocusOwner = policy.getInitialComponent (this);
|
||||
validate();
|
||||
if (visible)
|
||||
toFront();
|
||||
else
|
||||
{
|
||||
super.show();
|
||||
// Show visible owned windows.
|
||||
Iterator e = ownedWindows.iterator();
|
||||
while (e.hasNext())
|
||||
{
|
||||
Window w = (Window) (((Reference) e.next()).get());
|
||||
if (w != null)
|
||||
{
|
||||
if (w.isVisible())
|
||||
w.getPeer().setVisible(true);
|
||||
}
|
||||
else
|
||||
// Remove null weak reference from ownedWindows.
|
||||
// Unfortunately this can't be done in the Window's
|
||||
// finalize method because there is no way to guarantee
|
||||
// synchronous access to ownedWindows there.
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||
manager.setGlobalFocusedWindow(this);
|
||||
|
||||
if (initialFocusOwner != null)
|
||||
initialFocusOwner.requestFocusInWindow ();
|
||||
if (! shown)
|
||||
{
|
||||
FocusTraversalPolicy policy = getFocusTraversalPolicy();
|
||||
Component initialFocusOwner = null;
|
||||
|
||||
shown = true;
|
||||
if (policy != null)
|
||||
initialFocusOwner = policy.getInitialComponent(this);
|
||||
|
||||
if (initialFocusOwner != null)
|
||||
initialFocusOwner.requestFocusInWindow();
|
||||
|
||||
shown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hide()
|
||||
|
|
|
@ -157,38 +157,42 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
|
|||
ClassLoader classLoader)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
// Bootstrap
|
||||
try
|
||||
{
|
||||
return(Class.forName(className));
|
||||
return Class.forName(className);
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
// Commented out for Java 1.1
|
||||
/*
|
||||
try
|
||||
catch(ClassNotFoundException cnfe)
|
||||
{
|
||||
return(className.getClass().getClassLoader().findClass(className));
|
||||
// Ignored.
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
|
||||
// System
|
||||
try
|
||||
{
|
||||
return(ClassLoader.getSystemClassLoader().findClass(className));
|
||||
ClassLoader loader = ClassLoader.getSystemClassLoader();
|
||||
return Class.forName(className, true, loader);
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
*/
|
||||
|
||||
// FIXME: What is the context class loader?
|
||||
/*
|
||||
catch(ClassNotFoundException cnfe)
|
||||
{
|
||||
// Ignored.
|
||||
}
|
||||
|
||||
// Context
|
||||
try
|
||||
{
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
return Class.forName(className, true, loader);
|
||||
}
|
||||
catch(Exception e) { ; }
|
||||
*/
|
||||
|
||||
catch(ClassNotFoundException cnfe)
|
||||
{
|
||||
// Ignored.
|
||||
}
|
||||
|
||||
if (classLoader != null)
|
||||
return(classLoader.loadClass(className));
|
||||
else
|
||||
throw new ClassNotFoundException(className);
|
||||
return Class.forName(className, true, classLoader);
|
||||
|
||||
throw new ClassNotFoundException(className);
|
||||
}
|
||||
|
||||
private static Class getRepresentationClassFromMime(String mimeString,
|
||||
|
@ -203,7 +207,13 @@ public class DataFlavor implements java.io.Externalizable, Cloneable
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("classname: " + e.getMessage());
|
||||
IllegalArgumentException iae;
|
||||
iae = new IllegalArgumentException("mimeString: "
|
||||
+ mimeString
|
||||
+ " classLoader: "
|
||||
+ classLoader);
|
||||
iae.initCause(e);
|
||||
throw iae;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -90,7 +90,7 @@ public class DragSource implements Serializable
|
|||
*/
|
||||
public static DragSource getDefaultDragSource()
|
||||
{
|
||||
return null;
|
||||
return new DragSource();
|
||||
}
|
||||
|
||||
public static boolean isDragImageSupported()
|
||||
|
@ -172,13 +172,34 @@ public class DragSource implements Serializable
|
|||
return flavorMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dummy DragGestureRecognizer when Toolkit doesn't support drag and drop.
|
||||
*/
|
||||
static class NoDragGestureRecognizer extends DragGestureRecognizer
|
||||
{
|
||||
NoDragGestureRecognizer(DragSource ds, Component c, int actions,
|
||||
DragGestureListener dgl)
|
||||
{
|
||||
super(ds, c, actions, dgl);
|
||||
}
|
||||
|
||||
protected void registerListeners() { }
|
||||
protected void unregisterListeners() { }
|
||||
}
|
||||
|
||||
public DragGestureRecognizer
|
||||
createDragGestureRecognizer(Class recognizer, Component c, int actions,
|
||||
DragGestureListener dgl)
|
||||
{
|
||||
return Toolkit.getDefaultToolkit ()
|
||||
DragGestureRecognizer dgr;
|
||||
dgr = Toolkit.getDefaultToolkit ()
|
||||
.createDragGestureRecognizer (recognizer, this, c, actions,
|
||||
dgl);
|
||||
|
||||
if (dgr == null)
|
||||
dgr = new NoDragGestureRecognizer(this, c, actions, dgl);
|
||||
|
||||
return dgr;
|
||||
}
|
||||
|
||||
public DragGestureRecognizer
|
||||
|
|
BIN
libjava/classpath/java/awt/doc-files/capjoin.png
Normal file
BIN
libjava/classpath/java/awt/doc-files/capjoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -72,75 +72,15 @@ public class AWTEventListenerProxy extends EventListenerProxy
|
|||
}
|
||||
|
||||
/**
|
||||
* Forwards events on to the delegate if they meet the event mask.
|
||||
* Forwards events on to the delegate.
|
||||
*
|
||||
* @param event the to forward to the delagate listener
|
||||
*
|
||||
* @param event the property change event to filter
|
||||
* @throws NullPointerException if the delegate this was created with is null
|
||||
*/
|
||||
public void eventDispatched(AWTEvent event)
|
||||
{
|
||||
int id = event == null ? 0 : event.getID();
|
||||
if (((mask & AWTEvent.ACTION_EVENT_MASK) != 0
|
||||
&& event instanceof ActionEvent)
|
||||
|| ((mask & AWTEvent.ADJUSTMENT_EVENT_MASK) != 0
|
||||
&& event instanceof AdjustmentEvent)
|
||||
|| ((mask & AWTEvent.COMPONENT_EVENT_MASK) != 0
|
||||
&& event instanceof ComponentEvent
|
||||
&& (id >= ComponentEvent.COMPONENT_FIRST
|
||||
&& id <= ComponentEvent.COMPONENT_LAST))
|
||||
|| ((mask & AWTEvent.CONTAINER_EVENT_MASK) != 0
|
||||
&& event instanceof ContainerEvent)
|
||||
|| ((mask & AWTEvent.FOCUS_EVENT_MASK) != 0
|
||||
&& event instanceof FocusEvent)
|
||||
|| ((mask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) != 0
|
||||
&& event instanceof HierarchyEvent
|
||||
&& (id == HierarchyEvent.ANCESTOR_MOVED
|
||||
|| id == HierarchyEvent.ANCESTOR_RESIZED))
|
||||
|| ((mask & AWTEvent.HIERARCHY_EVENT_MASK) != 0
|
||||
&& event instanceof HierarchyEvent
|
||||
&& id == HierarchyEvent.HIERARCHY_CHANGED)
|
||||
|| ((mask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0
|
||||
&& event instanceof InputMethodEvent)
|
||||
|| ((mask & AWTEvent.INVOCATION_EVENT_MASK) != 0
|
||||
&& event instanceof InvocationEvent)
|
||||
|| ((mask & AWTEvent.ITEM_EVENT_MASK) != 0
|
||||
&& event instanceof ItemEvent)
|
||||
|| ((mask & AWTEvent.KEY_EVENT_MASK) != 0
|
||||
&& event instanceof KeyEvent)
|
||||
|| ((mask & AWTEvent.MOUSE_EVENT_MASK) != 0
|
||||
&& event instanceof MouseEvent
|
||||
&& (id == MouseEvent.MOUSE_PRESSED
|
||||
|| id == MouseEvent.MOUSE_RELEASED
|
||||
|| id == MouseEvent.MOUSE_CLICKED
|
||||
|| id == MouseEvent.MOUSE_ENTERED
|
||||
|| id == MouseEvent.MOUSE_EXITED))
|
||||
|| ((mask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0
|
||||
&& event instanceof MouseEvent
|
||||
&& (id == MouseEvent.MOUSE_MOVED
|
||||
|| id == MouseEvent.MOUSE_DRAGGED))
|
||||
|| ((mask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0
|
||||
&& event instanceof MouseWheelEvent)
|
||||
|| ((mask & AWTEvent.PAINT_EVENT_MASK) != 0
|
||||
&& event instanceof PaintEvent)
|
||||
|| ((mask & AWTEvent.TEXT_EVENT_MASK) != 0
|
||||
&& event instanceof TextEvent)
|
||||
|| ((mask & AWTEvent.WINDOW_EVENT_MASK) != 0
|
||||
&& event instanceof WindowEvent
|
||||
&& (id == WindowEvent.WINDOW_OPENED
|
||||
|| id == WindowEvent.WINDOW_CLOSING
|
||||
|| id == WindowEvent.WINDOW_CLOSED
|
||||
|| id == WindowEvent.WINDOW_ICONIFIED
|
||||
|| id == WindowEvent.WINDOW_DEICONIFIED
|
||||
|| id == WindowEvent.WINDOW_ACTIVATED
|
||||
|| id == WindowEvent.WINDOW_DEACTIVATED))
|
||||
|| ((mask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0
|
||||
&& event instanceof WindowEvent
|
||||
&& (id == WindowEvent.WINDOW_GAINED_FOCUS
|
||||
|| id == WindowEvent.WINDOW_LOST_FOCUS))
|
||||
|| ((mask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0
|
||||
&& event instanceof WindowEvent
|
||||
&& id == WindowEvent.WINDOW_STATE_CHANGED))
|
||||
((AWTEventListener) getListener()).eventDispatched(event);
|
||||
((AWTEventListener) getListener()).eventDispatched(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,76 +59,344 @@ import java.awt.image.ImageObserver;
|
|||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.VolatileImage;
|
||||
|
||||
/**
|
||||
* Defines the methods that a component peer is required to implement.
|
||||
*/
|
||||
public interface ComponentPeer
|
||||
{
|
||||
/**
|
||||
* Returns the construction status of the specified image. This is called
|
||||
* by {@link Component#checkImage(Image, int, int, ImageObserver)}.
|
||||
*
|
||||
* @param img the image
|
||||
* @param width the width of the image
|
||||
* @param height the height of the image
|
||||
* @param ob the image observer to be notified of updates of the status
|
||||
*
|
||||
* @return a bitwise ORed set of ImageObserver flags
|
||||
*/
|
||||
int checkImage(Image img, int width, int height,
|
||||
ImageObserver ob);
|
||||
ImageObserver ob);
|
||||
|
||||
/**
|
||||
* Creates an image by starting the specified image producer. This is called
|
||||
* by {@link Component#createImage(ImageProducer)}.
|
||||
*
|
||||
* @param prod the image producer to be used to create the image
|
||||
*
|
||||
* @return the created image
|
||||
*/
|
||||
Image createImage(ImageProducer prod);
|
||||
|
||||
/**
|
||||
* Creates an empty image with the specified <code>width</code> and
|
||||
* <code>height</code>.
|
||||
*
|
||||
* @param width the width of the image to be created
|
||||
* @param height the height of the image to be created
|
||||
*
|
||||
* @return the created image
|
||||
*/
|
||||
Image createImage(int width, int height);
|
||||
|
||||
/**
|
||||
* Disables the component. This is called by {@link Component#disable()}.
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* Disposes the component peer. This should release all resources held by the
|
||||
* peer. This is called when the component is no longer in use.
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
/**
|
||||
* Enables the component. This is called by {@link Component#enable()}.
|
||||
*/
|
||||
void enable();
|
||||
|
||||
/**
|
||||
* Returns the color model of the component. This is currently not used.
|
||||
*
|
||||
* @return the color model of the component
|
||||
*/
|
||||
ColorModel getColorModel();
|
||||
|
||||
/**
|
||||
* Returns the font metrics for the specified font. This is called by
|
||||
* {@link Component#getFontMetrics(Font)}.
|
||||
*
|
||||
* @param f the font for which to query the font metrics
|
||||
*
|
||||
* @return the font metrics for the specified font
|
||||
*/
|
||||
FontMetrics getFontMetrics(Font f);
|
||||
|
||||
/**
|
||||
* Returns a {@link Graphics} object suitable for drawing on this component.
|
||||
* This is called by {@link Component#getGraphics()}.
|
||||
*
|
||||
* @return a graphics object suitable for drawing on this component
|
||||
*/
|
||||
Graphics getGraphics();
|
||||
|
||||
/**
|
||||
* Returns the location of this component in screen coordinates. This is
|
||||
* called by {@link Component#getLocationOnScreen()}.
|
||||
*
|
||||
* @return the location of this component in screen coordinates
|
||||
*/
|
||||
Point getLocationOnScreen();
|
||||
|
||||
/**
|
||||
* Returns the minimum size for the component. This is called by
|
||||
* {@link Component#getMinimumSize()}.
|
||||
*
|
||||
* @return the minimum size for the component
|
||||
*/
|
||||
Dimension getMinimumSize();
|
||||
|
||||
/**
|
||||
* Returns the preferred size for the component. This is called by
|
||||
* {@link Component#getPreferredSize()}.
|
||||
*
|
||||
* @return the preferred size for the component
|
||||
*/
|
||||
Dimension getPreferredSize();
|
||||
|
||||
/**
|
||||
* Returns the toolkit that created this peer.
|
||||
*
|
||||
* @return the toolkit that created this peer
|
||||
*/
|
||||
Toolkit getToolkit();
|
||||
|
||||
/**
|
||||
* Handles the given event. This is called from
|
||||
* {@link Component#dispatchEvent(AWTEvent)} to give the peer a chance to
|
||||
* react to events for the component.
|
||||
*
|
||||
* @param e the event
|
||||
*/
|
||||
void handleEvent(AWTEvent e);
|
||||
|
||||
/**
|
||||
* Makes the component invisible. This is called from
|
||||
* {@link Component#hide()}.
|
||||
*/
|
||||
void hide();
|
||||
|
||||
/**
|
||||
* Part of the earlier 1.1 API, replaced by isFocusable().
|
||||
* Returns <code>true</code> if the component can receive keyboard input
|
||||
* focus. This is called from {@link Component#isFocusTraversable()}.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, replaced by isFocusable().
|
||||
*/
|
||||
boolean isFocusTraversable();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the component can receive keyboard input
|
||||
* focus. This is called from {@link Component#isFocusable()}.
|
||||
*/
|
||||
boolean isFocusable();
|
||||
|
||||
/**
|
||||
* Returns the minimum size for the component. This is called by
|
||||
* {@link Component#minimumSize()}.
|
||||
*
|
||||
* @return the minimum size for the component
|
||||
*/
|
||||
Dimension minimumSize();
|
||||
|
||||
/**
|
||||
* Returns the preferred size for the component. This is called by
|
||||
* {@link Component#getPreferredSize()}.
|
||||
*
|
||||
* @return the preferred size for the component
|
||||
*/
|
||||
Dimension preferredSize();
|
||||
|
||||
void paint(Graphics graphics);
|
||||
|
||||
/**
|
||||
* Prepares an image for rendering on this component. This is called by
|
||||
* {@link Component#prepareImage(Image, int, int, ImageObserver)}.
|
||||
*
|
||||
* @param img the image to prepare
|
||||
* @param width the desired width of the rendered image
|
||||
* @param height the desired height of the rendered image
|
||||
* @param ob the image observer to be notified of updates in the preparation
|
||||
* process
|
||||
*
|
||||
* @return <code>true</code> if the image has been fully prepared,
|
||||
* <code>false</code> otherwise (in which case the image observer
|
||||
* receives updates)
|
||||
*/
|
||||
boolean prepareImage(Image img, int width, int height,
|
||||
ImageObserver ob);
|
||||
|
||||
void print(Graphics graphics);
|
||||
|
||||
/**
|
||||
* Repaints the specified rectangle of this component. This is called from
|
||||
* {@link Component#repaint(long, int, int, int, int)}.
|
||||
*
|
||||
* @param tm number of milliseconds to wait with repainting
|
||||
* @param x the X coordinate of the upper left corner of the damaged rectangle
|
||||
* @param y the Y coordinate of the upper left corner of the damaged rectangle
|
||||
* @param width the width of the damaged rectangle
|
||||
* @param height the height of the damaged rectangle
|
||||
*/
|
||||
void repaint(long tm, int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Part of the earlier 1.1 API, apparently replaced by argument
|
||||
* form of the same method.
|
||||
* Requests that this component receives the focus. This is called from
|
||||
* {@link Component#requestFocus()}.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, apparently replaced by argument
|
||||
* form of the same method.
|
||||
*/
|
||||
void requestFocus();
|
||||
boolean requestFocus (Component source, boolean bool1, boolean bool2, long x);
|
||||
|
||||
/**
|
||||
* Requests that this component receives the focus. This is called from
|
||||
* {@link Component#requestFocus()}.
|
||||
*
|
||||
* @param source TODO
|
||||
* @param bool1 TODO
|
||||
* @param bool2 TODO
|
||||
* @param x TODO
|
||||
*/
|
||||
boolean requestFocus(Component source, boolean bool1, boolean bool2, long x);
|
||||
|
||||
/**
|
||||
* Notifies the peer that the bounds of this component have changed. This
|
||||
* is called by {@link Component#reshape(int, int, int, int)}.
|
||||
*
|
||||
* @param x the X coordinate of the upper left corner of the component
|
||||
* @param y the Y coordinate of the upper left corner of the component
|
||||
* @param width the width of the component
|
||||
* @param height the height of the component
|
||||
*/
|
||||
void reshape(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Sets the background color of the component. This is called by
|
||||
* {@link Component#setBackground(Color)}.
|
||||
*
|
||||
* @param color the background color to set
|
||||
*/
|
||||
void setBackground(Color color);
|
||||
|
||||
/**
|
||||
* Notifies the peer that the bounds of this component have changed. This
|
||||
* is called by {@link Component#setBounds(int, int, int, int)}.
|
||||
*
|
||||
* @param x the X coordinate of the upper left corner of the component
|
||||
* @param y the Y coordinate of the upper left corner of the component
|
||||
* @param width the width of the component
|
||||
* @param height the height of the component
|
||||
*/
|
||||
void setBounds(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Part of the earlier 1.1 API, apparently no longer needed.
|
||||
* Sets the cursor of the component. This is called by
|
||||
* {@link Component#setCursor(Cursor)}.
|
||||
*
|
||||
* @specnote Part of the earlier 1.1 API, apparently no longer needed.
|
||||
*/
|
||||
void setCursor(Cursor cursor);
|
||||
|
||||
/**
|
||||
* Sets the enabled/disabled state of this component. This is called by
|
||||
* {@link Component#setEnabled(boolean)}.
|
||||
*
|
||||
* @param enabled <code>true</code> to enable the component,
|
||||
* <code>false</code> to disable it
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Sets the font of the component. This is called by
|
||||
* {@link Component#setFont(Font)}.
|
||||
*
|
||||
* @param font the font to set
|
||||
*/
|
||||
void setFont(Font font);
|
||||
|
||||
/**
|
||||
* Sets the foreground color of the component. This is called by
|
||||
* {@link Component#setForeground(Color)}.
|
||||
*
|
||||
* @param color the foreground color to set
|
||||
*/
|
||||
void setForeground(Color color);
|
||||
|
||||
/**
|
||||
* Sets the visibility state of the component. This is called by
|
||||
* {@link Component#setVisible(boolean)}.
|
||||
*
|
||||
* @param visible <code>true</code> to make the component visible,
|
||||
* <code>false</code> to make it invisible
|
||||
*/
|
||||
void setVisible(boolean visible);
|
||||
|
||||
/**
|
||||
* Makes the component visible. This is called by {@link Component#show()}.
|
||||
*/
|
||||
void show();
|
||||
|
||||
/**
|
||||
* Get the graphics configuration of the component. The color model
|
||||
* of the component can be derived from the configuration.
|
||||
*
|
||||
* @return the graphics configuration of the component
|
||||
*/
|
||||
GraphicsConfiguration getGraphicsConfiguration();
|
||||
|
||||
/**
|
||||
* Part of an older API, no longer needed.
|
||||
*/
|
||||
void setEventMask (long mask);
|
||||
void setEventMask(long mask);
|
||||
|
||||
// Methods below are introduced since 1.1
|
||||
/**
|
||||
* Returns <code>true</code> if this component has been obscured,
|
||||
* <code>false</code> otherwise. This will only work if
|
||||
* {@link #canDetermineObscurity()} also returns <code>true</code>.
|
||||
*
|
||||
* @return <code>true</code> if this component has been obscured,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
boolean isObscured();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if this component peer can determine if the
|
||||
* component has been obscured, <code>false</code> otherwise.
|
||||
*
|
||||
* @return <code>true</code> if this component peer can determine if the
|
||||
* component has been obscured, <code>false</code> otherwise
|
||||
*/
|
||||
boolean canDetermineObscurity();
|
||||
|
||||
/**
|
||||
* Coalesces the specified paint event.
|
||||
*
|
||||
* @param e the paint event
|
||||
*/
|
||||
void coalescePaintEvent(PaintEvent e);
|
||||
|
||||
/**
|
||||
* Updates the cursor.
|
||||
*/
|
||||
void updateCursorImmediately();
|
||||
|
||||
/**
|
||||
* Returns true, if this component can handle wheel scrolling,
|
||||
* <code>false</code> otherwise.
|
||||
*
|
||||
* @return true, if this component can handle wheel scrolling,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean handlesWheelScrolling();
|
||||
|
||||
/**
|
||||
|
|
124
libjava/classpath/java/awt/print/NoPrinterJob.java
Normal file
124
libjava/classpath/java/awt/print/NoPrinterJob.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/* NoPrinterJob.java -- Fake PrinterJob that just signals no print service.
|
||||
Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* Fake PrinterJob that just signals no print service. This is only
|
||||
* here so applications can call
|
||||
* <code>PrintJob.getPrinterJob().getPrinterJob()</code> and check
|
||||
* that it returns <code>null</code> which indicates no actual
|
||||
* printing support is available.
|
||||
*/
|
||||
class NoPrinterJob extends PrinterJob
|
||||
{
|
||||
public int getCopies()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setCopies(int copies)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public String getJobName()
|
||||
{
|
||||
return "NoPrinterJob";
|
||||
}
|
||||
|
||||
public void setJobName(String job_name)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return "NoUser";
|
||||
}
|
||||
|
||||
public void cancel()
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public PageFormat defaultPage(PageFormat page_format)
|
||||
{
|
||||
return page_format;
|
||||
}
|
||||
|
||||
public PageFormat pageDialog(PageFormat page_format)
|
||||
{
|
||||
return page_format;
|
||||
}
|
||||
|
||||
public void print() throws PrinterException
|
||||
{
|
||||
throw new PrinterException("No printer");
|
||||
}
|
||||
|
||||
public boolean printDialog()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPageable(Pageable pageable)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void setPrintable(Printable printable)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void setPrintable(Printable printable, PageFormat page_format)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public PageFormat validatePage(PageFormat page_format)
|
||||
{
|
||||
return page_format;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* PageFormat.java -- Information about the page format
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,254 +39,195 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This class contains information about the desired page format to
|
||||
* use for printing a particular set of pages.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class PageFormat implements Cloneable
|
||||
{
|
||||
|
||||
/*
|
||||
* Static Variables
|
||||
* This class contains information about the desired page format to use for
|
||||
* printing a particular set of pages.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
|
||||
/**
|
||||
* A constant for a landscaped page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int LANDSCAPE = 0;
|
||||
|
||||
/**
|
||||
* A constant for a portrait page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int PORTRAIT = 1;
|
||||
|
||||
/**
|
||||
* A constant for a reversed landscaped page orientation. This is
|
||||
* the orientation used by Macintosh's for landscape. The origin is
|
||||
* in the upper right hand corner instead of the upper left. The
|
||||
* X and Y axes are reversed. Used by <code>getOrientation</code> and
|
||||
* <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int REVERSE_LANDSCAPE = 2;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
*/
|
||||
|
||||
// The page orientation
|
||||
private int orientation;
|
||||
|
||||
// The paper type
|
||||
private Paper paper;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method creates a default page layout, which will be in portrait
|
||||
* format.
|
||||
*/
|
||||
public
|
||||
PageFormat()
|
||||
public class PageFormat
|
||||
implements Cloneable
|
||||
{
|
||||
this.paper = new Paper();
|
||||
this.orientation = PORTRAIT;
|
||||
/**
|
||||
* A constant for a landscaped page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int LANDSCAPE = 0;
|
||||
|
||||
/**
|
||||
* A constant for a portrait page orientation. Used by
|
||||
* <code>getOrientation</code> and <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int PORTRAIT = 1;
|
||||
|
||||
/**
|
||||
* A constant for a reversed landscaped page orientation. This is the
|
||||
* orientation used by Macintosh's for landscape. The origin is in the
|
||||
* upper right hand corner instead of the upper left. The X and Y axes
|
||||
* are reversed. Used by <code>getOrientation</code> and
|
||||
* <code>setOrientation</code>.
|
||||
*/
|
||||
public static final int REVERSE_LANDSCAPE = 2;
|
||||
|
||||
// The page orientation
|
||||
private int orientation;
|
||||
|
||||
// The paper type
|
||||
private Paper paper;
|
||||
|
||||
/**
|
||||
* This method creates a default page layout, which will be in portrait
|
||||
* format.
|
||||
*/
|
||||
public PageFormat()
|
||||
{
|
||||
this.paper = new Paper();
|
||||
this.orientation = PORTRAIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the width of the page, in 1/72nd's of an inch. The
|
||||
* "width" measured depends on orientation.
|
||||
*
|
||||
* @return The width of the page.
|
||||
*/
|
||||
public double getWidth()
|
||||
{
|
||||
return paper.getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the height of the page, in 1/72nd's of an inch. The
|
||||
* "height" measured depends on the orientation.
|
||||
*
|
||||
* @return The height of the page.
|
||||
*/
|
||||
public double getHeight()
|
||||
{
|
||||
return paper.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate value of the upper leftmost drawable
|
||||
* area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable X coordinate.
|
||||
*/
|
||||
public double getImageableX()
|
||||
{
|
||||
return paper.getImageableX();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate value of the upper leftmost drawable
|
||||
* area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable Y coordinate.
|
||||
*/
|
||||
public double getImageableY()
|
||||
{
|
||||
return paper.getImageableY();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the imageable width of the paper, in 1/72nd's of an
|
||||
* inch.
|
||||
*
|
||||
* @return The imageable width of the paper.
|
||||
*/
|
||||
public double getImageableWidth()
|
||||
{
|
||||
return paper.getImageableWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the imageable height of the paper, in 1/72nd's of an
|
||||
* inch.
|
||||
*
|
||||
* @return The imageable height of the paper.
|
||||
*/
|
||||
public double getImageableHeight()
|
||||
{
|
||||
return paper.getImageableHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy of the <code>paper</code> object being used for this page
|
||||
* format.
|
||||
*
|
||||
* @return A copy of the <code>Paper</code> object for this format.
|
||||
*/
|
||||
public Paper getPaper()
|
||||
{
|
||||
return (Paper) paper.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>Paper</code> object to be used by this page format.
|
||||
*
|
||||
* @param paper The new <code>Paper</code> object for this page format.
|
||||
*/
|
||||
public void setPaper(Paper paper)
|
||||
{
|
||||
this.paper = paper;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the current page orientation. The value returned will
|
||||
* be one of the page orientation constants from this class.
|
||||
*
|
||||
* @return The current page orientation.
|
||||
*/
|
||||
public int getOrientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the page orientation for this format to the specified
|
||||
* value. It must be one of the page orientation constants from this class
|
||||
* or an exception will be thrown.
|
||||
*
|
||||
* @param orientation The new page orientation.
|
||||
* @exception IllegalArgumentException If the specified page orientation
|
||||
* value is not one of the constants from this class.
|
||||
*/
|
||||
public void setOrientation(int orientation) throws IllegalArgumentException
|
||||
{
|
||||
if ((orientation != PORTRAIT) && (orientation != LANDSCAPE)
|
||||
&& (orientation != REVERSE_LANDSCAPE))
|
||||
throw new IllegalArgumentException("Bad page orientation value: "
|
||||
+ orientation);
|
||||
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a matrix used for transforming user space coordinates
|
||||
* to page coordinates. The value returned will be six doubles as described
|
||||
* in <code>java.awt.geom.AffineTransform</code>.
|
||||
*
|
||||
* @return The transformation matrix for this page format.
|
||||
*/
|
||||
public double[] getMatrix()
|
||||
{
|
||||
throw new RuntimeException("Not implemented since I don't know what to do");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (super.clone());
|
||||
}
|
||||
catch (CloneNotSupportedException e)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns the width of the page, in 1/72nd's of an inch. The
|
||||
* "width" measured depends on orientation.
|
||||
*
|
||||
* @return The width of the page.
|
||||
*/
|
||||
public double
|
||||
getWidth()
|
||||
{
|
||||
return(paper.getWidth());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the height of the page, in 1/72nd's of an inch.
|
||||
* The "height" measured depends on the orientation.
|
||||
*
|
||||
* @return The height of the page.
|
||||
*/
|
||||
public double
|
||||
getHeight()
|
||||
{
|
||||
return(paper.getHeight());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate value of the upper leftmost
|
||||
* drawable area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable X coordinate.
|
||||
*/
|
||||
public double
|
||||
getImageableX()
|
||||
{
|
||||
return(paper.getImageableX());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate value of the upper leftmost
|
||||
* drawable area of the paper.
|
||||
*
|
||||
* @return The upper leftmost imageable Y coordinate.
|
||||
*/
|
||||
public double
|
||||
getImageableY()
|
||||
{
|
||||
return(paper.getImageableY());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the imageable width of the paper, in 1/72nd's of
|
||||
* an inch.
|
||||
*
|
||||
* @return The imageable width of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableWidth()
|
||||
{
|
||||
return(paper.getImageableWidth());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the imageable height of the paper, in 1/72nd's of
|
||||
* an inch.
|
||||
*
|
||||
* @return The imageable height of the paper.
|
||||
*/
|
||||
public double getImageableHeight()
|
||||
{
|
||||
return(paper.getImageableHeight());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns a copy of the <code>paper</code> object being used for this
|
||||
* page format.
|
||||
*
|
||||
* @return A copy of the <code>Paper</code> object for this format.
|
||||
*/
|
||||
public Paper
|
||||
getPaper()
|
||||
{
|
||||
return((Paper)paper.clone());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Sets the <code>Paper</code> object to be used by this page format.
|
||||
*
|
||||
* @param paper The new <code>Paper</code> object for this page format.
|
||||
*/
|
||||
public void
|
||||
setPaper(Paper paper)
|
||||
{
|
||||
this.paper = paper;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the current page orientation. The value returned
|
||||
* will be one of the page orientation constants from this class.
|
||||
*
|
||||
* @return The current page orientation.
|
||||
*/
|
||||
public int
|
||||
getOrientation()
|
||||
{
|
||||
return(orientation);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets the page orientation for this format to the
|
||||
* specified value. It must be one of the page orientation constants
|
||||
* from this class or an exception will be thrown.
|
||||
*
|
||||
* @param orientation The new page orientation.
|
||||
*
|
||||
* @exception IllegalArgumentException If the specified page orientation
|
||||
* value is not one of the constants from this class.
|
||||
*/
|
||||
public void
|
||||
setOrientation(int orientation) throws IllegalArgumentException
|
||||
{
|
||||
if ((orientation != PORTRAIT) &&
|
||||
(orientation != LANDSCAPE) &&
|
||||
(orientation != REVERSE_LANDSCAPE))
|
||||
throw new IllegalArgumentException("Bad page orientation value: " +
|
||||
orientation);
|
||||
|
||||
this.orientation = orientation;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns a matrix used for transforming user space
|
||||
* coordinates to page coordinates. The value returned will be six
|
||||
* doubles as described in <code>java.awt.geom.AffineTransform</code>.
|
||||
*
|
||||
* @return The transformation matrix for this page format.
|
||||
*/
|
||||
public double[]
|
||||
getMatrix()
|
||||
{
|
||||
throw new RuntimeException("Not implemented since I don't know what to do");
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object
|
||||
clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return(super.clone());
|
||||
}
|
||||
catch(CloneNotSupportedException e)
|
||||
{
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
} // class PageFormat
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Pageable.java -- Pages to be printed
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,75 +39,52 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This interface represents pages that are to be printed.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
* This interface represents pages that are to be printed.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public interface Pageable
|
||||
{
|
||||
/**
|
||||
* This constant is returned when <code>getNumberOfPages()</code> cannot
|
||||
* determine the number of pages available for printing.
|
||||
*/
|
||||
int UNKNOWN_NUMBER_OF_PAGES = - 1;
|
||||
|
||||
/*
|
||||
* Static Variables
|
||||
*/
|
||||
/**
|
||||
* This method returns the number of pages this object contains, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if it cannot determine the number
|
||||
* of pages to be printed.
|
||||
*
|
||||
* @return The number of pages to be printed, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if this is unknown.
|
||||
*/
|
||||
int getNumberOfPages();
|
||||
|
||||
/**
|
||||
* This constant is returned when <code>getNumberOfPages()</code>
|
||||
* cannot determine the number of pages available for printing.
|
||||
*/
|
||||
int UNKNOWN_NUMBER_OF_PAGES = -1;
|
||||
/**
|
||||
* This method returns the <code>PageFormat</code> instance for the
|
||||
* specified page. Page numbers start at zero. An exception is thrown if the
|
||||
* requested page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>PageFormat</code> for.
|
||||
* @return The <code>PageFormat</code> for the requested page.
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method returns the number of pages this object contains, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if it cannot determine the number
|
||||
* of pages to be printed.
|
||||
*
|
||||
* @return The number of pages to be printed, or
|
||||
* <code>UNKNOWN_NUMBER_OF_PAGES</code> if this is unknown.
|
||||
*/
|
||||
int
|
||||
getNumberOfPages();
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the <code>PageFormat</code> instance for the
|
||||
* specified page. Page numbers start at zero. An exception is thrown if
|
||||
* the requested page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>PageFormat</code> for.
|
||||
*
|
||||
* @return The <code>PageFormat</code> for the requested page.
|
||||
*
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
PageFormat
|
||||
getPageFormat(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the <code>Printable</code> instance for the
|
||||
* specified page. Page numbers start at zero. An exception is thrown if
|
||||
* the requested page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>Printable</code> for.
|
||||
*
|
||||
* @return The <code>Printable</code> for the requested page.
|
||||
*
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
Printable
|
||||
getPrintable(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
} // interface Pageable
|
||||
/**
|
||||
* This method returns the <code>Printable</code> instance for the specified
|
||||
* page. Page numbers start at zero. An exception is thrown if the requested
|
||||
* page does not exist.
|
||||
*
|
||||
* @param pageIndex The index of the page to return the
|
||||
* <code>Printable</code> for.
|
||||
* @return The <code>Printable</code> for the requested page.
|
||||
* @exception IndexOutOfBoundsException If the requested page number does
|
||||
* not exist.
|
||||
*/
|
||||
Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Paper.java -- Information about a paper type.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,198 +39,159 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This class describes a particular type of paper.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public class Paper implements Cloneable
|
||||
{
|
||||
|
||||
/*
|
||||
* Instance Variables
|
||||
* This class describes a particular type of paper.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
|
||||
// Height of the paper
|
||||
private double height;
|
||||
|
||||
// Width of the paper
|
||||
private double width;
|
||||
|
||||
// Upper left imageable X coordinate
|
||||
private double imageableX;
|
||||
|
||||
// Upper left imageable Y coordinate
|
||||
private double imageableY;
|
||||
|
||||
// Imageable width of the page
|
||||
private double imageableWidth;
|
||||
|
||||
// Imageable height of the page
|
||||
private double imageableHeight;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
/**
|
||||
* This method creates a letter sized paper with one inch margins
|
||||
*/
|
||||
public
|
||||
Paper()
|
||||
public class Paper
|
||||
implements Cloneable
|
||||
{
|
||||
width = 8.5 * 72;
|
||||
height = 11 * 72;
|
||||
imageableX = 72;
|
||||
imageableY = 72;
|
||||
imageableWidth = width - (2 * 72);
|
||||
imageableHeight = height - (2 * 72);
|
||||
// Height of the paper
|
||||
private double height;
|
||||
|
||||
// Width of the paper
|
||||
private double width;
|
||||
|
||||
// Upper left imageable X coordinate
|
||||
private double imageableX;
|
||||
|
||||
// Upper left imageable Y coordinate
|
||||
private double imageableY;
|
||||
|
||||
// Imageable width of the page
|
||||
private double imageableWidth;
|
||||
|
||||
// Imageable height of the page
|
||||
private double imageableHeight;
|
||||
|
||||
/**
|
||||
* This method creates a letter sized paper with one inch margins
|
||||
*/
|
||||
public Paper()
|
||||
{
|
||||
width = 8.5 * 72;
|
||||
height = 11 * 72;
|
||||
imageableX = 72;
|
||||
imageableY = 72;
|
||||
imageableWidth = width - (2 * 72);
|
||||
imageableHeight = height - (2 * 72);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the height of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The width of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate of the upper left hand corner of the
|
||||
* imageable area of the paper.
|
||||
*
|
||||
* @return The X coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double getImageableX()
|
||||
{
|
||||
return imageableX;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate of the upper left hand corner of the
|
||||
* imageable area of the paper.
|
||||
*
|
||||
* @return The Y coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double getImageableY()
|
||||
{
|
||||
return imageableY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of the imageable area of the paper.
|
||||
*
|
||||
* @return The width of the imageable area of the paper.
|
||||
*/
|
||||
public double getImageableWidth()
|
||||
{
|
||||
return imageableWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the imageable area of the paper.
|
||||
*
|
||||
* @return The height of the imageable area of the paper.
|
||||
*/
|
||||
public double getImageableHeight()
|
||||
{
|
||||
return imageableHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the size of the paper to the specified width and height,
|
||||
* which are specified in 1/72nds of an inch.
|
||||
*
|
||||
* @param width The width of the paper in 1/72nds of an inch.
|
||||
* @param height The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public void setSize(double width, double height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the imageable area of the paper by specifying the
|
||||
* coordinates of the upper left hand corner of that area, and its length
|
||||
* and height. All values are in 1/72nds of an inch.
|
||||
*
|
||||
* @param imageableX The X coordinate of the upper left hand corner of the
|
||||
* imageable area, in 1/72nds of an inch.
|
||||
* @param imageableY The Y coordinate of the upper left hand corner of the
|
||||
* imageable area, in 1/72nds of an inch.
|
||||
* @param imageableWidth The width of the imageable area of the paper, in
|
||||
* 1/72nds of an inch.
|
||||
* @param imageableHeight The heigth of the imageable area of the paper, in
|
||||
* 1/72nds of an inch.
|
||||
*/
|
||||
public void setImageableArea(double imageableX, double imageableY,
|
||||
double imageableWidth, double imageableHeight)
|
||||
{
|
||||
this.imageableX = imageableX;
|
||||
this.imageableY = imageableY;
|
||||
this.imageableWidth = imageableWidth;
|
||||
this.imageableHeight = imageableHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (super.clone());
|
||||
}
|
||||
catch (CloneNotSupportedException e)
|
||||
{
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the height of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double
|
||||
getHeight()
|
||||
{
|
||||
return(height);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the width of the paper in 1/72nds of an inch.
|
||||
*
|
||||
* @return The width of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public double
|
||||
getWidth()
|
||||
{
|
||||
return(width);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the X coordinate of the upper left hand corner
|
||||
* of the imageable area of the paper.
|
||||
*
|
||||
* @return The X coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableX()
|
||||
{
|
||||
return(imageableX);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method returns the Y coordinate of the upper left hand corner
|
||||
* of the imageable area of the paper.
|
||||
*
|
||||
* @return The Y coordinate of the upper left hand corner of the imageable
|
||||
* area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableY()
|
||||
{
|
||||
return(imageableY);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the width of the imageable area of the paper.
|
||||
*
|
||||
* @return The width of the imageable area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableWidth()
|
||||
{
|
||||
return(imageableWidth);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Returns the height of the imageable area of the paper.
|
||||
*
|
||||
* @return The height of the imageable area of the paper.
|
||||
*/
|
||||
public double
|
||||
getImageableHeight()
|
||||
{
|
||||
return(imageableHeight);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets the size of the paper to the specified width and
|
||||
* height, which are specified in 1/72nds of an inch.
|
||||
*
|
||||
* @param width The width of the paper in 1/72nds of an inch.
|
||||
* @param height The height of the paper in 1/72nds of an inch.
|
||||
*/
|
||||
public void
|
||||
setSize(double width, double height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method sets the imageable area of the paper by specifying the
|
||||
* coordinates of the upper left hand corner of that area, and its
|
||||
* length and height. All values are in 1/72nds of an inch.
|
||||
*
|
||||
* @param imageableX The X coordinate of the upper left hand corner of
|
||||
* the imageable area, in 1/72nds of an inch.
|
||||
* @param imageableY The Y coordinate of the upper left hand corner of
|
||||
* the imageable area, in 1/72nds of an inch.
|
||||
* @param imageableWidth The width of the imageable area of the paper,
|
||||
* in 1/72nds of an inch.
|
||||
* @param imageableHeight The heigth of the imageable area of the paper,
|
||||
* in 1/72nds of an inch.
|
||||
*/
|
||||
public void
|
||||
setImageableArea(double imageableX, double imageableY,
|
||||
double imageableWidth, double imageableHeight)
|
||||
{
|
||||
this.imageableX = imageableX;
|
||||
this.imageableY = imageableY;
|
||||
this.imageableWidth = imageableWidth;
|
||||
this.imageableHeight = imageableHeight;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* This method creates a copy of this object.
|
||||
*
|
||||
* @return A copy of this object.
|
||||
*/
|
||||
public Object
|
||||
clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return(super.clone());
|
||||
}
|
||||
catch(CloneNotSupportedException e)
|
||||
{
|
||||
return(null);
|
||||
}
|
||||
}
|
||||
|
||||
} // class Paper
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PrinterGraphics.java -- Hook to return print job controller.
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,23 +39,20 @@ exception statement from your version. */
|
|||
package java.awt.print;
|
||||
|
||||
/**
|
||||
* This interface is implemented by the <code>Graphics</code> instance
|
||||
* that is used for rendering pages. It provides a hook to return the
|
||||
* object that is controlling the print job.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
* This interface is implemented by the <code>Graphics</code> instance that is
|
||||
* used for rendering pages. It provides a hook to return the object that is
|
||||
* controlling the print job.
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
*/
|
||||
public interface PrinterGraphics
|
||||
{
|
||||
/**
|
||||
* This method returns the instance of <code>PrinterJob</code> that is
|
||||
* controlling this print job.
|
||||
*
|
||||
* @return The <code>PrinterJob</code> that is controlling this print job.
|
||||
*/
|
||||
PrinterJob getPrinterJob();
|
||||
|
||||
/**
|
||||
* This method returns the instance of <code>PrinterJob</code> that is
|
||||
* controlling this print job.
|
||||
*
|
||||
* @return The <code>PrinterJob</code> that is controlling this print job.
|
||||
*/
|
||||
PrinterJob
|
||||
getPrinterJob();
|
||||
|
||||
} // interface PrinterGraphics
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* PrinterJob.java -- This job is the printer control class
|
||||
Copyright (C) 1999, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -61,7 +61,7 @@ public abstract class PrinterJob
|
|||
public static PrinterJob getPrinterJob()
|
||||
{
|
||||
// FIXME: Need to fix this to load a default implementation instance.
|
||||
return null;
|
||||
return new NoPrinterJob();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -157,6 +157,23 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate
|
|||
protected void initialize(Class type, Object oldInstance, Object newInstance,
|
||||
Encoder out)
|
||||
{
|
||||
// Calling the supertype's implementation of initialize makes it
|
||||
// possible that descendants of classes like AbstractHashMap
|
||||
// or Hashtable are serialized correctly. This mechanism grounds on
|
||||
// two other facts:
|
||||
// * Each class which has not registered a special purpose
|
||||
// PersistenceDelegate is handled by a DefaultPersistenceDelegate
|
||||
// instance.
|
||||
// * PersistenceDelegate.initialize() is implemented in a way that it
|
||||
// calls the initialize method of the superclass' persistence delegate.
|
||||
super.initialize(type, oldInstance, newInstance, out);
|
||||
|
||||
// Suppresses the writing of property setting statements when this delegate
|
||||
// is not used for the exact instance type. By doing so the following code
|
||||
// is called only once per object.
|
||||
if (type != oldInstance.getClass())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
PropertyDescriptor[] propertyDescs = Introspector.getBeanInfo(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Encoder.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,21 +38,16 @@
|
|||
|
||||
package java.beans;
|
||||
|
||||
import gnu.java.beans.DefaultExceptionListener;
|
||||
import gnu.java.beans.encoder.ArrayPersistenceDelegate;
|
||||
import gnu.java.beans.encoder.ClassPersistenceDelegate;
|
||||
import gnu.java.beans.encoder.CollectionPersistenceDelegate;
|
||||
import gnu.java.beans.encoder.MapPersistenceDelegate;
|
||||
import gnu.java.beans.encoder.PrimitivePersistenceDelegate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
|
@ -123,31 +118,11 @@ public class Encoder
|
|||
delegates.put(Object[].class, new ArrayPersistenceDelegate());
|
||||
|
||||
pd = new CollectionPersistenceDelegate();
|
||||
delegates.put(ArrayList.class, pd);
|
||||
delegates.put(LinkedList.class, pd);
|
||||
delegates.put(Vector.class, pd);
|
||||
delegates.put(HashSet.class, pd);
|
||||
delegates.put(LinkedHashSet.class, pd);
|
||||
delegates.put(TreeSet.class, pd);
|
||||
delegates.put(AbstractCollection.class, pd);
|
||||
|
||||
pd = new MapPersistenceDelegate();
|
||||
delegates.put(HashMap.class, pd);
|
||||
delegates.put(TreeMap.class, pd);
|
||||
delegates.put(java.util.AbstractMap.class, pd);
|
||||
delegates.put(java.util.Hashtable.class, pd);
|
||||
delegates.put(java.util.IdentityHashMap.class, pd);
|
||||
|
||||
delegates.put(java.util.LinkedHashMap.class, pd);
|
||||
delegates.put(java.util.Properties.class, pd);
|
||||
|
||||
delegates.put(java.awt.RenderingHints.class, pd);
|
||||
delegates.put(java.util.WeakHashMap.class, pd);
|
||||
delegates.put(javax.swing.UIDefaults.class, pd);
|
||||
|
||||
// TODO: These classes need to be implemented first
|
||||
//delegates.put(java.security.AuthProvider.class, pd);
|
||||
//delegates.put(java.util.concurrent.ConcurrentHashMap.class, pd);
|
||||
//delegates.put(java.util.EnumMap.class, pd);
|
||||
//delegates.put(javax.management.openmbean.TabularDataSupport.class, pd);
|
||||
|
||||
defaultPersistenceDelegate = new DefaultPersistenceDelegate();
|
||||
delegates.put(Object.class, defaultPersistenceDelegate);
|
||||
|
@ -194,14 +169,8 @@ public class Encoder
|
|||
*/
|
||||
public void setExceptionListener(ExceptionListener listener)
|
||||
{
|
||||
exceptionListener = (listener != null) ? listener : new ExceptionListener()
|
||||
{
|
||||
public void exceptionThrown(Exception e)
|
||||
{
|
||||
System.err.println("exception thrown: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
exceptionListener = (listener != null)
|
||||
? listener : DefaultExceptionListener.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,9 +59,8 @@ public abstract class PersistenceDelegate
|
|||
{
|
||||
type = type.getSuperclass();
|
||||
|
||||
PersistenceDelegate pd = out.getPersistenceDelegate(
|
||||
oldInstance.getClass().getSuperclass());
|
||||
|
||||
PersistenceDelegate pd = out.getPersistenceDelegate(type);
|
||||
|
||||
pd.initialize(type, oldInstance, newInstance, out);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* PropertyChangeSupport.java -- support to manage property change listeners
|
||||
Copyright (C) 1998, 1999, 2000, 2002, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -120,14 +121,17 @@ public class PropertyChangeSupport implements Serializable
|
|||
* property change events will be sent to this listener. The listener add
|
||||
* is not unique: that is, <em>n</em> adds with the same listener will
|
||||
* result in <em>n</em> events being sent to that listener for every
|
||||
* property change. Adding a null listener may cause a NullPointerException
|
||||
* down the road. This method will unwrap a PropertyChangeListenerProxy,
|
||||
* property change. Adding a null listener is silently ignored.
|
||||
* This method will unwrap a PropertyChangeListenerProxy,
|
||||
* registering the underlying delegate to the named property list.
|
||||
*
|
||||
* @param l the listener to add
|
||||
*/
|
||||
public synchronized void addPropertyChangeListener(PropertyChangeListener l)
|
||||
{
|
||||
if (l == null)
|
||||
return;
|
||||
|
||||
if (l instanceof PropertyChangeListenerProxy)
|
||||
{
|
||||
PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
|
||||
|
@ -216,8 +220,8 @@ public class PropertyChangeSupport implements Serializable
|
|||
* cumulative, too; if you are registered to listen to receive events on
|
||||
* all property changes, and then you register on a particular property,
|
||||
* you will receive change events for that property twice. Adding a null
|
||||
* listener may cause a NullPointerException down the road. This method
|
||||
* will unwrap a PropertyChangeListenerProxy, registering the underlying
|
||||
* listener is silently ignored. This method will unwrap a
|
||||
* PropertyChangeListenerProxy, registering the underlying
|
||||
* delegate to the named property list if the names match, and discarding
|
||||
* it otherwise.
|
||||
*
|
||||
|
@ -228,6 +232,9 @@ public class PropertyChangeSupport implements Serializable
|
|||
public synchronized void addPropertyChangeListener(String propertyName,
|
||||
PropertyChangeListener l)
|
||||
{
|
||||
if (l == null)
|
||||
return;
|
||||
|
||||
while (l instanceof PropertyChangeListenerProxy)
|
||||
{
|
||||
PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
|
||||
|
@ -290,17 +297,16 @@ public class PropertyChangeSupport implements Serializable
|
|||
|
||||
/**
|
||||
* Returns an array of all property change listeners registered under the
|
||||
* given property name. If there are no registered listeners, this returns
|
||||
* an empty array.
|
||||
* given property name. If there are no registered listeners, or
|
||||
* propertyName is null, this returns an empty array.
|
||||
*
|
||||
* @return the array of registered listeners
|
||||
* @throws NullPointerException if propertyName is null
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized PropertyChangeListener[]
|
||||
getPropertyChangeListeners(String propertyName)
|
||||
{
|
||||
if (children == null)
|
||||
if (children == null || propertyName == null)
|
||||
return new PropertyChangeListener[0];
|
||||
PropertyChangeSupport s
|
||||
= (PropertyChangeSupport) children.get(propertyName);
|
||||
|
@ -455,7 +461,6 @@ public class PropertyChangeSupport implements Serializable
|
|||
*
|
||||
* @param propertyName the property that may be listened on
|
||||
* @return whether the property is being listened on
|
||||
* @throws NullPointerException if propertyName is null
|
||||
*/
|
||||
public synchronized boolean hasListeners(String propertyName)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,8 @@ exception statement from your version. */
|
|||
|
||||
package java.beans;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
|
@ -344,6 +346,71 @@ public class PropertyDescriptor extends FeatureDescriptor
|
|||
this.propertyEditorClass = propertyEditorClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate a property editor using the property editor class.
|
||||
* If no property editor class has been set, this will return null.
|
||||
* If the editor class has a public constructor which takes a single
|
||||
* argument, that will be used and the bean parameter will be passed
|
||||
* to it. Otherwise, a public no-argument constructor will be used,
|
||||
* if available. This method will return null if no constructor is
|
||||
* found or if construction fails for any reason.
|
||||
* @param bean the argument to the constructor
|
||||
* @return a new PropertyEditor, or null on error
|
||||
* @since 1.5
|
||||
*/
|
||||
public PropertyEditor createPropertyEditor(Object bean)
|
||||
{
|
||||
if (propertyEditorClass == null)
|
||||
return null;
|
||||
Constructor c = findConstructor(propertyEditorClass,
|
||||
new Class[] { Object.class });
|
||||
if (c != null)
|
||||
return instantiateClass(c, new Object[] { bean });
|
||||
c = findConstructor(propertyEditorClass, null);
|
||||
if (c != null)
|
||||
return instantiateClass(c, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Helper method to look up a constructor and return null if it is not
|
||||
// found.
|
||||
private Constructor findConstructor(Class k, Class[] argTypes)
|
||||
{
|
||||
try
|
||||
{
|
||||
return k.getConstructor(argTypes);
|
||||
}
|
||||
catch (NoSuchMethodException _)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper method to instantiate an object but return null on error.
|
||||
private PropertyEditor instantiateClass(Constructor c, Object[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (PropertyEditor) c.newInstance(args);
|
||||
}
|
||||
catch (InstantiationException _)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (InvocationTargetException _)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (IllegalAccessException _)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (ClassCastException _)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void findMethods(
|
||||
Class beanClass,
|
||||
String getMethodName1,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* java.beans.XMLDecoder --
|
||||
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,7 +38,7 @@ exception statement from your version. */
|
|||
|
||||
package java.beans;
|
||||
|
||||
import gnu.java.beans.decoder.DefaultExceptionListener;
|
||||
import gnu.java.beans.DefaultExceptionListener;
|
||||
import gnu.java.beans.decoder.PersistenceParser;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -289,7 +289,7 @@ public class XMLDecoder
|
|||
// uses a default implementation when null
|
||||
if (listener == null)
|
||||
{
|
||||
listener = new DefaultExceptionListener();
|
||||
listener = DefaultExceptionListener.INSTANCE;
|
||||
}
|
||||
exceptionListener = listener;
|
||||
}
|
||||
|
|
|
@ -168,6 +168,8 @@ public class XMLEncoder extends Encoder
|
|||
// an erroneous state to the ScanEngine without behaving different
|
||||
// to the JDK.
|
||||
scanEngine.revoke();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
writeObject(value);
|
||||
|
|
|
@ -193,10 +193,8 @@ public abstract class InputStream
|
|||
*/
|
||||
public int read(byte[] b, int off, int len) throws IOException
|
||||
{
|
||||
if (off < 0 || len < 0 || off + len > b.length)
|
||||
if (off < 0 || len < 0 || b.length - off < len)
|
||||
throw new IndexOutOfBoundsException();
|
||||
if (b.length == 0)
|
||||
return 0;
|
||||
|
||||
int i, ch;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* InputStreamReader.java -- Reader than transforms bytes to chars
|
||||
Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,6 +39,7 @@ exception statement from your version. */
|
|||
|
||||
package java.io;
|
||||
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.nio.charset.EncodingHelper;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -145,7 +147,7 @@ public class InputStreamReader extends Reader
|
|||
this.in = in;
|
||||
try
|
||||
{
|
||||
encoding = System.getProperty("file.encoding");
|
||||
encoding = SystemProperties.getProperty("file.encoding");
|
||||
// Don't use NIO if avoidable
|
||||
if(EncodingHelper.isISOLatin1(encoding))
|
||||
{
|
||||
|
@ -231,12 +233,20 @@ public class InputStreamReader extends Reader
|
|||
* charset to decode the bytes in the InputStream into
|
||||
* characters.
|
||||
*
|
||||
* @since 1.5
|
||||
* @since 1.4
|
||||
*/
|
||||
public InputStreamReader(InputStream in, Charset charset) {
|
||||
if (in == null)
|
||||
throw new NullPointerException();
|
||||
this.in = in;
|
||||
decoder = charset.newDecoder();
|
||||
|
||||
try {
|
||||
maxBytesPerChar = charset.newEncoder().maxBytesPerChar();
|
||||
} catch(UnsupportedOperationException _){
|
||||
maxBytesPerChar = 1f;
|
||||
}
|
||||
|
||||
decoder.onMalformedInput(CodingErrorAction.REPLACE);
|
||||
decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
|
||||
decoder.reset();
|
||||
|
@ -247,9 +257,11 @@ public class InputStreamReader extends Reader
|
|||
* Creates an InputStreamReader that uses the given charset decoder
|
||||
* to decode the bytes in the InputStream into characters.
|
||||
*
|
||||
* @since 1.5
|
||||
* @since 1.4
|
||||
*/
|
||||
public InputStreamReader(InputStream in, CharsetDecoder decoder) {
|
||||
if (in == null)
|
||||
throw new NullPointerException();
|
||||
this.in = in;
|
||||
this.decoder = decoder;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ObjectInputStream.java -- Class used to read serialized objects
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
@ -555,8 +555,7 @@ public class ObjectInputStream extends InputStream
|
|||
classLookupTable.put(clazz, osc);
|
||||
setBlockDataMode(oldmode);
|
||||
|
||||
// find the first non-serializable, non-abstract
|
||||
// class in clazz's inheritance hierarchy
|
||||
// find the first non-serializable class in clazz's inheritance hierarchy
|
||||
Class first_nonserial = clazz.getSuperclass();
|
||||
// Maybe it is a primitive class, those don't have a super class,
|
||||
// or Object itself. Otherwise we can keep getting the superclass
|
||||
|
@ -565,9 +564,8 @@ public class ObjectInputStream extends InputStream
|
|||
if (first_nonserial == null)
|
||||
first_nonserial = clazz;
|
||||
else
|
||||
while (Serializable.class.isAssignableFrom(first_nonserial)
|
||||
|| Modifier.isAbstract(first_nonserial.getModifiers()))
|
||||
first_nonserial = first_nonserial.getSuperclass();
|
||||
while (Serializable.class.isAssignableFrom(first_nonserial))
|
||||
first_nonserial = first_nonserial.getSuperclass();
|
||||
|
||||
final Class local_constructor_class = first_nonserial;
|
||||
|
||||
|
@ -1596,7 +1594,14 @@ public class ObjectInputStream extends InputStream
|
|||
|
||||
private void readNextBlock() throws IOException
|
||||
{
|
||||
readNextBlock(this.realInputStream.readByte());
|
||||
byte marker = this.realInputStream.readByte();
|
||||
while (marker == TC_RESET)
|
||||
{
|
||||
if(dump) dumpElementln("RESET");
|
||||
clearHandles();
|
||||
marker = this.realInputStream.readByte();
|
||||
}
|
||||
readNextBlock(marker);
|
||||
}
|
||||
|
||||
private void readNextBlock(byte marker) throws IOException
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* ObjectOutputStream.java -- Class used to write serialized objects
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
@ -421,6 +421,8 @@ public class ObjectOutputStream extends OutputStream
|
|||
for (int i = 0; i < intfs.length; i++)
|
||||
realOutput.writeUTF(intfs[i].getName());
|
||||
|
||||
assignNewHandle(osc);
|
||||
|
||||
boolean oldmode = setBlockDataMode(true);
|
||||
annotateProxyClass(osc.forClass());
|
||||
setBlockDataMode(oldmode);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -70,7 +70,7 @@ public class ClassNotFoundException extends Exception
|
|||
*/
|
||||
public ClassNotFoundException()
|
||||
{
|
||||
this(null, null);
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +81,8 @@ public class ClassNotFoundException extends Exception
|
|||
*/
|
||||
public ClassNotFoundException(String s)
|
||||
{
|
||||
this(s, null);
|
||||
super(s);
|
||||
ex = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* java.lang.Math -- common mathematical functions, native allowed
|
||||
Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
/* java.lang.Math -- common mathematical functions, native allowed (VMMath)
|
||||
Copyright (C) 1998, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -52,10 +52,26 @@ import java.util.Random;
|
|||
* @author Paul Fisher
|
||||
* @author John Keiser
|
||||
* @author Eric Blake (ebb9@email.byu.edu)
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class Math
|
||||
{
|
||||
|
||||
// FIXME - This is here because we need to load the "javalang" system
|
||||
// library somewhere late in the bootstrap cycle. We cannot do this
|
||||
// from VMSystem or VMRuntime since those are used to actually load
|
||||
// the library. This is mainly here because historically Math was
|
||||
// late enough in the bootstrap cycle to start using System after it
|
||||
// was initialized (called from the java.util classes).
|
||||
static
|
||||
{
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
{
|
||||
System.loadLibrary("javalang");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Math is non-instantiable
|
||||
*/
|
||||
|
@ -63,14 +79,6 @@ public final class Math
|
|||
{
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
{
|
||||
System.loadLibrary("javalang");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A random number generator, initialized on first use.
|
||||
*/
|
||||
|
@ -298,7 +306,10 @@ public final class Math
|
|||
* @param a the angle (in radians)
|
||||
* @return sin(a)
|
||||
*/
|
||||
public static native double sin(double a);
|
||||
public static double sin(double a)
|
||||
{
|
||||
return VMMath.sin(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigonometric function <em>cos</em>. The cosine of NaN or infinity is
|
||||
|
@ -307,7 +318,10 @@ public final class Math
|
|||
* @param a the angle (in radians)
|
||||
* @return cos(a)
|
||||
*/
|
||||
public static native double cos(double a);
|
||||
public static double cos(double a)
|
||||
{
|
||||
return VMMath.cos(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigonometric function <em>tan</em>. The tangent of NaN or infinity
|
||||
|
@ -317,7 +331,10 @@ public final class Math
|
|||
* @param a the angle (in radians)
|
||||
* @return tan(a)
|
||||
*/
|
||||
public static native double tan(double a);
|
||||
public static double tan(double a)
|
||||
{
|
||||
return VMMath.tan(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigonometric function <em>arcsin</em>. The range of angles returned
|
||||
|
@ -328,7 +345,10 @@ public final class Math
|
|||
* @param a the sin to turn back into an angle
|
||||
* @return arcsin(a)
|
||||
*/
|
||||
public static native double asin(double a);
|
||||
public static double asin(double a)
|
||||
{
|
||||
return VMMath.asin(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigonometric function <em>arccos</em>. The range of angles returned
|
||||
|
@ -339,7 +359,10 @@ public final class Math
|
|||
* @param a the cos to turn back into an angle
|
||||
* @return arccos(a)
|
||||
*/
|
||||
public static native double acos(double a);
|
||||
public static double acos(double a)
|
||||
{
|
||||
return VMMath.acos(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* The trigonometric function <em>arcsin</em>. The range of angles returned
|
||||
|
@ -351,7 +374,10 @@ public final class Math
|
|||
* @return arcsin(a)
|
||||
* @see #atan2(double, double)
|
||||
*/
|
||||
public static native double atan(double a);
|
||||
public static double atan(double a)
|
||||
{
|
||||
return VMMath.atan(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* A special version of the trigonometric function <em>arctan</em>, for
|
||||
|
@ -400,7 +426,10 @@ public final class Math
|
|||
* @return <em>theta</em> in the conversion of (x, y) to (r, theta)
|
||||
* @see #atan(double)
|
||||
*/
|
||||
public static native double atan2(double y, double x);
|
||||
public static double atan2(double y, double x)
|
||||
{
|
||||
return VMMath.atan2(y,x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take <em>e</em><sup>a</sup>. The opposite of <code>log()</code>. If the
|
||||
|
@ -414,7 +443,10 @@ public final class Math
|
|||
* @see #log(double)
|
||||
* @see #pow(double, double)
|
||||
*/
|
||||
public static native double exp(double a);
|
||||
public static double exp(double a)
|
||||
{
|
||||
return VMMath.exp(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take ln(a) (the natural log). The opposite of <code>exp()</code>. If the
|
||||
|
@ -430,7 +462,10 @@ public final class Math
|
|||
* @return the natural log of <code>a</code>
|
||||
* @see #exp(double)
|
||||
*/
|
||||
public static native double log(double a);
|
||||
public static double log(double a)
|
||||
{
|
||||
return VMMath.log(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a square root. If the argument is NaN or negative, the result is
|
||||
|
@ -438,13 +473,18 @@ public final class Math
|
|||
* infinity; and if the result is either zero, the result is the same.
|
||||
* This is accurate within the limits of doubles.
|
||||
*
|
||||
* <p>For other roots, use pow(a, 1 / rootNumber).
|
||||
* <p>For a cube root, use <code>cbrt</code>. For other roots, use
|
||||
* <code>pow(a, 1 / rootNumber)</code>.</p>
|
||||
*
|
||||
* @param a the numeric argument
|
||||
* @return the square root of the argument
|
||||
* @see #cbrt(double)
|
||||
* @see #pow(double, double)
|
||||
*/
|
||||
public static native double sqrt(double a);
|
||||
public static double sqrt(double a)
|
||||
{
|
||||
return VMMath.sqrt(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a number to a power. Special cases:<ul>
|
||||
|
@ -514,7 +554,10 @@ public final class Math
|
|||
* @param b the power to raise it to
|
||||
* @return a<sup>b</sup>
|
||||
*/
|
||||
public static native double pow(double a, double b);
|
||||
public static double pow(double a, double b)
|
||||
{
|
||||
return VMMath.pow(a,b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IEEE 754 floating point remainder on two numbers. This is the
|
||||
|
@ -530,7 +573,10 @@ public final class Math
|
|||
* @return the IEEE 754-defined floating point remainder of x/y
|
||||
* @see #rint(double)
|
||||
*/
|
||||
public static native double IEEEremainder(double x, double y);
|
||||
public static double IEEEremainder(double x, double y)
|
||||
{
|
||||
return VMMath.IEEEremainder(x,y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the nearest integer that is that is greater than or equal to the
|
||||
|
@ -541,7 +587,10 @@ public final class Math
|
|||
* @param a the value to act upon
|
||||
* @return the nearest integer >= <code>a</code>
|
||||
*/
|
||||
public static native double ceil(double a);
|
||||
public static double ceil(double a)
|
||||
{
|
||||
return VMMath.ceil(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the nearest integer that is that is less than or equal to the
|
||||
|
@ -551,7 +600,10 @@ public final class Math
|
|||
* @param a the value to act upon
|
||||
* @return the nearest integer <= <code>a</code>
|
||||
*/
|
||||
public static native double floor(double a);
|
||||
public static double floor(double a)
|
||||
{
|
||||
return VMMath.floor(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the nearest integer to the argument. If it is exactly between
|
||||
|
@ -561,7 +613,10 @@ public final class Math
|
|||
* @param a the value to act upon
|
||||
* @return the nearest integer to <code>a</code>
|
||||
*/
|
||||
public static native double rint(double a);
|
||||
public static double rint(double a)
|
||||
{
|
||||
return VMMath.rint(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the nearest integer to the argument. This is equivalent to
|
||||
|
@ -647,4 +702,250 @@ public final class Math
|
|||
{
|
||||
return (rads * 180) / PI;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Take a cube root. If the argument is <code>NaN</code>, an infinity or
|
||||
* zero, then the original value is returned. The returned result is
|
||||
* within 1 ulp of the exact result. For a finite value, <code>x</code>,
|
||||
* the cube root of <code>-x</code> is equal to the negation of the cube root
|
||||
* of <code>x</code>.
|
||||
* </p>
|
||||
* <p>
|
||||
* For a square root, use <code>sqrt</code>. For other roots, use
|
||||
* <code>pow(a, 1 / rootNumber)</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument
|
||||
* @return the cube root of the argument
|
||||
* @see #sqrt(double)
|
||||
* @see #pow(double, double)
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double cbrt(double a)
|
||||
{
|
||||
return VMMath.cbrt(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the hyperbolic cosine of the given value. For a value,
|
||||
* <code>x</code>, the hyperbolic cosine is <code>(e<sup>x</sup> +
|
||||
* e<sup>-x</sup>)/2</code>
|
||||
* with <code>e</code> being <a href="#E">Euler's number</a>. The returned
|
||||
* result is within 2.5 ulps of the exact result.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the supplied value is <code>NaN</code>, then the original value is
|
||||
* returned. For either infinity, positive infinity is returned.
|
||||
* The hyperbolic cosine of zero is 1.0.
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument
|
||||
* @return the hyperbolic cosine of <code>a</code>.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double cosh(double a)
|
||||
{
|
||||
return VMMath.cosh(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns <code>e<sup>a</sup> - 1. For values close to 0, the
|
||||
* result of <code>expm1(a) + 1</code> tend to be much closer to the
|
||||
* exact result than simply <code>exp(x)</code>. The result is within
|
||||
* 1 ulp of the exact result, and results are semi-monotonic. For finite
|
||||
* inputs, the returned value is greater than or equal to -1.0. Once
|
||||
* a result enters within half a ulp of this limit, the limit is returned.
|
||||
* </p>
|
||||
* <p>
|
||||
* For <code>NaN</code>, positive infinity and zero, the original value
|
||||
* is returned. Negative infinity returns a result of -1.0 (the limit).
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument
|
||||
* @return <code>e<sup>a</sup> - 1</code>
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double expm1(double a)
|
||||
{
|
||||
return VMMath.expm1(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the hypotenuse, <code>a<sup>2</sup> + b<sup>2</sup></code>,
|
||||
* without intermediate overflow or underflow. The returned result is
|
||||
* within 1 ulp of the exact result. If one parameter is held constant,
|
||||
* then the result in the other parameter is semi-monotonic.
|
||||
* </p>
|
||||
* <p>
|
||||
* If either of the arguments is an infinity, then the returned result
|
||||
* is positive infinity. Otherwise, if either argument is <code>NaN</code>,
|
||||
* then <code>NaN</code> is returned.
|
||||
* </p>
|
||||
*
|
||||
* @param a the first parameter.
|
||||
* @param b the second parameter.
|
||||
* @return the hypotenuse matching the supplied parameters.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double hypot(double a, double b)
|
||||
{
|
||||
return VMMath.hypot(a,b);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the base 10 logarithm of the supplied value. The returned
|
||||
* result is within 1 ulp of the exact result, and the results are
|
||||
* semi-monotonic.
|
||||
* </p>
|
||||
* <p>
|
||||
* Arguments of either <code>NaN</code> or less than zero return
|
||||
* <code>NaN</code>. An argument of positive infinity returns positive
|
||||
* infinity. Negative infinity is returned if either positive or negative
|
||||
* zero is supplied. Where the argument is the result of
|
||||
* <code>10<sup>n</sup</code>, then <code>n</code> is returned.
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument.
|
||||
* @return the base 10 logarithm of <code>a</code>.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double log10(double a)
|
||||
{
|
||||
return VMMath.log10(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the natural logarithm resulting from the sum of the argument,
|
||||
* <code>a</code> and 1. For values close to 0, the
|
||||
* result of <code>log1p(a)</code> tend to be much closer to the
|
||||
* exact result than simply <code>log(1.0+a)</code>. The returned
|
||||
* result is within 1 ulp of the exact result, and the results are
|
||||
* semi-monotonic.
|
||||
* </p>
|
||||
* <p>
|
||||
* Arguments of either <code>NaN</code> or less than -1 return
|
||||
* <code>NaN</code>. An argument of positive infinity or zero
|
||||
* returns the original argument. Negative infinity is returned from an
|
||||
* argument of -1.
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument.
|
||||
* @return the natural logarithm of <code>a</code> + 1.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double log1p(double a)
|
||||
{
|
||||
return VMMath.log1p(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the sign of the argument as follows:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>If <code>a</code> is greater than zero, the result is 1.0.</li>
|
||||
* <li>If <code>a</code> is less than zero, the result is -1.0.</li>
|
||||
* <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
|
||||
* <li>If <code>a</code> is positive or negative zero, the result is the
|
||||
* same.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param a the numeric argument.
|
||||
* @return the sign of the argument.
|
||||
* @since 1.5.
|
||||
*/
|
||||
public static double signum(double a)
|
||||
{
|
||||
if (Double.isNaN(a))
|
||||
return Double.NaN;
|
||||
if (a > 0)
|
||||
return 1.0;
|
||||
if (a < 0)
|
||||
return -1.0;
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the sign of the argument as follows:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>If <code>a</code> is greater than zero, the result is 1.0f.</li>
|
||||
* <li>If <code>a</code> is less than zero, the result is -1.0f.</li>
|
||||
* <li>If <code>a</code> is <code>NaN</code>, the result is <code>NaN</code>.
|
||||
* <li>If <code>a</code> is positive or negative zero, the result is the
|
||||
* same.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param a the numeric argument.
|
||||
* @return the sign of the argument.
|
||||
* @since 1.5.
|
||||
*/
|
||||
public static float signum(float a)
|
||||
{
|
||||
if (Float.isNaN(a))
|
||||
return Float.NaN;
|
||||
if (a > 0)
|
||||
return 1.0f;
|
||||
if (a < 0)
|
||||
return -1.0f;
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the hyperbolic sine of the given value. For a value,
|
||||
* <code>x</code>, the hyperbolic sine is <code>(e<sup>x</sup> -
|
||||
* e<sup>-x</sup>)/2</code>
|
||||
* with <code>e</code> being <a href="#E">Euler's number</a>. The returned
|
||||
* result is within 2.5 ulps of the exact result.
|
||||
* </p>
|
||||
* <p>
|
||||
* If the supplied value is <code>NaN</code>, an infinity or a zero, then the
|
||||
* original value is returned.
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument
|
||||
* @return the hyperbolic sine of <code>a</code>.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double sinh(double a)
|
||||
{
|
||||
return VMMath.sinh(a);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the hyperbolic tangent of the given value. For a value,
|
||||
* <code>x</code>, the hyperbolic tangent is <code>(e<sup>x</sup> -
|
||||
* e<sup>-x</sup>)/(e<sup>x</sup> + e<sup>-x</sup>)</code>
|
||||
* (i.e. <code>sinh(a)/cosh(a)</code>)
|
||||
* with <code>e</code> being <a href="#E">Euler's number</a>. The returned
|
||||
* result is within 2.5 ulps of the exact result. The absolute value
|
||||
* of the exact result is always less than 1. Computed results are thus
|
||||
* less than or equal to 1 for finite arguments, with results within
|
||||
* half a ulp of either positive or negative 1 returning the appropriate
|
||||
* limit value (i.e. as if the argument was an infinity).
|
||||
* </p>
|
||||
* <p>
|
||||
* If the supplied value is <code>NaN</code> or zero, then the original
|
||||
* value is returned. Positive infinity returns +1.0 and negative infinity
|
||||
* returns -1.0.
|
||||
* </p>
|
||||
*
|
||||
* @param a the numeric argument
|
||||
* @return the hyperbolic tangent of <code>a</code>.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static double tanh(double a)
|
||||
{
|
||||
return VMMath.tanh(a);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -554,6 +554,49 @@ public final class String implements Serializable, Comparable, CharSequence
|
|||
this.count = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new String containing the characters represented in the
|
||||
* given subarray of Unicode code points.
|
||||
* @param codePoints the entire array of code points
|
||||
* @param offset the start of the subarray
|
||||
* @param count the length of the subarray
|
||||
*
|
||||
* @throws IllegalArgumentException if an invalid code point is found
|
||||
* in the codePoints array
|
||||
* @throws IndexOutOfBoundsException if offset is negative or offset + count
|
||||
* is greater than the length of the array.
|
||||
*/
|
||||
public String(int[] codePoints, int offset, int count)
|
||||
{
|
||||
// FIXME: This implementation appears to give correct internal
|
||||
// representation of the String because:
|
||||
// - length() is correct
|
||||
// - getting a char[] from toCharArray() and testing
|
||||
// Character.codePointAt() on all the characters in that array gives
|
||||
// the appropriate results
|
||||
// however printing the String gives incorrect results. This may be
|
||||
// due to printing method errors (such as incorrectly looping through
|
||||
// the String one char at a time rather than one "character" at a time.
|
||||
|
||||
if (offset < 0)
|
||||
throw new IndexOutOfBoundsException();
|
||||
int end = offset + count;
|
||||
int pos = 0;
|
||||
// This creates a char array that is long enough for all of the code
|
||||
// points to represent supplementary characters. This is more than likely
|
||||
// a waste of storage, so we use it only temporarily and then copy the
|
||||
// used portion into the value array.
|
||||
char[] temp = new char[2 * codePoints.length];
|
||||
for (int i = offset; i < end; i++)
|
||||
{
|
||||
pos += Character.toChars(codePoints[i], temp, pos);
|
||||
}
|
||||
this.count = pos;
|
||||
this.value = new char[pos];
|
||||
System.arraycopy(temp, 0, value, 0, pos);
|
||||
this.offset = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of characters contained in this String.
|
||||
*
|
||||
|
@ -1822,7 +1865,7 @@ public final class String implements Serializable, Comparable, CharSequence
|
|||
*/
|
||||
private static int upperCaseExpansion(char ch)
|
||||
{
|
||||
return Character.direction[Character.readChar(ch) >> 7] & 3;
|
||||
return Character.direction[0][Character.readCodePoint((int)ch) >> 7] & 3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1918,4 +1961,29 @@ public final class String implements Serializable, Comparable, CharSequence
|
|||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the index into this String that is offset from the given index by
|
||||
* <code>codePointOffset</code> code points.
|
||||
* @param index the index at which to start
|
||||
* @param codePointOffset the number of code points to offset
|
||||
* @return the index into this String that is <code>codePointOffset</code>
|
||||
* code points offset from <code>index</code>.
|
||||
*
|
||||
* @throws IndexOutOfBoundsException if index is negative or larger than the
|
||||
* length of this string.
|
||||
* @throws IndexOutOfBoundsException if codePointOffset is positive and the
|
||||
* substring starting with index has fewer than codePointOffset code points.
|
||||
* @throws IndexOutOfBoundsException if codePointOffset is negative and the
|
||||
* substring ending with index has fewer than (-codePointOffset) code points.
|
||||
* @since 1.5
|
||||
*/
|
||||
public int offsetByCodePoints(int index, int codePointOffset)
|
||||
{
|
||||
if (index < 0 || index > count)
|
||||
throw new IndexOutOfBoundsException();
|
||||
|
||||
return Character.offsetByCodePoints(value, offset, count, offset + index,
|
||||
codePointOffset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1006,4 +1006,65 @@ public final class StringBuilder
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the code point at the specified index. This is like #charAt(int),
|
||||
* but if the character is the start of a surrogate pair, and the
|
||||
* following character completes the pair, then the corresponding
|
||||
* supplementary code point is returned.
|
||||
* @param index the index of the codepoint to get, starting at 0
|
||||
* @return the codepoint at the specified index
|
||||
* @throws IndexOutOfBoundsException if index is negative or >= length()
|
||||
* @since 1.5
|
||||
*/
|
||||
public int codePointAt(int index)
|
||||
{
|
||||
return Character.codePointAt(value, index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the code point before the specified index. This is like
|
||||
* #codePointAt(int), but checks the characters at <code>index-1</code> and
|
||||
* <code>index-2</code> to see if they form a supplementary code point.
|
||||
* @param index the index just past the codepoint to get, starting at 0
|
||||
* @return the codepoint at the specified index
|
||||
* @throws IndexOutOfBoundsException if index is negative or >= length()
|
||||
* @since 1.5
|
||||
*/
|
||||
public int codePointBefore(int index)
|
||||
{
|
||||
// Character.codePointBefore() doesn't perform this check. We
|
||||
// could use the CharSequence overload, but this is just as easy.
|
||||
if (index >= count)
|
||||
throw new IndexOutOfBoundsException();
|
||||
return Character.codePointBefore(value, index, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of Unicode code points in the specified sub sequence.
|
||||
* Surrogate pairs count as one code point.
|
||||
* @param beginIndex the start of the subarray
|
||||
* @param endIndex the index after the last char in the subarray
|
||||
* @return the number of code points
|
||||
* @throws IndexOutOfBoundsException if beginIndex is less than zero or
|
||||
* greater than endIndex or if endIndex is greater than the length of this
|
||||
* StringBuilder
|
||||
*/
|
||||
public int codePointCount(int beginIndex,int endIndex)
|
||||
{
|
||||
if (beginIndex < 0 || beginIndex > endIndex || endIndex > count)
|
||||
throw new IndexOutOfBoundsException("invalid indices: " + beginIndex
|
||||
+ ", " + endIndex);
|
||||
return Character.codePointCount(value, beginIndex, endIndex - beginIndex);
|
||||
}
|
||||
|
||||
public void trimToSize()
|
||||
{
|
||||
if (count < value.length)
|
||||
{
|
||||
char[] newValue = new char[count];
|
||||
System.arraycopy(value, 0, newValue, 0, count);
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,6 +178,23 @@ public final class System
|
|||
if (SecurityManager.current != null)
|
||||
SecurityManager.current.checkPermission
|
||||
(new RuntimePermission("setSecurityManager"));
|
||||
|
||||
// java.security.Security's class initialiser loads and parses the
|
||||
// policy files. If it hasn't been run already it will be run
|
||||
// during the first permission check. That initialisation will
|
||||
// fail if a very restrictive security manager is in force, so we
|
||||
// preload it here.
|
||||
if (SecurityManager.current == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("java.security.Security");
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
SecurityManager.current = sm;
|
||||
}
|
||||
|
||||
|
|
|
@ -906,7 +906,7 @@ public class Thread implements Runnable
|
|||
if (sm != null)
|
||||
{
|
||||
sm.checkAccess(this);
|
||||
if (this != currentThread())
|
||||
if (this != currentThread() || !(t instanceof ThreadDeath))
|
||||
sm.checkPermission(new RuntimePermission("stopThread"));
|
||||
}
|
||||
VMThread vt = vmThread;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Proxy.java -- build a proxy class that implements reflected interfaces
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -42,6 +42,7 @@ import gnu.java.lang.reflect.TypeSignature;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -732,6 +733,12 @@ public class Proxy implements Serializable
|
|||
int j = methods.length;
|
||||
while (--j >= 0)
|
||||
{
|
||||
if (isCoreObjectMethod(methods[j]))
|
||||
{
|
||||
// In the case of an attempt to redefine a public non-final
|
||||
// method of Object, we must skip it
|
||||
continue;
|
||||
}
|
||||
ProxySignature sig = new ProxySignature(methods[j]);
|
||||
ProxySignature old = (ProxySignature) method_set.put(sig, sig);
|
||||
if (old != null)
|
||||
|
@ -752,6 +759,41 @@ public class Proxy implements Serializable
|
|||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the method is similar to a public non-final method of
|
||||
* Object or not (i.e. with the same name and parameter types). Note that we
|
||||
* can't rely, directly or indirectly (via Collection.contains) on
|
||||
* Method.equals as it would also check the declaring class, what we do not
|
||||
* want. We only want to check that the given method have the same signature
|
||||
* as a core method (same name and parameter types)
|
||||
*
|
||||
* @param method the method to check
|
||||
* @return whether the method has the same name and parameter types as
|
||||
* Object.equals, Object.hashCode or Object.toString
|
||||
* @see java.lang.Object#equals(Object)
|
||||
* @see java.lang.Object#hashCode()
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
private static boolean isCoreObjectMethod(Method method)
|
||||
{
|
||||
String methodName = method.getName();
|
||||
if (methodName.equals("equals"))
|
||||
{
|
||||
return Arrays.equals(method.getParameterTypes(),
|
||||
new Class[] { Object.class });
|
||||
}
|
||||
if (methodName.equals("hashCode"))
|
||||
{
|
||||
return method.getParameterTypes().length == 0;
|
||||
}
|
||||
if (methodName.equals("toString"))
|
||||
{
|
||||
return method.getParameterTypes().length == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // class ProxyData
|
||||
|
||||
/**
|
||||
|
|
|
@ -365,16 +365,13 @@ public class BigDecimal extends Number implements Comparable
|
|||
|
||||
// quotients are the same, so compare remainders
|
||||
|
||||
// remove trailing zeros
|
||||
if (thisParts[1].equals (BigInteger.valueOf (0)) == false)
|
||||
while (thisParts[1].mod (BigInteger.valueOf (10)).equals
|
||||
(BigInteger.valueOf (0)))
|
||||
thisParts[1] = thisParts[1].divide (BigInteger.valueOf (10));
|
||||
// again...
|
||||
if (valParts[1].equals(BigInteger.valueOf (0)) == false)
|
||||
while (valParts[1].mod (BigInteger.valueOf (10)).equals
|
||||
(BigInteger.valueOf (0)))
|
||||
valParts[1] = valParts[1].divide (BigInteger.valueOf (10));
|
||||
// Add some trailing zeros to the remainder with the smallest scale
|
||||
if (scale < val.scale)
|
||||
thisParts[1] = thisParts[1].multiply
|
||||
(BigInteger.valueOf (10).pow (val.scale - scale));
|
||||
else if (scale > val.scale)
|
||||
valParts[1] = valParts[1].multiply
|
||||
(BigInteger.valueOf (10).pow (scale - val.scale));
|
||||
|
||||
// and compare them
|
||||
return thisParts[1].compareTo (valParts[1]);
|
||||
|
|
|
@ -356,9 +356,9 @@ public class BigInteger extends Number implements Comparable
|
|||
|
||||
public int signum()
|
||||
{
|
||||
int top = words == null ? ival : words[ival-1];
|
||||
if (top == 0 && words == null)
|
||||
if (ival == 0 && words == null)
|
||||
return 0;
|
||||
int top = words == null ? ival : words[ival-1];
|
||||
return top < 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
|
@ -2227,17 +2227,25 @@ public class BigInteger extends Number implements Comparable
|
|||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
s.defaultReadObject();
|
||||
words = byteArrayToIntArray(magnitude, signum < 0 ? -1 : 0);
|
||||
BigInteger result = make(words, words.length);
|
||||
this.ival = result.ival;
|
||||
this.words = result.words;
|
||||
if (magnitude.length == 0 || signum == 0)
|
||||
{
|
||||
this.ival = 0;
|
||||
this.words = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
words = byteArrayToIntArray(magnitude, signum < 0 ? -1 : 0);
|
||||
BigInteger result = make(words, words.length);
|
||||
this.ival = result.ival;
|
||||
this.words = result.words;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream s)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
signum = signum();
|
||||
magnitude = toByteArray();
|
||||
magnitude = signum == 0 ? new byte[0] : toByteArray();
|
||||
s.defaultWriteObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -651,9 +651,9 @@ public class InetAddress implements Serializable
|
|||
/*
|
||||
* Needed for serialization
|
||||
*/
|
||||
private void readResolve() throws ObjectStreamException
|
||||
private Object readResolve() throws ObjectStreamException
|
||||
{
|
||||
// FIXME: implement this
|
||||
return new Inet4Address(addr, hostName);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream ois)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* SocketPermission.java -- Class modeling permissions for socket operations
|
||||
Copyright (C) 1998, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 2000, 2001, 2002, 2004, 2006 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -37,9 +38,13 @@ exception statement from your version. */
|
|||
|
||||
package java.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -104,24 +109,52 @@ import java.security.PermissionCollection;
|
|||
*
|
||||
* @since 1.2
|
||||
*
|
||||
* @author Aaron M. Renn (arenn@urbanophile.com)
|
||||
* @author Written by Aaron M. Renn (arenn@urbanophile.com)
|
||||
* @author Extensively modified by Gary Benson (gbenson@redhat.com)
|
||||
*/
|
||||
public final class SocketPermission extends Permission implements Serializable
|
||||
{
|
||||
static final long serialVersionUID = -7204263841984476862L;
|
||||
|
||||
// FIXME: Needs serialization work, including readObject/writeObject methods.
|
||||
|
||||
/**
|
||||
* A hostname/port combination as described above
|
||||
* A hostname (possibly wildcarded) or IP address (IPv4 or IPv6).
|
||||
*/
|
||||
private transient String hostport;
|
||||
private transient String host;
|
||||
|
||||
/**
|
||||
* A comma separated list of actions for which we have permission
|
||||
* A range of ports.
|
||||
*/
|
||||
private transient int minport;
|
||||
private transient int maxport;
|
||||
|
||||
/**
|
||||
* Values used for minimum and maximum ports when one or both bounds
|
||||
* are omitted. This class is essentially independent of the
|
||||
* networking code it describes, so we do not limit ports to the
|
||||
* usual network limits of 1 and 65535.
|
||||
*/
|
||||
private static final int MIN_PORT = 0;
|
||||
private static final int MAX_PORT = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* The actions for which we have permission. This field is present
|
||||
* to make the serialized form correct and should not be used by
|
||||
* anything other than writeObject: everything else should use
|
||||
* actionmask.
|
||||
*/
|
||||
private String actions;
|
||||
|
||||
/**
|
||||
* A bitmask representing the actions for which we have permission.
|
||||
*/
|
||||
private transient int actionmask;
|
||||
|
||||
/**
|
||||
* The available actions, in the canonical order required for getActions().
|
||||
*/
|
||||
private static final String[] ACTIONS = new String[] {
|
||||
"connect", "listen", "accept", "resolve"};
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>SocketPermission</code> with the
|
||||
* specified host/port combination and actions string.
|
||||
|
@ -133,8 +166,137 @@ public final class SocketPermission extends Permission implements Serializable
|
|||
{
|
||||
super(hostport);
|
||||
|
||||
this.hostport = hostport;
|
||||
this.actions = actions;
|
||||
setHostPort(hostport);
|
||||
setActions(actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the hostport argument to the constructor.
|
||||
*/
|
||||
private void setHostPort(String hostport)
|
||||
{
|
||||
// Split into host and ports
|
||||
String ports;
|
||||
if (hostport.length() == 0)
|
||||
{
|
||||
host = ports = "";
|
||||
}
|
||||
else if (hostport.charAt(0) == '[')
|
||||
{
|
||||
// host is a bracketed IPv6 address
|
||||
int end = hostport.indexOf("]");
|
||||
if (end == -1)
|
||||
throw new IllegalArgumentException("Unmatched '['");
|
||||
host = hostport.substring(1, end);
|
||||
|
||||
if (end == hostport.length() - 1)
|
||||
ports = "";
|
||||
else if (hostport.charAt(end + 1) == ':')
|
||||
ports = hostport.substring(end + 2);
|
||||
else
|
||||
throw new IllegalArgumentException("Bad character after ']'");
|
||||
}
|
||||
else
|
||||
{
|
||||
// host is a hostname or IPv4 address
|
||||
int sep = hostport.indexOf(":");
|
||||
if (sep == -1)
|
||||
{
|
||||
host = hostport;
|
||||
ports = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
host = hostport.substring(0, sep);
|
||||
ports = hostport.substring(sep + 1);
|
||||
}
|
||||
}
|
||||
if (ports.indexOf(":") != -1)
|
||||
throw new IllegalArgumentException("Unexpected ':'");
|
||||
|
||||
// Parse and validate the ports
|
||||
if (ports.length() == 0)
|
||||
{
|
||||
minport = MIN_PORT;
|
||||
maxport = MAX_PORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
int sep = ports.indexOf("-");
|
||||
if (sep == -1)
|
||||
{
|
||||
// a single port
|
||||
minport = maxport = Integer.parseInt(ports);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ports.indexOf("-", sep + 1) != -1)
|
||||
throw new IllegalArgumentException("Unexpected '-'");
|
||||
|
||||
if (sep == 0)
|
||||
{
|
||||
// an upper bound
|
||||
minport = MIN_PORT;
|
||||
maxport = Integer.parseInt(ports.substring(1));
|
||||
}
|
||||
else if (sep == ports.length() - 1)
|
||||
{
|
||||
// a lower bound
|
||||
minport =
|
||||
Integer.parseInt(ports.substring(0, ports.length() - 1));
|
||||
maxport = MAX_PORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
// a range with two bounds
|
||||
minport = Integer.parseInt(ports.substring(0, sep));
|
||||
maxport = Integer.parseInt(ports.substring(sep + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the actions argument to the constructor.
|
||||
*/
|
||||
private void setActions(String actionstring)
|
||||
{
|
||||
actionmask = 0;
|
||||
|
||||
boolean resolve_needed = false;
|
||||
boolean resolve_present = false;
|
||||
|
||||
StringTokenizer t = new StringTokenizer(actionstring, ",");
|
||||
while (t.hasMoreTokens())
|
||||
{
|
||||
String action = t.nextToken();
|
||||
action = action.trim().toLowerCase();
|
||||
setAction(action);
|
||||
|
||||
if (action.equals("resolve"))
|
||||
resolve_present = true;
|
||||
else
|
||||
resolve_needed = true;
|
||||
}
|
||||
|
||||
if (resolve_needed && !resolve_present)
|
||||
setAction("resolve");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse one element of the actions argument to the constructor.
|
||||
*/
|
||||
private void setAction(String action)
|
||||
{
|
||||
for (int i = 0; i < ACTIONS.length; i++)
|
||||
{
|
||||
if (action.equals(ACTIONS[i]))
|
||||
{
|
||||
actionmask |= 1 << i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown action " + action);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,14 +312,17 @@ public final class SocketPermission extends Permission implements Serializable
|
|||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (! (obj instanceof SocketPermission))
|
||||
SocketPermission p;
|
||||
|
||||
if (obj instanceof SocketPermission)
|
||||
p = (SocketPermission) obj;
|
||||
else
|
||||
return false;
|
||||
|
||||
if (((SocketPermission) obj).hostport.equals(hostport))
|
||||
if (((SocketPermission) obj).actions.equals(actions))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return p.actionmask == actionmask &&
|
||||
p.minport == minport &&
|
||||
p.maxport == maxport &&
|
||||
p.host.equals(host);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,12 +333,7 @@ public final class SocketPermission extends Permission implements Serializable
|
|||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = 100;
|
||||
if (hostport != null)
|
||||
hash += hostport.hashCode();
|
||||
if (actions != null)
|
||||
hash += actions.hashCode();
|
||||
return hash;
|
||||
return actionmask + minport + maxport + host.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,38 +344,18 @@ public final class SocketPermission extends Permission implements Serializable
|
|||
*/
|
||||
public String getActions()
|
||||
{
|
||||
boolean found = false;
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
|
||||
if (actions.indexOf("connect") != -1)
|
||||
for (int i = 0; i < ACTIONS.length; i++)
|
||||
{
|
||||
sb.append("connect");
|
||||
found = true;
|
||||
if ((actionmask & (1 << i)) != 0)
|
||||
{
|
||||
if (sb.length() != 0)
|
||||
sb.append(",");
|
||||
sb.append(ACTIONS[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (actions.indexOf("listen") != -1)
|
||||
if (found)
|
||||
sb.append(",listen");
|
||||
else
|
||||
{
|
||||
sb.append("listen");
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (actions.indexOf("accept") != -1)
|
||||
if (found)
|
||||
sb.append(",accept");
|
||||
else
|
||||
{
|
||||
sb.append("accept");
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (found)
|
||||
sb.append(",resolve");
|
||||
else if (actions.indexOf("resolve") != -1)
|
||||
sb.append("resolve");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
@ -268,136 +408,43 @@ public final class SocketPermission extends Permission implements Serializable
|
|||
return false;
|
||||
|
||||
// Next check the actions
|
||||
String ourlist = getActions();
|
||||
String theirlist = p.getActions();
|
||||
if ((p.actionmask & actionmask) != p.actionmask)
|
||||
return false;
|
||||
|
||||
if (! ourlist.startsWith(theirlist))
|
||||
// Then check the ports
|
||||
if ((p.minport < minport) || (p.maxport > maxport))
|
||||
return false;
|
||||
|
||||
// Now check ports
|
||||
int ourfirstport = 0;
|
||||
|
||||
// Now check ports
|
||||
int ourlastport = 0;
|
||||
|
||||
// Now check ports
|
||||
int theirfirstport = 0;
|
||||
|
||||
// Now check ports
|
||||
int theirlastport = 0;
|
||||
|
||||
// Get ours
|
||||
if (hostport.indexOf(":") == -1)
|
||||
{
|
||||
ourfirstport = 0;
|
||||
ourlastport = 65535;
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: Needs bulletproofing.
|
||||
// This will dump if hostport if all sorts of bad data was passed to
|
||||
// the constructor
|
||||
String range = hostport.substring(hostport.indexOf(":") + 1);
|
||||
if (range.startsWith("-"))
|
||||
ourfirstport = 0;
|
||||
else if (range.indexOf("-") == -1)
|
||||
ourfirstport = Integer.parseInt(range);
|
||||
else
|
||||
ourfirstport =
|
||||
Integer.parseInt(range.substring(0, range.indexOf("-")));
|
||||
|
||||
if (range.endsWith("-"))
|
||||
ourlastport = 65535;
|
||||
else if (range.indexOf("-") == -1)
|
||||
ourlastport = Integer.parseInt(range);
|
||||
else
|
||||
ourlastport =
|
||||
Integer.parseInt(range.substring(range.indexOf("-") + 1,
|
||||
range.length()));
|
||||
}
|
||||
|
||||
// Get theirs
|
||||
if (p.hostport.indexOf(":") == -1)
|
||||
{
|
||||
theirfirstport = 0;
|
||||
ourlastport = 65535;
|
||||
}
|
||||
else
|
||||
{
|
||||
// This will dump if hostport if all sorts of bad data was passed to
|
||||
// the constructor
|
||||
String range = p.hostport.substring(hostport.indexOf(":") + 1);
|
||||
if (range.startsWith("-"))
|
||||
theirfirstport = 0;
|
||||
else if (range.indexOf("-") == -1)
|
||||
theirfirstport = Integer.parseInt(range);
|
||||
else
|
||||
theirfirstport =
|
||||
Integer.parseInt(range.substring(0, range.indexOf("-")));
|
||||
|
||||
if (range.endsWith("-"))
|
||||
theirlastport = 65535;
|
||||
else if (range.indexOf("-") == -1)
|
||||
theirlastport = Integer.parseInt(range);
|
||||
else
|
||||
theirlastport =
|
||||
Integer.parseInt(range.substring(range.indexOf("-") + 1,
|
||||
range.length()));
|
||||
}
|
||||
|
||||
// Now check them
|
||||
if ((theirfirstport < ourfirstport) || (theirlastport > ourlastport))
|
||||
return false;
|
||||
|
||||
// Finally we can check the hosts
|
||||
String ourhost;
|
||||
|
||||
// Finally we can check the hosts
|
||||
String theirhost;
|
||||
|
||||
// Get ours
|
||||
if (hostport.indexOf(":") == -1)
|
||||
ourhost = hostport;
|
||||
else
|
||||
ourhost = hostport.substring(0, hostport.indexOf(":"));
|
||||
|
||||
// Get theirs
|
||||
if (p.hostport.indexOf(":") == -1)
|
||||
theirhost = p.hostport;
|
||||
else
|
||||
theirhost = p.hostport.substring(0, p.hostport.indexOf(":"));
|
||||
|
||||
// Are they equal?
|
||||
if (ourhost.equals(theirhost))
|
||||
// Finally check the hosts
|
||||
if (host.equals(p.host))
|
||||
return true;
|
||||
|
||||
// Try the canonical names
|
||||
String ourcanonical = null;
|
||||
|
||||
// Try the canonical names
|
||||
String theircanonical = null;
|
||||
try
|
||||
{
|
||||
ourcanonical = InetAddress.getByName(ourhost).getHostName();
|
||||
theircanonical = InetAddress.getByName(theirhost).getHostName();
|
||||
ourcanonical = InetAddress.getByName(host).getHostName();
|
||||
theircanonical = InetAddress.getByName(p.host).getHostName();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
// Who didn't resolve? Just assume current address is canonical enough
|
||||
// Is this ok to do?
|
||||
if (ourcanonical == null)
|
||||
ourcanonical = ourhost;
|
||||
ourcanonical = host;
|
||||
if (theircanonical == null)
|
||||
theircanonical = theirhost;
|
||||
theircanonical = p.host;
|
||||
}
|
||||
|
||||
if (ourcanonical.equals(theircanonical))
|
||||
return true;
|
||||
|
||||
// Well, last chance. Try for a wildcard
|
||||
if (ourhost.indexOf("*.") != -1)
|
||||
if (host.indexOf("*.") != -1)
|
||||
{
|
||||
String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));
|
||||
String wild_domain =
|
||||
host.substring(host.indexOf("*" + 1));
|
||||
if (theircanonical.endsWith(wild_domain))
|
||||
return true;
|
||||
}
|
||||
|
@ -405,4 +452,35 @@ public final class SocketPermission extends Permission implements Serializable
|
|||
// Didn't make it
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes a <code>SocketPermission</code> object from
|
||||
* an input stream.
|
||||
*
|
||||
* @param input the input stream.
|
||||
* @throws IOException if an I/O error occurs in the stream.
|
||||
* @throws ClassNotFoundException if the class of the
|
||||
* serialized object could not be found.
|
||||
*/
|
||||
private void readObject(ObjectInputStream input)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
input.defaultReadObject();
|
||||
setHostPort(getName());
|
||||
setActions(actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a <code>SocketPermission</code> object to an
|
||||
* output stream.
|
||||
*
|
||||
* @param output the output stream.
|
||||
* @throws IOException if an I/O error occurs in the stream.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream output)
|
||||
throws IOException
|
||||
{
|
||||
actions = getActions();
|
||||
output.defaultWriteObject();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* URI.java -- An URI class
|
||||
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -346,8 +346,15 @@ public final class URI
|
|||
private static String getURIGroup(Matcher match, int group)
|
||||
{
|
||||
String matched = match.group(group);
|
||||
return matched.length() == 0
|
||||
? ((match.group(group - 1).length() == 0) ? null : "") : matched;
|
||||
if (matched == null || matched.length() == 0)
|
||||
{
|
||||
String prevMatched = match.group(group -1);
|
||||
if (prevMatched == null || prevMatched.length() == 0)
|
||||
return null;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -399,40 +399,59 @@ public final class URL implements Serializable
|
|||
&& ! spec.regionMatches(colon, "://:", 0, 4))
|
||||
context = null;
|
||||
|
||||
boolean protocolSpecified = false;
|
||||
|
||||
if ((colon = spec.indexOf(':')) > 0
|
||||
&& (colon < slash || slash < 0))
|
||||
{
|
||||
// Protocol specified in spec string.
|
||||
// Protocol may have been specified in spec string.
|
||||
protocolSpecified = true;
|
||||
protocol = spec.substring(0, colon).toLowerCase();
|
||||
if (context != null && context.protocol.equals(protocol))
|
||||
{
|
||||
// The 1.2 doc specifically says these are copied to the new URL.
|
||||
host = context.host;
|
||||
port = context.port;
|
||||
userInfo = context.userInfo;
|
||||
authority = context.authority;
|
||||
}
|
||||
if (context != null)
|
||||
{
|
||||
if (context.protocol.equals(protocol))
|
||||
{
|
||||
// The 1.2 doc specifically says these are copied to the new URL.
|
||||
host = context.host;
|
||||
port = context.port;
|
||||
userInfo = context.userInfo;
|
||||
authority = context.authority;
|
||||
}
|
||||
else
|
||||
{
|
||||
// There was a colon in the spec. Check to see if
|
||||
// what precedes it is a valid protocol. If it was
|
||||
// not, assume that it is relative to the context.
|
||||
URLStreamHandler specPh = getURLStreamHandler(protocol.trim());
|
||||
if (null == specPh)
|
||||
protocolSpecified = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (context != null)
|
||||
|
||||
if (!protocolSpecified)
|
||||
{
|
||||
// Protocol NOT specified in spec string.
|
||||
// Use context fields (except ref) as a foundation for relative URLs.
|
||||
colon = -1;
|
||||
protocol = context.protocol;
|
||||
host = context.host;
|
||||
port = context.port;
|
||||
userInfo = context.userInfo;
|
||||
if (spec.indexOf(":/", 1) < 0)
|
||||
{
|
||||
file = context.file;
|
||||
if (file == null || file.length() == 0)
|
||||
file = "/";
|
||||
}
|
||||
authority = context.authority;
|
||||
if (context != null)
|
||||
{
|
||||
// Protocol NOT specified in spec string.
|
||||
// Use context fields (except ref) as a foundation for relative URLs.
|
||||
colon = -1;
|
||||
protocol = context.protocol;
|
||||
host = context.host;
|
||||
port = context.port;
|
||||
userInfo = context.userInfo;
|
||||
if (spec.indexOf(":/", 1) < 0)
|
||||
{
|
||||
file = context.file;
|
||||
if (file == null || file.length() == 0)
|
||||
file = "/";
|
||||
}
|
||||
authority = context.authority;
|
||||
}
|
||||
else // Protocol NOT specified in spec. and no context available.
|
||||
throw new MalformedURLException("Absolute URL required with null"
|
||||
+ " context: " + spec);
|
||||
}
|
||||
else // Protocol NOT specified in spec. and no context available.
|
||||
throw new MalformedURLException("Absolute URL required with null"
|
||||
+ " context: " + spec);
|
||||
|
||||
protocol = protocol.trim();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* URLClassLoader.java -- ClassLoader that loads classes from one or more URLs
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
@ -292,9 +292,10 @@ public class URLClassLoader extends SecureClassLoader
|
|||
|
||||
Vector classPath; // The "Class-Path" attribute of this Jar's manifest
|
||||
|
||||
public JarURLLoader(URLClassLoader classloader, URL baseURL)
|
||||
public JarURLLoader(URLClassLoader classloader, URL baseURL,
|
||||
URL absoluteUrl)
|
||||
{
|
||||
super(classloader, baseURL);
|
||||
super(classloader, baseURL, absoluteUrl);
|
||||
|
||||
// Cache url prefix for all resources in this jar url.
|
||||
String external = baseURL.toExternalForm();
|
||||
|
@ -526,10 +527,10 @@ public class URLClassLoader extends SecureClassLoader
|
|||
{
|
||||
File dir; //the file for this file url
|
||||
|
||||
FileURLLoader(URLClassLoader classloader, URL url)
|
||||
FileURLLoader(URLClassLoader classloader, URL url, URL absoluteUrl)
|
||||
{
|
||||
super(classloader, url);
|
||||
dir = new File(baseURL.getFile());
|
||||
super(classloader, url, absoluteUrl);
|
||||
dir = new File(absoluteUrl.getFile());
|
||||
}
|
||||
|
||||
/** get resource with the name "name" in the file url */
|
||||
|
@ -723,11 +724,42 @@ public class URLClassLoader extends SecureClassLoader
|
|||
String file = newUrl.getFile();
|
||||
String protocol = newUrl.getProtocol();
|
||||
|
||||
// If we have a file: URL, we want to make it absolute
|
||||
// here, before we decide whether it is really a jar.
|
||||
URL absoluteURL;
|
||||
if ("file".equals (protocol))
|
||||
{
|
||||
File dir = new File(file);
|
||||
URL absUrl;
|
||||
try
|
||||
{
|
||||
absoluteURL = dir.getCanonicalFile().toURL();
|
||||
}
|
||||
catch (IOException ignore)
|
||||
{
|
||||
try
|
||||
{
|
||||
absoluteURL = dir.getAbsoluteFile().toURL();
|
||||
}
|
||||
catch (MalformedURLException _)
|
||||
{
|
||||
// This really should not happen.
|
||||
absoluteURL = newUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This doesn't hurt, and it simplifies the logic a
|
||||
// little.
|
||||
absoluteURL = newUrl;
|
||||
}
|
||||
|
||||
// Check that it is not a directory
|
||||
if (! (file.endsWith("/") || file.endsWith(File.separator)))
|
||||
loader = new JarURLLoader(this, newUrl);
|
||||
loader = new JarURLLoader(this, newUrl, absoluteURL);
|
||||
else if ("file".equals(protocol))
|
||||
loader = new FileURLLoader(this, newUrl);
|
||||
loader = new FileURLLoader(this, newUrl, absoluteURL);
|
||||
else
|
||||
loader = new RemoteURLLoader(this, newUrl);
|
||||
|
||||
|
|
|
@ -598,6 +598,9 @@ public abstract class URLConnection
|
|||
*/
|
||||
public void setAllowUserInteraction(boolean allow)
|
||||
{
|
||||
if (connected)
|
||||
throw new IllegalStateException("Already connected");
|
||||
|
||||
allowUserInteraction = allow;
|
||||
}
|
||||
|
||||
|
@ -776,7 +779,7 @@ public abstract class URLConnection
|
|||
*
|
||||
* @param key The name of the property
|
||||
*
|
||||
* @return Value of the property
|
||||
* @return Value of the property, or <code>null</code> if key is null.
|
||||
*
|
||||
* @exception IllegalStateException If already connected
|
||||
*
|
||||
|
|
|
@ -42,6 +42,8 @@ package java.nio;
|
|||
*/
|
||||
public class BufferOverflowException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = - 5484897634319144535L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,8 @@ package java.nio;
|
|||
*/
|
||||
public class BufferUnderflowException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = - 1713313658691622206L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -43,6 +43,8 @@ package java.nio;
|
|||
*/
|
||||
public class InvalidMarkException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = 1698329710438510774L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -43,6 +43,8 @@ package java.nio;
|
|||
*/
|
||||
public class ReadOnlyBufferException extends UnsupportedOperationException
|
||||
{
|
||||
private static final long serialVersionUID = - 1210063976496234090L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -39,6 +39,8 @@ package java.nio.channels;
|
|||
|
||||
public class AlreadyConnectedException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = - 7331895245053773357L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class AsynchronousCloseException extends ClosedChannelException
|
||||
{
|
||||
private static final long serialVersionUID = 6891178312432313966L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class CancelledKeyException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = - 8438032138028814268L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,7 @@ import java.io.Writer;
|
|||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class ClosedByInterruptException extends AsynchronousCloseException
|
||||
{
|
||||
private static final long serialVersionUID = - 4488191543534286750L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -46,6 +46,8 @@ import java.io.IOException;
|
|||
*/
|
||||
public class ClosedChannelException extends IOException
|
||||
{
|
||||
private static final long serialVersionUID = 882777185433553857L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class ClosedSelectorException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = 6466297122317847835L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class ConnectionPendingException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = 2008393366501760879L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -124,7 +124,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
|
|||
/**
|
||||
* Tells whether or not this channel's socket is connected.
|
||||
*
|
||||
* @exception IOException If an error occurs.
|
||||
* @exception NotYetConnectedException The channel's socket is not connected.
|
||||
*/
|
||||
public abstract boolean isConnected();
|
||||
|
@ -200,7 +199,6 @@ public abstract class DatagramChannel extends AbstractSelectableChannel
|
|||
/**
|
||||
* Retrieves the valid operations for this channel.
|
||||
*
|
||||
* @exception IOException If an error occurs.
|
||||
* @exception NotYetConnectedException The channel's socket is not connected.
|
||||
*/
|
||||
public final int validOps()
|
||||
|
|
|
@ -219,7 +219,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
|
|||
public abstract void force(boolean metaData) throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a file lock for the whole assoziated file.
|
||||
* Creates a file lock for the whole associated file.
|
||||
*
|
||||
* @exception AsynchronousCloseException If another thread closes this channel
|
||||
* while the transfer is in progress.
|
||||
|
@ -242,7 +242,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a file lock for a region of the assoziated file.
|
||||
* Creates a file lock for a region of the associated file.
|
||||
*
|
||||
* @exception AsynchronousCloseException If another thread closes this channel
|
||||
* while the transfer is in progress.
|
||||
|
@ -265,7 +265,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
|
|||
throws IOException;
|
||||
|
||||
/**
|
||||
* Tries to aqquire alock on the whole assoziated file.
|
||||
* Tries to aqquire alock on the whole associated file.
|
||||
*
|
||||
* @exception ClosedChannelException If this channel is closed.
|
||||
* @exception IOException If an I/O error occurs.
|
||||
|
@ -280,7 +280,7 @@ public abstract class FileChannel extends AbstractInterruptibleChannel
|
|||
}
|
||||
|
||||
/**
|
||||
* Tries to aqquire a lock on a region of the assoziated file.
|
||||
* Tries to aqquire a lock on a region of the associated file.
|
||||
*
|
||||
* @exception ClosedChannelException If this channel is closed.
|
||||
* @exception IllegalArgumentException If the preconditions on the parameters
|
||||
|
|
|
@ -46,6 +46,8 @@ import java.io.IOException;
|
|||
*/
|
||||
public class FileLockInterruptionException extends IOException
|
||||
{
|
||||
private static final long serialVersionUID = 7104080643653532383L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -47,6 +47,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class IllegalBlockingModeException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = - 3335774961855590474L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class IllegalSelectorException extends IllegalArgumentException
|
||||
{
|
||||
private static final long serialVersionUID = - 8406323347253320987L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class NoConnectionPendingException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = - 8296561183633134743L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class NonReadableChannelException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = - 3200915679294993514L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class NonWritableChannelException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = - 7071230488279011621L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class NotYetBoundException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = 4640999303950202242L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class NotYetConnectedException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = 4697316551909513464L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class OverlappingFileLockException extends IllegalStateException
|
||||
{
|
||||
private static final long serialVersionUID = 2047812138163068433L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class UnresolvedAddressException extends IllegalArgumentException
|
||||
{
|
||||
private static final long serialVersionUID = 6136959093620794148L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -44,6 +44,8 @@ package java.nio.channels;
|
|||
*/
|
||||
public class UnsupportedAddressTypeException extends IllegalArgumentException
|
||||
{
|
||||
private static final long serialVersionUID = - 2964323842829700493L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -40,6 +40,7 @@ package java.nio.channels.spi;
|
|||
import java.io.IOException;
|
||||
import java.nio.channels.AsynchronousCloseException;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.ClosedByInterruptException;
|
||||
import java.nio.channels.InterruptibleChannel;
|
||||
|
||||
|
||||
|
@ -86,7 +87,6 @@ public abstract class AbstractInterruptibleChannel
|
|||
* @param completed true if the task completed successfully,
|
||||
* false otherwise
|
||||
*
|
||||
* @exception IOException if an error occurs
|
||||
* @exception AsynchronousCloseException If the channel was asynchronously
|
||||
* closed.
|
||||
* @exception ClosedByInterruptException If the thread blocked in the
|
||||
|
|
|
@ -44,6 +44,8 @@ import java.io.IOException;
|
|||
*/
|
||||
public class CharacterCodingException extends IOException
|
||||
{
|
||||
private static final long serialVersionUID = 8421532232154627783L;
|
||||
|
||||
/**
|
||||
* Creates the exception
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,8 @@ package java.nio.charset;
|
|||
*/
|
||||
public class CoderMalfunctionError extends Error
|
||||
{
|
||||
private static final long serialVersionUID = - 1151412348057794301L;
|
||||
|
||||
/**
|
||||
* Creates the error
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,8 @@ package java.nio.charset;
|
|||
*/
|
||||
public class MalformedInputException extends CharacterCodingException
|
||||
{
|
||||
private static final long serialVersionUID = - 3438823399834806194L;
|
||||
|
||||
private int inputLength;
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,8 @@ package java.nio.charset;
|
|||
*/
|
||||
public class UnmappableCharacterException extends CharacterCodingException
|
||||
{
|
||||
private static final long serialVersionUID = - 7026962371537706123L;
|
||||
|
||||
private int inputLength;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* AccessException.java -- thrown if the caller does not have access
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -43,7 +44,7 @@ package java.rmi;
|
|||
*
|
||||
* @author unknown
|
||||
* @see Naming
|
||||
* @see ActivationSystem
|
||||
* @see java.rmi.activation.ActivationSystem
|
||||
* @since 1.1
|
||||
*/
|
||||
public class AccessException extends RemoteException
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* AlreadyBoundException.java -- thrown if a binding is already bound
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -42,8 +43,8 @@ package java.rmi;
|
|||
* bound.
|
||||
*
|
||||
* @author unknown
|
||||
* @see Naming#bind(String, Remote)
|
||||
* @see Registry#bind(String, Remote)
|
||||
* @see java.rmi.Naming#bind(String, Remote)
|
||||
* @see java.rmi.registry.Registry#bind(String, Remote)
|
||||
* @since 1.1
|
||||
* @status updated to 1.4
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* MarshalledObject.java --
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -42,38 +43,68 @@ import gnu.java.rmi.RMIMarshalledObjectInputStream;
|
|||
import gnu.java.rmi.RMIMarshalledObjectOutputStream;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* FIXME - doc missing
|
||||
* A <code>MarshalledObject</code> consists of a serialized object which is
|
||||
* marshalled according to the RMI specification.
|
||||
* <p>
|
||||
* An object passed to the constructor is serialized and tagged with the needed
|
||||
* URL to retrieve its class definition for remote usage. If the object is a
|
||||
* remote reference its stub is serialized instead. The instance of this
|
||||
* marshalled object can be later retrieved by its <code>get()</code> method.
|
||||
* </p>
|
||||
*
|
||||
* @author unknown
|
||||
*/
|
||||
public final class MarshalledObject implements Serializable
|
||||
public final class MarshalledObject
|
||||
implements Serializable
|
||||
{
|
||||
//The following fields are from Java API Documentation "Serialized form"
|
||||
// The following fields are from Java API Documentation "Serialized form"
|
||||
private static final long serialVersionUID = 8988374069173025854L;
|
||||
|
||||
byte[] objBytes;
|
||||
byte[] locBytes;
|
||||
int hash;
|
||||
|
||||
public MarshalledObject(Object obj) throws java.io.IOException
|
||||
|
||||
/**
|
||||
* Constructs a <code>MarshalledObject</code> from the given object.
|
||||
*
|
||||
* @param obj the object to marshal
|
||||
* @throws IOException if an I/O error during serialization occurs.
|
||||
*/
|
||||
public MarshalledObject(Object obj) throws IOException
|
||||
{
|
||||
ByteArrayOutputStream objStream = new ByteArrayOutputStream();
|
||||
RMIMarshalledObjectOutputStream stream = new RMIMarshalledObjectOutputStream(objStream);
|
||||
RMIMarshalledObjectOutputStream stream =
|
||||
new RMIMarshalledObjectOutputStream(objStream);
|
||||
stream.writeObject(obj);
|
||||
stream.flush();
|
||||
objBytes = objStream.toByteArray();
|
||||
locBytes = stream.getLocBytes();
|
||||
|
||||
//The following algorithm of calculating hashCode is similar to String
|
||||
|
||||
// The following algorithm of calculating hashCode is similar to String
|
||||
hash = 0;
|
||||
for (int i = 0; i < objBytes.length; i++)
|
||||
hash = hash * 31 + objBytes[i];
|
||||
if(locBytes != null)
|
||||
|
||||
if (locBytes != null)
|
||||
for (int i = 0; i < locBytes.length; i++)
|
||||
hash = hash * 31 + locBytes[i];
|
||||
hash = hash * 31 + locBytes[i];
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
|
||||
/**
|
||||
* Checks if the given object is equal to this marshalled object.
|
||||
*
|
||||
* <p>Marshalled objects are considered equal if they contain the
|
||||
* same serialized object. Codebase annotations where the class
|
||||
* definition can be downloaded are ignored in the equals test.</p>
|
||||
*
|
||||
* @param obj the object to compare.
|
||||
* @return <code>true</code> if equal, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (! (obj instanceof MarshalledObject))
|
||||
return false;
|
||||
|
@ -81,33 +112,43 @@ public final class MarshalledObject implements Serializable
|
|||
// hashCode even differs, don't do the time-consuming comparisons
|
||||
if (obj.hashCode() != hash)
|
||||
return false;
|
||||
|
||||
MarshalledObject aobj = (MarshalledObject)obj;
|
||||
|
||||
MarshalledObject aobj = (MarshalledObject) obj;
|
||||
if (objBytes == null || aobj.objBytes == null)
|
||||
return objBytes == aobj.objBytes;
|
||||
if (objBytes.length != aobj.objBytes.length)
|
||||
return false;
|
||||
for (int i = 0; i < objBytes.length; i++)
|
||||
for (int i = 0; i < objBytes.length; i++)
|
||||
{
|
||||
if (objBytes[i] != aobj.objBytes[i])
|
||||
return false;
|
||||
if (objBytes[i] != aobj.objBytes[i])
|
||||
return false;
|
||||
}
|
||||
// Ignore comparison of locBytes(annotation)
|
||||
return true;
|
||||
}
|
||||
|
||||
public Object get()
|
||||
throws java.io.IOException, java.lang.ClassNotFoundException
|
||||
{
|
||||
if(objBytes == null)
|
||||
return null;
|
||||
RMIMarshalledObjectInputStream stream =
|
||||
new RMIMarshalledObjectInputStream(objBytes, locBytes);
|
||||
return stream.readObject();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
||||
/**
|
||||
* Constructs and returns a copy of the internal serialized object.
|
||||
*
|
||||
* @return The deserialized object.
|
||||
*
|
||||
* @throws IOException if an I/O exception occurs during deserialization.
|
||||
* @throws ClassNotFoundException if the class of the deserialized object
|
||||
* cannot be found.
|
||||
*/
|
||||
public Object get() throws IOException, ClassNotFoundException
|
||||
{
|
||||
if (objBytes == null)
|
||||
return null;
|
||||
|
||||
RMIMarshalledObjectInputStream stream =
|
||||
new RMIMarshalledObjectInputStream(objBytes, locBytes);
|
||||
return stream.readObject();
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Naming.java --
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -76,136 +77,150 @@ import java.rmi.registry.Registry;
|
|||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @since 1.1
|
||||
*/
|
||||
public final class Naming {
|
||||
|
||||
public final class Naming
|
||||
{
|
||||
/**
|
||||
* This class isn't intended to be instantiated.
|
||||
*/
|
||||
private Naming() {}
|
||||
|
||||
/**
|
||||
* Looks for the remote object that is associated with the named service.
|
||||
* Name and location is given in form of a URL without a scheme:
|
||||
*
|
||||
* <pre>
|
||||
* //host:port/service-name
|
||||
* </pre>
|
||||
*
|
||||
* The port is optional.
|
||||
*
|
||||
* @param name the service name and location
|
||||
* @return Remote-object that implements the named service
|
||||
* @throws NotBoundException if no object implements the service
|
||||
* @throws MalformedURLException
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public static Remote lookup(String name) throws NotBoundException, MalformedURLException, RemoteException {
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
return (getRegistry(u).lookup(serviceName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to bind the given object to the given service name.
|
||||
* @param name
|
||||
* @param obj
|
||||
* @throws AlreadyBoundException
|
||||
* @throws MalformedURLException
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public static void bind(String name, Remote obj) throws AlreadyBoundException, MalformedURLException, RemoteException {
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
getRegistry(u).bind(serviceName, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a binding for a given service name.
|
||||
* @param name
|
||||
* @throws RemoteException
|
||||
* @throws NotBoundException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static void unbind(String name) throws RemoteException, NotBoundException, MalformedURLException {
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
getRegistry(u).unbind(serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the binding between the given Remote-object and the given service name, even
|
||||
* if there was already an object bound to this name.
|
||||
* @param name
|
||||
* @param obj
|
||||
* @throws RemoteException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static void rebind(String name, Remote obj) throws RemoteException, MalformedURLException {
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
getRegistry(u).rebind(serviceName, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all services at the named registry.
|
||||
* @param name url that specifies the registry
|
||||
* @return list of services at the name registry
|
||||
* @throws RemoteException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static String[] list(String name) throws RemoteException, MalformedURLException {
|
||||
return (getRegistry(parseURL(name)).list());
|
||||
}
|
||||
|
||||
private static Registry getRegistry(URL u) throws RemoteException {
|
||||
if (u.getPort() == -1) {
|
||||
return (LocateRegistry.getRegistry(u.getHost()));
|
||||
}
|
||||
else {
|
||||
return (LocateRegistry.getRegistry(u.getHost(), u.getPort()));
|
||||
}
|
||||
}
|
||||
private Naming()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the supplied URL and converts it to use the HTTP
|
||||
* protocol. From an RMI perspective, the scheme is irrelevant
|
||||
* and we want to be able to create a URL for which a handler is
|
||||
* available.
|
||||
*
|
||||
* @param name the URL in String form.
|
||||
* @throws MalformedURLException if the URL is invalid.
|
||||
* Looks for the remote object that is associated with the named service.
|
||||
* Name and location is given in form of a URL without a scheme:
|
||||
*
|
||||
* <pre>
|
||||
* //host:port/service-name
|
||||
* </pre>
|
||||
*
|
||||
* The port is optional.
|
||||
*
|
||||
* @param name the service name and location
|
||||
* @return Remote-object that implements the named service
|
||||
* @throws NotBoundException if no object implements the service
|
||||
* @throws MalformedURLException
|
||||
* @throws RemoteException
|
||||
*/
|
||||
private static URL parseURL(String name)
|
||||
throws MalformedURLException
|
||||
public static Remote lookup(String name) throws NotBoundException,
|
||||
MalformedURLException, RemoteException
|
||||
{
|
||||
try
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
return (getRegistry(u).lookup(serviceName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to bind the given object to the given service name.
|
||||
*
|
||||
* @param name
|
||||
* @param obj
|
||||
* @throws AlreadyBoundException
|
||||
* @throws MalformedURLException
|
||||
* @throws RemoteException
|
||||
*/
|
||||
public static void bind(String name, Remote obj)
|
||||
throws AlreadyBoundException, MalformedURLException, RemoteException
|
||||
{
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
getRegistry(u).bind(serviceName, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a binding for a given service name.
|
||||
*
|
||||
* @param name
|
||||
* @throws RemoteException
|
||||
* @throws NotBoundException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static void unbind(String name) throws RemoteException,
|
||||
NotBoundException, MalformedURLException
|
||||
{
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
getRegistry(u).unbind(serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the binding between the given Remote-object and the given service
|
||||
* name, even if there was already an object bound to this name.
|
||||
*
|
||||
* @param name
|
||||
* @param obj
|
||||
* @throws RemoteException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static void rebind(String name, Remote obj) throws RemoteException,
|
||||
MalformedURLException
|
||||
{
|
||||
URL u = parseURL(name);
|
||||
String serviceName = getName(u);
|
||||
getRegistry(u).rebind(serviceName, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all services at the named registry.
|
||||
*
|
||||
* @param name url that specifies the registry
|
||||
* @return list of services at the name registry
|
||||
* @throws RemoteException
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static String[] list(String name) throws RemoteException,
|
||||
MalformedURLException
|
||||
{
|
||||
return (getRegistry(parseURL(name)).list());
|
||||
}
|
||||
|
||||
private static Registry getRegistry(URL u) throws RemoteException
|
||||
{
|
||||
if (u.getPort() == - 1)
|
||||
{
|
||||
URI uri = new URI(name);
|
||||
String host = uri.getHost();
|
||||
int port = uri.getPort();
|
||||
String query = uri.getQuery();
|
||||
String path = uri.getPath();
|
||||
return new URL("http",
|
||||
(host == null ? "localhost" : host),
|
||||
(port == -1 ? 1099 : port),
|
||||
uri.getPath() + (query == null ? "" : query));
|
||||
return (LocateRegistry.getRegistry(u.getHost()));
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
else
|
||||
{
|
||||
throw new MalformedURLException("The URL syntax was invalid: " +
|
||||
e.getMessage());
|
||||
return (LocateRegistry.getRegistry(u.getHost(), u.getPort()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the URL contains a name, and removes any leading
|
||||
* slashes.
|
||||
*
|
||||
* Parses the supplied URL and converts it to use the HTTP protocol. From an
|
||||
* RMI perspective, the scheme is irrelevant and we want to be able to create
|
||||
* a URL for which a handler is available.
|
||||
*
|
||||
* @param name the URL in String form.
|
||||
* @throws MalformedURLException if the URL is invalid.
|
||||
*/
|
||||
private static URL parseURL(String name) throws MalformedURLException
|
||||
{
|
||||
try
|
||||
{
|
||||
URI uri = new URI(name);
|
||||
String host = uri.getHost();
|
||||
int port = uri.getPort();
|
||||
String query = uri.getQuery();
|
||||
String path = uri.getPath();
|
||||
return new URL("http", (host == null ? "localhost" : host),
|
||||
(port == - 1 ? 1099 : port), uri.getPath()
|
||||
+ (query == null ? "" : query));
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
throw new MalformedURLException("The URL syntax was invalid: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the URL contains a name, and removes any leading slashes.
|
||||
*
|
||||
* @param url the URL to check.
|
||||
* @throws MalformedURLException if no name is specified.
|
||||
*/
|
||||
private static String getName(URL url)
|
||||
throws MalformedURLException
|
||||
*/
|
||||
private static String getName(URL url) throws MalformedURLException
|
||||
{
|
||||
String filename = url.getFile();
|
||||
if (filename.length() == 0)
|
||||
|
@ -216,5 +231,4 @@ private static Registry getRegistry(URL u) throws RemoteException {
|
|||
return filename.substring(1);
|
||||
return filename;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* NoSuchObjectException.java -- thrown if the remote object no longer exists
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -43,9 +44,9 @@ package java.rmi;
|
|||
* obey the semantics of "at most once".
|
||||
*
|
||||
* @author unknown
|
||||
* @see RemoteObject#toStub(Remote)
|
||||
* @see UnicastRemoteObject#unexportObject(Remote, boolean)
|
||||
* @see Activatable#unexportObject(Remote, boolean)
|
||||
* @see java.rmi.server.RemoteObject#toStub(Remote)
|
||||
* @see java.rmi.server.UnicastRemoteObject#unexportObject(Remote, boolean)
|
||||
* @see java.rmi.activation.Activatable#unexportObject(Remote, boolean)
|
||||
* @since 1.1
|
||||
* @status updated to 1.4
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* NotBoundException.java -- attempt to use a registry name with no binding
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -42,10 +43,10 @@ package java.rmi;
|
|||
* associated binding.
|
||||
*
|
||||
* @author unknown
|
||||
* @see Naming#lookup(String)
|
||||
* @see Naming#unbind(String)
|
||||
* @see Registry#lookup(String)
|
||||
* @see Registry#unbind(String)
|
||||
* @see java.rmi.Naming#lookup(String)
|
||||
* @see java.rmi.Naming#unbind(String)
|
||||
* @see java.rmi.registry.Registry#lookup(String)
|
||||
* @see java.rmi.registry.Registry#unbind(String)
|
||||
* @since 1.1
|
||||
* @status updated to 1.4
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* RMISecurityException.java -- deprecated version of SecurityException
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -38,11 +39,12 @@ exception statement from your version. */
|
|||
package java.rmi;
|
||||
|
||||
/**
|
||||
* Never thrown, but originally intended to wrap a java.lang.SecurityException.
|
||||
* Never thrown, but originally intended to wrap a
|
||||
* {@link java.lang.SecurityException} in the case of RMI.
|
||||
*
|
||||
* @author unknown
|
||||
* @since 1.1
|
||||
* @deprecated use {@link SecurityException} instead
|
||||
* @deprecated use {@link java.lang.SecurityException} instead
|
||||
* @status updated to 1.4
|
||||
*/
|
||||
public class RMISecurityException extends SecurityException
|
||||
|
@ -55,7 +57,7 @@ public class RMISecurityException extends SecurityException
|
|||
/**
|
||||
* Create an exception with a message.
|
||||
*
|
||||
* @param s the message
|
||||
* @param n the message
|
||||
* @deprecated no longer needed
|
||||
*/
|
||||
public RMISecurityException(String n)
|
||||
|
@ -66,8 +68,8 @@ public class RMISecurityException extends SecurityException
|
|||
/**
|
||||
* Create an exception with a message and a cause.
|
||||
*
|
||||
* @param s the message
|
||||
* @param e the cause
|
||||
* @param n the message
|
||||
* @param a the cause (ignored)
|
||||
* @deprecated no longer needed
|
||||
*/
|
||||
public RMISecurityException(String n, String a)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Remote.java
|
||||
Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -37,5 +37,22 @@ exception statement from your version. */
|
|||
|
||||
package java.rmi;
|
||||
|
||||
/**
|
||||
* Marker interface for interfaces which methods are invokable
|
||||
* from outside of this virtual machine through remote method calls.
|
||||
* <p>
|
||||
* Remote invokable methods of remote object implementations are specified
|
||||
* as the methods defined in the implemented remote interfaces. Typically
|
||||
* remote object implementations are subclasses of the convenience classes
|
||||
* {@link java.rmi.server.UnicastRemoteObject} or
|
||||
* {@link java.rmi.activation.Activatable} implementing one or more remote
|
||||
* interfaces indicating their remotely accessible methods. The convenience
|
||||
* classes provide implementations for correct remote object creation,
|
||||
* hash, equals and toString methods.
|
||||
* </p>
|
||||
*
|
||||
* @author unknown
|
||||
*/
|
||||
public interface Remote {
|
||||
// marker interface
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* RemoteException.java -- common superclass for exceptions in java.rmi
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -86,7 +87,7 @@ public class RemoteException extends IOException
|
|||
* Create an exception with the given message and cause.
|
||||
*
|
||||
* @param s the message
|
||||
* @param ex the cause
|
||||
* @param e the cause
|
||||
*/
|
||||
public RemoteException(String s, Throwable e)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* StubNotFoundException.java -- thrown if a valid stub is not found
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -41,8 +42,8 @@ package java.rmi;
|
|||
* Thrown if a valid stub class is not found for an object when it is exported.
|
||||
*
|
||||
* @author unknown
|
||||
* @see UnicastRemoteObject
|
||||
* @see Activatable
|
||||
* @see java.rmi.server.UnicastRemoteObject
|
||||
* @see java.rmi.activation.Activatable
|
||||
* @since 1.1
|
||||
* @status updated to 1.4
|
||||
*/
|
||||
|
|
|
@ -41,11 +41,40 @@ import java.rmi.Remote;
|
|||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.ObjID;
|
||||
|
||||
public interface DGC extends Remote
|
||||
/**
|
||||
* The DGC implementation is used for the server side during the distributed
|
||||
* garbage collection. This interface contains the two methods: dirty and clean.
|
||||
* A dirty call is made when a remote reference is unmarshaled in a client. A
|
||||
* corresponding clean call is made by client it no longer uses that remote
|
||||
* reference. A reference to a remote object is also automatically released
|
||||
* after so called lease period that starts after the dirty call is received. It
|
||||
* is the client's responsibility to renew the leases, by making additional
|
||||
* dirty calls before such leases expire.
|
||||
*/
|
||||
public interface DGC
|
||||
extends Remote
|
||||
{
|
||||
Lease dirty (ObjID[] ids, long sequenceNum, Lease lease)
|
||||
throws RemoteException;
|
||||
/**
|
||||
* Mark the given objects referecnes as used on the client side.
|
||||
*
|
||||
* @param ids the ids of the used objects.
|
||||
* @param sequenceNum the number of the call (used to detect and discard late
|
||||
* calls).
|
||||
* @param lease the requested lease
|
||||
* @return the granted lease
|
||||
*/
|
||||
Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
|
||||
throws RemoteException;
|
||||
|
||||
void clean (ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
|
||||
throws RemoteException;
|
||||
/**
|
||||
* Mark the given objects as no longer used on the client side.
|
||||
*
|
||||
* @param ids the ids of the objects that are no longer used.
|
||||
* @param sequenceNum the number of the call (used to detect and discard late
|
||||
* @param vmid the VMID of the client.
|
||||
* @param strong make the "strong" clean call ("strong" calls are scheduled
|
||||
* after the failed dirty calls).
|
||||
*/
|
||||
void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
|
||||
throws RemoteException;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Lease.java
|
||||
Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -7,7 +8,7 @@ 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
|
||||
|
@ -39,29 +40,61 @@ package java.rmi.dgc;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A lease object is used to request and grant leases for the remote objects. It
|
||||
* contains the lease duration and the unique VM indentifier.
|
||||
*/
|
||||
public final class Lease
|
||||
implements Serializable {
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
static final long serialVersionUID = -5713411624328831948L;
|
||||
static final long serialVersionUID = - 5713411624328831948L;
|
||||
|
||||
private VMID vmid;
|
||||
private long value;
|
||||
private VMID vmid;
|
||||
|
||||
public Lease(VMID id, long duration) {
|
||||
vmid = id;
|
||||
value = duration;
|
||||
}
|
||||
private long value;
|
||||
|
||||
public VMID getVMID() {
|
||||
return (vmid);
|
||||
}
|
||||
/**
|
||||
* Create the new lease with the given id and duration
|
||||
*
|
||||
* @param id the lease id
|
||||
* @param duration the lease duration
|
||||
*/
|
||||
public Lease(VMID id, long duration)
|
||||
{
|
||||
vmid = id;
|
||||
value = duration;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return (value);
|
||||
}
|
||||
/**
|
||||
* Get the lease id.
|
||||
*
|
||||
* @return the lease id
|
||||
*/
|
||||
public VMID getVMID()
|
||||
{
|
||||
return (vmid);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return ("[" + vmid.toString() + ", " + Long.toString(value) + "]");
|
||||
}
|
||||
/**
|
||||
* Get the lease duration
|
||||
*
|
||||
* @return the lease duration
|
||||
*/
|
||||
public long getValue()
|
||||
{
|
||||
return (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string representation of this lease
|
||||
*
|
||||
* @return the string represenation (lease id, followed by the lease
|
||||
* duration).
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return ("[" + vmid.toString() + ", " + Long.toString(value) + "]");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ exception statement from your version. -->
|
|||
<head><title>GNU Classpath - java.rmi</title></head>
|
||||
|
||||
<body>
|
||||
<p></p>
|
||||
<p>Provides basic Remote Method Invocation (RMI) interfaces, classes and exceptions.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue