Examples of IViewShape


Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

    final Graphics2D2SVG graphics = new Graphics2D2SVG(doc);
        final SVGElement root;
        final boolean viewCreated;
        // Instead of creating a view, its is gathered from the Java view of the application.
    IViewShape view = MappingRegistry.REGISTRY.getTargetFromSource(shape, IViewDot.class);

    if(view==null) {
      view =  View2DTK.getFactory().createView(shape);
      viewCreated = true;
    }
    else viewCreated = false;

        view.paint(graphics, null);
        root = graphics.getElement();

        root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_DOT);
        root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_SIZE, String.valueOf(shape.getDiametre()));
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_DOT_SHAPE, shape.getDotStyle().getPSTToken());
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_POSITION, shape.getPosition().getX() + " " + shape.getPosition().getY()); //$NON-NLS-1$

    graphics.dispose();

    if(viewCreated)
      view.flush();

    return root;
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

  }


  @Override
  public void paintViews(final Graphics2D g, final boolean withZoom, final boolean withGrid) {
    final IViewShape temp   = getTempView();
    final double zoomValue   = getZoom();
    final boolean mustZoom   = withZoom && !LNumber.equalsDouble(zoomValue, 1.);

    g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, alphaInterpolValue);
    g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,      colorRenderingValue);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,      antiAliasingValue);
    g.setRenderingHint(RenderingHints.KEY_RENDERING,        renderingValue);

    // Displaying the magnetic grid.
    if(withGrid && magneticGrid.isGridDisplayed())
        magneticGrid.paint(g);

    g.translate(ORIGIN.getX(), ORIGIN.getY());

    if(mustZoom)
      g.scale(zoomValue, zoomValue);

    page.paint(g, ShapeFactory.createPoint());

    // Getting the clip must be done here to consider the scaling and translation.
    final Rectangle clip = g.getClipBounds();

    synchronized(views){
      for(final IViewShape view : views)
          view.paint(g, clip);
    }

      if(temp!=null)
        temp.paint(g, clip);

      if(userSelectionBorder!=null) {
        g.setStroke(STROKE_USER_SELECTION_BORDER);
        g.setColor(Color.GRAY);
        g.draw(userSelectionBorder);
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

  }


  @Override
  public void updateBorder() {
    final IViewShape temp = getTempView();

    if(views.isEmpty() && temp==null)
      border.setFrame(0., 0., 0., 0.);
    else {
      double minX = Double.MAX_VALUE;
      double minY = Double.MAX_VALUE;
      double maxX = Double.MIN_VALUE;
      double maxY = Double.MIN_VALUE;

      Rectangle2D bounds;
      synchronized(views){
        for(final IViewShape view : views) {
          bounds = view.getBorder();

          if(bounds.getMinX()<minX)
            minX = bounds.getMinX();

          if(bounds.getMinY()<minY)
            minY = bounds.getMinY();

          if(bounds.getMaxX()>maxX)
            maxX = bounds.getMaxX();

          if(bounds.getMaxY()>maxY)
            maxY = bounds.getMaxY();
        }
      }

      if(temp!=null) {
        bounds = temp.getBorder();

        if(bounds.getMinX()<minX)
          minX = bounds.getMinX();

        if(bounds.getMinY()<minY)
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

    if(!GLibUtilities.isValidPoint(x, y))
      return null;

    final double x2 = x/getZoom();
    final double y2 = y/getZoom();
    IViewShape view = null;
    synchronized(views){
      int i=views.size()-1;

      while(i>=0 && view==null)
        if(views.get(i).contains(x2, y2))
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

  }


  @Override
  public void onObjectAdded(final Object list, final Object object, final int index) {
    final IViewShape view = MappingRegistry.REGISTRY.getTargetFromSource(object, IViewShape.class);

    if(view!=null) {
      updateActivation(list);
      border.add(view);
    }
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

    }
  }

  @Override
  public void onObjectRemoved(final Object list, final Object object, final int index) {
    final IViewShape view = MappingRegistry.REGISTRY.getTargetFromSource(object, IViewShape.class);

    if(view!=null) {
      border.remove(view);
      updateActivation(list);
    }
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

  @Override
  public void onObjectAdded(final Object list, final Object object, final int index) {
    super.onObjectAdded(list, object, index);

    if(object instanceof IShape) {
      final IViewShape view = index==-1 ? target.get(target.size()-1) : target.get(index);
      MappingRegistry.REGISTRY.addMapping(new Shape2ViewMapping((IShape)object, view));

      // If the shape is a text, a special mapping must be added.
      if(view instanceof IViewText)
        MappingRegistry.REGISTRY.addMapping(new Package2TextViewMapping(LaTeXGenerator.getPackagesUnary(), (IViewText)view));
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape



  @Override
  public void onObjectRemoved(final Object list, final Object object, final int index) {
    final IViewShape view = index==-1 ? target.get(target.size()-1) : target.get(index);

    view.flush();
    super.onObjectRemoved(list, object, index);
    border.remove(view);
    MappingRegistry.REGISTRY.removeMappingsUsingSource(object, Shape2ViewMapping.class);

    // If the shape is a text, the special mapping previously added must be removed.
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape


  public void testCreateGroupView() {
    IGroup gp = ShapeFactory.createGroup();
    gp.addShape(ShapeFactory.createText());
    IViewShape view = viewFac.createView(gp);
    assertNotNull(view);
    assertTrue(view.getClass().getName().toLowerCase().contains("group")); //$NON-NLS-1$
  }
View Full Code Here

Examples of net.sf.latexdraw.glib.views.Java2D.interfaces.IViewShape

    assertTrue(view.getClass().getName().toLowerCase().contains("group")); //$NON-NLS-1$
  }


  public void testCreateTextView() {
    IViewShape view = viewFac.createView(ShapeFactory.createText());
    assertNotNull(view);
    assertTrue(view.getClass().getName().toLowerCase().contains("text")); //$NON-NLS-1$
  }
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.