Package net.sf.latexdraw.parsers.svg

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


      throw new IllegalArgumentException();

    final NodeList nl = elt.getElementsByTagNameNS(SVGDocument.SVG_NAMESPACE, SVGElements.SVG_TEXT);

    if(nl.getLength()>0) {
      final SVGTextElement text = (SVGTextElement)nl.item(0);
      shape.setText(text.getText());
      shape.setPosition(text.getX(), text.getY());
    }
    else
      throw new IllegalArgumentException();

    TextSize textSize;
View Full Code Here


    if(doc == null)
      return null;

    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, String.valueOf(shape.getTextPosition().getLatexToken()));

    txt.setAttribute(SVGAttributes.SVG_X, String.valueOf(shape.getX()));
    txt.setAttribute(SVGAttributes.SVG_Y, String.valueOf(shape.getY()));
    txt.appendChild(doc.createCDATASection(shape.getText()));
    root.appendChild(txt);

    setSVGRotationAttribute(root);

    return root;
View Full Code Here

    texts.setAttribute(SVGAttributes.SVG_FONT_SIZE, String.valueOf(shape.getLabelsSize()));
    texts.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(gridLabelsColor, true));
    texts.setAttribute(prefix+LNamespace.XML_TYPE, LNamespace.XML_TYPE_TEXT);

    for(i=tlx + (isYLabelWest ? width+gridLabelsSize/4. : -width-labelWidth-gridLabelsSize/4.), j=minX; j<=maxX; i+=absStep, j++) {
      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);
    }

    if(isYLabelWest)
      for(i=tly + (isXLabelSouth ? -width-gridLabelsSize/4. : width+labelHeight), j=maxY ; j>=minY; i+=absStep, j--) {
        label = String.valueOf((int)j);
        text = new SVGTextElement(document);
        text.setAttribute(SVGAttributes.SVG_X, String.valueOf((int)(xorigin-fontMetrics.stringWidth(label)-gridLabelsSize/4.-width)));
        text.setAttribute(SVGAttributes.SVG_Y, String.valueOf((int)i));
        text.setTextContent(label);
        texts.appendChild(text);
      }
    else
      for(i=tly + (isXLabelSouth ? -width-gridLabelsSize/4. : width+labelHeight), j=maxY; j>=minY; i+=absStep, j--) {
        label = String.valueOf((int)j);
        text = new SVGTextElement(document);
        text.setAttribute(SVGAttributes.SVG_X, String.valueOf((int)(xorigin+gridLabelsSize/4.+width)));
        text.setAttribute(SVGAttributes.SVG_Y, String.valueOf((int)i));
        text.setTextContent(label);
        texts.appendChild(text);
      }
View Full Code Here

TOP

Related Classes of net.sf.latexdraw.parsers.svg.SVGTextElement

Copyright © 2018 www.massapicom. 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.