Back to index

wims  3.65+svn20090927
LogoWindow.java
Go to the documentation of this file.
00001 /*
00002  * Created on 22.10.2005
00003  *
00004  */
00005 package rene.zirkel;
00006 
00007 import java.awt.Color;
00008 import java.awt.Dimension;
00009 import java.awt.Font;
00010 import java.awt.Graphics;
00011 import java.awt.Graphics2D;
00012 import java.awt.Image;
00013 import java.awt.MediaTracker;
00014 import java.awt.RenderingHints;
00015 import java.awt.Toolkit;
00016 import java.awt.Window;
00017 import java.io.InputStream;
00018 
00019 import rene.gui.Global;
00020 
00021 class LogoWindow extends Window
00022 implements Runnable
00023 {      ZirkelFrame ZF;
00024 
00025 public LogoWindow (ZirkelFrame zf)
00026 {      super(zf);
00027        setSize(400,300);
00028        Dimension d=getSize();
00029        String name="zirkelframe";
00030        int x=Global.getParameter(name+".x",100);
00031        int y=Global.getParameter(name+".y",100);
00032        int w=Global.getParameter(name+".w",600);
00033        int h=Global.getParameter(name+".h",600);
00034        setLocation(x+w/2-d.width/2,y+h/2-d.height/2);
00035        loadLogo();
00036        setVisible(true);
00037        new Thread(this).start();
00038 }
00039 
00040 Image I;
00041 
00042 public void loadLogo ()
00043 {      try
00044        {      InputStream in=getClass().getResourceAsStream("/rene/zirkel/logowindow.gif");
00045               int pos=0;
00046               int n=in.available();
00047               byte b[]=new byte[200000];
00048               while (n>0)
00049               {      int k=in.read(b,pos,n);
00050                      if (k<0) break;
00051                      pos+=k;
00052                      n=in.available();
00053               }
00054               in.close();
00055               I=Toolkit.getDefaultToolkit().createImage(b,0,pos);
00056               MediaTracker T=new MediaTracker(this);
00057               T.addImage(I,0);
00058               T.waitForAll();
00059        }
00060        catch (Exception e)
00061        {      setVisible(false);
00062               I=null;
00063        }
00064 }
00065 
00066 public void paint (Graphics g)     
00067 {      if (I==null) return; 
00068        g.drawImage(I,0,0,this);
00069        Graphics2D G=(Graphics2D)g;
00070        G.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
00071               RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
00072        g.setFont(new Font("Dialog",Font.BOLD,14));
00073        String s=Zirkel.name("version")+" "+Zirkel.name("program.version");
00074        g.setColor(Color.black);
00075        g.drawString(s,45,270);
00076 }
00077 
00078 public void run ()
00079 {      try
00080        {      Thread.sleep(5000);
00081        } catch(Exception e){}
00082        setVisible(false);
00083        dispose();
00084 }
00085 }
00086 
00087