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 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 colors

    This package contains Color constants.

    This package contains Color constants. They cover all the colors listed in the W3C’s CSS Color Module specification (July 5th, 2017); there are some additional ones as well.

    All the colors are fully opaque, except Transparent, which is fully transparent.

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

    Definition Classes
    gui
  • package event

    This package exists in order to provide aliases to event classes in Swing and to add some methods to Swing’s InputEvent via o1.gui.event.ConvenientInputEvent.

    This package exists in order to provide aliases to event classes in Swing and to add some methods to Swing’s InputEvent via o1.gui.event.ConvenientInputEvent.

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

    Definition Classes
    gui
  • package layout

    The package o1.gui.layout contains utilities that make it more convenient to lay out components in simple GridBagPanels from Scala's Swing library.

    The package o1.gui.layout contains utilities that make it more convenient to lay out components in simple GridBagPanels from Scala's Swing library. These utilities are used internally by some of the given GUIs in O1.

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

    Definition Classes
    gui
  • Animation
  • Color
  • DefaultFrameSettings
  • Dialog
  • Escapable
  • Pic
  • SimpleFrame
  • TerminatesOnClose
  • View
  • immutable
  • mutable
o

o1.gui

Dialog

object Dialog

This object provides convenience methods for displaying messages and reading user input via simple Swing dialogs.

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

Type Members

  1. sealed trait Position extends Product with Serializable

    Represents the positioning policy of an input dialog.

    Represents the positioning policy of an input dialog. Used with the methods on Dialog. @see RelativeTo, Centered

  2. final case class RelativeTo(locator: Component) extends Position with Product with Serializable

    A positioning policy that places the dialog near another Swing component.

    A positioning policy that places the dialog near another Swing component. An alternative to Centered.

    locator

    the Swing component in front of which the Dialog should appear

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  6. def display(message: String, position: Position): Unit

    Displays a textual message in a Swing dialog.

    Displays a textual message in a Swing dialog.

    message

    a message to the end user

    position

    the location of the dialog onscreen

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. def requestAnyDouble(prompt: String, position: Position): Option[Double]

    Asks the user to input a decimal number by typing it in a Swing dialog.

    Asks the user to input a decimal number by typing it in a Swing dialog. Keeps prompting the user with new dialogs until it receives text interpretable as a Double or the user cancels.

    prompt

    a message that prompts the user for input

    position

    the location of the dialog(s) onscreen

    returns

    the user input, converted from the textual input with toDouble; None if the user cancelled

  16. def requestAnyInt(prompt: String, errorMessage: String, position: Position): Option[Int]

    Asks the user to input an integer by typing it in a Swing dialog.

    Asks the user to input an integer by typing it in a Swing dialog. Keeps prompting the user with new dialogs until it receives text interpretable as a Double or the user cancels.

    prompt

    a message that prompts the user for input

    errorMessage

    a prefix added to prompt on each request except the first

    position

    the location of the dialog(s) onscreen

    returns

    the user input, converted from the textual input with toInt; None if the user cancelled

  17. def requestAnyLine(prompt: String, position: Position): Option[String]

    Asks the user to input a line of text via a Swing dialog; accepts any string as input.

    Asks the user to input a line of text via a Swing dialog; accepts any string as input.

    prompt

    a message that prompts the user for input

    position

    the location of the dialog onscreen

    returns

    the string entered by the user; None if they cancelled

  18. def requestChoice[Choice](prompt: String, options: Seq[Choice], position: Position): Option[Choice]

    Asks the user to choose among the given options via a Swing dialog.

    Asks the user to choose among the given options via a Swing dialog.

    prompt

    a message that prompts the user for input

    options

    any objects that the user will choose one of; their toStrings will show in the input dialog

    position

    the location of the dialog onscreen

    returns

    one of the options as chosen by the user; None if the user cancelled

  19. def requestDouble(prompt: String, isOK: (Double) => Boolean, errorMessage: String, position: Position): Option[Double]

    Asks the user to input a decimal number by typing it in a Swing dialog.

    Asks the user to input a decimal number by typing it in a Swing dialog. Keeps prompting the user with new dialogs until it receives a valid input or the user cancels. An input is invalid if isOK(inputString.toDouble) returns false or fails with an exception.

    prompt

    a message that prompts the user for input

    isOK

    a function applied to any actual Double input to check if it’s valid

    errorMessage

    a prefix added to prompt on each request except the first

    position

    the location of the dialog(s) onscreen

    returns

    the user input, converted from the textual input with toDouble; None if the user cancelled

  20. def requestInput[Input](prompt: String, convert: (String) => Input, isOK: (Input) => Boolean, errorMessage: String, position: Position): Option[Input]

    Asks the user to input a line of text via a Swing dialog and interprets the input with the given functions.

    Asks the user to input a line of text via a Swing dialog and interprets the input with the given functions. Keeps prompting the user with new dialogs until it receives a valid input or the user cancels. An input is invalid if isOK(convert(input)) returns false or fails with an exception.

    Input

    the type of the user input (converted from a string to this type)

    prompt

    a message that prompts the user for input

    convert

    a function applied to the input string to produce the actual return value

    isOK

    a function applied to the input string to check if it’s valid

    errorMessage

    a prefix added to prompt on each request except the first

    position

    the location of the dialog(s) onscreen

    returns

    a valid user input (converted from a string); None if the user cancelled

  21. def requestInt(prompt: String, isOK: (Int) => Boolean, errorMessage: String, position: Position): Option[Int]

    Asks the user to input an integer by typing it in a Swing dialog.

    Asks the user to input an integer by typing it in a Swing dialog. Keeps prompting the user with new dialogs until it receives a valid input or the user cancels. An input is invalid if isOK(inputString.toInt) returns false or fails with an exception.

    prompt

    a message that prompts the user for input

    isOK

    a function applied to any actual integer input to check if it’s valid

    errorMessage

    a prefix added to prompt on each request except the first

    position

    the location of the dialog(s) onscreen

    returns

    the user input, converted from the textual input with toInt; None if the user cancelled

  22. def requestNonEmptyLine(prompt: String, errorMessage: String, position: Position): Option[String]

    Asks the user to input a non-empty line of text via a Swing dialog.

    Asks the user to input a non-empty line of text via a Swing dialog. Keeps prompting the user with new dialogs until it receives a non-empty string as input or the user cancels.

    prompt

    a message that prompts the user for input

    errorMessage

    a prefix added to prompt on each request except the first

    position

    the location of the dialog(s) onscreen

    returns

    the user input, a non-empty string; None if the user cancelled

  23. def requestString(prompt: String, isOK: (String) => Boolean, errorMessage: String, position: Position): Option[String]

    Asks the user to input a line of text via a Swing dialog.

    Asks the user to input a line of text via a Swing dialog. Keeps prompting the user with new dialogs until it receives a valid input or the user cancels. An input is invalid if isOK(input.trim) returns false or fails with an exception.

    prompt

    a message that prompts the user for input

    isOK

    a function applied to the input string to check if it’s valid

    errorMessage

    a prefix added to prompt on each request except the first

    position

    the location of the dialog(s) onscreen

    returns

    a valid user input, trimmed for whitespce; None if the user cancelled

  24. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  25. def toString: String
    Definition Classes
    AnyRef → Any
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. object Centered extends Position with Product with Serializable

    A positioning policy that centers the dialog onscreen.

    A positioning policy that centers the dialog onscreen. An alternative to RelativeTo.

  30. object RelativeTo extends Product with Serializable

    A companion object with factory methods.

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Ungrouped