Examples of SVGLength


Examples of fr.dz.swan.balises.types.SVGLength

  public BaliseGraphic(String name) {
    super(name);
    attributes.put("fill",new SVGColor((Color)null));// normalement pas svgcolor mais svgpaint
    attributes.put("stroke",new SVGColor(Color.black)); // idem
    attributes.put("stroke-width",new SVGLength(0.0));
   
  }
View Full Code Here

Examples of fr.dz.swan.balises.types.SVGLength

  public void paint(Graphics2D g) {

    Color oldColor = g.getColor();
    Stroke oldStroke = g.getStroke();
   
    SVGLength strokeWidth=(SVGLength)attributes.get("stroke-width");
    SVGColor stroke=(SVGColor)attributes.get("stroke");
    SVGColor fill=(SVGColor)attributes.get("fill");

    Shape s =getShape();
   
   

    if(fill.getValue()!=null){
      g.setColor(fill.getValue());
      g.fill(s);
    }
    if(stroke.getValue()!=null){
      Stroke bs = new BasicStroke(strokeWidth.getValue().floatValue(),BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER);
      g.setStroke(bs);
      g.setColor(stroke.getValue());
      g.draw(s);
    }
View Full Code Here

Examples of fr.dz.swan.balises.types.SVGLength

*/
public class Rect extends BaliseGraphic {

    public Rect() {
        super("rect");
        attributes.put("width", new SVGLength(0.0));
        attributes.put("height", new SVGLength(0.0));
        attributes.put("x", new SVGCoordinate(0.0));
        attributes.put("y", new SVGCoordinate(0.0));
        attributes.put("rx", new SVGLength(0.0));
        attributes.put("ry", new SVGLength(0.0));
    }
View Full Code Here

Examples of fr.dz.swan.balises.types.SVGLength

   
    @Override
    public Shape getShape() {
   
        SVGLength width =(SVGLength) attributes.get("width");
        SVGLength height =(SVGLength)attributes.get("height");
        SVGCoordinate x =(SVGCoordinate)attributes.get("x");
        SVGCoordinate y =(SVGCoordinate)attributes.get("y");
        SVGLength rx =(SVGLength)attributes.get("rx");
        SVGLength ry =(SVGLength)attributes.get("ry");
       
       
        return new RoundRectangle2D.Double(x.getValue(), y.getValue(), width.getValue(), height.getValue(),rx.getValue(),ry.getValue());
    }
View Full Code Here

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

public class TestSVGLength {
  @SuppressWarnings("unused")
  @Test
  public void testConsctrutor() {
    try {
      new SVGLength(1, null, "1"); //$NON-NLS-1$
      fail();
    }
    catch(IllegalArgumentException e){ /* */ }

    try {
      new SVGLength(1, LengthType.CM, null);
      fail();
    }
    catch(IllegalArgumentException e){ /* */ }
  }
View Full Code Here

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

  }


  @Test
  public void testGetters() {
    SVGLength l = new SVGLength(1, LengthType.MM, "1"); //$NON-NLS-1$

    assertEquals(l.getValue(), 1., 0.1);
    assertEquals(l.getLengthType(), LengthType.MM);
    assertEquals(l.getValueAsString(), "1"); //$NON-NLS-1$
  }
View Full Code Here

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

public class TestSVGLengthParser {
  @SuppressWarnings("unused")
  @Test
  public void testParseLength() throws ParseException {
    SVGLengthParser p;
    SVGLength l;

    try {
      new SVGLengthParser(null);
      fail();
    }
    catch(IllegalArgumentException e){ /* */ }

    try {
      p = new SVGLengthParser(""); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1m"); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("m"); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1p"); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1e1i"); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1ci"); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1 c "); //$NON-NLS-1$
      l = p.parseLength();
      fail();
    }
    catch(ParseException e){ /* */ }

    p = new SVGLengthParser("1mm"); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "1"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(1, SVGLength.LengthType.MM), l.getValue(), 0.001);

    p = new SVGLengthParser("0.65 cm"); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "0.65"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(0.65, SVGLength.LengthType.CM), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -10.65  \t \n pc"); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "-10.65"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-10.65, SVGLength.LengthType.PC), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -10.65e2  \t \n px \t   "); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "-10.65e2"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-10.65e2, SVGLength.LengthType.PX), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -10.65e0pt \t   "); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "-10.65e0"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-10.65e0, SVGLength.LengthType.PT), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -1.in \t   "); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "-1."); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-1., SVGLength.LengthType.IN), l.getValue(), 0.001);

    p = new SVGLengthParser("-1."); //$NON-NLS-1$
    l = p.parseLength();

    assertEquals(l.getValueAsString(), "-1."); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-1., SVGLength.LengthType.NUMBER), l.getValue(), 0.001);
  }
View Full Code Here

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


  @Test
  public void testParseNumberOrPercent() throws ParseException {
    SVGLengthParser p;
    SVGLength l;

    p = new SVGLengthParser("1mm"); //$NON-NLS-1$
    l = p.parseNumberOrPercent();

    assertEquals(l.getValueAsString(), "1"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.NUMBER);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(1, SVGLength.LengthType.NUMBER), l.getValue(), 0.001);

    p = new SVGLengthParser("0.876"); //$NON-NLS-1$
    l = p.parseNumberOrPercent();

    assertEquals(l.getValueAsString(), "0.876"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.NUMBER);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(0.876, SVGLength.LengthType.NUMBER), l.getValue(), 0.001);
  }
View Full Code Here

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


  @Test
  public void testParseCoordinate() throws ParseException {
    SVGLengthParser p;
    SVGLength l;

    try {
      p = new SVGLengthParser(""); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1m"); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("m"); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1p"); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1e1i"); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1ci"); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    try {
      p = new SVGLengthParser("1 c "); //$NON-NLS-1$
      l = p.parseCoordinate();
      fail();
    }
    catch(ParseException e){ /* */ }

    p = new SVGLengthParser("1mm"); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "1"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(1, SVGLength.LengthType.MM), l.getValue(), 0.001);

    p = new SVGLengthParser("0.65 cm"); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "0.65"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(0.65, SVGLength.LengthType.CM), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -10.65  \t \n pc"); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "-10.65"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-10.65, SVGLength.LengthType.PC), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -10.65e2  \t \n px \t   "); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "-10.65e2"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-10.65e2, SVGLength.LengthType.PX), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -10.65e0pt \t   "); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "-10.65e0"); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-10.65e0, SVGLength.LengthType.PT), l.getValue(), 0.001);

    p = new SVGLengthParser("\t -1.in \t   "); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "-1."); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-1., SVGLength.LengthType.IN), l.getValue(), 0.001);

    p = new SVGLengthParser("-1."); //$NON-NLS-1$
    l = p.parseCoordinate();

    assertEquals(l.getValueAsString(), "-1."); //$NON-NLS-1$
    assertEquals(l.getLengthType(), SVGLength.LengthType.PX);
    assertEquals(UnitProcessor.INSTANCE.toUserUnit(-1., SVGLength.LengthType.NUMBER), l.getValue(), 0.001);
  }
View Full Code Here

Examples of org.w3c.dom.svg.SVGLength

    /**
     */
    protected SVGItem createSVGItem(Object newItem){
       
        SVGLength l = (SVGLength)newItem;

        return new SVGLengthItem(l.getUnitType(), l.getValueInSpecifiedUnits(),direction);
    }
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.