c't Projekte - c't-Bot und c't-Sim -
Mailinglisten
[Voriger (Datum)]
[Nächster (Datum)]
[Voriger (Thread)]
[Nächster (Thread)]
[Nach Datum][Nach Thread]
Absender: Andreas Kielkopf
Datum: Sa, 29.07.2006 17:32:47
Hallo zusammen.
Bei meinen versuchen habe ich eine Anzeige vermisst, die mich wissen
läßt, was der Bot gerade denkt. Natürlich kann ich das in LOG-Meldungen
erfahren, aber ich fand das nicht sehr übersichtlich.
Insbesondere, wenn es um Sensordaten geht, verliert man schnell den
Überblick. Auch hätte ich gerne angezeigt bekommen, wo der Bot denkt,
daß er ist, oder wo er denkt, daß eine Wand, oder ein Loch ist.
Also habe ich ein ablösbares Fenster in den Sim integriert, das mir
anhand der LOG-Meldungen vom Bot Linien und Punkte in eine farbige
Landkarte einzeichnet. Das Fenster ist so implementiert, daß es
primitive Grafikbefehle vom Bot annimmt, und permanent zeichnet (4*pro
Sekunde). Nach 2000 Grafikbefehlen werden die ältesten Objekte gelöscht,
so daß die Grafik nur aktuelle Daten anzeigt. Dieser Wert kann von jedem
seinen Bedürfnissen angepasst werden.
Die Skalierung für die Koordinaten werden von Zeit zu Zeit (alle 100
Linien) neu berechnet, so daß man sich keine Gedanken wegen der
Wertebereiche der gesendeten Daten zu machen braucht.
Anwendungsmöglichkeiten:
Sensordaten analysieren
Den Weg des Bot darstellen (oder zumindest das was er meint
gefahren zu sein)
beim Drehen die Sensordaten über den Winkel abbilden
Die vermuteten Wände einzeichnen
Den nächsten Zielpunkt einzeichnen
...
Den eigentliche Zeichenvorgang löst der Bot durch eine LOG-Meldung aus,
die den Text "Punkt" oder "Linie" und die notwendige Anzahl an
Koordinaten enthält.
LOG_INFO(("Linie %03d %03d %03d %03d red",x1,y1,x2,y2));
LOG_INFO(("Linie %03d %03d green",x1,y1));
Die Werte können byte, int, float oder double sein. Sie werden als
Double behandelt und zwischengespeichert. Ein Punkt braucht 2 Werte,
eine Linie braucht 4 Werte. Optional kann eine Farbe zur Darstellung
angegeben werden.
Ein Beispiel:
In der Datei sensor.c wird folgende Zeile direkt hinter
void sensor_abstand(uint16 left, uint16 right){
eingefügt:
LOG_INFO(("Linie %03d %03d %03d %03d red",left
+right-2,-(left-right-2),left+right+2,-(left-right+2)));
Nach starten des Simulators und des Bots sollte die BotMap angeklickt
werden, und dann mit dem links sichtbaren Griff aus dem kleinen Fenster
herrausgezogen werden, in dem die BotMap angezeigt wird. Sie können
diese dann frei auf dem Bildschirm platzieren. (zurück gehts über den
close-Knopf)
Daraufhin erscheinen im Fenster textuellen BotMap regelmäßig die hierzu
passenden LOG-Meldungen, und im grafischen BotMap werden Linien
entsprechend den Sensorwerten angezeigt.
Nach ca. 100 Linien skaliert das Fenster neu auf die angezeigten Linien,
so daß diese möglichst groß dargestellt werden können, gleichzeitig aber
auch nichts ausserhalb des Fensters verloren geht.
Nach ca. 2000 Linien beginnen die alten Linien zu verschwinden. Das hält
das ganze Bild übersichtlich.
Ich hoffe, anderen gefällt es ebenso wie mir, die BotMap zu beobachten
während der Bot fährt.
--
Andreas Kielkopf <a.kielkopf@xxxxxxxxxxxxxxxxx>
Index: Changelog.txt
===================================================================
RCS file: /ctbot/ct-Sim/Changelog.txt,v
retrieving revision 1.24.2.4
diff -u -r1.24.2.4 Changelog.txt
--- Changelog.txt 24 Jul 2006 10:38:45 -0000 1.24.2.4
+++ Changelog.txt 29 Jul 2006 16:05:22 -0000
@@ -1,5 +1,6 @@
Changelog fuer c't-Sim
======================
+2006-07-29 Andreas Kielkopf [andreas.kielkopf@xxxxxxxxxxxxxxxxx] BotMap hinzugef??gt. Grafische Anzeige von Logmeldungen aus dem c`t-Bot (Landkarte, Sensorwerte, Kennlinien ...)
2006-07-24 Peter Koenig [pek@xxxxxxxx]: Text der GPL eingefuegt
Index: ctSim/view/actuators/LogScreenGUI.java
===================================================================
RCS file: /ctbot/ct-Sim/ctSim/view/actuators/LogScreenGUI.java,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 LogScreenGUI.java
--- ctSim/view/actuators/LogScreenGUI.java 15 Jul 2006 00:01:01 -0000 1.3.2.1
+++ ctSim/view/actuators/LogScreenGUI.java 29 Jul 2006 16:05:22 -0000
@@ -22,17 +22,20 @@
import java.util.List;
import java.util.Set;
+import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
+import ctSim.model.bots.components.actuators.BotMap;
import ctSim.model.bots.components.actuators.LogScreen;
/**
* Klasse fuer grafische Anzeige von LogScreens
* @author Felix Beckwermert
+ * @author Andreas Kielkopf
*/
public class LogScreenGUI extends ActuatorGroupGUI<LogScreen> {
@@ -62,9 +65,14 @@
while(it.hasNext()) {
LogScreen log = it.next();
-
+
// Groesse?? Unterscheiden zw. LogScreen u. Disp.???
- JTextArea lcd = new JTextArea(4, 20);
+ JTextArea lcd;
+ if (log instanceof BotMap) {
+ lcd = new BotMapView((BotMap)log);
+ }else{
+ lcd = new JTextArea(9, 20);
+ }
lcd.setBorder(new EtchedBorder());
lcd.setEditable(false);
if(log.getFont()!=null)
@@ -79,7 +87,7 @@
//scroll.setMinimumSize(lcd.getPreferredSize());
scroll.setMinimumSize(lcd.getPreferredScrollableViewportSize());
- this.lcds.add(lcd);
+ this.lcds.add(lcd);
}
this.add(tab);
Index: ctSim/model/bots/ctbot/CtBotSimTcp.java
===================================================================
RCS file: /ctbot/ct-Sim/ctSim/model/bots/ctbot/CtBotSimTcp.java,v
retrieving revision 1.3.2.3
diff -u -r1.3.2.3 CtBotSimTcp.java
--- ctSim/model/bots/ctbot/CtBotSimTcp.java 18 Jul 2006 10:05:48 -0000 1.3.2.3
+++ ctSim/model/bots/ctbot/CtBotSimTcp.java 29 Jul 2006 16:05:22 -0000
@@ -39,6 +39,7 @@
import ctSim.model.bots.components.Actuator;
import ctSim.model.bots.components.Characteristic;
import ctSim.model.bots.components.Sensor;
+import ctSim.model.bots.components.actuators.BotMap;
import ctSim.model.bots.components.actuators.Display;
import ctSim.model.bots.components.actuators.Indicator;
import ctSim.model.bots.components.actuators.LogScreen;
@@ -53,6 +54,8 @@
/**
* Klasse aller simulierten c't-Bots, die ueber TCP mit dem Simulator kommunizieren
*
+ * @author ???
+ * @author Andreas Kielkopf
*/
public class CtBotSimTcp extends CtBotSim implements TcpBot {
@@ -126,7 +129,7 @@
private Sensor irL, irR, lineL, lineR, borderL, borderR, lightL, lightR, encL, encR;
- private Actuator govL, govR, log, disp;
+ private Actuator govL, govR, log, disp, map;
/**
* Der Konstruktor
@@ -279,12 +282,14 @@
this.disp = new Display("Display", new Point3d(), new Vector3d()); //$NON-NLS-1$
this.log = new LogScreen("LogScreen", new Point3d(), new Vector3d()); //$NON-NLS-1$
+ this.map = new BotMap("Map", new Point3d(), new Vector3d());
this.addActuator(this.govL);
this.addActuator(this.govR);
this.addActuator(this.disp);
this.addActuator(this.log);
+ this.addActuator(this.map);
}
/**
@@ -758,8 +763,10 @@
break;
case Command.CMD_LOG:
this.setLog(command.getDataBytesAsString());
-
- this.log.setValue(this.getLog().toString());
+ String tmpLog=this.getLog().toString();
+ this.log.setValue(tmpLog);
+ // eine kopie des Logs geht zur Auswertung an die BotMap
+ this.map.setValue(tmpLog);
break;
//
@@ -944,9 +951,9 @@
new Color(255, 137, 137), // rot
new Color(255, 230, 139), // orange
new Color(255, 255, 159), // gelb
- new Color(170, 255, 170), // gr?n
- new Color(200, 255, 245), // t?rkis
- new Color(245, 245, 245) // wei?
+ new Color(170, 255, 170), // gr???n
+ new Color(200, 255, 245), // t???rkis
+ new Color(245, 245, 245) // wei???
};
private static final Color[] colsAct = {
@@ -955,8 +962,8 @@
new Color(255, 0, 0), // rot
new Color(255, 200, 0), // orange
new Color(255, 255, 0), // gelb
- new Color( 0, 255, 0), // gr?n
- new Color( 0, 255, 210), // t?rkis
- new Color(255, 255, 255) // wei?
+ new Color( 0, 255, 0), // gr???n
+ new Color( 0, 255, 210), // t???rkis
+ new Color(255, 255, 255) // wei???
};
}
Index: ctSim/view/actuators/BotMapInnerView.java
===================================================================
RCS file: ctSim/view/actuators/BotMapInnerView.java
diff -N ctSim/view/actuators/BotMapInnerView.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ctSim/view/actuators/BotMapInnerView.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,153 @@
+/*
+ * c't-Sim - Robotersimulator fuer den c't-Bot
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+
+package ctSim.view.actuators;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.util.ArrayList;
+
+import javax.swing.JPanel;
+
+import ctSim.model.bots.components.actuators.BotMap;
+
+/**
+ * Der innere BotMapView stellt die eigentliche Grafik dar. In einer Arraylist werden zeichenbare Objekte (SHAPE)
+ * gesammelt, die dann beim neuzeichnen dargestellt werden. (Diese Klasse wurde mit dem Eclipse-VE erzeugt, und
+ * nachbearbeitet)
+ *
+ * @author Andreas.Kielkopf andreas.kielkopf@xxxxxxxxxxxxxxxxx
+ *
+ */
+public class BotMapInnerView extends JPanel {
+
+ private ArrayList<ColorShape> colorShapes; // @jve:decl-index=0:
+
+ private AffineTransform botMapTransform = new AffineTransform(); // @jve:decl-index=0:
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * This is the default constructor
+ */
+ public BotMapInnerView() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(600, 600);
+ this.setLayout(null);
+ this.colorShapes = new ArrayList<ColorShape>();
+ if (true) {
+ // F??ge einen Grundrahmen ein, der aber verschwindet, sobald der Zeichenpuffer ??berl??uft
+ final int A = -1024, B = 1023;
+ colorShapes.add(new ColorShape(new Line2D.Double(A, A, B, A), Color.gray));
+ colorShapes.add(new ColorShape(new Line2D.Double(A, B, B, B), Color.gray));
+ colorShapes.add(new ColorShape(new Line2D.Double(A, A, A, B), Color.gray));
+ colorShapes.add(new ColorShape(new Line2D.Double(B, A, B, B), Color.gray));
+ // Dieser Rahemen beeinflusst auch die automatische skalierung !!
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.swing.JComponent#paint(java.awt.Graphics)
+ */
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g); // Hintergrund zeichnen
+ try {
+ Graphics2D g2d = (Graphics2D) g;
+ AffineTransform tmpTransformg = g2d.getTransform();
+ g2d.setTransform(botMapTransform); // spezielle Transformation zur verbesserten Darstellung der Werte
+ if (true) {
+ g2d.setColor(Color.lightGray); // zeichne Fadenkreuz (x+y-Achse) dauerhaft
+ g2d.drawLine(-33000, 0, 33000, 0);
+ g2d.drawLine(0, -33000, 0, 33000);
+ }
+ ArrayList<ColorShape> paintColorShapes = colorShapes; // zwischenspeichern, um Konflikt zu vermeiden
+ for (ColorShape pcs : paintColorShapes) {
+ if (g2d.getColor() != pcs.color) {
+ g2d.setColor(pcs.color);
+ }
+ g2d.draw(pcs.shape);
+ }
+ g2d.setTransform(tmpTransformg);
+ // g2d.dispose;
+ } catch (RuntimeException e) {
+ } // Auf keinen Fall hier abbrechen !!!
+ }
+
+ /**
+ * fuegt weitere farbige Shapes ein, bis MAX_SHAPES erreicht ist. Dann werden automatisch aeltere Shapes entfernt
+ *
+ * @param shape
+ * @param color
+ */
+ public void addShape(Shape shape, Color color) {
+ ArrayList<ColorShape> tmp_colorShapes = new ArrayList<ColorShape>(colorShapes);
+ if (tmp_colorShapes.size() > BotMap.MAX_SHAPES) {
+ ColorShape tmp = tmp_colorShapes.get(0);
+ tmp.color = null;
+ tmp.shape = null;
+ tmp_colorShapes.remove(0);
+ }
+ tmp_colorShapes.add(new ColorShape(shape, color));
+ colorShapes = tmp_colorShapes;
+ repaint(250); // maximal 4 mal pro sekunde neu zeichnen
+ }
+
+ /**
+ * Versucht alle gespeicherten Shapes anzuzeigen, indem eine passende Skalierung gew??hlt wird, und der Nullpunkt
+ * verschoben wird. Das ergebniss wird in BotmapTransform uebergeben.
+ *
+ */
+ public void calibrate() {
+ if (colorShapes.size() > 3) {
+ // addiere alle Punkte zu einem Rechteck
+ Rectangle2D r2d;
+ r2d = colorShapes.get(1).shape.getBounds2D(); // ein neuer Anfang
+ for (ColorShape cs : colorShapes) {
+ r2d.add(cs.shape.getBounds2D());
+ }
+ if (r2d.getWidth() > 0 && r2d.getHeight() > 0) {
+ AffineTransform tmp = new AffineTransform();
+ double moveX = r2d.getMinX();
+ double moveY = r2d.getMinY();
+ double scaleX = getWidth() / r2d.getWidth();
+ double scaleY = getHeight() / r2d.getHeight();
+ tmp.scale(scaleX, scaleY);
+ tmp.translate(-moveX, -moveY);
+ botMapTransform = tmp;
+ }
+ }
+ }
+}
Index: ctSim/model/bots/components/actuators/BotMap.java
===================================================================
RCS file: ctSim/model/bots/components/actuators/BotMap.java
diff -N ctSim/model/bots/components/actuators/BotMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ctSim/model/bots/components/actuators/BotMap.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,275 @@
+/*
+ * c't-Sim - Robotersimulator fuer den c't-Bot
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+package ctSim.model.bots.components.actuators;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.geom.Line2D;
+import java.util.StringTokenizer;
+
+import javax.vecmath.Point3d;
+import javax.vecmath.Vector3d;
+
+import ctSim.view.actuators.ActuatorGroupGUI;
+import ctSim.view.actuators.Actuators;
+import ctSim.view.actuators.BotMapInnerView;
+
+/**
+ * Klasse aller BotMaps Die BotMap zeigt farbige Punkte und Linien an, die vom Bot im Log ausgegeben werden. Durch
+ * einf??gen entsprechender Log-Anweisungen, kann man so grafisch debugen, welche Informationen vom Bot gerade
+ * verarbeitet werden. nach einer einstellbaren Zahl von Meldungen verschwinden alte Meldungen wieder. Der Bot kann
+ * einzelne Punkte auf der Karte farbig markieren, oder farbige linien zeichnen.
+ *
+ * Der Bot k??nnte so anzeigen, wo er die Eckpfosten vermutet (gelber Punkt), oder wo er den Ausgang vermutet (roter
+ * Punkt), oder wo er Waende (Blaue Linie) gescannt hat. Weiterhin k??nnte er mit schwarzen Punkten markieren, wo er
+ * vermutet, da?? er ist. Das mag helfen, sein Verhalten besser zu verstehen, und Fehler oder bessere Loesungen zu
+ * finden.
+ *
+ * Ein Anwendungsbeispiel:
+ *
+ * in der Routine
+ *
+ * void sensor_abstand(uint16 left, uint16 right){
+ *
+ * k??nnen folgende Zeilen eingefuegt werden:
+ *
+ * LOG_INFO(("Linie %03d %03d %03d %03d blue",left-2,right-2,left+2,right+2)); // am Anfang
+ *
+ * LOG_INFO(("Linie %03d %03d %03d %03d green",sensDistL-2,sensDistR+2,sensDistL+2,sensDistR-2)); // am Ende
+ *
+ *
+ *
+ * @author Andreas.Kielkopf andreas.kielkopf@xxxxxxxxxxxxxxxxx
+ *
+ */
+public class BotMap extends LogScreen {
+ // Nach 2000 Linien werden alte Linien entfernt (wegen der ??bersichtlichkeit)
+ public static final int MAX_SHAPES = 2000;
+
+ // Doppelte Logmeldungen verwerfen
+ private String lastValue = "";
+
+ // Das Display kalibiriert sich alle 100 Schritte neu, um eine optimale Anzeige zu gew??hrleisten
+ final int CALIBRATE = 100;
+
+ // Der Z??hler fuers kalibrieren vorbelegen
+ private int calibrate = (int) (CALIBRATE * 0.9);
+
+ private BotMapInnerView view;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ctSim.model.bots.components.actuators.LogScreen#getValue()
+ */
+ @Override
+ public String getValue() {
+ return super.getValue();
+ }
+
+ /**
+ * Durchsucht den ??bergebene String nach grafischen Befehlen f??r die BotMap, und ??bertr??gt diese in die BotMap
+ *
+ * @see ctSim.model.bots.components.actuators.LogScreen#setValue(java.lang.String)
+ */
+ @Override
+ public void setValue(String value) {
+ super.setValue(value); // zeigt den Befehl im Hintergrund zur Kontrolle an
+ if ((value != null) && (true)) {
+ try {
+ if (!value.equalsIgnoreCase(lastValue)) {
+ boolean isPunkt = value.contains("Punkt ");
+ //
+ // Beispiel:
+ // Punkt 17 25
+ // Punkt 15,3 70
+ // Punkt 1 255,73
+ // entspricht einem Befehl im Bot :
+ // LOG_INFO(("Punkt %03d %03d red",sensDistL,sensDistR));
+ //
+ boolean isLine = value.contains("Linie ");
+ //
+ // Beispiel:
+ // Linie 10 10 25 30
+ // Linie 25 30 40 40
+ // Linie 55,74 1 800 9,9
+ // LOG_INFO(("Linie %03d %03d %03d %03d green",sensDistL-2,sensDistR+2,sensDistL+2,sensDistR-2));
+ //
+ if (isPunkt || isLine) {
+ calibrate++;
+ if (calibrate >= CALIBRATE) {
+ calibrate = 0;
+ view.calibrate();
+ }
+ lastValue = value;
+ double x1 = -1, y1 = -1, x2 = -1, y2 = -1;
+ Line2D line = null;
+ StringTokenizer st = new StringTokenizer(value, " ");
+ do {
+ String nextToken = st.nextToken();
+ if (isLine && nextToken.contains("Linie"))break; // Skip Line
+ if (isPunkt && nextToken.contains("Punkt"))break; // Skip Punkt
+ } while (st.hasMoreTokens());
+ x1 = getDouble(st);
+ y1 = getDouble(st);
+ if (isPunkt) {
+ // Ein Punkt ist eine kurze Linie
+ line = new Line2D.Double(x1, y1, x1, y1);
+ } else {
+ x2 = getDouble(st);
+ y2 = getDouble(st);
+ if ((x1 != x2) || (y1 != y2)) {
+ // Eine Linie, die ein Punkt ist, wird nicht gezeichnet!!!
+ line = new Line2D.Double(x1, y1, x2, y2);
+ }
+ }
+ if (line != null) {
+ view.addShape(line, getColor(st));
+ }
+ }
+ }
+ } catch (NumberFormatException e) {
+ // wenn der Eintrag nicht passt, einfach ignorieren
+ }
+ }
+ }
+
+ /**
+ * Ermittelt den naechsten Wert, und gibt ihn zur??ck
+ *
+ * @param st
+ * Der zu durchsuchende StringTokenizer
+ * @return einen numerischen Wert oder -1
+ * @throws NumberFormatException
+ */
+ private double getDouble(StringTokenizer st) throws NumberFormatException {
+ if (st.hasMoreTokens())
+ return Double.parseDouble(st.nextToken());
+ return -1;
+ }
+
+ /**
+ * Ermittelt die gewuenschte Farbe
+ *
+ * @param st
+ * Der zu durchsuchende StringTokenizer
+ * @return
+ */
+ private Color getColor(StringTokenizer st) {
+ if (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if (token.contains("black"))
+ return Color.black;
+ if (token.contains("blue"))
+ return Color.blue;
+ if (token.contains("cyan"))
+ return Color.cyan;
+ if (token.contains("darkGray"))
+ return Color.darkGray;
+ if (token.contains("gray"))
+ return Color.gray;
+ if (token.contains("green"))
+ return Color.green;
+ if (token.contains("ligtGray"))
+ return Color.lightGray;
+ if (token.contains("magenta"))
+ return Color.magenta;
+ if (token.contains("orange"))
+ return Color.orange;
+ if (token.contains("pink"))
+ return Color.pink;
+ if (token.contains("red"))
+ return Color.red;
+ if (token.contains("white"))
+ return Color.white;
+ if (token.contains("yellow"))
+ return Color.yellow;
+ }
+ return Color.black;
+ }
+
+ /**
+ * Der Konstruktor
+ *
+ * @param name
+ * Display-Name
+ * @param relPos
+ * relative Position zum Bot
+ * @param relHead
+ * relative Blickrichtung zum Bot
+ */
+ public BotMap(String name, Point3d relPos, Vector3d relHead) {
+ super(name, relPos, relHead);
+ }
+
+ /**
+ * @see ctSim.model.bots.components.Actuator#getActuatorGroupGUI()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public ActuatorGroupGUI getActuatorGroupGUI() {
+ ActuatorGroupGUI gui = Actuators.getGuiFor(this);
+ gui.addActuator(this);
+ return gui;
+ }
+
+ /**
+ * @see ctSim.model.bots.components.BotComponent#getType()
+ */
+ @Override
+ public String getType() {
+ return "BotMap"; //$NON-NLS-1$
+ }
+
+ /**
+ * @see ctSim.model.bots.components.BotComponent#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return "Eine Karte dessen, was der Bot gerade denkt";
+ }
+
+ /**
+ * @see ctSim.model.bots.components.actuators.LogScreen#getBackgroundColor()
+ */
+ @Override
+ public Color getBackgroundColor() {
+ return new Color(120, 150, 90);
+ }
+
+ /**
+ * @see ctSim.model.bots.components.actuators.LogScreen#getFont()
+ */
+ @Override
+ public Font getFont() {
+ return new Font("Monospaced", Font.BOLD, 12); //$NON-NLS-1$
+ }
+
+ /**
+ * @see ctSim.model.bots.components.actuators.LogScreen#hasToRewrite()
+ */
+ @Override
+ public boolean hasToRewrite() {
+ return true;
+ }
+
+ public void setView(BotMapInnerView view) {
+ this.view = view;
+ }
+}
Index: ctSim/view/actuators/BotMapView.java
===================================================================
RCS file: ctSim/view/actuators/BotMapView.java
diff -N ctSim/view/actuators/BotMapView.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ctSim/view/actuators/BotMapView.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,149 @@
+/*
+ * c't-Sim - Robotersimulator fuer den c't-Bot
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+
+package ctSim.view.actuators;
+
+import java.awt.Dimension;
+import java.awt.GridBagLayout;
+import java.awt.Shape;
+
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.JToolBar;
+import java.awt.BorderLayout;
+import javax.swing.JScrollPane;
+
+import ctSim.model.bots.components.actuators.BotMap;
+
+import java.awt.Dimension;
+import java.util.ArrayList;
+
+/**
+ * Klasse aller BotMapViews Hier wird ein abl??sbares Fenster zur Verf??gung gestellt, in dem die eigentliche Anzeige
+ * stattfinden kann. (Diese Klasse wurde mit dem Eclipse-VE erzeugt, und nachbearbeitet)
+ *
+ * @author Andreas Kielkopf
+ *
+ */
+public class BotMapView extends JTextArea {
+ /*
+ * Hier wird etwas geschummelt. Eigentlich k??nnte auch JComponent erweitert werden, aber so ist die Integration in
+ * den vorhandenen ctsim weniger "invasiv". Als sch??nen Nebeneffekt kann man nach abl??sen des Fensters hier die
+ * jeweils letzte Meldung nachlesen
+ */
+ private static final long serialVersionUID = 1L;
+
+ private JToolBar jToolBar = null;
+
+ private JPanel jPanel = null;
+
+ private JScrollPane jScrollPane = null;
+
+ private BotMapInnerView innerView = null; // Die eigentliche Anzeige
+
+ /**
+ * This is the default constructor
+ */
+ public BotMapView() {
+ super();
+ initialize();
+ }
+
+ public BotMapView(BotMap botmap) {
+ this();
+ botmap.setView(this.innerView);
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(300, 200);
+ this.setLayout(new BorderLayout());
+ this.add(getJToolBar(), BorderLayout.CENTER);
+ }
+
+ /**
+ * This method initializes jToolBar
+ *
+ * @return javax.swing.JToolBar
+ */
+ private JToolBar getJToolBar() {
+ if (jToolBar == null) {
+ jToolBar = new JToolBar();
+ jToolBar.setPreferredSize(new Dimension(300, 300));
+ jToolBar.setName("BotMap");
+ jToolBar.add(getJPanel());
+ }
+ return jToolBar;
+ }
+
+ /**
+ * This method initializes jPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanel() {
+ if (jPanel == null) {
+ jPanel = new JPanel();
+ jPanel.setLayout(new BorderLayout());
+ jPanel.setName("BotMap");
+ jPanel.add(getJScrollPane(), BorderLayout.CENTER);
+ }
+ return jPanel;
+ }
+
+ /**
+ * This method initializes jScrollPane
+ *
+ * @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setViewportView(getInnerView());
+ }
+ return jScrollPane;
+ }
+
+ /**
+ * This method initializes jPanel1
+ *
+ * @return javax.swing.JPanel
+ */
+ private BotMapInnerView getInnerView() {
+ if (innerView == null) {
+ innerView = new BotMapInnerView();
+ innerView.setLayout(new GridBagLayout());
+ }
+ return innerView;
+ }
+
+ /**
+ * @param preferredSize
+ * @see javax.swing.JComponent#setPreferredSize(java.awt.Dimension)
+ */
+ @Override
+ public void setPreferredSize(Dimension preferredSize) {
+ super.setPreferredSize(preferredSize);
+ jToolBar.setPreferredSize(preferredSize);
+ }
+}
Index: ctSim/view/actuators/ColorShape.java
===================================================================
RCS file: ctSim/view/actuators/ColorShape.java
diff -N ctSim/view/actuators/ColorShape.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ctSim/view/actuators/ColorShape.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,50 @@
+/*
+ * c't-Sim - Robotersimulator fuer den c't-Bot
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ * This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+package ctSim.view.actuators;
+
+import java.awt.Color;
+import java.awt.Shape;
+
+/**
+ * Eine einfache Gruppierung einer Farbe und eines Shape, die gemeinsam gespeichert und gemeinsam verworfen werden
+ * k??nnen. Aus Geschwindigkeitsgr??nden wird auf eine richtige Kapselung verzichtet.
+ *
+ * @author Andreas.Kielkopf andreas.kielkopf@xxxxxxxxxxxxxxxxx
+ *
+ */
+public class ColorShape extends Object {
+ public Shape shape;
+
+ public Color color;
+
+ private ColorShape() {
+ super();
+ }
+
+ /**
+ * Erzeugt ein ColorShape
+ * @param shape das zeichenbare Objekt
+ * @param color die gew??nschte Farbe
+ */
+ public ColorShape(Shape shape, Color color) {
+ super();
+ this.shape = shape;
+ this.color = color;
+ }
+}