Packages

  • package root
    Definition Classes
    root
  • package o1

    O1Library is a toolkit designed for the course Programming 1 (a.k.a. O1) at Aalto University.

    O1Library is a toolkit designed for the course Programming 1 (a.k.a. O1) at Aalto University. It contains an assortment of tools; most prominently, it provides a framework for simple graphical programming and utilities for playing sound.

    This is the front page of O1Library’s documentation. However, this is probably not the best place to start learning about O1Library as a student. That’s because the relevant content of this library is introduced bit by bit in the chapters of O1’s custom ebook alongside the associated programming concepts and assignments.

    You may still find this documentation useful as a reference. You can also find some optional content here that you may wish to try.

    This front page lists the content available in the top-level package called simply o1. These tools are available with the simple command import o1._ in your Scala programs. Some of them you’ll use a lot; some of them you won’t necessarily need at all.

    The tools listed here are actually implemented in a number of subpackages (o1.gui, o1.sound, etc.); what you see here are just “shortcut aliases” to those actual implementations. The aliases are here to make that convenient import command work and to provide you with this list of links to some of the more commonly used tools in O1Library. The subpackages also contain additional content not listed here.

    O1Library has been developed by Aleksi Lukkarinen and Juha Sorva. Several of the key components in o1.gui and o1.world are built upon Aleksi’s Scala Media Computation Library. Some parts of O1Library draw inspiration from the “teachpacks” of the Racket programming language.

    We are grateful to Riku Autio, Joonatan Honkamaa, Juhani Numminen, Leo Varis, Veera Kahva, and anonymous students for bug reports and fixes. We thank Otto Seppälä for helpful discussions.

    Definition Classes
    root
  • package grid

    This package contains tools for working with grid-like two-dimensional structures.

    This package contains tools for working with grid-like two-dimensional structures.

    The contents of this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

    Definition Classes
    o1
  • package gui

    This package contains tools for building simple GUIs.

    This package contains tools for building simple GUIs. The toolkit is particularly well suited to constructing GUIs that display information as 2D images and/or geometric shapes. It is not designed for demanding graphical needs that call for high efficiency. Some of the tools in this package are built on the Swing GUI library, and the two libraries can be used in combination.

    Some of the types in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._. Some of the package contents are not available in the top-level package or included in this documentation.

    Please note: One of this package’s key components (views) comes in multiple varieties, which which are defined in the subpackages o1.gui.mutable and o1.gui.immutable and not listed below. The View that is most commonly used in O1 (and aliased as o1.View in the top-level package) is o1.gui.mutable.ViewFrame.

    Definition Classes
    o1
  • package sound

    Please see one of the two subpackages:

    Please see one of the two subpackages:

    • o1.sound.midi for MIDI sound described in terms of notes, instruments, and other directives
    • o1.sound.sampled for working with recorded sound samples.
    Definition Classes
    o1
  • package util

    The package o1.util contains miscellaneous tools that are used internally by some of the given programs in O1 for added convenience.

    The package o1.util contains miscellaneous tools that are used internally by some of the given programs in O1 for added convenience.

    NOTE TO STUDENTS: In this course, you don't need to understand how this package works or can be used.

    This documentation lists only some of the tools in the package. The listed tools are largely a mix of:

    • functions for simple I/O from files and URLs;
    • aliases for easy access (via import o1.util._) to some of the tools from scala.util; and
    • implicit classes that add a few convenience methods to selected types from the Scala API.
    Definition Classes
    o1
  • package world

    This package contains tools for locations and movement in two-dimensional space.

    This package contains tools for locations and movement in two-dimensional space.

    The tools in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

    The subpackage o1.world.objects contains additional tools for representing entities that reside within two-dimensional spaces.

    Definition Classes
    o1
  • package objects

    This package contains tools for representing objects that exist in two-dimensional space.

    This package contains tools for representing objects that exist in two-dimensional space. In particular, it defines:

    • the Anchor type: an anchor is the point where an object connects to its environment; and
    • a number of traits (HasPos, HasVelocity, etc.) the classes of an application can mix in to gain access to various convenience methods.

    NOTE TO STUDENTS: In this course, you don't need to understand how this package works or can be used. That being said, some students may wish to experiment with some of its contents. Many of the traits in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

  • Bounds
  • Direction
  • Pos
  • Velocity
p

o1

world

package world

This package contains tools for locations and movement in two-dimensional space.

The tools in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

The subpackage o1.world.objects contains additional tools for representing entities that reside within two-dimensional spaces.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. world
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package objects

    This package contains tools for representing objects that exist in two-dimensional space.

    This package contains tools for representing objects that exist in two-dimensional space. In particular, it defines:

    • the Anchor type: an anchor is the point where an object connects to its environment; and
    • a number of traits (HasPos, HasVelocity, etc.) the classes of an application can mix in to gain access to various convenience methods.

    NOTE TO STUDENTS: In this course, you don't need to understand how this package works or can be used. That being said, some students may wish to experiment with some of its contents. Many of the traits in this package have aliases in the top-level package o1, so they are accessible to students simply via import o1._.

