mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
added dashed/dotted lines
added 5 and 7-point curves
This commit is contained in:
@@ -48,7 +48,7 @@ public class EyeletBoard extends AbstractBoard {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color BOARD_COLOR = Color.decode("#CCFFCC");
|
||||
public static Color BOARD_COLOR = Color.decode("#E3EAB4");
|
||||
public static Color BORDER_COLOR = BOARD_COLOR.darker();
|
||||
public static Color EYELET_COLOR = Color.decode("#C3E4ED");
|
||||
|
||||
|
||||
@@ -1,112 +1,108 @@
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.components.AbstractCurvedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.PCBLayer;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractCurvedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
|
||||
zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
||||
public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.black;
|
||||
public static Size SIZE = new Size(1d, SizeUnit.mm);
|
||||
|
||||
protected Size size = SIZE;
|
||||
private PCBLayer layer = PCBLayer._1;
|
||||
|
||||
@Override
|
||||
protected Color getDefaultColor() {
|
||||
return COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d, ComponentState componentState, IDrawingObserver drawingObserver) {
|
||||
float thickness = (float) size.convertToPixels();
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(thickness));
|
||||
Color curveColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: color;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.annotations.KeywordPolicy;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
|
||||
@ComponentDescriptor(name = "Curved Trace", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
instanceNamePrefix = "Trace", description = "Curved copper trace with two control points",
|
||||
zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
||||
public class CurvedTrace extends AbstractCurvedComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.black;
|
||||
public static Size SIZE = new Size(1d, SizeUnit.mm);
|
||||
|
||||
protected Size size = SIZE;
|
||||
private PCBLayer layer = PCBLayer._1;
|
||||
|
||||
@Override
|
||||
protected Color getDefaultColor() {
|
||||
return COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawCurve(Path2D curve, Graphics2D g2d, ComponentState componentState, IDrawingObserver drawingObserver) {
|
||||
float thickness = (float) size.convertToPixels();
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(thickness));
|
||||
Color curveColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: color;
|
||||
g2d.setColor(curveColor);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
drawingObserver.startTrackingContinuityArea(true);
|
||||
g2d.draw(curve);
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Width")
|
||||
public Size getThickness() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setThickness(Size size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public PCBLayer getLayer() {
|
||||
if (layer == null) {
|
||||
layer = PCBLayer._1;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
public void setLayer(PCBLayer layer) {
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
|
||||
@Override
|
||||
public Byte getAlpha() {
|
||||
return super.getAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(Byte alpha) {
|
||||
super.setAlpha(alpha);
|
||||
}
|
||||
}
|
||||
drawingObserver.stopTrackingContinuityArea();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Width")
|
||||
public Size getThickness() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setThickness(Size size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@EditableProperty
|
||||
public PCBLayer getLayer() {
|
||||
if (layer == null) {
|
||||
layer = PCBLayer._1;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
public void setLayer(PCBLayer layer) {
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
|
||||
@Override
|
||||
public Byte getAlpha() {
|
||||
return super.getAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(Byte alpha) {
|
||||
super.setAlpha(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,90 +1,112 @@
|
||||
/*
|
||||
*
|
||||
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
*
|
||||
* This file is part of DIYLC.
|
||||
*
|
||||
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.components.connectivity;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.CubicCurve2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractCurvedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractCurvedComponent;
|
||||
import org.diylc.core.ComponentState;
|
||||
import org.diylc.core.IDIYComponent;
|
||||
import org.diylc.core.IDrawingObserver;
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.COMPONENT,
|
||||
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class, continuity = true)
|
||||
public class HookupWire extends AbstractCurvedComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.green;
|
||||
public static double INSULATION_THICKNESS_PCT = 0.3;
|
||||
|
||||
protected AWG gauge = AWG._22;
|
||||
|
||||
@Override
|
||||
protected Color getDefaultColor() {
|
||||
return COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawCurve(CubicCurve2D curve, Graphics2D g2d, ComponentState componentState, IDrawingObserver drawingObserver) {
|
||||
int thickness =
|
||||
(int) (Math.pow(Math.E, -1.12436 - 0.11594 * gauge.getValue()) * Constants.PIXELS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
|
||||
Color curveColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: color.darker();
|
||||
g2d.setColor(curveColor);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(thickness));
|
||||
g2d.draw(curve);
|
||||
if (componentState == ComponentState.NORMAL) {
|
||||
g2d.setColor(color);
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(thickness - 2));
|
||||
g2d.draw(curve);
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "AWG")
|
||||
public AWG getGauge() {
|
||||
return gauge;
|
||||
}
|
||||
|
||||
public void setGauge(AWG gauge) {
|
||||
this.gauge = gauge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
}
|
||||
import org.diylc.core.annotations.BomPolicy;
|
||||
import org.diylc.core.annotations.ComponentDescriptor;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Hookup Wire", author = "Branislav Stojkovic", category = "Connectivity",
|
||||
instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.COMPONENT,
|
||||
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class, continuity = true)
|
||||
public class HookupWire extends AbstractCurvedComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static Color COLOR = Color.green;
|
||||
public static double INSULATION_THICKNESS_PCT = 0.3;
|
||||
|
||||
protected AWG gauge = AWG._22;
|
||||
|
||||
@Override
|
||||
protected Color getDefaultColor() {
|
||||
return COLOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawCurve(Path2D curve, Graphics2D g2d, ComponentState componentState, IDrawingObserver drawingObserver) {
|
||||
int thickness =
|
||||
(int) (Math.pow(Math.E, -1.12436 - 0.11594 * gauge.getValue()) * Constants.PIXELS_PER_INCH * (1 + 2 * INSULATION_THICKNESS_PCT));
|
||||
Color curveColor =
|
||||
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||
: color.darker();
|
||||
g2d.setColor(curveColor);
|
||||
Stroke stroke = null;
|
||||
switch (getStyle()) {
|
||||
case SOLID:
|
||||
stroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
||||
break;
|
||||
case DASHED:
|
||||
stroke =
|
||||
ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness * 2, thickness * 3}, thickness * 4);
|
||||
break;
|
||||
case DOTTED:
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness / 4, thickness * 3}, 0);
|
||||
break;
|
||||
}
|
||||
g2d.setStroke(stroke);
|
||||
g2d.draw(curve);
|
||||
if (componentState == ComponentState.NORMAL) {
|
||||
g2d.setColor(color);
|
||||
switch (getStyle()) {
|
||||
case SOLID:
|
||||
stroke = ObjectCache.getInstance().fetchBasicStroke(thickness - 2);
|
||||
break;
|
||||
case DASHED:
|
||||
stroke =
|
||||
ObjectCache.getInstance().fetchStroke(thickness - 2, new float[] {thickness * 2, thickness * 3},
|
||||
thickness * 4);
|
||||
break;
|
||||
case DOTTED:
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness - 2, new float[] {thickness / 4, thickness * 3}, 0);
|
||||
}
|
||||
g2d.setStroke(stroke);
|
||||
g2d.draw(curve);
|
||||
}
|
||||
}
|
||||
|
||||
@EditableProperty(name = "AWG")
|
||||
public AWG getGauge() {
|
||||
return gauge;
|
||||
}
|
||||
|
||||
public void setGauge(AWG gauge) {
|
||||
this.gauge = gauge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ package org.diylc.components.connectivity;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
|
||||
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.LineStyle;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
@@ -48,7 +49,8 @@ public class Jumper extends AbstractLeadedComponent<Void> {
|
||||
public static Color COLOR = Color.blue;
|
||||
|
||||
@Deprecated
|
||||
private Color color;
|
||||
private Color color;
|
||||
protected LineStyle style = LineStyle.SOLID;
|
||||
|
||||
public Jumper() {
|
||||
super();
|
||||
@@ -78,6 +80,17 @@ public class Jumper extends AbstractLeadedComponent<Void> {
|
||||
this.leadColor = color;
|
||||
}
|
||||
return super.getLeadColor();
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Style")
|
||||
public LineStyle getStyle() {
|
||||
if (style == null)
|
||||
style = LineStyle.SOLID;
|
||||
return style;
|
||||
}
|
||||
|
||||
public void setStyle(LineStyle style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public Color getBodyColor() {
|
||||
|
||||
@@ -24,8 +24,10 @@ package org.diylc.components.connectivity;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
|
||||
import java.awt.Stroke;
|
||||
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.LineStyle;
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
import org.diylc.components.AbstractLeadedComponent;
|
||||
@@ -49,7 +51,8 @@ public class Line extends AbstractLeadedComponent<Void> {
|
||||
|
||||
public static Color COLOR = Color.black;
|
||||
|
||||
private Color color = COLOR;
|
||||
private Color color = COLOR;
|
||||
protected LineStyle style = LineStyle.SOLID;
|
||||
|
||||
@Override
|
||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||
@@ -60,8 +63,21 @@ public class Line extends AbstractLeadedComponent<Void> {
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||
IDrawingObserver drawingObserver) {
|
||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||
IDrawingObserver drawingObserver) {
|
||||
float thickness = 1f;
|
||||
Stroke stroke = null;
|
||||
switch (getStyle()) {
|
||||
case SOLID:
|
||||
stroke = ObjectCache.getInstance().fetchBasicStroke(thickness);
|
||||
break;
|
||||
case DASHED:
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness * 2}, thickness * 4);
|
||||
break;
|
||||
case DOTTED:
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness / 4, thickness * 3}, 0);
|
||||
break;
|
||||
}
|
||||
g2d.setStroke(stroke);
|
||||
g2d.setColor(color);
|
||||
g2d.drawLine(getControlPoint(0).x, getControlPoint(0).y, getControlPoint(1).x, getControlPoint(1).y);
|
||||
}
|
||||
@@ -84,6 +100,17 @@ public class Line extends AbstractLeadedComponent<Void> {
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@EditableProperty(name = "Style")
|
||||
public LineStyle getStyle() {
|
||||
if (style == null)
|
||||
style = LineStyle.SOLID;
|
||||
return style;
|
||||
}
|
||||
|
||||
public void setStyle(LineStyle style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public Color getBodyColor() {
|
||||
|
||||
Reference in New Issue
Block a user