Commit 3fe442b1 authored by h2b's avatar h2b

Cell-based factory methods added to screen driver and world.

parent 540c4883
......@@ -20,6 +20,8 @@ package de.h2b.scala.lib.simgraf
import scala.language.implicitConversions
import de.h2b.scala.lib.simgraf.shapes.{ Drawable, Fillable, Line }
import de.h2b.scala.lib.simgraf.layout.Cell
import de.h2b.scala.lib.simgraf.shapes.Rectangle
/**
* Provides graphics in world coordinates.
......@@ -163,4 +165,17 @@ object World {
new World(p1, p2) with ScreenObj
}
/**
* @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
*
* @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) (cell: Cell, title: String): World =
apply(frame.p1, frame.p2)(cell.origin, cell.width, cell.height, title)
}
......@@ -18,6 +18,7 @@
package de.h2b.scala.lib.simgraf.driver
import de.h2b.scala.lib.simgraf.{ Color, Pixel }
import de.h2b.scala.lib.simgraf.layout.Cell
/**
* Driver methods for screen graphics.
......@@ -185,6 +186,14 @@ object ScreenDriver {
def apply (p0: Pixel, width: Int, height: Int, title: String = ""): ScreenDriver =
awt(p0, width, 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
*/
def apply (cell: Cell, title: String): ScreenDriver =
apply(cell.origin, cell.width, cell.height, title)
/**
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
......@@ -195,4 +204,13 @@ object ScreenDriver {
*/
def awt (p0: Pixel, width: Int, height: Int, title: String = ""): ScreenDriver =
new ScreenDriver(p0, width, height, title) with AwtScreenDriver
/**
* @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
*/
def awt (cell: Cell, title: String): ScreenDriver =
awt(cell.origin, cell.width, cell.height, title)
}
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