Skip to content

Instantly share code, notes, and snippets.

View PragmaticCoding's full-sized avatar

Dave Barrett PragmaticCoding

View GitHub Profile
@PragmaticCoding
PragmaticCoding / AreaChartDemo.java
Created March 15, 2022 21:34
Demo Showing Custom Node for Z-Graph
public class AreaChartDemo extends Application {
public static void main(String[] args) {
launch(args);
}
private Point2D firstClick = null;
private float SND(double x) {
hbox.children += createConfiguredImageView(path)
private fun createConfiguredImageView(path: URI) = ImageView(Image(path.toExternalForm())).apply {
fitHeight = 600.0
isPreserveRatio = true
opacity = 0.7
}
val imageView = ImageView(Image(path.toExternalForm()))
imageView.fitHeight = 600.0
imageView.isPreserveRatio = true
imageView.opacity = 0.7
hbox.getChildren().add(imageView)
hbox.children += ImageView(Image(path.toExternalForm())).apply {
fitHeight = 600.0
isPreserveRatio = true
opacity = 0.7
}
fun handleNullable() {
val customer: Customer? = database.fetchCustomer(customerId)
val customerName:String = customer?.let{it.getName()}?: "Mr. Nobody"
println("The customer name is $customerName")
}
fun betterHandleNullable() {
println("The customer name is " + database.fetchCustomer(customerId)?.name ?: "Mr. Nobody")
}
class Sample {
var intField: Int = 0
}
fun UseSample() {
val sample = Sample()
sample.inField = 3
println(sample.intField)
}
@PragmaticCoding
PragmaticCoding / gist:aee9580aad1e0d3a7347eb742f82ddda
Last active November 26, 2021 20:14
Simple Kotlin Class Showing Getter and Setter Use
class Sample {
var intField: Int = 0
}
fun UseSample() {
val sample = Sample()
sample.setIntField(3)
println(sample.getIntField())
}
@PragmaticCoding
PragmaticCoding / gist:a55821e44ddb909e290a05491bfaad4f
Created November 26, 2021 19:48
Simple Class With 1 Field + Getter + Setter
class Sample {
private int intField = 0;
public int getIntField() {
return intField;
}
public void setIntField(int newValue) {
intField = newValue;
@PragmaticCoding
PragmaticCoding / gist:d301cb308d2b4741220c6146cf3ba69c
Last active January 13, 2022 07:11
Intellij Live Template for JavaFX Property Bean
private val _$PROPERTY$: ObjectProperty<$PROPERTY_TYPE$> = SimpleObjectProperty($INIT_VAL$)
var $PROPERTY$: $PROPERTY_TYPE$
get() = _$PROPERTY$.get()
set(value) = _$PROPERTY$.set(value)
fun $PROPERTY$Property() = _$PROPERTY$
@PragmaticCoding
PragmaticCoding / gist:f6d3bd9dfc261b6d411d7945172d5833
Last active January 13, 2022 07:10
JavaFX Property "Bean" Implemented in Kotlin
class KotlinClass() {
private val _nickName: ObjectProperty<String> = SimpleObjectProperty("")
var nickName: String
get() = _nickName.get()
set(value) = _nickName.set(value)
fun nickNameProperty() = _nickName
}
fun main(args: Array<String>) {