當前位置: 首頁>>代碼示例>>Java>>正文


Java Layout.setLocation方法代碼示例

本文整理匯總了Java中edu.uci.ics.jung.algorithms.layout.Layout.setLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Layout.setLocation方法的具體用法?Java Layout.setLocation怎麽用?Java Layout.setLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.uci.ics.jung.algorithms.layout.Layout的用法示例。


在下文中一共展示了Layout.setLocation方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: collapse

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void collapse(Layout layout, Forest tree, Object subRoot) throws InstantiationException, IllegalAccessException {
       
   	// get a sub tree from subRoot
   	Forest subTree = TreeUtils.getSubTree(tree, subRoot);
   	Object parent = null;
   	Object edge = null;
   	if(tree.getPredecessorCount(subRoot) > 0) {
   		parent = tree.getPredecessors(subRoot).iterator().next();
   		edge = tree.getInEdges(subRoot).iterator().next();
   	}	
   	tree.removeVertex(subRoot);
   	if(parent != null) {
   		tree.addEdge(edge, parent, subTree);
   	} else {
   		tree.addVertex(subTree);
   	}
   	
   	layout.setLocation(subTree, (Point2D)layout.transform(subRoot));
   }
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:21,代碼來源:TreeCollapser.java

示例2: mouseDraggedSuperAction

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * This is the MouseDragged super action of the super class (because of several exceptions).
 * @param me the MouseEvent
 */
private void mouseDraggedSuperAction(MouseEvent me) {

	if(locked == false) {
           VisualizationViewer<GraphNode,GraphEdge> vv = this.basicGraphGUI.getVisualizationViewer();
           if(vertex != null) {
               Point p = me.getPoint();
               Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
               Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
               Layout<GraphNode,GraphEdge> layout = vv.getGraphLayout();
               double dx = graphPoint.getX()-graphDown.getX();
               double dy = graphPoint.getY()-graphDown.getY();
               PickedState<GraphNode> ps = vv.getPickedVertexState();
               
               for(GraphNode v : ps.getPicked()) {
                   Point2D vp = layout.transform(v);
                   vp.setLocation(vp.getX()+dx, vp.getY()+dy);
                   layout.setLocation(v, vp);
               }
               down = p;
               me.consume();
               vv.repaint();
               
           } else {
               Point2D out = me.getPoint();
               if(me.getModifiers() == this.addToSelectionModifiers || me.getModifiers() == modifiers) {
                   if (down!=null) {
                   	rect.setFrameFromDiagonal(down,out);
                   	vv.repaint();
                   }
               }
           }
       }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:38,代碼來源:GraphEnvironmentMousePlugin.java

示例3: mouseDragged

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * If the mouse is over a picked vertex, drag all picked
 * vertices with the mouse.
 * If the mouse is not over a Vertex, draw the rectangle
 * to select multiple Vertices
 */
@SuppressWarnings("unchecked")
public void mouseDragged( MouseEvent e ) {
    if (locked == false) {
        VisualizationViewer<Room, Exit> vv = (VisualizationViewer) e.getSource();
        if (room != null) {
            Point p = e.getPoint();
            Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform( p );
            Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform( down );
            Layout<Room, Exit> layout = vv.getGraphLayout();
            double dx = graphPoint.getX() - graphDown.getX();
            double dy = graphPoint.getY() - graphDown.getY();
            PickedState<Room> ps = vv.getPickedVertexState();

            for (Room v : ps.getPicked()) {
                Point2D vp = layout.transform( v );
                vp.setLocation( vp.getX() + dx, vp.getY() + dy );
                layout.setLocation( v, vp );
            }
            down = p;

        } else {
            Point2D out = e.getPoint();
            if (e.getModifiers() == this.addToSelectionModifiers ||
                    e.getModifiers() == modifiers) {
                rect.setFrameFromDiagonal( down, out );
            }
        }
        if (room != null) e.consume();
        vv.repaint();
    }
}
 
開發者ID:lauriholmas,項目名稱:batmapper,代碼行數:38,代碼來源:MapperPickingGraphMousePlugin.java

示例4: mouseDragged

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
 * If the mouse is over a picked vertex, drag all picked vertices with the mouse. If the mouse
 * is not over a Vertex, draw the rectangle to select multiple Vertices
 *
 */
@Override
@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent e) {
	if (locked == false) {
		VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
		if (vertex != null) {
			Point p = e.getPoint();
			Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
			Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
			Layout<V, E> layout = vv.getGraphLayout();
			double dx = graphPoint.getX() - graphDown.getX();
			double dy = graphPoint.getY() - graphDown.getY();
			PickedState<V> ps = vv.getPickedVertexState();

			for (V v : ps.getPicked()) {
				Point2D vp = layout.transform(v);
				vp.setLocation(vp.getX() + dx, vp.getY() + dy);
				layout.setLocation(v, vp);
			}
			down = p;

		} else {
			if (rectangleSelectionEnabled) {
				Point2D out = e.getPoint();
				if (e.getModifiers() == this.addToSelectionModifiers || e.getModifiers() == modifiers) {
					rect.setFrameFromDiagonal(down, out);
				}
			}
		}
		if (vertex != null) {
			e.consume();
		}
		vv.repaint();
	}
}
 
開發者ID:rapidminer,項目名稱:rapidminer-studio,代碼行數:41,代碼來源:ExtendedPickingGraphMousePlugin.java

