Examples of IDrawing


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

  }


  @Test
  public void testConstructor() {
    IDrawing d = ShapeFactory.createDrawing();

    assertNotNull(d.getSelection());
    assertNotNull(d.getShapes());
  }
View Full Code Here

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

    View2DTK.setFactory(new LViewsFactory());
  }


  public T saveLoadShape(T sh) {
    IDrawing drawing = ShapeFactory.createDrawing();
    drawing.addShape(sh);
    SVGDocument doc = toSVG(drawing);
    return toLatexdraw(doc);
  }
View Full Code Here

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

  @Before
  @SuppressWarnings("unused")
  public void setUp() {
    View2DTK.setFactory(new LViewsFactory());
    IDrawing drawing = ShapeFactory.createDrawing();
    MLayeredPane layers = new MLayeredPane(false, false);
    canvas     = new LCanvas(drawing);
    LMagneticGrid grid = new LMagneticGrid(canvas);
    WidgetZoomer zoomer = new WidgetZoomer(canvas, true, true, null, "", null, "", true); //$NON-NLS-1$ //$NON-NLS-2$
    instrument   = new Pencil(canvas, new TextSetter(layers), layers);
View Full Code Here

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

  @Override
  public void update() {
    emptyCache();

    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);

      if(pstView!=null) {
        code = pstView.getCache();
View Full Code Here

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

   * The builder of the frame.
   * @since 3.0
   */
  private void buildFrame(final MProgressBar progressBar) {
    final LCanvas canvas   = getCanvas();
    final IDrawing drawing  = getDrawing();

    tabbedPanel = new MTabbedPane(true);

    layeredPanel = new MLayeredPane(false, false);
    layeredPanel.add(canvas.getScrollpane(), JLayeredPane.DEFAULT_LAYER);
    layeredPanel.addComponentsToResize(canvas.getScrollpane());

    if(progressBar!=null)
      progressBar.addToProgressBar(5);

    /* Creation of the rulers. */
    yScaleRuler = new YScaleRuler(canvas);
    xScaleRuler = new XScaleRuler(canvas, yScaleRuler);

    if(progressBar!=null)
      progressBar.addToProgressBar(5);

    /* Initialisation of the mapping between the model and the canvas. */
    MappingRegistry.REGISTRY.addMapping(new ShapeList2ViewListMapping(drawing.getShapes(), canvas.getViews(), canvas.getBorderInstrument()));
    MappingRegistry.REGISTRY.addMapping(new Drawing2CanvasMapping(drawing, canvas));
    MappingRegistry.REGISTRY.addMapping(new Selection2BorderMapping(drawing.getSelection().getShapes(), canvas.getBorderInstrument()));
    MappingRegistry.REGISTRY.addMapping(new Zoom2ScaleRuler(canvas.getZoomUnary(), xScaleRuler));
    MappingRegistry.REGISTRY.addMapping(new Zoom2ScaleRuler(canvas.getZoomUnary(), yScaleRuler));
    MappingRegistry.REGISTRY.addMapping(new Unit2ScaleRuler(ScaleRuler.getUnitSingleton(), xScaleRuler));
    MappingRegistry.REGISTRY.addMapping(new Unit2ScaleRuler(ScaleRuler.getUnitSingleton(), yScaleRuler));

    if(progressBar!=null)
      progressBar.addToProgressBar(5);

    // Initialisation of the status bar.
    statusBar = new JLabel("");//$NON-NLS-1$
//    statusBar.setEditable(false);

    /* Creation of the instruments. */
    instantiateInstruments(canvas, drawing);

    if(progressBar!=null)
      progressBar.addToProgressBar(15);

    textSetter.setPencil(pencil);
    MappingRegistry.REGISTRY.addMapping(new ShapeList2ExporterMapping(drawing.getShapes(), exporter));
    MappingRegistry.REGISTRY.addMapping(new Selection2MetaCustumiserMapping(drawing.getSelection().getShapes(), metaShapeCustomiser));
    MappingRegistry.REGISTRY.addMapping(new Selection2DeleterMapping(drawing.getSelection().getShapes(), deleter));
    MappingRegistry.REGISTRY.addMapping(new Selection2TemplateManager(drawing.getSelection().getShapes(), templateManager));

    if(progressBar!=null)
      progressBar.addToProgressBar(5);

    try{setIconImage(LResources.LATEXDRAW_ICON.getImage());}catch(final Exception ex){BadaboomCollector.INSTANCE.add(ex);}
View Full Code Here

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

  }


  @Override
  public void initialisePresentations() {
    final IDrawing drawing  = ShapeFactory.createDrawing();
    final LCanvas canvas  = new LCanvas(drawing);
    presentations.add(new Presentation<>(drawing, canvas));
    presentations.add(new Presentation<>(drawing, new LCodePanel(drawing, canvas)));
  }
View Full Code Here

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

    @Override
    protected Boolean doInBackground() throws Exception {
      super.doInBackground();
      try{
        final SVGDocument svgDoc = new SVGDocument(new File(path).toURI());
        final IDrawing pres = ui.getPresentation(IDrawing.class, LCanvas.class).getAbstractPresentation();
        // Adding loaded shapes.
        pres.addShape(toLatexdraw(svgDoc, 0));
        // Updating the possible widgets of the instruments.
        for(final Instrument instrument : ui.getInstruments())
          instrument.interimFeedback();
        ui.updatePresentations();
        return true;
View Full Code Here

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

    @Override
    protected Boolean doInBackground() throws Exception {
      super.doInBackground();

      setProgress(0);
      final IDrawing drawing = ui.getPresentation(IDrawing.class, LCanvas.class).getAbstractPresentation();
      // Creation of the SVG document.
      final Instrument[] instruments   = ui.getInstruments();
      final double incr        = 100./(drawing.size() + instruments.length + ui.getPresentations().size());
      final SVGDocument doc       = toSVG(drawing, incr);
      final SVGMetadataElement meta  = new SVGMetadataElement(doc);
      final SVGSVGElement root     = doc.getFirstChild();
      final SVGElement metaLTD    = (SVGElement)doc.createElement(LNamespace.LATEXDRAW_NAMESPACE+':'+SVGElements.SVG_METADATA);
View Full Code Here

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

      try{
        final SVGDocument svgDoc     = new SVGDocument(new File(path).toURI());
        final Element meta          = svgDoc.getDocumentElement().getMeta();
        final Instrument[] instruments   = ui.getInstruments();
        final IDrawing drawing = ui.getPresentation(IDrawing.class, LCanvas.class).getAbstractPresentation();
        final Element ldMeta;
        final double incrProgressBar;

        if(meta==null)
          ldMeta = null;
        else {
          final NodeList nl  = meta.getElementsByTagNameNS(LNamespace.LATEXDRAW_NAMESPACE_URI, SVGElements.SVG_METADATA);
          final Node node    = nl.getLength()==0 ? null : nl.item(0);
          ldMeta         = node instanceof Element ? (Element)node : null;
        }

              setProgress(0);

        // Adding loaded shapes.
        incrProgressBar       = Math.max(50./(svgDoc.getDocumentElement().getChildNodes().getLength()+ui.getPresentations().size()), 1.);
        final IShape shape     = toLatexdraw(svgDoc, incrProgressBar);

        if(shape instanceof IGroup) { // If several shapes have been loaded
          final IGroup group = (IGroup)shape;
          final double incr  = Math.max(50./group.size(), 1.);

          for(final IShape sh : group.getShapes()) {
            drawing.addShape(sh);
            setProgress((int)Math.min(100., getProgress()+incr));
          }
        } else { // If only a single shape has been loaded.
          drawing.addShape(shape);
          setProgress(Math.min(100, getProgress()+50));
        }

        // Loads the presentation's data.
        for(final Presentation<?,?> presentation : ui.getPresentations()) {
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.