Examples of SVGElement


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

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

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

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

    setSVGLatexdrawParameters(elt);
View Full Code Here

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

    final IPoint 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 root = new SVGGElement(doc);
        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_ELLIPSE);
        root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
        final double gap   = getPositionGap();
        final double width  = Math.max(1., (brx-tlx+gap)/2.);
        final double height = Math.max(1., (bry-tly+gap)/2.);
        final double x    = (brx+tlx)/2.;
        final double y    = (bry+tly)/2.;

        if(shape.hasShadow()) {
          elt = new SVGEllipseElement(x, y, width, height, doc);
          setSVGShadowAttributes(elt, true);
          root.appendChild(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 SVGEllipseElement(x, y, width, height, doc);
          setSVGBorderBackground(elt, root);
        }

        elt = new SVGEllipseElement(x, y, width, height, doc);
        setSVGAttributes(doc, elt, true);
        root.appendChild(elt);

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

        setSVGRotationAttribute(root);

    return root;
View Full Code Here

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

    if(elt==null)
      throw new IllegalArgumentException();

    String v = elt.getAttribute(elt.getUsablePrefix(LNamespace.LATEXDRAW_NAMESPACE_URI)+LNamespace.XML_SIZE);
    final SVGElement main = getLaTeXDrawElement(elt, null);

    try { shape.setDotStyle(DotStyle.getStyle(elt.getAttribute(elt.getUsablePrefix(LNamespace.LATEXDRAW_NAMESPACE_URI)+LNamespace.XML_DOT_SHAPE))); }
    catch(final IllegalArgumentException e) { BadaboomCollector.INSTANCE.add(e); }

    if(v!=null)
      try { shape.setDiametre(Double.parseDouble(v)); }
      catch(final NumberFormatException e) { BadaboomCollector.INSTANCE.add(e); }

    v = elt.getAttribute(elt.getUsablePrefix(LNamespace.LATEXDRAW_NAMESPACE_URI)+LNamespace.XML_POSITION);

    final List<Point2D> pos = SVGPointsParser.getPoints(v);

    if(pos!=null && !pos.isEmpty())
      shape.setPosition(pos.get(0).getX(), pos.get(0).getY());

    setSVGLatexdrawParameters(elt);
    setSVGParameters(main);

    if(withTransformation)
      applyTransformations(elt);

    if(!shape.isFillable() && shape.isFilled())
      shape.setLineColour(CSSColors.INSTANCE.getRGBColour(main.getFill()));
  }
View Full Code Here

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

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

    final Graphics2D2SVG graphics = new Graphics2D2SVG(doc);
        final SVGElement root;
        final boolean viewCreated;
        // Instead of creating a view, its is gathered from the Java view of the application.
    IViewShape view = MappingRegistry.REGISTRY.getTargetFromSource(shape, IViewDot.class);

    if(view==null) {
      view =  View2DTK.getFactory().createView(shape);
      viewCreated = true;
    }
    else viewCreated = false;

        view.paint(graphics, null);
        root = graphics.getElement();

        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_DOT);
        root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_SIZE, String.valueOf(shape.getDiametre()));
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_DOT_SHAPE, shape.getDotStyle().getPSTToken());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_POSITION, shape.getPosition().getX() + " " + shape.getPosition().getY()); //$NON-NLS-1$

    graphics.dispose();

    if(viewCreated)
      view.flush();
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);
    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

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



  private double toSVGCircle(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape     = arrow.getShape();
    final SVGElement circle = new SVGCircleElement(doc);
    final double r       = (arrow.getDotSizeDim()+arrow.getDotSizeNum()*lineWidth)/2.-lineWidth/2.;

    circle.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_DOT_SIZE_NUM, String.valueOf(arrow.getDotSizeNum()));
    circle.setAttribute(SVGAttributes.SVG_R, String.valueOf(r/lineWidth));
    circle.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(shape.getFillingCol(), true));
    circle.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    circle.setStrokeWidth(1);
    marker.appendChild(circle);

    return arrow.getArrowStyle()==ArrowStyle.CIRCLE_IN ? lineWidth*(arrow.isLeftArrow() ? -1. : 1.) : 0.;
  }
