Back to index

wims  3.65+svn20090927
SizesDialog.java
Go to the documentation of this file.
00001 /*
00002  * Created on 05.04.2006
00003  *
00004  */
00005 package rene.zirkel.dialogs;
00006 
00007 import java.awt.*;
00008 
00009 import rene.gui.*;
00010 import rene.zirkel.*;
00011 
00012 public class SizesDialog extends HelpCloseDialog 
00013 {      ZirkelFrame ZF;
00014        TextField Pointsize,Linewidth,Arrowsize,Selectionsize,Fontsize;
00015        
00016        public SizesDialog (ZirkelFrame zf)
00017        {      super(zf,Zirkel.name("sizesdialog.title"),true);
00018               ZF=zf;
00019               setLayout(new BorderLayout());
00020               
00021               Panel center=new MyPanel();
00022               center.setLayout(new GridLayout(0,2));
00023               
00024               Pointsize=addfield(center,"minpointsize.prompt","minpointsize",3);
00025               Linewidth=addfield(center,"minlinesize.prompt","minlinesize",1);
00026               Fontsize=addfield(center,"minfontsize.prompt","minfontsize",12);
00027               Selectionsize=addfield(center,"selectionsize.prompt","selectionsize",1.5);
00028               Arrowsize=addfield(center,"arrowsize.prompt","arrowsize",15);
00029               
00030               add("Center",new Panel3D(center));
00031               
00032               Panel p=new MyPanel();
00033               Button b=new ButtonAction(this,Zirkel.name("edit.ok"),"OK");
00034               p.add(b);
00035               b=new ButtonAction(this,Zirkel.name("edit.cancel"),"Close");
00036               p.add(b);
00037               b.addActionListener(this);
00038               addHelp(p,"sizes");
00039               add("South",new Panel3D(p));
00040               
00041               center();
00042               pack();
00043               setVisible(true);
00044        }
00045        
00046        public void doAction (String o)
00047        {      if (o.equals("OK"))
00048               {      set(Pointsize,"minpointsize",0.5,10);
00049                      set(Linewidth,"minlinesize",0.5,3);
00050                      set(Fontsize,"minfontsize",2,30);
00051                      set(Arrowsize,"arrowsize",5,50);
00052                      set(Selectionsize,"selectionsize",0.5,5);
00053                      doclose();
00054               }
00055               else super.doAction(o);
00056        }
00057 
00058        public TextField addfield (Panel p, String tag, String deftag, double def)
00059        {      p.add(new MyLabel(Global.name(tag)));
00060               TextField t=new MyTextField(""+Global.getParameter(deftag,def),20);
00061               p.add(t);
00062               return t;
00063        }
00064        
00065        public void set (TextField t, String tag, double min, double max)
00066        {      try
00067               {      double x=new Double(t.getText()).doubleValue();
00068                      if (x<min) x=min;
00069                      if (x>max) x=max;
00070                      Global.setParameter(tag,x);
00071               }
00072               catch (Exception e)
00073               {}
00074        }
00075 }