use of net.sf.latexdraw.parsers.svg.SVGElement in project latexdraw by arnobl.
the class TestSVGAttr method testLookupNamespaceURIOK.
@Test
public void testLookupNamespaceURIOK() {
SVGAttr attr = new SVGAttr("pref:n", "", node);
SVGElement elt = (SVGElement) node.getOwnerDocument().createElement("tag2");
elt.setAttribute("xmlns:pref", "namespace");
elt.appendChild(node);
assertEquals("namespace", attr.lookupNamespaceURI("pref"));
}
use of net.sf.latexdraw.parsers.svg.SVGElement in project latexdraw by arnobl.
the class TestSVGAttr method testGetNamespaceURIOK.
@Test
public void testGetNamespaceURIOK() {
SVGAttr attr = new SVGAttr("pref:n", "", node);
SVGElement elt = (SVGElement) node.getOwnerDocument().createElement("tag2");
elt.setAttribute("xmlns:pref", "namespace");
elt.appendChild(node);
assertEquals("namespace", attr.getNamespaceURI());
}
use of net.sf.latexdraw.parsers.svg.SVGElement in project latexdraw by arnobl.
the class TestSVGNodeList method testItemKO.
@Test
public void testItemKO() {
final SVGElement elt = (SVGElement) doc.createElement("elt");
list.getNodes().add(elt);
assertNull(list.item(-1));
assertNull(list.item(1));
}
use of net.sf.latexdraw.parsers.svg.SVGElement in project latexdraw by arnobl.
the class SVGAxes method toSVG.
@Override
public SVGElement toSVG(final SVGDocument doc) {
if (doc == null) {
return null;
}
currentDoc = doc;
currentPath = new SVGPathSegList();
currentTicks = new SVGGElement(doc);
final SVGElement root = new SVGGElement(doc);
final String pref = LNamespace.LATEXDRAW_NAMESPACE + ':';
final SVGPathElement path = new SVGPathElement(doc);
setSVGAttributes(doc, root, false);
root.setAttribute(SVGAttributes.SVG_TRANSFORM, "translate(" + MathUtils.INST.format.format(shape.getPosition().getX()) + ',' + MathUtils.INST.format.format(shape.getPosition().getY()) + ')');
root.setAttribute(pref + LNamespace.XML_STYLE, shape.getAxesStyle().toString());
root.setAttribute(pref + LNamespace.XML_GRID_START, shape.getGridStartX() + " " + shape.getGridStartY());
root.setAttribute(pref + LNamespace.XML_GRID_END, shape.getGridEndX() + " " + shape.getGridEndY());
root.setAttribute(pref + LNamespace.XML_GRID_ORIGIN, shape.getOriginX() + " " + shape.getOriginY());
root.setAttribute(pref + LNamespace.XML_AXE_INCREMENT, shape.getIncrementX() + " " + shape.getIncrementY());
root.setAttribute(pref + LNamespace.XML_AXE_DIST_LABELS, shape.getDistLabelsX() + " " + shape.getDistLabelsY());
root.setAttribute(pref + LNamespace.XML_AXE_TICKS_SIZE, String.valueOf(shape.getTicksSize()));
root.setAttribute(pref + LNamespace.XML_AXE_SHOW_ORIGIN, String.valueOf(shape.isShowOrigin()));
root.setAttribute(pref + LNamespace.XML_AXE_SHOW_TICKS, shape.getTicksDisplayed().toString());
root.setAttribute(pref + LNamespace.XML_AXE_LABELS_STYLE, shape.getLabelsDisplayed().toString());
root.setAttribute(pref + LNamespace.XML_AXE_TICKS_STYLE, shape.getTicksStyle().toString());
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_AXE);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
createSVGAxe(root, doc);
setSVGRotationAttribute(root);
updatePathTicks();
updatePathLabels();
root.appendChild(currentTicks);
path.setPathData(currentPath);
root.appendChild(path);
return root;
}
use of net.sf.latexdraw.parsers.svg.SVGElement in project latexdraw by arnobl.
the class SVGAxes method createFrame.
private void createFrame(final SVGElement elt, final SVGDocument document) {
final double gridEndx = shape.getGridEndX();
final double gridEndy = shape.getGridEndY();
if (gridEndx > 0 || gridEndy > 0) {
final double positionx = shape.getPosition().getX();
final double positiony = shape.getPosition().getY();
final double xMax = positionx + gridEndx * IShape.PPC;
final double yMax = positiony - gridEndy * IShape.PPC;
final IPoint pos = ShapeFactory.INST.createPoint(positionx, gridEndy > 0 ? yMax : positiony);
final IRectangle r = ShapeFactory.INST.createRectangle(pos, Math.abs(pos.getX() - (gridEndx > 0 ? xMax : positionx)), Math.abs(pos.getY() - positiony));
r.setBordersPosition(BorderPos.MID);
r.setLineColour(shape.getLineColour());
r.setLineStyle(shape.getLineStyle());
r.setThickness(shape.getThickness());
final SVGElement frame = new SVGRectangle(r).toSVG(document);
frame.setAttribute(SVGAttributes.SVG_TRANSFORM, "translate(" + MathUtils.INST.format.format(-shape.getPosition().getX()) + ',' + MathUtils.INST.format.format(-shape.getPosition().getY()) + ')');
elt.appendChild(frame);
}
}
Aggregations