View Javadoc

1   /*
2    * this class is for generating a java.awt.geom.Ellipse2D.Float using interface ShapeBean and the method genShape()
3    * the ellipse (Shape) will be using to define a clickable part on the ImageIcon
4    * all methods set and get and constructor without argument are for generating a xml file with java.beans.XMLEncoder
5    */
6   package org.lsst.ccs.utilities.zonesui;
7   
8   import java.awt.Shape;
9   
10  /**
11   *
12   * @author Pascal Durieu
13   */
14  public class ZEllipse implements ShapeBean {
15      private float fx, fy, fwidth, fheight;
16      
17      public ZEllipse() {}
18  
19      public ZEllipse(int ix, int iy, int iw, int ih) {
20          this.fx = (float)ix;
21          this.fy = (float)iy;
22          this.fwidth = (float)iw;
23          this.fheight = (float)ih;
24      }
25      
26      // get method
27      public int getX () {return (int)fx;}
28      public int getY () {return (int)fy;}
29      public int getWidth () {return (int)fwidth;}
30      public int getHeight () {return (int)fheight;}
31      
32      //set method
33      public void setX (int i) {fx = (float)i;}
34      public void setY (int i) {fy = (float)i;}
35      public void setWidth (int i) {fwidth = (float)i;}
36      public void setHeight (int i) {fheight = (float)i;}
37  
38      public void setX (float i) {fx = (float)i;}
39      public void setY (float i) {fy = (float)i;}
40      public void setWidth (float i) {fwidth = (float)i;}
41      public void setHeight (float i) {fheight = (float)i;}
42      //method from ShapeBean interface to generate a Shape
43      @Override
44      public Shape genShape() {
45          return new java.awt.geom.Ellipse2D.Float(fx, fy, fwidth, fheight);
46      }
47      @Override
48      public String toString() {
49          return "ZEllipse ("+(int)fx+","+(int)fy+","+(int)fwidth+","+(int)fheight+")";
50      }    
51  }