-
Notifications
You must be signed in to change notification settings - Fork 47
/
DirectlyProportionalMapperProvider.kt
32 lines (28 loc) · 1.18 KB
/
DirectlyProportionalMapperProvider.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* Copyright (c) 2019. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package jetbrains.datalore.plot.builder.scale.provider
import jetbrains.datalore.base.gcommon.collect.ClosedRange
import jetbrains.datalore.plot.base.ContinuousTransform
import jetbrains.datalore.plot.base.scale.MapperUtil
import jetbrains.datalore.plot.builder.scale.ContinuousOnlyMapperProvider
import jetbrains.datalore.plot.builder.scale.GuideMapper
import jetbrains.datalore.plot.builder.scale.mapper.GuideMappers
/**
* @param naValue value used when size is not defined
*/
open class DirectlyProportionalMapperProvider(
private val max: Double,
naValue: Double
) : ContinuousOnlyMapperProvider<Double>(naValue) {
override fun createContinuousMapper(
domain: ClosedRange<Double>,
lowerLimit: Double?,
upperLimit: Double?,
trans: ContinuousTransform
): GuideMapper<Double> {
val dataMax = MapperUtil.rangeWithLimitsAfterTransform(domain, lowerLimit, upperLimit, trans).upperEnd
return GuideMappers.continuousToContinuous(ClosedRange(0.0, dataMax), ClosedRange(0.0, max), naValue)
}
}