[kaffe] CVS kaffe (robilad): Resynced with GNU Classpath: awt and swing fixes
Kaffe CVS
cvs-commits at kaffe.org
Sun Jul 3 07:02:47 PDT 2005
PatchSet 6683
Date: 2005/07/03 13:58:06
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: awt and swing fixes
Members:
ChangeLog:1.4208->1.4209
libraries/javalib/Makefile.am:1.366->1.367
libraries/javalib/Makefile.in:1.456->1.457
libraries/javalib/all.files:1.137->1.138
libraries/javalib/java/awt/image/SampleModel.java:INITIAL->1.5
libraries/javalib/java/text/AttributedStringIterator.java:1.6->1.7
libraries/javalib/javax/swing/JFormattedTextField.java:1.10->1.11
libraries/javalib/javax/swing/JSpinner.java:1.7->1.8
libraries/javalib/javax/swing/plaf/metal/MetalLookAndFeel.java:1.10->1.11
libraries/javalib/javax/swing/plaf/metal/MetalScrollBarUI.java:1.2->1.3
libraries/javalib/javax/swing/plaf/metal/MetalSplitPaneDivider.java:INITIAL->1.1
libraries/javalib/javax/swing/plaf/metal/MetalSplitPaneUI.java:1.2->1.3
libraries/javalib/javax/swing/plaf/metal/MetalUtils.java:INITIAL->1.1
libraries/javalib/javax/swing/text/DateFormatter.java:INITIAL->1.1
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4208 kaffe/ChangeLog:1.4209
--- kaffe/ChangeLog:1.4208 Sun Jul 3 02:14:03 2005
+++ kaffe/ChangeLog Sun Jul 3 13:58:06 2005
@@ -2,6 +2,58 @@
Resynced with GNU Classpath.
+ 2005-06-13 Ziga Mahkovec <ziga.mahkovec at klika.si>
+
+ * java/awt/image/SampleModel.java (getPixels): Fixed array
+ assignment.
+
+ 2005-06-13 Ziga Mahkovec <ziga.mahkovec at klika.si>
+
+ * java/text/AttributedStringIterator.java (getRunLimit): Fixed the
+ range of the returned indexes.
+
+ 2005-06-13 Roman Kennke <roman at kennke.org>
+
+ * javax/swing/plaf/metal/MetalUtils.java:
+ Added new package-private helper class.
+ * javax/swing/plaf/metal/MetalSplitPaneDivider.java:
+ Added new package-private class. This is the divider used
+ by JSplitPane.
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (paintThumb): Use new MetalUtils class for drawing the typical
+ Metal pattern on the thumb.
+ * javax/swing/plaf/metal/MetalScrollBarUI.java
+ (initComponentDefaults): Added color defaults for SplitPane.
+ * javax/swing/plaf/metal/MetalSplitPaneUI.java:
+ (createDefaultDivider): Implemented new method. This creates
+ the Metal divider for JSplitPane.
+
+ 2005-06-13 Roman Kennke <roman at kennke.org>
+
+ * javax/swing/JSpinner.java
+ (StubEditor): Removed this inner class.
+ (DefaultEditor): Implemented this class and its dummy methods.
+ (DateEditor): Added and implemented this inner class.
+
+ 2005-06-13 Roman Kennke <roman at kennke.org>
+
+ * javax/swing/JFormattedTextField.java
+ (setValue): Creates an AbstractFormatter instance based on the type
+ of the value beeing set.
+ (createFormatter): New helper method.
+
+
+ 2005-06-13 Roman Kennke <roman at kennke.org>
+
+ * javax/swing/text/DateFormatter.java:
+ Implemented new class.
+ * javax/swing/JFormattedTextField.java
+ (setValue): Added conversion from value to text.
+
+2005-07-03 Dalibor Topic <robilad at kaffe.org>
+
+ Resynced with GNU Classpath.
+
2005-06-12 Ziga Mahkovec <ziga.mahkovec at klika.si>
* java/text/MessageFormat.java (parse): When parsing strings, check
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.366 kaffe/libraries/javalib/Makefile.am:1.367
--- kaffe/libraries/javalib/Makefile.am:1.366 Sun Jul 3 01:32:19 2005
+++ kaffe/libraries/javalib/Makefile.am Sun Jul 3 13:58:09 2005
@@ -3853,6 +3853,7 @@
javax/swing/plaf/metal/MetalScrollPaneUI.java \
javax/swing/plaf/metal/MetalSeparatorUI.java \
javax/swing/plaf/metal/MetalSliderUI.java \
+ javax/swing/plaf/metal/MetalSplitPaneDivider.java \
javax/swing/plaf/metal/MetalSplitPaneUI.java \
javax/swing/plaf/metal/MetalTabbedPaneUI.java \
javax/swing/plaf/metal/MetalTextFieldUI.java \
@@ -3860,7 +3861,8 @@
javax/swing/plaf/metal/MetalToggleButtonUI.java \
javax/swing/plaf/metal/MetalToolBarUI.java \
javax/swing/plaf/metal/MetalToolTipUI.java \
- javax/swing/plaf/metal/MetalTreeUI.java
+ javax/swing/plaf/metal/MetalTreeUI.java \
+ javax/swing/plaf/metal/MetalUtils.java
javax_swing_table_SRCS = \
javax/swing/table/AbstractTableModel.java \
javax/swing/table/DefaultTableCellRenderer.java \
@@ -3879,6 +3881,7 @@
javax/swing/text/Caret.java \
javax/swing/text/ChangedCharSetException.java \
javax/swing/text/ComponentView.java \
+ javax/swing/text/DateFormatter.java \
javax/swing/text/DefaultCaret.java \
javax/swing/text/DefaultEditorKit.java \
javax/swing/text/DefaultFormatter.java \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.456 kaffe/libraries/javalib/Makefile.in:1.457
--- kaffe/libraries/javalib/Makefile.in:1.456 Sun Jul 3 01:32:20 2005
+++ kaffe/libraries/javalib/Makefile.in Sun Jul 3 13:58:10 2005
@@ -4428,6 +4428,7 @@
javax/swing/plaf/metal/MetalScrollPaneUI.java \
javax/swing/plaf/metal/MetalSeparatorUI.java \
javax/swing/plaf/metal/MetalSliderUI.java \
+ javax/swing/plaf/metal/MetalSplitPaneDivider.java \
javax/swing/plaf/metal/MetalSplitPaneUI.java \
javax/swing/plaf/metal/MetalTabbedPaneUI.java \
javax/swing/plaf/metal/MetalTextFieldUI.java \
@@ -4435,7 +4436,8 @@
javax/swing/plaf/metal/MetalToggleButtonUI.java \
javax/swing/plaf/metal/MetalToolBarUI.java \
javax/swing/plaf/metal/MetalToolTipUI.java \
- javax/swing/plaf/metal/MetalTreeUI.java
+ javax/swing/plaf/metal/MetalTreeUI.java \
+ javax/swing/plaf/metal/MetalUtils.java
javax_swing_table_SRCS = \
javax/swing/table/AbstractTableModel.java \
@@ -4456,6 +4458,7 @@
javax/swing/text/Caret.java \
javax/swing/text/ChangedCharSetException.java \
javax/swing/text/ComponentView.java \
+ javax/swing/text/DateFormatter.java \
javax/swing/text/DefaultCaret.java \
javax/swing/text/DefaultEditorKit.java \
javax/swing/text/DefaultFormatter.java \
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.137 kaffe/libraries/javalib/all.files:1.138
--- kaffe/libraries/javalib/all.files:1.137 Sun Jul 3 01:32:23 2005
+++ kaffe/libraries/javalib/all.files Sun Jul 3 13:58:11 2005
@@ -3263,6 +3263,7 @@
javax/swing/plaf/metal/MetalScrollPaneUI.java
javax/swing/plaf/metal/MetalSeparatorUI.java
javax/swing/plaf/metal/MetalSliderUI.java
+javax/swing/plaf/metal/MetalSplitPaneDivider.java
javax/swing/plaf/metal/MetalSplitPaneUI.java
javax/swing/plaf/metal/MetalTabbedPaneUI.java
javax/swing/plaf/metal/MetalTextFieldUI.java
@@ -3271,6 +3272,7 @@
javax/swing/plaf/metal/MetalToolBarUI.java
javax/swing/plaf/metal/MetalToolTipUI.java
javax/swing/plaf/metal/MetalTreeUI.java
+javax/swing/plaf/metal/MetalUtils.java
javax/swing/table/AbstractTableModel.java
javax/swing/table/DefaultTableCellRenderer.java
javax/swing/table/DefaultTableColumnModel.java
@@ -3287,6 +3289,7 @@
javax/swing/text/Caret.java
javax/swing/text/ChangedCharSetException.java
javax/swing/text/ComponentView.java
+javax/swing/text/DateFormatter.java
javax/swing/text/DefaultCaret.java
javax/swing/text/DefaultEditorKit.java
javax/swing/text/DefaultFormatter.java
===================================================================
Checking out kaffe/libraries/javalib/java/awt/image/SampleModel.java
RCS: /home/cvs/kaffe/kaffe/libraries/javalib/java/awt/image/SampleModel.java,v
VERS: 1.5
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/libraries/javalib/java/awt/image/SampleModel.java Sun Jul 3 14:02:46 2005
@@ -0,0 +1,477 @@
+/* Copyright (C) 2000, 2001, 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.awt.image;
+
+/**
+ * @author Rolf W. Rasmussen (rolfwr at ii.uib.no)
+ */
+public abstract class SampleModel
+{
+ /** Width of image described. */
+ protected int width;
+
+ /** Height of image described. */
+ protected int height;
+
+ /** Number of bands in the image described. */
+ protected int numBands;
+
+ /**
+ * The DataBuffer type that is used to store the data of the image
+ * described.
+ */
+ protected int dataType;
+
+ public SampleModel(int dataType, int w, int h, int numBands)
+ {
+ if ((w <= 0) || (h <= 0))
+ throw new IllegalArgumentException((w <= 0 ? " width<=0" : " width is ok")
+ +(h <= 0 ? " height<=0" : " height is ok"));
+
+ // FIXME: How can an int be greater than Integer.MAX_VALUE?
+ // FIXME: How do we identify an unsupported data type?
+
+ this.dataType = dataType;
+ this.width = w;
+ this.height = h;
+ this.numBands = numBands;
+ }
+
+ public final int getWidth()
+ {
+ return width;
+ }
+
+ public final int getHeight()
+ {
+ return height;
+ }
+
+ public final int getNumBands()
+ {
+ return numBands;
+ }
+
+ public abstract int getNumDataElements();
+
+ public final int getDataType()
+ {
+ return dataType;
+ }
+
+ public int getTransferType()
+ {
+ // FIXME: Is this a reasonable default implementation?
+ return dataType;
+ }
+
+ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
+ {
+ if (iArray == null) iArray = new int[numBands];
+ for (int b=0; b<numBands; b++) iArray[b] = getSample(x, y, b, data);
+ return iArray;
+ }
+
+ /**
+ *
+ * This method is provided as a faster alternative to getPixel(),
+ * that can be used when there is no need to decode the pixel into
+ * separate sample values.
+ *
+ * @param obj An array to return the pixel data in. If null, an
+ * array of the right type and size will be created.
+ *
+ * @return A single pixel as an array object of a primitive type,
+ * based on the transfer type. Eg. if transfer type is
+ * DataBuffer.TYPE_USHORT, then a short[] object is returned.
+ */
+ public abstract Object getDataElements(int x, int y, Object obj,
+ DataBuffer data);
+
+
+ public Object getDataElements(int x, int y, int w, int h, Object obj,
+ DataBuffer data)
+ {
+ int size = w*h;
+ int numDataElements = getNumDataElements();
+ int dataSize = numDataElements*size;
+
+ if (obj == null)
+ {
+ switch (getTransferType())
+ {
+ case DataBuffer.TYPE_BYTE:
+ obj = new byte[dataSize];
+ break;
+ case DataBuffer.TYPE_USHORT:
+ obj = new short[dataSize];
+ break;
+ case DataBuffer.TYPE_INT:
+ obj = new int[dataSize];
+ break;
+ default:
+ // Seems like the only sensible thing to do.
+ throw new ClassCastException();
+ }
+ }
+ Object pixelData = null;
+ int outOffset = 0;
+ for (int yy = y; yy<(y+h); yy++)
+ {
+ for (int xx = x; xx<(x+w); xx++)
+ {
+ pixelData = getDataElements(xx, yy, pixelData, data);
+ System.arraycopy(pixelData, 0, obj, outOffset,
+ numDataElements);
+ outOffset += numDataElements;
+ }
+ }
+ return obj;
+ }
+
+ public abstract void setDataElements(int x, int y, Object obj,
+ DataBuffer data);
+
+ public void setDataElements(int x, int y, int w, int h,
+ Object obj, DataBuffer data)
+ {
+ int size = w*h;
+ int numDataElements = getNumDataElements();
+ int dataSize = numDataElements*size;
+
+ Object pixelData;
+ switch (getTransferType())
+ {
+ case DataBuffer.TYPE_BYTE:
+ pixelData = new byte[numDataElements];
+ break;
+ case DataBuffer.TYPE_USHORT:
+ pixelData = new short[numDataElements];
+ break;
+ case DataBuffer.TYPE_INT:
+ pixelData = new int[numDataElements];
+ break;
+ default:
+ // Seems like the only sensible thing to do.
+ throw new ClassCastException();
+ }
+ int inOffset = 0;
+
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ System.arraycopy(obj, inOffset, pixelData, 0,
+ numDataElements);
+ setDataElements(xx, yy, pixelData, data);
+ inOffset += numDataElements;
+ }
+ }
+ }
+
+ public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
+ {
+ if (fArray == null) fArray = new float[numBands];
+
+ for (int b=0; b<numBands; b++)
+ {
+ fArray[b] = getSampleFloat(x, y, b, data);
+ }
+ return fArray;
+ }
+
+ public double[] getPixel(int x, int y, double[] dArray, DataBuffer data) {
+ if (dArray == null) dArray = new double[numBands];
+ for (int b=0; b<numBands; b++)
+ {
+ dArray[b] = getSampleDouble(x, y, b, data);
+ }
+ return dArray;
+ }
+
+ /* FIXME: Should it return a banded or pixel interleaved array of
+ samples? (Assume interleaved.) */
+ public int[] getPixels(int x, int y, int w, int h, int[] iArray,
+ DataBuffer data)
+ {
+ int size = w*h;
+ int outOffset = 0;
+ int[] pixel = null;
+ if (iArray == null) iArray = new int[w*h*numBands];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ pixel = getPixel(xx, yy, pixel, data);
+ System.arraycopy(pixel, 0, iArray, outOffset, numBands);
+ outOffset += numBands;
+ }
+ }
+ return iArray;
+ }
+
+ /* FIXME: Should it return a banded or pixel interleaved array of
+ samples? (Assume interleaved.) */
+ public float[] getPixels(int x, int y, int w, int h, float[] fArray,
+ DataBuffer data)
+ {
+ int size = w*h;
+ int outOffset = 0;
+ float[] pixel = null;
+ if (fArray == null) fArray = new float[w*h*numBands];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ pixel = getPixel(xx, yy, pixel, data);
+ System.arraycopy(pixel, 0, fArray, outOffset, numBands);
+ outOffset += numBands;
+ }
+ }
+ return fArray;
+ }
+
+ /* FIXME: Should it return a banded or pixel interleaved array of
+ samples? (Assume interleaved.) */
+ public double[] getPixels(int x, int y, int w, int h, double[] dArray,
+ DataBuffer data)
+ {
+ int size = w*h;
+ int outOffset = 0;
+ double[] pixel = null;
+ if (dArray == null) dArray = new double[w*h*numBands];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ pixel = getPixel(xx, yy, pixel, data);
+ System.arraycopy(pixel, 0, dArray, outOffset, numBands);
+ outOffset += numBands;
+ }
+ }
+ return dArray;
+ }
+
+ public abstract int getSample(int x, int y, int b, DataBuffer data);
+
+ public float getSampleFloat(int x, int y, int b, DataBuffer data)
+ {
+ return getSample(x, y, b, data);
+ }
+
+ public double getSampleDouble(int x, int y, int b, DataBuffer data)
+ {
+ return getSampleFloat(x, y, b, data);
+ }
+
+ public int[] getSamples(int x, int y, int w, int h, int b,
+ int[] iArray, DataBuffer data)
+ {
+ int size = w*h;
+ int outOffset = 0;
+ if (iArray == null) iArray = new int[size];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ iArray[outOffset++] = getSample(xx, yy, b, data);
+ }
+ }
+ return iArray;
+ }
+
+ public float[] getSamples(int x, int y, int w, int h, int b,
+ float[] fArray, DataBuffer data)
+ {
+ int size = w*h;
+ int outOffset = 0;
+ if (fArray == null) fArray = new float[size];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ fArray[outOffset++] = getSampleFloat(xx, yy, b, data);
+ }
+ }
+ return fArray;
+ }
+
+ public double[] getSamples(int x, int y, int w, int h, int b,
+ double[] dArray, DataBuffer data)
+ {
+ int size = w*h;
+ int outOffset = 0;
+ if (dArray == null) dArray = new double[size];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ dArray[outOffset++] = getSampleDouble(xx, yy, b, data);
+ }
+ }
+ return dArray;
+ }
+
+ public void setPixel(int x, int y, int[] iArray, DataBuffer data)
+ {
+ for (int b=0; b<numBands; b++) setSample(x, y, b, iArray[b], data);
+ }
+
+ public void setPixel(int x, int y, float[] fArray, DataBuffer data)
+ {
+ for (int b=0; b<numBands; b++) setSample(x, y, b, fArray[b], data);
+ }
+
+ public void setPixel(int x, int y, double[] dArray, DataBuffer data)
+ {
+ for (int b=0; b<numBands; b++) setSample(x, y, b, dArray[b], data);
+ }
+
+ public void setPixels(int x, int y, int w, int h, int[] iArray,
+ DataBuffer data)
+ {
+ int inOffset = 0;
+ int[] pixel = new int[numBands];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ System.arraycopy(iArray, inOffset, pixel, 0, numBands);
+ setPixel(xx, yy, pixel, data);
+ inOffset += numBands;
+ }
+ }
+ }
+
+ public void setPixels(int x, int y, int w, int h, float[] fArray,
+ DataBuffer data)
+ {
+ int inOffset = 0;
+ float[] pixel = new float[numBands];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ System.arraycopy(fArray, inOffset, pixel, 0, numBands);
+ setPixel(xx, yy, pixel, data);
+ inOffset += numBands;
+ }
+ }
+ }
+
+ public void setPixels(int x, int y, int w, int h, double[] dArray,
+ DataBuffer data)
+ {
+ int inOffset = 0;
+ double[] pixel = new double[numBands];
+ for (int yy=y; yy<(y+h); yy++)
+ {
+ for (int xx=x; xx<(x+w); xx++)
+ {
+ System.arraycopy(dArray, inOffset, pixel, 0, numBands);
+ setPixel(xx, yy, pixel, data);
+ inOffset += numBands;
+ }
+ }
+ }
+
+ public abstract void setSample(int x, int y, int b, int s,
+ DataBuffer data);
+
+ public void setSample(int x, int y, int b, float s,
+ DataBuffer data)
+ {
+ setSample(x, y, b, (int) s, data);
+ }
+
+ public void setSample(int x, int y, int b, double s,
+ DataBuffer data)
+ {
+ setSample(x, y, b, (float) s, data);
+ }
+
+ public void setSamples(int x, int y, int w, int h, int b,
+ int[] iArray, DataBuffer data)
+ {
+ int size = w*h;
+ int inOffset = 0;
+ for (int yy=y; yy<(y+h); yy++)
+ for (int xx=x; xx<(x+w); xx++)
+ setSample(xx, yy, b, iArray[inOffset++], data);
+ }
+
+ public void setSamples(int x, int y, int w, int h, int b,
+ float[] fArray, DataBuffer data)
+ {
+ int size = w*h;
+ int inOffset = 0;
+ for (int yy=y; yy<(y+h); yy++)
+ for (int xx=x; xx<(x+w); xx++)
+ setSample(xx, yy, b, fArray[inOffset++], data);
+
+ }
+
+ public void setSamples(int x, int y, int w, int h, int b,
+ double[] dArray, DataBuffer data) {
+ int size = w*h;
+ int inOffset = 0;
+ for (int yy=y; yy<(y+h); yy++)
+ for (int xx=x; xx<(x+w); xx++)
+ setSample(xx, yy, b, dArray[inOffset++], data);
+ }
+
+ public abstract SampleModel createCompatibleSampleModel(int w, int h);
+
+ /**
+ * Return a SampleModel with a subset of the bands in this model.
+ *
+ * Selects bands.length bands from this sample model. The bands chosen
+ * are specified in the indices of bands[]. This also permits permuting
+ * the bands as well as taking a subset. Thus, giving an array with
+ * 1, 2, 3, ..., numbands, will give an identical sample model.
+ *
+ * @param bands Array with band indices to include.
+ * @return A new sample model
+ */
+ public abstract SampleModel createSubsetSampleModel(int[] bands);
+
+ public abstract DataBuffer createDataBuffer();
+
+ public abstract int[] getSampleSize();
+
+ public abstract int getSampleSize(int band);
+}
Index: kaffe/libraries/javalib/java/text/AttributedStringIterator.java
diff -u kaffe/libraries/javalib/java/text/AttributedStringIterator.java:1.6 kaffe/libraries/javalib/java/text/AttributedStringIterator.java:1.7
--- kaffe/libraries/javalib/java/text/AttributedStringIterator.java:1.6 Sun May 2 05:55:30 2004
+++ kaffe/libraries/javalib/java/text/AttributedStringIterator.java Sun Jul 3 13:58:15 2005
@@ -1,5 +1,5 @@
/* AttributedStringIterator.java -- Class to iterate over AttributedString
- Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -228,7 +228,7 @@
for (int i = 0; i < attribs.length; ++i)
{
if (pos >= attribs[i].begin_index &&
- pos <= attribs[i].end_index)
+ pos < attribs[i].end_index)
{
Iterator iter = attribute_set.iterator();
while(iter.hasNext())
@@ -242,7 +242,7 @@
if (hit)
return runLimit;
else
- return -1;
+ return ci.getEndIndex();
}
/*************************************************************************/
Index: kaffe/libraries/javalib/javax/swing/JFormattedTextField.java
diff -u kaffe/libraries/javalib/javax/swing/JFormattedTextField.java:1.10 kaffe/libraries/javalib/javax/swing/JFormattedTextField.java:1.11
--- kaffe/libraries/javalib/javax/swing/JFormattedTextField.java:1.10 Sat Jun 11 21:43:17 2005
+++ kaffe/libraries/javalib/javax/swing/JFormattedTextField.java Sun Jul 3 13:58:15 2005
@@ -42,7 +42,10 @@
import java.io.Serializable;
import java.text.Format;
import java.text.ParseException;
+import java.util.Date;
+import javax.swing.text.DateFormatter;
+import javax.swing.text.DefaultFormatter;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
import javax.swing.text.NavigationFilter;
@@ -296,9 +299,49 @@
{
if (value == newValue)
return;
-
+
+ // format value
+ AbstractFormatter formatter = createFormatter(newValue);
+ try
+ {
+ setText(formatter.valueToString(newValue));
+ }
+ catch (ParseException ex)
+ {
+ // TODO: what should we do with this?
+ }
+
Object oldValue = value;
value = newValue;
firePropertyChange("value", oldValue, newValue);
+ }
+
+ /**
+ * A helper method that attempts to create a formatter that is suitable
+ * to format objects of the type like <code>value</code>.
+ *
+ * If <code>formatterFactory</code> is not null and the returned formatter
+ * is also not <code>null</code> then this formatter is used. Otherwise we
+ * try to create one based on the type of <code>value</code>.
+ *
+ * @param value an object which should be formatted by the formatter
+ *
+ * @return a formatter able to format objects of the class of
+ * <code>value</code>
+ */
+ AbstractFormatter createFormatter(Object value)
+ {
+ AbstractFormatter formatter = null;
+ if (formatterFactory != null
+ && formatterFactory.getFormatter(this) != null)
+ formatter = formatterFactory.getFormatter(this);
+ else
+ {
+ if (value instanceof Date)
+ formatter = new DateFormatter();
+ else
+ formatter = new DefaultFormatter();
+ }
+ return formatter;
}
}
Index: kaffe/libraries/javalib/javax/swing/JSpinner.java
diff -u kaffe/libraries/javalib/javax/swing/JSpinner.java:1.7 kaffe/libraries/javalib/javax/swing/JSpinner.java:1.8
--- kaffe/libraries/javalib/javax/swing/JSpinner.java:1.7 Mon May 30 01:27:47 2005
+++ kaffe/libraries/javalib/javax/swing/JSpinner.java Sun Jul 3 13:58:15 2005
@@ -41,17 +41,19 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
+import java.awt.Insets;
import java.awt.LayoutManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.DecimalFormat;
import java.text.ParseException;
+import java.text.SimpleDateFormat;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.SpinnerUI;
-
+import javax.swing.text.DateFormatter;
/**
* A JSpinner is a component which typically contains a numeric value and a
@@ -66,53 +68,15 @@
/**
* DOCUMENT ME!
*/
- public static class StubEditor extends JLabel implements ChangeListener
- {
- /** DOCUMENT ME! */
- private JLabel label;
-
- /** DOCUMENT ME! */
- private JButton up;
-
- /** DOCUMENT ME! */
- private JButton down;
-
- /** DOCUMENT ME! */
- private JSpinner spinner;
-
- /**
- * Creates a new StubEditor object.
- *
- * @param spinner DOCUMENT ME!
- */
- public StubEditor(JSpinner spinner)
- {
- this.spinner = spinner;
- setBorder(new EtchedBorder());
- setHorizontalAlignment(SwingConstants.TRAILING);
- stateChanged(null); /* fill in the label */
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param evt DOCUMENT ME!
- */
- public void stateChanged(ChangeEvent evt)
- {
- setText(String.valueOf(spinner.getValue()));
- }
- }
-
- /**
- * DOCUMENT ME!
- */
public static class DefaultEditor extends JPanel implements ChangeListener,
PropertyChangeListener,
LayoutManager
{
private JSpinner spinner;
-
+
+ /** The JFormattedTextField that backs the editor. */
+ JFormattedTextField ftf;
+
/**
* For compatability with Sun's JDK 1.4.2 rev. 5
*/
@@ -125,8 +89,12 @@
*/
public DefaultEditor(JSpinner spinner)
{
+ super();
+ setLayout(this);
this.spinner = spinner;
-
+ ftf = new JFormattedTextField();
+ add(ftf);
+ ftf.setValue(spinner.getValue());
spinner.addChangeListener(this);
}
@@ -163,8 +131,8 @@
*/
public JFormattedTextField getTextField()
{
- return null;
- } /* TODO */
+ return ftf;
+ }
/**
* DOCUMENT ME!
@@ -173,7 +141,12 @@
*/
public void layoutContainer(Container parent)
{
- } /* TODO */
+ Insets insets = getInsets();
+ Dimension size = getSize();
+ ftf.setBounds(insets.left, insets.top,
+ size.width - insets.left - insets.right,
+ size.height - insets.top - insets.bottom);
+ }
/**
* DOCUMENT ME!
@@ -184,8 +157,11 @@
*/
public Dimension minimumLayoutSize(Container parent)
{
- return null;
- } /* TODO */
+ Insets insets = getInsets();
+ Dimension minSize = ftf.getMinimumSize();
+ return new Dimension(minSize.width + insets.left + insets.right,
+ minSize.height + insets.top + insets.bottom);
+ }
/**
* DOCUMENT ME!
@@ -196,8 +172,11 @@
*/
public Dimension preferredLayoutSize(Container parent)
{
- return null;
- } /* TODO */
+ Insets insets = getInsets();
+ Dimension prefSize = ftf.getPreferredSize();
+ return new Dimension(prefSize.width + insets.left + insets.right,
+ prefSize.height + insets.top + insets.bottom);
+ }
/**
* DOCUMENT ME!
@@ -279,6 +258,95 @@
}
}
+ /**
+ * An editor class for a <code>JSpinner</code> that is used
+ * for displaying and editing dates (e.g. that uses
+ * <code>SpinnerDateModel</code> as model).
+ *
+ * The editor uses a {@link JTextField} with the value
+ * displayed by a {@link DateFormatter} instance.
+ */
+ public static class DateEditor extends DefaultEditor
+ {
+
+ /** The serialVersionUID. */
+ private static final long serialVersionUID = -4279356973770397815L;
+
+ /** The DateFormat instance used to format the date. */
+ SimpleDateFormat dateFormat;
+
+ /**
+ * Creates a new instance of DateEditor for the specified
+ * <code>JSpinner</code>.
+ *
+ * @param spinner the <code>JSpinner</code> for which to
+ * create a <code>DateEditor</code> instance
+ */
+ public DateEditor(JSpinner spinner)
+ {
+ super(spinner);
+ init(new SimpleDateFormat());
+ }
+
+ /**
+ * Creates a new instance of DateEditor for the specified
+ * <code>JSpinner</code> using the specified date format
+ * pattern.
+ *
+ * @param spinner the <code>JSpinner</code> for which to
+ * create a <code>DateEditor</code> instance
+ * @param dateFormatPattern the date format to use
+ *
+ * @see SimpleDateFormat(String)
+ */
+ public DateEditor(JSpinner spinner, String dateFormatPattern)
+ {
+ super(spinner);
+ init(new SimpleDateFormat(dateFormatPattern));
+ }
+
+ /**
+ * Initializes the JFormattedTextField for this editor.
+ *
+ * @param the date format to use in the formatted text field
+ */
+ private void init(SimpleDateFormat format)
+ {
+ dateFormat = format;
+ getTextField().setFormatterFactory(
+ new JFormattedTextField.AbstractFormatterFactory()
+ {
+ public JFormattedTextField.AbstractFormatter
+ getFormatter(JFormattedTextField ftf)
+ {
+ return new DateFormatter(dateFormat);
+ }
+ });
+ }
+
+ /**
+ * Returns the <code>SimpleDateFormat</code> instance that is used to
+ * format the date value.
+ *
+ * @return the <code>SimpleDateFormat</code> instance that is used to
+ * format the date value
+ */
+ public SimpleDateFormat getFormat()
+ {
+ return dateFormat;
+ }
+
+ /**
+ * Returns the {@link SpinnerDateModel} that is edited by this editor.
+ *
+ * @return the <code>SpinnerDateModel</code> that is edited by this editor
+ */
+ public SpinnerDateModel getModel()
+ {
+ return (SpinnerDateModel) getSpinner().getModel();
+ }
+ }
+
private static final long serialVersionUID = 3412663575706551720L;
*** Patch too long, truncated ***
More information about the kaffe
mailing list