當前位置: 首頁>>代碼示例>>Java>>正文


Java EdgeDrawInfo2D類代碼示例

本文整理匯總了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);
}
 
開發者ID:gsi-upm,項目名稱:shanks-wsn-module,代碼行數:31,代碼來源:WirelessLink2DPortrayal.java

示例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);

}
 
開發者ID:gsi-upm,項目名稱:TwitterSimulator,代碼行數:25,代碼來源:LinkPortrayal2D.java

示例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 );

}
 
開發者ID:gsi-upm,項目名稱:Shanks,代碼行數:23,代碼來源:Link2DPortrayal.java

示例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);
}
 
開發者ID:gsi-upm,項目名稱:Shanks,代碼行數:32,代碼來源:MyLink2DPortrayal.java

示例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);
}
 
開發者ID:gsi-upm,項目名稱:shanks-wsn-module,代碼行數:11,代碼來源:WirelessLink2DPortrayal.java

示例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);
}
 
開發者ID:gsi-upm,項目名稱:Shanks,代碼行數:39,代碼來源:MyLink2DPortrayal.java


注:本文中的sim.portrayal.network.EdgeDrawInfo2D類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。