use of net.sf.latexdraw.parsers.svg.SVGTransformList in project latexdraw by arnobl.
the class TestSVGTransformList method testContructorsNotEmpty.
@Test
public void testContructorsNotEmpty() {
t = new SVGTransformList("translate(2,2)");
assertFalse(t.isEmpty());
}
use of net.sf.latexdraw.parsers.svg.SVGTransformList in project latexdraw by arnobl.
the class TestSVGTransformList method testContructorsEmptyEmpty.
@Test
public void testContructorsEmptyEmpty() {
t = new SVGTransformList("");
assertTrue(t.isEmpty());
}
use of net.sf.latexdraw.parsers.svg.SVGTransformList in project latexdraw by arnobl.
the class SVGShape method setSVGShadowParameters.
/**
* Sets the shadow parameters of the figure by using an SVG element having "type:shadow".
* @param elt The source element.
*/
protected void setSVGShadowParameters(final SVGElement elt) {
if (elt == null || !shape.isShadowable())
return;
if (shape.isFillable()) {
final String fill = elt.getFill();
if (fill != null && !fill.equals(SVGAttributes.SVG_VALUE_NONE) && !fill.startsWith(SVG_URL_TOKEN_BEGIN)) {
shape.setShadowCol(CSSColors.INSTANCE.getRGBColour(fill));
}
}
final Color strok = elt.getStroke();
if (strok != null) {
shape.setShadowCol(strok);
}
final SVGTransformList tl = elt.getTransform();
SVGTransform t;
double tx;
double ty;
boolean sSize = false;
boolean sAngle = false;
for (int i = 0, size = tl.size(); i < size && (!sSize || !sAngle); i++) {
t = tl.get(i);
if (t.isTranslation()) {
tx = t.getTX();
ty = t.getTY();
if (MathUtils.INST.equalsDouble(ty, 0.) && !sSize) {
// It is shadowSize.
shape.setShadowSize(tx);
sSize = true;
} else {
final IPoint gravityCenter = shape.getGravityCentre();
double angle;
final double shSize = shape.getShadowSize();
if (MathUtils.INST.equalsDouble(ty, 0.)) {
angle = tx < 0. ? Math.PI : 0.;
} else {
if (MathUtils.INST.equalsDouble(shSize, Math.abs(tx))) {
angle = ty > 0. ? -Math.PI / 2. : Math.PI / 2.;
} else {
angle = Math.acos(gravityCenter.distance(gravityCenter.getX() + tx + shSize, gravityCenter.getY()) / gravityCenter.distance(gravityCenter.getX() + tx + shSize, gravityCenter.getY() + ty));
if (tx + shSize < 0) {
if (ty < 0.) {
angle = Math.PI - angle;
} else {
angle += Math.PI;
}
} else {
if (ty > 0.) {
angle *= -1;
}
}
}
}
shape.setShadowAngle(angle);
sAngle = true;
}
}
}
shape.setHasShadow(true);
}
use of net.sf.latexdraw.parsers.svg.SVGTransformList in project latexdraw by arnobl.
the class TestSVGTransformList method testContructorsEmptynull.
@Test
public void testContructorsEmptynull() {
t = new SVGTransformList(null);
assertTrue(t.isEmpty());
}
Aggregations