A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AlmasB/FXGL/commit/62980b4d9 below:

RechargeableDoubleComponent also has the value in percentage fo… · AlmasB/FXGL@62980b4 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+17

-0

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+17

-0

lines changed Original file line number Diff line number Diff line change

@@ -47,13 +47,18 @@ abstract class RechargeableDoubleComponent

47 47

) : DoubleComponent(initialValue) {

48 48 49 49

private val maxValueProp = SimpleDoubleProperty(maxValue)

50 +

private val valuePercentBinding = valueProperty().divide(maxValueProp).multiply(100)

50 51 51 52

fun maxValueProperty() = maxValueProp

53 +

fun valuePercentProperty() = valuePercentBinding

52 54 53 55

var maxValue: Double

54 56

get() = maxValueProp.value

55 57

set(value) { maxValueProp.value = value }

56 58 59 +

val valuePercent: Double

60 +

get() = valuePercentBinding.value

61 + 57 62

/**

58 63

* Set component value to 0.

59 64

*/

Original file line number Diff line number Diff line change

@@ -155,4 +155,16 @@ class RechargeableDoubleComponentTest {

155 155

assertThat(value, `is`(30.0))

156 156

assertThat(zero, `is`(false))

157 157

}

158 + 159 +

@Test

160 +

fun `value in percent`() {

161 +

hp.value = 10.0

162 +

hp.maxValue = 100.0

163 + 164 +

assertThat(hp.valuePercent, `is`(10.0))

165 + 166 +

hp.maxValue = 50.0

167 + 168 +

assertThat(hp.valuePercent, `is`(20.0))

169 +

}

158 170

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4