Back to index

wims  3.65+svn20090927
Zirkel.java
Go to the documentation of this file.
00001 package rene.zirkel;
00002 
00003 // File: Zirkel.java
00004 
00005 import java.awt.*;
00006 import java.applet.*;
00007 import java.awt.event.*;
00008 import java.util.*;
00009 import java.io.*;
00010 
00011 import rene.dialogs.Warning;
00012 import rene.gui.*;
00013 import rene.zirkel.help.*;
00014 
00015 public class Zirkel extends Applet
00016        implements ActionListener
00017 {      public static final long Version=110;
00018        public static boolean IsApplet=false;
00019        public static String name (String tag, String def)
00020        {      return Global.name(tag,def);
00021        }
00022        public static String name (String tag)
00023        {      return Global.name(tag);
00024        }
00025        public void init ()
00026        // zirkel is called as applet
00027        {      String s=getParameter("Language");
00028               if (s!=null) Locale.setDefault(new Locale(s,""));
00029               Global.initBundle("rene/zirkel/docs/ZirkelProperties");
00030               setLayout(new BorderLayout());
00031               Button StartButton=new Button("Start");
00032               add("Center",StartButton);
00033               StartButton.addActionListener(this);
00034               IsApplet=true;
00035               if (getParameter("oldicons")!=null)
00036               {      Global.setParameter("iconpath","/rene/zirkel/icons/");
00037                      Global.setParameter("icontype","gif");
00038                      Global.setParameter("iconsize",20);
00039               }      
00040               else
00041               {      Global.setParameter("iconpath","/rene/zirkel/newicons/");
00042                      Global.setParameter("icontype","png");
00043                      if (getParameter("smallicons")!=null)
00044                             Global.setParameter("iconsize",24);
00045                      else Global.setParameter("iconsize",32);
00046               }
00047        }
00048 
00049        public static void main (String args[])
00050        // zirkel is calles as application
00051        {      int i=0;
00052               String filename="";
00053               boolean simple=false,restricted=false;
00054               String Home=null;
00055               if (Global.getJavaVersion()<1.4)
00056               {      Frame f=new Frame();
00057                      Warning w=new Warning(f,"Please update to Java 1.4!","Warning");
00058                      w.center();
00059                      w.setVisible(true);
00060                      System.exit(0);
00061               }
00062               while (i<args.length)
00063               {      if (args[i].startsWith("-l") && i<args.length-1)
00064                      {      Locale.setDefault(new Locale(args[i+1],""));
00065                             i+=2;
00066                      }
00067                      else if (args[i].startsWith("-h") && i<args.length-1)
00068                      {      Home=args[i+1];
00069                             i+=2;
00070                      }
00071                      else if (args[i].startsWith("-s"))
00072                      {      simple=true;
00073                             i++;
00074                      }
00075                      else if (args[i].startsWith("-r"))
00076                      {      restricted=true;
00077                             i++;
00078                      }
00079                      else if (args[i].startsWith("-d"))
00080                      {      Properties p=System.getProperties();
00081                             try
00082                             {      PrintStream out=new PrintStream(
00083                                           new FileOutputStream(p.getProperty("user.home")+
00084                                                  p.getProperty("file.separator")+"zirkel.log"));
00085                                    System.setErr(out);
00086                                    System.setOut(out);
00087                             }
00088                             catch (Exception e)
00089                             {      System.out.println("Could not open log file!");
00090                             }
00091                             i++;
00092                      }
00093                      else
00094                      {      filename=args[i];
00095                             i++;
00096                      }
00097               }
00098               if (new File(".zir.cfg").exists()) Global.loadProperties(".zir.cfg");
00099               else if (Home!=null) Global.loadProperties(Home,".zir.cfg");
00100               else Global.loadPropertiesInHome(".zir.cfg");
00101               Global.initBundle("rene/zirkel/docs/ZirkelProperties",true);
00102               if (simple) Global.setParameter("simplegraphics",simple); 
00103               if (restricted) Global.setParameter("restricted",true);
00104               if (!Global.getParameter("program.version","").equals(
00105                      Zirkel.name("program.version")))
00106               {      Global.setParameter("program.newversion",true);
00107                      Global.setParameter("program.version",Zirkel.name("program.version"));
00108                      Global.setParameter("icons",ZirkelFrame.DefaultIcons);
00109               }
00110               if (simple || Global.getParameter("options.oldicons",false))
00111               {      Global.setParameter("iconpath","/rene/zirkel/icons/");
00112                      Global.setParameter("icontype","gif");
00113                      Global.setParameter("iconsize",20);
00114               }      
00115               else
00116               {      Global.setParameter("iconpath","/rene/zirkel/newicons/");
00117                      Global.setParameter("icontype","png");
00118                      if (Global.getParameter("options.smallicons",false))
00119                             Global.setParameter("iconsize",24);
00120                      else Global.setParameter("iconsize",32);
00121               }
00122               Help.CodePage=Global.name("codepage.help","");
00123               ZirkelFrame f=new ZirkelFrame(false);
00124               if (!filename.equals(""))
00125               {      f.load(filename);
00126               }
00127               if (!Global.haveParameter("options.germanpoints") && 
00128                             Locale.getDefault().getLanguage().equals("de"))
00129                      Global.setParameter("options.germanpoints",true);
00130                      
00131        }
00132        
00133        public void actionPerformed (ActionEvent e)
00134        // the user pressed the start button of the applet
00135        {      ZirkelFrame F=new ZirkelFrame(true);
00136               F.setVisible(true);
00137        }
00138 } 
00139