示例5: createMetaNode

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
public static LocationNode createMetaNode(String id, Collection<LocationNode> nodes, NodePropertySchema nodeSchema,
		String metaNodeProperty, Layout<LocationNode, Edge<LocationNode>> layout) {

	double x = nodes.stream().mapToDouble(n -> n.getCenter().getX()).average().getAsDouble();
	double y = nodes.stream().mapToDouble(n -> n.getCenter().getY()).average().getAsDouble();
	LocationNode newNode = new LocationNode(id,
			CanvasUtils.joinPropertiesOfNodes(nodes, nodeSchema, id, metaNodeProperty), new Point2D.Double(x, y));

	layout.setLocation(newNode, newNode.getCenter());

	return newNode;
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:13,代碼來源:LocationCanvasUtils.java

示例6: mouseDragged

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent e) {
	BetterVisualizationViewer<V, E> vv = (BetterVisualizationViewer<V, E>) e.getSource();
       
	if (vertex != null) {
		if (allowMovingNodes && down != null) {
			Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint());
			Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
			Point2D move = PointUtils.substractPoints(graphPoint, graphDown);
			Layout<V, E> layout = vv.getGraphLayout();
			
			PickedState<V> ps = vv.getPickedVertexState();

			for (V v : ps.getPicked()) {
				if(!layout.isLocked(v)) {
					layout.setLocation(v, PointUtils.addPoints(layout.transform(v), move));
					nodesMoved = true;
				}
			}

			if(nodesMoved) vv.repaint();
		}

		down = e.getPoint();
	} else if (edge != null) {
		down = e.getPoint();
	} else if (down != null) {
		rect.setFrameFromDiagonal(down, e.getPoint());
		vv.drawRect(rect);
	} else {
		down = e.getPoint();
	}
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:35,代碼來源:BetterPickingGraphMousePlugin.java

示例7: mouseDragged

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
* If the mouse is over a picked vertex, drag all picked
* vertices with the mouse.
* If the mouse is not over a Vertex, draw the rectangle
* to select multiple Vertices
* 
*/
  @SuppressWarnings("unchecked")
  public void mouseDragged(MouseEvent e) {
      if(locked == false) {
          VisualizationViewer<V,E> vv = (VisualizationViewer)e.getSource();
          if(vertex != null) {
              Point p = e.getPoint();
              Point2D graphPoint = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p);
              Point2D graphDown = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(down);
              Layout<V,E> layout = vv.getGraphLayout();
              double dx = graphPoint.getX()-graphDown.getX();
              double dy = graphPoint.getY()-graphDown.getY();
              PickedState<V> ps = vv.getPickedVertexState();
              
              for(V v : ps.getPicked()) {
                  Point2D vp = layout.transform(v);
                  vp.setLocation(vp.getX()+dx, vp.getY()+dy);
                  layout.setLocation(v, vp);
              }
              down = p;

          } else {
              Point2D out = e.getPoint();
              if(e.getModifiers() == this.addToSelectionModifiers ||
                      e.getModifiers() == modifiers) {
                  rect.setFrameFromDiagonal(down,out);
              }
          }
          if(vertex != null) e.consume();
          vv.repaint();
      }
  }
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:39,代碼來源:PickingGraphMousePlugin.java

示例8: mousePressed

import edu.uci.ics.jung.algorithms.layout.Layout; //導入方法依賴的package包/類
/**
    * If the mouse is pressed in an empty area, create a new vertex there.
    * If the mouse is pressed on an existing vertex, prepare to create
    * an edge from that vertex to another
    */
   @SuppressWarnings("unchecked")
public void mousePressed(MouseEvent e) {
       if(checkModifiers(e)) {
           final VisualizationViewer<V,E> vv =
               (VisualizationViewer<V,E>)e.getSource();
           final Point2D p = e.getPoint();
           GraphElementAccessor<V,E> pickSupport = vv.getPickSupport();
           if(pickSupport != null) {
           	Graph<V,E> graph = vv.getModel().getGraphLayout().getGraph();
           	// set default edge type
           	if(graph instanceof DirectedGraph) {
           		edgeIsDirected = EdgeType.DIRECTED;
           	} else {
           		edgeIsDirected = EdgeType.UNDIRECTED;
           	}
           	
               final V vertex = pickSupport.getVertex(vv.getModel().getGraphLayout(), p.getX(), p.getY());
               if(vertex != null) { // get ready to make an edge
                   startVertex = vertex;
                   down = e.getPoint();
                   transformEdgeShape(down, down);
                   vv.addPostRenderPaintable(edgePaintable);
                   if((e.getModifiers() & MouseEvent.SHIFT_MASK) != 0
                   		&& vv.getModel().getGraphLayout().getGraph() instanceof UndirectedGraph == false) {
                       edgeIsDirected = EdgeType.DIRECTED;
                   }
                   if(edgeIsDirected == EdgeType.DIRECTED) {
                       transformArrowShape(down, e.getPoint());
                       vv.addPostRenderPaintable(arrowPaintable);
                   }
               } else { // make a new vertex

                   V newVertex = vertexFactory.create();
                   Layout<V,E> layout = vv.getModel().getGraphLayout();
                   graph.addVertex(newVertex);
                   layout.setLocation(newVertex, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(e.getPoint()));
               }
           }
           vv.repaint();
       }
   }
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:47,代碼來源:EditingGraphMousePlugin.java


注:本文中的edu.uci.ics.jung.algorithms.layout.Layout.setLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。