summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gilbert <david.gilbert@object-refinery.com>2006-07-26 06:27:27 +0000
committerDavid Gilbert <david.gilbert@object-refinery.com>2006-07-26 06:27:27 +0000
commit9279f29cf31e98480b3bec523ab8230f4d02f3d2 (patch)
tree87d6685747b4c1f2b4a2ef93b9558f8ca306cd21
parent31ce90710901a8b6936150c8fa701b73a27db3fc (diff)
downloadclasspath-9279f29cf31e98480b3bec523ab8230f4d02f3d2.tar.gz
2006-07-26 David Gilbert <david.gilbert@object-refinery.com>
* java/awt/image/BandedSampleModel.java (createCompatibleSampleModel): Fixed typo in loop increment, set correct scanlineStride, and updated API docs.
-rw-r--r--ChangeLog6
-rw-r--r--java/awt/image/BandedSampleModel.java40
2 files changed, 28 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 60d5db0b1..4f5c2e0a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-26 David Gilbert <david.gilbert@object-refinery.com>
+
+ * java/awt/image/BandedSampleModel.java
+ (createCompatibleSampleModel): Fixed typo in loop increment, set
+ correct scanlineStride, and updated API docs.
+
2006-07-25 Roman Kennke <kennke@aicas.com>
* javax/swing/plaf/basic/BasicPopupMenuUI.java
diff --git a/java/awt/image/BandedSampleModel.java b/java/awt/image/BandedSampleModel.java
index a346cf6af..33e945f44 100644
--- a/java/awt/image/BandedSampleModel.java
+++ b/java/awt/image/BandedSampleModel.java
@@ -107,10 +107,15 @@ public final class BandedSampleModel extends ComponentSampleModel
* Creates a new <code>SampleModel</code> that is compatible with this
* model and has the specified width and height.
*
- * @param w the width (in pixels).
- * @param h the height (in pixels).
+ * @param w the width (in pixels, must be greater than zero).
+ * @param h the height (in pixels, must be greater than zero).
*
* @return The new sample model.
+ *
+ * @throws IllegalArgumentException if <code>w</code> or <code>h</code> is
+ * not greater than zero.
+ * @throws IllegalArgumentException if <code>w * h</code> exceeds
+ * <code>Integer.MAX_VALUE</code>.
*/
public SampleModel createCompatibleSampleModel(int w, int h)
{
@@ -125,28 +130,27 @@ public final class BandedSampleModel extends ComponentSampleModel
// FIXME: This is N^2, but not a big issue, unless there's a lot of
// bands...
for (int i = 0; i < bandOffsets.length; i++)
- for (int j = i + 1; j < bandOffsets.length; i++)
- if (bankIndices[order[i]] > bankIndices[order[j]]
- || (bankIndices[order[i]] == bankIndices[order[j]]
- && bandOffsets[order[i]] > bandOffsets[order[j]]))
- {
- int t = order[i]; order[i] = order[j]; order[j] = t;
- }
+ for (int j = i + 1; j < bandOffsets.length; j++)
+ if (bankIndices[order[i]] > bankIndices[order[j]]
+ || (bankIndices[order[i]] == bankIndices[order[j]]
+ && bandOffsets[order[i]] > bandOffsets[order[j]]))
+ {
+ int t = order[i]; order[i] = order[j]; order[j] = t;
+ }
int bank = 0;
int offset = 0;
for (int i = 0; i < bandOffsets.length; i++)
{
- if (bankIndices[order[i]] != bank)
- {
- bank = bankIndices[order[i]];
- offset = 0;
- }
- newoffsets[order[i]] = offset;
- offset += w * scanlineStride;
+ if (bankIndices[order[i]] != bank)
+ {
+ bank = bankIndices[order[i]];
+ offset = 0;
+ }
+ newoffsets[order[i]] = offset;
+ offset += w * scanlineStride;
}
- return new BandedSampleModel(dataType, w, h, scanlineStride, bankIndices,
- newoffsets);
+ return new BandedSampleModel(dataType, w, h, w, bankIndices, newoffsets);
}