Examples of SVGElement


Examples of net.sf.latexdraw.parsers.svg.SVGElement

      throw new IllegalArgumentException();

    final double gap = getPositionGap();
    final IPoint tl  = shape.getTopLeftPoint();
    final IPoint br  = shape.getBottomRightPoint();
    SVGElement elt;
        final SVGElement root = new SVGGElement(document);
        final double width  = Math.max(1, br.getX()-tl.getX()+gap);
        final double height = Math.max(1., br.getY()-tl.getY()+gap);
        final double x    = tl.getX()-gap/2.;
        final double y    = tl.getY()-gap/2.;

        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_RECT);
        root.setAttribute(SVGAttributes.SVG_ID, getSVGID());

        if(shape.hasShadow()) {
          elt = new SVGRectElement(x, y, width, height, document);
          setSVGShadowAttributes(elt, true);
          root.appendChild(elt);
          setSVGRoundCorner(elt);
        }

        if(shape.hasShadow() && !shape.getLineStyle().getLatexToken().equals(PSTricksConstants.LINE_NONE_STYLE)) {
          // 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);

        if(shape.hasDbleBord()) {
          elt = new SVGRectElement(x, y, width, height, document);
          setSVGDoubleBordersAttributes(elt);
          setSVGRoundCorner(elt);
          root.appendChild(elt);
        }

        setSVGRotationAttribute(root);

    return root;
View Full Code Here

Examples of net.sf.latexdraw.parsers.svg.SVGElement


  protected LFreeHandSVGGenerator(final SVGGElement elt, final boolean withTransformation) {
    this(ShapeFactory.createFreeHand());

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

    if(elt==null || elt2==null || !(elt2 instanceof SVGPathElement))
      throw new IllegalArgumentException();

    final SVGPathElement main = (SVGPathElement)elt2;
View Full Code Here

Examples of net.sf.latexdraw.parsers.svg.SVGElement

  @Override
  public SVGElement toSVG(final SVGDocument doc) {
    if(doc==null)
      return null;

    final SVGElement root = new SVGGElement(doc);
    SVGElement elt;

    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_FREEHAND);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_PATH_TYPE, String.valueOf(shape.getType()));
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_INTERVAL, String.valueOf(shape.getInterval()));
    final String path = getPath().toString();
    final StringBuilder pts = new StringBuilder();

    for(int i = 0, size = shape.getNbPoints(); i < size; i++)
        pts.append(shape.getPtAt(i).getX()).append(' ').append(shape.getPtAt(i).getY()).append(' ');

    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_POINTS, pts.toString());

    if(shape.hasShadow()) {
      final SVGElement shad = new SVGPathElement(doc);
      shad.setAttribute(SVGAttributes.SVG_D, path);
      setSVGShadowAttributes(shad, false);
      root.appendChild(shad);
    }

        if(shape.hasShadow() && shape.getLineStyle()!=LineStyle.NONE && shape.isFilled())
View Full Code Here

Examples of net.sf.latexdraw.parsers.svg.SVGElement

   * @since 2.0.0
   */
  protected LCircleSVGGenerator(final SVGGElement elt, final boolean withTransformation) {
    this(ShapeFactory.createCircle());

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

    if(elt==null || !(elt2 instanceof SVGCircleElement))
      throw new IllegalArgumentException();

    setSVGLatexdrawParameters(elt);
View Full Code Here

Examples of org.axsl.fo.foreign.SvgElement

                newFoArea.viewportBPD());

        // Create the reference area for the content.
        final FoForeignXml foreign = generatedBy.getForeignXml();
        if (foreign instanceof SvgElement) {
            final SvgElement svgElement = (SvgElement) foreign;
            final SVGArea svgArea = SVGArea.makeSvgArea(svgElement, newFoArea,
                    graftingPoint);
            newFoArea.foreignContent = svgArea;
        } else if (foreign instanceof MathElement) {
            final MathElement mathElement = (MathElement) foreign;
View Full Code Here

Examples of org.w3c.dom.svg.SVGElement

     * also be an instance of <code>EventTarget</code> otherwise no listener
     * will be added.
     * @param node the <code>GraphicsNode</code>.
     */
    public static void addDOMListener(BridgeContext ctx, Element eee) {
        SVGElement element = null;
        EventTarget target = null;
        try {
            element = (SVGElement)eee;
            // ability for scripts to be called
            target = (EventTarget)element;
        } catch (ClassCastException e) {
            // will not work on this one!
            return;
        }
        SVGSVGElement svgElement = (SVGSVGElement)element.getOwnerSVGElement();
        if (svgElement == null) {
            if (element.getLocalName().equals(SVG_SVG_TAG)) {
                svgElement = (SVGSVGElement)element;
            } else {
                // something goes wrong => disable scripting
                return;
            }
        }
        String language = svgElement.getContentScriptType();
        String script = null;
        if (element.getLocalName().equals(SVG_SVG_TAG)) {
            for (int i = 0; i < EVENT_ATTRIBUTES_SVG.length; i++) {
                if (!(script = element.getAttribute(EVENT_ATTRIBUTES_SVG[i])).
                    equals("")) {
                    // <!> TODO this will stop working if someone change
                    // the content of the event attribute
                    addScriptCaller(target, EVENT_NAMES[i+FIRST_SVG_EVENT],
                                    new ScriptCaller(ctx, script, language));
                }
            }
            // continue
        } else
            if (element.getLocalName().equals("set") ||
                element.getLocalName().startsWith("animate")) {
                for (int i = 0; i < EVENT_ATTRIBUTES_ANIMATION.length; i++) {
                    if (!(script =
                          element.getAttribute(EVENT_ATTRIBUTES_ANIMATION[i])).
                        equals("")) {
                        // <!> TODO this will stop working if someone change
                        // the content of the event attribute
                        addScriptCaller(target, EVENT_NAMES[i+
                                                           FIRST_ANIMATION_EVENT],
                                        new ScriptCaller(ctx, script, language));
                    }
                }
                // not other stuff to do on this kind of events
                return;
            }
        for (int i = 0; i < EVENT_ATTRIBUTES_GRAPHICS.length; i++) {
            if (!(script = element.getAttribute(EVENT_ATTRIBUTES_GRAPHICS[i])).
                equals("")) {
                // <!> TODO this will stop working if someone change
                // the content of the event attribute
                addScriptCaller(target, EVENT_NAMES[i],
                                 new ScriptCaller(ctx, script, language));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.