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:
@@ -39,6 +39,7 @@ import org.diylc.core.annotations.ComponentDescriptor;
|
|||||||
import org.diylc.core.annotations.EditableProperty;
|
import org.diylc.core.annotations.EditableProperty;
|
||||||
import org.diylc.core.measures.Size;
|
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",
|
@ComponentDescriptor(name = "Ground", author = "Branislav Stojkovic", category = "Schematic Symbols",
|
||||||
instanceNamePrefix = "GND", description = "Ground schematic symbol",
|
instanceNamePrefix = "GND", description = "Ground schematic symbol",
|
||||||
@@ -55,14 +56,15 @@ public class GroundSymbol extends AbstractComponent<Void> implements ICommonNode
|
|||||||
private Size size = SIZE;
|
private Size size = SIZE;
|
||||||
private GroundSymbolType type = GroundSymbolType.DEFAULT;
|
private GroundSymbolType type = GroundSymbolType.DEFAULT;
|
||||||
private Orientation orientation = Orientation.DEFAULT;
|
private Orientation orientation = Orientation.DEFAULT;
|
||||||
|
private Integer stroke = 1;
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
double sizePx = size.convertToPixels();
|
double sizePx = size.convertToPixels();
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((float)getStroke()));
|
||||||
g2d.setColor(color);
|
|
||||||
double x = point.getX();
|
double x = point.getX();
|
||||||
double y = point.getY();
|
double y = point.getY();
|
||||||
|
|
||||||
@@ -78,17 +80,24 @@ public class GroundSymbol extends AbstractComponent<Void> implements ICommonNode
|
|||||||
break;
|
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));
|
g2d.drawLine((int)x, (int)y, (int)x, (int)(y + sizePx / 6));
|
||||||
if (type == GroundSymbolType.DEFAULT) {
|
if (type == GroundSymbolType.DEFAULT) {
|
||||||
double delta = sizePx / 7;
|
double delta = sizePx / 7.5;
|
||||||
for (int i = 0; i < 5; i++) {
|
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
|
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)));
|
* (i + 1)));
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
g2d.draw(poly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,6 +123,18 @@ public class GroundSymbol extends AbstractComponent<Void> implements ICommonNode
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty
|
||||||
|
public int getStroke() {
|
||||||
|
if (stroke == null) {
|
||||||
|
stroke = 1;
|
||||||
|
}
|
||||||
|
return stroke;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStroke(int stroke) {
|
||||||
|
this.stroke = stroke;
|
||||||
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@EditableProperty
|
||||||
public Orientation getOrientation() {
|
public Orientation getOrientation() {
|
||||||
if (orientation == null)
|
if (orientation == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user