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