Commit 4a67264b authored by h2b's avatar h2b

New factory method added.

parent eace029e
......@@ -158,12 +158,8 @@ object World {
* system greater than or equal to upper bound
*/
def apply (p1: Point, p2: Point)
(p0: Pixel, width: Int, height: Int, title: String = ""): World = {
trait ScreenObj {
val screen: Screen = Screen(p0, width, height, title)
}
new World(p1, p2) with ScreenObj
}
(p0: Pixel, width: Int, height: Int, title: String = ""): World =
apply(Rectangle(p1, p2), Screen(p0, width, height, title))
/**
* @param frame bounding rectangle of the world coordinate system
......@@ -176,7 +172,7 @@ object World {
* system greater than or equal to upper bound
*/
def apply (frame: Rectangle) (cell: Cell, title: String): World =
apply(frame.p1, frame.p2)(cell.origin, cell.width, cell.height, title)
apply(frame, Screen(cell, title))
/**
* @param frame bounding rectangle of the world coordinate system
......@@ -189,9 +185,21 @@ object World {
* 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 = {
def withEvents (frame: Rectangle) (cell: Cell, title: String): World =
apply(frame, Screen.withEvents(cell, title))
/**
* @param frame bounding rectangle of the world coordinate system
* @param window screen on which the world is shown
* @return a new world on the given screen
*
* @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 apply (frame: Rectangle, window: Screen): World = {
trait ScreenObj {
val screen: Screen = Screen.withEvents(cell, title)
val screen: Screen = window
}
new World(frame.p1, frame.p2) with ScreenObj
}
......
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