mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
make grid spacing flexible
This commit is contained in:
+6
-3
@@ -11,7 +11,8 @@ import org.diylc.components.AbstractTransparentComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.utils.Constants;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
public abstract class AbstractBoard extends AbstractTransparentComponent<String> {
|
||||
|
||||
@@ -19,12 +20,14 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
||||
|
||||
public static Color BOARD_COLOR = Color.decode("#BCED91");
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
|
||||
public static Size DEFAULT_HEIGHT = new Size(1d, SizeUnit.in);
|
||||
|
||||
protected String name;
|
||||
protected String value;
|
||||
protected Point[] controlPoints = new Point[] {
|
||||
new Point((int) (-5 * Constants.GRID), (int) (-5 * Constants.GRID)),
|
||||
new Point((int) (5 * Constants.GRID), (int) (5 * Constants.GRID)) };
|
||||
new Point(-DEFAULT_WIDTH.convertToPixels() / 2, -DEFAULT_HEIGHT.convertToPixels() / 2),
|
||||
new Point(DEFAULT_WIDTH.convertToPixels() / 2, DEFAULT_HEIGHT.convertToPixels() / 2) };
|
||||
|
||||
protected Color boardColor = BOARD_COLOR;
|
||||
protected Color borderColor = BORDER_COLOR;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class HookupWire extends AbstractCurvedComponent<AWG> {
|
||||
@Override
|
||||
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d, ComponentState componentState) {
|
||||
int thickness = (int) (Math.pow(Math.E, -1.12436 - 0.11594 * value.getValue())
|
||||
* Constants.GRID * Constants.GRIDS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
|
||||
* Constants.PIXELS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
|
||||
g2d.setColor(componentState == ComponentState.SELECTED
|
||||
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR : color.darker());
|
||||
g2d.setStroke(new BasicStroke(thickness));
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.diylc.utils.Constants;
|
||||
public class BOM extends AbstractComponent<Void> {
|
||||
|
||||
public static Size DEFAULT_SIZE = new Size(10d, SizeUnit.cm);
|
||||
public static Size SPACING = Constants.GRID_SIZE;
|
||||
public static Size SPACING = new Size(0.1d, SizeUnit.in);
|
||||
public static Color COLOR = Color.black;
|
||||
public static String DEFAULT_TEXT = "No components to show in the Bill of Materials";
|
||||
|
||||
|
||||
-1
@@ -20,7 +20,6 @@ import org.diylc.utils.Constants;
|
||||
public class ProjectInformation extends AbstractComponent<Void> {
|
||||
|
||||
public static Size DEFAULT_SIZE = new Size(10d, SizeUnit.cm);
|
||||
public static Size SPACING = Constants.GRID_SIZE;
|
||||
public static Color COLOR = Color.black;
|
||||
public static String DEFAULT_TEXT = "No components to show in the Bill of Materials";
|
||||
|
||||
|
||||
+34
-22
@@ -41,13 +41,16 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
private String value = "";
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private PinCount pinCount = PinCount._8;
|
||||
private Size pinSpacing = new Size(0.1d, SizeUnit.in);
|
||||
private Size rowSpacing = new Size(0.3d, SizeUnit.in);
|
||||
private Point[] controlPoints = new Point[] { new Point(0, 0),
|
||||
new Point(0, (int) Constants.GRID), new Point(0, (int) (2 * Constants.GRID)),
|
||||
new Point(0, (int) (3 * Constants.GRID)), new Point((int) (3 * Constants.GRID), 0),
|
||||
new Point((int) (3 * Constants.GRID), (int) Constants.GRID),
|
||||
new Point((int) (3 * Constants.GRID), (int) (2 * Constants.GRID)),
|
||||
new Point((int) (3 * Constants.GRID), (int) (3 * Constants.GRID)) };
|
||||
private Point[] controlPoints = new Point[] { new Point(0, 0) };
|
||||
// new Point(0, pinSpacing.convertToPixels()),
|
||||
// new Point(0, 2 * pinSpacing.convertToPixels()),
|
||||
// new Point(0, 3 * pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 0),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 2 * pinSpacing.convertToPixels()),
|
||||
// new Point(3 * pinSpacing.convertToPixels(), 3 * pinSpacing.convertToPixels()) };
|
||||
private Shape body;
|
||||
|
||||
public DIL_IC() {
|
||||
@@ -87,6 +90,15 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
body = null;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Pin spacing")
|
||||
public Size getPinSpacing() {
|
||||
return pinSpacing;
|
||||
}
|
||||
|
||||
public void setPinSpacing(Size pinSpacing) {
|
||||
this.pinSpacing = pinSpacing;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Row spacing")
|
||||
public Size getRowSpacing() {
|
||||
return rowSpacing;
|
||||
@@ -128,26 +140,26 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
dx1 = 0;
|
||||
dy1 = (int) (i * Constants.GRID);
|
||||
dy1 = i * pinSpacing.convertToPixels();
|
||||
dx2 = rowSpacing.convertToPixels();
|
||||
dy2 = (int) (i * Constants.GRID);
|
||||
dy2 = i * pinSpacing.convertToPixels();
|
||||
break;
|
||||
case _90:
|
||||
dx1 = (int) (-i * Constants.GRID);
|
||||
dx1 = -i * pinSpacing.convertToPixels();
|
||||
dy1 = 0;
|
||||
dx2 = (int) (-i * Constants.GRID);
|
||||
dx2 = -i * pinSpacing.convertToPixels();
|
||||
dy2 = rowSpacing.convertToPixels();
|
||||
break;
|
||||
case _180:
|
||||
dx1 = 0;
|
||||
dy1 = (int) (-i * Constants.GRID);
|
||||
dy1 = -i * pinSpacing.convertToPixels();
|
||||
dx2 = -rowSpacing.convertToPixels();
|
||||
dy2 = (int) (-i * Constants.GRID);
|
||||
dy2 = -i * pinSpacing.convertToPixels();
|
||||
break;
|
||||
case _270:
|
||||
dx1 = (int) (i * Constants.GRID);
|
||||
dx1 = i * pinSpacing.convertToPixels();
|
||||
dy1 = 0;
|
||||
dx2 = (int) (i * Constants.GRID);
|
||||
dx2 = i * pinSpacing.convertToPixels();
|
||||
dy2 = rowSpacing.convertToPixels();
|
||||
break;
|
||||
default:
|
||||
@@ -169,26 +181,26 @@ public class DIL_IC extends AbstractTransparentComponent<String> {
|
||||
switch (orientation) {
|
||||
case DEFAULT:
|
||||
width = rowSpacing.convertToPixels() - pinSize;
|
||||
height = (int) ((pinCount.getValue() / 2) * Constants.GRID);
|
||||
height = (pinCount.getValue() / 2) * pinSpacing.convertToPixels();
|
||||
x += pinSize / 2;
|
||||
y -= (int) (Constants.GRID / 2);
|
||||
y -= pinSpacing.convertToPixels() / 2;
|
||||
break;
|
||||
case _90:
|
||||
width = (int) ((pinCount.getValue() / 2) * Constants.GRID);
|
||||
width = (pinCount.getValue() / 2) * pinSpacing.convertToPixels();
|
||||
height = rowSpacing.convertToPixels() - pinSize;
|
||||
x -= (int) (Constants.GRID / 2) + width - Constants.GRID;
|
||||
x -= (pinSpacing.convertToPixels() / 2) + width - pinSpacing.convertToPixels();
|
||||
y += pinSize / 2;
|
||||
break;
|
||||
case _180:
|
||||
width = rowSpacing.convertToPixels() - pinSize;
|
||||
height = (int) ((pinCount.getValue() / 2) * Constants.GRID);
|
||||
height = (pinCount.getValue() / 2) * pinSpacing.convertToPixels();
|
||||
x -= rowSpacing.convertToPixels() - pinSize / 2;
|
||||
y -= (int) (Constants.GRID / 2) + height - Constants.GRID;
|
||||
y -= (pinSpacing.convertToPixels() / 2) + height - pinSpacing.convertToPixels();
|
||||
break;
|
||||
case _270:
|
||||
width = (int) ((pinCount.getValue() / 2) * Constants.GRID);
|
||||
width = (pinCount.getValue() / 2) * pinSpacing.convertToPixels();
|
||||
height = rowSpacing.convertToPixels() - pinSize;
|
||||
x -= (int) (Constants.GRID / 2);
|
||||
x -= pinSpacing.convertToPixels() / 2;
|
||||
y += pinSize / 2;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user