|
|
@@ -337,19 +337,18 @@ class CustomSwitchStationLayer @JvmOverloads constructor(
|
|
|
for (p in points) {
|
|
|
val c = centerOf(p)
|
|
|
|
|
|
- // 选中环
|
|
|
- if (p.isSelected) {
|
|
|
- paint.style = Paint.Style.STROKE
|
|
|
- paint.strokeWidth = mapStroke
|
|
|
- paint.color = colSelectRing
|
|
|
- canvas.drawCircle(c.x, c.y, mapR, paint)
|
|
|
- }
|
|
|
-
|
|
|
- // 主体圆
|
|
|
- paint.style = Paint.Style.FILL_AND_STROKE
|
|
|
+ // 主体圆(纯填充!不要 STROKE)
|
|
|
+ paint.style = Paint.Style.FILL
|
|
|
+ paint.strokeWidth = 0f
|
|
|
when (p.status) {
|
|
|
- STATUS_ON -> { paint.color = colOn; paint.alpha = 255; canvas.drawCircle(c.x, c.y, mapR, paint) }
|
|
|
- STATUS_OFF -> { paint.color = colOff; paint.alpha = 255; canvas.drawCircle(c.x, c.y, mapR, paint) }
|
|
|
+ STATUS_ON -> {
|
|
|
+ paint.color = colOn; paint.alpha = 255
|
|
|
+ canvas.drawCircle(c.x, c.y, mapR, paint)
|
|
|
+ }
|
|
|
+ STATUS_OFF -> {
|
|
|
+ paint.color = colOff; paint.alpha = 255
|
|
|
+ canvas.drawCircle(c.x, c.y, mapR, paint)
|
|
|
+ }
|
|
|
STATUS_ALARM -> {
|
|
|
val t = pulsePhase
|
|
|
val color = if (t < 0.5f) colRed else colOrange
|
|
|
@@ -361,21 +360,32 @@ class CustomSwitchStationLayer @JvmOverloads constructor(
|
|
|
canvas.drawCircle(c.x, c.y, r * 1.25f, paint)
|
|
|
paint.alpha = 255
|
|
|
}
|
|
|
- else -> { paint.color = Color.DKGRAY; paint.alpha = 200; canvas.drawCircle(c.x, c.y, mapR, paint); paint.alpha = 255 }
|
|
|
+ else -> {
|
|
|
+ paint.color = Color.DKGRAY; paint.alpha = 200
|
|
|
+ canvas.drawCircle(c.x, c.y, mapR, paint)
|
|
|
+ paint.alpha = 255
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 选中环:放在主体之后画,半径 +1~2 像素,描边 3~4 像素
|
|
|
+ if (p.isSelected) {
|
|
|
+ val ringPad = 2f // 比主体略大
|
|
|
+ val ringStroke = 4f // 你也可以调小/大
|
|
|
+ paint.style = Paint.Style.STROKE
|
|
|
+ paint.strokeWidth = ringStroke
|
|
|
+ paint.color = colSelectRing
|
|
|
+ canvas.drawCircle(c.x, c.y, mapR + ringPad, paint)
|
|
|
}
|
|
|
|
|
|
- // 文本:先算希望的屏幕宽度,再 /zoom 得到地图层文字 size
|
|
|
+ // 文本
|
|
|
val text = p.motorCode ?: ""
|
|
|
if (text.isNotEmpty()) {
|
|
|
paint.style = Paint.Style.FILL
|
|
|
- paint.strokeWidth = mapStroke
|
|
|
+ paint.strokeWidth = 0f
|
|
|
paint.color = Color.WHITE
|
|
|
-
|
|
|
- val maxTextWidthScreen = (screenR * 2f) - 6f // 屏幕像素
|
|
|
- // 先在“屏幕像素语义”下求字号
|
|
|
+ val maxTextWidthScreen = (screenR * 2f) - 6f
|
|
|
val screenTextSize = fitTextSizeScreen(paint, text, maxTextWidthScreen, screenTextMin, screenTextMax)
|
|
|
val mapTextSize = screenTextSize
|
|
|
-
|
|
|
paint.textSize = mapTextSize
|
|
|
val textW = paint.measureText(text)
|
|
|
val fm = paint.fontMetrics
|