本文整理汇总了Scala中javafx.application.Application类的典型用法代码示例。如果您正苦于以下问题:Scala Application类的具体用法?Scala Application怎么用?Scala Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: BootstrapApplication
//设置package包名称以及导入依赖的类
package io.scalatestfx.zzznolongerused
import java.util.concurrent.CountDownLatch
import javafx.application.Application
import javafx.stage.Stage
object BootstrapApplication {
private val launchLatch = new CountDownLatch(1)
var launched = false
def launch() {
if (!launched) {
new Thread(new Runnable() {
def run() {
Application.launch(classOf[BootstrapApplication])
}
}).start()
launchLatch.await()
launched = true
}
}
}
class BootstrapApplication extends Application {
override def start(stage: Stage) {
BootstrapApplication.launchLatch.countDown()
}
}
开发者ID:haraldmaida,项目名称:ScalaTestFX,代码行数:28,代码来源:BootstrapApplication.scala
示例2: Dragon
//设置package包名称以及导入依赖的类
package jp.qilab.aiis.fractal
import javafx.application.Application
import javafx.scene.canvas.GraphicsContext
object Dragon {
def main(args: Array[String]): Unit = {
Application.launch(classOf[DragonApp], args: _*)
}
class DragonApp extends CurveApp {
override def draw(): Unit = {
val c = new Dragon(g)
c.move(150, 300)
c.draw(13, 300, 0, 1)
}
}
}
class Dragon(g: GraphicsContext) extends Curve(g) {
val theta = math.Pi * 0.25
def draw(n: Int, len: Double, angle: Double, sw: Int): Unit = {
if (n == 1) {
forward(len, angle)
} else {
val l = len / (2 * math.cos(theta))
val a = theta * sw
draw(n - 1, l, angle - a, 1)
draw(n - 1, l, angle + a, -1)
}
}
}
开发者ID:qilab,项目名称:ml,代码行数:34,代码来源:Dragon.scala
示例3: Tree
//设置package包名称以及导入依赖的类
package jp.qilab.aiis.fractal
import javafx.application.Application
import javafx.scene.canvas.GraphicsContext
object Tree {
def main(args: Array[String]): Unit = {
Application.launch(classOf[TreeApp], args: _*)
}
class TreeApp extends CurveApp {
override def draw(): Unit = {
val c = new Tree(g)
c.move(300, 600)
c.draw(7, 450, math.Pi * -0.5, 1)
}
}
}
class Tree(g: GraphicsContext) extends Curve(g) {
def draw(n: Int, len: Double, angle: Double, sw: Int): Unit = {
// save current position
val (x, y) = (lastX, lastY)
if (n == 1) {
forward(len, angle)
} else {
val l = len / math.sqrt(2.0)
val a = math.Pi * 0.15 * sw
forward(l * 0.33, angle)
draw(n - 1, l * 0.8, angle - a, 1)
forward(l * 0.33, angle)
draw(n - 1, l * 0.7, angle + a * 1.5, -1)
forward(l * 0.33, angle)
draw(n - 1, l * 0.6, angle, 1)
}
// restore
lastX = x
lastY = y
}
}
开发者ID:qilab,项目名称:ml,代码行数:43,代码来源:Tree.scala
示例4: CurveApp
//设置package包名称以及导入依赖的类
package jp.qilab.aiis.fractal
import javafx.application.Application
import javafx.scene.Scene
import javafx.scene.canvas.Canvas
import javafx.scene.layout.StackPane
import javafx.stage.Stage
object CurveApp {
def main(args: Array[String]): Unit = {
Application.launch(classOf[CurveApp], args: _*)
}
}
class CurveApp extends Application {
val canvas = new Canvas(600, 600)
val g = canvas.getGraphicsContext2D
override def start(stage: Stage): Unit = {
val pane = new StackPane
pane.getChildren.add(canvas)
stage.setScene(new Scene(pane))
stage.show()
draw()
}
def draw(): Unit = {
val c = new Curve(g)
c.move(50, 300)
c.draw(500, 0)
}
}
开发者ID:qilab,项目名称:ml,代码行数:34,代码来源:CurveApp.scala
示例5: Koch
//设置package包名称以及导入依赖的类
package jp.qilab.aiis.fractal
import javafx.application.Application
import javafx.scene.canvas.GraphicsContext
object Koch {
def main(args: Array[String]): Unit = {
Application.launch(classOf[KochApp], args: _*)
}
class KochApp extends CurveApp {
override def draw(): Unit = {
val c = new Koch(g)
c.move(50, 300)
c.draw(5, 500, 0)
}
}
}
class Koch(g: GraphicsContext) extends Curve(g) {
val theta = math.Pi * 0.25
def draw(n: Int, len: Double, angle: Double): Unit = {
if (n == 1) {
forward(len, angle)
} else {
val l = len / (2 * math.cos(theta) + 2)
val a = theta
draw(n - 1, l, angle)
draw(n - 1, l, angle - a)
draw(n - 1, l, angle + a)
draw(n - 1, l, angle)
}
}
}
开发者ID:qilab,项目名称:ml,代码行数:36,代码来源:Koch.scala
示例6: Sierpinski
//设置package包名称以及导入依赖的类
package jp.qilab.aiis.fractal
import javafx.application.Application
import javafx.scene.canvas.GraphicsContext
object Sierpinski {
def main(args: Array[String]): Unit = {
Application.launch(classOf[SierpinskiApp], args: _*)
}
class SierpinskiApp extends CurveApp {
override def draw(): Unit = {
val c = new Sierpinski(g)
c.draw(6, 300, 300, 150)
}
}
}
class Sierpinski(g: GraphicsContext) extends Curve(g) {
def draw(n: Int, len: Double, x: Double, y: Double): Unit = {
val l = len / 2
val x1 = x - l
val x2 = x + l
val y1 = y + l * math.sqrt(3)
if (n == 1) {
g.strokeLine(x, y, x1, y1)
g.strokeLine(x1, y1, x2, y1)
g.strokeLine(x2, y1, x, y)
} else {
val l2 = l / 2
draw(n - 1, l, x, y)
draw(n - 1, l, x - l2, y + l2 * math.sqrt(3))
draw(n - 1, l, x + l2, y + l2 * math.sqrt(3))
}
}
}
开发者ID:qilab,项目名称:ml,代码行数:37,代码来源:Sierpinski.scala
示例7: TreeGenerator
//设置package包名称以及导入依赖的类
package at.fitosoft.experiments.procedural.trees
import javafx.application.Application
import javafx.scene.canvas.{Canvas, GraphicsContext}
import javafx.scene.paint.Color
import javafx.scene.{Group, Scene}
import javafx.stage.Stage
import at.fitosoft.experiments.procedural.Seed
object TreeGenerator {
def main(args: Array[String]): Unit = {
Application.launch(classOf[TreeGenerator], args: _*)
}
}
class TreeGenerator extends Application {
val Zoom = 20
override def start(primaryStage: Stage): Unit = {
val tree1 = Tree(Seed(982734981))
println(s"tree1 = $tree1")
val tree2 = Tree(Seed(609804563))
println(s"tree2 = $tree2")
primaryStage.setTitle("Hello Trees!")
val root: Group = new Group
val canvas: Canvas = new Canvas(1024, 768)
val gc: GraphicsContext = canvas.getGraphicsContext2D
gc.setStroke(Color.BROWN)
gc.setLineWidth(5)
drawTree(tree1, 250, 650, gc)
drawTree(tree2, 550, 650, gc)
root.getChildren.add(canvas)
primaryStage.setScene(new Scene(root))
primaryStage.show()
}
def drawTree(tree1: Tree, startX: Int, startY: Int, gc: GraphicsContext): Unit = {
gc.strokeLine(startX, startY, startX, startY - tree1.trunkHeight * Zoom)
}
}
开发者ID:Fitosoft,项目名称:Experiments,代码行数:49,代码来源:TreeGenerator.scala
示例8: Main
//设置package包名称以及导入依赖的类
package views
import javafx.application.Application
import javafx.stage.Stage
import javafx.scene.Scene
import javafx.scene.layout.BorderPane
class Main extends Application {
override def start(stage: Stage) {
stage.setTitle("pafelog")
stage.setScene(new Scene(new BorderPane {
setTop(Menus)
setCenter(new BorderPane {
setTop(Tools)
setCenter(Table)
})
}))
stage.setWidth(640)
stage.setHeight(480)
stage.show
}
}
object Main {
def main(args: Array[String]) {
Application.launch(classOf[Main], args: _*)
}
}
开发者ID:nextzlog,项目名称:pafe,代码行数:29,代码来源:Main.scala
示例9: DatePickerSample
//设置package包名称以及导入依赖的类
package net.sf.hajuergens.format
package net.sf.hajuergens.format
import java.util.Locale
import javafx.application.Application
import javafx.scene.Scene
import javafx.scene.control.{DatePicker => FxDatePicer}
import javafx.scene.layout.StackPane
import javafx.stage.Stage
object DatePickerSample {
locally {
Locale.setDefault(Locale.US)
}
def main(args: Array[String]) {
val appClass : Class[_ <: Application]= classOf[DatePickerSample]
Application.launch(appClass, args: _*)
}
}
class DatePickerSample extends Application {
override def start(primaryStage: Stage): Unit = {
val datePicker = new FxDatePicer()
datePicker.setConverter(new StringConverterLocalDate(datePicker.getChronology))
primaryStage.setScene(new Scene(new StackPane(Array(datePicker): _*), 375, 120))
primaryStage.show()
}
}
开发者ID:hjuergens,项目名称:cascading.formatters,代码行数:33,代码来源:DatePickerSample.scala
示例10: JavaFXInitializer
//设置package包名称以及导入依赖的类
package com.reactific.jfxtend
import org.specs2.mutable.{Before, Specification}
import javafx.application.Application
import javafx.stage.Stage
class JavaFXInitializer(val barrier : Object) extends Application {
var stage : Stage = null
def start(primaryStage : Stage) : Unit = {
stage = primaryStage
this.synchronized {
barrier.notify()
}
}
}
abstract class JFXtendSpecification extends Specification with Before {
private var _stage : Stage = null
def stage : Option[Stage] = Option(_stage)
def before : Any = {
val barrier = new Object()
val initializer = new JavaFXInitializer(barrier)
val task = new Runnable {
def run : Unit = {
Application.launch(classOf[JavaFXInitializer])
}
}
val thread = new Thread(task, "JavaFX Init Thread")
thread.setDaemon(true)
thread.start()
initializer.synchronized {
barrier.wait()
}
_stage = initializer.stage
success
}
}
开发者ID:reactific,项目名称:jfxtend,代码行数:45,代码来源:JFXtendSpecification.scala
注:本文中的javafx.application.Application类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论