package morepaste; import java.awt.*; import java.io.Serializable; import javax.swing.ImageIcon; import java.io.*; import java.util.jar.*; import java.util.Enumeration; import morepaste.plugin.*; /** * @version 1.0.1 2002-01-21 * @author Takashi KOBAYASHI * @see morepaste.plugin.AbstractTabPanel */ public class SplashPanel extends AbstractTabPanel implements Serializable { private final String theTitle = "About..."; private final boolean defVisible = true; private final boolean theVisibilityChangable = false; private final boolean theDropAcceptable = true; private final boolean theTabChangeEventAcceptable = false; private final boolean theBatchEnable = false; private final String dir = "morepaste"; private final String imgfile = "MPSplash.jpg"; private final String jarfile = "MorePaste.jar"; private ImageIcon splash; public SplashPanel() { title = theTitle; tabVisible = defVisible; visibilityChangable = theVisibilityChangable; dropAcceptable = theDropAcceptable; tabChangeEventAcceptable = theTabChangeEventAcceptable; batchEnable = theBatchEnable; initSelected = true; // jarファイルからイメージデータを取り出す String sep = "/"; String path = dir + sep + imgfile; File theFile = new File( jarfile ); if( theFile.exists() ) { try{ JarFile jFile = new JarFile( theFile ); InputStream in = jFile.getInputStream( jFile.getEntry( path ) ); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] b = new byte[1024]; int i; while( ( i = in.read( b ) ) != -1 ) baos.write( b, 0, i ); byte[] pix = baos.toByteArray(); Image img = Toolkit.getDefaultToolkit().createImage( pix ); splash = new ImageIcon( img ); } catch( IOException e ){} } // イメージファイルからイメージを読み出す else { sep = System.getProperty( "file.separator" ); path = "." + sep + dir + sep + imgfile; theFile = new File( path ); if( theFile.exists() ) splash = new ImageIcon( path ); } if( splash == null ) splash = new ImageIcon(); } public String toString() { return title; } public String doCommand( String in ) { return in; } public void paint( Graphics g ) { splash.paintIcon( this, g, (this.getWidth() - splash.getImage().getWidth( this ))/2, (this.getHeight() - splash.getImage().getHeight( this ))/2 ); } public Dimension getPreferredSize() { return new Dimension( splash.getImage().getWidth( this ), splash.getImage().getHeight( this ) ); } }