正在显示
2 个修改的文件
包含
93 行增加
和
12 行删除
@@ -103,7 +103,7 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { | @@ -103,7 +103,7 @@ func CellsLocationAdjust(cells []*domain.LayoutCell) { | ||
103 | } | 103 | } |
104 | //move = cell.Length | 104 | //move = cell.Length |
105 | //c = cell | 105 | //c = cell |
106 | - if max(move, cell.Length) != move { | 106 | + if max(move, cell.Length) != move && c==nil { |
107 | c = cell | 107 | c = cell |
108 | } | 108 | } |
109 | move = max(move, cell.Length) | 109 | move = max(move, cell.Length) |
@@ -200,7 +200,6 @@ func (ptr *QuerySetService) LoadDataTables(ctx *domain.Context, cells []*domain. | @@ -200,7 +200,6 @@ func (ptr *QuerySetService) LoadDataTables(ctx *domain.Context, cells []*domain. | ||
200 | func DataLayout(res *domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) { | 200 | func DataLayout(res *domain.DataTable, cells []*domain.LayoutCell) (*domain.DataTable, error) { |
201 | dt := &DataLayoutDataTable{ | 201 | dt := &DataLayoutDataTable{ |
202 | DataTable: res, | 202 | DataTable: res, |
203 | - //MapDataTables: dataTables, | ||
204 | unprocessed: cells, | 203 | unprocessed: cells, |
205 | } | 204 | } |
206 | dt.Init(DefaultExpandNum) | 205 | dt.Init(DefaultExpandNum) |
@@ -266,10 +265,6 @@ func (l *Location) Update(x int, y int, compare func(int, int) int) { | @@ -266,10 +265,6 @@ func (l *Location) Update(x int, y int, compare func(int, int) int) { | ||
266 | } | 265 | } |
267 | } | 266 | } |
268 | 267 | ||
269 | -//func (d *DataLayoutDataTable) StartCell() { | ||
270 | -// | ||
271 | -//} | ||
272 | - | ||
273 | func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData []string) { | 268 | func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData []string) { |
274 | if d.PointBegin == nil { | 269 | if d.PointBegin == nil { |
275 | d.PointBegin = NewLocation(cell.X, cell.Y) | 270 | d.PointBegin = NewLocation(cell.X, cell.Y) |
@@ -280,20 +275,14 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [ | @@ -280,20 +275,14 @@ func (d *DataLayoutDataTable) addByLocation(cell *domain.LayoutCell, blockData [ | ||
280 | for i := range blockData { | 275 | for i := range blockData { |
281 | d.DataTable.Data[cell.X][cell.Y+i] = blockData[i] | 276 | d.DataTable.Data[cell.X][cell.Y+i] = blockData[i] |
282 | } | 277 | } |
283 | - //d.PointEnd.UpdateX(cell.X) | ||
284 | - //d.PointEnd.UpdateY(cell.Y + len(blockData) - 1) | ||
285 | d.PointEnd.Update(cell.X, cell.Y+len(blockData)-1, max) | 278 | d.PointEnd.Update(cell.X, cell.Y+len(blockData)-1, max) |
286 | case domain.DirectionDown: | 279 | case domain.DirectionDown: |
287 | for i := range blockData { | 280 | for i := range blockData { |
288 | d.DataTable.Data[cell.X+i][cell.Y] = blockData[i] | 281 | d.DataTable.Data[cell.X+i][cell.Y] = blockData[i] |
289 | } | 282 | } |
290 | - //d.PointEnd.UpdateX(cell.X + len(blockData) - 1) | ||
291 | - //d.PointEnd.UpdateY(cell.Y) | ||
292 | d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max) | 283 | d.PointEnd.Update(cell.X+len(blockData)-1, cell.Y, max) |
293 | case domain.DirectionNone: | 284 | case domain.DirectionNone: |
294 | d.DataTable.Data[cell.X][cell.Y] = blockData[0] | 285 | d.DataTable.Data[cell.X][cell.Y] = blockData[0] |
295 | - //d.PointEnd.UpdateX(cell.X) | ||
296 | - //d.PointEnd.UpdateY(cell.Y) | ||
297 | d.PointEnd.Update(cell.X, cell.Y, max) | 286 | d.PointEnd.Update(cell.X, cell.Y, max) |
298 | } | 287 | } |
299 | } | 288 | } |
@@ -13,6 +13,7 @@ func TestDataLayout(t *testing.T) { | @@ -13,6 +13,7 @@ func TestDataLayout(t *testing.T) { | ||
13 | cells []*domain.LayoutCell | 13 | cells []*domain.LayoutCell |
14 | flag Location | 14 | flag Location |
15 | title string | 15 | title string |
16 | + debug bool | ||
16 | }{ | 17 | }{ |
17 | { | 18 | { |
18 | title: "配置组多组混合", | 19 | title: "配置组多组混合", |
@@ -410,6 +411,93 @@ func TestDataLayout(t *testing.T) { | @@ -410,6 +411,93 @@ func TestDataLayout(t *testing.T) { | ||
410 | flag: Location{X: 2, Y: 1}, | 411 | flag: Location{X: 2, Y: 1}, |
411 | }, | 412 | }, |
412 | { | 413 | { |
414 | + title: "测试用例4", | ||
415 | + cells: []*domain.LayoutCell{ | ||
416 | + // 分组一 | ||
417 | + { | ||
418 | + X: 0, | ||
419 | + Y: 0, | ||
420 | + Length: 5, | ||
421 | + ImageData: "a", | ||
422 | + Direction: domain.DirectionDown, | ||
423 | + }, | ||
424 | + { | ||
425 | + X: 0, | ||
426 | + Y: 1, | ||
427 | + Length: 5, | ||
428 | + ImageData: "b", | ||
429 | + Direction: domain.DirectionDown, | ||
430 | + }, | ||
431 | + // , | ||
432 | + // { | ||
433 | + // X: 1, | ||
434 | + // Y: 1, | ||
435 | + // Length: 5, | ||
436 | + // ImageData: "c", | ||
437 | + // Direction: domain.DirectionRight, | ||
438 | + // }, | ||
439 | + // { | ||
440 | + // X: 2, | ||
441 | + // Y: 1, | ||
442 | + // Length: 5, | ||
443 | + // ImageData: "d", | ||
444 | + // Direction: domain.DirectionRight, | ||
445 | + // }, | ||
446 | + }, | ||
447 | + flag: Location{X: 0, Y: 0}, | ||
448 | + }, | ||
449 | + { | ||
450 | + title: "测试用例5", | ||
451 | + cells: []*domain.LayoutCell{ | ||
452 | + // 分组一 | ||
453 | + { | ||
454 | + X: 0, | ||
455 | + Y: 0, | ||
456 | + Length: 5, | ||
457 | + ImageData: "a", | ||
458 | + Direction: domain.DirectionDown, | ||
459 | + }, | ||
460 | + { | ||
461 | + X: 0, | ||
462 | + Y: 1, | ||
463 | + Length: 6, | ||
464 | + ImageData: "b", | ||
465 | + Direction: domain.DirectionDown, | ||
466 | + }, | ||
467 | + { | ||
468 | + X: 1, | ||
469 | + Y: 0, | ||
470 | + Length: 1, | ||
471 | + ImageData: "t", | ||
472 | + Direction: domain.DirectionNone, | ||
473 | + }, | ||
474 | + { | ||
475 | + X: 1, | ||
476 | + Y: 1, | ||
477 | + Length: 1, | ||
478 | + ImageData: "x", | ||
479 | + Direction: domain.DirectionNone, | ||
480 | + }, | ||
481 | + // , | ||
482 | + // { | ||
483 | + // X: 1, | ||
484 | + // Y: 1, | ||
485 | + // Length: 5, | ||
486 | + // ImageData: "c", | ||
487 | + // Direction: domain.DirectionRight, | ||
488 | + // }, | ||
489 | + // { | ||
490 | + // X: 2, | ||
491 | + // Y: 1, | ||
492 | + // Length: 5, | ||
493 | + // ImageData: "d", | ||
494 | + // Direction: domain.DirectionRight, | ||
495 | + // }, | ||
496 | + }, | ||
497 | + flag: Location{X: 0, Y: 0}, | ||
498 | + debug:true, | ||
499 | + }, | ||
500 | + { | ||
413 | title: "测试用例6", | 501 | title: "测试用例6", |
414 | cells: []*domain.LayoutCell{ | 502 | cells: []*domain.LayoutCell{ |
415 | // 分组一 | 503 | // 分组一 |
@@ -445,7 +533,11 @@ func TestDataLayout(t *testing.T) { | @@ -445,7 +533,11 @@ func TestDataLayout(t *testing.T) { | ||
445 | } | 533 | } |
446 | } | 534 | } |
447 | } | 535 | } |
536 | + debugItem:= false | ||
448 | for _, input := range inputs { | 537 | for _, input := range inputs { |
538 | + if debugItem && !input.debug{ | ||
539 | + continue | ||
540 | + } | ||
449 | padding(input.cells) | 541 | padding(input.cells) |
450 | // 根据数据修改位移 | 542 | // 根据数据修改位移 |
451 | CellsLocationAdjust(input.cells) | 543 | CellsLocationAdjust(input.cells) |
-
请 注册 或 登录 后发表评论