mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-12 02:02:16 +10:00
Polygon Ground Fill component
This commit is contained in:
Binary file not shown.
+3
-2
@@ -13,10 +13,11 @@ public class BlankBoard extends AbstractBoard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
int factor = 32 / width;
|
||||||
g2d.setColor(BOARD_COLOR);
|
g2d.setColor(BOARD_COLOR);
|
||||||
g2d.fillRect(2, 2, width - 4, height - 4);
|
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-4
@@ -100,17 +100,18 @@ public class EyeletBoard extends AbstractBoard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
int factor = 32 / width;
|
||||||
g2d.setColor(BOARD_COLOR);
|
g2d.setColor(BOARD_COLOR);
|
||||||
g2d.fillRect(2, 2, width - 4, height - 4);
|
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
|
||||||
g2d.setColor(EYELET_COLOR);
|
g2d.setColor(EYELET_COLOR);
|
||||||
g2d.fillOval(width / 4, width / 4, width / 2, width / 2);
|
g2d.fillOval(width / 4, width / 4, width / 2, width / 2);
|
||||||
g2d.setColor(EYELET_COLOR.darker());
|
g2d.setColor(EYELET_COLOR.darker());
|
||||||
g2d.drawOval(width / 4, width / 4, width / 2, width / 2);
|
g2d.drawOval(width / 4, width / 4, width / 2, width / 2);
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(width / 2 - 2, width / 2 - 2, 5, 5);
|
g2d.fillOval(width / 2 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(EYELET_COLOR.darker());
|
g2d.setColor(EYELET_COLOR.darker());
|
||||||
g2d.drawOval(width / 2 - 2, width / 2 - 2, 5, 5);
|
g2d.drawOval(width / 2 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-19
@@ -37,18 +37,20 @@ public class MarshallPerfBoard extends AbstractBoard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||||
Project project, IDrawingObserver drawingObserver) {
|
boolean outlineMode, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip)
|
||||||
|
&& !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(
|
||||||
/ MAX_ALPHA));
|
AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
Point p = new Point(firstPoint);
|
Point p = new Point(firstPoint);
|
||||||
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||||
@@ -60,11 +62,11 @@ public class MarshallPerfBoard extends AbstractBoard {
|
|||||||
while (p.x < secondPoint.x - spacing - holeDiameter) {
|
while (p.x < secondPoint.x - spacing - holeDiameter) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
g2d.fillOval(p.x - holeDiameter / 2,
|
||||||
holeDiameter);
|
p.y - holeDiameter / 2, holeDiameter, holeDiameter);
|
||||||
g2d.setColor(borderColor);
|
g2d.setColor(borderColor);
|
||||||
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
g2d.drawOval(p.x - holeDiameter / 2,
|
||||||
holeDiameter);
|
p.y - holeDiameter / 2, holeDiameter, holeDiameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.drawCoordinates(g2d, spacing);
|
super.drawCoordinates(g2d, spacing);
|
||||||
@@ -82,29 +84,40 @@ public class MarshallPerfBoard extends AbstractBoard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
int factor = 32 / width;
|
||||||
g2d.setColor(BOARD_COLOR);
|
g2d.setColor(BOARD_COLOR);
|
||||||
g2d.fillRect(2, 2, width - 4, height - 4);
|
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||||
|
/ factor);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||||
|
/ factor);
|
||||||
|
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(width / 3 - 2, width / 3 - 2, 5, 5);
|
g2d.fillOval(width / 3 - 2 / factor, width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawOval(width / 3 - 2, width / 3 - 2, 5, 5);
|
g2d.drawOval(width / 3 - 2 / factor, width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
|
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(2 * width / 3 - 2, width / 3 - 2, 5, 5);
|
g2d.fillOval(2 * width / 3 - 2 / factor, width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawOval(2 * width / 3 - 2, width / 3 - 2, 5, 5);
|
g2d.drawOval(2 * width / 3 - 2 / factor, width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
|
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(width / 3 - 2, 2 * width / 3 - 2, 5, 5);
|
g2d.fillOval(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawOval(width / 3 - 2, 2 * width / 3 - 2, 5, 5);
|
g2d.drawOval(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
|
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(2 * width / 3 - 2, 2 * width / 3 - 2, 5, 5);
|
g2d.fillOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawOval(2 * width / 3 - 2, 2 * width / 3 - 2, 5, 5);
|
g2d.drawOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-15
@@ -33,18 +33,20 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
protected Color padColor = COPPER_COLOR;
|
protected Color padColor = COPPER_COLOR;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||||
Project project, IDrawingObserver drawingObserver) {
|
boolean outlineMode, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip)
|
||||||
|
&& !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(
|
||||||
/ MAX_ALPHA));
|
AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
Point p = new Point(firstPoint);
|
Point p = new Point(firstPoint);
|
||||||
int diameter = getClosestOdd((int) PAD_SIZE.convertToPixels());
|
int diameter = getClosestOdd((int) PAD_SIZE.convertToPixels());
|
||||||
@@ -57,15 +59,17 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
while (p.x < secondPoint.x - spacing - diameter) {
|
while (p.x < secondPoint.x - spacing - diameter) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(padColor);
|
g2d.setColor(padColor);
|
||||||
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2,
|
||||||
|
diameter, diameter);
|
||||||
g2d.setColor(padColor.darker());
|
g2d.setColor(padColor.darker());
|
||||||
g2d.drawOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
g2d.drawOval(p.x - diameter / 2, p.y - diameter / 2,
|
||||||
|
diameter, diameter);
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
g2d.fillOval(p.x - holeDiameter / 2,
|
||||||
holeDiameter);
|
p.y - holeDiameter / 2, holeDiameter, holeDiameter);
|
||||||
g2d.setColor(padColor.darker());
|
g2d.setColor(padColor.darker());
|
||||||
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter,
|
g2d.drawOval(p.x - holeDiameter / 2,
|
||||||
holeDiameter);
|
p.y - holeDiameter / 2, holeDiameter, holeDiameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.drawCoordinates(g2d, spacing);
|
super.drawCoordinates(g2d, spacing);
|
||||||
@@ -92,17 +96,22 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
int factor = 32 / width;
|
||||||
g2d.setColor(BOARD_COLOR);
|
g2d.setColor(BOARD_COLOR);
|
||||||
g2d.fillRect(2, 2, width - 4, height - 4);
|
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||||
|
/ factor);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||||
|
/ factor);
|
||||||
g2d.setColor(COPPER_COLOR);
|
g2d.setColor(COPPER_COLOR);
|
||||||
g2d.fillOval(width / 4, width / 4, width / 2, width / 2);
|
g2d.fillOval(width / 4, width / 4, width / 2, width / 2);
|
||||||
g2d.setColor(COPPER_COLOR.darker());
|
g2d.setColor(COPPER_COLOR.darker());
|
||||||
g2d.drawOval(width / 4, width / 4, width / 2, width / 2);
|
g2d.drawOval(width / 4, width / 4, width / 2, width / 2);
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(width / 2 - 2, width / 2 - 2, 5, 5);
|
g2d.fillOval(width / 2 - 2 / factor, width / 2 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(COPPER_COLOR.darker());
|
g2d.setColor(COPPER_COLOR.darker());
|
||||||
g2d.drawOval(width / 2 - 2, width / 2 - 2, 5, 5);
|
g2d.drawOval(width / 2 - 2 / factor, width / 2 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-25
@@ -36,10 +36,12 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
|
protected OrientationHV orientation = OrientationHV.HORIZONTAL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
|
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||||
Project project, IDrawingObserver drawingObserver) {
|
boolean outlineMode, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip)
|
||||||
|
&& !clip.contains(firstPoint.x, secondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -47,8 +49,8 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
if (componentState != ComponentState.DRAGGING) {
|
if (componentState != ComponentState.DRAGGING) {
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
if (alpha < MAX_ALPHA) {
|
if (alpha < MAX_ALPHA) {
|
||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha
|
g2d.setComposite(AlphaComposite.getInstance(
|
||||||
/ MAX_ALPHA));
|
AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
Point p = new Point(firstPoint);
|
Point p = new Point(firstPoint);
|
||||||
int stripSize = getClosestOdd((int) STRIP_SIZE.convertToPixels());
|
int stripSize = getClosestOdd((int) STRIP_SIZE.convertToPixels());
|
||||||
@@ -60,17 +62,19 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
g2d.setColor(stripColor);
|
g2d.setColor(stripColor);
|
||||||
g2d.fillRect(p.x + spacing / 2, p.y - stripSize / 2, secondPoint.x - spacing
|
g2d.fillRect(p.x + spacing / 2, p.y - stripSize / 2,
|
||||||
- p.x, stripSize);
|
secondPoint.x - spacing - p.x, stripSize);
|
||||||
g2d.setColor(stripColor.darker());
|
g2d.setColor(stripColor.darker());
|
||||||
g2d.drawRect(p.x + spacing / 2, p.y - stripSize / 2, secondPoint.x - spacing
|
g2d.drawRect(p.x + spacing / 2, p.y - stripSize / 2,
|
||||||
- p.x, stripSize);
|
secondPoint.x - spacing - p.x, stripSize);
|
||||||
while (p.x < secondPoint.x - spacing - holeSize) {
|
while (p.x < secondPoint.x - spacing - holeSize) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2,
|
||||||
|
holeSize, holeSize);
|
||||||
g2d.setColor(stripColor.darker());
|
g2d.setColor(stripColor.darker());
|
||||||
g2d.drawOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.drawOval(p.x - holeSize / 2, p.y - holeSize / 2,
|
||||||
|
holeSize, holeSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -78,17 +82,19 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
p.y = firstPoint.y;
|
p.y = firstPoint.y;
|
||||||
g2d.setColor(stripColor);
|
g2d.setColor(stripColor);
|
||||||
g2d.fillRect(p.x - stripSize / 2, p.y + spacing / 2, stripSize, secondPoint.y
|
g2d.fillRect(p.x - stripSize / 2, p.y + spacing / 2,
|
||||||
- spacing - p.y);
|
stripSize, secondPoint.y - spacing - p.y);
|
||||||
g2d.setColor(stripColor.darker());
|
g2d.setColor(stripColor.darker());
|
||||||
g2d.drawRect(p.x - stripSize / 2, p.y + spacing / 2, stripSize, secondPoint.y
|
g2d.drawRect(p.x - stripSize / 2, p.y + spacing / 2,
|
||||||
- spacing - p.y);
|
stripSize, secondPoint.y - spacing - p.y);
|
||||||
while (p.y < secondPoint.y - spacing - holeSize) {
|
while (p.y < secondPoint.y - spacing - holeSize) {
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2,
|
||||||
|
holeSize, holeSize);
|
||||||
g2d.setColor(stripColor.darker());
|
g2d.setColor(stripColor.darker());
|
||||||
g2d.drawOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.drawOval(p.x - holeSize / 2, p.y - holeSize / 2,
|
||||||
|
holeSize, holeSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,19 +132,26 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
int factor = 32 / width;
|
||||||
g2d.setColor(BOARD_COLOR);
|
g2d.setColor(BOARD_COLOR);
|
||||||
g2d.fillRect(2, 2, width - 4, height - 4);
|
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||||
|
/ factor);
|
||||||
g2d.setColor(BORDER_COLOR);
|
g2d.setColor(BORDER_COLOR);
|
||||||
g2d.drawRect(2, 2, width - 4, height - 4);
|
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4
|
||||||
|
/ factor);
|
||||||
g2d.setColor(STRIP_COLOR);
|
g2d.setColor(STRIP_COLOR);
|
||||||
g2d.fillRect(4, width / 4, width - 8, width / 2);
|
g2d.fillRect(4 / factor, width / 4, width - 8 / factor, width / 2);
|
||||||
g2d.setColor(STRIP_COLOR.darker());
|
g2d.setColor(STRIP_COLOR.darker());
|
||||||
g2d.drawRect(4, width / 4, width - 8, width / 2);
|
g2d.drawRect(4 / factor, width / 4, width - 8 / factor, width / 2);
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(width / 3 - 2, width / 2 - 2, 5, 5);
|
g2d.fillOval(width / 3 - 2 / factor, width / 2 - 2 / factor,
|
||||||
g2d.fillOval(2 * width / 3 - 2, width / 2 - 2, 5, 5);
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
|
g2d.fillOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
g2d.setColor(STRIP_COLOR.darker());
|
g2d.setColor(STRIP_COLOR.darker());
|
||||||
g2d.drawOval(width / 3 - 2, width / 2 - 2, 5, 5);
|
g2d.drawOval(width / 3 - 2 / factor, width / 2 - 2 / factor,
|
||||||
g2d.drawOval(2 * width / 3 - 2, width / 2 - 2, 5, 5);
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
|
g2d.drawOval(2 * width / 3 - 2 / factor, width / 2 - 2 / factor,
|
||||||
|
getClosestOdd(5.0 / factor), getClosestOdd(5.0 / factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+144
@@ -0,0 +1,144 @@
|
|||||||
|
package org.diylc.components.connectivity;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.diylc.common.ObjectCache;
|
||||||
|
import org.diylc.components.AbstractComponent;
|
||||||
|
import org.diylc.core.ComponentState;
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.IDrawingObserver;
|
||||||
|
import org.diylc.core.Project;
|
||||||
|
import org.diylc.core.VisibilityPolicy;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ComponentDescriptor(name = "Ground Fill", author = "Branislav Stojkovic", category = "Connectivity", instanceNamePrefix = "GF", description = "Polygonal ground fill area", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false)
|
||||||
|
public class GroundFill extends AbstractComponent<Void> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public static Color COLOR = Color.black;
|
||||||
|
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
|
||||||
|
public static Size DEFAULT_HEIGHT = new Size(1.2d, SizeUnit.in);
|
||||||
|
|
||||||
|
protected Point[] controlPoints = new Point[] {
|
||||||
|
new Point(0, 0),
|
||||||
|
new Point(0, (int) DEFAULT_HEIGHT.convertToPixels()),
|
||||||
|
new Point((int) DEFAULT_WIDTH.convertToPixels(),
|
||||||
|
(int) DEFAULT_HEIGHT.convertToPixels()),
|
||||||
|
new Point((int) DEFAULT_WIDTH.convertToPixels(), 0) };
|
||||||
|
|
||||||
|
protected Color color = COLOR;
|
||||||
|
protected PointCount pointCount = PointCount._4;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics2D g2d, ComponentState componentState,
|
||||||
|
boolean outlineMode, Project project,
|
||||||
|
IDrawingObserver drawingObserver) {
|
||||||
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
|
Color fillColor = componentState == ComponentState.SELECTED
|
||||||
|
|| componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
|
: color;
|
||||||
|
g2d.setColor(fillColor);
|
||||||
|
int[] xPoints = new int[controlPoints.length];
|
||||||
|
int[] yPoints = new int[controlPoints.length];
|
||||||
|
for (int i = 0; i < controlPoints.length; i++) {
|
||||||
|
xPoints[i] = controlPoints[i].x;
|
||||||
|
yPoints[i] = controlPoints[i].y;
|
||||||
|
}
|
||||||
|
g2d.fillPolygon(xPoints, yPoints, controlPoints.length);
|
||||||
|
// Do not track any changes that follow because the whole board has been
|
||||||
|
// tracked so far.
|
||||||
|
drawingObserver.stopTracking();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Color")
|
||||||
|
public Color getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getControlPointCount() {
|
||||||
|
return controlPoints.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point getControlPoint(int index) {
|
||||||
|
return controlPoints[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isControlPointSticky(int index) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
|
return VisibilityPolicy.WHEN_SELECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setControlPoint(Point point, int index) {
|
||||||
|
controlPoints[index].setLocation(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Edges")
|
||||||
|
public PointCount getPointCount() {
|
||||||
|
return pointCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointCount(PointCount pointCount) {
|
||||||
|
if (this.pointCount == pointCount)
|
||||||
|
return;
|
||||||
|
int oldPointCount = Integer.parseInt(this.pointCount.toString());
|
||||||
|
int newPointCount = Integer.parseInt(pointCount.toString());
|
||||||
|
this.controlPoints = Arrays.copyOf(this.controlPoints, newPointCount);
|
||||||
|
if (oldPointCount < newPointCount) {
|
||||||
|
this.controlPoints[newPointCount - 1] = this.controlPoints[oldPointCount - 1];
|
||||||
|
for (int i = oldPointCount - 1; i < newPointCount - 1; i++) {
|
||||||
|
this.controlPoints[i] = new Point(
|
||||||
|
(this.controlPoints[i - 1].x + this.controlPoints[newPointCount - 1].x) / 2,
|
||||||
|
(this.controlPoints[i - 1].y + this.controlPoints[newPointCount - 1].y) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.pointCount = pointCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public Void getValue() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public void setValue(Void value) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
|
int factor = 32 / width;
|
||||||
|
g2d.setColor(COLOR);
|
||||||
|
int[] x = {2 / factor, width - 2 / factor, width - 4 / factor, 3 / factor};
|
||||||
|
int[] y = {4 / factor, 2 / factor, height - 5 / factor, height - 2 / factor};
|
||||||
|
g2d.fillPolygon(x, y, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PointCount {
|
||||||
|
_3, _4, _5, _6, _7, _8;
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return name().substring(1);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user