本文整理汇总了Java中sim.portrayal.network.EdgeDrawInfo2D类的典型用法代码示例。如果您正苦于以下问题:Java EdgeDrawInfo2D类的具体用法?Java EdgeDrawInfo2D怎么用?Java EdgeDrawInfo2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EdgeDrawInfo2D类属于sim.portrayal.network包,在下文中一共展示了EdgeDrawInfo2D类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawSimpleLinkWithLabel
import sim.portrayal.network.EdgeDrawInfo2D; //导入依赖的package包/类
/**
* @param link
* @param object
* @param graphics
* @param info
*/
public void drawSimpleLinkWithLabel(Link link, Object object, Graphics2D graphics, DrawInfo2D info) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
final int midX = (int) (ei.draw.x + ei.secondPoint.x) / 2;
final int midY = (int) (ei.draw.y + ei.secondPoint.y) / 2;
graphics.setColor(Color.black);
// HashMap<String, Boolean> status = link.getStatus();
// if (status.get(MyLink.OK_STATUS)) {
// graphics.setColor(Color.green);
// } else if (status.get(MyLink.BROKEN_STATUS)) {
// graphics.setColor(Color.red);
// }
graphics.drawLine(startX, startY, endX, endY);
graphics.setColor(Color.blue);
graphics.setFont(labelFont);
int width = graphics.getFontMetrics().stringWidth(link.getID());
graphics.drawString(link.getID(), midX - width / 2, midY);
}
示例2: draw
import sim.portrayal.network.EdgeDrawInfo2D; //导入依赖的package包/类
@Override
public void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
graphics.setColor(new Color(0, 200, 255));//Color light blue - near cian
graphics.drawLine(startX, startY, endX, endY);
// Draw the ID in the center of the link.
// Edge e = (Edge) object;
// Connection connection = (Connection) e.getInfo();
// graphics.setColor(Color.blue);
// graphics.setFont(labelFont);
// int width =
// graphics.getFontMetrics().stringWidth("L"+connection.getId());
// final int midX = (int) (ei.draw.x + ei.secondPoint.x) / 2;
// final int midY = (int) (ei.draw.y + ei.secondPoint.y) / 2;
// graphics.drawString("L"+connection.getId(), midX - width / 2, midY);
}
示例3: draw
import sim.portrayal.network.EdgeDrawInfo2D; //导入依赖的package包/类
@Override
public void draw(Object object, Graphics2D graphics, DrawInfo2D info) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
Edge e = (Edge) object;
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
final int midX = (int) (ei.draw.x + ei.secondPoint.x) / 2;
final int midY = (int) (ei.draw.y + ei.secondPoint.y) / 2;
graphics.setColor(Color.yellow);
graphics.drawLine(startX, startY, endX, endY);
Link link = (Link) e.getInfo();
graphics.setColor(Color.blue);
graphics.setFont(labelFont);
int width = graphics.getFontMetrics().stringWidth(link.getID());
graphics.drawString( link.getID(), midX - width / 2, midY );
}
示例4: drawSimpleLink
import sim.portrayal.network.EdgeDrawInfo2D; //导入依赖的package包/类
/**
* @param link
* @param object
* @param graphics
* @param info
*/
private void drawSimpleLink(Link link, Object object, Graphics2D graphics,
DrawInfo2D info) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
final int midX = (int) (ei.draw.x + ei.secondPoint.x) / 2;
final int midY = (int) (ei.draw.y + ei.secondPoint.y) / 2;
graphics.setColor(Color.black);
HashMap<String, Boolean> status = link.getStatus();
if (status.get(MyLink.OK_STATUS)) {
graphics.setColor(Color.green);
} else if (status.get(MyLink.BROKEN_STATUS)) {
graphics.setColor(Color.red);
}
graphics.drawLine(startX, startY, endX, endY);
graphics.setColor(Color.blue);
graphics.setFont(labelFont);
int width = graphics.getFontMetrics().stringWidth(link.getID());
graphics.drawString(link.getID(), midX - width / 2, midY);
}
示例5: drawSimpleLink
import sim.portrayal.network.EdgeDrawInfo2D; //导入依赖的package包/类
public void drawSimpleLink(Link link, Object object, Graphics2D graphics, DrawInfo2D info, Color color) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
graphics.setColor(color);
graphics.drawLine(startX, startY, endX, endY);
}
示例6: drawComplexLink
import sim.portrayal.network.EdgeDrawInfo2D; //导入依赖的package包/类
/**
* @param link
* @param object
* @param graphics
* @param info
*/
private void drawComplexLink(Link link, Object object, Graphics2D graphics,
DrawInfo2D info) {
EdgeDrawInfo2D ei = (EdgeDrawInfo2D) info;
final double width = 20;
final double height = 20;
HashMap<String, Boolean> status = link.getStatus();
graphics.setColor(Color.black);
if (status.get(MyLink.OK_STATUS)) {
graphics.setColor(Color.green);
} else if (status.get(MyLink.BROKEN_STATUS)) {
graphics.setColor(Color.red);
}
final int startX = (int) ei.draw.x;
final int startY = (int) ei.draw.y;
final int endX = (int) ei.secondPoint.x;
final int endY = (int) ei.secondPoint.y;
final int midX = (int) (ei.draw.x + ei.secondPoint.x) / 2;
final int midY = (int) (ei.draw.y + ei.secondPoint.y) / 2;
final int w = (int) (width);
final int h = (int) (height);
graphics.drawLine(startX, startY, endX, endY);
graphics.fillRect(midX-(int)(width/2), midY-(int)(height/2), w, h);
// Draw the devices ID ID
graphics.setColor(Color.black);
graphics.drawString(link.getID(), midX - 5, midY);
}