diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index 5d13643c..55d0d90b 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-library/src/org/diylc/components/connectivity/SolderPad.java b/diylc/diylc-library/src/org/diylc/components/connectivity/SolderPad.java index 25ada2ef..7a395587 100644 --- a/diylc/diylc-library/src/org/diylc/components/connectivity/SolderPad.java +++ b/diylc/diylc-library/src/org/diylc/components/connectivity/SolderPad.java @@ -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 + * . + */ +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.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 - 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 = "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 { - 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 . + 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; -*/ -package org.diylc.components.connectivity; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.geom.Ellipse2D; -import java.awt.geom.Rectangle2D; - -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; - -@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 { - - 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)); + 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; } - drawingObserver.stopTrackingContinuityArea(); - if (getHoleSize().getValue() > 0) { - g2d.setColor(Constants.CANVAS_COLOR); - g2d.fill(new Ellipse2D.Double(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter, holeDiameter)); - } - } - - @Override - public void drawIcon(Graphics2D g2d, int width, int height) { - int diameter = getClosestOdd(width / 2); - int holeDiameter = 5; - g2d.setColor(COLOR); - g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter); - g2d.setColor(Constants.CANVAS_COLOR); - g2d.fillOval((width - holeDiameter) / 2, (height - holeDiameter) / 2, holeDiameter, holeDiameter); - } - - @EditableProperty(validatorClass = PositiveMeasureValidator.class) - public Size getSize() { - return size; - } - - public void setSize(Size size) { - this.size = size; - } - - @EditableProperty(name = "Hole") - public Size getHoleSize() { - if (holeSize == null) { - holeSize = HOLE_SIZE; - } - return holeSize; - } - - public void setHoleSize(Size holeSize) { - this.holeSize = holeSize; - } - - @EditableProperty - public PCBLayer getLayer() { - if (layer == null) { - layer = PCBLayer._1; - } - return layer; - } - - public void setLayer(PCBLayer layer) { - this.layer = layer; - } - - @Override - public String getName() { - return super.getName(); - } - - @Override - public int getControlPointCount() { - return 1; - } - - @Override - public boolean isControlPointSticky(int index) { - return true; - } - - @Override - public VisibilityPolicy getControlPointVisibilityPolicy(int index) { - return VisibilityPolicy.NEVER; - } - - @Override - public Point getControlPoint(int index) { - return point; - } - - @Override - public void setControlPoint(Point point, int index) { - this.point.setLocation(point); - } - - @EditableProperty(name = "Color") - public Color getLeadColor() { - return color; - } - - public void setLeadColor(Color color) { - this.color = color; - } - - @EditableProperty - public Type getType() { - return type; - } - - public void setType(Type type) { - this.type = type; - } - - @Override - public Void getValue() { - return null; - } - - @Override - public void setValue(Void value) {} - - public static enum Type { - ROUND, SQUARE; - - @Override - public String toString() { - return name().substring(0, 1) + name().substring(1).toLowerCase(); - } - } -} + 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 if (type == Type.OVAL_HORIZONTAL) { + g2d.fill(new Ellipse2D.Double(point.x - diameter / 2, point.y - diameter * 3 / 8, diameter, diameter * 3 / 4)); + } else if (type == Type.OVAL_VERTICAL) { + g2d.fill(new Ellipse2D.Double(point.x - diameter * 3 / 8, point.y - diameter / 2, diameter * 3 / 4, diameter)); + } else { + g2d.fill(new Rectangle2D.Double(point.x - diameter / 2, point.y - diameter / 2, diameter, diameter)); + } + drawingObserver.stopTrackingContinuityArea(); + if (getHoleSize().getValue() > 0) { + g2d.setColor(Constants.CANVAS_COLOR); + g2d.fill(new Ellipse2D.Double(point.x - holeDiameter / 2, point.y - holeDiameter / 2, holeDiameter, holeDiameter)); + } + } + + @Override + public void drawIcon(Graphics2D g2d, int width, int height) { + int diameter = getClosestOdd(width / 2); + int holeDiameter = 5; + g2d.setColor(COLOR); + g2d.fillOval((width - diameter) / 2, (height - diameter) / 2, diameter, diameter); + g2d.setColor(Constants.CANVAS_COLOR); + g2d.fillOval((width - holeDiameter) / 2, (height - holeDiameter) / 2, holeDiameter, holeDiameter); + } + + @EditableProperty(validatorClass = PositiveMeasureValidator.class) + public Size getSize() { + return size; + } + + public void setSize(Size size) { + this.size = size; + } + + @EditableProperty(name = "Hole") + public Size getHoleSize() { + if (holeSize == null) { + holeSize = HOLE_SIZE; + } + return holeSize; + } + + public void setHoleSize(Size holeSize) { + this.holeSize = holeSize; + } + + @EditableProperty + public PCBLayer getLayer() { + if (layer == null) { + layer = PCBLayer._1; + } + return layer; + } + + public void setLayer(PCBLayer layer) { + this.layer = layer; + } + + @Override + public String getName() { + return super.getName(); + } + + @Override + public int getControlPointCount() { + return 1; + } + + @Override + public boolean isControlPointSticky(int index) { + return true; + } + + @Override + public VisibilityPolicy getControlPointVisibilityPolicy(int index) { + return VisibilityPolicy.NEVER; + } + + @Override + public Point getControlPoint(int index) { + return point; + } + + @Override + public void setControlPoint(Point point, int index) { + this.point.setLocation(point); + } + + @EditableProperty(name = "Color") + public Color getLeadColor() { + return color; + } + + public void setLeadColor(Color color) { + this.color = color; + } + + @EditableProperty + public Type getType() { + return type; + } + + public void setType(Type type) { + this.type = type; + } + + @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('_', ' '); + } + } +} diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 5d13643c..55d0d90b 100644 Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index f7929d68..5a5987ff 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 0befae09..12616f0c 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2038,6 +2038,10 @@ 2018-12-25 00:00:00.000 CET + + NEW_FEATURE + Oval solder pads, available as new types of regular "Solder Pad" components + IMPROVEMENT Faster click and popup menu response due to improved performance of selection area calculations, especially with bigger layouts