-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dependency): add ScalaFX and JavaFX dependencies
- Loading branch information
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package javafx | ||
|
||
import utility.OS | ||
import utility.OS.OSType | ||
|
||
/** | ||
* Extension for JavaFX. | ||
*/ | ||
object JavaFX { | ||
private val classifiers: Map<OSType, String> = mapOf( | ||
OSType.Linux to "linux", | ||
OSType.Mac to "mac", | ||
OSType.Windows to "win", | ||
) | ||
|
||
/** @return the classifier for javafx artifacts. */ | ||
fun getClassifier(): String = classifiers.getValue(OS.getType()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package utility | ||
|
||
/** | ||
* OS utility functions. | ||
*/ | ||
object OS { | ||
private val osName = System.getProperty("os.name") | ||
|
||
/** Type of operative system. */ | ||
public enum class OSType { Linux, Mac, Windows } | ||
|
||
/** @return the string identifier of this operative system. */ | ||
fun getString(): String = this.osName | ||
|
||
/** @return the type of operative system. */ | ||
fun getType(): OSType = when { | ||
this.osName.startsWith("Linux") -> OSType.Linux | ||
this.osName.startsWith("Mac") -> OSType.Mac | ||
this.osName.startsWith("Windows") -> OSType.Windows | ||
else -> throw UnsupportedOSError("Could not infer the type of operative system.") | ||
} | ||
|
||
private data class UnsupportedOSError(override val message: String) : Error(message) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
chess/src/main/scala/io/github/chess/viewcontroller/ScalaFXHelloWorld.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* MIT License | ||
* Copyright (c) 2023 Cesario Jahrim Gabriele & Derevyanchenko Maxim & Felice Mirko & Kentpayeva Madina | ||
* | ||
* Full license description available at: https://github.com/jahrim/PPS-22-chess/blob/master/LICENSE | ||
*/ | ||
package io.github.chess.viewcontroller | ||
|
||
import scalafx.application.JFXApp3 | ||
import scalafx.geometry.Insets | ||
import scalafx.scene.Scene | ||
import scalafx.scene.effect.DropShadow | ||
import scalafx.scene.layout.HBox | ||
import scalafx.scene.paint.Color._ | ||
import scalafx.scene.paint._ | ||
import scalafx.scene.text.Text | ||
|
||
object ScalaFXHelloWorld extends JFXApp3: | ||
override def start(): Unit = | ||
stage = new JFXApp3.PrimaryStage: | ||
// initStyle(StageStyle.Unified) | ||
title = "ScalaFX Hello World" | ||
scene = new Scene: | ||
fill = Color.rgb(38, 38, 38) | ||
content = new HBox: | ||
padding = Insets(50, 80, 50, 80) | ||
children = Seq( | ||
new Text { | ||
text = "Scala" | ||
style = "-fx-font: normal bold 100pt sans-serif" | ||
fill = new LinearGradient(endX = 0, stops = Stops(Red, DarkRed)) | ||
}, | ||
new Text { | ||
text = "FX" | ||
style = "-fx-font: italic bold 100pt sans-serif" | ||
fill = new LinearGradient( | ||
endX = 0, | ||
stops = Stops(White, DarkGray) | ||
) | ||
effect = new DropShadow { | ||
color = DarkGray | ||
radius = 15 | ||
spread = 0.25 | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters