Changeset 7511


Ignore:
Timestamp:
Nov 1, 2018, 12:52:00 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2129: Preparations for Java 11 support

Fixes the errors in TestSpotImages.

The problem was caused by the JAI toolkit that tries to use an old and internal (com.sun.image.codec.jpeg.JPEGCodec) implementation of JPEG encoding/decoding. The old implementation was replaced with a new one (in javax.imageio) a long time ago, but JAI has not been updated.

The code in BASE has been updated to use javax.imageio for handling JPEG images.

We have also deprecated all functionality that is related to spot images, because we don't know how much longer JAI will be working and we don't have the resources to fully replace it with something new.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/PermissionUtil.java

    r7406 r7511  
    162162    All items which permissions depend on some other item only.
    163163  */
     164  @SuppressWarnings("deprecation")
    164165  private static final Set<Item> ignored = EnumSet.of(
    165166    Item.SYSTEM, Item.HELP,
  • trunk/src/clients/web/net/sf/basedb/clients/web/formatter/SpotImageFormatter.java

    r6135 r7511  
    3434  @version 2.0
    3535  @base.modified $Date$
     36  @deprecated In 3.14, will be removed in the future without replacement
    3637*/
     38@Deprecated
    3739public class SpotImageFormatter
    3840  implements Formatter<Integer>
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/ViewSpotImage.java

    r7159 r7511  
    5050   @version 2.0
    5151   @base.modified $Date$
     52  @deprecated In 3.14, will be removed in the future without replacement
    5253*/
    53 
     54@Deprecated
    5455public final class ViewSpotImage
    5556  extends HttpServlet
  • trunk/src/core/net/sf/basedb/core/File.java

    r7381 r7511  
    575575    @since 2.2
    576576  */
     577  @SuppressWarnings("deprecation")
    577578  @Override
    578579  public Set<ItemProxy> getUsingItems()
  • trunk/src/core/net/sf/basedb/core/Item.java

    r7431 r7511  
    505505  /**
    506506    The item is a {@link SpotImages}.
    507   */
     507    @deprecated In 3.14, will be removed in the future without replacement
     508  */
     509  @Deprecated
    508510  SPOTIMAGES(265, "Spot images", "spi", SpotImages.class, SpotImagesData.class, null,
    509511    310),
  • trunk/src/core/net/sf/basedb/core/RawBioAssay.java

    r7447 r7511  
    934934    @throws BaseException If there is some kind of error.
    935935    @see #hasSpotImages()
    936   */
     936    @deprecated In 3.14, will be removed in the future without replacement
     937  */
     938  @Deprecated
    937939  public SpotImages getSpotImages()
    938940    throws PermissionDeniedException, BaseException
     
    955957    Check if spot images exists for this raw bioassay or not.
    956958    @see #getSpotImages()
    957   */
     959    @deprecated In 3.14, will be removed in the future without replacement
     960  */
     961  @Deprecated
    958962  public boolean hasSpotImages()
    959963  {
  • trunk/src/core/net/sf/basedb/core/SpotImages.java

    r6881 r7511  
    4141import java.io.ByteArrayOutputStream;
    4242import java.awt.image.RenderedImage;
     43import java.awt.image.BufferedImage;
    4344import java.awt.image.DataBuffer;
    4445import java.awt.image.renderable.ParameterBlock;
    4546
     47import javax.imageio.IIOImage;
     48import javax.imageio.ImageIO;
     49import javax.imageio.ImageWriteParam;
     50import javax.imageio.ImageWriter;
     51import javax.imageio.stream.MemoryCacheImageOutputStream;
    4652import javax.media.jai.JAI;
    4753import javax.media.jai.RenderedOp;
     
    5258import com.sun.media.jai.codec.TIFFDecodeParam;
    5359import com.sun.media.jai.codec.SeekableStream;
    54 import com.sun.media.jai.codec.JPEGEncodeParam;
    5560
    5661
     
    6671  @base.modified $Date$
    6772  @version 2.0
     73  @deprecated In 3.14, will be removed in the future without replacement
    6874*/
     75@Deprecated
    6976public class SpotImages
    7077  extends ChildItem
     
    605612      int lastImageNumber = -1;
    606613      // Holds a single NxN image
    607       RenderedOp image = null;
     614      BufferedImage image = null;
    608615      final int spotsize = getSpotsize();
    609616      final int spotImagesPerImage = NUM_SPOT_IMAGES * NUM_SPOT_IMAGES;
     
    633640            else
    634641            {
    635               // Open it as RenderedOp object
    636               SeekableStream stream = SeekableStream.wrapInputStream(zipFile.getInputStream(zipEntry), true);
    637               ParameterBlock jpegParameters = new ParameterBlock();
    638               jpegParameters.add(stream);
    639               image = JAI.create("jpeg", jpegParameters);
     642              // Open it as BufferedImage object
     643              image = ImageIO.read(zipFile.getInputStream(zipEntry));
    640644            }
    641645            lastImageNumber = imageNumber;
     
    956960  {
    957961    zipFileStream.putNextEntry(new ZipEntry(fileName));
    958     JPEGEncodeParam jpegParam = new JPEGEncodeParam();
    959     jpegParam.setQuality(quality);
    960     ParameterBlock encodeParameters = new ParameterBlock();
    961     encodeParameters.addSource(image);
    962     encodeParameters.add(zipFileStream);
    963     encodeParameters.add("jpeg");
    964     encodeParameters.add(jpegParam);
    965     JAI.create("encode", encodeParameters);
     962    ImageWriter jpgWriter = ImageIO.getImageWritersByFormatName("jpg").next();
     963    ImageWriteParam jpgParam = jpgWriter.getDefaultWriteParam();
     964    jpgParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
     965    jpgParam.setCompressionQuality(quality);
     966    jpgWriter.setOutput(new MemoryCacheImageOutputStream(zipFileStream));
     967    jpgWriter.write(null, new IIOImage(image, null, null), jpgParam);
     968    jpgWriter.dispose();
    966969  }
    967970 
  • trunk/src/plugins/core/net/sf/basedb/plugins/SpotImageCreator.java

    r6127 r7511  
    5050  @version 2.0
    5151  @base.modified $Date$
     52  @deprecated In 3.14, will be removed in the future without replacement
    5253*/
     54@Deprecated
    5355public class SpotImageCreator
    5456  extends AbstractPlugin
  • trunk/src/test/TestSpotImages.java

    r6127 r7511  
    3939import javax.swing.JFrame;
    4040import javax.swing.Box;
    41 
     41@SuppressWarnings("deprecation")
    4242public class TestSpotImages
    4343{
Note: See TracChangeset for help on using the changeset viewer.