use of net.sf.latexdraw.parser.svg.SVGCircleElement in project latexdraw by arnobl.
the class SVGGrid method createSVGSubGridDots.
/**
* Creates the SVG element corresponding to the sub dotted part of the grid.
*/
private void createSVGSubGridDots(final SVGDocument document, final SVGElement elt, final String prefix, final double subGridDiv, final double unit, final double xSubStep, final double ySubStep, final double minX, final double maxX, final double minY, final double maxY, final int subGridDots, final double subGridWidth, final double tlx, final double tly, final double brx, final double bry, final Color subGridColour) {
final double dotStep = unit * Shape.PPC / (subGridDots * subGridDiv);
final double nbX = (maxX - minX) * subGridDiv;
final double nbY = (maxY - minY) * subGridDiv;
final SVGElement subgridDots = new SVGGElement(document);
SVGElement dot;
subgridDots.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(subGridColour, true));
subgridDots.setAttribute(prefix + LNamespace.XML_TYPE, LNamespace.XML_TYPE_GRID_SUB);
subgridDots.setAttribute(prefix + LNamespace.XML_GRID_DOTS, String.valueOf(subGridDots));
subgridDots.setAttribute(prefix + LNamespace.XML_GRID_SUB_DIV, String.valueOf(subGridDiv));
subgridDots.setAttribute(prefix + LNamespace.XML_GRID_WIDTH, String.valueOf(subGridWidth));
if (subGridColour.getO() < 1d) {
subgridDots.setAttribute(SVGAttributes.SVG_FILL_OPACITY, MathUtils.INST.format.format(subGridColour.getO()));
}
for (double i = 0, n = tlx; i < nbX; i++, n += xSubStep) {
for (double j = 0, m = tly; j <= nbY; j++, m += ySubStep) {
for (double k = 0; k < subGridDots; k++) {
dot = new SVGCircleElement(document);
dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(n + k * dotStep));
dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(m));
dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(subGridWidth / 2.));
subgridDots.appendChild(dot);
}
}
}
for (double j = 0, n = tly; j < nbY; j++, n += ySubStep) {
for (double i = 0, m = tlx; i <= nbX; i++, m += xSubStep) {
for (double k = 0; k < subGridDots; k++) {
dot = new SVGCircleElement(document);
dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(m));
dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(n + k * dotStep));
dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(subGridWidth / 2.));
subgridDots.appendChild(dot);
}
}
}
dot = new SVGCircleElement(document);
dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(brx));
dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(bry));
dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(subGridWidth / 2.));
elt.appendChild(subgridDots);
}
use of net.sf.latexdraw.parser.svg.SVGCircleElement in project latexdraw by arnobl.
the class SVGCircle method toSVG.
@Override
SVGElement toSVG(@NotNull final SVGDocument doc) {
if (doc.getFirstChild().getDefs() == null) {
return null;
}
final Point tl = shape.getTopLeftPoint();
final Point br = shape.getBottomRightPoint();
final double tlx = tl.getX();
final double tly = tl.getY();
final double brx = br.getX();
final double bry = br.getY();
SVGElement elt;
final SVGElement shad;
final SVGElement dblBord;
final SVGElement root = new SVGGElement(doc);
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_CIRCLE);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
final double gap = getPositionGap();
final double abs = Math.abs((brx - tlx + gap) / 2d);
if (shape.hasShadow()) {
shad = new SVGCircleElement((brx + tlx) / 2d, (bry + tly) / 2d, abs, doc);
setSVGShadowAttributes(shad, true);
root.appendChild(shad);
}
if (shape.hasShadow() && !PSTricksConstants.LINE_NONE_STYLE.equals(shape.getLineStyle().getLatexToken())) {
// The background of the borders must be filled is there is a shadow.
elt = new SVGCircleElement((brx + tlx) / 2d, (bry + tly) / 2d, abs, doc);
setSVGBorderBackground(elt, root);
}
elt = new SVGCircleElement((brx + tlx) / 2d, (bry + tly) / 2d, abs, doc);
root.appendChild(elt);
if (shape.hasDbleBord()) {
dblBord = new SVGCircleElement((brx + tlx) / 2d, (bry + tly) / 2d, abs, doc);
setSVGDoubleBordersAttributes(dblBord);
root.appendChild(dblBord);
}
setSVGAttributes(doc, elt, true);
setSVGRotationAttribute(root);
return root;
}
use of net.sf.latexdraw.parser.svg.SVGCircleElement in project latexdraw by arnobl.
the class SVGGrid method createSVGGridDots.
/**
* Creates the SVG element corresponding to the main dotted part of the grid.
*/
private void createSVGGridDots(final SVGDocument document, final SVGElement elt, final String prefix, final double absStep, final double minX, final double maxX, final double minY, final double maxY, final double tlx, final double tly, final double brx, final double bry, final double unit, final double posX, final double posY, final double xStep, final double yStep, final double gridWidth, final Color linesColour) {
double k;
double i;
double m;
double n;
double l;
double j;
final int gridDots = shape.getGridDots();
final double dotStep = unit * Shape.PPC / gridDots;
final SVGElement gridDotsElt = new SVGGElement(document);
SVGElement dot;
gridDotsElt.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(linesColour, true));
gridDotsElt.setAttribute(prefix + LNamespace.XML_TYPE, LNamespace.XML_TYPE_GRID);
gridDotsElt.setAttribute(prefix + LNamespace.XML_GRID_DOTS, String.valueOf(gridDots));
gridDotsElt.setAttribute(prefix + LNamespace.XML_GRID_WIDTH, String.valueOf(gridWidth));
if (linesColour.getO() < 1d) {
gridDotsElt.setAttribute(SVGAttributes.SVG_FILL_OPACITY, MathUtils.INST.format.format(linesColour.getO()));
}
for (k = minX, i = posX; k <= maxX; i += xStep, k++) {
for (m = tly, n = minY; n < maxY; n++, m += absStep) {
for (l = 0, j = m; l < gridDots; l++, j += dotStep) {
dot = new SVGCircleElement(document);
dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(i));
dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(j));
dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(gridWidth / 2.));
gridDotsElt.appendChild(dot);
}
}
}
for (k = minY, i = posY; k <= maxY; i -= yStep, k++) {
for (m = tlx, n = minX; n < maxX; n++, m += absStep) {
for (l = 0, j = m; l < gridDots; l++, j += dotStep) {
dot = new SVGCircleElement(document);
dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(j));
dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(i));
dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(gridWidth / 2.));
gridDotsElt.appendChild(dot);
}
}
}
dot = new SVGCircleElement(document);
dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(brx));
dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(bry));
dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(gridWidth / 2.));
gridDotsElt.appendChild(dot);
elt.appendChild(gridDotsElt);
}
use of net.sf.latexdraw.parser.svg.SVGCircleElement in project latexdraw by arnobl.
the class SVGArrow method createCircle.
@Override
public void createCircle(final double cx, final double cy, final double r) {
if (currentDoc != null && currentMarker != null) {
currentCircle = new SVGCircleElement(currentDoc);
currentCircle.setAttribute(SVGAttributes.SVG_R, MathUtils.INST.format.format(r));
currentCircle.setAttribute(SVGAttributes.SVG_CX, MathUtils.INST.format.format(cx));
currentCircle.setAttribute(SVGAttributes.SVG_CY, MathUtils.INST.format.format(cy));
currentCircle.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_ARROW_DOT_SIZE_NUM, MathUtils.INST.format.format(arrow.getDotSizeNum()));
currentMarker.appendChild(currentCircle);
}
}
Aggregations