improvements

This commit is contained in:
Bane Stojkovic
2026-08-17 10:30:29 +02:00
parent c978bc6733
commit 0a76439583
9 changed files with 92 additions and 48 deletions
@@ -425,10 +425,10 @@ public abstract class AbstractMakerBoard extends AbstractTransparentComponent<Vo
if (minX == Double.MAX_VALUE) {
Point2D p0 = (controlPoints != null && controlPoints.length > 0 && controlPoints[0] != null)
? controlPoints[0] : new Point2D.Double(0, 0);
return new Rectangle2D.Double(p0.getX() - 20, p0.getY() - 20, 40, 40);
return new Rectangle2D.Double(p0.getX() - 50, p0.getY() - 50, 100, 100);
}
int margin = 20;
int margin = 50;
return new Rectangle2D.Double(minX - margin, minY - margin, (maxX - minX) + 2 * margin, (maxY - minY) + 2 * margin);
}
}
@@ -213,12 +213,39 @@ public class WS2812BStick extends AbstractMakerBoard {
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
double rectX = 2;
double rectY = height / 2.0 - 5;
double rectW = width - 4;
double rectH = 10;
g2d.setColor(NEO_BLACK);
g2d.fill(new RoundRectangle2D.Double(2, 10, width - 4, height - 20, 2, 2));
Color[] rainbow = new Color[] { Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.MAGENTA };
for (int i = 0; i < 5; i++) {
g2d.fill(new RoundRectangle2D.Double(rectX, rectY, rectW, rectH, 2, 2));
g2d.setColor(Color.DARK_GRAY);
g2d.draw(new RoundRectangle2D.Double(rectX, rectY, rectW, rectH, 2, 2));
Color[] rainbow = new Color[] {
Color.decode("#FF3333"), // Red
Color.decode("#FFD700"), // Yellow
Color.decode("#00E676"), // Green
Color.decode("#00E5FF"), // Cyan
Color.decode("#E040FB") // Magenta
};
double dotSize = Math.max(3.0, Math.min(4.0, rectH - 4.0));
double margin = 3.0;
double step = (rectW - 2 * margin - dotSize) / (rainbow.length - 1);
for (int i = 0; i < rainbow.length; i++) {
double dotX = rectX + margin + i * step;
double dotY = height / 2.0 - dotSize / 2.0;
// 5050 package mini white backing
g2d.setColor(Color.WHITE);
g2d.fill(new Rectangle2D.Double(dotX - 0.5, dotY - 0.5, dotSize + 1, dotSize + 1));
// RGB LED dot
g2d.setColor(rainbow[i]);
g2d.fill(new Ellipse2D.Double(4 + i * 6, height / 2 - 2, 4, 4));
g2d.fill(new Ellipse2D.Double(dotX, dotY, dotSize, dotSize));
}
}
}
@@ -72,7 +72,7 @@ public class ArduinoMega extends AbstractMakerBoard {
// Digital Low (24..31)
"D0 (RX0)", "D1 (TX0)", "D2", "D3 (~)", "D4", "D5 (~)", "D6 (~)", "D7",
// Digital High (32..41)
"D8", "D9 (~)", "D10 (~)", "D11 (~)", "D12", "D13", "GND", "AREF", "SDA", "SCL",
"D8", "D9 (~)", "D10 (~)", "D11 (~)", "D12", "D13", "GND3", "AREF", "SDA", "SCL",
// Communication Header (42..49)
"D14 (TX3)", "D15 (RX3)", "D16 (TX2)", "D17 (RX2)", "D18 (TX1)", "D19 (RX1)", "D20 (SDA)", "D21 (SCL)",
// Double Digital 2x18 Header (50..85: D22..D53, 5V, 5V, GND, GND)
@@ -64,7 +64,7 @@ public class ArduinoNano extends AbstractMakerBoard {
public static final String[] PIN_NAMES = new String[] {
// Left row (0..14)
"D13", "3V3", "REF", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "5V", "RST", "GND", "VIN",
"D13", "3V3", "REF", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "5V", "RST1", "GND1", "VIN",
// Right row (15..29)
"TX1", "RX0", "RST2", "GND2", "D2", "D3 (~)", "D4", "D5 (~)", "D6 (~)", "D7", "D8", "D9 (~)", "D10 (~)", "D11 (~)", "D12",
// ICSP (30..35)
@@ -73,7 +73,7 @@ public class ArduinoUno extends AbstractMakerBoard {
// Digital Low (14..21)
"D0 (RX)", "D1 (TX)", "D2", "D3 (~)", "D4", "D5 (~)", "D6 (~)", "D7",
// Digital High (22..31)
"D8", "D9 (~)", "D10 (~)", "D11 (~)", "D12", "D13", "GND", "AREF", "SDA", "SCL",
"D8", "D9 (~)", "D10 (~)", "D11 (~)", "D12", "D13", "GND3", "AREF", "SDA", "SCL",
// ICSP (32..37)
"MISO", "5V_ICSP", "SCK", "MOSI", "RST_ICSP", "GND_ICSP"
};
@@ -62,26 +62,26 @@ public class RaspberryPi extends AbstractMakerBoard {
public static Size BOARD_HEIGHT = new Size(56.0d, SizeUnit.mm);
public static final String[] PIN_NAMES = new String[] {
"Pin 1 (3.3V)", "Pin 2 (5V)",
"Pin 3 (GPIO2/SDA)", "Pin 4 (5V)",
"Pin 5 (GPIO3/SCL)", "Pin 6 (GND)",
"Pin 7 (GPIO4)", "Pin 8 (GPIO14/TXD)",
"Pin 9 (GND)", "Pin 10 (GPIO15/RXD)",
"Pin 11 (GPIO17)", "Pin 12 (GPIO18)",
"Pin 13 (GPIO27)", "Pin 14 (GND)",
"Pin 15 (GPIO22)", "Pin 16 (GPIO23)",
"Pin 17 (3.3V)", "Pin 18 (GPIO24)",
"Pin 19 (GPIO10/MOSI)", "Pin 20 (GND)",
"Pin 21 (GPIO9/MISO)", "Pin 22 (GPIO25)",
"Pin 23 (GPIO11/SCLK)", "Pin 24 (GPIO8/CE0)",
"Pin 25 (GND)", "Pin 26 (GPIO7/CE1)",
"Pin 27 (ID_SD)", "Pin 28 (ID_SC)",
"Pin 29 (GPIO5)", "Pin 30 (GND)",
"Pin 31 (GPIO6)", "Pin 32 (GPIO12)",
"Pin 33 (GPIO13)", "Pin 34 (GND)",
"Pin 35 (GPIO19)", "Pin 36 (GPIO16)",
"Pin 37 (GPIO26)", "Pin 38 (GPIO20)",
"Pin 39 (GND)", "Pin 40 (GPIO21)"
"3.3V (Pin 1)", "5V (Pin 2)",
"GPIO2/SDA (Pin 3)", "5V (Pin 4)",
"GPIO3/SCL (Pin 5)", "GND (Pin 6)",
"GPIO4 (Pin 7)", "GPIO14/TXD (Pin 8)",
"GND (Pin 9)", "GPIO15/RXD (Pin 10)",
"GPIO17 (Pin 11)", "GPIO18 (Pin 12)",
"GPIO27 (Pin 13)", "GND (Pin 14)",
"GPIO22 (Pin 15)", "GPIO23 (Pin 16)",
"3.3V (Pin 17)", "GPIO24 (Pin 18)",
"GPIO10/MOSI (Pin 19)", "GND (Pin 20)",
"GPIO9/MISO (Pin 21)", "GPIO25 (Pin 22)",
"GPIO11/SCLK (Pin 23)", "GPIO8/CE0 (Pin 24)",
"GND (Pin 25)", "GPIO7/CE1 (Pin 26)",
"ID_SD (Pin 27)", "ID_SC (Pin 28)",
"GPIO5 (Pin 29)", "GND (Pin 30)",
"GPIO6 (Pin 31)", "GPIO12 (Pin 32)",
"GPIO13 (Pin 33)", "GND (Pin 34)",
"GPIO19 (Pin 35)", "GPIO16 (Pin 36)",
"GPIO26 (Pin 37)", "GPIO20 (Pin 38)",
"GND (Pin 39)", "GPIO21 (Pin 40)"
};
public RaspberryPi() {
@@ -103,15 +103,15 @@ public class RaspberryPi extends AbstractMakerBoard {
Point2D firstPoint = controlPoints[0];
double spacing = PIN_SPACING.convertToPixels();
// 2x20 header: Pin 1 at (0,0), Pin 2 at (0, spacing), Pin 3 at (spacing, 0), Pin 4 at (spacing, spacing)...
// 2x20 header: Pin 1 at (0,0), Pin 2 at (0, -spacing), Pin 3 at (spacing, 0), Pin 4 at (spacing, -spacing)...
double[][] relativeOffsets = new double[40][2];
for (int col = 0; col < 20; col++) {
int pinOdd = col * 2; // Pin 1, 3, 5... (bottom row of header)
int pinEven = col * 2 + 1; // Pin 2, 4, 6... (top row of header)
int pinOdd = col * 2; // Pin 1, 3, 5... (bottom/inner row of header)
int pinEven = col * 2 + 1; // Pin 2, 4, 6... (top/outer row of header)
relativeOffsets[pinOdd][0] = col * spacing;
relativeOffsets[pinOdd][1] = spacing;
relativeOffsets[pinOdd][1] = 0;
relativeOffsets[pinEven][0] = col * spacing;
relativeOffsets[pinEven][1] = 0;
relativeOffsets[pinEven][1] = -spacing;
}
rotatePoints(firstPoint, relativeOffsets);
@@ -125,7 +125,7 @@ public class RaspberryPi extends AbstractMakerBoard {
double boardW = BOARD_WIDTH.convertToPixels();
double boardH = BOARD_HEIGHT.convertToPixels();
double boardX = x - 60;
double boardY = y - 30;
double boardY = y - 50;
return new RoundRectangle2D.Double(boardX, boardY, boardW, boardH, 16, 16);
}
@@ -148,7 +148,7 @@ public class RaspberryPi extends AbstractMakerBoard {
double boardW = BOARD_WIDTH.convertToPixels();
double boardH = BOARD_HEIGHT.convertToPixels();
double boardX = x - 60;
double boardY = y - 30;
double boardY = y - 50;
Shape boardShape = getBodyShape();
@@ -188,7 +188,7 @@ public class RaspberryPi extends AbstractMakerBoard {
g2d.setFont(SILK_FONT_LARGE);
StringUtils.drawCenteredText(g2d, "Raspberry Pi", boardX + 120, boardY + 120, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
g2d.setFont(SILK_FONT_SMALL);
StringUtils.drawCenteredText(g2d, "40-PIN GPIO", x + 190, y - 10, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
StringUtils.drawCenteredText(g2d, "40-PIN GPIO", x + 190, y - 32, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
g2d.setTransform(oldTx);
@@ -81,12 +81,12 @@ public class RaspberryPiZero extends AbstractMakerBoard {
double[][] relativeOffsets = new double[40][2];
for (int col = 0; col < 20; col++) {
int pinOdd = col * 2;
int pinEven = col * 2 + 1;
int pinOdd = col * 2; // Pin 1, 3, 5... (bottom/inner row of header)
int pinEven = col * 2 + 1; // Pin 2, 4, 6... (top/outer row of header)
relativeOffsets[pinOdd][0] = col * spacing;
relativeOffsets[pinOdd][1] = spacing;
relativeOffsets[pinOdd][1] = 0;
relativeOffsets[pinEven][0] = col * spacing;
relativeOffsets[pinEven][1] = 0;
relativeOffsets[pinEven][1] = -spacing;
}
rotatePoints(firstPoint, relativeOffsets);
@@ -100,7 +100,7 @@ public class RaspberryPiZero extends AbstractMakerBoard {
double boardW = BOARD_WIDTH.convertToPixels();
double boardH = BOARD_HEIGHT.convertToPixels();
double boardX = x - 55;
double boardY = y - 25;
double boardY = y - 45;
return new RoundRectangle2D.Double(boardX, boardY, boardW, boardH, 12, 12);
}
@@ -123,7 +123,7 @@ public class RaspberryPiZero extends AbstractMakerBoard {
double boardW = BOARD_WIDTH.convertToPixels();
double boardH = BOARD_HEIGHT.convertToPixels();
double boardX = x - 55;
double boardY = y - 25;
double boardY = y - 45;
Shape boardShape = getBodyShape();
@@ -145,9 +145,9 @@ public class RaspberryPiZero extends AbstractMakerBoard {
drawMountingHole(g2d, boardX + boardW - 25, boardY + boardH - 25, 20);
// Mini HDMI & Dual Micro-USB
drawMetalConnector(g2d, boardX + 80, boardY + boardH - 12, 45, 24, "HDMI");
drawMetalConnector(g2d, boardX + 240, boardY + boardH - 12, 40, 24, "USB");
drawMetalConnector(g2d, boardX + 340, boardY + boardH - 12, 40, 24, "PWR");
drawMetalConnector(g2d, boardX + 80, boardY + boardH - 8, 65, 40, "HDMI");
drawMetalConnector(g2d, boardX + 240, boardY + boardH - 8, 55, 40, "USB");
drawMetalConnector(g2d, boardX + 350, boardY + boardH - 8, 55, 40, "PWR");
// SoC chip
drawChip(g2d, boardX + 150, boardY + 80, 80, 80, "RPi SoC");
@@ -222,10 +222,10 @@ public abstract class AbstractMotor extends AbstractTransparentComponent<Void> {
if (minX == Double.MAX_VALUE) {
Point2D p0 = (controlPoints != null && controlPoints.length > 0 && controlPoints[0] != null)
? controlPoints[0] : new Point2D.Double(0, 0);
return new Rectangle2D.Double(p0.getX() - 20, p0.getY() - 20, 40, 40);
return new Rectangle2D.Double(p0.getX() - 50, p0.getY() - 50, 100, 100);
}
int margin = 20;
int margin = 50;
return new Rectangle2D.Double(minX - margin, minY - margin, (maxX - minX) + 2 * margin, (maxY - minY) + 2 * margin);
}
}
@@ -225,4 +225,21 @@ public class MakerComponentsTest {
}
}
}
@Test
public void testControlPointsAreDistinct() throws Exception {
for (Class<? extends IDIYComponent<?>> clazz : allMakerComponentClasses) {
IDIYComponent<?> component = clazz.getDeclaredConstructor().newInstance();
component.setControlPoint(new Point2D.Double(200, 200), 0);
int count = component.getControlPointCount();
for (int i = 0; i < count; i++) {
Point2D p1 = component.getControlPoint(i);
for (int j = i + 1; j < count; j++) {
Point2D p2 = component.getControlPoint(j);
Assert.assertTrue("Duplicate control point coordinates detected between point " + i + " and point " + j + " in " + clazz.getSimpleName(),
p1.distance(p2) > 0.001);
}
}
}
}
}