mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
add caching support to more component types
This commit is contained in:
Binary file not shown.
@@ -251,6 +251,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
if (bodyColor != null) {
|
||||
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : bodyColor);
|
||||
|
||||
drawingObserver.startTracking();
|
||||
|
||||
if (!outlineMode && ConfigurationManager.getInstance().readBoolean(IPlugInPort.HI_QUALITY_RENDER_KEY, false)) {
|
||||
Point p1 = new Point((int) (length / 2), 0);
|
||||
Point p2 = new Point((int) (length / 2), (int) width);
|
||||
@@ -262,6 +264,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
} else {
|
||||
g2d.fill(shape);
|
||||
}
|
||||
|
||||
drawingObserver.stopTracking();
|
||||
}
|
||||
|
||||
drawingObserver.stopTracking();
|
||||
@@ -287,8 +291,16 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
|
||||
: borderColor;
|
||||
}
|
||||
g2d.setColor(finalBorderColor);
|
||||
|
||||
// if we are not filling the shape with color we need to ensure that we track the outline (e.g. with schematic symbols)
|
||||
if (bodyColor == null)
|
||||
drawingObserver.startTracking();
|
||||
|
||||
g2d.draw(shape);
|
||||
|
||||
if (bodyColor == null)
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
if (decorateAboveBorder()) {
|
||||
g2d.setComposite(newComposite);
|
||||
decorateComponentBody(g2d, outlineMode);
|
||||
|
||||
@@ -24,6 +24,7 @@ package org.diylc.components.connectivity;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
@@ -46,7 +47,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Eyelet", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Eyelet or turret terminal", instanceNamePrefix = "Eyelet",
|
||||
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class,
|
||||
enableCache = true)
|
||||
public class Eyelet extends AbstractComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -169,5 +171,11 @@ public class Eyelet extends AbstractComponent<String> {
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
double size = getSize().convertToPixels();
|
||||
return new Rectangle2D.Double(point.getX() - size, point.getY() - size, size * 2, size * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,16 +78,16 @@ public class HookupWire extends AbstractCurvedComponent<Void> implements IContin
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] {thickness / 4, thickness * 3}, 0, BasicStroke.CAP_ROUND);
|
||||
break;
|
||||
}
|
||||
Shape s = stroke.createStrokedShape(curve);
|
||||
Shape s = stroke.createStrokedShape(curve);
|
||||
drawingObserver.startTracking();
|
||||
g2d.fill(s);
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
if (getStriped()) {
|
||||
stroke = ObjectCache.getInstance().fetchStroke(thickness, new float[] { thickness / 2, thickness * 2 }, thickness * 10, BasicStroke.CAP_BUTT);
|
||||
Shape stripe = stroke.createStrokedShape(curve);
|
||||
g2d.setColor(getStripeColor());
|
||||
drawingObserver.stopTracking();
|
||||
g2d.fill(stripe);
|
||||
drawingObserver.startTracking();
|
||||
g2d.setColor(getStripeColor());
|
||||
g2d.fill(stripe);
|
||||
}
|
||||
|
||||
drawingObserver.stopTracking();
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Solder Pad", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Copper solder pad, round or square", instanceNamePrefix = "Pad",
|
||||
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TAG, keywordTag = "PCB", transformer = SimpleComponentTransformer.class, enableCache = true)
|
||||
public class SolderPad extends AbstractComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -190,6 +190,12 @@ public class SolderPad extends AbstractComponent<Void> {
|
||||
|
||||
@Override
|
||||
public void setValue(Void value) {}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
double size = getSize().convertToPixels();
|
||||
return new Rectangle2D.Double(point.getX() - size, point.getY() - size, size * 2, size * 2);
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
ROUND, SQUARE, OVAL_HORIZONTAL, OVAL_VERTICAL;
|
||||
|
||||
@@ -24,6 +24,7 @@ package org.diylc.components.connectivity;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
@@ -45,7 +46,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Trace Cut", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Designates the place where a trace on the vero board needs to be cut", instanceNamePrefix = "Cut",
|
||||
zOrder = IDIYComponent.BOARD + 1, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
transformer = SimpleComponentTransformer.class, enableCache = true)
|
||||
public class TraceCut extends AbstractComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -237,5 +238,11 @@ public class TraceCut extends AbstractComponent<Void> {
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
double size = getSize().convertToPixels();
|
||||
return new Rectangle2D.Double(point.getX() - size, point.getY() - size, size * 2, size * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ package org.diylc.components.connectivity;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.ObjectCache;
|
||||
import org.diylc.common.SimpleComponentTransformer;
|
||||
@@ -44,7 +45,8 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Turret Lug", category = "Connectivity", author = "Branislav Stojkovic",
|
||||
description = "Turret terminal lug", instanceNamePrefix = "Turret",
|
||||
zOrder = IDIYComponent.TRACE + 0.1, bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class)
|
||||
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class,
|
||||
enableCache = true)
|
||||
public class Turret extends AbstractComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -167,5 +169,11 @@ public class Turret extends AbstractComponent<String> {
|
||||
@Override
|
||||
public String getControlPointNodeName(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
double size = getSize().convertToPixels();
|
||||
return new Rectangle2D.Double(point.getX() - size, point.getY() - size, size * 2, size * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
@@ -56,7 +57,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Cliff 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Cliff-style closed panel mount 1/4\" phono jack",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = CliffJackTransformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = CliffJackTransformer.class,
|
||||
enableCache = true)
|
||||
public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -345,5 +347,17 @@ public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Area area = new Area();
|
||||
Area[] body = getBody();
|
||||
int margin = 20;
|
||||
for (Area a : body)
|
||||
if (a != null)
|
||||
area.add(a);
|
||||
Rectangle2D bounds = area.getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.awt.StringUtils;
|
||||
@@ -56,7 +57,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Closed 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Enclosed panel mount 1/4\" phono jack", zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "J", autoEdit = false, transformer = ClosedJackTransformer.class)
|
||||
instanceNamePrefix = "J", autoEdit = false, transformer = ClosedJackTransformer.class, enableCache = true)
|
||||
public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -369,5 +370,17 @@ public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Area area = new Area();
|
||||
Shape[] body = getBody();
|
||||
int margin = 20;
|
||||
for (Shape a : body)
|
||||
if (a != null)
|
||||
area.add(new Area(a));
|
||||
Rectangle2D bounds = area.getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "DIP Switch", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "SW", description = "Dual-in-line package switch",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class,
|
||||
enableCache = true)
|
||||
public class DIPSwitch extends AbstractTransparentComponent<String> implements ISwitch {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -544,6 +545,13 @@ public class DIPSwitch extends AbstractTransparentComponent<String> implements I
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
private String toBinary(int n) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
do {
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Fuse Holder (Panel)", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mounted fuse holder", zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "FH", autoEdit = false)
|
||||
instanceNamePrefix = "FH", autoEdit = false, enableCache = true)
|
||||
public class FuseHolderPanel extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -337,5 +337,12 @@ public class FuseHolderPanel extends AbstractMultiPartComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.awt.Point;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
@@ -51,7 +52,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "IEC Socket", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mounted IEC power socket", zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "IEC", autoEdit = false)
|
||||
instanceNamePrefix = "IEC", autoEdit = false, enableCache = true)
|
||||
public class IECSocket extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -391,5 +392,12 @@ public class IECSocket extends AbstractMultiPartComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Mini Relay", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "RY", description = "Miniature PCB mount relay, like Omron G5V-1 or G5V-2",
|
||||
zOrder = IDIYComponent.COMPONENT)
|
||||
zOrder = IDIYComponent.COMPONENT, enableCache = true)
|
||||
public class MiniRelay extends AbstractTransparentComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -430,6 +430,28 @@ public class MiniRelay extends AbstractTransparentComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int margin = 50;
|
||||
for (int i = 0; i < getControlPointCount(); i++) {
|
||||
Point p = getControlPoint(i);
|
||||
if (p.x < minX)
|
||||
minX = p.x;
|
||||
if (p.x > maxX)
|
||||
maxX = p.x;
|
||||
if (p.y < minY)
|
||||
minY = p.y;
|
||||
if (p.y > maxY)
|
||||
maxY = p.y;
|
||||
}
|
||||
|
||||
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin);
|
||||
}
|
||||
|
||||
public static enum RelayType {
|
||||
|
||||
+9
-1
@@ -29,6 +29,7 @@ import java.awt.Point;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
@@ -52,7 +53,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mounted mini toggle switch", zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "SW", autoEdit = false)
|
||||
instanceNamePrefix = "SW", autoEdit = false, enableCache = true)
|
||||
public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchType> implements ISwitch {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -454,5 +455,12 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
||||
return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody().getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
@@ -54,7 +55,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Open 1/4\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Switchcraft-style open panel mount 1/4\" phono jack, stereo and mono",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J")
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", enableCache = true)
|
||||
public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final double RING_THETA = Math.PI * 0.795;
|
||||
@@ -323,7 +324,7 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
|
||||
@Override
|
||||
public boolean isControlPointSticky(int index) {
|
||||
return index < 2 || getType() == OpenJackType.STEREO;
|
||||
return index < 2 || (getType() == OpenJackType.STEREO || getType() == OpenJackType.SWITCHED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -409,6 +410,18 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Area area = new Area();
|
||||
Area[] body = getBody();
|
||||
int margin = 20;
|
||||
for (Area a : body)
|
||||
if (a != null)
|
||||
area.add(a);
|
||||
Rectangle2D bounds = area.getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
public enum OpenJackType {
|
||||
|
||||
MONO, STEREO, SWITCHED;
|
||||
|
||||
+13
-1
@@ -53,7 +53,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Pilot Lamp Holder", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Fender-style pilot bulb holder for T2 and T-3 ¼ miniature bayonet lamps",
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PL")
|
||||
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "PL", enableCache = true)
|
||||
public class PilotLampHolder extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -411,5 +411,17 @@ public class PilotLampHolder extends AbstractMultiPartComponent<String> {
|
||||
|
||||
protected double getTheta() {
|
||||
return Math.toRadians(getAngle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Area area = new Area();
|
||||
Area[] body = getBody();
|
||||
int margin = 20;
|
||||
for (Area a : body)
|
||||
if (a != null)
|
||||
area.add(a);
|
||||
Rectangle2D bounds = area.getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Pin Header", author = "Branislav Stojkovic", category = "Electro-Mechanical",
|
||||
instanceNamePrefix = "PH", description = "PCB mount male pin header with editable number or pins and pin spacing",
|
||||
zOrder = IDIYComponent.COMPONENT)
|
||||
zOrder = IDIYComponent.COMPONENT, enableCache = true)
|
||||
public class PinHeader extends AbstractTransparentComponent<Void> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -354,5 +354,27 @@ public class PinHeader extends AbstractTransparentComponent<Void> {
|
||||
|
||||
@Deprecated
|
||||
public void setValue(Void value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int margin = 50;
|
||||
for (int i = 0; i < getControlPointCount(); i++) {
|
||||
Point p = getControlPoint(i);
|
||||
if (p.x < minX)
|
||||
minX = p.x;
|
||||
if (p.x > maxX)
|
||||
maxX = p.x;
|
||||
if (p.y < minY)
|
||||
minY = p.y;
|
||||
if (p.y > maxY)
|
||||
maxY = p.y;
|
||||
}
|
||||
|
||||
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.awt.StringUtils;
|
||||
@@ -52,7 +53,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Plastic DC Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mount plastic DC jack", zOrder = IDIYComponent.COMPONENT,
|
||||
instanceNamePrefix = "J", autoEdit = false)
|
||||
instanceNamePrefix = "J", autoEdit = false, enableCache = true)
|
||||
public class PlasticDCJack extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -267,5 +268,12 @@ public class PlasticDCJack extends AbstractMultiPartComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.awt.TwoCircleTangent;
|
||||
@@ -52,7 +53,8 @@ import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "RCA Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||
description = "Panel mount RCA phono jack socket", zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J")
|
||||
description = "Panel mount RCA phono jack socket", zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J",
|
||||
enableCache = true)
|
||||
public class RCAJack extends AbstractMultiPartComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -323,5 +325,12 @@ public class RCAJack extends AbstractMultiPartComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[1].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.Format;
|
||||
|
||||
@@ -57,7 +58,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Multi-Section Capacitor", author = "Branislav Stojkovic", category = "Passive",
|
||||
instanceNamePrefix = "C", description = "Multi-section vertically mounted electrolytic capacitor, similar to JJ, CE and others",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
|
||||
public class MultiSectionCapacitor extends AbstractTransparentComponent<Capacitance[]> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -521,5 +522,12 @@ public class MultiSectionCapacitor extends AbstractTransparentComponent<Capacita
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Potentiometer", author = "Branislav Stojkovic", category = "Passive",
|
||||
creationMethod = CreationMethod.SINGLE_CLICK, instanceNamePrefix = "VR",
|
||||
description = "Panel mount potentiometer with solder lugs", zOrder = IDIYComponent.COMPONENT,
|
||||
transformer = PotentiometerTransformer.class)
|
||||
transformer = PotentiometerTransformer.class, enableCache = true)
|
||||
public class PotentiometerPanel extends AbstractPotentiometer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -470,6 +470,18 @@ public class PotentiometerPanel extends AbstractPotentiometer {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Area area = new Area();
|
||||
Area[] body = getBody();
|
||||
int margin = 20;
|
||||
for (Area a : body)
|
||||
if (a != null)
|
||||
area.add(a);
|
||||
Rectangle2D bounds = area.getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
|
||||
+10
@@ -24,6 +24,7 @@ package org.diylc.components.semiconductors;
|
||||
import java.awt.Color;
|
||||
import java.awt.Point;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import org.diylc.common.Display;
|
||||
import org.diylc.common.Orientation;
|
||||
@@ -52,6 +53,8 @@ public abstract class AbstractTransistorPackage extends AbstractTransparentCompo
|
||||
|
||||
protected abstract void updateControlPoints();
|
||||
|
||||
public abstract Area[] getBody();
|
||||
|
||||
@Override
|
||||
public int mapToSpiceNode(int index) {
|
||||
if (getPinout() == null)
|
||||
@@ -208,4 +211,11 @@ public abstract class AbstractTransistorPackage extends AbstractTransparentCompo
|
||||
return null;
|
||||
return Integer.toString(index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Bridge Rectifier", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "BR", description = "Few variations of bridge rectifier chips",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class,
|
||||
enableCache = true)
|
||||
public class BridgeRectifier extends AbstractTransparentComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -667,6 +668,13 @@ public class BridgeRectifier extends AbstractTransparentComponent<String> {
|
||||
@Override
|
||||
public boolean canPointMoveFreely(int pointIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
int margin = 20;
|
||||
Rectangle2D bounds = getBody()[0].getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
public static enum RectifierType {
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Diode (glass)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
|
||||
description = "Glass diode, like most small signal diodes.", zOrder = IDIYComponent.COMPONENT,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
transformer = SimpleComponentTransformer.class, enableCache = true)
|
||||
public class DiodeGlass extends AbstractLeadedComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.diylc.utils.Constants;
|
||||
@ComponentDescriptor(name = "Diode (plastic)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
creationMethod = CreationMethod.POINT_BY_POINT, instanceNamePrefix = "D",
|
||||
description = "Plastic diode, like most rectifier, zener, schottky, etc.", zOrder = IDIYComponent.COMPONENT,
|
||||
transformer = SimpleComponentTransformer.class)
|
||||
transformer = SimpleComponentTransformer.class, enableCache = true)
|
||||
public class DiodePlastic extends AbstractLeadedComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -52,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Transistor (TO-1)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with small metal body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO1Transformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO1Transformer.class,
|
||||
enableCache = true)
|
||||
public class TransistorTO1 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -52,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Transistor (TO-126)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistors with a hole for heat sink mounting",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class,
|
||||
enableCache = true)
|
||||
public class TransistorTO126 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -52,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Transistor (TO-220)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistors with metal tab for heat sink mounting",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO220Transformer.class,
|
||||
enableCache = true)
|
||||
public class TransistorTO220 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -57,7 +57,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Transistor (TO-3)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with large metal body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
|
||||
public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -359,5 +359,17 @@ public class TransistorTO3 extends AbstractTransparentComponent<String> {
|
||||
|
||||
public void setDisplay(Display display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Area area = new Area();
|
||||
Area[] body = getBody();
|
||||
int margin = 20;
|
||||
for (Area a : body)
|
||||
if (a != null)
|
||||
area.add(a);
|
||||
Rectangle2D bounds = area.getBounds2D();
|
||||
return new Rectangle2D.Double(bounds.getX() - margin, bounds.getY() - margin, bounds.getWidth() + 2 * margin, bounds.getHeight() + 2 * margin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Transistor (TO-92)", author = "Branislav Stojkovic", category = "Semiconductors",
|
||||
instanceNamePrefix = "Q", description = "Transistor with small plastic or epoxy body",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO92Transformer.class)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = TO92Transformer.class,
|
||||
enableCache = true)
|
||||
public class TransistorTO92 extends AbstractTransistorPackage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -55,7 +55,7 @@ import org.diylc.utils.Constants;
|
||||
|
||||
@ComponentDescriptor(name = "Tube Socket", author = "Branislav Stojkovic", category = "Tubes",
|
||||
instanceNamePrefix = "V", description = "Various types of tube/valve sockets",
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
|
||||
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
|
||||
public class TubeSocket extends AbstractTransparentComponent<String> {
|
||||
|
||||
private static final Size B9A_PIN_SPACING_CHASSIS = new Size(12.5d, SizeUnit.mm);
|
||||
@@ -437,6 +437,13 @@ public class TubeSocket extends AbstractTransparentComponent<String> {
|
||||
updateControlPoints();
|
||||
// Reset body shape
|
||||
body = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle2D getCachingBounds() {
|
||||
Rectangle2D rect = getBody().getBounds2D();
|
||||
int margin = 40; // to catch the pins that are outside the body, if needed
|
||||
return new Rectangle2D.Double(rect.getX() - margin, rect.getY() - margin, rect.getWidth() + 2 * margin, rect.getHeight() + 2 * margin);
|
||||
}
|
||||
|
||||
public static enum Base {
|
||||
|
||||
Reference in New Issue
Block a user