Viewer

org.appliedtopology.tda4j.plot.Viewer
object Viewer extends MainRoutes

The live viewer: one browser tab that shows every plot view()ed from this JVM, newest first, as it arrives.

The first view() starts a small web server on 127.0.0.1 (port 8337, or a free one when that is taken; set another with the system property tda4j.plot.port or the environment variable TDA4J_PLOT_PORT) and opens the page in the default browser. Where there is no desktop to open it on (a remote machine, a container), it prints the address instead: open it yourself, forwarding the port if needed (ssh -L 8337:localhost:8337 host). Set TDA4J_PLOT_BROWSER=none (or the system property tda4j.plot.browser=none) to never open a browser. The page keeps a list of every plot shown, and reconnects by itself when the JVM restarts on the same port.

Only programs on the same machine can reach 127.0.0.1. Where the page is read from somewhere else and the port cannot be forwarded (a container that publishes the port to its host), name the address to listen on with the system property tda4j.plot.host or the environment variable TDA4J_PLOT_HOST; 0.0.0.0 is every address of the machine. The page has no password: whoever reaches the port sees the plots.

The server's threads are daemon threads: a REPL or script exits as usual, and the page then waits for a new one. Nothing here uses Swing or AWT windows, so it works the same from sbt console, scala and scala-cli on any OS.

Attributes

Experimental
true
Source
Viewer.scala
Graph
Supertypes
class MainRoutes
trait Routes
class Main
class Object
trait Matchable
class Any
Show all
Self type
Viewer.type

Members list

Value members

Concrete methods

def browse(address: String): Boolean

Opens address in the default browser, unless browsers are turned off (TDA4J_PLOT_BROWSER=none, or the system property tda4j.plot.browser=none) or there is no desktop to open it on. Returns whether it did.

Opens address in the default browser, unless browsers are turned off (TDA4J_PLOT_BROWSER=none, or the system property tda4j.plot.browser=none) or there is no desktop to open it on. Returns whether it did.

Attributes

Source
Viewer.scala
def events(): Response[Data]

Attributes

Source
Viewer.scala
def index(): Response[String]

Attributes

Source
Viewer.scala
def list(): Response[String]

Attributes

Source
Viewer.scala
def plot(id: String): Response[String]

Attributes

Source
Viewer.scala
def show(plot: Plot): Unit

Shows plot in the viewer's tab (starting the server and opening the tab the first time).

Shows plot in the viewer's tab (starting the server and opening the tab the first time).

Attributes

Source
Viewer.scala
def stop(): Unit

Stops the server; the next view() starts a new one.

Stops the server; the next view() starts a new one.

Attributes

Source
Viewer.scala
def url: String

The page's address, starting the server if it is not running yet.

The page's address, starting the server if it is not running yet.

Attributes

Source
Viewer.scala

Inherited methods

def allRoutes: Seq[Routes]

Attributes

Inherited from:
MainRoutes
Source
Main.scala
def caskMetadata: RoutesEndpointsMetadata[this.type]

Attributes

Inherited from:
Routes
Source
Routes.scala
def createActorContext: Simple

Attributes

Inherited from:
Main
Source
Main.scala
def createExecutionContext: ExecutionContextExecutorService

Attributes

Inherited from:
Main
Source
Main.scala
def debugMode: Boolean

Attributes

Inherited from:
Main
Source
Main.scala
def decorators: Seq[Decorator[_, _, _, _]]

Attributes

Inherited from:
Routes
Source
Routes.scala
def defaultHandler: HttpHandler

Attributes

Inherited from:
Main
Source
Main.scala
def dispatchTrie: DispatchTrie[Map[String, (Routes, EndpointMetadata[_])]]

Attributes

Inherited from:
Main
Source
Main.scala
def handleEndpointError(routes: Routes, metadata: EndpointMetadata[_], e: Error, req: Request): Raw

Attributes

Inherited from:
Main
Source
Main.scala
def handleMethodNotAllowed(req: Request): Raw

Attributes

Inherited from:
Main
Source
Main.scala
def handleNotFound(req: Request): Raw

Attributes

Inherited from:
Main
Source
Main.scala
def host: String

Attributes

Inherited from:
Main
Source
Main.scala
def main(args: Array[String]): Unit

Attributes

Inherited from:
Main
Source
Main.scala
def mainDecorators: Seq[Decorator[_, _, _, _]]

Attributes

Inherited from:
Main
Source
Main.scala
def port: Int

Attributes

Inherited from:
Main
Source
Main.scala
def verbose: Boolean

Attributes

Inherited from:
Main
Source
Main.scala

Inherited fields

val executionContext: ExecutionContextExecutorService

Attributes

Inherited from:
Main
Source
Main.scala

Implicits

Inherited implicits

implicit val actorContext: Context

Attributes

Inherited from:
Main
Source
Main.scala
implicit def log: Logger

Attributes

Inherited from:
Main
Source
Main.scala