mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
improved few components
This commit is contained in:
@@ -14,6 +14,10 @@
|
|||||||
<string>metric</string>
|
<string>metric</string>
|
||||||
<boolean>true</boolean>
|
<boolean>true</boolean>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<string>default.org.diylc.components.semiconductors.DIL_IC:Value</string>
|
||||||
|
<string>LM366</string>
|
||||||
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<string>default.org.diylc.components.passive.AxialFilmCapacitor:Width</string>
|
<string>default.org.diylc.components.passive.AxialFilmCapacitor:Width</string>
|
||||||
<org.diylc.core.measures.Size>
|
<org.diylc.core.measures.Size>
|
||||||
|
|||||||
Binary file not shown.
+13
-5
@@ -14,7 +14,7 @@ import org.diylc.core.measures.Size;
|
|||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "Trace", description = "Curved copper trace with two control points", zOrder = IDIYComponent.ABOVE_BOARD)
|
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "Trace", description = "Curved copper trace with two control points", zOrder = IDIYComponent.ABOVE_BOARD)
|
||||||
public class CurvedTrace extends AbstractCurvedComponent<Size> {
|
public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -38,13 +38,21 @@ public class CurvedTrace extends AbstractCurvedComponent<Size> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Width")
|
@EditableProperty(name = "Width")
|
||||||
@Override
|
public Size getSize() {
|
||||||
public Size getValue() {
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSize(Size size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Size value) {
|
public Void getValue() {
|
||||||
this.size = value;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Void value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-5
@@ -15,7 +15,7 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Pad", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD + 0.1)
|
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic", description = "test", instanceNamePrefix = "Pad", stretchable = false, zOrder = IDIYComponent.ABOVE_BOARD + 0.1)
|
||||||
public class SolderPad extends AbstractComponent<Color> {
|
public class SolderPad extends AbstractComponent<Void> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -81,13 +81,21 @@ public class SolderPad extends AbstractComponent<Color> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Color")
|
@EditableProperty(name = "Color")
|
||||||
@Override
|
public Color getColor() {
|
||||||
public Color getValue() {
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Color value) {
|
public Void getValue() {
|
||||||
this.color = value;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Void value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-2
@@ -1,6 +1,7 @@
|
|||||||
package org.diylc.components.misc;
|
package org.diylc.components.misc;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@@ -20,12 +21,13 @@ import org.diylc.plugins.file.BomEntry;
|
|||||||
import org.diylc.plugins.file.BomMaker;
|
import org.diylc.plugins.file.BomMaker;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Bill of materials", author = "Branislav Stojkovic", category = "Misc", description = "", instanceNamePrefix = "BOM", zOrder = IDIYComponent.ABOVE_COMPONENT, stretchable = false)
|
@ComponentDescriptor(name = "Bill of Materials", author = "Branislav Stojkovic", category = "Misc", description = "", instanceNamePrefix = "BOM", zOrder = IDIYComponent.ABOVE_COMPONENT, stretchable = false)
|
||||||
public class BOM extends AbstractComponent<Size> {
|
public class BOM extends AbstractComponent<Size> {
|
||||||
|
|
||||||
public static Size DEFAULT_SIZE = new Size(10d, SizeUnit.cm);
|
public static Size DEFAULT_SIZE = new Size(10d, SizeUnit.cm);
|
||||||
public static Size SPACING = Constants.GRID_SIZE;
|
public static Size SPACING = Constants.GRID_SIZE;
|
||||||
public static Color COLOR = Color.black;
|
public static Color COLOR = Color.black;
|
||||||
|
public static String DEFAULT_TEXT = "No components to show in the Bill of Materials";
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Size size = DEFAULT_SIZE;
|
private Size size = DEFAULT_SIZE;
|
||||||
@@ -76,6 +78,7 @@ public class BOM extends AbstractComponent<Size> {
|
|||||||
int columnWidth = size.convertToPixels() / columnCount;
|
int columnWidth = size.convertToPixels() / columnCount;
|
||||||
int entriesPerColumn = (int) Math.ceil(1.d * bom.size() / columnCount);
|
int entriesPerColumn = (int) Math.ceil(1.d * bom.size() / columnCount);
|
||||||
if (entriesPerColumn == 0) {
|
if (entriesPerColumn == 0) {
|
||||||
|
g2d.drawString(DEFAULT_TEXT, point.x, point.y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < bom.size(); i++) {
|
for (int i = 0; i < bom.size(); i++) {
|
||||||
@@ -91,8 +94,32 @@ public class BOM extends AbstractComponent<Size> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
// TODO Auto-generated method stub
|
g2d.setColor(Color.white);
|
||||||
|
g2d.fillRect(width / 8, 0, 6 * width / 8, height - 1);
|
||||||
|
g2d.setColor(Color.black);
|
||||||
|
g2d.drawRect(width / 8, 0, 6 * width / 8, height - 1);
|
||||||
|
g2d.setFont(Constants.LABEL_FONT.deriveFont(1f * 9 * width / 32).deriveFont(Font.PLAIN));
|
||||||
|
|
||||||
|
FontMetrics fontMetrics = g2d.getFontMetrics();
|
||||||
|
Rectangle2D rect = fontMetrics.getStringBounds("BOM", g2d);
|
||||||
|
|
||||||
|
int textHeight = (int) (rect.getHeight());
|
||||||
|
int textWidth = (int) (rect.getWidth());
|
||||||
|
|
||||||
|
// Center text horizontally and vertically.
|
||||||
|
int x = (width - textWidth) / 2 + 1;
|
||||||
|
int y = textHeight + 2;
|
||||||
|
|
||||||
|
g2d.drawString("BOM", x, y);
|
||||||
|
|
||||||
|
g2d.setFont(g2d.getFont().deriveFont(1f * 5 * width / 32));
|
||||||
|
|
||||||
|
fontMetrics = g2d.getFontMetrics();
|
||||||
|
rect = fontMetrics.getStringBounds("resistors", g2d);
|
||||||
|
x = (width - textWidth) / 2 + 1;
|
||||||
|
g2d.drawString("resistors", x, 4 * height / 7);
|
||||||
|
g2d.drawString("tubes", x, 5 * height / 7);
|
||||||
|
g2d.drawString("diodes", x, 6 * height / 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user