|
From: <nr...@us...> - 2011-07-08 15:59:35
|
Revision: 15676
http://dcm4che.svn.sourceforge.net/dcm4che/?rev=15676&view=rev
Author: nroduit
Date: 2011-07-08 15:59:29 +0000 (Fri, 08 Jul 2011)
Log Message:
-----------
fix nullpointer exception
Modified Paths:
--------------
weasis/weasis_framework/trunk/weasis-core/weasis-core-api/src/main/java/org/weasis/core/api/media/data/Thumbnail.java
Modified: weasis/weasis_framework/trunk/weasis-core/weasis-core-api/src/main/java/org/weasis/core/api/media/data/Thumbnail.java
===================================================================
--- weasis/weasis_framework/trunk/weasis-core/weasis-core-api/src/main/java/org/weasis/core/api/media/data/Thumbnail.java 2011-07-08 14:36:37 UTC (rev 15675)
+++ weasis/weasis_framework/trunk/weasis-core/weasis-core-api/src/main/java/org/weasis/core/api/media/data/Thumbnail.java 2011-07-08 15:59:29 UTC (rev 15676)
@@ -108,8 +108,9 @@
public Thumbnail(final MediaSeries<E> sequence, File thumbnailPath, int thumbnailSize) {
super(null, null, SwingConstants.CENTER);
- if (sequence == null)
+ if (sequence == null) {
throw new IllegalArgumentException("Sequence cannot be null"); //$NON-NLS-1$
+ }
this.thumbnailSize = thumbnailSize;
this.series = sequence;
this.thumbnailPath = thumbnailPath;
@@ -323,17 +324,22 @@
BufferedImage img = null;
try {
img = future.get();
- int width = img.getWidth();
- int height = img.getHeight();
- if (width > thumbnailSize || height > thumbnailSize) {
- final double scale = Math.min(thumbnailSize / (double) height, thumbnailSize / (double) width);
- PlanarImage t =
- scale < 1.0 ? SubsampleAverageDescriptor.create(img, scale, scale, DownScaleQualityHints)
- : PlanarImage.wrapRenderedImage(img);
- thumb = t.getAsBufferedImage();
- t.dispose();
+ if (img == null) {
+ thumb = null;
} else {
- thumb = img;
+ int width = img.getWidth();
+ int height = img.getHeight();
+ if (width > thumbnailSize || height > thumbnailSize) {
+ final double scale =
+ Math.min(thumbnailSize / (double) height, thumbnailSize / (double) width);
+ PlanarImage t =
+ scale < 1.0 ? SubsampleAverageDescriptor.create(img, scale, scale,
+ DownScaleQualityHints) : PlanarImage.wrapRenderedImage(img);
+ thumb = t.getAsBufferedImage();
+ t.dispose();
+ } else {
+ thumb = img;
+ }
}
} catch (InterruptedException e) {
@@ -353,8 +359,9 @@
imageSoftRef = new SoftReference<BufferedImage>(thumb);
}
}
- if (imageSoftRef == null)
+ if (imageSoftRef == null) {
return null;
+ }
return imageSoftRef.get();
}
@@ -465,8 +472,9 @@
private JPanel getScrollPane() {
Container container = getParent();
while (container != null) {
- if (container.getParent() instanceof JViewport)
+ if (container.getParent() instanceof JViewport) {
return (JPanel) container;
+ }
container = container.getParent();
}
return null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|