Skip to content

Commit

Permalink
7.56.0 Plot Factorio Maps
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Aug 28, 2024
1 parent d68f7a8 commit 033caea
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.marginallyclever</groupId>
<artifactId>Makelangelo</artifactId>
<version>7.55.7</version>
<version>7.56.0</version>
<name>Makelangelo</name>
<description>Makelangelo Software is a Java program that prepares art for CNC plotters. It is especially designed for the Makelangelo Robot.
It pairs really well with Marlin-polargraph, the code in the brain of the robot that receives instructions and moves the motors.</description>
Expand Down
37 changes: 21 additions & 16 deletions src/main/java/com/marginallyclever/convenience/LineCollection.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.marginallyclever.convenience;

import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

public class LineCollection extends ArrayList<LineSegment2D> {
private boolean[] usePt;
Expand All @@ -20,27 +22,30 @@ public LineCollection(LineCollection list) {
* @return the list of collections separated by color
*/
public ArrayList<LineCollection> splitByColor() {
ArrayList<LineCollection> result = new ArrayList<LineCollection> ();
if(this.size()>0) {
LineSegment2D head = get(0);

LineCollection c = new LineCollection();
result.add(c);
c.add(head);

for(int i=1;i<size();++i) {
LineSegment2D next = get(i);
if(next.color.equals(head.color)) {
c.add(next);
var map = new HashMap<Color,LineCollection>();

if(this.isEmpty()) return new ArrayList<>();

LineSegment2D head = get(0);
LineCollection c = new LineCollection();
map.put(head.color,c);
c.add(head);

for(int i=1;i<size();++i) {
LineSegment2D next = get(i);
if(!next.color.equals(head.color)) {
head = next;
if(map.containsKey(next.color)) {
c = map.get(next.color);
} else {
head = next;
c = new LineCollection();
result.add(c);
c.add(head);
map.put(next.color, c);
}
}
c.add(next);
}
return result;

return new ArrayList<>(map.values());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ public boolean canLoad(String filename) {

@Override
public Turtle load(InputStream in) throws Exception {
if (in == null) {
throw new NullPointerException("Input stream is null");
}
if (in == null) throw new NullPointerException("Input stream is null");

logger.debug("Loading...");

Expand Down
Loading

0 comments on commit 033caea

Please sign in to comment.