segment.java

来自「MASON代表多主体邻里或网络仿真(Multi-Agent Simulator 」· Java 代码 · 共 33 行

JAVA
33
字号
// Class Segmentpackage sim.app.lsystem;import java.awt.*;import sim.portrayal.*;import sim.util.*;public /*strictfp*/ class Segment extends SimplePortrayal2D    {    public double x,y,x2,y2;        public Segment(double x, double y, double dist, double theta)        {        this.x = x;        this.y = y;        this.x2 = /*Strict*/Math.cos(theta)*dist;        this.y2 = /*Strict*/Math.sin(theta)*dist;        }        public void draw(Object object,  final Graphics2D g, final DrawInfo2D info )        {        g.setColor(new Color(0,127,0));        g.drawLine((int)info.draw.x,                   (int)info.draw.y,                   (int)(info.draw.x) + (int)(info.draw.width*x2),                   (int)(info.draw.y) + (int)(info.draw.height*y2));        }    public void hitObjects(DrawInfo2D range, Bag putInHere)        {        // don't want to have any inspectors        }    }

⌨️ 快捷键说明

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