java.awt.geom.Ellipse2D#getHeight ( )源码实例Demo

下面列出了java.awt.geom.Ellipse2D#getHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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 ) );
}
 
@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);
}
 
源代码3 项目: jfreesvg   文件: GraphicsUtils.java
/**
 * 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);
}