Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size unit implementation for PointGeom and TextGeom #215

Merged
merged 17 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify PointGeom.getSizeUnitRatio implementation
  • Loading branch information
IKrukov-HORIS committed Oct 22, 2020
commit 487e5e65ec6247e80aeb3d01e822a88328e8d29f
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ object AesScaling {

fun circleDiameter(p: DataPointAesthetics): Double {
// aes Units -> px
return circleDiameter(p.size()!!)
}

fun circleDiameter(size: Double): Double {
// aes Units -> px
return size * CIRCLE_DIAMETER_FACTOR
return p.size()!! * 2.2
}

fun circleDiameterSmaller(p: DataPointAesthetics): Double {
Expand All @@ -32,14 +27,11 @@ object AesScaling {

fun sizeFromCircleDiameter(diameter: Double): Double {
// px -> aes Units
return diameter / CIRCLE_DIAMETER_FACTOR
return diameter / 2.2
}

fun textSize(p: DataPointAesthetics): Double {
// aes Units -> px
return textSize(p.size()!!)
return p.size()!! * 2
}

fun textSize(size: Double) = size * 2

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ open class PointGeom : GeomBase() {
sizeUnit?.let { sizeUnitValue ->
alshan marked this conversation as resolved.
Show resolved Hide resolved
val unitRes = getUnitResBySizeUnit(ctx, sizeUnitValue)

// TODO: Need refactoring: It's better to use NamedShape.FILLED_CIRCLE.size(1.0)
// but AesScaling.circleDiameter is used because Shape.size() takes DataPointAesthetics
val unitShapeSize = AesScaling.circleDiameter(1.0)
val unitShapeSize = 2.2
alshan marked this conversation as resolved.
Show resolved Hide resolved
return unitRes / unitShapeSize
}

Expand Down