revert border color changes

This commit is contained in:
bancika
2020-04-13 15:29:01 +02:00
parent 9963b7b3d3
commit f299106430
6 changed files with 296 additions and 287 deletions
@@ -2954,10 +2954,6 @@
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Prevent the app from closing while running background operations, like saving and exporting files</description> <description>Prevent the app from closing while running background operations, like saving and exporting files</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Automatically determine border color of board components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Fixed the issue with "Highlight Connected Areas" not recognizing some conductive areas</description> <description>Fixed the issue with "Highlight Connected Areas" not recognizing some conductive areas</description>
@@ -46,6 +46,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color BOARD_COLOR = Color.decode("#F8EBB3"); public static Color BOARD_COLOR = Color.decode("#F8EBB3");
public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Color COORDINATE_COLOR = Color.gray.brighter(); public static Color COORDINATE_COLOR = Color.gray.brighter();
public static float COORDINATE_FONT_SIZE = 9f; public static float COORDINATE_FONT_SIZE = 9f;
public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in); public static Size DEFAULT_WIDTH = new Size(1.5d, SizeUnit.in);
@@ -58,8 +59,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
protected Point secondPoint = new Point(); protected Point secondPoint = new Point();
protected Color boardColor = BOARD_COLOR; protected Color boardColor = BOARD_COLOR;
@Deprecated protected Color borderColor = BORDER_COLOR;
protected Color borderColor;
protected Color coordinateColor = COORDINATE_COLOR; protected Color coordinateColor = COORDINATE_COLOR;
protected Boolean drawCoordinates = null; protected Boolean drawCoordinates = null;
protected CoordinateType xType = CoordinateType.Numbers; protected CoordinateType xType = CoordinateType.Numbers;
@@ -92,7 +92,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
// tracked so far. // tracked so far.
drawingObserver.stopTracking(); drawingObserver.stopTracking();
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: getBoardColor().darker()); : borderColor);
g2d.drawRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y); g2d.drawRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
} }
@@ -167,7 +167,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
drawPoint.x += xOffset; drawPoint.x += xOffset;
StringUtils.drawCenteredText(g2d, label, StringUtils.drawCenteredText(g2d, label,
drawPoint.x, firstPoint.y - 2, drawPoint.x, firstPoint.y + 2,
HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) { if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) {
StringUtils.drawCenteredText(g2d, label, StringUtils.drawCenteredText(g2d, label,
@@ -211,6 +211,15 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
public void setCoordinateColor(Color coordinateColor) { public void setCoordinateColor(Color coordinateColor) {
this.coordinateColor = coordinateColor; this.coordinateColor = coordinateColor;
} }
@EditableProperty(name = "Border")
public Color getBorderColor() {
return borderColor;
}
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
@EditableProperty(name = "X") @EditableProperty(name = "X")
public CoordinateType getxType() { public CoordinateType getxType() {
@@ -19,8 +19,8 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.boards; package org.diylc.components.boards;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Composite; import java.awt.Composite;
@@ -37,58 +37,58 @@ import org.diylc.core.Project;
import org.diylc.core.annotations.BomPolicy; import org.diylc.core.annotations.BomPolicy;
import org.diylc.core.annotations.ComponentDescriptor; import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
@ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Blank Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Blank circuit board", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Blank circuit board",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, transformer = SimpleComponentTransformer.class) bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, transformer = SimpleComponentTransformer.class)
public class BlankBoard extends AbstractBoard { public class BlankBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Type type = Type.SQUARE; private Type type = Type.SQUARE;
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
int factor = 32 / width; int factor = 32 / width;
g2d.setColor(BOARD_COLOR); g2d.setColor(BOARD_COLOR);
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
} }
@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) {
Point finalSecondPoint = getFinalSecondPoint(); Point finalSecondPoint = getFinalSecondPoint();
Shape clip = g2d.getClip(); Shape clip = g2d.getClip();
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y) if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) { && !clip.contains(finalSecondPoint.x, firstPoint.y)) {
return; return;
} }
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1)); g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
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 / MAX_ALPHA)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
} }
g2d.setColor(boardColor); g2d.setColor(boardColor);
if (getType() == Type.SQUARE) if (getType() == Type.SQUARE)
g2d.fillRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y); g2d.fillRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
else else
g2d.fillOval(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y); g2d.fillOval(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
} }
// Do not track any changes that follow because the whole board has been // Do not track any changes that follow because the whole board has been
// tracked so far. // tracked so far.
drawingObserver.stopTracking(); drawingObserver.stopTracking();
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: getBoardColor().darker()); : borderColor);
if (getType() == Type.SQUARE) if (getType() == Type.SQUARE)
g2d.drawRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y); g2d.drawRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
else else
g2d.drawOval(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y); g2d.drawOval(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
} }
@Override @Override
@@ -113,31 +113,31 @@ public class BlankBoard extends AbstractBoard {
public Color getCoordinateColor() { public Color getCoordinateColor() {
// Override to prevent editing. // Override to prevent editing.
return super.getCoordinateColor(); return super.getCoordinateColor();
} }
@EditableProperty(name = "Shape") @EditableProperty(name = "Shape")
public Type getType() { public Type getType() {
if (type == null) { if (type == null) {
type = Type.SQUARE; type = Type.SQUARE;
} }
return type; return type;
} }
public void setType(Type type) { public void setType(Type type) {
this.type = type; this.type = type;
} }
@Override @Override
public String getControlPointNodeName(int index) { public String getControlPointNodeName(int index) {
return null; return null;
} }
static enum Type { static enum Type {
ROUND, SQUARE; ROUND, SQUARE;
@Override @Override
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
} }
@@ -19,8 +19,8 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.boards; package org.diylc.components.boards;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@@ -39,109 +39,111 @@ import org.diylc.core.annotations.KeywordPolicy;
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; import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Eyelet Board", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Eyelet Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with eyelets", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", description = "Perforated board with eyelets",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME,
transformer = SimpleComponentTransformer.class, enableCache = true) transformer = SimpleComponentTransformer.class, enableCache = true)
public class EyeletBoard extends AbstractBoard { public class EyeletBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color BOARD_COLOR = Color.decode("#E3EAB4"); public static Color BOARD_COLOR = Color.decode("#E3EAB4");
public static Color EYELET_COLOR = Color.decode("#C3E4ED"); public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Color EYELET_COLOR = Color.decode("#C3E4ED");
public static Size SPACING = new Size(0.5d, SizeUnit.in);
public static Size EYELET_SIZE = new Size(0.2d, SizeUnit.in); public static Size SPACING = new Size(0.5d, SizeUnit.in);
public static Size HOLE_SIZE = new Size(0.1d, SizeUnit.in); public static Size EYELET_SIZE = new Size(0.2d, SizeUnit.in);
public static Size HOLE_SIZE = new Size(0.1d, SizeUnit.in);
// private Area copperArea;
protected Size spacing = SPACING; // private Area copperArea;
protected Color eyeletColor = EYELET_COLOR; protected Size spacing = SPACING;
protected Color eyeletColor = EYELET_COLOR;
public EyeletBoard() {
super(); public EyeletBoard() {
this.boardColor = BOARD_COLOR; super();
} this.boardColor = BOARD_COLOR;
this.borderColor = BORDER_COLOR;
@Override }
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) { IDrawingObserver drawingObserver) {
Point finalSecondPoint = getFinalSecondPoint(); Point finalSecondPoint = getFinalSecondPoint();
Shape clip = g2d.getClip(); Shape clip = g2d.getClip();
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y) if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) { && !clip.contains(finalSecondPoint.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 / MAX_ALPHA)); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
} }
Point p = new Point(firstPoint); Point p = new Point(firstPoint);
int diameter = getClosestOdd((int) EYELET_SIZE.convertToPixels()); int diameter = getClosestOdd((int) EYELET_SIZE.convertToPixels());
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels()); int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
int spacing = (int) this.spacing.convertToPixels(); int spacing = (int) this.spacing.convertToPixels();
while (p.y < finalSecondPoint.y - spacing) { while (p.y < finalSecondPoint.y - spacing) {
p.x = firstPoint.x; p.x = firstPoint.x;
p.y += spacing; p.y += spacing;
while (p.x < finalSecondPoint.x - spacing - diameter) { while (p.x < finalSecondPoint.x - spacing - diameter) {
p.x += spacing; p.x += spacing;
g2d.setColor(eyeletColor); g2d.setColor(eyeletColor);
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(eyeletColor.darker()); g2d.setColor(eyeletColor.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, holeDiameter); g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
g2d.setColor(eyeletColor.darker()); g2d.setColor(eyeletColor.darker());
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
} }
} }
super.drawCoordinates(g2d, spacing, project); super.drawCoordinates(g2d, spacing, project);
} }
} }
@EditableProperty(name = "Eyelet color") @EditableProperty(name = "Eyelet color")
public Color getEyeletColor() { public Color getEyeletColor() {
return eyeletColor; return eyeletColor;
} }
public void setEyeletColor(Color padColor) { public void setEyeletColor(Color padColor) {
this.eyeletColor = padColor; this.eyeletColor = padColor;
} }
@EditableProperty @EditableProperty
public Size getSpacing() { public Size getSpacing() {
return spacing; return spacing;
} }
public void setSpacing(Size spacing) { public void setSpacing(Size spacing) {
this.spacing = spacing; this.spacing = spacing;
} }
@Override @Override
public String getControlPointNodeName(int index) { public String getControlPointNodeName(int index) {
return null; return null;
} }
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
int factor = 32 / width; int factor = 32 / width;
g2d.setColor(BOARD_COLOR); g2d.setColor(BOARD_COLOR);
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); 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 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(width / 2 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(EYELET_COLOR.darker()); g2d.setColor(EYELET_COLOR.darker());
g2d.drawOval(width / 2 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(width / 2 - 2 / factor, width / 2 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
} }
} }
@@ -19,8 +19,8 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.boards; package org.diylc.components.boards;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@@ -40,110 +40,112 @@ import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
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; import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Marshall Style Perf Board", category = "Boards", author = "Branislav Stojkovic", @ComponentDescriptor(name = "Marshall Style Perf Board", category = "Boards", author = "Branislav Stojkovic",
zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board", zOrder = IDIYComponent.BOARD, instanceNamePrefix = "Board",
description = "Perforated board as found on some Marshall and Trainwreck amps", description = "Perforated board as found on some Marshall and Trainwreck amps",
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG,
keywordTag = "Perf Board", transformer = SimpleComponentTransformer.class) keywordTag = "Perf Board", transformer = SimpleComponentTransformer.class)
public class MarshallPerfBoard extends AbstractBoard { public class MarshallPerfBoard extends AbstractBoard {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static Color BOARD_COLOR = Color.decode("#CD8500"); public static Color BOARD_COLOR = Color.decode("#CD8500");
public static Size SPACING = new Size(3 / 8d, SizeUnit.in); public static Color BORDER_COLOR = BOARD_COLOR.darker();
public static Size HOLE_SIZE = new Size(1 / 8d, SizeUnit.in); public static Size SPACING = new Size(3 / 8d, SizeUnit.in);
public static Size HOLE_SIZE = new Size(1 / 8d, SizeUnit.in);
// private Area copperArea;
protected Size spacing = SPACING; // private Area copperArea;
protected Size spacing = SPACING;
public MarshallPerfBoard() {
super(); public MarshallPerfBoard() {
this.boardColor = BOARD_COLOR; super();
} this.boardColor = BOARD_COLOR;
this.borderColor = BORDER_COLOR;
@Override }
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) { IDrawingObserver drawingObserver) {
Point finalSecondPoint = getFinalSecondPoint(); Point finalSecondPoint = getFinalSecondPoint();
Shape clip = g2d.getClip(); Shape clip = g2d.getClip();
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y) if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) { && !clip.contains(finalSecondPoint.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 / MAX_ALPHA)); g2d.setComposite(AlphaComposite.getInstance(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());
int spacing = (int) this.spacing.convertToPixels(); int spacing = (int) this.spacing.convertToPixels();
while (p.y < finalSecondPoint.y - spacing) { while (p.y < finalSecondPoint.y - spacing) {
p.x = firstPoint.x; p.x = firstPoint.x;
p.y += spacing; p.y += spacing;
while (p.x < finalSecondPoint.x - spacing - holeDiameter) { while (p.x < finalSecondPoint.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, holeDiameter); g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
g2d.setColor(getBoardColor().darker()); g2d.setColor(borderColor);
g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter); g2d.drawOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
} }
} }
super.drawCoordinates(g2d, spacing, project); super.drawCoordinates(g2d, spacing, project);
} }
} }
@EditableProperty(validatorClass = PositiveNonZeroMeasureValidator.class) @EditableProperty(validatorClass = PositiveNonZeroMeasureValidator.class)
public Size getSpacing() { public Size getSpacing() {
return spacing; return spacing;
} }
public void setSpacing(Size spacing) { public void setSpacing(Size spacing) {
this.spacing = spacing; this.spacing = spacing;
} }
@Override @Override
public String getControlPointNodeName(int index) { public String getControlPointNodeName(int index) {
return null; return null;
} }
@Override @Override
public void drawIcon(Graphics2D g2d, int width, int height) { public void drawIcon(Graphics2D g2d, int width, int height) {
int factor = 32 / width; int factor = 32 / width;
g2d.setColor(BOARD_COLOR); g2d.setColor(BOARD_COLOR);
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); 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 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawOval(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / 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 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawOval(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(2 * width / 3 - 2 / factor, width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(Constants.CANVAS_COLOR); g2d.setColor(Constants.CANVAS_COLOR);
g2d.fillOval(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawOval(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / 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 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.fillOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor), g2d.drawOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, getClosestOdd(5.0 / factor),
getClosestOdd(5.0 / factor)); getClosestOdd(5.0 / factor));
} }
} }
@@ -126,7 +126,7 @@ public class PerfBoard extends AbstractBoard {
int factor = 32 / width; int factor = 32 / width;
g2d.setColor(BOARD_COLOR); g2d.setColor(BOARD_COLOR);
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
g2d.setColor(BOARD_COLOR.darker()); g2d.setColor(BORDER_COLOR);
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor); 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);