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

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


    final IDrawing drawing  = synchro.getDrawing();
    StringBuilder code;
    String pkg         = LaTeXGenerator.getPackages();
    PSTShapeView<?> pstView;
    final ViewsSynchroniserHandler handler = synchro.getHandler();
    final IPoint origin   = handler.getOriginDrawingPoint();
    final IPoint tl       = handler.getTopRightDrawingPoint();
    final IPoint br       = handler.getBottomLeftDrawingPoint();
    final int ppc         = handler.getPPCDrawing();
    final Map<String, String> addedColours = new HashMap<>();
    final StringBuilder shapeCode = new StringBuilder();
    final boolean hasBeginFigure;

    if(drawing.isEmpty())
      return ;

    if(withComments && comment!=null && !comment.isEmpty())
      cache.append(comment);

    cache.append(PACKAGE_PSTRICKS);

    if(!pkg.isEmpty()) {
      pkg = "% User Packages:" + LResources.EOL + "% " + pkg.replace(LResources.EOL, LResources.EOL + "% "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      cache.append(pkg).append(LResources.EOL);
    }

    if(withLatexParams && (positionVertToken!=VerticalPosition.NONE || !caption.isEmpty() || !label.isEmpty())) {
      cache.append("\\begin{figure}"); //$NON-NLS-1$

      if(positionVertToken==VerticalPosition.NONE)
        cache.append(LResources.EOL);
      else
        cache.append('[').append(positionVertToken.getToken()).append(']').append(LResources.EOL);

      hasBeginFigure = true;
    }
    else hasBeginFigure = false;

    if(withLatexParams && positionHoriCentre)
      cache.append("\\begin{center}").append(LResources.EOL);//$NON-NLS-1$

    final Float scaleF = (float)LNumber.getCutNumber(getScale());
    cache.append("\\psscalebox{").append(scaleF).append(' ').append(scaleF).append("} % Change this value to rescale the drawing.");//$NON-NLS-1$ //$NON-NLS-2$
    cache.append(LResources.EOL).append('{').append(LResources.EOL);
    cache.append("\\begin{pspicture}("); //$NON-NLS-1$
    cache.append(0).append(',').append((float)LNumber.getCutNumber((origin.getY()-br.getY())/ppc)).append(')').append('(');
    cache.append((float)LNumber.getCutNumber((tl.getX()-origin.getX())/ppc)).append(',').append((float)LNumber.getCutNumber((origin.getY()-tl.getY())/ppc));
    cache.append(')').append(LResources.EOL);

    for(final IShape shape : drawing.getShapes()) {
      pstView = synchro.getView(shape);
View Full Code Here


  @Override
  public void update(final IModifiablePointsShape sh, final double zoom) {
    if(sh==null) return;

    final IPoint zoomedGC = sh.getGravityCentre().zoom(zoom);
    final double rotAngle = sh.getRotationAngle();
    IPoint pt = sh.getPtAt(indexPt);

    // If the shape is rotated, the handler's position must fit the rotation angle.
    if(!LNumber.equalsDouble(rotAngle, 0.))
      pt = pt.rotatePoint(zoomedGC, rotAngle);

    point.setPoint(pt.zoom(zoom));
    super.update(sh, zoom);
  }
View Full Code Here

  @Override
  public void update(final IArc arc, final double zoom) {
    if(arc==null) return;

    final IPoint zoomedGC = arc.getGravityCentre().zoom(zoom);
    final double rotAngle = arc.getRotationAngle();
    IPoint pt;

    if(start)
      pt = arc.getStartPoint();
    else
      pt = arc.getEndPoint();

    // If the shape is rotated, the handler's position must fit the rotation angle.
    if(!LNumber.equalsDouble(rotAngle, 0.))
      pt = pt.rotatePoint(zoomedGC, rotAngle);

    point.setPoint(pt.zoom(zoom).getMiddlePoint(zoomedGC));
    super.update(arc, zoom);
  }
View Full Code Here

    final double rotationAngle = shape.getRotationAngle();
    final double startAngle    = shape.getAngleStart()%(2.*Math.PI);
    final double endAngle      = shape.getAngleEnd()%(2.*Math.PI);
    final ArcStyle type      = shape.getArcStyle();
        final SVGElement root    = new SVGGElement(doc);
        final IPoint start      = shape.getStartPoint();
        final IPoint end        = shape.getEndPoint();
        final double radius      = shape.getWidth()/2.0;
        final boolean largeArcFlag = Math.abs(startAngle-endAngle)>=Math.PI || startAngle>endAngle;
        final SVGPathSegList path  = new SVGPathSegList();
        SVGElement elt;

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

        path.add(new SVGPathSegMoveto(start.getX(), start.getY(), false));
        path.add(new SVGPathSegArc(end.getX(), end.getY(), radius, radius, 0, largeArcFlag, false, false));

        if(type==ArcStyle.CHORD)
          path.add(new SVGPathSegClosePath());
        else
          if(type==ArcStyle.WEDGE) {
            final IPoint gravityCenter = shape.getGravityCentre();
            path.add(new SVGPathSegLineto(gravityCenter.getX(), gravityCenter.getY(), false));
            path.add(new SVGPathSegClosePath());
          }

        if(shape.hasShadow())  {
          final SVGElement shad = new SVGPathElement(doc);
View Full Code Here


  @Override
  protected void update(final IGroup shape) {
    if(shape!=null) {
      final IPoint tl = shape.getTopLeftPoint();
      tlxS.setValueSafely(tl.getX());
      tlyS.setValueSafely(tl.getY());
    }
  }
View Full Code Here

    @Override
    public void updateAction() {
      super.updateAction();

      final IPoint tl = action.drawing().get().getSelection().getTopLeftPoint();
      final double value = Double.parseDouble(interaction.getSpinner().getValue().toString());

      if(interaction.getSpinner()==instrument.tlxS)
        action.setTx(value-tl.getX());
      else
        action.setTy(value-tl.getY());
    }
View Full Code Here

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

    final IPoint tl  = shape.getTopLeftPoint();
    final IPoint br  = shape.getBottomRightPoint();
    final IPoint gc = shape.getGravityCentre();
    final IPoint p1 = ShapeFactory.createPoint((tl.getX()+br.getX())/2., tl.getY());
    final IPoint p2 = ShapeFactory.createPoint(br.getX(), (tl.getY()+br.getY())/2.);
    final IPoint p3 = ShapeFactory.createPoint((tl.getX()+br.getX())/2., br.getY());
    final SVGElement root = new SVGGElement(doc);
    SVGElement elt;
      final double gap = getPositionGap()/2.;
      final double cornerGap1 = GLibUtilities.getCornerGap(gc, p1, p2, gap);
      double cornerGap2 = GLibUtilities.getCornerGap(gc, p2, p3, gap);

      if(p2.getX()<p3.getX())
        cornerGap2*=-1;

        final String points = String.valueOf(p1.getX()) + ',' + (p1.getY() - cornerGap1) + ' ' + (p2.getX() + cornerGap2) + ',' + p2.getY() + ' ' + p3.getX() + ',' + (p3.getY() + cornerGap1) + ' ' + (tl.getX() - cornerGap2) + ',' + p2.getY();

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

        if(shape.hasShadow()) {
View Full Code Here

  @Override
  public void setCentre(final IPoint centre) {
    if(!GLibUtilities.isValidPoint(centre))
      return ;

    final IPoint gc = getGravityCentre();

    translate(centre.getX()-gc.getX(), centre.getY()-gc.getY());
  }
View Full Code Here

    if(isVerticalLine())//FIXME must always create a perpendicular line + add test
      return LNumber.equalsDouble(pt.getX(), x1) ? ShapeFactory.createLine(pt.getY(), ShapeFactory.createPoint(pt)) : null;

    if(LNumber.equalsDouble(pt.getX(), 0.)) {
      final IPoint pt3  = ShapeFactory.createPoint(getPoint2());
      final IPoint pt2  = pt3.rotatePoint(pt, Math.PI/2.);

      return ShapeFactory.createLine(pt2, pt);
    }

    if(LNumber.equalsDouble(a, 0.))
View Full Code Here

  }


  @Override
  public IPoint getIntersectionSegment(final ILine l) {
    final IPoint p = getIntersection(l);

    if(p==null)
      return null;

    final double px  = p.getX();
    final double py  = p.getY();
    final IPoint tl  = getTopLeftPoint();
    final IPoint br  = getBottomRightPoint();
    final IPoint tl2 = l.getTopLeftPoint();
    final IPoint br2 = l.getBottomRightPoint();

    if(px>=tl.getX() && px<=br.getX() && py>=tl.getY() && py<=br.getY() &&
       px>=tl2.getX() && px<=br2.getX() && py>=tl2.getY() && py<=br2.getY())
      return p;

    return null;
  }
View Full Code Here

TOP

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

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.