Examples of IShape


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

  }


  @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

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

  }


  @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

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

  }



  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.glib.models.interfaces.shape.IShape

  }



  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.glib.models.interfaces.shape.IShape

  }



  private void toSVGBar(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGPathElement bar  = new SVGPathElement(doc);
    final double width       = arrow.getTBarSizeDim() + arrow.getTBarSizeNum()*lineWidth;
    final SVGPathSegList path   = new SVGPathSegList();
    final double x         = arrow.getArrowStyle()==ArrowStyle.BAR_IN ? arrow.isLeftArrow() ? 0.5 : -0.5 : 0.;

    bar.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_TBAR_SIZE_NUM, String.valueOf(arrow.getTBarSizeNum()));
    path.add(new SVGPathSegMoveto(x, -width/(lineWidth*2.), false));
    path.add(new SVGPathSegLineto(x, width/(lineWidth*2.), false));
    bar.setPathData(path);
    bar.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    bar.setAttribute(SVGAttributes.SVG_FILL, SVGAttributes.SVG_VALUE_NONE);
    bar.setPathData(path);
    bar.setStrokeWidth(1.);
    marker.appendChild(bar);
  }
View Full Code Here

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

  }



  private double toSVGSquareBracket(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape      = arrow.getShape();
    final SVGPathElement bar   = new SVGPathElement(doc);
    final double width       = arrow.getTBarSizeDim() + arrow.getTBarSizeNum()*lineWidth;
    final SVGPathSegList path   = new SVGPathSegList();
    final double lgth       = arrow.getBracketNum()*(arrow.getTBarSizeDim()/IShape.PPC + arrow.getTBarSizeNum()*lineWidth)/lineWidth;
    final boolean isInverted    = arrow.isInverted();//FIXME shape.PPC
    final double gapPostion;

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_SQUARE_BRACKET) {
      final double lgth2 = isInverted ? -lgth : 0.;
      path.add(new SVGPathSegMoveto(lgth+lgth2+0.5, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, width/(lineWidth*2)-0.5, false));
      path.add(new SVGPathSegLineto(lgth+lgth2+0.5, width/(lineWidth*2)-0.5, false));
      gapPostion = isInverted ? -lineWidth/4. : -lineWidth/2.;
    }
    else {
      final double lgth2 = isInverted ? lgth : 0.;
      path.add(new SVGPathSegMoveto(-lgth+lgth2-0.5, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, -width/(lineWidth*2)+0.5, false));
      path.add(new SVGPathSegLineto(lgth2, width/(lineWidth*2)-0.5, false));
      path.add(new SVGPathSegLineto(-lgth+lgth2-0.5, width/(lineWidth*2)-0.5, false));
      gapPostion = isInverted ? lineWidth/4. : lineWidth/2.;
    }

    marker.appendChild(bar);
    bar.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_TBAR_SIZE_NUM, String.valueOf(arrow.getTBarSizeNum()));
    bar.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    bar.setAttribute(SVGAttributes.SVG_FILL, SVGAttributes.SVG_VALUE_NONE);
    bar.setPathData(path);
    bar.setAttribute(SVGAttributes.SVG_STROKE_WIDTH, "1"); //$NON-NLS-1$

    return gapPostion;
View Full Code Here

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

  }



  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.glib.models.interfaces.shape.IShape

  }



  private void toSVGRoundBracket(final SVGDocument doc, final double lineWidth, final boolean isShadow, final SVGElement marker) {
    final IShape shape        = arrow.getShape();
    final SVGPathElement rbracket   = new SVGPathElement(doc);
    final double width         = (arrow.getTBarSizeDim() + arrow.getTBarSizeNum()*lineWidth)/lineWidth;
    double lgth            = arrow.getRBracketNum()*width;
    final SVGPathSegList path     = new SVGPathSegList();
    double gap            = 0.5;

    if(arrow.getArrowStyle()==ArrowStyle.LEFT_ROUND_BRACKET) {
      lgth *= -1.;
      gap *= -1.;
    }

    final double lgth2 = arrow.isInverted() ? lgth : 0.;
    path.add(new SVGPathSegMoveto(-lgth+lgth2-gap, width/2., false));
    path.add(new SVGPathSegCurvetoCubic(-lgth+lgth2-gap, -width/2., 0., width/2., 0., -width/2., false));

    marker.appendChild(rbracket);
    rbracket.setAttribute(SVGAttributes.SVG_STROKE, CSSColors.INSTANCE.getColorName(isShadow ? shape.getShadowCol() : shape.getLineColour(), true));
    rbracket.setAttribute(SVGAttributes.SVG_FILL, SVGAttributes.SVG_VALUE_NONE);
    rbracket.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_ARROW_TBAR_SIZE_NUM, String.valueOf(arrow.getTBarSizeNum()));
    rbracket.setPathData(path);
    rbracket.setStrokeWidth(1);
  }
View Full Code Here

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

    rbracket.setStrokeWidth(1);
  }


  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.glib.models.interfaces.shape.IShape

    arrowSVG.setAttribute(SVGAttributes.SVG_D, path.toString());
  }


  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.