Made class and methods overridable

This commit is contained in:
dankito 2020-05-24 19:28:02 +02:00
parent 7167d6e59c
commit 78730d53ea
1 changed files with 16 additions and 16 deletions

View File

@ -15,20 +15,20 @@ import net.dankito.utils.javafx.ui.extensions.setBackgroundToColor
import tornadofx.* import tornadofx.*
class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() { open class ChipTanFlickerCodeView(protected val flickerCode: FlickerCode): View() {
companion object { companion object {
private const val ChangeSizeStripeHeightStep = 7.0 const val ChangeSizeStripeHeightStep = 7.0
private const val ChangeSizeStripeWidthStep = 2.0 const val ChangeSizeStripeWidthStep = 2.0
private const val ChangeSizeSpaceBetweenStripesStep = 1.0 const val ChangeSizeSpaceBetweenStripesStep = 1.0
const val MinFlickerCodeViewWidth = 124.0 + ChangeSizeStripeWidthStep + ChangeSizeSpaceBetweenStripesStep // below space between stripes aren't visible anymore const val MinFlickerCodeViewWidth = 124.0 + ChangeSizeStripeWidthStep + ChangeSizeSpaceBetweenStripesStep // below space between stripes aren't visible anymore
const val MaxFlickerCodeViewWidth = 1000.0 // what is a senseful value? const val MaxFlickerCodeViewWidth = 1000.0 // what is a senseful value?
private const val ChangeFrequencyStep = 5 const val ChangeFrequencyStep = 5
private const val IconWidth = 26.0 const val IconWidth = 26.0
private const val IconHeight = 26.0 const val IconHeight = 26.0
} }
@ -161,7 +161,7 @@ class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() {
} }
private fun paintFlickerCode(step: Array<Bit>) { protected open fun paintFlickerCode(step: Array<Bit>) {
stripe1.set(step[0] == Bit.High) stripe1.set(step[0] == Bit.High)
stripe2.set(step[1] == Bit.High) stripe2.set(step[1] == Bit.High)
stripe3.set(step[2] == Bit.High) stripe3.set(step[2] == Bit.High)
@ -169,20 +169,20 @@ class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() {
stripe5.set(step[4] == Bit.High) stripe5.set(step[4] == Bit.High)
} }
private fun setLeftMarkerPosition(component: UIComponent) { protected open fun setLeftMarkerPosition(component: UIComponent) {
component.root.anchorpaneConstraints { component.root.anchorpaneConstraints {
leftAnchor = (stripeWidth.value / 2) leftAnchor = (stripeWidth.value / 2)
} }
} }
private fun setRightMarkerPosition(component: UIComponent) { protected open fun setRightMarkerPosition(component: UIComponent) {
component.root.anchorpaneConstraints { component.root.anchorpaneConstraints {
rightAnchor = (stripeWidth.value / 2) rightAnchor = (stripeWidth.value / 2)
} }
} }
private fun increaseSize() { protected open fun increaseSize() {
if (isMaxSizeReached.value == false) { if (isMaxSizeReached.value == false) {
stripeHeight.value = stripeHeight.value + ChangeSizeStripeHeightStep stripeHeight.value = stripeHeight.value + ChangeSizeStripeHeightStep
stripeWidth.value = stripeWidth.value + ChangeSizeStripeWidthStep stripeWidth.value = stripeWidth.value + ChangeSizeStripeWidthStep
@ -192,7 +192,7 @@ class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() {
updateMinAndMaxSizeReached() updateMinAndMaxSizeReached()
} }
private fun decreaseSize() { protected open fun decreaseSize() {
if (isMinSizeReached.value == false) { if (isMinSizeReached.value == false) {
stripeHeight.value = stripeHeight.value - ChangeSizeStripeHeightStep stripeHeight.value = stripeHeight.value - ChangeSizeStripeHeightStep
stripeWidth.value = stripeWidth.value - ChangeSizeStripeWidthStep stripeWidth.value = stripeWidth.value - ChangeSizeStripeWidthStep
@ -202,14 +202,14 @@ class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() {
updateMinAndMaxSizeReached() updateMinAndMaxSizeReached()
} }
private fun updateMinAndMaxSizeReached() { protected open fun updateMinAndMaxSizeReached() {
val flickerCodeWidth = stripeWidth.value * 5 + spaceBetweenStripes.value * 4 val flickerCodeWidth = stripeWidth.value * 5 + spaceBetweenStripes.value * 4
isMinSizeReached.value = flickerCodeWidth < MinFlickerCodeViewWidth isMinSizeReached.value = flickerCodeWidth < MinFlickerCodeViewWidth
isMaxSizeReached.value = flickerCodeWidth > MaxFlickerCodeViewWidth isMaxSizeReached.value = flickerCodeWidth > MaxFlickerCodeViewWidth
} }
private fun increaseFrequency() { protected open fun increaseFrequency() {
if (isMaxFrequencyReached.value == false if (isMaxFrequencyReached.value == false
&& (currentFrequency + ChangeFrequencyStep) <= FlickerCodeAnimator.MaxFrequency) { && (currentFrequency + ChangeFrequencyStep) <= FlickerCodeAnimator.MaxFrequency) {
@ -220,7 +220,7 @@ class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() {
updateMinAndMaxFrequencyReached() updateMinAndMaxFrequencyReached()
} }
private fun decreaseFrequency() { protected open fun decreaseFrequency() {
if (isMinFrequencyReached.value == false if (isMinFrequencyReached.value == false
&& (currentFrequency - ChangeFrequencyStep) >= FlickerCodeAnimator.MinFrequency) { && (currentFrequency - ChangeFrequencyStep) >= FlickerCodeAnimator.MinFrequency) {
@ -231,7 +231,7 @@ class ChipTanFlickerCodeView(private val flickerCode: FlickerCode): View() {
updateMinAndMaxFrequencyReached() updateMinAndMaxFrequencyReached()
} }
private fun updateMinAndMaxFrequencyReached() { protected open fun updateMinAndMaxFrequencyReached() {
isMaxFrequencyReached.value = (currentFrequency + ChangeFrequencyStep) > FlickerCodeAnimator.MaxFrequency isMaxFrequencyReached.value = (currentFrequency + ChangeFrequencyStep) > FlickerCodeAnimator.MaxFrequency
isMinFrequencyReached.value = (currentFrequency - ChangeFrequencyStep) < FlickerCodeAnimator.MinFrequency isMinFrequencyReached.value = (currentFrequency - ChangeFrequencyStep) < FlickerCodeAnimator.MinFrequency
} }