Skip to content

Commit 2683f04

Browse files
Classic to Donatello (#782)
* added List of Points Lsit of Points is a List<Point2d> Added DAO Added OutputPoints and InputPoints Added PrintPoints Node Added TurtleToPoints Node Added GridOfPoints Node * Create PatternAtPoints.java * added angle so diamonds can be boxes. * dispose of Graphics2D to be tidy * Boxxy style * fix pom for jitpack * x and y spacing now use InputNumber, added style. * fixed an add a Node to Graph more than once. * use PrintWithGraphics::getLayer() * Added `b / (a spacing)` style to GridOfPoints * expose min and max for customizing * expose layer * bump dependencies nodegraphcore 1.2.0 donatelllo 1.5.1 * Create SaveTurtleTest.java * Changed Variable to Port in nodegraphcore * Update SaveTurtle.java * bump version nodegraphcore 1.3.0 donatello 1.5.2 * 7.66.1 * Variable > Port pt 2 * center on origin * Added CropToRectangle Node * points should be round * pattern should treat images as centered on their origins * origin at center * expose layer * reverse mouse wheel - push away to make smaller * Update Converter_CMYK_Circles.java * create new instance to prevent accidents * use progress bar, adjust for centered image * Output.send now Output.setValue and Select tests moved to Donatello * bump version nodegraphcore 1.3.1 donatello 1.5.2 * exposed subdivisions * bump versions slf4j, logback, nodegraphcore, and donatello * fix Exception on empty filename * updates for bumped * more exception testing * Fix #789 * fix #790 and vastly increase PrintTurtle performance
1 parent 4bceb6c commit 2683f04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+810
-606
lines changed

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.marginallyclever</groupId>
88
<artifactId>Makelangelo</artifactId>
9-
<version>7.65.0</version>
9+
<version>7.66.2</version>
1010
<name>Makelangelo</name>
1111
<description>Makelangelo Software is a Java program that prepares art for CNC plotters. It is especially designed for the Makelangelo Robot.
1212
It pairs really well with Marlin-polargraph, the code in the brain of the robot that receives instructions and moves the motors.</description>
@@ -427,7 +427,7 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
427427
<dependency>
428428
<groupId>ch.qos.logback</groupId>
429429
<artifactId>logback-classic</artifactId>
430-
<version>1.5.9</version>
430+
<version>1.5.16</version>
431431
</dependency>
432432
<dependency>
433433
<groupId>org.codehaus.janino</groupId>
@@ -438,7 +438,7 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
438438
<dependency>
439439
<groupId>org.slf4j</groupId>
440440
<artifactId>slf4j-api</artifactId>
441-
<version>2.0.12</version>
441+
<version>2.0.16</version>
442442
</dependency>
443443

444444
<dependency>
@@ -571,7 +571,7 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
571571
-->
572572
<groupId>com.github.marginallyclever</groupId>
573573
<artifactId>nodegraphcore</artifactId>
574-
<version>1.1.0</version>
574+
<version>1.3.2</version>
575575
</dependency>
576576
<dependency>
577577
<!--
@@ -583,7 +583,7 @@ It pairs really well with Marlin-polargraph, the code in the brain of the robot
583583
-->
584584
<groupId>com.github.marginallyclever</groupId>
585585
<artifactId>donatello</artifactId>
586-
<version>1.4.3</version>
586+
<version>1.5.5</version>
587587
</dependency>
588588

589589
<!-- read audio files -->

src/main/java/com/marginallyclever/convenience/LineSegment2D.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class LineSegment2D {
1515

1616
public LineSegment2D(Point2D start, Point2D end, Color color) {
1717
super();
18-
this.start = start;
19-
this.end = end;
18+
this.start = new Point2D(start);
19+
this.end = new Point2D(end);
2020
this.color = color;
2121
}
2222

src/main/java/com/marginallyclever/makelangelo/CollapsiblePanel.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,12 @@ public static void main(String[] args) {
185185
JFrame frame = new JFrame("Collapsible Panel");
186186
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
187187

188-
JPanel jPanel = new JPanel();
189-
jPanel.setLayout(new BorderLayout());
190-
SelectBoolean a = new SelectBoolean("A", "AAAAAAAAAAA", false);
191-
jPanel.add(a, BorderLayout.NORTH);
188+
JPanel jPanel = new JPanel(new GridBagLayout());
192189

193190
CollapsiblePanel cpanel = new CollapsiblePanel(frame, "lot of buttons", 400, true);
194191
jPanel.add(cpanel, BorderLayout.CENTER);
195192

193+
SelectBoolean a = new SelectBoolean("A", "AAAAAAAAAAA", false);
196194
SelectButton b = new SelectButton("B", "B");
197195
SelectColor c = new SelectColor("C", "CCCCCC", Color.BLACK, frame);
198196
SelectFile d = new SelectFile("D", "D", null,cpanel);
@@ -205,15 +203,19 @@ public static void main(String[] args) {
205203
SelectSlider i = new SelectSlider("I", "I", 200, 0, 100);
206204
SelectTextArea j = new SelectTextArea("J", "J", ipsum);
207205

208-
cpanel.add(b);
209-
cpanel.add(c);
210-
cpanel.add(d);
211-
cpanel.add(e);
212-
cpanel.add(f);
213-
cpanel.add(g);
214-
cpanel.add(h);
215-
cpanel.add(i);
216-
cpanel.add(j);
206+
var inner = new JPanel(new GridBagLayout());
207+
GridBagConstraints gbc = new GridBagConstraints();
208+
a.attach(inner, gbc); gbc.gridy++;
209+
b.attach(inner,gbc); gbc.gridy++;
210+
c.attach(inner,gbc); gbc.gridy++;
211+
d.attach(inner,gbc); gbc.gridy++;
212+
e.attach(inner,gbc); gbc.gridy++;
213+
f.attach(inner,gbc); gbc.gridy++;
214+
g.attach(inner,gbc); gbc.gridy++;
215+
h.attach(inner,gbc); gbc.gridy++;
216+
i.attach(inner,gbc); gbc.gridy++;
217+
j.attach(inner,gbc); gbc.gridy++;
218+
cpanel.add(inner);
217219

218220
frame.setPreferredSize(new Dimension(600, 90));
219221
frame.add(jPanel);

src/main/java/com/marginallyclever/makelangelo/MainFrame.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.marginallyclever.convenience.FileAccess;
1010
import com.marginallyclever.donatello.Donatello;
1111
import com.marginallyclever.donatello.NodeFactoryPanel;
12-
import com.marginallyclever.donatello.actions.undoable.NodeAddAction;
1312
import com.marginallyclever.makelangelo.applicationsettings.MetricsPreferences;
1413
import com.marginallyclever.makelangelo.donatelloimpl.DonatelloDropTarget;
1514
import com.marginallyclever.makelangelo.makeart.io.LoadFilePanel;
@@ -85,18 +84,7 @@ public MainFrame() {
8584
setJMenuBar(mainMenuBar);
8685

8786
setupDropTarget();
88-
connectFactoryToPreview();
89-
}
90-
91-
private void connectFactoryToPreview() {
92-
nodeFactoryPanel.addListener(e->{
93-
var p = donatello.getPopupPoint();
94-
if(p!=null) p = donatello.getPaintArea().transformScreenToWorldPoint(p);
95-
else p = donatello.getPaintArea().getCameraPosition();
96-
97-
var add = new NodeAddAction("Add",donatello,nodeFactoryPanel);
98-
add.commitAdd(e,p);
99-
});
87+
donatello.connectNodeFactory(nodeFactoryPanel);
10088
}
10189

10290
private void initDocking() {

src/main/java/com/marginallyclever/makelangelo/donatelloimpl/DonatelloDropTarget.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private Node loadFile(String absolutePath) {
8585
*/
8686
private Node loadImage(String absPath) {
8787
LoadImage loadImage = new LoadImage();
88-
var first = loadImage.getVariable(0);
88+
var first = loadImage.getPort(0);
8989
if(!(first instanceof Input<?> inputFile)) throw new IllegalStateException("First variable is not an Input");
9090
if(!(inputFile.getValue() instanceof Filename)) throw new IllegalStateException("Input value is not a Filename");
9191
donatello.getGraph().add(loadImage);
@@ -101,7 +101,7 @@ private Node loadImage(String absPath) {
101101
*/
102102
private Node loadVector(String absPath) {
103103
LoadTurtle loadTurtle = new LoadTurtle();
104-
var first = loadTurtle.getVariable(0);
104+
var first = loadTurtle.getPort(0);
105105
if(!(first instanceof InputFilename inputFile)) throw new IllegalStateException("First variable is not an Input");
106106
if(inputFile.getValue() == null) throw new IllegalStateException("Input value is not a Filename");
107107
donatello.getGraph().add(loadTurtle);

src/main/java/com/marginallyclever/makelangelo/donatelloimpl/MakelangeloRegistry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.marginallyclever.makelangelo.donatelloimpl;
22

3+
import com.marginallyclever.makelangelo.donatelloimpl.nodes.points.PointsDAO4JSON;
34
import com.marginallyclever.makelangelo.donatelloimpl.nodes.turtle.TurtleDAO4JSON;
45
import com.marginallyclever.makelangelo.turtle.Turtle;
56
import com.marginallyclever.nodegraphcore.DAO4JSONFactory;
@@ -32,5 +33,6 @@ public void registerNodes() {
3233
public void registerDAO() {
3334
logger.info("Registering makelangelo-software DAOs");
3435
DAO4JSONFactory.registerDAO(new TurtleDAO4JSON());
36+
DAO4JSONFactory.registerDAO(new PointsDAO4JSON());
3537
}
3638
}

src/main/java/com/marginallyclever/makelangelo/donatelloimpl/nodes/Canvas.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,47 @@ public class Canvas extends Node implements PrintWithGraphics {
1515
private final InputInt width = new InputInt("width", 1);
1616
private final InputInt height = new InputInt("height", 1);
1717
private final InputColor color = new InputColor("color", Color.WHITE);
18+
private final InputInt layer = new InputInt("layer",5);
1819
private final OutputInt outx = new OutputInt("x",0);
1920
private final OutputInt outy = new OutputInt("y",0);
2021
private final OutputInt outw = new OutputInt("width",width.getValue());
2122
private final OutputInt outh = new OutputInt("height",height.getValue());
2223

2324
public Canvas() {
2425
super("Canvas");
25-
addVariable(width);
26-
addVariable(height);
27-
addVariable(color);
28-
addVariable(outx);
29-
addVariable(outy);
30-
addVariable(outw);
31-
addVariable(outh);
26+
addPort(width);
27+
addPort(height);
28+
addPort(color);
29+
addPort(outx);
30+
addPort(outy);
31+
addPort(outw);
32+
addPort(outh);
33+
addPort(layer);
3234
}
3335

3436
@Override
3537
public void update() {
3638
var w = Math.max(1,width.getValue());
3739
var h = Math.max(1,height.getValue());
38-
outx.send(0);
39-
outy.send(0);
40-
outw.send(w);
41-
outh.send(h);
40+
outx.setValue(-w/2);
41+
outy.setValue(-h/2);
42+
outw.setValue(w);
43+
outh.setValue(h);
4244
}
4345

4446

4547
@Override
4648
public void print(Graphics g) {
49+
var x = outx.getValue();
50+
var y = outy.getValue();
4751
var w = Math.max(1,width.getValue());
4852
var h = Math.max(1,height.getValue());
4953
g.setColor(color.getValue());
50-
g.fillRect(0,0,w,h);
54+
g.fillRect(x,y,w,h);
55+
}
56+
57+
@Override
58+
public int getLayer() {
59+
return layer.getValue();
5160
}
5261
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.marginallyclever.makelangelo.donatelloimpl.nodes.points;
2+
3+
import com.marginallyclever.donatello.ports.InputDouble;
4+
import com.marginallyclever.donatello.ports.InputNumber;
5+
import com.marginallyclever.donatello.ports.InputOneOfMany;
6+
import com.marginallyclever.nodegraphcore.Node;
7+
8+
import javax.vecmath.Matrix3d;
9+
import javax.vecmath.Point2d;
10+
import javax.vecmath.Point3d;
11+
import java.util.stream.IntStream;
12+
13+
/**
14+
* Create a grid of points controlled by the number (quantity) and spacing (distance between points).
15+
*/
16+
public class GridOfPoints extends Node {
17+
private final InputNumber Xa = new InputNumber("Xa",10);
18+
private final InputNumber Xb = new InputNumber("Xb",10d);
19+
private final InputNumber Ya = new InputNumber("Ya",10);
20+
private final InputNumber Yb = new InputNumber("Yb",10d);
21+
private final InputOneOfMany style = new InputOneOfMany("style");
22+
private final InputDouble angle = new InputDouble("angle");
23+
private final OutputPoints output = new OutputPoints("output");
24+
25+
public GridOfPoints() {
26+
super("GridOfPoints");
27+
addPort(Xa);
28+
addPort(Xb);
29+
addPort(Ya);
30+
addPort(Yb);
31+
addPort(style);
32+
addPort(angle);
33+
addPort(output);
34+
35+
style.setOptions(new String[]{"a * b","b / (a count)","b / (a distance)"});
36+
}
37+
38+
@Override
39+
public void update() {
40+
// we're going to make a grid nx,ny with margin dx,dy.
41+
int nx,ny;
42+
double dx, dy;
43+
44+
var list = new ListOfPoints();
45+
switch(style.getValue()) {
46+
case 2: {
47+
// d = a
48+
// n = total distance (b) divided by spacing (a)
49+
dx = Math.max(1, Xa.getValue().doubleValue());
50+
dy = Math.max(1, Ya.getValue().doubleValue());
51+
nx = (int)Math.max(1, Xb.getValue().doubleValue() / dx);
52+
ny = (int)Math.max(1, Yb.getValue().doubleValue() / dy);
53+
break;
54+
}
55+
case 1: {
56+
// n = a
57+
// d = total distance (b) divided by number of points (a).
58+
nx = Math.max(1, Xa.getValue().intValue());
59+
ny = Math.max(1, Ya.getValue().intValue());
60+
dx = Xb.getValue().doubleValue() / nx;
61+
dy = Yb.getValue().doubleValue() / ny;
62+
break;
63+
}
64+
default: {
65+
// n = a
66+
// d = b
67+
nx = Math.max(1, Xa.getValue().intValue());
68+
ny = Math.max(1, Ya.getValue().intValue());
69+
dx = Xb.getValue().doubleValue();
70+
dy = Yb.getValue().doubleValue();
71+
break;
72+
}
73+
}
74+
75+
double halfX = (nx*dx) / 2;
76+
double halfY = (ny*dy) / 2;
77+
Matrix3d transform = new Matrix3d();
78+
transform.rotZ(Math.toRadians(angle.getValue()));
79+
80+
// now make the grid
81+
IntStream.range(0,ny).forEach(y -> {
82+
IntStream.range(0,nx).forEach(x -> {
83+
var p = new Point3d(x * dx - halfX, y * dy - halfY,0d);
84+
transform.transform(p);
85+
list.add(new Point2d(p.x, p.y));
86+
});
87+
});
88+
output.setValue(list);
89+
}
90+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.marginallyclever.makelangelo.donatelloimpl.nodes.points;
2+
3+
import com.marginallyclever.nodegraphcore.port.Input;
4+
5+
/**
6+
* {@link Input} for a {@link ListOfPoints}.
7+
*/
8+
public class InputPoints extends Input<ListOfPoints> {
9+
public InputPoints(String _name) throws IllegalArgumentException {
10+
super(_name, ListOfPoints.class, new ListOfPoints());
11+
}
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.marginallyclever.makelangelo.donatelloimpl.nodes.points;
2+
3+
import javax.vecmath.Point2d;
4+
import java.util.ArrayList;
5+
6+
/**
7+
* A list of 2D points with double precision.
8+
*/
9+
public class ListOfPoints extends ArrayList<Point2d> {}

0 commit comments

Comments
 (0)