use of net.sf.latexdraw.parsers.svg.SVGLineElement in project latexdraw by arnobl.
the class SVGShape method getShowPointsLine.
/**
* Creates a line with the style of the 'show points' option.
* @param doc The document owner.
* @param thickness The thickness of the line to create.
* @param col The colour of the line.
* @param p1 The first point of the line.
* @param p2 The second point of the line.
* @param blackDash The black dash interval.
* @param whiteDash The white dash interval.
* @param hasDble Defines if the shape had double borders.
* @param dotSep The dot interval.
* @return The created SVG line or null.
*/
protected static SVGLineElement getShowPointsLine(final SVGDocument doc, final double thickness, final Color col, final IPoint p1, final IPoint p2, final double blackDash, final double whiteDash, final boolean hasDble, final double dotSep, final double doubleSep) {
if (doc == null) {
return null;
}
final SVGLineElement line = new SVGLineElement(doc);
if (p1 != null) {
line.setX1(p1.getX());
line.setY1(p1.getY());
}
if (p2 != null) {
line.setX2(p2.getX());
line.setY2(p2.getY());
}
line.setStrokeWidth(thickness);
line.setStroke(col);
SVGShape.setDashedDotted(line, blackDash, whiteDash, dotSep, PSTricksConstants.LINE_DASHED_STYLE, hasDble, thickness, doubleSep);
return line;
}
use of net.sf.latexdraw.parsers.svg.SVGLineElement in project latexdraw by arnobl.
the class SVGGrid method createSVGGridDiv.
/**
* Creates the SVG element corresponding to the main not-dotted part of the grid.
*/
private void createSVGGridDiv(final SVGDocument document, final SVGElement elt, final String prefix, 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 posX, final double posY, final double xStep, final double yStep, final double gridWidth, final Color linesColour) {
double k;
double i;
final SVGElement grids = new SVGGElement(document);
SVGElement line;
grids.setAttribute(SVGAttributes.SVG_STROKE_WIDTH, String.valueOf(gridWidth));
grids.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(linesColour, true));
grids.setAttribute(SVGAttributes.SVG_STROKE_LINECAP, SVGAttributes.SVG_LINECAP_VALUE_SQUARE);
grids.setAttribute(prefix + LNamespace.XML_TYPE, LNamespace.XML_TYPE_GRID);
if (linesColour.getO() < 1d) {
grids.setAttribute(SVGAttributes.SVG_STROKE_OPACITY, MathUtils.INST.format.format(linesColour.getO()));
}
for (k = minX, i = posX; k <= maxX; i += xStep, k++) {
line = new SVGLineElement(document);
line.setAttribute(SVGAttributes.SVG_X1, String.valueOf(i));
line.setAttribute(SVGAttributes.SVG_X2, String.valueOf(i));
line.setAttribute(SVGAttributes.SVG_Y1, String.valueOf(bry));
line.setAttribute(SVGAttributes.SVG_Y2, String.valueOf(tly));
grids.appendChild(line);
}
for (k = minY, i = posY; k <= maxY; i -= yStep, k++) {
line = new SVGLineElement(document);
line.setAttribute(SVGAttributes.SVG_X1, String.valueOf(tlx));
line.setAttribute(SVGAttributes.SVG_X2, String.valueOf(brx));
line.setAttribute(SVGAttributes.SVG_Y1, String.valueOf(i));
line.setAttribute(SVGAttributes.SVG_Y2, String.valueOf(i));
grids.appendChild(line);
}
elt.appendChild(grids);
}
use of net.sf.latexdraw.parsers.svg.SVGLineElement in project latexdraw by arnobl.
the class SVGGrid method createSVGSubGridDiv.
/**
* Creates the SVG element corresponding to the sub not-dotted part of the grid.
*/
private void createSVGSubGridDiv(final SVGDocument document, final SVGElement elt, final String prefix, final double subGridDiv, 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 posX, final double posY, final double xStep, final double yStep) {
double i;
double j;
double k;
final SVGElement subgrids = new SVGGElement(document);
SVGElement line;
subgrids.setAttribute(SVGAttributes.SVG_STROKE_WIDTH, String.valueOf(subGridWidth));
subgrids.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(subGridColour, true));
subgrids.setAttribute(SVGAttributes.SVG_STROKE_LINECAP, SVGAttributes.SVG_LINECAP_VALUE_ROUND);
subgrids.setAttribute(prefix + LNamespace.XML_TYPE, LNamespace.XML_TYPE_GRID_SUB);
subgrids.setAttribute(prefix + LNamespace.XML_GRID_DOTS, String.valueOf(subGridDots));
subgrids.setAttribute(prefix + LNamespace.XML_GRID_SUB_DIV, String.valueOf(subGridDiv));
if (subGridColour.getO() < 1d) {
subgrids.setAttribute(SVGAttributes.SVG_STROKE_OPACITY, MathUtils.INST.format.format(subGridColour.getO()));
}
for (k = minX, i = posX; k < maxX; i += xStep, k++) for (j = 0; j <= subGridDiv; j++) {
line = new SVGLineElement(document);
line.setAttribute(SVGAttributes.SVG_X1, String.valueOf(i + xSubStep * j));
line.setAttribute(SVGAttributes.SVG_X2, String.valueOf(i + xSubStep * j));
line.setAttribute(SVGAttributes.SVG_Y1, String.valueOf(bry));
line.setAttribute(SVGAttributes.SVG_Y2, String.valueOf(tly));
subgrids.appendChild(line);
}
for (k = minY, i = posY; k < maxY; i -= yStep, k++) for (j = 0; j <= subGridDiv; j++) {
line = new SVGLineElement(document);
line.setAttribute(SVGAttributes.SVG_X1, String.valueOf(tlx));
line.setAttribute(SVGAttributes.SVG_X2, String.valueOf(brx));
line.setAttribute(SVGAttributes.SVG_Y1, String.valueOf(i - ySubStep * j));
line.setAttribute(SVGAttributes.SVG_Y2, String.valueOf(i - ySubStep * j));
subgrids.appendChild(line);
}
elt.appendChild(subgrids);
}
Aggregations