sim.app.lsystem.Segment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mason Show documentation
Show all versions of mason Show documentation
MASON is a fast discrete-event multiagent simulation library core in Java, designed to be the foundation for large custom-purpose Java simulations, and also to provide more than enough functionality for many lightweight simulation needs. MASON contains both a model library and an optional suite of visualization tools in 2D and 3D.
The newest version!
/*
Copyright 2006 by Daniel Kuebrich
Licensed under the Academic Free License version 3.0
See the file "LICENSE" for more information
*/
// Class Segment
package sim.app.lsystem;
import java.awt.*;
import sim.portrayal.*;
import sim.util.*;
public class Segment extends SimplePortrayal2D
{
private static final long serialVersionUID = 1;
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
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy