View Javadoc

1   /**********************************************
2    * Copyright (C) 2009 Lukas Laag
3    * This file is part of Vectomatic.
4    * 
5    * Vectomatic is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * Vectomatic is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with Vectomatic.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  package org.vectomatic.common.model.geometry;
19  
20  import org.vectomatic.common.model.IShapeVisitor;
21  import org.vectomatic.common.model.Shape;
22  
23  import com.google.gwt.user.client.rpc.IsSerializable;
24  
25  /**
26   * Class to represent an ellipse
27   */
28  public class Ellipse extends Shape implements IsSerializable {
29  	public static final float K = ((float)Math.sqrt(2) - 1) * 4 / 3;
30  	public Ellipse() {
31  		super();
32  		_bbox = BoundingBox.UNIT_BOX;		
33  	}
34  	public Ellipse(Ellipse ellipse) {
35  		super(ellipse);
36  	}
37  	@Override
38  	public void acceptVisitor(IShapeVisitor visitor) {
39  		visitor.visitEllipse(this);
40  	}
41  	@Override
42  	public boolean isSame(Shape shape) {
43  		if (shape instanceof Ellipse) {
44  			Ellipse ellipse = (Ellipse)shape;
45  			return getTransform().equals(ellipse.getTransform()) 
46  				&& _attributes.equals(ellipse._attributes);
47  		}
48  		return false;
49  	}
50  
51  	@Override
52  	public String toString() {
53  		StringBuffer buffer = new StringBuffer();
54  		buffer.append("Ellipse(m=");
55  		buffer.append(getTransform().toString());
56  		buffer.append(" atts=");
57  		buffer.append(_attributes.toString());
58  		buffer.append(")");
59  		return buffer.toString();
60  	}
61  }