Examples of SVGElement


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

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

    final SVGElement root = new SVGGElement(doc);
        SVGElement elt;
        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_TRIANGLE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
      final double gap     = getPositionGap()/2.;
      final IPoint pt1     = shape.getTopLeftPoint();
      final IPoint pt2     = shape.getBottomRightPoint();
    final IPoint p1     = ShapeFactory.createPoint((pt1.getX()+pt2.getX())/2., pt1.getY());
    final IPoint p2     = ShapeFactory.createPoint(pt2.getX(), pt2.getY());
    final IPoint p3     = ShapeFactory.createPoint(pt1.getX(), pt2.getY());
      final double p1x = p1.getX();
      final double p1y = p1.getY();
      final double p2x = p2.getX();
      final double p2y = p2.getY();
      final double p3x = p3.getX();
      double cornerGap1 = GLibUtilities.getCornerGap(ShapeFactory.createPoint(p1x, p2y), p1, p2, gap);
      double cornerGap2 = GLibUtilities.getCornerGap(shape.getGravityCentre(), p2, p3, gap);

      if(p2x>p3x)
        cornerGap2*=-1;

      if(p1y>p2y)
        cornerGap1*=-1;

    final String points = p1x + "," + (p1y - cornerGap1) + " " + //$NON-NLS-1$//$NON-NLS-2$
            (p2x - cornerGap2) + "," + (p2y + (p1y<p2y ? gap : -gap)) + " " + //$NON-NLS-1$//$NON-NLS-2$
            (p3x + cornerGap2) + "," + (p2y + (p1y<p2y ? gap : -gap));//$NON-NLS-1$
      final String ltdPoints = pt1.getX() + " " + pt1.getY() + " " + shape.getPtAt(1).getX() + " " + shape.getPtAt(1).getY() +//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                " " + shape.getPtAt(2).getX() + " " + shape.getPtAt(2).getY() + " " + pt2.getX() + " " + pt2.getY();//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$

    if(shape.hasShadow()){
      final SVGElement shad = new SVGPolygonElement(doc);

         shad.setAttribute(SVGAttributes.SVG_POINTS, points);
         setSVGShadowAttributes(shad, true);
         root.appendChild(shad);
    }

        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 SVGPolygonElement(doc);
        elt.setAttribute(SVGAttributes.SVG_POINTS, points);
        setSVGBorderBackground(elt, root);
        }

    elt = new SVGPolygonElement(doc);
    elt.setAttribute(SVGAttributes.SVG_POINTS, points);
    root.appendChild(elt);
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_POINTS, ltdPoints);

    if(shape.hasDbleBord()){
      final SVGElement dblBord = new SVGPolygonElement(doc);

      dblBord.setAttribute(SVGAttributes.SVG_POINTS, points);
      setSVGDoubleBordersAttributes(dblBord);
      root.appendChild(dblBord);
    }

    setSVGAttributes(doc, elt, true);
View Full Code Here

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

   * @param elt The source element.
   * @throws IllegalArgumentException If the given element is null or not valid.
   * @since 3.0
   */
  protected 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);
View Full Code Here

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 x    = tl.getX()-gap/2.;
        final double y    = tl.getY()-gap/2.;

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

        if(shape.hasShadow()) {
          elt = new SVGRectElement(x, y, width, width, 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, width, document);
          setSVGBorderBackground(elt, root);
          setSVGRoundCorner(elt);
        }

        elt = new SVGRectElement(x, y, width, width, document);
        root.appendChild(elt);
        setSVGAttributes(document, elt, true);
        setSVGRoundCorner(elt);

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

        setSVGRotationAttribute(root);

    return root;
