Package net.sf.latexdraw.glib.models.interfaces.shape

Examples of net.sf.latexdraw.glib.models.interfaces.shape.IShape




  @Test
  public void testParamFillingcolor() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=solid, fillcolor =blue]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isFillable()) {
      assertEquals(Color.BLUE, sh.getFillingCol());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=solid, fillcolor=\\psfillcolor]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.WHITE, sh.getFillingCol());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=solid, fillcolor=\\psfillcolor,fillcolor=red]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.RED, sh.getFillingCol());
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here




  @Test
  public void testParamGradbegin() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradbegin =blue]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isInteriorStylable()) {
      assertEquals(Color.BLUE, sh.getGradColStart());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradbegin=\\psfillcolor]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.WHITE, sh.getGradColStart());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradbegin=\\psfillcolor,gradbegin=red]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.RED, sh.getGradColStart());
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here



  @Test
  public void testParamGradend() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradend =blue]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isInteriorStylable()) {
      assertEquals(Color.BLUE, sh.getGradColEnd());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradend=\\psfillcolor]"+getBasicCoordinates()).get().getShapeAt(0)//$NON-NLS-1$//$NON-NLS-2$
      assertEquals(Color.WHITE, sh.getGradColEnd());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradend=\\psfillcolor,gradend=red]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.RED, sh.getGradColEnd());
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here

  }


  @Test
  public void testParamHatchcolor() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=clines, hatchcolor =blue]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isInteriorStylable()) {
      assertEquals(Color.BLUE, sh.getHatchingsCol());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=clines, hatchcolor=\\psfillcolor]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.WHITE, sh.getHatchingsCol());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=clines, hatchcolor=\\psfillcolor,hatchcolor=red]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Color.RED, sh.getHatchingsCol());
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here

  }


  @Test
  public void testParamDoubleLine() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[doubleline = true]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isDbleBorderable()) {
      assertTrue(sh.hasDbleBord());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[doubleline =false]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertFalse(sh.hasDbleBord());
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[doubleline =true, doubleline=false]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertFalse(sh.hasDbleBord());
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here


public abstract class TestParsingShape extends TestPSTParser {
  @Test
  public void testParamGradlines() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradlines=100]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isInteriorStylable()) {
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradlines=200]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradlines=300]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertTrue(PSTParser.errorLogs().isEmpty());
View Full Code Here

  }


  @Test
  public void testParamShadowangle() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[shadow=true, shadowangle=10]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isShadowable()) {
      assertEquals(Math.toRadians(10.), sh.getShadowAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[shadow=true, shadowangle=20.]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(20.), sh.getShadowAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[shadow=true, shadowangle=0.5]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(0.5), sh.getShadowAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[shadow=true, shadowangle=+---123.1]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(-123.1), sh.getShadowAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[shadow=true, shadowangle=10, shadowangle=-12]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(-12.), sh.getShadowAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here

  }


  @Test
  public void testParamGradangle() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradangle=10]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isInteriorStylable()) {
      assertEquals(Math.toRadians(10.), sh.getGradAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradangle=20.]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(20.), sh.getGradAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradangle=0.5]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(0.5), sh.getGradAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradangle=+---123.1]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(-123.1), sh.getGradAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradangle=10, gradangle=-12]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(Math.toRadians(-12.), sh.getGradAngle(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
    }
  }
View Full Code Here

  }


  @Test
  public void testParamGradmidpoint() throws ParseException {
    IShape sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradmidpoint=0]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
    if(sh.isInteriorStylable()) {
      assertEquals(0., sh.getGradMidPt(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradmidpoint=1]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(1., sh.getGradMidPt(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradmidpoint=0.5]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(0.5, sh.getGradMidPt(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradmidpoint=0.22]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertEquals(0.22, sh.getGradMidPt(), 0.00001);
      assertTrue(PSTParser.errorLogs().isEmpty());
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradmidpoint=-1]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
      assertFalse(PSTParser.errorLogs().isEmpty());
      PSTParser.errorLogs().clear();
      sh = parser.parsePSTCode("\\"+getCommandName()+"[fillstyle=gradient, gradmidpoint=2]"+getBasicCoordinates()).get().getShapeAt(0); //$NON-NLS-1$ //$NON-NLS-2$
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

TOP

Related Classes of net.sf.latexdraw.glib.models.interfaces.shape.IShape

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.