⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 randomlayoutmanager.java

📁 无限传感器网络的模拟结果的图形查看环境
💻 JAVA
字号:
package animation.layout;import animation.layout.GraphLayoutManager;import java.util.Dictionary;import java.util.Enumeration;import java.awt.Dimension;import animation.Node;/**   RandomLayoutManager provides and implementation of GraphLayoutManager that   merely places nodes at random positions.   This is primarily intended for testing.*/public class RandomLayoutManager extends GraphLayoutManager{    /**       The constructor simply takes the nodes and links as parameters.       @param nodes a dictionary of all nodes, indexed by node address       @param links a vector of links    */    public RandomLayoutManager(Dictionary nodes,java.util.Vector links,			       Dimension screensize) {      super(nodes,links,screensize);    }     /**       doLayout in this class just goes through all the nodes and gives them       random positions.       @param iterations randomlayout will ignore this parameter    */    public void doLayout(int iterations) {      for (Enumeration e=m_nodes.elements();e.hasMoreElements();) {	Node n=(Node)e.nextElement();	n.setX(Math.random()*m_screen.width);	n.setY(Math.random()*m_screen.height);      }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -