Search in sources :

Example 1 with SVGRectElement

use of net.sf.latexdraw.parser.svg.SVGRectElement in project latexdraw by arnobl.

the class SVGRectangular method setDbleBordSVGRect.

final void setDbleBordSVGRect(final SVGElement root, final double x, final double y, final double width, final double height, final SVGDocument doc) {
    if (shape.hasDbleBord()) {
        final SVGRectElement elt = new SVGRectElement(x, y, width, height, doc);
        setSVGDoubleBordersAttributes(elt);
        setSVGRoundCorner(elt);
        root.appendChild(elt);
    }
}
Also used : SVGRectElement(net.sf.latexdraw.parser.svg.SVGRectElement)

Example 2 with SVGRectElement

use of net.sf.latexdraw.parser.svg.SVGRectElement in project latexdraw by arnobl.

the class SVGRectangle method toSVG.

@Override
SVGElement toSVG(@NotNull final SVGDocument document) {
    if (document.getFirstChild().getDefs() == null) {
        throw new IllegalArgumentException();
    }
    final double gap = getPositionGap();
    final Point tl = shape.getTopLeftPoint();
    final Point br = shape.getBottomRightPoint();
    SVGElement elt;
    final SVGElement root = new SVGGElement(document);
    final double width = Math.max(1d, br.getX() - tl.getX() + gap);
    final double height = Math.max(1d, br.getY() - tl.getY() + gap);
    final double x = tl.getX() - gap / 2d;
    final double y = tl.getY() - gap / 2d;
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_RECT);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    setShadowSVGRect(root, x, y, width, height, document);
    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 SVGRectElement(x, y, width, height, document);
        setSVGBorderBackground(elt, root);
        setSVGRoundCorner(elt);
    }
    elt = new SVGRectElement(x, y, width, height, document);
    root.appendChild(elt);
    setSVGAttributes(document, elt, true);
    setSVGRoundCorner(elt);
    setDbleBordSVGRect(root, x, y, width, height, document);
    setSVGRotationAttribute(root);
    return root;
}
Also used : SVGGElement(net.sf.latexdraw.parser.svg.SVGGElement) SVGRectElement(net.sf.latexdraw.parser.svg.SVGRectElement) SVGElement(net.sf.latexdraw.parser.svg.SVGElement) Point(net.sf.latexdraw.model.api.shape.Point)

Example 3 with SVGRectElement

use of net.sf.latexdraw.parser.svg.SVGRectElement in project latexdraw by arnobl.

the class SVGSquare method toSVG.

@Override
SVGElement toSVG(@NotNull final SVGDocument document) {
    if (document.getFirstChild().getDefs() == null) {
        return null;
    }
    final double gap = getPositionGap();
    final Point tl = shape.getTopLeftPoint();
    final Point br = shape.getBottomRightPoint();
    SVGElement elt;
    final SVGElement root = new SVGGElement(document);
    final double width = Math.max(1d, br.getX() - tl.getX() + gap);
    final double x = tl.getX() - gap / 2d;
    final double y = tl.getY() - gap / 2d;
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_SQUARE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    setShadowSVGRect(root, x, y, width, width, document);
    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 SVGRectElement(x, y, width, width, document);
        setSVGBorderBackground(elt, root);
        setSVGRoundCorner(elt);
    }
    elt = new SVGRectElement(x, y, width, width, document);
    root.appendChild(elt);
    setSVGAttributes(document, elt, true);
    setSVGRoundCorner(elt);
    setDbleBordSVGRect(root, x, y, width, width, document);
    setSVGRotationAttribute(root);
    return root;
}
Also used : SVGGElement(net.sf.latexdraw.parser.svg.SVGGElement) SVGRectElement(net.sf.latexdraw.parser.svg.SVGRectElement) SVGElement(net.sf.latexdraw.parser.svg.SVGElement) Point(net.sf.latexdraw.model.api.shape.Point)

Example 4 with SVGRectElement

use of net.sf.latexdraw.parser.svg.SVGRectElement in project latexdraw by arnobl.

the class SVGRectangular method initRectangle.

/**
 * Initialises the rectangle using an SVGGElement provided by a latexdraw SVG document.
 * @param elt The source element.
 * @throws IllegalArgumentException If the given element is null or not valid.
 */
void initRectangle(final SVGGElement elt, final boolean withTransformation) {
    final SVGElement elt2 = getLaTeXDrawElement(elt, null);
    if (elt == null || !(elt2 instanceof SVGRectElement)) {
        throw new IllegalArgumentException();
    }
    setSVGLatexdrawParameters(elt);
    setSVGRectParameters((SVGRectElement) elt2);
    setSVGShadowParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_SHADOW));
    setSVGDbleBordersParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_DBLE_BORDERS));
    if (withTransformation) {
        applyTransformations(elt);
    }
}
Also used : SVGRectElement(net.sf.latexdraw.parser.svg.SVGRectElement) SVGElement(net.sf.latexdraw.parser.svg.SVGElement)

Example 5 with SVGRectElement

use of net.sf.latexdraw.parser.svg.SVGRectElement in project latexdraw by arnobl.

the class SVGRectangular method setShadowSVGRect.

final void setShadowSVGRect(final SVGElement root, final double x, final double y, final double width, final double height, final SVGDocument doc) {
    if (shape.hasShadow()) {
        final SVGRectElement elt = new SVGRectElement(x, y, width, height, doc);
        setSVGShadowAttributes(elt, true);
        root.appendChild(elt);
        setSVGRoundCorner(elt);
    }
}
Also used : SVGRectElement(net.sf.latexdraw.parser.svg.SVGRectElement)

Aggregations

SVGRectElement (net.sf.latexdraw.parser.svg.SVGRectElement)5 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)3 Point (net.sf.latexdraw.model.api.shape.Point)2 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)2