@Override
public void setGeometry(double [] a){
      isGeometrySet=true;

      int i, i0, i1;
      int nSegment;

      if(a[0] == a[a.length-2] && a[1] == a[a.length-1]){
         // user already closed the polygon for us
         nSegment = (a.length-2)/2;
      }else{
         nSegment = a.length/2;
      }

      segmentArray = new RsSegment[nSegment];
      for(i=0; i<nSegment; i++){
         i0 = i*2;
         i1 = (i*2+2)%a.length;
         segmentArray[i] = new RsSegment(a[i0], a[i0+1], a[i1], a[i1+1]);
      }

      try{
         polygon = new RsPolygon(nSegment, segmentArray);
      }catch(RsPolygonException rspe){
         polygon = null;
      }

      RsRectangle r=new RsRectangle(
                  segmentArray[0].x, segmentArray[0].y,
                  segmentArray[0].v.x, segmentArray[0].v.y);

      for(i=2; i<segmentArray.length;i++)
         r.insert(segmentArray[i].x, segmentArray[i].y);

      setBounds(r);
   }