improve continuity highlighting

massively simplified outline tracing
This commit is contained in:
Branislav Stojkovic
2018-12-16 01:47:30 +01:00
parent 58a4ff987f
commit 2cc916c8c1
10 changed files with 230 additions and 301 deletions
Binary file not shown.
@@ -1,163 +1,165 @@
/*
*
* 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.Shape;
This file is part of DIYLC.
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.ObjectCache;
import org.diylc.common.PCBLayer;
import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.BomPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
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.
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace",
description = "Straight copper trace", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW,
autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB",
transformer = SimpleComponentTransformer.class)
public class CopperTrace extends AbstractLeadedComponent<Void> {
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.
private static final long serialVersionUID = 1L;
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
public static Size THICKNESS = new Size(1d, SizeUnit.mm);
public static Color COLOR = Color.black;
*/
package org.diylc.components.connectivity;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import org.diylc.common.SimpleComponentTransformer;
import org.diylc.common.ObjectCache;
import org.diylc.common.PCBLayer;
import org.diylc.components.AbstractLeadedComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.BomPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Copper Trace", author = "Branislav Stojkovic", category = "Connectivity",
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "Trace",
description = "Straight copper trace", zOrder = IDIYComponent.TRACE, bomPolicy = BomPolicy.NEVER_SHOW,
autoEdit = false, keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
public class CopperTrace extends AbstractLeadedComponent<Void> {
private static final long serialVersionUID = 1L;
public static Size THICKNESS = new Size(1d, SizeUnit.mm);
public static Color COLOR = Color.black;
private Size thickness = THICKNESS;
private PCBLayer layer = PCBLayer._1;
public CopperTrace() {
super();
this.leadColor = COLOR;
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(3));
g2d.setColor(COLOR);
g2d.drawLine(1, height - 2, width - 2, 1);
}
@Override
protected Color getLeadColorForPainting(ComponentState componentState) {
return componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: getLeadColor();
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.WHEN_SELECTED;
}
@Override
@EditableProperty(name = "Color")
public Color getLeadColor() {
return leadColor;
}
@EditableProperty(name = "Width")
public Size getThickness() {
return thickness;
}
public void setThickness(Size thickness) {
this.thickness = thickness;
}
@EditableProperty
public PCBLayer getLayer() {
if (layer == null) {
layer = PCBLayer._1;
}
return layer;
}
public void setLayer(PCBLayer layer) {
this.layer = layer;
}
@Override
protected float getLeadThickness() {
return (float) getThickness().convertToPixels();
}
@Override
protected boolean shouldShadeLeads() {
return false;
}
public Color getBodyColor() {
return super.getBodyColor();
}
@Override
public Color getBorderColor() {
return super.getBorderColor();
}
@Override
public Byte getAlpha() {
return super.getAlpha();
}
@Override
public Size getLength() {
return super.getLength();
}
@Override
public Size getWidth() {
return super.getWidth();
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {}
@Override
protected Shape getBodyShape() {
return null;
}
@Override
protected Size getDefaultWidth() {
return null;
}
@Override
protected Size getDefaultLength() {
return null;
}
}
private Size thickness = THICKNESS;
private PCBLayer layer = PCBLayer._1;
public CopperTrace() {
super();
this.leadColor = COLOR;
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(3));
g2d.setColor(COLOR);
g2d.drawLine(1, height - 2, width - 2, 1);
}
@Override
protected Color getLeadColorForPainting(ComponentState componentState) {
return componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: getLeadColor();
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.WHEN_SELECTED;
}
@Override
@EditableProperty(name = "Color")
public Color getLeadColor() {
return leadColor;
}
@EditableProperty(name = "Width")
public Size getThickness() {
return thickness;
}
public void setThickness(Size thickness) {
this.thickness = thickness;
}
@EditableProperty
public PCBLayer getLayer() {
if (layer == null) {
layer = PCBLayer._1;
}
return layer;
}
public void setLayer(PCBLayer layer) {
this.layer = layer;
}
@Override
protected float getLeadThickness() {
return (float) getThickness().convertToPixels();
}
@Override
protected boolean shouldShadeLeads() {
return false;
}
public Color getBodyColor() {
return super.getBodyColor();
}
@Override
public Color getBorderColor() {
return super.getBorderColor();
}
@Override
public Byte getAlpha() {
return super.getAlpha();
}
@Override
public Size getLength() {
return super.getLength();
}
@Override
public Size getWidth() {
return super.getWidth();
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {}
@Override
protected Shape getBodyShape() {
return null;
}
@Override
protected Size getDefaultWidth() {
return null;
}
@Override
protected Size getDefaultLength() {
return null;
}
@Override
protected boolean IsCopperArea() {
return true;
}
}
@@ -66,8 +66,10 @@ public class Eyelet extends AbstractComponent<String> {
}
int diameter = getClosestOdd((int) size.convertToPixels());
int holeDiameter = getClosestOdd((int) holeSize.convertToPixels());
g2d.setColor(color);
g2d.fillOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);
g2d.setColor(color);
drawingObserver.startTrackingContinuityArea(true);
g2d.fillOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);
drawingObserver.stopTrackingContinuityArea();
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: color.darker());
g2d.drawOval(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter);