use of net.sf.latexdraw.parser.svg.SVGTextElement in project latexdraw by arnobl.
the class SVGGrid method produceSVGGridYWestLabelsTexts.
private final void produceSVGGridYWestLabelsTexts(final SVGDocument document, final SVGElement texts, final double xorigin, final double tly, final double gridWidth, final Text fooText, final double minY, final double maxY, final double labelHeight, final double absStep) {
final double width = gridWidth / 2d;
final int gridLabelsSize = shape.getLabelsSize();
for (double i = tly + (shape.isXLabelSouth() ? -width - gridLabelsSize / 4d : width + labelHeight), j = maxY; j >= minY; i += absStep, j--) {
final String label = String.valueOf((int) j);
final SVGElement text = new SVGTextElement(document);
fooText.setText(label);
text.setAttribute(SVGAttributes.SVG_X, String.valueOf((int) (xorigin - fooText.getLayoutBounds().getWidth() - gridLabelsSize / 4d - width)));
text.setAttribute(SVGAttributes.SVG_Y, String.valueOf((int) i));
text.setTextContent(label);
texts.appendChild(text);
}
}
use of net.sf.latexdraw.parser.svg.SVGTextElement in project latexdraw by arnobl.
the class SVGGrid method produceSVGGridXLabelsTexts.
private final void produceSVGGridXLabelsTexts(final SVGDocument document, final SVGElement texts, final double yorigin, final double minX, final double maxX, final double tlx, final double labelWidth, final double gridWidth, final double absStep) {
final int gridLabelsSize = shape.getLabelsSize();
final double width = gridWidth / 2d;
final double tmp = shape.isXLabelSouth() ? width : -width;
for (double i = tlx + (shape.isYLabelWest() ? width + gridLabelsSize / 4d : -width - labelWidth - gridLabelsSize / 4d), j = minX; j <= maxX; i += absStep, j++) {
final SVGElement text = new SVGTextElement(document);
text.setAttribute(SVGAttributes.SVG_X, String.valueOf((int) i));
text.setAttribute(SVGAttributes.SVG_Y, String.valueOf((int) (yorigin + tmp)));
text.setTextContent(String.valueOf((int) j));
texts.appendChild(text);
}
}
use of net.sf.latexdraw.parser.svg.SVGTextElement in project latexdraw by arnobl.
the class SVGGrid method produceSVGGridYEastLabelsTexts.
private final void produceSVGGridYEastLabelsTexts(final SVGDocument document, final SVGElement texts, final double xorigin, final double tly, final double gridWidth, final double minY, final double maxY, final double labelHeight, final double absStep) {
final double width = gridWidth / 2d;
final int gridLabelsSize = shape.getLabelsSize();
for (double i = tly + (shape.isXLabelSouth() ? -width - gridLabelsSize / 4d : width + labelHeight), j = maxY; j >= minY; i += absStep, j--) {
final String label = String.valueOf((int) j);
final SVGElement text = new SVGTextElement(document);
text.setAttribute(SVGAttributes.SVG_X, String.valueOf((int) (xorigin + gridLabelsSize / 4d + width)));
text.setAttribute(SVGAttributes.SVG_Y, String.valueOf((int) i));
text.setTextContent(label);
texts.appendChild(text);
}
}
use of net.sf.latexdraw.parser.svg.SVGTextElement in project latexdraw by arnobl.
the class SVGText method toSVG.
@Override
SVGElement toSVG(@NotNull final SVGDocument doc) {
final SVGElement root = new SVGGElement(doc);
final String ltdPref = LNamespace.LATEXDRAW_NAMESPACE + ':';
final Element txt = new SVGTextElement(doc);
root.setAttribute(ltdPref + LNamespace.XML_TYPE, LNamespace.XML_TYPE_TEXT);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
root.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(shape.getLineColour(), true));
root.setAttribute(ltdPref + LNamespace.XML_POSITION, shape.getTextPosition().getLatexToken());
txt.setAttribute(SVGAttributes.SVG_X, String.valueOf(shape.getX()));
txt.setAttribute(SVGAttributes.SVG_Y, String.valueOf(shape.getY()));
txt.appendChild(doc.createTextNode(shape.getText()));
root.appendChild(txt);
setSVGRotationAttribute(root);
return root;
}
Aggregations