当前位置: 首页>>代码示例>>Java>>正文


Java MutableTransformer.translate方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.MutableTransformer.translate方法的典型用法代码示例。如果您正苦于以下问题:Java MutableTransformer.translate方法的具体用法?Java MutableTransformer.translate怎么用?Java MutableTransformer.translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.visualization.transform.MutableTransformer的用法示例。


在下文中一共展示了MutableTransformer.translate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent e) {
	VisualizationViewer<?, ?> vv = (VisualizationViewer<?, ?>) e.getSource();

	if (down != null) {
		MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer()
				.getTransformer(Layer.LAYOUT);
		Point2D p1 = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
		Point2D p2 = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());

		modelTransformer.translate(p2.getX() - p1.getX(), p2.getY() - p1.getY());
		down = e.getPoint();
		vv.repaint();

		changed = true;
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:18,代码来源:BetterTranslatingGraphMousePlugin.java

示例2: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
   * chack the modifiers. If accepted, translate the graph according
   * to the dragging of the mouse pointer
   * @param e the event
*/
  public void mouseDragged(MouseEvent e) {
      VisualizationViewer<?,?> vv = (VisualizationViewer<?,?>)e.getSource();
      boolean accepted = checkModifiers(e);
      if(accepted) {
          MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
          vv.setCursor(cursor);
          try {
              Point2D q = viewTransformer.inverseTransform(down);
              Point2D p = viewTransformer.inverseTransform(e.getPoint());
              float dx = (float) (p.getX()-q.getX());
              float dy = (float) (p.getY()-q.getY());
              
              viewTransformer.translate(dx, dy);
              down.x = e.getX();
              down.y = e.getY();
          } catch(RuntimeException ex) {
              System.err.println("down = "+down+", e = "+e);
              throw ex;
          }
      
          e.consume();
      }
  }
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:29,代码来源:ViewTranslatingGraphMousePlugin.java

示例3: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
   * chack the modifiers. If accepted, translate the graph according
   * to the dragging of the mouse pointer
   * @param e the event
*/
  public void mouseDragged(MouseEvent e) {
      VisualizationViewer vv = (VisualizationViewer)e.getSource();
      boolean accepted = checkModifiers(e);
      if(accepted) {
          MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
          vv.setCursor(cursor);
          try {
              Point2D q = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
              Point2D p = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());
              float dx = (float) (p.getX()-q.getX());
              float dy = (float) (p.getY()-q.getY());
              
              modelTransformer.translate(dx, dy);
              down.x = e.getX();
              down.y = e.getY();
          } catch(RuntimeException ex) {
              System.err.println("down = "+down+", e = "+e);
              throw ex;
          }
      
          e.consume();
          vv.repaint();
      }
  }
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:30,代码来源:TranslatingGraphMousePlugin.java

示例4: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
   * chack the modifiers. If accepted, translate the graph according
   * to the dragging of the mouse pointer
   * @param e the event
*/
  public void mouseDragged(MouseEvent e) {
      VisualizationViewer vv = (VisualizationViewer)e.getSource();
      boolean accepted = checkModifiers(e);
      if(accepted) {
          MutableTransformer viewTransformer = vv.getViewTransformer();
          vv.setCursor(cursor);
          try {
              Point2D q = viewTransformer.inverseTransform(down);
              Point2D p = viewTransformer.inverseTransform(e.getPoint());
              float dx = (float) (p.getX()-q.getX());
              float dy = (float) (p.getY()-q.getY());
              
              viewTransformer.translate(dx, dy);
              down.x = e.getX();
              down.y = e.getY();
          } catch(RuntimeException ex) {
              System.err.println("down = "+down+", e = "+e);
              throw ex;
          }
      
          e.consume();
      }
  }
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:29,代码来源:ViewTranslatingGraphMousePlugin.java

示例5: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
   * chack the modifiers. If accepted, translate the graph according
   * to the dragging of the mouse pointer
   * @param e the event
*/
  public void mouseDragged(MouseEvent e) {
      VisualizationViewer vv = (VisualizationViewer)e.getSource();
      boolean accepted = checkModifiers(e);
      if(accepted) {
          MutableTransformer modelTransformer = vv.getLayoutTransformer();
          vv.setCursor(cursor);
          try {
              Point2D q = vv.inverseTransform(down);
              Point2D p = vv.inverseTransform(e.getPoint());
              float dx = (float) (p.getX()-q.getX());
              float dy = (float) (p.getY()-q.getY());
              
              modelTransformer.translate(dx, dy);
              down.x = e.getX();
              down.y = e.getY();
          } catch(RuntimeException ex) {
              System.err.println("down = "+down+", e = "+e);
              throw ex;
          }
      
          e.consume();
      }
  }
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:29,代码来源:TranslatingGraphMousePlugin.java

