Commit 2c8c2263 authored by h2b's avatar h2b

Eventful factory methods added.

parent 9845311f
......@@ -21,6 +21,7 @@ import scala.concurrent.Future
import de.h2b.scala.lib.simgraf.driver.{ AwtScreenDriver, ScreenDriver }
import de.h2b.scala.lib.simgraf.layout.Cell
import de.h2b.scala.lib.simgraf.driver.AwtEventDriver
/**
* Provides screen (pixel) graphics.
......@@ -305,11 +306,19 @@ object Screen {
/**
* @param cell defines location, width and height of this screen
* @param title window title (will not reduce the drawing area)
* @return a new screen based on AWT driver
* @return a new screen based on a default driver
*/
def apply (cell: Cell, title: String): Screen =
apply(cell.origin, cell.width, cell.height, title)
/**
* @param cell defines location, width and height of this screen
* @param title window title (will not reduce the drawing area)
* @return a new screen based on a default driver with some input events enabled
*/
def withEvents (cell: Cell, title: String): Screen =
awtWithEvents(cell, title)
/**
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
......@@ -329,5 +338,13 @@ object Screen {
def awt (cell: Cell, title: String): Screen =
awt(cell.origin, cell.width, cell.height, title)
/**
* @param cell defines location, width and height of this screen
* @param title window title (will not reduce the drawing area)
* @return a new screen based on AWT driver with key and mouse events enabled
*/
def awtWithEvents (cell: Cell, title: String): Screen =
new Screen(cell.origin, cell.width, cell.height, title) with AwtEventDriver
}
......@@ -178,4 +178,22 @@ object World {
def apply (frame: Rectangle) (cell: Cell, title: String): World =
apply(frame.p1, frame.p2)(cell.origin, cell.width, cell.height, title)
/**
* @param frame bounding rectangle of the world coordinate system
* @param cell defines location, width and height of this world on the screen
* @param title window title (will not reduce the drawing area)
* @return a new world on a screen based on a default screen driver with some
* input events enabled
*
* @throws IllegalArgumentException if left bound of the world coordinate system
* greater than or equal to right bound or lower bound of the world coordinate
* system greater than or equal to upper bound
*/
def withEvents (frame: Rectangle) (cell: Cell, title: String): World = {
trait ScreenObj {
val screen: Screen = Screen.withEvents(cell, title)
}
new World(frame.p1, frame.p2) with ScreenObj
}
}
......@@ -183,7 +183,7 @@ object ScreenDriver {
* defaults to empty string)
* @return a new default screen driver
*/
def apply (p0: Pixel, width: Int, height: Int, title: String = ""): ScreenDriver =
def apply (p0: Pixel, width: Int, height: Int, title: String = ""): ScreenDriver =
awt(p0, width, height, title)
/**
......@@ -191,9 +191,17 @@ object ScreenDriver {
* @param title window title (will not reduce the drawing area)
* @return a new default screen driver
*/
def apply (cell: Cell, title: String): ScreenDriver =
def apply (cell: Cell, title: String): ScreenDriver =
apply(cell.origin, cell.width, cell.height, title)
/**
* @param cell defines location, width and height of this screen driver
* @param title window title (will not reduce the drawing area)
* @return a new default screen driver with some input events enabled
*/
def withEvents (cell: Cell, title: String): ScreenDriver =
awtWithEvents(cell, title)
/**
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
......@@ -213,4 +221,12 @@ object ScreenDriver {
def awt (cell: Cell, title: String): ScreenDriver =
awt(cell.origin, cell.width, cell.height, title)
/**
* @param cell defines location, width and height of this screen driver
* @param title window title (will not reduce the drawing area)
* @return a new AWT screen driver with key and mouse events enabled
*/
def awtWithEvents (cell: Cell, title: String): ScreenDriver =
new ScreenDriver(cell.origin, cell.width, cell.height, title) with AwtEventDriver
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment