[llvm-commits] [llvm-gcc-4.2] r43913 [34/80] - in /llvm-gcc-4.2/trunk: boehm-gc/ boehm-gc/Mac_files/ boehm-gc/cord/ boehm-gc/doc/ boehm-gc/include/ boehm-gc/include/private/ boehm-gc/tests/ libffi/ libffi/include/ libffi/src/ libffi/src/alpha/ libffi/src/arm/ libffi/src/cris/ libffi/src/frv/ libffi/src/ia64/ libffi/src/m32r/ libffi/src/m68k/ libffi/src/mips/ libffi/src/pa/ libffi/src/powerpc/ libffi/src/s390/ libffi/src/sh/ libffi/src/sh64/ libffi/src/sparc/ libffi/src/x86/ libffi/testsuite/ libffi/testsuite/config/ li...
Bill Wendling
isanbard at gmail.com
Thu Nov 8 14:57:11 PST 2007
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayout.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayout.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayout.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayout.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1101 @@
+/* GridBagLayout - Layout manager for components according to GridBagConstraints
+ Copyright (C) 2002, 2003, 2004, 2005, 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 java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @author Jeroen Frijters (jeroen at frijters.net)
+ */
+public class GridBagLayout
+ implements Serializable, LayoutManager2
+{
+ private static final long serialVersionUID = 8838754796412211005L;
+
+ protected static final int MINSIZE = 1;
+ protected static final int PREFERREDSIZE = 2;
+ protected static final int MAXGRIDSIZE = 512;
+
+ // comptable remembers the original contraints given to us.
+ // internalcomptable is used to keep track of modified constraint values
+ // that we calculate, particularly when we are given RELATIVE and
+ // REMAINDER constraints.
+ // Constraints kept in comptable are never modified, and constraints
+ // kept in internalcomptable can be modified internally only.
+ protected Hashtable comptable;
+ private Hashtable internalcomptable;
+ protected GridBagLayoutInfo layoutInfo;
+ protected GridBagConstraints defaultConstraints;
+
+ public double[] columnWeights;
+ public int[] columnWidths;
+ public double[] rowWeights;
+ public int[] rowHeights;
+
+ public GridBagLayout ()
+ {
+ this.comptable = new Hashtable();
+ this.internalcomptable = new Hashtable();
+ this.defaultConstraints= new GridBagConstraints();
+ }
+
+ /**
+ * Helper method to calc the sum of a range of elements in an int array.
+ */
+ private int sumIntArray (int[] array, int upto)
+ {
+ int result = 0;
+
+ for (int i = 0; i < upto; i++)
+ result += array [i];
+
+ return result;
+ }
+
+ /**
+ * Helper method to calc the sum of all elements in an int array.
+ */
+ private int sumIntArray (int[] array)
+ {
+ return sumIntArray(array, array.length);
+ }
+
+ /**
+ * Helper method to calc the sum of all elements in an double array.
+ */
+ private double sumDoubleArray (double[] array)
+ {
+ double result = 0;
+
+ for (int i = 0; i < array.length; i++)
+ result += array [i];
+
+ return result;
+ }
+
+ public void addLayoutComponent (String name, Component component)
+ {
+ // do nothing here.
+ }
+
+ public void removeLayoutComponent (Component component)
+ {
+ // do nothing here
+ }
+
+ public void addLayoutComponent (Component component, Object constraints)
+ {
+ if (constraints == null)
+ return;
+
+ if (!(constraints instanceof GridBagConstraints))
+ throw new IllegalArgumentException("constraints "
+ + constraints
+ + " are not an instance of GridBagConstraints");
+
+ setConstraints (component, (GridBagConstraints) constraints);
+ }
+
+ public Dimension preferredLayoutSize (Container parent)
+ {
+ if (parent == null)
+ return new Dimension (0, 0);
+
+ GridBagLayoutInfo li = getLayoutInfo (parent, PREFERREDSIZE);
+ return getMinSize (parent, li);
+ }
+
+ public Dimension minimumLayoutSize (Container parent)
+ {
+ if (parent == null)
+ return new Dimension (0, 0);
+
+ GridBagLayoutInfo li = getLayoutInfo (parent, MINSIZE);
+ return getMinSize (parent, li);
+ }
+
+ public Dimension maximumLayoutSize (Container target)
+ {
+ return new Dimension (Integer.MAX_VALUE, Integer.MAX_VALUE);
+ }
+
+ public void layoutContainer (Container parent)
+ {
+ arrangeGrid (parent);
+ }
+
+ public float getLayoutAlignmentX (Container target)
+ {
+ return Component.CENTER_ALIGNMENT;
+ }
+
+ public float getLayoutAlignmentY (Container target)
+ {
+ return Component.CENTER_ALIGNMENT;
+ }
+
+ public void invalidateLayout (Container target)
+ {
+ this.layoutInfo = null;
+ }
+
+ public void setConstraints (Component component,
+ GridBagConstraints constraints)
+ {
+ GridBagConstraints clone = (GridBagConstraints) constraints.clone();
+
+ if (clone.gridx < 0)
+ clone.gridx = GridBagConstraints.RELATIVE;
+
+ if (clone.gridy < 0)
+ clone.gridy = GridBagConstraints.RELATIVE;
+
+ if (clone.gridwidth == 0)
+ clone.gridwidth = GridBagConstraints.REMAINDER;
+ else if (clone.gridwidth < 0)
+ clone.gridwidth = 1;
+
+ if (clone.gridheight == 0)
+ clone.gridheight = GridBagConstraints.REMAINDER;
+ else if (clone.gridheight < 0)
+ clone.gridheight = 1;
+
+ comptable.put (component, clone);
+ }
+
+ public GridBagConstraints getConstraints (Component component)
+ {
+ return (GridBagConstraints) (lookupConstraints (component).clone());
+ }
+
+ protected GridBagConstraints lookupConstraints (Component component)
+ {
+ GridBagConstraints result = (GridBagConstraints) comptable.get (component);
+
+ if (result == null)
+ {
+ setConstraints (component, defaultConstraints);
+ result = (GridBagConstraints) comptable.get (component);
+ }
+
+ return result;
+ }
+
+ private GridBagConstraints lookupInternalConstraints (Component component)
+ {
+ GridBagConstraints result =
+ (GridBagConstraints) internalcomptable.get (component);
+
+ if (result == null)
+ {
+ result = (GridBagConstraints) lookupConstraints(component).clone();
+ internalcomptable.put (component, result);
+ }
+
+ return result;
+ }
+
+ /**
+ * @since 1.1
+ */
+ public Point getLayoutOrigin ()
+ {
+ if (layoutInfo == null)
+ return new Point (0, 0);
+
+ return new Point (layoutInfo.pos_x, layoutInfo.pos_y);
+ }
+
+ /**
+ * @since 1.1
+ */
+ public int[][] getLayoutDimensions ()
+ {
+ int[][] result = new int [2][];
+ if (layoutInfo == null)
+ {
+ result[0] = new int[0];
+ result[1] = new int[0];
+
+ return result;
+ }
+
+ result [0] = new int [layoutInfo.cols];
+ System.arraycopy (layoutInfo.colWidths, 0, result [0], 0, layoutInfo.cols);
+ result [1] = new int [layoutInfo.rows];
+ System.arraycopy (layoutInfo.rowHeights, 0, result [1], 0, layoutInfo.rows);
+ return result;
+ }
+
+ public double[][] getLayoutWeights ()
+ {
+ double[][] result = new double [2][];
+ if (layoutInfo == null)
+ {
+ result[0] = new double[0];
+ result[1] = new double[0];
+
+ return result;
+ }
+
+ result [0] = new double [layoutInfo.cols];
+ System.arraycopy (layoutInfo.colWeights, 0, result [0], 0, layoutInfo.cols);
+ result [1] = new double [layoutInfo.rows];
+ System.arraycopy (layoutInfo.rowWeights, 0, result [1], 0, layoutInfo.rows);
+ return result;
+ }
+
+ /**
+ * @since 1.1
+ */
+ public Point location (int x, int y)
+ {
+ if (layoutInfo == null)
+ return new Point (0, 0);
+
+ int col;
+ int row;
+ int pixel_x = layoutInfo.pos_x;
+ int pixel_y = layoutInfo.pos_y;
+
+ for (col = 0; col < layoutInfo.cols; col++)
+ {
+ int w = layoutInfo.colWidths [col];
+ if (x < pixel_x + w)
+ break;
+
+ pixel_x += w;
+ }
+
+ for (row = 0; row < layoutInfo.rows; row++)
+ {
+ int h = layoutInfo.rowHeights [row];
+ if (y < pixel_y + h)
+ break;
+
+ pixel_y += h;
+ }
+
+ return new Point (col, row);
+ }
+
+ /**
+ * Move and resize a rectangle according to a set of grid bag
+ * constraints. The x, y, width and height fields of the
+ * rectangle argument are adjusted to the new values.
+ *
+ * @param constraints position and size constraints
+ * @param r rectangle to be moved and resized
+ */
+ protected void AdjustForGravity (GridBagConstraints constraints,
+ Rectangle r)
+ {
+ Insets insets = constraints.insets;
+ if (insets != null)
+ {
+ r.x += insets.left;
+ r.y += insets.top;
+ r.width -= insets.left + insets.right;
+ r.height -= insets.top + insets.bottom;
+ }
+ }
+
+ /**
+ * Obsolete.
+ */
+ protected void ArrangeGrid (Container parent)
+ {
+ Component[] components = parent.getComponents();
+
+ if (components.length == 0)
+ return;
+
+ GridBagLayoutInfo info = getLayoutInfo (parent, PREFERREDSIZE);
+ if (info.cols == 0 && info.rows == 0)
+ return;
+
+ // DEBUG
+ //dumpLayoutInfo (info);
+
+ // Calling setBounds on these components causes this layout to
+ // be invalidated, clearing the layout information cache,
+ // layoutInfo. So we wait until after this for loop to set
+ // layoutInfo.
+ Component lastComp = null;
+
+ Rectangle cell = new Rectangle();
+
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components[i];
+
+ // If component is not visible we dont have to care about it.
+ if (! component.isVisible())
+ continue;
+
+ Dimension dim = component.getPreferredSize();
+ GridBagConstraints constraints = lookupInternalConstraints(component);
+
+ if (lastComp != null
+ && constraints.gridheight == GridBagConstraints.REMAINDER)
+ cell.y += cell.height;
+ else
+ cell.y = sumIntArray(info.rowHeights, constraints.gridy);
+
+ if (lastComp != null
+ && constraints.gridwidth == GridBagConstraints.REMAINDER)
+ cell.x += cell.width;
+ else
+ cell.x = sumIntArray(info.colWidths, constraints.gridx);
+
+ cell.width = sumIntArray(info.colWidths, constraints.gridx
+ + constraints.gridwidth) - cell.x;
+ cell.height = sumIntArray(info.rowHeights, constraints.gridy
+ + constraints.gridheight) - cell.y;
+
+ // Adjust for insets.
+ AdjustForGravity( constraints, cell );
+
+ // Note: Documentation says that padding is added on both sides, but
+ // visual inspection shows that the Sun implementation only adds it
+ // once, so we do the same.
+ dim.width += constraints.ipadx;
+ dim.height += constraints.ipady;
+
+ switch (constraints.fill)
+ {
+ case GridBagConstraints.HORIZONTAL:
+ dim.width = cell.width;
+ break;
+ case GridBagConstraints.VERTICAL:
+ dim.height = cell.height;
+ break;
+ case GridBagConstraints.BOTH:
+ dim.width = cell.width;
+ dim.height = cell.height;
+ break;
+ }
+
+ int x = 0;
+ int y = 0;
+
+ switch (constraints.anchor)
+ {
+ case GridBagConstraints.NORTH:
+ x = cell.x + (cell.width - dim.width) / 2;
+ y = cell.y;
+ break;
+ case GridBagConstraints.SOUTH:
+ x = cell.x + (cell.width - dim.width) / 2;
+ y = cell.y + cell.height - dim.height;
+ break;
+ case GridBagConstraints.WEST:
+ x = cell.x;
+ y = cell.y + (cell.height - dim.height) / 2;
+ break;
+ case GridBagConstraints.EAST:
+ x = cell.x + cell.width - dim.width;
+ y = cell.y + (cell.height - dim.height) / 2;
+ break;
+ case GridBagConstraints.NORTHEAST:
+ x = cell.x + cell.width - dim.width;
+ y = cell.y;
+ break;
+ case GridBagConstraints.NORTHWEST:
+ x = cell.x;
+ y = cell.y;
+ break;
+ case GridBagConstraints.SOUTHEAST:
+ x = cell.x + cell.width - dim.width;
+ y = cell.y + cell.height - dim.height;
+ break;
+ case GridBagConstraints.SOUTHWEST:
+ x = cell.x;
+ y = cell.y + cell.height - dim.height;
+ break;
+ default:
+ x = cell.x + (cell.width - dim.width) / 2;
+ y = cell.y + (cell.height - dim.height) / 2;
+ break;
+ }
+ component.setBounds(info.pos_x + x, info.pos_y + y, dim.width,
+ dim.height);
+ lastComp = component;
+ }
+
+ // DEBUG
+ //dumpLayoutInfo(info);
+
+ // Cache layout information.
+ layoutInfo = getLayoutInfo(parent, PREFERREDSIZE);
+ }
+
+ /**
+ * Obsolete.
+ */
+ protected GridBagLayoutInfo GetLayoutInfo (Container parent, int sizeflag)
+ {
+ if (sizeflag != MINSIZE && sizeflag != PREFERREDSIZE)
+ throw new IllegalArgumentException();
+
+ Dimension parentDim = parent.getSize ();
+ Insets parentInsets = parent.getInsets ();
+ parentDim.width -= parentInsets.left + parentInsets.right;
+ parentDim.height -= parentInsets.top + parentInsets.bottom;
+
+ int current_y = 0;
+ int max_x = 0;
+ int max_y = 0;
+
+ // Guaranteed to contain the last component added to the given row
+ // or column, whose gridwidth/height is not REMAINDER.
+ HashMap lastInRow = new HashMap();
+ HashMap lastInCol = new HashMap();
+
+ Component[] components = parent.getComponents();
+
+ // Components sorted by gridwidths/heights,
+ // smallest to largest, with REMAINDER and RELATIVE at the end.
+ // These are useful when determining sizes and weights.
+ ArrayList sortedByWidth = new ArrayList(components.length);
+ ArrayList sortedByHeight = new ArrayList(components.length);
+
+ // STEP 1: first we figure out how many rows/columns
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ // When looking up the constraint for the first time, check the
+ // original unmodified constraint. After the first time, always
+ // refer to the internal modified constraint.
+ GridBagConstraints originalConstraints = lookupConstraints (component);
+ GridBagConstraints constraints = (GridBagConstraints) originalConstraints.clone();
+ internalcomptable.put(component, constraints);
+
+ // Cases:
+ //
+ // 1. gridy == RELATIVE, gridx == RELATIVE
+ //
+ // use y as the row number; check for the next
+ // available slot at row y
+ //
+ // 2. only gridx == RELATIVE
+ //
+ // check for the next available slot at row gridy
+ //
+ // 3. only gridy == RELATIVE
+ //
+ // check for the next available slot at column gridx
+ //
+ // 4. neither gridx or gridy == RELATIVE
+ //
+ // nothing to check; just add it
+
+ // cases 1 and 2
+ if(constraints.gridx == GridBagConstraints.RELATIVE)
+ {
+ if (constraints.gridy == GridBagConstraints.RELATIVE)
+ constraints.gridy = current_y;
+
+ int x;
+
+ // Check the component that occupies the right-most spot in this
+ // row. We want to add this component after it.
+ // If this row is empty, add to the 0 position.
+ if (!lastInRow.containsKey(new Integer(constraints.gridy)))
+ x = 0;
+ else
+ {
+ Component lastComponent = (Component) lastInRow.get(new Integer(constraints.gridy));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+ x = lastConstraints.gridx + Math.max(1, lastConstraints.gridwidth);
+ }
+
+ // Determine if this component will fit in the slot vertically.
+ // If not, bump it over to where it does fit.
+ for (int y = constraints.gridy + 1; y < constraints.gridy + Math.max(1, constraints.gridheight); y++)
+ {
+ if (lastInRow.containsKey(new Integer(y)))
+ {
+ Component lastComponent = (Component) lastInRow.get(new Integer(y));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+ x = Math.max (x,
+ lastConstraints.gridx + Math.max(1, lastConstraints.gridwidth));
+ }
+ }
+
+ constraints.gridx = x;
+ }
+ // case 3
+ else if(constraints.gridy == GridBagConstraints.RELATIVE)
+ {
+ int y;
+ // Check the component that occupies the bottom-most spot in
+ // this column. We want to add this component below it.
+ // If this column is empty, add to the 0 position.
+ if (!lastInCol.containsKey(new Integer(constraints.gridx)))
+ {
+ y = current_y;
+ }
+ else
+ {
+ Component lastComponent = (Component)lastInCol.get(new Integer(constraints.gridx));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+ y = lastConstraints.gridy + Math.max(1, lastConstraints.gridheight);
+ }
+
+ // Determine if this component will fit in the slot horizontally.
+ // If not, bump it down to where it does fit.
+ for (int x = constraints.gridx + 1; x < constraints.gridx + Math.max(1, constraints.gridwidth); x++)
+ {
+ if (lastInCol.containsKey(new Integer(x)))
+ {
+ Component lastComponent = (Component) lastInCol.get(new Integer(x));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+ y = Math.max (y,
+ lastConstraints.gridy + Math.max(1, lastConstraints.gridheight));
+ }
+ }
+
+ constraints.gridy = y;
+ }
+ // case 4: do nothing
+
+ max_x = Math.max(max_x,
+ constraints.gridx + Math.max(1, constraints.gridwidth));
+ max_y = Math.max(max_y,
+ constraints.gridy + Math.max(1, constraints.gridheight));
+
+ sortBySpan(component, constraints.gridwidth, sortedByWidth, true);
+ sortBySpan(component, constraints.gridheight, sortedByHeight, false);
+
+ // Update our reference points for RELATIVE gridx and gridy.
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER)
+ {
+ current_y = constraints.gridy + Math.max(1, constraints.gridheight);
+ }
+ else if (constraints.gridwidth != GridBagConstraints.REMAINDER)
+ {
+ for (int y = constraints.gridy; y < constraints.gridy + Math.max(1, constraints.gridheight); y++)
+ {
+ if(lastInRow.containsKey(new Integer(y)))
+ {
+ Component lastComponent = (Component) lastInRow.get(new Integer(y));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+ if (constraints.gridx > lastConstraints.gridx)
+ {
+ lastInRow.put(new Integer(y), component);
+ }
+ }
+ else
+ {
+ lastInRow.put(new Integer(y), component);
+ }
+ }
+
+ for (int x = constraints.gridx; x < constraints.gridx + Math.max(1, constraints.gridwidth); x++)
+ {
+ if(lastInCol.containsKey(new Integer(x)))
+ {
+ Component lastComponent = (Component) lastInCol.get(new Integer(x));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+ if (constraints.gridy > lastConstraints.gridy)
+ {
+ lastInCol.put(new Integer(x), component);
+ }
+ }
+ else
+ {
+ lastInCol.put(new Integer(x), component);
+ }
+ }
+ }
+ } // end of STEP 1
+
+ GridBagLayoutInfo info = new GridBagLayoutInfo(max_x, max_y);
+
+ // Check if column widths and row heights are overridden.
+
+ for (int x = 0; x < max_x; x++)
+ {
+ if(columnWidths != null && columnWidths.length > x)
+ info.colWidths[x] = columnWidths[x];
+ if(columnWeights != null && columnWeights.length > x)
+ info.colWeights[x] = columnWeights[x];
+ }
+
+ for (int y = 0; y < max_y; y++)
+ {
+ if(rowHeights != null && rowHeights.length > y)
+ info.rowHeights[y] = rowHeights[y];
+ if(rowWeights != null && rowWeights.length > y)
+ info.rowWeights[y] = rowWeights[y];
+ }
+
+ // STEP 2: Fix up any cells with width/height as REMAINDER/RELATIVE.
+ for (int i = 0; i < components.length; i++)
+ {
+ Component component = components [i];
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupInternalConstraints (component);
+
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER || constraints.gridwidth == GridBagConstraints.RELATIVE)
+ {
+ if(constraints.gridwidth == GridBagConstraints.REMAINDER)
+ {
+ for (int y = constraints.gridy; y < constraints.gridy + Math.max(1, constraints.gridheight); y++)
+ {
+ if (lastInRow.containsKey(new Integer(y)))
+ {
+ Component lastComponent = (Component) lastInRow.get(new Integer(y));
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+
+ if (lastConstraints.gridwidth == GridBagConstraints.RELATIVE)
+ {
+ constraints.gridx = max_x - 1;
+ break;
+ }
+ else
+ {
+ constraints.gridx = Math.max (constraints.gridx,
+ lastConstraints.gridx + Math.max (1, lastConstraints.gridwidth));
+ }
+ }
+ }
+ constraints.gridwidth = max_x - constraints.gridx;
+ }
+ else if (constraints.gridwidth == GridBagConstraints.RELATIVE)
+ {
+ constraints.gridwidth = max_x - constraints.gridx - 1;
+ }
+
+ // Re-sort
+ sortedByWidth.remove(sortedByWidth.indexOf(component));
+ sortBySpan(component, constraints.gridwidth, sortedByWidth, true);
+ }
+
+ if(constraints.gridheight == GridBagConstraints.REMAINDER || constraints.gridheight == GridBagConstraints.RELATIVE)
+ {
+ if(constraints.gridheight == GridBagConstraints.REMAINDER)
+ {
+ for (int x = constraints.gridx; x < constraints.gridx + Math.max(1, constraints.gridwidth); x++)
+ {
+ if (lastInCol.containsKey(new Integer(x)))
+ {
+ Component lastComponent = (Component) lastInRow.get(new Integer(x));
+ if (lastComponent != null)
+ {
+ GridBagConstraints lastConstraints = lookupInternalConstraints(lastComponent);
+
+ if (lastConstraints.gridheight == GridBagConstraints.RELATIVE)
+ {
+ constraints.gridy = max_y - 1;
+ break;
+ }
+ else
+ {
+ constraints.gridy = Math.max (constraints.gridy,
+ lastConstraints.gridy + Math.max (1, lastConstraints.gridheight));
+ }
+ }
+ }
+ }
+ constraints.gridheight = max_y - constraints.gridy;
+ }
+ else if (constraints.gridheight == GridBagConstraints.RELATIVE)
+ {
+ constraints.gridheight = max_y - constraints.gridy - 1;
+ }
+
+ // Re-sort
+ sortedByHeight.remove(sortedByHeight.indexOf(component));
+ sortBySpan(component, constraints.gridheight, sortedByHeight, false);
+ }
+ } // end of STEP 2
+
+ // STEP 3: Determine sizes and weights for columns.
+ for (int i = 0; i < sortedByWidth.size(); i++)
+ {
+ Component component = (Component) sortedByWidth.get(i);
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupInternalConstraints (component);
+
+ int width = (sizeflag == PREFERREDSIZE) ?
+ component.getPreferredSize().width :
+ component.getMinimumSize().width;
+
+ if(constraints.insets != null)
+ width += constraints.insets.left + constraints.insets.right;
+
+ width += constraints.ipadx;
+
+ distributeSizeAndWeight(width,
+ constraints.weightx,
+ constraints.gridx,
+ constraints.gridwidth,
+ info.colWidths,
+ info.colWeights);
+ } // end of STEP 3
+
+ // STEP 4: Determine sizes and weights for rows.
+ for (int i = 0; i < sortedByHeight.size(); i++)
+ {
+ Component component = (Component) sortedByHeight.get(i);
+
+ // If component is not visible we dont have to care about it.
+ if (!component.isVisible())
+ continue;
+
+ GridBagConstraints constraints = lookupInternalConstraints (component);
+
+ int height = (sizeflag == PREFERREDSIZE) ?
+ component.getPreferredSize().height :
+ component.getMinimumSize().height;
+
+ if(constraints.insets != null)
+ height += constraints.insets.top + constraints.insets.bottom;
+
+ height += constraints.ipady;
+
+ distributeSizeAndWeight(height,
+ constraints.weighty,
+ constraints.gridy,
+ constraints.gridheight,
+ info.rowHeights,
+ info.rowWeights);
+ } // end of STEP 4
+
+ // Adjust cell sizes iff parent size not zero.
+ if (parentDim.width > 0 && parentDim.height > 0)
+ {
+ calcCellSizes (info.colWidths, info.colWeights, parentDim.width);
+ calcCellSizes (info.rowHeights, info.rowWeights, parentDim.height);
+ }
+
+ int totalWidth = sumIntArray(info.colWidths);
+ int totalHeight = sumIntArray(info.rowHeights);
+
+ // Make sure pos_x and pos_y are never negative.
+ if (totalWidth >= parentDim.width)
+ info.pos_x = parentInsets.left;
+ else
+ info.pos_x = parentInsets.left + (parentDim.width - totalWidth) / 2;
+
+ if (totalHeight >= parentDim.height)
+ info.pos_y = parentInsets.top;
+ else
+ info.pos_y = parentInsets.top + (parentDim.height - totalHeight) / 2;
+
+ // DEBUG
+ //dumpLayoutInfo (info);
+
+ return info;
+ }
+
+ /**
+ * Obsolete.
+ */
+ protected Dimension GetMinSize (Container parent, GridBagLayoutInfo info)
+ {
+ if (parent == null || info == null)
+ return new Dimension (0, 0);
+
+ Insets insets = parent.getInsets();
+ int width = sumIntArray (info.colWidths) + insets.left + insets.right;
+ int height = sumIntArray (info.rowHeights) + insets.top + insets.bottom;
+ return new Dimension (width, height);
+ }
+
+ /**
+ * @since 1.4
+ */
+ protected Dimension getMinSize (Container parent, GridBagLayoutInfo info)
+ {
+ return GetMinSize (parent, info);
+ }
+
+ /**
+ * Helper method used by GetLayoutInfo to keep components sorted, either
+ * by gridwidth or gridheight.
+ *
+ * @param component Component to add to the sorted list.
+ * @param span Either the component's gridwidth or gridheight.
+ * @param list <code>ArrayList</code> of components, sorted by
+ * their span.
+ * @param sortByWidth Flag indicating sorting index. If true, sort by
+ * width. Otherwise, sort by height.
+ * FIXME: Use a better sorting algorithm.
+ */
+ private void sortBySpan (Component component, int span, ArrayList list, boolean sortByWidth)
+ {
+ if (span == GridBagConstraints.REMAINDER
+ || span == GridBagConstraints.RELATIVE)
+ {
+ // Put all RELATIVE and REMAINDER components at the end.
+ list.add(component);
+ }
+ else
+ {
+ int i = 0;
+ if (list.size() > 0)
+ {
+ GridBagConstraints gbc = lookupInternalConstraints((Component) list.get(i));
+ int otherspan = sortByWidth ?
+ gbc.gridwidth :
+ gbc.gridheight;
+ while (otherspan != GridBagConstraints.REMAINDER
+ && otherspan != GridBagConstraints.RELATIVE
+ && span >= otherspan)
+ {
+ i++;
+ if (i < list.size())
+ {
+ gbc = lookupInternalConstraints((Component) list.get(i));
+ otherspan = sortByWidth ?
+ gbc.gridwidth :
+ gbc.gridheight;
+ }
+ else
+ break;
+ }
+ }
+ list.add(i, component);
+ }
+ }
+
+ /**
+ * Helper method used by GetLayoutInfo to distribute a component's size
+ * and weight.
+ *
+ * @param size Preferred size of component, with inset and padding
+ * already added.
+ * @param weight Weight of component.
+ * @param start Starting position of component. Either
+ * constraints.gridx or gridy.
+ * @param span Span of component. either contraints.gridwidth or
+ * gridheight.
+ * @param sizes Sizes of rows or columns.
+ * @param weights Weights of rows or columns.
+ */
+ private void distributeSizeAndWeight (int size, double weight,
+ int start, int span,
+ int[] sizes, double[] weights)
+ {
+ if (span == 1)
+ {
+ sizes[start] = Math.max(sizes[start], size);
+ weights[start] = Math.max(weights[start], weight);
+ }
+ else
+ {
+ int numOccupied = span;
+ int lastOccupied = -1;
+
+ for(int i = start; i < start + span; i++)
+ {
+ if (sizes[i] == 0.0)
+ numOccupied--;
+ else
+ {
+ size -= sizes[i];
+ lastOccupied = i;
+ }
+ }
+
+ // A component needs to occupy at least one row.
+ if(numOccupied == 0)
+ sizes[start + span - 1] = size;
+ else if (size > 0)
+ sizes[lastOccupied] += size;
+
+ calcCellWeights(weight, weights, start, span);
+ }
+ }
+
+ /**
+ * Helper method used by GetLayoutInfo to calculate weight distribution.
+ * @param weight Weight of component.
+ * @param weights Weights of rows/columns.
+ * @param start Starting position of component in grid (gridx/gridy).
+ * @param span Span of component (gridwidth/gridheight).
+ */
+ private void calcCellWeights (double weight, double[] weights, int start, int span)
+ {
+ double totalWeight = 0.0;
+ for(int k = start; k < start + span; k++)
+ totalWeight += weights[k];
+
+ if(weight > totalWeight)
+ {
+ if (totalWeight == 0.0)
+ {
+ weights[start + span - 1] += weight;
+ }
+ else
+ {
+ double diff = weight - totalWeight ;
+ double remaining = diff;
+
+ for(int k = start; k < start + span; k++)
+ {
+ double extraWeight = diff * weights[k] / totalWeight;
+ weights[k] += extraWeight;
+ remaining -= extraWeight;
+ }
+
+ if (remaining > 0.0 && weights[start + span - 1] != 0.0)
+ {
+ weights[start + span - 1] += remaining;
+ }
+ }
+ }
+ }
+
+ /**
+ * Helper method used by GetLayoutInfo to distribute extra space
+ * based on weight distribution.
+ *
+ * @param sizes Sizes of rows/columns.
+ * @param weights Weights of rows/columns.
+ * @param range Dimension of container.
+ */
+ private void calcCellSizes (int[] sizes, double[] weights, int range)
+ {
+ int totalSize = sumIntArray (sizes);
+ double totalWeight = sumDoubleArray (weights);
+
+ int diff = range - totalSize;
+
+ if (diff == 0)
+ return;
+
+ for (int i = 0; i < sizes.length; i++)
+ {
+ int newsize = (int) (sizes[i] + (((double) diff) * weights [i] / totalWeight ));
+
+ if (newsize > 0)
+ sizes[i] = newsize;
+ }
+ }
+
+ private void dumpLayoutInfo (GridBagLayoutInfo info)
+ {
+ System.out.println ("GridBagLayoutInfo:");
+ System.out.println ("cols: " + info.cols + ", rows: " + info.rows);
+ System.out.print ("colWidths: ");
+ dumpArray(info.colWidths);
+ System.out.print ("rowHeights: ");
+ dumpArray(info.rowHeights);
+ System.out.print ("colWeights: ");
+ dumpArray(info.colWeights);
+ System.out.print ("rowWeights: ");
+ dumpArray(info.rowWeights);
+ }
+
+ private void dumpArray(int[] array)
+ {
+ String sep = "";
+ for(int i = 0; i < array.length; i++)
+ {
+ System.out.print(sep);
+ System.out.print(array[i]);
+ sep = ", ";
+ }
+ System.out.println();
+ }
+
+ private void dumpArray(double[] array)
+ {
+ String sep = "";
+ for(int i = 0; i < array.length; i++)
+ {
+ System.out.print(sep);
+ System.out.print(array[i]);
+ sep = ", ";
+ }
+ System.out.println();
+ }
+
+ /**
+ * @since 1.4
+ */
+ protected void arrangeGrid (Container parent)
+ {
+ ArrangeGrid (parent);
+ }
+
+ /**
+ * @since 1.4
+ */
+ protected GridBagLayoutInfo getLayoutInfo (Container parent, int sizeflag)
+ {
+ return GetLayoutInfo (parent, sizeflag);
+ }
+
+ /**
+ * Move and resize a rectangle according to a set of grid bag
+ * constraints. The x, y, width and height fields of the
+ * rectangle argument are adjusted to the new values.
+ *
+ * @param constraints position and size constraints
+ * @param r rectangle to be moved and resized
+ *
+ * @since 1.4
+ */
+ protected void adjustForGravity (GridBagConstraints constraints,
+ Rectangle r)
+ {
+ AdjustForGravity (constraints, r);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayoutInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayoutInfo.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayoutInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridBagLayoutInfo.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* GridBagLayoutInfo -
+ Copyright (C) 2003, 2005 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 java.io.Serializable;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+class GridBagLayoutInfo implements Serializable
+{
+ private static final long serialVersionUID = -4899416460737170217L;
+
+ int pos_x;
+ int pos_y;
+ int cols;
+ int rows;
+ int colWidths[];
+ int rowHeights[];
+ double colWeights[];
+ double rowWeights[];
+
+ GridBagLayoutInfo (int cols, int rows)
+ {
+ this.pos_x = 0;
+ this.pos_y = 0;
+ this.cols = cols;
+ this.rows = rows;
+ this.colWidths = new int [cols];
+ this.rowHeights = new int [rows];
+ this.colWeights = new double [cols];
+ this.rowWeights = new double [rows];
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridLayout.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridLayout.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridLayout.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/GridLayout.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,354 @@
+/* GridLayout.java -- Grid-based layout engine
+ Copyright (C) 1999, 2000, 2002, 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.io.Serializable;
+
+/** This class implements a grid-based layout scheme. Components are
+ * all given the same size and are laid out from left to right and top
+ * to bottom. A GridLayout is configured with a number of rows and a
+ * number of columns. If both are specified, then the number of
+ * columns is ignored and is derived from the number of rows and the
+ * total number of components. If either is zero then that dimension
+ * is computed based on the actual size of the container. An
+ * exception is thrown if an attempt is made to set both the number of
+ * rows and the number of columns to 0. This class also supports
+ * horizontal and vertical gaps; these are used as spacing between
+ * cells.
+ *
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class GridLayout implements LayoutManager, Serializable
+{
+ static final long serialVersionUID = -7411804673224730901L;
+
+ /** Add a new component to the layout. This particular implementation
+ * does nothing.
+ * @param name The name of the component to add.
+ * @param comp The component to add.
+ */
+ public void addLayoutComponent (String name, Component comp)
+ {
+ // Nothing.
+ }
+
+ /** Return the number of columns in this layout. */
+ public int getColumns ()
+ {
+ return cols;
+ }
+
+ /** Return the horizontal gap. */
+ public int getHgap ()
+ {
+ return hgap;
+ }
+
+ /** Return the number of rows in this layout. */
+ public int getRows ()
+ {
+ return rows;
+ }
+
+ /** Return the vertical gap. */
+ public int getVgap ()
+ {
+ return vgap;
+ }
+
+ /** Create a new <code>GridLayout</code> with one row and any number
+ * of columns. Both gaps are set to 0.
+ */
+ public GridLayout ()
+ {
+ this (1, 0, 0, 0);
+ }
+
+ /** Create a new <code>GridLayout</code> with the specified number
+ * of rows and columns. Both gaps are set to 0. Note that the row
+ * and column settings cannot both be zero. If both the row and
+ * column values are non-zero, the rows value takes precedence.
+ * @param rows Number of rows
+ * @param cols Number of columns
+ * @exception IllegalArgumentException If rows and columns are both
+ * 0, or if either are negative
+ */
+ public GridLayout (int rows, int cols)
+ {
+ this (rows, cols, 0, 0);
+ }
+
+ /** Create a new GridLayout with the specified number of rows and
+ * columns and the specified gaps.
+ * Note that the row and column settings cannot both be
+ * zero. If both the row and column values are non-zero, the rows value
+ * takes precedence.
+ * @param rows Number of rows
+ * @param cols Number of columns
+ * @param hgap The horizontal gap
+ * @param vgap The vertical gap
+ * @exception IllegalArgumentException If rows and columns are both
+ * 0, if either are negative, or if either gap is negative
+ */
+ public GridLayout (int rows, int cols, int hgap, int vgap)
+ {
+ if (rows < 0)
+ throw new IllegalArgumentException ("number of rows cannot be negative");
+ if (cols < 0)
+ throw new IllegalArgumentException ("number of columns cannot be negative");
+ if (rows == 0 && cols == 0)
+ throw new IllegalArgumentException ("both rows and columns cannot be 0");
+ if (hgap < 0)
+ throw new IllegalArgumentException ("horizontal gap must be nonnegative");
+ if (vgap < 0)
+ throw new IllegalArgumentException ("vertical gap must be nonnegative");
+ this.rows = rows;
+ this.cols = cols;
+ this.hgap = hgap;
+ this.vgap = vgap;
+ }
+
+ /** Lay out the container's components based on current settings.
+ * The free space in the container is divided evenly into the specified
+ * number of rows and columns in this object.
+ * @param parent The container to lay out
+ */
+ public void layoutContainer (Container parent)
+ {
+ synchronized (parent.getTreeLock ())
+ {
+ int num = parent.ncomponents;
+
+ // There's no point, and handling this would mean adding special
+ // cases.
+ if (num == 0)
+ return;
+
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+
+ int real_rows = rows;
+ int real_cols = cols;
+ if (real_rows == 0)
+ real_rows = (num + real_cols - 1) / real_cols;
+ else
+ real_cols = (num + real_rows - 1) / real_rows;
+
+ // We might have less than a single row. In this case we expand
+ // to fill.
+ if (num < real_cols)
+ real_cols = num;
+
+ Dimension d = parent.getSize ();
+ Insets ins = parent.getInsets ();
+
+ // Compute width and height of each cell in the grid.
+ int tw = d.width - ins.left - ins.right;
+ tw = (tw - (real_cols - 1) * hgap) / real_cols;
+ int th = d.height - ins.top - ins.bottom;
+ th = (th - (real_rows - 1) * vgap) / real_rows;
+
+ // If the cells are too small, still try to do something.
+ if (tw < 0)
+ tw = 1;
+ if (th < 0)
+ th = 1;
+
+ int x = ins.left;
+ int y = ins.top;
+ int i = 0;
+ int recount = 0;
+
+ while (i < num)
+ {
+ comps[i].setBounds (x, y, tw, th);
+
+ ++i;
+ ++recount;
+ if (recount == real_cols)
+ {
+ recount = 0;
+ y += vgap + th;
+ x = ins.left;
+ }
+ else
+ x += hgap + tw;
+ }
+ }
+ }
+
+ /** Get the minimum layout size of the container.
+ * @param cont The parent container
+ */
+ public Dimension minimumLayoutSize (Container cont)
+ {
+ return getSize (cont, true);
+ }
+
+ /** Get the preferred layout size of the container.
+ * @param cont The parent container
+ */
+ public Dimension preferredLayoutSize (Container cont)
+ {
+ return getSize (cont, false);
+ }
+
+ /** Remove the indicated component from this layout manager.
+ * This particular implementation does nothing.
+ * @param comp The component to remove
+ */
+ public void removeLayoutComponent (Component comp)
+ {
+ // Nothing.
+ }
+
+ /** Set the number of columns.
+ * @param newCols
+ * @exception IllegalArgumentException If the number of columns is
+ * negative, or if the number of columns is zero and the number
+ * of rows is already 0.
+ */
+ public void setColumns (int newCols)
+ {
+ if (newCols < 0)
+ throw new IllegalArgumentException ("number of columns cannot be negative");
+ if (newCols == 0 && rows == 0)
+ throw new IllegalArgumentException ("number of rows is already 0");
+ this.cols = newCols;
+ }
+
+ /** Set the horizontal gap. An Exception is not thrown if hgap < 0.
+ * @param hgap The horizontal gap
+ */
+ public void setHgap (int hgap)
+ {
+ this.hgap = hgap;
+ }
+
+ /** Set the number of rows
+ * @param newRows
+ * @exception IllegalArgumentException If the number of rows is
+ * negative, or if the number of rows is zero and the number
+ * of columns is already 0.
+ */
+ public void setRows (int newRows)
+ {
+ if (newRows < 0)
+ throw new IllegalArgumentException ("number of rows cannot be negative");
+ if (newRows == 0 && cols == 0)
+ throw new IllegalArgumentException ("number of columns is already 0");
+ this.rows = newRows;
+ }
+
+ /** Set the vertical gap. An Exception is not thrown if vgap < 0.
+ * @param vgap The vertical gap
+ */
+ public void setVgap (int vgap)
+ {
+ this.vgap = vgap;
+ }
+
+ /** Return String description of this object. */
+ public String toString ()
+ {
+ return (getClass ().getName () + "["
+ + ",hgap=" + hgap + ",vgap=" + vgap
+ + ",rows=" + rows + ",cols=" + cols
+ + "]");
+ }
+
+ // This method is used to compute the various sizes.
+ private Dimension getSize (Container parent, boolean is_min)
+ {
+ synchronized (parent.getTreeLock ())
+ {
+ int w = 0, h = 0, num = parent.ncomponents;
+ // This is more efficient than calling getComponents().
+ Component[] comps = parent.component;
+
+ for (int i = 0; i < num; ++i)
+ {
+ Dimension d;
+
+ if (is_min)
+ d = comps[i].getMinimumSize ();
+ else
+ d = comps[i].getPreferredSize ();
+
+ w = Math.max (d.width, w);
+ h = Math.max (d.height, h);
+ }
+
+ int real_rows = rows;
+ int real_cols = cols;
+ if (real_rows == 0)
+ real_rows = (num + real_cols - 1) / real_cols;
+ else
+ real_cols = (num + real_rows - 1) / real_rows;
+
+ Insets ins = parent.getInsets ();
+ // We subtract out an extra gap here because the gaps are only
+ // between cells.
+ w = ins.left + ins.right + real_cols * (w + hgap) - hgap;
+ h = ins.top + ins.bottom + real_rows * (h + vgap) - vgap;
+ return new Dimension (w, h);
+ }
+ }
+
+ /**
+ * @serial The number of columns in the grid.
+ */
+ private int cols;
+
+ /**
+ * @serial The number of rows in the grid.
+ */
+ private int rows;
+
+ /**
+ * @serial The horizontal gap between columns
+ */
+ private int hgap;
+
+ /**
+ * @serial The vertical gap between rows
+ */
+ private int vgap;
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/HeadlessException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/HeadlessException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/HeadlessException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/HeadlessException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,72 @@
+/* HeadlessException.java -- operation not possible in headless environment
+ Copyright (C) 2002, 2005 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;
+
+/**
+ * This exception is thrown when code dependent on a keyboard, mouse, or
+ * display is executed in a headless environment.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public class HeadlessException extends UnsupportedOperationException
+{
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = 167183644944358563L;
+
+ /**
+ * Create a new instance with no detailed error message.
+ */
+ public HeadlessException()
+ {
+ }
+
+ /**
+ * Create a new instance with the specified detailed error message.
+ *
+ * @param message the detailed error message
+ */
+ public HeadlessException(String message)
+ {
+ super(message);
+ }
+} // class HeadlessException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/IllegalComponentStateException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/IllegalComponentStateException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/IllegalComponentStateException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/IllegalComponentStateException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* IllegalComponentStateException.java -- bad component state
+ Copyright (C) 1999, 2002, 2005 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;
+
+/**
+ * This exception is thrown when the requested operation failed because
+ * a component was not in the proper state.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @status updated to 1.4
+ */
+public class IllegalComponentStateException extends IllegalStateException
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -1889339587208144238L;
+
+ /**
+ * Create a new instance with no detailed error message.
+ */
+ public IllegalComponentStateException()
+ {
+ }
+
+ /**
+ * Create a new instance with the specified detailed error message.
+ *
+ * @param message the detailed error message
+ */
+ public IllegalComponentStateException(String message)
+ {
+ super(message);
+ }
+} // class IllegalComponentStateException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Image.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Image.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Image.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Image.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,242 @@
+/* Image.java -- superclass for images
+ Copyright (C) 1999, 2002, 2004, 2005, 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 java.awt.image.AreaAveragingScaleFilter;
+import java.awt.image.FilteredImageSource;
+import java.awt.image.ImageFilter;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.ReplicateScaleFilter;
+
+/**
+ * This is the abstract superclass of all image objects in Java.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.5
+ */
+public abstract class Image
+{
+ /**
+ * This variable is returned whenever a property that is not defined
+ * is requested.
+ */
+ // For debug purposes, this might as well be a unique string.
+ public static final Object UndefinedProperty
+ = new String("undefined property");
+
+ /**
+ * Constant indicating that the default scaling algorithm should be used.
+ *
+ * @since 1.1
+ */
+ public static final int SCALE_DEFAULT = 1;
+
+ /**
+ * Constant indicating that a fast scaling algorithm should be used.
+ *
+ * @since 1.1
+ */
+ public static final int SCALE_FAST = 2;
+
+ /**
+ * Constant indicating that a smooth scaling algorithm should be used.
+ *
+ * @since 1.1
+ */
+ public static final int SCALE_SMOOTH = 4;
+
+ /**
+ * Constant indicating that the <code>ReplicateScaleFilter</code> class
+ * algorithm should be used for scaling.
+ *
+ * @see ReplicateScaleFilter
+ * @since 1.1
+ */
+ public static final int SCALE_REPLICATE = 8;
+
+ /**
+ * Constant indicating that the area averaging scaling algorithm should be
+ * used.
+ *
+ * @see java.awt.image.AreaAveragingScaleFilter
+ * @since 1.1
+ */
+ public static final int SCALE_AREA_AVERAGING = 16;
+
+ /**
+ * The acceleration priority of the image
+ * @since 1.5
+ */
+ protected float accelerationPriority;
+
+ /**
+ * A default constructor for subclasses.
+ */
+ public Image()
+ {
+ }
+
+ /**
+ * Returns the width of the image, or -1 if it is unknown. If the
+ * image width is unknown, the observer object will be notified when
+ * the value is known.
+ *
+ * @param observer the image observer for this object
+ * @return the width in pixels
+ * @see #getHeight(ImageObserver)
+ */
+ public abstract int getWidth(ImageObserver observer);
+
+ /**
+ * Returns the height of the image, or -1 if it is unknown. If the
+ * image height is unknown, the observer object will be notified when
+ * the value is known.
+ *
+ * @param observer the image observer for this object
+ * @return the height in pixels
+ * @see #getWidth(ImageObserver)
+ */
+ public abstract int getHeight(ImageObserver observer);
+
+ /**
+ * Returns the image producer object for this object. The producer is the
+ * object which generates pixels for this image.
+ *
+ * @return the image producer for this object
+ */
+ public abstract ImageProducer getSource();
+
+ /**
+ * Returns a graphics context object for drawing an off-screen object.
+ * This method is only valid for off-screen objects.
+ *
+ * @return a graphics context object for an off-screen object
+ */
+ public abstract Graphics getGraphics();
+
+ /**
+ * This method requests a named property for an object. The value of the
+ * property is returned. The value <code>UndefinedProperty</code> is
+ * returned if there is no property with the specified name. The value
+ * <code>null</code> is returned if the properties for the object are
+ * not yet known. In this case, the specified image observer is notified
+ * when the properties are known.
+ *
+ * @param name the requested property name
+ * @param observer the image observer for this object
+ * @return the named property, if available
+ * @see #UndefinedProperty
+ */
+ public abstract Object getProperty(String name, ImageObserver observer);
+
+ /**
+ * Scales the image to the requested dimension. A new Image with asynchronous
+ * loading will be produced according to the hints of the algorithm
+ * requested. If either the width or height is non-positive, it is adjusted
+ * to preserve the original aspect ratio.
+ * If an illegal value of <code>flags</code> is passed,
+ * the default algorithm is used.
+ *
+ * @param width the width of the scaled image
+ * @param height the height of the scaled image
+ * @param flags a value indicating the algorithm to use
+ * @return the scaled <code>Image</code> object
+ * @see #SCALE_DEFAULT
+ * @see #SCALE_FAST
+ * @see #SCALE_SMOOTH
+ * @see #SCALE_REPLICATE
+ * @see #SCALE_AREA_AVERAGING
+ * @since 1.1
+ */
+ public Image getScaledInstance(int width, int height, int flags)
+ {
+ ImageFilter filter;
+ switch (flags)
+ {
+ case SCALE_AREA_AVERAGING:
+ case SCALE_SMOOTH:
+ filter = new AreaAveragingScaleFilter(width, height);
+ break;
+ case SCALE_DEFAULT:
+ case SCALE_FAST:
+ case SCALE_REPLICATE:
+ default:
+ filter = new ReplicateScaleFilter(width, height);
+ }
+
+ ImageProducer producer = new FilteredImageSource(getSource(), filter);
+ return Toolkit.getDefaultToolkit().createImage(producer);
+ }
+
+ /**
+ * Flushes (that is, destroys) any resources used for this image. This
+ * includes the actual image data.
+ */
+ public abstract void flush();
+
+ /**
+ * Sets the acceleration priority of the image.
+ * This is a value from 0 (lowest) to 1 (highest), which may
+ * be used as a hint for image acceleration.
+ * E.g. higher priority images may be stored in video memory.
+ * @param priority - the priority
+ * @throws IllegalArgumentException if priority is not >= 0 and <= 1.
+ *
+ * @since 1.5
+ */
+ public void setAccelerationPriority(float priority)
+ {
+ if( priority < 0f || priority > 1f)
+ throw new IllegalArgumentException("Invalid priority value.");
+ accelerationPriority = priority;
+ }
+
+ /**
+ * Returns the acceleration priority of the image.
+ *
+ * @see #setAccelerationPriority(float)
+ * @since 1.5
+ */
+ public float getAccelerationPriority()
+ {
+ return accelerationPriority;
+ }
+} // class Image
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ImageCapabilities.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ImageCapabilities.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ImageCapabilities.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ImageCapabilities.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,107 @@
+/* ImageCapabilities.java -- the capabilities of an image buffer
+ Copyright (C) 2002, 2005 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;
+
+/**
+ * This class represents the capabilities of an image buffer. An
+ * image buffer may be backed by accelerated graphics resources.
+ * Those resources may or may not be volatile. This class is used to
+ * describe these image buffer characteristics.
+ */
+public class ImageCapabilities implements Cloneable
+{
+ /**
+ * Whether or not this the image buffer uses accelerated graphics
+ * resources.
+ */
+ private final boolean accelerated;
+
+ /**
+ * Create a new image capability descriptor.
+ *
+ * @param accelerated true if the image buffer uses accelerated
+ * graphics resources
+ */
+ public ImageCapabilities(boolean accelerated)
+ {
+ this.accelerated = accelerated;
+ }
+
+ /**
+ * Returns whether or not the image buffer uses accelerated graphics
+ * resources.
+ *
+ * @return true if the image buffer uses accelerated graphics
+ * resources; false otherwise
+ */
+ public boolean isAccelerated()
+ {
+ return accelerated;
+ }
+
+ /**
+ * Returns whether or not the image buffer's resources are volatile,
+ * meaning that they can be reclaimed by the graphics system at any
+ * time.
+ *
+ * @return true if the image buffer's resources are volatile; false
+ * otherwise
+ */
+ public boolean isTrueVolatile()
+ {
+ return true;
+ }
+
+ /**
+ * Clone this image capability descriptor.
+ *
+ * @return a clone of this image capability descriptor
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw (Error) new InternalError().initCause(e);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Insets.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Insets.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Insets.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Insets.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,177 @@
+/* Insets.java -- information about a container border
+ Copyright (C) 1999, 2000, 2002, 2005, 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 java.io.Serializable;
+
+/**
+ * This class represents the "margin" or space around a container.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status
+ */
+public class Insets implements Cloneable, Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -2272572637695466749L;
+
+ /**
+ * The gap from the top.
+ *
+ * @serial the top inset
+ */
+ public int top;
+
+ /**
+ * The gap from the left.
+ *
+ * @serial the left inset
+ */
+ public int left;
+
+ /**
+ * The gap from the bottom.
+ *
+ * @serial the bottom inset
+ */
+ public int bottom;
+
+ /**
+ * The gap from the right.
+ *
+ * @serial the right inset
+ */
+ public int right;
+
+ /**
+ * Initializes a new instance of <code>Inset</code> with the specified
+ * inset values.
+ *
+ * @param top the top inset
+ * @param left the left inset
+ * @param bottom the bottom inset
+ * @param right the right inset
+ */
+ public Insets(int top, int left, int bottom, int right)
+ {
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ 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)
+ {
+ if (! (obj instanceof Insets))
+ return false;
+ Insets i = (Insets) obj;
+ return top == i.top && bottom == i.bottom
+ && left == i.left && right == i.right;
+ }
+
+ /**
+ * Returns a hashcode for this instance. The formula is unspecified, but
+ * appears to be <code>XXX what is it? </code>.
+ *
+ * @return the hashcode
+ */
+ public int hashCode()
+ {
+ // This can't be right...
+ return top + bottom + left + right;
+ }
+
+ /**
+ * Returns a string representation of this object, which will be non-null.
+ *
+ * @return a string representation of this object
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[top=" + top + ",left=" + left
+ + ",bottom=" + bottom + ",right=" + right + ']';
+ }
+
+ /**
+ * Returns a copy of this object.
+ *
+ * @return a copy of this object
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw (Error) new InternalError().initCause(e); // Impossible
+ }
+ }
+} // class Insets
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ItemSelectable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ItemSelectable.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ItemSelectable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ItemSelectable.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* ItemSelectable.java -- items that can be selected
+ Copyright (C) 1999, 2002, 2005 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 java.awt.event.ItemListener;
+
+/**
+ * This interface is for objects that can have one or more items selected.
+ * For example, radio buttons.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface ItemSelectable
+{
+ /**
+ * Returns the list of objects that are selected in this component.
+ *
+ * @return the list of selected objects, or null
+ */
+ Object[] getSelectedObjects();
+
+ /**
+ * Adds an item listener to this object. It will receive selection events
+ * for this object by the user (but not programatically). If listener is
+ * null, it is ignored.
+ *
+ * @param listener the item listener to add
+ */
+ void addItemListener(ItemListener listener);
+
+ /**
+ * Removes an item listener from this object.
+ *
+ * @param listener the item listener to remove
+ */
+ void removeItemListener(ItemListener listener);
+} // interface ItemSelectable
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/JobAttributes.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/JobAttributes.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/JobAttributes.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/JobAttributes.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,500 @@
+/* JobAttributes.java --
+ Copyright (C) 2002, 2005 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;
+
+/**
+ * Needs documentation...
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4, lacks documentation
+ */
+public final class JobAttributes implements Cloneable
+{
+ public static final class DefaultSelectionType extends AttributeValue
+ {
+ private static final String[] NAMES = { "all", "range", "selection" };
+ public static final DefaultSelectionType ALL
+ = new DefaultSelectionType(0);
+ public static final DefaultSelectionType RANGE
+ = new DefaultSelectionType(1);
+ public static final DefaultSelectionType SELECTION
+ = new DefaultSelectionType(2);
+ private DefaultSelectionType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class DefaultSelectionType
+
+ public static final class DestinationType extends AttributeValue
+ {
+ private static final String[] NAMES = { "file", "printer" };
+ public static final DestinationType FILE = new DestinationType(0);
+ public static final DestinationType PRINTER = new DestinationType(1);
+ private DestinationType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class DestinationType
+
+ public static final class DialogType extends AttributeValue
+ {
+ private static final String[] NAMES = { "common", "native", "none" };
+ public static final DialogType COMMON = new DialogType(0);
+ public static final DialogType NATIVE = new DialogType(1);
+ public static final DialogType NONE = new DialogType(2);
+ private DialogType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class DialogType
+
+ public static final class MultipleDocumentHandlingType
+ extends AttributeValue
+ {
+ private static final String[] NAMES = {
+ "separate-documents-collated-copies",
+ "separate-documents-uncollated-copies"
+ };
+ public static final MultipleDocumentHandlingType
+ SEPARATE_DOCUMENTS_COLLATED_COPIES
+ = new MultipleDocumentHandlingType(0);
+ public static final MultipleDocumentHandlingType
+ SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
+ = new MultipleDocumentHandlingType(1);
+ private MultipleDocumentHandlingType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class MultipleDocumentHandlingType
+
+ public static final class SidesType extends AttributeValue
+ {
+ private static final String[] NAMES
+ = { "one-sided", "two-sided-long-edge", "two-sided-short-edge" };
+ public static final SidesType ONE_SIDED = new SidesType(0);
+ public static final SidesType TWO_SIDED_LONG_EDGE = new SidesType(1);
+ public static final SidesType TWO_SIDED_SHORT_EDGE = new SidesType(2);
+ private SidesType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class SidesType
+
+ private int copies;
+ private DefaultSelectionType selection;
+ private DestinationType destination;
+ private DialogType dialog;
+ private String filename;
+ private int maxPage;
+ private int minPage;
+ private MultipleDocumentHandlingType multiple;
+ private int[][] pageRanges; // null for default value
+ private int fromPage; // 0 for default value
+ private int toPage; // 0 for default value
+ private String printer;
+ private SidesType sides;
+
+ public JobAttributes()
+ {
+ copies = 1;
+ selection = DefaultSelectionType.ALL;
+ destination = DestinationType.PRINTER;
+ dialog = DialogType.NATIVE;
+ maxPage = Integer.MAX_VALUE;
+ minPage = 1;
+ multiple
+ = MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES;
+ sides = SidesType.ONE_SIDED;
+ }
+
+ public JobAttributes(JobAttributes attr)
+ {
+ set(attr);
+ }
+
+ public JobAttributes(int copies, DefaultSelectionType selection,
+ DestinationType destination, DialogType dialog,
+ String filename, int max, int min,
+ MultipleDocumentHandlingType multiple,
+ int[][] pageRanges, String printer, SidesType sides)
+ {
+ if (copies <= 0 || selection == null || destination == null
+ || dialog == null || max < min || min <= 0 || multiple == null
+ || sides == null)
+ throw new IllegalArgumentException();
+ this.copies = copies;
+ this.selection = selection;
+ this.destination = destination;
+ this.dialog = dialog;
+ this.filename = filename;
+ maxPage = max;
+ minPage = min;
+ this.multiple = multiple;
+ setPageRanges(pageRanges);
+ this.printer = printer;
+ this.sides = sides;
+ }
+
+ public Object clone()
+ {
+ return new JobAttributes(this);
+ }
+
+ public void set(JobAttributes attr)
+ {
+ copies = attr.copies;
+ selection = attr.selection;
+ destination = attr.destination;
+ dialog = attr.dialog;
+ filename = attr.filename;
+ maxPage = attr.maxPage;
+ minPage = attr.minPage;
+ multiple = attr.multiple;
+ pageRanges = (int[][]) attr.pageRanges.clone();
+ printer = attr.printer;
+ sides = attr.sides;
+ fromPage = attr.fromPage;
+ toPage = attr.toPage;
+ }
+
+ public int getCopies()
+ {
+ return copies;
+ }
+
+ public void setCopies(int copies)
+ {
+ if (copies <= 0)
+ throw new IllegalArgumentException();
+ this.copies = copies;
+ }
+
+ public void setCopiesToDefault()
+ {
+ copies = 1;
+ }
+
+ public DefaultSelectionType getDefaultSelection()
+ {
+ return selection;
+ }
+
+ public void setDefaultSelection(DefaultSelectionType selection)
+ {
+ if (selection == null)
+ throw new IllegalArgumentException();
+ this.selection = selection;
+ }
+
+ public DestinationType getDestination()
+ {
+ return destination;
+ }
+
+ public void setDestination(DestinationType destination)
+ {
+ if (destination == null)
+ throw new IllegalArgumentException();
+ this.destination = destination;
+ }
+
+ public DialogType getDialog()
+ {
+ return dialog;
+ }
+
+ public void setDialog(DialogType dialog)
+ {
+ if (dialog == null)
+ throw new IllegalArgumentException();
+ this.dialog = dialog;
+ }
+
+ public String getFileName()
+ {
+ return filename;
+ }
+
+ public void setFileName(String filename)
+ {
+ this.filename = filename;
+ }
+
+ public int getFromPage()
+ {
+ return fromPage != 0 ? fromPage
+ : pageRanges != null ? pageRanges[0][0]
+ : toPage != 0 ? toPage : minPage;
+ }
+
+ public void setFromPage(int fromPage)
+ {
+ if (fromPage < minPage || (fromPage > toPage && toPage != 0)
+ || fromPage > maxPage)
+ throw new IllegalArgumentException();
+ if (pageRanges == null)
+ this.fromPage = fromPage;
+ }
+
+ public int getMaxPage()
+ {
+ return maxPage;
+ }
+
+ public void setMaxPage(int maxPage)
+ {
+ if (maxPage < minPage)
+ throw new IllegalArgumentException();
+ this.maxPage = maxPage;
+ if (maxPage < fromPage)
+ fromPage = maxPage;
+ if (maxPage < toPage)
+ toPage = maxPage;
+ if (pageRanges != null)
+ {
+ int i = pageRanges.length - 1;
+ while (i >= 0 && maxPage < pageRanges[i][1])
+ i--;
+ if (maxPage >= pageRanges[++i][0])
+ pageRanges[i++][1] = maxPage;
+ if (i == 0)
+ pageRanges = null;
+ else if (i < pageRanges.length)
+ {
+ int[][] tmp = new int[i][];
+ System.arraycopy(pageRanges, 0, tmp, 0, i);
+ pageRanges = tmp;
+ }
+ }
+ }
+
+ public int getMinPage()
+ {
+ return minPage;
+ }
+
+ public void setMinPage(int minPage)
+ {
+ if (minPage <= 0 || minPage > maxPage)
+ throw new IllegalArgumentException();
+ this.minPage = minPage;
+ if (minPage > toPage)
+ toPage = minPage;
+ if (minPage > fromPage)
+ fromPage = minPage;
+ if (pageRanges != null)
+ {
+ int size = pageRanges.length;
+ int i = 0;
+ while (i < size && minPage > pageRanges[i][0])
+ i++;
+ if (minPage <= pageRanges[i - 1][1])
+ pageRanges[--i][0] = minPage;
+ if (i == size)
+ pageRanges = null;
+ else if (i > 0)
+ {
+ int[][] tmp = new int[size - i][];
+ System.arraycopy(pageRanges, i, tmp, 0, size - i);
+ pageRanges = tmp;
+ }
+ }
+ }
+
+ public MultipleDocumentHandlingType getMultipleDocumentHandling()
+ {
+ return multiple;
+ }
+
+ public void setMultipleDocumentHandling
+ (MultipleDocumentHandlingType multiple)
+ {
+ if (multiple == null)
+ throw new IllegalArgumentException();
+ this.multiple = multiple;
+ }
+
+ public void setMultipleDocumentHandlingToDefault()
+ {
+ multiple
+ = MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES;
+ }
+
+ public int[][] getPageRanges()
+ {
+ if (pageRanges == null)
+ return new int[][] { { getFromPage(), getToPage() } };
+ // Perform a deep clone, so user code cannot affect original arrays.
+ int i = pageRanges.length;
+ int[][] result = new int[i][];
+ while (--i >= 0)
+ result[i] = (int[]) pageRanges[i].clone();
+ return result;
+ }
+
+ public void setPageRanges(int[][] pageRanges)
+ {
+ int size = pageRanges == null ? 0 : pageRanges.length;
+ if (size == 0)
+ throw new IllegalArgumentException();
+ while (--size >= 0)
+ {
+ int[] range = pageRanges[size];
+ if (range == null || range.length != 2
+ || range[0] < minPage || range[1] < range[0] || range[1] > maxPage
+ || (size != 0 && range[0] <= pageRanges[size - 1][1]))
+ throw new IllegalArgumentException();
+ }
+ size = pageRanges.length;
+ if (fromPage > 0 && pageRanges[0][0] > fromPage)
+ fromPage = pageRanges[0][0];
+ if (toPage > 0 && pageRanges[size - 1][1] < toPage)
+ toPage = pageRanges[size - 1][1];
+ this.pageRanges = new int[size][];
+ while (--size >= 0)
+ this.pageRanges[size] = (int[]) pageRanges[size].clone();
+ }
+
+ public String getPrinter()
+ {
+ return printer;
+ }
+
+ public void setPrinter(String printer)
+ {
+ this.printer = printer;
+ }
+
+ public SidesType getSides()
+ {
+ return sides;
+ }
+
+ public void setSides(SidesType sides)
+ {
+ if (sides == null)
+ throw new IllegalArgumentException();
+ this.sides = sides;
+ }
+
+ public void setSidesToDefault()
+ {
+ sides = SidesType.ONE_SIDED;
+ }
+
+ public int getToPage()
+ {
+ return toPage != 0 ? toPage
+ : pageRanges != null ? pageRanges[pageRanges.length - 1][1]
+ : fromPage != 0 ? fromPage : maxPage;
+ }
+
+ public void setToPage(int toPage)
+ {
+ if (toPage < minPage || (fromPage > toPage && fromPage != 0)
+ || toPage > maxPage)
+ throw new IllegalArgumentException();
+ if (pageRanges == null)
+ this.toPage = toPage;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ return true;
+ if (! (o instanceof JobAttributes))
+ return false;
+ JobAttributes ja = (JobAttributes) o;
+ if (copies != ja.copies || selection != ja.selection
+ || destination != ja.destination || dialog != ja.dialog
+ || ! filename.equals(ja.filename) || maxPage != ja.maxPage
+ || minPage != ja.minPage || multiple != ja.multiple
+ || fromPage != ja.fromPage || toPage != ja.toPage
+ || ! printer.equals(ja.printer) || sides != ja.sides
+ || (pageRanges == null) != (ja.pageRanges == null))
+ return false;
+ if (pageRanges != ja.pageRanges)
+ for (int i = pageRanges.length; --i >= 0; )
+ if (pageRanges[i][0] != ja.pageRanges[i][0]
+ || pageRanges[i][1] != ja.pageRanges[i][1])
+ return false;
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int hash = (selection.value << 6) ^ (destination.value << 5)
+ ^ (dialog.value << 3) ^ (multiple.value << 2) ^ sides.value
+ ^ (filename == null ? 0 : filename.hashCode())
+ ^ (printer == null ? 0 : printer.hashCode());
+ // The effect of the above fields on the hashcode match the JDK. However,
+ // I am unable to reverse engineer the effect of the fields listed below,
+ // so I am using my own implementation. Note that this still satisfies
+ // the general contract of hashcode, it just doesn't match the JDK.
+ hash ^= (copies << 27) ^ (maxPage << 22) ^ (minPage << 17);
+ if (pageRanges == null)
+ hash ^= (getFromPage() << 13) ^ (getToPage() << 8);
+ else
+ for (int i = pageRanges.length; --i >= 0; )
+ hash ^= (pageRanges[i][0] << 13) ^ (pageRanges[i][1] << 8);
+ return hash;
+ }
+
+ public String toString()
+ {
+ StringBuffer s = new StringBuffer("copies=").append(copies)
+ .append(",defaultSelection=").append(selection).append(",destination=")
+ .append(destination).append(",dialog=").append(dialog)
+ .append(",fileName=").append(filename).append(",fromPage=")
+ .append(getFromPage()).append(",maxPage=").append(maxPage)
+ .append(",minPage=").append(minPage)
+ .append(",multiple-document-handling=").append(multiple)
+ .append(",page-ranges=[");
+ if (pageRanges == null)
+ s.append(minPage).append(':').append(minPage).append(']');
+ else
+ for (int i = 0; i < pageRanges.length; i++)
+ s.append(pageRanges[i][0]).append(':').append(pageRanges[i][1])
+ .append(',');
+ s.setLength(s.length() - 1);
+ return s.append("],printer=").append(printer).append(",sides=")
+ .append(sides).append(",toPage=").append(getToPage()).toString();
+ }
+} // class JobAttributes
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventDispatcher.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventDispatcher.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventDispatcher.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventDispatcher.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,82 @@
+/* KeyEventDispatcher.java -- dispatches key events
+ Copyright (C) 2002, 2005 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 java.awt.event.KeyEvent;
+
+/**
+ * An instance of this interface coordinates with a KeyboardFocusManager to
+ * target and dispatch all key events. This allows retargeting, consuming,
+ * changing, or otherwise manipulating the key event before sending it on to
+ * a target.
+ *
+ * <p>By default, the KeyboardFocusManager is the sink for all key events not
+ * dispatched by other dispatchers. Therefore, it is unnecessary for the user
+ * to register the focus manager as a dispatcher.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see KeyboardFocusManager#addKeyEventDispatcher(KeyEventDispatcher)
+ * @see KeyboardFocusManager#removeKeyEventDispatcher(KeyEventDispatcher)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public interface KeyEventDispatcher
+{
+ /**
+ * Called by the KeyboardFocusManager to request that a key event be
+ * dispatched. The dispatcher is free to retarget the event, consume it,
+ * dispatch it, or make other changes. This is usually done to allow
+ * delivery of key events to objects other than the window in focus, such
+ * as for navigating non-focusable components. If this dispatcher chooses
+ * to dispatch the event itself, it should call <code>redispatchEvent</code>
+ * to avoid infinite recursion.
+ *
+ * <p>If the return value is false, the KeyEvent is passed to the next
+ * dispatcher in the chain, ending with the KeyboardFocusManager. If the
+ * return value is true, the event has been consumed (although it might
+ * have been ignored), and no further action will be taken on the event. Be
+ * sure to check whether the event was consumed before dispatching it
+ * further.
+ *
+ * @param e the key event
+ * @return true if the event has been consumed
+ * @see KeyboardFocusManager#redispatchEvent(Component, AWTEvent)
+ */
+ boolean dispatchKeyEvent(KeyEvent e);
+} // interface KeyEventDispatcher
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventPostProcessor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventPostProcessor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventPostProcessor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyEventPostProcessor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,81 @@
+/* KeyEventPostProcessor.java -- performs actions after a key event dispatch
+ Copyright (C) 2002, 2005 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 java.awt.event.KeyEvent;
+
+/**
+ * An instance of this interface coordinates with a KeyboardFocusManager to
+ * target and dispatch all key events that are otherwise unconsumed. This
+ * allows events which take place when nothing has focus to still operate,
+ * such as menu keyboard shortcuts.
+ *
+ * <p>By default, the KeyboardFocusManager is the sink for all key events not
+ * post-processed elsewhere. Therefore, it is unnecessary for the user
+ * to register the focus manager as a dispatcher.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see KeyboardFocusManager#addKeyEventPostProcessor(KeyEventPostProcessor)
+ * @see KeyboardFocusManager#removeKeyEventPostProcessor(KeyEventPostProcessor)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public interface KeyEventPostProcessor
+{
+ /**
+ * Called by the KeyboardFocusManager to request that a key event be
+ * post-processed. Typically, the event has already been dispatched and
+ * handled, unless no object has focus. Thus, this allows global event
+ * handling for things like menu shortcuts. If this post-processor chooses
+ * to dispatch the event, it should call <code>redispatchEvent</code>
+ * to avoid infinite recursion.
+ *
+ * <p>If the return value is false, the KeyEvent is passed to the next
+ * dispatcher in the chain, ending with the KeyboardFocusManager. If the
+ * return value is true, the event has been consumed (although it might
+ * have been ignored), and no further action will be taken on the event. Be
+ * sure to check whether the event was consumed before dispatching it
+ * further.
+ *
+ * @param e the key event
+ * @return true if the event has been consumed
+ * @see KeyboardFocusManager#redispatchEvent(Component, AWTEvent)
+ */
+ boolean postProcessKeyEvent(KeyEvent e);
+} // interface KeyEventPostProcessor
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyboardFocusManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyboardFocusManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyboardFocusManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/KeyboardFocusManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1477 @@
+/* KeyboardFocusManager.java -- manage component focusing via the keyboard
+ Copyright (C) 2002, 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.applet.Applet;
+import java.awt.FocusTraversalPolicy;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The <code>KeyboardFocusManager</code> handles the focusing of
+ * windows for receiving keyboard events. The manager handles
+ * the dispatch of all <code>FocusEvent</code>s and
+ * <code>KeyEvent</code>s, along with <code>WindowEvent</code>s
+ * relating to the focused window. Users can use the manager
+ * to ascertain the current focus owner and fire events.
+ * <br />
+ * <br />
+ * The focus owner is the <code>Component</code> that receives
+ * key events. The focus owner is either the currently focused
+ * window or a component within this window.
+ * <br />
+ * <br />
+ * The underlying native windowing system may denote the active
+ * window or its children with special decorations (e.g. a highlighted
+ * title bar). The active window is always either a <code>Frame</code>
+ * or <code>Dialog</code>, and is either the currently focused
+ * window or its owner.
+ * <br />
+ * <br />
+ * Applets may be partitioned into different applet contexts, according
+ * to their code base. In this case, each context has its own
+ * <code>KeyboardFocusManager</code>, as opposed to the global
+ * manager maintained by applets which share the same context.
+ * Each context is insulated from the others, and they don't interact.
+ * The resulting behaviour, as with context division, depends on the browser
+ * supporting the applets. Regardless, there can only ever be
+ * one focused window, one active window and one focus owner
+ * per <code>ClassLoader</code>.
+ * <br />
+ * <br />
+ * To support this separation of focus managers, the manager instances
+ * and the internal state information is grouped by the
+ * <code>ThreadGroup</code> to which it pertains. With respect to
+ * applets, each code base has its own <code>ThreadGroup</code>, so the
+ * isolation of each context is enforced within the manager.
+ * <br />
+ * <br />
+ * By default, the manager defines TAB and Ctrl+TAB as the
+ * forward focus traversal keys and Shift+TAB and Ctrl+Shift+TAB
+ * as the backward focus traversal keys. No up or down cycle
+ * traversal keys are defined by default. Traversal takes effect
+ * on the firing of a relevant <code>KEY_PRESSED</code> event.
+ * However, all other key events related to the use of the
+ * defined focus traversal key sequence are consumed and not
+ * dispatched.
+ * <br />
+ * <br />
+ * These default traversal keys come into effect on all windows
+ * for which no alternative set of keys is defined. This also
+ * applies recursively to any child components of such a window,
+ * which define no traversal keys of their own.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ * @since 1.4
+ */
+public abstract class KeyboardFocusManager
+ implements KeyEventDispatcher, KeyEventPostProcessor
+{
+ /** Identifies {@link AWTKeyStroke}s that move the focus forward in
+ the focus cycle. */
+ public static final int FORWARD_TRAVERSAL_KEYS = 0;
+
+ /** Identifies {@link AWTKeyStroke}s that move the focus backward in
+ the focus cycle. */
+ public static final int BACKWARD_TRAVERSAL_KEYS = 1;
+
+ /** Identifies {@link AWTKeyStroke}s that move the focus up to the
+ parent focus cycle root. */
+ public static final int UP_CYCLE_TRAVERSAL_KEYS = 2;
+
+ /** Identifies {@link AWTKeyStroke}s that move the focus down to the
+ child focus cycle root. */
+ public static final int DOWN_CYCLE_TRAVERSAL_KEYS = 3;
+
+ /** The set of {@link AWTKeyStroke}s that cause focus to be moved to
+ the next focusable Component in the focus cycle. */
+ private static final Set DEFAULT_FORWARD_KEYS;
+
+ /** The set of {@link AWTKeyStroke}s that cause focus to be moved to
+ the previous focusable Component in the focus cycle. */
+ private static final Set DEFAULT_BACKWARD_KEYS;
+
+ /** Populate the DEFAULT_FORWARD_KEYS and DEFAULT_BACKWARD_KEYS
+ {@link java.util.Set}s. */
+ static
+ {
+ Set s = new HashSet();
+ s.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
+ s.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,
+ KeyEvent.CTRL_DOWN_MASK));
+ DEFAULT_FORWARD_KEYS = Collections.unmodifiableSet(s);
+ s = new HashSet();
+ s.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,
+ KeyEvent.SHIFT_DOWN_MASK));
+ s.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB,
+ KeyEvent.SHIFT_DOWN_MASK
+ | KeyEvent.CTRL_DOWN_MASK));
+ DEFAULT_BACKWARD_KEYS = Collections.unmodifiableSet(s);
+ }
+
+ /** The global object {@link java.util.Map}s. */
+
+ /** For security reasons, {@link java.applet.Applet}s in different
+ codebases must be insulated from one another. Since {@link
+ KeyboardFocusManager}s have the ability to return {@link
+ Component}s from a given {@link java.applet.Applet}, each
+ codebase must have an independent {@link KeyboardFocusManager}.
+ Since each codebase has its own {@link ThreadGroup} in which its
+ {@link Applet}s run, it makes sense to partition {@link
+ KeyboardFocusManager}s according to {@link
+ java.lang.ThreadGroup}. Thus, currentKeyboardFocusManagers is a
+ {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}. */
+ private static Map currentKeyboardFocusManagers = new HashMap ();
+
+ /** {@link java.applet.Applet}s in one codebase must not be allowed
+ to access {@link Component}s in {@link java.applet.Applet}s in
+ other codebases. To enforce this restriction, we key the
+ following {@link java.util.Map}s on {@link java.lang.ThreadGroup}s (which
+ are per-codebase). For example, if {@link
+ java.lang.ThreadGroup} A calls {@link #setGlobalFocusOwner},
+ passing {@link Component} C, currentFocusOwners[A] is assigned
+ C, and all other currentFocusOwners values are nullified. Then
+ if {@link java.lang.ThreadGroup} A subsequently calls {@link
+ #getGlobalFocusOwner}, it will return currentFocusOwners[A],
+ that is, {@link Component} C. If another {@link
+ java.lang.ThreadGroup} K calls {@link #getGlobalFocusOwner}, it
+ will return currentFocusOwners[K], that is, null.
+
+ Since this is a static field, we ensure that there is only one
+ focused {@link Component} per class loader. */
+ private static Map currentFocusOwners = new HashMap ();
+
+ /** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
+ that stores the {@link Component} that owns the permanent
+ keyboard focus. @see currentFocusOwners */
+ private static Map currentPermanentFocusOwners = new HashMap ();
+
+ /** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
+ that stores the focused {@link Window}. @see
+ currentFocusOwners */
+ private static Map currentFocusedWindows = new HashMap ();
+
+ /** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
+ that stores the active {@link Window}. @see
+ currentFocusOwners */
+ private static Map currentActiveWindows = new HashMap ();
+
+ /** A {@link java.util.Map} keyed on {@link java.lang.ThreadGroup}s
+ that stores the focus cycle root {@link Container}. @see
+ currentFocusOwners */
+ private static Map currentFocusCycleRoots = new HashMap ();
+
+ /** The default {@link FocusTraversalPolicy} that focus-managing
+ {@link Container}s will use to define their initial focus
+ traversal policy. */
+ private FocusTraversalPolicy defaultPolicy;
+
+ /** An array that stores the {@link #FORWARD_TRAVERSAL_KEYS}, {@link
+ #BACKWARD_TRAVERSAL_KEYS}, {@link #UP_CYCLE_TRAVERSAL_KEYS} and
+ {@link #DOWN_CYCLE_TRAVERSAL_KEYS} {@link AWTKeyStroke}s {@link
+ java.util.Set}s. */
+ private Set[] defaultFocusKeys = new Set[]
+ {
+ DEFAULT_FORWARD_KEYS, DEFAULT_BACKWARD_KEYS,
+ Collections.EMPTY_SET, Collections.EMPTY_SET
+ };
+
+ /**
+ * A utility class to support the handling of events relating to property changes.
+ */
+ private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport (this);
+
+ /**
+ * A utility class to support the handling of events relating to vetoable changes.
+ */
+ private final VetoableChangeSupport vetoableChangeSupport = new VetoableChangeSupport (this);
+
+ /** A list of {@link KeyEventDispatcher}s that process {@link
+ KeyEvent}s before they are processed the default keyboard focus
+ manager. */
+ private final ArrayList keyEventDispatchers = new ArrayList();
+
+ /** A list of {@link KeyEventPostProcessor}s that process unconsumed
+ {@link KeyEvent}s. */
+ private final ArrayList keyEventPostProcessors = new ArrayList();
+
+ /**
+ * Construct a KeyboardFocusManager.
+ */
+ public KeyboardFocusManager ()
+ {
+ }
+
+ /**
+ * Retrieve the keyboard focus manager associated with the {@link
+ * java.lang.ThreadGroup} to which the calling thread belongs.
+ *
+ * @return the keyboard focus manager associated with the current
+ * thread group
+ */
+ public static KeyboardFocusManager getCurrentKeyboardFocusManager ()
+ {
+ ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
+
+ if (currentKeyboardFocusManagers.get (currentGroup) == null)
+ setCurrentKeyboardFocusManager (null);
+
+ return (KeyboardFocusManager) currentKeyboardFocusManagers.get (currentGroup);
+ }
+
+ /**
+ * Set the keyboard focus manager associated with the {@link
+ * java.lang.ThreadGroup} to which the calling thread belongs.
+ *
+ * @param m the keyboard focus manager for the current thread group
+ */
+ public static void setCurrentKeyboardFocusManager (KeyboardFocusManager m)
+ {
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkPermission (new AWTPermission ("replaceKeyboardFocusManager"));
+
+ ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
+ KeyboardFocusManager manager;
+
+ if (m == null)
+ manager = new DefaultKeyboardFocusManager();
+ else
+ manager = m;
+
+ currentKeyboardFocusManagers.put (currentGroup, manager);
+ }
+
+ /**
+ * Retrieve the {@link Component} that has the keyboard focus, or
+ * null if the focus owner was not set by a thread in the current
+ * {@link java.lang.ThreadGroup}.
+ *
+ * @return the keyboard focus owner or null
+ */
+ public Component getFocusOwner ()
+ {
+ return (Component) getObject (currentFocusOwners);
+ }
+
+ /**
+ * Retrieve the {@link Component} that has the keyboard focus,
+ * regardless of whether or not it was set by a thread in the
+ * current {@link java.lang.ThreadGroup}. If there is no temporary
+ * focus owner in effect then this method will return the same value
+ * as {@link #getGlobalPermanentFocusOwner}.
+ *
+ * @return the keyboard focus owner
+ * @throws SecurityException if this is not the keyboard focus
+ * manager associated with the current {@link java.lang.ThreadGroup}
+ */
+ protected Component getGlobalFocusOwner ()
+ {
+ return (Component) getGlobalObject(currentFocusOwners, true);
+ }
+
+ /**
+ * Set the {@link Component} that will be returned by {@link
+ * #getFocusOwner} (when it is called from the current {@link
+ * java.lang.ThreadGroup}) and {@link #getGlobalFocusOwner}. This
+ * method does not actually transfer the keyboard focus.
+ *
+ * @param owner the Component to return from getFocusOwner and
+ * getGlobalFocusOwner
+ *
+ * @see Component#requestFocus()
+ * @see Component#requestFocusInWindow()
+ */
+ protected void setGlobalFocusOwner (Component owner)
+ {
+ if (owner == null || owner.focusable)
+ setGlobalObject (currentFocusOwners, owner, "focusOwner");
+ }
+
+ /**
+ * Clear the global focus owner and deliver a FOCUS_LOST event to
+ * the previously-focused {@link Component}. Until another {@link
+ * Component} becomes the keyboard focus owner, key events will be
+ * discarded by top-level windows.
+ */
+ public void clearGlobalFocusOwner ()
+ {
+ synchronized (currentFocusOwners)
+ {
+ Component focusOwner = getGlobalFocusOwner ();
+ Component permanentFocusOwner = getGlobalPermanentFocusOwner ();
+
+ setGlobalFocusOwner (null);
+ setGlobalPermanentFocusOwner (null);
+
+ // Inform the old focus owner that it has lost permanent
+ // focus.
+ if (focusOwner != null)
+ {
+ // We can't cache the event queue, because of
+ // bootstrapping issues. We need to set the default
+ // KeyboardFocusManager in EventQueue before the event
+ // queue is started.
+ EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
+ if (focusOwner != permanentFocusOwner)
+ q.postEvent (new FocusEvent (focusOwner, FocusEvent.FOCUS_LOST, true));
+ else
+ q.postEvent (new FocusEvent (focusOwner, FocusEvent.FOCUS_LOST, false));
+ }
+
+ if (focusOwner != permanentFocusOwner)
+ {
+ EventQueue q = Toolkit.getDefaultToolkit ().getSystemEventQueue ();
+ q.postEvent (new FocusEvent (permanentFocusOwner, FocusEvent.FOCUS_LOST, false));
+ }
+ }
+ }
+
+ /**
+ * Retrieve the {@link Component} that has the permanent keyboard
+ * focus, or null if the focus owner was not set by a thread in the
+ * current {@link java.lang.ThreadGroup}.
+ *
+ * @return the keyboard focus owner or null
+ */
+ public Component getPermanentFocusOwner ()
+ {
+ return (Component) getObject (currentPermanentFocusOwners);
+ }
+
+ /**
+ * Retrieve the {@link Component} that has the permanent keyboard
+ * focus, regardless of whether or not it was set by a thread in the
+ * current {@link java.lang.ThreadGroup}.
+ *
+ * @return the keyboard focus owner
+ * @throws SecurityException if this is not the keyboard focus
+ * manager associated with the current {@link java.lang.ThreadGroup}
+ */
+ protected Component getGlobalPermanentFocusOwner ()
+ {
+ return (Component) getGlobalObject (currentPermanentFocusOwners, true);
+ }
+
+ /**
+ * Set the {@link Component} that will be returned by {@link
+ * #getPermanentFocusOwner} (when it is called from the current
+ * {@link java.lang.ThreadGroup}) and {@link
+ * #getGlobalPermanentFocusOwner}. This method does not actually
+ * transfer the keyboard focus.
+ *
+ * @param focusOwner the Component to return from
+ * getPermanentFocusOwner and getGlobalPermanentFocusOwner
+ *
+ * @see Component#requestFocus()
+ * @see Component#requestFocusInWindow()
+ */
+ protected void setGlobalPermanentFocusOwner (Component focusOwner)
+ {
+ if (focusOwner == null || focusOwner.focusable)
+ setGlobalObject (currentPermanentFocusOwners, focusOwner,
+ "permanentFocusOwner");
+ }
+
+ /**
+ * Retrieve the {@link Window} that is or contains the keyboard
+ * focus owner, or null if the focused window was not set by a
+ * thread in the current {@link java.lang.ThreadGroup}.
+ *
+ * @return the focused window or null
+ */
+ public Window getFocusedWindow ()
+ {
+ return (Window) getObject (currentFocusedWindows);
+ }
+
+ /**
+ * Retrieve the {@link Window} that is or contains the focus owner,
+ * regardless of whether or not the {@link Window} was set focused
+ * by a thread in the current {@link java.lang.ThreadGroup}.
+ *
+ * @return the focused window
+ * @throws SecurityException if this is not the keyboard focus
+ * manager associated with the current {@link java.lang.ThreadGroup}
+ */
+ protected Window getGlobalFocusedWindow ()
+ {
+ return (Window) getGlobalObject (currentFocusedWindows, true);
+ }
+
+ /**
+ * Set the {@link Window} that will be returned by {@link
+ * #getFocusedWindow} (when it is called from the current {@link
+ * java.lang.ThreadGroup}) and {@link #getGlobalFocusedWindow}.
+ * This method does not actually cause <code>window</code> to become
+ * the focused {@link Window}.
+ *
+ * @param window the Window to return from getFocusedWindow and
+ * getGlobalFocusedWindow
+ */
+ protected void setGlobalFocusedWindow (Window window)
+ {
+ if (window == null || window.focusable)
+ setGlobalObject (currentFocusedWindows, window, "focusedWindow");
+ }
+
+ /**
+ * Retrieve the active {@link Window}, or null if the active window
+ * was not set by a thread in the current {@link
+ * java.lang.ThreadGroup}.
+ *
+ * @return the active window or null
+ */
+ public Window getActiveWindow()
+ {
+ return (Window) getObject (currentActiveWindows);
+ }
+
+ /**
+ * Retrieve the active {@link Window}, regardless of whether or not
+ * the {@link Window} was made active by a thread in the current
+ * {@link java.lang.ThreadGroup}.
+ *
+ * @return the active window
+ * @throws SecurityException if this is not the keyboard focus
+ * manager associated with the current {@link java.lang.ThreadGroup}
+ */
+ protected Window getGlobalActiveWindow()
+ {
+ return (Window) getGlobalObject (currentActiveWindows, true);
+ }
+
+ /**
+ * Set the {@link Window} that will be returned by {@link
+ * #getActiveWindow} (when it is called from the current {@link
+ * java.lang.ThreadGroup}) and {@link #getGlobalActiveWindow}. This
+ * method does not actually cause <code>window</code> to be made
+ * active.
+ *
+ * @param window the Window to return from getActiveWindow and
+ * getGlobalActiveWindow
+ */
+ protected void setGlobalActiveWindow(Window window)
+ {
+ setGlobalObject (currentActiveWindows, window, "activeWindow");
+ }
+
+ /**
+ * Retrieve the default {@link FocusTraversalPolicy}.
+ * Focus-managing {@link Container}s use the returned object to
+ * define their initial focus traversal policy.
+ *
+ * @return a non-null default FocusTraversalPolicy object
+ */
+ public FocusTraversalPolicy getDefaultFocusTraversalPolicy ()
+ {
+ if (defaultPolicy == null)
+ defaultPolicy = new DefaultFocusTraversalPolicy ();
+ return defaultPolicy;
+ }
+
+ /**
+ * Set the {@link FocusTraversalPolicy} returned by {@link
+ * #getDefaultFocusTraversalPolicy}. Focus-managing {@link
+ * Container}s created after this call will use policy as their
+ * initial focus traversal policy. Existing {@link Container}s'
+ * focus traversal policies will not be affected by calls to this
+ * method.
+ *
+ * @param policy the FocusTraversalPolicy that will be returned by
+ * subsequent calls to getDefaultFocusTraversalPolicy
+ * @throws IllegalArgumentException if policy is null
+ */
+ public void setDefaultFocusTraversalPolicy (FocusTraversalPolicy policy)
+ {
+ if (policy == null)
+ throw new IllegalArgumentException ();
+ firePropertyChange ("defaultFocusTraversalPolicy", defaultPolicy, policy);
+ defaultPolicy = policy;
+ }
+
+ /**
+ * Set the default {@link java.util.Set} of focus traversal keys for
+ * one of the focus traversal directions.
+ *
+ * @param id focus traversal direction identifier
+ * @param keystrokes set of AWTKeyStrokes
+ *
+ * @see #FORWARD_TRAVERSAL_KEYS
+ * @see #BACKWARD_TRAVERSAL_KEYS
+ * @see #UP_CYCLE_TRAVERSAL_KEYS
+ * @see #DOWN_CYCLE_TRAVERSAL_KEYS
+ */
+ public void setDefaultFocusTraversalKeys (int id, Set keystrokes)
+ {
+ if (id != KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS &&
+ id != KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException ();
+
+ if (keystrokes == null)
+ throw new IllegalArgumentException ();
+
+ Set sa;
+ Set sb;
+ Set sc;
+ String type;
+ switch (id)
+ {
+ case FORWARD_TRAVERSAL_KEYS:
+ sa = defaultFocusKeys[BACKWARD_TRAVERSAL_KEYS];
+ sb = defaultFocusKeys[UP_CYCLE_TRAVERSAL_KEYS];
+ sc = defaultFocusKeys[DOWN_CYCLE_TRAVERSAL_KEYS];
+ type = "forwardDefaultFocusTraversalKeys";
+ break;
+ case BACKWARD_TRAVERSAL_KEYS:
+ sa = defaultFocusKeys[FORWARD_TRAVERSAL_KEYS];
+ sb = defaultFocusKeys[UP_CYCLE_TRAVERSAL_KEYS];
+ sc = defaultFocusKeys[DOWN_CYCLE_TRAVERSAL_KEYS];
+ type = "backwardDefaultFocusTraversalKeys";
+ break;
+ case UP_CYCLE_TRAVERSAL_KEYS:
+ sa = defaultFocusKeys[FORWARD_TRAVERSAL_KEYS];
+ sb = defaultFocusKeys[BACKWARD_TRAVERSAL_KEYS];
+ sc = defaultFocusKeys[DOWN_CYCLE_TRAVERSAL_KEYS];
+ type = "upCycleDefaultFocusTraversalKeys";
+ break;
+ case DOWN_CYCLE_TRAVERSAL_KEYS:
+ sa = defaultFocusKeys[FORWARD_TRAVERSAL_KEYS];
+ sb = defaultFocusKeys[BACKWARD_TRAVERSAL_KEYS];
+ sc = defaultFocusKeys[UP_CYCLE_TRAVERSAL_KEYS];
+ type = "downCycleDefaultFocusTraversalKeys";
+ break;
+ default:
+ throw new IllegalArgumentException ();
+ }
+ int i = keystrokes.size ();
+ Iterator iter = keystrokes.iterator ();
+ while (--i >= 0)
+ {
+ Object o = iter.next ();
+ if (!(o instanceof AWTKeyStroke)
+ || sa.contains (o) || sb.contains (o) || sc.contains (o)
+ || ((AWTKeyStroke) o).keyCode == KeyEvent.VK_UNDEFINED)
+ throw new IllegalArgumentException ();
+ }
+ keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
+ firePropertyChange (type, defaultFocusKeys[id], keystrokes);
+ defaultFocusKeys[id] = keystrokes;
+ }
+
+ /**
+ * Retrieve the default {@link java.util.Set} of focus traversal
+ * keys for one of the focus traversal directions.
+ *
+ * @param id focus traversal direction identifier
+ *
+ * @return the default set of AWTKeyStrokes
+ *
+ * @see #FORWARD_TRAVERSAL_KEYS
+ * @see #BACKWARD_TRAVERSAL_KEYS
+ * @see #UP_CYCLE_TRAVERSAL_KEYS
+ * @see #DOWN_CYCLE_TRAVERSAL_KEYS
+ */
+ public Set getDefaultFocusTraversalKeys (int id)
+ {
+ if (id < FORWARD_TRAVERSAL_KEYS || id > DOWN_CYCLE_TRAVERSAL_KEYS)
+ throw new IllegalArgumentException ();
+ return defaultFocusKeys[id];
+ }
+
+ /**
+ * Retrieve the current focus cycle root, or null if the focus owner
+ * was not set by a thread in the current {@link
+ * java.lang.ThreadGroup}.
+ *
+ * @return the current focus cycle root or null
+ */
+ public Container getCurrentFocusCycleRoot ()
+ {
+ return (Container) getObject (currentFocusCycleRoots);
+ }
+
+ /**
+ * Retrieve the current focus cycle root, regardless of whether or
+ * not it was made set by a thread in the current {@link
+ * java.lang.ThreadGroup}.
+ *
+ * @return the current focus cycle root
+ * @throws SecurityException if this is not the keyboard focus
+ * manager associated with the current {@link java.lang.ThreadGroup}
+ */
+ protected Container getGlobalCurrentFocusCycleRoot ()
+ {
+ return (Container) getGlobalObject (currentFocusCycleRoots, true);
+ }
+
+ /**
+ * Set the {@link Container} that will be returned by {@link
+ * #getCurrentFocusCycleRoot} (when it is called from the current
+ * {@link java.lang.ThreadGroup}) and {@link
+ * #getGlobalCurrentFocusCycleRoot}. This method does not actually
+ * make <code>cycleRoot</code> the current focus cycle root.
+ *
+ * @param cycleRoot the focus cycle root to return from
+ * getCurrentFocusCycleRoot and getGlobalCurrentFocusCycleRoot
+ */
+ public void setGlobalCurrentFocusCycleRoot (Container cycleRoot)
+ {
+ setGlobalObject (currentFocusCycleRoots, cycleRoot, "currentFocusCycleRoot");
+ }
+
+ /**
+ * Registers the supplied property change listener for receiving
+ * events caused by the following property changes:
+ *
+ * <ul>
+ * <li>the current focus owner ("focusOwner")</li>
+ * <li>the permanent focus owner ("permanentFocusOwner")</li>
+ * <li>the focused window ("focusedWindow")</li>
+ * <li>the active window ("activeWindow")</li>
+ * <li>the default focus traversal policy ("defaultFocusTraversalPolicy")</li>
+ * <li>the default set of forward traversal keys ("forwardDefaultFocusTraversalKeys")</li>
+ * <li>the default set of backward traversal keys ("backwardDefaultFocusTraversalKeys")</li>
+ * <li>the default set of up cycle traversal keys ("upCycleDefaultFocusTraversalKeys")</li>
+ * <li>the default set of down cycle traversal keys ("downCycleDefaultFocusTraversalKeys")</li>
+ * <li>the current focus cycle root ("currentFocusCycleRoot")</li>
+ * </ul>
+ *
+ * If the supplied listener is null, nothing occurs.
+ *
+ * @param l the new listener to register.
+ * @see KeyboardFocusManager#addPropertyChangeListener(String, java.beans.PropertyChangeListener)
+ */
+ public void addPropertyChangeListener(PropertyChangeListener l)
+ {
+ if (l != null)
+ propertyChangeSupport.addPropertyChangeListener(l);
+ }
+
+ /**
+ * Removes the supplied property change listener from the list
+ * of registered listeners. If the supplied listener is null,
+ * nothing occurs.
+ *
+ * @param l the listener to remove.
+ */
+ public void removePropertyChangeListener(PropertyChangeListener l)
+ {
+ if (l != null)
+ propertyChangeSupport.removePropertyChangeListener(l);
+ }
+
+ /**
+ * Returns the currently registered property change listeners
+ * in array form. The returned array is empty if no listeners are
+ * currently registered.
+ *
+ * @return an array of registered property change listeners.
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ return propertyChangeSupport.getPropertyChangeListeners();
+ }
+
+ /**
+ * Registers a property change listener for receiving events relating
+ * to a change to a specified property. The supplied property name can be
+ * either user-defined or one from the following list of properties
+ * relevant to this class:
+ *
+ * <ul>
+ * <li>the current focus owner ("focusOwner")</li>
+ * <li>the permanent focus owner ("permanentFocusOwner")</li>
+ * <li>the focused window ("focusedWindow")</li>
+ * <li>the active window ("activeWindow")</li>
+ * <li>the default focus traversal policy ("defaultFocusTraversalPolicy")</li>
+ * <li>the default set of forward traversal keys ("forwardDefaultFocusTraversalKeys")</li>
+ * <li>the default set of backward traversal keys ("backwardDefaultFocusTraversalKeys")</li>
+ * <li>the default set of up cycle traversal keys ("upCycleDefaultFocusTraversalKeys")</li>
+ * <li>the default set of down cycle traversal keys ("downCycleDefaultFocusTraversalKeys")</li>
+ * <li>the current focus cycle root ("currentFocusCycleRoot")</li>
+ * </ul>
+ *
+ * Nothing occurs if a null listener is supplied. null is regarded as a valid property name.
+ *
+ * @param name the name of the property to handle change events for.
+ * @param l the listener to register for changes to the specified property.
+ * @see KeyboardFocusManager#addPropertyChangeListener(java.beans.PropertyChangeListener)
+ */
+ public void addPropertyChangeListener(String name, PropertyChangeListener l)
+ {
+ if (l != null)
+ propertyChangeSupport.addPropertyChangeListener(name, l);
+ }
+
+ /**
+ * Removes the supplied property change listener registered for the
+ * specified property from the list of registered listeners. If the
+ * supplied listener is null, nothing occurs.
+ *
+ * @param name the name of the property the listener is
+ * monitoring changes to.
+ * @param l the listener to remove.
+ */
+ public void removePropertyChangeListener(String name,
+ PropertyChangeListener l)
+ {
+ if (l != null)
+ propertyChangeSupport.removePropertyChangeListener(name, l);
+ }
+
+ /**
+ * Returns the currently registered property change listeners
+ * in array form, which listen for changes to the supplied property.
+ * The returned array is empty, if no listeners are currently registered
+ * for events pertaining to the supplied property.
+ *
+ * @param name The property the returned listeners monitor for changes.
+ * @return an array of registered property change listeners which
+ * listen for changes to the supplied property.
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners(String name)
+ {
+ return propertyChangeSupport.getPropertyChangeListeners(name);
+ }
+
+ /**
+ * Fires a property change event as a response to a change to
+ * to the specified property. The event is only fired if a
+ * change has actually occurred (i.e. o and n are different).
+ *
+ * @param name The name of the property to which a change occurred.
+ * @param o The old value of the property.
+ * @param n The new value of the property.
+ */
+ protected void firePropertyChange(String name, Object o, Object n)
+ {
+ propertyChangeSupport.firePropertyChange(name, o, n);
+ }
+
+ /**
+ * Registers a vetoable property change listener for receiving events
+ * relating to the following properties:
+ *
+ * <ul>
+ * <li>the current focus owner ("focusOwner")</li>
+ * <li>the permanent focus owner ("permanentFocusOwner")</li>
+ * <li>the focused window ("focusedWindow")</li>
+ * <li>the active window ("activeWindow")</li>
+ * </ul>
+ *
+ * Nothing occurs if a null listener is supplied.
+ *
+ * @param l the listener to register.
+ * @see KeyboardFocusManager#addVetoableChangeListener(String, java.beans.VetoableChangeListener)
+ */
+ public void addVetoableChangeListener(VetoableChangeListener l)
+ {
+ if (l != null)
+ vetoableChangeSupport.addVetoableChangeListener(l);
+ }
+
+ /**
+ * Removes the supplied vetoable property change listener from
+ * the list of registered listeners. If the supplied listener
+ * is null, nothing occurs.
+ *
+ * @param l the listener to remove.
+ */
+ public void removeVetoableChangeListener(VetoableChangeListener l)
+ {
+ if (l != null)
+ vetoableChangeSupport.removeVetoableChangeListener(l);
+ }
+
+ /**
+ * Returns the currently registered vetoable property change listeners
+ * in array form. The returned array is empty if no listeners are
+ * currently registered.
+ *
+ * @return an array of registered vetoable property change listeners.
+ * @since 1.4
+ */
+ public VetoableChangeListener[] getVetoableChangeListeners()
+ {
+ return vetoableChangeSupport.getVetoableChangeListeners();
+ }
+
+ /**
+ * Registers a vetoable property change listener for receiving events relating
+ * to a vetoable change to a specified property. The supplied property name can be
+ * either user-defined or one from the following list of properties
+ * relevant to this class:
+ *
+ * <ul>
+ * <li>the current focus owner ("focusOwner")</li>
+ * <li>the permanent focus owner ("permanentFocusOwner")</li>
+ * <li>the focused window ("focusedWindow")</li>
+ * <li>the active window ("activeWindow")</li>
+ * </ul>
+ *
+ * Nothing occurs if a null listener is supplied. null is regarded as a valid property name.
+ *
+ * @param name the name of the property to handle change events for.
+ * @param l the listener to register for changes to the specified property.
+ * @see KeyboardFocusManager#addVetoableChangeListener(java.beans.VetoableChangeListener)
+ */
+ public void addVetoableChangeListener(String name, VetoableChangeListener l)
+ {
+ if (l != null)
+ vetoableChangeSupport.addVetoableChangeListener(name, l);
+ }
+
+ /**
+ * Removes the supplied vetoable property change listener registered
+ * for the specified property from the list of registered listeners.
+ * If the supplied listener is null, nothing occurs.
+ *
+ * @param name the name of the vetoable property the listener is
+ * monitoring changes to.
+ * @param l the listener to remove.
+ */
+ public void removeVetoableChangeListener(String name,
+ VetoableChangeListener l)
+ {
+ if (l != null)
+ vetoableChangeSupport.removeVetoableChangeListener(name, l);
+ }
+
+ /**
+ * Returns the currently registered vetoable property change listeners
+ * in array form, which listen for changes to the supplied property.
+ * The returned array is empty, if no listeners are currently registered
+ * for events pertaining to the supplied property.
+ *
+ * @param name The property the returned listeners monitor for changes.
+ * @return an array of registered property change listeners which
+ * listen for changes to the supplied property.
+ * @since 1.4
+ */
+ public VetoableChangeListener[] getVetoableChangeListeners(String name)
+ {
+ return vetoableChangeSupport.getVetoableChangeListeners(name);
+ }
+
+ /**
+ * Fires a property change event as a response to a vetoable change to
+ * to the specified property. The event is only fired if a
+ * change has actually occurred (i.e. o and n are different).
+ * In the event that the property change is vetoed, the following
+ * occurs:
+ *
+ * <ol>
+ * <li>
+ * This method throws a <code>PropertyVetoException</code> to
+ * the proposed change.
+ * </li>
+ * <li>
+ * A new event is fired to reverse the previous change.
+ * </li>
+ * <li>
+ * This method again throws a <code>PropertyVetoException</code>
+ * in response to the reversion.
+ * </li>
+ * </ol>
+ *
+ * @param name The name of the property to which a change occurred.
+ * @param o The old value of the property.
+ * @param n The new value of the property.
+ * @throws PropertyVetoException if one of the listeners vetos
+ * the change by throwing this exception.
+ */
+ protected void fireVetoableChange(String name, Object o, Object n)
+ throws PropertyVetoException
+ {
+ vetoableChangeSupport.fireVetoableChange(name, o, n);
+ }
+
+ /**
+ * Adds a key event dispatcher to the list of registered dispatchers.
+ * When a key event is fired, each dispatcher's <code>dispatchKeyEvent</code>
+ * method is called in the order that they were added, prior to the manager
+ * dispatching the event itself. Notifications halt when one of the
+ * dispatchers returns true.
+ * <br />
+ * <br />
+ * The same dispatcher can exist multiple times within the list
+ * of registered dispatchers, and there is no limit on the length
+ * of this list. A null dispatcher is simply ignored.
+ *
+ * @param dispatcher The dispatcher to register.
+ */
+ public void addKeyEventDispatcher(KeyEventDispatcher dispatcher)
+ {
+ if (dispatcher != null)
+ keyEventDispatchers.add(dispatcher);
+ }
+
+ /**
+ * Removes the specified key event dispatcher from the list of
+ * registered dispatchers. The manager always dispatches events,
+ * regardless of its existence within the list. The manager
+ * can be added and removed from the list, as with any other
+ * dispatcher, but this does not affect its ability to dispatch
+ * key events. Non-existent and null dispatchers are simply ignored
+ * by this method.
+ *
+ * @param dispatcher The dispatcher to remove.
+ */
+ public void removeKeyEventDispatcher(KeyEventDispatcher dispatcher)
+ {
+ keyEventDispatchers.remove(dispatcher);
+ }
+
+ /**
+ * Returns the currently registered key event dispatchers in <code>List</code>
+ * form. At present, this only includes dispatchers explicitly registered
+ * via the <code>addKeyEventDispatcher()</code> method, but this behaviour
+ * is subject to change and should not be depended on. The manager itself
+ * may be a member of the list, but only if explicitly registered. If no
+ * dispatchers have been registered, the list will be empty.
+ *
+ * @return A list of explicitly registered key event dispatchers.
+ * @see KeyboardFocusManager#addKeyEventDispatcher(java.awt.KeyEventDispatcher)
+ */
+ protected List getKeyEventDispatchers ()
+ {
+ return (List) keyEventDispatchers.clone ();
+ }
+
+ /**
+ * Adds a key event post processor to the list of registered post processors.
+ * Post processors work in the same way as key event dispatchers, except
+ * that they are invoked after the manager has dispatched the key event,
+ * and not prior to this. Each post processor's <code>postProcessKeyEvent</code>
+ * method is called to see if any post processing needs to be performed. THe
+ * processors are called in the order in which they were added to the list,
+ * and notifications continue until one returns true. As with key event
+ * dispatchers, the manager is implicitly called following this process,
+ * regardless of whether or not it is present within the list.
+ * <br />
+ * <br />
+ * The same post processor can exist multiple times within the list
+ * of registered post processors, and there is no limit on the length
+ * of this list. A null post processor is simply ignored.
+ *
+ * @param postProcessor the post processor to register.
+ * @see KeyboardFocusManager#addKeyEventDispatcher(java.awt.KeyEventDispatcher)
+ */
+ public void addKeyEventPostProcessor (KeyEventPostProcessor postProcessor)
+ {
+ if (postProcessor != null)
+ keyEventPostProcessors.add (postProcessor);
+ }
+
+ /**
+ * Removes the specified key event post processor from the list of
+ * registered post processors. The manager always post processes events,
+ * regardless of its existence within the list. The manager
+ * can be added and removed from the list, as with any other
+ * post processor, but this does not affect its ability to post process
+ * key events. Non-existent and null post processors are simply ignored
+ * by this method.
+ *
+ * @param postProcessor the post processor to remove.
+ */
+ public void removeKeyEventPostProcessor (KeyEventPostProcessor postProcessor)
+ {
+ keyEventPostProcessors.remove (postProcessor);
+ }
+
+ /**
+ * Returns the currently registered key event post processors in <code>List</code>
+ * form. At present, this only includes post processors explicitly registered
+ * via the <code>addKeyEventPostProcessor()</code> method, but this behaviour
+ * is subject to change and should not be depended on. The manager itself
+ * may be a member of the list, but only if explicitly registered. If no
+ * post processors have been registered, the list will be empty.
+ *
+ * @return A list of explicitly registered key event post processors.
+ * @see KeyboardFocusManager#addKeyEventPostProcessor(java.awt.KeyEventPostProcessor)
+ */
+ protected List getKeyEventPostProcessors ()
+ {
+ return (List) keyEventPostProcessors.clone ();
+ }
+
+ /**
+ * The AWT event dispatcher uses this method to request that the manager
+ * handle a particular event. If the manager fails or refuses to
+ * dispatch the supplied event (this method returns false), the
+ * AWT event dispatcher will try to dispatch the event itself.
+ * <br />
+ * <br />
+ * The manager is expected to handle all <code>FocusEvent</code>s
+ * and <code>KeyEvent</code>s, and <code>WindowEvent</code>s
+ * relating to the focus. Dispatch is done with regard to the
+ * the focus owner and the currently focused and active windows.
+ * In handling the event, the source of the event may be overridden.
+ * <br />
+ * <br />
+ * The actual dispatching is performed by calling
+ * <code>redispatchEvent()</code>. This avoids the infinite recursion
+ * of dispatch requests which may occur if this method is called on
+ * the target component.
+ *
+ * @param e the event to dispatch.
+ * @return true if the event was dispatched.
+ * @see KeyboardFocusManager#redispatchEvent(java.awt.Component, java.awt.AWTEvent)
+ * @see KeyEvent
+ * @see FocusEvent
+ * @see WindowEvent
+ */
+ public abstract boolean dispatchEvent (AWTEvent e);
+
+ /**
+ * Handles redispatching of an event so that recursion of
+ * dispatch requests does not occur. Event dispatch methods
+ * within this manager (<code>dispatchEvent()</code>) and
+ * the key event dispatchers should use this method to handle
+ * dispatching rather than the dispatch method of the target
+ * component.
+ * <br />
+ * <br />
+ * <strong>
+ * This method is not intended for general consumption, and is
+ * only for the use of the aforementioned classes.
+ * </strong>
+ *
+ * @param target the target component to which the event is
+ * dispatched.
+ * @param e the event to dispatch.
+ */
+ public final void redispatchEvent (Component target, AWTEvent e)
+ {
+ e.isFocusManagerEvent = true;
+ target.dispatchEvent (e);
+ e.isFocusManagerEvent = false;
+ }
+
+ /**
+ * Attempts to dispatch key events for which no key event dispatcher
+ * has so far succeeded. This method is usually called by
+ * <code>dispatchEvent()</code> following the sending of the key
+ * event to any registered key event dispatchers. If the key
+ * event reaches this stage, none of the dispatchers returned
+ * true. This is, of course, always the case if there are no
+ * registered dispatchers.
+ * <br />
+ * <br />
+ * If this method also fails to handle the key event, then
+ * false is returned to the caller. In the case of
+ * <code>dispatchEvent()</code>, the calling method may try
+ * to handle the event itself or simply forward on the
+ * false result to its caller. When the event is dispatched
+ * by this method, a true result is propogated through the
+ * calling methods.
+ *
+ * @param e the key event to dispatch.
+ * @return true if the event was dispatched successfully.
+ */
+ public abstract boolean dispatchKeyEvent (KeyEvent e);
+
+ /**
+ * Handles the post processing of key events. By default,
+ * this method will map unhandled key events to appropriate
+ * <code>MenuShortcut</code>s. The event is consumed
+ * in the process and the shortcut is activated. This
+ * method is usually called by <code>dispatchKeyEvent</code>.
+ *
+ * @param e the key event to post process.
+ * @return true by default, as the event was handled.
+ */
+ public abstract boolean postProcessKeyEvent (KeyEvent e);
+
+ /**
+ * Handles focus traversal operations for key events which
+ * represent focus traversal keys in relation to the supplied
+ * component. The supplied component is assumed to have the
+ * focus, whether it does so or not, and the operation is
+ * carried out as appropriate, with this in mind.
+ *
+ * @param focused the component on which to perform focus traversal,
+ * on the assumption that this component has the focus.
+ * @param e the possible focus traversal key event.
+ */
+ public abstract void processKeyEvent (Component focused, KeyEvent e);
+
+ /**
+ * Delays all key events following the specified timestamp until the
+ * supplied component has focus. The AWT calls this method when it is
+ * determined that a focus change may occur within the native windowing
+ * system. Any key events which occur following the time specified by
+ * after are delayed until a <code>FOCUS_GAINED</code> event is received
+ * for the untilFocused component. The manager is responsible for ensuring
+ * this takes place.
+ *
+ * @param after the timestamp beyond which all key events are delayed until
+ * the supplied component gains focus.
+ * @param untilFocused the component to wait on gaining focus.
+ */
+ protected abstract void enqueueKeyEvents (long after, Component untilFocused);
+
+ /**
+ * Removes the key event block specified by the supplied timestamp and component.
+ * All delayed key events are released for normal dispatching following its
+ * removal and subsequent key events that would have been blocked are now
+ * immediately dispatched. If the specified timestamp is below 0, then
+ * the request with the oldest timestamp is removed.
+ *
+ * @param after the timestamp of the key event block to be removed, or a
+ * value smaller than 0 if the oldest is to be removed.
+ * @param untilFocused the component of the key event block to be removed.
+ */
+ protected abstract void dequeueKeyEvents (long after, Component untilFocused);
+
+ /**
+ * Discards all key event blocks relating to focus requirements for
+ * the supplied component, regardless of timestamp.
+ *
+ * @param comp the component of the key event block(s) to be removed.
+ */
+ protected abstract void discardKeyEvents (Component comp);
+
+ /**
+ * Moves the current focus to the next component following
+ * comp, based on the current focus traversal policy. By
+ * default, only visible, displayable, accepted components
+ * can receive focus. <code>Canvas</code>es, <code>Panel</code>s,
+ * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,
+ * <code>Window</code>s and lightweight components are judged
+ * to be unacceptable by default. See the
+ * <code>DefaultFocusTraversalPolicy</code> for more details.
+ *
+ * @param comp the component prior to the one which will
+ * become the focus, following execution of this method.
+ * @see DefaultFocusTraversalPolicy
+ */
+ public abstract void focusNextComponent(Component comp);
+
+ /**
+ * Moves the current focus to the previous component, prior to
+ * comp, based on the current focus traversal policy. By
+ * default, only visible, displayable, accepted components
+ * can receive focus. <code>Canvas</code>es, <code>Panel</code>s,
+ * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,
+ * <code>Window</code>s and lightweight components are judged
+ * to be unacceptable by default. See the
+ * <code>DefaultFocusTraversalPolicy</code> for more details.
+ *
+ * @param comp the component following the one which will
+ * become the focus, following execution of this method.
+ * @see DefaultFocusTraversalPolicy
+ */
+ public abstract void focusPreviousComponent(Component comp);
+
+ /**
+ * Moves the current focus upwards by one focus cycle.
+ * Both the current focus owner and current focus cycle root
+ * become the focus cycle root of the supplied component.
+ * However, in the case of a <code>Window</code>, the default
+ * focus component becomes the focus owner and the focus cycle
+ * root is not changed.
+ *
+ * @param comp the component used as part of the focus traversal.
+ */
+ public abstract void upFocusCycle(Component comp);
+
+ /**
+ * Moves the current focus downwards by one focus cycle.
+ * If the supplied container is a focus cycle root, then this
+ * becomes the current focus cycle root and the focus goes
+ * to the default component of the specified container.
+ * Nothing happens for non-focus cycle root containers.
+ *
+ * @param cont the container used as part of the focus traversal.
+ */
+ public abstract void downFocusCycle(Container cont);
+
+ /**
+ * Moves the current focus to the next component, based on the
+ * current focus traversal policy. By default, only visible,
+ * displayable, accepted component can receive focus.
+ * <code>Canvas</code>es, <code>Panel</code>s,
+ * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,
+ * <code>Window</code>s and lightweight components are judged
+ * to be unacceptable by default. See the
+ * <code>DefaultFocusTraversalPolicy</code> for more details.
+ *
+ * @see DefaultFocusTraversalPolicy
+ */
+ public final void focusNextComponent()
+ {
+ focusNextComponent (null);
+ }
+
+ /**
+ * Moves the current focus to the previous component, based on the
+ * current focus traversal policy. By default, only visible,
+ * displayable, accepted component can receive focus.
+ * <code>Canvas</code>es, <code>Panel</code>s,
+ * <code>Label</code>s, <code>ScrollPane</code>s, <code>Scrollbar</code>s,
+ * <code>Window</code>s and lightweight components are judged
+ * to be unacceptable by default. See the
+ * <code>DefaultFocusTraversalPolicy</code> for more details.
+ *
+ * @see DefaultFocusTraversalPolicy
+ */
+ public final void focusPreviousComponent()
+ {
+ focusPreviousComponent (null);
+ }
+
+ /**
+ * Moves the current focus upwards by one focus cycle,
+ * so that the new focus owner is the focus cycle root
+ * of the current owner. The current focus cycle root then
+ * becomes the focus cycle root of the new focus owner.
+ * However, in the case of the focus cycle root of the
+ * current focus owner being a <code>Window</code>, the default
+ * component of this window becomes the focus owner and the
+ * focus cycle root is not changed.
+ */
+ public final void upFocusCycle()
+ {
+ upFocusCycle (null);
+ }
+
+ /**
+ * Moves the current focus downwards by one focus cycle,
+ * iff the current focus cycle root is a <code>Container</code>.
+ * Usually, the new focus owner is set to the default component
+ * of the container and the current focus cycle root is set
+ * to the current focus owner. Nothing occurs if the current
+ * focus cycle root is not a container.
+ */
+ public final void downFocusCycle()
+ {
+ Component focusOwner = getGlobalFocusOwner ();
+ if (focusOwner instanceof Container
+ && ((Container) focusOwner).isFocusCycleRoot ())
+ downFocusCycle ((Container) focusOwner);
+ }
+
+ /**
+ * Retrieve an object from one of the global object {@link
+ * java.util.Map}s, if the object was set by the a thread in the
+ * current {@link java.lang.ThreadGroup}. Otherwise, return null.
+ *
+ * @param globalMap one of the global object Maps
+ *
+ * @return a global object set by the current ThreadGroup, or null
+ *
+ * @see #getFocusOwner()
+ * @see #getPermanentFocusOwner()
+ * @see #getFocusedWindow()
+ * @see #getActiveWindow()
+ * @see #getCurrentFocusCycleRoot()
+ */
+ private Object getObject (Map globalMap)
+ {
+ ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
+ return globalMap.get (currentGroup);
+ }
+
+ /**
+ * Retrieve an object from one of the global object {@link
+ * java.util.Map}s, regardless of whether or not the object was set
+ * by a thread in the current {@link java.lang.ThreadGroup}.
+ *
+ * @param globalMap one of the global object Maps
+ *
+ * @return a global object set by the current ThreadGroup, or null
+ *
+ * @throws SecurityException if this is not the keyboard focus
+ * manager associated with the current {@link java.lang.ThreadGroup}
+ *
+ * @see #getGlobalFocusOwner()
+ * @see #getGlobalPermanentFocusOwner()
+ * @see #getGlobalFocusedWindow()
+ * @see #getGlobalActiveWindow()
+ * @see #getGlobalCurrentFocusCycleRoot()
+ */
+ private Object getGlobalObject (Map globalMap, boolean checkThread)
+ {
+ if (checkThread)
+ {
+ ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
+ KeyboardFocusManager managerForCallingThread =
+ (KeyboardFocusManager) currentKeyboardFocusManagers.get(currentGroup);
+
+ if (this != managerForCallingThread)
+ throw new SecurityException ("Attempted to retrieve an object from a "
+ + "keyboard focus manager that isn't "
+ + "associated with the current thread group.");
+ }
+ synchronized (globalMap)
+ {
+ Collection globalObjects = globalMap.values ();
+ Iterator i = globalObjects.iterator ();
+ Component globalObject;
+
+ while (i.hasNext ())
+ {
+ globalObject = (Component) i.next ();
+ if (globalObject != null)
+ return globalObject;
+ }
+ }
+
+ // No Object was found.
+ return null;
+ }
+
+ /**
+ * Set an object in one of the global object {@link java.util.Map}s,
+ * that will be returned by subsequent calls to getGlobalObject on
+ * the same {@link java.util.Map}.
+ *
+ * @param globalMap one of the global object Maps
+ * @param newObject the object to set
+ * @param property the property that will change
+ *
+ * @see #setGlobalFocusOwner(Component)
+ * @see #setGlobalPermanentFocusOwner(Component)
+ * @see #setGlobalFocusedWindow(Window)
+ * @see #setGlobalActiveWindow(Window)
+ * @see #setGlobalCurrentFocusCycleRoot(Container)
+ */
+ private void setGlobalObject (Map globalMap,
+ Object newObject,
+ String property)
+ {
+ synchronized (globalMap)
+ {
+ // Save old object.
+ Object oldObject = getGlobalObject(globalMap, false);
+
+ // Nullify old object.
+ Collection threadGroups = globalMap.keySet ();
+ Iterator i = threadGroups.iterator ();
+ while (i.hasNext ())
+ {
+ ThreadGroup oldThreadGroup = (ThreadGroup) i.next ();
+ if (globalMap.get (oldThreadGroup) != null)
+ {
+ globalMap.put (oldThreadGroup, null);
+ // There should only be one object set at a time, so
+ // we can short circuit.
+ break;
+ }
+ }
+
+ ThreadGroup currentGroup = Thread.currentThread ().getThreadGroup ();
+ firePropertyChange (property, oldObject, newObject);
+ try
+ {
+ fireVetoableChange (property, oldObject, newObject);
+ // Set new object.
+ globalMap.put (currentGroup, newObject);
+ }
+ catch (PropertyVetoException e)
+ {
+ }
+ }
+ }
+
+
+ /**
+ * Maps focus requests from heavyweight to lightweight components.
+ */
+ private static HashMap focusRequests = new HashMap();
+
+ /**
+ * Retargets focus events that come from the peer (which only know about
+ * heavyweight components) to go to the correct lightweight component
+ * if appropriate.
+ *
+ * @param ev the event to check
+ *
+ * @return the retargetted event
+ */
+ static AWTEvent retargetFocusEvent(AWTEvent ev)
+ {
+ if (ev instanceof FocusEvent)
+ {
+ FocusEvent fe = (FocusEvent) ev;
+ Component target = fe.getComponent();
+ if (focusRequests.containsKey(target))
+ {
+ Component lightweight = (Component) focusRequests.get(target);
+ ev = new FocusEvent(lightweight, fe.id, fe.isTemporary());
+ focusRequests.remove(target);
+ }
+ }
+ return ev;
+ }
+
+ /**
+ * Adds a lightweight focus request for a heavyweight component.
+ *
+ * @param heavyweight the heavyweight from which we will receive a focus
+ * event soon
+ * @param lightweight the lightweight that ultimately receives the request
+ */
+ static void addLightweightFocusRequest(Component heavyweight,
+ Component lightweight)
+ {
+ focusRequests.put(heavyweight, lightweight);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Label.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Label.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Label.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Label.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,295 @@
+/* Label.java -- Java label widget
+ Copyright (C) 1999, 2000, 2002, 2004, 2005, 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 java.awt.peer.LabelPeer;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * This component is used for displaying simple text strings that cannot
+ * be edited by the user.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+public class Label extends Component implements Accessible
+{
+
+ /**
+ * Alignment constant aligning the text to the left of its window.
+ */
+ public static final int LEFT = 0;
+
+ /**
+ * Alignment constant aligning the text in the center of its window.
+ */
+ public static final int CENTER = 1;
+
+ /**
+ * Alignment constant aligning the text to the right of its window.
+ */
+ public static final int RIGHT = 2;
+
+ // Serialization version constant:
+ private static final long serialVersionUID = 3094126758329070636L;
+
+ /**
+ * @serial Indicates the alignment of the text within this label's window.
+ * This is one of the constants in this class. The default value is
+ * <code>LEFT</code>.
+ */
+ private int alignment;
+
+ /**
+ * @serial The text displayed in the label
+ */
+ private String text;
+
+ /**
+ * Initializes a new instance of <code>Label</code> with no text.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Label()
+ {
+ this("", LEFT);
+ }
+
+ /**
+ * Initializes a new instance of <code>Label</code> with the specified
+ * text that is aligned to the left.
+ *
+ * @param text The text of the label.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Label(String text)
+ {
+ this(text, LEFT);
+ }
+
+ /**
+ * Initializes a new instance of <code>Label</code> with the specified
+ * text and alignment.
+ *
+ * @param text The text of the label.
+ * @param alignment The desired alignment for the text in this label,
+ * which must be one of <code>LEFT</code>, <code>CENTER</code>, or
+ * <code>RIGHT</code>.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Label(String text, int alignment)
+ {
+ setAlignment(alignment);
+ setText(text);
+
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ }
+
+ /**
+ * Returns the constant indicating the alignment of the text in this
+ * label. The value returned will be one of the alignment constants
+ * from this class.
+ *
+ * @return The alignment of the text in the label.
+ */
+ public int getAlignment()
+ {
+ return(alignment);
+ }
+
+ /**
+ * Sets the text alignment of this label to the specified value.
+ *
+ * @param alignment The desired alignment for the text in this label,
+ * which must be one of <code>LEFT</code>, <code>CENTER</code>, or
+ * <code>RIGHT</code>.
+ */
+ public synchronized void setAlignment(int alignment)
+ {
+ if (alignment != CENTER && alignment != LEFT && alignment != RIGHT)
+ throw new IllegalArgumentException("invalid alignment: " + alignment);
+ this.alignment = alignment;
+ if (peer != null)
+ {
+ LabelPeer lp = (LabelPeer) peer;
+ lp.setAlignment(alignment);
+ }
+ }
+
+ /**
+ * Returns the text displayed in this label.
+ *
+ * @return The text for this label.
+ */
+ public String getText()
+ {
+ return text;
+ }
+
+ /**
+ * Sets the text in this label to the specified value.
+ *
+ * @param text The new text for this label.
+ */
+ public synchronized void setText(String text)
+ {
+ if ((this.text == null && text != null)
+ || (this.text != null && ! this.text.equals(text)))
+ {
+ this.text = text;
+
+ if (peer != null)
+ {
+ LabelPeer lp = (LabelPeer) peer;
+ lp.setText(text);
+ }
+ invalidate();
+ }
+ }
+
+ /**
+ * Notifies this label that it has been added to a container, causing
+ * the peer to be created. This method is called internally by the AWT
+ * system.
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit().createLabel(this);
+ super.addNotify();
+ }
+
+ /**
+ * Returns a parameter string useful for debugging.
+ *
+ * @return A debugging string.
+ */
+ protected String paramString()
+ {
+ return ("text=" + getText() + ",alignment=" +
+ getAlignment() + "," + super.paramString());
+ }
+
+ /**
+ * This class provides accessibility support for the label.
+ */
+ protected class AccessibleAWTLabel
+ extends AccessibleAWTComponent
+ {
+ /**
+ * For compatability with Sun's JDK 1.4.2 rev. 5
+ */
+ private static final long serialVersionUID = -3568967560160480438L;
+
+ /**
+ * Constructor for the accessible label.
+ */
+ public AccessibleAWTLabel()
+ {
+ }
+
+ /**
+ * Returns the accessible name for the label. This is
+ * the text used in the label.
+ *
+ * @return a <code>String</code> containing the accessible
+ * name for this label.
+ */
+ public String getAccessibleName()
+ {
+ return getText();
+ }
+
+ /**
+ * Returns the accessible role for the label.
+ *
+ * @return an instance of <code>AccessibleRole</code>, describing
+ * the role of the label.
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.LABEL;
+ }
+
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Label</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 AccessibleAWTLabel();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this button.
+ *
+ * @return A unique name for this button.
+ */
+ String generateName()
+ {
+ return "label" + getUniqueLong();
+ }
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long nextLabelNumber;
+
+ private static synchronized long getUniqueLong()
+ {
+ return nextLabelNumber++;
+ }
+
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,92 @@
+/* LayoutManager.java -- lay out elements in a Container
+ Copyright (C) 1999, 2002, 2005 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;
+
+/**
+ * This interface is for laying out containers in a particular sequence.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see Container
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface LayoutManager
+{
+ /**
+ * Adds the specified component to the layout group.
+ *
+ * @param name the name of the component to add
+ * @param component the component to add
+ */
+ void addLayoutComponent(String name, Component component);
+
+ /**
+ * Removes the specified component from the layout group.
+ *
+ * @param component the component to remove
+ */
+ void removeLayoutComponent(Component component);
+
+ /**
+ * Calculates the preferred size for this container, taking into account
+ * the components it contains.
+ *
+ * @param parent the parent container to lay out
+ * @return the preferred dimensions of this container
+ * @see #minimumLayoutSize(Container)
+ */
+ Dimension preferredLayoutSize(Container parent);
+
+ /**
+ * Calculates the minimum size for this container, taking into account
+ * the components it contains.
+ *
+ * @param parent the parent container to lay out
+ * @return the minimum dimensions of this container
+ * @see #preferredLayoutSize(Container)
+ */
+ Dimension minimumLayoutSize(Container parent);
+
+ /**
+ * Lays out the components in the given container.
+ *
+ * @param parent the container to lay out
+ */
+ void layoutContainer(Container parent);
+} // interface LayoutManager
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager2.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager2.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager2.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LayoutManager2.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* LayoutManager2.java -- enhanced layout manager
+ Copyright (C) 1999, 2002 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;
+
+/**
+ * Layout manager for laying out containers based on contraints. The
+ * constraints control how the layout will proceed.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see LayoutManager
+ * @see Container
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface LayoutManager2 extends LayoutManager
+{
+ /**
+ * Adds the specified component to the layout, with the specified
+ * constraints object.
+ *
+ * @param component the component to add
+ * @param constraints the constraints to satisfy
+ */
+ void addLayoutComponent(Component component, Object constraints);
+
+ /**
+ * Determines the maximum size of the specified target container.
+ *
+ * @param target the container to lay out
+ * @return the maximum size of the container
+ * @see Component#getMaximumSize()
+ */
+ Dimension maximumLayoutSize(Container target);
+
+ /**
+ * Returns the preferred X axis alignment for the specified target
+ * container. This value will range from 0 to 1 where 0 is alignment
+ * closest to the origin, 0.5 is centered, and 1 is aligned furthest
+ * from the origin.
+ *
+ * @param target the target container
+ * @return the x-axis alignment preference
+ */
+ float getLayoutAlignmentX(Container target);
+
+ /**
+ * Returns the preferred Y axis alignment for the specified target
+ * container. This value will range from 0 to 1 where 0 is alignment
+ * closest to the origin, 0.5 is centered, and 1 is aligned furthest
+ * from the origin.
+ *
+ * @param target the target container
+ * @return the y-axis alignment preference
+ */
+ float getLayoutAlignmentY(Container target);
+
+ /**
+ * Forces the layout manager to purge any cached information about the
+ * layout of the target container. This will force it to be recalculated.
+ *
+ * @param target the target container
+ */
+ void invalidateLayout(Container target);
+} // interface LayoutManager2
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LightweightDispatcher.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LightweightDispatcher.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LightweightDispatcher.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/LightweightDispatcher.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,347 @@
+/* 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 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 at 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;
+
+ /**
+ * Stores the button number which started the drag operation. This is needed
+ * because we want to handle only one drag operation and only the button that
+ * started the dragging should be able to stop it (by a button release).
+ */
+ private int dragButton;
+
+ /**
+ * 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)
+ {
+ if (event instanceof MouseEvent && event.getSource() instanceof Window)
+ {
+ MouseEvent mouseEvent = (MouseEvent) event;
+ return handleMouseEvent(mouseEvent);
+ }
+ return false;
+ }
+
+ /**
+ * 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
+ * @return whether or not we found a lightweight that handled the event.
+ */
+ private boolean handleMouseEvent(MouseEvent ev)
+ {
+ Window window = (Window) ev.getSource();
+ // Find the target for the mouse event. We first seach the deepest
+ // component at the specified location. The we go up to its parent and
+ // try to find a neighbor of the deepest component that is suitable as
+ // mouse event target (it must be showing, at that location and have either
+ // a MouseListener or MouseMotionListener installed). If no such component
+ // is found, then we walk up the container hierarchy and find the next
+ // container that has a MouseListener or MouseMotionListener installed.
+ Component deepest = window.findComponentAt(ev.getX(), ev.getY());
+ if (deepest == null)
+ return false;
+ Container parent = deepest.getParent();
+ Point loc = ev.getPoint();
+ loc = convertPointToChild(window, loc, parent);
+ Component target = null;
+ if (parent != null)
+ {
+ target = findTarget(parent, loc);
+ while (target == null && parent != null)
+ {
+ if (parent.mouseListener != null
+ || parent.mouseMotionListener != null
+ || (parent.eventMask
+ & (AWTEvent.MOUSE_EVENT_MASK
+ | AWTEvent.MOUSE_MOTION_EVENT_MASK)) != 0)
+ {
+ target = parent;
+ }
+ else
+ parent = parent.getParent();
+ }
+ }
+ 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 = convertPointToChild(window, ev.getPoint(),
+ lastTarget);
+ MouseEvent mouseExited =
+ new MouseEvent(lastTarget, MouseEvent.MOUSE_EXITED,
+ ev.getWhen(), ev.getModifiers(), p1.x, p1.y,
+ ev.getClickCount(), ev.isPopupTrigger());
+ //System.err.println("event: " + mouseExited);
+ lastTarget.dispatchEvent(mouseExited);
+ }
+
+ // If a target exists dispatch the MOUSE_ENTERED event.
+ // Experimenting shows that the MOUSE_ENTERED is also dispatched
+ // when the mouse is dragging.
+ if (target != null)
+ {
+ Point p = convertPointToChild(window, ev.getPoint(), target);
+ MouseEvent mouseEntered =
+ new MouseEvent(target,
+ MouseEvent.MOUSE_ENTERED, ev.getWhen(),
+ ev.getModifiers(), p.x, p.y, ev.getClickCount(),
+ ev.isPopupTrigger());
+ //System.err.println("event: " + mouseEntered);
+ target.dispatchEvent(mouseEntered);
+ }
+ }
+
+ switch (ev.getID())
+ {
+ case MouseEvent.MOUSE_PRESSED:
+ // Handle the start of a drag operation or discard the event if
+ // one is already in progress. This prevents focus changes with the
+ // other mouse buttons when one is used for dragging.
+ if (dragTarget == null)
+ {
+ lastTarget = dragTarget = target;
+
+ // Save the button that started the drag operation.
+ dragButton = ev.getButton();
+ }
+ else
+ return false;
+
+ break;
+ case MouseEvent.MOUSE_RELEASED:
+ // Stop the drag operation only when the button that started
+ // it was released.
+ if (dragTarget != null && dragButton == ev.getButton())
+ {
+ // Only post MOUSE_RELEASED to dragTarget (set in
+ // MOUSE_PRESSED) when the dragTarget is actually visible.
+ // Otherwise post the event to the normal target.
+ if (dragTarget.isVisible())
+ target = dragTarget;
+ dragTarget = null;
+ }
+
+ lastTarget = target;
+ 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.
+ // This line is the reason why it is not possible to move the
+ // 'lastTarget = target' assignment before the switch-statement.
+ target = lastTarget;
+ break;
+ case MouseEvent.MOUSE_DRAGGED:
+ // We consider only dragTarget for redispatching the event still
+ // we have to act in a way that the newly found target component
+ // was handled.
+ lastTarget = target;
+ target = dragTarget;
+ break;
+ default:
+ // Only declare current target as the old value in all other
+ // cases.
+ lastTarget = target;
+ break;
+ }
+
+ if (target != null)
+ {
+ Point targetCoordinates = convertPointToChild(window,
+ ev.getPoint(),
+ 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);
+ }
+
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Finds the actual target for a mouseevent, starting at <code>c</code>.
+ * This searches through the children of the container and finds the first
+ * one which is showing, at the location from the mouse event and has
+ * a MouseListener or MouseMotionListener attached. If no such child component
+ * is found, null is returned.
+ *
+ * @param c the container to search through
+ * @param loc the mouse event point
+ *
+ * @return the actual receiver of the mouse event, or null, if no such
+ * component has been found
+ */
+ private Component findTarget(Container c, Point loc)
+ {
+ int numComponents = c.getComponentCount();
+ Component target = null;
+ if (c != null)
+ {
+ for (int i = 0; i < numComponents; i++)
+ {
+ Component child = c.getComponent(i);
+ if (child.isShowing())
+ {
+ if (child.contains(loc.x - child.getX(), loc.y - child.getY())
+ && (child.mouseListener != null
+ || child.mouseMotionListener != null
+ || (child.eventMask
+ & (AWTEvent.MOUSE_EVENT_MASK
+ | AWTEvent.MOUSE_MOTION_EVENT_MASK)) != 0))
+ {
+ target = child;
+ break;
+ }
+ }
+ }
+ }
+ return target;
+ }
+
+ /**
+ * Converts a point in the parent's coordinate system to a child coordinate
+ * system. The resulting point is stored in the same Point object and
+ * returned.
+ *
+ * @param parent the parent component
+ * @param p the point
+ * @param child the child component
+ *
+ * @return the translated point
+ */
+ private Point convertPointToChild(Component parent, Point p,
+ Component child)
+ {
+ int offX = 0;
+ int offY = 0;
+ Component comp = child;
+ while (comp != null && comp != parent)
+ {
+ offX += comp.getX();
+ offY += comp.getY();
+ comp = comp.getParent();
+ }
+ p.x -= offX;
+ p.y -= offY;
+ return p;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/List.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/List.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/List.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/List.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1289 @@
+/* List.java -- A listbox widget
+ Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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 java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.peer.ListPeer;
+import java.util.EventListener;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * Class that implements a listbox widget
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class List extends Component
+ implements ItemSelectable, Accessible
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_list_number;
+
+// Serialization constant
+private static final long serialVersionUID = -3304312411574666869L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+// FIXME: Need read/writeObject
+
+/**
+ * @serial The items in the list.
+ */
+private Vector items = new Vector();
+
+/**
+ * @serial Indicates whether or not multiple items can be selected
+ * simultaneously.
+ */
+private boolean multipleMode;
+
+/**
+ * @serial The number of rows in the list. This is set on creation
+ * only and cannot be modified.
+ */
+private int rows;
+
+/**
+ * @serial An array of the item indices that are selected.
+ */
+private int[] selected;
+
+/**
+ * @serial An index value used by <code>makeVisible()</code> and
+ * <code>getVisibleIndex</code>.
+ */
+private int visibleIndex;
+
+// The list of ItemListeners for this object.
+private ItemListener item_listeners;
+
+// The list of ActionListeners for this object.
+private ActionListener action_listeners;
+
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>List</code> with no visible lines
+ * and multi-select disabled.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+List()
+{
+ this(4, false);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>List</code> with the specified
+ * number of visible lines and multi-select disabled.
+ *
+ * @param rows The number of visible rows in the list.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+List(int rows)
+{
+ this(rows, false);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>List</code> with the specified
+ * number of lines and the specified multi-select setting.
+ *
+ * @param rows The number of visible rows in the list.
+ * @param multipleMode <code>true</code> if multiple lines can be selected
+ * simultaneously, <code>false</code> otherwise.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+List(int rows, boolean multipleMode)
+{
+ if (rows == 0)
+ this.rows = 4;
+ else
+ this.rows = rows;
+
+ this.multipleMode = multipleMode;
+ selected = new int[0];
+
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * Returns the number of items in this list.
+ *
+ * @return The number of items in this list.
+ */
+public int
+getItemCount()
+{
+ return countItems ();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the number of items in this list.
+ *
+ * @return The number of items in this list.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getItemCount()</code>
+ */
+public int
+countItems()
+{
+ return items.size ();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the complete list of items.
+ *
+ * @return The complete list of items in the list.
+ */
+public synchronized String[]
+getItems()
+{
+ String[] l_items = new String[getItemCount()];
+
+ items.copyInto(l_items);
+ return(l_items);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the item at the specified index.
+ *
+ * @param index The index of the item to retrieve.
+ *
+ * @exception IndexOutOfBoundsException If the index value is not valid.
+ */
+public String
+getItem(int index)
+{
+ return((String)items.elementAt(index));
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the number of visible rows in the list.
+ *
+ * @return The number of visible rows in the list.
+ */
+public int
+getRows()
+{
+ return(rows);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not multi-select mode is enabled.
+ *
+ * @return <code>true</code> if multi-select mode is enabled,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isMultipleMode()
+{
+ return allowsMultipleSelections ();
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not multi-select mode is enabled.
+ *
+ * @return <code>true</code> if multi-select mode is enabled,
+ * <code>false</code> otherwise.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>isMultipleMode()</code>.
+ */
+public boolean
+allowsMultipleSelections()
+{
+ return multipleMode;
+}
+
+/*************************************************************************/
+
+/**
+ * This method enables or disables multiple selection mode for this
+ * list.
+ *
+ * @param multipleMode <code>true</code> to enable multiple mode,
+ * <code>false</code> otherwise.
+ */
+public void
+setMultipleMode(boolean multipleMode)
+{
+ setMultipleSelections (multipleMode);
+}
+
+/*************************************************************************/
+
+/**
+ * This method enables or disables multiple selection mode for this
+ * list.
+ *
+ * @param multipleMode <code>true</code> to enable multiple mode,
+ * <code>false</code> otherwise.
+ *
+ * @deprecated
+ */
+public void
+setMultipleSelections(boolean multipleMode)
+{
+ this.multipleMode = multipleMode;
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.setMultipleMode (multipleMode);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the minimum size of this component.
+ *
+ * @return The minimum size of this component.
+ */
+public Dimension
+getMinimumSize()
+{
+ return getMinimumSize (getRows ());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the minimum size of this component.
+ *
+ * @return The minimum size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize</code>.
+ */
+public Dimension
+minimumSize()
+{
+ return minimumSize (getRows ());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the minimum size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The minimum size of this component.
+ */
+public Dimension
+getMinimumSize(int rows)
+{
+ return minimumSize (rows);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the minimum size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The minimum size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize(int)</code>>
+ */
+public Dimension
+minimumSize(int rows)
+{
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ return peer.minimumSize (rows);
+ else
+ return new Dimension (0, 0);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the preferred size of this component.
+ *
+ * @return The preferred size of this component.
+ */
+public Dimension
+getPreferredSize()
+{
+ return getPreferredSize (getRows ());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the preferred size of this component.
+ *
+ * @return The preferred size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize</code>.
+ */
+public Dimension
+preferredSize()
+{
+ return preferredSize (getRows ());
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the preferred size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The preferred size of this component.
+ */
+public Dimension
+getPreferredSize(int rows)
+{
+ return preferredSize (rows);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the preferred size of this component assuming it had the specified
+ * number of rows.
+ *
+ * @param rows The number of rows to size for.
+ *
+ * @return The preferred size of this component.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize(int)</code>>
+ */
+public Dimension
+preferredSize(int rows)
+{
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ return peer.preferredSize (rows);
+ else
+ return getSize();
+}
+
+/*************************************************************************/
+
+/**
+ * This method adds the specified item to the end of the list.
+ *
+ * @param item The item to add to the list.
+ */
+public void
+add(String item)
+{
+ add (item, -1);
+}
+
+/*************************************************************************/
+
+/**
+ * This method adds the specified item to the end of the list.
+ *
+ * @param item The item to add to the list.
+ *
+ * @deprecated Use add() instead.
+ */
+public void
+addItem(String item)
+{
+ addItem (item, -1);
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified item to the specified location in the list.
+ * If the desired index is -1 or greater than the number of rows
+ * in the list, then the item is added to the end.
+ *
+ * @param item The item to add to the list.
+ * @param index The location in the list to add the item, or -1 to add
+ * to the end.
+ */
+public void
+add(String item, int index)
+{
+ addItem (item, index);
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified item to the specified location in the list.
+ * If the desired index is -1 or greater than the number of rows
+ * in the list, then the item is added to the end.
+ *
+ * @param item The item to add to the list.
+ * @param index The location in the list to add the item, or -1 to add
+ * to the end.
+ *
+ * @deprecated Use add() instead.
+ */
+public void
+addItem(String item, int index)
+{
+ if ((index == -1) || (index >= items.size ()))
+ items.addElement (item);
+ else
+ items.insertElementAt (item, index);
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.add (item, index);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes the item at the specified index.
+ *
+ * @param index The index of the item to delete.
+ *
+ * @exception IllegalArgumentException If the index is not valid
+ *
+ * @deprecated
+ */
+public void
+delItem(int index) throws IllegalArgumentException
+{
+ items.removeElementAt (index);
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.delItems (index, index);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes the item at the specified index.
+ *
+ * @param index The index of the item to delete.
+ *
+ * @exception IllegalArgumentException If the index is not valid
+ */
+public void
+remove(int index) throws IllegalArgumentException
+{
+ delItem (index);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes all items in the specified index range.
+ *
+ * @param start The beginning index of the range to delete.
+ * @param end The ending index of the range to delete.
+ *
+ * @exception IllegalArgumentException If the indexes are not valid
+ *
+ * @deprecated This method is deprecated for some unknown reason.
+ */
+public synchronized void
+delItems(int start, int end) throws IllegalArgumentException
+{
+ if ((start < 0) || (start >= items.size()))
+ throw new IllegalArgumentException("Bad list start index value: " + start);
+
+ if ((start < 0) || (start >= items.size()))
+ throw new IllegalArgumentException("Bad list start index value: " + start);
+
+ if (start > end)
+ throw new IllegalArgumentException("Start is greater than end!");
+
+ // We must run the loop in reverse direction.
+ for (int i = end; i >= start; --i)
+ items.removeElementAt (i);
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ l.delItems (start, end);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes the first occurrence of the specified item from the list.
+ *
+ * @param item The item to delete.
+ *
+ * @exception IllegalArgumentException If the specified item does not exist.
+ */
+public synchronized void
+remove(String item) throws IllegalArgumentException
+{
+ int index = items.indexOf(item);
+ if (index == -1)
+ throw new IllegalArgumentException("List element to delete not found");
+
+ remove(index);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes all of the items from the list.
+ */
+public synchronized void
+removeAll()
+{
+ clear ();
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes all of the items from the list.
+ *
+ * @deprecated This method is deprecated in favor of <code>removeAll()</code>.
+ */
+public void
+clear()
+{
+ items.clear();
+
+ ListPeer peer = (ListPeer) getPeer ();
+ if (peer != null)
+ peer.removeAll ();
+}
+
+/*************************************************************************/
+
+/**
+ * Replaces the item at the specified index with the specified item.
+ *
+ * @param item The new item value.
+ * @param index The index of the item to replace.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index is not valid.
+ */
+public synchronized void
+replaceItem(String item, int index) throws ArrayIndexOutOfBoundsException
+{
+ if ((index < 0) || (index >= items.size()))
+ throw new ArrayIndexOutOfBoundsException("Bad list index: " + index);
+
+ items.insertElementAt(item, index + 1);
+ items.removeElementAt (index);
+
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+
+ /* We add first and then remove so that the selected
+ item remains the same */
+ l.add (item, index + 1);
+ l.delItems (index, index);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the index of the currently selected item. -1 will be returned
+ * if there are no selected rows or if there are multiple selected rows.
+ *
+ * @return The index of the selected row.
+ */
+public synchronized int
+getSelectedIndex()
+{
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ selected = l.getSelectedIndexes ();
+ }
+
+ if (selected == null || selected.length != 1)
+ return -1;
+ return selected[0];
+}
+
+/*************************************************************************/
+
+/**
+ * Returns an array containing the indexes of the rows that are
+ * currently selected.
+ *
+ * @return A list of indexes of selected rows.
+ */
+public synchronized int[]
+getSelectedIndexes()
+{
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ selected = l.getSelectedIndexes ();
+ }
+ return selected;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the item that is currently selected, or <code>null</code> if there
+ * is no item selected. FIXME: What happens if multiple items selected?
+ *
+ * @return The selected item, or <code>null</code> if there is no
+ * selected item.
+ */
+public synchronized String
+getSelectedItem()
+{
+ int index = getSelectedIndex();
+ if (index == -1)
+ return(null);
+
+ return((String)items.elementAt(index));
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the list of items that are currently selected in this list.
+ *
+ * @return The list of currently selected items.
+ */
+public synchronized String[]
+getSelectedItems()
+{
+ int[] indexes = getSelectedIndexes();
+ if (indexes == null)
+ return(new String[0]);
+
+ String[] retvals = new String[indexes.length];
+ if (retvals.length > 0)
+ for (int i = 0 ; i < retvals.length; i++)
+ retvals[i] = (String)items.elementAt(indexes[i]);
+
+ return(retvals);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the list of items that are currently selected in this list as
+ * an array of type <code>Object[]</code> instead of <code>String[]</code>.
+ *
+ * @return The list of currently selected items.
+ */
+public synchronized Object[]
+getSelectedObjects()
+{
+ int[] indexes = getSelectedIndexes();
+ if (indexes == null)
+ return(new Object[0]);
+
+ Object[] retvals = new Object[indexes.length];
+ if (retvals.length > 0)
+ for (int i = 0 ; i < retvals.length; i++)
+ retvals[i] = items.elementAt(indexes[i]);
+
+ return(retvals);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not the specified index is selected.
+ *
+ * @param index The index to test.
+ *
+ * @return <code>true</code> if the index is selected, <code>false</code>
+ * otherwise.
+ */
+public boolean
+isIndexSelected(int index)
+{
+ return isSelected (index);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not the specified index is selected.
+ *
+ * @param index The index to test.
+ *
+ * @return <code>true</code> if the index is selected, <code>false</code>
+ * otherwise.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>isIndexSelected(int)</code>.
+ */
+public boolean
+isSelected(int index)
+{
+ int[] indexes = getSelectedIndexes ();
+
+ for (int i = 0; i < indexes.length; i++)
+ if (indexes[i] == index)
+ return true;
+
+ return false;
+}
+
+/*************************************************************************/
+
+/**
+ * This method ensures that the item at the specified index is visible.
+ *
+ * @param index The index of the item to be made visible.
+ */
+public synchronized void
+makeVisible(int index) throws IllegalArgumentException
+{
+ visibleIndex = index;
+ if (peer != null)
+ {
+ ListPeer l = (ListPeer) peer;
+ l.makeVisible (index);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the index of the last item that was made visible via the
+ * <code>makeVisible()</code> method.
+ *
+ * @return The index of the last item made visible via the
+ * <code>makeVisible()</code> method.
+ */
+public int
+getVisibleIndex()
+{
+ return(visibleIndex);
+}
+
+/*************************************************************************/
+
+/**
+ * Makes the item at the specified index selected.
+ *
+ * @param index The index of the item to select.
+ */
+public synchronized void
+select(int index)
+{
+ ListPeer lp = (ListPeer)getPeer();
+ if (lp != null)
+ lp.select(index);
+}
+
+/*************************************************************************/
+
+/**
+ * Makes the item at the specified index not selected.
+ *
+ * @param index The index of the item to unselect.
+ */
+public synchronized void
+deselect(int index)
+{
+ ListPeer lp = (ListPeer)getPeer();
+ if (lp != null)
+ lp.deselect(index);
+}
+
+/*************************************************************************/
+
+/**
+ * Notifies this object to create its native peer.
+ */
+public void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit ().createList (this);
+ super.addNotify ();
+}
+
+/*************************************************************************/
+
+/**
+ * Notifies this object to destroy its native peer.
+ */
+public void
+removeNotify()
+{
+ super.removeNotify();
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified <code>ActionListener</code> to the list of
+ * registered listeners for this object.
+ *
+ * @param listener The listener to add.
+ */
+public synchronized void
+addActionListener(ActionListener listener)
+{
+ action_listeners = AWTEventMulticaster.add(action_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes the specified <code>ActionListener</code> from the list of
+ * registers listeners for this object.
+ *
+ * @param listener The listener to remove.
+ */
+public synchronized void
+removeActionListener(ActionListener listener)
+{
+ action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified <code>ItemListener</code> to the list of
+ * registered listeners for this object.
+ *
+ * @param listener The listener to add.
+ */
+public synchronized void
+addItemListener(ItemListener listener)
+{
+ item_listeners = AWTEventMulticaster.add(item_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes the specified <code>ItemListener</code> from the list of
+ * registers listeners for this object.
+ *
+ * @param listener The listener to remove.
+ */
+public synchronized void
+removeItemListener(ItemListener listener)
+{
+ item_listeners = AWTEventMulticaster.remove(item_listeners, listener);
+}
+
+/*************************************************************************/
+
+/**
+ * Processes the specified event for this object. If the event is an
+ * instance of <code>ActionEvent</code> then the
+ * <code>processActionEvent()</code> method is called. Similarly, if the
+ * even is an instance of <code>ItemEvent</code> then the
+ * <code>processItemEvent()</code> method is called. Otherwise the
+ * superclass method is called to process this event.
+ *
+ * @param event The event to process.
+ */
+protected void
+processEvent(AWTEvent event)
+{
+ if (event instanceof ActionEvent)
+ processActionEvent((ActionEvent)event);
+ else if (event instanceof ItemEvent)
+ processItemEvent((ItemEvent)event);
+ else
+ super.processEvent(event);
+}
+
+/*************************************************************************/
+
+/**
+ * This method processes the specified event by dispatching it to any
+ * registered listeners. Note that this method will only get called if
+ * action events are enabled. This will happen automatically if any
+ * listeners are added, or it can be done "manually" by calling
+ * the <code>enableEvents()</code> method.
+ *
+ * @param event The event to process.
+ */
+protected void
+processActionEvent(ActionEvent event)
+{
+ if (action_listeners != null)
+ action_listeners.actionPerformed(event);
+}
+
+/*************************************************************************/
+
+/**
+ * This method processes the specified event by dispatching it to any
+ * registered listeners. Note that this method will only get called if
+ * item events are enabled. This will happen automatically if any
+ * listeners are added, or it can be done "manually" by calling
+ * the <code>enableEvents()</code> method.
+ *
+ * @param event The event to process.
+ */
+protected void
+processItemEvent(ItemEvent event)
+{
+ if (item_listeners != null)
+ 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 if (e.id <= ActionEvent.ACTION_LAST
+ && e.id >= ActionEvent.ACTION_FIRST
+ && (action_listeners != null
+ || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+protected String
+paramString()
+{
+ return "multiple=" + multipleMode + ",rows=" + rows + super.paramString();
+}
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this <code>List</code>. FooListeners are registered using the
+ * addFooListener method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ if (listenerType == ActionListener.class)
+ return AWTEventMulticaster.getListeners (action_listeners, listenerType);
+
+ if (listenerType == ItemListener.class)
+ return AWTEventMulticaster.getListeners (item_listeners, listenerType);
+
+ return super.getListeners (listenerType);
+ }
+
+ /**
+ * Returns all action listeners registered to this object.
+ */
+ public ActionListener[] getActionListeners ()
+ {
+ return (ActionListener[]) getListeners (ActionListener.class);
+ }
+
+ /**
+ * Returns all action listeners registered to this object.
+ */
+ public ItemListener[] getItemListeners ()
+ {
+ return (ItemListener[]) getListeners (ItemListener.class);
+ }
+
+ // Accessibility internal class
+ protected class AccessibleAWTList extends AccessibleAWTComponent
+ implements AccessibleSelection, ItemListener, ActionListener
+ {
+ private static final long serialVersionUID = 7924617370136012829L;
+
+ protected class AccessibleAWTListChild extends AccessibleAWTComponent
+ implements Accessible
+ {
+ private static final long serialVersionUID = 4412022926028300317L;
+
+ // Field names are fixed by serialization spec.
+ private List parent;
+ private int indexInParent;
+
+ public AccessibleAWTListChild(List parent, int indexInParent)
+ {
+ this.parent = parent;
+ this.indexInParent = indexInParent;
+ if (parent == null)
+ this.indexInParent = -1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.Accessible#getAccessibleContext()
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ return this;
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.LIST_ITEM;
+ }
+
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ if (parent.isIndexSelected(indexInParent))
+ states.add(AccessibleState.SELECTED);
+ return states;
+ }
+
+ public int getAccessibleIndexInParent()
+ {
+ return indexInParent;
+ }
+
+ }
+
+ public AccessibleAWTList()
+ {
+ addItemListener(this);
+ addActionListener(this);
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.LIST;
+ }
+
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ states.add(AccessibleState.SELECTABLE);
+ if (isMultipleMode())
+ states.add(AccessibleState.MULTISELECTABLE);
+ return states;
+ }
+
+ public int getAccessibleChildrenCount()
+ {
+ return getItemCount();
+ }
+
+ public Accessible getAccessibleChild(int i)
+ {
+ if (i >= getItemCount())
+ return null;
+ return new AccessibleAWTListChild(List.this, i);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#getAccessibleSelectionCount()
+ */
+ public int getAccessibleSelectionCount()
+ {
+ return getSelectedIndexes().length;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#getAccessibleSelection()
+ */
+ public AccessibleSelection getAccessibleSelection()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#getAccessibleSelection(int)
+ */
+ public Accessible getAccessibleSelection(int i)
+ {
+ int[] items = getSelectedIndexes();
+ if (i >= items.length)
+ return null;
+ return new AccessibleAWTListChild(List.this, items[i]);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#isAccessibleChildSelected(int)
+ */
+ public boolean isAccessibleChildSelected(int i)
+ {
+ return isIndexSelected(i);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#addAccessibleSelection(int)
+ */
+ public void addAccessibleSelection(int i)
+ {
+ select(i);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#removeAccessibleSelection(int)
+ */
+ public void removeAccessibleSelection(int i)
+ {
+ deselect(i);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#clearAccessibleSelection()
+ */
+ public void clearAccessibleSelection()
+ {
+ for (int i = 0; i < getItemCount(); i++)
+ deselect(i);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleSelection#selectAllAccessibleSelection()
+ */
+ public void selectAllAccessibleSelection()
+ {
+ if (isMultipleMode())
+ for (int i = 0; i < getItemCount(); i++)
+ select(i);
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+ */
+ public void itemStateChanged(ItemEvent event)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ }
+
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>List</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 AccessibleAWTList();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this <code>List</code>.
+ *
+ * @return A unique name for this <code>List</code>.
+ */
+ String generateName()
+ {
+ return "list" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_list_number++;
+ }
+} // class List
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MediaTracker.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MediaTracker.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MediaTracker.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MediaTracker.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,698 @@
+/* MediaTracker.java -- Class used for keeping track of images
+ Copyright (C) 1999, 2002, 2004, 2005 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 java.awt.image.ImageObserver;
+import java.util.ArrayList;
+
+/**
+ * This class is used for keeping track of the status of various media
+ * objects.
+ *
+ * Media objects are tracked by assigning them an ID. It is possible
+ * to assign the same ID to mutliple objects, effectivly grouping them
+ * together. In this case the status flags ({@link #statusID}) and error flag
+ * (@link #isErrorID} and {@link #getErrorsID}) are ORed together. This
+ * means that you cannot say exactly which media object has which status,
+ * at most you can say that there <em>are</em> certain media objects with
+ * some certain status.
+ *
+ * At the moment only images are supported by this class.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Bryce McKinlay
+ */
+public class MediaTracker implements java.io.Serializable
+{
+ /** Indicates that the media is still loading. */
+ public static final int LOADING = 1 << 0;
+
+ /** Indicates that the loading operation has been aborted. */
+ public static final int ABORTED = 1 << 1;
+
+ /** Indicates that an error has occured during loading of the media. */
+ public static final int ERRORED = 1 << 2;
+
+ /** Indicates that the media has been successfully and completely loaded. */
+ public static final int COMPLETE = 1 << 3;
+
+ /** The component on which the media is eventually been drawn. */
+ Component target;
+
+ /** The head of the linked list of tracked media objects. */
+ MediaEntry head;
+
+ /** Our serialVersionUID for serialization. */
+ static final long serialVersionUID = -483174189758638095L;
+
+ /**
+ * This represents a media object that is tracked by a MediaTracker.
+ * It also implements a simple linked list.
+ */
+ // FIXME: The serialized form documentation says MediaEntry is a
+ // serializable field, but the serialized form of MediaEntry itself
+ // doesn't appear to be documented.
+ class MediaEntry implements ImageObserver
+ {
+ /** The ID of the media object. */
+ int id;
+
+ /** The media object. (only images are supported ATM). */
+ Image image;
+
+ /** The link to the next entry in the list. */
+ MediaEntry next;
+
+ /** The tracking status. */
+ int status;
+
+ /** The width of the image. */
+ int width;
+
+ /** The height of the image. */
+ int height;
+
+ /**
+ * Receives notification from an {@link java.awt.image.ImageProducer}
+ * that more data of the image is available.
+ *
+ * @param img the image that is updated
+ * @param flags flags from the ImageProducer that indicate the status
+ * of the loading process
+ * @param x the X coordinate of the upper left corner of the image
+ * @param y the Y coordinate of the upper left corner of the image
+ * @param width the width of the image
+ * @param height the height of the image
+ *
+ * @return <code>true</code> if more data is needed, <code>false</code>
+ * otherwise
+ *
+ * @see java.awt.image.ImageObserver
+ */
+ public boolean imageUpdate(Image img, int flags, int x, int y,
+ int width, int height)
+ {
+ if ((flags & ABORT) != 0)
+ status = ABORTED;
+ else if ((flags & ERROR) != 0)
+ status = ERRORED;
+ else if ((flags & ALLBITS) != 0)
+ status = COMPLETE;
+ else
+ status = 0;
+
+ synchronized (MediaTracker.this)
+ {
+ MediaTracker.this.notifyAll();
+ }
+
+ // If status is not COMPLETE then we need more updates.
+ return ((status & (COMPLETE | ERRORED | ABORTED)) == 0);
+ }
+ }
+
+ /**
+ * Constructs a new MediaTracker for the component <code>c</code>. The
+ * component should be the component that uses the media (i.e. draws it).
+ *
+ * @param c the Component that wants to use the media
+ */
+ public MediaTracker(Component c)
+ {
+ target = c;
+ }
+
+ /**
+ * Adds an image to the tracker with the specified <code>ID</code>.
+ *
+ * @param image the image to be added
+ * @param id the ID of the tracker list to which the image is added
+ */
+ public void addImage(Image image, int id)
+ {
+ MediaEntry e = new MediaEntry();
+ e.id = id;
+ e.image = image;
+ synchronized(this)
+ {
+ e.next = head;
+ head = e;
+ }
+ }
+
+ /**
+ * Adds an image to the tracker with the specified <code>ID</code>.
+ * The image is expected to be rendered with the specified width and
+ * height.
+ *
+ * @param image the image to be added
+ * @param id the ID of the tracker list to which the image is added
+ * @param width the width of the image
+ * @param height the height of the image
+ */
+ public void addImage(Image image, int id, int width, int height)
+ {
+ MediaEntry e = new MediaEntry();
+ e.id = id;
+ e.image = image;
+ e.width = width;
+ e.height = height;
+ synchronized(this)
+ {
+ e.next = head;
+ head = e;
+ }
+ }
+
+ /**
+ * Checks if all media objects have finished loading, i.e. are
+ * {@link #COMPLETE}, {@link #ABORTED} or {@link #ERRORED}.
+ *
+ * If the media objects are not already loading, a call to this
+ * method does <em>not</em> start loading. This is equivalent to
+ * a call to <code>checkAll(false)</code>.
+ *
+ * @return if all media objects have finished loading either by beeing
+ * complete, have been aborted or errored.
+ */
+ public boolean checkAll()
+ {
+ return checkAll(false);
+ }
+
+ /**
+ * Checks if all media objects have finished loading, i.e. are
+ * {@link #COMPLETE}, {@link #ABORTED} or {@link #ERRORED}.
+ *
+ * If the media objects are not already loading, and <code>load</code>
+ * is <code>true</code> then a call to this
+ * method starts loading the media objects.
+ *
+ * @param load if <code>true</code> this method starts loading objects
+ * that are not already loading
+ *
+ * @return if all media objects have finished loading either by beeing
+ * complete, have been aborted or errored.
+ */
+ public boolean checkAll(boolean load)
+ {
+ MediaEntry e = head;
+ boolean result = true;
+
+ while (e != null)
+ {
+ if ((e.status & (COMPLETE | ERRORED | ABORTED)) == 0)
+ {
+ if (load && ((e.status & LOADING) == 0))
+ {
+ if (target.prepareImage(e.image, e))
+ e.status = COMPLETE;
+ else
+ {
+ e.status = LOADING;
+ int flags = target.checkImage(e.image, e);
+ if ((flags & ImageObserver.ABORT) != 0)
+ e.status = ABORTED;
+ else if ((flags & ImageObserver.ERROR) != 0)
+ e.status = ERRORED;
+ else if ((flags & ImageObserver.ALLBITS) != 0)
+ e.status = COMPLETE;
+ }
+ boolean complete = (e.status
+ & (COMPLETE | ABORTED | ERRORED)) != 0;
+ if (!complete)
+ result = false;
+ }
+ else
+ result = false;
+ }
+ e = e.next;
+ }
+ return result;
+ }
+
+ /**
+ * Checks if any of the registered media objects has encountered an error
+ * during loading.
+ *
+ * @return <code>true</code> if at least one media object has encountered
+ * an error during loading, <code>false</code> otherwise
+ *
+ */
+ public boolean isErrorAny()
+ {
+ MediaEntry e = head;
+ while (e != null)
+ {
+ if ((e.status & ERRORED) != 0)
+ return true;
+ e = e.next;
+ }
+ return false;
+ }
+
+ /**
+ * Returns all media objects that have encountered errors during loading.
+ *
+ * @return an array of all media objects that have encountered errors
+ * or <code>null</code> if there were no errors at all
+ */
+ public Object[] getErrorsAny()
+ {
+ MediaEntry e = head;
+ ArrayList result = null;
+ while (e != null)
+ {
+ if ((e.status & ERRORED) != 0)
+ {
+ if (result == null)
+ result = new ArrayList();
+ result.add(e.image);
+ }
+ e = e.next;
+ }
+ if (result == null)
+ return null;
+ else
+ return result.toArray();
+ }
+
+ /**
+ * Waits for all media objects to finish loading, either by completing
+ * successfully or by aborting or encountering an error.
+ *
+ * @throws InterruptedException if another thread interrupted the
+ * current thread while waiting
+ */
+ public void waitForAll() throws InterruptedException
+ {
+ synchronized (this)
+ {
+ while (checkAll(true) == false)
+ wait();
+ }
+ }
+
+ /**
+ * Waits for all media objects to finish loading, either by completing
+ * successfully or by aborting or encountering an error.
+ *
+ * This method waits at most <code>ms</code> milliseconds. If the
+ * media objects have not completed loading within this timeframe, this
+ * method returns <code>false</code>, otherwise <code>true</code>.
+ *
+ * @param ms timeframe in milliseconds to wait for the media objects to
+ * finish
+ *
+ * @return <code>true</code> if all media objects have successfully loaded
+ * within the timeframe, <code>false</code> otherwise
+ *
+ * @throws InterruptedException if another thread interrupted the
+ * current thread while waiting
+ */
+ public boolean waitForAll(long ms) throws InterruptedException
+ {
+ long start = System.currentTimeMillis();
+ boolean result = checkAll(true);
+ synchronized (this)
+ {
+ while (result == false)
+ {
+ wait(ms);
+ result = checkAll(true);
+ if ((System.currentTimeMillis() - start) > ms)
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the status flags of all registered media objects ORed together.
+ * If <code>load</code> is <code>true</code> then media objects that
+ * are not already loading will be started to load.
+ *
+ * @param load if set to <code>true</code> then media objects that are
+ * not already loading are started
+ *
+ * @return the status flags of all tracked media objects ORed together
+ */
+ public int statusAll(boolean load)
+ {
+ int result = 0;
+ MediaEntry e = head;
+ while (e != null)
+ {
+ if (load && e.status == 0)
+ {
+ if (target.prepareImage(e.image, e))
+ e.status = COMPLETE;
+ else
+ {
+ e.status = LOADING;
+ int flags = target.checkImage(e.image, e);
+ if ((flags & ImageObserver.ABORT) != 0)
+ e.status = ABORTED;
+ else if ((flags & ImageObserver.ERROR) != 0)
+ e.status = ERRORED;
+ else if ((flags & ImageObserver.ALLBITS) != 0)
+ e.status = COMPLETE;
+ }
+ }
+ result |= e.status;
+ e = e.next;
+ }
+ return result;
+ }
+
+ /**
+ * Checks if the media objects with <code>ID</code> have completed loading.
+ *
+ * @param id the ID of the media objects to check
+ *
+ * @return <code>true</code> if all media objects with <code>ID</code>
+ * have successfully finished
+ */
+ public boolean checkID(int id)
+ {
+ return checkID(id, false);
+ }
+
+ /**
+ * Checks if the media objects with <code>ID</code> have completed loading.
+ * If <code>load</code> is <code>true</code> then media objects that
+ * are not already loading will be started to load.
+ *
+ * @param id the ID of the media objects to check
+ * @param load if set to <code>true</code> then media objects that are
+ * not already loading are started
+ *
+ * @return <code>true</code> if all media objects with <code>ID</code>
+ * have successfully finished
+ */
+ public boolean checkID(int id, boolean load)
+ {
+ MediaEntry e = head;
+ boolean result = true;
+
+ while (e != null)
+ {
+ if (e.id == id && ((e.status & (COMPLETE | ABORTED | ERRORED)) == 0))
+ {
+ if (load && ((e.status & LOADING) == 0))
+ {
+ e.status = LOADING;
+ if (target.prepareImage(e.image, e))
+ e.status = COMPLETE;
+ else
+ {
+ int flags = target.checkImage(e.image, e);
+ if ((flags & ImageObserver.ABORT) != 0)
+ e.status = ABORTED;
+ else if ((flags & ImageObserver.ERROR) != 0)
+ e.status = ERRORED;
+ else if ((flags & ImageObserver.ALLBITS) != 0)
+ e.status = COMPLETE;
+ }
+ boolean complete = (e.status
+ & (COMPLETE | ABORTED | ERRORED)) != 0;
+ if (!complete)
+ result = false;
+ }
+ else
+ result = false;
+ }
+ e = e.next;
+ }
+ return result;
+ }
+
+ /**
+ * Returns <code>true</code> if any of the media objects with <code>ID</code>
+ * have encountered errors during loading, false otherwise.
+ *
+ * @param id the ID of the media objects to check
+ *
+ * @return <code>true</code> if any of the media objects with <code>ID</code>
+ * have encountered errors during loading, false otherwise
+ */
+ public boolean isErrorID(int id)
+ {
+ MediaEntry e = head;
+ while (e != null)
+ {
+ if (e.id == id && ((e.status & ERRORED) != 0))
+ return true;
+ e = e.next;
+ }
+ return false;
+ }
+
+ /**
+ * Returns all media objects with the specified ID that have encountered
+ * an error.
+ *
+ * @param id the ID of the media objects to check
+ *
+ * @return an array of all media objects with the specified ID that
+ * have encountered an error
+ */
+ public Object[] getErrorsID(int id)
+ {
+ MediaEntry e = head;
+ ArrayList result = null;
+ while (e != null)
+ {
+ if (e.id == id && ((e.status & ERRORED) != 0))
+ {
+ if (result == null)
+ result = new ArrayList();
+ result.add(e.image);
+ }
+ e = e.next;
+ }
+ if (result == null)
+ return null;
+ else
+ return result.toArray();
+ }
+
+ /**
+ * Waits for all media objects with the specified ID to finish loading,
+ * either by completing successfully or by aborting or encountering an error.
+ *
+ * @param id the ID of the media objects to wait for
+ *
+ * @throws InterruptedException if another thread interrupted the
+ * current thread while waiting
+ */
+ public void waitForID(int id) throws InterruptedException
+ {
+ MediaEntry e = head;
+ synchronized (this)
+ {
+ while (checkID (id, true) == false)
+ wait();
+ }
+ }
+
+ /**
+ * Waits for all media objects with the specified ID to finish loading,
+ * either by completing successfully or by aborting or encountering an error.
+ *
+ * This method waits at most <code>ms</code> milliseconds. If the
+ * media objects have not completed loading within this timeframe, this
+ * method returns <code>false</code>, otherwise <code>true</code>.
+ *
+ * @param id the ID of the media objects to wait for
+ * @param ms timeframe in milliseconds to wait for the media objects to
+ * finish
+ *
+ * @return <code>true</code> if all media objects have successfully loaded
+ * within the timeframe, <code>false</code> otherwise
+ *
+ * @throws InterruptedException if another thread interrupted the
+ * current thread while waiting
+ */
+ public boolean waitForID(int id, long ms) throws InterruptedException
+ {
+ MediaEntry e = head;
+ long start = System.currentTimeMillis();
+ boolean result = checkID(id, true);
+
+ synchronized (this)
+ {
+ while (result == false)
+ {
+ wait(ms);
+ result = checkID(id, true);
+ if ((System.currentTimeMillis() - start) > ms)
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the status flags of the media objects with the specified ID
+ * ORed together.
+ *
+ * If <code>load</code> is <code>true</code> then media objects that
+ * are not already loading will be started to load.
+ *
+ * @param load if set to <code>true</code> then media objects that are
+ * not already loading are started
+ *
+ * @return the status flags of all tracked media objects ORed together
+ */
+ public int statusID(int id, boolean load)
+ {
+ int result = 0;
+ MediaEntry e = head;
+ while (e != null)
+ {
+ if (e.id == id)
+ {
+ if (load && e.status == 0)
+ {
+ if (target.prepareImage(e.image, e))
+ e.status = COMPLETE;
+ else
+ {
+ e.status = LOADING;
+ int flags = target.checkImage(e.image, e);
+ if ((flags & ImageObserver.ABORT) != 0)
+ e.status = ABORTED;
+ else if ((flags & ImageObserver.ERROR) != 0)
+ e.status = ERRORED;
+ else if ((flags & ImageObserver.ALLBITS) != 0)
+ e.status = COMPLETE;
+ }
+ }
+ result |= e.status;
+ }
+ e = e.next;
+ }
+ return result;
+ }
+
+ /**
+ * Removes an image from this MediaTracker.
+ *
+ * @param image the image to be removed
+ */
+ public void removeImage(Image image)
+ {
+ synchronized (this)
+ {
+ MediaEntry e = head;
+ MediaEntry prev = null;
+ while (e != null)
+ {
+ if (e.image == image)
+ {
+ if (prev == null)
+ head = e.next;
+ else
+ prev.next = e.next;
+ }
+ else
+ prev = e;
+ e = e.next;
+ }
+ }
+ }
+
+ /**
+ * Removes an image with the specified ID from this MediaTracker.
+ *
+ * @param image the image to be removed
+ */
+ public void removeImage(Image image, int id)
+ {
+ synchronized (this)
+ {
+ MediaEntry e = head;
+ MediaEntry prev = null;
+ while (e != null)
+ {
+ if (e.id == id && e.image == image)
+ {
+ if (prev == null)
+ head = e.next;
+ else
+ prev.next = e.next;
+ }
+ else
+ prev = e;
+ e = e.next;
+ }
+ }
+ }
+
+ /**
+ * Removes an image with the specified ID and scale from this MediaTracker.
+ *
+ * @param image the image to be removed
+ */
+ public void removeImage(Image image, int id, int width, int height)
+ {
+ synchronized (this)
+ {
+ MediaEntry e = head;
+ MediaEntry prev = null;
+ while (e != null)
+ {
+ if (e.id == id && e.image == image
+ && e.width == width && e.height == height)
+ {
+ if (prev == null)
+ head = e.next;
+ else
+ prev.next = e.next;
+ }
+ else
+ prev = e;
+ e = e.next;
+ }
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Menu.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Menu.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Menu.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Menu.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,509 @@
+/* Menu.java -- A Java AWT Menu
+ Copyright (C) 1999, 2002, 2004, 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 java.awt.peer.MenuPeer;
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * This class represents a pull down or tear off menu in Java's AWT.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class Menu extends MenuItem implements MenuContainer, Serializable
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_menu_number;
+
+// Serialization Constant
+private static final long serialVersionUID = -8809584163345499784L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The actual items in the menu
+ */
+private Vector items = new Vector();
+
+/**
+ * @serial Flag indicating whether or not this menu is a tear off
+ */
+private boolean tearOff;
+
+/**
+ * @serial Indicates whether or not this is a help menu.
+ */
+private boolean isHelpMenu;
+
+ /*
+ * @serial Unused in this implementation, but present in Sun's
+ * serialization spec. Value obtained via reflection.
+ */
+ private int menuSerializedDataVersion = 1;
+
+static final transient String separatorLabel = "-";
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>Menu</code> with no label and that
+ * is not a tearoff;
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+Menu()
+{
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Menu</code> that is not a tearoff and
+ * that has the specified label.
+ *
+ * @param label The menu label.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+Menu(String label)
+{
+ this(label, false);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>Menu</code> with the specified
+ * label and tearoff status.
+ *
+ * @param label The label for this menu
+ * @param isTearOff <code>true</code> if this menu is a tear off menu,
+ * <code>false</code> otherwise.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+Menu(String label, boolean isTearOff)
+{
+ super(label);
+
+ tearOff = isTearOff;
+
+ if (label.equals("Help"))
+ isHelpMenu = true;
+
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Tests whether or not this menu is a tearoff.
+ *
+ * @return <code>true</code> if this menu is a tearoff, <code>false</code>
+ * otherwise.
+ */
+public boolean
+isTearOff()
+{
+ return(tearOff);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the number of items in this menu.
+ *
+ * @return The number of items in this menu.
+ */
+public int
+getItemCount()
+{
+ return countItems ();
+}
+
+/**
+ * Returns the number of items in this menu.
+ *
+ * @return The number of items in this menu.
+ *
+ * @deprecated As of JDK 1.1, replaced by getItemCount().
+ */
+public int countItems ()
+{
+ return items.size ();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the item at the specified index.
+ *
+ * @return The item at the specified index.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index value is not valid.
+ */
+public MenuItem
+getItem(int index)
+{
+ return((MenuItem)items.elementAt(index));
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified item to this menu. If it was previously part of
+ * another menu, it is first removed from that menu.
+ *
+ * @param item The new item to add.
+ *
+ * @return The item that was added.
+ */
+public MenuItem
+add(MenuItem item)
+{
+ MenuContainer parent = item.getParent();
+ if (parent != null)
+ parent.remove(item);
+
+ items.addElement(item);
+ item.setParent(this);
+
+ if (peer != null)
+ {
+ item.addNotify();
+ MenuPeer mp = (MenuPeer) peer;
+ mp.addItem(item);
+ }
+
+ return item;
+}
+
+/*************************************************************************/
+
+/**
+ * Add an item with the specified label to this menu.
+ *
+ * @param label The label of the menu item to add.
+ */
+public void
+add(String label)
+{
+ add(new MenuItem(label));
+}
+
+/*************************************************************************/
+
+/**
+ * Inserts the specified menu item into this menu at the specified index.
+ *
+ * @param item The menu item to add.
+ * @param index The index of the menu item.
+ *
+ * @exception IllegalArgumentException If the index is less than zero.
+ * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
+ */
+public void
+insert(MenuItem item, int index)
+{
+ if (index < 0)
+ throw new IllegalArgumentException("Index is less than zero");
+
+ int count = getItemCount ();
+
+ if (index >= count)
+ add(item);
+ else
+ {
+ MenuContainer parent = item.getParent();
+ if (parent != null)
+ parent.remove(item);
+
+ items.insertElementAt(item, index);
+ item.setParent(this);
+
+ 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));
+ }
+
+}
+
+/*************************************************************************/
+
+/**
+ * Inserts an item with the specified label into this menu at the specified index.
+ *
+ * @param label The label of the item to add.
+ * @param index The index of the menu item.
+ *
+ * @exception IllegalArgumentException If the index is less than zero.
+ * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
+ */
+public void
+insert(String label, int index)
+{
+ insert(new MenuItem(label), index);
+}
+
+/*************************************************************************/
+
+/**
+ * Adds a separator bar at the current menu location.
+ */
+public void
+addSeparator()
+{
+ add(new MenuItem(separatorLabel));
+}
+
+/*************************************************************************/
+
+/**
+ * Inserts a separator bar at the specified index value.
+ *
+ * @param index The index at which to insert a separator bar.
+ *
+ * @exception IllegalArgumentException If the index is less than zero.
+ * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
+ */
+public void
+insertSeparator(int index)
+{
+ insert(new MenuItem(separatorLabel), index);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes the item at the specified index from this menu.
+ *
+ * @param index The index of the item to remove.
+ *
+ * @exception ArrayIndexOutOfBoundsException If the index is otherwise invalid.
+ */
+public synchronized void
+remove(int index)
+{
+ MenuItem item = (MenuItem) items.remove(index);
+
+ MenuPeer mp = (MenuPeer) getPeer();
+ if (mp != null)
+ {
+ mp.delItem(index);
+ item.removeNotify();
+ }
+ item.setParent(null);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes the specifed item from the menu. If the specified component
+ * does not exist, this method does nothing.
+ *
+ * @param item The component to remove.
+ */
+public void
+remove(MenuComponent item)
+{
+ int index = items.indexOf(item);
+ if (index == -1)
+ return;
+
+ remove(index);
+}
+
+/*************************************************************************/
+
+/**
+ * Removes all the elements from this menu.
+ */
+public synchronized void
+removeAll()
+{
+ int count = getItemCount();
+ for(int i = 0; i < count; i++)
+ {
+ // We must always remove item 0.
+ remove(0);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Creates the native peer for this object.
+ */
+public void
+addNotify()
+{
+ MenuPeer peer = (MenuPeer) getPeer();
+ if (peer == null)
+ {
+ 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 ();
+}
+
+/*************************************************************************/
+
+/**
+ * Destroys the native peer for this object.
+ */
+public void
+removeNotify()
+{
+ Enumeration e = items.elements();
+ while (e.hasMoreElements())
+ {
+ MenuItem mi = (MenuItem) e.nextElement();
+ mi.removeNotify();
+ }
+ super.removeNotify();
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this menu.
+ *
+ * @return A debugging string for this menu.
+ */
+public String
+paramString()
+{
+ return (",tearOff=" + tearOff + ",isHelpMenu=" + isHelpMenu
+ + super.paramString());
+}
+
+ /**
+ * Basic Accessibility class for Menu. Details get provided in derived
+ * classes.
+ */
+ protected class AccessibleAWTMenu extends AccessibleAWTMenuItem
+ {
+ private static final long serialVersionUID = 5228160894980069094L;
+
+ protected AccessibleAWTMenu()
+ {
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.MENU;
+ }
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Menu</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 AccessibleAWTMenu();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this <code>Menu</code>.
+ *
+ * @return A unique name for this <code>Menu</code>.
+ */
+ String generateName()
+ {
+ return "menu" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_menu_number++;
+ }
+
+} // class Menu
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuBar.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuBar.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuBar.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuBar.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,390 @@
+/* MenuBar.java -- An AWT menu bar class
+ Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 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 java.awt.peer.MenuBarPeer;
+
+import java.io.Serializable;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * This class implements a menu bar in the AWT system.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at redhat.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+public class MenuBar extends MenuComponent
+ implements MenuContainer, Serializable, Accessible
+{
+
+ // Serialization Constant
+ private static final long serialVersionUID = -4930327919388951260L;
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menubar_number;
+
+ /**
+ * @serial The menu used for providing help information
+ */
+ private Menu helpMenu;
+
+ /**
+ * @serial The menus contained in this menu bar.
+ */
+ private Vector menus = new Vector();
+
+ /**
+ * Initializes a new instance of <code>MenuBar</code>.
+ *
+ * @throws HeadlessException if GraphicsEnvironment.isHeadless() is true
+ */
+ public MenuBar()
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ }
+
+ /**
+ * 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)
+ {
+ 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);
+ }
+ }
+
+ /**
+ * 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 ();
+
+ MenuContainer parent = menu.getParent();
+ if (parent != null)
+ parent.remove(menu);
+
+ menus.addElement(menu);
+ menu.setParent(this);
+
+ 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();
+
+ if (mp != null)
+ m.removeNotify();
+
+ m.setParent(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;
+
+ 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
+ *
+ * @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;
+ }
+
+ /**
+ * Generate a unique name for this <code>MenuBar</code>.
+ *
+ * @return A unique name for this <code>MenuBar</code>.
+ */
+ String generateName()
+ {
+ return "menubar" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_menubar_number++;
+ }
+
+ /**
+ * This class provides accessibility support for AWT menu bars.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+ protected class AccessibleAWTMenuBar
+ extends AccessibleAWTMenuComponent
+ {
+
+ /**
+ * 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;
+ }
+
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuComponent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuComponent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuComponent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuComponent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1302 @@
+/* MenuComponent.java -- Superclass of all AWT menu components
+ Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 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 java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.peer.MenuComponentPeer;
+import java.io.Serializable;
+import java.util.Locale;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleComponent;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleSelection;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * This is the superclass of all menu AWT widgets.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+public abstract class MenuComponent implements Serializable
+{
+
+//Serialization Constant
+ private static final long serialVersionUID = -4536902356223894379L;
+
+ /**
+ * The font for this component.
+ *
+ * @see #getFont()
+ * @see #setFont(java.awt.Font)
+ * @serial the component's font.
+ */
+ private Font font;
+
+ /**
+ * The name of the component.
+ *
+ * @see #getName()
+ * @see #setName(String)
+ * @serial the component's name.
+ */
+ private String name;
+
+ /**
+ * The parent of this component.
+ *
+ * @see #getParent()
+ * @see #setParent(java.awt.MenuContainer)
+ * @serial ignored.
+ */
+ transient MenuContainer parent;
+
+ /**
+ * The native peer for this component.
+ *
+ * @see #getPeer()
+ * @see #setPeer(java.awt.peer.MenuComponentPeer)
+ * @serial ignored.
+ */
+ transient MenuComponentPeer peer;
+
+ /**
+ * The synchronization locking object for this component.
+ *
+ * @serial ignored.
+ */
+ private transient Object tree_lock = this;
+
+ /**
+ * The toolkit for this object.
+ *
+ * @see #getToolkit()
+ * @serial ignored.
+ */
+ private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
+
+ /**
+ * The accessible context for this component.
+ *
+ * @see #getAccessibleContext()
+ * @serial the accessibility information for this component.
+ */
+ AccessibleContext accessibleContext;
+
+ /**
+ * Was the name of the component set? This value defaults
+ * to false and becomes true after a call to <code>setName()</code>.
+ * Please note that this does not guarantee that name will then
+ * be non-null, as this may be the value passed to <code>setName()</code>.
+ *
+ * @see #setName(String)
+ * @serial true if the name value has been explicitly set by calling
+ * <code>setName()</code>.
+ */
+ private boolean nameExplicitlySet;
+
+ /**
+ * Does this component handle new events? Events will be handled
+ * by this component if this is true. Otherwise, they will be forwarded
+ * up the component hierarchy. This implementation does not use this
+ * variable; it is merely provided for serialization compatability.
+ *
+ * @see #dispatchEvent(AWTEvent)
+ * @serial true if events are to be processed locally. Unused.
+ */
+ private boolean newEventsOnly;
+
+ /**
+ * The focus listener chain handler which deals with focus events for
+ * the accessible context of this component.
+ *
+ * @see AccessibleAWTMenuComponent#addFocusListener(java.awt.event.FocusListener)
+ * @serial ignored.
+ * This is package-private to avoid an accessor method.
+ */
+ transient FocusListener focusListener;
+
+ /**
+ * Default constructor for subclasses.
+ *
+ * @throws HeadlessException ff GraphicsEnvironment.isHeadless() is true
+ */
+ public MenuComponent()
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+ }
+
+/**
+ * Returns the font in use for this component.
+ *
+ * @return the font for this component
+ */
+ public Font getFont()
+ {
+ if (font != null)
+ return font;
+
+ if (parent != null)
+ return parent.getFont();
+
+ return null;
+ }
+
+ /**
+ * Sets the font for this component to the specified font.
+ *
+ * @param font the new font for this component
+ */
+ public void setFont(Font font)
+ {
+ this.font = font;
+ }
+
+ /**
+ * Returns the name of this component.
+ *
+ * @return the name of this component
+ */
+ public String getName()
+ {
+ if (name == null && ! nameExplicitlySet)
+ name = generateName();
+ return name;
+ }
+
+ /**
+ * Subclasses should override this to return unique component names like
+ * "menuitem0".
+ *
+ * @return the generated name for this menu component
+ */
+ String generateName()
+ {
+ // MenuComponent is abstract.
+ return null;
+ }
+
+ /**
+ * Sets the name of this component to the specified name.
+ *
+ * @param name the new name of this component
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ nameExplicitlySet = true;
+ }
+
+ /**
+ * Returns the parent of this component.
+ *
+ * @return the parent of this component
+ */
+ public MenuContainer getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Sets the parent of this component.
+ *
+ * @param parent the parent to set
+ */
+ final void setParent(MenuContainer parent)
+ {
+ this.parent = parent;
+ }
+
+ /**
+ * Returns the native windowing system peer for this component.
+ *
+ * @return the peer for this component
+ *
+ * @deprecated
+ */
+ public MenuComponentPeer getPeer()
+ {
+ return peer;
+ }
+
+ /**
+ * Sets the peer for this component.
+ *
+ * @param peer the peer to set
+ */
+ final void setPeer(MenuComponentPeer peer)
+ {
+ this.peer = peer;
+ }
+
+ /**
+ * Destroys this component's native peer
+ */
+ public void removeNotify()
+ {
+ if (peer != null)
+ peer.dispose();
+ peer = null;
+ }
+
+ /**
+ * Returns the toolkit in use for this component.
+ *
+ * @return the toolkit for this component
+ */
+ final Toolkit getToolkit()
+ {
+ return toolkit;
+ }
+
+ /**
+ * Returns the object used for synchronization locks on this component
+ * when performing tree and layout functions.
+ *
+ * @return the synchronization lock for this component
+ */
+ protected final Object getTreeLock()
+ {
+ return tree_lock;
+ }
+
+ /**
+ * Sets the sync lock object for this component.
+ *
+ * @param treeLock the sync lock to set
+ */
+ final void setTreeLock(Object treeLock)
+ {
+ this.tree_lock = treeLock;
+ }
+
+ /**
+ * AWT 1.0 event dispatcher.
+ *
+ * @return true if the event was dispatched, false otherwise
+ *
+ * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
+ */
+ public boolean
+ postEvent(Event event)
+ {
+ boolean retVal = false;
+ MenuContainer parent = getParent();
+ if (parent != null)
+ retVal = parent.postEvent(event);
+
+ return retVal;
+ }
+
+ /**
+ * Sends this event to this component or a subcomponent for processing.
+ *
+ * @param event The event to dispatch
+ */
+ public final void dispatchEvent(AWTEvent event)
+ {
+ // Convert AWT 1.1 event to AWT 1.0 event.
+ Event oldStyleEvent = Component.translateEvent(event);
+ if (oldStyleEvent != null)
+ {
+ postEvent(oldStyleEvent);
+ }
+
+ // See comment in Component.dispatchEvent().
+ dispatchEventImpl(event);
+ }
+
+ /**
+ * Implementation of dispatchEvent. Allows trusted package classes
+ * to dispatch additional events first. This implementation first
+ * translates <code>event</code> to an AWT 1.0 event and sends the
+ * result to {@link #postEvent}. The event is then
+ * passed on to {@link #processEvent} for local processing.
+ *
+ * @param event the event to dispatch
+ */
+ void dispatchEventImpl(AWTEvent event)
+ {
+ // Do local processing.
+ processEvent(event);
+ }
+
+ /**
+ * Processes the specified event. In this class, this method simply
+ * calls one of the more specific event handlers.
+ *
+ * @param event the event to process
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ // Pass a focus event to the focus listener for
+ // the accessibility context.
+ if (event instanceof FocusEvent)
+ {
+ if (focusListener != null)
+ {
+ switch (event.id)
+ {
+ case FocusEvent.FOCUS_GAINED:
+ focusListener.focusGained((FocusEvent) event);
+ break;
+ case FocusEvent.FOCUS_LOST:
+ focusListener.focusLost((FocusEvent) event);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a string representation of this component.
+ *
+ * @return a string representation of this component
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[" + paramString() + "]";
+ }
+
+ /**
+ * Returns a debugging string for this component
+ */
+ protected String paramString()
+ {
+ return "name=" + getName();
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>MenuComponent</code>.
+ * As an abstract class, we return null. Concrete subclasses should return
+ * their implementation of the accessibility context.
+ *
+ * @return null
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ return null;
+ }
+
+ /**
+ * This class provides a base for the accessibility support of menu
+ * components.
+ *
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+ protected abstract class AccessibleAWTMenuComponent
+ extends AccessibleContext
+ implements Serializable, AccessibleComponent, AccessibleSelection
+ {
+
+ /**
+ * Compatible with JDK 1.4.2 revision 5
+ */
+ private static final long serialVersionUID = -4269533416223798698L;
+
+ /**
+ * This is the default constructor. It should be called by
+ * concrete subclasses to ensure necessary groundwork is completed.
+ */
+ protected AccessibleAWTMenuComponent()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Replaces or supplements the component's selection with the
+ * <code>Accessible</code> child at the supplied index. If
+ * the component supports multiple selection, the child is
+ * added to the current selection. Otherwise, the current
+ * selection becomes the specified child. If the child is
+ * already selected, nothing happens.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the specified child within a
+ * zero-based list of the component's children
+ */
+ public void addAccessibleSelection(int index)
+ {
+ // Subclasses with children should implement this.
+ }
+
+ /**
+ * Registers the specified focus listener to receive
+ * focus events from this component.
+ *
+ * @param listener the new focus listener
+ */
+ public void addFocusListener(FocusListener listener)
+ {
+ // Chain the new focus listener to the existing chain
+ // of focus listeners. Each new focus listener is
+ // coupled via multicasting to the existing chain.
+ focusListener = AWTEventMulticaster.add(focusListener, listener);
+ }
+
+ /**
+ * Clears the component's current selection. Following
+ * the calling of this method, no children of the component
+ * will be selected.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ */
+ public void clearAccessibleSelection()
+ {
+ // Nothing to do here.
+ }
+
+ /**
+ * Returns true if the specified point lies within the
+ * component. The supplied co-ordinates are assumed to
+ * be relative to the co-ordinate system of the component
+ * itself. Thus, the point (0,0) is the upper left corner
+ * of this component.
+ * <br />
+ * <br />
+ * Please note that this method depends on a correctly implemented
+ * version of the <code>getBounds()</code> method. Subclasses
+ * must provide the bounding rectangle via <code>getBounds()</code>
+ * in order for this method to work.
+ *
+ * @param point the point to check against this component
+ * @return true if the point is within this component
+ * @see #getBounds()
+ */
+ public boolean contains(Point point)
+ {
+ // We can simply return the result of a
+ // test for containment in the bounding rectangle.
+ return getBounds().contains(point);
+ }
+
+ /**
+ * Returns the <code>Accessible</code> child of this component present
+ * at the specified point. The supplied co-ordinates are
+ * assumed to be relative to the co-ordinate system of this
+ * component (the parent of any returned accessible). Thus,
+ * the point (0,0) is the upper left corner of this menu
+ * component.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param point the point at which the returned accessible
+ * is located
+ * @return null
+ */
+ public Accessible getAccessibleAt(Point point)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the <code>Accessible</code> child at the supplied
+ * index within the list of children of this component.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the <code>Accessible</code> child
+ * to retrieve
+ *
+ * @return null
+ */
+ public Accessible getAccessibleChild(int index)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the number of children of this component which
+ * implement the <code>Accessible</code> interface. If
+ * all children of this component are accessible, then
+ * the returned value will be the same as the number of
+ * children.
+ * <br />
+ * <br />
+ *
+ * @return 0
+ */
+ public int getAccessibleChildrenCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Retrieves the <code>AccessibleComponent</code> associated
+ * with this accessible context and its component. As the
+ * context itself implements <code>AccessibleComponent</code>,
+ * this is the return value.
+ *
+ * @return the context itself
+ */
+ public AccessibleComponent getAccessibleComponent()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the accessible name for this menu component. This
+ * is the name given to the component, which may be null if
+ * not set using <code>setName()</code>.
+ * <br />
+ * <br />
+ * The name is not the most appropriate description of this
+ * object. Subclasses should preferably provide a more
+ * accurate description. For example, a File menu could
+ * have the description `Lists commands related to the
+ * file system'.
+ *
+ * @return a description of the component. Currently,
+ * this is just the contents of the name property
+ *
+ * @see MenuComponent#setName(String)
+ */
+ public String getAccessibleDescription()
+ {
+ return MenuComponent.this.getName();
+ }
+
+ /**
+ * Retrieves the index of this component within its parent.
+ * If no parent exists, -1 is returned.
+ *
+ * @return -1 as the parent, a <code>MenuContainer</code>
+ * is not <code>Accessible</code>
+ */
+ public int getAccessibleIndexInParent()
+ {
+ return -1;
+ }
+
+ /**
+ * Returns the accessible name of this component. This
+ * is the name given to the component, which may be null if
+ * not set using <code>setName()</code>.
+ * <br />
+ * <br />
+ * The name property is not the most suitable string to return
+ * for this method. The string should be localized, and
+ * relevant to the operation of the component. For example,
+ * it could be the text of a menu item. However, this can
+ * not be used at this level of abstraction, so it is the
+ * responsibility of subclasses to provide a more appropriate
+ * name.
+ *
+ * @return a localized name for this component. Currently, this
+ * is just the contents of the name property
+ *
+ * @see MenuComponent#setName(String)
+ */
+ public String getAccessibleName()
+ {
+ return MenuComponent.this.getName();
+ }
+
+ /**
+ * Returns the <code>Accessible</code> parent of this component.
+ * As the parent of a <code>MenuComponent</code> is a
+ * <code>MenuContainer</code>, which doesn't implement
+ * <code>Accessible</code>, this method returns null.
+ *
+ * @return null
+ */
+ public Accessible getAccessibleParent()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the accessible role of this component.
+ * <br />
+ * <br />
+ * The abstract implementation of this method returns
+ * <code>AccessibleRole.AWT_COMPONENT</code>,
+ * as the abstract component has no specific role. This
+ * method should be overridden by concrete subclasses, so
+ * as to return an appropriate role for the component.
+ *
+ * @return <code>AccessibleRole.AWT_COMPONENT</code>
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.AWT_COMPONENT;
+ }
+
+ /**
+ * Retrieves the <code>AccessibleSelection</code> associated
+ * with this accessible context and its component. As the
+ * context itself implements <code>AccessibleSelection</code>,
+ * this is the return value.
+ *
+ * @return the context itself
+ */
+ public AccessibleSelection getAccessibleSelection()
+ {
+ return this;
+ }
+
+ /**
+ * Retrieves the <code>Accessible</code> selected child
+ * at the specified index. If there are no selected children
+ * or the index is outside the range of selected children,
+ * null is returned. Please note that the index refers
+ * to the index of the child in the list of <strong>selected
+ * children</strong>, and not the index of the child in
+ * the list of all <code>Accessible</code> children.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the selected <code>Accessible</code>
+ * child
+ */
+ public Accessible getAccessibleSelection(int index)
+ {
+ return null;
+ }
+
+ /**
+ * Returns a count of the number of <code>Accessible</code>
+ * children of this component which are currently selected.
+ * If there are no children currently selected, 0 is returned.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @return 0
+ */
+ public int getAccessibleSelectionCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Retrieves the current state of this component
+ * in an accessible form. For example, a given component
+ * may be visible, selected, disabled, etc.
+ * <br />
+ * <br />
+ * As this class tells us virtually nothing about the component,
+ * except for its name and font, no state information can be
+ * provided. This implementation thus returns an empty
+ * state set, and it is left to concrete subclasses to provide
+ * a more acceptable and relevant state set. Changes to these
+ * properties also need to be handled using
+ * <code>PropertyChangeListener</code>s.
+ *
+ * @return an empty <code>AccessibleStateSet</code>
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ return new AccessibleStateSet();
+ }
+
+ /**
+ * Returns the background color of the component, or null
+ * if this property is unsupported.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns the
+ * default system background color used for rendering menus.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @return the default system background color for menus
+ *
+ * @see #setBackground(java.awt.Color)
+ */
+ public Color getBackground()
+ {
+ return SystemColor.menu;
+ }
+
+ /**
+ * Returns a <code>Rectangle</code> which represents the
+ * bounds of this component. The returned rectangle has the
+ * height and width of the component's bounds, and is positioned
+ * at a location relative to this component's parent, the
+ * <code>MenuContainer</code>. null is returned if bounds
+ * are not supported by the component.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns null.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @return null
+ *
+ * @see #setBounds(java.awt.Rectangle)
+ */
+ public Rectangle getBounds()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the <code>Cursor</code> displayed when the pointer
+ * is positioned over this component. Alternatively, null
+ * is returned if the component doesn't support the cursor
+ * property.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns the default
+ * system cursor. Concrete subclasses which handle the drawing
+ * of an onscreen menu component may override this method and provide
+ * the appropriate information.
+ *
+ * @return the default system cursor
+ *
+ * @see #setCursor(java.awt.Cursor)
+ */
+ public Cursor getCursor()
+ {
+ return Cursor.getDefaultCursor();
+ }
+
+ /**
+ * Returns the <code>Font</code> used for text created by this component.
+ *
+ * @return the current font
+ *
+ * @see #setFont(java.awt.Font)
+ */
+ public Font getFont()
+ {
+ return MenuComponent.this.getFont();
+ }
+
+ /**
+ * Retrieves information on the rendering and metrics of the supplied
+ * font. If font metrics are not supported by this component, null
+ * is returned.
+ * <br />
+ * <br />
+ * The abstract implementation of this method simply uses the toolkit
+ * to obtain the <code>FontMetrics</code>. Concrete subclasses may
+ * find it more efficient to invoke their peer class directly, if one
+ * is available.
+ *
+ * @param font the font about which to retrieve rendering and metric
+ * information
+ *
+ * @return the metrics of the given font, as provided by the system
+ * toolkit
+ *
+ * @throws NullPointerException if the supplied font was null
+ */
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return MenuComponent.this.getToolkit().getFontMetrics(font);
+ }
+
+ /**
+ * Returns the foreground color of the component, or null
+ * if this property is unsupported.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns the
+ * default system text color used for rendering menus.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @return the default system text color for menus
+ *
+ * @see #setForeground(java.awt.Color)
+ */
+ public Color getForeground()
+ {
+ return SystemColor.menuText;
+ }
+
+ /**
+ * Returns the locale currently in use by this component.
+ * <br />
+ * <br />
+ * This abstract class has no property relating to the
+ * locale used by the component, so this method simply
+ * returns the default locale for the current instance
+ * of the Java Virtual Machine (JVM). Concrete subclasses
+ * which maintain such a property should override this method
+ * and provide the locale information more accurately.
+ *
+ * @return the default locale for this JVM instance
+ */
+ public Locale getLocale()
+ {
+ return Locale.getDefault();
+ }
+
+ /**
+ * Returns the location of the component, with co-ordinates
+ * relative to the parent component and using the co-ordinate
+ * space of the screen. Thus, the point (0,0) is the upper
+ * left corner of the parent component.
+ * <br />
+ * <br />
+ * Please note that this method depends on a correctly implemented
+ * version of the <code>getBounds()</code> method. Subclasses
+ * must provide the bounding rectangle via <code>getBounds()</code>
+ * in order for this method to work.
+ *
+ * @return the location of the component, relative to its parent
+ *
+ * @see #setLocation(java.awt.Point)
+ */
+ public Point getLocation()
+ {
+ // Simply return the location of the bounding rectangle.
+ return getBounds().getLocation();
+ }
+
+ /**
+ * Returns the location of the component, with co-ordinates
+ * relative to the screen. Thus, the point (0,0) is the upper
+ * left corner of the screen. null is returned if the component
+ * is either not on screen or if this property is unsupported.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply returns null.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @return the location of the component, relative to the screen
+ */
+ public Point getLocationOnScreen()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the size of the component.
+ * <br />
+ * <br />
+ * Please note that this method depends on a correctly implemented
+ * version of the <code>getBounds()</code> method. Subclasses
+ * must provide the bounding rectangle via <code>getBounds()</code>
+ * in order for this method to work.
+ *
+ * @return the size of the component
+ *
+ * @see #setSize(java.awt.Dimension)
+ */
+ public Dimension getSize()
+ {
+ // Simply return the size of the bounding rectangle.
+ return getBounds().getSize();
+ }
+
+ /**
+ * Returns true if the accessible child specified by the supplied index
+ * is currently selected.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the accessible child to check for selection
+ *
+ * @return false
+ */
+ public boolean isAccessibleChildSelected(int index)
+ {
+ return false;
+ }
+
+ /**
+ * Returns true if this component is currently enabled.
+ * <br />
+ * <br />
+ * As this abstract component has no properties related to
+ * its enabled or disabled state, the implementation of this
+ * method is left to subclasses.
+ *
+ * @return false
+ *
+ * @see #setEnabled(boolean)
+ */
+ public boolean isEnabled()
+ {
+ return false;
+ }
+
+ /**
+ * Returns true if this component is included in the traversal
+ * of the current focus from one component to the other.
+ * <br />
+ * <br />
+ * As this abstract component has no properties related to
+ * its ability to accept the focus, the implementation of this
+ * method is left to subclasses.
+ *
+ * @return false
+ */
+ public boolean isFocusTraversable()
+ {
+ return false;
+ }
+
+ /**
+ * Returns true if the component is being shown on screen.
+ * A component is determined to be shown if it is visible,
+ * and each parent component is also visible. Please note
+ * that, even when a component is showing, it may still be
+ * obscured by other components in front. This method only
+ * determines if the component is being drawn on the screen.
+ * <br />
+ * <br />
+ * As this abstract component and its parent have no properties
+ * relating to visibility, the implementation of this method is
+ * left to subclasses.
+ *
+ * @return false
+ *
+ * @see #isVisible()
+ */
+ public boolean isShowing()
+ {
+ return false;
+ }
+
+ /**
+ * Returns true if the component is visible. A component may
+ * be visible but not drawn on the screen if one of its parent
+ * components is not visible. To determine if the component is
+ * actually drawn on screen, <code>isShowing()</code> should be
+ * used.
+ * <br />
+ * <br />
+ * As this abstract component has no properties relating to its
+ * visibility, the implementation of this method is left to subclasses.
+ *
+ * @return false
+ *
+ * @see #isShowing()
+ * @see #setVisible(boolean)
+ */
+ public boolean isVisible()
+ {
+ return false;
+ }
+
+ /**
+ * Removes the accessible child specified by the supplied index from
+ * the list of currently selected children. If the child specified
+ * is not selected, nothing happens.
+ * <br />
+ * <br />
+ * As the existence of children can not be determined from
+ * this abstract class, the implementation of this method
+ * is left to subclasses.
+ *
+ * @param index the index of the <code>Accessible</code> child
+ */
+ public void removeAccessibleSelection(int index)
+ {
+ // Subclasses with children should implement this.
+ }
+
+ /**
+ * Removes the specified focus listener from the list of registered
+ * focus listeners for this component.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeFocusListener(FocusListener listener)
+ {
+ // Remove the focus listener from the chain.
+ focusListener = AWTEventMulticaster.remove(focusListener, listener);
+ }
+
+ /**
+ * Requests that this component gains focus. This depends on the
+ * component being focus traversable.
+ * <br />
+ * <br />
+ * As this abstract component has no properties relating to its
+ * focus traversability, or access to a peer with request focusing
+ * abilities, the implementation of this method is left to subclasses.
+ */
+ public void requestFocus()
+ {
+ // Ignored.
+ }
+
+ /**
+ * Selects all <code>Accessible</code> children of this component which
+ * it is possible to select. The component needs to support multiple
+ * selections.
+ * <br />
+ * <br />
+ * This abstract component provides a simplistic implementation of this
+ * method, which ignores the ability of the component to support multiple
+ * selections and simply uses <code>addAccessibleSelection</code> to
+ * add each <code>Accessible</code> child to the selection. The last
+ * <code>Accessible</code> component is thus selected for components
+ * which don't support multiple selections. Concrete implementations should
+ * override this with a more appopriate and efficient implementation, which
+ * properly takes into account the ability of the component to support multiple
+ * selections.
+ */
+ public void selectAllAccessibleSelection()
+ {
+ // Simply call addAccessibleSelection() on all accessible children.
+ for (int a = 0; a < getAccessibleChildrenCount(); ++a)
+ {
+ addAccessibleSelection(a);
+ }
+ }
+
+ /**
+ * Sets the background color of the component to that specified.
+ * Unspecified behaviour occurs when null is given as the new
+ * background color.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply ignores the supplied
+ * color and continues to use the default system color.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @param color the new color to use for the background
+ *
+ * @see #getBackground()
+ */
+ public void setBackground(Color color)
+ {
+ // Ignored.
+ }
+
+ /**
+ * Sets the height and width of the component, and its position
+ * relative to this component's parent, to the values specified
+ * by the supplied rectangle. Unspecified behaviour occurs when
+ * null is given as the new bounds.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply ignores the new
+ * rectangle and continues to return null from <code>getBounds()</code>.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @param rectangle a rectangle which specifies the new bounds of
+ * the component
+ *
+ * @see #getBounds()
+ */
+ public void setBounds(Rectangle rectangle)
+ {
+ // Ignored.
+ }
+
+ /**
+ * Sets the <code>Cursor</code> used when the pointer is positioned over the
+ * component. Unspecified behaviour occurs when null is given as the new
+ * cursor.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply ignores the new cursor
+ * and continues to return the default system cursor. Concrete
+ * subclasses which handle the drawing of an onscreen menu component
+ * may override this method and provide the appropriate information.
+ *
+ * @param cursor the new cursor to use
+ *
+ * @see #getCursor()
+ */
+ public void setCursor(Cursor cursor)
+ {
+ // Ignored.
+ }
+
+ /**
+ * Sets the enabled/disabled state of this component.
+ * <br />
+ * <br />
+ * As this abstract component has no properties related to
+ * its enabled or disabled state, the implementation of this
+ * method is left to subclasses.
+ *
+ * @param enabled true if the component should be enabled,
+ * false otherwise
+ *
+ * @see #isEnabled()
+ */
+ public void setEnabled(boolean enabled)
+ {
+ // Ignored.
+ }
+
+ /**
+ * Sets the <code>Font</code> used for text created by this component.
+ * Unspecified behaviour occurs when null is given as the new
+ * font.
+ *
+ * @param font the new font to use for text.
+ * @see #getFont()
+ */
+ public void setFont(Font font)
+ {
+ // Call the method of the enclosing component.
+ MenuComponent.this.setFont(font);
+ }
+
+ /**
+ * Sets the foreground color of the component to that specified.
+ * Unspecified behaviour occurs when null is given as the new
+ * background color.
+ * <br />
+ * <br />
+ * This abstract class knows nothing about how the component
+ * is drawn on screen, so this method simply ignores the supplied
+ * color and continues to return the default system text color used
+ * for rendering menus.
+ * Concrete subclasses which handle the drawing of an onscreen
+ * menu component should override this method and provide
+ * the appropriate information.
+ *
+ * @param color the new foreground color
+ *
+ * @see #getForeground()
+ */
+ public void setForeground(Color color)
+ {
+ // Ignored.
+ }
+
+ /**
+ * Sets the location of the component, with co-ordinates
+ * relative to the parent component and using the co-ordinate
+ * space of the screen. Thus, the point (0,0) is the upper
+ * left corner of the parent component.
+ * <br />
+ * <br />
+ * Please note that this method depends on a correctly implemented
+ * version of the <code>getBounds()</code> method. Subclasses
+ * must provide the bounding rectangle via <code>getBounds()</code>
+ * in order for this method to work.
+ *
+ * @param point the location of the component, relative to its parent
+ *
+ * @see #getLocation()
+ */
+ public void setLocation(Point point)
+ {
+ getBounds().setLocation(point);
+ }
+
+ /**
+ * Sets the size of the component.
+ * <br />
+ * <br />
+ * Please note that this method depends on a correctly implemented
+ * version of the <code>getBounds()</code> method. Subclasses
+ * must provide the bounding rectangle via <code>getBounds()</code>
+ * in order for this method to work.
+ *
+ * @param size the new size of the component
+ *
+ * @see #getSize()
+ */
+ public void setSize(Dimension size)
+ {
+ getBounds().setSize(size);
+ }
+
+ /**
+ * Sets the visibility state of the component. A component may
+ * be visible but not drawn on the screen if one of its parent
+ * components is not visible. To determine if the component is
+ * actually drawn on screen, <code>isShowing()</code> should be
+ * used.
+ * <br />
+ * <br />
+ * As this abstract component has no properties relating to its
+ * visibility, the implementation of this method is left to subclasses.
+ *
+ * @param visibility the new visibility of the component -- true if
+ * the component is visible, false if not
+ *
+ * @see #isShowing()
+ * @see #isVisible()
+ */
+ public void setVisible(boolean visibility)
+ {
+ // Ignored.
+ }
+
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuContainer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuContainer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuContainer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuContainer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,71 @@
+/* MenuContainer.java -- container for menu items
+ Copyright (C) 1999, 2002, 2005 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;
+
+/**
+ * This interface is a container for menu components.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface MenuContainer
+{
+ /**
+ * Returns the font in use by this container.
+ *
+ * @return the menu font
+ */
+ Font getFont();
+
+ /**
+ * Removes the specified menu component from the menu.
+ *
+ * @param component the menu component to remove
+ */
+ void remove(MenuComponent component);
+
+ /**
+ * Posts an event to the listeners.
+ *
+ * @param event the event to dispatch
+ * @deprecated use {@link MenuComponent#dispatchEvent(AWTEvent)} instead
+ */
+ boolean postEvent(Event event);
+} // interface MenuContainer
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuItem.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuItem.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuItem.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuItem.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,623 @@
+/* MenuItem.java -- An item in a menu
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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 java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.peer.MenuItemPeer;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleAction;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleValue;
+
+/**
+ * This class represents an item in a menu.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class MenuItem extends MenuComponent
+ implements Serializable, Accessible
+{
+
+/*
+ * Static Variables
+ */
+
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_menuitem_number;
+
+ // Serialization Constant
+ private static final long serialVersionUID = - 21757335363267194L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The name of the action command generated by this item.
+ * This is package-private to avoid an accessor method.
+ */
+String actionCommand;
+
+/**
+ * @serial Indicates whether or not this menu item is enabled.
+ * This is package-private to avoid an accessor method.
+ */
+boolean enabled = true;
+
+/**
+ * @serial The mask of events that are enabled for this menu item.
+ */
+long eventMask;
+
+/**
+ * @serial This menu item's label
+ * This is package-private to avoid an accessor method.
+ */
+String label = "";
+
+/**
+ * @serial The shortcut for this menu item, if any
+ */
+private MenuShortcut shortcut;
+
+// The list of action listeners for this menu item.
+private transient ActionListener action_listeners;
+
+ protected class AccessibleAWTMenuItem
+ extends MenuComponent.AccessibleAWTMenuComponent
+ implements AccessibleAction, AccessibleValue
+ {
+ private static final long serialVersionUID = -217847831945965825L;
+
+ /** Constructor */
+ protected AccessibleAWTMenuItem()
+ {
+ super();
+ }
+
+
+
+ public String getAccessibleName()
+ {
+ return label;
+ }
+
+ public AccessibleAction getAccessibleAction()
+ {
+ return this;
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.MENU_ITEM;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionCount()
+ */
+ public int getAccessibleActionCount()
+ {
+ return 1;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#getAccessibleActionDescription(int)
+ */
+ public String getAccessibleActionDescription(int i)
+ {
+ if (i == 0)
+ return label;
+ else
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleAction#doAccessibleAction(int)
+ */
+ public boolean doAccessibleAction(int i)
+ {
+ if (i != 0)
+ return false;
+ processActionEvent(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand));
+ return true;
+ }
+
+ public AccessibleValue getAccessibleValue()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getCurrentAccessibleValue()
+ */
+ public Number getCurrentAccessibleValue()
+ {
+ return (enabled) ? new Integer(1) : new Integer(0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#setCurrentAccessibleValue(java.lang.Number)
+ */
+ public boolean setCurrentAccessibleValue(Number number)
+ {
+ boolean result = (number.intValue() != 0);
+ // this. is required by javac 1.3, otherwise it is confused with
+ // MenuItem.this.setEnabled.
+ this.setEnabled(result);
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getMinimumAccessibleValue()
+ */
+ public Number getMinimumAccessibleValue()
+ {
+ return new Integer(0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleValue#getMaximumAccessibleValue()
+ */
+ public Number getMaximumAccessibleValue()
+ {
+ return new Integer(0);
+ }
+
+ }
+
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>MenuItem</code> with no label
+ * and no shortcut.
+ */
+public
+MenuItem()
+{
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>MenuItem</code> with the specified
+ * label and no shortcut.
+ *
+ * @param label The label for this menu item.
+ */
+public
+MenuItem(String label)
+{
+ this.label = label;
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>MenuItem</code> with the specified
+ * label and shortcut.
+ *
+ * @param label The label for this menu item.
+ * @param shortcut The shortcut for this menu item.
+ */
+public
+MenuItem(String label, MenuShortcut shortcut)
+{
+ this.label = label;
+ this.shortcut = shortcut;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns the label for this menu item, which may be <code>null</code>.
+ *
+ * @return The label for this menu item.
+ */
+public String
+getLabel()
+{
+ return(label);
+}
+
+/*************************************************************************/
+
+/**
+ * This method sets the label for this menu to the specified value.
+ *
+ * @param label The new label for this menu item.
+ */
+public synchronized void
+setLabel(String label)
+{
+ this.label = label;
+ if (peer != null)
+ {
+ MenuItemPeer mp = (MenuItemPeer) peer;
+ mp.setLabel (label);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not this menu item is enabled.
+ *
+ * @return <code>true</code> if this menu item is enabled, <code>false</code>
+ * otherwise.
+ */
+public boolean
+isEnabled()
+{
+ return(enabled);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the enabled status of this menu item.
+ *
+ * @param enabled <code>true</code> to enable this menu item,
+ * <code>false</code> otherwise.
+ */
+public synchronized void
+setEnabled(boolean enabled)
+{
+ enable (enabled);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the enabled status of this menu item.
+ *
+ * @param enabled <code>true</code> to enable this menu item,
+ * <code>false</code> otherwise.
+ *
+ * @deprecated This method is deprecated in favor of <code>setEnabled()</code>.
+ */
+public void
+enable(boolean enabled)
+{
+ if (enabled)
+ enable ();
+ else
+ disable ();
+}
+
+/*************************************************************************/
+
+/**
+ * Enables this menu item.
+ *
+ * @deprecated This method is deprecated in favor of <code>setEnabled()</code>.
+ */
+public void
+enable()
+{
+ if (enabled)
+ return;
+
+ this.enabled = true;
+ if (peer != null)
+ ((MenuItemPeer) peer).setEnabled (true);
+}
+
+/*************************************************************************/
+
+/**
+ * Disables this menu item.
+ *
+ * @deprecated This method is deprecated in favor of <code>setEnabled()</code>.
+ */
+public void
+disable()
+{
+ if (!enabled)
+ return;
+
+ this.enabled = false;
+ if (peer != null)
+ ((MenuItemPeer) peer).setEnabled (false);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the shortcut for this menu item, which may be <code>null</code>.
+ *
+ * @return The shortcut for this menu item.
+ */
+public MenuShortcut
+getShortcut()
+{
+ return(shortcut);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the shortcut for this menu item to the specified value. This
+ * must be done before the native peer is created.
+ *
+ * @param shortcut The new shortcut for this menu item.
+ */
+public void
+setShortcut(MenuShortcut shortcut)
+{
+ this.shortcut = shortcut;
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes the shortcut for this menu item if one exists. This must be
+ * done before the native peer is created.
+ */
+public void
+deleteShortcut()
+{
+ shortcut = null;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the name of the action command in the action events
+ * generated by this menu item.
+ *
+ * @return The action command name
+ */
+public String
+getActionCommand()
+{
+ if (actionCommand == null)
+ return label;
+ else
+ return actionCommand;
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the name of the action command in the action events generated by
+ * this menu item.
+ *
+ * @param actionCommand The new action command name.
+ */
+public void
+setActionCommand(String actionCommand)
+{
+ this.actionCommand = actionCommand;
+}
+
+/*************************************************************************/
+
+/**
+ * Enables the specified events. This is done automatically when a
+ * listener is added and does not normally need to be done by
+ * application code.
+ *
+ * @param events The events to enable, which should be the bit masks
+ * from <code>AWTEvent</code>.
+ */
+protected final void
+enableEvents(long events)
+{
+ eventMask |= events;
+ // TODO: see comment in Component.enableEvents().
+}
+
+/*************************************************************************/
+
+/**
+ * Disables the specified events.
+ *
+ * @param events The events to enable, which should be the bit masks
+ * from <code>AWTEvent</code>.
+ */
+protected final void
+disableEvents(long events)
+{
+ eventMask &= ~events;
+}
+
+/*************************************************************************/
+
+/**
+ * Creates the native peer for this object.
+ */
+public void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit ().createMenuItem (this);
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified listener to the list of registered action listeners
+ * for this component.
+ *
+ * @param listener The listener to add.
+ */
+public synchronized void
+addActionListener(ActionListener listener)
+{
+ action_listeners = AWTEventMulticaster.add(action_listeners, listener);
+
+ enableEvents(AWTEvent.ACTION_EVENT_MASK);
+}
+
+public synchronized void
+removeActionListener(ActionListener l)
+{
+ action_listeners = AWTEventMulticaster.remove(action_listeners, l);
+}
+
+ public synchronized ActionListener[] getActionListeners()
+ {
+ return (ActionListener[])
+ AWTEventMulticaster.getListeners(action_listeners,
+ ActionListener.class);
+ }
+
+/** Returns all registered EventListers of the given listenerType.
+ * listenerType must be a subclass of EventListener, or a
+ * ClassClassException is thrown.
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == ActionListener.class)
+ return getActionListeners();
+ return (EventListener[]) Array.newInstance(listenerType, 0);
+ }
+
+/*************************************************************************/
+
+void
+dispatchEventImpl(AWTEvent e)
+{
+ if (e.id <= ActionEvent.ACTION_LAST
+ && e.id >= ActionEvent.ACTION_FIRST
+ && (action_listeners != null
+ || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
+ processEvent(e);
+
+ // Send the event to the parent menu if it has not yet been
+ // consumed.
+ if (!e.isConsumed ())
+ ((Menu) getParent ()).processEvent (e);
+}
+
+/**
+ * Processes the specified event by calling <code>processActionEvent()</code>
+ * if it is an instance of <code>ActionEvent</code>.
+ *
+ * @param event The event to process.
+ */
+protected void
+processEvent(AWTEvent event)
+{
+ if (event instanceof ActionEvent)
+ processActionEvent((ActionEvent)event);
+}
+
+/*************************************************************************/
+
+/**
+ * Processes the specified event by dispatching it to any registered listeners.
+ *
+ * @param event The event to process.
+ */
+protected void
+processActionEvent(ActionEvent event)
+{
+ if (action_listeners != null)
+ {
+ event.setSource(this);
+ action_listeners.actionPerformed(event);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+public String
+paramString()
+{
+ return ("label=" + label + ",enabled=" + enabled +
+ ",actionCommand=" + actionCommand + "," + super.paramString());
+}
+
+/**
+ * Gets the AccessibleContext associated with this <code>MenuItem</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 AccessibleAWTMenuItem();
+ return accessibleContext;
+}
+
+/**
+ * Generate a unique name for this <code>MenuItem</code>.
+ *
+ * @return A unique name for this <code>MenuItem</code>.
+ */
+String generateName()
+{
+ return "menuitem" + getUniqueLong();
+}
+
+private static synchronized long getUniqueLong()
+{
+ return next_menuitem_number++;
+}
+
+} // class MenuItem
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuShortcut.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuShortcut.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuShortcut.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MenuShortcut.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,207 @@
+/* MenuShortcut.java -- A class for menu accelerators
+ Copyright (C) 1999, 2002 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;
+
+/**
+ * This class implements a keyboard accelerator for a menu item.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class MenuShortcut implements java.io.Serializable
+{
+
+/*
+ * Static Variables
+ */
+
+// Serialization Constant
+private static final long serialVersionUID = 143448358473180225L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The virtual keycode for the shortcut.
+ */
+private int key;
+
+/**
+ * @serial <code>true</code> if the shift key was used with this shortcut,
+ * or <code>false</code> otherwise.
+ */
+private boolean usesShift;
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>MenuShortcut</code> with the
+ * specified virtual key value.
+ *
+ * @param key The virtual keycode for the shortcut.
+ */
+public
+MenuShortcut(int key)
+{
+ this(key, false);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>MenuShortcut</code> with the
+ * specified virtual key value and shift setting.
+ *
+ * @param key The virtual keycode for the shortcut.
+ * @param usesShift <code>true</code> if the shift key was pressed,
+ * <code>false</code> otherwise.
+ */
+public
+MenuShortcut(int key, boolean usesShift)
+{
+ this.key = key;
+ this.usesShift = usesShift;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Returns the virtual keycode for this shortcut.
+ *
+ * @return The virtual keycode for this shortcut.
+ */
+public int
+getKey()
+{
+ return(key);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the shift setting for this shortcut.
+ *
+ * @return <code>true</code> if the shift key was pressed, <code>false</code>
+ * otherwise.
+ */
+public boolean
+usesShiftModifier()
+{
+ return(usesShift);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests this object for equality against the specified object. The two
+ * objects will be considered equal if and only if the specified object
+ * is an instance of <code>MenuShortcut</code> and has the same key value
+ * and shift setting as this object.
+ *
+ * @param obj The object to test for equality against.
+ *
+ * @return <code>true</code> if the two objects are equal, <code>false</code>
+ * otherwise.
+ */
+public boolean
+equals(MenuShortcut obj)
+{
+ if (obj == null)
+ return(false);
+
+ if (obj.key != this.key)
+ return(false);
+
+ if (obj.usesShift != this.usesShift)
+ return(false);
+
+ return(true);
+}
+
+public boolean
+equals(Object obj)
+{
+ if (obj instanceof MenuShortcut)
+ {
+ MenuShortcut ms = (MenuShortcut) obj;
+ return (ms.key == key && ms.usesShift == usesShift);
+ }
+ return false;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a string representation of this shortcut.
+ *
+ * @return A string representation of this shortcut.
+ */
+public String
+toString()
+{
+ return(getClass().getName() + "[" + paramString () + "]");
+}
+
+public int
+hashCode()
+{
+ // Arbitrary.
+ return key + (usesShift ? 23 : 57);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+protected String
+paramString()
+{
+ return "key=" + key + ",usesShift=" + usesShift;
+}
+
+} // class MenuShortcut
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MouseInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MouseInfo.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MouseInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/MouseInfo.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,95 @@
+/* MouseInfo.java -- utility methods for mice.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt;
+
+import gnu.java.awt.ClasspathToolkit;
+import java.awt.peer.MouseInfoPeer;
+
+/**
+ * MouseInfo is a class containing utility functions for mouse information.
+ *
+ * @author Sven de Marothy
+ * @since 1.5
+ */
+public class MouseInfo
+{
+ private static MouseInfoPeer peer;
+
+ /**
+ * Returns a PointerInfo object containing information about the current
+ * location of the mouse pointer
+ *
+ * @throws HeadlessException if the current GraphicsEnvironment is headless.
+ * @return a PointerInfo object.
+ */
+ public static PointerInfo getPointerInfo() throws HeadlessException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission( new AWTPermission("watchMousePointer") );
+
+ if( GraphicsEnvironment.isHeadless() )
+ throw new HeadlessException();
+
+ if( peer == null )
+ peer = Toolkit.getDefaultToolkit().getMouseInfoPeer();
+
+ Point p = new Point();
+ int screen = peer.fillPointWithCoords( p );
+
+ GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
+ getScreenDevices();
+
+ return new PointerInfo( gds[ screen ], p );
+ }
+
+ /**
+ * Returns the number of mouse buttons, or -1 if no mouse is connected.
+ * (mentioned in the 1.5 release notes)
+ *
+ * @throws HeadlessException if the current GraphicsEnvironment is headless.
+ * @return an integer number of buttons.
+ */
+ public static int getNumberOfButtons() throws HeadlessException
+ {
+ if( GraphicsEnvironment.isHeadless() )
+ throw new HeadlessException();
+ return ((ClasspathToolkit)Toolkit.getDefaultToolkit()).
+ getMouseNumberOfButtons();
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PageAttributes.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PageAttributes.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PageAttributes.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PageAttributes.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,482 @@
+/* PageAttributes.java --
+ Copyright (C) 2002, 2005 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 java.util.Locale;
+
+/**
+ * Missing Documentation
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ * @status updated to 1.4, but missing documentation
+ */
+public final class PageAttributes implements Cloneable
+{
+ public static final class ColorType extends AttributeValue
+ {
+ private static final String[] NAMES = { "color", "monochrome" };
+ public static final ColorType COLOR = new ColorType(0);
+ public static final ColorType MONOCHROME = new ColorType(1);
+ private ColorType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class ColorType
+ public static final class MediaType extends AttributeValue
+ {
+ private static final String[] NAMES
+ = { "iso-4a0", "iso-2a0", "iso-a0", "iso-a1", "iso-a2", "iso-a3",
+ "iso-a4", "iso-a5", "iso-a6", "iso-a7", "iso-a8", "iso-a9",
+ "iso-a10", "iso-b0", "iso-b1", "iso-b2", "iso-b3", "iso-b4",
+ "iso-b5", "iso-b6", "iso-b7", "iso-b8", "iso-b9", "iso-b10",
+ "jis-b0", "jis-b1", "jis-b2", "jis-b3", "jis-b4", "jis-b5",
+ "jis-b6", "jis-b7", "jis-b8", "jis-b9", "jis-b10", "iso-c0",
+ "iso-c1", "iso-c2", "iso-c3", "iso-c4", "iso-c5", "iso-c6",
+ "iso-c7", "iso-c8", "iso-c9", "iso-c10", "iso-designated-long",
+ "executive", "folio", "invoice", "ledger", "na-letter", "na-legal",
+ "quarto", "a", "b", "c", "d", "e", "na-10x15-envelope",
+ "na-10x14-envelope", "na-10x13-envelope", "na-9x12-envelope",
+ "na-9x11-envelope", "na-7x9-envelope", "na-6x9-envelope",
+ "na-number-9-envelope", "na-number-10-envelope",
+ "na-number-11-envelope", "na-number-12-envelope",
+ "na-number-14-envelope", "invite-envelope", "italy-envelope",
+ "monarch-envelope", "personal-envelope" };
+ public static final MediaType ISO_4A0 = new MediaType(0);
+ public static final MediaType ISO_2A0 = new MediaType(1);
+ public static final MediaType ISO_A0 = new MediaType(2);
+ public static final MediaType ISO_A1 = new MediaType(3);
+ public static final MediaType ISO_A2 = new MediaType(4);
+ public static final MediaType ISO_A3 = new MediaType(5);
+ public static final MediaType ISO_A4 = new MediaType(6);
+ public static final MediaType ISO_A5 = new MediaType(7);
+ public static final MediaType ISO_A6 = new MediaType(8);
+ public static final MediaType ISO_A7 = new MediaType(9);
+ public static final MediaType ISO_A8 = new MediaType(10);
+ public static final MediaType ISO_A9 = new MediaType(11);
+ public static final MediaType ISO_A10 = new MediaType(12);
+ public static final MediaType ISO_B0 = new MediaType(13);
+ public static final MediaType ISO_B1 = new MediaType(14);
+ public static final MediaType ISO_B2 = new MediaType(15);
+ public static final MediaType ISO_B3 = new MediaType(16);
+ public static final MediaType ISO_B4 = new MediaType(17);
+ public static final MediaType ISO_B5 = new MediaType(18);
+ public static final MediaType ISO_B6 = new MediaType(19);
+ public static final MediaType ISO_B7 = new MediaType(20);
+ public static final MediaType ISO_B8 = new MediaType(21);
+ public static final MediaType ISO_B9 = new MediaType(22);
+ public static final MediaType ISO_B10 = new MediaType(23);
+ public static final MediaType JIS_B0 = new MediaType(24);
+ public static final MediaType JIS_B1 = new MediaType(25);
+ public static final MediaType JIS_B2 = new MediaType(26);
+ public static final MediaType JIS_B3 = new MediaType(27);
+ public static final MediaType JIS_B4 = new MediaType(28);
+ public static final MediaType JIS_B5 = new MediaType(29);
+ public static final MediaType JIS_B6 = new MediaType(30);
+ public static final MediaType JIS_B7 = new MediaType(31);
+ public static final MediaType JIS_B8 = new MediaType(32);
+ public static final MediaType JIS_B9 = new MediaType(33);
+ public static final MediaType JIS_B10 = new MediaType(34);
+ public static final MediaType ISO_C0 = new MediaType(35);
+ public static final MediaType ISO_C1 = new MediaType(36);
+ public static final MediaType ISO_C2 = new MediaType(37);
+ public static final MediaType ISO_C3 = new MediaType(38);
+ public static final MediaType ISO_C4 = new MediaType(39);
+ public static final MediaType ISO_C5 = new MediaType(40);
+ public static final MediaType ISO_C6 = new MediaType(41);
+ public static final MediaType ISO_C7 = new MediaType(42);
+ public static final MediaType ISO_C8 = new MediaType(43);
+ public static final MediaType ISO_C9 = new MediaType(44);
+ public static final MediaType ISO_C10 = new MediaType(45);
+ public static final MediaType ISO_DESIGNATED_LONG = new MediaType(46);
+ public static final MediaType EXECUTIVE = new MediaType(47);
+ public static final MediaType FOLIO = new MediaType(48);
+ public static final MediaType INVOICE = new MediaType(49);
+ public static final MediaType LEDGER = new MediaType(50);
+ public static final MediaType NA_LETTER = new MediaType(51);
+ public static final MediaType NA_LEGAL = new MediaType(52);
+ public static final MediaType QUARTO = new MediaType(53);
+ public static final MediaType A = new MediaType(54);
+ public static final MediaType B = new MediaType(55);
+ public static final MediaType C = new MediaType(56);
+ public static final MediaType D = new MediaType(57);
+ public static final MediaType E = new MediaType(58);
+ public static final MediaType NA_10X15_ENVELOPE = new MediaType(59);
+ public static final MediaType NA_10X14_ENVELOPE = new MediaType(60);
+ public static final MediaType NA_10X13_ENVELOPE = new MediaType(61);
+ public static final MediaType NA_9X12_ENVELOPE = new MediaType(62);
+ public static final MediaType NA_9X11_ENVELOPE = new MediaType(63);
+ public static final MediaType NA_7X9_ENVELOPE = new MediaType(64);
+ public static final MediaType NA_6X9_ENVELOPE = new MediaType(65);
+ public static final MediaType NA_NUMBER_9_ENVELOPE = new MediaType(66);
+ public static final MediaType NA_NUMBER_10_ENVELOPE = new MediaType(67);
+ public static final MediaType NA_NUMBER_11_ENVELOPE = new MediaType(68);
+ public static final MediaType NA_NUMBER_12_ENVELOPE = new MediaType(69);
+ public static final MediaType NA_NUMBER_14_ENVELOPE = new MediaType(70);
+ public static final MediaType INVITE_ENVELOPE = new MediaType(71);
+ public static final MediaType ITALY_ENVELOPE = new MediaType(72);
+ public static final MediaType MONARCH_ENVELOPE = new MediaType(73);
+ public static final MediaType PERSONAL_ENVELOPE = new MediaType(74);
+ public static final MediaType A0 = ISO_A0;
+ public static final MediaType A1 = ISO_A1;
+ public static final MediaType A2 = ISO_A2;
+ public static final MediaType A3 = ISO_A3;
+ public static final MediaType A4 = ISO_A4;
+ public static final MediaType A5 = ISO_A5;
+ public static final MediaType A6 = ISO_A6;
+ public static final MediaType A7 = ISO_A7;
+ public static final MediaType A8 = ISO_A8;
+ public static final MediaType A9 = ISO_A9;
+ public static final MediaType A10 = ISO_A10;
+ public static final MediaType B0 = ISO_B0;
+ public static final MediaType B1 = ISO_B1;
+ public static final MediaType B2 = ISO_B2;
+ public static final MediaType B3 = ISO_B3;
+ public static final MediaType B4 = ISO_B4;
+ public static final MediaType ISO_B4_ENVELOPE = ISO_B4;
+ public static final MediaType B5 = ISO_B5;
+ public static final MediaType ISO_B5_ENVELOPE = ISO_B4;
+ public static final MediaType B6 = ISO_B6;
+ public static final MediaType B7 = ISO_B7;
+ public static final MediaType B8 = ISO_B8;
+ public static final MediaType B9 = ISO_B9;
+ public static final MediaType B10 = ISO_B10;
+ public static final MediaType C0 = ISO_B0;
+ public static final MediaType ISO_C0_ENVELOPE = ISO_C0;
+ public static final MediaType C1 = ISO_C1;
+ public static final MediaType ISO_C1_ENVELOPE = ISO_C1;
+ public static final MediaType C2 = ISO_C2;
+ public static final MediaType ISO_C2_ENVELOPE = ISO_C2;
+ public static final MediaType C3 = ISO_C3;
+ public static final MediaType ISO_C3_ENVELOPE = ISO_C3;
+ public static final MediaType C4 = ISO_C4;
+ public static final MediaType ISO_C4_ENVELOPE = ISO_C4;
+ public static final MediaType C5 = ISO_C5;
+ public static final MediaType ISO_C5_ENVELOPE = ISO_C5;
+ public static final MediaType C6 = ISO_C6;
+ public static final MediaType ISO_C6_ENVELOPE = ISO_C6;
+ public static final MediaType C7 = ISO_C7;
+ public static final MediaType ISO_C7_ENVELOPE = ISO_C7;
+ public static final MediaType C8 = ISO_C8;
+ public static final MediaType ISO_C8_ENVELOPE = ISO_C8;
+ public static final MediaType C9 = ISO_C9;
+ public static final MediaType ISO_C9_ENVELOPE = ISO_C9;
+ public static final MediaType C10 = ISO_C10;
+ public static final MediaType ISO_C10_ENVELOPE = ISO_C10;
+ public static final MediaType ISO_DESIGNATED_LONG_ENVELOPE
+ = ISO_DESIGNATED_LONG;
+ public static final MediaType STATEMENT = INVOICE;
+ public static final MediaType TABLOID = LEDGER;
+ public static final MediaType LETTER = NA_LETTER;
+ public static final MediaType NOTE = NA_LETTER;
+ public static final MediaType LEGAL = NA_LEGAL;
+ public static final MediaType ENV_10X15 = NA_10X15_ENVELOPE;
+ public static final MediaType ENV_10X14 = NA_10X14_ENVELOPE;
+ public static final MediaType ENV_10X13 = NA_10X13_ENVELOPE;
+ public static final MediaType ENV_9X12 = NA_9X12_ENVELOPE;
+ public static final MediaType ENV_9X11 = NA_9X11_ENVELOPE;
+ public static final MediaType ENV_7X9 = NA_7X9_ENVELOPE;
+ public static final MediaType ENV_6X9 = NA_6X9_ENVELOPE;
+ public static final MediaType ENV_9 = NA_NUMBER_9_ENVELOPE;
+ public static final MediaType ENV_10 = NA_NUMBER_10_ENVELOPE;
+ public static final MediaType ENV_11 = NA_NUMBER_11_ENVELOPE;
+ public static final MediaType ENV_12 = NA_NUMBER_12_ENVELOPE;
+ public static final MediaType ENV_14 = NA_NUMBER_14_ENVELOPE;
+ public static final MediaType ENV_INVITE = INVITE_ENVELOPE;
+ public static final MediaType ENV_ITALY = ITALY_ENVELOPE;
+ public static final MediaType ENV_MONARCH = MONARCH_ENVELOPE;
+ public static final MediaType ENV_PERSONAL = PERSONAL_ENVELOPE;
+ public static final MediaType INVITE = INVITE_ENVELOPE;
+ public static final MediaType ITALY = ITALY_ENVELOPE;
+ public static final MediaType MONARCH = MONARCH_ENVELOPE;
+ public static final MediaType PERSONAL = PERSONAL_ENVELOPE;
+ private MediaType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class MediaType
+ public static final class OrientationRequestedType extends AttributeValue
+ {
+ private static final String[] NAMES = { "portrait", "landscape" };
+ public static final OrientationRequestedType PORTRAIT
+ = new OrientationRequestedType(0);
+ public static final OrientationRequestedType LANDSCAPE
+ = new OrientationRequestedType(1);
+ private OrientationRequestedType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class OrientationRequestedType
+ public static final class OriginType extends AttributeValue
+ {
+ private static final String[] NAMES = { "physical", "printable" };
+ public static final OriginType PHYSICAL = new OriginType(0);
+ public static final OriginType PRINTABLE = new OriginType(1);
+ private OriginType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class OriginType
+ public static final class PrintQualityType extends AttributeValue
+ {
+ private static final String[] NAMES = { "high", "normal", "draft" };
+ public static final PrintQualityType HIGH = new PrintQualityType(0);
+ public static final PrintQualityType NORMAL = new PrintQualityType(1);
+ public static final PrintQualityType DRAFT = new PrintQualityType(2);
+ private PrintQualityType(int value)
+ {
+ super(value, NAMES);
+ }
+ } // class PrintQualityType
+
+
+ private ColorType color;
+ private MediaType media;
+ private OrientationRequestedType orientation;
+ private OriginType origin;
+ private PrintQualityType quality;
+ private int resolutionX;
+ private int resolutionY;
+ private int resolutionScale;
+ public PageAttributes()
+ {
+ color = ColorType.MONOCHROME;
+ setMediaToDefault();
+ orientation = OrientationRequestedType.PORTRAIT;
+ origin = OriginType.PHYSICAL;
+ quality = PrintQualityType.NORMAL;
+ setPrinterResolutionToDefault();
+ }
+
+ public PageAttributes(PageAttributes attr)
+ {
+ set(attr);
+ }
+
+ public PageAttributes(ColorType color, MediaType media,
+ OrientationRequestedType orientation,
+ OriginType origin, PrintQualityType quality,
+ int[] resolution)
+ {
+ if (color == null || media == null || orientation == null
+ || origin == null || quality == null)
+ throw new IllegalArgumentException();
+ setPrinterResolution(resolution);
+ this.color = color;
+ this.media = media;
+ this.orientation = orientation;
+ this.origin = origin;
+ this.quality = quality;
+ }
+
+ public Object clone()
+ {
+ return new PageAttributes(this);
+ }
+
+ public void set(PageAttributes attr)
+ {
+ color = attr.color;
+ media = attr.media;
+ orientation = attr.orientation;
+ origin = attr.origin;
+ quality = attr.quality;
+ resolutionX = attr.resolutionX;
+ resolutionY = attr.resolutionY;
+ resolutionScale = attr.resolutionScale;
+ }
+
+ public ColorType getColor()
+ {
+ return color;
+ }
+
+ public void setColor(ColorType color)
+ {
+ if (color == null)
+ throw new IllegalArgumentException();
+ this.color = color;
+ }
+
+ public MediaType getMedia()
+ {
+ return media;
+ }
+
+ public void setMedia(MediaType media)
+ {
+ if (media == null)
+ throw new IllegalArgumentException();
+ this.media = media;
+ }
+
+ public void setMediaToDefault()
+ {
+ String country = Locale.getDefault().getCountry();
+ media = ("US".equals(country) || "CA".equals(country)) ? MediaType.LETTER
+ : MediaType.A4;
+ }
+
+ public OrientationRequestedType getOrientationRequested()
+ {
+ return orientation;
+ }
+
+ public void setOrientationRequested(OrientationRequestedType orientation)
+ {
+ if (orientation == null)
+ throw new IllegalArgumentException();
+ this.orientation = orientation;
+ }
+
+ public void setOrientationRequested(int orientation)
+ {
+ if (orientation == 3)
+ this.orientation = OrientationRequestedType.PORTRAIT;
+ else if (orientation == 4)
+ this.orientation = OrientationRequestedType.LANDSCAPE;
+ else
+ throw new IllegalArgumentException();
+ }
+
+ public void setOrientationRequestedToDefault()
+ {
+ orientation = OrientationRequestedType.PORTRAIT;
+ }
+
+ public OriginType getOrigin()
+ {
+ return origin;
+ }
+
+ public void setOrigin(OriginType origin)
+ {
+ if (origin == null)
+ throw new IllegalArgumentException();
+ this.origin = origin;
+ }
+
+ public PrintQualityType getPrintQuality()
+ {
+ return quality;
+ }
+
+ public void setPrintQuality(PrintQualityType quality)
+ {
+ if (quality == null)
+ throw new IllegalArgumentException();
+ this.quality = quality;
+ }
+
+ public void setPrintQuality(int quality)
+ {
+ if (quality == 3)
+ this.quality = PrintQualityType.DRAFT;
+ else if (quality == 4)
+ this.quality = PrintQualityType.NORMAL;
+ else if (quality == 5)
+ this.quality = PrintQualityType.HIGH;
+ else
+ throw new IllegalArgumentException();
+ }
+
+ public void setPrintQualityToDefault()
+ {
+ quality = PrintQualityType.NORMAL;
+ }
+
+ public int[] getPrinterResolution()
+ {
+ return new int[] { resolutionX, resolutionY, resolutionScale };
+ }
+
+ public void setPrinterResolution(int[] resolution)
+ {
+ if (resolution == null || resolution.length != 3 || resolution[0] <= 0
+ || resolution[1] <= 0 || resolution[2] < 3 || resolution[2] > 4)
+ throw new IllegalArgumentException();
+ resolutionX = resolution[0];
+ resolutionY = resolution[1];
+ resolutionScale = resolution[2];
+ }
+
+ public void setPrinterResolution(int resolution)
+ {
+ if (resolution <= 0)
+ throw new IllegalArgumentException();
+ resolutionX = resolution;
+ resolutionY = resolution;
+ resolutionScale = 3;
+ }
+
+ public void setPrinterResolutionToDefault()
+ {
+ resolutionX = 72;
+ resolutionY = 72;
+ resolutionScale = 3;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ return true;
+ if (! (o instanceof PageAttributes))
+ return false;
+ PageAttributes pa = (PageAttributes) o;
+ return color == pa.color && media == pa.media
+ && orientation == pa.orientation && origin == pa.origin
+ && quality == pa.quality && resolutionX == pa.resolutionX
+ && resolutionY == pa.resolutionY
+ && resolutionScale == pa.resolutionScale;
+ }
+ public int hashCode()
+ {
+ return (color.value << 31) ^ (media.value << 24)
+ ^ (orientation.value << 23) ^ (origin.value << 22)
+ ^ (quality.value << 20) ^ (resolutionScale << 19)
+ ^ (resolutionY << 10) ^ resolutionX;
+ }
+ public String toString()
+ {
+ return "color=" + color + ",media=" + media + ",orientation-requested="
+ + orientation + ",origin=" + origin + ",print-quality=" + quality
+ + ",printer-resolution=[" + resolutionX + ',' + resolutionY + ','
+ + resolutionScale + ']';
+ }
+} // class PageAttributes
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Paint.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Paint.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Paint.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Paint.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,79 @@
+/* Paint.java -- generate colors for Graphics2D operations
+ Copyright (C) 2000, 2002 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
+
+/**
+ * Defines how color patterns are generated for Graphics2D operations. This
+ * is used to perform the <code>draw</code> and <code>fill</code> methods
+ * of the graphics object. Instances must be immutable, because the graphics
+ * object does not clone them.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see PaintContext
+ * @see Color
+ * @see GradientPaint
+ * @see TexturePaint
+ * @see Graphics2D#setPaint(Paint)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface Paint extends Transparency
+{
+ /**
+ * Create the context necessary for performing the color pattern generation.
+ * The color model is a hint, and may be null for Classpath implementations;
+ * however some legacy code may throw a NullPointerException when passed a
+ * null. Leaving the color model null provides the most efficiency and leeway
+ * in the generation of the color pattern.
+ *
+ * @param cm the color model, used as a hint
+ * @param deviceBounds the device space bounding box of the painted area
+ * @param userBounds the user space bounding box of the painted area
+ * @param xform the transformation from user space to device space
+ * @param hints any hints for choosing between rendering alternatives
+ * @return the context for performing the paint
+ */
+ PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+ Rectangle2D userBounds, AffineTransform xform,
+ RenderingHints hints);
+} // interface Paint
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PaintContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PaintContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PaintContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PaintContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,76 @@
+/* PaintContext.java -- the environment for performing a paint operation
+ Copyright (C) 2000, 2002 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+
+/**
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @see Paint
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface PaintContext
+{
+ /**
+ * Release the resources allocated for the paint.
+ */
+ void dispose();
+
+ /**
+ * Return the color model of this context. It may be different from the
+ * hint specified during createContext, as not all contexts can generate
+ * color patterns in an arbitrary model.
+ *
+ * @return the context color model
+ */
+ ColorModel getColorModel();
+
+ /**
+ * Return a raster containing the colors for the graphics operation.
+ *
+ * @param x the x-coordinate, in device space
+ * @param y the y-coordinate, in device space
+ * @param w the width, in device space
+ * @param h the height, in device space
+ * @return a raster for the given area and color
+ */
+ Raster getRaster(int x, int y, int w, int h);
+} // interface PaintContext
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Panel.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Panel.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Panel.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Panel.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,173 @@
+/* Panel.java -- Simple container object
+ Copyright (C) 1999, 2002, 2004, 2005 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 javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * A panel is a simple container class. It's default layout is the
+ * <code>FlowLayout</code> manager.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see FlowLayout
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Panel extends Container implements Accessible
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -2728009084054400034L;
+
+ /** The cached accessible context. */
+ private transient AccessibleContext context;
+
+ /** Flag set when the first system-requested paint event is
+ dispatched. */
+ private transient boolean initialSystemUpdateDone;
+
+ /** Flag set when the first application-requested paint event is
+ consumed. */
+ private transient boolean initialUpdateConsumed;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_panel_number;
+
+ /**
+ * Initializes a new instance of <code>Panel</code> that has a default
+ * layout manager of <code>FlowLayout</code>.
+ */
+ public Panel()
+ {
+ this(new FlowLayout());
+ }
+
+ /**
+ * Initializes a new instance of <code>Panel</code> with the specified
+ * layout manager.
+ *
+ * @param layoutManager the layout manager for this object
+ * @since 1.1
+ */
+ public Panel(LayoutManager layoutManager)
+ {
+ setLayout(layoutManager);
+ }
+
+ /**
+ * Notifies this object to create its native peer.
+ *
+ * @see #isDisplayable()
+ * @see #removeNotify()
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit().createPanel(this);
+ super.addNotify();
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this panel, creating one if
+ * necessary. This always returns an instance of {@link AccessibleAWTPanel}.
+ *
+ * @return the accessibility context of this panel
+ * @since 1.3
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (context == null)
+ context = new AccessibleAWTPanel();
+ return context;
+ }
+
+ /**
+ * This class provides accessibility support for Panels, and is the
+ * runtime type returned by {@link #getAccessibleContext()}.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.3
+ */
+ protected class AccessibleAWTPanel extends AccessibleAWTContainer
+ {
+ /**
+ * Compatible with JDK 1.4+.
+ */
+ private static final long serialVersionUID = -6409552226660031050L;
+
+ /**
+ * The default constructor.
+ */
+ protected AccessibleAWTPanel()
+ {
+ }
+
+ /**
+ * Get the role of this accessible object, a panel.
+ *
+ * @return the role of the object
+ * @see AccessibleRole#PANEL
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.PANEL;
+ }
+ }
+
+ /**
+ * Generate a unique name for this panel.
+ *
+ * @return A unique name for this panel.
+ */
+ String generateName ()
+ {
+ return "panel" + getUniqueLong ();
+ }
+
+ private static synchronized long getUniqueLong ()
+ {
+ return next_panel_number++;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Point.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Point.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Point.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Point.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,250 @@
+/* Point.java -- represents a point in 2-D space
+ Copyright (C) 1999, 2002, 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.geom.Point2D;
+import java.io.Serializable;
+
+/**
+ * This class represents a point on the screen using cartesian coordinates.
+ * Remember that in screen coordinates, increasing x values go from left to
+ * right, and increasing y values go from top to bottom.
+ *
+ * <p>There are some public fields; if you mess with them in an inconsistent
+ * manner, it is your own fault when you get invalid results. Also, this
+ * class is not threadsafe.
+ *
+ * @author Per Bothner (bothner at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Point extends Point2D implements Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -5276940640259749850L;
+
+ /**
+ * The x coordinate.
+ *
+ * @see #getLocation()
+ * @see #move(int, int)
+ * @serial the X coordinate of the point
+ */
+ public int x;
+
+ /**
+ * The y coordinate.
+ *
+ * @see #getLocation()
+ * @see #move(int, int)
+ * @serial The Y coordinate of the point
+ */
+ public int y;
+
+ /**
+ * Initializes a new instance of <code>Point</code> representing the
+ * coordinates (0, 0).
+ *
+ * @since 1.1
+ */
+ public Point()
+ {
+ }
+
+ /**
+ * Initializes a new instance of <code>Point</code> with coordinates
+ * identical to the coordinates of the specified point.
+ *
+ * @param p the point to copy the coordinates from
+ * @throws NullPointerException if p is null
+ */
+ public Point(Point p)
+ {
+ x = p.x;
+ y = p.y;
+ }
+
+ /**
+ * Initializes a new instance of <code>Point</code> with the specified
+ * coordinates.
+ *
+ * @param x the X coordinate
+ * @param y the Y coordinate
+ */
+ public Point(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Get the x coordinate.
+ *
+ * @return the value of x, as a double
+ */
+ public double getX()
+ {
+ return x;
+ }
+
+ /**
+ * Get the y coordinate.
+ *
+ * @return the value of y, as a double
+ */
+ public double getY()
+ {
+ return y;
+ }
+
+ /**
+ * Returns the location of this point. A pretty useless method, as this
+ * is already a point.
+ *
+ * @return a copy of this point
+ * @see #setLocation(Point)
+ * @since 1.1
+ */
+ public Point getLocation()
+ {
+ return new Point(x, y);
+ }
+
+ /**
+ * Sets this object's coordinates to match those of the specified point.
+ *
+ * @param p the point to copy the coordinates from
+ * @throws NullPointerException if p is null
+ * @since 1.1
+ */
+ public void setLocation(Point p)
+ {
+ x = p.x;
+ y = p.y;
+ }
+
+ /**
+ * Sets this object's coordinates to the specified values. This method
+ * is identical to the <code>move()</code> method.
+ *
+ * @param x the new X coordinate
+ * @param y the new Y coordinate
+ */
+ public void setLocation(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Sets this object's coordinates to the specified values. This method
+ * rounds to the nearest integer coordinates by adding 0.5 and calling
+ * {@link Math#floor(double)}.
+ *
+ * @param x the new X coordinate
+ * @param y the new Y coordinate
+ */
+ public void setLocation(double x, double y)
+ {
+ this.x = (int) Math.floor(x + 0.5);
+ this.y = (int) Math.floor(y + 0.5);
+ }
+
+ /**
+ * Sets this object's coordinates to the specified values. This method
+ * is identical to the <code>setLocation(int, int)</code> method.
+ *
+ * @param x the new X coordinate
+ * @param y the new Y coordinate
+ */
+ public void move(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Changes the coordinates of this point such that the specified
+ * <code>dx</code> parameter is added to the existing X coordinate and
+ * <code>dy</code> is added to the existing Y coordinate.
+ *
+ * @param dx the amount to add to the X coordinate
+ * @param dy the amount to add to the Y coordinate
+ */
+ public void translate(int dx, int dy)
+ {
+ x += dx;
+ y += dy;
+ }
+
+ /**
+ * Tests whether or not this object is equal to the specified object.
+ * This will be true if and only if the specified object is an instance
+ * of Point2D and has the same X and Y coordinates.
+ *
+ * @param obj the object to test against for equality
+ * @return true if the specified object is equal
+ */
+ public boolean equals(Object obj)
+ {
+ // NOTE: No special hashCode() method is required for this class,
+ // as this equals() implementation is functionally equivalent to
+ // super.equals(), which does define a proper hashCode().
+
+ if (! (obj instanceof Point2D))
+ return false;
+ Point2D p = (Point2D) obj;
+ return x == p.getX() && y == p.getY();
+ }
+
+ /**
+ * Returns a string representation of this object. The format is:
+ * <code>getClass().getName() + "[x=" + x + ",y=" + y + ']'</code>.
+ *
+ * @return a string representation of this object
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[x=" + x + ",y=" + y + ']';
+ }
+} // class Point
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PointerInfo.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PointerInfo.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PointerInfo.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PointerInfo.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,84 @@
+/* PointerInfo.java -- mouse pointer data
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt;
+
+/**
+ * PointerInfo represents information about the mouse pointer,
+ * i.e. its GraphicsDevice and location.
+ *
+ * PointerInfo objects cannot be instantiated directly, but are
+ * retrieved from MouseInfo.getPointerInfo(). PointerInfo objects
+ * are immutable and will not be updated for future mouse motions.
+ *
+ * @since 1.5
+ * @author Sven de Marothy
+ */
+public class PointerInfo
+{
+ private GraphicsDevice gd;
+ private Point p;
+
+ /**
+ * Package-private constructor used by MouseInfo.
+ */
+ PointerInfo( GraphicsDevice gd, Point p )
+ {
+ this.gd = gd;
+ this.p = p;
+ }
+
+ /**
+ * Returns the GraphicsDevice on which the mouse pointer was located
+ *
+ * @return a GraphicsDevice object.
+ */
+ public GraphicsDevice getDevice()
+ {
+ return gd;
+ }
+
+ /**
+ * Returns the coordinates of the mouse pointer.
+ *
+ * @return a Point object containing the pointer coordinates.
+ */
+ public Point getLocation()
+ {
+ return p;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Polygon.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Polygon.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Polygon.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Polygon.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,612 @@
+/* Polygon.java -- class representing a polygon
+ Copyright (C) 1999, 2002, 2004, 2005 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 java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+
+/**
+ * This class represents a polygon, a closed, two-dimensional region in a
+ * coordinate space. The region is bounded by an arbitrary number of line
+ * segments, between (x,y) coordinate vertices. The polygon has even-odd
+ * winding, meaning that a point is inside the shape if it crosses the
+ * boundary an odd number of times on the way to infinity.
+ *
+ * <p>There are some public fields; if you mess with them in an inconsistent
+ * manner, it is your own fault when you get NullPointerException,
+ * ArrayIndexOutOfBoundsException, or invalid results. Also, this class is
+ * not threadsafe.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Polygon implements Shape, Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -6460061437900069969L;
+
+ /**
+ * This total number of endpoints.
+ *
+ * @serial the number of endpoints, possibly less than the array sizes
+ */
+ public int npoints;
+
+ /**
+ * The array of X coordinates of endpoints. This should not be null.
+ *
+ * @see #addPoint(int, int)
+ * @serial the x coordinates
+ */
+ public int[] xpoints;
+
+ /**
+ * The array of Y coordinates of endpoints. This should not be null.
+ *
+ * @see #addPoint(int, int)
+ * @serial the y coordinates
+ */
+ public int[] ypoints;
+
+ /**
+ * The bounding box of this polygon. This is lazily created and cached, so
+ * it must be invalidated after changing points.
+ *
+ * @see #getBounds()
+ * @serial the bounding box, or null
+ */
+ protected Rectangle bounds;
+
+ /** A big number, but not so big it can't survive a few float operations */
+ private static final double BIG_VALUE = java.lang.Double.MAX_VALUE / 10.0;
+
+ /**
+ * Initializes an empty polygon.
+ */
+ public Polygon()
+ {
+ // Leave room for growth.
+ xpoints = new int[4];
+ ypoints = new int[4];
+ }
+
+ /**
+ * Create a new polygon with the specified endpoints. The arrays are copied,
+ * so that future modifications to the parameters do not affect the polygon.
+ *
+ * @param xpoints the array of X coordinates for this polygon
+ * @param ypoints the array of Y coordinates for this polygon
+ * @param npoints the total number of endpoints in this polygon
+ * @throws NegativeArraySizeException if npoints is negative
+ * @throws IndexOutOfBoundsException if npoints exceeds either array
+ * @throws NullPointerException if xpoints or ypoints is null
+ */
+ public Polygon(int[] xpoints, int[] ypoints, int npoints)
+ {
+ this.xpoints = new int[npoints];
+ this.ypoints = new int[npoints];
+ System.arraycopy(xpoints, 0, this.xpoints, 0, npoints);
+ System.arraycopy(ypoints, 0, this.ypoints, 0, npoints);
+ this.npoints = npoints;
+ }
+
+ /**
+ * Reset the polygon to be empty. The arrays are left alone, to avoid object
+ * allocation, but the number of points is set to 0, and all cached data
+ * is discarded. If you are discarding a huge number of points, it may be
+ * more efficient to just create a new Polygon.
+ *
+ * @see #invalidate()
+ * @since 1.4
+ */
+ public void reset()
+ {
+ npoints = 0;
+ invalidate();
+ }
+
+ /**
+ * Invalidate or flush all cached data. After direct manipulation of the
+ * public member fields, this is necessary to avoid inconsistent results
+ * in methods like <code>contains</code>.
+ *
+ * @see #getBounds()
+ * @since 1.4
+ */
+ public void invalidate()
+ {
+ bounds = null;
+ }
+
+ /**
+ * Translates the polygon by adding the specified values to all X and Y
+ * coordinates. This updates the bounding box, if it has been calculated.
+ *
+ * @param dx the amount to add to all X coordinates
+ * @param dy the amount to add to all Y coordinates
+ * @since 1.1
+ */
+ public void translate(int dx, int dy)
+ {
+ int i = npoints;
+ while (--i >= 0)
+ {
+ xpoints[i] += dx;
+ ypoints[i] += dy;
+ }
+ if (bounds != null)
+ {
+ bounds.x += dx;
+ bounds.y += dy;
+ }
+ }
+
+ /**
+ * Adds the specified endpoint to the polygon. This updates the bounding
+ * box, if it has been created.
+ *
+ * @param x the X coordinate of the point to add
+ * @param y the Y coordiante of the point to add
+ */
+ public void addPoint(int x, int y)
+ {
+ if (npoints + 1 > xpoints.length)
+ {
+ int[] newx = new int[npoints + 1];
+ System.arraycopy(xpoints, 0, newx, 0, npoints);
+ xpoints = newx;
+ }
+ if (npoints + 1 > ypoints.length)
+ {
+ int[] newy = new int[npoints + 1];
+ System.arraycopy(ypoints, 0, newy, 0, npoints);
+ ypoints = newy;
+ }
+ xpoints[npoints] = x;
+ ypoints[npoints] = y;
+ npoints++;
+ if (bounds != null)
+ {
+ if (npoints == 1)
+ {
+ bounds.x = x;
+ bounds.y = y;
+ }
+ else
+ {
+ if (x < bounds.x)
+ {
+ bounds.width += bounds.x - x;
+ bounds.x = x;
+ }
+ else if (x > bounds.x + bounds.width)
+ bounds.width = x - bounds.x;
+ if (y < bounds.y)
+ {
+ bounds.height += bounds.y - y;
+ bounds.y = y;
+ }
+ else if (y > bounds.y + bounds.height)
+ bounds.height = y - bounds.y;
+ }
+ }
+ }
+
+ /**
+ * Returns the bounding box of this polygon. This is the smallest
+ * rectangle with sides parallel to the X axis that will contain this
+ * polygon.
+ *
+ * @return the bounding box for this polygon
+ * @see #getBounds2D()
+ * @since 1.1
+ */
+ public Rectangle getBounds()
+ {
+ return getBoundingBox();
+ }
+
+ /**
+ * Returns the bounding box of this polygon. This is the smallest
+ * rectangle with sides parallel to the X axis that will contain this
+ * polygon.
+ *
+ * @return the bounding box for this polygon
+ * @see #getBounds2D()
+ * @deprecated use {@link #getBounds()} instead
+ */
+ public Rectangle getBoundingBox()
+ {
+ if (bounds == null)
+ {
+ if (npoints == 0)
+ return bounds = new Rectangle();
+ int i = npoints - 1;
+ int minx = xpoints[i];
+ int maxx = minx;
+ int miny = ypoints[i];
+ int maxy = miny;
+ while (--i >= 0)
+ {
+ int x = xpoints[i];
+ int y = ypoints[i];
+ if (x < minx)
+ minx = x;
+ else if (x > maxx)
+ maxx = x;
+ if (y < miny)
+ miny = y;
+ else if (y > maxy)
+ maxy = y;
+ }
+ bounds = new Rectangle(minx, miny, maxx - minx, maxy - miny);
+ }
+ return bounds;
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this polygon.
+ *
+ * @param p the point to test
+ * @return true if the point is inside this polygon
+ * @throws NullPointerException if p is null
+ * @see #contains(double, double)
+ */
+ public boolean contains(Point p)
+ {
+ return contains(p.getX(), p.getY());
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this polygon.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is inside this polygon
+ * @see #contains(double, double)
+ * @since 1.1
+ */
+ public boolean contains(int x, int y)
+ {
+ return contains((double) x, (double) y);
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this polygon.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is inside this polygon
+ * @see #contains(double, double)
+ * @deprecated use {@link #contains(int, int)} instead
+ */
+ public boolean inside(int x, int y)
+ {
+ return contains((double) x, (double) y);
+ }
+
+ /**
+ * Returns a high-precision bounding box of this polygon. This is the
+ * smallest rectangle with sides parallel to the X axis that will contain
+ * this polygon.
+ *
+ * @return the bounding box for this polygon
+ * @see #getBounds()
+ * @since 1.2
+ */
+ public Rectangle2D getBounds2D()
+ {
+ // For polygons, the integer version is exact!
+ return getBounds();
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this polygon.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is inside this polygon
+ * @since 1.2
+ */
+ public boolean contains(double x, double y)
+ {
+ return ((evaluateCrossings(x, y, false, BIG_VALUE) & 1) != 0);
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this polygon.
+ *
+ * @param p the point to test
+ * @return true if the point is inside this polygon
+ * @throws NullPointerException if p is null
+ * @see #contains(double, double)
+ * @since 1.2
+ */
+ public boolean contains(Point2D p)
+ {
+ return contains(p.getX(), p.getY());
+ }
+
+ /**
+ * Test if a high-precision rectangle intersects the shape. This is true
+ * if any point in the rectangle is in the shape. This implementation is
+ * precise.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param w the width of the rectangle, treated as point if negative
+ * @param h the height of the rectangle, treated as point if negative
+ * @return true if the rectangle intersects this shape
+ * @since 1.2
+ */
+ public boolean intersects(double x, double y, double w, double h)
+ {
+ /* Does any edge intersect? */
+ if (evaluateCrossings(x, y, false, w) != 0 /* top */
+ || evaluateCrossings(x, y + h, false, w) != 0 /* bottom */
+ || evaluateCrossings(x + w, y, true, h) != 0 /* right */
+ || evaluateCrossings(x, y, true, h) != 0) /* left */
+ return true;
+
+ /* No intersections, is any point inside? */
+ if ((evaluateCrossings(x, y, false, BIG_VALUE) & 1) != 0)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Test if a high-precision rectangle intersects the shape. This is true
+ * if any point in the rectangle is in the shape. This implementation is
+ * precise.
+ *
+ * @param r the rectangle
+ * @return true if the rectangle intersects this shape
+ * @throws NullPointerException if r is null
+ * @see #intersects(double, double, double, double)
+ * @since 1.2
+ */
+ public boolean intersects(Rectangle2D r)
+ {
+ return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+ }
+
+ /**
+ * Test if a high-precision rectangle lies completely in the shape. This is
+ * true if all points in the rectangle are in the shape. This implementation
+ * is precise.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param w the width of the rectangle, treated as point if negative
+ * @param h the height of the rectangle, treated as point if negative
+ * @return true if the rectangle is contained in this shape
+ * @since 1.2
+ */
+ public boolean contains(double x, double y, double w, double h)
+ {
+ if (! getBounds2D().intersects(x, y, w, h))
+ return false;
+
+ /* Does any edge intersect? */
+ if (evaluateCrossings(x, y, false, w) != 0 /* top */
+ || evaluateCrossings(x, y + h, false, w) != 0 /* bottom */
+ || evaluateCrossings(x + w, y, true, h) != 0 /* right */
+ || evaluateCrossings(x, y, true, h) != 0) /* left */
+ return false;
+
+ /* No intersections, is any point inside? */
+ if ((evaluateCrossings(x, y, false, BIG_VALUE) & 1) != 0)
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Test if a high-precision rectangle lies completely in the shape. This is
+ * true if all points in the rectangle are in the shape. This implementation
+ * is precise.
+ *
+ * @param r the rectangle
+ * @return true if the rectangle is contained in this shape
+ * @throws NullPointerException if r is null
+ * @see #contains(double, double, double, double)
+ * @since 1.2
+ */
+ public boolean contains(Rectangle2D r)
+ {
+ return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+ }
+
+ /**
+ * Return an iterator along the shape boundary. If the optional transform
+ * is provided, the iterator is transformed accordingly. Each call returns
+ * a new object, independent from others in use. This class is not
+ * threadsafe to begin with, so the path iterator is not either.
+ *
+ * @param transform an optional transform to apply to the iterator
+ * @return a new iterator over the boundary
+ * @since 1.2
+ */
+ public PathIterator getPathIterator(final AffineTransform transform)
+ {
+ return new PathIterator()
+ {
+ /** The current vertex of iteration. */
+ private int vertex;
+
+ public int getWindingRule()
+ {
+ return WIND_EVEN_ODD;
+ }
+
+ public boolean isDone()
+ {
+ return vertex > npoints;
+ }
+
+ public void next()
+ {
+ vertex++;
+ }
+
+ public int currentSegment(float[] coords)
+ {
+ if (vertex >= npoints)
+ return SEG_CLOSE;
+ coords[0] = xpoints[vertex];
+ coords[1] = ypoints[vertex];
+ if (transform != null)
+ transform.transform(coords, 0, coords, 0, 1);
+ return vertex == 0 ? SEG_MOVETO : SEG_LINETO;
+ }
+
+ public int currentSegment(double[] coords)
+ {
+ if (vertex >= npoints)
+ return SEG_CLOSE;
+ coords[0] = xpoints[vertex];
+ coords[1] = ypoints[vertex];
+ if (transform != null)
+ transform.transform(coords, 0, coords, 0, 1);
+ return vertex == 0 ? SEG_MOVETO : SEG_LINETO;
+ }
+ };
+ }
+
+ /**
+ * Return an iterator along the flattened version of the shape boundary.
+ * Since polygons are already flat, the flatness parameter is ignored, and
+ * the resulting iterator only has SEG_MOVETO, SEG_LINETO and SEG_CLOSE
+ * points. If the optional transform is provided, the iterator is
+ * transformed accordingly. Each call returns a new object, independent
+ * from others in use. This class is not threadsafe to begin with, so the
+ * path iterator is not either.
+ *
+ * @param transform an optional transform to apply to the iterator
+ * @param flatness the maximum distance for deviation from the real boundary
+ * @return a new iterator over the boundary
+ * @since 1.2
+ */
+ public PathIterator getPathIterator(AffineTransform transform,
+ double flatness)
+ {
+ return getPathIterator(transform);
+ }
+
+ /**
+ * Helper for contains, intersects, calculates the number of intersections
+ * between the polygon and a line extending from the point (x, y) along
+ * the positive X, or Y axis, within a given interval.
+ *
+ * @return the winding number.
+ * @see #contains(double, double)
+ */
+ private int evaluateCrossings(double x, double y, boolean useYaxis,
+ double distance)
+ {
+ double x0;
+ double x1;
+ double y0;
+ double y1;
+ double epsilon = 0.0;
+ int crossings = 0;
+ int[] xp;
+ int[] yp;
+
+ if (useYaxis)
+ {
+ xp = ypoints;
+ yp = xpoints;
+ double swap;
+ swap = y;
+ y = x;
+ x = swap;
+ }
+ else
+ {
+ xp = xpoints;
+ yp = ypoints;
+ }
+
+ /* Get a value which is small but not insignificant relative the path. */
+ epsilon = 1E-7;
+
+ x0 = xp[0] - x;
+ y0 = yp[0] - y;
+ for (int i = 1; i < npoints; i++)
+ {
+ x1 = xp[i] - x;
+ y1 = yp[i] - y;
+
+ if (y0 == 0.0)
+ y0 -= epsilon;
+ if (y1 == 0.0)
+ y1 -= epsilon;
+ if (y0 * y1 < 0)
+ if (Line2D.linesIntersect(x0, y0, x1, y1, epsilon, 0.0, distance, 0.0))
+ ++crossings;
+
+ x0 = xp[i] - x;
+ y0 = yp[i] - y;
+ }
+
+ // end segment
+ x1 = xp[0] - x;
+ y1 = yp[0] - y;
+ if (y0 == 0.0)
+ y0 -= epsilon;
+ if (y1 == 0.0)
+ y1 -= epsilon;
+ if (y0 * y1 < 0)
+ if (Line2D.linesIntersect(x0, y0, x1, y1, epsilon, 0.0, distance, 0.0))
+ ++crossings;
+
+ return crossings;
+ }
+} // class Polygon
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PopupMenu.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PopupMenu.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PopupMenu.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PopupMenu.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,191 @@
+/* PopupMenu.java -- An AWT popup menu
+ Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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 java.awt.peer.PopupMenuPeer;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+/**
+ * This class implement an AWT popup menu widget
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class PopupMenu extends Menu
+{
+
+/*
+ * Static Variables
+ */
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_popup_number;
+
+ // Serialization Constant
+ private static final long serialVersionUID = - 4620452533522760060L;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>PopupMenu</code>.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+public
+PopupMenu()
+{
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>PopupMenu</code> with the specified
+ * label.
+ *
+ * @param label The label for this popup menu.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+public
+PopupMenu(String label)
+{
+ super(label);
+
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+ * Creates this object's native peer.
+ */
+public void
+addNotify()
+{
+ if (peer == null)
+ peer = getToolkit ().createPopupMenu (this);
+ super.addNotify ();
+}
+
+/*************************************************************************/
+
+/**
+ * Displays this popup menu at the specified coordinates relative to
+ * the specified component.
+ *
+ * @param component The component to which the display coordinates are relative.
+ * @param x The X coordinate of the menu.
+ * @param y The Y coordinate of the menu.
+ */
+public void
+show(Component component, int x, int y)
+{
+ if (getPeer() == null)
+ this.addNotify();
+ PopupMenuPeer pmp = (PopupMenuPeer)getPeer();
+ if (pmp != null)
+ {
+ /* XXX
+ Event e = new Event (component, Event.ACTION_EVENT, component);
+ e.x = x;
+ e.y = y;*/
+ pmp.show (component, x, y);
+ }
+}
+
+ protected class AccessibleAWTPopupMenu extends AccessibleAWTMenu
+ {
+ private static final long serialVersionUID = -4282044795947239955L;
+
+ protected AccessibleAWTPopupMenu()
+ {
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.POPUP_MENU;
+ }
+
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>PopupMenu</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 AccessibleAWTPopupMenu();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this <code>PopupMenu</code>.
+ *
+ * @return A unique name for this <code>PopupMenu</code>.
+ */
+ String generateName()
+ {
+ return "popup" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_popup_number++;
+ }
+
+} // class PopupMenu
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintGraphics.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintGraphics.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintGraphics.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintGraphics.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* PrintGraphics.java -- a print graphics context
+ Copyright (C) 1999, 2002, 2005 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;
+
+/**
+ * This interface allows the originating print job to be obtained.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface PrintGraphics
+{
+ /**
+ * Returns the <code>PrintJob</code> that this object is being
+ * managed by.
+ *
+ * @return the print job for this object
+ */
+ PrintJob getPrintJob();
+} // interface PrintGraphics
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintJob.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintJob.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintJob.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/PrintJob.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,104 @@
+/* PrintJob.java -- A print job class
+ Copyright (C) 1999, 2002, 2005 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 java.util.Properties;
+
+/**
+ * This abstract class represents a print job.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see Toolkit#getPrintJob(Frame, String, Properties)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public abstract class PrintJob
+{
+ /**
+ * Create a new PrintJob.
+ */
+ public PrintJob()
+ {
+ }
+
+ /**
+ * Returns a graphics context suitable for rendering the next page. The
+ * return must also implement {@link PrintGraphics}.
+ *
+ * @return a graphics context for printing the next page
+ */
+ public abstract Graphics getGraphics();
+
+ /**
+ * Returns the dimension of the page in pixels. The resolution will be
+ * chosen to be similar to the on screen image.
+ *
+ * @return the page dimensions
+ */
+ public abstract Dimension getPageDimension();
+
+ /**
+ * Returns the resolution of the page in pixels per inch. Note that this is
+ * not necessarily the printer's resolution.
+ *
+ * @return the resolution of the page in pixels per inch
+ */
+ public abstract int getPageResolution();
+
+ /**
+ * Tests whether or not the last page will be printed first.
+ *
+ * @return true if the last page prints first
+ */
+ public abstract boolean lastPageFirst();
+
+ /**
+ * Informs the print job that printing is complete or should be aborted.
+ */
+ public abstract void end();
+
+ /**
+ * This method explicitly ends the print job in the event the job
+ * becomes un-referenced without the application having done so.
+ */
+ public void finalize()
+ {
+ end();
+ }
+} // class PrintJob
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Rectangle.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Rectangle.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Rectangle.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Rectangle.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,753 @@
+/* Rectangle.java -- represents a graphics rectangle
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+
+/**
+ * This class represents a rectangle and all the interesting things you
+ * might want to do with it. Note that the coordinate system uses
+ * the origin (0,0) as the top left of the screen, with the x and y
+ * values increasing as they move to the right and down respectively.
+ *
+ * <p>It is valid for a rectangle to have negative width or height; but it
+ * is considered to have no area or internal points. Therefore, the behavior
+ * in methods like <code>contains</code> or <code>intersects</code> is
+ * undefined unless the rectangle has positive width and height.
+ *
+ * <p>There are some public fields; if you mess with them in an inconsistent
+ * manner, it is your own fault when you get NullPointerException,
+ * ArrayIndexOutOfBoundsException, or invalid results. Also, this class is
+ * not threadsafe.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public class Rectangle extends Rectangle2D implements Shape, Serializable
+{
+ /**
+ * Compatible with JDK 1.0+.
+ */
+ private static final long serialVersionUID = -4345857070255674764L;
+
+ /**
+ * The X coordinate of the top-left corner of the rectangle.
+ *
+ * @see #setLocation(int, int)
+ * @see #getLocation()
+ * @serial the x coordinate
+ */
+ public int x;
+
+ /**
+ * The Y coordinate of the top-left corner of the rectangle.
+ *
+ * @see #setLocation(int, int)
+ * @see #getLocation()
+ * @serial the y coordinate
+ */
+ public int y;
+
+ /**
+ * The width of the rectangle.
+ *
+ * @see #setSize(int, int)
+ * @see #getSize()
+ * @serial
+ */
+ public int width;
+
+ /**
+ * The height of the rectangle.
+ *
+ * @see #setSize(int, int)
+ * @see #getSize()
+ * @serial
+ */
+ public int height;
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> with a top
+ * left corner at (0,0) and a width and height of 0.
+ */
+ public Rectangle()
+ {
+ }
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> from the
+ * coordinates of the specified rectangle.
+ *
+ * @param r the rectangle to copy from
+ * @throws NullPointerException if r is null
+ * @since 1.1
+ */
+ public Rectangle(Rectangle r)
+ {
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> from the specified
+ * inputs.
+ *
+ * @param x the X coordinate of the top left corner
+ * @param y the Y coordinate of the top left corner
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ */
+ public Rectangle(int x, int y, int width, int height)
+ {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> with the specified
+ * width and height. The upper left corner of the rectangle will be at
+ * the origin (0,0).
+ *
+ * @param width the width of the rectangle
+ * @param height the height of the rectange
+ */
+ public Rectangle(int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> with a top-left
+ * corner represented by the specified point and the width and height
+ * represented by the specified dimension.
+ *
+ * @param p the upper left corner of the rectangle
+ * @param d the width and height of the rectangle
+ * @throws NullPointerException if p or d is null
+ */
+ public Rectangle(Point p, Dimension d)
+ {
+ x = p.x;
+ y = p.y;
+ width = d.width;
+ height = d.height;
+ }
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> with a top left
+ * corner at the specified point and a width and height of zero.
+ *
+ * @param p the upper left corner of the rectangle
+ */
+ public Rectangle(Point p)
+ {
+ x = p.x;
+ y = p.y;
+ }
+
+ /**
+ * Initializes a new instance of <code>Rectangle</code> with an
+ * upper left corner at the origin (0,0) and a width and height represented
+ * by the specified dimension.
+ *
+ * @param d the width and height of the rectangle
+ */
+ public Rectangle(Dimension d)
+ {
+ width = d.width;
+ height = d.height;
+ }
+
+ /**
+ * Get the X coordinate of the upper-left corner.
+ *
+ * @return the value of x, as a double
+ */
+ public double getX()
+ {
+ return x;
+ }
+
+ /**
+ * Get the Y coordinate of the upper-left corner.
+ *
+ * @return the value of y, as a double
+ */
+ public double getY()
+ {
+ return y;
+ }
+
+ /**
+ * Get the width of the rectangle.
+ *
+ * @return the value of width, as a double
+ */
+ public double getWidth()
+ {
+ return width;
+ }
+
+ /**
+ * Get the height of the rectangle.
+ *
+ * @return the value of height, as a double
+ */
+ public double getHeight()
+ {
+ return height;
+ }
+
+ /**
+ * Returns the bounds of this rectangle. A pretty useless method, as this
+ * is already a rectangle; it is included to mimic the
+ * <code>getBounds</code> method in Component.
+ *
+ * @return a copy of this rectangle
+ * @see #setBounds(Rectangle)
+ * @since 1.1
+ */
+ public Rectangle getBounds()
+ {
+ return new Rectangle(this);
+ }
+
+ /**
+ * Returns the high-precision bounds of this rectangle. A pretty useless
+ * method, as this is already a rectangle.
+ *
+ * @return a copy of this rectangle
+ * @see #setBounds(Rectangle)
+ * @since 1.2
+ */
+ public Rectangle2D getBounds2D()
+ {
+ return new Rectangle(x, y, width, height);
+ }
+
+ /**
+ * Updates this rectangle to match the dimensions of the specified
+ * rectangle.
+ *
+ * @param r the rectangle to update from
+ * @throws NullPointerException if r is null
+ * @see #setBounds(int, int, int, int)
+ * @since 1.1
+ */
+ public void setBounds(Rectangle r)
+ {
+ setBounds (r.x, r.y, r.width, r.height);
+ }
+
+ /**
+ * Updates this rectangle to have the specified dimensions.
+ *
+ * @param x the new X coordinate of the upper left hand corner
+ * @param y the new Y coordinate of the upper left hand corner
+ * @param width the new width of this rectangle
+ * @param height the new height of this rectangle
+ * @since 1.1
+ */
+ public void setBounds(int x, int y, int width, int height)
+ {
+ reshape (x, y, width, height);
+ }
+
+ /**
+ * Updates this rectangle to have the specified dimensions, as rounded to
+ * integers.
+ *
+ * @param x the new X coordinate of the upper left hand corner
+ * @param y the new Y coordinate of the upper left hand corner
+ * @param width the new width of this rectangle
+ * @param height the new height of this rectangle
+ * @since 1.2
+ */
+ public void setRect(double x, double y, double width, double height)
+ {
+ this.x = (int) x;
+ this.y = (int) y;
+ this.width = (int) width;
+ this.height = (int) height;
+ }
+
+ /**
+ * Updates this rectangle to have the specified dimensions.
+ *
+ * @param x the new X coordinate of the upper left hand corner
+ * @param y the new Y coordinate of the upper left hand corner
+ * @param width the new width of this rectangle
+ * @param height the new height of this rectangle
+ * @deprecated use {@link #setBounds(int, int, int, int)} instead
+ */
+ public void reshape(int x, int y, int width, int height)
+ {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Returns the location of this rectangle, which is the coordinates of
+ * its upper left corner.
+ *
+ * @return the point where this rectangle is located
+ * @see #setLocation(Point)
+ * @since 1.1
+ */
+ public Point getLocation()
+ {
+ return new Point(x,y);
+ }
+
+ /**
+ * Moves the location of this rectangle by setting its upper left
+ * corner to the specified point.
+ *
+ * @param p the point to move the rectangle to
+ * @throws NullPointerException if p is null
+ * @see #getLocation()
+ * @since 1.1
+ */
+ public void setLocation(Point p)
+ {
+ setLocation (p.x, p.y);
+ }
+
+ /**
+ * Moves the location of this rectangle by setting its upper left
+ * corner to the specified coordinates.
+ *
+ * @param x the new X coordinate for this rectangle
+ * @param y the new Y coordinate for this rectangle
+ * @since 1.1
+ */
+ public void setLocation(int x, int y)
+ {
+ move (x, y);
+ }
+
+ /**
+ * Moves the location of this rectangle by setting its upper left
+ * corner to the specified coordinates.
+ *
+ * @param x the new X coordinate for this rectangle
+ * @param y the new Y coordinate for this rectangle
+ * @deprecated use {@link #setLocation(int, int)} instead
+ */
+ public void move(int x, int y)
+ {
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * Translate the location of this rectangle by the given amounts.
+ *
+ * @param dx the x distance to move by
+ * @param dy the y distance to move by
+ * @see #setLocation(int, int)
+ */
+ public void translate(int dx, int dy)
+ {
+ x += dx;
+ y += dy;
+ }
+
+ /**
+ * Returns the size of this rectangle.
+ *
+ * @return the size of this rectangle
+ * @see #setSize(Dimension)
+ * @since 1.1
+ */
+ public Dimension getSize()
+ {
+ return new Dimension(width, height);
+ }
+
+ /**
+ * Sets the size of this rectangle based on the specified dimensions.
+ *
+ * @param d the new dimensions of the rectangle
+ * @throws NullPointerException if d is null
+ * @see #getSize()
+ * @since 1.1
+ */
+ public void setSize(Dimension d)
+ {
+ setSize (d.width, d.height);
+ }
+
+ /**
+ * Sets the size of this rectangle based on the specified dimensions.
+ *
+ * @param width the new width of the rectangle
+ * @param height the new height of the rectangle
+ * @since 1.1
+ */
+ public void setSize(int width, int height)
+ {
+ resize (width, height);
+ }
+
+ /**
+ * Sets the size of this rectangle based on the specified dimensions.
+ *
+ * @param width the new width of the rectangle
+ * @param height the new height of the rectangle
+ * @deprecated use {@link #setSize(int, int)} instead
+ */
+ public void resize(int width, int height)
+ {
+ this.width = width;
+ this.height = height;
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this rectangle.
+ * According to the contract of Shape, a point on the border is in only if
+ * it has an adjacent point inside the rectangle in either the increasing
+ * x or y direction.
+ *
+ * @param p the point to test
+ * @return true if the point is inside the rectangle
+ * @throws NullPointerException if p is null
+ * @see #contains(int, int)
+ * @since 1.1
+ */
+ public boolean contains(Point p)
+ {
+ return contains (p.x, p.y);
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this rectangle.
+ * According to the contract of Shape, a point on the border is in only if
+ * it has an adjacent point inside the rectangle in either the increasing
+ * x or y direction.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is inside the rectangle
+ * @since 1.1
+ */
+ public boolean contains(int x, int y)
+ {
+ return inside (x, y);
+ }
+
+ /**
+ * Checks whether all points in the given rectangle are contained in this
+ * rectangle.
+ *
+ * @param r the rectangle to check
+ * @return true if r is contained in this rectangle
+ * @throws NullPointerException if r is null
+ * @see #contains(int, int, int, int)
+ * @since 1.1
+ */
+ public boolean contains(Rectangle r)
+ {
+ return contains (r.x, r.y, r.width, r.height);
+ }
+
+ /**
+ * Checks whether all points in the given rectangle are contained in this
+ * rectangle.
+ *
+ * @param x the x coordinate of the rectangle to check
+ * @param y the y coordinate of the rectangle to check
+ * @param w the width of the rectangle to check
+ * @param h the height of the rectangle to check
+ * @return true if the parameters are contained in this rectangle
+ * @since 1.1
+ */
+ public boolean contains(int x, int y, int w, int h)
+ {
+ return width > 0 && height > 0 && w > 0 && h > 0
+ && x >= this.x && x + w <= this.x + this.width
+ && y >= this.y && y + h <= this.y + this.height;
+ }
+
+ /**
+ * Tests whether or not the specified point is inside this rectangle.
+ *
+ * @param x the X coordinate of the point to test
+ * @param y the Y coordinate of the point to test
+ * @return true if the point is inside the rectangle
+ * @deprecated use {@link #contains(int, int)} instead
+ */
+ public boolean inside(int x, int y)
+ {
+ return width > 0 && height > 0
+ && x >= this.x && x < this.x + width
+ && y >= this.y && y < this.y + height;
+ }
+
+ /**
+ * Tests whether or not the specified rectangle intersects this rectangle.
+ * This means the two rectangles share at least one internal point.
+ *
+ * @param r the rectangle to test against
+ * @return true if the specified rectangle intersects this one
+ * @throws NullPointerException if r is null
+ * @since 1.2
+ */
+ public boolean intersects(Rectangle r)
+ {
+ return r.width > 0 && r.height > 0 && width > 0 && height > 0
+ && r.x < x + width && r.x + r.width > x
+ && r.y < y + height && r.y + r.height > y;
+ }
+
+ /**
+ * Determines the rectangle which is formed by the intersection of this
+ * rectangle with the specified rectangle. If the two do not intersect,
+ * an empty rectangle will be returned (meaning the width and/or height
+ * will be non-positive).
+ *
+ * @param r the rectange to calculate the intersection with
+ * @return a new rectangle bounding the intersection
+ * @throws NullPointerException if r is null
+ */
+ public Rectangle intersection(Rectangle r)
+ {
+ Rectangle res = new Rectangle();
+ intersect(this, r, res);
+ return res;
+ }
+
+ /**
+ * Returns the smallest rectangle that contains both this rectangle
+ * and the specified rectangle.
+ *
+ * @param r the rectangle to compute the union with
+ * @return the smallest rectangle containing both rectangles
+ * @throws NullPointerException if r is null
+ */
+ public Rectangle union(Rectangle r)
+ {
+ Rectangle res = new Rectangle();
+ union(this, r, res);
+ return res;
+ }
+
+ /**
+ * Modifies this rectangle so that it represents the smallest rectangle
+ * that contains both the existing rectangle and the specified point.
+ * However, if the point falls on one of the two borders which are not
+ * inside the rectangle, a subsequent call to <code>contains</code> may
+ * return false.
+ *
+ * @param x the X coordinate of the point to add to this rectangle
+ * @param y the Y coordinate of the point to add to this rectangle
+ */
+ public void add(int x, int y)
+ {
+ add((double) x, (double) y);
+ }
+
+ /**
+ * Modifies this rectangle so that it represents the smallest rectangle
+ * that contains both the existing rectangle and the specified point.
+ * However, if the point falls on one of the two borders which are not
+ * inside the rectangle, a subsequent call to <code>contains</code> may
+ * return false.
+ *
+ * @param p the point to add to this rectangle
+ * @throws NullPointerException if p is null
+ */
+ public void add(Point p)
+ {
+ add((double) p.x, (double) p.y);
+ }
+
+ /**
+ * Modifies this rectangle so that it represents the smallest rectangle
+ * that contains both the existing rectangle and the specified rectangle.
+ *
+ * @param r the rectangle to add to this rectangle
+ * @throws NullPointerException if r is null
+ * @see #union(Rectangle)
+ */
+ public void add(Rectangle r)
+ {
+ union(this, r, this);
+ }
+
+ /**
+ * Expands the rectangle by the specified amount. The horizontal
+ * and vertical expansion values are applied both to the X,Y coordinate
+ * of this rectangle, and its width and height. Thus the width and
+ * height will increase by 2h and 2v accordingly.
+ *
+ * @param h the horizontal expansion value
+ * @param v the vertical expansion value
+ */
+ public void grow(int h, int v)
+ {
+ x -= h;
+ y -= v;
+ width += h + h;
+ height += v + v;
+ }
+
+ /**
+ * Tests whether or not this rectangle is empty. An empty rectangle
+ * has a non-positive width or height.
+ *
+ * @return true if the rectangle is empty
+ */
+ public boolean isEmpty()
+ {
+ return width <= 0 || height <= 0;
+ }
+
+ /**
+ * Determine where the point lies with respect to this rectangle. The
+ * result will be the binary OR of the appropriate bit masks.
+ *
+ * @param x the x coordinate to check
+ * @param y the y coordinate to check
+ * @return the binary OR of the result
+ * @see #OUT_LEFT
+ * @see #OUT_TOP
+ * @see #OUT_RIGHT
+ * @see #OUT_BOTTOM
+ * @since 1.2
+ */
+ public int outcode(double x, double y)
+ {
+ int result = 0;
+ if (width <= 0)
+ result |= OUT_LEFT | OUT_RIGHT;
+ else if (x < this.x)
+ result |= OUT_LEFT;
+ else if (x > this.x + width)
+ result |= OUT_RIGHT;
+ if (height <= 0)
+ result |= OUT_BOTTOM | OUT_TOP;
+ else if (y < this.y) // Remember that +y heads top-to-bottom.
+ result |= OUT_TOP;
+ else if (y > this.y + height)
+ result |= OUT_BOTTOM;
+ return result;
+ }
+
+ /**
+ * Determines the rectangle which is formed by the intersection of this
+ * rectangle with the specified rectangle. If the two do not intersect,
+ * an empty rectangle will be returned (meaning the width and/or height
+ * will be non-positive).
+ *
+ * @param r the rectange to calculate the intersection with
+ * @return a new rectangle bounding the intersection
+ * @throws NullPointerException if r is null
+ * @since 1.2
+ */
+ public Rectangle2D createIntersection(Rectangle2D r)
+ {
+ // Favor runtime type of other rectangle.
+ Rectangle2D res = r.getBounds2D();
+ intersect(this, r, res);
+ return res;
+ }
+
+ /**
+ * Returns the smallest rectangle that contains both this rectangle
+ * and the specified rectangle.
+ *
+ * @param r the rectangle to compute the union with
+ * @return the smallest rectangle containing both rectangles
+ * @throws NullPointerException if r is null
+ * @since 1.2
+ */
+ public Rectangle2D createUnion(Rectangle2D r)
+ {
+ // Favor runtime type of other rectangle.
+ Rectangle2D res = r.getBounds2D();
+ union(this, r, res);
+ return res;
+ }
+
+ /**
+ * Tests this rectangle for equality against the specified object. This
+ * will be true if an only if the specified object is an instance of
+ * Rectangle2D with the same coordinates and dimensions.
+ *
+ * @param obj the object to test against for equality
+ * @return true if the specified object is equal to this one
+ */
+ public boolean equals(Object obj)
+ {
+ // NOTE: No special hashCode() method is required for this class,
+ // as this equals() implementation is functionally equivalent to
+ // super.equals(), which does define a proper hashCode().
+
+ if (! (obj instanceof Rectangle2D))
+ return false;
+ Rectangle2D r = (Rectangle2D) obj;
+ return r.getX() == x && r.getY() == y
+ && r.getWidth() == width && r.getHeight() == height;
+ }
+
+ /**
+ * Returns a string representation of this rectangle. This is in the form
+ * <code>getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width
+ * + ",height=" + height + ']'</code>.
+ *
+ * @return a string representation of this rectangle
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[x=" + x + ",y=" + y + ",width=" + width
+ + ",height=" + height + ']';
+ }
+} // class Rectangle
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/RenderingHints.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/RenderingHints.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/RenderingHints.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/RenderingHints.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,803 @@
+/* RenderingHints.java --
+ Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A collection of (key, value) items that provide 'hints' for the
+ * {@link java.awt.Graphics2D} rendering pipeline. Because these
+ * items are hints only, they may be ignored by a particular
+ * {@link java.awt.Graphics2D} implementation.
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ */
+public class RenderingHints implements Map, Cloneable
+{
+ /**
+ * The base class used to represent keys.
+ */
+ public abstract static class Key
+ {
+ private final int key;
+
+ /**
+ * Creates a new key.
+ *
+ * @param privateKey the private key.
+ */
+ protected Key(int privateKey)
+ {
+ key = privateKey;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified value is compatible with
+ * this key, and <code>false</code> otherwise.
+ *
+ * @param value the value (<code>null</code> permitted).
+ *
+ * @return A boolean.
+ */
+ public abstract boolean isCompatibleValue(Object value);
+
+ /**
+ * Returns the private key for this instance.
+ *
+ * @return The private key.
+ */
+ protected final int intKey()
+ {
+ return key;
+ }
+
+ /**
+ * Returns a hash code for the key.
+ *
+ * @return A hash code.
+ */
+ public final int hashCode()
+ {
+ return System.identityHashCode(this);
+ }
+
+ /**
+ * Checks this key for equality with an arbitrary object.
+ *
+ * @param other the object (<code>null</code> permitted)
+ *
+ * @return A boolean.
+ */
+ public final boolean equals(Object other)
+ {
+ return this == other;
+ }
+ } // class Key
+
+ private static final class KeyImpl extends Key
+ {
+ final String description;
+ final Object v1;
+ final Object v2;
+ final Object v3;
+
+ KeyImpl(int privateKey, String description,
+ Object v1, Object v2, Object v3)
+ {
+ super(privateKey);
+ this.description = description;
+ this.v1 = v1;
+ this.v2 = v2;
+ this.v3 = v3;
+ }
+
+ /**
+ * Returns <code>true</code> if the specified value is compatible with
+ * this key, and <code>false</code> otherwise.
+ *
+ * @param value the value (<code>null</code> permitted).
+ *
+ * @return A boolean.
+ */
+ public boolean isCompatibleValue(Object value)
+ {
+ return value == v1 || value == v2 || value == v3;
+ }
+
+ /**
+ * Returns a string representation of the key.
+ *
+ * @return A string.
+ */
+ public String toString()
+ {
+ return description;
+ }
+ } // class KeyImpl
+
+ private HashMap hintMap = new HashMap();
+
+ /**
+ * A key for the 'antialiasing' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_ANTIALIAS_OFF}</td>
+ * <td>Render without antialiasing (better speed).</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_ANTIALIAS_ON}</td>
+ * <td>Render with antialiasing (better quality).</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_ANTIALIAS_DEFAULT}</td>
+ * <td>Use the default value for antialiasing.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_ANTIALIASING;
+
+ /**
+ * This value is for use with the {@link #KEY_ANTIALIASING} key.
+ */
+ public static final Object VALUE_ANTIALIAS_ON
+ = "Antialiased rendering mode";
+
+ /**
+ * This value is for use with the {@link #KEY_ANTIALIASING} key.
+ */
+ public static final Object VALUE_ANTIALIAS_OFF
+ = "Nonantialiased rendering mode";
+
+ /**
+ * This value is for use with the {@link #KEY_ANTIALIASING} key.
+ */
+ public static final Object VALUE_ANTIALIAS_DEFAULT
+ = "Default antialiasing rendering mode";
+
+ /**
+ * A key for the 'rendering' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_RENDER_SPEED}</td>
+ * <td>Prefer speed over quality when rendering.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_RENDER_QUALITY}</td>
+ * <td>Prefer quality over speed when rendering.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_RENDER_DEFAULT}</td>
+ * <td>Use the default value for quality vs. speed when rendering.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_RENDERING;
+
+ /**
+ * This value is for use with the {@link #KEY_RENDERING} key.
+ */
+ public static final Object VALUE_RENDER_SPEED
+ = "Fastest rendering methods";
+
+ /**
+ * This value is for use with the {@link #KEY_RENDERING} key.
+ */
+ public static final Object VALUE_RENDER_QUALITY
+ = "Highest quality rendering methods";
+
+ /**
+ * This value is for use with the {@link #KEY_RENDERING} key.
+ */
+ public static final Object VALUE_RENDER_DEFAULT
+ = "Default rendering methods";
+
+ /**
+ * A key for the 'dithering' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_DITHER_DISABLE}</td>
+ * <td>Disable dithering.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_DITHER_ENABLE}</td>
+ * <td>Enable dithering.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_DITHER_DEFAULT}</td>
+ * <td>Use the default value for dithering.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_DITHERING;
+
+ /**
+ * This value is for use with the {@link #KEY_DITHERING} key.
+ */
+ public static final Object VALUE_DITHER_DISABLE
+ = "Nondithered rendering mode";
+
+ /**
+ * This value is for use with the {@link #KEY_DITHERING} key.
+ */
+ public static final Object VALUE_DITHER_ENABLE
+ = "Dithered rendering mode";
+
+ /**
+ * This value is for use with the {@link #KEY_DITHERING} key.
+ */
+ public static final Object VALUE_DITHER_DEFAULT
+ = "Default dithering mode";
+
+ /**
+ * A key for the 'text antialiasing' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_TEXT_ANTIALIAS_ON}</td>
+ * <td>Render text with antialiasing (better quality usually).</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_TEXT_ANTIALIAS_OFF}</td>
+ * <td>Render test without antialiasing (better speed).</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_TEXT_ANTIALIAS_DEFAULT}</td>
+ * <td>Use the default value for text antialiasing.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_TEXT_ANTIALIASING;
+
+ /**
+ * This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
+ */
+ public static final Object VALUE_TEXT_ANTIALIAS_ON
+ = "Antialiased text mode";
+
+ /**
+ * This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
+ */
+ public static final Object VALUE_TEXT_ANTIALIAS_OFF
+ = "Nonantialiased text mode";
+
+ /**
+ * This value is for use with the {@link #KEY_TEXT_ANTIALIASING} key.
+ */
+ public static final Object VALUE_TEXT_ANTIALIAS_DEFAULT
+ = "Default antialiasing text mode";
+
+ /**
+ * A key for the 'fractional metrics' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_FRACTIONALMETRICS_OFF}</td>
+ * <td>Render text with fractional metrics off.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_FRACTIONALMETRICS_ON}</td>
+ * <td>Render text with fractional metrics on.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_FRACTIONALMETRICS_DEFAULT}</td>
+ * <td>Use the default value for fractional metrics.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_FRACTIONALMETRICS;
+
+ /**
+ * This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
+ */
+ public static final Object VALUE_FRACTIONALMETRICS_OFF
+ = "Integer text metrics mode";
+
+ /**
+ * This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
+ */
+ public static final Object VALUE_FRACTIONALMETRICS_ON
+ = "Fractional text metrics mode";
+
+ /**
+ * This value is for use with the {@link #KEY_FRACTIONALMETRICS} key.
+ */
+ public static final Object VALUE_FRACTIONALMETRICS_DEFAULT
+ = "Default fractional text metrics mode";
+
+ /**
+ * A key for the 'interpolation' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_INTERPOLATION_NEAREST_NEIGHBOR}</td>
+ * <td>Use nearest neighbour interpolation.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_INTERPOLATION_BILINEAR}</td>
+ * <td>Use bilinear interpolation.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_INTERPOLATION_BICUBIC}</td>
+ * <td>Use bicubic interpolation.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_INTERPOLATION;
+
+ /**
+ * This value is for use with the {@link #KEY_INTERPOLATION} key.
+ */
+ public static final Object VALUE_INTERPOLATION_NEAREST_NEIGHBOR
+ = "Nearest Neighbor image interpolation mode";
+
+ /**
+ * This value is for use with the {@link #KEY_INTERPOLATION} key.
+ */
+ public static final Object VALUE_INTERPOLATION_BILINEAR
+ = "Bilinear image interpolation mode";
+
+ /**
+ * This value is for use with the {@link #KEY_INTERPOLATION} key.
+ */
+ public static final Object VALUE_INTERPOLATION_BICUBIC
+ = "Bicubic image interpolation mode";
+
+ /**
+ * A key for the 'alpha interpolation' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_ALPHA_INTERPOLATION_SPEED}</td>
+ * <td>Prefer speed over quality.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_ALPHA_INTERPOLATION_QUALITY}</td>
+ * <td>Prefer quality over speed.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_ALPHA_INTERPOLATION_DEFAULT}</td>
+ * <td>Use the default setting.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_ALPHA_INTERPOLATION;
+
+ /**
+ * This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
+ */
+ public static final Object VALUE_ALPHA_INTERPOLATION_SPEED
+ = "Fastest alpha blending methods";
+
+ /**
+ * This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
+ */
+ public static final Object VALUE_ALPHA_INTERPOLATION_QUALITY
+ = "Highest quality alpha blending methods";
+
+ /**
+ * This value is for use with the {@link #KEY_ALPHA_INTERPOLATION} key.
+ */
+ public static final Object VALUE_ALPHA_INTERPOLATION_DEFAULT
+ = "Default alpha blending methods";
+
+ /**
+ * A key for the 'color rendering' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_COLOR_RENDER_SPEED}</td>
+ * <td>Prefer speed over quality.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_COLOR_RENDER_QUALITY}</td>
+ * <td>Prefer quality over speed.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_COLOR_RENDER_DEFAULT}</td>
+ * <td>Use the default setting.</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_COLOR_RENDERING;
+
+ /**
+ * This value is for use with the {@link #KEY_COLOR_RENDERING} key.
+ */
+ public static final Object VALUE_COLOR_RENDER_SPEED
+ = "Fastest color rendering mode";
+
+ /**
+ * This value is for use with the {@link #KEY_COLOR_RENDERING} key.
+ */
+ public static final Object VALUE_COLOR_RENDER_QUALITY
+ = "Highest quality color rendering mode";
+
+ /**
+ * This value is for use with the {@link #KEY_COLOR_RENDERING} key.
+ */
+ public static final Object VALUE_COLOR_RENDER_DEFAULT
+ = "Default color rendering mode";
+
+ /**
+ * A key for the 'stroke control' hint. Permitted values are:
+ * <p>
+ * <table>
+ * <tr>
+ * <td>{@link #VALUE_STROKE_DEFAULT}</td>
+ * <td>Use the default setting.</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_STROKE_NORMALIZE}</td>
+ * <td>XXX</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #VALUE_STROKE_PURE}</td>
+ * <td>XXX</td>
+ * </tr>
+ * </table>
+ */
+ public static final Key KEY_STROKE_CONTROL;
+
+ /**
+ * This value is for use with the {@link #KEY_STROKE_CONTROL} key.
+ */
+ public static final Object VALUE_STROKE_DEFAULT
+ = "Default stroke normalization";
+
+ /**
+ * This value is for use with the {@link #KEY_STROKE_CONTROL} key.
+ */
+ public static final Object VALUE_STROKE_NORMALIZE
+ = "Normalize strokes for consistent rendering";
+
+ /**
+ * This value is for use with the {@link #KEY_STROKE_CONTROL} key.
+ */
+ public static final Object VALUE_STROKE_PURE
+ = "Pure stroke conversion for accurate paths";
+
+ static
+ {
+ KEY_ANTIALIASING = new KeyImpl(1, "Global antialiasing enable key",
+ VALUE_ANTIALIAS_ON,
+ VALUE_ANTIALIAS_OFF,
+ VALUE_ANTIALIAS_DEFAULT);
+ KEY_RENDERING = new KeyImpl(2, "Global rendering quality key",
+ VALUE_RENDER_SPEED,
+ VALUE_RENDER_QUALITY,
+ VALUE_RENDER_DEFAULT);
+ KEY_DITHERING = new KeyImpl(3, "Dithering quality key",
+ VALUE_DITHER_DISABLE,
+ VALUE_DITHER_ENABLE,
+ VALUE_DITHER_DEFAULT);
+ KEY_TEXT_ANTIALIASING
+ = new KeyImpl(4, "Text-specific antialiasing enable key",
+ VALUE_TEXT_ANTIALIAS_ON,
+ VALUE_TEXT_ANTIALIAS_OFF,
+ VALUE_TEXT_ANTIALIAS_DEFAULT);
+ KEY_FRACTIONALMETRICS = new KeyImpl(5, "Fractional metrics enable key",
+ VALUE_FRACTIONALMETRICS_OFF,
+ VALUE_FRACTIONALMETRICS_ON,
+ VALUE_FRACTIONALMETRICS_DEFAULT);
+ KEY_INTERPOLATION = new KeyImpl(6, "Image interpolation method key",
+ VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
+ VALUE_INTERPOLATION_BILINEAR,
+ VALUE_INTERPOLATION_BICUBIC);
+ KEY_ALPHA_INTERPOLATION
+ = new KeyImpl(7, "Alpha blending interpolation method key",
+ VALUE_ALPHA_INTERPOLATION_SPEED,
+ VALUE_ALPHA_INTERPOLATION_QUALITY,
+ VALUE_ALPHA_INTERPOLATION_DEFAULT);
+ KEY_COLOR_RENDERING = new KeyImpl(8, "Color rendering quality key",
+ VALUE_COLOR_RENDER_SPEED,
+ VALUE_COLOR_RENDER_QUALITY,
+ VALUE_COLOR_RENDER_DEFAULT);
+ KEY_STROKE_CONTROL = new KeyImpl(9, "Stroke normalization control key",
+ VALUE_STROKE_DEFAULT,
+ VALUE_STROKE_NORMALIZE,
+ VALUE_STROKE_PURE);
+ }
+
+ /**
+ * Creates a new collection of hints containing all the (key, value) pairs
+ * in the specified map.
+ *
+ * @param init a map containing a collection of hints (<code>null</code>
+ * permitted).
+ */
+ public RenderingHints(Map init)
+ {
+ if (init != null)
+ putAll(init);
+ }
+
+ /**
+ * Creates a new collection containing a single (key, value) pair.
+ *
+ * @param key the key.
+ * @param value the value.
+ */
+ public RenderingHints(Key key, Object value)
+ {
+ put(key, value);
+ }
+
+ /**
+ * Returns the number of hints in the collection.
+ *
+ * @return The number of hints.
+ */
+ public int size()
+ {
+ return hintMap.size();
+ }
+
+ /**
+ * Returns <code>true</code> if there are no hints in the collection,
+ * and <code>false</code> otherwise.
+ *
+ * @return A boolean.
+ */
+ public boolean isEmpty()
+ {
+ return hintMap.isEmpty();
+ }
+
+ /**
+ * Returns <code>true</code> if the collection of hints contains the
+ * specified key, and <code>false</code> otherwise.
+ *
+ * @param key the key (<code>null</code> not permitted).
+ *
+ * @return A boolean.
+ *
+ * @throws NullPointerException if <code>key</code> is <code>null</code>.
+ * @throws ClassCastException if <code>key</code> is not a {@link Key}.
+ */
+ public boolean containsKey(Object key)
+ {
+ if (key == null)
+ throw new NullPointerException();
+ // don't remove the cast, it is necessary to throw the required exception
+ return hintMap.containsKey((Key) key);
+ }
+
+ /**
+ * Returns <code>true</code> if the collection of hints contains the
+ * specified value, and <code>false</code> otherwise.
+ *
+ * @param value the value.
+ *
+ * @return A boolean.
+ */
+ public boolean containsValue(Object value)
+ {
+ return hintMap.containsValue(value);
+ }
+
+ /**
+ * Returns the value associated with the specified key, or <code>null</code>
+ * if there is no value defined for the key.
+ *
+ * @param key the key (<code>null</code> permitted).
+ *
+ * @return The value (possibly <code>null</code>).
+ *
+ * @throws ClassCastException if <code>key</code> is not a {@link Key}.
+ *
+ * @see #containsKey(Object)
+ */
+ public Object get(Object key)
+ {
+ // don't remove the cast, it is necessary to throw the required exception
+ return hintMap.get((Key) key);
+ }
+
+ /**
+ * Adds a (key, value) pair to the collection of hints (if the
+ * collection already contains the specified key, then the
+ * value is updated).
+ *
+ * @param key the key.
+ * @param value the value.
+ *
+ * @return the previous value of the key or <code>null</code> if the key
+ * didn't have a value yet.
+ */
+ public Object put(Object key, Object value)
+ {
+ if (key == null || value == null)
+ throw new NullPointerException();
+ if (! ((Key) key).isCompatibleValue(value))
+ throw new IllegalArgumentException();
+ return hintMap.put(key, value);
+ }
+
+ /**
+ * Adds all the hints from a collection to this collection.
+ *
+ * @param hints the hint collection.
+ */
+ public void add(RenderingHints hints)
+ {
+ hintMap.putAll(hints);
+ }
+
+ /**
+ * Clears all the hints from this collection.
+ */
+ public void clear()
+ {
+ hintMap.clear();
+ }
+
+ /**
+ * Removes a hint from the collection.
+ *
+ * @param key the key.
+ *
+ * @return The value that was associated with the key, or <code>null</code> if
+ * the key was not part of the collection
+ *
+ * @throws ClassCastException if the key is not a subclass of
+ * {@link RenderingHints.Key}.
+ */
+ public Object remove(Object key)
+ {
+ // don't remove the (Key) cast, it is necessary to throw the exception
+ // required by the spec
+ return hintMap.remove((Key) key);
+ }
+
+ /**
+ * Adds a collection of (key, value) pairs to the collection.
+ *
+ * @param m a map containing (key, value) items.
+ *
+ * @throws ClassCastException if the map contains a key that is not
+ * a subclass of {@link RenderingHints.Key}.
+ * @throws IllegalArgumentException if the map contains a value that is
+ * not compatible with its key.
+ */
+ public void putAll(Map m)
+ {
+ // preprocess map to generate appropriate exceptions
+ Iterator iterator = m.keySet().iterator();
+ while (iterator.hasNext())
+ {
+ Key key = (Key) iterator.next();
+ if (!key.isCompatibleValue(m.get(key)))
+ throw new IllegalArgumentException();
+ }
+ // map is OK, update
+ hintMap.putAll(m);
+ }
+
+ /**
+ * Returns a set containing the keys from this collection.
+ *
+ * @return A set of keys.
+ */
+ public Set keySet()
+ {
+ return hintMap.keySet();
+ }
+
+ /**
+ * Returns a collection of the values from this hint collection. The
+ * collection is backed by the <code>RenderingHints</code> instance,
+ * so updates to one will affect the other.
+ *
+ * @return A collection of values.
+ */
+ public Collection values()
+ {
+ return hintMap.values();
+ }
+
+ /**
+ * Returns a set of entries from the collection.
+ *
+ * @return A set of entries.
+ */
+ public Set entrySet()
+ {
+ return Collections.unmodifiableSet(hintMap.entrySet());
+ }
+
+ /**
+ * Checks this collection for equality with an arbitrary object.
+ *
+ * @param o the object (<code>null</code> permitted)
+ *
+ * @return A boolean.
+ */
+ public boolean equals(Object o)
+ {
+ return hintMap.equals(o);
+ }
+
+ /**
+ * Returns a hash code for the collection of hints.
+ *
+ * @return A hash code.
+ */
+ public int hashCode()
+ {
+ return hintMap.hashCode();
+ }
+
+ /**
+ * Creates a clone of this instance.
+ *
+ * @return A clone.
+ */
+ public Object clone()
+ {
+ try
+ {
+ RenderingHints copy = (RenderingHints) super.clone();
+ copy.hintMap = (HashMap) hintMap.clone();
+ return copy;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw (Error) new InternalError().initCause(e); // Impossible
+ }
+ }
+
+ /**
+ * Returns a string representation of this instance.
+ *
+ * @return A string.
+ */
+ public String toString()
+ {
+ return hintMap.toString();
+ }
+} // class RenderingHints
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Robot.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Robot.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Robot.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Robot.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,423 @@
+/* Robot.java -- a native input event generator
+ Copyright (C) 2004, 2005 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.ClasspathToolkit;
+
+import java.lang.reflect.InvocationTargetException;
+import java.awt.event.InputEvent;
+import java.awt.image.BufferedImage;
+import java.awt.peer.RobotPeer;
+
+/**
+ * The Robot class is used to simulate user interaction with graphical
+ * programs. It can generate native windowing system input events and
+ * retrieve image data from the current screen. Robot is used to test
+ * the AWT and Swing library implementations; it can also be used to
+ * create self-running demo programs.
+ *
+ * Since Robot generates native windowing system events, rather than
+ * simply inserting {@link AWTEvent}s on the AWT event queue, its use
+ * is not restricted to Java programs. It can be used to
+ * programatically drive any graphical application.
+ *
+ * This implementation requires an X server that supports the XTest
+ * extension.
+ *
+ * @author Thomas Fitzsimmons (fitzsim at redhat.com)
+ *
+ * @since 1.3
+ */
+public class Robot
+{
+ private boolean waitForIdle;
+ private int autoDelay;
+ private RobotPeer peer;
+
+ /**
+ * Construct a Robot object that operates on the default screen.
+ *
+ * @exception AWTException if GraphicsEnvironment.isHeadless()
+ * returns true or if the X server does not support the XTest
+ * extension
+ * @exception SecurityException if createRobot permission is not
+ * granted
+ */
+ public Robot () throws AWTException
+ {
+ if (GraphicsEnvironment.isHeadless ())
+ throw new AWTException ("Robot: headless graphics environment");
+
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkPermission (new AWTPermission ("createRobot"));
+
+ ClasspathToolkit tk = (ClasspathToolkit) Toolkit.getDefaultToolkit ();
+
+ // createRobot will throw AWTException if XTest is not supported.
+ peer = tk.createRobot (GraphicsEnvironment.getLocalGraphicsEnvironment ()
+ .getDefaultScreenDevice ());
+ }
+
+ /**
+ * Construct a Robot object that operates on the specified screen.
+ *
+ * @exception AWTException if GraphicsEnvironment.isHeadless()
+ * returns true or if the X server does not support the XTest
+ * extension
+ * @exception IllegalArgumentException if screen is not a screen
+ * GraphicsDevice
+ * @exception SecurityException if createRobot permission is not
+ * granted
+ */
+ public Robot (GraphicsDevice screen) throws AWTException
+ {
+ if (GraphicsEnvironment.isHeadless ())
+ throw new AWTException ("Robot: headless graphics environment");
+
+ if (screen.getType () != GraphicsDevice.TYPE_RASTER_SCREEN)
+ throw new IllegalArgumentException ("Robot: graphics"
+ + " device is not a screen");
+
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkPermission (new AWTPermission ("createRobot"));
+
+ ClasspathToolkit tk = (ClasspathToolkit) Toolkit.getDefaultToolkit ();
+
+ // createRobot will throw AWTException if XTest is not supported.
+ peer = tk.createRobot (screen);
+ }
+
+ /**
+ * Move the mouse pointer to absolute coordinates (x, y).
+ *
+ * @param x the destination x coordinate
+ * @param y the destination y coordinate
+ */
+ public void mouseMove(int x, int y)
+ {
+ peer.mouseMove (x, y);
+
+ if (waitForIdle)
+ waitForIdle ();
+
+ if (autoDelay > 0)
+ delay (autoDelay);
+ }
+
+ /**
+ * Press one or more mouse buttons.
+ *
+ * @param buttons the buttons to press; a bitmask of one or more of
+ * these {@link InputEvent} fields:
+ *
+ * <ul>
+ * <li>BUTTON1_MASK</li>
+ * <li>BUTTON2_MASK</li>
+ * <li>BUTTON3_MASK</li>
+ * </ul>
+ *
+ * @exception IllegalArgumentException if the button mask is invalid
+ */
+ public void mousePress (int buttons)
+ {
+ if ((buttons & InputEvent.BUTTON1_MASK) == 0
+ && (buttons & InputEvent.BUTTON2_MASK) == 0
+ && (buttons & InputEvent.BUTTON3_MASK) == 0)
+ throw new IllegalArgumentException ("Robot: mousePress:"
+ + " invalid button mask");
+
+ peer.mousePress (buttons);
+
+ if (waitForIdle)
+ waitForIdle ();
+
+ if (autoDelay > 0)
+ delay (autoDelay);
+ }
+
+ /**
+ * Release one or more mouse buttons.
+ *
+ * @param buttons the buttons to release; a bitmask of one or more
+ * of these {@link InputEvent} fields:
+ *
+ * <ul>
+ * <li>BUTTON1_MASK</li>
+ * <li>BUTTON2_MASK</li>
+ * <li>BUTTON3_MASK</li>
+ * </ul>
+ *
+ * @exception IllegalArgumentException if the button mask is invalid
+ */
+ public void mouseRelease(int buttons)
+ {
+ if ((buttons & InputEvent.BUTTON1_MASK) == 0
+ && (buttons & InputEvent.BUTTON2_MASK) == 0
+ && (buttons & InputEvent.BUTTON3_MASK) == 0)
+ throw new IllegalArgumentException ("Robot: mouseRelease:"
+ + " invalid button mask");
+
+ peer.mouseRelease (buttons);
+
+ if (waitForIdle)
+ waitForIdle ();
+
+ if (autoDelay > 0)
+ delay (autoDelay);
+ }
+
+ /**
+ * Rotate the mouse scroll wheel.
+ *
+ * @param wheelAmt number of steps to rotate mouse wheel. negative
+ * to rotate wheel up (away from the user), positive to rotate wheel
+ * down (toward the user).
+ *
+ * @since 1.4
+ */
+ public void mouseWheel (int wheelAmt)
+ {
+ peer.mouseWheel (wheelAmt);
+
+ if (waitForIdle)
+ waitForIdle ();
+
+ if (autoDelay > 0)
+ delay (autoDelay);
+ }
+
+ /**
+ * Press a key.
+ *
+ * @param keycode key to press, a {@link java.awt.event.KeyEvent} VK_ constant
+ *
+ * @exception IllegalArgumentException if keycode is not a valid key
+ */
+ public void keyPress (int keycode)
+ {
+ peer.keyPress (keycode);
+
+ if (waitForIdle)
+ waitForIdle ();
+
+ if (autoDelay > 0)
+ delay (autoDelay);
+ }
+
+ /**
+ * Release a key.
+ *
+ * @param keycode key to release, a {@link java.awt.event.KeyEvent} VK_
+ * constant
+ *
+ * @exception IllegalArgumentException if keycode is not a valid key
+ */
+ public void keyRelease (int keycode)
+ {
+ peer.keyRelease (keycode);
+
+ if (waitForIdle)
+ waitForIdle ();
+
+ if (autoDelay > 0)
+ delay (autoDelay);
+ }
+
+ /**
+ * Return the color of the pixel at the given screen coordinates.
+ *
+ * @param x the x coordinate of the pixel
+ * @param y the y coordinate of the pixel
+ *
+ * @return the Color of the pixel at screen coodinates <code>(x, y)</code>
+ */
+ public Color getPixelColor (int x, int y)
+ {
+ return new Color (peer.getRGBPixel (x, y));
+ }
+
+ /**
+ * Create an image containing pixels read from the screen. The
+ * image does not include the mouse pointer.
+ *
+ * @param screenRect the rectangle of pixels to capture, in screen
+ * coordinates
+ *
+ * @return a BufferedImage containing the requested pixels
+ *
+ * @exception IllegalArgumentException if requested width and height
+ * are not both greater than zero
+ * @exception SecurityException if readDisplayPixels permission is
+ * not granted
+ */
+ public BufferedImage createScreenCapture (Rectangle screenRect)
+ {
+ if (screenRect.width <= 0)
+ throw new IllegalArgumentException ("Robot: capture width is <= 0");
+
+ if (screenRect.height <= 0)
+ throw new IllegalArgumentException ("Robot: capture height is <= 0");
+
+ SecurityManager sm = System.getSecurityManager ();
+ if (sm != null)
+ sm.checkPermission (new AWTPermission ("readDisplayPixels"));
+
+ int[] pixels = peer.getRGBPixels (screenRect);
+
+ BufferedImage bufferedImage =
+ new BufferedImage (screenRect.width, screenRect.height,
+ BufferedImage.TYPE_INT_ARGB);
+
+ bufferedImage.setRGB (0, 0, screenRect.width, screenRect.height,
+ pixels, 0, screenRect.width);
+
+ return bufferedImage;
+ }
+
+ /**
+ * Check if this Robot automatically calls {@link #waitForIdle()} after
+ * generating an event.
+ *
+ * @return true if waitForIdle is automatically called
+ */
+ public boolean isAutoWaitForIdle ()
+ {
+ return waitForIdle;
+ }
+
+ /**
+ * Set whether or not this Robot automatically calls {@link
+ * #waitForIdle()} after generating an event.
+ *
+ * @param isOn true if waitForIdle should be called automatically
+ */
+ public void setAutoWaitForIdle (boolean isOn)
+ {
+ waitForIdle = isOn;
+ }
+
+ /**
+ * Retrieve the length of time this Robot sleeps after generating an
+ * event.
+ *
+ * @return the length of time in milliseconds
+ */
+ public int getAutoDelay ()
+ {
+ return autoDelay;
+ }
+
+ /**
+ * Set the length of time this Robot sleeps after generating an
+ * event.
+ *
+ * @param ms the length of time in milliseconds
+ *
+ * @exception IllegalArgumentException if ms is not between 0 and
+ * 60,000 milliseconds inclusive
+ */
+ public void setAutoDelay (int ms)
+ {
+ if (ms <= 0 || ms >= 60000)
+ throw new IllegalArgumentException ("Robot: delay length out-of-bounds");
+
+ autoDelay = ms;
+ }
+
+ /**
+ * Sleep for a specified length of time.
+ *
+ * @param ms the length of time in milliseconds
+ *
+ * @exception IllegalArgumentException if ms is not between 0 and
+ * 60,000 milliseconds inclusive
+ */
+ public void delay (int ms)
+ {
+ if (ms < 0 || ms > 60000)
+ throw new IllegalArgumentException ("Robot: delay length out-of-bounds");
+
+ try
+ {
+ Thread.sleep (ms);
+ }
+ catch (InterruptedException e)
+ {
+ System.err.println ("Robot: delay interrupted");
+ }
+ }
+
+ /**
+ * Wait until all events currently on the event queue have been
+ * dispatched.
+ */
+ public void waitForIdle ()
+ {
+ if (EventQueue.isDispatchThread ())
+ throw new IllegalThreadStateException ("Robot: waitForIdle called from "
+ + "the event dispatch thread");
+
+ try
+ {
+ EventQueue.invokeAndWait (new Runnable () { public void run () { } });
+ }
+ catch (InterruptedException e)
+ {
+ System.err.println ("Robot: waitForIdle interrupted");
+ }
+ catch (InvocationTargetException e)
+ {
+ System.err.println ("Robot: waitForIdle cannot invoke target");
+ }
+ }
+
+ /**
+ * Return a string representation of this Robot.
+ *
+ * @return a string representation
+ */
+ public String toString ()
+ {
+ return getClass ().getName ()
+ + "[ autoDelay = " + autoDelay + ", autoWaitForIdle = "
+ + waitForIdle + " ]";
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPane.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPane.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPane.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPane.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,639 @@
+/* ScrollPane.java -- Scrolling window
+ Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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 java.awt.event.MouseEvent;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.ScrollPanePeer;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+
+/**
+ * This widget provides a scrollable region that allows a single
+ * subcomponent to be viewed through a smaller window.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class ScrollPane extends Container implements Accessible
+{
+
+/*
+ * Static Variables
+ */
+
+/**
+ * Constant indicating that scrollbars are created as needed in this
+ * windows.
+ */
+public static final int SCROLLBARS_AS_NEEDED = 0;
+
+/**
+ * Constant indicating that scrollbars are always displayed in this
+ * window.
+ */
+public static final int SCROLLBARS_ALWAYS = 1;
+
+/**
+ * Constant indicating that scrollbars are never displayed in this window.
+ */
+public static final int SCROLLBARS_NEVER = 2;
+
+/**
+ * The number used to generate the name returned by getName.
+ */
+private static transient long next_scrollpane_number;
+
+// Serialization constant
+private static final long serialVersionUID = 7956609840827222915L;
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * @serial The horizontal scrollbar for this window. The methods
+ * <code>setMinimum()</code>, <code>setMaximum</code>, and
+ * <code>setVisibleAmount</code> must not be called on this scrollbar.
+ */
+private ScrollPaneAdjustable hAdjustable;
+
+/**
+ * @serial The vertical scrollbar for this window. The methods
+ * <code>setMinimum()</code>, <code>setMaximum</code>, and
+ * <code>setVisibleAmount</code> must not be called on this scrollbar.
+ */
+private ScrollPaneAdjustable vAdjustable;
+
+/**
+ * @serial Indicates when scrollbars are displayed in this window, will
+ * be one of the constants from this class.
+ */
+private int scrollbarDisplayPolicy;
+
+// Current scroll position
+private Point scrollPosition = new Point(0, 0);
+
+private boolean wheelScrollingEnabled;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+ * Initializes a new instance of <code>ScrollPane</code> with a default
+ * scrollbar policy of <code>SCROLLBARS_AS_NEEDED</code>.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+ScrollPane()
+{
+ this(SCROLLBARS_AS_NEEDED);
+}
+
+/*************************************************************************/
+
+/**
+ * Initializes a new instance of <code>ScrollPane</code> with the
+ * specified scrollbar policy.
+ *
+ * @param scrollbarDisplayPolicy When to display scrollbars, which must
+ * be one of the constants defined in this class.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+public
+ScrollPane(int scrollbarDisplayPolicy)
+{
+ if (GraphicsEnvironment.isHeadless ())
+ throw new HeadlessException ();
+
+ this.scrollbarDisplayPolicy = scrollbarDisplayPolicy;
+
+ if (scrollbarDisplayPolicy != SCROLLBARS_ALWAYS
+ && scrollbarDisplayPolicy != SCROLLBARS_AS_NEEDED
+ && scrollbarDisplayPolicy != SCROLLBARS_NEVER)
+ throw new IllegalArgumentException("Bad scrollbarDisplayPolicy: " +
+ scrollbarDisplayPolicy);
+
+ if (scrollbarDisplayPolicy != SCROLLBARS_NEVER)
+ {
+ hAdjustable = new ScrollPaneAdjustable (this, Scrollbar.HORIZONTAL);
+ vAdjustable = new ScrollPaneAdjustable (this, Scrollbar.VERTICAL);
+ }
+
+ wheelScrollingEnabled = true;
+
+ // Default size.
+ setSize(100,100);
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+ * Returns the current scrollbar display policy.
+ *
+ * @return The current scrollbar display policy.
+ */
+public int
+getScrollbarDisplayPolicy()
+{
+ return(scrollbarDisplayPolicy);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the horizontal scrollbar for this object. If the scrollbar
+ * display policy is set to <code>SCROLLBARS_NEVER</code> then this
+ * will be <code>null</code>.
+ *
+ * @return The horizontal scrollbar for this window.
+ */
+public Adjustable
+getHAdjustable()
+{
+ return(hAdjustable);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the vertical scrollbar for this object. If the scrollbar
+ * display policy is set to <code>SCROLLBARS_NEVER</code> then this
+ * will be <code>null</code>.
+ *
+ * @return The horizontal scrollbar for this window.
+ */
+public Adjustable
+getVAdjustable()
+{
+ return(vAdjustable);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the current viewport size. The viewport is the region of
+ * this object's window where the child is actually displayed.
+ *
+ * @return The viewport size.
+ */
+public Dimension getViewportSize ()
+{
+ Dimension viewsize = getSize ();
+ Insets insets = getInsets ();
+
+ viewsize.width -= (insets.left + insets.right);
+ viewsize.height -= (insets.top + insets.bottom);
+
+ Component[] list = getComponents();
+ if ((list == null) || (list.length <= 0))
+ return viewsize;
+
+ Dimension dim = list[0].getPreferredSize();
+
+ if (dim.width <= 0 && dim.height <= 0)
+ return viewsize;
+
+ int vScrollbarWidth = getVScrollbarWidth ();
+ int hScrollbarHeight = getHScrollbarHeight ();
+
+ if (scrollbarDisplayPolicy == SCROLLBARS_ALWAYS)
+ {
+ viewsize.width -= vScrollbarWidth;
+ viewsize.height -= hScrollbarHeight;
+ return viewsize;
+ }
+
+ if (scrollbarDisplayPolicy == SCROLLBARS_NEVER)
+ return viewsize;
+
+ // The scroll policy is SCROLLBARS_AS_NEEDED, so we need to see if
+ // either scrollbar is needed.
+
+ // Assume we don't need either scrollbar.
+ boolean mayNeedVertical = false;
+ boolean mayNeedHorizontal = false;
+
+ boolean needVertical = false;
+ boolean needHorizontal = false;
+
+ // Check if we need vertical scrollbars. If we do, then we need to
+ // subtract the width of the vertical scrollbar from the viewport's
+ // width.
+ if (dim.height > viewsize.height)
+ needVertical = true;
+ else if (dim.height > (viewsize.height - hScrollbarHeight))
+ // This is tricky. In this case the child is tall enough that its
+ // bottom edge would be covered by a horizontal scrollbar, if one
+ // were present. This means that if there's a horizontal
+ // scrollbar then we need a vertical scrollbar.
+ mayNeedVertical = true;
+
+ if (dim.width > viewsize.width)
+ needHorizontal = true;
+ else if (dim.width > (viewsize.width - vScrollbarWidth))
+ mayNeedHorizontal = true;
+
+ if (needVertical && mayNeedHorizontal)
+ needHorizontal = true;
+
+ if (needHorizontal && mayNeedVertical)
+ needVertical = true;
+
+ if (needHorizontal)
+ viewsize.height -= hScrollbarHeight;
+
+ if (needVertical)
+ viewsize.width -= vScrollbarWidth;
+
+ return viewsize;
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the height of a horizontal scrollbar.
+ *
+ * @return The height of a horizontal scrollbar.
+ */
+public int
+getHScrollbarHeight()
+{
+ ScrollPanePeer spp = (ScrollPanePeer)getPeer();
+ if (spp != null)
+ return(spp.getHScrollbarHeight());
+ else
+ return(0); // FIXME: What to do here?
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the width of a vertical scrollbar.
+ *
+ * @return The width of a vertical scrollbar.
+ */
+public int
+getVScrollbarWidth()
+{
+ ScrollPanePeer spp = (ScrollPanePeer)getPeer();
+ if (spp != null)
+ return(spp.getVScrollbarWidth());
+ else
+ return(0); // FIXME: What to do here?
+}
+
+/*************************************************************************/
+
+/**
+ * Returns the current scroll position of the viewport.
+ *
+ * @return The current scroll position of the viewport.
+ */
+public Point
+getScrollPosition()
+{
+ int x = 0;
+ int y = 0;
+
+ Adjustable v = getVAdjustable();
+ Adjustable h = getHAdjustable();
+
+ if (v != null)
+ y = v.getValue();
+ if (h != null)
+ x = h.getValue();
+
+ return(new Point(x, y));
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the scroll position to the specified value.
+ *
+ * @param scrollPosition The new scrollPosition.
+ *
+ * @exception IllegalArgumentException If the specified value is outside
+ * the legal scrolling range.
+ */
+public void
+setScrollPosition(Point scrollPosition) throws IllegalArgumentException
+{
+ setScrollPosition(scrollPosition.x, scrollPosition.y);
+}
+
+/*************************************************************************/
+
+/**
+ * Sets the scroll position to the specified value.
+ *
+ * @param x The new X coordinate of the scroll position.
+ * @param y The new Y coordinate of the scroll position.
+ *
+ * @exception IllegalArgumentException If the specified value is outside
+ * the legal scrolling range.
+ */
+public void
+setScrollPosition(int x, int y)
+{
+ Adjustable h = getHAdjustable();
+ Adjustable v = getVAdjustable();
+
+ if (h != null)
+ h.setValue(x);
+ if (v != null)
+ v.setValue(y);
+
+ ScrollPanePeer spp = (ScrollPanePeer)getPeer();
+ if (spp != null)
+ spp.setScrollPosition(x, y);
+}
+
+/*************************************************************************/
+
+/**
+ * Notifies this object that it should create its native peer.
+ */
+public void
+addNotify()
+{
+ if (peer != null)
+ return;
+
+ setPeer((ComponentPeer)getToolkit().createScrollPane(this));
+ super.addNotify();
+
+ Component[] list = getComponents();
+ if (list != null && list.length > 0 && ! (list[0] instanceof Panel))
+ {
+ Panel panel = new Panel();
+ panel.setLayout(new BorderLayout());
+ panel.add(list[0], BorderLayout.CENTER);
+ add(panel);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * Notifies this object that it should destroy its native peers.
+ */
+public void
+removeNotify()
+{
+ super.removeNotify();
+}
+
+/*************************************************************************/
+
+/**
+ * Adds the specified child component to this container. A
+ * <code>ScrollPane</code> can have at most one child, so if a second
+ * one is added, then first one is removed.
+ *
+ * @param component The component to add to this container.
+ * @param constraints A list of layout constraints for this object.
+ * @param index The index at which to add the child, which is ignored
+ * in this implementation.
+ */
+ protected final void addImpl (Component component, Object constraints,
+ int index)
+{
+ Component[] list = getComponents();
+ if ((list != null) && (list.length > 0))
+ remove(list[0]);
+
+ super.addImpl(component, constraints, -1);
+
+ doLayout();
+}
+
+/*************************************************************************/
+
+/**
+ * Lays out this component. This consists of resizing the sole child
+ * component to its perferred size.
+ */
+public void
+doLayout()
+{
+ layout ();
+}
+
+/*************************************************************************/
+
+/**
+ * Lays out this component. This consists of resizing the sole child
+ * component to its perferred size.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>doLayout()</code>.
+ */
+public void
+layout()
+{
+ Component[] list = getComponents ();
+ if ((list != null) && (list.length > 0))
+ {
+ Dimension dim = list[0].getPreferredSize ();
+ Dimension vp = getViewportSize ();
+
+ if (dim.width < vp.width)
+ dim.width = vp.width;
+
+ if (dim.height < vp.height)
+ dim.height = vp.height;
+
+ ScrollPanePeer peer = (ScrollPanePeer) getPeer ();
+ if (peer != null)
+ peer.childResized (dim.width, dim.height);
+
+ list[0].setSize (dim);
+
+ Point p = getScrollPosition ();
+ if (p.x > dim.width)
+ p.x = dim.width;
+ if (p.y > dim.height)
+ p.y = dim.height;
+
+ setScrollPosition (p);
+ }
+}
+
+/*************************************************************************/
+
+/**
+ * This method overrides its superclass method to ensure no layout
+ * manager is set for this container. <code>ScrollPane</code>'s do
+ * not have layout managers.
+ *
+ * @param layoutManager Ignored
+ */
+public final void
+setLayout(LayoutManager layoutManager)
+{
+ return;
+}
+
+/*************************************************************************/
+
+/**
+ * Prints all of the components in this container.
+ *
+ * @param graphics The desired graphics context for printing.
+ */
+public void
+printComponents(Graphics graphics)
+{
+ super.printComponents(graphics);
+}
+
+/*************************************************************************/
+
+/**
+ * Returns a debug string for this object.
+ *
+ * @return A debug string for this object.
+ */
+public String
+paramString()
+{
+ Insets insets = getInsets();
+ return getName() + ","
+ + getX() + ","
+ + getY() + ","
+ + getWidth() + "x" + getHeight() + ","
+ + "ScrollPosition=(" + scrollPosition.getX() + ","
+ + scrollPosition.getY() + "),"
+ + "Insets=(" + insets.top + ","
+ + insets.left + ","
+ + insets.bottom + ","
+ + insets.right + "),"
+ + "ScrollbarDisplayPolicy=" + getScrollbarDisplayPolicy() + ","
+ + "wheelScrollingEnabled=" + isWheelScrollingEnabled();
+}
+
+ /**
+ * Tells whether or not an event is enabled.
+ *
+ * @since 1.4
+ */
+ protected boolean eventTypeEnabled (int type)
+ {
+ if (type == MouseEvent.MOUSE_WHEEL)
+ return wheelScrollingEnabled;
+
+ return super.eventTypeEnabled (type);
+ }
+
+ /**
+ * Tells whether or not wheel scrolling is enabled.
+ *
+ * @since 1.4
+ */
+ public boolean isWheelScrollingEnabled ()
+ {
+ return wheelScrollingEnabled;
+ }
+
+ /**
+ * Enables/disables wheel scrolling.
+ *
+ * @since 1.4
+ */
+ public void setWheelScrollingEnabled (boolean enable)
+ {
+ wheelScrollingEnabled = enable;
+ }
+
+ protected class AccessibleAWTScrollPane extends AccessibleAWTContainer
+ {
+ private static final long serialVersionUID = 6100703663886637L;
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.SCROLL_PANE;
+ }
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>ScrollPane</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 AccessibleAWTScrollPane();
+ return accessibleContext;
+ }
+
+ /**
+ * Generate a unique name for this <code>ScrollPane</code>.
+ *
+ * @return A unique name for this <code>ScrollPane</code>.
+ */
+ String generateName()
+ {
+ return "scrollpane" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_scrollpane_number++;
+ }
+
+} // class ScrollPane
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPaneAdjustable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPaneAdjustable.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPaneAdjustable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/ScrollPaneAdjustable.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,213 @@
+/* ScrollPaneAdjustable.java -- Scrollbars for a ScrollPane
+ Copyright (C) 1999 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 java.awt.event.AdjustmentListener;
+import java.io.Serializable;
+
+/**
+ * Need this class since the serialization spec for ScrollPane
+ * uses it.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.4
+ */
+public class ScrollPaneAdjustable
+ implements Adjustable, Serializable
+{
+ private static final long serialVersionUID = -3359745691033257079L;
+
+ ScrollPane sp;
+ int orientation;
+ int value;
+ int minimum;
+ int maximum;
+ int visibleAmount;
+ int unitIncrement = 1;
+ int blockIncrement = 1;
+ AdjustmentListener adjustmentListener;
+
+ private transient boolean valueIsAdjusting = false;
+
+ ScrollPaneAdjustable (ScrollPane sp, int orientation)
+ {
+ this.sp = sp;
+ this.orientation = orientation;
+ }
+
+ ScrollPaneAdjustable (ScrollPane sp, int orientation, int value, int minimum,
+ int maximum, int visibleAmount, int unitIncrement,
+ int blockIncrement)
+ {
+ this.sp = sp;
+ this.orientation = orientation;
+ this.value = value;
+ this.minimum = minimum;
+ this.maximum = maximum;
+ this.visibleAmount = visibleAmount;
+ this.unitIncrement = unitIncrement;
+ this.blockIncrement = blockIncrement;
+ }
+
+ public void addAdjustmentListener (AdjustmentListener listener)
+ {
+ if (listener == null)
+ return;
+ adjustmentListener = AWTEventMulticaster.add (adjustmentListener, listener);
+ }
+
+ public void removeAdjustmentListener (AdjustmentListener listener)
+ {
+ if (listener == null)
+ return;
+ adjustmentListener = AWTEventMulticaster.remove (adjustmentListener, listener);
+ }
+
+ public AdjustmentListener[] getAdjustmentListeners ()
+ {
+ return (AdjustmentListener[]) AWTEventMulticaster.getListeners
+ (adjustmentListener, AdjustmentListener.class);
+ }
+
+ public int getBlockIncrement ()
+ {
+ return blockIncrement;
+ }
+
+ public int getMaximum ()
+ {
+ return maximum;
+ }
+
+ public int getMinimum ()
+ {
+ return minimum;
+ }
+
+ public int getOrientation ()
+ {
+ return orientation;
+ }
+
+ public int getUnitIncrement ()
+ {
+ return unitIncrement;
+ }
+
+ public int getValue ()
+ {
+ return value;
+ }
+
+ public int getVisibleAmount ()
+ {
+ return visibleAmount;
+ }
+
+ public void setBlockIncrement (int blockIncrement)
+ {
+ this.blockIncrement = blockIncrement;
+ }
+
+ public void setMaximum (int maximum)
+ {
+ this.maximum = maximum;
+ }
+
+ public void setMinimum (int minimum)
+ {
+ this.minimum = minimum;
+ }
+
+ public void setUnitIncrement (int unitIncrement)
+ {
+ this.unitIncrement = unitIncrement;
+ }
+
+ public void setValue (int value)
+ {
+ this.value = value;
+
+ if (value < minimum)
+ minimum = value;
+
+ if (value > maximum)
+ maximum = value;
+ }
+
+ public void setVisibleAmount (int visibleAmount)
+ {
+ this.visibleAmount = visibleAmount;
+ }
+
+ public String paramString ()
+ {
+ return ("scrollpane=" + sp + ", orientation=" + orientation
+ + ", value=" + value + ", minimum=" + minimum
+ + ", maximum=" + maximum + ", visibleAmount=" + visibleAmount
+ + ", unitIncrement=" + unitIncrement
+ + ", blockIncrement=" + blockIncrement);
+ }
+
+ public String toString()
+ {
+ return getClass().getName() + "[" + paramString() + "]";
+ }
+
+ /**
+ * Returns true if the value is in the process of changing.
+ *
+ * @since 1.4
+ */
+ public boolean getValueIsAdjusting ()
+ {
+ return valueIsAdjusting;
+ }
+
+ /**
+ * Sets the value of valueIsAdjusting.
+ *
+ * @since 1.4
+ */
+ public void setValueIsAdjusting (boolean valueIsAdjusting)
+ {
+ this.valueIsAdjusting = valueIsAdjusting;
+ }
+} // class ScrollPaneAdjustable
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Scrollbar.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Scrollbar.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Scrollbar.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Scrollbar.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,845 @@
+/* Scrollbar.java -- AWT Scrollbar widget
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 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 java.awt.event.AdjustmentEvent;
+import java.awt.event.AdjustmentListener;
+import java.awt.peer.ScrollbarPeer;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.accessibility.AccessibleValue;
+
+/**
+ * This class implements a scrollbar widget.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Tom Tromey (tromey at cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+public class Scrollbar extends Component implements Accessible, Adjustable
+{
+ // FIXME: Serialization readObject/writeObject
+
+ /**
+ * Constant indicating that a scrollbar is horizontal.
+ */
+ public static final int HORIZONTAL = 0;
+
+ /**
+ * Constant indicating that a scrollbar is vertical.
+ */
+ public static final int VERTICAL = 1;
+
+ /**
+ * Serialization Constant.
+ */
+ private static final long serialVersionUID = 8451667562882310543L;
+
+ /**
+ * @serial The amount by which the value of the scrollbar is changed
+ * when incrementing in line mode.
+ */
+ private int lineIncrement;
+
+ /**
+ * @serial The amount by which the value of the scrollbar is changed
+ * when incrementing in page mode.
+ */
+ private int pageIncrement;
+
+ /**
+ * @serial The maximum value for this scrollbar
+ */
+ private int maximum;
+
+ /**
+ * @serial The minimum value for this scrollbar
+ */
+ private int minimum;
+
+ /**
+ * @serial The orientation of this scrollbar, which will be either
+ * the <code>HORIZONTAL</code> or <code>VERTICAL</code> constant
+ * from this class.
+ */
+ private int orientation;
+
+ /**
+ * @serial The current value of this scrollbar.
+ */
+ private int value;
+
+ /**
+ * @serial The width of the scrollbar's thumb, which is relative
+ * to the minimum and maximum value of the scrollbar.
+ */
+ private int visibleAmount;
+
+ /**
+ * List of AdjustmentListener's.
+ */
+ private AdjustmentListener adjustment_listeners;
+
+ /**
+ * true if the scrollbar is adjusting, false otherwise.
+ */
+ private transient boolean valueIsAdjusting = false;
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_scrollbar_number;
+
+ /**
+ * Initializes a new instance of <code>Scrollbar</code> with a
+ * vertical orientation and default values for all other parameters.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public Scrollbar()
+ {
+ this(VERTICAL);
+ }
+
+ /**
+ * Initializes a new instance of <code>Scrollbar</code> with the
+ * specified orientation and default values for all other parameters.
+ * The orientation must be either the constant <code>HORIZONTAL</code> or
+ * <code>VERTICAL</code> from this class. An incorrect value will throw
+ * an exception.
+ *
+ * @param orientation The orientation of this scrollbar.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ * @exception IllegalArgumentException If the orientation value is not valid.
+ */
+ public Scrollbar(int orientation) throws IllegalArgumentException
+ {
+ this(orientation, 0, 10, 0, 100);
+ }
+
+ /**
+ * Initializes a new instance of <code>Scrollbar</code> with the
+ * specified parameters. The orientation must be either the constant
+ * <code>HORIZONTAL</code> or <code>VERTICAL</code>. An incorrect value
+ * will throw an exception. Inconsistent values for other parameters
+ * are silently corrected to valid values.
+ *
+ * @param orientation The orientation of this scrollbar.
+ * @param value The initial value of the scrollbar.
+ * @param visibleAmount The width of the scrollbar thumb.
+ * @param minimum The minimum value of the scrollbar.
+ * @param maximum The maximum value of the scrollbar.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ * @exception IllegalArgumentException If the orientation value is not valid.
+ */
+ public Scrollbar(int orientation, int value, int visibleAmount, int minimum,
+ int maximum) throws IllegalArgumentException
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException();
+
+ if ((orientation != HORIZONTAL) && (orientation != VERTICAL))
+ throw new IllegalArgumentException("Bad orientation value: "
+ + orientation);
+
+ this.orientation = orientation;
+
+ setValues(value, visibleAmount, minimum, maximum);
+
+ // Default is 1 according to online docs.
+ lineIncrement = 1;
+
+ // Default is 10 according to javadocs.
+ pageIncrement = 10;
+ }
+
+ /**
+ * Returns the orientation constant for this object.
+ *
+ * @return The orientation constant for this object.
+ */
+ public int getOrientation()
+ {
+ return orientation;
+ }
+
+ /**
+ * Sets the orientation of this scrollbar to the specified value. This
+ * value must be either the constant <code>HORIZONTAL</code> or
+ * <code>VERTICAL</code> from this class or an exception will be thrown.
+ *
+ * @param orientation The new orientation value.
+ *
+ * @exception IllegalArgumentException If the orientation value is not valid.
+ */
+ public void setOrientation(int orientation)
+ {
+ if ((orientation != HORIZONTAL) && (orientation != VERTICAL))
+ throw new IllegalArgumentException("Bad orientation value: "
+ + orientation);
+
+ // FIXME: Communicate to peer? Or must this be called before peer creation?
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the current value for this scrollbar.
+ *
+ * @return The current value for this scrollbar.
+ */
+ public int getValue()
+ {
+ return value;
+ }
+
+ /**
+ * Sets the current value for this scrollbar to the specified value.
+ * If this is inconsistent with the minimum and maximum values for this
+ * scrollbar, the value is silently adjusted.
+ *
+ * @param value The new value for this scrollbar.
+ */
+ public void setValue(int value)
+ {
+ setValues(value, visibleAmount, minimum, maximum);
+ }
+
+ /**
+ * Returns the maximum value for this scrollbar.
+ *
+ * @return The maximum value for this scrollbar.
+ */
+ public int getMaximum()
+ {
+ return maximum;
+ }
+
+ /**
+ * Sets the maximum value for this scrollbar to the specified value.
+ * If the value is less than the current minimum value, it is silent
+ * set to equal the minimum value.
+ *
+ * @param maximum The new maximum value for this scrollbar.
+ */
+ public void setMaximum(int maximum)
+ {
+ setValues(value, visibleAmount, minimum, maximum);
+ }
+
+ /**
+ * Returns the minimum value for this scrollbar.
+ *
+ * @return The minimum value for this scrollbar.
+ */
+ public int getMinimum()
+ {
+ return minimum;
+ }
+
+ /**
+ * Sets the minimum value for this scrollbar to the specified value. If
+ * this is not consistent with the current value and maximum, it is
+ * silently adjusted to be consistent.
+ *
+ * @param minimum The new minimum value for this scrollbar.
+ */
+ public void setMinimum(int minimum)
+ {
+ setValues(value, visibleAmount, minimum, maximum);
+ }
+
+ /**
+ * Returns the width of the scrollbar's thumb, in units relative to the
+ * maximum and minimum value of the scrollbar.
+ *
+ * @return The width of the scrollbar's thumb.
+ */
+ public int getVisibleAmount()
+ {
+ return getVisible();
+ }
+
+ /**
+ * Returns the width of the scrollbar's thumb, in units relative to the
+ * maximum and minimum value of the scrollbar.
+ *
+ * @return The width of the scrollbar's thumb.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getVisibleAmount()</code>.
+ */
+ public int getVisible()
+ {
+ return visibleAmount;
+ }
+
+ /**
+ * Sets the width of the scrollbar's thumb, in units relative to the
+ * maximum and minimum value of the scrollbar.
+ *
+ * @param visibleAmount The new visible amount value of the scrollbar.
+ */
+ public void setVisibleAmount(int visibleAmount)
+ {
+ setValues(value, visibleAmount, minimum, maximum);
+ }
+
+ /**
+ * Sets the current value, visible amount, minimum, and maximum for this
+ * scrollbar. These values are adjusted to be internally consistent
+ * if necessary.
+ *
+ * @param value The new value for this scrollbar.
+ * @param visibleAmount The new visible amount for this scrollbar.
+ * @param minimum The new minimum value for this scrollbar.
+ * @param maximum The new maximum value for this scrollbar.
+ */
+ public synchronized void setValues(int value, int visibleAmount,
+ int minimum, int maximum)
+ {
+ if (maximum < minimum)
+ maximum = minimum;
+
+ if (value < minimum)
+ value = minimum;
+
+ if (value > maximum)
+ value = maximum;
+
+ if (visibleAmount > maximum - minimum)
+ visibleAmount = maximum - minimum;
+
+ ScrollbarPeer peer = (ScrollbarPeer) getPeer();
+ if (peer != null
+ && (this.value != value || this.visibleAmount != visibleAmount
+ || this.minimum != minimum || this.maximum != maximum))
+ peer.setValues(value, visibleAmount, minimum, maximum);
+
+ this.value = value;
+ this.visibleAmount = visibleAmount;
+ this.minimum = minimum;
+ this.maximum = maximum;
+
+ int range = maximum - minimum;
+ if (lineIncrement > range)
+ {
+ if (range == 0)
+ lineIncrement = 1;
+ else
+ lineIncrement = range;
+
+ if (peer != null)
+ peer.setLineIncrement(lineIncrement);
+ }
+
+ if (pageIncrement > range)
+ {
+ if (range == 0)
+ pageIncrement = 1;
+ else
+ pageIncrement = range;
+
+ if (peer != null)
+ peer.setPageIncrement(pageIncrement);
+ }
+ }
+
+ /**
+ * Returns the value added or subtracted when the user activates the scrollbar
+ * scroll by a "unit" amount.
+ *
+ * @return The unit increment value.
+ */
+ public int getUnitIncrement()
+ {
+ return getLineIncrement();
+ }
+
+ /**
+ * Returns the value added or subtracted when the user selects the scrollbar
+ * scroll by a "unit" amount control.
+ *
+ * @return The unit increment value.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getUnitIncrement()</code>.
+ */
+ public int getLineIncrement()
+ {
+ return lineIncrement;
+ }
+
+ /**
+ * Sets the value added or subtracted to the scrollbar value when the
+ * user selects the scroll by a "unit" amount control.
+ *
+ * @param unitIncrement The new unit increment amount.
+ */
+ public synchronized void setUnitIncrement(int unitIncrement)
+ {
+ setLineIncrement(unitIncrement);
+ }
+
+ /**
+ * Sets the value added or subtracted to the scrollbar value when the
+ * user selects the scroll by a "unit" amount control.
+ *
+ * @param lineIncrement The new unit increment amount.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>setUnitIncrement()</code>.
+ */
+ public void setLineIncrement(int lineIncrement)
+ {
+ if (lineIncrement < 0)
+ throw new IllegalArgumentException("Unit increment less than zero.");
+
+ int range = maximum - minimum;
+ if (lineIncrement > range)
+ {
+ if (range == 0)
+ lineIncrement = 1;
+ else
+ lineIncrement = range;
+ }
+
+ if (lineIncrement == this.lineIncrement)
+ return;
+
+ this.lineIncrement = lineIncrement;
+
+ ScrollbarPeer peer = (ScrollbarPeer) getPeer();
+ if (peer != null)
+ peer.setLineIncrement(this.lineIncrement);
+ }
+
+ /**
+ * Returns the value added or subtracted when the user activates the scrollbar
+ * scroll by a "block" amount.
+ *
+ * @return The block increment value.
+ */
+ public int getBlockIncrement()
+ {
+ return getPageIncrement();
+ }
+
+ /**
+ * Returns the value added or subtracted when the user selects the scrollbar
+ * scroll by a "block" amount control.
+ *
+ * @return The block increment value.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getBlockIncrement()</code>.
+ */
+ public int getPageIncrement()
+ {
+ return pageIncrement;
+ }
+
+ /**
+ * Sets the value added or subtracted to the scrollbar value when the
+ * user selects the scroll by a "block" amount control.
+ *
+ * @param blockIncrement The new block increment amount.
+ */
+ public synchronized void setBlockIncrement(int blockIncrement)
+ {
+ setPageIncrement(blockIncrement);
+ }
+
+ /**
+ * Sets the value added or subtracted to the scrollbar value when the
+ * user selects the scroll by a "block" amount control.
+ *
+ * @param pageIncrement The new block increment amount.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>setBlockIncrement()</code>.
+ */
+ public void setPageIncrement(int pageIncrement)
+ {
+ if (pageIncrement < 0)
+ throw new IllegalArgumentException("Block increment less than zero.");
+
+ int range = maximum - minimum;
+ if (pageIncrement > range)
+ {
+ if (range == 0)
+ pageIncrement = 1;
+ else
+ pageIncrement = range;
+ }
+
+ if (pageIncrement == this.pageIncrement)
+ return;
+
+ this.pageIncrement = pageIncrement;
+
+ ScrollbarPeer peer = (ScrollbarPeer) getPeer();
+ if (peer != null)
+ peer.setPageIncrement(this.pageIncrement);
+ }
+
+ /**
+ * Notifies this object to create its native peer.
+ */
+ public synchronized void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit().createScrollbar(this);
+ super.addNotify();
+ }
+
+ /**
+ * Adds a new adjustment listener to the list of registered listeners
+ * for this object.
+ *
+ * @param listener The listener to add.
+ */
+ public synchronized void addAdjustmentListener(AdjustmentListener listener)
+ {
+ adjustment_listeners = AWTEventMulticaster.add(adjustment_listeners,
+ listener);
+ enableEvents(AWTEvent.ADJUSTMENT_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the list of registered listeners
+ * for this object.
+ *
+ * @param listener The listener to remove.
+ */
+ public synchronized void removeAdjustmentListener(AdjustmentListener listener)
+ {
+ adjustment_listeners = AWTEventMulticaster.remove(adjustment_listeners,
+ listener);
+ }
+
+ /**
+ * Processes events for this scrollbar. It does this by calling
+ * <code>processAdjustmentEvent()</code> if the event is an instance of
+ * <code>AdjustmentEvent</code>, otherwise it calls the superclass to
+ * process the event.
+ *
+ * @param event The event to process.
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof AdjustmentEvent)
+ processAdjustmentEvent((AdjustmentEvent) event);
+ else
+ super.processEvent(event);
+ }
+
+ /**
+ * Processes adjustment events for this object by dispatching them to
+ * any registered listeners. Note that this method will only be called
+ * if adjustment events are enabled. This will happen automatically if
+ * any listeners are registered. Otherwise, it can be enabled by a
+ * call to <code>enableEvents()</code>.
+ *
+ * @param event The event to process.
+ */
+ protected void processAdjustmentEvent(AdjustmentEvent event)
+ {
+ value = event.getValue();
+ if (adjustment_listeners != null)
+ 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)
+ {
+ 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);
+ }
+
+ /**
+ * Returns a debugging string for this object.
+ *
+ * @return A debugging string for this object.
+ */
+ protected String paramString()
+ {
+ return ("value=" + getValue() + ",visibleAmount=" + getVisibleAmount()
+ + ",minimum=" + getMinimum() + ",maximum=" + getMaximum()
+ + ",pageIncrement=" + pageIncrement + ",lineIncrement="
+ + lineIncrement + ",orientation="
+ + (orientation == HORIZONTAL ? "HORIZONTAL" : "VERTICAL")
+ + super.paramString());
+ }
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this <code>Scrollbar</code>. FooListeners are registered using the
+ * addFooListener method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == AdjustmentListener.class)
+ return AWTEventMulticaster.getListeners(adjustment_listeners,
+ listenerType);
+
+ return super.getListeners(listenerType);
+ }
+
+ /**
+ * Returns an array of all registered adjustment listeners.
+ */
+ public AdjustmentListener[] getAdjustmentListeners()
+ {
+ return (AdjustmentListener[]) getListeners(AdjustmentListener.class);
+ }
+
+ /**
+ * Returns true if the value is in the process of changing.
+ *
+ * @since 1.4
+ */
+ public boolean getValueIsAdjusting()
+ {
+ return valueIsAdjusting;
+ }
+
+ /**
+ * Sets the value of valueIsAdjusting.
+ *
+ * @since 1.4
+ */
+ public void setValueIsAdjusting(boolean valueIsAdjusting)
+ {
+ this.valueIsAdjusting = valueIsAdjusting;
+ }
+
+ /**
+ * Generate a unique name for this scroll bar.
+ *
+ * @return A unique name for this scroll bar.
+ */
+ String generateName()
+ {
+ return "scrollbar" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_scrollbar_number++;
+ }
+
+ /**
+ * This class provides accessibility support for the
+ * scrollbar.
+ *
+ * @author Jerry Quinn (jlquinn at optonline.net)
+ * @author Andrew John Hughes (gnu_andrew at member.fsf.org)
+ */
+ protected class AccessibleAWTScrollBar extends AccessibleAWTComponent
+ implements AccessibleValue
+ {
+ /**
+ * Serialization constant to match JDK 1.5
+ */
+ private static final long serialVersionUID = -344337268523697807L;
+
+ /**
+ * Returns the role of this accessible object.
+ *
+ * @return the instance of <code>AccessibleRole</code>,
+ * which describes this object.
+ *
+ * @see javax.accessibility.AccessibleRole
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.SCROLL_BAR;
+ }
+
+ /**
+ * Returns the state set of this accessible object.
+ *
+ * @return a set of <code>AccessibleState</code>s which
+ * represent the current state of the accessible object.
+ *
+ * @see javax.accessibility.AccessibleState
+ * @see javax.accessibility.AccessibleStateSet
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ if (getOrientation() == HORIZONTAL)
+ states.add(AccessibleState.HORIZONTAL);
+ else
+ states.add(AccessibleState.VERTICAL);
+ if (getValueIsAdjusting())
+ states.add(AccessibleState.BUSY);
+ return states;
+ }
+
+ /**
+ * Returns an implementation of the <code>AccessibleValue</code>
+ * interface for this accessible object. In this case, the
+ * current instance is simply returned (with a more appropriate
+ * type), as it also implements the accessible value as well as
+ * the context.
+ *
+ * @return the accessible value associated with this context.
+ *
+ * @see javax.accessibility.AccessibleValue
+ */
+ public AccessibleValue getAccessibleValue()
+ {
+ return this;
+ }
+
+ /**
+ * Returns the current value of this accessible object.
+ * In this case, this is the same as the value for
+ * the scrollbar, wrapped in an <code>Integer</code>
+ * object.
+ *
+ * @return the numeric value of this scrollbar.
+ *
+ * @see javax.accessibility.AccessibleValue#getCurrentAccessibleValue()
+ */
+ public Number getCurrentAccessibleValue()
+ {
+ return new Integer(getValue());
+ }
+
+ /**
+ * Sets the current value of this accessible object
+ * to that supplied. In this case, the value of the
+ * scrollbar is set, and this method always returns
+ * true.
+ *
+ * @param number the new accessible value.
+ *
+ * @return true if the value was set.
+ *
+ * @see javax.accessibility.AccessibleValue#setCurrentAccessibleValue(java.lang.Number)
+ */
+ public boolean setCurrentAccessibleValue(Number number)
+ {
+ setValue(number.intValue());
+ return true;
+ }
+
+ /**
+ * Returns the minimum acceptable accessible value used
+ * by this object. In this case, this is the same as
+ * the minimum value of the scrollbar, wrapped in an
+ * object.
+ *
+ * @return the minimum value of this scrollbar.
+ *
+ * @see javax.accessibility.AccessibleValue#getMinimumAccessibleValue()
+ */
+ public Number getMinimumAccessibleValue()
+ {
+ return new Integer(getMinimum());
+ }
+
+ /**
+ * Returns the maximum acceptable accessible value used
+ * by this object. In this case, this is the same as
+ * the maximum value of the scrollbar, wrapped in an
+ * object.
+ *
+ * @return the maximum value of this scrollbar.
+ *
+ * @see javax.accessibility.AccessibleValue#getMaximumAccessibleValue()
+ */
+ public Number getMaximumAccessibleValue()
+ {
+ return new Integer(getMaximum());
+ }
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Scrollbar</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 AccessibleAWTScrollBar();
+
+ return accessibleContext;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Shape.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Shape.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Shape.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Shape.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,205 @@
+/* Shape.java -- the classic Object-Oriented shape interface
+ Copyright (C) 1999, 2002, 2005, 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 java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/**
+ * This interface represents an abstract shape. The shape is described by
+ * a {@link PathIterator}, and has callbacks for determining bounding box,
+ * where points and rectangles lie in relation to the shape, and tracing
+ * the trajectory.
+ *
+ * <p>A point is inside if it is completely inside, or on the boundary and
+ * adjacent points in the increasing x or y direction are completely inside.
+ * Unclosed shapes are considered as implicitly closed when performing
+ * <code>contains</code> or <code>intersects</code>.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see PathIterator
+ * @see AffineTransform
+ * @see java.awt.geom.FlatteningPathIterator
+ * @see java.awt.geom.GeneralPath
+ * @since 1.0
+ * @status updated to 1.4
+ */
+public interface Shape
+{
+ /**
+ * Returns a <code>Rectange</code> that bounds the shape. There is no
+ * guarantee that this is the minimum bounding box, particularly if
+ * the shape overflows the finite integer range of a bound. Generally,
+ * <code>getBounds2D</code> returns a tighter bound.
+ *
+ * @return the shape's bounding box
+ * @see #getBounds2D()
+ */
+ Rectangle getBounds();
+
+ /**
+ * Returns a high precision bounding box of the shape. There is no guarantee
+ * that this is the minimum bounding box, but at least it never overflows.
+ *
+ * @return the shape's bounding box
+ * @see #getBounds()
+ * @since 1.2
+ */
+ Rectangle2D getBounds2D();
+
+ /**
+ * Test if the coordinates lie in the shape.
+ *
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @return true if (x,y) lies inside the shape
+ * @since 1.2
+ */
+ boolean contains(double x, double y);
+
+ /**
+ * Test if the point lie in the shape.
+ *
+ * @param p the high-precision point
+ * @return true if p lies inside the shape
+ * @throws NullPointerException if p is null
+ * @since 1.2
+ */
+ boolean contains(Point2D p);
+
+ /**
+ * Test if a high-precision rectangle intersects the shape. This is true
+ * if any point in the rectangle is in the shape, with the caveat that the
+ * operation may include high probability estimates when the actual
+ * calculation is prohibitively expensive. The {@link java.awt.geom.Area}
+ * class can be used for more precise answers.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param w the width of the rectangle, undefined results if negative
+ * @param h the height of the rectangle, undefined results if negative
+ * @return true if the rectangle intersects this shape
+ * @see java.awt.geom.Area
+ * @since 1.2
+ */
+ boolean intersects(double x, double y, double w, double h);
+
+ /**
+ * Test if a high-precision rectangle intersects the shape. This is true
+ * if any point in the rectangle is in the shape, with the caveat that the
+ * operation may include high probability estimates when the actual
+ * calculation is prohibitively expensive. The {@link java.awt.geom.Area}
+ * class can be used for more precise answers.
+ *
+ * @param r the rectangle
+ * @return true if the rectangle intersects this shape
+ * @throws NullPointerException if r is null
+ * @see #intersects(double, double, double, double)
+ * @since 1.2
+ */
+ boolean intersects(Rectangle2D r);
+
+ /**
+ * Test if a high-precision rectangle lies completely in the shape. This is
+ * true if all points in the rectangle are in the shape, with the caveat
+ * that the operation may include high probability estimates when the actual
+ * calculation is prohibitively expensive. The {@link java.awt.geom.Area}
+ * class can be used for more precise answers.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param w the width of the rectangle, undefined results if negative
+ * @param h the height of the rectangle, undefined results if negative
+ * @return true if the rectangle is contained in this shape
+ * @see java.awt.geom.Area
+ * @since 1.2
+ */
+ boolean contains(double x, double y, double w, double h);
+
+ /**
+ * Test if a high-precision rectangle lies completely in the shape. This is
+ * true if all points in the rectangle are in the shape, with the caveat
+ * that the operation may include high probability estimates when the actual
+ * calculation is prohibitively expensive. The {@link java.awt.geom.Area}
+ * class can be used for more precise answers.
+ *
+ * @param r the rectangle
+ * @return true if the rectangle is contained in this shape
+ * @throws NullPointerException if r is null
+ * @see #contains(double, double, double, double)
+ * @since 1.2
+ */
+ boolean contains(Rectangle2D r);
+
+ /**
+ * Return an iterator along the shape boundary. If the optional transform
+ * is provided, the iterator is transformed accordingly. Each call returns
+ * a new object, independent from others in use. It is recommended, but
+ * not required, that the Shape isolate iterations from future changes to
+ * the boundary, and document this fact.
+ *
+ * @param transform an optional transform to apply to the
+ * iterator (<code>null</code> permitted).
+ * @return a new iterator over the boundary
+ * @since 1.2
+ */
+ PathIterator getPathIterator(AffineTransform transform);
+
+ /**
+ * Return an iterator along the flattened version of the shape boundary.
+ * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE points are returned in the
+ * iterator. The flatness parameter controls how far points are allowed to
+ * differ from the real curve; although a limit on accuracy may cause this
+ * parameter to be enlarged if needed.
+ *
+ * <p>If the optional transform is provided, the iterator is transformed
+ * accordingly. Each call returns a new object, independent from others in
+ * use. It is recommended, but not required, that the Shape isolate
+ * iterations from future changes to the boundary, and document this fact.
+ *
+ * @param transform an optional transform to apply to the
+ * iterator (<code>null</code> permitted).
+ * @param flatness the maximum distance for deviation from the real boundary
+ * @return a new iterator over the boundary
+ * @since 1.2
+ */
+ PathIterator getPathIterator(AffineTransform transform, double flatness);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Stroke.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Stroke.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Stroke.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Stroke.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* Stroke.java -- a stroked outline of a shape
+ Copyright (C) 2002, 2005 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;
+
+/**
+ * This interface allows a Graphics2D to grab the outline of a shape, as if
+ * stroked by a marking pen of appropriate size and shape. The area inked
+ * by the pen is the area of this stroke. Anything in the graphic which
+ * traces an outline will use this stroke, such as <code>drawLine</code>.
+ * Strokes must be immutable, because the graphics object does not clone
+ * them.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see BasicStroke
+ * @see Graphics2D#setStroke(Stroke)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface Stroke
+{
+ /**
+ * Returns a shape which outlines the boundary of the given shape, in
+ * effect converting the infinitely thin line into a new shape.
+ *
+ * @param s the shape to stroke
+ * @return the stroked outline shape
+ */
+ Shape createStrokedShape(Shape s);
+} // interface Stroke
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/SystemColor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/SystemColor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/SystemColor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/SystemColor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,462 @@
+/* SystemColor.java -- access dynamic system color values
+ Copyright (C) 1999, 2002, 2004, 2005 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 java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
+import java.io.Serializable;
+
+/**
+ * This class contains the various "system colors" in use by the native
+ * windowing system. The <code>getRGB()</code> method is dynamic on systems
+ * which support dynamic system color changes, and most methods in the
+ * superclass are written to use this dynamic value when reporting colors.
+ * However, the <code>equals()</code> method is not dynamic, and does not
+ * track the actual color of instances in this class. This means that equals
+ * may give surprising results; you are better off relying on getRGB.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public final class SystemColor extends Color implements Serializable
+{
+ // Implementation note: To be serial compatible with JDK, this class must
+ // violate the semantic meaning of super.value to be one of the
+ // NUM_COLORS constants instead of the actual RGB value. Hence there are
+ // a lot of ugly workarounds in Color and in this class. I would have
+ // designed it MUCH differently, making a separate id field in this class.
+
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 4503142729533789064L;
+
+ /**
+ * Array index of the desktop color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #desktop
+ */
+ public static final int DESKTOP = 0;
+
+ /**
+ * Array index of the active caption color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #activeCaption
+ */
+ public static final int ACTIVE_CAPTION = 1;
+
+ /**
+ * Array index of the active caption text color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #activeCaptionText
+ */
+ public static final int ACTIVE_CAPTION_TEXT = 2;
+
+ /**
+ * Array index of the active caption border color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #activeCaptionBorder
+ */
+ public static final int ACTIVE_CAPTION_BORDER = 3;
+
+ /**
+ * Array index of the inactive caption color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #inactiveCaption
+ */
+ public static final int INACTIVE_CAPTION = 4;
+
+ /**
+ * Array index of the inactive caption text color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #inactiveCaptionText
+ */
+ public static final int INACTIVE_CAPTION_TEXT = 5;
+
+ /**
+ * Array index of the inactive caption border color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #inactiveCaptionBorder
+ */
+ public static final int INACTIVE_CAPTION_BORDER = 6;
+
+ /**
+ * Array index of the window background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #window
+ */
+ public static final int WINDOW = 7;
+
+ /**
+ * Array index of the window border color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #windowBorder
+ */
+ public static final int WINDOW_BORDER = 8;
+
+ /**
+ * Array index of the window text color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #windowText
+ */
+ public static final int WINDOW_TEXT = 9;
+
+ /**
+ * Array index of the menu background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #menu
+ */
+ public static final int MENU = 10;
+
+ /**
+ * Array index of the menu text color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #menuText
+ */
+ public static final int MENU_TEXT = 11;
+
+ /**
+ * Array index of the text background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #text
+ */
+ public static final int TEXT = 12;
+
+ /**
+ * Array index of the text foreground color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #textText
+ */
+ public static final int TEXT_TEXT = 13;
+
+ /**
+ * Array index of the highlighted text background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #textHighlight
+ */
+ public static final int TEXT_HIGHLIGHT = 14;
+
+ /**
+ * Array index of the highlighted text foreground color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #textHighlightText
+ */
+ public static final int TEXT_HIGHLIGHT_TEXT = 15;
+
+ /**
+ * Array index of the inactive text foreground color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #textInactiveText
+ */
+ public static final int TEXT_INACTIVE_TEXT = 16;
+
+ /**
+ * Array index of the control background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #control
+ */
+ public static final int CONTROL = 17;
+
+ /**
+ * Array index of the control text color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #controlText
+ */
+ public static final int CONTROL_TEXT = 18;
+
+ /**
+ * Array index of the highlighted control background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #controlHighlight
+ */
+ public static final int CONTROL_HIGHLIGHT = 19;
+
+ /**
+ * Array index of the lightly highlighted control background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #controlLtHighlight
+ */
+ public static final int CONTROL_LT_HIGHLIGHT = 20;
+
+ /**
+ * Array index of the shadowed control background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #controlShadow
+ */
+ public static final int CONTROL_SHADOW = 21;
+
+ /**
+ * Array index of the darkly shadowed control background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #controlDkShadow
+ */
+ public static final int CONTROL_DK_SHADOW = 22;
+
+ /**
+ * Array index of the scrollbar background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #scrollbar
+ */
+ public static final int SCROLLBAR = 23;
+
+ /**
+ * Array index of the info background color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #info
+ */
+ public static final int INFO = 24;
+
+ /**
+ * Array index of the info text color. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ *
+ * @see #infoText
+ */
+ public static final int INFO_TEXT = 25;
+
+ /**
+ * The number of system colors. Used by
+ * {@link Toolkit#loadSystemColors(int[])}.
+ */
+ public static final int NUM_COLORS = 26;
+
+ /**
+ * The internal array used to dynamically update <code>getRGB()</code>.
+ */
+ private static final int[] colors = new int[NUM_COLORS];
+
+ /** The desktop color. */
+ public static final SystemColor desktop
+ = new SystemColor(DESKTOP);
+
+ /** The active caption background color. */
+ public static final SystemColor activeCaption
+ = new SystemColor(ACTIVE_CAPTION);
+
+ /** The active caption text color. */
+ public static final SystemColor activeCaptionText
+ = new SystemColor(ACTIVE_CAPTION_TEXT);
+
+ /** The active caption border color. */
+ public static final SystemColor activeCaptionBorder
+ = new SystemColor(ACTIVE_CAPTION_BORDER);
+
+ /** The inactive caption background color. */
+ public static final SystemColor inactiveCaption
+ = new SystemColor(INACTIVE_CAPTION);
+
+ /** The inactive caption text color. */
+ public static final SystemColor inactiveCaptionText
+ = new SystemColor(INACTIVE_CAPTION_TEXT);
+
+ /** The inactive caption border color. */
+ public static final SystemColor inactiveCaptionBorder
+ = new SystemColor(INACTIVE_CAPTION_BORDER);
+
+ /** The window background color. */
+ public static final SystemColor window
+ = new SystemColor(WINDOW);
+
+ /** The window border color. */
+ public static final SystemColor windowBorder
+ = new SystemColor(WINDOW_BORDER);
+
+ /** The window text color. */
+ public static final SystemColor windowText
+ = new SystemColor(WINDOW_TEXT);
+
+ /** The menu background color. */
+ public static final SystemColor menu
+ = new SystemColor(MENU);
+
+ /** The menu text color. */
+ public static final SystemColor menuText
+ = new SystemColor(MENU_TEXT);
+
+ /** The text background color. */
+ public static final SystemColor text
+ = new SystemColor(TEXT);
+
+ /** The text foreground color. */
+ public static final SystemColor textText
+ = new SystemColor(TEXT_TEXT);
+
+ /** The highlighted text background color. */
+ public static final SystemColor textHighlight
+ = new SystemColor(TEXT_HIGHLIGHT);
+
+ /** The highlighted text foreground color. */
+ public static final SystemColor textHighlightText
+ = new SystemColor(TEXT_HIGHLIGHT_TEXT);
+
+ /** The inactive text color. */
+ public static final SystemColor textInactiveText
+ = new SystemColor(TEXT_INACTIVE_TEXT);
+
+ /** The control background color. */
+ public static final SystemColor control
+ = new SystemColor(CONTROL);
+
+ /** The control text color. */
+ public static final SystemColor controlText
+ = new SystemColor(CONTROL_TEXT);
+
+ /** The control highlight color. */
+ public static final SystemColor controlHighlight
+ = new SystemColor(CONTROL_HIGHLIGHT);
+
+ /** The control light highlight color. */
+ public static final SystemColor controlLtHighlight
+ = new SystemColor(CONTROL_LT_HIGHLIGHT);
+
+ /** The control shadow color. */
+ public static final SystemColor controlShadow
+ = new SystemColor(CONTROL_SHADOW);
+
+ /** The control dark shadow color. */
+ public static final SystemColor controlDkShadow
+ = new SystemColor(CONTROL_DK_SHADOW);
+
+ /** The scrollbar color. */
+ public static final SystemColor scrollbar
+ = new SystemColor(SCROLLBAR);
+
+ /** The info text background color. */
+ public static final SystemColor info
+ = new SystemColor(INFO);
+
+ /** The info text foreground color. */
+ public static final SystemColor infoText
+ = new SystemColor(INFO_TEXT);
+
+ /**
+ * Construct a system color which is dynamically updated.
+ *
+ * @param id the color id
+ */
+ private SystemColor(int id)
+ {
+ // Note: See Color#Color(int, boolean) to explain why we use this
+ // particular constructor.
+ super(id, true);
+ }
+
+ /**
+ * Returns the RGB value for this color, in the sRGB color space. The blue
+ * value will be in bits 0-7, green in 8-15, red in 6-23, and the alpha
+ * value (bits 24-31) is 0xff. This is dynamically updated, so it may not
+ * match the results of <code>getRed()</code>, <code>getGreen()</code>, or
+ * <code>getBlue()</code>.
+ *
+ * @return the current RGB value
+ */
+ public int getRGB()
+ {
+ Toolkit.getDefaultToolkit().loadSystemColors(colors);
+ return colors[value] | ALPHA_MASK;
+ }
+
+ /**
+ * Returns a paint context, used for filling areas of a raster scan with
+ * the current value of this system color. Since the system colors may be
+ * dynamically updated, the returned value may not always be the same; but
+ * as the system color is solid, the context does not need any of the
+ * passed parameters to do its job.
+ *
+ * @param cm the requested color model
+ * @param deviceBounds the bounding box in device coordinates, ignored
+ * @param userBounds the bounding box in user coordinates, ignored
+ * @param xform the bounds transformation, ignored
+ * @param hints any rendering hints, ignored
+ * @return a context for painting this solid color
+ */
+ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+ Rectangle2D userBounds,
+ AffineTransform xform,
+ RenderingHints hints)
+ {
+ Toolkit.getDefaultToolkit().loadSystemColors(colors);
+ int color = colors[value] | ALPHA_MASK;
+ if (context == null || color != context.color || !context.getColorModel().equals(cm))
+ context = new ColorPaintContext(cm,color);
+ return context;
+ }
+
+ /**
+ * Returns a string describing this color. This is in the format
+ * "java.awt.SystemColor[i=" + index + ']', where index is one of the
+ * integer constants of this class. Unfortunately, this description
+ * does not describe the current value of the color; for that you should
+ * use <code>new Color(syscolor.getRGB()).toString()</code>.
+ *
+ * @return a string describing this color
+ */
+ public String toString()
+ {
+ return "java.awt.SystemColor[i=" + value + ']';
+ }
+} // class SystemColor
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextArea.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextArea.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextArea.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextArea.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,657 @@
+/* TextArea.java -- A multi-line text entry component
+ Copyright (C) 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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 java.awt.event.KeyEvent;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.TextAreaPeer;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleStateSet;
+
+
+/**
+ * A TextArea is a text component capable of displaying multiple lines
+ * of user-editable text. A TextArea handles its own scrolling and
+ * can display vertical and horizontal scrollbars as navigation aids.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class TextArea extends TextComponent implements java.io.Serializable
+{
+ /**
+ * Display both horiztonal and vertical scroll bars.
+ */
+ public static final int SCROLLBARS_BOTH = 0;
+
+ /**
+ * Display vertical scroll bar only.
+ */
+ public static final int SCROLLBARS_VERTICAL_ONLY = 1;
+
+ /**
+ * Display horizatonal scroll bar only.
+ */
+ public static final int SCROLLBARS_HORIZONTAL_ONLY = 2;
+
+ /**
+ * Do not display scrollbars.
+ */
+ public static final int SCROLLBARS_NONE = 3;
+
+ /**
+ * Serialization constant.
+ */
+ private static final long serialVersionUID = 3692302836626095722L;
+
+ /**
+ * @serial The number of columns used in this text area's preferred
+ * and minimum size calculations.
+ */
+ private int columns;
+
+ /**
+ * @serial The number of rows used in this text area's preferred and
+ * minimum size calculations.
+ */
+ private int rows;
+
+ /**
+ * @serial The scrollbar display policy. One of SCROLLBARS_BOTH,
+ * SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY,
+ * SCROLLBARS_NONE.
+ */
+ private int scrollbarVisibility;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_text_number;
+
+ /**
+ * Initialize a new instance of <code>TextArea</code> that is empty.
+ * Conceptually the <code>TextArea</code> has 0 rows and 0 columns
+ * but its initial bounds are defined by its peer or by the
+ * container in which it is packed. Both horizontal and vertical
+ * scrollbars will be displayed.
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
+ */
+ public TextArea ()
+ {
+ this ("", 0, 0, SCROLLBARS_BOTH);
+ }
+
+ /**
+ * Initialize a new instance of <code>TextArea</code> that contains
+ * the specified text. Conceptually the <code>TextArea</code> has 0
+ * rows and 0 columns but its initial bounds are defined by its peer
+ * or by the container in which it is packed. Both horizontal and
+ * veritcal scrollbars will be displayed. The TextArea initially contains
+ * the specified text. If text specified as <code>null<code>, it will
+ * be set to "".
+ *
+ * @param text The text to display in this text area (<code>null</code> permitted).
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
+ */
+ public TextArea (String text)
+ {
+ this (text, 0, 0, SCROLLBARS_BOTH);
+ }
+
+ /**
+ * Initialize a new instance of <code>TextArea</code> that is empty
+ * and can display the specified number of rows and columns of text,
+ * without the need to scroll. Both horizontal and vertical
+ * scrollbars will be displayed.
+ *
+ * @param rows The number of rows in this text area.
+ * @param columns The number of columns in this text area.
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
+ */
+ public TextArea (int rows, int columns)
+ {
+ this ("", rows, columns, SCROLLBARS_BOTH);
+ }
+
+ /**
+ * Initialize a new instance of <code>TextArea</code> that can
+ * display the specified number of rows and columns of text, without
+ * the need to scroll. The TextArea initially contains the
+ * specified text. If text specified as <code>null<code>, it will
+ * be set to "".
+ *
+ * @param text The text to display in this text area (<code>null</code> permitted).
+ * @param rows The number of rows in this text area.
+ * @param columns The number of columns in this text area.
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
+ */
+ public TextArea (String text, int rows, int columns)
+ {
+ this (text, rows, columns, SCROLLBARS_BOTH);
+ }
+
+ /**
+ * Initialize a new instance of <code>TextArea</code> that initially
+ * contains the specified text. The TextArea can display the
+ * specified number of rows and columns of text, without the need to
+ * scroll. This constructor allows specification of the scroll bar
+ * display policy. The TextArea initially contains the specified text.
+ * If text specified as <code>null<code>, it will be set to "".
+ *
+ * @param text The text to display in this text area (<code>null</code> permitted).
+ * @param rows The number of rows in this text area.
+ * @param columns The number of columns in this text area.
+ * @param scrollbarVisibility The scroll bar display policy. One of
+ * SCROLLBARS_BOTH, SCROLLBARS_VERTICAL_ONLY,
+ * SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE.
+ *
+ * @exception HeadlessException if GraphicsEnvironment.isHeadless () is true
+ */
+ public TextArea (String text, int rows, int columns, int scrollbarVisibility)
+ {
+ super (text);
+
+ if (GraphicsEnvironment.isHeadless ())
+ throw new HeadlessException ();
+
+ if (rows < 0)
+ this.rows = 0;
+ else
+ this.rows = rows;
+
+ if (columns < 0)
+ this.columns = 0;
+ else
+ this.columns = columns;
+
+ if (scrollbarVisibility < 0 || scrollbarVisibility > 4)
+ this.scrollbarVisibility = SCROLLBARS_BOTH;
+ else
+ this.scrollbarVisibility = scrollbarVisibility;
+
+ // TextAreas need to receive tab key events so we override the
+ // default forward and backward traversal key sets.
+ Set s = new HashSet ();
+ s.add (AWTKeyStroke.getAWTKeyStroke (KeyEvent.VK_TAB,
+ KeyEvent.CTRL_DOWN_MASK));
+ setFocusTraversalKeys (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, s);
+ s = new HashSet ();
+ s.add (AWTKeyStroke.getAWTKeyStroke (KeyEvent.VK_TAB,
+ KeyEvent.SHIFT_DOWN_MASK
+ | KeyEvent.CTRL_DOWN_MASK));
+ setFocusTraversalKeys (KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, s);
+ }
+
+ /**
+ * Retrieve the number of columns that this text area would prefer
+ * to display. This value may or may not correspond to the number
+ * of columns that are actually displayed.
+ *
+ * @return The preferred number of columns.
+ */
+ public int getColumns ()
+ {
+ return columns;
+ }
+
+ /**
+ * Set the preferred number of columns for this text area. This
+ * method does not cause the number of columns displayed by the text
+ * area to be updated, if the text area is currently visible.
+ *
+ * @param columns The preferred number of columns.
+ *
+ * @exception IllegalArgumentException If columns is less than zero.
+ */
+ public synchronized void setColumns (int columns)
+ {
+ if (columns < 0)
+ throw new IllegalArgumentException ("Value is less than zero: "
+ + columns);
+
+ this.columns = columns;
+ }
+
+ /**
+ * Retrieve the number of rows that this text area would prefer to
+ * display. This value may or may not correspond to the number of
+ * rows that are actually displayed.
+ *
+ * @return The preferred number of rows.
+ */
+ public int getRows ()
+ {
+ return rows;
+ }
+
+ /**
+ * Set the preferred number of rows for this text area. This method
+ * does not cause the number of columns displayed by the text area
+ * to be updated, if the text area is currently visible.
+ *
+ * @param rows The preferred number of rows.
+ *
+ * @exception IllegalArgumentException If rows is less than zero.
+ */
+ public synchronized void setRows (int rows)
+ {
+ if (rows < 1)
+ throw new IllegalArgumentException ("Value is less than one: " + rows);
+
+ this.rows = rows;
+ }
+
+ /**
+ * Retrieve the minimum size for this text area, considering the
+ * text area's current row and column values. A text area's minimum
+ * size depends on the number of rows and columns of text it would
+ * prefer to display, and on the size of the font in which the text
+ * would be displayed.
+ *
+ * @return The minimum size for this text field.
+ */
+ public Dimension getMinimumSize ()
+ {
+ return getMinimumSize (getRows (), getColumns ());
+ }
+
+ /**
+ * Retrieve the minimum size that this text area would have if its
+ * row and column values were equal to those specified. A text
+ * area's minimum size depends on the number of rows and columns of
+ * text it would prefer to display, and on the size of the font in
+ * which the text would be displayed.
+ *
+ * @param rows The number of rows to use in the minimum size
+ * calculation.
+ * @param columns The number of columns to use in the minimum size
+ * calculation.
+ *
+ * @return The minimum size for this text area.
+ */
+ public Dimension getMinimumSize (int rows, int columns)
+ {
+ return minimumSize (rows, columns);
+ }
+
+ /**
+ * Retrieve the minimum size for this text area, considering the
+ * text area's current row and column values. A text area's minimum
+ * size depends on the number of rows and columns of text it would
+ * prefer to display, and on the size of the font in which the text
+ * would be displayed.
+ *
+ * @return The minimum size for this text area.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize ()</code>.
+ */
+ public Dimension minimumSize ()
+ {
+ return minimumSize (getRows (), getColumns ());
+ }
+
+ /**
+ * Retrieve the minimum size that this text area would have if its
+ * row and column values were equal to those specified. A text
+ * area's minimum size depends on the number of rows and columns of
+ * text it would prefer to display, and on the size of the font in
+ * which the text would be displayed.
+ *
+ * @param rows The number of rows to use in the minimum size
+ * calculation.
+ * @param columns The number of columns to use in the minimum size
+ * calculation.
+ *
+ * @return The minimum size for this text area.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize (int, int)</code>.
+ */
+ public Dimension minimumSize (int rows, int columns)
+ {
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+
+ // Sun returns Dimension (0,0) in this case.
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getMinimumSize (rows, columns);
+ }
+
+ /**
+ * Retrieve the preferred size for this text area, considering the
+ * text area's current row and column values. A text area's preferred
+ * size depends on the number of rows and columns of text it would
+ * prefer to display, and on the size of the font in which the text
+ * would be displayed.
+ *
+ * @return The preferred size for this text field.
+ */
+ public Dimension getPreferredSize ()
+ {
+ return getPreferredSize (getRows (), getColumns ());
+ }
+
+ /**
+ * Retrieve the preferred size that this text area would have if its
+ * row and column values were equal to those specified. A text
+ * area's preferred size depends on the number of rows and columns
+ * of text it would prefer to display, and on the size of the font
+ * in which the text would be displayed.
+ *
+ * @param rows The number of rows to use in the preferred size
+ * calculation.
+ * @param columns The number of columns to use in the preferred size
+ * calculation.
+ *
+ * @return The preferred size for this text area.
+ */
+ public Dimension getPreferredSize (int rows, int columns)
+ {
+ return preferredSize (rows, columns);
+ }
+
+ /**
+ * Retrieve the preferred size for this text area, considering the
+ * text area's current row and column values. A text area's preferred
+ * size depends on the number of rows and columns of text it would
+ * prefer to display, and on the size of the font in which the text
+ * would be displayed.
+ *
+ * @return The preferred size for this text field.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize ()</code>.
+ */
+ public Dimension preferredSize ()
+ {
+ return preferredSize (getRows (), getColumns ());
+ }
+
+ /**
+ * Retrieve the preferred size that this text area would have if its
+ * row and column values were equal to those specified. A text
+ * area's preferred size depends on the number of rows and columns
+ * of text it would prefer to display, and on the size of the font
+ * in which the text would be displayed.
+ *
+ * @param rows The number of rows to use in the preferred size
+ * calculation.
+ * @param columns The number of columns to use in the preferred size
+ * calculation.
+ *
+ * @return The preferred size for this text area.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize (int, int)</code>.
+ */
+ public Dimension preferredSize (int rows, int columns)
+ {
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+
+ // Sun returns Dimension (0,0) in this case.
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getPreferredSize (rows, columns);
+ }
+
+ /**
+ * Retrieve the scroll bar display policy -- one of SCROLLBARS_BOTH,
+ * SCROLLBARS_VERTICAL_ONLY, SCROLLBARS_HORIZONTAL_ONLY,
+ * SCROLLBARS_NONE.
+ *
+ * @return The current scroll bar display policy.
+ */
+ public int getScrollbarVisibility ()
+ {
+ return scrollbarVisibility;
+ }
+
+ /**
+ * Notify this object that it should create its native peer.
+ */
+ public void addNotify ()
+ {
+ if (getPeer () == null)
+ setPeer ((ComponentPeer) getToolkit().createTextArea (this));
+ }
+
+ /**
+ * Append the specified text to the end of the current text.
+ *
+ * @param str The text to append.
+ */
+ public void append (String str)
+ {
+ appendText (str);
+ }
+
+ /**
+ * Append the specified text to the end of the current text.
+ *
+ * @param str The text to append.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>append ()</code>.
+ */
+ public void appendText (String str)
+ {
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+
+ if (peer != null)
+ peer.insert (str, peer.getText().length ());
+ else
+ setText(getText() + str);
+ }
+
+ /**
+ * Insert the specified text at the specified position. The first
+ * character in the text area is at position zero.
+ *
+ * @param str The text to insert.
+ * @param pos The position at which to insert text.
+ */
+ public void insert (String str, int pos)
+ {
+ insertText (str, pos);
+ }
+
+ /**
+ * Insert the specified text at the specified position. The first
+ * character in the text area is at position zero.
+ *
+ * @param str The text to insert.
+ * @param pos The position at which to insert text.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>insert ()</code>.
+ */
+ public void insertText (String str, int pos)
+ {
+ String tmp1 = null;
+ String tmp2 = null;
+
+ TextAreaPeer peer = (TextAreaPeer) getPeer ();
+
+ if (peer != null)
+ peer.insert (str, pos);
+ else
+ {
+ tmp1 = getText().substring(0, pos);
+ tmp2 = getText().substring(pos, getText().length());
+ setText(tmp1 + str + tmp2);
+ }
+ }
+
+ /**
+ * Replace a range of characters with the specified text. The
+ * character at the start position will be replaced, unless start ==
+ * end. The character at the end posistion will not be replaced.
+ * The first character in the text area is at position zero. The
+ * length of the replacement text may differ from the length of the
+ * text that is replaced.
+ *
+ * @param str The new text for the range.
+ * @param start The start position of the replacement range.
+ * @param end The end position of the replacement range.
+ */
+ public void replaceRange (String str, int start, int end)
+ {
+ replaceText (str, start, end);
+ }
+
+ /**
+ * Replace a range of characters with the specified text. The
+ * character at the start position will be replaced, unless start ==
+ * end. The character at the end posistion will not be replaced.
+ * The first character in the text area is at position zero. The
+ * length of the replacement text may differ from the length of the
+ * text that is replaced.
+ *
+ * @param str The new text for the range.
+ * @param start The start position of the replacement range.
+ * @param end The end position of the replacement range.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>replaceRange ()</code>.
+ */
+ public void replaceText (String str, int start, int end)
+ {
+ String tmp1 = null;
+ String tmp2 = null;
+
+ TextAreaPeer peer = (TextAreaPeer) getPeer();
+
+ if (peer != null)
+ peer.replaceRange(str, start, end);
+ else
+ {
+ tmp1 = getText().substring(0, start);
+ tmp2 = getText().substring(end, getText().length());
+ setText(tmp1 + str + tmp2);
+ }
+ }
+
+ /**
+ * Retrieve a debugging string for this text area.
+ *
+ * @return A debugging string for this text area.
+ */
+ protected String paramString ()
+ {
+ String sbVisibility = "";
+
+ switch (scrollbarVisibility)
+ {
+ case SCROLLBARS_BOTH:
+ sbVisibility = "both";
+ break;
+ case SCROLLBARS_VERTICAL_ONLY:
+ sbVisibility = "vertical-only";
+ break;
+ case SCROLLBARS_HORIZONTAL_ONLY:
+ sbVisibility = "horizontal-only";
+ break;
+ case SCROLLBARS_NONE:
+ sbVisibility = "none";
+ break;
+ }
+
+ String editable = "";
+ if (isEditable ())
+ editable = "editable,";
+
+ return getName () + "," + getX () + "," + getY () + "," + getWidth ()
+ + "x" + getHeight () + "," + "text=" + getText () + "," + editable
+ + "selection=" + getSelectionStart () + "-" + getSelectionEnd ()
+ + ",rows=" + rows + ",columns=" + columns + ",scrollbarVisibility="
+ + sbVisibility;
+ }
+
+ /**
+ * Generate a unique name for this text area.
+ *
+ * @return A unique name for this text area.
+ */
+ String generateName ()
+ {
+ return "text" + getUniqueLong ();
+ }
+
+ private static synchronized long getUniqueLong ()
+ {
+ return next_text_number++;
+ }
+
+ protected class AccessibleAWTTextArea extends AccessibleAWTTextComponent
+ {
+ private static final long serialVersionUID = 3472827823632144419L;
+
+ protected AccessibleAWTTextArea()
+ {
+ }
+
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ return super.getAccessibleStateSet();
+ }
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>TextArea</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 AccessibleAWTTextArea();
+ return accessibleContext;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextComponent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextComponent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextComponent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextComponent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,675 @@
+/* TextComponent.java -- Widgets for entering text
+ Copyright (C) 1999, 2002, 2003, 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 java.awt.event.TextEvent;
+import java.awt.event.TextListener;
+import java.awt.peer.TextComponentPeer;
+import java.io.Serializable;
+import java.text.BreakIterator;
+import java.util.EventListener;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.accessibility.AccessibleText;
+import javax.swing.text.AttributeSet;
+
+/**
+ * This class provides common functionality for widgets than
+ * contain text.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class TextComponent extends Component
+ implements Serializable, Accessible
+{
+
+ private static final long serialVersionUID = -2214773872412987419L;
+
+ /**
+ * @serial Indicates whether or not this component is editable.
+ * This is package-private to avoid an accessor method.
+ */
+ boolean editable;
+
+ /**
+ * @serial The starting position of the selected text region.
+ * This is package-private to avoid an accessor method.
+ */
+ int selectionStart;
+
+ /**
+ * @serial The ending position of the selected text region.
+ * This is package-private to avoid an accessor method.
+ */
+ int selectionEnd;
+
+ /**
+ * @serial The text in the component
+ * This is package-private to avoid an accessor method.
+ */
+ String text;
+
+ /**
+ * A list of listeners that will receive events from this object.
+ */
+ protected transient TextListener textListener;
+
+ protected class AccessibleAWTTextComponent
+ extends AccessibleAWTComponent
+ implements AccessibleText, TextListener
+ {
+ private static final long serialVersionUID = 3631432373506317811L;
+
+ // Constructor
+ // Adds a listener for tracking caret changes
+ public AccessibleAWTTextComponent()
+ {
+ TextComponent.this.addTextListener(this);
+ }
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.TEXT;
+ }
+
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ // TODO: Docs say PropertyChangeEvent will fire if this state changes.
+ // That means that the event has to fire when editable changes.
+ AccessibleStateSet ss = super.getAccessibleStateSet();
+ if (editable)
+ ss.add(AccessibleState.EDITABLE);
+ return ss;
+ }
+
+ public AccessibleText getAccessibleText()
+ {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getIndexAtPoint(java.awt.Point)
+ */
+ public int getIndexAtPoint(Point point)
+ {
+ return TextComponent.this.getIndexAtPoint(point);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getCharacterBounds(int)
+ */
+ public Rectangle getCharacterBounds(int index)
+ {
+ return TextComponent.this.getCharacterBounds(index);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getCharCount()
+ */
+ public int getCharCount()
+ {
+ return text.length();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getCaretPosition()
+ */
+ public int getCaretPosition()
+ {
+ return TextComponent.this.getCaretPosition();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getAtIndex(int, int)
+ */
+ public String getAtIndex(int part, int index)
+ {
+ if (index < 0 || index >= text.length())
+ return null;
+ BreakIterator it = null;
+ switch (part)
+ {
+ case CHARACTER:
+ return text.substring(index, index + 1);
+ case WORD:
+ it = BreakIterator.getWordInstance();
+ break;
+ case SENTENCE:
+ it = BreakIterator.getSentenceInstance();
+ break;
+ default:
+ return null;
+ }
+ it.setText(text);
+ int start = index;
+ if (!it.isBoundary(index))
+ start = it.preceding(index);
+ int end = it.following(index);
+ if (end == -1)
+ return text.substring(index);
+ else
+ return text.substring(index, end);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getAfterIndex(int, int)
+ */
+ public String getAfterIndex(int part, int index) {
+ if (index < 0 || index >= text.length())
+ return null;
+ BreakIterator it = null;
+ switch (part)
+ {
+ case CHARACTER:
+ return text.substring(index, index + 1);
+ case WORD:
+ it = BreakIterator.getWordInstance();
+ break;
+ case SENTENCE:
+ it = BreakIterator.getSentenceInstance();
+ break;
+ default:
+ return null;
+ }
+ it.setText(text);
+ int start = index;
+ if (!it.isBoundary(index))
+ start = it.following(index);
+ // Make sure there was a complete unit. I.e. if index is in the middle
+ // of a word, return null if there is no word after the that one.
+ if (start == -1)
+ return null;
+ int end = it.following(start);
+ if (end == -1)
+ return text.substring(index);
+ else
+ return text.substring(index, end);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getBeforeIndex(int, int)
+ */
+ public String getBeforeIndex(int part, int index)
+ {
+ if (index < 1 || index >= text.length())
+ return null;
+ BreakIterator it = null;
+ switch (part)
+ {
+ case CHARACTER:
+ return text.substring(index - 1, index);
+ case WORD:
+ it = BreakIterator.getWordInstance();
+ break;
+ case SENTENCE:
+ it = BreakIterator.getSentenceInstance();
+ break;
+ default:
+ return null;
+ }
+ it.setText(text);
+ int end = index;
+ if (!it.isBoundary(index))
+ end = it.preceding(index);
+ // Make sure there was a complete unit. I.e. if index is in the middle
+ // of a word, return null if there is no word before that one.
+ if (end == -1)
+ return null;
+ int start = it.preceding(end);
+ if (start == -1)
+ return text.substring(0, end);
+ else
+ return text.substring(start, end);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getCharacterAttribute(int)
+ */
+ public AttributeSet getCharacterAttribute(int index)
+ {
+ // FIXME: I suspect this really gets filled in by subclasses.
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getSelectionStart()
+ */
+ public int getSelectionStart() {
+ // TODO Auto-generated method stub
+ return selectionStart;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getSelectionEnd()
+ */
+ public int getSelectionEnd()
+ {
+ return selectionEnd;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.accessibility.AccessibleText#getSelectedText()
+ */
+ public String getSelectedText()
+ {
+ if (selectionEnd - selectionStart > 0)
+ return text.substring(selectionStart, selectionEnd);
+ else
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.awt.event.TextListener#textValueChanged(java.awt.event.TextEvent)
+ */
+ public void textValueChanged(TextEvent event)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ TextComponent(String text)
+ {
+ if (text == null)
+ this.text = "";
+ else
+ this.text = text;
+
+ this.editable = true;
+ }
+
+
+ /**
+ * Returns the text in this component
+ *
+ * @return The text in this component.
+ */
+ public synchronized String getText()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ text = tcp.getText();
+
+ return(text);
+ }
+
+ /**
+ * Sets the text in this component to the specified string.
+ *
+ * @param text The new text for this component.
+ */
+ public synchronized void setText(String text)
+ {
+ if (text == null)
+ text = "";
+
+ this.text = text;
+
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.setText(text);
+ setCaretPosition(0);
+ }
+
+ /**
+ * Returns a string that contains the text that is currently selected.
+ *
+ * @return The currently selected text region.
+ */
+ public synchronized String getSelectedText()
+ {
+ String alltext = getText();
+ int start = getSelectionStart();
+ int end = getSelectionEnd();
+
+ return(alltext.substring(start, end));
+ }
+
+ /**
+ * Returns the starting position of the selected text region.
+ * If the text is not selected then caret position is returned.
+ *
+ * @return The starting position of the selected text region.
+ */
+ public synchronized int getSelectionStart()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ selectionStart = tcp.getSelectionStart();
+
+ return(selectionStart);
+ }
+
+ /**
+ * Sets the starting position of the selected region to the
+ * specified value. If the specified value is out of range, then it
+ * will be silently changed to the nearest legal value.
+ *
+ * @param selectionStart The new start position for selected text.
+ */
+ public synchronized void setSelectionStart(int selectionStart)
+ {
+ select(selectionStart, getSelectionEnd());
+ }
+
+ /**
+ * Returns the ending position of the selected text region.
+ * If the text is not selected, then caret position is returned
+ *
+ * @return The ending position of the selected text region.
+ */
+ public synchronized int getSelectionEnd()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ selectionEnd = tcp.getSelectionEnd();
+
+ return(selectionEnd);
+ }
+
+ /**
+ * Sets the ending position of the selected region to the
+ * specified value. If the specified value is out of range, then it
+ * will be silently changed to the nearest legal value.
+ *
+ * @param selectionEnd The new start position for selected text.
+ */
+ public synchronized void setSelectionEnd(int selectionEnd)
+ {
+ select(getSelectionStart(), selectionEnd);
+ }
+
+ /**
+ * This method sets the selected text range to the text between the
+ * specified start and end positions. Illegal values for these
+ * positions are silently fixed.
+ *
+ * @param selectionStart The new start position for the selected text.
+ * @param selectionEnd The new end position for the selected text.
+ */
+ public synchronized void select(int selectionStart, int selectionEnd)
+ {
+ if (selectionStart < 0)
+ selectionStart = 0;
+
+ if (selectionStart > getText().length())
+ selectionStart = text.length();
+
+ if (selectionEnd > text.length())
+ selectionEnd = text.length();
+
+ if (selectionStart > selectionEnd)
+ selectionStart = selectionEnd;
+
+ this.selectionStart = selectionStart;
+ this.selectionEnd = selectionEnd;
+
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.select(selectionStart, selectionEnd);
+ }
+
+ /**
+ * Selects all of the text in the component.
+ */
+ public synchronized void selectAll()
+ {
+ select(0, getText().length());
+ }
+
+ /**
+ * Returns the current caret position in the text.
+ *
+ * @return The caret position in the text.
+ */
+ public synchronized int getCaretPosition()
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ return(tcp.getCaretPosition());
+ else
+ return(0);
+ }
+
+ /**
+ * Sets the caret position to the specified value.
+ *
+ * @param caretPosition The new caret position.
+ *
+ * @exception IllegalArgumentException If the value supplied for position
+ * is less than zero.
+ *
+ * @since 1.1
+ */
+ public synchronized void setCaretPosition(int caretPosition)
+ {
+ if (caretPosition < 0)
+ throw new IllegalArgumentException();
+
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.setCaretPosition(caretPosition);
+ }
+
+ /**
+ * Tests whether or not this component's text can be edited.
+ *
+ * @return <code>true</code> if the text can be edited, <code>false</code>
+ * otherwise.
+ */
+ public boolean isEditable()
+ {
+ return(editable);
+ }
+
+ /**
+ * Sets whether or not this component's text can be edited.
+ *
+ * @param editable <code>true</code> to enable editing of the text,
+ * <code>false</code> to disable it.
+ */
+ public synchronized void setEditable(boolean editable)
+ {
+ this.editable = editable;
+
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ tcp.setEditable(editable);
+ }
+
+ /**
+ * Notifies the component that it should destroy its native peer.
+ */
+ public void removeNotify()
+ {
+ super.removeNotify();
+ }
+
+ /**
+ * Adds a new listener to the list of text listeners for this
+ * component.
+ *
+ * @param listener The listener to be added.
+ */
+ public synchronized void addTextListener(TextListener listener)
+ {
+ textListener = AWTEventMulticaster.add(textListener, listener);
+
+ enableEvents(AWTEvent.TEXT_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the list of listeners
+ * for this component.
+ *
+ * @param listener The listener to remove.
+ */
+ public synchronized void removeTextListener(TextListener listener)
+ {
+ textListener = AWTEventMulticaster.remove(textListener, listener);
+ }
+
+ /**
+ * Processes the specified event for this component. Text events are
+ * processed by calling the <code>processTextEvent()</code> method.
+ * All other events are passed to the superclass method.
+ *
+ * @param event The event to process.
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof TextEvent)
+ processTextEvent((TextEvent)event);
+ else
+ super.processEvent(event);
+ }
+
+ /**
+ * Processes the specified text event by dispatching it to any listeners
+ * that are registered. Note that this method will only be called
+ * if text event's are enabled. This will be true if there are any
+ * registered listeners, or if the event has been specifically
+ * enabled using <code>enableEvents()</code>.
+ *
+ * @param event The text event to process.
+ */
+ protected void processTextEvent(TextEvent event)
+ {
+ if (textListener != null)
+ textListener.textValueChanged(event);
+ }
+
+ void dispatchEventImpl(AWTEvent e)
+ {
+ if (e.id <= TextEvent.TEXT_LAST
+ && e.id >= TextEvent.TEXT_FIRST
+ && (textListener != null
+ || (eventMask & AWTEvent.TEXT_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+ }
+
+ /**
+ * Returns a debugging string.
+ *
+ * @return A debugging string.
+ */
+ protected String paramString()
+ {
+ return(getClass().getName() + "(text=" + getText() + ")");
+ }
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this <code>TextComponent</code>. FooListeners are registered using
+ * the addFooListener method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == TextListener.class)
+ return AWTEventMulticaster.getListeners(textListener, listenerType);
+
+ return super.getListeners(listenerType);
+ }
+
+ /**
+ * Returns all text listeners registered to this object.
+ */
+ public TextListener[] getTextListeners()
+ {
+ return (TextListener[]) getListeners(TextListener.class);
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>TextComponent</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 AccessibleAWTTextComponent();
+ return accessibleContext;
+ }
+
+
+ // Provide AccessibleAWTTextComponent access to several peer functions that
+ // aren't publicly exposed. This is package-private to avoid an accessor
+ // method.
+ synchronized int getIndexAtPoint(Point p)
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ return tcp.getIndexAtPoint(p.x, p.y);
+ return -1;
+ }
+
+ synchronized Rectangle getCharacterBounds(int i)
+ {
+ TextComponentPeer tcp = (TextComponentPeer) getPeer();
+ if (tcp != null)
+ return tcp.getCharacterBounds(i);
+ return null;
+ }
+
+ /**
+ * All old mouse events for this component should
+ * be ignored.
+ *
+ * @return true to ignore all old mouse events.
+ */
+ static boolean ignoreOldMouseEvents()
+ {
+ return true;
+ }
+
+} // class TextComponent
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextField.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextField.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextField.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TextField.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,478 @@
+/* TextField.java -- A one line text entry field
+ Copyright (C) 1999, 2002, 2004, 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 java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.TextFieldPeer;
+import java.util.EventListener;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * This class implements a single line text entry field widget
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class TextField extends TextComponent
+{
+
+ /**
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_textfield_number;
+
+
+ private static final long serialVersionUID = -2966288784432217853L;
+
+
+ /**
+ * @serial The number of columns in the text entry field.
+ */
+ private int columns;
+
+ /**
+ * @serial The character that is echoed when doing protected input
+ */
+ private char echoChar;
+
+ // List of registered ActionListener's for this object.
+ private ActionListener action_listeners;
+
+ /**
+ * Initializes a new instance of <code>TextField</code> that is empty
+ * and has one column.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField()
+ {
+ this("", 0);
+ }
+
+ /**
+ * Initializes a new instance of <code>TextField</code> containing
+ * the specified text. The number of columns will be equal to the
+ * length of the text string.
+ *
+ * @param text The text to display in the field.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField(String text)
+ {
+ this(text, (text == null) ? 0 : text.length());
+ }
+
+ /**
+ * Initializes a new instance of <code>TextField</code> that is empty
+ * and has the specified number of columns.
+ *
+ * @param columns The number of columns in the text field.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField(int columns)
+ {
+ this("", columns);
+ }
+
+ /**
+ * Initializes a new instance of <code>TextField</code> with the
+ * specified text and number of columns.
+ *
+ * @param text The text to display in the field.
+ * @param columns The number of columns in the field.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true,
+ */
+ public TextField(String text, int columns)
+ {
+ super(text);
+
+ if (columns < 0)
+ this.columns = 0;
+ else
+ this.columns = columns;
+
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException ();
+ }
+
+ /**
+ * Returns the number of columns in the field.
+ *
+ * @return The number of columns in the field.
+ */
+ public int getColumns()
+ {
+ return(columns);
+ }
+
+ /**
+ * Sets the number of columns in this field to the specified value.
+ *
+ * @param columns The new number of columns in the field.
+ *
+ * @exception IllegalArgumentException If columns is less than zero.
+ */
+ public synchronized void setColumns(int columns)
+ {
+ if (columns < 0)
+ throw new IllegalArgumentException("Value is less than zero: " +
+ columns);
+
+ this.columns = columns;
+ // FIXME: How to we communicate this to our peer?
+ }
+
+ /**
+ * Returns the character that is echoed to the screen when a text
+ * field is protected (such as when a password is being entered).
+ *
+ * @return The echo character for this text field.
+ */
+ public char getEchoChar()
+ {
+ return(echoChar);
+ }
+
+ /**
+ * Sets the character that is echoed when protected input such as
+ * a password is displayed.
+ *
+ * @param echoChar The new echo character.
+ */
+ public void setEchoChar(char echoChar)
+ {
+ setEchoCharacter(echoChar);
+ }
+
+ /**
+ * Sets the character that is echoed when protected input such as
+ * a password is displayed.
+ *
+ * @param echoChar The new echo character.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>setEchoChar()</code>
+ */
+ public void setEchoCharacter(char echoChar)
+ {
+ this.echoChar = echoChar;
+
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer != null)
+ peer.setEchoChar (echoChar);
+ }
+
+ /**
+ * Tests whether or not this text field has an echo character set
+ * so that characters the user type are not echoed to the screen.
+ *
+ * @return <code>true</code> if an echo character is set,
+ * <code>false</code> otherwise.
+ */
+ public boolean echoCharIsSet()
+ {
+ if (echoChar == '\u0000')
+ return(false);
+ else
+ return(true);
+ }
+
+ /**
+ * Returns the minimum size for this text field.
+ *
+ * @return The minimum size for this text field.
+ */
+ public Dimension getMinimumSize()
+ {
+ return getMinimumSize (getColumns ());
+ }
+
+ /**
+ * Returns the minimum size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the minimum size for.
+ */
+ public Dimension getMinimumSize(int columns)
+ {
+ return minimumSize(columns);
+ }
+
+ /**
+ * Returns the minimum size for this text field.
+ *
+ * @return The minimum size for this text field.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize()</code>.
+ */
+ public Dimension minimumSize()
+ {
+ return minimumSize(getColumns ());
+ }
+
+ /**
+ * Returns the minimum size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the minimum size for.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getMinimumSize(int)</code>.
+ */
+ public Dimension minimumSize(int columns)
+ {
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return null; // FIXME: What do we do if there is no peer?
+
+ return peer.getMinimumSize (columns);
+ }
+
+ /**
+ * Returns the preferred size for this text field.
+ *
+ * @return The preferred size for this text field.
+ */
+ public Dimension getPreferredSize()
+ {
+ return getPreferredSize(getColumns ());
+ }
+
+ /**
+ * Returns the preferred size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the preferred size for.
+ */
+ public Dimension getPreferredSize(int columns)
+ {
+ return preferredSize(columns);
+ }
+
+ /**
+ * Returns the preferred size for this text field.
+ *
+ * @return The preferred size for this text field.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize()</code>.
+ */
+ public Dimension preferredSize()
+ {
+ return preferredSize(getColumns ());
+ }
+
+ /**
+ * Returns the preferred size of a text field with the specified number
+ * of columns.
+ *
+ * @param columns The number of columns to get the preferred size for.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>getPreferredSize(int)</code>.
+ */
+ public Dimension preferredSize(int columns)
+ {
+ TextFieldPeer peer = (TextFieldPeer) getPeer ();
+ if (peer == null)
+ return new Dimension (0, 0);
+
+ return peer.getPreferredSize (columns);
+ }
+
+ /**
+ * Notifies this object that it should create its native peer.
+ */
+ public void addNotify()
+ {
+ if (getPeer() != null)
+ return;
+
+ setPeer((ComponentPeer)getToolkit().createTextField(this));
+ super.addNotify();
+ }
+
+ /**
+ * Addes a new listener to the list of action listeners for this
+ * object.
+ *
+ * @param listener The listener to add to the list.
+ */
+ public synchronized void addActionListener(ActionListener listener)
+ {
+ action_listeners = AWTEventMulticaster.add(action_listeners, listener);
+
+ enableEvents(AWTEvent.ACTION_EVENT_MASK);
+ }
+
+ /**
+ * Removes the specified listener from the list of action listeners
+ * for this object.
+ *
+ * @param listener The listener to remove from the list.
+ */
+ public synchronized void removeActionListener(ActionListener listener)
+ {
+ action_listeners = AWTEventMulticaster.remove(action_listeners, listener);
+ }
+
+ /**
+ * Processes the specified event. If the event is an instance of
+ * <code>ActionEvent</code> then <code>processActionEvent()</code> is
+ * called to process it, otherwise the event is sent to the
+ * superclass.
+ *
+ * @param event The event to process.
+ */
+ protected void processEvent(AWTEvent event)
+ {
+ if (event instanceof ActionEvent)
+ processActionEvent((ActionEvent)event);
+ else
+ super.processEvent(event);
+ }
+
+ /**
+ * Processes an action event by calling any registered listeners.
+ * Note to subclasses: This method is not called unless action events
+ * are enabled on this object. This will be true if any listeners
+ * are registered, or if action events were specifically enabled
+ * using <code>enableEvents()</code>.
+ *
+ * @param event The event to process.
+ */
+ protected void processActionEvent(ActionEvent event)
+ {
+ if (action_listeners != null)
+ action_listeners.actionPerformed(event);
+ }
+
+ void dispatchEventImpl(AWTEvent e)
+ {
+ if (e.id <= ActionEvent.ACTION_LAST
+ && e.id >= ActionEvent.ACTION_FIRST
+ && (action_listeners != null
+ || (eventMask & AWTEvent.ACTION_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ super.dispatchEventImpl(e);
+ }
+
+ /**
+ * Returns a debug string for this object.
+ *
+ * @return A debug string for this object.
+ */
+ protected String paramString()
+ {
+ return(getClass().getName() + "(columns=" + getColumns() + ",echoChar=" +
+ getEchoChar());
+ }
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this <code>TextField</code>. FooListeners are registered using the
+ * addFooListener method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ if (listenerType == ActionListener.class)
+ return AWTEventMulticaster.getListeners (action_listeners, listenerType);
+
+ return super.getListeners (listenerType);
+ }
+
+ /**
+ * Return all ActionListeners register to this <code>TextField</code> object
+ * as an array.
+ *
+ * @since 1.4
+ */
+ public ActionListener[] getActionListeners ()
+ {
+ return (ActionListener[]) getListeners (ActionListener.class);
+ }
+
+ /**
+ * Generate a unique name for this <code>TextField</code>.
+ *
+ * @return A unique name for this <code>TextField</code>.
+ */
+ String generateName()
+ {
+ return "textfield" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_textfield_number++;
+ }
+
+ protected class AccessibleAWTTextField extends AccessibleAWTTextComponent
+ {
+ private static final long serialVersionUID = 6219164359235943158L;
+
+ protected AccessibleAWTTextField()
+ {
+ }
+
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ return super.getAccessibleStateSet();
+ }
+ }
+
+ public AccessibleContext getAccessibleContext()
+ {
+ return new AccessibleAWTTextField();
+ }
+
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TexturePaint.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TexturePaint.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TexturePaint.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/TexturePaint.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,118 @@
+/* TexturePaint.java --
+ Copyright (C) 2002 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.java2d.TexturePaintContext;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+
+/**
+ * This class provides a way to fill a Shape with a texture that is
+ * specified by a BufferedImage.
+ */
+public class TexturePaint implements Paint
+{
+ private final BufferedImage texture;
+ private final Rectangle2D anchor;
+
+ /**
+ * Constructor.
+ *
+ * @param texture - the texture
+ * @param anchor - the shape
+ */
+ public TexturePaint(BufferedImage texture, Rectangle2D anchor)
+ {
+ this.texture = texture;
+ this.anchor = anchor;
+ }
+
+ /**
+ * Gets the texture image.
+ *
+ * @return the texture
+ */
+ public BufferedImage getImage()
+ {
+ return texture;
+ }
+
+ /**
+ * Gets the shape anchor.
+ *
+ * @return the shape anchor
+ */
+ public Rectangle2D getAnchorRect()
+ {
+ return anchor;
+ }
+
+ /**
+ * Creates the context used to paint the texture.
+ *
+ * @param cm - the ColorModel that receives the Paint data. Used only as a hint.
+ * @param deviceBounds - the device space being rendered.
+ * @param userBounds - the user space being rendered
+ * @param xform - the AffineTransform from user space into device space
+ * @param hints - a RenderingHints object that is used to specify how the
+ * pattern is rendered
+ * @return the paint context used to paint the texture
+ */
+ public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
+ Rectangle2D userBounds,
+ AffineTransform xform, RenderingHints hints)
+ {
+ // TODO: Maybe add some hook for providing alternative/accelerated
+ // implementations of this.
+ return new TexturePaintContext(this, deviceBounds, userBounds, xform);
+ }
+
+ /**
+ * Returns the transparency mode.
+ *
+ * @return the transparency mode.
+ */
+ public int getTransparency()
+ {
+ return texture.getTransparency();
+ }
+} // class TexturePaint
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Toolkit.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Toolkit.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Toolkit.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Toolkit.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1390 @@
+/* Toolkit.java -- AWT Toolkit superclass
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 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.classpath.SystemProperties;
+import gnu.java.awt.peer.GLightweightPeer;
+
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragGestureListener;
+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;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.LightweightPeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.MouseInfoPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.WindowPeer;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * The AWT system uses a set of native peer objects to implement its
+ * widgets. These peers are provided by a peer toolkit, that is accessed
+ * via a subclass of this superclass. The system toolkit is retrieved
+ * by the static methods <code>getDefaultToolkit</code>. This method
+ * determines the system toolkit by examining the system property
+ * <code>awt.toolkit</code>. That property is set to the name of the
+ * <code>Toolkit</code> subclass for the specified peer set. If the
+ * <code>awt.toolkit</code> property is not set, then the default
+ * toolkit <code>gnu.java.awt.peer.gtk.GtkToolkit</code> is used. This
+ * toolkit creates its peers using the GTK+ toolkit.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public abstract class Toolkit
+{
+ /** The default toolkit name. */
+ private static String default_toolkit_name
+ = gnu.classpath.Configuration.default_awt_peer_toolkit;
+
+ /**
+ * The toolkit in use. Once we load it, we don't ever change it
+ * if the awt.toolkit property is set.
+ */
+ private static Toolkit toolkit;
+
+ /** The toolkit properties. */
+ private static Properties props = new Properties();
+
+ protected final Map desktopProperties = new Properties();
+
+ 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];
+ }
+
+ /**
+ * Creates a peer object for the specified <code>Button</code>.
+ *
+ * @param target The <code>Button</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Button</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract ButtonPeer createButton(Button target);
+
+ /**
+ * Creates a peer object for the specified <code>TextField</code>.
+ *
+ * @param target The <code>TextField</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>TextField</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract TextFieldPeer createTextField(TextField target);
+
+ /**
+ * Creates a peer object for the specified <code>Label</code>.
+ *
+ * @param target The <code>Label</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Label</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract LabelPeer createLabel(Label target);
+
+ /**
+ * Creates a peer object for the specified <code>List</code>.
+ *
+ * @param target The <code>List</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>List</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract ListPeer createList(List target);
+
+ /**
+ * Creates a peer object for the specified <code>Checkbox</code>.
+ *
+ * @param target The <code>Checkbox</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Checkbox</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract CheckboxPeer createCheckbox(Checkbox target);
+
+ /**
+ * Creates a peer object for the specified <code>Scrollbar</code>.
+ *
+ * @param target The <code>Scrollbar</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Scrollbar</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract ScrollbarPeer createScrollbar(Scrollbar target);
+
+ /**
+ * Creates a peer object for the specified <code>ScrollPane</code>.
+ *
+ * @param target The <code>ScrollPane</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>ScrollPane</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract ScrollPanePeer createScrollPane(ScrollPane target);
+
+ /**
+ * Creates a peer object for the specified <code>TextArea</code>.
+ *
+ * @param target The <code>TextArea</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>TextArea</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract TextAreaPeer createTextArea(TextArea target);
+
+ /**
+ * Creates a peer object for the specified <code>Choice</code>.
+ *
+ * @param target The <code>Choice</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Choice</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract ChoicePeer createChoice(Choice target);
+
+ /**
+ * Creates a peer object for the specified <code>Frame</code>.
+ *
+ * @param target The <code>Frame</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Frame</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract FramePeer createFrame(Frame target);
+
+ /**
+ * Creates a peer object for the specified <code>Canvas</code>.
+ *
+ * @param target The <code>Canvas</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Canvas</code> object.
+ */
+ protected abstract CanvasPeer createCanvas(Canvas target);
+
+ /**
+ * Creates a peer object for the specified <code>Panel</code>.
+ *
+ * @param target The <code>Panel</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Panel</code> object.
+ */
+ protected abstract PanelPeer createPanel(Panel target);
+
+ /**
+ * Creates a peer object for the specified <code>Window</code>.
+ *
+ * @param target The <code>Window</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Window</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract WindowPeer createWindow(Window target);
+
+ /**
+ * Creates a peer object for the specified <code>Dialog</code>.
+ *
+ * @param target The dialog to create the peer for
+ *
+ * @return The peer for the specified font name.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract DialogPeer createDialog(Dialog target);
+
+ /**
+ * Creates a peer object for the specified <code>MenuBar</code>.
+ *
+ * @param target The <code>MenuBar</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>MenuBar</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract MenuBarPeer createMenuBar(MenuBar target);
+
+ /**
+ * Creates a peer object for the specified <code>Menu</code>.
+ *
+ * @param target The <code>Menu</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Menu</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract MenuPeer createMenu(Menu target);
+
+ /**
+ * Creates a peer object for the specified <code>PopupMenu</code>.
+ *
+ * @param target The <code>PopupMenu</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>PopupMenu</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract PopupMenuPeer createPopupMenu(PopupMenu target);
+
+ /**
+ * Creates a peer object for the specified <code>MenuItem</code>.
+ *
+ * @param target The <code>MenuItem</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>MenuItem</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract MenuItemPeer createMenuItem(MenuItem target);
+
+ /**
+ * Returns a MouseInfoPeer.
+ * The default implementation of this method throws
+ * UnsupportedOperationException.
+ *
+ * Toolkit implementations should overload this if possible, however.
+ */
+ protected MouseInfoPeer getMouseInfoPeer()
+ {
+ throw new UnsupportedOperationException("No mouse info peer.");
+ }
+
+ /**
+ * Creates a peer object for the specified <code>FileDialog</code>.
+ *
+ * @param target The <code>FileDialog</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>FileDialog</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract FileDialogPeer createFileDialog(FileDialog target);
+
+ /**
+ * Creates a peer object for the specified <code>CheckboxMenuItem</code>.
+ *
+ * @param target The <code>CheckboxMenuItem</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>CheckboxMenuItem</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected abstract CheckboxMenuItemPeer
+ createCheckboxMenuItem(CheckboxMenuItem target);
+
+ /**
+ * Creates a peer object for the specified <code>Component</code>. The
+ * peer returned by this method is not a native windowing system peer
+ * with its own native window. Instead, this method allows the component
+ * to draw on its parent window as a "lightweight" widget.
+ *
+ * @param target The <code>Component</code> to create the peer for.
+ *
+ * @return The peer for the specified <code>Component</code> object.
+ */
+ protected LightweightPeer createComponent(Component target)
+ {
+ return new GLightweightPeer(target);
+ }
+
+ /**
+ * Creates a peer object for the specified font name.
+ *
+ * @param name The font to create the peer for.
+ * @param style The font style to create the peer for.
+ *
+ * @return The peer for the specified font name.
+ *
+ * @deprecated
+ */
+ protected abstract FontPeer getFontPeer(String name, int style);
+
+ /**
+ * Copies the current system colors into the specified array. This is
+ * the interface used by the <code>SystemColor</code> class. Although
+ * this method fills in the array with some default colors a real Toolkit
+ * should override this method and provide real system colors for the
+ * native GUI platform.
+ *
+ * @param systemColors The array to copy the system colors into.
+ * It must be at least 26 elements.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ *
+ * @see java.awt.SystemColor
+ */
+ protected void loadSystemColors(int systemColors[])
+ {
+ systemColors[SystemColor.DESKTOP] = 0xFF005C5C;
+ systemColors[SystemColor.ACTIVE_CAPTION] = 0xFF000080;
+ systemColors[SystemColor.ACTIVE_CAPTION_TEXT] = 0xFFFFFFFF;
+ systemColors[SystemColor.ACTIVE_CAPTION_BORDER] = 0xFFC0C0C0;
+ systemColors[SystemColor.INACTIVE_CAPTION] = 0xFF808080;
+ systemColors[SystemColor.INACTIVE_CAPTION_TEXT] = 0xFFC0C0C0;
+ systemColors[SystemColor.INACTIVE_CAPTION_BORDER] = 0xFFC0C0C0;
+ systemColors[SystemColor.WINDOW] = 0xFFFFFFFF;
+ systemColors[SystemColor.WINDOW_BORDER] = 0xFF000000;
+ systemColors[SystemColor.WINDOW_TEXT] = 0xFF000000;
+ systemColors[SystemColor.MENU] = 0xFFC0C0C0;
+ systemColors[SystemColor.MENU_TEXT] = 0xFF000000;
+ systemColors[SystemColor.TEXT] = 0xFFC0C0C0;
+ systemColors[SystemColor.TEXT_TEXT] = 0xFF000000;
+ systemColors[SystemColor.TEXT_HIGHLIGHT] = 0xFF000090;
+ systemColors[SystemColor.TEXT_HIGHLIGHT_TEXT] = 0xFFFFFFFF;
+ systemColors[SystemColor.TEXT_INACTIVE_TEXT] = 0xFF808080;
+ systemColors[SystemColor.CONTROL] = 0xFFC0C0C0;
+ systemColors[SystemColor.CONTROL_TEXT] = 0xFF000000;
+ systemColors[SystemColor.CONTROL_HIGHLIGHT] = 0xFFFFFFFF;
+ systemColors[SystemColor.CONTROL_LT_HIGHLIGHT] = 0xFFE0E0E0;
+ systemColors[SystemColor.CONTROL_SHADOW] = 0xFF808080;
+ systemColors[SystemColor.CONTROL_DK_SHADOW] = 0xFF000000;
+ systemColors[SystemColor.SCROLLBAR] = 0xFFE0E0E0;
+ systemColors[SystemColor.INFO] = 0xFFE0E000;
+ systemColors[SystemColor.INFO_TEXT] = 0xFF000000;
+ }
+
+ /**
+ * @since 1.4
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public void setDynamicLayout(boolean dynamic)
+ {
+ }
+
+ /**
+ * @since 1.4
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ protected boolean isDynamicLayoutSet()
+ {
+ return false;
+ }
+
+ /**
+ * @since 1.4
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public boolean isDynamicLayoutActive()
+ {
+ return false;
+ }
+
+ /**
+ * Returns the dimensions of the screen in pixels.
+ *
+ * @return The dimensions of the screen in pixels.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public abstract Dimension getScreenSize();
+
+ /**
+ * Returns the screen resolution in dots per square inch.
+ *
+ * @return The screen resolution in dots per square inch.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public abstract int getScreenResolution();
+
+ /**
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ *
+ * @since 1.4
+ */
+ public Insets getScreenInsets(GraphicsConfiguration gc)
+ {
+ return new Insets(0, 0, 0, 0);
+ }
+
+ /**
+ * Returns the color model of the screen.
+ *
+ * @return The color model of the screen.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public abstract ColorModel getColorModel();
+
+ /**
+ * Returns the names of the available fonts.
+ *
+ * @return The names of the available fonts.
+ *
+ * @deprecated
+ */
+ public abstract String[] getFontList();
+
+ /**
+ * Return the font metrics for the specified font
+ *
+ * @param name The name of the font to return metrics for.
+ *
+ * @return The requested font metrics.
+ *
+ * @deprecated
+ */
+ public abstract FontMetrics getFontMetrics(Font name);
+
+ /**
+ * Flushes any buffered data to the screen so that it is in sync with
+ * what the AWT system has drawn to it.
+ */
+ public abstract void sync();
+
+ /**
+ * Returns an instance of the default toolkit. The default toolkit is
+ * the subclass of <code>Toolkit</code> specified in the system property
+ * <code>awt.toolkit</code>, or <code>gnu.java.awt.peer.gtk.GtkToolkit</code>
+ * if the property is not set.
+ *
+ * @return An instance of the system default toolkit.
+ *
+ * @throws AWTError If the toolkit cannot be loaded.
+ */
+ public static Toolkit getDefaultToolkit()
+ {
+ if (toolkit != null)
+ return toolkit;
+ String toolkit_name = SystemProperties.getProperty("awt.toolkit",
+ default_toolkit_name);
+ try
+ {
+ ClassLoader cl;
+ cl = (ClassLoader) AccessController.doPrivileged
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ return ClassLoader.getSystemClassLoader();
+ }
+ });
+ Class cls = Class.forName(toolkit_name, true, cl);
+ Object obj = cls.newInstance();
+ if (!(obj instanceof Toolkit))
+ throw new AWTError(toolkit_name + " is not a subclass of " +
+ "java.awt.Toolkit");
+ toolkit = (Toolkit) obj;
+
+ initAccessibility();
+ return toolkit;
+ }
+ catch (ThreadDeath death)
+ {
+ throw death;
+ }
+ catch (Throwable t)
+ {
+ AWTError e = new AWTError("Cannot load AWT toolkit: " + toolkit_name);
+ throw (AWTError) e.initCause(t);
+ }
+ }
+
+ /**
+ * Returns an image from the specified file, which must be in a
+ * recognized format. Supported formats vary from toolkit to toolkit.
+ *
+ * @return name The name of the file to read the image from.
+ */
+ public abstract Image getImage(String name);
+
+ /**
+ * Returns an image from the specified URL, which must be in a
+ * recognized format. Supported formats vary from toolkit to toolkit.
+ *
+ * @return url The URl to read the image from.
+ */
+ public abstract Image getImage(URL url);
+
+ public abstract Image createImage(String filename);
+
+ public abstract Image createImage(URL url);
+
+ /**
+ * Readies an image to be rendered on the screen. The width and height
+ * values can be set to the default sizes for the image by passing -1
+ * in those parameters.
+ *
+ * @param image The image to prepare for rendering.
+ * @param width The width of the image.
+ * @param height The height of the image.
+ * @param observer The observer to receive events about the preparation
+ * process.
+ *
+ * @return <code>true</code> if the image is already prepared for rendering,
+ * <code>false</code> otherwise.
+ */
+ public abstract boolean prepareImage(Image image, int width, int height,
+ ImageObserver observer);
+
+ /**
+ * Checks the status of specified image as it is being readied for
+ * rendering.
+ *
+ * @param image The image to prepare for rendering.
+ * @param width The width of the image.
+ * @param height The height of the image.
+ * @param observer The observer to receive events about the preparation
+ * process.
+ *
+ * @return A union of the bitmasks from
+ * <code>java.awt.image.ImageObserver</code> that indicates the current
+ * state of the imaging readying process.
+ */
+ public abstract int checkImage(Image image, int width, int height,
+ ImageObserver observer);
+
+ /**
+ * Creates an image using the specified <code>ImageProducer</code>
+ *
+ * @param producer The <code>ImageProducer</code> to create the image from.
+ *
+ * @return The created image.
+ */
+ public abstract Image createImage(ImageProducer producer);
+
+ /**
+ * Creates an image from the specified byte array. The array must be in
+ * a recognized format. Supported formats vary from toolkit to toolkit.
+ *
+ * @param data The raw image data.
+ *
+ * @return The created image.
+ */
+ public Image createImage(byte[] data)
+ {
+ return createImage(data, 0, data.length);
+ }
+
+ /**
+ * Creates an image from the specified portion of the byte array passed.
+ * The array must be in a recognized format. Supported formats vary from
+ * toolkit to toolkit.
+ *
+ * @param data The raw image data.
+ * @param offset The offset into the data where the image data starts.
+ * @param len The length of the image data.
+ *
+ * @return The created image.
+ */
+ public abstract Image createImage(byte[] data, int offset, int len);
+
+ /**
+ * Returns a instance of <code>PrintJob</code> for the specified
+ * arguments.
+ *
+ * @param frame The window initiating the print job.
+ * @param title The print job title.
+ * @param props The print job properties.
+ *
+ * @return The requested print job, or <code>null</code> if the job
+ * was cancelled.
+ *
+ * @exception NullPointerException If frame is null,
+ * or GraphicsEnvironment.isHeadless() returns true.
+ * @exception SecurityException If this thread is not allowed to initiate
+ * a print job request.
+ */
+ public abstract PrintJob getPrintJob(Frame frame, String title,
+ Properties props);
+
+ /**
+ * Returns a instance of <code>PrintJob</code> for the specified
+ * arguments.
+ *
+ * @param frame The window initiating the print job.
+ * @param title The print job title.
+ * @param jobAttr A set of job attributes which will control the print job.
+ * @param pageAttr A set of page attributes which will control the print job.
+ *
+ * @exception NullPointerException If frame is null, and either jobAttr is null
+ * or jobAttr.getDialog() returns JobAttributes.DialogType.NATIVE.
+ * @exception IllegalArgumentException If pageAttrspecifies differing cross
+ * feed and feed resolutions, or when GraphicsEnvironment.isHeadless() returns
+ * true.
+ * @exception SecurityException If this thread is not allowed to initiate
+ * a print job request.
+ *
+ * @since 1.3
+ */
+ public PrintJob getPrintJob(Frame frame, String title,
+ JobAttributes jobAttr, PageAttributes pageAttr)
+ {
+ // FIXME: it is possible this check may be removed
+ // if this method, when written, always delegates to
+ // getPrintJob(Frame, String, Properties).
+ SecurityManager sm;
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPrintJobAccess();
+
+ return null;
+ }
+
+ /**
+ * Causes a "beep" tone to be generated.
+ */
+ public abstract void beep();
+
+ /**
+ * Returns the system clipboard.
+ *
+ * @return THe system clipboard.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public abstract Clipboard getSystemClipboard();
+
+ /**
+ * Gets the singleton instance of the system selection as a
+ * Clipboard object. The system selection contains the selected text
+ * of the last component/widget that had focus and a text selection.
+ * The default implementation returns null.
+ *
+ * @return The Clipboard holding the system (text) selection or null
+ * if the Toolkit or system doesn't support a selection clipboard.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * is true.
+ * @exception SecurityException If the current security manager
+ * checkSystemClipboardAccess() doesn't allow access.
+ *
+ * @since 1.4
+ */
+ public Clipboard getSystemSelection()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the accelerator key mask for menu shortcuts. The default is
+ * <code>Event.CTRL_MASK</code>. A toolkit must override this method
+ * to change the default.
+ *
+ * @return The key mask for the menu accelerator key.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public int getMenuShortcutKeyMask()
+ {
+ return Event.CTRL_MASK;
+ }
+
+ /**
+ * Returns whether the given locking key on the keyboard is currently in its
+ * "on" state.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ * @exception IllegalArgumentException If keyCode is not one of the valid keys.
+ * @exception UnsupportedOperationException If the host system doesn't allow
+ * getting the state of this key programmatically, or if the keyboard doesn't
+ * have this key.
+ */
+ public boolean getLockingKeyState(int keyCode)
+ {
+ if (keyCode != KeyEvent.VK_CAPS_LOCK
+ && keyCode != KeyEvent.VK_NUM_LOCK
+ && keyCode != KeyEvent.VK_SCROLL_LOCK)
+ throw new IllegalArgumentException();
+
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Sets the state of the given locking key on the keyboard.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ * @exception IllegalArgumentException If keyCode is not one of the valid keys.
+ * @exception UnsupportedOperationException If the host system doesn't allow
+ * getting the state of this key programmatically, or if the keyboard doesn't
+ * have this key.
+ */
+ public void setLockingKeyState(int keyCode, boolean on)
+ {
+ if (keyCode != KeyEvent.VK_CAPS_LOCK
+ && keyCode != KeyEvent.VK_NUM_LOCK
+ && keyCode != KeyEvent.VK_SCROLL_LOCK)
+ throw new IllegalArgumentException();
+
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Returns the native container object of the specified component. This
+ * method is necessary because the parent component might be a lightweight
+ * component.
+ *
+ * @param component The component to fetch the native container for.
+ *
+ * @return The native container object for this component.
+ */
+ protected static Container getNativeContainer(Component component)
+ {
+ component = component.getParent();
+ while (true)
+ {
+ if (component == null)
+ return null;
+ if (! (component instanceof Container))
+ {
+ component = component.getParent();
+ continue;
+ }
+ if (component.getPeer() instanceof LightweightPeer)
+ {
+ component = component.getParent();
+ continue;
+ }
+ return (Container) component;
+ }
+ }
+
+ /**
+ * Creates a new custom cursor object.
+ *
+ * @exception IndexOutOfBoundsException If the hotSpot values are outside
+ * the bounds of the cursor.
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
+ {
+ // Presumably the only reason this isn't abstract is for backwards
+ // compatibility? FIXME?
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException("No custom cursor in an headless graphics "
+ + "environment.");
+ return null;
+ }
+
+ /**
+ * Returns the supported cursor dimension which is closest to the
+ * desired sizes.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
+ {
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException("No best cursor size in an headless "
+ + "graphics environment.");
+ return new Dimension (0,0);
+ }
+
+ /**
+ * Returns the maximum number of colors the Toolkit supports in a custom
+ * cursor palette.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public int getMaximumCursorColors()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns whether Toolkit supports this state for Frames.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ *
+ * @since 1.4
+ */
+ public boolean isFrameStateSupported(int state)
+ {
+ return false;
+ }
+
+ /**
+ * Returns the value of the property with the specified name, or the
+ * default value if the property does not exist.
+ *
+ * @param key The name of the property to retrieve.
+ * @param def The default value of the property.
+ */
+ public static String getProperty(String key, String def)
+ {
+ return props.getProperty(key, def);
+ }
+
+
+ /**
+ * Returns the event queue that is suitable for the calling context.
+ *
+ * <p>Despite the word “System” in the name of this
+ * method, a toolkit may provide different event queues for each
+ * applet. There is no guarantee that the same queue is shared
+ * system-wide.
+ *
+ * <p>The implementation first checks whether a
+ * SecurityManager has been installed. If so, its {@link
+ * java.lang.SecurityManager#checkAwtEventQueueAccess()} method gets
+ * called. The security manager will throw a SecurityException if it
+ * does not grant the permission to access the event queue.
+ *
+ * <p>Next, the call is delegated to {@link
+ * #getSystemEventQueueImpl()}.
+ *
+ * @return The event queue for this applet (or application).
+ *
+ * @throws SecurityException if a security manager has been
+ * installed, and it does not grant the permission to access the
+ * event queue.
+ */
+ public final EventQueue getSystemEventQueue()
+ {
+ SecurityManager sm;
+
+ sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkAwtEventQueueAccess();
+
+ return getSystemEventQueueImpl();
+ }
+
+
+ /**
+ * Returns the event queue that is suitable for the calling context.
+ *
+ * <p>Despite the word “System” in the name of this
+ * method, a toolkit may provide different event queues for each
+ * applet. There is no guarantee that the same queue is shared
+ * system-wide.
+ *
+ * <p>No security checks are performed, which is why this method
+ * may only be called by Toolkits.
+ *
+ * @see #getSystemEventQueue()
+ */
+ protected abstract EventQueue getSystemEventQueueImpl();
+
+
+ /**
+ * @since 1.3
+ */
+ public abstract DragSourceContextPeer
+ createDragSourceContextPeer(DragGestureEvent e);
+
+ /**
+ * @since 1.3
+ */
+ public DragGestureRecognizer
+ createDragGestureRecognizer(Class recognizer, DragSource ds,
+ Component comp, int actions,
+ DragGestureListener l)
+ {
+ return null;
+ }
+
+ public final Object getDesktopProperty(String propertyName)
+ {
+ return desktopProperties.get(propertyName);
+ }
+
+ protected final void setDesktopProperty(String name, Object newValue)
+ {
+ Object oldValue = getDesktopProperty(name);
+ desktopProperties.put(name, newValue);
+ desktopPropsSupport.firePropertyChange(name, oldValue, newValue);
+ }
+
+ protected Object lazilyLoadDesktopProperty(String name)
+ {
+ // FIXME - what is this??
+ return null;
+ }
+
+ protected void initializeDesktopProperties()
+ {
+ // Overridden by toolkit implementation?
+ }
+
+ public void addPropertyChangeListener(String name,
+ PropertyChangeListener pcl)
+ {
+ desktopPropsSupport.addPropertyChangeListener(name, pcl);
+ }
+
+ public void removePropertyChangeListener(String name,
+ PropertyChangeListener pcl)
+ {
+ desktopPropsSupport.removePropertyChangeListener(name, pcl);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ return desktopPropsSupport.getPropertyChangeListeners();
+ }
+
+ /**
+ * @since 1.4
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners(String name)
+ {
+ 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)
+ {
+ // First we must check the security permissions.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null)
+ s.checkPermission(new AWTPermission("listenToAllAWTEvents"));
+
+ // 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()
+ {
+ // 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)
+ {
+ // 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);
+ }
+ }
+
+ /**
+ * @since 1.3
+ */
+ public abstract Map mapInputMethodHighlight(InputMethodHighlight highlight);
+
+ /**
+ * Initializes the accessibility framework. In particular, this loads the
+ * properties javax.accessibility.screen_magnifier_present and
+ * javax.accessibility.screen_reader_present and loads
+ * the classes specified in javax.accessibility.assistive_technologies.
+ */
+ private static void initAccessibility()
+ {
+ AccessController.doPrivileged
+ (new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Properties props = new Properties();
+ String sep = File.separator;
+
+ // Try the user configuration.
+ try
+ {
+ File propsFile = new File(System.getProperty("user.home") + sep
+ + ".accessibility.properties");
+ FileInputStream in = new FileInputStream(propsFile);
+ props.load(in);
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ // User configuration not present, ignore.
+ }
+
+ // Try the system configuration if there was no user configuration.
+ if (props.size() == 0)
+ {
+ try
+ {
+ File propsFile =
+ new File(System.getProperty("gnu.classpath.home.url")
+ + sep + "accessibility.properties");
+ FileInputStream in = new FileInputStream(propsFile);
+ props.load(in);
+ in.close();
+ }
+ catch (Exception ex)
+ {
+ // System configuration not present, ignore.
+ }
+ }
+
+ // Fetch the screen_magnifier_present property. Check systen properties
+ // first, then fallback to the configuration file.
+ String magPresent = SystemProperties.getProperty
+ ("javax.accessibility.screen_magnifier_present");
+ if (magPresent == null)
+ {
+ magPresent = props.getProperty("screen_magnifier_present");
+ if (magPresent != null)
+ {
+ SystemProperties.setProperty
+ ("javax.accessibility.screen_magnifier_present", magPresent);
+ }
+ }
+
+ // Fetch the screen_reader_present property. Check systen properties
+ // first, then fallback to the configuration file.
+ String readerPresent = SystemProperties.getProperty
+ ("javax.accessibility.screen_reader_present");
+ if (readerPresent == null)
+ {
+ readerPresent = props.getProperty("screen_reader_present");
+ if (readerPresent != null)
+ {
+ SystemProperties.setProperty
+ ("javax.accessibility.screen_reader_present", readerPresent);
+ }
+ }
+
+ // Fetch the list of classes to be loaded.
+ String classes = SystemProperties.getProperty
+ ("javax.accessibility.assistive_technologies");
+ if (classes == null)
+ {
+ classes = props.getProperty("assistive_technologies");
+ if (classes != null)
+ {
+ SystemProperties.setProperty
+ ("javax.accessibility.assistive_technologies", classes);
+ }
+ }
+
+ // Try to load the assisitive_technologies classes.
+ if (classes != null)
+ {
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ StringTokenizer tokenizer = new StringTokenizer(classes, ",");
+ while (tokenizer.hasMoreTokens())
+ {
+ String className = tokenizer.nextToken();
+ try
+ {
+ Class atClass = cl.loadClass(className);
+ atClass.newInstance();
+ }
+ catch (ClassNotFoundException ex)
+ {
+ AWTError err = new AWTError("Assistive Technology class not"
+ + " found: " + className);
+ err.initCause(ex);
+ throw err;
+ }
+ catch (InstantiationException ex)
+ {
+ AWTError err =
+ new AWTError("Assistive Technology class cannot be "
+ + "instantiated: " + className);
+ err.initCause(ex);
+ throw err;
+ }
+ catch (IllegalAccessException ex)
+ {
+ AWTError err =
+ new AWTError("Assistive Technology class cannot be "
+ + "accessed: " + className);
+ err.initCause(err);
+ throw err;
+ }
+ }
+ }
+ return null;
+ }
+ });
+
+ }
+
+} // class Toolkit
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Transparency.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Transparency.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Transparency.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Transparency.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,67 @@
+/* Transparency.java -- common transparency modes in graphics
+ Copyright (C) 2000, 2002, 2005 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt;
+
+/**
+ * A common transparency mode for layering graphics.
+ *
+ * @author Warren Levy (warrenl at cygnus.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface Transparency
+{
+ /** Image data which is completely opaque, for an alpha value of 1.0. */
+ int OPAQUE = 1;
+
+ /**
+ * Image data which is either completely opaque or transparent, for an
+ * exact integer alpha value.
+ */
+ int BITMASK = 2;
+
+ /** Image data which is translucent, for a non-integer alpha value. */
+ int TRANSLUCENT = 3;
+
+ /**
+ * Return the transparency type.
+ *
+ * @return One of {@link #OPAQUE}, {@link #BITMASK}, or {@link #TRANSLUCENT}.
+ */
+ int getTransparency();
+} // interface Transparency
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Window.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Window.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Window.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/Window.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1240 @@
+/* Window.java --
+ Copyright (C) 1999, 2000, 2002, 2003, 2004, 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt;
+
+import java.awt.event.ComponentEvent;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
+import java.awt.event.WindowListener;
+import java.awt.event.WindowStateListener;
+import java.awt.image.BufferStrategy;
+import java.awt.peer.WindowPeer;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.EventListener;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Vector;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+/**
+ * This class represents a top-level window with no decorations.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Warren Levy (warrenl at cygnus.com)
+ */
+public class Window extends Container implements Accessible
+{
+ private static final long serialVersionUID = 4497834738069338734L;
+
+ // Serialized fields, from Sun's serialization spec.
+ private String warningString = null;
+ private int windowSerializedDataVersion = 0; // FIXME
+ /** @since 1.2 */
+ // private FocusManager focusMgr; // FIXME: what is this?
+ /** @since 1.2 */
+ private int state = 0;
+ /** @since 1.4 */
+ private boolean focusableWindowState = true;
+ /** @since 1.5 */
+ private boolean alwaysOnTop = false;
+
+ // A list of other top-level windows owned by this window.
+ private transient Vector ownedWindows = new Vector();
+
+ private transient WindowListener windowListener;
+ private transient WindowFocusListener windowFocusListener;
+ private transient WindowStateListener windowStateListener;
+ private transient GraphicsConfiguration graphicsConfiguration;
+
+ private transient boolean shown;
+
+ // This is package-private to avoid an accessor method.
+ transient Component windowFocusOwner;
+
+ /*
+ * The number used to generate the name returned by getName.
+ */
+ private static transient long next_window_number;
+
+ protected class AccessibleAWTWindow extends AccessibleAWTContainer
+ {
+ private static final long serialVersionUID = 4215068635060671780L;
+
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.WINDOW;
+ }
+
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ if (isActive())
+ states.add(AccessibleState.ACTIVE);
+ return states;
+ }
+ }
+
+ /**
+ * This (package access) constructor is used by subclasses that want
+ * to build windows that do not have parents. Eg. toplevel
+ * application frames. Subclasses cannot call super(null), since
+ * null is an illegal argument.
+ */
+ Window()
+ {
+ visible = false;
+ // Windows are the only Containers that default to being focus
+ // cycle roots.
+ focusCycleRoot = true;
+ setLayout(new BorderLayout());
+
+ GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration();
+ }
+
+ Window(GraphicsConfiguration gc)
+ {
+ this();
+ graphicsConfiguration = gc;
+ }
+
+ /**
+ * Initializes a new instance of <code>Window</code> with the specified
+ * parent. The window will initially be invisible.
+ *
+ * @param owner The owning <code>Frame</code> of this window.
+ *
+ * @exception IllegalArgumentException If the owner's GraphicsConfiguration
+ * is not from a screen device, or if owner is null; this exception is always
+ * thrown when GraphicsEnvironment.isHeadless returns true.
+ */
+ public Window(Frame owner)
+ {
+ this (owner, owner.getGraphicsConfiguration ());
+ }
+
+ /**
+ * Initializes a new instance of <code>Window</code> with the specified
+ * parent. The window will initially be invisible.
+ *
+ * @exception IllegalArgumentException If the owner's GraphicsConfiguration
+ * is not from a screen device, or if owner is null; this exception is always
+ * thrown when GraphicsEnvironment.isHeadless returns true.
+ *
+ * @since 1.2
+ */
+ public Window(Window owner)
+ {
+ this (owner, owner.getGraphicsConfiguration ());
+ }
+
+ /**
+ * Initializes a new instance of <code>Window</code> with the specified
+ * parent. The window will initially be invisible.
+ *
+ * @exception IllegalArgumentException If owner is null or if gc is not from a
+ * screen device; this exception is always thrown when
+ * GraphicsEnvironment.isHeadless returns true.
+ *
+ * @since 1.3
+ */
+ public Window(Window owner, GraphicsConfiguration gc)
+ {
+ this ();
+
+ synchronized (getTreeLock())
+ {
+ if (owner == null)
+ throw new IllegalArgumentException ("owner must not be null");
+
+ parent = owner;
+ owner.ownedWindows.add(new WeakReference(this));
+ }
+
+ // FIXME: make this text visible in the window.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null && ! s.checkTopLevelWindow(this))
+ warningString = System.getProperty("awt.appletWarning");
+
+ if (gc != null
+ && gc.getDevice().getType() != GraphicsDevice.TYPE_RASTER_SCREEN)
+ throw new IllegalArgumentException ("gc must be from a screen device");
+
+ if (gc == null)
+ graphicsConfiguration = GraphicsEnvironment.getLocalGraphicsEnvironment()
+ .getDefaultScreenDevice()
+ .getDefaultConfiguration();
+ else
+ graphicsConfiguration = gc;
+ }
+
+ GraphicsConfiguration getGraphicsConfigurationImpl()
+ {
+ if (graphicsConfiguration != null)
+ return graphicsConfiguration;
+
+ return super.getGraphicsConfigurationImpl();
+ }
+
+ /**
+ * Creates the native peer for this window.
+ */
+ public void addNotify()
+ {
+ if (peer == null)
+ peer = getToolkit().createWindow(this);
+ super.addNotify();
+ }
+
+ /**
+ * Relays out this window's child components at their preferred size.
+ *
+ * @specnote pack() doesn't appear to be called internally by show(), so
+ * we duplicate some of the functionality.
+ */
+ public void pack()
+ {
+ if (parent != null && !parent.isDisplayable())
+ parent.addNotify();
+ if (peer == null)
+ addNotify();
+
+ setSize(getPreferredSize());
+
+ validate();
+ }
+
+ /**
+ * Shows on-screen this window and any of its owned windows for whom
+ * isVisible returns true.
+ */
+ public void show()
+ {
+ synchronized (getTreeLock())
+ {
+ if (parent != null && ! parent.isDisplayable())
+ parent.addNotify();
+ if (peer == null)
+ addNotify();
+
+ 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 (! shown)
+ {
+ FocusTraversalPolicy policy = getFocusTraversalPolicy();
+ Component initialFocusOwner = null;
+
+ if (policy != null)
+ initialFocusOwner = policy.getInitialComponent(this);
+
+ if (initialFocusOwner != null)
+ initialFocusOwner.requestFocusInWindow();
+
+ shown = true;
+ }
+ }
+ }
+
+ public void hide()
+ {
+ // Hide visible owned windows.
+ synchronized (getTreeLock ())
+ {
+ Iterator e = ownedWindows.iterator();
+ while(e.hasNext())
+ {
+ Window w = (Window)(((Reference) e.next()).get());
+ if (w != null)
+ {
+ if (w.isVisible() && w.getPeer() != null)
+ w.getPeer().setVisible(false);
+ }
+ else
+ e.remove();
+ }
+ }
+ super.hide();
+ }
+
+ /**
+ * Destroys any resources associated with this window. This includes
+ * all components in the window and all owned top-level windows.
+ */
+ public void dispose()
+ {
+ hide();
+
+ synchronized (getTreeLock ())
+ {
+ Iterator e = ownedWindows.iterator();
+ while(e.hasNext())
+ {
+ Window w = (Window)(((Reference) e.next()).get());
+ if (w != null)
+ w.dispose();
+ else
+ // Remove null weak reference from ownedWindows.
+ e.remove();
+ }
+
+ for (int i = 0; i < ncomponents; ++i)
+ component[i].removeNotify();
+ this.removeNotify();
+
+ // Post a WINDOW_CLOSED event.
+ WindowEvent we = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
+ getToolkit().getSystemEventQueue().postEvent(we);
+ }
+ }
+
+ /**
+ * Sends this window to the back so that all other windows display in
+ * front of it.
+ *
+ * If the window is set to be always-on-top, this will remove its
+ * always-on-top status.
+ */
+ public void toBack()
+ {
+ if (peer != null)
+ {
+ if( alwaysOnTop )
+ setAlwaysOnTop( false );
+ ( (WindowPeer) peer ).toBack();
+ }
+ }
+
+ /**
+ * Brings this window to the front so that it displays in front of
+ * any other windows.
+ */
+ public void toFront()
+ {
+ if (peer != null)
+ ( (WindowPeer) peer ).toFront();
+ }
+
+ /**
+ * Returns the toolkit used to create this window.
+ *
+ * @return The toolkit used to create this window.
+ *
+ * @specnote Unlike Component.getToolkit, this implementation always
+ * returns the value of Toolkit.getDefaultToolkit().
+ */
+ public Toolkit getToolkit()
+ {
+ return Toolkit.getDefaultToolkit();
+ }
+
+ /**
+ * Returns the warning string that will be displayed if this window is
+ * popped up by an unsecure applet or application.
+ *
+ * @return The unsecure window warning message.
+ */
+ public final String getWarningString()
+ {
+ return warningString;
+ }
+
+ /**
+ * Returns the locale that this window is configured for.
+ *
+ * @return The locale this window is configured for.
+ */
+ public Locale getLocale()
+ {
+ return locale == null ? Locale.getDefault() : locale;
+ }
+
+ /*
+ /** @since 1.2
+ public InputContext getInputContext()
+ {
+ // FIXME
+ }
+ */
+
+ /**
+ * Sets the cursor for this window to the specifiec cursor.
+ *
+ * @param cursor The new cursor for this window.
+ */
+ public void setCursor(Cursor cursor)
+ {
+ super.setCursor(cursor);
+ }
+
+ public Window getOwner()
+ {
+ return (Window) parent;
+ }
+
+ /** @since 1.2 */
+ public Window[] getOwnedWindows()
+ {
+ Window [] trimmedList;
+ synchronized (getTreeLock ())
+ {
+ // Windows with non-null weak references in ownedWindows.
+ Window [] validList = new Window [ownedWindows.size()];
+
+ Iterator e = ownedWindows.iterator();
+ int numValid = 0;
+ while (e.hasNext())
+ {
+ Window w = (Window)(((Reference) e.next()).get());
+ if (w != null)
+ validList[numValid++] = w;
+ else
+ // Remove null weak reference from ownedWindows.
+ e.remove();
+ }
+
+ if (numValid != validList.length)
+ {
+ trimmedList = new Window [numValid];
+ System.arraycopy (validList, 0, trimmedList, 0, numValid);
+ }
+ else
+ trimmedList = validList;
+ }
+ return trimmedList;
+ }
+
+ /**
+ * Adds the specified listener to the list of <code>WindowListeners</code>
+ * that will receive events for this window.
+ *
+ * @param listener The <code>WindowListener</code> to add.
+ */
+ public synchronized void addWindowListener(WindowListener listener)
+ {
+ windowListener = AWTEventMulticaster.add(windowListener, listener);
+ }
+
+ /**
+ * Removes the specified listener from the list of
+ * <code>WindowListeners</code> that will receive events for this window.
+ *
+ * @param listener The <code>WindowListener</code> to remove.
+ */
+ public synchronized void removeWindowListener(WindowListener listener)
+ {
+ windowListener = AWTEventMulticaster.remove(windowListener, listener);
+ }
+
+ /**
+ * Returns an array of all the window listeners registered on this window.
+ *
+ * @since 1.4
+ */
+ public synchronized WindowListener[] getWindowListeners()
+ {
+ return (WindowListener[])
+ AWTEventMulticaster.getListeners(windowListener,
+ WindowListener.class);
+ }
+
+ /**
+ * Returns an array of all the window focus listeners registered on this
+ * window.
+ *
+ * @since 1.4
+ */
+ public synchronized WindowFocusListener[] getWindowFocusListeners()
+ {
+ return (WindowFocusListener[])
+ AWTEventMulticaster.getListeners(windowFocusListener,
+ WindowFocusListener.class);
+ }
+
+ /**
+ * Returns an array of all the window state listeners registered on this
+ * window.
+ *
+ * @since 1.4
+ */
+ public synchronized WindowStateListener[] getWindowStateListeners()
+ {
+ return (WindowStateListener[])
+ AWTEventMulticaster.getListeners(windowStateListener,
+ WindowStateListener.class);
+ }
+
+ /**
+ * Adds the specified listener to this window.
+ */
+ public void addWindowFocusListener (WindowFocusListener wfl)
+ {
+ windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl);
+ }
+
+ /**
+ * Adds the specified listener to this window.
+ *
+ * @since 1.4
+ */
+ public void addWindowStateListener (WindowStateListener wsl)
+ {
+ windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl);
+ }
+
+ /**
+ * Removes the specified listener from this window.
+ */
+ public void removeWindowFocusListener (WindowFocusListener wfl)
+ {
+ windowFocusListener = AWTEventMulticaster.remove (windowFocusListener, wfl);
+ }
+
+ /**
+ * Removes the specified listener from this window.
+ *
+ * @since 1.4
+ */
+ public void removeWindowStateListener (WindowStateListener wsl)
+ {
+ windowStateListener = AWTEventMulticaster.remove (windowStateListener, wsl);
+ }
+
+ /**
+ * Returns an array of all the objects currently registered as FooListeners
+ * upon this Window. FooListeners are registered using the addFooListener
+ * method.
+ *
+ * @exception ClassCastException If listenerType doesn't specify a class or
+ * interface that implements java.util.EventListener.
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ if (listenerType == WindowListener.class)
+ return getWindowListeners();
+ return super.getListeners(listenerType);
+ }
+
+ void dispatchEventImpl(AWTEvent e)
+ {
+ // Make use of event id's in order to avoid multiple instanceof tests.
+ if (e.id <= WindowEvent.WINDOW_LAST
+ && e.id >= WindowEvent.WINDOW_FIRST
+ && (windowListener != null
+ || windowFocusListener != null
+ || windowStateListener != null
+ || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
+ processEvent(e);
+ else
+ {
+ if (peer != null && (e.id == ComponentEvent.COMPONENT_RESIZED
+ || e.id == ComponentEvent.COMPONENT_MOVED))
+ {
+ Rectangle bounds = peer.getBounds();
+ x = bounds.x;
+ y = bounds.y;
+ height = bounds.height;
+ width = bounds.width;
+
+ if (e.id == ComponentEvent.COMPONENT_RESIZED)
+ {
+ invalidate();
+ validate();
+ }
+ }
+ super.dispatchEventImpl(e);
+ }
+ }
+
+ /**
+ * Processes the specified event for this window. If the event is an
+ * instance of <code>WindowEvent</code>, then
+ * <code>processWindowEvent()</code> is called to process the event,
+ * otherwise the superclass version of this method is invoked.
+ *
+ * @param evt The event to process.
+ */
+ protected void processEvent(AWTEvent evt)
+ {
+ if (evt instanceof WindowEvent)
+ processWindowEvent((WindowEvent) evt);
+ else
+ super.processEvent(evt);
+ }
+
+ /**
+ * Dispatches this event to any listeners that are listening for
+ * <code>WindowEvents</code> on this window. This method only gets
+ * invoked if it is enabled via <code>enableEvents()</code> or if
+ * a listener has been added.
+ *
+ * @param evt The event to process.
+ */
+ protected void processWindowEvent(WindowEvent evt)
+ {
+ int id = evt.getID();
+
+ if (id == WindowEvent.WINDOW_GAINED_FOCUS
+ || id == WindowEvent.WINDOW_LOST_FOCUS)
+ processWindowFocusEvent (evt);
+ else if (id == WindowEvent.WINDOW_STATE_CHANGED)
+ processWindowStateEvent (evt);
+ else
+ {
+ if (windowListener != null)
+ {
+ switch (evt.getID())
+ {
+ case WindowEvent.WINDOW_ACTIVATED:
+ windowListener.windowActivated(evt);
+ break;
+
+ case WindowEvent.WINDOW_CLOSED:
+ windowListener.windowClosed(evt);
+ break;
+
+ case WindowEvent.WINDOW_CLOSING:
+ windowListener.windowClosing(evt);
+ break;
+
+ case WindowEvent.WINDOW_DEACTIVATED:
+ windowListener.windowDeactivated(evt);
+ break;
+
+ case WindowEvent.WINDOW_DEICONIFIED:
+ windowListener.windowDeiconified(evt);
+ break;
+
+ case WindowEvent.WINDOW_ICONIFIED:
+ windowListener.windowIconified(evt);
+ break;
+
+ case WindowEvent.WINDOW_OPENED:
+ windowListener.windowOpened(evt);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Identifies if this window is active. The active window is a Frame or
+ * Dialog that has focus or owns the active window.
+ *
+ * @return true if active, else false.
+ * @since 1.4
+ */
+ public boolean isActive()
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ return manager.getActiveWindow() == this;
+ }
+
+ /**
+ * Identifies if this window is focused. A window is focused if it is the
+ * focus owner or it contains the focus owner.
+ *
+ * @return true if focused, else false.
+ * @since 1.4
+ */
+ public boolean isFocused()
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+ return manager.getFocusedWindow() == this;
+ }
+
+ /**
+ * Returns the child window that has focus if this window is active.
+ * This method returns <code>null</code> if this window is not active
+ * or no children have focus.
+ *
+ * @return The component that has focus, or <code>null</code> if no
+ * component has focus.
+ */
+ public Component getFocusOwner ()
+ {
+ KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();
+
+ Window activeWindow = manager.getActiveWindow ();
+
+ // The currently-focused Component belongs to the active Window.
+ if (activeWindow == this)
+ return manager.getFocusOwner ();
+ else
+ return null;
+ }
+
+ /**
+ * Returns the child component of this window that would receive
+ * focus if this window were to become focused. If the window
+ * already has the top-level focus, then this method returns the
+ * same component as getFocusOwner. If no child component has
+ * requested focus within the window, then the initial focus owner
+ * is returned. If this is a non-focusable window, this method
+ * returns null.
+ *
+ * @return the child component of this window that most recently had
+ * the focus, or <code>null</code>
+ * @since 1.4
+ */
+ public Component getMostRecentFocusOwner ()
+ {
+ return windowFocusOwner;
+ }
+
+ /**
+ * Set the focus owner for this window. This method is used to
+ * remember which component was focused when this window lost
+ * top-level focus, so that when it regains top-level focus the same
+ * child component can be refocused.
+ *
+ * @param windowFocusOwner the component in this window that owns
+ * the focus.
+ */
+ void setFocusOwner (Component windowFocusOwner)
+ {
+ this.windowFocusOwner = windowFocusOwner;
+ }
+
+ /**
+ * Post a Java 1.0 event to the event queue.
+ *
+ * @param e The event to post.
+ *
+ * @deprecated
+ */
+ public boolean postEvent(Event e)
+ {
+ return handleEvent (e);
+ }
+
+ /**
+ * Tests whether or not this window is visible on the screen.
+ *
+ * In contrast to the normal behaviour of Container, which is that
+ * a container is showing if its parent is visible and showing, a Window
+ * is even showing, if its parent (i.e. an invisible Frame) is not showing.
+ *
+ * @return <code>true</code> if this window is visible, <code>false</code>
+ * otherwise.
+ */
+ public boolean isShowing()
+ {
+ return isVisible();
+ }
+
+ public void setLocationRelativeTo(Component c)
+ {
+ int x = 0;
+ int y = 0;
+
+ if (c == null || !c.isShowing())
+ {
+ GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Point center = ge.getCenterPoint();
+ x = center.x - (width / 2);
+ y = center.y - (height / 2);
+ }
+ else
+ {
+ int cWidth = c.getWidth();
+ int cHeight = c.getHeight();
+ Dimension screenSize = getToolkit().getScreenSize();
+
+ x = c.getLocationOnScreen().x;
+ y = c.getLocationOnScreen().y;
+
+ // If bottom of component is cut off, window placed
+ // on the left or the right side of component
+ if ((y + cHeight) > screenSize.height)
+ {
+ // If the right side of the component is closer to the center
+ if ((screenSize.width / 2 - x) <= 0)
+ {
+ if ((x - width) >= 0)
+ x -= width;
+ else
+ x = 0;
+ }
+ else
+ {
+ if ((x + cWidth + width) <= screenSize.width)
+ x += cWidth;
+ else
+ x = screenSize.width - width;
+ }
+
+ y = screenSize.height - height;
+ }
+ else if (cWidth > width || cHeight > height)
+ {
+ // If right side of component is cut off
+ if ((x + width) > screenSize.width)
+ x = screenSize.width - width;
+ // If left side of component is cut off
+ else if (x < 0)
+ x = 0;
+ else
+ x += (cWidth - width) / 2;
+
+ y += (cHeight - height) / 2;
+ }
+ else
+ {
+ // If right side of component is cut off
+ if ((x + width) > screenSize.width)
+ x = screenSize.width - width;
+ // If left side of component is cut off
+ else if (x < 0 || (x - (width - cWidth) / 2) < 0)
+ x = 0;
+ else
+ x -= (width - cWidth) / 2;
+
+ if ((y - (height - cHeight) / 2) > 0)
+ y -= (height - cHeight) / 2;
+ else
+ y = 0;
+ }
+ }
+
+ setLocation(x, y);
+ }
+
+ /**
+ * A BltBufferStrategy for windows.
+ */
+ private class WindowBltBufferStrategy extends BltBufferStrategy
+ {
+ /**
+ * Creates a block transfer strategy for this window.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ * @param accelerated true if the buffer should be accelerated,
+ * false otherwise
+ */
+ WindowBltBufferStrategy(int numBuffers, boolean accelerated)
+ {
+ super(numBuffers,
+ new BufferCapabilities(new ImageCapabilities(accelerated),
+ new ImageCapabilities(accelerated),
+ BufferCapabilities.FlipContents.COPIED));
+ }
+ }
+
+ /**
+ * A FlipBufferStrategy for windows.
+ */
+ private class WindowFlipBufferStrategy extends FlipBufferStrategy
+ {
+ /**
+ * Creates a flip buffer strategy for this window.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ *
+ * @throws AWTException if the requested number of buffers is not
+ * supported
+ */
+ WindowFlipBufferStrategy(int numBuffers)
+ throws AWTException
+ {
+ super(numBuffers,
+ new BufferCapabilities(new ImageCapabilities(true),
+ new ImageCapabilities(true),
+ BufferCapabilities.FlipContents.COPIED));
+ }
+ }
+
+ /**
+ * Creates a buffering strategy that manages how this window is
+ * repainted. This method attempts to create the optimum strategy
+ * based on the desired number of buffers. Hardware or software
+ * acceleration may be used.
+ *
+ * createBufferStrategy attempts different levels of optimization,
+ * but guarantees that some strategy with the requested number of
+ * buffers will be created even if it is not optimal. First it
+ * attempts to create a page flipping strategy, then an accelerated
+ * blitting strategy, then an unaccelerated blitting strategy.
+ *
+ * Calling this method causes any existing buffer strategy to be
+ * destroyed.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ *
+ * @throws IllegalArgumentException if requested number of buffers
+ * is less than one
+ * @throws IllegalStateException if this window is not displayable
+ *
+ * @since 1.4
+ */
+ public void createBufferStrategy(int numBuffers)
+ {
+ if (numBuffers < 1)
+ throw new IllegalArgumentException("Window.createBufferStrategy: number"
+ + " of buffers is less than one");
+
+ if (!isDisplayable())
+ throw new IllegalStateException("Window.createBufferStrategy: window is"
+ + " not displayable");
+
+ BufferStrategy newStrategy = null;
+
+ // try a flipping strategy
+ try
+ {
+ newStrategy = new WindowFlipBufferStrategy(numBuffers);
+ }
+ catch (AWTException e)
+ {
+ }
+
+ // fall back to an accelerated blitting strategy
+ if (newStrategy == null)
+ newStrategy = new WindowBltBufferStrategy(numBuffers, true);
+
+ bufferStrategy = newStrategy;
+ }
+
+ /**
+ * Creates a buffering strategy that manages how this window is
+ * repainted. This method attempts to create a strategy based on
+ * the specified capabilities and throws an exception if the
+ * requested strategy is not supported.
+ *
+ * Calling this method causes any existing buffer strategy to be
+ * destroyed.
+ *
+ * @param numBuffers the number of buffers in this strategy
+ * @param caps the requested buffering capabilities
+ *
+ * @throws AWTException if the requested capabilities are not
+ * supported
+ * @throws IllegalArgumentException if requested number of buffers
+ * is less than one or if caps is null
+ *
+ * @since 1.4
+ */
+ public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
+ throws AWTException
+ {
+ if (numBuffers < 1)
+ throw new IllegalArgumentException("Window.createBufferStrategy: number"
+ + " of buffers is less than one");
+
+ if (caps == null)
+ throw new IllegalArgumentException("Window.createBufferStrategy:"
+ + " capabilities object is null");
+
+ // a flipping strategy was requested
+ if (caps.isPageFlipping())
+ bufferStrategy = new WindowFlipBufferStrategy(numBuffers);
+ else
+ bufferStrategy = new WindowBltBufferStrategy(numBuffers, true);
+ }
+
+ /**
+ * Returns the buffer strategy used by the window.
+ *
+ * @return the buffer strategy.
+ * @since 1.4
+ */
+ public BufferStrategy getBufferStrategy()
+ {
+ return bufferStrategy;
+ }
+
+ /**
+ * @since 1.2
+ *
+ * @deprecated replaced by Component.applyComponentOrientation.
+ */
+ public void applyResourceBundle(ResourceBundle rb)
+ {
+ applyComponentOrientation(ComponentOrientation.getOrientation(rb));
+ }
+
+ /**
+ * @since 1.2
+ *
+ * @deprecated
+ */
+ public void applyResourceBundle(String rbName)
+ {
+ ResourceBundle rb = ResourceBundle.getBundle(rbName, Locale.getDefault(),
+ ClassLoader.getSystemClassLoader());
+ if (rb != null)
+ applyResourceBundle(rb);
+ }
+
+ /**
+ * Gets the AccessibleContext associated with this <code>Window</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 AccessibleAWTWindow();
+ return accessibleContext;
+ }
+
+ /**
+ * Get graphics configuration. The implementation for Window will
+ * not ask any parent containers, since Window is a toplevel
+ * window and not actually embedded in the parent component.
+ */
+ public GraphicsConfiguration getGraphicsConfiguration()
+ {
+ if (graphicsConfiguration != null) return graphicsConfiguration;
+ if (peer != null) return peer.getGraphicsConfiguration();
+ return null;
+ }
+
+ protected void processWindowFocusEvent(WindowEvent event)
+ {
+ if (windowFocusListener != null)
+ {
+ switch (event.getID ())
+ {
+ case WindowEvent.WINDOW_GAINED_FOCUS:
+ windowFocusListener.windowGainedFocus (event);
+ break;
+
+ case WindowEvent.WINDOW_LOST_FOCUS:
+ windowFocusListener.windowLostFocus (event);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ /**
+ * @since 1.4
+ */
+ protected void processWindowStateEvent(WindowEvent event)
+ {
+ if (windowStateListener != null
+ && event.getID () == WindowEvent.WINDOW_STATE_CHANGED)
+ windowStateListener.windowStateChanged (event);
+ }
+
+ /**
+ * Returns whether this <code>Window</code> can get the focus or not.
+ *
+ * @since 1.4
+ */
+ public final boolean isFocusableWindow ()
+ {
+ if (getFocusableWindowState () == false)
+ return false;
+
+ if (this instanceof Dialog
+ || this instanceof Frame)
+ return true;
+
+ // FIXME: Implement more possible cases for returning true.
+
+ return false;
+ }
+
+ /**
+ * Returns the value of the focusableWindowState property.
+ *
+ * @since 1.4
+ */
+ public boolean getFocusableWindowState ()
+ {
+ return focusableWindowState;
+ }
+
+ /**
+ * Sets the value of the focusableWindowState property.
+ *
+ * @since 1.4
+ */
+ public void setFocusableWindowState (boolean focusableWindowState)
+ {
+ this.focusableWindowState = focusableWindowState;
+ }
+
+ /**
+ * Check whether this Container is a focus cycle root.
+ * Returns always <code>true</code> as Windows are the
+ * root of the focus cycle.
+ *
+ * @return Always <code>true</code>.
+ *
+ * @since 1.4
+ */
+ public final boolean isFocusCycleRoot()
+ {
+ return true;
+ }
+
+ /**
+ * Set whether or not this Container is the root of a focus
+ * traversal cycle. Windows are the root of the focus cycle
+ * and therefore this method does nothing.
+ *
+ * @param focusCycleRoot ignored.
+ *
+ * @since 1.4
+ */
+ public final void setFocusCycleRoot(boolean focusCycleRoot)
+ {
+ // calls to the method are ignored
+ }
+
+ /**
+ * Returns the root container that owns the focus cycle where this
+ * component resides. Windows have no ancestors and this method
+ * returns always <code>null</code>.
+ *
+ * @return Always <code>null</code>.
+ * @since 1.4
+ */
+ public final Container getFocusCycleRootAncestor()
+ {
+ return null;
+ }
+
+ /**
+ * Returns whether the Windows is an always-on-top window,
+ * meaning whether the window can be obscured by other windows or not.
+ *
+ * @return <code>true</code> if the windows is always-on-top,
+ * <code>false</code> otherwise.
+ * @since 1.5
+ */
+ public final boolean isAlwaysOnTop()
+ {
+ return alwaysOnTop;
+ }
+
+ /**
+ * Sets the always-on-top state of this window (if supported).
+ *
+ * Setting a window to always-on-top means it will not be obscured
+ * by any other windows (with the exception of other always-on-top
+ * windows). Not all platforms may support this.
+ *
+ * If an window's always-on-top status is changed to false, the window
+ * will remain at the front but not be anchored there.
+ *
+ * Calling toBack() on an always-on-top window will change its
+ * always-on-top status to false.
+ *
+ * @since 1.5
+ */
+ public final void setAlwaysOnTop(boolean alwaysOnTop)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission( new AWTPermission("setWindowAlwaysOnTop") );
+
+ if( this.alwaysOnTop == alwaysOnTop )
+ return;
+
+ if( alwaysOnTop )
+ toFront();
+
+ firePropertyChange("alwaysOnTop", this.alwaysOnTop, alwaysOnTop );
+ this.alwaysOnTop = alwaysOnTop;
+
+ if (peer != null)
+ ( (WindowPeer) peer).updateAlwaysOnTop();
+ else
+ System.out.println("Null peer?!");
+ }
+
+ /**
+ * Generate a unique name for this window.
+ *
+ * @return A unique name for this window.
+ */
+ String generateName()
+ {
+ return "win" + getUniqueLong();
+ }
+
+ private static synchronized long getUniqueLong()
+ {
+ return next_window_number++;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/CMMException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/CMMException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/CMMException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/CMMException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* CMMException.java -- error in the native CMM
+ Copyright (C) 2002, 2005 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.color;
+
+/**
+ * Thrown when there is an error in the native CMM.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status updated to 1.4
+ */
+public class CMMException extends RuntimeException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 5775558044142994965L;
+
+ /**
+ * Create a new instance with a specified detailed error message.
+ *
+ * @param message the message
+ */
+ public CMMException(String message)
+ {
+ super(message);
+ }
+} // class CMMException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ColorSpace.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ColorSpace.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ColorSpace.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ColorSpace.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,183 @@
+/* ColorSpace.java -- transforms between color spaces
+ Copyright (C) 2000, 2002 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.color;
+
+import java.io.Serializable;
+
+/**
+ * NEEDS DOCUMENTATION
+ *
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @since 1.2
+ */
+public abstract class ColorSpace implements Serializable
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -409452704308689724L;
+
+ public static final int TYPE_XYZ = 0;
+ public static final int TYPE_Lab = 1;
+ public static final int TYPE_Luv = 2;
+ public static final int TYPE_YCbCr = 3;
+ public static final int TYPE_Yxy = 4;
+ public static final int TYPE_RGB = 5;
+ public static final int TYPE_GRAY = 6;
+ public static final int TYPE_HSV = 7;
+ public static final int TYPE_HLS = 8;
+ public static final int TYPE_CMYK = 9;
+ // mysterious gap in the enumeration sequenece
+ public static final int TYPE_CMY = 11;
+ public static final int TYPE_2CLR = 12;
+ public static final int TYPE_3CLR = 13;
+ public static final int TYPE_4CLR = 14;
+ public static final int TYPE_5CLR = 15;
+ public static final int TYPE_6CLR = 16;
+ public static final int TYPE_7CLR = 17;
+ public static final int TYPE_8CLR = 18;
+ public static final int TYPE_9CLR = 19;
+ public static final int TYPE_ACLR = 20;
+ public static final int TYPE_BCLR = 21;
+ public static final int TYPE_CCLR = 22;
+ public static final int TYPE_DCLR = 23;
+ public static final int TYPE_ECLR = 24;
+ public static final int TYPE_FCLR = 25;
+
+ public static final int CS_sRGB = 1000;
+ public static final int CS_LINEAR_RGB = 1004;
+ public static final int CS_CIEXYZ = 1001;
+ public static final int CS_PYCC = 1002;
+ public static final int CS_GRAY = 1003;
+
+ private static final int CS_BASE = CS_sRGB;
+ private static final int CS_END = CS_LINEAR_RGB + 1;
+ private static final int CS_COUNT = CS_END - CS_BASE;
+
+ // Instances are lazily instantiated
+ private static final ColorSpace[] INSTANCES = new ColorSpace[CS_COUNT];
+
+ /**
+ * @serial
+ */
+ // Visible in subclass.
+ final int type;
+
+ /**
+ * @serial
+ */
+ // Visible in subclass.
+ final int numComponents;
+
+ protected ColorSpace(int type, int numcomponents)
+ {
+ this.type = type;
+ numComponents = numcomponents;
+ }
+
+ public static ColorSpace getInstance(int colorspace)
+ {
+ if ((colorspace >= CS_BASE) && (colorspace < CS_END))
+ {
+ int instanceIndex = colorspace - CS_BASE;
+ if (INSTANCES[instanceIndex] == null)
+ {
+ ICC_Profile profile = new ICC_Profile(colorspace);
+ INSTANCES[instanceIndex] = new ICC_ColorSpace(profile);
+ }
+ return INSTANCES[instanceIndex];
+ }
+ throw new IllegalArgumentException("unknown/unsupported colorspace");
+ }
+
+ public boolean isCS_sRGB()
+ {
+ return type == CS_sRGB;
+ }
+
+ /**
+ * Transforms a color value assumed to be in this ColorSpace into a value in
+ * the default CS_sRGB color space.
+ *
+ * @exception ArrayIndexOutOfBoundsException If array length is not at least
+ * the number of components in this ColorSpace.
+ */
+ public abstract float[] toRGB(float[] colorvalue);
+
+ public abstract float[] fromRGB(float[] rgbvalue);
+
+ public abstract float[] toCIEXYZ(float[] colorvalue);
+
+ public abstract float[] fromCIEXYZ(float[] colorvalue);
+
+ public int getType()
+ {
+ return type;
+ }
+
+ public int getNumComponents()
+ {
+ return numComponents;
+ }
+
+ public String getName(int idx)
+ {
+ return "type " + type;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public float getMinValue(int idx)
+ {
+ if (idx < 0 || idx >= numComponents)
+ throw new IllegalArgumentException();
+ return 0;
+ }
+
+ /**
+ * @since 1.4
+ */
+ public float getMaxValue(int idx)
+ {
+ if (idx < 0 || idx >= numComponents)
+ throw new IllegalArgumentException();
+ return 1;
+ }
+} // class ColorSpace
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ColorSpace.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ColorSpace.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ColorSpace.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ColorSpace.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,314 @@
+/* ICC_ColorSpace.java -- the canonical color space implementation
+ Copyright (C) 2000, 2002, 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.color;
+
+import gnu.java.awt.color.CieXyzConverter;
+import gnu.java.awt.color.ClutProfileConverter;
+import gnu.java.awt.color.ColorSpaceConverter;
+import gnu.java.awt.color.GrayProfileConverter;
+import gnu.java.awt.color.GrayScaleConverter;
+import gnu.java.awt.color.LinearRGBConverter;
+import gnu.java.awt.color.PyccConverter;
+import gnu.java.awt.color.RgbProfileConverter;
+import gnu.java.awt.color.SrgbConverter;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+/**
+ * ICC_ColorSpace - an implementation of ColorSpace
+ *
+ * While an ICC_Profile class abstracts the data in an ICC profile file
+ * an ICC_ColorSpace performs the color space conversions defined by
+ * an ICC_Profile instance.
+ *
+ * Typically, an ICC_Profile will either be created using getInstance,
+ * either from the built-in colorspaces, or from an ICC profile file.
+ * Then a ICC_Colorspace will be used to perform transforms from the
+ * device colorspace to and from the profile color space.
+ *
+ * The PCS used by ColorSpace is CIE XYZ relative a D50 white point.
+ * (Profiles using a CIE Lab PCS will have their input and output converted
+ * to D50 CIE XYZ accordingly.
+ *
+ * Note that a valid profile may not contain transforms in both directions,
+ * in which case the output may be undefined.
+ * All built-in colorspaces have bidirectional transforms, but developers
+ * using an ICC profile file may want to check the profile class using
+ * the ICC_Profile.getProfileClass() method. Input class profiles are
+ * guaranteed to have transforms to the PCS, output class profiles are
+ * guaranteed to have transforms from the PCS to device space.
+ *
+ * @author Sven de Marothy
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @since 1.2
+ */
+public class ICC_ColorSpace extends ColorSpace
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 3455889114070431483L;
+
+ /**
+ * @serial
+ */
+ private ICC_Profile thisProfile;
+
+ /**
+ * @serial
+ */
+ private float[] minVal;
+
+ /**
+ * @serial
+ */
+ private float[] maxVal;
+
+ /**
+ * @serial
+ */
+ private float[] diffMinMax;
+
+ /**
+ * @serial
+ */
+ private float[] invDiffMinMax;
+
+ /**
+ * @serial
+ */
+ private boolean needScaleInit;
+
+ /**
+ * Tells us if the PCS is CIE LAB (must be CIEXYZ otherwise)
+ */
+ private transient int type;
+ private transient int nComponents;
+ private transient ColorSpaceConverter converter;
+
+ /**
+ * Constructs a new ICC_ColorSpace from an ICC_Profile object.
+ *
+ * @exception IllegalArgumentException If profile is inappropriate for
+ * representing a ColorSpace.
+ */
+ public ICC_ColorSpace(ICC_Profile profile)
+ {
+ super(profile.getColorSpaceType(), profile.getNumComponents());
+
+ converter = getConverter(profile);
+ thisProfile = profile;
+ nComponents = profile.getNumComponents();
+ type = profile.getColorSpaceType();
+ makeArrays();
+ }
+
+ /**
+ * Return the profile
+ */
+ public ICC_Profile getProfile()
+ {
+ return thisProfile;
+ }
+
+ /**
+ * Transforms a color value assumed to be in this ColorSpace into a value in
+ * the default CS_sRGB color space.
+ *
+ * @exception ArrayIndexOutOfBoundsException If array length is not at least
+ * the number of components in this ColorSpace.
+ */
+ public float[] toRGB(float[] colorvalue)
+ {
+ return converter.toRGB(colorvalue);
+ }
+
+ /**
+ * Transforms a color value assumed to be in the default CS_sRGB color space
+ * into this ColorSpace.
+ *
+ * @exception ArrayIndexOutOfBoundsException If array length is not at
+ * least 3.
+ */
+ public float[] fromRGB(float[] rgbvalue)
+ {
+ return converter.fromRGB(rgbvalue);
+ }
+
+ /**
+ * Transforms a color value assumed to be in this ColorSpace into the
+ * CS_CIEXYZ conversion color space.
+ *
+ * @exception ArrayIndexOutOfBoundsException If array length is not at
+ * least the number of components in this ColorSpace.
+ */
+ public float[] toCIEXYZ(float[] colorvalue)
+ {
+ return converter.toCIEXYZ(colorvalue);
+ }
+
+ /**
+ * Transforms a color value assumed to be in the CS_CIEXYZ conversion color
+ * space into this ColorSpace.
+ *
+ * @exception ArrayIndexOutOfBoundsException If array length is not at
+ * least 3.
+ */
+ public float[] fromCIEXYZ(float[] colorvalue)
+ {
+ return converter.fromCIEXYZ(colorvalue);
+ }
+
+ public boolean isCS_sRGB()
+ {
+ return converter instanceof SrgbConverter;
+ }
+
+ /**
+ * Returns the minimum normalized color component value for the specified
+ * component.
+ *
+ * @exception IllegalArgumentException If component is less than 0 or greater
+ * than numComponents - 1.
+ *
+ * @since 1.4
+ */
+ public float getMinValue(int idx)
+ {
+ // FIXME: Not 100% certain of this.
+ if (type == ColorSpace.TYPE_Lab && (idx == 1 || idx == 2))
+ return -128f;
+
+ if (idx < 0 || idx >= nComponents)
+ throw new IllegalArgumentException();
+ return 0;
+ }
+
+ /**
+ * Returns the maximum normalized color component value for the specified
+ * component.
+ *
+ * @exception IllegalArgumentException If component is less than 0 or greater
+ * than numComponents - 1.
+ *
+ * @since 1.4
+ */
+ public float getMaxValue(int idx)
+ {
+ if (type == ColorSpace.TYPE_XYZ && idx >= 0 && idx <= 2)
+ return 1 + 32767 / 32768f;
+ else if (type == ColorSpace.TYPE_Lab)
+ {
+ if (idx == 0)
+ return 100;
+ if (idx == 1 || idx == 2)
+ return 127;
+ }
+ if (idx < 0 || idx >= nComponents)
+ throw new IllegalArgumentException();
+ return 1;
+ }
+
+ /**
+ * Returns a colorspace converter suitable for a given profile
+ */
+ private ColorSpaceConverter getConverter(ICC_Profile profile)
+ {
+ ColorSpaceConverter converter;
+ switch (profile.isPredefined())
+ {
+ case CS_sRGB:
+ converter = new SrgbConverter();
+ break;
+ case CS_CIEXYZ:
+ converter = new CieXyzConverter();
+ break;
+ case CS_GRAY:
+ converter = new GrayScaleConverter();
+ break;
+ case CS_LINEAR_RGB:
+ converter = new LinearRGBConverter();
+ break;
+ case CS_PYCC:
+ converter = new PyccConverter();
+ break;
+ default:
+ if (profile instanceof ICC_ProfileRGB)
+ converter = new RgbProfileConverter((ICC_ProfileRGB) profile);
+ else if (profile instanceof ICC_ProfileGray)
+ converter = new GrayProfileConverter((ICC_ProfileGray) profile);
+ else
+ converter = new ClutProfileConverter(profile);
+ break;
+ }
+ return converter;
+ }
+
+ /**
+ * Serialization compatibility requires these variable to be set,
+ * although we don't use them. Perhaps we should?
+ */
+ private void makeArrays()
+ {
+ minVal = new float[nComponents];
+ maxVal = new float[nComponents];
+
+ invDiffMinMax = diffMinMax = null;
+ for (int i = 0; i < nComponents; i++)
+ {
+ minVal[i] = getMinValue(i);
+ maxVal[i] = getMaxValue(i);
+ }
+ needScaleInit = true;
+ }
+
+ /**
+ * Deserializes the object
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException
+ {
+ s.defaultReadObject();
+ // set up objects
+ converter = getConverter(thisProfile);
+ nComponents = thisProfile.getNumComponents();
+ type = thisProfile.getColorSpaceType();
+ }
+} // class ICC_ColorSpace
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_Profile.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_Profile.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_Profile.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_Profile.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1244 @@
+/* ICC_Profile.java -- color space profiling
+ Copyright (C) 2000, 2002, 2004 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.color;
+
+import gnu.java.awt.color.ProfileHeader;
+import gnu.java.awt.color.TagEntry;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+/**
+ * ICC Profile - represents an ICC Color profile.
+ * The ICC profile format is a standard file format which maps the transform
+ * from a device color space to a standard Profile Color Space (PCS), which
+ * can either be CIE L*a*b or CIE XYZ.
+ * (With the exception of device link profiles which map from one device space
+ * to another)
+ *
+ * ICC profiles calibrated to specific input/output devices are used when color
+ * fidelity is of importance.
+ *
+ * An instance of ICC_Profile can be created using the getInstance() methods,
+ * either using one of the predefined color spaces enumerated in ColorSpace,
+ * or from an ICC profile file, or from an input stream.
+ *
+ * An ICC_ColorSpace object can then be created to transform color values
+ * through the profile.
+ *
+ * The ICC_Profile class implements the version 2 format specified by
+ * International Color Consortium Specification ICC.1:1998-09,
+ * and its addendum ICC.1A:1999-04, April 1999
+ * (available at www.color.org)
+ *
+ * @author Sven de Marothy
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ * @since 1.2
+ */
+public class ICC_Profile implements Serializable
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -3938515861990936766L;
+
+ /**
+ * ICC Profile classes
+ */
+ public static final int CLASS_INPUT = 0;
+ public static final int CLASS_DISPLAY = 1;
+ public static final int CLASS_OUTPUT = 2;
+ public static final int CLASS_DEVICELINK = 3;
+ public static final int CLASS_COLORSPACECONVERSION = 4;
+ public static final int CLASS_ABSTRACT = 5;
+ public static final int CLASS_NAMEDCOLOR = 6;
+
+ /**
+ * ICC Profile class signatures
+ */
+ public static final int icSigInputClass = 0x73636e72; // 'scnr'
+ public static final int icSigDisplayClass = 0x6d6e7472; // 'mntr'
+ public static final int icSigOutputClass = 0x70727472; // 'prtr'
+ public static final int icSigLinkClass = 0x6c696e6b; // 'link'
+ public static final int icSigColorSpaceClass = 0x73706163; // 'spac'
+ public static final int icSigAbstractClass = 0x61627374; // 'abst'
+ public static final int icSigNamedColorClass = 0x6e6d636c; // 'nmcl'
+
+ /**
+ * Color space signatures
+ */
+ public static final int icSigXYZData = 0x58595A20; // 'XYZ '
+ public static final int icSigLabData = 0x4C616220; // 'Lab '
+ public static final int icSigLuvData = 0x4C757620; // 'Luv '
+ public static final int icSigYCbCrData = 0x59436272; // 'YCbr'
+ public static final int icSigYxyData = 0x59787920; // 'Yxy '
+ public static final int icSigRgbData = 0x52474220; // 'RGB '
+ public static final int icSigGrayData = 0x47524159; // 'GRAY'
+ public static final int icSigHsvData = 0x48535620; // 'HSV '
+ public static final int icSigHlsData = 0x484C5320; // 'HLS '
+ public static final int icSigCmykData = 0x434D594B; // 'CMYK'
+ public static final int icSigCmyData = 0x434D5920; // 'CMY '
+ public static final int icSigSpace2CLR = 0x32434C52; // '2CLR'
+ public static final int icSigSpace3CLR = 0x33434C52; // '3CLR'
+ public static final int icSigSpace4CLR = 0x34434C52; // '4CLR'
+ public static final int icSigSpace5CLR = 0x35434C52; // '5CLR'
+ public static final int icSigSpace6CLR = 0x36434C52; // '6CLR'
+ public static final int icSigSpace7CLR = 0x37434C52; // '7CLR'
+ public static final int icSigSpace8CLR = 0x38434C52; // '8CLR'
+ public static final int icSigSpace9CLR = 0x39434C52; // '9CLR'
+ public static final int icSigSpaceACLR = 0x41434C52; // 'ACLR'
+ public static final int icSigSpaceBCLR = 0x42434C52; // 'BCLR'
+ public static final int icSigSpaceCCLR = 0x43434C52; // 'CCLR'
+ public static final int icSigSpaceDCLR = 0x44434C52; // 'DCLR'
+ public static final int icSigSpaceECLR = 0x45434C52; // 'ECLR'
+ public static final int icSigSpaceFCLR = 0x46434C52; // 'FCLR'
+
+ /**
+ * Rendering intents
+ */
+ public static final int icPerceptual = 0;
+ public static final int icRelativeColorimetric = 1;
+ public static final int icSaturation = 2;
+ public static final int icAbsoluteColorimetric = 3;
+
+ /**
+ * Tag signatures
+ */
+ public static final int icSigAToB0Tag = 0x41324230; // 'A2B0'
+ public static final int icSigAToB1Tag = 0x41324231; // 'A2B1'
+ public static final int icSigAToB2Tag = 0x41324232; // 'A2B2'
+ public static final int icSigBlueColorantTag = 0x6258595A; // 'bXYZ'
+ public static final int icSigBlueTRCTag = 0x62545243; // 'bTRC'
+ public static final int icSigBToA0Tag = 0x42324130; // 'B2A0'
+ public static final int icSigBToA1Tag = 0x42324131; // 'B2A1'
+ public static final int icSigBToA2Tag = 0x42324132; // 'B2A2'
+ public static final int icSigCalibrationDateTimeTag = 0x63616C74; // 'calt'
+ public static final int icSigCharTargetTag = 0x74617267; // 'targ'
+ public static final int icSigCopyrightTag = 0x63707274; // 'cprt'
+ public static final int icSigCrdInfoTag = 0x63726469; // 'crdi'
+ public static final int icSigDeviceMfgDescTag = 0x646D6E64; // 'dmnd'
+ public static final int icSigDeviceModelDescTag = 0x646D6464; // 'dmdd'
+ public static final int icSigDeviceSettingsTag = 0x64657673; // 'devs'
+ public static final int icSigGamutTag = 0x67616D74; // 'gamt'
+ public static final int icSigGrayTRCTag = 0x6b545243; // 'kTRC'
+ public static final int icSigGreenColorantTag = 0x6758595A; // 'gXYZ'
+ public static final int icSigGreenTRCTag = 0x67545243; // 'gTRC'
+ public static final int icSigLuminanceTag = 0x6C756d69; // 'lumi'
+ public static final int icSigMeasurementTag = 0x6D656173; // 'meas'
+ public static final int icSigMediaBlackPointTag = 0x626B7074; // 'bkpt'
+ public static final int icSigMediaWhitePointTag = 0x77747074; // 'wtpt'
+ public static final int icSigNamedColor2Tag = 0x6E636C32; // 'ncl2'
+ public static final int icSigOutputResponseTag = 0x72657370; // 'resp'
+ public static final int icSigPreview0Tag = 0x70726530; // 'pre0'
+ public static final int icSigPreview1Tag = 0x70726531; // 'pre1'
+ public static final int icSigPreview2Tag = 0x70726532; // 'pre2'
+ public static final int icSigProfileDescriptionTag = 0x64657363; // 'desc'
+ public static final int icSigProfileSequenceDescTag = 0x70736571; // 'pseq'
+ public static final int icSigPs2CRD0Tag = 0x70736430; // 'psd0'
+ public static final int icSigPs2CRD1Tag = 0x70736431; // 'psd1'
+ public static final int icSigPs2CRD2Tag = 0x70736432; // 'psd2'
+ public static final int icSigPs2CRD3Tag = 0x70736433; // 'psd3'
+ public static final int icSigPs2CSATag = 0x70733273; // 'ps2s'
+ public static final int icSigPs2RenderingIntentTag = 0x70733269; // 'ps2i'
+ public static final int icSigRedColorantTag = 0x7258595A; // 'rXYZ'
+ public static final int icSigRedTRCTag = 0x72545243; // 'rTRC'
+ public static final int icSigScreeningDescTag = 0x73637264; // 'scrd'
+ public static final int icSigScreeningTag = 0x7363726E; // 'scrn'
+ public static final int icSigTechnologyTag = 0x74656368; // 'tech'
+ public static final int icSigUcrBgTag = 0x62666420; // 'bfd '
+ public static final int icSigViewingCondDescTag = 0x76756564; // 'vued'
+ public static final int icSigViewingConditionsTag = 0x76696577; // 'view'
+ public static final int icSigChromaticityTag = 0x6368726D; // 'chrm'
+
+ /**
+ * Non-ICC tag 'head' for use in retrieving the header with getData()
+ */
+ public static final int icSigHead = 0x68656164;
+
+ /**
+ * Header offsets
+ */
+ public static final int icHdrSize = 0;
+ public static final int icHdrCmmId = 4;
+ public static final int icHdrVersion = 8;
+ public static final int icHdrDeviceClass = 12;
+ public static final int icHdrColorSpace = 16;
+ public static final int icHdrPcs = 20;
+ public static final int icHdrDate = 24;
+ public static final int icHdrMagic = 36;
+ public static final int icHdrPlatform = 40;
+ public static final int icHdrFlags = 44;
+ public static final int icHdrManufacturer = 48;
+ public static final int icHdrModel = 52;
+ public static final int icHdrAttributes = 56;
+ public static final int icHdrRenderingIntent = 64;
+ public static final int icHdrIlluminant = 68;
+ public static final int icHdrCreator = 80;
+
+ /**
+ *
+ */
+ public static final int icTagType = 0;
+ public static final int icTagReserved = 4;
+ public static final int icCurveCount = 8;
+ public static final int icCurveData = 12;
+ public static final int icXYZNumberX = 8;
+
+ /**
+ * offset of the Tag table
+ */
+ private static final int tagTableOffset = 128;
+
+ /**
+ * @serial
+ */
+ private static final int iccProfileSerializedDataVersion = 1;
+
+ /**
+ * Constants related to generating profiles for
+ * built-in colorspace profiles
+ */
+ /**
+ * Copyright notice to stick into built-in-profile files.
+ */
+ private static final String copyrightNotice = "Generated by GNU Classpath.";
+
+ /**
+ * Resolution of the TRC to use for predefined profiles.
+ * 1024 should suffice.
+ */
+ private static final int TRC_POINTS = 1024;
+
+ /**
+ * CIE 1931 D50 white point (in Lab coordinates)
+ */
+ private static final float[] D50 = { 0.96422f, 1.00f, 0.82521f };
+
+ /**
+ * Color space profile ID
+ * Set to the predefined profile class (e.g. CS_sRGB) if a predefined
+ * color space is used, set to -1 otherwise.
+ * (or if the profile has been modified)
+ */
+ private transient int profileID;
+
+ /**
+ * The profile header data
+ */
+ private transient ProfileHeader header;
+
+ /**
+ * A hashtable containing the profile tags as TagEntry objects
+ */
+ private transient Hashtable tagTable;
+
+ /**
+ * Contructor for predefined colorspaces
+ */
+ ICC_Profile(int profileID)
+ {
+ header = null;
+ tagTable = null;
+ createProfile(profileID);
+ }
+
+ /**
+ * Constructs an ICC_Profile from a header and a table of loaded tags.
+ */
+ ICC_Profile(ProfileHeader h, Hashtable tags) throws IllegalArgumentException
+ {
+ header = h;
+ tagTable = tags;
+ profileID = -1; // Not a predefined color space
+ }
+
+ /**
+ * Constructs an ICC_Profile from a byte array of data.
+ */
+ ICC_Profile(byte[] data) throws IllegalArgumentException
+ {
+ // get header and verify it
+ header = new ProfileHeader(data);
+ header.verifyHeader(data.length);
+ tagTable = createTagTable(data);
+ profileID = -1; // Not a predefined color space
+ }
+
+ /**
+ * Free up the used memory.
+ */
+ protected void finalize()
+ {
+ }
+
+ /**
+ * Returns an ICC_Profile instance from a byte array of profile data.
+ *
+ * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
+ * may be returned if appropriate.
+ *
+ * @param data - the profile data
+ * @return An ICC_Profile object
+ *
+ * @throws IllegalArgumentException if the profile data is an invalid
+ * v2 profile.
+ */
+ public static ICC_Profile getInstance(byte[] data)
+ {
+ ProfileHeader header = new ProfileHeader(data);
+
+ // verify it as a correct ICC header, including size
+ header.verifyHeader(data.length);
+
+ Hashtable tags = createTagTable(data);
+
+ if (isRGBProfile(header, tags))
+ return new ICC_ProfileRGB(data);
+ if (isGrayProfile(header, tags))
+ return new ICC_ProfileGray(data);
+
+ return new ICC_Profile(header, tags);
+ }
+
+ /**
+ * Returns an predefined ICC_Profile instance.
+ *
+ * This will construct an ICC_Profile instance from one of the predefined
+ * color spaces in the ColorSpace class. (e.g. CS_sRGB, CS_GRAY, etc)
+ *
+ * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
+ * may be returned if appropriate.
+ *
+ * @return An ICC_Profile object
+ */
+ public static ICC_Profile getInstance(int cspace)
+ {
+ if (cspace == ColorSpace.CS_sRGB || cspace == ColorSpace.CS_LINEAR_RGB)
+ return new ICC_ProfileRGB(cspace);
+ if (cspace == ColorSpace.CS_GRAY)
+ return new ICC_ProfileGray(cspace);
+ return new ICC_Profile(cspace);
+ }
+
+ /**
+ * Returns an ICC_Profile instance from an ICC Profile file.
+ *
+ * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
+ * may be returned if appropriate.
+ *
+ * @param filename - the file name of the profile file.
+ * @return An ICC_Profile object
+ *
+ * @throws IllegalArgumentException if the profile data is an invalid
+ * v2 profile.
+ * @throws IOException if the file could not be read.
+ */
+ public static ICC_Profile getInstance(String filename)
+ throws IOException
+ {
+ return getInstance(new FileInputStream(filename));
+ }
+
+ /**
+ * Returns an ICC_Profile instance from an InputStream.
+ *
+ * This method can be used for reading ICC profiles embedded in files
+ * which support this. (JPEG and SVG for instance).
+ *
+ * The stream is treated in the following way: The profile header
+ * (128 bytes) is read first, and the header is validated. If the profile
+ * header is valid, it will then attempt to read the rest of the profile
+ * from the stream. The stream is not closed after reading.
+ *
+ * An instance of the specialized classes ICC_ProfileRGB or ICC_ProfileGray
+ * may be returned if appropriate.
+ *
+ * @param in - the input stream to read the profile from.
+ * @return An ICC_Profile object
+ *
+ * @throws IllegalArgumentException if the profile data is an invalid
+ * v2 profile.
+ * @throws IOException if the stream could not be read.
+ */
+ public static ICC_Profile getInstance(InputStream in)
+ throws IOException
+ {
+ // read the header
+ byte[] headerData = new byte[ProfileHeader.HEADERSIZE];
+ if (in.read(headerData) != ProfileHeader.HEADERSIZE)
+ throw new IllegalArgumentException("Invalid profile header");
+
+ ProfileHeader header = new ProfileHeader(headerData);
+
+ // verify it as a correct ICC header, but do not verify the
+ // size as we are reading from a stream.
+ header.verifyHeader(-1);
+
+ // get the size
+ byte[] data = new byte[header.getSize()];
+ System.arraycopy(headerData, 0, data, 0, ProfileHeader.HEADERSIZE);
+
+ // read the rest
+ if (in.read(data, ProfileHeader.HEADERSIZE,
+ header.getSize() - ProfileHeader.HEADERSIZE) != header.getSize()
+ - ProfileHeader.HEADERSIZE)
+ throw new IOException("Incorrect profile size");
+
+ return getInstance(data);
+ }
+
+ /**
+ * Returns the major version number
+ */
+ public int getMajorVersion()
+ {
+ return header.getMajorVersion();
+ }
+
+ /**
+ * Returns the minor version number.
+ *
+ * Only the least-significant byte contains data, in BCD form:
+ * the least-significant nibble is the BCD bug fix revision,
+ * the most-significant nibble is the BCD minor revision number.
+ *
+ * (E.g. For a v2.1.0 profile this will return <code>0x10</code>)
+ */
+ public int getMinorVersion()
+ {
+ return header.getMinorVersion();
+ }
+
+ /**
+ * Returns the device class of this profile,
+ *
+ * (E.g. CLASS_INPUT for a scanner profile,
+ * CLASS_OUTPUT for a printer)
+ */
+ public int getProfileClass()
+ {
+ return header.getProfileClass();
+ }
+
+ /**
+ * Returns the color space of this profile, in terms
+ * of the color space constants defined in ColorSpace.
+ * (For example, it may be a ColorSpace.TYPE_RGB)
+ */
+ public int getColorSpaceType()
+ {
+ return header.getColorSpace();
+ }
+
+ /**
+ * Returns the color space of this profile's Profile Connection Space (OCS)
+ *
+ * In terms of the color space constants defined in ColorSpace.
+ * This may be TYPE_XYZ or TYPE_Lab
+ */
+ public int getPCSType()
+ {
+ return header.getProfileColorSpace();
+ }
+
+ /**
+ * Writes the profile data to an ICC profile file.
+ * @param filename - The name of the file to write
+ * @throws IOException if the write failed.
+ */
+ public void write(String filename) throws IOException
+ {
+ FileOutputStream out = new FileOutputStream(filename);
+ write(out);
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * Writes the profile data in ICC profile file-format to a stream.
+ * This is useful for embedding ICC profiles in file formats which
+ * support this (such as JPEG and SVG).
+ *
+ * The stream is not closed after writing.
+ * @param out - The outputstream to which the profile data should be written
+ * @throws IOException if the write failed.
+ */
+ public void write(OutputStream out) throws IOException
+ {
+ out.write(getData());
+ }
+
+ /**
+ * Returns the data corresponding to this ICC_Profile as a byte array.
+ *
+ * @return The data in a byte array,
+ * where the first element corresponds to first byte of the profile file.
+ */
+ public byte[] getData()
+ {
+ int size = getSize();
+ byte[] data = new byte[size];
+
+ // Header
+ System.arraycopy(header.getData(size), 0, data, 0, ProfileHeader.HEADERSIZE);
+ // # of tags
+ byte[] tt = getTagTable();
+ System.arraycopy(tt, 0, data, ProfileHeader.HEADERSIZE, tt.length);
+
+ Enumeration e = tagTable.elements();
+ while (e.hasMoreElements())
+ {
+ TagEntry tag = (TagEntry) e.nextElement();
+ System.arraycopy(tag.getData(), 0,
+ data, tag.getOffset(), tag.getSize());
+ }
+ return data;
+ }
+
+ /**
+ * Returns the ICC profile tag data
+ * The non ICC-tag icSigHead is also permitted to request the header data.
+ *
+ * @param tagSignature The ICC signature of the requested tag
+ * @return A byte array containing the tag data
+ */
+ public byte[] getData(int tagSignature)
+ {
+ if (tagSignature == icSigHead)
+ return header.getData(getSize());
+
+ TagEntry t = (TagEntry) tagTable.get(TagEntry.tagHashKey(tagSignature));
+ if (t == null)
+ return null;
+ return t.getData();
+ }
+
+ /**
+ * Sets the ICC profile tag data.
+ *
+ * Note that an ICC profile can only contain one tag of each type, if
+ * a tag already exists with the given signature, it is replaced.
+ *
+ * @param tagSignature - The signature of the tag to set
+ * @param data - A byte array containing the tag data
+ */
+ public void setData(int tagSignature, byte[] data)
+ {
+ profileID = -1; // Not a predefined color space if modified.
+
+ if (tagSignature == icSigHead)
+ header = new ProfileHeader(data);
+ else
+ {
+ TagEntry t = new TagEntry(tagSignature, data);
+ tagTable.put(t.hashKey(), t);
+ }
+ }
+
+ /**
+ * Get the number of components in the profile's device color space.
+ */
+ public int getNumComponents()
+ {
+ int[] lookup =
+ {
+ ColorSpace.TYPE_RGB, 3, ColorSpace.TYPE_CMY, 3,
+ ColorSpace.TYPE_CMYK, 4, ColorSpace.TYPE_GRAY, 1,
+ ColorSpace.TYPE_YCbCr, 3, ColorSpace.TYPE_XYZ, 3,
+ ColorSpace.TYPE_Lab, 3, ColorSpace.TYPE_HSV, 3,
+ ColorSpace.TYPE_2CLR, 2, ColorSpace.TYPE_Luv, 3,
+ ColorSpace.TYPE_Yxy, 3, ColorSpace.TYPE_HLS, 3,
+ ColorSpace.TYPE_3CLR, 3, ColorSpace.TYPE_4CLR, 4,
+ ColorSpace.TYPE_5CLR, 5, ColorSpace.TYPE_6CLR, 6,
+ ColorSpace.TYPE_7CLR, 7, ColorSpace.TYPE_8CLR, 8,
+ ColorSpace.TYPE_9CLR, 9, ColorSpace.TYPE_ACLR, 10,
+ ColorSpace.TYPE_BCLR, 11, ColorSpace.TYPE_CCLR, 12,
+ ColorSpace.TYPE_DCLR, 13, ColorSpace.TYPE_ECLR, 14,
+ ColorSpace.TYPE_FCLR, 15
+ };
+ for (int i = 0; i < lookup.length; i += 2)
+ if (header.getColorSpace() == lookup[i])
+ return lookup[i + 1];
+ return 3; // should never happen.
+ }
+
+ /**
+ * After deserializing we must determine if the class we want
+ * is really one of the more specialized ICC_ProfileRGB or
+ * ICC_ProfileGray classes.
+ */
+ protected Object readResolve() throws ObjectStreamException
+ {
+ if (isRGBProfile(header, tagTable))
+ return new ICC_ProfileRGB(getData());
+ if (isGrayProfile(header, tagTable))
+ return new ICC_ProfileGray(getData());
+ return this;
+ }
+
+ /**
+ * Deserializes an instance
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException
+ {
+ s.defaultReadObject();
+ String predef = (String) s.readObject();
+ byte[] data = (byte[]) s.readObject();
+
+ if (data != null)
+ {
+ header = new ProfileHeader(data);
+ tagTable = createTagTable(data);
+ profileID = -1; // Not a predefined color space
+ }
+
+ if (predef != null)
+ {
+ predef = predef.intern();
+ if (predef.equals("CS_sRGB"))
+ createProfile(ColorSpace.CS_sRGB);
+ if (predef.equals("CS_LINEAR_RGB"))
+ createProfile(ColorSpace.CS_LINEAR_RGB);
+ if (predef.equals("CS_CIEXYZ"))
+ createProfile(ColorSpace.CS_CIEXYZ);
+ if (predef.equals("CS_GRAY"))
+ createProfile(ColorSpace.CS_GRAY);
+ if (predef.equals("CS_PYCC"))
+ createProfile(ColorSpace.CS_PYCC);
+ }
+ }
+
+ /**
+ * Serializes an instance
+ * The format is a String and a byte array,
+ * The string is non-null if the instance is one of the built-in profiles.
+ * Otherwise the byte array is non-null and represents the profile data.
+ */
+ private void writeObject(ObjectOutputStream s) throws IOException
+ {
+ s.defaultWriteObject();
+ if (profileID == ColorSpace.CS_sRGB)
+ s.writeObject("CS_sRGB");
+ else if (profileID == ColorSpace.CS_LINEAR_RGB)
+ s.writeObject("CS_LINEAR_RGB");
+ else if (profileID == ColorSpace.CS_CIEXYZ)
+ s.writeObject("CS_CIEXYZ");
+ else if (profileID == ColorSpace.CS_GRAY)
+ s.writeObject("CS_GRAY");
+ else if (profileID == ColorSpace.CS_PYCC)
+ s.writeObject("CS_PYCC");
+ else
+ {
+ s.writeObject(null); // null string
+ s.writeObject(getData()); // data
+ return;
+ }
+ s.writeObject(null); // null data
+ }
+
+ /**
+ * Sorts a ICC profile byte array into TagEntry objects stored in
+ * a hash table.
+ */
+ private static Hashtable createTagTable(byte[] data)
+ throws IllegalArgumentException
+ {
+ ByteBuffer buf = ByteBuffer.wrap(data);
+ int nTags = buf.getInt(tagTableOffset);
+
+ Hashtable tagTable = new Hashtable();
+ for (int i = 0; i < nTags; i++)
+ {
+ TagEntry te = new TagEntry(buf.getInt(tagTableOffset
+ + i * TagEntry.entrySize + 4),
+ buf.getInt(tagTableOffset
+ + i * TagEntry.entrySize + 8),
+ buf.getInt(tagTableOffset
+ + i * TagEntry.entrySize + 12),
+ data);
+
+ if (tagTable.put(te.hashKey(), te) != null)
+ throw new IllegalArgumentException("Duplicate tag in profile:" + te);
+ }
+ return tagTable;
+ }
+
+ /**
+ * Returns the total size of the padded, stored data
+ * Note: Tags must be stored on 4-byte aligned offsets.
+ */
+ private int getSize()
+ {
+ int totalSize = ProfileHeader.HEADERSIZE; // size of header
+
+ int tagTableSize = 4 + tagTable.size() * TagEntry.entrySize; // size of tag table
+ if ((tagTableSize & 0x0003) != 0)
+ tagTableSize += 4 - (tagTableSize & 0x0003); // pad
+ totalSize += tagTableSize;
+
+ Enumeration e = tagTable.elements();
+ while (e.hasMoreElements())
+ { // tag data
+ int tagSize = ((TagEntry) e.nextElement()).getSize();
+ if ((tagSize & 0x0003) != 0)
+ tagSize += 4 - (tagSize & 0x0003); // pad
+ totalSize += tagSize;
+ }
+ return totalSize;
+ }
+
+ /**
+ * Generates the tag index table
+ */
+ private byte[] getTagTable()
+ {
+ int tagTableSize = 4 + tagTable.size() * TagEntry.entrySize;
+ if ((tagTableSize & 0x0003) != 0)
+ tagTableSize += 4 - (tagTableSize & 0x0003); // pad
+
+ int offset = 4;
+ int tagOffset = ProfileHeader.HEADERSIZE + tagTableSize;
+ ByteBuffer buf = ByteBuffer.allocate(tagTableSize);
+ buf.putInt(tagTable.size()); // number of tags
+
+ Enumeration e = tagTable.elements();
+ while (e.hasMoreElements())
+ {
+ TagEntry tag = (TagEntry) e.nextElement();
+ buf.putInt(offset, tag.getSignature());
+ buf.putInt(offset + 4, tagOffset);
+ buf.putInt(offset + 8, tag.getSize());
+ tag.setOffset(tagOffset);
+ int tagSize = tag.getSize();
+ if ((tagSize & 0x0003) != 0)
+ tagSize += 4 - (tagSize & 0x0003); // pad
+ tagOffset += tagSize;
+ offset += 12;
+ }
+ return buf.array();
+ }
+
+ /**
+ * Returns if the criteria for an ICC_ProfileRGB are met.
+ * This means:
+ * Color space is TYPE_RGB
+ * (r,g,b)ColorantTags included
+ * (r,g,b)TRCTags included
+ * mediaWhitePointTag included
+ */
+ private static boolean isRGBProfile(ProfileHeader header, Hashtable tags)
+ {
+ if (header.getColorSpace() != ColorSpace.TYPE_RGB)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigRedColorantTag)) == null)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigGreenColorantTag)) == null)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigBlueColorantTag)) == null)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigRedTRCTag)) == null)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigGreenTRCTag)) == null)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigBlueTRCTag)) == null)
+ return false;
+ return (tags.get(TagEntry.tagHashKey(icSigMediaWhitePointTag)) != null);
+ }
+
+ /**
+ * Returns if the criteria for an ICC_ProfileGray are met.
+ * This means:
+ * Colorspace is TYPE_GRAY
+ * grayTRCTag included
+ * mediaWhitePointTag included
+ */
+ private static boolean isGrayProfile(ProfileHeader header, Hashtable tags)
+ {
+ if (header.getColorSpace() != ColorSpace.TYPE_GRAY)
+ return false;
+ if (tags.get(TagEntry.tagHashKey(icSigGrayTRCTag)) == null)
+ return false;
+ return (tags.get(TagEntry.tagHashKey(icSigMediaWhitePointTag)) != null);
+ }
+
+ /**
+ * Returns curve data for a 'curv'-type tag
+ * If it's a gamma curve, a single entry will be returned with the
+ * gamma value (including 1.0 for linear response)
+ * Otherwise the TRC table is returned.
+ *
+ * (Package private - used by ICC_ProfileRGB and ICC_ProfileGray)
+ */
+ short[] getCurve(int signature)
+ {
+ byte[] data = getData(signature);
+ short[] curve;
+
+ // can't find tag?
+ if (data == null)
+ return null;
+
+ // not an curve type tag?
+ ByteBuffer buf = ByteBuffer.wrap(data);
+ if (buf.getInt(0) != 0x63757276) // 'curv' type
+ return null;
+ int count = buf.getInt(8);
+ if (count == 0)
+ {
+ curve = new short[1];
+ curve[0] = 0x0100; // 1.00 in u8fixed8
+ return curve;
+ }
+ if (count == 1)
+ {
+ curve = new short[1];
+ curve[0] = buf.getShort(12); // other u8fixed8 gamma
+ return curve;
+ }
+ curve = new short[count];
+ for (int i = 0; i < count; i++)
+ curve[i] = buf.getShort(12 + i * 2);
+ return curve;
+ }
+
+ /**
+ * Returns XYZ tristimulus values for an 'XYZ ' type tag
+ * @return the XYZ values, or null if the tag was not an 'XYZ ' type tag.
+ *
+ * (Package private - used by ICC_ProfileXYZ and ICC_ProfileGray)
+ */
+ float[] getXYZData(int signature)
+ {
+ byte[] data = getData(signature);
+
+ // can't find tag?
+ if (data == null)
+ return null;
+
+ // not an XYZData type tag?
+ ByteBuffer buf = ByteBuffer.wrap(data);
+ if (buf.getInt(0) != icSigXYZData) // 'XYZ ' type
+ return null;
+
+ float[] point = new float[3];
+
+ // get the X,Y,Z tristimulus values
+ point[0] = ((float) buf.getInt(8)) / 65536f;
+ point[1] = ((float) buf.getInt(12)) / 65536f;
+ point[2] = ((float) buf.getInt(16)) / 65536f;
+ return point;
+ }
+
+ /**
+ * Returns the profile ID if it's a predefined profile
+ * Or -1 for a profile loaded from an ICC profile
+ *
+ * (Package private - used by ICC_ColorSpace)
+ */
+ int isPredefined()
+ {
+ return profileID;
+ }
+
+ /**
+ * Creates a tag of XYZ-value type.
+ */
+ private byte[] makeXYZData(float[] values)
+ {
+ ByteBuffer buf = ByteBuffer.allocate(20);
+ buf.putInt(0, icSigXYZData); // 'XYZ '
+ buf.putInt(4, 0);
+ buf.putInt(8, (int) (values[0] * 65536.0));
+ buf.putInt(12, (int) (values[1] * 65536.0));
+ buf.putInt(16, (int) (values[2] * 65536.0));
+ return buf.array();
+ }
+
+ /**
+ * Creates a tag of text type
+ */
+ private byte[] makeTextTag(String text)
+ {
+ int length = text.length();
+ ByteBuffer buf = ByteBuffer.allocate(8 + length + 1);
+ byte[] data;
+ try
+ {
+ data = text.getBytes("US-ASCII");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ data = new byte[length]; // shouldn't happen
+ }
+
+ buf.putInt(0, (int) 0x74657874); // 'text'
+ buf.putInt(4, 0);
+ for (int i = 0; i < length; i++)
+ buf.put(8 + i, data[i]);
+ buf.put(8 + length, (byte) 0); // null-terminate
+ return buf.array();
+ }
+
+ /**
+ * Creates a tag of textDescriptionType
+ */
+ private byte[] makeDescTag(String text)
+ {
+ int length = text.length();
+ ByteBuffer buf = ByteBuffer.allocate(90 + length + 1);
+ buf.putInt(0, (int) 0x64657363); // 'desc'
+ buf.putInt(4, 0); // reserved
+ buf.putInt(8, length + 1); // ASCII length, including null termination
+ byte[] data;
+
+ try
+ {
+ data = text.getBytes("US-ASCII");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ data = new byte[length]; // shouldn't happen
+ }
+
+ for (int i = 0; i < length; i++)
+ buf.put(12 + i, data[i]);
+ buf.put(12 + length, (byte) 0); // null-terminate
+
+ for (int i = 0; i < 39; i++)
+ buf.putShort(13 + length + (i * 2), (short) 0); // 78 bytes we can ignore
+
+ return buf.array();
+ }
+
+ /**
+ * Creates a tag of TRC type (linear curve)
+ */
+ private byte[] makeTRC()
+ {
+ ByteBuffer buf = ByteBuffer.allocate(12);
+ buf.putInt(0, 0x63757276); // 'curv' type
+ buf.putInt(4, 0); // reserved
+ buf.putInt(8, 0);
+ return buf.array();
+ }
+
+ /**
+ * Creates a tag of TRC type (single gamma value)
+ */
+ private byte[] makeTRC(float gamma)
+ {
+ short gammaValue = (short) (gamma * 256f);
+ ByteBuffer buf = ByteBuffer.allocate(14);
+ buf.putInt(0, 0x63757276); // 'curv' type
+ buf.putInt(4, 0); // reserved
+ buf.putInt(8, 1);
+ buf.putShort(12, gammaValue); // 1.00 in u8fixed8
+ return buf.array();
+ }
+
+ /**
+ * Creates a tag of TRC type (TRC curve points)
+ */
+ private byte[] makeTRC(float[] trc)
+ {
+ ByteBuffer buf = ByteBuffer.allocate(12 + 2 * trc.length);
+ buf.putInt(0, 0x63757276); // 'curv' type
+ buf.putInt(4, 0); // reserved
+ buf.putInt(8, trc.length); // number of points
+
+ // put the curve values
+ for (int i = 0; i < trc.length; i++)
+ buf.putShort(12 + i * 2, (short) (trc[i] * 65535f));
+
+ return buf.array();
+ }
+
+ /**
+ * Creates an identity color lookup table.
+ */
+ private byte[] makeIdentityClut()
+ {
+ final int nIn = 3;
+ final int nOut = 3;
+ final int nInEntries = 256;
+ final int nOutEntries = 256;
+ final int gridpoints = 16;
+
+ // gridpoints**nIn
+ final int clutSize = 2 * nOut * gridpoints * gridpoints * gridpoints;
+ final int totalSize = clutSize + 2 * nInEntries * nIn
+ + 2 * nOutEntries * nOut + 52;
+
+ ByteBuffer buf = ByteBuffer.allocate(totalSize);
+ buf.putInt(0, 0x6D667432); // 'mft2'
+ buf.putInt(4, 0); // reserved
+ buf.put(8, (byte) nIn); // number input channels
+ buf.put(9, (byte) nOut); // number output channels
+ buf.put(10, (byte) gridpoints); // number gridpoints
+ buf.put(11, (byte) 0); // padding
+
+ // identity matrix
+ buf.putInt(12, 65536); // = 1 in s15.16 fixed point
+ buf.putInt(16, 0);
+ buf.putInt(20, 0);
+ buf.putInt(24, 0);
+ buf.putInt(28, 65536);
+ buf.putInt(32, 0);
+ buf.putInt(36, 0);
+ buf.putInt(40, 0);
+ buf.putInt(44, 65536);
+
+ buf.putShort(48, (short) nInEntries); // input table entries
+ buf.putShort(50, (short) nOutEntries); // output table entries
+
+ // write the linear input channels, unsigned 16.16 fixed point,
+ // from 0.0 to FF.FF
+ for (int channel = 0; channel < 3; channel++)
+ for (int i = 0; i < nInEntries; i++)
+ {
+ short n = (short) ((i << 8) | i); // assumes 256 entries
+ buf.putShort(52 + (channel * nInEntries + i) * 2, n);
+ }
+ int clutOffset = 52 + nInEntries * nIn * 2;
+
+ for (int x = 0; x < gridpoints; x++)
+ for (int y = 0; y < gridpoints; y++)
+ for (int z = 0; z < gridpoints; z++)
+ {
+ int offset = clutOffset + z * 2 * nOut + y * gridpoints * 2 * nOut
+ + x * gridpoints * gridpoints * 2 * nOut;
+ double xf = ((double) x) / ((double) gridpoints - 1.0);
+ double yf = ((double) y) / ((double) gridpoints - 1.0);
+ double zf = ((double) z) / ((double) gridpoints - 1.0);
+ buf.putShort(offset, (short) (xf * 65535.0));
+ buf.putShort(offset + 2, (short) (yf * 65535.0));
+ buf.putShort(offset + 4, (short) (zf * 65535.0));
+ }
+
+ for (int channel = 0; channel < 3; channel++)
+ for (int i = 0; i < nOutEntries; i++)
+ {
+ short n = (short) ((i << 8) | i); // assumes 256 entries
+ buf.putShort(clutOffset + clutSize + (channel * nOutEntries + i) * 2,
+ n);
+ }
+
+ return buf.array();
+ }
+
+ /**
+ * Creates profile data corresponding to the built-in colorspaces.
+ */
+ private void createProfile(int colorSpace) throws IllegalArgumentException
+ {
+ this.profileID = colorSpace;
+ header = new ProfileHeader();
+ tagTable = new Hashtable();
+
+ switch (colorSpace)
+ {
+ case ColorSpace.CS_sRGB:
+ createRGBProfile();
+ return;
+ case ColorSpace.CS_LINEAR_RGB:
+ createLinearRGBProfile();
+ return;
+ case ColorSpace.CS_CIEXYZ:
+ createCIEProfile();
+ return;
+ case ColorSpace.CS_GRAY:
+ createGrayProfile();
+ return;
+ case ColorSpace.CS_PYCC:
+ createPyccProfile();
+ return;
+ default:
+ throw new IllegalArgumentException("Not a predefined color space!");
+ }
+ }
+
+ /**
+ * Creates an ICC_Profile representing the sRGB color space
+ */
+ private void createRGBProfile()
+ {
+ header.setColorSpace( ColorSpace.TYPE_RGB );
+ header.setProfileColorSpace( ColorSpace.TYPE_XYZ );
+ ICC_ColorSpace cs = new ICC_ColorSpace(this);
+
+ float[] r = { 1f, 0f, 0f };
+ float[] g = { 0f, 1f, 0f };
+ float[] b = { 0f, 0f, 1f };
+ float[] black = { 0f, 0f, 0f };
+
+ // CIE 1931 D50 white point (in Lab coordinates)
+ float[] white = D50;
+
+ // Get tristimulus values (matrix elements)
+ r = cs.toCIEXYZ(r);
+ g = cs.toCIEXYZ(g);
+ b = cs.toCIEXYZ(b);
+
+ // Generate the sRGB TRC curve, this is the linear->nonlinear
+ // RGB transform.
+ cs = new ICC_ColorSpace(getInstance(ICC_ColorSpace.CS_LINEAR_RGB));
+ float[] points = new float[TRC_POINTS];
+ float[] in = new float[3];
+ for (int i = 0; i < TRC_POINTS; i++)
+ {
+ in[0] = in[1] = in[2] = ((float) i) / ((float) TRC_POINTS - 1);
+ in = cs.fromRGB(in);
+ // Note this value is the same for all components.
+ points[i] = in[0];
+ }
+
+ setData(icSigRedColorantTag, makeXYZData(r));
+ setData(icSigGreenColorantTag, makeXYZData(g));
+ setData(icSigBlueColorantTag, makeXYZData(b));
+ setData(icSigMediaWhitePointTag, makeXYZData(white));
+ setData(icSigMediaBlackPointTag, makeXYZData(black));
+ setData(icSigRedTRCTag, makeTRC(points));
+ setData(icSigGreenTRCTag, makeTRC(points));
+ setData(icSigBlueTRCTag, makeTRC(points));
+ setData(icSigCopyrightTag, makeTextTag(copyrightNotice));
+ setData(icSigProfileDescriptionTag, makeDescTag("Generic sRGB"));
+ this.profileID = ColorSpace.CS_sRGB;
+ }
+
+ /**
+ * Creates an linear sRGB profile
+ */
+ private void createLinearRGBProfile()
+ {
+ header.setColorSpace(ColorSpace.TYPE_RGB);
+ header.setProfileColorSpace(ColorSpace.TYPE_XYZ);
+ ICC_ColorSpace cs = new ICC_ColorSpace(this);
+
+ float[] r = { 1f, 0f, 0f };
+ float[] g = { 0f, 1f, 0f };
+ float[] b = { 0f, 0f, 1f };
+ float[] black = { 0f, 0f, 0f };
+
+ float[] white = D50;
+
+ // Get tristimulus values (matrix elements)
+ r = cs.toCIEXYZ(r);
+ g = cs.toCIEXYZ(g);
+ b = cs.toCIEXYZ(b);
+
+ setData(icSigRedColorantTag, makeXYZData(r));
+ setData(icSigGreenColorantTag, makeXYZData(g));
+ setData(icSigBlueColorantTag, makeXYZData(b));
+
+ setData(icSigMediaWhitePointTag, makeXYZData(white));
+ setData(icSigMediaBlackPointTag, makeXYZData(black));
+
+ setData(icSigRedTRCTag, makeTRC());
+ setData(icSigGreenTRCTag, makeTRC());
+ setData(icSigBlueTRCTag, makeTRC());
+ setData(icSigCopyrightTag, makeTextTag(copyrightNotice));
+ setData(icSigProfileDescriptionTag, makeDescTag("Linear RGB"));
+ this.profileID = ColorSpace.CS_LINEAR_RGB;
+ }
+
+ /**
+ * Creates an CIE XYZ identity profile
+ */
+ private void createCIEProfile()
+ {
+ header.setColorSpace( ColorSpace.TYPE_XYZ );
+ header.setProfileColorSpace( ColorSpace.TYPE_XYZ );
+ header.setProfileClass( CLASS_COLORSPACECONVERSION );
+ ICC_ColorSpace cs = new ICC_ColorSpace(this);
+
+ float[] white = D50;
+
+ setData(icSigMediaWhitePointTag, makeXYZData(white));
+ setData(icSigAToB0Tag, makeIdentityClut());
+ setData(icSigBToA0Tag, makeIdentityClut());
+ setData(icSigCopyrightTag, makeTextTag(copyrightNotice));
+ setData(icSigProfileDescriptionTag, makeDescTag("CIE XYZ identity profile"));
+ this.profileID = ColorSpace.CS_CIEXYZ;
+ }
+
+ /**
+ * Creates a linear gray ICC_Profile
+ */
+ private void createGrayProfile()
+ {
+ header.setColorSpace(ColorSpace.TYPE_GRAY);
+ header.setProfileColorSpace(ColorSpace.TYPE_XYZ);
+
+ // CIE 1931 D50 white point (in Lab coordinates)
+ float[] white = D50;
+
+ setData(icSigMediaWhitePointTag, makeXYZData(white));
+ setData(icSigGrayTRCTag, makeTRC(1.0f));
+ setData(icSigCopyrightTag, makeTextTag(copyrightNotice));
+ setData(icSigProfileDescriptionTag, makeDescTag("Linear grayscale"));
+ this.profileID = ColorSpace.CS_GRAY;
+ }
+
+ /**
+ * XXX Implement me
+ */
+ private void createPyccProfile()
+ {
+ header.setColorSpace(ColorSpace.TYPE_3CLR);
+ header.setProfileColorSpace(ColorSpace.TYPE_XYZ);
+
+ // Create CLUTs here. :-)
+
+ setData(icSigCopyrightTag, makeTextTag(copyrightNotice));
+ setData(icSigProfileDescriptionTag, makeDescTag("Photo YCC"));
+ this.profileID = ColorSpace.CS_PYCC;
+ }
+} // class ICC_Profile
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileGray.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileGray.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileGray.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileGray.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,133 @@
+/* ICC_ProfileGray.java -- the ICC profile for a Gray colorspace
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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.color;
+
+/**
+ * ICC_ProfileGray - a special case of ICC_Profiles.
+ *
+ * The ICC_Profile.getInstance() method will return an instance of the
+ * ICC_ProfileGray subclass when all the following conditions are met:
+ * The device color space of the profile is TYPE_GRAY.
+ * The profile contains a gray TRCTag.
+ * The profile contains a mediaWhitePointTag.
+ *
+ * As per the ICC specification, the color space conversion can then
+ * be done through the following method:
+ * linearGray = grayTRC[deviceGray]
+ *
+ * Note that if the profile contains a CLUT for the color space conversion,
+ * it should be used instead, and the TRC information ignored.
+ *
+ * @author Sven de Marothy
+ * @since 1.2
+ */
+public class ICC_ProfileGray extends ICC_Profile
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -1124721290732002649L;
+ private transient float[] whitePoint;
+
+ /**
+ * Package-private constructor used by ICC_ColorSpace for creating an
+ * ICC_ProfileGray from a predefined ColorSpace (CS_GRAY)
+ */
+ ICC_ProfileGray(int cspace)
+ {
+ super(cspace);
+ whitePoint = getXYZData(icSigMediaWhitePointTag);
+ }
+
+ /**
+ * Package-private constructor used by ICC_ColorSpace for creating an
+ * ICC_ProfileGray from profile data.
+ */
+ ICC_ProfileGray(byte[] data)
+ {
+ super(data);
+ whitePoint = getXYZData(icSigMediaWhitePointTag);
+ }
+
+
+ /**
+ * Returns the media white point of the profile.
+ */
+ public float[] getMediaWhitePoint()
+ {
+ float[] wp = new float[3];
+ wp[0] = whitePoint[0];
+ wp[1] = whitePoint[1];
+ wp[2] = whitePoint[2];
+ return wp;
+ }
+
+ /**
+ * Returns the TRC gamma value.
+ * @throws ProfileDataException if the TRC is described by a lookup
+ * table and not a gamma value.
+ */
+ public float getGamma()
+ {
+ short[] data = getCurve(icSigGrayTRCTag);
+ if (data == null)
+ throw new IllegalArgumentException("Couldn't read Gray TRC data.");
+ if (data.length != 1)
+ throw new ProfileDataException("TRC is a table, not a gamma value.");
+
+ // convert the unsigned 7.8 fixed-point gamma to a float.
+ double gamma = (double) (data[0] & (0xFFFF)) / 256.0;
+ return (float) gamma;
+ }
+
+ /**
+ * Returns the TRC lookup table.
+ * @throws ProfileDataException if the TRC is described by a gamma value
+ * and not a lookup table.
+ */
+ public short[] getTRC()
+ {
+ short[] data = getCurve(icSigGrayTRCTag);
+ if (data == null)
+ throw new IllegalArgumentException("Couldn't read Gray TRC data.");
+ if (data.length <= 1)
+ throw new ProfileDataException("Gamma value, not a TRC table.");
+ return data;
+ }
+} // class ICC_ProfileGray
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileRGB.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileRGB.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileRGB.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ICC_ProfileRGB.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,227 @@
+/* ICC_ProfileRGB.java -- the ICC profile for a RGB colorspace
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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.color;
+
+/**
+ * ICC_ProfileRGB - a special case of ICC_Profiles.
+ *
+ * The ICC_Profile.getInstance() method will return an instance of the
+ * ICC_ProfileRGB subclass when all the following conditions are met:
+ * The device color space of the profile is TYPE_RGB.
+ * The profile contains red, green and blue ColorantTags.
+ * The profile contains red, green and blue TRCTags.
+ * The profile contains a mediaWhitePointTag included.
+ *
+ * As per the ICC specification, the color space conversion can then
+ * be done through the following method:
+ * linearR = redTRC[deviceR]
+ * linearG = greenTRC[deviceG]
+ * linearB = blueTRC[deviceB]
+ * TRC curves are either a single gamma value, or a 1-dimensional lookup table.
+ *
+ * Followed by the matrix transform:
+ * PCS = M*linear
+ *
+ * Where PCS is the vector of profile color space (must be XYZ) coordinates,
+ * linear is the vector of linear RGB coordinates, and the matrix M is
+ * constructed from the ColorantTags, where the columns are red, green and
+ * blue respectively, and the rows are X, Y and Z.
+ *
+ * Note that if the profile contains a CLUT for the color space conversion,
+ * it should be used instead, and the TRC information ignored.
+ *
+ * @author Sven de Marothy
+ * @since 1.2
+ */
+public class ICC_ProfileRGB extends ICC_Profile
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 8505067385152579334L;
+
+ public static final int REDCOMPONENT = 0;
+
+ public static final int GREENCOMPONENT = 1;
+
+ public static final int BLUECOMPONENT = 2;
+
+ private transient float[][] matrix;
+
+ private transient float[] gamma;
+
+ private transient float[] whitePoint;
+
+
+ /**
+ * Package-private constructor used by ICC_ColorSpace for creating an
+ * ICC_ProfileRGB from a predefined ColorSpace (CS_LINEAR_RGB and CS_sRGB)
+ */
+ ICC_ProfileRGB(int cspace)
+ {
+ super(cspace);
+ matrix = createMatrix();
+ whitePoint = getXYZData(icSigMediaWhitePointTag);
+ }
+
+ /**
+ * Package-private constructor used by ICC_ColorSpace for creating an
+ * ICC_ProfileRGB from profile data.
+ */
+ ICC_ProfileRGB(byte[] data)
+ {
+ super(data);
+ matrix = createMatrix();
+ whitePoint = getXYZData(icSigMediaWhitePointTag);
+ }
+
+ /**
+ * Returns the media white point of the profile.
+ */
+ public float[] getMediaWhitePoint()
+ {
+ float[] wp = new float[3];
+ wp[0] = whitePoint[0];
+ wp[1] = whitePoint[1];
+ wp[2] = whitePoint[2];
+ return wp;
+ }
+
+ /**
+ * Returns the colorant matrix of the conversion.
+ */
+ public float[][] getMatrix()
+ {
+ float[][] mat = new float[3][3];
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ mat[i][j] = matrix[i][j];
+ return mat;
+ }
+
+ /**
+ * Returns the gamma value of a component
+ * @throws ProfileDataException if the TRC is described by a lookup
+ * table and not a gamma value.
+ */
+ public float getGamma(int component)
+ {
+ short[] data;
+ switch (component)
+ {
+ case REDCOMPONENT:
+ data = getCurve(icSigRedTRCTag);
+ break;
+ case GREENCOMPONENT:
+ data = getCurve(icSigGreenTRCTag);
+ break;
+ case BLUECOMPONENT:
+ data = getCurve(icSigBlueTRCTag);
+ break;
+ default:
+ throw new IllegalArgumentException("Not a valid component");
+ }
+ if (data == null)
+ throw new IllegalArgumentException("Error reading TRC");
+
+ if (data.length != 1)
+ throw new ProfileDataException("Not a single-gamma TRC");
+
+ // convert the unsigned 7.8 fixed-point gamma to a float.
+ float gamma = (float) (((int) data[0] & 0xFF00) >> 8);
+ double fraction = ((int) data[0] & 0x00FF) / 256.0;
+ gamma += (float) fraction;
+ return gamma;
+ }
+
+ /**
+ * Returns the TRC lookup table for a component
+ * @throws ProfileDataException if the TRC is described by a gamma
+ * value and not a lookup table.
+ */
+ public short[] getTRC(int component)
+ {
+ short[] data;
+ switch (component)
+ {
+ case REDCOMPONENT:
+ data = getCurve(icSigRedTRCTag);
+ break;
+ case GREENCOMPONENT:
+ data = getCurve(icSigGreenTRCTag);
+ break;
+ case BLUECOMPONENT:
+ data = getCurve(icSigBlueTRCTag);
+ break;
+ default:
+ throw new IllegalArgumentException("Not a valid component");
+ }
+ if (data == null)
+ throw new IllegalArgumentException("Error reading TRC");
+
+ if (data.length <= 1)
+ throw new ProfileDataException("Gamma value, not a TRC table.");
+
+ return data;
+ }
+
+ /**
+ * Creates the colorspace conversion matrix from the RGB tristimulus
+ * values.
+ */
+ private float[][] createMatrix() throws IllegalArgumentException
+ {
+ float[][] mat = new float[3][3];
+ float[] r;
+ float[] g;
+ float[] b;
+ r = getXYZData(icSigRedColorantTag);
+ g = getXYZData(icSigGreenColorantTag);
+ b = getXYZData(icSigBlueColorantTag);
+ if (r == null || g == null || b == null)
+ throw new IllegalArgumentException("Error reading colorant tags!");
+ for (int i = 0; i < 3; i++)
+ {
+ mat[i][0] = r[i];
+ mat[i][1] = g[i];
+ mat[i][2] = b[i];
+ }
+ return mat;
+ }
+} // class ICC_ProfileRGB
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ProfileDataException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ProfileDataException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ProfileDataException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/ProfileDataException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* ProfileDataException.java -- error in processing an ICC_Profile
+ Copyright (C) 2002, 2005 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.color;
+
+/**
+ * Thrown when there is an error accessing or processing an
+ * <code>ICC_Profile</code>.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @status updated to 1.4
+ */
+public class ProfileDataException extends RuntimeException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 7286140888240322498L;
+
+ /**
+ * Create a new instance with a specified detailed error message.
+ *
+ * @param message the message
+ */
+ public ProfileDataException(String message)
+ {
+ super(message);
+ }
+} // class ProfileDataException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/color/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.color package.
+ Copyright (C) 2002 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.color</title></head>
+
+<body>
+<p>Classes to represent color spaces and profiles.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Clipboard.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Clipboard.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Clipboard.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Clipboard.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,213 @@
+/* Clipboard.java -- Class for transferring data via cut and paste.
+ Copyright (C) 1999, 2001, 2005, 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.datatransfer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * This class allows data to be transferred using a cut and paste type
+ * mechanism.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @author Mark J. Wielaard (mark at klomp.org)
+ */
+public class Clipboard
+{
+ /**
+ * The data currently on this clipboard. For use by
+ * subclasses. Also returned by the public method getContents().
+ */
+ protected Transferable contents;
+
+ /**
+ * The owner of this clipboard.
+ */
+ protected ClipboardOwner owner;
+
+ // The clipboard name
+ private final String name;
+
+ // The flavor listeners (most likely small).
+ private final ArrayList listeners = new ArrayList(3);
+
+ /**
+ * Initializes a new instance of <code>Clipboard</code> with the
+ * specified name.
+ *
+ * @param name The clipboard name.
+ */
+ public Clipboard(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Returns the name of the clipboard.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Returns the contents of the clipboard.
+ *
+ * @param requestor The object requesting the contents. This
+ * implementation ignores this parameter.
+ *
+ * @exception IllegalStateException If the clipboard is currently unavailable
+ */
+ public synchronized Transferable getContents(Object requestor)
+ {
+ return contents;
+ }
+
+ /**
+ * Sets the content and owner of this clipboard. If the given owner
+ * is different from the current owner then <code>lostOwnership()</code>
+ * is called on the current owner with the old contents of the given
+ * clipboard.
+ *
+ * @param contents The new clipboard contents.
+ * @param owner The new clipboard owner
+ *
+ * @exception IllegalStateException If the clipboard is currently unavailable
+ */
+ public synchronized void setContents(Transferable contents,
+ ClipboardOwner owner)
+ {
+ Transferable oldContents = getContents(null);
+ this.contents = contents;
+ if (this.owner != owner)
+ {
+ ClipboardOwner oldOwner = this.owner;
+ this.owner = owner;
+ if (oldOwner != null)
+ oldOwner.lostOwnership(this, oldContents);
+ }
+
+ FlavorListener[] fs = getFlavorListeners();
+ if (fs.length > 0)
+ {
+ // We are a bit optimistic here. We assume DataFlavors will be
+ // given in the same order. If the number of flavors is
+ // different or the order of the DataFlavors in the list then
+ // fire a change event.
+ boolean newFlavors = ((contents != null && oldContents == null)
+ || (contents == null && oldContents != null));
+ if (!newFlavors && contents != null && oldContents != null)
+ {
+ DataFlavor[] df1 = contents.getTransferDataFlavors();
+ DataFlavor[] df2 = oldContents.getTransferDataFlavors();
+ newFlavors = df1.length != df2.length;
+
+ for (int i = 0; !newFlavors && i < df1.length; i++)
+ newFlavors = !df1[i].equals(df2[i]);
+ }
+
+ if (newFlavors)
+ {
+ FlavorEvent e = new FlavorEvent(this);
+ for (int i = 0; i < fs.length; i++)
+ fs[i].flavorsChanged(e);
+ }
+ }
+ }
+
+ public DataFlavor[] getAvailableDataFlavors()
+ {
+ Transferable c = getContents(null);
+ if (c == null)
+ return new DataFlavor[0];
+ else
+ return c.getTransferDataFlavors();
+ }
+
+ public boolean isDataFlavorAvailable(DataFlavor flavor)
+ {
+ DataFlavor[] fs = getAvailableDataFlavors();
+ for (int i = 0; i < fs.length; i++)
+ if (flavor.equals(fs[i]))
+ return true;
+
+ return false;
+ }
+
+ public Object getData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException
+ {
+ Transferable c = getContents(null);
+ if (c == null)
+ throw new UnsupportedFlavorException(flavor);
+ else
+ return c.getTransferData(flavor);
+ }
+
+ public void addFlavorListener(FlavorListener listener)
+ {
+ if (listener == null)
+ return;
+
+ synchronized(listeners)
+ {
+ listeners.add(listener);
+ }
+ }
+
+ public void removeFlavorListener(FlavorListener listener)
+ {
+ if (listener == null)
+ return;
+
+ synchronized(listeners)
+ {
+ listeners.remove(listener);
+ }
+ }
+
+ public FlavorListener[] getFlavorListeners()
+ {
+ synchronized(listeners)
+ {
+ return (FlavorListener[])
+ listeners.toArray(new FlavorListener[listeners.size()]);
+ }
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/ClipboardOwner.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* ClipboardOwner.java -- Interface for clipboard providers
+ Copyright (C) 1999 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.datatransfer;
+
+/**
+ * This interface is for classes that will own a clipboard object.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface ClipboardOwner
+{
+ /**
+ * This method is called to notify this object that it no longer
+ * has ownership of the specified <code>Clipboard</code>.
+ *
+ * @param clipboard The clipboard for which ownership was lost.
+ * @param contents The contents of the clipboard which are no longer owned.
+ */
+ void lostOwnership (Clipboard clipboard, Transferable contents);
+}
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/DataFlavor.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/DataFlavor.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/DataFlavor.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/DataFlavor.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,1018 @@
+/* DataFlavor.java -- A type of data to transfer via the clipboard.
+ Copyright (C) 1999, 2001, 2004, 2005, 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.datatransfer;
+
+import gnu.classpath.NotImplementedException;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.rmi.Remote;
+
+/**
+ * This class represents a particular data format used for transferring
+ * data via the clipboard.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class DataFlavor implements java.io.Externalizable, Cloneable
+{
+ static final long serialVersionUID = 8367026044764648243L;
+
+ // FIXME: Serialization: Need to write methods for.
+
+ /**
+ * This is the data flavor used for tranferring plain text. The MIME
+ * type is "text/plain; charset=unicode". The representation class
+ * is <code>java.io.InputStream</code>.
+ *
+ * @deprecated The charset unicode is platform specific and InputStream
+ * deals with bytes not chars. Use <code>getRederForText()</code>.
+ */
+ public static final DataFlavor plainTextFlavor =
+ new DataFlavor(java.io.InputStream.class,
+ "text/plain; charset=unicode",
+ "plain unicode text");
+
+ /**
+ * This is the data flavor used for transferring Java strings. The
+ * MIME type is "application/x-java-serialized-object" and the
+ * representation class is <code>java.lang.String</code>.
+ */
+ public static final DataFlavor stringFlavor =
+ new DataFlavor(java.lang.String.class, "Java Unicode String");
+
+ /**
+ * This is a data flavor used for transferring lists of files. The
+ * representation type is a <code>java.util.List</code>, with each
+ * element of the list being a <code>java.io.File</code>.
+ */
+ public static final DataFlavor javaFileListFlavor =
+ new DataFlavor(java.util.List.class,
+ "application/x-java-file-list; class=java.util.List",
+ "Java File List");
+
+ /**
+ * This is an image flavor used for transferring images. The
+ * representation type is a <code>java.awt.Image</code>.
+ */
+ public static final DataFlavor imageFlavor =
+ new DataFlavor(java.awt.Image.class, "Java Image");
+
+ /**
+ * This is the MIME type used for transferring a serialized object.
+ * The representation class is the type of object be deserialized.
+ */
+ public static final String javaSerializedObjectMimeType =
+ "application/x-java-serialized-object";
+
+ /**
+ * This is the MIME type used to transfer a Java object reference within
+ * the same JVM. The representation class is the class of the object
+ * being transferred.
+ */
+ public static final String javaJVMLocalObjectMimeType =
+ "application/x-java-jvm-local-objectref";
+
+ /**
+ * This is the MIME type used to transfer a link to a remote object.
+ * The representation class is the type of object being linked to.
+ */
+ public static final String javaRemoteObjectMimeType =
+ "application/x-java-remote-object";
+
+ /*
+ * Instance Variables
+ */
+
+ // The MIME type for this flavor
+ private final String mimeType;
+
+ // The representation class for this flavor
+ private final Class representationClass;
+
+ // The human readable name of this flavor
+ private String humanPresentableName;
+
+ /*
+ * Static Methods
+ */
+
+ /**
+ * This method attempts to load the named class. The following class
+ * loaders are searched in order: the bootstrap class loader, the
+ * system class loader, the context class loader (if it exists), and
+ * the specified fallback class loader.
+ *
+ * @param className The name of the class to load.
+ * @param classLoader The class loader to use if all others fail, which
+ * may be <code>null</code>.
+ *
+ * @exception ClassNotFoundException If the class cannot be loaded.
+ */
+ protected static final Class tryToLoadClass(String className,
+ ClassLoader classLoader)
+ throws ClassNotFoundException
+ {
+ // Bootstrap
+ try
+ {
+ return Class.forName(className);
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ // Ignored.
+ }
+
+ // System
+ try
+ {
+ ClassLoader loader = ClassLoader.getSystemClassLoader();
+ return Class.forName(className, true, loader);
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ // Ignored.
+ }
+
+ // Context
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return Class.forName(className, true, loader);
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ // Ignored.
+ }
+
+ if (classLoader != null)
+ return Class.forName(className, true, classLoader);
+
+ throw new ClassNotFoundException(className);
+ }
+
+ private static Class getRepresentationClassFromMimeThrows(String mimeString,
+ ClassLoader classLoader)
+ throws ClassNotFoundException
+ {
+ String classname = getParameter("class", mimeString);
+ if (classname != null)
+ return tryToLoadClass(classname, classLoader);
+ else
+ return java.io.InputStream.class;
+ }
+
+ // Same as above, but wraps any ClassNotFoundExceptions
+ private static Class getRepresentationClassFromMime(String mimeString,
+ ClassLoader classLoader)
+ {
+ try
+ {
+ return getRepresentationClassFromMimeThrows(mimeString, classLoader);
+ }
+ catch(ClassNotFoundException cnfe)
+ {
+ IllegalArgumentException iae;
+ iae = new IllegalArgumentException("mimeString: "
+ + mimeString
+ + " classLoader: "
+ + classLoader);
+ iae.initCause(cnfe);
+ throw iae;
+ }
+ }
+
+ /**
+ * Returns the value of the named MIME type parameter, or <code>null</code>
+ * if the parameter does not exist. Given the parameter name and the mime
+ * string.
+ *
+ * @param paramName The name of the parameter.
+ * @param mimeString The mime string from where the name should be found.
+ *
+ * @return The value of the parameter or null.
+ */
+ private static String getParameter(String paramName, String mimeString)
+ {
+ int idx = mimeString.indexOf(paramName + "=");
+ if (idx == -1)
+ return(null);
+
+ String value = mimeString.substring(idx + paramName.length() + 1);
+
+ idx = value.indexOf(";");
+ if (idx == -1)
+ return(value);
+ else
+ return(value.substring(0, idx));
+ }
+
+ /**
+ * XXX - Currently returns <code>plainTextFlavor</code>.
+ */
+ public static final DataFlavor getTextPlainUnicodeFlavor()
+ {
+ return plainTextFlavor;
+ }
+
+ /**
+ * Selects the best supported text flavor on this implementation.
+ * Returns <code>null</code> when none of the given flavors is liked.
+ *
+ * The <code>DataFlavor</code> returned the first data flavor in the
+ * array that has either a representation class which is (a subclass of)
+ * <code>Reader</code> or <code>String</code>, or has a representation
+ * class which is (a subclass of) <code>InputStream</code> and has a
+ * primary MIME type of "text" and has an supported encoding.
+ */
+ public static final DataFlavor
+ selectBestTextFlavor(DataFlavor[] availableFlavors)
+ {
+ for(int i = 0; i < availableFlavors.length; i++)
+ {
+ DataFlavor df = availableFlavors[i];
+ Class c = df.representationClass;
+
+ // A Reader or String is good.
+ if ((Reader.class.isAssignableFrom(c))
+ || (String.class.isAssignableFrom(c)))
+ return df;
+
+ // A InputStream is good if the mime primary type is "text"
+ if ((InputStream.class.isAssignableFrom(c))
+ && ("text".equals(df.getPrimaryType())))
+ {
+ String encoding = availableFlavors[i].getParameter("charset");
+ if (encoding == null)
+ encoding = "us-ascii";
+ Reader r = null;
+ try
+ {
+ // Try to construct a dummy reader with the found encoding
+ r = new InputStreamReader
+ (new ByteArrayInputStream(new byte[0]), encoding);
+ }
+ catch(UnsupportedEncodingException uee) { /* ignore */ }
+
+ if (r != null)
+ return df;
+ }
+ }
+
+ // Nothing found
+ return null;
+ }
+
+
+ /*
+ * Constructors
+ */
+
+ /**
+ * Empty public constructor needed for externalization.
+ * Should not be used for normal instantiation.
+ */
+ public DataFlavor()
+ {
+ mimeType = null;
+ representationClass = null;
+ humanPresentableName = null;
+ }
+
+ /**
+ * Private constructor.
+ */
+ private DataFlavor(Class representationClass,
+ String mimeType,
+ String humanPresentableName)
+ {
+ this.representationClass = representationClass;
+ this.mimeType = mimeType;
+
+ // Do some simple validity checks
+ String type = getPrimaryType() + "/" + getSubType();
+ if (type.indexOf(' ') != -1
+ || type.indexOf('=') != -1
+ || type.indexOf(';') != -1)
+ throw new IllegalArgumentException(mimeType);
+
+ if (humanPresentableName != null)
+ this.humanPresentableName = humanPresentableName;
+ else
+ this.humanPresentableName = mimeType;
+ }
+
+ /**
+ * Initializes a new instance of <code>DataFlavor</code>. The class
+ * and human readable name are specified, the MIME type will be
+ * "application/x-java-serialized-object". If the human readable name
+ * is not specified (<code>null</code>) then the human readable name
+ * will be the same as the MIME type.
+ *
+ * @param representationClass The representation class for this object.
+ * @param humanPresentableName The display name of the object.
+ */
+ public DataFlavor(Class representationClass, String humanPresentableName)
+ {
+ this(representationClass,
+ "application/x-java-serialized-object"
+ + "; class="
+ + representationClass.getName(),
+ humanPresentableName);
+ }
+
+ /**
+ * Initializes a new instance of <code>DataFlavor</code> with the
+ * specified MIME type and description. If the MIME type has a
+ * "class=<rep class>" parameter then the representation class will
+ * be the class name specified. Otherwise the class defaults to
+ * <code>java.io.InputStream</code>. If the human readable name
+ * is not specified (<code>null</code>) then the human readable name
+ * will be the same as the MIME type.
+ *
+ * @param mimeType The MIME type for this flavor.
+ * @param humanPresentableName The display name of this flavor.
+ * @param classLoader The class loader for finding classes if the default
+ * class loaders do not work.
+ *
+ * @exception IllegalArgumentException If the representation class
+ * specified cannot be loaded.
+ * @exception ClassNotFoundException If the class is not loaded.
+ */
+ public DataFlavor(String mimeType, String humanPresentableName,
+ ClassLoader classLoader)
+ throws ClassNotFoundException
+ {
+ this(getRepresentationClassFromMimeThrows(mimeType, classLoader),
+ mimeType, humanPresentableName);
+ }
+
+ /**
+ * Initializes a new instance of <code>DataFlavor</code> with the
+ * specified MIME type and description. If the MIME type has a
+ * "class=<rep class>" parameter then the representation class will
+ * be the class name specified. Otherwise the class defaults to
+ * <code>java.io.InputStream</code>. If the human readable name
+ * is not specified (<code>null</code>) then the human readable name
+ * will be the same as the MIME type. This is the same as calling
+ * <code>new DataFlavor(mimeType, humanPresentableName, null)</code>.
+ *
+ * @param mimeType The MIME type for this flavor.
+ * @param humanPresentableName The display name of this flavor.
+ *
+ * @exception IllegalArgumentException If the representation class
+ * specified cannot be loaded.
+ */
+ public DataFlavor(String mimeType, String humanPresentableName)
+ {
+ this(getRepresentationClassFromMime (mimeType, null),
+ mimeType, humanPresentableName);
+ }
+
+ /**
+ * Initializes a new instance of <code>DataFlavor</code> with the specified
+ * MIME type. This type can have a "class=" parameter to specify the
+ * representation class, and then the class must exist or an exception will
+ * be thrown. If there is no "class=" parameter then the representation class
+ * will be <code>java.io.InputStream</code>. This is the same as calling
+ * <code>new DataFlavor(mimeType, null)</code>.
+ *
+ * @param mimeType The MIME type for this flavor.
+ *
+ * @exception IllegalArgumentException If a class is not specified in
+ * the MIME type.
+ * @exception ClassNotFoundException If the class cannot be loaded.
+ */
+ public DataFlavor(String mimeType) throws ClassNotFoundException
+ {
+ this(getRepresentationClassFromMimeThrows(mimeType, null),
+ mimeType, null);
+ }
+
+ /**
+ * Returns the MIME type of this flavor.
+ *
+ * @return The MIME type for this flavor.
+ */
+ public String getMimeType()
+ {
+ return(mimeType);
+ }
+
+ /**
+ * Returns the representation class for this flavor.
+ *
+ * @return The representation class for this flavor.
+ */
+ public Class getRepresentationClass()
+ {
+ return(representationClass);
+ }
+
+ /**
+ * Returns the human presentable name for this flavor.
+ *
+ * @return The human presentable name for this flavor.
+ */
+ public String getHumanPresentableName()
+ {
+ return(humanPresentableName);
+ }
+
+ /**
+ * Returns the primary MIME type for this flavor.
+ *
+ * @return The primary MIME type for this flavor.
+ */
+ public String getPrimaryType()
+ {
+ int idx = mimeType.indexOf("/");
+ if (idx == -1)
+ return(mimeType);
+
+ return(mimeType.substring(0, idx));
+ }
+
+ /**
+ * Returns the MIME subtype for this flavor.
+ *
+ * @return The MIME subtype for this flavor.
+ */
+ public String getSubType()
+ {
+ int start = mimeType.indexOf("/");
+ if (start == -1)
+ return "";
+
+ int end = mimeType.indexOf(";", start + 1);
+ if (end == -1)
+ return mimeType.substring(start + 1);
+ else
+ return mimeType.substring(start + 1, end);
+ }
+
+ /**
+ * Returns the value of the named MIME type parameter, or <code>null</code>
+ * if the parameter does not exist.
+ *
+ * @param paramName The name of the paramter.
+ *
+ * @return The value of the parameter.
+ */
+ public String getParameter(String paramName)
+ {
+ if ("humanPresentableName".equals(paramName))
+ return getHumanPresentableName();
+
+ return getParameter(paramName, mimeType);
+ }
+
+ /**
+ * Sets the human presentable name to the specified value.
+ *
+ * @param humanPresentableName The new display name.
+ */
+ public void setHumanPresentableName(String humanPresentableName)
+ {
+ this.humanPresentableName = humanPresentableName;
+ }
+
+ /**
+ * Tests the MIME type of this object for equality against the specified
+ * MIME type. Ignores parameters.
+ *
+ * @param mimeType The MIME type to test against.
+ *
+ * @return <code>true</code> if the MIME type is equal to this object's
+ * MIME type (ignoring parameters), <code>false</code> otherwise.
+ *
+ * @exception NullPointerException If mimeType is null.
+ */
+ public boolean isMimeTypeEqual(String mimeType)
+ {
+ String mime = getMimeType();
+ int i = mime.indexOf(";");
+ if (i != -1)
+ mime = mime.substring(0, i);
+
+ i = mimeType.indexOf(";");
+ if (i != -1)
+ mimeType = mimeType.substring(0, i);
+
+ return mime.equals(mimeType);
+ }
+
+ /**
+ * Tests the MIME type of this object for equality against the specified
+ * data flavor's MIME type
+ *
+ * @param flavor The flavor to test against.
+ *
+ * @return <code>true</code> if the flavor's MIME type is equal to this
+ * object's MIME type, <code>false</code> otherwise.
+ */
+ public final boolean isMimeTypeEqual(DataFlavor flavor)
+ {
+ return isMimeTypeEqual(flavor.getMimeType());
+ }
+
+ /**
+ * Tests whether or not this flavor represents a serialized object.
+ *
+ * @return <code>true</code> if this flavor represents a serialized
+ * object, <code>false</code> otherwise.
+ */
+ public boolean isMimeTypeSerializedObject()
+ {
+ return mimeType.startsWith(javaSerializedObjectMimeType);
+ }
+
+ /**
+ * Tests whether or not this flavor has a representation class of
+ * <code>java.io.InputStream</code>.
+ *
+ * @return <code>true</code> if the representation class of this flavor
+ * is <code>java.io.InputStream</code>, <code>false</code> otherwise.
+ */
+ public boolean isRepresentationClassInputStream()
+ {
+ return InputStream.class.isAssignableFrom(representationClass);
+ }
+
+ /**
+ * Tests whether the representation class for this flavor is
+ * serializable.
+ *
+ * @return <code>true</code> if the representation class is serializable,
+ * <code>false</code> otherwise.
+ */
+ public boolean isRepresentationClassSerializable()
+ {
+ return Serializable.class.isAssignableFrom(representationClass);
+ }
+
+ /**
+ * Tests whether the representation class for his flavor is remote.
+ *
+ * @return <code>true</code> if the representation class is remote,
+ * <code>false</code> otherwise.
+ */
+ public boolean isRepresentationClassRemote()
+ {
+ return Remote.class.isAssignableFrom (representationClass);
+ }
+
+ /**
+ * Tests whether or not this flavor represents a serialized object.
+ *
+ * @return <code>true</code> if this flavor represents a serialized
+ * object, <code>false</code> otherwise.
+ */
+ public boolean isFlavorSerializedObjectType()
+ {
+ // FIXME: What is the diff between this and isMimeTypeSerializedObject?
+ return(mimeType.startsWith(javaSerializedObjectMimeType));
+ }
+
+ /**
+ * Tests whether or not this flavor represents a remote object.
+ *
+ * @return <code>true</code> if this flavor represents a remote object,
+ * <code>false</code> otherwise.
+ */
+ public boolean isFlavorRemoteObjectType()
+ {
+ return(mimeType.startsWith(javaRemoteObjectMimeType));
+ }
+
+ /**
+ * Tests whether or not this flavor represents a list of files.
+ *
+ * @return <code>true</code> if this flavor represents a list of files,
+ * <code>false</code> otherwise.
+ */
+ public boolean isFlavorJavaFileListType()
+ {
+ if (getPrimaryType().equals(javaFileListFlavor.getPrimaryType())
+ && getSubType().equals(javaFileListFlavor.getSubType())
+ && javaFileListFlavor.representationClass
+ .isAssignableFrom(representationClass))
+ return true;
+
+ return false ;
+ }
+
+ /**
+ * Returns a copy of this object.
+ *
+ * @return A copy of this object.
+ *
+ * @exception CloneNotSupportedException If the object's class does not support
+ * the Cloneable interface. Subclasses that override the clone method can also
+ * throw this exception to indicate that an instance cannot be cloned.
+ */
+ public Object clone () throws CloneNotSupportedException
+ {
+ // FIXME - This cannot be right.
+ try
+ {
+ return super.clone();
+ }
+ catch(Exception e)
+ {
+ return null;
+ }
+ }
+
+ /**
+ * This method test the specified <code>DataFlavor</code> for equality
+ * against this object. This will be true if the MIME type and
+ * representation class are the equal. If the primary type is 'text'
+ * then also the value of the charset parameter is compared. In such a
+ * case when the charset parameter isn't given then the charset is
+ * assumed to be equal to the default charset of the platform. All
+ * other parameters are ignored.
+ *
+ * @param flavor The <code>DataFlavor</code> to test against.
+ *
+ * @return <code>true</code> if the flavor is equal to this object,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(DataFlavor flavor)
+ {
+ if (flavor == null)
+ return false;
+
+ String primary = getPrimaryType();
+ if (! primary.equals(flavor.getPrimaryType()))
+ return false;
+
+ String sub = getSubType();
+ if (! sub.equals(flavor.getSubType()))
+ return false;
+
+ if (! this.representationClass.equals(flavor.representationClass))
+ return false;
+
+ if (primary.equals("text"))
+ if (! isRepresentationClassCharBuffer()
+ && ! isRepresentationClassReader()
+ && representationClass != java.lang.String.class
+ && ! (representationClass.isArray()
+ && representationClass.getComponentType() == Character.TYPE))
+ {
+ String charset = getParameter("charset");
+ String otherset = flavor.getParameter("charset");
+ String defaultset = Charset.defaultCharset().name();
+
+ if (charset == null || charset.equals(defaultset))
+ return (otherset == null || otherset.equals(defaultset));
+
+ return charset.equals(otherset);
+ }
+
+ return true;
+ }
+
+ /**
+ * This method test the specified <code>Object</code> for equality
+ * against this object. This will be true if the following conditions
+ * are met:
+ * <p>
+ * <ul>
+ * <li>The object is not <code>null</code>.</li>
+ * <li>The object is an instance of <code>DataFlavor</code>.</li>
+ * <li>The object's MIME type and representation class are equal to
+ * this object's.</li>
+ * </ul>
+ *
+ * @param obj The <code>Object</code> to test against.
+ *
+ * @return <code>true</code> if the flavor is equal to this object,
+ * <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof DataFlavor))
+ return false;
+
+ return equals((DataFlavor) obj);
+ }
+
+ /**
+ * Tests whether or not the specified string is equal to the MIME type
+ * of this object.
+ *
+ * @param str The string to test against.
+ *
+ * @return <code>true</code> if the string is equal to this object's MIME
+ * type, <code>false</code> otherwise.
+ *
+ * @deprecated Not compatible with <code>hashCode()</code>.
+ * Use <code>isMimeTypeEqual()</code>
+ */
+ public boolean equals(String str)
+ {
+ return isMimeTypeEqual(str);
+ }
+
+ /**
+ * Returns the hash code for this data flavor.
+ * The hash code is based on the (lower case) mime type and the
+ * representation class.
+ */
+ public int hashCode()
+ {
+ return mimeType.toLowerCase().hashCode() ^ representationClass.hashCode();
+ }
+
+ /**
+ * Returns <code>true</code> when the given <code>DataFlavor</code>
+ * matches this one.
+ */
+ public boolean match(DataFlavor dataFlavor)
+ {
+ // XXX - How is this different from equals?
+ return equals(dataFlavor);
+ }
+
+ /**
+ * This method exists for backward compatibility. It simply returns
+ * the same name/value pair passed in.
+ *
+ * @param name The parameter name.
+ * @param value The parameter value.
+ *
+ * @return The name/value pair.
+ *
+ * @deprecated
+ */
+ protected String normalizeMimeTypeParameter(String name, String value)
+ {
+ return name + "=" + value;
+ }
+
+ /**
+ * This method exists for backward compatibility. It simply returns
+ * the MIME type string unchanged.
+ *
+ * @param type The MIME type.
+ *
+ * @return The MIME type.
+ *
+ * @deprecated
+ */
+ protected String normalizeMimeType(String type)
+ {
+ return type;
+ }
+
+ /**
+ * Serialize this class.
+ *
+ * @param stream The <code>ObjectOutput</code> stream to serialize to.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public void writeExternal(ObjectOutput stream)
+ throws IOException, NotImplementedException
+ {
+ // FIXME: Implement me
+ }
+
+
+ /**
+ * De-serialize this class.
+ *
+ * @param stream The <code>ObjectInput</code> stream to deserialize from.
+ *
+ * @exception IOException If an error ocurs.
+ * @exception ClassNotFoundException If the class for an object being restored
+ * cannot be found.
+ */
+ public void readExternal(ObjectInput stream)
+ throws IOException, ClassNotFoundException, NotImplementedException
+ {
+ // FIXME: Implement me
+ }
+
+ /**
+ * Returns a string representation of this DataFlavor. Including the
+ * representation class name, MIME type and human presentable name.
+ */
+ public String toString()
+ {
+ return (getClass().getName()
+ + "[representationClass=" + getRepresentationClass().getName()
+ + ",mimeType=" + getMimeType()
+ + ",humanPresentableName=" + getHumanPresentableName()
+ + "]");
+ }
+
+ /**
+ * XXX - Currently returns <code>java.io.InputStream</code>.
+ *
+ * @since 1.3
+ */
+ public final Class getDefaultRepresentationClass()
+ {
+ return java.io.InputStream.class;
+ }
+
+ /**
+ * XXX - Currently returns <code>java.io.InputStream</code>.
+ */
+ public final String getDefaultRepresentationClassAsString()
+ {
+ return getDefaultRepresentationClass().getName();
+ }
+
+ /**
+ * Creates a <code>Reader</code> for a given <code>Transferable</code>.
+ *
+ * If the representation class is a (subclass of) <code>Reader</code>
+ * then an instance of the representation class is returned. If the
+ * representatation class is a <code>String</code> then a
+ * <code>StringReader</code> is returned. And if the representation class
+ * is a (subclass of) <code>InputStream</code> and the primary MIME type
+ * is "text" then a <code>InputStreamReader</code> for the correct charset
+ * encoding is returned.
+ *
+ * @param transferable The <code>Transferable</code> for which a text
+ * <code>Reader</code> is requested.
+ *
+ * @exception IllegalArgumentException If the representation class is not one
+ * of the seven listed above or the Transferable has null data.
+ * @exception NullPointerException If the Transferable is null.
+ * @exception UnsupportedFlavorException when the transferable doesn't
+ * support this <code>DataFlavor</code>. Or if the representable class
+ * isn't a (subclass of) <code>Reader</code>, <code>String</code>,
+ * <code>InputStream</code> and/or the primary MIME type isn't "text".
+ * @exception IOException when any IOException occurs.
+ * @exception UnsupportedEncodingException if the "charset" isn't supported
+ * on this platform.
+ */
+ public Reader getReaderForText(Transferable transferable)
+ throws UnsupportedFlavorException, IOException
+ {
+ if (!transferable.isDataFlavorSupported(this))
+ throw new UnsupportedFlavorException(this);
+
+ if (Reader.class.isAssignableFrom(representationClass))
+ return (Reader)transferable.getTransferData(this);
+
+ if (String.class.isAssignableFrom(representationClass))
+ return new StringReader((String)transferable.getTransferData(this));
+
+ if (InputStream.class.isAssignableFrom(representationClass)
+ && "text".equals(getPrimaryType()))
+ {
+ InputStream in = (InputStream)transferable.getTransferData(this);
+ String encoding = getParameter("charset");
+ if (encoding == null)
+ encoding = "us-ascii";
+ return new InputStreamReader(in, encoding);
+ }
+
+ throw new UnsupportedFlavorException(this);
+ }
+
+ /**
+ * Returns whether the representation class for this DataFlavor is
+ * @see java.nio.ByteBuffer or a subclass thereof.
+ *
+ * @since 1.4
+ */
+ public boolean isRepresentationClassByteBuffer()
+ {
+ return ByteBuffer.class.isAssignableFrom(representationClass);
+ }
+
+ /**
+ * Returns whether the representation class for this DataFlavor is
+ * @see java.nio.CharBuffer or a subclass thereof.
+ *
+ * @since 1.4
+ */
+ public boolean isRepresentationClassCharBuffer()
+ {
+ return CharBuffer.class.isAssignableFrom(representationClass);
+ }
+
+ /**
+ * Returns whether the representation class for this DataFlavor is
+ * @see java.io.Reader or a subclass thereof.
+ *
+ * @since 1.4
+ */
+ public boolean isRepresentationClassReader()
+ {
+ return Reader.class.isAssignableFrom(representationClass);
+ }
+
+ /**
+ * Returns whether this <code>DataFlavor</code> is a valid text flavor for
+ * this implementation of the Java platform. Only flavors equivalent to
+ * <code>DataFlavor.stringFlavor</code> and <code>DataFlavor</code>s with
+ * a primary MIME type of "text" can be valid text flavors.
+ * <p>
+ * If this flavor supports the charset parameter, it must be equivalent to
+ * <code>DataFlavor.stringFlavor</code>, or its representation must be
+ * <code>java.io.Reader</code>, <code>java.lang.String</code>,
+ * <code>java.nio.CharBuffer</code>, <code>java.io.InputStream</code> or
+ * <code>java.nio.ByteBuffer</code>,
+ * If the representation is <code>java.io.InputStream</code> or
+ * <code>java.nio.ByteBuffer</code>, then this flavor's <code>charset</code>
+ * parameter must be supported by this implementation of the Java platform.
+ * If a charset is not specified, then the platform default charset, which
+ * is always supported, is assumed.
+ * <p>
+ * If this flavor does not support the charset parameter, its
+ * representation must be <code>java.io.InputStream</code>,
+ * <code>java.nio.ByteBuffer</code>.
+ * <p>
+ * See <code>selectBestTextFlavor</code> for a list of text flavors which
+ * support the charset parameter.
+ *
+ * @return <code>true</code> if this <code>DataFlavor</code> is a valid
+ * text flavor as described above; <code>false</code> otherwise
+ * @see #selectBestTextFlavor
+ * @since 1.4
+ */
+ public boolean isFlavorTextType() {
+ // FIXME: I'm not 100% sure if this implementation does the same like sun's does
+ if(equals(DataFlavor.stringFlavor) || getPrimaryType().equals("text"))
+ {
+ String charset = getParameter("charset");
+ Class c = getRepresentationClass();
+ if(charset != null)
+ {
+ if(Reader.class.isAssignableFrom(c)
+ || CharBuffer.class.isAssignableFrom(c)
+ || String.class.isAssignableFrom(c))
+ {
+ return true;
+ }
+ else if(InputStream.class.isAssignableFrom(c)
+ || ByteBuffer.class.isAssignableFrom(c))
+ {
+ return Charset.isSupported(charset);
+ }
+ }
+ else if(InputStream.class.isAssignableFrom(c)
+ || ByteBuffer.class.isAssignableFrom(c))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+} // class DataFlavor
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* FlavorEvent -- Event indicating a ClipBoard has different flavors available.
+ Copyright (C) 2005 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.datatransfer;
+
+import java.util.EventObject;
+
+/**
+ * Event indicating a Clipboard has different flavors available.
+ * Fired by a ClipBoard for registered FlavorListeners.
+ *
+ * @author Mark J. Wielaard (mark at klomp.org)
+ *
+ * @since 1.5
+ */
+public class FlavorEvent extends EventObject
+{
+ public FlavorEvent(Clipboard board)
+ {
+ super(board);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,54 @@
+/* FlavorListener -- Interface for tagging an interest in FlavorEvents.
+ Copyright (C) 2005 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.datatransfer;
+
+import java.util.EventListener;
+
+/**
+ * Interface for tagging an interest in FlavorEvents by a class. The
+ * flavorsChanged() method will be called with a FlavorEvent pointing
+ * to the Clipboard which has content in different Flavors available.
+ *
+ * @author Mark J. Wielaard (mark at klomp.org)
+ */
+public interface FlavorListener
+ extends EventListener
+{
+ void flavorsChanged(FlavorEvent event);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorMap.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorMap.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,75 @@
+/* FlavorMap.java -- Maps between flavor names and MIME types.
+ Copyright (C) 1999, 2001 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.datatransfer;
+
+import java.util.Map;
+
+/**
+ * This interface maps between native platform type names and DataFlavors.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public interface FlavorMap
+{
+ /**
+ * Maps the specified <code>DataFlavor</code> objects to the native
+ * data type name. The returned <code>Map</code> has keys that are
+ * the data flavors and values that are strings. The returned map
+ * may be modified. This can be useful for implementing nested mappings.
+ *
+ * @param flavors An array of data flavors to map
+ * or null for all data flavors.
+ *
+ * @return A <code>Map</code> of native data types.
+ */
+ Map getNativesForFlavors (DataFlavor[] flavors);
+
+ /**
+ * Maps the specified native type names to <code>DataFlavor</code>'s.
+ * The returned <code>Map</code> has keys that are strings and values
+ * that are <code>DataFlavor</code>'s. The returned map may be
+ * modified. This can be useful for implementing nested mappings.
+ *
+ * @param natives An array of native types to map
+ * or null for all native types.
+ *
+ * @return A <code>Map</code> of data flavors.
+ */
+ Map getFlavorsForNatives (String[] natives);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorTable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorTable.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorTable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/FlavorTable.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,73 @@
+/* FlavorTable.java -- A relaxed mapping between flavors
+ Copyright (C) 2002, 2005 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.datatransfer;
+
+import java.util.List;
+
+/**
+ * A FlavorMap which no longer requires a 1-to-1 mapping between flavors. Any
+ * native can map to multiple flavors, and any flavor can map to multiple
+ * natives; although the mappings are usually symmetric.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public interface FlavorTable extends FlavorMap
+{
+ /**
+ * Returns a list of String natives corresponding to the given flavor. The
+ * list should be sorted from best to worst. The list must be modifiable
+ * without affecting this table.
+ *
+ * @param flavor the flavor to look up, or null to return all natives
+ * @return the sorted list of natives
+ */
+ List getNativesForFlavor(DataFlavor flavor);
+
+ /**
+ * Returns a list of flavors corresponding to the given String native. The
+ * list should be sorted from best to worst. The list must be modifiable
+ * without affecting this table.
+ *
+ * @param name the native name to look up, or null to return all flavors
+ * @return the sorted list of flavors
+ */
+ List getFlavorsForNative(String name);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/MimeTypeParseException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* MimeTypeParseException.java -- thrown when MIME string couldn't be parsed
+ Copyright (C) 2001, 2002, 2005 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.datatransfer;
+
+/**
+ * MIME string couldn't be parsed correctly.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ * @status updated to 1.4
+ */
+public class MimeTypeParseException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -5604407764691570741L;
+
+ /**
+ * Create a new instance without any message.
+ */
+ public MimeTypeParseException()
+ {
+ }
+
+ /**
+ * Create a new instance with a specified detailed error message.
+ *
+ * @param message the message
+ */
+ public MimeTypeParseException(String message)
+ {
+ super(message);
+ }
+} // class MimeTypeParseException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/StringSelection.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/StringSelection.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/StringSelection.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/StringSelection.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,158 @@
+/* StringSelection.java -- Clipboard handler for text.
+ Copyright (C) 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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.datatransfer;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+/**
+ * This class transfers a string as plain text using the clipboard.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ */
+public class StringSelection implements Transferable, ClipboardOwner
+{
+
+/*
+ * Class Variables
+ */
+
+// List of flavors we support
+// XXX: DataFlavor.plainTextFlavor is deprecated.
+static final DataFlavor[] supported_flavors
+ = { DataFlavor.stringFlavor,
+ DataFlavor.plainTextFlavor };
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+// This is the data to transfer
+private String data;
+
+ /**
+ * Transfer the specfied string as text.
+ *
+ * @param data the data for the string selection
+ */
+ public StringSelection(String data)
+ {
+ this.data = data;
+ }
+
+/**
+ * Returns a list of supported data flavors.
+ *
+ * @return A list of supported data flavors.
+ */
+public DataFlavor[]
+getTransferDataFlavors()
+{
+ return(supported_flavors);
+}
+
+/*************************************************************************/
+
+/**
+ * Tests whether or not the specified data flavor is supported.
+ *
+ * @param flavor The data flavor to test.
+ *
+ * @return <code>true</code> if the data flavor is supported,
+ * <code>false</code> otherwise.
+ */
+public boolean
+isDataFlavorSupported(DataFlavor flavor)
+{
+ for (int i = 0; i < supported_flavors.length; i++)
+ if (supported_flavors[i].equals(flavor))
+ return(true);
+
+ return(false);
+}
+
+/*************************************************************************/
+
+/**
+ * This method returns the data in the requested format.
+ *
+ * @param flavor The desired data flavor.
+ *
+ * @return The transferred data.
+ *
+ * @exception UnsupportedFlavorException If the specified flavor is not
+ * supported.
+ * @exception IOException If any other error occurs.
+ */
+public Object
+getTransferData(DataFlavor flavor) throws UnsupportedFlavorException,
+ IOException
+{
+ if (!isDataFlavorSupported(flavor))
+ throw new UnsupportedFlavorException(flavor);
+
+ if (DataFlavor.plainTextFlavor == flavor)
+ /* The behavior of this method for DataFlavor.plainTextFlavor and
+ equivalent DataFlavors is inconsistent with the definition of
+ DataFlavor.plainTextFlavor. We choose to do like Sun's implementation
+ and return a Reader instead of an InputString. */
+ /* return(new StringBufferInputStream(data)); */
+ return(new StringReader(data));
+ else // DataFlavor.stringFlavor
+ return data;
+}
+
+/*************************************************************************/
+
+/**
+ * Called when ownership of the clipboard object is lost.
+ *
+ * @param clipboard The affected clipboard.
+ * @param contents The clipboard contents.
+ */
+public void
+lostOwnership(Clipboard clipboard, Transferable contents)
+{
+ // FIXME: What does this do?
+}
+
+} // class StringSelection
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/SystemFlavorMap.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/SystemFlavorMap.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/SystemFlavorMap.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/SystemFlavorMap.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,433 @@
+/* SystemFlavorMap.java -- Maps between native flavor names and MIME types.
+ Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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.datatransfer;
+
+import gnu.classpath.NotImplementedException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * This class maps between native platform type names and DataFlavors.
+ *
+ * XXX - The current implementation does no mapping at all.
+ *
+ * @author Mark Wielaard (mark at klomp.org)
+ *
+ * @since 1.2
+ */
+public final class SystemFlavorMap implements FlavorMap, FlavorTable
+{
+ /**
+ * The map which maps the thread's <code>ClassLoaders</code> to
+ * <code>SystemFlavorMaps</code>.
+ */
+ private static final Map systemFlavorMaps = new WeakHashMap();
+
+ /**
+ * Constant which is used to prefix encode Java MIME types.
+ */
+ private static final String GNU_JAVA_MIME_PREFIX = "gnu.java:";
+
+ /**
+ * This map maps native <code>String</code>s to lists of
+ * <code>DataFlavor</code>s
+ */
+ private HashMap nativeToFlavorMap = new HashMap();
+
+ /**
+ * This map maps <code>DataFlavor</code>s to lists of native
+ * <code>String</code>s
+ */
+ private HashMap flavorToNativeMap = new HashMap();
+
+ /**
+ * Private constructor.
+ */
+ private SystemFlavorMap ()
+ {
+ }
+
+ /**
+ * Maps the specified <code>DataFlavor</code> objects to the native
+ * data type name. The returned <code>Map</code> has keys that are
+ * the data flavors and values that are strings. The returned map
+ * may be modified. This can be useful for implementing nested mappings.
+ *
+ * @param flavors An array of data flavors to map
+ * or null for all data flavors.
+ *
+ * @return A <code>Map</code> of native data types to data flavors.
+ */
+ public Map getNativesForFlavors (DataFlavor[] flavors)
+ {
+ return new HashMap();
+ }
+
+ /**
+ * Maps the specified native type names to <code>DataFlavor</code>'s.
+ * The returned <code>Map</code> has keys that are strings and values
+ * that are <code>DataFlavor</code>'s. The returned map may be
+ * modified. This can be useful for implementing nested mappings.
+ *
+ * @param natives An array of native types to map
+ * or null for all native types.
+ *
+ * @return A <code>Map</code> of data flavors to native type names.
+ */
+ public Map getFlavorsForNatives (String[] natives)
+ {
+ return new HashMap();
+ }
+
+ /**
+ * Returns the (System)FlavorMap for the current thread's
+ * ClassLoader.
+ */
+ public static FlavorMap getDefaultFlavorMap ()
+ {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+
+ //if ContextClassLoader not set, use system default
+ if (classLoader == null)
+ {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
+
+ synchronized(systemFlavorMaps)
+ {
+ FlavorMap map = (FlavorMap)
+ systemFlavorMaps.get(classLoader);
+ if (map == null)
+ {
+ map = new SystemFlavorMap();
+ systemFlavorMaps.put(classLoader, map);
+ }
+ return map;
+ }
+ }
+
+ /**
+ * Encodes a MIME type for use as a <code>String</code> native. The format
+ * of an encoded representation of a MIME type is implementation-dependent.
+ * The only restrictions are:
+ * <ul>
+ * <li>The encoded representation is <code>null</code> if and only if the
+ * MIME type <code>String</code> is <code>null</code>.</li>
+ * <li>The encoded representations for two non-<code>null</code> MIME type
+ * <code>String</code>s are equal if and only if these <code>String</code>s
+ * are equal according to <code>String.equals(Object)</code>.</li>
+ * </ul>
+ * <p>
+ * The present implementation of this method returns the specified MIME
+ * type <code>String</code> prefixed with <code>gnu.java:</code>.
+ *
+ * @param mime the MIME type to encode
+ * @return the encoded <code>String</code>, or <code>null</code> if
+ * mimeType is <code>null</code>
+ */
+ public static String encodeJavaMIMEType (String mime)
+ {
+ if (mime != null)
+ return GNU_JAVA_MIME_PREFIX + mime;
+ else
+ return null;
+ }
+
+ /**
+ * Encodes a <code>DataFlavor</code> for use as a <code>String</code>
+ * native. The format of an encoded <code>DataFlavor</code> is
+ * implementation-dependent. The only restrictions are:
+ * <ul>
+ * <li>The encoded representation is <code>null</code> if and only if the
+ * specified <code>DataFlavor</code> is <code>null</code> or its MIME type
+ * <code>String</code> is <code>null</code>.</li>
+ * <li>The encoded representations for two non-<code>null</code>
+ * <code>DataFlavor</code>s with non-<code>null</code> MIME type
+ * <code>String</code>s are equal if and only if the MIME type
+ * <code>String</code>s of these <code>DataFlavor</code>s are equal
+ * according to <code>String.equals(Object)</code>.</li>
+ * </ul>
+ * <p>
+ * The present implementation of this method returns the MIME type
+ * <code>String</code> of the specified <code>DataFlavor</code> prefixed
+ * with <code>gnu.java:</code>.
+ *
+ * @param df the <code>DataFlavor</code> to encode
+ * @return the encoded <code>String</code>, or <code>null</code> if
+ * flav is <code>null</code> or has a <code>null</code> MIME type
+ */
+ public static String encodeDataFlavor (DataFlavor df)
+ {
+ if (df != null)
+ {
+ return encodeJavaMIMEType(df.getMimeType());
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Returns true if the native type name can be represented as
+ * a java mime type. Returns <code>false</code> if parameter is
+ * <code>null</code>.
+ */
+ public static boolean isJavaMIMEType (String name)
+ {
+ return (name != null && name.startsWith(GNU_JAVA_MIME_PREFIX));
+ }
+
+ /**
+ * Decodes a <code>String</code> native for use as a Java MIME type.
+ *
+ * @param name the <code>String</code> to decode
+ * @return the decoded Java MIME type, or <code>null</code> if nat
+ * is not an encoded <code>String</code> native
+ */
+ public static String decodeJavaMIMEType (String name)
+ {
+ if (isJavaMIMEType(name))
+ {
+ return name.substring(GNU_JAVA_MIME_PREFIX.length());
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Returns the data flavor given the native type name
+ * or null when no such data flavor exists.
+ */
+ public static DataFlavor decodeDataFlavor (String name)
+ throws ClassNotFoundException
+ {
+ String javaMIMEType = decodeJavaMIMEType (name);
+
+ if (javaMIMEType != null)
+ return new DataFlavor (javaMIMEType);
+ else
+ return null;
+ }
+
+ /**
+ * Returns a List of <code>DataFlavors</code> to which the specified
+ * <code>String</code> native can be translated by the data transfer
+ * subsystem. The <code>List</code> will be sorted from best
+ * <code>DataFlavor</code> to worst. That is, the first <code>DataFlavor
+ * </code> will best reflect data in the specified native to a Java
+ * application.
+ * <p>
+ * If the specified native is previously unknown to the data transfer
+ * subsystem, and that native has been properly encoded, then invoking
+ * this method will establish a mapping in both directions between the
+ * specified native and a DataFlavor whose MIME type is a decoded
+ * version of the native.
+ */
+ public List getFlavorsForNative (String nat)
+ throws NotImplementedException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ public List getNativesForFlavor (DataFlavor flav)
+ throws NotImplementedException
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * Adds a mapping from a single <code>String</code> native to a single
+ * <code>DataFlavor</code>. Unlike <code>getFlavorsForNative</code>, the
+ * mapping will only be established in one direction, and the native will
+ * not be encoded. To establish a two-way mapping, call
+ * <code>addUnencodedNativeForFlavor</code> as well. The new mapping will
+ * be of lower priority than any existing mapping.
+ * This method has no effect if a mapping from the specified
+ * <code>String</code> native to the specified or equal
+ * <code>DataFlavor</code> already exists.
+ *
+ * @param nativeStr the <code>String</code> native key for the mapping
+ * @param flavor the <code>DataFlavor</code> value for the mapping
+ * @throws NullPointerException if nat or flav is <code>null</code>
+ *
+ * @see #addUnencodedNativeForFlavor
+ * @since 1.4
+ */
+ public synchronized void addFlavorForUnencodedNative(String nativeStr,
+ DataFlavor flavor)
+ {
+ if ((nativeStr == null) || (flavor == null))
+ throw new NullPointerException();
+ List flavors = (List) nativeToFlavorMap.get(nativeStr);
+ if (flavors == null)
+ {
+ flavors = new ArrayList();
+ nativeToFlavorMap.put(nativeStr, flavors);
+ }
+ else
+ {
+ if (! flavors.contains(flavor))
+ flavors.add(flavor);
+ }
+ }
+
+ /**
+ * Adds a mapping from the specified <code>DataFlavor</code> (and all
+ * <code>DataFlavor</code>s equal to the specified <code>DataFlavor</code>)
+ * to the specified <code>String</code> native.
+ * Unlike <code>getNativesForFlavor</code>, the mapping will only be
+ * established in one direction, and the native will not be encoded. To
+ * establish a two-way mapping, call
+ * <code>addFlavorForUnencodedNative</code> as well. The new mapping will
+ * be of lower priority than any existing mapping.
+ * This method has no effect if a mapping from the specified or equal
+ * <code>DataFlavor</code> to the specified <code>String</code> native
+ * already exists.
+ *
+ * @param flavor the <code>DataFlavor</code> key for the mapping
+ * @param nativeStr the <code>String</code> native value for the mapping
+ * @throws NullPointerException if flav or nat is <code>null</code>
+ *
+ * @see #addFlavorForUnencodedNative
+ * @since 1.4
+ */
+ public synchronized void addUnencodedNativeForFlavor(DataFlavor flavor,
+ String nativeStr)
+ {
+ if ((nativeStr == null) || (flavor == null))
+ throw new NullPointerException();
+ List natives = (List) flavorToNativeMap.get(flavor);
+ if (natives == null)
+ {
+ natives = new ArrayList();
+ flavorToNativeMap.put(flavor, natives);
+ }
+ else
+ {
+ if (! natives.contains(nativeStr))
+ natives.add(nativeStr);
+ }
+ }
+
+ /**
+ * Discards the current mappings for the specified <code>DataFlavor</code>
+ * and all <code>DataFlavor</code>s equal to the specified
+ * <code>DataFlavor</code>, and creates new mappings to the
+ * specified <code>String</code> natives.
+ * Unlike <code>getNativesForFlavor</code>, the mappings will only be
+ * established in one direction, and the natives will not be encoded. To
+ * establish two-way mappings, call <code>setFlavorsForNative</code>
+ * as well. The first native in the array will represent the highest
+ * priority mapping. Subsequent natives will represent mappings of
+ * decreasing priority.
+ * <p>
+ * If the array contains several elements that reference equal
+ * <code>String</code> natives, this method will establish new mappings
+ * for the first of those elements and ignore the rest of them.
+ * <p>
+ * It is recommended that client code not reset mappings established by the
+ * data transfer subsystem. This method should only be used for
+ * application-level mappings.
+ *
+ * @param flavor the <code>DataFlavor</code> key for the mappings
+ * @param natives the <code>String</code> native values for the mappings
+ * @throws NullPointerException if flav or natives is <code>null</code>
+ * or if natives contains <code>null</code> elements
+ *
+ * @see #setFlavorsForNative
+ * @since 1.4
+ */
+ public synchronized void setNativesForFlavor(DataFlavor flavor,
+ String[] natives)
+ {
+ if ((natives == null) || (flavor == null))
+ throw new NullPointerException();
+
+ flavorToNativeMap.remove(flavor);
+ for (int i = 0; i < natives.length; i++)
+ {
+ addUnencodedNativeForFlavor(flavor, natives[i]);
+ }
+ }
+
+ /**
+ * Discards the current mappings for the specified <code>String</code>
+ * native, and creates new mappings to the specified
+ * <code>DataFlavor</code>s. Unlike <code>getFlavorsForNative</code>, the
+ * mappings will only be established in one direction, and the natives need
+ * not be encoded. To establish two-way mappings, call
+ * <code>setNativesForFlavor</code> as well. The first
+ * <code>DataFlavor</code> in the array will represent the highest priority
+ * mapping. Subsequent <code>DataFlavor</code>s will represent mappings of
+ * decreasing priority.
+ * <p>
+ * If the array contains several elements that reference equal
+ * <code>DataFlavor</code>s, this method will establish new mappings
+ * for the first of those elements and ignore the rest of them.
+ * <p>
+ * It is recommended that client code not reset mappings established by the
+ * data transfer subsystem. This method should only be used for
+ * application-level mappings.
+ *
+ * @param nativeStr the <code>String</code> native key for the mappings
+ * @param flavors the <code>DataFlavor</code> values for the mappings
+ * @throws NullPointerException if nat or flavors is <code>null</code>
+ * or if flavors contains <code>null</code> elements
+ *
+ * @see #setNativesForFlavor
+ * @since 1.4
+ */
+ public synchronized void setFlavorsForNative(String nativeStr,
+ DataFlavor[] flavors)
+ {
+ if ((nativeStr == null) || (flavors == null))
+ throw new NullPointerException();
+
+ nativeToFlavorMap.remove(nativeStr);
+ for (int i = 0; i < flavors.length; i++)
+ {
+ addFlavorForUnencodedNative(nativeStr, flavors[i]);
+ }
+ }
+
+} // class SystemFlavorMap
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Transferable.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Transferable.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Transferable.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/Transferable.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,83 @@
+/* Transferable.java -- Data transfer source
+ Copyright (C) 1999, 2002, 2005 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.datatransfer;
+
+import java.io.IOException;
+
+/**
+ * This interface is implemented by classes that can transfer data.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public interface Transferable
+{
+ /**
+ * This method returns a list of available data flavors for the data being
+ * transferred. The array returned will be sorted from most preferred
+ * flavor at the beginning to least preferred at the end.
+ *
+ * @return adA list of data flavors for this data
+ */
+ DataFlavor[] getTransferDataFlavors();
+
+ /**
+ * Tests whether or not this data can be delivered in the specified data
+ * flavor.
+ *
+ * @param flavor the data flavor to test
+ * @return true if the data flavor is supported
+ */
+ boolean isDataFlavorSupported(DataFlavor flavor);
+
+ /**
+ * Returns the data in the specified <code>DataFlavor</code>.
+ *
+ * @param flavor the data flavor to return
+ * @return the data in the appropriate flavor
+ * @throws UnsupportedFlavorException if the flavor is not supported
+ * @throws IOException if the data is not available
+ * @see DataFlavor#getRepresentationClass
+ */
+ Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException;
+
+} // interface Transferable
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/UnsupportedFlavorException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,65 @@
+/* UnsupportedFlavorException.java -- ata flavor is not valid
+ Copyright (C) 1999, 2002, 2005 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.datatransfer;
+
+/**
+ * The data flavor requested is not supported for the transfer data.
+ *
+ * @author Aaron M. Renn (arenn at urbanophile.com)
+ * @see Transferable#getTransferData(DataFlavor)
+ * @status updated to 1.4
+ */
+public class UnsupportedFlavorException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 5383814944251665601L;
+
+ /**
+ * Initializes a new instance of <code>UnsupportedDataFlavor</code>
+ * for the specified data flavor.
+ *
+ * @param flavor the data flavor that is not supported
+ */
+ public UnsupportedFlavorException(DataFlavor flavor)
+ {
+ super(flavor == null ? null : flavor.getHumanPresentableName());
+ }
+} // class UnsupportedFlavorException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/datatransfer/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.datatransfer package.
+ Copyright (C) 2002 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.datatransfer</title></head>
+
+<body>
+<p>Classes to represent different flavors of data for transferring native
+and system types through for example a clipboard.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/Autoscroll.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/Autoscroll.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/Autoscroll.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/Autoscroll.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,70 @@
+/* Autoscroll.java --
+ Copyright (C) 2002, 2004, 2005 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.dnd;
+
+import java.awt.Insets;
+import java.awt.Point;
+
+/**
+ * During DnD operations it is possible that a user may wish to drop the
+ * subject of the operation on a region of a scrollable GUI control that
+ * is not currently visible to the user.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface Autoscroll
+{
+ /**
+ * This method returns the Insets describing the autoscrolling region or
+ * border relative to the geometry of the implementing Component
+ */
+ Insets getAutoscrollInsets ();
+
+ /**
+ * Notify the Component to autoscroll
+ *
+ * @param location A Point indicating the location of the cursor that
+ * triggered this operation
+ */
+ void autoscroll (Point location);
+
+} // interface Autoscroll
+
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDConstants.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDConstants.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDConstants.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDConstants.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,77 @@
+/* DnDConstants.java -- constants for drag-and-drop operations
+ Copyright (C) 2002, 2005 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.dnd;
+
+/**
+ * This class contains various constants used in drag-and-drop operations.
+ * Why it is not an interface is beyond me.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public final class DnDConstants
+{
+ /** No action takes place. */
+ public static final int ACTION_NONE = 0;
+
+ /** The copy action. */
+ public static final int ACTION_COPY = 1;
+
+ /** The move action. */
+ public static final int ACTION_MOVE = 2;
+
+ /** Either a copy or a move. */
+ public static final int ACTION_COPY_OR_MOVE = 3;
+
+ /**
+ * A link action. This does not copy or move, but creates a reference back
+ * to the original. However, since platforms differ on how a reference should
+ * behave, this action is not recommended for common use.
+ */
+ public static final int ACTION_LINK = 1073741824;
+
+ /** A synonym for {@link #ACTION_LINK}. */
+ public static final int ACTION_REFERENCE = ACTION_LINK;
+
+ private DnDConstants()
+ {
+ // Do nothing here.
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDEventMulticaster.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDEventMulticaster.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDEventMulticaster.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DnDEventMulticaster.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* DnDEventMulticaster.java -- helper class for listener chains in java.awt.dnd
+ Copyright (C) 2003 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.dnd;
+
+import java.awt.AWTEventMulticaster;
+import java.util.EventListener;
+
+class DnDEventMulticaster extends AWTEventMulticaster
+{
+ protected DnDEventMulticaster (EventListener a, EventListener b)
+ {
+ super (a, b);
+ }
+
+ public static DragSourceListener add (DragSourceListener a,
+ DragSourceListener b)
+ {
+ return (DragSourceListener) addInternal (a, b);
+ }
+
+ public static DragSourceMotionListener add (DragSourceMotionListener a,
+ DragSourceMotionListener b)
+ {
+ return (DragSourceMotionListener) addInternal (a, b);
+ }
+
+ public static DragSourceListener remove (DragSourceListener a,
+ DragSourceListener b)
+ {
+ return (DragSourceListener) removeInternal (a, b);
+ }
+
+ public static DragSourceMotionListener remove (DragSourceMotionListener a,
+ DragSourceMotionListener b)
+ {
+ return (DragSourceMotionListener) removeInternal (a, b);
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,219 @@
+/* DragGestureEvent.java --
+ Copyright (C) 2002 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.dnd;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.datatransfer.Transferable;
+import java.awt.event.InputEvent;
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.List;
+
+public class DragGestureEvent extends EventObject
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 9080172649166731306L;
+
+ private DragSource dragSource;
+ private Component component;
+ private final Point origin;
+ private final int action;
+ private List events;
+ private DragGestureRecognizer dgr;
+
+ /**
+ * Constructs a new DragGestureEvent.
+ * @param dgr - DragGestureRecognizer firing this event
+ * @param action - user's preferred action
+ * @param origin - origin of the drag
+ * @param events - List of events that make up the gesture
+ * @throws IllegalArgumentException - if input parameters are null
+ */
+ public DragGestureEvent(DragGestureRecognizer dgr, int action, Point origin,
+ List events)
+ {
+ super(dgr);
+ if (origin == null || events == null || dgr == null)
+ throw new IllegalArgumentException();
+
+ this.origin = origin;
+ this.action = action;
+ this.events = events;
+ this.dgr = dgr;
+ this.component = dgr.getComponent();
+ this.dragSource = dgr.getDragSource();
+ }
+
+ /**
+ * Returns the source casted as a DragGestureRecognizer.
+ *
+ * @return the source casted as a DragGestureRecognizer.
+ */
+ public DragGestureRecognizer getSourceAsDragGestureRecognizer()
+ {
+ return (DragGestureRecognizer) getSource();
+ }
+
+ /**
+ * Returns the Component corresponding to this.
+ *
+ * @return the Component corresponding to this.
+ */
+ public Component getComponent()
+ {
+ return component;
+ }
+
+ /**
+ * Gets the DragSource corresponding to this.
+ *
+ * @return the DragSource corresponding to this.
+ */
+ public DragSource getDragSource()
+ {
+ return dragSource;
+ }
+
+ /**
+ * Returns the origin of the drag.
+ *
+ * @return the origin of the drag.
+ */
+ public Point getDragOrigin()
+ {
+ return origin;
+ }
+
+ /**
+ * Gets an iterator representation of the List of events.
+ *
+ * @return an iterator representation of the List of events.
+ */
+ public Iterator iterator()
+ {
+ return events.iterator();
+ }
+
+ /**
+ * Gets an array representation of the List of events.
+ *
+ * @return an array representation of the List of events.
+ */
+ public Object[] toArray()
+ {
+ return events.toArray();
+ }
+
+ /**
+ * Gets an array representation of the List of events.
+ *
+ * @param array - the array to store the events in.
+ * @return an array representation of the List of events.
+ */
+ public Object[] toArray(Object[] array)
+ {
+ return events.toArray(array);
+ }
+
+ /**
+ * Gets the user's preferred action.
+ *
+ * @return the user's preferred action.
+ */
+ public int getDragAction()
+ {
+ return action;
+ }
+
+ /**
+ * Get the event that triggered this gesture.
+ *
+ * @return the event that triggered this gesture.
+ */
+ public InputEvent getTriggerEvent()
+ {
+ return dgr.getTriggerEvent();
+ }
+
+ /**
+ * Starts the drag given the initial Cursor to display, the Transferable
+ * object, and the DragSourceListener to use.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(Cursor dragCursor, Transferable trans)
+ {
+ startDrag(dragCursor, null, null, trans, null);
+ }
+
+ /**
+ * Starts the drag given the initial Cursor to display, the Transferable
+ * object, and the DragSourceListener to use.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(Cursor dragCursor, Transferable trans,
+ DragSourceListener l)
+ {
+ startDrag(dragCursor, null, null, trans, l);
+ }
+
+ /**
+ * Starts the drag given the initial Cursor to display, the Transferable
+ * object, and the DragSourceListener to use.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(Cursor dragCursor, Image dragImage, Point imageOffset,
+ Transferable trans, DragSourceListener l)
+ {
+ dragSource.startDrag(this, dragCursor, dragImage, imageOffset, trans, l);
+ }
+} // class DragGestureEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,63 @@
+/* DragGestureListener.java --
+ Copyright (C) 2002, 2005 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.dnd;
+
+import java.util.EventListener;
+
+/**
+ * This is a listener for starting a drag-and-drop gesture. Upon receiving
+ * notification, the implementor then starts the drag operation.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see DragGestureRecognizer
+ * @see DragGestureEvent
+ * @see DragSource
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface DragGestureListener extends EventListener
+{
+ /**
+ * Called when the native platform notifies the virtual machine that a
+ * drag-and-drop has been initiated.
+ *
+ * @param e the event
+ */
+ void dragGestureRecognized(DragGestureEvent e);
+} // interface DragGestureListener
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragGestureRecognizer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,189 @@
+/* DragGestureRecognizer.java --
+ Copyright (C) 2002,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.dnd;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.event.InputEvent;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.TooManyListenersException;
+
+/**
+ * STUBBED
+ * @since 1.2
+ */
+public abstract class DragGestureRecognizer implements Serializable
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 8996673345831063337L;
+
+ protected DragSource dragSource;
+ protected Component component;
+ protected transient DragGestureListener dragGestureListener;
+ protected int sourceActions;
+ protected ArrayList events = new ArrayList();
+
+ protected DragGestureRecognizer(DragSource ds, Component c, int sa,
+ DragGestureListener dgl)
+ {
+ if (ds == null)
+ throw new IllegalArgumentException();
+ dragSource = ds;
+ component = c;
+ sourceActions = sa;
+ dragGestureListener = dgl;
+ }
+
+ protected DragGestureRecognizer(DragSource ds, Component c, int sa)
+ {
+ this(ds, c, sa, null);
+ }
+
+ protected DragGestureRecognizer(DragSource ds, Component c)
+ {
+ this(ds, c, 0, null);
+ }
+
+ protected DragGestureRecognizer(DragSource ds)
+ {
+ this(ds, null, 0, null);
+ }
+
+ protected abstract void registerListeners();
+
+ protected abstract void unregisterListeners();
+
+ public DragSource getDragSource()
+ {
+ return dragSource;
+ }
+
+ public Component getComponent()
+ {
+ return component;
+ }
+
+ public void setComponent(Component c)
+ {
+ component = c;
+ }
+
+ public int getSourceActions()
+ {
+ return sourceActions;
+ }
+
+ public void setSourceActions(int sa)
+ {
+ sourceActions = sa;
+ }
+
+ public InputEvent getTriggerEvent()
+ {
+ return events.size() > 0 ? (InputEvent) events.get(0) : null;
+ }
+
+ public void resetRecognizer()
+ throws NotImplementedException
+ {
+ events = new ArrayList();
+ // FIXME: Not implemented fully.
+ }
+
+ /**
+ * Register a new DragGestureListener.
+ *
+ * @exception TooManyListenersException If a DragGestureListener has already
+ * been added.
+ */
+ public void addDragGestureListener(DragGestureListener dgl)
+ throws TooManyListenersException
+ {
+ if (dragGestureListener != null)
+ throw new TooManyListenersException();
+ dragGestureListener = dgl;
+ }
+
+ public void removeDragGestureListener(DragGestureListener dgl)
+ {
+ if (dragGestureListener != dgl)
+ throw new IllegalArgumentException();
+ dragGestureListener = null;
+ }
+
+ /**
+ * Fires a <code>DragGestureEvent</code> to the DragGestureListener
+ * associated with this object, if there is one.
+ */
+ protected void fireDragGestureRecognized(int dragAction, Point p)
+ {
+ if(dragGestureListener != null)
+ dragGestureListener.dragGestureRecognized
+ (new DragGestureEvent(this, dragAction, p, events));
+ }
+
+ protected void appendEvent(InputEvent e)
+ {
+ if (e == null)
+ return;
+ events.add(e);
+ }
+
+ private void readObject(ObjectInputStream s)
+ throws ClassNotFoundException, IOException
+ {
+ s.defaultReadObject();
+ dragGestureListener = (DragGestureListener) s.readObject();
+ }
+
+ private void writeObject(ObjectOutputStream s) throws IOException
+ {
+ s.defaultWriteObject();
+ s.writeObject(dragGestureListener instanceof Serializable
+ ? dragGestureListener : null);
+ }
+} // class DragGestureRecognizer
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSource.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSource.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSource.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSource.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,328 @@
+/* DragSource.java --
+ Copyright (C) 2002 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.dnd;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Toolkit;
+import java.awt.datatransfer.FlavorMap;
+import java.awt.datatransfer.SystemFlavorMap;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.io.Serializable;
+import java.util.EventListener;
+
+/**
+ * @since 1.2
+ */
+public class DragSource implements Serializable
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 6236096958971414066L;
+
+ public static final Cursor DefaultCopyDrop = null;
+ public static final Cursor DefaultMoveDrop = null;
+ public static final Cursor DefaultLinkDrop = null;
+ public static final Cursor DefaultCopyNoDrop = null;
+ public static final Cursor DefaultMoveNoDrop = null;
+ public static final Cursor DefaultLinkNoDrop = null;
+
+ private transient FlavorMap flavorMap = SystemFlavorMap.getDefaultFlavorMap ();
+ private transient DragSourceListener dragSourceListener;
+ private transient DragSourceMotionListener dragSourceMotionListener;
+
+ private static DragSource ds;
+ private DragSourceContextPeer peer;
+ private DragSourceContext context;
+
+ /**
+ * Initializes the drag source.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public DragSource()
+ {
+ if (GraphicsEnvironment.isHeadless())
+ {
+ ds = null;
+ throw new HeadlessException();
+ }
+ }
+
+ /**
+ * Gets the default drag source.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
+ */
+ public static DragSource getDefaultDragSource()
+ {
+ if (GraphicsEnvironment.isHeadless())
+ {
+ ds = null;
+ throw new HeadlessException();
+ }
+
+ if (ds == null)
+ ds = new DragSource();
+ return ds;
+ }
+
+ public static boolean isDragImageSupported()
+ throws NotImplementedException
+ {
+ // FIXME: Implement this
+ return false;
+ }
+
+ /**
+ * Start a drag, given the DragGestureEvent that initiated the drag.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
+ Image dragImage, Point imageOffset,
+ Transferable trans, DragSourceListener dsl,
+ FlavorMap map)
+ {
+ // http://www.javaworld.com/javaworld/jw-03-1999/jw-03-dragndrop.html
+
+ // This function creates a DragSourceContext object. This object tracks the
+ // state of the operation by listening to a native peer. In this situation,
+ // the DragSource may be obtained from the event or by an instance variable.
+ // This function also creates a new DragSourceContextPeer.
+
+ // This function sends the same message to the context, which then forwards
+ // it to the peer, passing itself as a parameter. Now, the native system has
+ // access to the Transferable through the context.
+
+ // FIXME: Add check to determine if dragging.
+
+ try
+ {
+ flavorMap = map;
+
+ if (peer == null)
+ peer = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
+
+ if (context == null)
+ context = createDragSourceContext(peer, trigger,
+ dragCursor,
+ dragImage,
+ imageOffset, trans,
+ dsl);
+
+ if (peer == null)
+ throw new InvalidDnDOperationException();
+
+ peer.startDrag(context, dragCursor, dragImage, imageOffset);
+ }
+ catch (Exception e)
+ {
+ throw new InvalidDnDOperationException("Drag and Drop system is "
+ + "unable to initiate a drag operation.");
+ }
+ }
+
+ /**
+ * Start a drag, given the DragGestureEvent that initiated the drag.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
+ Transferable trans, DragSourceListener dsl,
+ FlavorMap map)
+ {
+ startDrag(trigger, dragCursor, null, null, trans, dsl, map);
+ }
+
+ /**
+ * Start a drag, given the DragGestureEvent that initiated the drag.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
+ Image dragImage, Point imageOffset,
+ Transferable trans, DragSourceListener dsl)
+ {
+ startDrag(trigger, dragCursor, dragImage, imageOffset, trans, dsl, null);
+ }
+
+ /**
+ * Start a drag, given the DragGestureEvent that initiated the drag.
+ *
+ * @exception InvalidDnDOperationException If the Drag and Drop system is
+ * unable to initiate a drag operation, or if the user attempts to start
+ * a drag while an existing drag operation is still executing.
+ */
+ public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
+ Transferable trans, DragSourceListener dsl)
+ {
+ startDrag(trigger, dragCursor, null, null, trans, dsl, null);
+ }
+
+ /**
+ * Creates the DragSourceContext to handle this drag.
+ *
+ * @exception IllegalArgumentException
+ * @exception NullPointerException If dscp, dgl, dragImage or t is null.
+ */
+ protected DragSourceContext
+ createDragSourceContext(DragSourceContextPeer peer, DragGestureEvent dge,
+ Cursor cursor, Image image, Point offset,
+ Transferable t, DragSourceListener dsl)
+ {
+ return new DragSourceContext(peer, dge, cursor, image, offset, t, dsl);
+ }
+
+ public FlavorMap getFlavorMap()
+ {
+ return flavorMap;
+ }
+
+ public DragGestureRecognizer createDragGestureRecognizer(Class recognizer,
+ Component c,
+ int actions,
+ DragGestureListener dgl)
+ {
+ return Toolkit.getDefaultToolkit().createDragGestureRecognizer(recognizer,
+ this, c,
+ actions, dgl);
+ }
+
+ public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c,
+ int actions,
+ DragGestureListener dgl)
+ {
+ return createDragGestureRecognizer(MouseDragGestureRecognizer.class, c,
+ actions, dgl);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void addDragSourceListener(DragSourceListener l)
+ {
+ DnDEventMulticaster.add (dragSourceListener, l);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void removeDragSourceListener(DragSourceListener l)
+ {
+ DnDEventMulticaster.remove (dragSourceListener, l);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public DragSourceListener[] getDragSourceListeners()
+ {
+ return (DragSourceListener[]) getListeners (DragSourceListener.class);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void addDragSourceMotionListener(DragSourceMotionListener l)
+ {
+ DnDEventMulticaster.add (dragSourceMotionListener, l);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public void removeDragSourceMotionListener(DragSourceMotionListener l)
+ {
+ DnDEventMulticaster.remove (dragSourceMotionListener, l);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public DragSourceMotionListener[] getDragSourceMotionListeners ()
+ {
+ return (DragSourceMotionListener[]) getListeners
+ (DragSourceMotionListener.class);
+ }
+
+ /**
+ * @since 1.4
+ */
+ public EventListener[] getListeners (Class listenerType)
+ {
+ if (listenerType == DragSourceListener.class)
+ return DnDEventMulticaster.getListeners (dragSourceListener,
+ listenerType);
+
+ if (listenerType == DragSourceMotionListener.class)
+ return DnDEventMulticaster.getListeners (dragSourceMotionListener,
+ listenerType);
+
+ // Return an empty EventListener array.
+ return new EventListener [0];
+ }
+
+ /**
+ * TODO
+ * @return
+ *
+ * @since 1.5
+ */
+ public static int getDragThreshold()
+ throws NotImplementedException
+ {
+ // FIXME: Not implemented.
+ return 4;
+ }
+} // class DragSource
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceAdapter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceAdapter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceAdapter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceAdapter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,126 @@
+/* DragSourceAdapter.java -- drag-and-drop listener adapter
+ Copyright (C) 2002, 2005 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.dnd;
+
+/**
+ * This class implements <code>DragSourceListener</code> and
+ * <code>DragSourceMotionListener</code>, and implements all methods
+ * with empty bodies. This allows a listener interested in implementing only
+ * a subset of these interfaces to extend this class and override only the
+ * desired methods.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see DragSourceEvent
+ * @see DragSourceListener
+ * @see DragSourceMotionListener
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public abstract class DragSourceAdapter
+ implements DragSourceListener, DragSourceMotionListener
+{
+ /**
+ * Default constructor.
+ */
+ public DragSourceAdapter()
+ {
+ }
+
+ /**
+ * Called when the cursor hotspot enters a drop site which will accept the
+ * drag.
+ *
+ * @param e the event
+ */
+ public void dragEnter(DragSourceDragEvent e)
+ {
+ }
+
+ /**
+ * Called when the cursor hotspot moves inside of a drop site which will
+ * accept the drag.
+ *
+ * @param e the event
+ */
+ public void dragOver(DragSourceDragEvent e)
+ {
+ }
+
+ /**
+ * Called whenever the mouse is moved during a drag-and-drop operation.
+ *
+ * @param e the event
+ */
+ public void dragMouseMoved(DragSourceDragEvent e)
+ {
+ }
+
+ /**
+ * Called when the user modifies the drop gesture. This is often the case
+ * when additional mouse or key events are received during the drag.
+ *
+ * @param e the event
+ */
+ public void dropActionChanged(DragSourceDragEvent e)
+ {
+ }
+
+ /**
+ * Called when the cursor hotspot moves outside of a drop site which will
+ * accept the drag. This could also happen if the drop site is no longer
+ * active, or no longer accepts the drag.
+ *
+ * @param e the event
+ */
+ public void dragExit(DragSourceEvent e)
+ {
+ }
+
+ /**
+ * Called when the drag and drop operation is complete. After this event,
+ * <code>getDropSuccess</code> of the event is valid, and
+ * <code>getDropAction</code> holds the action requested by the drop site.
+ * Furthermore, the <code>DragSourceContext</code> is invalidated.
+ *
+ * @param e the event
+ */
+ public void dragDropEnd(DragSourceDropEvent e)
+ {
+ }
+} // class DragSourceAdapter
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,365 @@
+/* DragSourceContext.java --
+ Copyright (C) 2002 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.awt.dnd;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.io.Serializable;
+import java.util.TooManyListenersException;
+
+/**
+ * @since 1.2
+ */
+public class DragSourceContext
+ implements DragSourceListener, DragSourceMotionListener, Serializable
+{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ static final long serialVersionUID = -115407898692194719L;
+
+ protected static final int DEFAULT = 0;
+ protected static final int ENTER = 1;
+ protected static final int OVER = 2;
+ protected static final int CHANGED = 3;
+
+ private DragSourceContextPeer peer;
+ private Cursor cursor;
+ private Transferable transferable;
+ private DragGestureEvent trigger;
+ private DragSourceListener dragSourceListener;
+ private boolean useCustomCursor;
+ private int sourceActions;
+ private Image image;
+ private Point offset;
+
+ /**
+ * Initializes a drag source context.
+ *
+ * @exception IllegalArgumentException If Component or DragSource of trigger
+ * are null, the drag action for the trigger event is DnDConstants.ACTION_NONE
+ * or if the source actions for the DragGestureRecognizer associated with the
+ * trigger event are equal to DnDConstants.ACTION_NONE.
+ * @exception NullPointerException If peer, trans or trigger is null or if the
+ * image is not null but the offset is.
+ */
+ public DragSourceContext (DragSourceContextPeer peer,
+ DragGestureEvent trigger, Cursor cursor,
+ Image image, Point offset, Transferable trans,
+ DragSourceListener dsl)
+ {
+ if (peer == null
+ || trigger == null || trans == null
+ || (image != null && offset == null))
+ throw new NullPointerException ();
+
+ if (trigger.getComponent () == null
+ || trigger.getDragSource () == null
+ || trigger.getDragAction () == DnDConstants.ACTION_NONE
+ || trigger.getSourceAsDragGestureRecognizer ()
+ .getSourceActions () == DnDConstants.ACTION_NONE)
+ throw new IllegalArgumentException ();
+
+ this.peer = peer;
+ this.trigger = trigger;
+ this.cursor = cursor;
+ this.image = image;
+ this.offset = offset;
+ this.transferable = trans;
+ this.dragSourceListener = dsl;
+ this.sourceActions = trigger.getSourceAsDragGestureRecognizer().getSourceActions();
+
+ setCursor(cursor);
+ updateCurrentCursor(trigger.getDragAction(), sourceActions, DEFAULT);
+ }
+
+ /**
+ * Returns the DragSource object associated with the
+ * DragGestureEvent.
+ *
+ * @return the DragSource associated with the trigger.
+ */
+ public DragSource getDragSource()
+ {
+ return trigger.getDragSource ();
+ }
+
+ /**
+ * Returns the component associated with this.
+ *
+ * @return the component associated with the trigger.
+ */
+ public Component getComponent()
+ {
+ return trigger.getComponent ();
+ }
+
+ /**
+ * Gets the trigger associated with this.
+ *
+ * @return the trigger.
+ */
+ public DragGestureEvent getTrigger()
+ {
+ return trigger;
+ }
+
+ /**
+ * Returns the source actions for the DragGestureRecognizer.
+ *
+ * @return the source actions for DragGestureRecognizer.
+ */
+ public int getSourceActions()
+ {
+ if (sourceActions == 0)
+ sourceActions = trigger.getSourceAsDragGestureRecognizer().getSourceActions();
+ return sourceActions;
+ }
+
+ /**
+ * Sets the cursor for this drag operation to the specified cursor.
+ *
+ * @param cursor c - the Cursor to use, or null to use the default drag
+ * cursor.
+ */
+ public void setCursor(Cursor cursor)
+ {
+ if (cursor == null)
+ useCustomCursor = false;
+ else
+ useCustomCursor = true;
+ this.cursor = cursor;
+ peer.setCursor(cursor);
+ }
+
+ /**
+ * Returns the current cursor or null if the default
+ * drag cursor is used.
+ *
+ * @return the current cursor or null.
+ */
+ public Cursor getCursor()
+ {
+ return cursor;
+ }
+
+ /**
+ * Adds a <code>DragSourceListener</code>.
+ *
+ * @exception TooManyListenersException If a <code>DragSourceListener</code>
+ * has already been added.
+ */
+ public void addDragSourceListener (DragSourceListener dsl)
+ throws TooManyListenersException
+ {
+ if (dragSourceListener != null)
+ throw new TooManyListenersException ();
+
+ dragSourceListener = dsl;
+ }
+
+ public void removeDragSourceListener (DragSourceListener dsl)
+ {
+ if (dragSourceListener == dsl)
+ dragSourceListener = null;
+ }
+
+ /**
+ * This function tells the peer that the DataFlavors have been modified.
+ */
+ public void transferablesFlavorsChanged()
+ {
+ peer.transferablesFlavorsChanged();
+ }
+
+ /**
+ * Calls dragEnter on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
+ public void dragEnter(DragSourceDragEvent e)
+ {
+ if (dragSourceListener != null)
+ dragSourceListener.dragEnter(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragEnter(e);
+
+ updateCurrentCursor(e.getDropAction(), e.getTargetActions(), ENTER);
+ }
+
+ /**
+ * Calls dragOver on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
+ public void dragOver(DragSourceDragEvent e)
+ {
+ if (dragSourceListener != null)
+ dragSourceListener.dragOver(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragOver(e);
+
+ updateCurrentCursor(e.getDropAction(), e.getTargetActions(), OVER);
+ }
+
+ /**
+ * Calls dragExit on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceEvent
+ */
+ public void dragExit(DragSourceEvent e)
+ {
+ if (dragSourceListener != null)
+ dragSourceListener.dragExit(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragExit(e);
+
+ updateCurrentCursor(0, 0, DEFAULT);
+ }
+
+ /**
+ * Calls dropActionChanged on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
+ public void dropActionChanged(DragSourceDragEvent e)
+ {
+ if (dragSourceListener != null)
+ dragSourceListener.dropActionChanged(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dropActionChanged(e);
+
+ updateCurrentCursor(e.getDropAction(), e.getTargetActions(), CHANGED);
+ }
+
+ /**
+ * Calls dragDropEnd on the listeners registered with this
+ * and with the DragSource.
+ *
+ * @param e - the DragSourceDropEvent
+ */
+ public void dragDropEnd(DragSourceDropEvent e)
+ {
+ if (dragSourceListener != null)
+ dragSourceListener.dragDropEnd(e);
+
+ DragSource ds = getDragSource();
+ DragSourceListener[] dsl = ds.getDragSourceListeners();
+ for (int i = 0; i < dsl.length; i++)
+ dsl[i].dragDropEnd(e);
+ }
+
+ /**
+ * Calls dragMouseMoved on the listeners registered with the DragSource.
+ *
+ * @param e - the DragSourceDragEvent
+ */
+ public void dragMouseMoved(DragSourceDragEvent e)
+ {
+ DragSource ds = getDragSource();
+ DragSourceMotionListener[] dsml = ds.getDragSourceMotionListeners();
+ for (int i = 0; i < dsml.length; i++)
+ dsml[i].dragMouseMoved(e);
+ }
+
+ /**
+ * Returns the Transferable set with this object.
+ *
+ * @return the transferable.
+ */
+ public Transferable getTransferable()
+ {
+ return transferable;
+ }
+
+ /**
+ * This function sets the drag cursor for the specified operation, actions and
+ * status if the default drag cursor is active. Otherwise, the cursor is not
+ * updated in any way.
+ *
+ * @param dropOp - the current operation.
+ * @param targetAct - the supported actions.
+ * @param status - the status of the cursor (constant).
+ */
+ protected void updateCurrentCursor(int dropOp, int targetAct, int status)
+ throws NotImplementedException
+ {
+ // FIXME: Not implemented fully
+ if (!useCustomCursor)
+ {
+ Cursor cursor = null;
+ switch (status)
+ {
+ case ENTER:
+ break;
+ case CHANGED:
+ break;
+ case OVER:
+ break;
+ default:
+ break;
+ }
+
+ this.cursor = cursor;
+ peer.setCursor(cursor);
+ }
+ }
+} // class DragSourceContext
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDragEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDragEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDragEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDragEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,102 @@
+/* DragSourceDragEvent.java --
+ Copyright (C) 2002 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.dnd;
+
+import gnu.java.awt.EventModifier;
+
+/**
+ * @author Michael Koch
+ * @since 1.2
+ */
+public class DragSourceDragEvent extends DragSourceEvent
+{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = 481346297933902471L;
+
+ private final int dropAction;
+ private final int targetActions;
+ private final int gestureModifiers;
+
+ public DragSourceDragEvent(DragSourceContext context, int dropAction,
+ int actions, int modifiers)
+ {
+ super(context);
+ this.dropAction = dropAction;
+ targetActions = actions;
+ gestureModifiers = EventModifier.extend(modifiers);
+ }
+
+ public DragSourceDragEvent(DragSourceContext context, int dropAction,
+ int actions, int modifiers, int x, int y)
+ {
+ super(context, x, y);
+ this.dropAction = dropAction;
+ targetActions = actions;
+ gestureModifiers = EventModifier.extend(modifiers);
+ }
+
+ public int getTargetActions()
+ {
+ return targetActions;
+ }
+
+ public int getGestureModifiers()
+ {
+ return EventModifier.revert(gestureModifiers);
+ }
+
+ public int getGestureModifiersEx()
+ {
+ return gestureModifiers;
+ }
+
+ public int getUserAction()
+ {
+ return dropAction;
+ }
+
+ public int getDropAction()
+ {
+ return (dropAction
+ & targetActions
+ & ((DragSourceContext) source).getSourceActions());
+ }
+} // class DragSourceDragEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDropEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDropEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDropEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceDropEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* DragSourceDragEvent.java --
+ Copyright (C) 2002, 2005 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.dnd;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.2
+ *
+ * Written using JDK 1.4.1 Online API
+ * Status: JDK 1.4 complete
+ */
+public class DragSourceDropEvent extends DragSourceEvent
+{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -5571321229470821891L;
+
+ private final int dropAction;
+ private final boolean dropSuccess;
+
+ public DragSourceDropEvent (DragSourceContext context)
+ {
+ super (context);
+ this.dropAction = 0;
+ this.dropSuccess = false;
+ }
+
+ public DragSourceDropEvent (DragSourceContext context, int dropAction,
+ boolean dropSuccess)
+ {
+ super (context);
+ this.dropAction = dropAction;
+ this.dropSuccess = dropSuccess;
+ }
+
+ public DragSourceDropEvent (DragSourceContext context, int dropAction,
+ boolean dropSuccess, int x, int y)
+ {
+ super (context, x, y);
+ this.dropAction = dropAction;
+ this.dropSuccess = dropSuccess;
+ }
+
+ public int getDropAction()
+ {
+ return dropAction & ((DragSourceContext) source).getSourceActions();
+ }
+
+ public boolean getDropSuccess()
+ {
+ return dropSuccess;
+ }
+} // class DragSourceDropEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,93 @@
+/* DragSourceEvent.java --
+ Copyright (C) 2002 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.dnd;
+
+import java.awt.Point;
+import java.util.EventObject;
+
+/**
+ * @since 1.2
+ */
+public class DragSourceEvent extends EventObject
+{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -763287114604032641L;
+
+ private final boolean locationSpecified;
+ private final int x;
+ private final int y;
+
+ public DragSourceEvent(DragSourceContext context)
+ {
+ super(context);
+ locationSpecified = false;
+ x = 0;
+ y = 0;
+ }
+
+ public DragSourceEvent(DragSourceContext context, int x, int y)
+ {
+ super(context);
+ locationSpecified = true;
+ this.x = x;
+ this.y = y;
+ }
+
+ public DragSourceContext getDragSourceContext()
+ {
+ return (DragSourceContext) source;
+ }
+
+ public Point getLocation()
+ {
+ return locationSpecified ? new Point(x, y) : null;
+ }
+
+ public int getX()
+ {
+ return x;
+ }
+
+ public int getY()
+ {
+ return y;
+ }
+} // class DragSourceEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,97 @@
+/* DragSourceListener.java -- listen to events during the drag
+ Copyright (C) 2002, 2005 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.dnd;
+
+import java.util.EventListener;
+
+/**
+ * This class allows an object to listen for drag and drop events. It can
+ * be used to provide appropriate feedback for "drag over" actions. You can
+ * also use a <code>DragSourceAdapter</code> to filter the events you are
+ * interested in.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface DragSourceListener extends EventListener
+{
+ /**
+ * Called when the cursor hotspot enters a drop site which will accept the
+ * drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dragEnter(DragSourceDragEvent e);
+
+ /**
+ * Called when the cursor hotspot moves inside of a drop site which will
+ * accept the drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dragOver(DragSourceDragEvent e);
+
+ /**
+ * Called when the user modifies the drop gesture. This is often the case
+ * when additional mouse or key events are received during the drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dropActionChanged(DragSourceDragEvent e);
+
+ /**
+ * Called when the cursor hotspot moves outside of a drop site which will
+ * accept the drag. This could also happen if the drop site is no longer
+ * active, or no longer accepts the drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dragExit(DragSourceEvent e);
+
+ /**
+ * Called when the drag and drop operation is complete. After this event,
+ * <code>getDropSuccess</code> of the event is valid, and
+ * <code>getDropAction</code> holds the action requested by the drop site.
+ * Furthermore, the <code>DragSourceContext</code> is invalidated.
+ *
+ * @param e the drag source drag event
+ */
+ void dragDropEnd(DragSourceDropEvent e);
+} // interface DragSourceListener
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceMotionListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceMotionListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceMotionListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DragSourceMotionListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,64 @@
+/* DragSourceMotionListener.java -- tracks motion in the drag source
+ Copyright (C) 2002, 2005 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.dnd;
+
+import java.util.EventListener;
+
+/**
+ * This is a listener for mouse motion in the drag source before the drop
+ * event occurs. You can also use a <code>DragSourceAdapter</code> to filter
+ * the events you are interested in.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @see DragSourceDragEvent
+ * @see DragSource
+ * @see DragSourceListener
+ * @see DragSourceAdapter
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public interface DragSourceMotionListener extends EventListener
+{
+ /**
+ * Called whenever the mouse is moved during a drag-and-drop operation.
+ *
+ * @param e the event
+ */
+ void dragMouseMoved(DragSourceDragEvent e);
+} // interface DragSourceMotionListener
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTarget.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTarget.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTarget.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTarget.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,345 @@
+/* DropTarget.java --
+ Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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.dnd;
+
+import gnu.classpath.NotImplementedException;
+
+import java.awt.Component;
+import java.awt.GraphicsEnvironment;
+import java.awt.HeadlessException;
+import java.awt.Point;
+import java.awt.datatransfer.FlavorMap;
+import java.awt.dnd.peer.DropTargetPeer;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.LightweightPeer;
+import java.io.Serializable;
+import java.util.EventListener;
+import java.util.TooManyListenersException;
+
+/**
+ * @author Michael Koch
+ * @since 1.2
+ */
+public class DropTarget
+ implements DropTargetListener, EventListener, Serializable
+{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -6283860791671019047L;
+
+ protected static class DropTargetAutoScroller
+ implements ActionListener
+ {
+ private Component component;
+ private Point point;
+
+ protected DropTargetAutoScroller (Component c, Point p)
+ {
+ component = c;
+ point = p;
+ }
+
+ protected void updateLocation (Point newLocn)
+ {
+ point = newLocn;
+ }
+
+ protected void stop ()
+ throws NotImplementedException
+ {
+ // FIXME: implement this
+ }
+
+ public void actionPerformed (ActionEvent e)
+ throws NotImplementedException
+ {
+ // FIXME: implement this
+ }
+ }
+
+ private Component component;
+ private FlavorMap flavorMap;
+ private int actions;
+ private DropTargetPeer peer;
+ private DropTargetContext dropTargetContext;
+ private DropTargetListener dropTargetListener;
+ private DropTarget.DropTargetAutoScroller autoscroller;
+ private boolean active = true;
+
+ /**
+ * Creates a <code>DropTarget</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+ public DropTarget ()
+ {
+ this (null, 0, null, true, null);
+ }
+
+ /**
+ * Creates a <code>DropTarget</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+ public DropTarget (Component c, DropTargetListener dtl)
+ {
+ this (c, 0, dtl, true, null);
+ }
+
+ /**
+ * Creates a <code>DropTarget</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+ public DropTarget (Component c, int i, DropTargetListener dtl)
+ {
+ this (c, i, dtl, true, null);
+ }
+
+ /**
+ * Creates a <code>DropTarget</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+ public DropTarget (Component c, int i, DropTargetListener dtl, boolean b)
+ {
+ this (c, i, dtl, b, null);
+ }
+
+ /**
+ * Creates a <code>DropTarget</code> object.
+ *
+ * @exception HeadlessException If GraphicsEnvironment.isHeadless()
+ * returns true.
+ */
+ public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
+ FlavorMap fm)
+ {
+ if (GraphicsEnvironment.isHeadless ())
+ throw new HeadlessException ();
+
+ setComponent(c);
+ setDefaultActions(i);
+ dropTargetListener = dtl;
+ flavorMap = fm;
+
+ setActive (b);
+
+ if (c != null)
+ c.setDropTarget(this);
+ }
+
+ /**
+ * Sets the component associated with this drop target object.
+ */
+ public void setComponent (Component c)
+ {
+ component = c;
+ }
+
+ /**
+ * Returns the component associated with this drop target object.
+ */
+ public Component getComponent ()
+ {
+ return component;
+ }
+
+ /**
+ * Sets the default actions.
+ */
+ public void setDefaultActions (int ops)
+ {
+ actions = ops;
+ }
+
+ /**
+ * Returns the default actions.
+ */
+ public int getDefaultActions ()
+ {
+ return actions;
+ }
+
+ public void setActive (boolean active)
+ {
+ this.active = active;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ /**
+ * Adds a new <code>DropTargetListener</code>.
+ *
+ * @exception TooManyListenersException Sun's JDK does not, despite
+ * documentation, throw this exception here when you install an additional
+ * <code>DropTargetListener</code>. So to be compatible, we do the same
+ * thing.
+ */
+ public void addDropTargetListener (DropTargetListener dtl)
+ throws TooManyListenersException
+ {
+ if (dropTargetListener != null)
+ throw new TooManyListenersException ();
+
+ dropTargetListener = dtl;
+ }
+
+ public void removeDropTargetListener(DropTargetListener dtl)
+ {
+ if (dropTargetListener != null)
+ dropTargetListener = null;
+ }
+
+ public void dragEnter(DropTargetDragEvent dtde)
+ {
+ if (dropTargetListener != null)
+ dropTargetListener.dragEnter(dtde);
+ }
+
+ public void dragOver(DropTargetDragEvent dtde)
+ {
+ if (dropTargetListener != null)
+ dropTargetListener.dragOver(dtde);
+ }
+
+ public void dropActionChanged(DropTargetDragEvent dtde)
+ {
+ if (dropTargetListener != null)
+ dropTargetListener.dropActionChanged(dtde);
+ }
+
+ public void dragExit(DropTargetEvent dte)
+ {
+ if (dropTargetListener != null)
+ dropTargetListener.dragExit(dte);
+ }
+
+ public void drop(DropTargetDropEvent dtde)
+ {
+ if (dropTargetListener != null)
+ dropTargetListener.drop(dtde);
+ }
+
+ public FlavorMap getFlavorMap()
+ {
+ return flavorMap;
+ }
+
+ public void setFlavorMap(FlavorMap fm)
+ {
+ flavorMap = fm;
+ }
+
+ public void addNotify(ComponentPeer p)
+ {
+ Component c = component;
+ while (c != null && p instanceof LightweightPeer)
+ {
+ p = c.getPeer();
+ c = c.getParent();
+ }
+
+ if (p instanceof DropTargetPeer)
+ {
+ peer = ((DropTargetPeer) p);
+ peer.addDropTarget(this);
+ }
+ else
+ peer = null;
+ }
+
+ public void removeNotify(ComponentPeer p)
+ {
+ ((DropTargetPeer) peer).removeDropTarget(this);
+ peer = null;
+ p = null;
+ }
+
+ public DropTargetContext getDropTargetContext()
+ {
+ if (dropTargetContext == null)
+ dropTargetContext = createDropTargetContext ();
+
+ return dropTargetContext;
+ }
+
+ protected DropTargetContext createDropTargetContext()
+ {
+ if (dropTargetContext == null)
+ dropTargetContext = new DropTargetContext (this);
+
+ return dropTargetContext;
+ }
+
+ protected DropTarget.DropTargetAutoScroller createDropTargetAutoScroller
+ (Component c, Point p)
+ {
+ if (autoscroller == null)
+ autoscroller = new DropTarget.DropTargetAutoScroller (c, p);
+
+ return autoscroller;
+ }
+
+ protected void initializeAutoscrolling(Point p)
+ {
+ createDropTargetAutoScroller (component, p);
+ }
+
+ protected void updateAutoscroll(Point dragCursorLocn)
+ {
+ if (autoscroller != null)
+ autoscroller.updateLocation(dragCursorLocn);
+ }
+
+ protected void clearAutoscroll()
+ {
+ autoscroller = null;
+ }
+} // class DropTarget
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetAdapter.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetAdapter.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetAdapter.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetAdapter.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,100 @@
+/* DragSourceAdapter.java -- drag-and-drop listener adapter
+ Copyright (C) 2002, 2005 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.dnd;
+
+/**
+ * This class implements <code>DropTargetListener</code>, and implements all methods
+ * with empty bodies. This allows a listener interested in implementing only
+ * a subset of these interfaces to extend this class and override only the
+ * desired methods.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.4
+ * @status updated to 1.4
+ */
+public abstract class DropTargetAdapter
+ implements DropTargetListener
+{
+ /**
+ * Default constructor.
+ */
+ public DropTargetAdapter()
+ {
+ }
+
+ /**
+ * Called when the cursor hotspot enters a drop site which will accept the
+ * drag.
+ *
+ * @param e the event
+ */
+ public void dragEnter (DropTargetDragEvent e)
+ {
+ }
+
+ /**
+ * Called when the cursor hotspot moves inside of a drop site which will
+ * accept the drag.
+ *
+ * @param e the event
+ */
+ public void dragOver (DropTargetDragEvent e)
+ {
+ }
+
+ /**
+ * Called when the user modifies the drop gesture. This is often the case
+ * when additional mouse or key events are received during the drag.
+ *
+ * @param e the event
+ */
+ public void dropActionChanged (DropTargetDragEvent e)
+ {
+ }
+
+ /**
+ * Called when the cursor hotspot moves outside of a drop site which will
+ * accept the drag. This could also happen if the drop site is no longer
+ * active, or no longer accepts the drag.
+ *
+ * @param e the event
+ */
+ public void dragExit(DropTargetEvent e)
+ {
+ }
+} // class DropTargetAdapter
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetContext.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetContext.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetContext.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetContext.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,196 @@
+/* DropTargetContext.java --
+ Copyright (C) 2002, 2003, 2004, 2006, Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt.dnd;
+
+import java.awt.Component;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.peer.DropTargetContextPeer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.2
+ */
+public class DropTargetContext implements Serializable
+{
+ static final long serialVersionUID = -634158968993743371L;
+
+ protected class TransferableProxy implements Transferable
+ {
+ protected boolean isLocal;
+ protected Transferable transferable;
+
+ TransferableProxy(Transferable t, boolean local)
+ {
+ this.transferable = t;
+ this.isLocal = local;
+ }
+
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ return transferable.getTransferDataFlavors();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return transferable.isDataFlavorSupported(flavor);
+ }
+
+ public Object getTransferData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException
+ {
+ return transferable.getTransferData (flavor);
+ }
+ }
+
+ private DropTarget dropTarget;
+ private int targetActions;
+ private DropTargetContextPeer dtcp;
+
+ // package private
+ DropTargetContext(DropTarget dropTarget)
+ {
+ this.dropTarget = dropTarget;
+ }
+
+ public DropTarget getDropTarget()
+ {
+ return dropTarget;
+ }
+
+ public Component getComponent()
+ {
+ return dropTarget.getComponent();
+ }
+
+ public void addNotify(DropTargetContextPeer dtcp)
+ {
+ this.dtcp = dtcp;
+ }
+
+ public void removeNotify()
+ {
+ this.dtcp = null;
+ }
+
+ protected void setTargetActions(int actions)
+ {
+ targetActions = actions;
+ }
+
+ protected int getTargetActions()
+ {
+ return targetActions;
+ }
+
+ /**
+ * Signals that the drop is completed.
+ *
+ * @exception InvalidDnDOperationException If a drop is not outstanding.
+ */
+ public void dropComplete(boolean success)
+ {
+ if (dtcp != null)
+ dtcp.dropComplete(success);
+ }
+
+ protected void acceptDrag(int dragOperation)
+ {
+ if (dtcp != null)
+ dtcp.acceptDrag(dragOperation);
+ }
+
+ protected void rejectDrag()
+ {
+ if (dtcp != null)
+ dtcp.rejectDrag();
+ }
+
+ protected void acceptDrop(int dropOperation)
+ {
+ if (dtcp != null)
+ dtcp.acceptDrop(dropOperation);
+ }
+
+ protected void rejectDrop()
+ {
+ if (dtcp != null)
+ dtcp.rejectDrop();
+ }
+
+ protected DataFlavor[] getCurrentDataFlavors()
+ {
+ if (dtcp != null)
+ dtcp.getTransferDataFlavors();
+ return null;
+ }
+
+ protected List getCurrentDataFlavorsAsList()
+ {
+ return Arrays.asList(getCurrentDataFlavors());
+ }
+
+ protected boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return getCurrentDataFlavorsAsList().contains(flavor);
+ }
+
+ /**
+ * Return the <code>Transferable</code> operandof this operation.
+ *
+ * @exception InvalidDnDOperationException If a drag is not outstanding.
+ */
+ protected Transferable getTransferable()
+ throws InvalidDnDOperationException
+ {
+ // FIXME: Implement this
+ if (dtcp != null)
+ return dtcp.getTransferable();
+ return null;
+ }
+
+ protected Transferable createTransferableProxy(Transferable t, boolean local)
+ {
+ return new TransferableProxy(t, local);
+ }
+} // class DropTargetContext
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDragEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,153 @@
+/* DropTargetDragEvent.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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.dnd;
+
+import java.awt.Point;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.util.List;
+
+/**
+ * @since 1.2
+ */
+public class DropTargetDragEvent extends DropTargetEvent
+{
+ /**
+ * Compatible with 1.2+
+ */
+ private static final long serialVersionUID = -8422265619058953682L;
+
+ private final int dropAction;
+ private final int srcActions;
+ private final Point location;
+
+ /**
+ * Initializes a <code>DropTargetDragEvent</code>.
+ *
+ * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
+ * srcActions is not a bitwise mask of DnDConstants, or dtc is null.
+ * @exception NullPointerException If location is null.
+ */
+ public DropTargetDragEvent (DropTargetContext context, Point location,
+ int dropAction, int srcActions)
+ {
+ super (context);
+
+ if (location == null)
+ throw new NullPointerException ();
+
+ if (context == null)
+ throw new IllegalArgumentException ();
+
+ if (dropAction != DnDConstants.ACTION_NONE
+ && dropAction != DnDConstants.ACTION_COPY
+ && dropAction != DnDConstants.ACTION_MOVE
+ && dropAction != DnDConstants.ACTION_COPY_OR_MOVE
+ && dropAction != DnDConstants.ACTION_LINK
+ && dropAction != DnDConstants.ACTION_REFERENCE)
+ throw new IllegalArgumentException ();
+
+ int srcActionsMask = DnDConstants.ACTION_NONE
+ | DnDConstants.ACTION_COPY
+ | DnDConstants.ACTION_MOVE
+ | DnDConstants.ACTION_COPY_OR_MOVE
+ | DnDConstants.ACTION_LINK
+ | DnDConstants.ACTION_REFERENCE;
+
+ if (~(srcActions ^ srcActionsMask) != 0)
+ throw new IllegalArgumentException ();
+
+ this.dropAction = dropAction;
+ this.srcActions = srcActions;
+ this.location = location;
+ }
+
+ public void acceptDrag (int dragOperation)
+ {
+ context.acceptDrag (dragOperation);
+ }
+
+ public DataFlavor[] getCurrentDataFlavors ()
+ {
+ return context.getCurrentDataFlavors ();
+ }
+
+ public List getCurrentDataFlavorsAsList ()
+ {
+ return context.getCurrentDataFlavorsAsList ();
+ }
+
+ public int getDropAction()
+ {
+ return dropAction & ((DropTargetContext) source).getTargetActions();
+ }
+
+ public Point getLocation ()
+ {
+ return location;
+ }
+
+ public int getSourceActions ()
+ {
+ return srcActions;
+ }
+
+ public boolean isDataFlavorSupported (DataFlavor df)
+ {
+ return context.isDataFlavorSupported (df);
+ }
+
+ public void rejectDrag ()
+ {
+ context.rejectDrag ();
+ }
+
+ /**
+ * TODO
+ *
+ * @return
+ *
+ * @since 1.5
+ */
+ public Transferable getTransferable()
+ {
+ // FIXME: Not implemented
+ return null;
+ }
+} // class DropTargetDragEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetDropEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,170 @@
+/* DropTargetDropEvent.java --
+ Copyright (C) 2002 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.dnd;
+
+import java.awt.Point;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.util.List;
+
+/**
+ * @since 1.2
+ */
+public class DropTargetDropEvent extends DropTargetEvent
+{
+ /**
+ * Compatible with JDK 1.2+
+ */
+ private static final long serialVersionUID = -1721911170440459322L;
+
+ private final int dropAction;
+ private final int actions;
+ private final Point location;
+ private final boolean isLocalTx;
+
+ /**
+ * Initializes a <code>DropTargetDropEvent</code>. By default this constructor
+ * assumes that the target is not int same JVM.
+ *
+ * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
+ * actions is not a bitwise mask of DnDConstants, or dtc is null.
+ * @exception NullPointerException If location is null.
+ */
+ public DropTargetDropEvent(DropTargetContext dtc, Point location,
+ int dropAction, int actions)
+ {
+ this(dtc, location, dropAction, actions, false);
+ }
+
+ /**
+ * Initializes a <code>DropTargetDropEvent</code>.
+ *
+ * @exception IllegalArgumentException If dropAction is not one of DnDConstants,
+ * actions is not a bitwise mask of DnDConstants, or dtc is null.
+ * @exception NullPointerException If location is null.
+ */
+ public DropTargetDropEvent(DropTargetContext dtc, Point location,
+ int dropAction, int actions, boolean isLocalTx)
+ {
+ super(dtc);
+
+ if (location == null)
+ throw new NullPointerException();
+
+ if (dtc == null)
+ throw new IllegalArgumentException();
+
+ if (dropAction != DnDConstants.ACTION_NONE
+ && dropAction != DnDConstants.ACTION_COPY
+ && dropAction != DnDConstants.ACTION_MOVE
+ && dropAction != DnDConstants.ACTION_COPY_OR_MOVE
+ && dropAction != DnDConstants.ACTION_LINK
+ && dropAction != DnDConstants.ACTION_REFERENCE)
+ throw new IllegalArgumentException();
+
+ int actionsMask = DnDConstants.ACTION_NONE
+ | DnDConstants.ACTION_COPY
+ | DnDConstants.ACTION_MOVE
+ | DnDConstants.ACTION_COPY_OR_MOVE
+ | DnDConstants.ACTION_LINK
+ | DnDConstants.ACTION_REFERENCE;
+
+ if (~(actions ^ actionsMask) != 0)
+ throw new IllegalArgumentException();
+
+ this.dropAction = dropAction;
+ this.actions = actions;
+ this.location = location;
+ this.isLocalTx = isLocalTx;
+ }
+
+ public Point getLocation()
+ {
+ return location;
+ }
+
+ public DataFlavor[] getCurrentDataFlavors()
+ {
+ return context.getCurrentDataFlavors();
+ }
+
+ public List getCurrentDataFlavorsAsList()
+ {
+ return context.getCurrentDataFlavorsAsList();
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor flavor)
+ {
+ return context.isDataFlavorSupported(flavor);
+ }
+
+ public int getSourceActions()
+ {
+ return actions;
+ }
+
+ public int getDropAction()
+ {
+ return dropAction;
+ }
+
+ public Transferable getTransferable()
+ {
+ return context.getTransferable ();
+ }
+
+ public void acceptDrop(int dropAction)
+ {
+ context.acceptDrop(dropAction);
+ }
+
+ public void rejectDrop()
+ {
+ context.rejectDrop();
+ }
+
+ public void dropComplete(boolean success)
+ {
+ context.dropComplete(success);
+ }
+
+ public boolean isLocalTransfer()
+ {
+ return isLocalTx;
+ }
+} // class DropTargetDropEvent
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetEvent.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetEvent.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetEvent.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetEvent.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,58 @@
+/* DropTarget.java --
+ Copyright (C) 2002 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.dnd;
+
+import java.util.EventObject;
+
+public class DropTargetEvent extends EventObject
+{
+ private static final long serialVersionUID = 2821229066521922993L;
+
+ protected DropTargetContext context;
+
+ public DropTargetEvent (DropTargetContext context)
+ {
+ super (context);
+ this.context = context;
+ }
+
+ public DropTargetContext getDropTargetContext ()
+ {
+ return context;
+ }
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetListener.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetListener.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetListener.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/DropTargetListener.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,89 @@
+/* DropTargetListener.java -- listen to events during the drop
+ Copyright (C) 2002, 2005 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.dnd;
+
+import java.util.EventListener;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public interface DropTargetListener extends EventListener
+{
+ /**
+ * Called when the cursor hotspot enters a drop site which will accept the
+ * drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dragEnter (DropTargetDragEvent e);
+
+ /**
+ * Called when the cursor hotspot moves inside of a drop site which will
+ * accept the drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dragOver (DropTargetDragEvent e);
+
+ /**
+ * Called when the user modifies the drop gesture. This is often the case
+ * when additional mouse or key events are received during the drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dropActionChanged (DropTargetDragEvent e);
+
+ /**
+ * Called when the cursor hotspot moves outside of a drop site which will
+ * accept the drag. This could also happen if the drop site is no longer
+ * active, or no longer accepts the drag.
+ *
+ * @param e the drag source drag event
+ */
+ void dragExit (DropTargetEvent e);
+
+ /**
+ * Called when the drag operation has terminated with a drop.
+ *
+ * @param e the drag source drag event
+ */
+ void drop (DropTargetDropEvent e);
+} // interface DropTargetListener
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/InvalidDnDOperationException.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,74 @@
+/* InvalidDnDOperationException.java -- thrown when drag-and-drop fails
+ Copyright (C) 2002, 2005 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.dnd;
+
+/**
+ * Thrown when a method in the java.awt.dnd package is unable to perform a
+ * requested operation, usually because the underlying DnD system is in the
+ * wrong state.
+ *
+ * @author Eric Blake (ebb9 at email.byu.edu)
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class InvalidDnDOperationException extends IllegalStateException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -6062568741193956678L;
+
+ /**
+ * Create an exception without a message.
+ */
+ public InvalidDnDOperationException()
+ {
+ super();
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public InvalidDnDOperationException(String s)
+ {
+ super(s);
+ }
+} // class InvalidDnDOperationException
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/MouseDragGestureRecognizer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/MouseDragGestureRecognizer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/MouseDragGestureRecognizer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/MouseDragGestureRecognizer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,131 @@
+/* MouseDragGestureRecognizer.java --
+ Copyright (C) 2002, 2005 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.dnd;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+
+/**
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public abstract class MouseDragGestureRecognizer
+ extends DragGestureRecognizer
+ implements MouseListener, MouseMotionListener
+{
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
+ protected MouseDragGestureRecognizer (DragSource ds, Component c, int act,
+ DragGestureListener dgl)
+ {
+ super (ds, c, act, dgl);
+ }
+
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
+ protected MouseDragGestureRecognizer (DragSource ds, Component c, int act)
+ {
+ super (ds, c, act);
+ }
+
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
+ protected MouseDragGestureRecognizer (DragSource ds, Component c)
+ {
+ super (ds, c);
+ }
+
+ /**
+ * Creates a <code>MouseDragGestureRecognizer</code> object.
+ */
+ protected MouseDragGestureRecognizer (DragSource ds)
+ {
+ super (ds);
+ }
+
+ protected void registerListeners ()
+ {
+ component.addMouseListener (this);
+ component.addMouseMotionListener (this);
+ }
+
+ protected void unregisterListeners ()
+ {
+ component.removeMouseListener (this);
+ component.removeMouseMotionListener (this);
+ }
+
+ public void mouseClicked (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+
+ public void mousePressed (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+
+ public void mouseReleased (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+
+ public void mouseEntered (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+
+ public void mouseExited (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+
+ public void mouseDragged (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+
+ public void mouseMoved (MouseEvent e)
+ {
+ // Do nothing in here by default.
+ }
+} // class MouseDragGestureRecognizer
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/package.html
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/package.html?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/package.html (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/package.html Thu Nov 8 16:56:19 2007
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.awt.dnd package.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 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. -->
+
+<html>
+<head><title>GNU Classpath - java.awt.dnd</title></head>
+
+<body>
+<p>Events and listeners for drag and drop sources and targets.</p>
+
+</body>
+</html>
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DragSourceContextPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DragSourceContextPeer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DragSourceContextPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DragSourceContextPeer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,57 @@
+/* DragSourceContextPeer.java -- interface for drag-and-drop peers
+ Copyright (C) 2002 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.dnd.peer;
+
+import java.awt.Cursor;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.InvalidDnDOperationException;
+
+/**
+ * STUBBED
+ */
+public interface DragSourceContextPeer
+{
+ void startDrag(DragSourceContext context, Cursor c, Image i, Point p)
+ throws InvalidDnDOperationException;
+ Cursor getCursor();
+ void setCursor(Cursor c) throws InvalidDnDOperationException;
+ void transferablesFlavorsChanged();
+} // interface DragSourceContextPeer
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetContextPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetContextPeer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetContextPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetContextPeer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,68 @@
+/* DropTargetContextPeer.java -- interface for drag-and-drop peers
+ Copyright (C) 2002, 2004, 2005 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.dnd.peer;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.InvalidDnDOperationException;
+
+
+/**
+ * Used to control state of recipient protocol from the
+ * <code>DropTargetListener</code>. Occurs when a <code>Component</code>
+ * with an associated <code>DropTarget</code> and visible geometry is first
+ * intersected by a logical cursor.
+ *
+ * @author Michael Koch (konqueror at gmx.de)
+ */
+public interface DropTargetContextPeer
+{
+ void setTargetActions(int actions);
+ int getTargetActions();
+ DropTarget getDropTarget();
+ DataFlavor[] getTransferDataFlavors();
+ Transferable getTransferable() throws InvalidDnDOperationException;
+ boolean isTransferableJVMLocal();
+ void acceptDrag(int dragAction);
+ void rejectDrag();
+ void acceptDrop(int dropAction);
+ void rejectDrop();
+ void dropComplete(boolean success);
+}
Added: llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetPeer.java
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetPeer.java?rev=43913&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetPeer.java (added)
+++ llvm-gcc-4.2/trunk/libjava/classpath/java/awt/dnd/peer/DropTargetPeer.java Thu Nov 8 16:56:19 2007
@@ -0,0 +1,48 @@
+/* DropTargetPeer.java -- interface for drag-and-drop peers
+ Copyright (C) 2002 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.dnd.peer;
+
+import java.awt.dnd.DropTarget;
+
+/**
+ */
+public interface DropTargetPeer
+{
+ void addDropTarget (DropTarget target);
+ void removeDropTarget (DropTarget target);
+} // interface DropTargetContextPeer
More information about the llvm-commits
mailing list