mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Ground symbol enhancements
This commit is contained in:
@@ -38,7 +38,8 @@ import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Ground", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
||||
instanceNamePrefix = "GND", description = "Ground schematic symbol",
|
||||
@@ -54,15 +55,16 @@ public class GroundSymbol extends AbstractComponent<Void> implements ICommonNode
|
||||
private Color color = COLOR;
|
||||
private Size size = SIZE;
|
||||
private GroundSymbolType type = GroundSymbolType.DEFAULT;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private Orientation orientation = Orientation.DEFAULT;
|
||||
private Integer stroke = 1;
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
double sizePx = size.convertToPixels();
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
g2d.setColor(color);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((float)getStroke()));
|
||||
|
||||
double x = point.getX();
|
||||
double y = point.getY();
|
||||
|
||||
@@ -77,19 +79,26 @@ public class GroundSymbol extends AbstractComponent<Void> implements ICommonNode
|
||||
g2d.rotate(Math.PI * 3 / 2, point.getX(), point.getY());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Polygon poly =
|
||||
new Polygon(new int[] {(int)(x - sizePx / 2), (int)(x + sizePx / 2), (int)x}, new int[] {(int)(y + sizePx / 6), (int)(y + sizePx / 6),
|
||||
(int)(y + sizePx)}, 3);
|
||||
|
||||
g2d.setColor(Constants.TRANSPARENT_COLOR);
|
||||
g2d.fill(poly);
|
||||
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
g2d.setColor(color);
|
||||
g2d.drawLine((int)x, (int)y, (int)x, (int)(y + sizePx / 6));
|
||||
if (type == GroundSymbolType.DEFAULT) {
|
||||
double delta = sizePx / 7;
|
||||
double delta = sizePx / 7.5;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
g2d.drawLine((int)(x - sizePx / 2 + delta * i), (int)(y + sizePx / 6 * (i + 1)), (int)(x + sizePx / 2 - delta * i), (int)(y + sizePx / 6
|
||||
* (i + 1)));
|
||||
}
|
||||
} else {
|
||||
Polygon poly =
|
||||
new Polygon(new int[] {(int)(x - sizePx / 2), (int)(x + sizePx / 2), (int)x}, new int[] {(int)(y + sizePx / 6), (int)(y + sizePx / 6),
|
||||
(int)(y + sizePx)}, 3);
|
||||
g2d.draw(poly);
|
||||
} else {
|
||||
g2d.draw(poly);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +123,18 @@ public class GroundSymbol extends AbstractComponent<Void> implements ICommonNode
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public int getStroke() {
|
||||
if (stroke == null) {
|
||||
stroke = 1;
|
||||
}
|
||||
return stroke;
|
||||
}
|
||||
|
||||
public void setStroke(int stroke) {
|
||||
this.stroke = stroke;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public Orientation getOrientation() {
|
||||
if (orientation == null)
|
||||
|
||||
Reference in New Issue
Block a user