Revision 515
graphical fix
trunk/code/projects/colonet/client/Colonet.java | ||
---|---|---|
474 | 474 |
* @see ColonetServerInterface#sendXBeeIDRequest() |
475 | 475 |
*/ |
476 | 476 |
public void parseXBeeIDs (String line) { |
477 |
|
|
478 | 477 |
String [] str = line.split(" "); |
479 | 478 |
int num = Integer.parseInt(str[2]); |
480 | 479 |
xbeeID = new int[num]; |
... | ... | |
536 | 535 |
RobotIcon newIcon = new RobotIcon(id, x, y); |
537 | 536 |
newList.add(newIcon); |
538 | 537 |
} |
539 |
|
|
540 | 538 |
robotIcons = newList; |
541 | 539 |
repaint(); |
542 |
|
|
543 | 540 |
} |
544 | 541 |
|
545 | 542 |
|
... | ... | |
864 | 861 |
BufferedImage buffer; |
865 | 862 |
|
866 | 863 |
public WebcamPanel () { |
867 |
super(); |
|
864 |
super(false);
|
|
868 | 865 |
} |
869 | 866 |
|
870 | 867 |
public synchronized void setImage (BufferedImage newimg) { |
... | ... | |
915 | 912 |
|
916 | 913 |
|
917 | 914 |
// Draw Identifiers and battery levels |
918 |
if (robotIcons == null) |
|
919 |
return; |
|
920 |
|
|
921 |
bufferedGraphics.setStroke(new BasicStroke(2)); |
|
922 |
for (int i = 0; i < robotIcons.size(); i++) { |
|
923 |
RobotIcon r = robotIcons.get(i); |
|
924 |
bufferedGraphics.setColor(r.color); |
|
925 |
// Identifier circle |
|
926 |
int px = (int) (x + r.x * scale); |
|
927 |
int py = (int) (y + r.y * scale); |
|
928 |
bufferedGraphics.drawOval(px-RADIUS, py-RADIUS, 2*r.RADIUS, 2*r.RADIUS); |
|
929 |
// Battery |
|
930 |
//if (r.battery >= 0) { |
|
931 |
bufferedGraphics.setColor(Color.GREEN); |
|
932 |
bufferedGraphics.fillRect(px+20, py+20, 30, 10); |
|
933 |
bufferedGraphics.setColor(Color.BLACK); |
|
934 |
bufferedGraphics.drawRect(px+20, py+20, 50, 10); |
|
935 |
//} |
|
936 |
// If the robot has a destination, draw the vector |
|
937 |
if (r.destx >= 0) { |
|
938 |
bufferedGraphics.drawLine(px, py, (int)(x + r.destx * scale), (int)(y + r.desty * scale)); |
|
939 |
} |
|
915 |
if (robotIcons != null) { |
|
916 |
bufferedGraphics.setStroke(new BasicStroke(2)); |
|
917 |
for (int i = 0; i < robotIcons.size(); i++) { |
|
918 |
RobotIcon r = robotIcons.get(i); |
|
919 |
bufferedGraphics.setColor(r.color); |
|
920 |
// Identifier circle |
|
921 |
int px = (int) (x + r.x * scale); |
|
922 |
int py = (int) (y + r.y * scale); |
|
923 |
bufferedGraphics.drawOval(px-RADIUS, py-RADIUS, 2*r.RADIUS, 2*r.RADIUS); |
|
924 |
// Battery |
|
925 |
//if (r.battery >= 0) { |
|
926 |
bufferedGraphics.setColor(Color.GREEN); |
|
927 |
bufferedGraphics.fillRect(px+20, py+20, 30, 10); |
|
928 |
bufferedGraphics.setColor(Color.BLACK); |
|
929 |
bufferedGraphics.drawRect(px+20, py+20, 50, 10); |
|
930 |
//} |
|
931 |
// If the robot has a destination, draw the vector |
|
932 |
if (r.destx >= 0) { |
|
933 |
bufferedGraphics.drawLine(px, py, (int)(x + r.destx * scale), (int)(y + r.desty * scale)); |
|
934 |
} |
|
935 |
} |
|
940 | 936 |
} |
941 | 937 |
|
942 | 938 |
// Identify currently-selected robot |
943 |
if (selectedBot < 0)
|
|
944 |
return;
|
|
945 |
bufferedGraphics.setColor(Color.BLACK);
|
|
946 |
RobotIcon r = robotIcons.get(selectedBot);
|
|
947 |
int px = (int) (x + r.x * scale);
|
|
948 |
int py = (int) (y + r.y * scale);
|
|
949 |
bufferedGraphics.drawOval(px-RADIUS-6, py-RADIUS-6, 2*r.RADIUS+12, 2*r.RADIUS+12);
|
|
939 |
if (selectedBot >= 0) {
|
|
940 |
bufferedGraphics.setColor(Color.BLACK);
|
|
941 |
RobotIcon r = robotIcons.get(selectedBot);
|
|
942 |
int px = (int) (x + r.x * scale);
|
|
943 |
int py = (int) (y + r.y * scale);
|
|
944 |
bufferedGraphics.drawOval(px-RADIUS-6, py-RADIUS-6, 2*r.RADIUS+12, 2*r.RADIUS+12);
|
|
945 |
}
|
|
950 | 946 |
|
951 | 947 |
//Display buffered content |
952 |
g.drawImage(buffer, 0, 0, null); |
|
948 |
g.drawImage(buffer, 0, 0, this); |
|
949 |
txtMatrix.append("p"); |
|
953 | 950 |
} |
954 | 951 |
|
955 | 952 |
} |
Also available in: Unified diff