mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Ability to change pitch and appearance of PCB Terminal Block component
This commit is contained in:
@@ -4449,6 +4449,10 @@
|
|||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Ability to set explicit dimensions of basic shapes - rectangles and ellipses</description>
|
<description>Ability to set explicit dimensions of basic shapes - rectangles and ellipses</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Ability to change pitch and appearance of PCB Terminal Block component</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
|||||||
Binary file not shown.
@@ -54,11 +54,6 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static Size SPACING = new Size(5d, SizeUnit.mm);
|
|
||||||
private static Size WIDTH = new Size(7.7d, SizeUnit.mm);
|
|
||||||
private static Size CIRCLE_SIZE = new Size(3d, SizeUnit.mm);
|
|
||||||
private static Size OFFSET = new Size(4.5d, SizeUnit.mm);
|
|
||||||
|
|
||||||
private static Color BODY_COLOR = Color.decode("#90AB66");
|
private static Color BODY_COLOR = Color.decode("#90AB66");
|
||||||
private static Color BORDER_COLOR = BODY_COLOR.darker();
|
private static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
private static Color CIRCLE_COLOR = LIGHT_METAL_COLOR;
|
private static Color CIRCLE_COLOR = LIGHT_METAL_COLOR;
|
||||||
@@ -70,6 +65,10 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
|
|
||||||
private Color bodyColor = BODY_COLOR;
|
private Color bodyColor = BODY_COLOR;
|
||||||
private Color borderColor = BORDER_COLOR;
|
private Color borderColor = BORDER_COLOR;
|
||||||
|
|
||||||
|
private Size pitch = new Size(0.2d, SizeUnit.in);
|
||||||
|
private Size width = new Size(0.3d, SizeUnit.in);
|
||||||
|
private ScrewPosition screwPosition = ScrewPosition.Offset;
|
||||||
|
|
||||||
public PCBTerminalBlock() {
|
public PCBTerminalBlock() {
|
||||||
super();
|
super();
|
||||||
@@ -78,7 +77,7 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
|
|
||||||
private void updateControlPoints() {
|
private void updateControlPoints() {
|
||||||
Point2D firstPoint = controlPoints[0];
|
Point2D firstPoint = controlPoints[0];
|
||||||
int spacing = (int) SPACING.convertToPixels();
|
int spacing = (int) getPitch().convertToPixels();
|
||||||
controlPoints = new Point2D[count.getCount()];
|
controlPoints = new Point2D[count.getCount()];
|
||||||
controlPoints[0] = firstPoint;
|
controlPoints[0] = firstPoint;
|
||||||
|
|
||||||
@@ -150,6 +149,49 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
// Reset body shape.
|
// Reset body shape.
|
||||||
body = null;
|
body = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Size getPitch() {
|
||||||
|
if (pitch == null) {
|
||||||
|
pitch = new Size(0.2d, SizeUnit.in);
|
||||||
|
}
|
||||||
|
return pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPitch(Size pitch) {
|
||||||
|
this.pitch = pitch;
|
||||||
|
updateControlPoints();
|
||||||
|
// Reset body shape.
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public Size getWidth() {
|
||||||
|
if (width == null) {
|
||||||
|
width = new Size(0.3, SizeUnit.mm);
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(Size width) {
|
||||||
|
this.width = width;
|
||||||
|
// Reset body shape.
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Screw Position")
|
||||||
|
public ScrewPosition getScrewPosition() {
|
||||||
|
if (screwPosition == null) {
|
||||||
|
screwPosition = ScrewPosition.Offset;
|
||||||
|
}
|
||||||
|
return screwPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScrewPosition(ScrewPosition screwPosition) {
|
||||||
|
this.screwPosition = screwPosition;
|
||||||
|
// Reset body shape.
|
||||||
|
body = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
||||||
@@ -192,7 +234,7 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
// so far.
|
// so far.
|
||||||
drawingObserver.stopTracking();
|
drawingObserver.stopTracking();
|
||||||
// Draw lugs.
|
// Draw lugs.
|
||||||
int circleDiameter = getClosestOdd((int) CIRCLE_SIZE.convertToPixels());
|
int circleDiameter = getClosestOdd((int) (getPitch().convertToPixels() * 3d / 5));
|
||||||
|
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2f));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2f));
|
||||||
for (Point2D p : controlPoints) {
|
for (Point2D p : controlPoints) {
|
||||||
@@ -222,10 +264,15 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
if (body == null) {
|
if (body == null) {
|
||||||
body = new Shape[2];
|
body = new Shape[2];
|
||||||
Point2D firstPoint = controlPoints[0];
|
Point2D firstPoint = controlPoints[0];
|
||||||
int spacing = (int) SPACING.convertToPixels();
|
int spacing = (int) getPitch().convertToPixels();
|
||||||
int pointCount = count.getCount();
|
int pointCount = count.getCount();
|
||||||
int width = (int) WIDTH.convertToPixels();
|
int width = (int) getWidth().convertToPixels();
|
||||||
int offset = (int) OFFSET.convertToPixels();
|
int offset;
|
||||||
|
if (getScrewPosition() == ScrewPosition.Central) {
|
||||||
|
offset = (int) (getWidth().convertToPixels() / 2);
|
||||||
|
} else {
|
||||||
|
offset = (int) ((getWidth().convertToPixels() - getPitch().convertToPixels()) + getPitch().convertToPixels() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
body[0] = new Rectangle2D.Double(firstPoint.getX() - offset, firstPoint.getY() - spacing / 2,
|
body[0] = new Rectangle2D.Double(firstPoint.getX() - offset, firstPoint.getY() - spacing / 2,
|
||||||
width, pointCount * spacing);
|
width, pointCount * spacing);
|
||||||
@@ -322,4 +369,8 @@ public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBl
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum ScrewPosition {
|
||||||
|
Central, Offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user