
// Copyright 1997
// Black Dirt Software
// All rights reserved

public class bdcShape extends Control {
    private   int         shapeType = 2;
    private   String      borderColor = "0 , 0, 0";
    private   String      fillColor = "192 , 192, 192";
    private   String      shapeString  = "Rectangle";



    public void initialize(Control c) {
      super.initialize(c);
      this.setType("Shape");
      this.setJavaType("BDShape");
      this.getShapeInfo();
    }

    public String declareString() {
        return ("    BDShape  " + this.getName() + " = new BDShape(" +  "\"" + shapeString + "\"" + ", new Color (" + fillColor + "), new Color  (" + borderColor + ")); "  );
    }

    public String controlArrayInitString() {
        return ("      " + this.getName() + "[" + getIndex() + "] = new BDShape(" +  "\"" + shapeString + "\"" + ", new Color (" + fillColor + "), new Color  (" + borderColor + ")); "  );
    }

    public String addString( Control cParent) {
      return (defaultAddString(cParent));
    }

    public String addString11( Control cParent) {
      return (defaultAddString11(cParent));
    }

    public String getShapeString ( int typeVal){

    switch (typeVal){
     case 0: return ("Rectangle");
     case 1: return ("Square");
     case 2: return ("Oval");
     case 3: return ("Circle");
     case 4: return ("Rounded Rectangle");
     case 5: return ("Rounded Square");
     }
     return ("Rectangle");
    
    }




    public void getShapeInfo( ) {
      java.util.Enumeration thisInfo;
      ControlData cd;
      ToolkitInfo thisToolkitInfo;
      String  value;      
      String  property;

      property = new String();
      value = new String();

      thisToolkitInfo = new ToolkitInfo();
      

      thisInfo = ControlInfo.elements();
      while(thisInfo.hasMoreElements()){
          cd = (ControlData) thisInfo.nextElement();
          property = cd.getProperty();
          value = cd.getValue();

          if (property.equals("Shape")) {
              shapeType = new Integer(value).intValue();
              System.out.println("" + shapeType);
              shapeString = getShapeString(shapeType);
              System.out.println("" + shapeString);
          }
          else if (property.equals("FillColor")) {
            fillColor = thisToolkitInfo.doColor(value);
          }

          else if (property.equals("BorderColor")) {
              borderColor = thisToolkitInfo.doColor(value);
          }
      } // end while
    }   // end getGridInfo

}
