Java Code Examples for java.awt.geom.Ellipse2D#getHeight()

The following examples show how to use java.awt.geom.Ellipse2D#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ellipse2DObjectDescription.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Sets the parameters of this description object to match the supplied object.
 *
 * @param o
 *          the object (should be an instance of <code>Rectangle2D</code>).
 * @throws ObjectFactoryException
 *           if the object is not an instance of <code>Rectangle2D</code>.
 */
public void setParameterFromObject( final Object o ) throws ObjectFactoryException {
  if ( !( o instanceof Ellipse2D ) ) {
    throw new ObjectFactoryException( "The given object is no java.awt.geom.Rectangle2D." );
  }

  final Ellipse2D rect = (Ellipse2D) o;
  final float x = (float) rect.getX();
  final float y = (float) rect.getY();
  final float w = (float) rect.getWidth();
  final float h = (float) rect.getHeight();

  setParameter( "x", new Float( x ) );
  setParameter( "y", new Float( y ) );
  setParameter( "width", new Float( w ) );
  setParameter( "height", new Float( h ) );
}
 
Example 2
Source File: CustomPropertyInterpolatorSource.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Ellipse2D interpolate(Ellipse2D from, Ellipse2D to, float timelinePosition) {
    double x = from.getX() + timelinePosition * (to.getX() - from.getX());
    double y = from.getY() + timelinePosition * (to.getY() - from.getY());
    double w = from.getWidth() + timelinePosition * (to.getWidth() - from.getWidth());
    double h = from.getHeight() + timelinePosition * (to.getHeight() - from.getHeight());
    return new Ellipse2D.Double(x, y, w, h);
}
 
Example 3
Source File: GraphicsUtils.java    From jfreesvg with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a shape that is (more or less) equivalent to the supplied shape.
 * For some known shape implementations ({@code Line2D}, 
 * {@code Rectangle2D}, {@code RoundRectangle2D}, {@code Arc2D}, 
 * {@code Ellipse2D}, and {@code Polygon}) the copy will be an instance of 
 * that class.  For other shapes, a {@code Path2D} containing the outline 
 * of the shape is returned.
 * 
 * @param shape  the shape ({@code null} not permitted).
 * 
 * @return A copy of the shape or shape outline (never {@code null}). 
 */
public static Shape copyOf(Shape shape) {
   Args.nullNotPermitted(shape, "shape");
   if (shape instanceof Line2D) {
       Line2D l = (Line2D) shape;
       return new Line2D.Double(l.getX1(), l.getY1(), l.getX2(), l.getY2());
   }
   if (shape instanceof Rectangle2D) {
       Rectangle2D r = (Rectangle2D) shape;
       return new Rectangle2D.Double(r.getX(), r.getY(), r.getWidth(), 
               r.getHeight());
   }
   if (shape instanceof RoundRectangle2D) {
       RoundRectangle2D rr = (RoundRectangle2D) shape;
       return new RoundRectangle2D.Double(rr.getX(), rr.getY(), 
               rr.getWidth(), rr.getHeight(), rr.getArcWidth(), 
               rr.getArcHeight());
   }
   if (shape instanceof Arc2D) {
       Arc2D arc = (Arc2D) shape;
       return new Arc2D.Double(arc.getX(), arc.getY(), arc.getWidth(),
               arc.getHeight(), arc.getAngleStart(), arc.getAngleExtent(),
               arc.getArcType());
   }
   if (shape instanceof Ellipse2D) {
       Ellipse2D ell = (Ellipse2D) shape;
       return new Ellipse2D.Double(ell.getX(), ell.getY(), ell.getWidth(),
               ell.getHeight());
   }
   if (shape instanceof Polygon) {
       Polygon p = (Polygon) shape;
       return new Polygon(p.xpoints, p.ypoints, p.npoints);
   }
   return new Path2D.Double(shape);
}