• 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

85.71
/src/main/scala/tripaint/model/image/ImagePool.scala
1
package tripaint.model.image
2

3
import tripaint.model.coords.StorageCoords
4
import tripaint.model.image.format.StorageFormat
5
import tripaint.util.{InjectiveHashMap, InjectiveMap}
6

7
import java.io.File
8
import scala.collection.mutable
9

10
object ImagePool {
11
  case class SaveInfo(format: StorageFormat)
12
  case class SaveLocation(file: File, offset: StorageCoords = StorageCoords(0, 0))
1✔
13
}
14

15
/** This class should keep track of Map[SaveLocation, ImageStorage] So if SaveAs then this class
16
  * should be called so that collisions can be detected and dealt with, like e.g. when you save A
17
  * into the same place as B the user should be asked which image to keep, and after that they will
18
  * share the same ImageStorage.
19
  */
20
class ImagePool {
21
  import ImagePool.{SaveInfo, SaveLocation}
22

23
  private val mapping: InjectiveMap[SaveLocation, ImageStorage] = new InjectiveHashMap
1✔
24
  private val saveInfo: mutable.Map[ImageStorage, SaveInfo] = mutable.Map.empty
1✔
25

26
  final def locationOf(image: ImageStorage): Option[SaveLocation] = mapping.getLeft(image)
1✔
27

28
  def getSaveLocationAndInfo(image: ImageStorage): (Option[SaveLocation], Option[SaveInfo]) =
×
UNCOV
29
    (mapping.getLeft(image), saveInfo.get(image))
×
30

31
  def imageAt(location: SaveLocation): Option[ImageStorage] = mapping.getRight(location)
1✔
32

33
  def set(image: ImageStorage, location: SaveLocation, info: SaveInfo): Unit =
1✔
34
    mapping.getRight(location).foreach(this.remove)
1✔
35
    mapping.set(location, image)
1✔
36
    saveInfo(image) = info
1✔
37

38
  def remove(image: ImageStorage): Unit =
1✔
39
    mapping.removeRight(image)
1✔
40
    saveInfo.remove(image)
1✔
41
}
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