• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Martomate / TriPaint / 9275511596

28 May 2024 07:51PM UTC coverage: 29.682% (+1.8%) from 27.877%
9275511596

push

github

Martomate
Updated to Scala 3.4 and MUnit 1.0

2 of 11 new or added lines in 9 files covered. (18.18%)

430 existing lines in 38 files now uncovered.

401 of 1351 relevant lines covered (29.68%)

0.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/scala/tripaint/view/gui/ImagePreviewList.scala
1
package tripaint.view.gui
2

3
import tripaint.model.ImageGrid
4
import tripaint.model.coords.StorageCoords
5
import tripaint.model.image.{GridCell, ImagePool, ImageStorage}
6
import tripaint.model.image.ImagePool.SaveLocation
7
import tripaint.model.image.format.SimpleStorageFormat
8
import tripaint.view.image.TriImageForPreview
9

10
import scalafx.beans.property.ObjectProperty
11
import scalafx.scene.SnapshotParameters
12
import scalafx.scene.control.{ScrollPane, Tooltip}
13
import scalafx.scene.image.ImageView
14
import scalafx.scene.layout.HBox
15
import scalafx.scene.paint.Color
16

17
object ImagePreviewList {
UNCOV
18
  def fromImageContent(
×
19
      images: Seq[GridCell],
20
      previewSize: Int,
21
      locationOfImage: ImageStorage => Option[SaveLocation]
22
  ): (ScrollPane, (ImageGrid => Unit) => Unit) = {
UNCOV
23
    val imageSize = if images.nonEmpty then images.head.storage.imageSize else 8
×
24

25
    def makeContent(effect: ImageGrid => Unit): Seq[ImageView] = {
×
UNCOV
26
      val previewImages = images.map(cloneImageContent)
×
27

28
      val previewImageGrid = new ImageGrid(imageSize)
×
29
      for im <- previewImages do {
×
UNCOV
30
        previewImageGrid.set(im)
×
31
      }
32

UNCOV
33
      effect.apply(previewImageGrid)
×
34

UNCOV
35
      previewImages.map(ImagePreview.fromImageContent(_, previewSize, locationOfImage))
×
36
    }
37

38
    val scrollPane = {
39
      val p = new ScrollPane()
×
40
      p.maxWidth = previewSize * 5
×
NEW
41
      p.content = new HBox(children = makeContent(_ => ())*)
×
UNCOV
42
      p.minViewportHeight = previewSize * Math.sqrt(3) / 2
×
43
      p
44
    }
45

46
    val updatePreview: (ImageGrid => Unit) => Unit = effect => {
NEW
47
      scrollPane.content = new HBox(children = makeContent(effect)*)
×
48
    }
49

50
    (scrollPane, updatePreview)
51
  }
52

UNCOV
53
  private def cloneImageContent(content: GridCell): GridCell = {
×
54
    val format = SimpleStorageFormat
55
    val image = content.storage.toRegularImage(format)
×
56
    val imageSize = content.storage.imageSize
×
57
    val storage = ImageStorage.fromRegularImage(image, StorageCoords(0, 0), format, imageSize).get
×
UNCOV
58
    new GridCell(content.coords, storage)
×
59
  }
60
}
61

62
object ImagePreview {
UNCOV
63
  def fromImageContent(
×
64
      content: GridCell,
65
      previewSize: Int,
66
      locationOfImage: ImageStorage => Option[ImagePool.SaveLocation]
67
  ): ImageView = {
68
    val preview = new TriImageForPreview(content, previewSize)
×
UNCOV
69
    val tooltip = TriImageTooltip.fromImagePool(content, locationOfImage)
×
70

71
    val snapshotParams = new SnapshotParameters
×
UNCOV
72
    snapshotParams.fill = Color.Transparent
×
73

74
    val view = new ImageView
×
75
    view.image = preview.toImage(snapshotParams)
×
UNCOV
76
    Tooltip.install(view, tooltip)
×
77
    view
78
  }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc