Commit 713e84bc authored by h2b's avatar h2b

API documentation improved and completed.

Includes making many private constructors public since there seems no
way to get the API doc of case classes with private constructors.

Furthermore, some abstract vals turned into defs.
parent 95b764bc
......@@ -29,7 +29,7 @@ package de.h2b.scala.lib.simgraf
*
* @throws IllegalArgumentException if a parameter is not in the interval `[0, 255]`
*/
case class Color private (red: Int, green: Int, blue: Int, alpha: Int = 255) {
case class Color (red: Int, green: Int, blue: Int, alpha: Int = 255) {
require(0<=red && red<=255, s"red component out of range: $red")
require(0<=green && green<=255, s"green component out of range: $green")
......
......@@ -24,13 +24,6 @@ package de.h2b.scala.lib.simgraf
* next color.
*
* @author h2b
*
* @constructor
*
* The specified colors will be excluded from the iteration. Beware, that the
* resulting color sequence must not be empty.
*
* @throws IllegalArgumentException if the resulting color sequence is empty
*/
class ColorIterator private (val exclude: Seq[Color]) extends Iterator[Color] {
......@@ -49,7 +42,7 @@ class ColorIterator private (val exclude: Seq[Color]) extends Iterator[Color] {
}
/**
* @inheritdoc
* Converts this iterator to a sequence.
*
* Although this iterator is of infinite size, this version of `toSeq`
* terminates and returns the underlying color sequence.
......@@ -66,8 +59,14 @@ object ColorIterator {
DarkGray, Orange, Pink, LightGray, White)
/**
* Returns an iterator over all colors defined in the `Color` companion object
* except for the ones specified.
*
* Beware, that the resulting color sequence must not be empty.
*
* @param exclude colors to be excluded from the iteration
* @return a new color iterator over standard colors
* @throws IllegalArgumentException if the resulting color sequence is empty
*/
def apply (exclude: Color*): ColorIterator = new ColorIterator(exclude)
......
......@@ -21,8 +21,8 @@ import de.h2b.scala.lib.math.linalg.{ Index, Vector, VectorStore }
trait PointStore [E] extends VectorStore[E] {
val x: E
val y: E
def x: E
def y: E
val index: Index = Index(1, 2)
......
......@@ -30,6 +30,9 @@ import de.h2b.scala.lib.simgraf.driver.{ AwtScreenDriver, ScreenDriver }
* ensure clipping to that area, so that it is safe to use coordinates outside
* of it.
*
* Implementation note: This abstract class does not add abstract members other
* than it inherits from ` ScreenDriver`.
*
* @author h2b
*
* @constructor
......@@ -37,7 +40,8 @@ import de.h2b.scala.lib.simgraf.driver.{ AwtScreenDriver, ScreenDriver }
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
* @param height vertical dimension
* @param title optional window title (will not reduce the drawing area)
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
*/
abstract class Screen (override val p0: Pixel, override val width: Int,
override val height: Int, override val title: String = "") extends
......@@ -239,7 +243,8 @@ object Screen {
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
* @param height vertical dimension
* @param title optional window title (will not reduce the drawing area)
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
* @return a new screen based on a default driver
*/
def apply (p0: Pixel, width: Int, height: Int, title: String = ""): Screen =
......@@ -249,7 +254,8 @@ object Screen {
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
* @param height vertical dimension
* @param title optional window title (will not reduce the drawing area)
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
* @return a new screen based on AWT driver
*/
def awt (p0: Pixel, width: Int, height: Int, title: String = ""): Screen =
......
......@@ -24,10 +24,12 @@ import de.h2b.scala.lib.simgraf.shapes.{ Drawable, Fillable, Line }
/**
* Provides graphics in world coordinates.
*
* It will have a coordinate system with `p1` in the lower-left corner and the
* upper-right corner at `p2`. All operations ensure clipping to that area, so
* It will have a coordinate system specified by its lower-left and
* upper-right corner. All operations ensure clipping to that area, so
* that it is safe to use coordinates outside of it.
*
* Implementations of this abstract class must provide a `screen` object.
*
* @author h2b
*
* @constructor
......@@ -46,7 +48,7 @@ abstract class World (val p1: Point, val p2: Point) {
require(p1.x<p2.x, s"left bound must be lower than right bound: ${p1.x}>=${p2.x}")
require(p1.y<p2.y, s"lower bound must be lower than upper bound: ${p1.y}>=${p2.y}")
val screen: Screen
def screen: Screen
def width: Int = screen.width
def height: Int = screen.height
......@@ -145,7 +147,8 @@ object World {
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension in pixels
* @param height vertical dimension in pixels
* @param title optional window title (will not reduce the drawing area)
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
* @return a new world on a screen based on a default screen driver
*
* @throws IllegalArgumentException if left bound of the world coordinate system
......
......@@ -30,6 +30,9 @@ import de.h2b.scala.lib.simgraf.{ Color, Pixel }
* ensure clipping to that area, so that it is safe to use coordinates outside
* of it.
*
* Implementations have to provide the `activeColor` variable and the `draw...`
* and `fill...` methods as well as `getPixel` and `setPixel`.
*
* @author h2b
*
* @constructor
......@@ -37,7 +40,8 @@ import de.h2b.scala.lib.simgraf.{ Color, Pixel }
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
* @param height vertical dimension
* @param title optional window title (will not reduce the drawing area)
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
*/
abstract class ScreenDriver protected (val p0: Pixel, val width: Int, val height: Int, val title: String = "") {
......@@ -51,6 +55,10 @@ abstract class ScreenDriver protected (val p0: Pixel, val width: Int, val height
@deprecated("Use ScreenDriver.screenWidth instead.", "SimGraf 0.3.0")
val screenWidth: Int
/**
* color to be used for the next operations (except for those that use
* their own color)
**/
var activeColor: Color
/**
......@@ -176,9 +184,25 @@ object ScreenDriver {
/** available screen width in pixels */
val screenWidth: Int = AwtScreenDriver.screenWidth
/**
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
* @param height vertical dimension
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
* @return a new default screen driver
*/
def apply (p0: Pixel, width: Int, height: Int, title: String = ""): ScreenDriver =
awt(p0, width, height, title)
/**
* @param p0 location of the upper-left corner on the screen
* @param width horizontal dimension
* @param height vertical dimension
* @param title optional window title (will not reduce the drawing area,
* defaults to empty string)
* @return a new AWT screen driver
*/
def awt (p0: Pixel, width: Int, height: Int, title: String = ""): ScreenDriver =
new ScreenDriver(p0, width, height, title) with AwtScreenDriver
}
......@@ -39,7 +39,7 @@ import de.h2b.scala.lib.simgraf.{ Point, World }
* @example Arc(Point(10,10), 5, 5, 0, 2*Math.Pi) creates a circle of diameter 5
* around the centre (10,10)
*/
case class Arc private (val p0: Point, val width: Double, val height: Double,
case class Arc (val p0: Point, val width: Double, val height: Double,
val startAngle: Double, val arcAngle: Double) extends Drawable with Fillable {
def draw (w: World): Unit =
......
......@@ -31,7 +31,7 @@ import scala.math._
* @param p0 centre of the circle
* @param r radius of the circle
*/
case class Circle private (val p0: Point, val r: Double) extends Drawable with Fillable {
case class Circle (val p0: Point, val r: Double) extends Drawable with Fillable {
private val ell = Ellipse(p0, 2*r, 2*r)
......
......@@ -28,7 +28,7 @@ import de.h2b.scala.lib.simgraf.World
*
* @author h2b
*/
case class Collage private (val items: Seq[Shape]) extends Drawable with Fillable {
case class Collage (val items: Seq[Shape]) extends Drawable with Fillable {
private val drawables = items collect { case d: Drawable d }
private val fillables = items collect { case f: Fillable f }
......
......@@ -22,6 +22,8 @@ import de.h2b.scala.lib.simgraf.{ Color, Pixel, Point, World }
/**
* A computed coloring.
*
* @constructor
*
* @param col computing function that maps point coordinates to colors
*
* @param enc enclosing for this grid; defaults to the full world if not
......@@ -29,7 +31,7 @@ import de.h2b.scala.lib.simgraf.{ Color, Pixel, Point, World }
*
* @author h2b
*/
case class Coloring private (val col: Point Color) (implicit val enc: Enclosing)
case class Coloring (val col: Point Color) (implicit val enc: Enclosing)
extends Fillable {
def fill (w: World): Unit = {
......
......@@ -26,7 +26,7 @@ import de.h2b.scala.lib.simgraf.{ Point, World }
*
* @author h2b
*/
case class Dot private (val p: Point) extends Drawable {
case class Dot (val p: Point) extends Drawable {
def draw (w: World): Unit = w.plot(p, w.activeColor)
......
......@@ -32,7 +32,7 @@ import scala.math._
* @param width of the enclosing virtual rectangle
* @param height of the enclosing virtual rectangle
*/
case class Ellipse private (val p0: Point, val width: Double, val height: Double) extends Drawable with Fillable {
case class Ellipse (val p0: Point, val width: Double, val height: Double) extends Drawable with Fillable {
private val arc = Arc(p0, width, height, 0, 2*Pi)
......
......@@ -24,14 +24,16 @@ import de.h2b.scala.lib.simgraf.{ Pixel, World }
*
* When filling, this is done from the x axis (i.e. `y==0`).
*
* @constructor
*
* @param f
*
* @param enc enclosing for this grid; defaults to the full world if not
* @param enc enclosing for this function; defaults to the full world if not
* explicitly or otherwise implicitly given
*
* @author h2b
*/
case class Function private (val f: Double Double) (implicit val enc: Enclosing)
case class Function (val f: Double Double) (implicit val enc: Enclosing)
extends Drawable with Fillable {
def draw (w: World): Unit = {
......
......@@ -23,6 +23,8 @@ import de.h2b.scala.lib.simgraf.shapes.Grid.Label
/**
* A grid with labels.
*
* @constructor
*
* @param dx distance of vertical lines
* @param dy distance of horizontal lines
* @param label optional label formatting
......@@ -32,7 +34,7 @@ import de.h2b.scala.lib.simgraf.shapes.Grid.Label
*
* @author h2b
*/
case class Grid private (val dx: Double, val dy: Double, val label: Label = Label.Default)
case class Grid (val dx: Double, val dy: Double, val label: Label = Label.Default)
(implicit val enc: Enclosing) extends Drawable {
def draw (w: World): Unit = {
......
......@@ -20,11 +20,11 @@ package de.h2b.scala.lib.simgraf.shapes
import de.h2b.scala.lib.simgraf.{ Point, World }
/**
* A line from `p1` to `p2`.
* A line between two points.
*
* @author h2b
*/
case class Line private (val p1: Point, val p2: Point) extends Drawable {
case class Line (val p1: Point, val p2: Point) extends Drawable {
def draw (w: World): Unit = w.screen.drawLine(w.toPixel(p1), w.toPixel(p2))
......
......@@ -25,14 +25,16 @@ import de.h2b.scala.lib.simgraf.{ Pixel, World }
* When filling, this is done from the lowest to the highest multivalue for each
* x, respectively.
*
* @constructor
*
* @param f
*
* @param enc enclosing for this grid; defaults to the full world if not
* @param enc enclosing for this function; defaults to the full world if not
* explicitly or otherwise implicitly given
*
* @author h2b
*/
case class MultivaluedFunction private (val f: Double Set[Double]) (implicit val enc: Enclosing)
case class MultivaluedFunction (val f: Double Set[Double]) (implicit val enc: Enclosing)
extends Drawable with Fillable {
def draw (w: World): Unit = {
......
......@@ -29,7 +29,7 @@ import de.h2b.scala.lib.simgraf.{ Point, World }
* @param p0 centre of the sign
* @param l length of the lines of the sign
*/
case class Plus private (val p0: Point, val l: Double) extends Drawable {
case class Plus (val p0: Point, val l: Double) extends Drawable {
private val l1 = Line(Point(p0.x-l/2, p0.y), Point(p0.x+l/2, p0.y))
private val l2 = Line(Point(p0.x, p0.y-l/2), Point(p0.x, p0.y+l/2))
......
......@@ -28,7 +28,7 @@ import de.h2b.scala.lib.simgraf.{ Point, World }
*
* @author h2b
*/
case class Polygonal private (val p: Seq[Point]) extends Drawable with Fillable {
case class Polygonal (val p: Seq[Point]) extends Drawable with Fillable {
def draw (w: World): Unit = w.screen.drawPolyline(p.map(w.toPixel(_)))
......
......@@ -20,11 +20,11 @@ package de.h2b.scala.lib.simgraf.shapes
import de.h2b.scala.lib.simgraf.{ Point, World }
/**
* A rectangle with diagonal opposite corners at `p1` and `p2`.
* A rectangle specified by diagonal opposite corners.
*
* @author h2b
*/
case class Rectangle private (val p1: Point, val p2: Point) extends Drawable with Fillable {
case class Rectangle (val p1: Point, val p2: Point) extends Drawable with Fillable {
def draw (w: World): Unit = w.screen.drawRectangle(w.toPixel(p1), w.toPixel(p2))
......
......@@ -78,7 +78,7 @@ trait Fillable extends Shape {
*
* @param boundssOption some enclosing rectangle or `None` for the full world
*/
class Enclosing private (private val boundsOption: Option[Rectangle]) {
class Enclosing (private val boundsOption: Option[Rectangle]) {
private def rect (w: World): Rectangle = boundsOption match {
case Some(b) b
......
......@@ -29,7 +29,7 @@ import de.h2b.scala.lib.simgraf.{ Point, World }
* @param p0 centre of the square
* @param l side length of the square
*/
case class Square private (val p0: Point, val l: Double) extends Drawable with Fillable {
case class Square (val p0: Point, val l: Double) extends Drawable with Fillable {
private val rect = Rectangle(Point(p0.x-l/2, p0.y-l/2), Point(p0.x+l/2, p0.y+l/2))
......
......@@ -27,9 +27,9 @@ import de.h2b.scala.lib.simgraf.{ Point, World }
* @constructor
*
* @param p0 lower-left corner
* @param text (`null` is allowed and has no effect)
* @param text
*/
case class Text private (p0: Point, text: String) extends Drawable {
case class Text (p0: Point, text: String) extends Drawable {
def draw (w: World): Unit = w.screen.drawText(w.toPixel(p0), text)
......
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