Skip to content

Commit

Permalink
Code cleanup: remove unimplemented isReverse flag from GuideOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
OLarionova-HORIS committed Jun 20, 2024
1 parent 6f5a261 commit 4bc8ddc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ class ColorBarOptions constructor(
val width: Double? = null,
val height: Double? = null,
val binCount: Int? = null,
title: String? = null,
isReverse: Boolean = false
) : GuideOptions(title, isReverse) {

override fun withReverse(reverse: Boolean): ColorBarOptions {
return ColorBarOptions(
width, height, binCount, title, isReverse = reverse
)
}
title: String? = null
) : GuideOptions(title) {

override fun withTitle(title: String?): ColorBarOptions {
return ColorBarOptions(
width, height, binCount, title = title, isReverse
width, height, binCount, title = title
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@
package org.jetbrains.letsPlot.core.plot.builder.assemble

abstract class GuideOptions(
val title: String?,
val isReverse: Boolean
val title: String?
) {
abstract fun withTitle(title: String?): GuideOptions
abstract fun withReverse(reverse: Boolean): GuideOptions

// // In Kotlin Native objects a frozen by default. Annotate with `ThreadLocal` to unfreeze.
// // @link https://github.com/JetBrains/kotlin-native/blob/master/IMMUTABILITY.md
// // Required mutations:
// // - `isReverse` in the 'outer' class
// @ThreadLocal
companion object {
val NONE: GuideOptions = object : GuideOptions(null, false) {
val NONE: GuideOptions = object : GuideOptions(null) {
override fun withTitle(title: String?): GuideOptions = this
override fun withReverse(reverse: Boolean): GuideOptions = this // Do nothing
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class LegendOptions constructor(
val colCount: Int? = null,
val rowCount: Int? = null,
val byRow: Boolean = false,
title: String? = null,
isReverse: Boolean = false
) : GuideOptions(title, isReverse) {
title: String? = null
) : GuideOptions(title) {
init {
require(colCount == null || colCount > 0) { "Invalid value: colCount=$colCount" }
require(rowCount == null || rowCount > 0) { "Invalid value: colCount=$rowCount" }
Expand All @@ -25,15 +24,9 @@ class LegendOptions constructor(
return rowCount != null
}

override fun withReverse(reverse: Boolean): LegendOptions {
return LegendOptions(
colCount, rowCount, byRow, title, isReverse = reverse
)
}

override fun withTitle(title: String?): LegendOptions {
return LegendOptions(
colCount, rowCount, byRow, title = title, isReverse
colCount, rowCount, byRow, title = title
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ object Option {
const val COLOR_BAR = "colorbar"
const val COLOR_BAR_GB = "colourbar"

const val REVERSE = "reverse"
const val REVERSE = "reverse" // not implemented
const val TITLE = "title"

object Legend {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import org.jetbrains.letsPlot.core.spec.Option.Guide.Legend.BY_ROW
import org.jetbrains.letsPlot.core.spec.Option.Guide.Legend.COL_COUNT
import org.jetbrains.letsPlot.core.spec.Option.Guide.Legend.ROW_COUNT
import org.jetbrains.letsPlot.core.spec.Option.Guide.NONE
import org.jetbrains.letsPlot.core.spec.Option.Guide.REVERSE
import org.jetbrains.letsPlot.core.spec.Option.Guide.TITLE
import kotlin.math.max

Expand All @@ -28,7 +27,6 @@ abstract class GuideConfig private constructor(opts: Map<String, Any>) : Options
val options = createGuideOptionsIntern()
return options
.withTitle(getString(TITLE))
.withReverse(getBoolean(REVERSE))
}

protected abstract fun createGuideOptionsIntern(): GuideOptions
Expand Down

0 comments on commit 4bc8ddc

Please sign in to comment.