import javafx.embed.swing.SwingFXUtils
import javafx.scene.SnapshotParameters
import javax.imageio.ImageIO
import tornadofx.*
class MainController: Controller(){
val outPath= stringProperty(File("").absolutePath) //导出目录,默认为当前目录
val outNums= intProperty(5) //导出目录次数
}
private val c by inject<MainController>()
import javafx.scene.layout.Priority
import tornadofx.*
class SettingView : View("设置") {
private val c by inject<MainController>()
override val root = borderpane {
center = vbox(5) {
hbox(5) {
label("导出目录:")
textfield(c.outPath) {
hgrow = Priority.ALWAYS
}
}
hbox(5) {
label("导出次数:")
combobox(c.outNums, (1..100 step 2).toList())
}
}
setPrefSize(500.0, 500.0)
paddingAll = 10.0
style {
fontSize = 16.px
}
}
}
right = drawer {
item<SettingView>()
}
button("导出") {
action {
(1..c.outNums.value).map {i->
refreshGrid()
val img = r.snapshot(SnapshotParameters(), null)
ImageIO.write(SwingFXUtils.fromFXImage(img, null), "png", File(c.outPath.value+ "./schulteGrid$i.png"))
}
information("恭喜!成功导出 ${c.outNums.value} 张舒尔特方格。")
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。