From c6be4e94e3a3634f17752ea7c01f1564e6105bbf Mon Sep 17 00:00:00 2001 From: hama Date: Sat, 11 Oct 2014 00:28:02 +0200 Subject: [PATCH] Correct move of Movable, refactoring * fix: center object replacement instead of cloning has avoided the move * new: Movable stops if destination is reached * renamed: *SWT to *Swing * new: LineSwing * javadoc corrections --- src/jlection/robotic/RoboSim.java | 9 +-- src/jlection/robotic/RobotModel.java | 18 +++++- src/jlecture/simulation/DimensionRW.java | 11 ++++ src/jlecture/simulation/ISheet.java | 3 + src/jlecture/simulation/Model.java | 46 ++++++++++---- src/jlecture/simulation/Movable.java | 28 ++++++--- src/jlecture/simulation/PointRW.java | 11 ++++ src/jlecture/simulation/RectangleRW.java | 13 ++++ src/jlecture/swing/LineSwing.java | 61 +++++++++++++++++++ .../PanelSWT.java => swing/PanelSwing.java} | 8 +-- .../RectangleSwing.java} | 26 ++++---- .../SheetSWT.java => swing/SheetSwing.java} | 20 +++--- .../WidgetSWT.java => swing/WidgetSwing.java} | 17 ++++-- .../XCrossSWT.java => swing/XCrossSwing.java} | 22 +++---- test/jlecture/junit/RobotModelTest.java | 16 +++-- test/jlecture/junit/WidgetTest.java | 8 ++- 16 files changed, 237 insertions(+), 80 deletions(-) create mode 100644 src/jlecture/swing/LineSwing.java rename src/jlecture/{swt/PanelSWT.java => swing/PanelSwing.java} (88%) rename src/jlecture/{swt/RectangleSWT.java => swing/RectangleSwing.java} (61%) rename src/jlecture/{swt/SheetSWT.java => swing/SheetSwing.java} (79%) rename src/jlecture/{swt/WidgetSWT.java => swing/WidgetSwing.java} (80%) rename src/jlecture/{swt/XCrossSWT.java => swing/XCrossSwing.java} (66%) diff --git a/src/jlection/robotic/RoboSim.java b/src/jlection/robotic/RoboSim.java index c01c1e4..db907c7 100644 --- a/src/jlection/robotic/RoboSim.java +++ b/src/jlection/robotic/RoboSim.java @@ -9,7 +9,8 @@ import java.awt.Point; import javax.swing.SwingUtilities; import jlecture.simulation.Model; -import jlecture.swt.SheetSWT; +import jlecture.simulation.RectangleRW; +import jlecture.swing.SheetSwing; /** * Defines the main routine of the robot simulator. @@ -36,9 +37,9 @@ public class RoboSim { * Initializes the model and the graphical view. */ public void exec() { - Model model = new RobotModel(); - SheetSWT sheet = new SheetSWT(new Point(50, 10), new Dimension(1000, - 800), "Roboterfeld", model); + Model model = new RobotModel(new RectangleRW(0, 0, 1000, 800)); + SheetSwing sheet = new SheetSwing(new Point(50, 10), new Dimension( + 1000, 800), "Roboterfeld", model); model.createModel(); SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/src/jlection/robotic/RobotModel.java b/src/jlection/robotic/RobotModel.java index 56f505e..a91e975 100644 --- a/src/jlection/robotic/RobotModel.java +++ b/src/jlection/robotic/RobotModel.java @@ -8,6 +8,7 @@ import jlecture.simulation.DimensionRW; import jlecture.simulation.Model; import jlecture.simulation.Movable; import jlecture.simulation.PointRW; +import jlecture.simulation.RectangleRW; /** * Implements a robot simulation. @@ -16,6 +17,16 @@ import jlecture.simulation.PointRW; * */ public class RobotModel extends Model { + /** + * Constructor. + * + * @param region + * the visible real world coordinates (a rectangle) + */ + public RobotModel(RectangleRW region) { + super(region); + } + /** * Builds the elements of the simulator. * @@ -39,13 +50,14 @@ public class RobotModel extends Model { destination.x = robot.getWidget().getCenter().x; destination.y = robot.getWidget().getCenter().y; randomDestination(destination); - // 100 seconds for the whole width: - double velocity = 1 / 100.0 * this.region.width - * (0.5 + this.random.nextDouble() * 0.5); + double minSecondsForWidth = 25; + double velocity = 1 / minSecondsForWidth * this.region.width * 0.5 + * (1 + this.random.nextDouble()); robot.setMove(destination, velocity); this.things.add(robot); } this.isReady = true; + log("model completed"); } } diff --git a/src/jlecture/simulation/DimensionRW.java b/src/jlecture/simulation/DimensionRW.java index eee8b88..6c38cfc 100644 --- a/src/jlecture/simulation/DimensionRW.java +++ b/src/jlecture/simulation/DimensionRW.java @@ -37,4 +37,15 @@ public class DimensionRW extends Dimension { this.width = width; this.height = height; } + + /** + * Takes the values from another dimension. + * + * @param source + * the source to clone + */ + public void clone(DimensionRW source) { + this.width = source.width; + this.height = source.height; + } } diff --git a/src/jlecture/simulation/ISheet.java b/src/jlecture/simulation/ISheet.java index 335e896..7f4e0de 100644 --- a/src/jlecture/simulation/ISheet.java +++ b/src/jlecture/simulation/ISheet.java @@ -15,6 +15,9 @@ public interface ISheet { * the center of the rectangle * @param dimension * the width/height of the widget + * @param filled + * true: the rectangle will be filled
+ * otherwise: different colors of frame and area * @param model * the simulator model * @return a X cross widget diff --git a/src/jlecture/simulation/Model.java b/src/jlecture/simulation/Model.java index 1af27cb..9edabf5 100644 --- a/src/jlecture/simulation/Model.java +++ b/src/jlecture/simulation/Model.java @@ -45,17 +45,27 @@ public abstract class Model { /** * The simulator area with real world coordinates. */ - protected RectangleRW region = new RectangleRW(0, 0, 1024, 1024 * 2 / 3); + protected RectangleRW region = null; /** * A pseude random generator for repeatable results. */ protected Random random = new Random(0x4711); + private long sumTime = 0; + + private long count = 0; + + private long max = 0; + /** * Constructor. + * + * @param region + * the visible real world coordinates (a rectangle) */ - public Model() { + public Model(RectangleRW region) { + this.region = region; } /** @@ -96,6 +106,7 @@ public abstract class Model { * Logs a message. * * @param message + * message to log */ public void log(String message) { System.out.println(message); @@ -135,15 +146,28 @@ public abstract class Model { * are necessary for one simulation step. */ public void onTimer() { - if (this.isReady) - for (ThingRW thing : this.things) - if (thing instanceof Movable) { - Movable robot = (Movable) thing; - PointRW center = robot.getWidget().getCenter(); - // moves to the position belonging to the current move: - robot.currentPosition(center, System.currentTimeMillis()); - robot.getWidget().setCenter(center); - } + if (this.isReady) { + long start = System.currentTimeMillis(); + // count++; + // for (int n = 0; n < 1; n++) + { + for (ThingRW thing : this.things) + if (thing instanceof Movable) { + Movable robot = (Movable) thing; + PointRW center = robot.getWidget().getCenter(); + // moves to the position belonging to the current move: + robot.currentPosition(center, start); + robot.getWidget().setCenter(center); + } + } + // long diff = System.currentTimeMillis() - start; + // sumTime += diff; + // if (max < diff) + // max = diff; + // if (count % 1 == 0) + // log(String.format("Count: %d Duration: %f Max: %d", count, + // (double) sumTime / count, max)); + } } /** diff --git a/src/jlecture/simulation/Movable.java b/src/jlecture/simulation/Movable.java index 050ac03..3cd14c6 100644 --- a/src/jlecture/simulation/Movable.java +++ b/src/jlecture/simulation/Movable.java @@ -54,11 +54,10 @@ public class Movable extends ThingRW { * @param point * OUT: the calculated current position * @param currentTime - * < 0: relative to the starttime (negated)
+ * < 0: relative to the starttime (negated)
* otherwise: the current time in milliseconds */ public void currentPosition(PointRW point, long currentTime) { - ; if (this.velocity == 0.0) { point.x = this.widget.getCenter().x; point.y = this.widget.getCenter().y; @@ -71,15 +70,24 @@ public class Movable extends ThingRW { // hypotenuse: // c = sqrt(x_target _ x_start)**2 + (y_target _ y_start)**2) // Theory of intersecting lines: - // x_diff : distance = (x_target - x_start) / c - // y_diff : distance = (y_target - y_start) / c + // x_diff / distance = (x_target - x_start) / c + // y_diff / distance = (y_target - y_start) / c double x_diff = this.destination.x - this.start.x; double y_diff = this.destination.y - this.start.y; double c = Math.sqrt(x_diff * x_diff + y_diff * y_diff); - x_diff = distance * x_diff / c; - y_diff = distance * y_diff / c; - point.x = this.start.x + x_diff; - point.y = this.start.y + y_diff; + double x_diff2 = distance * x_diff / c; + double y_diff2 = distance * y_diff / c; + point.x = this.start.x + x_diff2; + point.y = this.start.y + y_diff2; + // Stop if the destination has reached: + if (Math.abs(x_diff2) > Math.abs(x_diff)) { + point.x = this.destination.x; + this.velocity = 0; + } + if (Math.abs(y_diff2) > Math.abs(y_diff)) { + point.y = this.destination.y; + this.velocity = 0; + } } } @@ -102,8 +110,8 @@ public class Movable extends ThingRW { * real world coordinates */ public void setMove(PointRW destination, double velocity) { - this.start = this.widget.getCenter(); - this.destination = destination; + this.start.clone(this.widget.getCenter()); + this.destination.clone(destination); this.startTime = System.currentTimeMillis(); this.velocity = velocity; } diff --git a/src/jlecture/simulation/PointRW.java b/src/jlecture/simulation/PointRW.java index 7289d22..caf09ca 100644 --- a/src/jlecture/simulation/PointRW.java +++ b/src/jlecture/simulation/PointRW.java @@ -34,4 +34,15 @@ public class PointRW { this.x = x; this.y = y; } + + /** + * Takes the values from another point. + * + * @param source + * the source to clone + */ + public void clone(PointRW source) { + this.x = source.x; + this.y = source.y; + } } diff --git a/src/jlecture/simulation/RectangleRW.java b/src/jlecture/simulation/RectangleRW.java index cb2434a..1e16e2e 100644 --- a/src/jlecture/simulation/RectangleRW.java +++ b/src/jlecture/simulation/RectangleRW.java @@ -47,4 +47,17 @@ public class RectangleRW { this.height = height; } + /** + * Takes the values from another rectangle. + * + * @param source + * the source to clone + */ + public void clone(RectangleRW source) { + this.x = source.x; + this.y = source.y; + this.width = source.width; + this.height = source.height; + } + } diff --git a/src/jlecture/swing/LineSwing.java b/src/jlecture/swing/LineSwing.java new file mode 100644 index 0000000..a7f303c --- /dev/null +++ b/src/jlecture/swing/LineSwing.java @@ -0,0 +1,61 @@ +/** + * + */ +package jlecture.swing; + +import java.awt.Graphics2D; + +import jlecture.simulation.Model; +import jlecture.simulation.PointRW; + +/** + * Implements a line in Swing. + * + * + * @author hm + * + */ +public class LineSwing extends WidgetSwing { + /** + * the first point of the line + */ + private PointRW from; + /** + * the last point of the line + */ + private PointRW to; + + /** + * Constructor. + * + * @param from + * the first point of the line + * @param to + * the last point of the line + * @param model + * the simulator model + */ + public LineSwing(PointRW from, PointRW to, Model model) { + super(from, model); + this.from = from; + this.to = to; + } + + @Override + protected void calculateContour() { + this.contour.x = Math.min(this.from.x, this.to.x); + this.contour.y = Math.min(this.from.y, this.to.y); + this.contour.width = Math.abs(this.from.x - this.to.x); + this.contour.height = Math.abs(this.from.y - this.to.y); + this.model.transform(this.contour, this.contourSwing); + } + + @Override + public void draw(Graphics2D graphics) { + graphics.drawLine(this.contourSwing.x, this.contourSwing.y, + this.contourSwing.x + this.contourSwing.width, this.contourSwing.y + + this.contourSwing.height); + + } + +} diff --git a/src/jlecture/swt/PanelSWT.java b/src/jlecture/swing/PanelSwing.java similarity index 88% rename from src/jlecture/swt/PanelSWT.java rename to src/jlecture/swing/PanelSwing.java index 9d3680b..5eecece 100644 --- a/src/jlecture/swt/PanelSWT.java +++ b/src/jlecture/swing/PanelSwing.java @@ -1,7 +1,7 @@ /** * */ -package jlecture.swt; +package jlecture.swing; /** * @author hm @@ -22,7 +22,7 @@ import jlecture.simulation.Model; * @author hm * */ -class PanelSWT extends JPanel { +class PanelSwing extends JPanel { Model model; private static final long serialVersionUID = 1L; @@ -35,7 +35,7 @@ class PanelSWT extends JPanel { * @param model * the simulator model */ - public PanelSWT(Model model) { + public PanelSwing(Model model) { this.model = model; } @@ -52,7 +52,7 @@ class PanelSWT extends JPanel { g2d.setBackground(this.background); for (IWidget item : this.model.getItems()) { - WidgetSWT item2 = (WidgetSWT) item; + WidgetSwing item2 = (WidgetSwing) item; item2.draw(g2d); } } diff --git a/src/jlecture/swt/RectangleSWT.java b/src/jlecture/swing/RectangleSwing.java similarity index 61% rename from src/jlecture/swt/RectangleSWT.java rename to src/jlecture/swing/RectangleSwing.java index f75551c..f603be0 100644 --- a/src/jlecture/swt/RectangleSWT.java +++ b/src/jlecture/swing/RectangleSwing.java @@ -1,10 +1,9 @@ /** * */ -package jlecture.swt; +package jlecture.swing; import java.awt.Graphics2D; -import java.awt.Rectangle; import jlecture.simulation.DimensionRW; import jlecture.simulation.Model; @@ -13,18 +12,16 @@ import jlecture.simulation.PointRW; /** * Implements a rectangle with real world coordinates. * - * @Note: The rectangle has real world coordinates but it will be shown with - * pixel coordinates. The translation is done internally (using the - * model). + * Note: The rectangle has real world coordinates but it will be shown with + * pixel coordinates. The translation is done internally (using the model). * * @author hm * */ -public class RectangleSWT extends WidgetSWT { +public class RectangleSwing extends WidgetSwing { private DimensionRW dimension = null; private boolean filled = false; - private Rectangle contourSWT = new Rectangle(); /** * Constructor. @@ -39,8 +36,8 @@ public class RectangleSWT extends WidgetSWT { * @param model * the simulator model */ - public RectangleSWT(PointRW center, DimensionRW dimension, boolean filled, - Model model) { + public RectangleSwing(PointRW center, DimensionRW dimension, + boolean filled, Model model) { super(center, model); this.dimension = dimension; this.filled = filled; @@ -53,17 +50,16 @@ public class RectangleSWT extends WidgetSWT { this.contour.y = this.center.y - this.dimension.height / 2; this.contour.width = this.dimension.width; this.contour.height = this.dimension.height; + this.model.transform(this.contour, this.contourSwing); } @Override public void draw(Graphics2D graphics) { - calculateContour(); - this.model.transform(this.contour, this.contourSWT); if (this.filled) - graphics.fillRect(this.contourSWT.x, this.contourSWT.y, - this.contourSWT.width, this.contourSWT.height); + graphics.fillRect(this.contourSwing.x, this.contourSwing.y, + this.contourSwing.width, this.contourSwing.height); else - graphics.drawRect(this.contourSWT.x, this.contourSWT.y, - this.contourSWT.width, this.contourSWT.height); + graphics.drawRect(this.contourSwing.x, this.contourSwing.y, + this.contourSwing.width, this.contourSwing.height); } } diff --git a/src/jlecture/swt/SheetSWT.java b/src/jlecture/swing/SheetSwing.java similarity index 79% rename from src/jlecture/swt/SheetSWT.java rename to src/jlecture/swing/SheetSwing.java index d8c9ad9..e040caf 100644 --- a/src/jlecture/swt/SheetSWT.java +++ b/src/jlecture/swing/SheetSwing.java @@ -1,4 +1,4 @@ -package jlecture.swt; +package jlecture.swing; import java.awt.Dimension; import java.awt.Point; @@ -15,17 +15,17 @@ import jlecture.simulation.Model; import jlecture.simulation.PointRW; /** - * Defines a windows driven by SWT. + * Defines a windows driven by Swing. * * This window contains a panel with the view of the simulated world. * - * @Note: this class uses pixel coordinates: the maximum x is right, the maximum - * y is at the bottom. + * Note: this class uses pixel coordinates: the maximum x is right, the maximum + * y is at the bottom. * * @author hm * */ -public class SheetSWT extends JFrame implements ISheet, ActionListener { +public class SheetSwing extends JFrame implements ISheet, ActionListener { private static final long serialVersionUID = 1L; private Point position = null; private Dimension dimension = null; @@ -42,8 +42,10 @@ public class SheetSWT extends JFrame implements ISheet, ActionListener { * the width and height of the window * @param title * the window's title + * @param model + * simulator model */ - public SheetSWT(Point position, Dimension dimension, String title, + public SheetSwing(Point position, Dimension dimension, String title, Model model) { this.position = position; this.dimension = dimension; @@ -67,13 +69,13 @@ public class SheetSWT extends JFrame implements ISheet, ActionListener { @Override public IWidget createRectangle(PointRW center, DimensionRW dimension, boolean filled, Model model) { - return new RectangleSWT(center, dimension, filled, model); + return new RectangleSwing(center, dimension, filled, model); } @Override public IWidget createXCross(PointRW center, DimensionRW dimension, Model model) { - return new XCrossSWT(center, dimension, model); + return new XCrossSwing(center, dimension, model); } /** @@ -84,7 +86,7 @@ public class SheetSWT extends JFrame implements ISheet, ActionListener { setTitle(this.title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - add(new PanelSWT(this.model)); + add(new PanelSwing(this.model)); setSize(this.dimension.width, this.dimension.height); diff --git a/src/jlecture/swt/WidgetSWT.java b/src/jlecture/swing/WidgetSwing.java similarity index 80% rename from src/jlecture/swt/WidgetSWT.java rename to src/jlecture/swing/WidgetSwing.java index b4b6f43..f92b107 100644 --- a/src/jlecture/swt/WidgetSWT.java +++ b/src/jlecture/swing/WidgetSwing.java @@ -1,9 +1,10 @@ /** * */ -package jlecture.swt; +package jlecture.swing; import java.awt.Graphics2D; +import java.awt.Rectangle; import jlecture.simulation.IWidget; import jlecture.simulation.Model; @@ -22,16 +23,22 @@ import jlecture.simulation.RectangleRW; * @author hm * */ -public abstract class WidgetSWT implements IWidget { +public abstract class WidgetSwing implements IWidget { /** * The center of the item in real world coordinates. This simply allows * calculating distance between 2 items. */ protected PointRW center; /** - * The smallest rectangle containing all parts of the item. + * The smallest rectangle containing all parts of the item (in real world + * coordinates). */ protected RectangleRW contour = new RectangleRW(0, 0, 0, 0); + /** + * The smallest rectangle containing all parts of the item (in pixel + * coordinates). + */ + protected Rectangle contourSwing = new Rectangle(); /** * Simulator model. @@ -43,8 +50,10 @@ public abstract class WidgetSWT implements IWidget { * * @param center * the central position of the widget. + * @param model + * simulator model */ - public WidgetSWT(PointRW center, Model model) { + public WidgetSwing(PointRW center, Model model) { this.center = center; this.model = model; model.getItems().add(this); diff --git a/src/jlecture/swt/XCrossSWT.java b/src/jlecture/swing/XCrossSwing.java similarity index 66% rename from src/jlecture/swt/XCrossSWT.java rename to src/jlecture/swing/XCrossSwing.java index bb3440f..b43e598 100644 --- a/src/jlecture/swt/XCrossSWT.java +++ b/src/jlecture/swing/XCrossSwing.java @@ -1,10 +1,9 @@ /** * */ -package jlecture.swt; +package jlecture.swing; import java.awt.Graphics2D; -import java.awt.Rectangle; import jlecture.simulation.DimensionRW; import jlecture.simulation.Model; @@ -18,13 +17,12 @@ import jlecture.simulation.RectangleRW; * @author hm * */ -public class XCrossSWT extends WidgetSWT { +public class XCrossSwing extends WidgetSwing { /** * The length of the square (contour). */ private DimensionRW dimension = null; private RectangleRW contour = new RectangleRW(0, 0, 0, 0); - private Rectangle contourSWT = new Rectangle(); /** * Constructor. @@ -36,7 +34,7 @@ public class XCrossSWT extends WidgetSWT { * @param model * the simulation model */ - public XCrossSWT(PointRW center, DimensionRW dimension, Model model) { + public XCrossSwing(PointRW center, DimensionRW dimension, Model model) { super(center, model); this.dimension = dimension; calculateContour(); @@ -56,12 +54,12 @@ public class XCrossSWT extends WidgetSWT { @Override public void draw(Graphics2D graphics) { calculateContour(); - this.model.transform(this.contour, this.contourSWT); - graphics.drawLine(this.contourSWT.x, this.contourSWT.y, - this.contourSWT.x + this.contourSWT.width, this.contourSWT.y - + this.contourSWT.height); - graphics.drawLine(this.contourSWT.x + this.contourSWT.width, - this.contourSWT.y, this.contourSWT.x, this.contourSWT.y - + this.contourSWT.height); + this.model.transform(this.contour, this.contourSwing); + graphics.drawLine(this.contourSwing.x, this.contourSwing.y, + this.contourSwing.x + this.contourSwing.width, this.contourSwing.y + + this.contourSwing.height); + graphics.drawLine(this.contourSwing.x + this.contourSwing.width, + this.contourSwing.y, this.contourSwing.x, this.contourSwing.y + + this.contourSwing.height); } } diff --git a/test/jlecture/junit/RobotModelTest.java b/test/jlecture/junit/RobotModelTest.java index 2532b7f..aaba9a2 100644 --- a/test/jlecture/junit/RobotModelTest.java +++ b/test/jlecture/junit/RobotModelTest.java @@ -13,16 +13,20 @@ import jlecture.simulation.Movable; import jlecture.simulation.PointRW; import jlecture.simulation.RectangleRW; import jlecture.simulation.ThingRW; -import jlecture.swt.SheetSWT; +import jlecture.swing.SheetSwing; import org.junit.Assert; import org.junit.Test; public class RobotModelTest extends RobotModel { + public RobotModelTest() { + super(new RectangleRW(0, 0, 1000, 800)); + } + @Test public void testMove() { - ISheet sheet = new SheetSWT(new Point(0, 0), new Dimension(1000, 800), - "test", this); + ISheet sheet = new SheetSwing(new Point(0, 0), + new Dimension(1000, 800), "test", this); IWidget rectangle = sheet.createRectangle(new PointRW(100, 100), new DimensionRW(20, 20), true, this); Movable robot = new Movable(rectangle); @@ -62,7 +66,7 @@ public class RobotModelTest extends RobotModel { @Test public void testOccupied() { - ISheet sheet = new SheetSWT(new Point(0, 0), new Dimension(200, 100), + ISheet sheet = new SheetSwing(new Point(0, 0), new Dimension(200, 100), "test", this); IWidget rectangle = sheet.createRectangle(new PointRW(100, 100), new DimensionRW(20, 20), true, this); @@ -79,7 +83,7 @@ public class RobotModelTest extends RobotModel { @Test public void testOpenPosition() { - ISheet sheet = new SheetSWT(new Point(0, 0), new Dimension(200, 100), + ISheet sheet = new SheetSwing(new Point(0, 0), new Dimension(200, 100), "test", this); IWidget rectangle = sheet.createRectangle(new PointRW(100, 100), new DimensionRW(20, 20), true, this); @@ -93,7 +97,7 @@ public class RobotModelTest extends RobotModel { @Test public void testOpenTransform() { - ISheet sheet = new SheetSWT(new Point(0, 0), new Dimension(200, 100), + ISheet sheet = new SheetSwing(new Point(0, 0), new Dimension(200, 100), "test", this); Rectangle rect = new Rectangle(0, 0, 0, 0); transform(new RectangleRW(1, 2, 3, 4), rect); diff --git a/test/jlecture/junit/WidgetTest.java b/test/jlecture/junit/WidgetTest.java index ccb5f9b..31ce8f1 100644 --- a/test/jlecture/junit/WidgetTest.java +++ b/test/jlecture/junit/WidgetTest.java @@ -14,7 +14,7 @@ import jlecture.simulation.IWidget; import jlecture.simulation.PointRW; import jlecture.simulation.RectangleRW; import jlecture.simulation.ThingRW; -import jlecture.swt.SheetSWT; +import jlecture.swing.SheetSwing; import org.junit.Assert; import org.junit.Test; @@ -25,9 +25,13 @@ import org.junit.Test; */ public class WidgetTest extends RobotModel { + public WidgetTest() { + super(new RectangleRW(0, 0, 1000, 800)); + } + @Test public void testBar() { - ISheet sheet = new SheetSWT(new Point(0, 0), new Dimension(200, 100), + ISheet sheet = new SheetSwing(new Point(0, 0), new Dimension(200, 100), "test", this); IWidget rectangle = sheet.createRectangle(new PointRW(100, 50), new DimensionRW(20, 20), true, this); -- 2.39.5