當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。