Type Members

  1. final case class Bounds(left: Double, top: Double, width: Double, height: Double) extends Product with Serializable

    A Bounds represents the dimensions of a rectangular area in two-dimensional space.

    A Bounds represents the dimensions of a rectangular area in two-dimensional space.

    Bounds objects are immutable. They assume a space in which x coordinates increase rightwards and y coordinates downwards.

    This class has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

    left

    the x coordinate of the left edge of the Bounds

    top

    the y coordinate of the top edge of the Bounds

    width

    the width of the Bounds (the distance from its left edge to its right edge)

    height

    the height of the Bounds (the distance from its top edge to its bottom edge)

  2. sealed case class Direction extends Product with Serializable

    Each instance of this class represents a direction on a two-dimensional plane.

    Each instance of this class represents a direction on a two-dimensional plane. A direction consists of two components: dx and dy, each of which is a number between -1.0 and +1.0 (inclusive). dx indicates the degree to which the x coordinate changes when moving in that direction; dy is the same for the y coordinate. The x coordinate increases rightwards and y downwards.

    For example, moving straight rightwards can be thought of a moving in a Direction with a dx of +1.0 and a dy of 0.0; by comparison, the upward direction would have a dx of 0.0 and a dy of -1.0. . Diagonals have non-zero values for both dx and dy.

    The dx and dy of any Direction always sum up to (roughly) 1.0, with the exception of the special value NoDirection which represents the lack of a direction and as zero for both components. (In this, a Direction is different than a Velocity, which is a combination of a direction of movement and a speed.)

    You don’t instantiate Direction directly; instead, you create Directions with the methods on the companion object. Among other things, you can:

    • construct a direction from two differences between coordinates, as in Direction.fromDeltas(-100, 50); or
    • create a direction that corresponds to a given angle, as in Direction.fromDegrees(60) and Direction.fromRadians(-scala.math.Pi / 4).

    Some of the methods of a Direction object also create and return new Directions, as does the directionOf method on Pos objects. Moreover, the companion object of this class has a few predefined Direction constants: Up, Down, Left, Right, and NoDirection.

    Direction objects are immutable.

    This class has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

  3. final case class Pos(x: Double, y: Double) extends Product with Serializable

    Each instance of this class represents a location on a two-dimensional plane.

    Each instance of this class represents a location on a two-dimensional plane. A Pos object is essentially a pair of two coordinates, x and y. Pos objects are immutable.

    This class has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

    x

    the x coordinate of the Pos

    y

    the y coordinate of the Pos

  4. final case class Velocity(direction: Direction, speed: Double) extends Product with Serializable

    Each instance of this class represents movement in the context of a two-dimensional plane.

    Each instance of this class represents movement in the context of a two-dimensional plane. A velocity is a combination of a Direction of movement with a speed (a non-negative Double).

    Another way to think about a Velocity is to divide it in two components: dx and dy. dx indicates the amount (and direction) of movement along the x axis; dy is the same for the y axis. The x coordinate increases rightwards and y downwards. For instance, a velocity with a dx of 10 and a dy of zero indicates rightward movement, and a velocity with a dx of -100 and a dy of -100 indicates faster movement leftwards and upwards.

    There are many ways to create a Velocity using the methods on the companion object. Among other things, you can:

    • construct a velocity from a direction and a (positive or zero) speed, as in Velocity(Direction.Left, 50);
    • construct a direction from dx and dy, as in Velocity(-100, 50); or
    • determine the velocity needed to go from one Pos to another in a single unit of time, as in Velocity.between(pos1, pos2).

    Many of the methods on Velocity objects also create and return new velocities.

    Velocity objects are immutable.

    This class has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

    direction

    the direction of movement

    speed

    the speed of movement; this cannot be negative

Value Members

  1. object Bounds extends Serializable

    This companion object of class Bounds exists to make creating Bounds objects a bit more convenient.

    This companion object of class Bounds exists to make creating Bounds objects a bit more convenient.

    The object has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

  2. object Direction extends Serializable

    This companion object of class Direction provides some constants of type Direction and methods for creating new Direction instances.

    This companion object of class Direction provides some constants of type Direction and methods for creating new Direction instances.

    The object has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

  3. object Pos extends Serializable

    This companion object of class Pos provides alternative methods for creating new Pos objects.

    This companion object of class Pos provides alternative methods for creating new Pos objects. It has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

  4. object Velocity extends Serializable

    This companion object of class Velocity exists primarily to provide convenience methods for creating new instances of Velocity.

    This companion object of class Velocity exists primarily to provide convenience methods for creating new instances of Velocity.

    The object has an alias in the top-level package o1, so it’s accessible to students simply via import o1._.

Inherited from AnyRef

Inherited from Any

Ungrouped