1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.viewer; 23 24 import java.awt.Graphics; 25 import java.awt.image.BufferedImage; 26 import java.io.IOException; 27 import java.io.InputStream; 28 29 import javax.imageio.ImageIO; 30 import javax.swing.JComponent; 31 import javax.swing.JPanel; 32 33 @SuppressWarnings("serial") 34 public class ImageView 35 extends JPanel 36 { ImageView(final InputStream aInputStream)37 public ImageView (final InputStream aInputStream) 38 { 39 BufferedImage aImage = null; 40 try 41 { 42 aImage = ImageIO.read(aInputStream); 43 } 44 catch (IOException e) 45 { 46 e.printStackTrace(); 47 } 48 maImage = aImage; 49 } 50 51 52 53 GetComponent()54 public JComponent GetComponent() 55 { 56 return this; 57 } 58 59 60 61 62 @Override paintComponent(final Graphics aGraphics)63 public void paintComponent (final Graphics aGraphics) 64 { 65 super.paintComponent(aGraphics); 66 if (maImage != null) 67 { 68 aGraphics.drawImage(maImage, 10, 10, null); 69 } 70 } 71 72 73 74 private final BufferedImage maImage; 75 } 76