mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
Oval solder pads
This commit is contained in:
Binary file not shown.
@@ -1,196 +1,196 @@
|
|||||||
/*
|
/*
|
||||||
|
*
|
||||||
|
* 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).
|
import java.awt.Color;
|
||||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.geom.Ellipse2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
This file is part of DIYLC.
|
import org.diylc.common.PCBLayer;
|
||||||
|
import org.diylc.common.SimpleComponentTransformer;
|
||||||
|
import org.diylc.components.AbstractComponent;
|
||||||
|
import org.diylc.core.ComponentState;
|
||||||
|
import org.diylc.core.IDIYComponent;
|
||||||
|
import org.diylc.core.IDrawingObserver;
|
||||||
|
import org.diylc.core.Project;
|
||||||
|
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.annotations.PositiveMeasureValidator;
|
||||||
|
import org.diylc.core.measures.Size;
|
||||||
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
import org.diylc.utils.Constants;
|
||||||
|
|
||||||
DIYLC is free software: you can redistribute it and/or modify
|
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic",
|
||||||
it under the terms of the GNU General Public License as published by
|
description = "Copper solder pad, round or square", instanceNamePrefix = "Pad", stretchable = false,
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||||
(at your option) any later version.
|
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
||||||
|
public class SolderPad extends AbstractComponent<Void> {
|
||||||
|
|
||||||
DIYLC is distributed in the hope that it will be useful,
|
private static final long serialVersionUID = 1L;
|
||||||
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
|
public static Size SIZE = new Size(0.09d, SizeUnit.in);
|
||||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
public static Size HOLE_SIZE = new Size(0.8d, SizeUnit.mm);
|
||||||
|
public static Color COLOR = Color.black;
|
||||||
|
|
||||||
*/
|
private Size size = SIZE;
|
||||||
package org.diylc.components.connectivity;
|
private Color color = COLOR;
|
||||||
|
private Point point = new Point(0, 0);
|
||||||
import java.awt.Color;
|
private Type type = Type.ROUND;
|
||||||
import java.awt.Graphics2D;
|
private Size holeSize = HOLE_SIZE;
|
||||||
import java.awt.Point;
|
private PCBLayer layer = PCBLayer._1;
|
||||||
import java.awt.geom.Ellipse2D;
|
|
||||||
import java.awt.geom.Rectangle2D;
|
@Override
|
||||||
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
import org.diylc.common.PCBLayer;
|
IDrawingObserver drawingObserver) {
|
||||||
import org.diylc.common.SimpleComponentTransformer;
|
if (checkPointsClipped(g2d.getClip())) {
|
||||||
import org.diylc.components.AbstractComponent;
|
return;
|
||||||
import org.diylc.core.ComponentState;
|
|
||||||
import org.diylc.core.IDIYComponent;
|
|
||||||
import org.diylc.core.IDrawingObserver;
|
|
||||||
import org.diylc.core.Project;
|
|
||||||
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.annotations.PositiveMeasureValidator;
|
|
||||||
import org.diylc.core.measures.Size;
|
|
||||||
import org.diylc.core.measures.SizeUnit;
|
|
||||||
import org.diylc.utils.Constants;
|
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic",
|
|
||||||
description = "Copper solder pad, round or square", instanceNamePrefix = "Pad", stretchable = false,
|
|
||||||
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
|
||||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
|
||||||
public class SolderPad extends AbstractComponent<Void> {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public static Size SIZE = new Size(0.09d, SizeUnit.in);
|
|
||||||
public static Size HOLE_SIZE = new Size(0.8d, SizeUnit.mm);
|
|
||||||
public static Color COLOR = Color.black;
|
|
||||||
|
|
||||||
private Size size = SIZE;
|
|
||||||
private Color color = COLOR;
|
|
||||||
private Point point = new Point(0, 0);
|
|
||||||
private Type type = Type.ROUND;
|
|
||||||
private Size holeSize = HOLE_SIZE;
|
|
||||||
private PCBLayer layer = PCBLayer._1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
|
||||||
IDrawingObserver drawingObserver) {
|
|
||||||
if (checkPointsClipped(g2d.getClip())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
double diameter = getSize().convertToPixels();
|
|
||||||
double holeDiameter = getHoleSize().convertToPixels();
|
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
|
||||||
: color);
|
|
||||||
drawingObserver.startTrackingContinuityArea(true);
|
|
||||||
if (type == Type.ROUND) {
|
|
||||||
g2d.fill(new Ellipse2D.Double(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter));
|
|
||||||
} else {
|
|
||||||
g2d.fill(new Rectangle2D.Double(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter));
|
|
||||||
}
|
}
|
||||||
drawingObserver.stopTrackingContinuityArea();
|
double diameter = getSize().convertToPixels();
|
||||||
if (getHoleSize().getValue() > 0) {
|
double holeDiameter = getHoleSize().convertToPixels();
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
g2d.fill(new Ellipse2D.Double(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter, holeDiameter));
|
: color);
|
||||||
}
|
drawingObserver.startTrackingContinuityArea(true);
|
||||||
}
|
if (type == Type.ROUND) {
|
||||||
|
g2d.fill(new Ellipse2D.Double(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter));
|
||||||
@Override
|
} else if (type == Type.OVAL_HORIZONTAL) {
|
||||||
public void drawIcon(Graphics2D g2d, int width, int height) {
|
g2d.fill(new Ellipse2D.Double(point.x - diameter / 2, point.y - diameter * 3 / 8, diameter, diameter * 3 / 4));
|
||||||
int diameter = getClosestOdd(width / 2);
|
} else if (type == Type.OVAL_VERTICAL) {
|
||||||
int holeDiameter = 5;
|
g2d.fill(new Ellipse2D.Double(point.x - diameter * 3 / 8, point.y - diameter / 2, diameter * 3 / 4, diameter));
|
||||||
g2d.setColor(COLOR);
|
} else {
|
||||||
g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter);
|
g2d.fill(new Rectangle2D.Double(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter));
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
}
|
||||||
g2d.fillOval((width - holeDiameter) / 2, (height - holeDiameter) / 2, holeDiameter, holeDiameter);
|
drawingObserver.stopTrackingContinuityArea();
|
||||||
}
|
if (getHoleSize().getValue() > 0) {
|
||||||
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
@EditableProperty(validatorClass = PositiveMeasureValidator.class)
|
g2d.fill(new Ellipse2D.Double(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter, holeDiameter));
|
||||||
public Size getSize() {
|
}
|
||||||
return size;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
public void setSize(Size size) {
|
public void drawIcon(Graphics2D g2d, int width, int height) {
|
||||||
this.size = size;
|
int diameter = getClosestOdd(width / 2);
|
||||||
}
|
int holeDiameter = 5;
|
||||||
|
g2d.setColor(COLOR);
|
||||||
@EditableProperty(name = "Hole")
|
g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter);
|
||||||
public Size getHoleSize() {
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
if (holeSize == null) {
|
g2d.fillOval((width - holeDiameter) / 2, (height - holeDiameter) / 2, holeDiameter, holeDiameter);
|
||||||
holeSize = HOLE_SIZE;
|
}
|
||||||
}
|
|
||||||
return holeSize;
|
@EditableProperty(validatorClass = PositiveMeasureValidator.class)
|
||||||
}
|
public Size getSize() {
|
||||||
|
return size;
|
||||||
public void setHoleSize(Size holeSize) {
|
}
|
||||||
this.holeSize = holeSize;
|
|
||||||
}
|
public void setSize(Size size) {
|
||||||
|
this.size = size;
|
||||||
@EditableProperty
|
}
|
||||||
public PCBLayer getLayer() {
|
|
||||||
if (layer == null) {
|
@EditableProperty(name = "Hole")
|
||||||
layer = PCBLayer._1;
|
public Size getHoleSize() {
|
||||||
}
|
if (holeSize == null) {
|
||||||
return layer;
|
holeSize = HOLE_SIZE;
|
||||||
}
|
}
|
||||||
|
return holeSize;
|
||||||
public void setLayer(PCBLayer layer) {
|
}
|
||||||
this.layer = layer;
|
|
||||||
}
|
public void setHoleSize(Size holeSize) {
|
||||||
|
this.holeSize = holeSize;
|
||||||
@Override
|
}
|
||||||
public String getName() {
|
|
||||||
return super.getName();
|
@EditableProperty
|
||||||
}
|
public PCBLayer getLayer() {
|
||||||
|
if (layer == null) {
|
||||||
@Override
|
layer = PCBLayer._1;
|
||||||
public int getControlPointCount() {
|
}
|
||||||
return 1;
|
return layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setLayer(PCBLayer layer) {
|
||||||
public boolean isControlPointSticky(int index) {
|
this.layer = layer;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public String getName() {
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
return super.getName();
|
||||||
return VisibilityPolicy.NEVER;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public int getControlPointCount() {
|
||||||
public Point getControlPoint(int index) {
|
return 1;
|
||||||
return point;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean isControlPointSticky(int index) {
|
||||||
public void setControlPoint(Point point, int index) {
|
return true;
|
||||||
this.point.setLocation(point);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@EditableProperty(name = "Color")
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
public Color getLeadColor() {
|
return VisibilityPolicy.NEVER;
|
||||||
return color;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
public void setLeadColor(Color color) {
|
public Point getControlPoint(int index) {
|
||||||
this.color = color;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty
|
@Override
|
||||||
public Type getType() {
|
public void setControlPoint(Point point, int index) {
|
||||||
return type;
|
this.point.setLocation(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type type) {
|
@EditableProperty(name = "Color")
|
||||||
this.type = type;
|
public Color getLeadColor() {
|
||||||
}
|
return color;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public Void getValue() {
|
public void setLeadColor(Color color) {
|
||||||
return null;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EditableProperty
|
||||||
public void setValue(Void value) {}
|
public Type getType() {
|
||||||
|
return type;
|
||||||
public static enum Type {
|
}
|
||||||
ROUND, SQUARE;
|
|
||||||
|
public void setType(Type type) {
|
||||||
@Override
|
this.type = type;
|
||||||
public String toString() {
|
}
|
||||||
return name().substring(0, 1) + name().substring(1).toLowerCase();
|
|
||||||
}
|
@Override
|
||||||
}
|
public Void getValue() {
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(Void value) {}
|
||||||
|
|
||||||
|
public static enum Type {
|
||||||
|
ROUND, SQUARE, OVAL_HORIZONTAL, OVAL_VERTICAL;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().substring(0, 1) + name().substring(1).toLowerCase().replace('_', ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -2038,6 +2038,10 @@
|
|||||||
<releaseDate>2018-12-25 00:00:00.000 CET</releaseDate>
|
<releaseDate>2018-12-25 00:00:00.000 CET</releaseDate>
|
||||||
<name></name>
|
<name></name>
|
||||||
<changes>
|
<changes>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Oval solder pads, available as new types of regular "Solder Pad" components</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Faster click and popup menu response due to improved performance of selection area calculations, especially with bigger layouts</description>
|
<description>Faster click and popup menu response due to improved performance of selection area calculations, especially with bigger layouts</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user