Back to index

wims  3.65+svn20090927
CircleEditDialog.java
Go to the documentation of this file.
00001 package rene.zirkel.dialogs;
00002 
00003 // file: PrimitiveCircleObject.java
00004 
00005 import java.awt.*;
00006 import java.awt.event.*;
00007 import rene.gui.*;
00008 import rene.zirkel.Zirkel;
00009 import rene.zirkel.ZirkelCanvas;
00010 import rene.zirkel.ZirkelFrame;
00011 import rene.zirkel.objects.*;
00012 
00013 public class CircleEditDialog extends ObjectEditDialog
00014 {      TextField Length,BoundA,BoundB;
00015        Checkbox Fixed,Arc;
00016        IconBar IC;
00017        ZirkelCanvas ZC;
00018        Button RangeButton,KillRangeButton,SetButton;
00019        
00020        static Color Colors[]=ZirkelFrame.Colors;
00021        static String ColorStrings[]=ZirkelFrame.ColorStrings;
00022        
00023        public CircleEditDialog (Frame f, PrimitiveCircleObject o,
00024               ZirkelCanvas zc)
00025        {      super(f,Zirkel.name("edit.circle.title"),o,"circle");
00026               ZC=zc;
00027        }
00028        
00029        public void addFirst (Panel P)
00030        {      PrimitiveCircleObject C=(PrimitiveCircleObject)O;
00031               
00032               if (C instanceof CircleObject)
00033               {      if (((CircleObject)C).canFix())
00034                      {      Fixed=new Checkbox("");     
00035                             Fixed.setState(((CircleObject)C).fixed());
00036                      }
00037                      Length=new TextFieldAction(this,"Length",((CircleObject)O).getStringLength(),30);
00038               }
00039               else if (C instanceof FixedCircleObject)
00040               {      Fixed=new Checkbox("");
00041                      Fixed.setState(!((FixedCircleObject)C).isDragable());
00042                      Length=new TextFieldAction(this,"Length",
00043                             ((FixedCircleObject)O).getStringLength(),30);
00044               }
00045               else Length=new MyTextField(""+C.round(C.getR()));
00046               
00047               P.add(new MyLabel(Zirkel.name("edit.circle.length"))); P.add(Length);
00048               if (Fixed!=null)
00049               {      P.add(new MyLabel(Zirkel.name("edit.fixed"))); P.add(Fixed);
00050               }
00051               else Length.setEditable(false);
00052               
00053               P.add(new MyLabel(Zirkel.name("edit.circle.bounds")));
00054               Panel bounds=new MyPanel();
00055               bounds.setLayout(new GridLayout(1,3));
00056               Arc=new Checkbox("");
00057               Arc.setState(C.hasRange());
00058               bounds.add(Arc);
00059               BoundA=new MyTextField(C.getStartString(),5);
00060               BoundB=new MyTextField(C.getEndString(),5);
00061               bounds.add(BoundA); bounds.add(BoundB);
00062               P.add(bounds);
00063        }
00064        
00065        public void addButton (Panel P)
00066        {      RangeButton=new ButtonAction(this,
00067                      Zirkel.name("edit.circle.range"),"Range");
00068               P.add(RangeButton);
00069               if (O instanceof FixedCircleObject)
00070               {      SetButton=new ButtonAction(this,
00071                             Zirkel.name("edit.fixedcircle.set"),"Set");
00072                      P.add(SetButton);
00073               }
00074        }
00075        
00076        public void addSecond (Panel P)
00077        {      PrimitiveCircleObject C=(PrimitiveCircleObject)O;
00078               
00079               IC=new IconBar(F);
00080               IC.setIconBarListener(this);
00081               IC.addOnOffLeft("partial");
00082               IC.setState("partial",C.isPartial());
00083               IC.addOnOffLeft("filled");
00084               IC.setState("filled",C.isFilled());
00085               IC.addOnOffLeft("obtuse");
00086               IC.setState("obtuse",C.getObtuse());
00087               IC.addOnOffLeft("chord");
00088               IC.setState("chord",!C.getArc());
00089               IC.setIconBarListener(this);
00090               P.add(new MyLabel(""));
00091               P.add(IC);
00092        }
00093        
00094        public void iconPressed (String o)
00095        {      if (o.equals("filled"))
00096               {      if (IC.getState("filled"))
00097                      {      IB.setState("isback",true);
00098                             ThicknessIB.setEnabled("solid",true);
00099                      }
00100                      else
00101                      {      IB.setState("isback",false);
00102                             ThicknessIB.setState("solid",false);
00103                             ThicknessIB.setEnabled("solid",false);
00104                      }
00105               }
00106               super.iconPressed(o);
00107        }
00108 
00109        public void doAction (String o)
00110        {      if (o.equals("Length") && Fixed!=null)
00111               {      Fixed.setState(true);
00112                      super.doAction("OK");
00113               }
00114               else if (o.equals("Range"))
00115               {      ZC.range((PrimitiveCircleObject)O);
00116                      super.doAction("OK");
00117               }
00118               else if (o.equals("KillRange"))
00119               {      ((PrimitiveCircleObject)O).clearRange();
00120                      super.doAction("OK");
00121               }
00122               else if (o.equals("Set") && O instanceof FixedCircleObject)
00123               {      ZC.set((FixedCircleObject)O);
00124                      super.doAction("OK");
00125               }
00126               else super.doAction(o);
00127        }
00128        
00129        public void setAction ()
00130        {      if (O instanceof CircleObject)
00131               {      try
00132                      {      ((CircleObject)O).setFixed(Fixed.getState(),Length.getText());
00133                      }
00134                      catch (Exception e) {}
00135               }
00136               else if (O instanceof FixedCircleObject)
00137               {      ((FixedCircleObject)O).setDragable(!Fixed.getState());
00138                      try
00139                      {      ((FixedCircleObject)O).setFixed(Length.getText());
00140                      }
00141                      catch (Exception e) {}
00142               }
00143               ((PrimitiveCircleObject)O).setPartial(IC.getState("partial"));
00144               ((PrimitiveCircleObject)O).setFilled(IC.getState("filled"));
00145               ((PrimitiveCircleObject)O).setArc(!IC.getState("chord"));
00146               O.setObtuse(IC.getState("obtuse"));
00147               if (!Arc.getState())
00148               {      ((PrimitiveCircleObject)O).clearRange();
00149               }
00150               else
00151               {      ((PrimitiveCircleObject)O).setRange(BoundA.getText(),BoundB.getText());
00152               }
00153               Global.setParameter("unit.length",Unit.getText());
00154        }
00155 
00156        public void focusGained (FocusEvent e)
00157        {      if (Fixed!=null && Fixed.getState()) Length.requestFocus();
00158               else super.focusGained(e);
00159        }
00160 }