Methods Summary |
---|
com.sun.perseus.j2d.Box | addNodeBBox(com.sun.perseus.j2d.Box bbox, com.sun.perseus.j2d.Transform t)
float rx = getRx();
float ry = getRy();
if (t == null
|| (t.getComponent(1) == 0 && t.getComponent(2) == 0)
|| width == 0
|| height == 0) {
// If we are dealing with no transform or if the
// transform is a simple zoom/pan
return addTransformedBBox(bbox, x, y, width, height, t);
}
//
// The ellipse's equations are:
//
// x = cx + rx * cos (t)
// y = cy + ry * sin (t)
//
// When transformed through t, the equation becomes:
//
// [x'] [m0 m2 m4] [x]
// [y'] = [m1 m3 m5] * [y]
// [1 ] [ 0 0 1] [1]
//
// x' = m0 * x + m2 * y + m4
// y' = m1 * x + m3 * y + m5
//
// x' = m0 * cx + m0 * rx * cos(t) + m2 * cy + m2 * ry * sin(t) + m4
// y' = m1 * cx + m1 * rx * cos(t) + m3 * cy + m3 * ry * sin(t) + m5
//
// x' = m0 * cx + m2 * cy + m4 + m0 * rx * cos(t) + m2 * ry * sin(t)
// y' = m1 * cx + m3 * cy + m5 + m1 * rx * cos(t) + m3 * ry * sin(t)
//
// fx = m0 * cx + m2 * cy + m4
// fy = m1 * cx + m3 * cy + m5
//
// vx(t) = m0 * rx * cos(t) + m2 * ry * sin(t)
// vy(t) = m1 * rx * cos(t) + m3 * ry * sin(t)
//
// The maximum and minimum are computed by the derivative functions:
//
// vx(t)' = -m0 * rx * sin(t) + m2 * ry * cos(t)
// vy(t)' = -m1 * rx * sin(t) + m3 * ry * cos(t)
//
// vx(t)' = 0 for tan(t) = sin(t) / cos(t)
// = m2 * ry / m0 * rx
// vy(t)' = 0 for tan(t) = sin(t) / cos(t)
// = m3 * ry / m1 * rx
//
float m0 = t.getComponent(0);
float m1 = t.getComponent(1);
float m2 = t.getComponent(2);
float m3 = t.getComponent(3);
float m4 = t.getComponent(4);
float m5 = t.getComponent(5);
float cx = getCx();
float cy = getCy();
float m0rx = m0 * rx;
float m2ry = m2 * ry;
float m1rx = m1 * rx;
float m3ry = m3 * ry;
float theta = MathSupport.atan2(m2ry, m0rx);
float theta2 = theta + MathSupport.PI;
float cost = MathSupport.cos(theta);
float sint = MathSupport.sin(theta);
float cost2 = MathSupport.cos(theta2);
float sint2 = MathSupport.sin(theta2);
float maxX = m0rx * cost + m2ry * sint;
float minX = m0rx * cost2 + m2ry * sint2;
float width = maxX - minX;
if (minX > maxX) {
minX = maxX;
width = -width;
}
theta = MathSupport.atan2(m3ry, m1rx);
theta2 = theta + MathSupport.PI;
cost = MathSupport.cos(theta);
sint = MathSupport.sin(theta);
cost2 = MathSupport.cos(theta2);
sint2 = MathSupport.sin(theta2);
float maxY = m1rx * cost + m3ry * sint;
float minY = m1rx * cost2 + m3ry * sint2;
float height = maxY - minY;
if (minY > maxY) {
minY = maxY;
height = -height;
}
float fx = m0 * cx + m2 * cy + m4;
float fy = m1 * cx + m3 * cy + m5;
// (fx, fy) is the upper left corner of the bounding box
return addBBox(bbox, fx + minX, fy + minY, width, height);
|
public boolean | contains(float x, float y, int fillRule)
// Normalize the coordinates compared to the ellipse
// having a center at 0,0 and a radius of 0.5.
float normx = (x - this.x) / width - 0.5f;
float normy = (y - this.y) / height - 0.5f;
return (normx * normx + normy * normy) < 0.25f;
|
TraitAnim | createTraitAnimImpl(java.lang.String traitName)
if (SVGConstants.SVG_CX_ATTRIBUTE == traitName
||
SVGConstants.SVG_CY_ATTRIBUTE == traitName
||
SVGConstants.SVG_RX_ATTRIBUTE == traitName
||
SVGConstants.SVG_RY_ATTRIBUTE == traitName
||
SVGConstants.SVG_R_ATTRIBUTE == traitName) {
return new FloatTraitAnim(this, traitName, TRAIT_TYPE_FLOAT);
} else {
return super.createTraitAnimImpl(traitName);
}
|
public void | drawShape(com.sun.perseus.j2d.RenderGraphics rg)
rg.drawOval(x, y, width, height);
|
public void | fillShape(com.sun.perseus.j2d.RenderGraphics rg)
rg.fillOval(x, y, width, height);
|
public float | getCx()
return x + width / 2;
|
public float | getCy()
return y + height / 2;
|
float | getFloatTraitImpl(java.lang.String name)Supported traits: cx, cy, rx, ry
if (SVGConstants.SVG_CX_ATTRIBUTE == name) {
return getCx();
} else if (SVGConstants.SVG_CY_ATTRIBUTE == name) {
return getCy();
} else if ((!isCircle && SVGConstants.SVG_RX_ATTRIBUTE == name)
||
(isCircle && SVGConstants.SVG_R_ATTRIBUTE == name)) {
return getRx();
} else if (SVGConstants.SVG_RY_ATTRIBUTE == name) {
return getRy();
} else {
return super.getFloatTraitImpl(name);
}
|
public java.lang.String | getLocalName()
if (isCircle) {
return SVGConstants.SVG_CIRCLE_TAG;
} else {
return SVGConstants.SVG_ELLIPSE_TAG;
}
|
public java.lang.String[] | getRequiredTraits()
if (isCircle) {
return CIRCLE_REQUIRED_TRAITS;
} else {
return ELLIPSE_REQUIRED_TRAITS;
}
|
public float | getRx()
return width / 2;
|
public float | getRy()
return height / 2;
|
java.lang.Object | getStrokedPath(com.sun.perseus.j2d.GraphicsProperties gp)Returns the stroked shape, using the given stroke properties.
return PathSupport.getStrokedEllipse(x,
y,
width,
height,
gp);
|
public java.lang.String | getTraitImpl(java.lang.String name)Supported traits: cx, cy, r, rx, ry
if (SVGConstants.SVG_CX_ATTRIBUTE == name) {
return Float.toString(getCx());
} else if (SVGConstants.SVG_CY_ATTRIBUTE == name) {
return Float.toString(getCy());
} else if ((!isCircle && SVGConstants.SVG_RX_ATTRIBUTE == name)
||
(isCircle && SVGConstants.SVG_R_ATTRIBUTE == name)) {
return Float.toString(getRx());
} else if (!isCircle && SVGConstants.SVG_RY_ATTRIBUTE == name) {
return Float.toString(getRy());
} else {
return super.getTraitImpl(name);
}
|
public ElementNode | newInstance(DocumentNode doc)Used by DocumentNode to create a new instance from
a prototype Ellipse .
return new Ellipse(doc, isCircle);
|
public void | setCx(float cx)
float newCx = cx - width / 2;
if (newCx == x) {
return;
}
modifyingNode();
x = newCx;
renderingDirty();
modifiedNode();
|
public void | setCy(float cy)
float newCy = cy - height / 2;
if (y == newCy) {
return;
}
modifyingNode();
y = newCy;
renderingDirty();
modifiedNode();
|
void | setFloatArrayTrait(java.lang.String name, float[][] value)Set the trait value as float.
if (SVGConstants.SVG_CX_ATTRIBUTE == name) {
setCx(value[0][0]);
} else if (SVGConstants.SVG_CY_ATTRIBUTE == name) {
setCy(value[0][0]);
} else if (SVGConstants.SVG_RX_ATTRIBUTE == name) {
checkPositive(name, value[0][0]);
setRx(value[0][0]);
} else if (SVGConstants.SVG_RY_ATTRIBUTE == name) {
checkPositive(name, value[0][0]);
setRy(value[0][0]);
} else if (SVGConstants.SVG_R_ATTRIBUTE == name) {
checkPositive(name, value[0][0]);
setRx(value[0][0]);
} else {
super.setFloatArrayTrait(name, value);
}
|
public void | setFloatTraitImpl(java.lang.String name, float value)Supported traits: cx, cy, rx, ry
if (SVGConstants.SVG_CX_ATTRIBUTE == name) {
setCx(value);
} else if (SVGConstants.SVG_CY_ATTRIBUTE == name) {
setCy(value);
} else if ((!isCircle
&& SVGConstants.SVG_RX_ATTRIBUTE == name)
||
(isCircle
&&
SVGConstants.SVG_R_ATTRIBUTE == name)) {
checkPositive(name, value);
setRx(value);
} else if (SVGConstants.SVG_RY_ATTRIBUTE == name) {
checkPositive(name, value);
setRy(value);
} else {
super.setFloatTraitImpl(name, value);
}
|
public void | setRx(float rx)
if (rx < 0) {
throw new IllegalArgumentException();
}
if (width == rx * 2) {
return;
}
modifyingNode();
renderingDirty();
float cx = getCx();
width = rx * 2;
x = cx - rx;
computeCanRenderWidthBit(width);
if (isCircle) {
float cy = getCy();
height = rx * 2;
y = cy - rx;
computeCanRenderHeightBit(width);
}
modifiedNode();
|
public void | setRy(float ry)
if (ry < 0) {
throw new IllegalArgumentException();
}
if (height == ry * 2) {
return;
}
modifyingNode();
renderingDirty();
float cy = getCy();
height = ry * 2;
y = cy - ry;
if (isCircle) {
float cx = getCx();
width = ry * 2;
x = cx - ry;
}
computeCanRenderHeightBit(height);
modifiedNode();
|
public void | setTraitImpl(java.lang.String name, java.lang.String value)Supported traits: cx, cy, rx, ry
if (SVGConstants.SVG_CX_ATTRIBUTE == name) {
setCx(parseFloatTrait(name, value));
} else if (SVGConstants.SVG_CY_ATTRIBUTE == name) {
setCy(parseFloatTrait(name, value));
} else if ((!isCircle && SVGConstants.SVG_RX_ATTRIBUTE == name)
||
(isCircle && SVGConstants.SVG_R_ATTRIBUTE == name)) {
setRx(parsePositiveFloatTrait(name, value));
} else if (SVGConstants.SVG_RY_ATTRIBUTE == name) {
setRy(parsePositiveFloatTrait(name, value));
} else {
super.setTraitImpl(name, value);
}
|
boolean | supportsTrait(java.lang.String traitName)Supported traits: cx, cy, rx, ry
if (SVGConstants.SVG_CX_ATTRIBUTE == traitName
||
SVGConstants.SVG_CY_ATTRIBUTE == traitName) {
return true;
}
if (isCircle && SVGConstants.SVG_R_ATTRIBUTE == traitName) {
return true;
} else if (!isCircle
&&
(SVGConstants.SVG_RX_ATTRIBUTE == traitName
||
SVGConstants.SVG_RY_ATTRIBUTE == traitName)) {
return true;
} else {
return super.supportsTrait(traitName);
}
|
java.lang.String | toStringTrait(java.lang.String name, float[][] value)
if (SVGConstants.SVG_CX_ATTRIBUTE == name
||
SVGConstants.SVG_CY_ATTRIBUTE == name) {
return Float.toString(value[0][0]);
} else if ((!isCircle
&& SVGConstants.SVG_RX_ATTRIBUTE == name)
||
(isCircle
&&
SVGConstants.SVG_R_ATTRIBUTE == name)) {
return Float.toString(value[0][0]);
} else if (SVGConstants.SVG_RY_ATTRIBUTE == name) {
return Float.toString(value[0][0]);
} else {
return super.toStringTrait(name, value);
}
|
public float[][] | validateFloatArrayTrait(java.lang.String traitName, java.lang.String value, java.lang.String reqNamespaceURI, java.lang.String reqLocalName, java.lang.String reqTraitNamespace, java.lang.String reqTraitName)Validates the input trait value.
if (SVGConstants.SVG_CX_ATTRIBUTE == traitName
||
SVGConstants.SVG_CY_ATTRIBUTE == traitName) {
return toAnimatedFloatArray(parseFloatTrait(traitName, value));
} else if (SVGConstants.SVG_RX_ATTRIBUTE == traitName
||
SVGConstants.SVG_R_ATTRIBUTE == traitName
||
SVGConstants.SVG_RY_ATTRIBUTE == traitName) {
return toAnimatedFloatArray(parsePositiveFloatTrait(traitName,
value));
} else {
return super.validateFloatArrayTrait(traitName,
value,
reqNamespaceURI,
reqLocalName,
reqTraitNamespace,
reqTraitName);
}
|