Commit 4780058b authored by h2b's avatar h2b

Documentation updated.

parent 0ae37930
......@@ -68,19 +68,19 @@ Various factory methods are provided that construct grid layouts from a sample c
## Events
Since version 1.2.0 an event package is available that constitutes a high-level abstraction of input (e.g., keyboard or mouse) events using actor event streams.
Since version 1.2.0 an event package is available that constitutes a high-level abstraction of input (e.g., keyboard or mouse) events using an actor event bus.
Such events, if triggered by the drivers, are published to the global event stream of that package and can be retrieved by subscribing to its `stream` object.
Also, there is a `Subscriber` actor that can be used to handle events. It's companion object defines a `ref` method with a `PartialFunction[Event, Unit]` as parameter that returns an actor reference.
Also, there is a `Subscriber` actor that can be used to handle events. Since version 1.3.0, it's companion object defines `on` methods for screens and worlds with a `PartialFunction[Event, Unit]` as a parameter.
So, for example, you just can write
Subscriber.ref {
case e: Event ⇒ println(e)
}
Subscriber.on(world) {
case e: Event ⇒ println(e)
}
to print out all occurring events.
to print out all events occurring on the specified `world`.
To get the triggering enabled, the `withEvents` factory methods of `World` or `Screen` have to be used.
......@@ -109,3 +109,21 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
## Major Changes
### Version 1.3.0
As of version 1.3.0, events are handled by a specialised `ScreenEventBus` instead of the standard Akka `EventStream`. This only has a slight impact on the API so that the major version of this project hasn't been promoted.
Anyway, for reference here are the substantial changes.
* The `AwtEventDriver` now can only be mixed into a class that is a subtype of `Screen`.
* The `ScreenDriver` factory methods have been removed.
* The type of the `event.stream` value changed from `EventStream` to `ScreenEventBus` (both are implementations of `EventBus`) in order to handle events classified by screen.
* The global `event.publisher` actor now only publishes events that are not associated with a screen rather than publishing all events. The drivers use dedicated publishers for each screen, respectively.
* Subscriber factory methods are provided for events of a specified screen or world. The `ref` method still is there, but receives no events from this package anymore.
......@@ -17,8 +17,7 @@
*/
package de.h2b.scala.lib.simgraf.driver
import java.awt.{ Color => AwtColor, Dimension, FileDialog, Frame, Graphics,
GraphicsEnvironment, Rectangle, RenderingHints }
import java.awt.{ Color => AwtColor, Dimension, FileDialog, Frame, Graphics, GraphicsEnvironment, Rectangle, RenderingHints }
import java.awt.event.{ ActionEvent, ActionListener, WindowEvent }
import java.awt.image.BufferedImage
import java.io.{ File, IOException }
......
......@@ -18,7 +18,6 @@
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.
......@@ -44,7 +43,8 @@ import de.h2b.scala.lib.simgraf.layout.Cell
* @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 = "") {
abstract class ScreenDriver protected (val p0: Pixel, val width: Int,
val height: Int, val title: String = "") {
/**
* color to be used for the next operations (except for those that use
......
......@@ -69,7 +69,7 @@ object Subscriber {
system.actorOf(Props(new Subscriber(Some(screen))(handler)))
/**
* Subscribes to events of a specified screen.
* Subscribes to events of a specified world.
*
* @param world the world to be listened for events
* @param handler partial function handling received events
......
......@@ -22,26 +22,25 @@ import akka.event.EventBus
/**
* This package constitutes a high-level abstraction of input (e.g.,
* keyboard or mouse) events using actor event streams.
* keyboard or mouse) events using an actor event bus.
*
* Such events, if triggered by the drivers, are published to the global
* event stream of this package and can be retrieved by subscribing to the
* `stream` object.
*
* Also, there is a `Subscriber` actor that can be used to handle events.
* It's companion object defines a `ref` method with a
* `PartialFunction[Event, Unit]` as parameter that returns an actor
* reference.
* Since version 1.3.0, it's companion object defines `on` methods for screens
* and worlds with a `PartialFunction[Event, Unit]` as a parameter.
*
* So, for example, you just can write
*
* {{{
* Subscriber.ref {
* case e: Event ⇒ println(e)
* }
* Subscriber.on(world) {
* case e: Event ⇒ println(e)
* }
* }}}
*
* to print out all occurring events.
* to print out all events occurring on the specified `world`.
*
* To get the triggering enabled, the `withEvents` factory methods of
* `World` or `Screen` have to be used.
......
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