|
@@ -15,8 +15,6 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
|
|
|
private val paint = Paint()
|
|
|
/** 墙轮廓 */
|
|
|
private var spacePath: Path? = null
|
|
|
- /** 空间轮廓线坐标list */
|
|
|
- private val pointArr = ArrayList<ArrayList<PointF>>()
|
|
|
/** X坐标最小值 */
|
|
|
private var minX = 0f
|
|
|
/** X坐标最大值 */
|
|
@@ -26,6 +24,8 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
|
|
|
/** Y坐标最大值 */
|
|
|
private var maxY = 0f
|
|
|
|
|
|
+ private var a=(1+Math.random()*(10-1+1))
|
|
|
+
|
|
|
init {
|
|
|
try {
|
|
|
zOrder = 1f
|
|
@@ -34,12 +34,10 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
|
|
|
maxX = data.outLine!![0][0].x
|
|
|
minY = data.outLine!![0][0].y
|
|
|
maxY = data.outLine!![0][0].y
|
|
|
-
|
|
|
for (line in data.outLine!!) {
|
|
|
if (line.size < 1) {
|
|
|
continue
|
|
|
}
|
|
|
-
|
|
|
val path = Path()
|
|
|
path.moveTo(line[0].x, -line[0].y)
|
|
|
for (p in line) {
|
|
@@ -60,43 +58,15 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
|
|
|
path.close()
|
|
|
if (spacePath == null) {
|
|
|
spacePath = path;
|
|
|
- } else {
|
|
|
- // spacePath.b
|
|
|
- }
|
|
|
+ } else { // spacePath.b
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (e: Exception) {
|
|
|
e.printStackTrace()
|
|
|
}
|
|
|
-
|
|
|
- //if (data.outLine!!.size > 0) {
|
|
|
-// val tempArr = this.data.OutLine
|
|
|
-// this.minX = tempArr[0][0].x
|
|
|
-// this.maxX = this.minX
|
|
|
-// this.minY = -(tempArr[0][0].y)
|
|
|
-// this.maxY = this.minY
|
|
|
- // 处理轮廓点数组,同时计算最大最小值
|
|
|
-// this.pointArr = tempArr.map(t => {
|
|
|
-// var tempArr = t.map(it => {
|
|
|
-// var x = it.X,
|
|
|
-// y = -it.Y
|
|
|
-// if (x < this.minX) {
|
|
|
-// this.minX = x
|
|
|
-// }
|
|
|
-// if (y < this.minY) {
|
|
|
-// this.minY = y
|
|
|
-// }
|
|
|
-// if (x > this.maxX) {
|
|
|
-// this.maxX = x
|
|
|
-// }
|
|
|
-// if (y > this.maxY) {
|
|
|
-// this.maxY = y
|
|
|
-// }
|
|
|
-// return SPoint(x, y)
|
|
|
-// })
|
|
|
-// return tempArr
|
|
|
-// })
|
|
|
- //}
|
|
|
+ setColor(paint, a.toInt())
|
|
|
+ paint.style = Paint.Style.FILL
|
|
|
} // Constructor
|
|
|
|
|
|
/**
|
|
@@ -109,47 +79,6 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
|
|
|
} // Function boundingRect()
|
|
|
|
|
|
/**
|
|
|
- * 判断点是否在区域内
|
|
|
- *
|
|
|
- * @param x
|
|
|
- * @param y
|
|
|
- */
|
|
|
- override fun contains(x: Float, y: Float): Boolean {
|
|
|
-// if (this.data?.OutLine!!.size > 0) {
|
|
|
-// var nCross: Double = 0.0
|
|
|
-// var point = ArrayList<String>()
|
|
|
-// point.add("x")
|
|
|
-// point.add("y")
|
|
|
-// var APoints = this.data?.OutLine!!.get(0)
|
|
|
-// var length = APoints.size
|
|
|
-// var p1: ArrayList<Point>? = null
|
|
|
-// var p2: ArrayList<Point>? = null
|
|
|
-// var i: Int? = null
|
|
|
-// var xinters: Double? = null
|
|
|
-// p1 = APoints.get(0)
|
|
|
-// i == 1
|
|
|
-// while (i!! <= length){
|
|
|
-// p2 = APoints.get((i % length))
|
|
|
-// if (point[0] > Math.min(p1.X, p2.X) && point[0] <= Math.max(p1.X, p2.X)) {
|
|
|
-// if (point[1] <= Math.max(p1.Y, p2.Y)) {
|
|
|
-// if (p1.X != p2.X) {
|
|
|
-// //计算位置信息
|
|
|
-// xinters = ((point[0] - p1.X) * (p2.Y - p1.Y)) / (p2.X - p1.X) + p1.Y
|
|
|
-// if (p1.Y == p2.Y || point[1] <= xinters) {
|
|
|
-// nCross++
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// p1 = p2
|
|
|
-// i++
|
|
|
-// }
|
|
|
-// return nCross % 2 === 1
|
|
|
-// }
|
|
|
- return false
|
|
|
- } // Function contains()
|
|
|
-
|
|
|
- /**
|
|
|
* Item绘制操作
|
|
|
*
|
|
|
* @param canvas 画布
|
|
@@ -157,11 +86,44 @@ class SpaceItem(private val data: Space, parent: SGraphyItem? = null) : SGraphyI
|
|
|
*/
|
|
|
override fun onDraw(canvas : Canvas) {
|
|
|
if (null != spacePath) {
|
|
|
- paint.style = Paint.Style.FILL
|
|
|
- paint.color = Opt.spaceColor;
|
|
|
canvas.drawPath(spacePath!!, paint)
|
|
|
|
|
|
}
|
|
|
} // Function onDraw()
|
|
|
|
|
|
+ fun setColor(pen:Paint,a:Int){
|
|
|
+ when(a){
|
|
|
+ 1 ->{
|
|
|
+ pen.color = Color.argb(20,139,0,139)
|
|
|
+ }
|
|
|
+ 2 ->{
|
|
|
+ pen.color = Color.argb(20,220,20,60)
|
|
|
+ }
|
|
|
+ 3 ->{
|
|
|
+ pen.color = Color.argb(20,255,20,147)
|
|
|
+ }
|
|
|
+ 4 ->{
|
|
|
+ pen.color = Color.argb(20,75,0,130)
|
|
|
+ }
|
|
|
+ 5 ->{
|
|
|
+ pen.color = Color.argb(20,123,104,238)
|
|
|
+ }
|
|
|
+ 6 ->{
|
|
|
+ pen.color = Color.argb(20,0,0,205)
|
|
|
+ }
|
|
|
+ 7 ->{
|
|
|
+ pen.color = Color.argb(20,119,136,153)
|
|
|
+ }
|
|
|
+ 8 ->{
|
|
|
+ pen.color = Color.argb(20, 30,144,255)
|
|
|
+ }
|
|
|
+ 9 ->{
|
|
|
+ pen.color = Color.argb(20,255,182,193)
|
|
|
+ }
|
|
|
+ 10 ->{
|
|
|
+ pen.color = Color.argb(20,123,104,238)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } // Fun
|
|
|
+
|
|
|
} // Class SpaceItem
|