View Full Code Here

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

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

    final SVGElement elt2 = getLaTeXDrawElement(elt, null);

    if(elt==null || !(elt2 instanceof SVGPolyLineElement) && !(elt2 instanceof SVGLineElement))
      throw new IllegalArgumentException();

    if(elt2 instanceof SVGPolyLineElement) {
      setSVGModifiablePointsParameters((SVGPolyLineElement)elt2);
    }else {
      final SVGLineElement lineElt = (SVGLineElement)elt2;
      shape.addPoint(ShapeFactory.createPoint(lineElt.getX1(), lineElt.getY1()));
      shape.addPoint(ShapeFactory.createPoint(lineElt.getX2(), lineElt.getY2()));
    }

    setSVGParameters(elt2);
    setSVGLatexdrawParameters(elt);
    setSVGShadowParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_SHADOW));
    setSVGDbleBordersParameters(getLaTeXDrawElement(elt, LNamespace.XML_TYPE_DBLE_BORDERS));
    final IArrow arrow1   = shape.getArrowAt(0);
    final IArrow arrow2   = shape.getArrowAt(-1);
    setSVGArrow(arrow1, elt2.getAttribute(elt2.getUsablePrefix()+SVGAttributes.SVG_MARKER_START), elt2, SVGAttributes.SVG_MARKER_START);
    setSVGArrow(arrow2, elt2.getAttribute(elt2.getUsablePrefix()+SVGAttributes.SVG_MARKER_END), elt2, SVGAttributes.SVG_MARKER_END);
    homogeniseArrows(arrow1, arrow2);

    if(withTransformation)
      applyTransformations(elt);
  }
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 SVGDefsElement defs   = doc.getFirstChild().getDefs();
    final StringBuilder points   = new StringBuilder();
    final List<IPoint> pts    = shape.getPoints();
    SVGPolyLineElement elt;

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

    for(final IPoint pt : pts)
      points.append(pt.getX()).append(',').append(pt.getY()).append(' ');

    final String pointsStr = points.toString();

    if(shape.hasShadow()) {
      final SVGPolyLineElement shad = new SVGPolyLineElement(doc);
      try { shad.setPoints(pointsStr); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
      setSVGShadowAttributes(shad, false);
      root.appendChild(shad);
      setSVGArrow(shape, shad, 0, true, doc, defs);
      setSVGArrow(shape, shad, 1, true, doc, defs);
    }

        if(shape.hasShadow() && !shape.getLineStyle().getLatexToken().equals(PSTricksConstants.LINE_NONE_STYLE) && shape.isFilled()) {
          // The background of the borders must be filled is there is a shadow.
        elt = new SVGPolyLineElement(doc);
        try { elt.setPoints(pointsStr); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
        setSVGBorderBackground(elt, root);
        }

    elt = new SVGPolyLineElement(doc);
    try { elt.setPoints(pointsStr); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
    root.appendChild(elt);

    if(shape.hasDbleBord()) {
      final SVGPolyLineElement dblBord = new SVGPolyLineElement(doc);
      try { dblBord.setPoints(pointsStr); }catch(final ParseException ex) { BadaboomCollector.INSTANCE.add(ex); }
      setSVGDoubleBordersAttributes(dblBord);
      root.appendChild(dblBord);
    }

    setSVGAttributes(doc, elt, false);
    elt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_ROTATION, String.valueOf(shape.getRotationAngle()));
View Full Code Here

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

     * @param doc The SVG document used to create elements.
     * @return The created view or null.
     * @since 3.0
     */
    public SVGElement execute(final IShape model, final SVGDocument doc) {
      final SVGElement view;

      if(clazz.isInstance(model))
        view = create(model, doc);
      else
        view = next==null ? null : next.execute(model, doc);
View Full Code Here

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

    final SVGNodeList nl = elt.getChildren(SVGElements.SVG_G);
    int i=0;
        final int size = nl.getLength();
        SVGGElement l1=null;
        SVGGElement l2=null;
        SVGElement element;

    while((l1==null || l2==null) && i<size) {
      element = nl.item(i);

      if(element instanceof SVGGElement)
View Full Code Here

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

//    final Graphics2D2SVG graphics = new Graphics2D2SVG(doc);
//    IViewShape view = View2DTK.getFactory().createView(shape);

//        view.paint(graphics);
        //  graphics.getElement();
        final SVGElement root = new SVGGElement(doc);
    final String pref = LNamespace.LATEXDRAW_NAMESPACE+':';
    setThickness(root, shape.getThickness(), false, 0.);
    root.setStroke(shape.getLineColour());

    root.setAttribute(pref+LNamespace.XML_STYLE, shape.getAxesStyle().toString());
    root.setAttribute(pref+LNamespace.XML_GRID_START, shape.getGridStartX() + " " + shape.getGridStartY()); //$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_GRID_END, shape.getGridEndX() + " " + shape.getGridEndY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_GRID_ORIGIN, shape.getOriginX() + " " + shape.getOriginY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_AXE_INCREMENT, shape.getIncrementX() + " " + shape.getIncrementY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_AXE_DIST_LABELS, shape.getDistLabelsX() + " " + shape.getDistLabelsY());//$NON-NLS-1$
    root.setAttribute(pref+LNamespace.XML_AXE_TICKS_SIZE, String.valueOf(shape.getTicksSize()));
    root.setAttribute(pref+LNamespace.XML_AXE_SHOW_ORIGIN, String.valueOf(shape.isShowOrigin()));
    root.setAttribute(pref+LNamespace.XML_AXE_SHOW_TICKS, shape.getTicksDisplayed().toString());
    root.setAttribute(pref+LNamespace.XML_AXE_LABELS_STYLE, shape.getLabelsDisplayed().toString());
    root.setAttribute(pref+LNamespace.XML_AXE_TICKS_STYLE, shape.getTicksStyle().toString());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_AXE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    createSVGAxe(root, doc);
    setSVGRotationAttribute(root);

//    view.flush();
//    graphics.dispose();
View Full Code Here

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

      xLine.getArrowAt(0).copy(arr0);
      xLine.getArrowAt(1).copy(arr1);
      yLine.getArrowAt(0).copy(shape.getArrowAt(0));
      yLine.getArrowAt(1).copy(shape.getArrowAt(2));
      final SVGElement eltX = new LPolylinesSVGGenerator(xLine).toSVG(document);
      final SVGElement eltY = new LPolylinesSVGGenerator(yLine).toSVG(document);

      elt.appendChild(eltX);
      elt.appendChild(eltY);
    }
  }
View Full Code Here

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

   * @param elt The source element.
   * @throws IllegalArgumentException If the given element is null or not valid.
   * @since 3.0
   */
  protected 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);
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.