View Full Code Here

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



  private double toSVGDisk(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape     = arrow.getShape();
    final SVGElement circle = new SVGCircleElement(doc);
    final double r       = (arrow.getDotSizeDim()+arrow.getDotSizeNum()*lineWidth)/2.;

    circle.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_DOT_SIZE_NUM, String.valueOf(arrow.getDotSizeNum()));
    circle.setAttribute(SVGAttributes.SVG_R, String.valueOf(r/lineWidth));
    circle.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    marker.appendChild(circle);

    return arrow.getArrowStyle()==ArrowStyle.DISK_IN ? lineWidth *  (arrow.isLeftArrow() ? -1. : 1.) : 0.;
  }
View Full Code Here

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



  private void toSVGArrow(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGElement arrowSVG   = new SVGPathElement(doc);
    final double width      = (arrow.getArrowSizeNum()*lineWidth + arrow.getArrowSizeDim())/lineWidth;
    double length         = arrow.getArrowLength()*width;
        double inset                = arrow.getArrowInset()*length;
        final SVGPathSegList path   = new SVGPathSegList();

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_ARROW) {
      length *= -1.;
      inset *= -1.;
    }

    final double lgth2 = arrow.isInverted() ? length : 0.;
    path.add(new SVGPathSegMoveto(lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length+lgth2, width/2., false));
    path.add(new SVGPathSegLineto(-length+inset+lgth2, 0.false));
    path.add(new SVGPathSegLineto(-length+lgth2, -width/2., false));
    path.add(new SVGPathSegClosePath());

    marker.appendChild(arrowSVG);
    arrowSVG.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_SIZE_NUM, String.valueOf(arrow.getArrowSizeNum()));
    arrowSVG.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    arrowSVG.setAttribute(SVGAttributes.SVG_D, path.toString());
  }
View Full Code Here

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

  }


  private void toSVGDoubleArrow(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGElement arrowSVG   = new SVGPathElement(doc);
    final double width      = (arrow.getArrowSizeNum()*lineWidth + arrow.getArrowSizeDim())/lineWidth;
    double length         = arrow.getArrowLength()*width;
        double inset                = arrow.getArrowInset()*length;
        final SVGPathSegList path   = new SVGPathSegList();

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_DBLE_ARROW) {
      inset *= -1.;
      length *= -1.;
    }

    final double lgth2 = arrow.isInverted() ? length*2 : 0.;
    path.add(new SVGPathSegMoveto(lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length+lgth2, width/2., false));
    path.add(new SVGPathSegLineto(-length+inset+lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length+lgth2, -width/2., false));
    path.add(new SVGPathSegClosePath());
    path.add(new SVGPathSegMoveto(-length+lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length*2+lgth2, width/2., false));
    path.add(new SVGPathSegLineto(-length*2+inset+lgth2, 0., false));
    path.add(new SVGPathSegLineto(-length*2+lgth2, -width/2., false));
    path.add(new SVGPathSegClosePath());

    marker.appendChild(arrowSVG);
    arrowSVG.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_SIZE_NUM, String.valueOf(arrow.getArrowSizeNum()));
    arrowSVG.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    arrowSVG.setAttribute(SVGAttributes.SVG_D, path.toString());
  }
View Full Code Here

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

  }


  private void toSVGRoundIn(final SVGDocument doc, final boolean isShadow, final SVGElement marker) {
    final IShape shape     = arrow.getShape();
    final SVGElement circle = new SVGCircleElement(doc);
    circle.setAttribute(SVGAttributes.SVG_R, "0.5"); //$NON-NLS-1$
    circle.setAttribute(SVGAttributes.SVG_FILL, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    marker.appendChild(circle);
  }
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.