mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
revert border color changes
This commit is contained in:
@@ -2954,10 +2954,6 @@
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<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>
|
||||
<changeType>IMPROVEMENT</changeType>
|
||||
<description>Automatically determine border color of board components</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<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;
|
||||
|
||||
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<String>
|
||||
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<String>
|
||||
// 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<String>
|
||||
|
||||
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<String>
|
||||
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() {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
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.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
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.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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
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.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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user