示例6: autoZoomViewer

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
public static void autoZoomViewer(VisualizationViewer<?, ?> vv,
		LayerViewer<?, ?> home, Directions direction) {
	if (vv == null || home == null)
		return;

	// reset transforms
	MutableTransformer layoutTrans = vv.getRenderContext()
			.getMultiLayerTransformer()
			.getTransformer(edu.uci.ics.jung.visualization.Layer.LAYOUT);
	layoutTrans.setToIdentity();
	MutableTransformer viewTrans = vv.getRenderContext()
			.getMultiLayerTransformer()
			.getTransformer(edu.uci.ics.jung.visualization.Layer.VIEW);
	viewTrans.setToIdentity();

	Dimension dim = vv.getSize();
	Rectangle2D.Double graphBounds = home.getGraphBoundsCache();

	CrossoverScalingControl scaler = new CrossoverScalingControl();

	// Scale using crossover scaler, so vertices will not grow
	// larger than they are in original
	double factor = Double.POSITIVE_INFINITY;

	if (direction == Directions.HORIZONTAL || direction == Directions.BOTH)
		factor = dim.getWidth() / graphBounds.width;
	if (direction == Directions.VERTICAL || direction == Directions.BOTH
			|| Double.isInfinite(factor))
		factor = Math.min(factor, dim.getHeight() / graphBounds.height);
	scaler.scale(vv, (float) factor, vv.getCenter());

	// Translate center of graph to center of vv.
	Point2D lvc = vv.getRenderContext().getMultiLayerTransformer()
			.inverseTransform(vv.getCenter());
	double dx = (lvc.getX() - graphBounds.getCenterX());
	double dy = (lvc.getY() - graphBounds.getCenterY());
	layoutTrans.translate(dx, dy);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:39,代码来源:LayerViewer.java

示例7: moveMapToStayWithCurrentRoom

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
 * This method refocuses current room into middle of map,
 * if current room is over away from center by 50% of distance to windowedge
 */
protected void moveMapToStayWithCurrentRoom() {

    Point2D currentRoomPoint = this.mapperLayout.transform( currentRoom );

    Point2D mapViewCenterPoint = this.panel.getMapperCentralPoint();
    Point2D viewPoint = vv.getRenderContext().getMultiLayerTransformer().transform( currentRoomPoint );
    if (needToRelocate( viewPoint, mapViewCenterPoint )) {
        MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer( Layer.LAYOUT );
        float dx = (float) ( mapViewCenterPoint.getX() - viewPoint.getX() );
        float dy = (float) ( mapViewCenterPoint.getY() - viewPoint.getY() );
        modelTransformer.translate( dx, dy );
        repaint();
    }
}
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:19,代码来源:MapperEngine.java

示例8: autoZoomViewer

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
public static void autoZoomViewer(VisualizationViewer<?, ?> vv,
                                  LayerViewer<?, ?> home, Directions direction) {
    if (vv == null || home == null)
        return;

    // reset transforms
    MutableTransformer layoutTrans = vv.getRenderContext()
            .getMultiLayerTransformer()
            .getTransformer(edu.uci.ics.jung.visualization.Layer.LAYOUT);
    layoutTrans.setToIdentity();
    MutableTransformer viewTrans = vv.getRenderContext()
            .getMultiLayerTransformer()
            .getTransformer(edu.uci.ics.jung.visualization.Layer.VIEW);
    viewTrans.setToIdentity();

    Dimension dim = vv.getSize();
    Rectangle2D.Double graphBounds = home.getGraphBoundsCache();

    CrossoverScalingControl scaler = new CrossoverScalingControl();

    // Scale using crossover scaler, so vertices will not grow
    // larger than they are in original
    double factor = Double.POSITIVE_INFINITY;

    if (direction == Directions.HORIZONTAL || direction == Directions.BOTH)
        factor = dim.getWidth() / graphBounds.width;
    if (direction == Directions.VERTICAL || direction == Directions.BOTH
            || Double.isInfinite(factor))
        factor = Math.min(factor, dim.getHeight() / graphBounds.height);
    scaler.scale(vv, (float) factor, vv.getCenter());

    // Translate center of graph to center of vv.
    Point2D lvc = vv.getRenderContext().getMultiLayerTransformer()
            .inverseTransform(vv.getCenter());
    double dx = (lvc.getX() - graphBounds.getCenterX());
    double dy = (lvc.getY() - graphBounds.getCenterY());
    layoutTrans.translate(dx, dy);
}
 
开发者ID:liruixpc11,项目名称:crucian,代码行数:39,代码来源:LayerViewer.java

示例9: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
 * chack the modifiers. If accepted, translate the main view according
 * to the dragging of the mouse pointer in the satellite view
 * @param e the event
 */
public void mouseDragged(MouseEvent e) {
    VisualizationViewer vv = (VisualizationViewer)e.getSource();
    boolean accepted = checkModifiers(e);
    if(accepted) {
        if(vv instanceof SatelliteVisualizationViewer) {
            VisualizationViewer vvMaster = 
                ((SatelliteVisualizationViewer)vv).getMaster();
            
            MutableTransformer modelTransformerMaster = 
            	vvMaster.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
            try {
                Point2D q = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
                Point2D p = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());
                float dx = (float) (p.getX()-q.getX());
                float dy = (float) (p.getY()-q.getY());
                
                modelTransformerMaster.translate(-dx, -dy);
                down.x = e.getX();
                down.y = e.getY();
            } catch(RuntimeException ex) {
                System.err.println("down = "+down+", e = "+e);
                throw ex;
            }
        }
        e.consume();
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:34,代码来源:SatelliteTranslatingGraphMousePlugin.java

示例10: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
 * chack the modifiers. If accepted, translate the main view according
 * to the dragging of the mouse pointer in the satellite view
 * @param e the event
 */
public void mouseDragged(MouseEvent e) {
    VisualizationViewer vv = (VisualizationViewer)e.getSource();
    boolean accepted = checkModifiers(e);
    if(accepted) {
        if(vv instanceof SatelliteVisualizationViewer) {
            VisualizationViewer vvMaster = 
                ((SatelliteVisualizationViewer)vv).getMaster();
            
            MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();
            vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
            try {
                Point2D q = vv.inverseTransform(down);
                Point2D p = vv.inverseTransform(e.getPoint());
                float dx = (float) (p.getX()-q.getX());
                float dy = (float) (p.getY()-q.getY());
                
                modelTransformerMaster.translate(-dx, -dy);
                down.x = e.getX();
                down.y = e.getY();
            } catch(RuntimeException ex) {
                System.err.println("down = "+down+", e = "+e);
                throw ex;
            }
        }
        e.consume();
    }
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:33,代码来源:SatelliteTranslatingGraphMousePlugin.java

示例11: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
@Override
public void mouseDragged(MouseEvent me){

	// --- Execute the normal (but corrected) super method ------
	this.mouseDraggedSuperAction(me);
	
	// ----------------------------------------------------------------------------------------
	// --- Action if the right mouse button is pressed and no graph element is selected -------
	// ----------------------------------------------------------------------------------------
	if (this.movePanelWithRightAction==true) {

		MutableTransformer modelTransformer = this.getVisViewer().getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
           try {
               Point2D q = this.getVisViewer().getRenderContext().getMultiLayerTransformer().inverseTransform(down);
               Point2D p = this.getVisViewer().getRenderContext().getMultiLayerTransformer().inverseTransform(me.getPoint());
               float dx = (float) (p.getX()-q.getX());
               float dy = (float) (p.getY()-q.getY());
               
               modelTransformer.translate(dx, dy);
               down.x = me.getX();
               down.y = me.getY();
           } catch(RuntimeException ex) {
               System.err.println("down = "+down+", e = "+me);
               throw ex;
           }
           me.consume();
	}
	
	// ----------------------------------------------------------------------------------------
	// --- Update the GraphNode's position attribute ------------------------------------------ 
	// ----------------------------------------------------------------------------------------
	if (this.moveNodeWithLeftAction==true) {
		
		Graph<GraphNode, GraphEdge> graph = null;
		boolean snapToGrid = this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter().getGeneralGraphSettings4MAS().isSnap2Grid();
		double snapRaster = this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter().getGeneralGraphSettings4MAS().getSnapRaster();
		
		Set<GraphNode> pickedNodes = this.getVisViewer().getPickedVertexState().getPicked();
		for(GraphNode pickedNode: pickedNodes){

			// --- Get the Graph, if not already there --------------------
			if (graph==null) {
				graph = this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter().getGraph();
				this.nodesMoved.removeAllElements();
				this.removeAllTemporaryNodes(graph);
			}
			
			// --- Get the position of the node ---------------------------
			Point2D newPos = this.getVisViewer().getGraphLayout().transform(pickedNode);
			if (snapToGrid==true && snapRaster>0) {
				double xPos = roundGridSnap(newPos.getX(), snapRaster); 
				double yPos = roundGridSnap(newPos.getY(), snapRaster);
				newPos.setLocation(xPos, yPos);
				
				this.nodesMoved.add(pickedNode);
				this.addTemporaryNode(graph, pickedNode, newPos);
			}
			pickedNode.setPosition(newPos);
			
		}
		me.consume();
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:65,代码来源:GraphEnvironmentMousePlugin.java

示例12: centerGraph

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
 * This method finds the location of the graph relative to the viewer and
 * shifts is so that it appears in the center of JUNG's VisualizationViewer.
 */
public static Point2D centerGraph(VisualizationViewer<Vertex, Edge> vv, BrowsableNetwork network, Layout<Vertex, Edge> layout,
		EditingModalGraphMouse<Vertex, Edge> mouse) {

	MutableTransformer layout2 = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
	double top = Double.MAX_VALUE;
	double bottom = Double.MAX_VALUE;
	double left = Double.MAX_VALUE;
	double right = Double.MAX_VALUE;

	for (Vertex v : network.getVertices()) {
		Point2D p;
		if (layout instanceof AbstractLayout)
			p = ((AbstractLayout<Vertex, Edge>) layout).transform(v);
		else
			p = ((TreeLayout<Vertex, Edge>) layout).transform(v);
		Point2D invP = layout2.transform(p);
		if (top < invP.getY() || top == Double.MAX_VALUE)
			top = invP.getY();
		if (bottom > invP.getY() || bottom == Double.MAX_VALUE)
			bottom = invP.getY();
		if (left > invP.getX() || left == Double.MAX_VALUE)
			left = invP.getX();
		if (right < invP.getX() || right == Double.MAX_VALUE)
			right = invP.getX();
	}
	if (mouse != null) {
		double scale = 0;
		do {
			scale = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).getScale();
			mouse.mouseWheelMoved(new MouseWheelEvent(vv, 0, 0, 0, vv.getWidth() / 2, vv.getHeight() / 2, 1, false, 1, -1, -1));
		} while (scale >= 1);
	}
	vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)
			.setScale(1, 1, new Point((int) (vv.getCenter().getX() - (right + left) / 2), (int) (vv.getCenter().getY() - (top + bottom) / 2)));

	double deltaX = vv.getCenter().getX() - (right + left) / 2;
	double deltaY = vv.getCenter().getY() - (top + bottom) / 2;
	if (!Double.isInfinite(deltaX) && !Double.isInfinite(deltaY) && !Double.isNaN(deltaX) && !Double.isNaN(deltaY)) {
		layout2.translate(deltaX, deltaY);
	}

	return vv.getCenter();
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:48,代码来源:NetworkPanel.java

示例13: moveCanvasTo

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
@Override
public void moveCanvasTo(Point2D destinationPoint)
{
    final MutableTransformer layoutTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
    layoutTransformer.translate(destinationPoint.getX(), destinationPoint.getY());
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:7,代码来源:JUNGCanvas.java

示例14: mouseDragged

import edu.uci.ics.jung.visualization.transform.MutableTransformer; //导入方法依赖的package包/类
/**
 * check the modifiers. If accepted, move or resize the lens according
 * to the dragging of the mouse pointer
 * @param e the event
 */
public void mouseDragged(MouseEvent e) {
    VisualizationViewer vv = (VisualizationViewer)e.getSource();
    MutableTransformer vt = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
    if(vt instanceof LensTransformer) {
    	vt = ((LensTransformer)vt).getDelegate();
    }
    Point2D p = vt.inverseTransform(e.getPoint());
    boolean accepted = checkModifiers(e);

    if(accepted ) {
        MutableTransformer modelTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
        vv.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
        if(dragOnLens) {
            setViewCenter(modelTransformer, p);
            setViewCenter(vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW), p);
            e.consume();
            vv.repaint();

        } else if(dragOnEdge) {

            setViewRadius(modelTransformer, p);
            setViewRadius(vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW), p);
            e.consume();
            vv.repaint();
            
        } else {
        	
        	MutableTransformer mt = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT);
            Point2D iq = vt.inverseTransform(down);
            iq = mt.inverseTransform(iq);
            Point2D ip = vt.inverseTransform(e.getPoint());
            ip = mt.inverseTransform(ip);
            float dx = (float) (ip.getX()-iq.getX());
            float dy = (float) (ip.getY()-iq.getY());
            
            modelTransformer.translate(dx, dy);
            down.x = e.getX();
            down.y = e.getY();
        }
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:47,代码来源:LensTranslatingGraphMousePlugin.java


注:本文中的edu.uci.ics.jung.visualization.transform.MutableTransformer.translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。