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

📄 exactlayoutmanager.java

📁 无限传感器网络的模拟结果的图形查看环境
💻 JAVA
字号:
package animation.layout;import java.util.Dictionary;import java.util.Enumeration;import java.awt.Dimension;import animation.Node;public class ExactLayoutManager extends GraphLayoutManager{    double maxX, maxY;        /**       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 ExactLayoutManager(Dictionary nodes,java.util.Vector links,			       Dimension screensize) {      super(nodes,links,screensize);      maxX = maxY = 0;    }     public void setMaxXMaxY() {        for (Enumeration e=m_nodes.elements();e.hasMoreElements();) {        	Node n=(Node)e.nextElement();        	if(n.getX()>maxX){        	    maxX = n.getX();        	}        	if(n.getY()>maxY){        	    maxY = n.getY();        	}        }        maxX += 5;        maxY += 5;    }        /**       doLayout in this class just goes through all the nodes and places       them at their position,        @param iterations randomlayout will ignore this parameter    */    public void doLayout(int iterations) {        setMaxXMaxY();                for (Enumeration e=m_nodes.elements();e.hasMoreElements();) {        	Node n=(Node)e.nextElement();                	n.setX(n.getX() * m_screen.width/maxX);        	n.setY(n.getY() * m_screen.height/maxY);        }    }}

⌨️ 快捷键说明

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