mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
better measurement
This commit is contained in:
+11
-13
@@ -1,7 +1,6 @@
|
||||
package org.diylc.components.boards;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -27,7 +26,7 @@ public class PerfBoard extends AbstractBoard {
|
||||
|
||||
private static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
private static Size PAD_SIZE = new Size(0.08d, SizeUnit.in);
|
||||
private static Size HOLE_SIZE = new Size(0.8d, SizeUnit.mm);
|
||||
private static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
|
||||
|
||||
// private Area copperArea;
|
||||
private Size spacing = SPACING;
|
||||
@@ -53,21 +52,20 @@ public class PerfBoard extends AbstractBoard {
|
||||
/ MAX_ALPHA));
|
||||
}
|
||||
Point p = new Point(controlPoints[0]);
|
||||
int radius = PAD_SIZE.convertToPixels() / 2;
|
||||
int holeRadius = HOLE_SIZE.convertToPixels() / 2;
|
||||
g2d.setStroke(new BasicStroke(radius));
|
||||
int diameter = getClosestOdd(PAD_SIZE.convertToPixels());
|
||||
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||
int spacing = this.spacing.convertToPixels();
|
||||
|
||||
while (p.y < controlPoints[1].y - spacing.convertToPixels()) {
|
||||
while (p.y < controlPoints[1].y - spacing) {
|
||||
p.x = controlPoints[0].x;
|
||||
p.y += spacing.convertToPixels();
|
||||
while (p.x < controlPoints[1].x - spacing.convertToPixels()) {
|
||||
p.x += spacing.convertToPixels();
|
||||
p.y += spacing;
|
||||
while (p.x < controlPoints[1].x - spacing) {
|
||||
p.x += spacing;
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillOval(p.x - radius, p.y - radius, radius * 2, radius * 2);
|
||||
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d
|
||||
.fillOval(p.x - holeRadius, p.y - holeRadius, holeRadius * 2,
|
||||
holeRadius * 2);
|
||||
g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
||||
holeDiameter);
|
||||
}
|
||||
}
|
||||
g2d.setComposite(oldComposite);
|
||||
|
||||
+11
-10
@@ -26,7 +26,7 @@ public class VeroBoard extends AbstractBoard {
|
||||
|
||||
private static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
private static Size STRIP_SIZE = new Size(0.085d, SizeUnit.in);
|
||||
private static Size HOLE_SIZE = new Size(0.8d, SizeUnit.mm);
|
||||
private static Size HOLE_SIZE = new Size(0.7d, SizeUnit.mm);
|
||||
|
||||
// private Area copperArea;
|
||||
private Size spacing = SPACING;
|
||||
@@ -52,17 +52,18 @@ public class VeroBoard extends AbstractBoard {
|
||||
/ MAX_ALPHA));
|
||||
}
|
||||
Point p = new Point(controlPoints[0]);
|
||||
int stripSize = STRIP_SIZE.convertToPixels() / 2 * 2;
|
||||
int holeRadius = HOLE_SIZE.convertToPixels() / 2;
|
||||
int stripSize = getClosestOdd(STRIP_SIZE.convertToPixels());
|
||||
int holeRadius = getClosestOdd(HOLE_SIZE.convertToPixels() / 2);
|
||||
int spacing = this.spacing.convertToPixels();
|
||||
|
||||
while (p.y < controlPoints[1].y - spacing.convertToPixels()) {
|
||||
while (p.y < controlPoints[1].y - spacing) {
|
||||
p.x = controlPoints[0].x;
|
||||
p.y += spacing.convertToPixels();
|
||||
p.y += spacing;
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(p.x + SPACING.convertToPixels() / 2, p.y - stripSize / 2,
|
||||
controlPoints[1].x - spacing.convertToPixels() - p.x, stripSize);
|
||||
while (p.x < controlPoints[1].x - spacing.convertToPixels()) {
|
||||
p.x += spacing.convertToPixels();
|
||||
controlPoints[1].x - spacing - p.x, stripSize);
|
||||
while (p.x < controlPoints[1].x - spacing) {
|
||||
p.x += spacing;
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d
|
||||
.fillOval(p.x - holeRadius, p.y - holeRadius, holeRadius * 2,
|
||||
@@ -153,7 +154,7 @@ public class VeroBoard extends AbstractBoard {
|
||||
g2d.setColor(COPPER_COLOR);
|
||||
g2d.fillRect(4, width / 4, width - 8, width / 2);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
g2d.fillOval(width / 3 - 1, width / 2 - 1, 2, 2);
|
||||
g2d.fillOval(2 * width / 3 - 1, width / 2 - 1, 2, 2);
|
||||
g2d.fillOval(width / 3 - 1, width / 2 - 1, 3, 3);
|
||||
g2d.fillOval(2 * width / 3 - 1, width / 2 - 1, 3, 3);
|
||||
}
|
||||
}
|
||||
|
||||
+35
-10
@@ -2,8 +2,9 @@ package org.diylc.components.connectivity;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
|
||||
import org.diylc.components.AbstractSinglePointComponent;
|
||||
import org.diylc.components.AbstractComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.Project;
|
||||
@@ -14,7 +15,7 @@ import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD + 0.1)
|
||||
public class SolderPad extends AbstractSinglePointComponent {
|
||||
public class SolderPad extends AbstractComponent<Color> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -24,11 +25,12 @@ public class SolderPad extends AbstractSinglePointComponent {
|
||||
|
||||
private Size size = SIZE;
|
||||
private Color color = COLOR;
|
||||
private Point point = new Point(0, 0);
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, Project project) {
|
||||
int diameter = size.convertToPixels();
|
||||
int holeDiameter = HOLE_SIZE.convertToPixels();
|
||||
int diameter = getClosestOdd(size.convertToPixels());
|
||||
int holeDiameter = getClosestOdd(HOLE_SIZE.convertToPixels());
|
||||
g2d.setColor(color);
|
||||
g2d.fillOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
@@ -38,8 +40,8 @@ public class SolderPad extends AbstractSinglePointComponent {
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
int diameter = width / 2;
|
||||
int holeDiameter = 4;
|
||||
int diameter = getClosestOdd(width / 2);
|
||||
int holeDiameter = 5;
|
||||
g2d.setColor(COLOR);
|
||||
g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter);
|
||||
g2d.setColor(Constants.CANVAS_COLOR);
|
||||
@@ -56,12 +58,35 @@ public class SolderPad extends AbstractSinglePointComponent {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Color getColor() {
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getControlPointCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point getControlPoint(int index) {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlPoint(Point point, int index) {
|
||||
this.point.setLocation(point);
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Color")
|
||||
@Override
|
||||
public Color getValue() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
@Override
|
||||
public void setValue(Color value) {
|
||||
this.color = value;
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -79,4 +79,10 @@ public class TraceCut extends AbstractSinglePointComponent {
|
||||
public void setBorderColor(Color borderColor) {
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName();
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -179,13 +179,13 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
g2d.draw(body);
|
||||
}
|
||||
if (componentState != ComponentState.DRAGGING) {
|
||||
int circleRadius = CIRCLE_SIZE.convertToPixels() / 2;
|
||||
int lugWidth = LUG_WIDTH.convertToPixels();
|
||||
int lugHeight = LUG_HEIGHT.convertToPixels();
|
||||
int circleDiameter = getClosestOdd(CIRCLE_SIZE.convertToPixels());
|
||||
int lugWidth = getClosestOdd(LUG_WIDTH.convertToPixels());
|
||||
int lugHeight = getClosestOdd(LUG_HEIGHT.convertToPixels());
|
||||
for (Point p : controlPoints) {
|
||||
g2d.setColor(CIRCLE_COLOR);
|
||||
g2d.fillOval(p.x - circleRadius, p.y - circleRadius, 2 * circleRadius,
|
||||
2 * circleRadius);
|
||||
g2d.fillOval(p.x - circleDiameter / 2, p.y - circleDiameter / 2,
|
||||
circleDiameter, circleDiameter);
|
||||
g2d.setColor(LUG_COLOR);
|
||||
g2d.fillRect(p.x - lugWidth / 2, p.y - lugHeight / 2, lugWidth, lugHeight);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user