Package net.sf.latexdraw.parsers.svg

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


  @SuppressWarnings("unused")
  @Test
  public void testContructor() throws MalformedSVGDocument {
    try {
      new SVGCircleElement(null, null);
      fail();
    }
    catch(Exception e){/**/}

    try {
      new SVGCircleElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    try {
      node.setAttribute(SVGAttributes.SVG_R, "dsd"); //$NON-NLS-1$
      new SVGCircleElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    try {
      node.setAttribute(SVGAttributes.SVG_R, "-1"); //$NON-NLS-1$
      new SVGCircleElement(node, null);
      fail();
    }
    catch(MalformedSVGDocument e){/**/}

    node.setAttribute(SVGAttributes.SVG_R, "10"); //$NON-NLS-1$
    new SVGCircleElement(node, null);
  }
View Full Code Here



  @Test
  public void testGetCy() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_R, "10"); //$NON-NLS-1$
    SVGCircleElement e = new SVGCircleElement(node, null);
    assertEquals(e.getCy(), 0., 0.0001);

    node.setAttribute(SVGAttributes.SVG_CY, "40"); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getCy(), 40., 0.0001);

    node.setAttribute(SVGAttributes.SVG_CY, "40px "); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getCy(), 40., 0.0001);

    node.setAttribute(SVGAttributes.SVG_CY, " 40 cm "); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getCy(), UnitProcessor.INSTANCE.toUserUnit(40, SVGLength.LengthType.CM), 0.0001);
  }
View Full Code Here


  @Test
  public void testGetCx() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_R, "10"); //$NON-NLS-1$
    SVGCircleElement e = new SVGCircleElement(node, null);
    assertEquals(e.getCx(), 0., 0.0001);

    node.setAttribute(SVGAttributes.SVG_CX, "76.987"); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getCx(), 76.987, 0.0001);

    node.setAttribute(SVGAttributes.SVG_CX, "40px "); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getCx(), 40., 0.0001);

    node.setAttribute(SVGAttributes.SVG_CX, " 30.5 mm "); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getCx(), UnitProcessor.INSTANCE.toUserUnit(30.5, SVGLength.LengthType.MM), 0.0001);
  }
View Full Code Here


  @Test
  public void testEnableRendering() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_R, "0"); //$NON-NLS-1$
    SVGCircleElement e = new SVGCircleElement(node, null);
    assertFalse(e.enableRendering());

    node.setAttribute(SVGAttributes.SVG_R, "10"); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertTrue(e.enableRendering());
  }
View Full Code Here


  @Test
  public void testGetR() throws MalformedSVGDocument {
    node.setAttribute(SVGAttributes.SVG_R, "20"); //$NON-NLS-1$
    SVGCircleElement e = new SVGCircleElement(node, null);
    assertEquals(e.getR(), 20., 0.0001);
    node.setAttribute(SVGAttributes.SVG_R, "20 pt"); //$NON-NLS-1$
    e = new SVGCircleElement(node, null);
    assertEquals(e.getR(), UnitProcessor.INSTANCE.toUserUnit(20, SVGLength.LengthType.PT), 0.0001);
  }
View Full Code Here



  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



  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

  }


  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

    subgridDots.setAttribute(prefix+LNamespace.XML_GRID_WIDTH, String.valueOf(subGridWidth));

    for(double i=0, n=tlx; i<nbX; i++, n+=xSubStep)
      for(double j=0, m=tly; j<=nbY; j++, m+=ySubStep)
        for(double k=0; k<subGridDots; k++) {
          dot = new SVGCircleElement(document);
          dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(n+k*dotStep));
          dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(m));
          dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(subGridWidth/2.));
          subgridDots.appendChild(dot);
        }

    for(double j=0, n=tly; j<nbY; j++, n+=ySubStep)
      for(double i=0, m=tlx; i<=nbX; i++, m+=xSubStep)
        for(double k=0; k<subGridDots; k++) {
          dot = new SVGCircleElement(document);
          dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(m));
          dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(n+k*dotStep));
          dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(subGridWidth/2.));
          subgridDots.appendChild(dot);
        }

    dot = new SVGCircleElement(document);
    dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(brx));
    dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(bry));
    dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(subGridWidth/2.));

    elt.appendChild(subgridDots);
View Full Code Here

    gridDotsElt.setAttribute(prefix+LNamespace.XML_GRID_WIDTH, String.valueOf(gridWidth));

    for(k=minX, i=posX; k<=maxX; i+=xStep, k++)
      for(m=tly, n=minY; n<maxY; n++, m+=absStep)
        for(l=0, j=m; l<gridDots; l++, j+=dotStep) {
          dot = new SVGCircleElement(document);
          dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(i));
          dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(j));
          dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(gridWidth/2.));
          gridDotsElt.appendChild(dot);
        }

    for(k=minY, i=posY; k<=maxY; i-=yStep, k++)
      for(m=tlx, n=minX; n<maxX; n++, m+=absStep)
        for(l=0, j=m; l<gridDots; l++, j+=dotStep) {
          dot = new SVGCircleElement(document);
          dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(j));
          dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(i));
          dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(gridWidth/2.));
          gridDotsElt.appendChild(dot);
        }

    dot = new SVGCircleElement(document);
    dot.setAttribute(SVGAttributes.SVG_CX, String.valueOf(brx));
    dot.setAttribute(SVGAttributes.SVG_CY, String.valueOf(bry));
    dot.setAttribute(SVGAttributes.SVG_R, String.valueOf(gridWidth/2.));
    gridDotsElt.appendChild(dot);
View Full Code Here

TOP

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

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.