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

📄 transformedportrayal2d.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 JAVA
字号:
package sim.portrayal.simple;import sim.portrayal.*;import java.awt.*;import java.awt.geom.*;import sim.display.*;/**   A wrapper for other Portrayal2Ds which transforms the graphics space before drawing them. */public class TransformedPortrayal2D extends SimplePortrayal2D    {    public SimplePortrayal2D child;    public AffineTransform transform;    boolean orient;    public TransformedPortrayal2D(SimplePortrayal2D child, AffineTransform transform)        {        this.child = child; this.transform = transform;        }            public SimplePortrayal2D getChild(Object object)        {        if (child!=null) return child;        else            {            if (!(object instanceof SimplePortrayal2D))                throw new RuntimeException("Object provided to TransformedPortrayal2D is not a SimplePortrayal2D: " + object);            return (SimplePortrayal2D) object;            }        }        public void draw(Object object, Graphics2D graphics, DrawInfo2D info)        {        final double theta = ((Oriented2D)object).orientation2D();        transform.setToRotation(theta);                        AffineTransform old = graphics.getTransform();        AffineTransform translationTransform = new AffineTransform();        translationTransform.setToTranslation(info.draw.x,info.draw.y);        graphics.transform(translationTransform);        graphics.transform(transform);        getChild(object).draw(object,graphics,new DrawInfo2D(info,-info.draw.x,-info.draw.y));        // restore        graphics.setTransform(old);        }            public boolean hitObject(Object object, DrawInfo2D range)        {        /* To-do */        return false;        }    public boolean setSelected(LocationWrapper wrapper, boolean selected)        {        return getChild(wrapper.getObject()).setSelected(wrapper, selected);        }    public Inspector getInspector(LocationWrapper wrapper, GUIState state)        {        return getChild(wrapper.getObject()).getInspector(wrapper,state);        }        public String getName(LocationWrapper wrapper)        {        return getChild(wrapper.getObject()).getName(wrapper);        }    }            

⌨️ 快捷键说明

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