MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / saveForRobot

Method saveForRobot

src/main/java/trace/util/SaveForRobot.kt:14–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12import java.util.function.Supplier
13
14class SaveForRobot {
15 fun saveForRobot(f: List<FLine>) {
16 if (f.size == 0) throw IllegalArgumentException(" no lines to save ")
17
18 val base = System.getProperty("user.home") + File.separatorChar + "field_robot" + File.separatorChar
19
20 var x = 1
21 while (File(base + Saver.pad(x)).exists()) x++
22
23 val prefix = File(base + Saver.pad(x) + ".robot")
24 prefix.parentFile.mkdirs()
25
26 var bounds: Rect? = null
27 f.forEach {
28 val b = FLinesAndJavaShapes.flineToJavaShape_notThickened(it).bounds2D
29 bounds = Rect.union(bounds, Rect(b.x, b.y, b.width, b.height))
30 }
31
32 val m = Math.max(bounds!!.w, bounds!!.h)
33
34 println("bounds are $bounds")
35
36 val r = Rasterizer(prefix.absolutePath, {
37 var r = Vec2((it.toVec2().x - bounds!!.x) / m, (it.toVec2().y - bounds!!.y) / m)
38 println(r)
39 r
40 })
41
42 f.forEach { r.append(it) }
43 r.finish()
44
45 Desktop.getDesktop().browseFileDirectory(prefix.parentFile)
46 }
47
48 fun saveForRobot(f: IdempotencyMap<Supplier<FLine>>) {

Callers

nothing calls this directly

Calls 15

FileFunction · 0.85
RectClass · 0.85
RasterizerClass · 0.85
existsMethod · 0.80
piecesMethod · 0.80
getMethod · 0.65
Vec2Class · 0.50
padMethod · 0.45
forEachMethod · 0.45
unionMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected