Compare commits

..

45 Commits

Author SHA1 Message Date
Bane Stojkovic 243b13c37c Release 4.37.0 2023-04-27 09:17:59 +02:00
Bane Stojkovic 4660467df5 Proto board updates 2023-04-27 09:17:44 +02:00
Bane Stojkovic 73a12bc107 Update ProtoBoard780.java 2023-04-26 17:32:55 +02:00
Bane Stojkovic ece6015a7f Ability to rotate (almost) all components using keyboard shortcuts and 'Transform Selection' menu 2023-04-26 17:32:50 +02:00
Bane Stojkovic 1cbdf505fe Update ProtoBoard780.java 2023-04-22 18:01:45 +02:00
Bane Stojkovic f0c1970784 Proto board 780 draft 2023-04-14 08:24:55 +02:00
Bane Stojkovic 14944a3e38 Release 4.36 2023-03-30 10:02:06 +02:00
Bane Stojkovic 48fe5f496b Fix fuse symbol 2023-03-29 09:38:27 +02:00
Bane Stojkovic 57a7932675 Improve backup file date format 2023-03-28 16:54:00 +02:00
Bane Stojkovic e0d2964e12 When backing up the configuration file, append the current timestamp at the end instead of a '~' 2023-03-28 16:35:40 +02:00
Bane Stojkovic c3f9208ab7 Fix issue deserializing building blocks 2023-03-28 16:12:33 +02:00
Bane Stojkovic 3a5e6f553d Fix issue with null value in inductor causing exceptions 2023-03-28 16:12:19 +02:00
Bane Stojkovic 24c8afd620 Configurable max switch combination count for circuit analysis (using org.diylc.maxSwitchCombinations argument) 2023-03-28 16:11:57 +02:00
Bane Stojkovic 4710d1b484 Merge branch 'master' of https://github.com/bancika/diy-layout-creator 2023-03-26 13:48:59 +02:00
Bane Stojkovic 2ce7677672 Title Block added as one of factory building blocks (was missing in 4.35 by mistake) 2023-03-26 13:48:58 +02:00
Bane Stojkovic 04a22436d2 Lever switch orientation not loaded correctly from files created prior to version 4.35 2023-03-26 13:48:26 +02:00
Bane Stojkovic 0ef3bc4adb Update ISSUE_TEMPLATE.md 2023-01-16 13:33:57 +01:00
Bane Stojkovic 887be7338f Release 4.35 2022-12-23 18:20:53 +01:00
Bane Stojkovic 72f61b978a REname audio transformer component 2022-12-23 16:00:26 +01:00
Bane Stojkovic 4c38075dc7 Lib update 2022-12-23 12:07:35 +01:00
Bane Stojkovic 8211976044 Trace cut doesn't affect continuity of vero board traces 2022-12-23 08:24:43 +01:00
Bane Stojkovic 22e9bbaa20 Fix netlist regression issue for IC 2022-12-20 23:43:23 +01:00
Bane Stojkovic 0fcf7e1fd4 Enhance jack icon 2022-12-20 23:42:57 +01:00
Bane Stojkovic 04302866e9 Jack icon improvement 2022-12-16 16:21:23 +01:00
Bane Stojkovic 9bcc56f228 Added '1/8" Cliff Jack' component - stereo and mono 2022-12-15 23:25:49 +01:00
Bane Stojkovic d7903bc3bb REname icon file 2022-12-14 23:13:06 +01:00
Bane Stojkovic 8178c72fbe New file icons for Mac OS 2022-12-14 23:10:32 +01:00
Bane Stojkovic ab53f7e85f 'Renumber On Paste' feature now applies to variants as well 2022-12-14 22:49:57 +01:00
Bane Stojkovic 7a186d0d49 Show wire gauge in the bom and project explorer 2022-12-14 22:15:40 +01:00
Bane Stojkovic d5d0ec56cf Double click in the project explorer to edit selected component 2022-12-14 22:15:07 +01:00
Bane Stojkovic b45ee77472 Upon starting or opening a project, the ruler is slightly misaligned with the project boundaries 2022-12-14 19:13:51 +01:00
Bane Stojkovic 796c825f02 Title Block added as one of factory building blocks 2022-12-14 18:31:28 +01:00
Bane Stojkovic 063cfde769 Diode symbol doesn't appear in the BOM 2022-12-14 12:29:45 +01:00
Bane Stojkovic b89a851513 Show jack type in the BOM 2022-12-13 18:39:16 +01:00
Bane Stojkovic b6f3020072 DIL IC pin labels don't match between the rendered values and values in the netlist 2022-12-12 23:35:02 +01:00
Bane Stojkovic f4f4ba7458 Ability to use up/down arrow keys in the project explorer to select components 2022-12-12 22:44:14 +01:00
Bane Stojkovic f181109ac7 Better component value render in explorer 2022-12-12 21:57:17 +01:00
Bane Stojkovic c7d5fe3cf4 Handle array value string representation 2022-12-12 01:17:53 +01:00
Bane Stojkovic e9414613a4 Don't show label value in bom and other places 2022-12-12 01:17:36 +01:00
Bane Stojkovic 54da44e0d0 Show component values in the project explorer 2022-12-12 01:17:17 +01:00
Bane Stojkovic 92f9c0c89a Added 'PCB Terminal Block' component 2022-12-12 01:03:07 +01:00
Bane Stojkovic 16d718ffc5 Added 'Solder Lug' component 2022-12-11 00:20:43 +01:00
Bane Stojkovic 03df6158e2 Use scroll buttons in 'Tabbed Toolbar' instead of arranging tabs into multiple lines when the screen is not large enough to show them all 2022-12-10 23:19:21 +01:00
Bane Stojkovic 895de4e7f2 Improved find tool usability, make the screen pan to the selected components 2022-12-09 23:13:55 +01:00
Bane Stojkovic 655f5253f6 Escape comma in BOM CSV files to avoid component names being split into separate columns 2022-12-09 22:46:44 +01:00
58 changed files with 5180 additions and 2025 deletions
+1
View File
@@ -2,6 +2,7 @@ Thank you for reporting issues and contributing ideas and features to DIYLC repo
Before you proceed, please read the following:
* One request or bug report per issue, please. No bundling.
* If you are reporting a bug, please attach the latest application log file together with description of steps that lead to the issue. They can be found in the user directory under `.diylc/logs` directory. On Windows 7 and later, it's located in `c:/Users/<your username>/.diylc/logs`. On Linux and MacOS, it's typically in `/Users/<your username>/.diylc/logs`.
* If you are having issues starting the application under MacOS, make sure that 3rd party apps are allowed on your Mac. This document covers how to do it - https://support.apple.com/en-us/HT202491.
* Try to look for similar unresolved issues that are already reported to avoid duplicates.
Binary file not shown.
@@ -0,0 +1,116 @@
package org.diylc.common;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.apache.log4j.Logger;
import org.diylc.core.Angle;
import org.diylc.core.IDIYComponent;
import org.diylc.presenter.ComponentProcessor;
public class DefaultComponentTransformer implements IComponentTransformer {
private static final Logger LOG = Logger.getLogger(DefaultComponentTransformer.class);
@Override
public boolean canRotate(IDIYComponent<?> component) {
List<PropertyWrapper> properties =
ComponentProcessor.getInstance().extractProperties(component.getClass());
for (PropertyWrapper property : properties) {
if (property.getType().isAssignableFrom(Orientation.class)
|| property.getType().isAssignableFrom(OrientationHV.class)
|| property.getType().isAssignableFrom(Angle.class))
return true;
}
return false;
}
@Override
public boolean canMirror(IDIYComponent<?> component) {
return false;
}
@Override
public boolean mirroringChangesCircuit() {
return false;
}
@Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
boolean canRotate = false;
List<PropertyWrapper> properties =
ComponentProcessor.getInstance().extractProperties(component.getClass());
for (PropertyWrapper property : properties) {
try {
property.readFrom(component);
} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException
| SecurityException | NoSuchMethodException e) {
LOG.warn("Error while rotating component " + component.getName(), e);
}
try {
if (property.getType().isAssignableFrom(Orientation.class)) {
canRotate = true;
Orientation o = (Orientation) property.getValue();
int oValue = o.ordinal();
oValue += direction;
if (oValue < 0)
oValue = Orientation.values().length - 1;
if (oValue >= Orientation.values().length)
oValue = 0;
o = Orientation.values()[oValue];
property.setValue(o);
}
if (property.getType().isAssignableFrom(OrientationHV.class)) {
canRotate = true;
OrientationHV o = (OrientationHV) property.getValue();
int oValue = o.ordinal();
oValue += direction;
if (oValue < 0)
oValue = OrientationHV.values().length - 1;
if (oValue >= OrientationHV.values().length)
oValue = 0;
o = OrientationHV.values()[oValue];
property.setValue(o);
}
if (property.getType().isAssignableFrom(Angle.class)) {
canRotate = true;
Angle angle = (Angle) property.getValue();
Angle newAngle = angle.rotate(direction);
property.setValue(newAngle);
}
} catch (Exception e) {
LOG.warn("Error while rotating component " + component.getName(), e);
}
if (canRotate) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction,
center.getX(), center.getY());
for (int index = 0; index < component.getControlPointCount(); index++) {
Point2D p = new Point2D.Double();
rotate.transform(component.getControlPoint(index), p);
component.setControlPoint(p, index);
}
try {
property.writeTo(component);
} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException
| SecurityException | NoSuchMethodException e) {
LOG.warn("Error while rotating component " + component.getName(), e);
}
break;
}
}
}
@Override
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {}
}
@@ -1,52 +0,0 @@
/*
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.common;
import java.awt.geom.Point2D;
import org.diylc.core.IDIYComponent;
public class DefaultTransformer implements IComponentTransformer {
@Override
public boolean canRotate(IDIYComponent<?> component) {
return false;
}
@Override
public boolean canMirror(IDIYComponent<?> component) {
return false;
}
@Override
public boolean mirroringChangesCircuit() {
return false;
}
@Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
}
@Override
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {
}
}
@@ -31,7 +31,7 @@ public abstract class AbstractAngledComponent<T> extends AbstractTransparentComp
private static final long serialVersionUID = 1L;
@Deprecated
protected transient Orientation orientation;
protected Orientation orientation;
protected int angle;
transient protected Shape[] body;
@@ -30,6 +30,7 @@ import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.annotations.EditableProperty;
@@ -87,8 +88,15 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
}
@Override
public String getValueForDisplay() {
return getValue() == null ? "" : getValue().toString();
public String getValueForDisplay() {
if (getValue() == null)
return "";
Object val = getValue();
if (val.getClass().isArray()) {
return String.join(" / ", Arrays.stream((Object[])val).map(x -> x == null ? "" : x.toString()).collect(Collectors.toList()));
}
return val.toString();
}
/**
@@ -23,7 +23,7 @@ package org.diylc.core.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.diylc.common.DefaultTransformer;
import org.diylc.common.DefaultComponentTransformer;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
@@ -94,7 +94,7 @@ public @interface ComponentDescriptor {
/**
* @return if the component can be rotated and/or mirrored, returns a class of the transformer that can do it
*/
Class<? extends IComponentTransformer> transformer() default DefaultTransformer.class;
Class<? extends IComponentTransformer> transformer() default DefaultComponentTransformer.class;
/**
* Defines if and how a component should appear in auto-generated project keywords. See
@@ -226,7 +226,7 @@ public abstract class NetlistAnalyzer {
}
protected String extractName(IDIYComponent<?> c) {
return c.getName() + " " + c.getValueForDisplay();
return c.getName() + " " + (c.getValueForDisplay() == null ? "" : c.getValueForDisplay());
}
public static List<Set<IDIYComponent<?>>> extractComponentGroups(List<Netlist> netlists) {
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
import org.diylc.common.ComponentType;
import org.diylc.core.ICommonNode;
import org.diylc.core.IContinuity;
@@ -50,10 +51,12 @@ public class NetlistBuilder {
public static final float eps = 4; // consider any nodes closer than this as connected
private static final int MAX_SWITCH_COMBINATIONS = 64;
public static int MAX_SWITCH_COMBINATIONS = 64;
private static final String MAX_SWITCH_COMBINATIONS_ERROR = LangUtil
.translate("Maximum number of switching combinations exceeded. Allowed: %s, actual: %s");
private static final Logger LOG = Logger.getLogger(NetlistBuilder.class);
@SuppressWarnings("unchecked")
public static List<Netlist> extractNetlists(boolean includeSwitches, Project project,
@@ -130,8 +133,18 @@ public class NetlistBuilder {
int totalSwitchCombinations =
switches.stream().map(sw -> sw.getPositionCount()).reduce(1, (a, b) -> a * b);
int maxSwitch = MAX_SWITCH_COMBINATIONS;
String maxSwitchStr = System.getProperty("org.diylc.maxSwitchCombinations");
if (maxSwitchStr != null) {
try {
maxSwitch = Integer.parseInt(maxSwitchStr);
} catch (Exception e) {
LOG.error("Could not apply property org.diylc.maxSwitchCombinations", e);
}
}
if (totalSwitchCombinations > MAX_SWITCH_COMBINATIONS) {
if (totalSwitchCombinations > maxSwitch) {
throw new NetlistException(String.format(MAX_SWITCH_COMBINATIONS_ERROR,
MAX_SWITCH_COMBINATIONS, totalSwitchCombinations));
}
@@ -178,22 +178,13 @@ public class BuildingBlockManager {
if (System.getProperty("org.diylc.WriteStaticBlocks", "false").equalsIgnoreCase("true")) {
Map<String, List<IDIYComponent<?>>> defaultBlockMap =
new HashMap<String, List<IDIYComponent<?>>>();
// unify default and user-variants
for (Map.Entry<String, List<IDIYComponent<?>>> entry : blocks.entrySet()) {
if (defaultBlockMap.containsKey(entry.getKey())) {
defaultBlockMap.get(entry.getKey()).addAll(entry.getValue());
} else {
defaultBlockMap.put(entry.getKey(), entry.getValue());
}
}
defaultBlockMap.put(blockName, blockComponents);
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(BLOCKS_FILE_NAME));
XStream xStream = new XStream(new DomDriver());
xStream.addPermission(AnyTypePermission.ANY);
xStream.toXML(defaultBlockMap, out);
out.close();
// no more user variants
configManager.writeValue(IBlockProcessor.BLOCKS_KEY, null);
LOG.info("Saved default blocks");
} catch (IOException e) {
LOG.error("Could not save default blocks", e);
@@ -285,8 +285,6 @@ public class InstantiationManager {
}
component.createdIn(currentProject);
component.setName(createUniqueName(componentType, currentProject.getComponents()));
// Translate them to the desired location.
if (point != null) {
for (int j = 0; j < component.getControlPointCount(); j++) {
@@ -297,11 +295,16 @@ public class InstantiationManager {
}
}
loadComponentShapeFromTemplate(component, template);
loadComponentShapeFromTemplate(component, template);
if (model == null) {
// do not fill with defaults if creating by a model
fillWithDefaultProperties(component, template);
}
// preserve component from the template if RENUMBER_ON_PASTE_KEY is OFF
if (template == null || ConfigurationManager.getInstance().readBoolean(IPlugInPort.RENUMBER_ON_PASTE_KEY, true)) {
component.setName(createUniqueName(componentType, currentProject.getComponents()));
}
// Write to recent components
@@ -1069,15 +1069,16 @@ public class Presenter implements IPlugInPort {
@Override
public void selectMatching(String criteria) {
Set<IDIYComponent<?>> matching = new HashSet<IDIYComponent<?>>();
String regex = ".*" + criteria.toLowerCase() + ".*";
for (IDIYComponent<?> c : currentProject.getComponents()) {
ComponentType type = ComponentProcessor.getInstance().extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
if ((c.getName() != null && c.getName().toLowerCase().matches(criteria.toLowerCase())) ||
(c.getValueForDisplay() != null && c.getValueForDisplay().toLowerCase().matches(criteria.toLowerCase())) ||
(type != null && type.getName().toLowerCase().matches(criteria.toLowerCase())))
if ((c.getName() != null && c.getName().toLowerCase().matches(regex)) ||
(c.getValueForDisplay() != null && c.getValueForDisplay().toLowerCase().matches(regex)) ||
(type != null && type.getName().toLowerCase().matches(regex)))
matching.add(c);
}
updateSelection(matching);
messageDispatcher.dispatchMessage(EventType.REPAINT);
messageDispatcher.dispatchMessage(EventType.REPAINT, true);
if (matching.size() > 0)
messageDispatcher.dispatchMessage(EventType.SCROLL_TO, getSelectionBounds(true));
}
@@ -2563,9 +2564,9 @@ public class Presenter implements IPlugInPort {
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(component.getClass());
Map<String, Object> values = new HashMap<String, Object>();
for (PropertyWrapper property : properties) {
if (property.getName().equalsIgnoreCase("name")) {
continue;
}
// if (property.getName().equalsIgnoreCase("name")) {
// continue;
// }
try {
property.readFrom(component);
values.put(property.getName(), property.getValue());
@@ -133,4 +133,608 @@
</diylc.semiconductors.TransistorTO92>
</list>
</entry>
<entry>
<string>Title Block</string>
<list>
<org.diylc.components.shapes.Rectangle>
<name>RECT1</name>
<alpha>127</alpha>
<value></value>
<controlPoints>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.7007874015748</x>
<y>149.60629921259843</y>
</java.awt.geom.Point2D_-Double>
</controlPoints>
<firstPoint>
<x>0.0</x>
<y>0.0</y>
</firstPoint>
<secondPoint>
<x>393.7007874015748</x>
<y>149.60629921259843</y>
</secondPoint>
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</color>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<borderThickness>
<value>0.5</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</borderThickness>
<edgeRadius>
<value>0.0</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</edgeRadius>
</org.diylc.components.shapes.Rectangle>
<org.diylc.components.connectivity.Line>
<name>LN1</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>188.9763779527559</x>
<y>149.60629921259843</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>188.9763779527559</x>
<y>118.11023622047246</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.connectivity.Line>
<name>LN2</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>118.11023622047246</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.70078740157487</x>
<y>118.11023622047246</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.connectivity.Line>
<name>LN3</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>55.118110236220474</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.7007874015748</x>
<y>55.118110236220474</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.connectivity.Line>
<name>LN4</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>86.61417322834646</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.70078740157476</x>
<y>86.61417322834646</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.misc.Label>
<name>LAB1</name>
<point>
<x>204.7244094488189</x>
<y>133.85826771653544</y>
</point>
<text>revision</text>
<font>
<size class="float">14.0</size>
<weight class="null"/>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Roman</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB2</name>
<point>
<x>291.3385826771654</x>
<y>133.85826771653544</y>
</point>
<text>1.0.0</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB3</name>
<point>
<x>15.748031496062993</x>
<y>133.85826771653544</y>
</point>
<text>updated</text>
<font>
<size class="float">14.0</size>
<weight class="null"/>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Roman</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB4</name>
<point>
<x>86.61417322834646</x>
<y>133.85826771653544</y>
</point>
<text>1/1/2020</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB5</name>
<point>
<x>47.24409448818898</x>
<y>70.86614173228347</y>
</point>
<text>drawn by</text>
<font reference="../../org.diylc.components.misc.Label/font"/>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB6</name>
<point>
<x>31.496062992125985</x>
<y>15.748031496062993</y>
</point>
<text>title</text>
<font reference="../../org.diylc.components.misc.Label/font"/>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB7</name>
<point>
<x>188.9763779527559</x>
<y>70.86614173228347</y>
</point>
<text>Author Name</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB8</name>
<point>
<x>188.9763779527559</x>
<y>31.496062992125985</y>
</point>
<text>My Cool Project</text>
<font>
<size class="float">20.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>255</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB9</name>
<point>
<x>15.748031496062993</x>
<y>102.36220472440945</y>
</point>
<text>website</text>
<font>
<size class="float">14.0</size>
<weight class="null"/>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Roman</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB10</name>
<point>
<x>188.9763779527559</x>
<y>102.36220472440945</y>
</point>
<text>www.mysite.com/myproject</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
</list>
</entry>
</map>
@@ -4225,5 +4225,149 @@
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>35</minor>
<build>0</build>
</versionNumber>
<releaseDate>2022-12-23 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added '1/8&quot; Cliff Jack' component - stereo and mono</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added 'Solder Lug' component</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added 'PCB Terminal Block' component</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Show component values in the project explorer</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Double click in the project explorer to edit selected component</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Title Block added as one of factory building blocks</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>'Renumber On Paste' feature now applies to variants as well. When set to OFF, the app honors the name saved in the variant</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>New file icons for Mac OS</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Ability to use up/down arrow keys in the project explorer to select components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Use scroll buttons in 'Tabbed Toolbar' instead of arranging tabs into multiple lines when the screen is not large enough to show them all</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Escape comma in BOM CSV files to avoid component names being split into separate columns</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Show jack type in the BOM and project explorer</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Show wire gauge in the BOM and project explorer</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improved find tool usability, make the screen pan to the selected components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Trace cut doesn't affect continuity of vero board traces</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>DIL IC pin labels incorrect in the netlist</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Diode symbol doesn't appear in the BOM</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Upon starting or opening a project, the ruler is slightly miss-aligned with the project boundaries</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>36</minor>
<build>0</build>
</versionNumber>
<releaseDate>2023-03-30 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Title Block added as one of factory building blocks (was missing in 4.35 by mistake)</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Configurable max switch combination count for circuit analysis (using org.diylc.maxSwitchCombinations argument)</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Added resilience to the code that saves the configuration file to avoid it getting corrupted</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>When backing up the configuration file, append the current timestamp at the end instead of a '~'</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improve the format of timestamp in file backups</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>General application slowness when Inductor or Fuse Symbol components are added to the drawing</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Lever switch orientation not loaded correctly from files created prior to version 4.35</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>37</minor>
<build>0</build>
</versionNumber>
<releaseDate>2023-04-27 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>'Proto Board 780 Holes' added with two variations (sponsored by Pete Olivier)</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Ability to rotate (almost) all components using keyboard shortcuts and 'Transform Selection' menu</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a>
</java.util.Arrays_-ArrayList>
@@ -26,6 +26,7 @@ import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;
/**
* Serializes {@link Font} objects in a more compact fashion. Backwards compatible when unmarshalling.
@@ -34,8 +35,8 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
*/
public class FontConverter extends com.thoughtworks.xstream.converters.extended.FontConverter {
public FontConverter() {
super(null);
public FontConverter(Mapper mapper) {
super(mapper);
}
@Override
@@ -50,7 +51,7 @@ public class FontConverter extends com.thoughtworks.xstream.converters.extended.
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
if (reader.getAttribute("name") != null) {
return new Font(reader.getAttribute("name"), Integer.parseInt(reader.getAttribute("style")), Integer.parseInt(reader.getAttribute("size")));
}
}
return super.unmarshal(reader, context);
}
@@ -116,9 +116,9 @@ public class ProjectFileManager {
xStream.aliasPackage("diylc", "org.diylc.components");
xStream.registerConverter(new PointConverter());
xStream.registerConverter(new ColorConverter());
xStream.registerConverter(new FontConverter());
xStream.registerConverter(new FontConverter(xStream.getMapper()));
xStream.registerConverter(new MeasureConverter());
xStream.registerConverter(new AreaConverter());
xStream.registerConverter(new AreaConverter());
xStream.addImmutableType(Color.class, true);
xStream.addImmutableType(java.awt.geom.Point2D.class, true);
xStream.addImmutableType(java.awt.geom.Point2D.Double.class, true);
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,515 @@
/*
*
* 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.boards;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.diylc.awt.StringUtils;
import org.diylc.common.HorizontalAlignment;
import org.diylc.common.ObjectCache;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.transform.ProtoBoardTransformer;
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.measures.Size;
import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Proto Board 780 Holes", category = "Boards",
author = "Branislav Stojkovic",
description = "Prototyping board similar to Radio Shack 276-168B or MPJA 33304",
instanceNamePrefix = "BB", zOrder = IDIYComponent.BOARD,
bomPolicy = BomPolicy.SHOW_ONLY_TYPE_NAME, autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, enableCache = true,
transformer = ProtoBoardTransformer.class)
public class ProtoBoard780 extends AbstractProtoBoard {
private static final long serialVersionUID = 1L;
public static Color FILL_COLOR = Color.decode("#6B9B6B");
public static Size SPACING = new Size(0.1d, SizeUnit.in);
public static Color SELECTION_COLOR = Color.red;
public static Color PAD_COLOR = COPPER_COLOR;
public static Color TRACE_COLOR = PAD_COLOR.brighter();
public static Color HOLE_COLOR = Color.white;
public static float COORDINATE_FONT_SIZE = 9f;
public static Color COORDINATE_COLOR = Color.decode("#DDDDDD");
public static Size PAD_SIZE = new Size(2d, SizeUnit.mm);
public static Size WIDTH_SIZE = new Size(72d, SizeUnit.mm);
public static Size LENGTH_SIZE = new Size(95d, SizeUnit.mm);
protected Point2D point = new Point2D.Double(0, 0);
protected Color boardColor = FILL_COLOR;
protected Color padColor = PAD_COLOR;
protected Color traceColor = TRACE_COLOR;
protected Color textColor = COORDINATE_COLOR;
public static Size MOUNTING_HORIZONTAL_SPACING_MPJA = new Size(60d, SizeUnit.mm);
public static Size MOUNTING_HORIZONTAL_SPACING_RS = new Size(56d, SizeUnit.mm);
public static Size MOUNTING_HOLE_SIZE = new Size(3d, SizeUnit.mm);
protected ProtoBoard780Type type = ProtoBoard780Type.MPJA;
@SuppressWarnings("incomplete-switch")
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
if (checkPointsClipped(g2d.getClip())) {
return;
}
// adjust the angle
double theta = 0;
switch (getOrientation()) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
if (theta != 0) {
g2d.rotate(theta, point.getX(), point.getY());
}
double spacing = SPACING.convertToPixels();
// draw body
g2d.setColor(boardColor);
int width = (int) WIDTH_SIZE.convertToPixels();
int length = (int) LENGTH_SIZE.convertToPixels();
int mountingHoleSize = (int) MOUNTING_HOLE_SIZE.convertToPixels();
Shape rect = new Rectangle2D.Double(point.getX(), point.getY(), width, length);
g2d.fill(rect);
Color finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: boardColor.darker();
g2d.setColor(finalBorderColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
drawingObserver.stopTracking();
g2d.draw(rect);
int padSize = getClosestOdd(PAD_SIZE.convertToPixels());
int holeSize = getClosestOdd(padSize / 3);
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE));
double offsetY = spacing * 0.5;
// top section
for (int i = 0; i < 15; i++) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize - 2f));
g2d.setColor(traceColor);
int padX = (int) (point.getX() + width / 2 - 7 * spacing + i * spacing);
drawingObserver.startTrackingContinuityArea(true);
g2d.drawLine(padX, (int) (point.getY() + offsetY), padX,
(int) (point.getY() + spacing + offsetY));
drawingObserver.stopTrackingContinuityArea();
for (int j = 0; j < 2; j++) {
int padY = (int) (point.getY() + spacing * j + offsetY);
g2d.setColor(padColor);
drawingObserver.startTrackingContinuityArea(true);
g2d.fillOval(padX - padSize / 2, padY - padSize / 2, padSize, padSize);
drawingObserver.stopTrackingContinuityArea();
g2d.setColor(padColor.darker());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
g2d.drawOval(padX - padSize / 2, padY - padSize / 2, padSize, padSize);
g2d.setColor(HOLE_COLOR);
g2d.fillOval(padX - holeSize / 2, padY - holeSize / 2, holeSize, holeSize);
}
}
// top section labels
g2d.setColor(textColor);
for (int i = 0; i < 4; i++) {
int x = i == 0 ? 1 : i * 5;
int padX = (int) (point.getX() + width / 2 - 8 * spacing + x * spacing);
int padY = (int) (point.getY() + spacing * 2);
// // flip the coordinates for MPJA
// if (type == ProtoBoard780Type.MPJA) {
// x = i == 3 ? 1 : (3 - i) * 5;
// }
StringUtils.drawCenteredText(g2d, Integer.toString(x), padX, padY, HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM);
}
offsetY = spacing * 5.5;
// draw 3-pad traces and vertical traces
drawingObserver.startTrackingContinuityArea(true);
g2d.setColor(traceColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize - 2f));
// the outer bus
g2d.drawLine((int) (point.getX() + width / 2 - 13 * spacing),
(int) (point.getY() - 2 * spacing + offsetY),
(int) (point.getX() + width / 2 + 13 * spacing),
(int) (point.getY() - 2 * spacing + offsetY));
g2d.drawLine((int) (point.getX() + width / 2 - 13 * spacing),
(int) (point.getY() - 2 * spacing + offsetY),
(int) (point.getX() + width / 2 - 13 * spacing),
(int) (point.getY() + (29 + (type == ProtoBoard780Type.RS ? 2 : 0)) * spacing + offsetY));
g2d.drawLine((int) (point.getX() + width / 2 + 13 * spacing),
(int) (point.getY() - 2 * spacing + offsetY),
(int) (point.getX() + width / 2 + 13 * spacing),
(int) (point.getY() + (29 + (type == ProtoBoard780Type.RS ? 2 : 0)) * spacing + offsetY));
// horizontal long traces
g2d.drawLine((int) (point.getX() + width / 2 - 12 * spacing), (int) (point.getY() + offsetY),
(int) (point.getX() + width / 2 + 12 * spacing), (int) (point.getY() + offsetY));
g2d.drawLine((int) (point.getX() + width / 2 - 12 * spacing),
(int) (point.getY() + spacing * 29 + offsetY),
(int) (point.getX() + width / 2 + 12 * spacing),
(int) (point.getY() + spacing * 29 + offsetY));
for (int i = 0; i < 5; i++) {
int padX = (int) (point.getX() + width / 2 - 12 * spacing + (i * 5 + 1) * spacing);
// vertical traces
g2d.drawLine((int) (padX - spacing), (int) (point.getY() + offsetY), (int) (padX - spacing),
(int) (point.getY() + spacing * 28 + offsetY));
g2d.drawLine((int) (padX + 3 * spacing), (int) (point.getY() + spacing + offsetY),
(int) (padX + 3 * spacing), (int) (point.getY() + spacing * 29 + offsetY));
for (int j = 1; j < 29; j++) {
int padY = (int) (point.getY() + spacing * j + offsetY);
// 3-pad traces
g2d.drawLine(padX, padY, (int) (padX + 2 * spacing), padY);
}
}
drawingObserver.stopTrackingContinuityArea();
// draw main pads
for (int i = 0; i < 25; i++) {
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(padSize - 2f));
g2d.setColor(padColor);
int padX = (int) (point.getX() + width / 2 - 12 * spacing + i * spacing);
// drawingObserver.startTrackingContinuityArea(true);
// g2d.drawLine(padX, (int)(point.getY() + offsetY), padX, (int)(point.getY() + spacing +
// offsetY));
// drawingObserver.stopTrackingContinuityArea();
for (int j = 0; j < 30; j++) {
int padY = (int) (point.getY() + spacing * j + offsetY);
g2d.setColor(padColor);
drawingObserver.startTrackingContinuityArea(true);
g2d.fillOval(padX - padSize / 2, padY - padSize / 2, padSize, padSize);
drawingObserver.stopTrackingContinuityArea();
g2d.setColor(padColor.darker());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
g2d.drawOval(padX - padSize / 2, padY - padSize / 2, padSize, padSize);
g2d.setColor(HOLE_COLOR);
g2d.fillOval(padX - holeSize / 2, padY - holeSize / 2, holeSize, holeSize);
}
}
g2d.setColor(textColor);
// horizontal coordinates
for (int i = 0; i < 6; i++) {
int x = i == 0 ? 1 : i * 5;
int padX = (int) (point.getX() + width / 2 - 13 * spacing + x * spacing);
int padY = (int) (point.getY() - spacing + offsetY);
String label = String.valueOf((char) ('A' + i));
StringUtils.drawCenteredText(g2d, label, padX, padY, HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM);
// StringUtils.drawCenteredText(g2d, label, padX, padY + spacing * 31,
// HorizontalAlignment.CENTER,
// VerticalAlignment.TOP);
}
// vertical coordinates
for (int i = 0; i < 7; i++) {
int y = i == 0 ? 1 : i * 5;
int padX = (int) (point.getX() + width / 2 - 14 * spacing);
int padY = (int) (point.getY() + spacing * (y - 1) + offsetY);
StringUtils.drawCenteredText(g2d, Integer.toString(y), padX, padY, HorizontalAlignment.LEFT,
VerticalAlignment.BOTTOM);
}
// model name
g2d.setFont(LABEL_FONT.deriveFont(COORDINATE_FONT_SIZE * 1.8f));
int x = (int) (point.getX() + width / 2);
int y = (int) (point.getY() + length - spacing * 1.5);
StringUtils.drawCenteredText(g2d,
type == ProtoBoard780Type.RS ? "Radio Shack 276-168B" : "MPJA.COM 33304 PB", x, y,
HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
// mounting holes
int dx = (int) (type == ProtoBoard780Type.RS ? 11 * spacing : 12 * spacing);
int holeY = (int) (point.getY() + spacing * (type == ProtoBoard780Type.RS ? 1 : 1.5));
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.setColor(HOLE_COLOR);
g2d.fillOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
g2d.fillOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
g2d.setColor(finalBorderColor);
g2d.drawOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
g2d.drawOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
holeY = (int) (point.getY() + length - spacing);
g2d.setColor(HOLE_COLOR);
g2d.fillOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
g2d.fillOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
g2d.setColor(finalBorderColor);
g2d.drawOval((int) (point.getX() + width / 2) - dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
g2d.drawOval((int) (point.getX() + width / 2) + dx - mountingHoleSize / 2,
holeY - mountingHoleSize / 2, mountingHoleSize, mountingHoleSize);
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
int factor = 32 / width;
g2d.setColor(FILL_COLOR);
g2d.fillRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
g2d.setColor(FILL_COLOR.darker());
g2d.drawRect(2 / factor, 2 / factor, width - 4 / factor, height - 4 / factor);
g2d.setColor(PAD_COLOR.brighter());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2 / factor));
int size = (int) (8.0 / factor);
g2d.drawLine(width / 3 - 2 / factor + size / 2, 6 / factor + size / 2, width,
6 / factor + size / 2);
g2d.drawLine(width / 3 - 2 / factor + size / 2, 2 * width / 3 - 2 / factor + size / 2, width,
2 * width / 3 - 2 / factor + size / 2);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.setColor(PAD_COLOR);
g2d.fillRect(width / 3 - 2 / factor, 6 / factor, size, size);
g2d.setColor(PAD_COLOR.darker());
g2d.drawRect(width / 3 - 2 / factor, 6 / factor, size, size);
g2d.setColor(PAD_COLOR);
g2d.fillOval(2 * width / 3 - 2 / factor, 6 / factor, size, size);
g2d.setColor(PAD_COLOR.darker());
g2d.drawOval(2 * width / 3 - 2 / factor, 6 / factor, size, size);
g2d.setColor(PAD_COLOR);
g2d.fillRect(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, size, size);
g2d.setColor(PAD_COLOR.darker());
g2d.drawRect(width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, size, size);
g2d.setColor(PAD_COLOR);
g2d.fillOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, size, size);
g2d.setColor(PAD_COLOR.darker());
g2d.drawOval(2 * width / 3 - 2 / factor, 2 * width / 3 - 2 / factor, size, size);
g2d.setColor(HOLE_COLOR);
g2d.fillOval(width / 3 - 2 / factor + size / 2 - 1, 6 / factor + size / 2 - 1, 3, 3);
g2d.fillOval(width / 3 - 2 / factor + size / 2 - 1, 2 * width / 3 - 2 / factor + size / 2 - 1,
3, 3);
g2d.fillOval(2 * width / 3 - 2 / factor + size / 2 - 1, 6 / factor + size / 2 - 1, 3, 3);
g2d.fillOval(2 * width / 3 - 2 / factor + size / 2 - 1,
2 * width / 3 - 2 / factor + size / 2 - 1, 3, 3);
}
@EditableProperty(name = "Board Color")
public Color getBoardColor() {
return boardColor;
}
public void setBoardColor(Color boardColor) {
this.boardColor = boardColor;
}
@EditableProperty(name = "Pad Color")
public Color getPadColor() {
return padColor;
}
public void setPadColor(Color padColor) {
this.padColor = padColor;
}
@EditableProperty(name = "Trace Color")
public Color getTraceColor() {
return traceColor;
}
public void setTraceColor(Color traceColor) {
this.traceColor = traceColor;
}
@EditableProperty(name = "Text Color")
public Color getTextColor() {
return textColor;
}
public void setTextColor(Color textColor) {
this.textColor = textColor;
}
@EditableProperty
public ProtoBoard780Type getType() {
return type;
}
public void setType(ProtoBoard780Type type) {
this.type = type;
}
@Override
public int getControlPointCount() {
return 2;
}
@Override
public boolean canPointMoveFreely(int pointIndex) {
return false;
}
@SuppressWarnings("incomplete-switch")
@Override
public Point2D getControlPoint(int index) {
if (index == 0)
return point;
// create a synthetic second control point for clipping check and to make sure that we cannot
// drag the right side of the board off the screen
// adjust the angle
double theta = 0;
switch (getOrientation()) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
int width = (int) WIDTH_SIZE.convertToPixels();
int length = (int) LENGTH_SIZE.convertToPixels();
Point2D secondPoint = new Point2D.Double(point.getX() + width, point.getY() + length);
if (theta != 0) {
AffineTransform tx = AffineTransform.getRotateInstance(theta, point.getX(), point.getY());
tx.transform(secondPoint, secondPoint);
}
return secondPoint;
}
@Override
public boolean isControlPointSticky(int index) {
return false;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public void setControlPoint(Point2D point, int index) {
if (index == 0)
this.point.setLocation(point);
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {}
@Override
public String getControlPointNodeName(int index) {
return null;
}
@Override
public Rectangle2D getCachingBounds() {
Point2D finalSecondPoint = getControlPoint(1);
return new Rectangle2D.Double(Math.min(point.getX(), finalSecondPoint.getX()),
Math.min(point.getY(), finalSecondPoint.getY()),
Math.abs(finalSecondPoint.getX() - point.getX()) + 2,
Math.abs(finalSecondPoint.getY() - point.getY()) + 2);
}
public static enum ProtoBoard780Type {
RS, MPJA
}
}
@@ -27,7 +27,7 @@ public enum AWG {
@Override
public String toString() {
return "#" + name().replace("_", "") + " (" + String.format("%1$,.2f", diameterIn() * 25.4) + "mm / " + String.format("%1$,.5f", diameterIn()) + "in)";
return "#" + name().replace("_", "") + " / " + String.format("%1$,.2f", diameterIn() * 25.4) + "mm";
}
public double diameterIn() {
@@ -41,7 +41,7 @@ import org.diylc.utils.Constants;
instanceNamePrefix = "W", description = "Flexible wire with two control points", zOrder = IDIYComponent.WIRING,
flexibleZOrder = true, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
transformer = SimpleComponentTransformer.class, enableCache = false)
public class HookupWire extends AbstractCurvedComponent<Void> implements IContinuity {
public class HookupWire extends AbstractCurvedComponent<AWG> implements IContinuity {
private static final long serialVersionUID = 1L;
@@ -117,22 +117,14 @@ public class HookupWire extends AbstractCurvedComponent<Void> implements IContin
}
@EditableProperty(name = "AWG")
public AWG getGauge() {
public AWG getValue() {
return gauge;
}
public void setGauge(AWG gauge) {
public void setValue(AWG gauge) {
this.gauge = gauge;
}
@Override
public Void getValue() {
return null;
}
@Override
public void setValue(Void value) {}
@EditableProperty(name = "Stripe")
public boolean getStriped() {
return striped;
@@ -0,0 +1,325 @@
/*
*
* 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;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.components.connectivity.PCBTerminalBlock.PCBTerminalBlockCount;
import org.diylc.components.transform.PCBTerminalBlockTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "PCB Terminal Block", category = "Connectivity",
author = "Branislav Stojkovic", description = "Horizontal PCB terminal block with 5mm pitch",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "TB", autoEdit = false,
enableCache = true, transformer = PCBTerminalBlockTransformer.class)
public class PCBTerminalBlock extends AbstractTransparentComponent<PCBTerminalBlockCount> {
private static final long serialVersionUID = 1L;
private static Size SPACING = new Size(5d, SizeUnit.mm);
private static Size WIDTH = new Size(7.7d, SizeUnit.mm);
private static Size CIRCLE_SIZE = new Size(3d, SizeUnit.mm);
private static Size OFFSET = new Size(4.5d, SizeUnit.mm);
private static Color BODY_COLOR = Color.decode("#90AB66");
private static Color BORDER_COLOR = BODY_COLOR.darker();
private static Color CIRCLE_COLOR = LIGHT_METAL_COLOR;
protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
transient protected Shape[] body;
protected PCBTerminalBlockCount count = PCBTerminalBlockCount._3;
private Orientation orientation = Orientation.DEFAULT;
private Color bodyColor = BODY_COLOR;
private Color borderColor = BORDER_COLOR;
public PCBTerminalBlock() {
super();
updateControlPoints();
}
private void updateControlPoints() {
Point2D firstPoint = controlPoints[0];
int spacing = (int) SPACING.convertToPixels();
controlPoints = new Point2D[count.getCount()];
controlPoints[0] = firstPoint;
for (int i = 1; i < controlPoints.length; i++) {
controlPoints[i] = new Point2D.Double(firstPoint.getX(), firstPoint.getY() + spacing * i);
}
if (orientation != Orientation.DEFAULT) {
AffineTransform xform = AffineTransform.getRotateInstance(orientation.toRadians(),
firstPoint.getX(), firstPoint.getY());
for (int i = 1; i < controlPoints.length; i++) {
xform.transform(controlPoints[i], controlPoints[i]);
}
}
}
@Override
public Point2D getControlPoint(int index) {
return controlPoints[index];
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public void setControlPoint(Point2D point, int index) {
controlPoints[index].setLocation(point);
// Reset body shape.
body = null;
}
@EditableProperty(name = "Pins")
@Override
public PCBTerminalBlockCount getValue() {
return count;
}
@Override
public void setValue(PCBTerminalBlockCount value) {
this.count = value;
updateControlPoints();
// Reset body shape.
body = null;
}
@EditableProperty
public Orientation getOrientation() {
if (orientation == null) {
orientation = Orientation.DEFAULT;
}
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Reset body shape.
body = null;
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
if (checkPointsClipped(g2d.getClip())) {
return;
}
Shape[] body = getBody();
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
// Draw body if available.
if (body != null) {
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(
AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
g2d.fill(body[0]);
g2d.setComposite(oldComposite);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
Color finalBorderColor;
if (outlineMode) {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: theme.getOutlineColor();
} else {
g2d.setColor(getBorderColor());
g2d.draw(body[1]);
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: getBorderColor();
}
g2d.setColor(finalBorderColor);
g2d.draw(body[0]);
}
// Do not track these changes because the whole switch has been tracked
// so far.
drawingObserver.stopTracking();
// Draw lugs.
int circleDiameter = getClosestOdd((int) CIRCLE_SIZE.convertToPixels());
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(2f));
for (Point2D p : controlPoints) {
if (outlineMode) {
// g2d.setColor(Constants.TRANSPARENT_COLOR);
// drawingObserver.startTrackingContinuityArea(true);
// g2d.fillRect((int)(p.getX() - lugWidth / 2), (int)(p.getY() - lugHeight / 2), lugWidth,
// lugHeight);
// drawingObserver.stopTrackingContinuityArea();
g2d.setColor(theme.getOutlineColor());
} else {
g2d.setColor(CIRCLE_COLOR);
g2d.fillOval((int) (p.getX() - circleDiameter / 2), (int) (p.getY() - circleDiameter / 2),
circleDiameter, circleDiameter);
g2d.setColor(CIRCLE_COLOR.darker());
g2d.drawLine((int) (p.getX() + Math.cos(Math.PI / 4) * circleDiameter / 2),
(int) (p.getY() + Math.sin(Math.PI / 4) * circleDiameter / 2),
(int) (p.getX() + Math.cos(5 * Math.PI / 4) * circleDiameter / 2),
(int) (p.getY() + Math.sin(5 * Math.PI / 4) * circleDiameter / 2));
}
}
}
public Shape[] getBody() {
if (body == null) {
body = new Shape[2];
Point2D firstPoint = controlPoints[0];
int spacing = (int) SPACING.convertToPixels();
int pointCount = count.getCount();
int width = (int) WIDTH.convertToPixels();
int offset = (int) OFFSET.convertToPixels();
body[0] = new Rectangle2D.Double(firstPoint.getX() - offset, firstPoint.getY() - spacing / 2,
width, pointCount * spacing);
body[1] = new Rectangle2D.Double(firstPoint.getX() - spacing / 2, firstPoint.getY() - spacing / 2,
spacing, pointCount * spacing);
if (orientation != Orientation.DEFAULT) {
AffineTransform xform = AffineTransform.getRotateInstance(orientation.toRadians(),
firstPoint.getX(), firstPoint.getY());
Area b = new Area(body[0]);
b.transform(xform);
body[0] = b;
b = new Area(body[1]);
b.transform(xform);
body[1] = b;
}
}
return body;
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
int circleSize = 6 * width / 32;
g2d.setColor(BODY_COLOR);
g2d.fillRect((int) (width / 4d - 2), 1, width / 2, height - 2);
g2d.setColor(BORDER_COLOR);
g2d.drawRect((int) (width / 4d - 2), 1, width / 2, height - 2);
g2d.drawRect((int) (width / 3d), 1, (int) (width / 3d), height - 2);
for (int i = 1; i <= 3; i++) {
g2d.setColor(CIRCLE_COLOR);
g2d.fillOval(width / 2 - circleSize / 2, (int) (i * height / 4d - circleSize / 2), circleSize, circleSize);
}
}
@EditableProperty(name = "Body")
public Color getBodyColor() {
if (bodyColor == null)
bodyColor = BODY_COLOR;
return bodyColor;
}
public void setBodyColor(Color bodyColor) {
this.bodyColor = bodyColor;
}
@EditableProperty(name = "Border")
public Color getBorderColor() {
if (borderColor == null)
borderColor = BORDER_COLOR;
return borderColor;
}
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
@Override
public String getControlPointNodeName(int index) {
// we don't want the block to produce any nodes, it just makes connections
return null;
}
@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);
}
static enum PCBTerminalBlockCount {
_2("Two"), _3("Three"), _4("Four"), _5("Five"), _6("Six"), _7("Seven"), _8("Eight"), _9(
"Nine"), _10("Ten");
private String label;
PCBTerminalBlockCount(String label) {
this.label = label;
}
public int getCount() {
return Integer.parseInt(name().substring(1));
}
@Override
public String toString() {
return label;
}
}
}
@@ -0,0 +1,270 @@
/*
*
* 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;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.awt.TwoCircleTangent;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.components.AbstractMultiPartComponent;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Solder Lug", category = "Connectivity", author = "Branislav Stojkovic",
description = "Locking terminal lug commonly used for chassis ground connections",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "SL", enableCache = true)
public class SolderLug extends AbstractMultiPartComponent<String> {
private static final long serialVersionUID = 1L;
private static Color BASE_COLOR = Color.lightGray;
private static Size BODY_LARGE_DIAMETER = new Size(7.92d, SizeUnit.mm);
private static Size BODY_SMALL_DIAMETER = new Size(3.66d, SizeUnit.mm);
private static Size LARGE_HOLE_DIAMETER = new Size(3.66d, SizeUnit.mm);
private static Size CENTER_TO_HOLE1 = new Size(8.4d, SizeUnit.mm);
private static Size CENTER_TO_HOLE2 = new Size(10.4d, SizeUnit.mm);
private static Size HOLE_DIAMETER = new Size(1.5d, SizeUnit.mm);
private String value = "";
private Point2D[] controlPoints =
new Point2D[] {new Point2D.Double(0, 0), new Point2D.Double(0, 0), new Point2D.Double(0, 0)};
transient Area[] body;
private Orientation orientation = Orientation.DEFAULT;
public SolderLug() {
super();
updateControlPoints();
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
Shape[] body = getBody();
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BASE_COLOR);
g2d.fill(body[0]);
g2d.setComposite(oldComposite);
Color finalBorderColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
finalBorderColor = theme.getOutlineColor();
} else {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: BASE_COLOR.darker();
}
g2d.setColor(finalBorderColor);
g2d.draw(body[0]);
g2d.setColor(Constants.TRANSPARENT_COLOR);
drawingObserver.startTrackingContinuityArea(true);
g2d.fill(body[1]);
drawingObserver.stopTrackingContinuityArea();
}
public Area[] getBody() {
if (body == null) {
body = new Area[2];
int bodyLargeDiameter = getClosestOdd(BODY_LARGE_DIAMETER.convertToPixels());
int bodySmallDiameter = getClosestOdd(BODY_SMALL_DIAMETER.convertToPixels());
int largeHoleDiameter = getClosestOdd(LARGE_HOLE_DIAMETER.convertToPixels());
int holeDiameter = getClosestOdd(HOLE_DIAMETER.convertToPixels());
Area area = new TwoCircleTangent(controlPoints[0], controlPoints[2], bodyLargeDiameter / 2,
bodySmallDiameter / 2);
Area conductivityMask = new Area(area);
area.subtract(new Area(new Ellipse2D.Double(controlPoints[1].getX() - holeDiameter / 2, controlPoints[1].getY() - holeDiameter / 2,
holeDiameter, holeDiameter)));
area.subtract(new Area(new Ellipse2D.Double(controlPoints[2].getX() - holeDiameter / 2, controlPoints[2].getY() - holeDiameter / 2,
holeDiameter, holeDiameter)));
area.subtract(new Area(new Ellipse2D.Double(controlPoints[0].getX() - largeHoleDiameter / 2,
controlPoints[0].getY() - largeHoleDiameter / 2, largeHoleDiameter, largeHoleDiameter)));
body[0] = area;
body[1] = conductivityMask;
}
return body;
}
@SuppressWarnings("incomplete-switch")
private void updateControlPoints() {
double x = controlPoints[0].getX();
double y = controlPoints[0].getY();
int centerToHole1 = (int) CENTER_TO_HOLE1.convertToPixels();
int centerToHole2 = (int) CENTER_TO_HOLE2.convertToPixels();
double centerY1 = y + centerToHole1;
double centerY2 = y + centerToHole2;
controlPoints[1].setLocation(x, centerY1);
controlPoints[2].setLocation(x, centerY2);
// Rotate if needed
if (orientation != Orientation.DEFAULT) {
double theta = 0;
switch (orientation) {
case _90:
theta = Math.PI / 2;
break;
case _180:
theta = Math.PI;
break;
case _270:
theta = Math.PI * 3 / 2;
break;
}
AffineTransform rotation = AffineTransform.getRotateInstance(theta, x, y);
rotation.transform(controlPoints[1], controlPoints[1]);
rotation.transform(controlPoints[2], controlPoints[2]);
}
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
double x0 = width * 0.35;
double y0 = height * 0.65;
double x1 = width * 0.75;
double y1 = height * 0.25;
TwoCircleTangent main = new TwoCircleTangent(new Point2D.Double(x0, y0),
new Point2D.Double(x1, y1), width * 0.28, width * 0.12);
main.subtract(new Area(new Ellipse2D.Double(x0 - 3, y0 - 3, 7, 7)));
main.subtract(new Area(new Ellipse2D.Double(x1 - 2, y1 - 1, 3, 3)));
main.subtract(new Area(new Ellipse2D.Double(x1 - 6, y1 + 3, 3, 3)));
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
g2d.setColor(BASE_COLOR);
g2d.fill(main);
g2d.setColor(BASE_COLOR.darker());
g2d.draw(main);
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public Point2D getControlPoint(int index) {
return controlPoints[index];
}
@Override
public void setControlPoint(Point2D point, int index) {
this.controlPoints[index].setLocation(point);
// Invalidate the body
body = null;
}
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Invalidate the body
body = null;
}
@Override
public String getControlPointNodeName(int index) {
return getName() + (index == 0 ? "Tip" : "Sleeve");
}
@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);
}
@Deprecated
@Override
public Integer getFontSizeOverride() {
return super.getFontSizeOverride();
}
}
@@ -34,6 +34,7 @@ import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.ILayer;
import org.diylc.core.Project;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.BomPolicy;
@@ -47,7 +48,7 @@ import org.diylc.utils.Constants;
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, enableCache = true)
public class TraceCut extends AbstractComponent<Void> {
public class TraceCut extends AbstractComponent<Void> implements ILayer {
private static final long serialVersionUID = 1L;
@@ -252,5 +253,10 @@ public class TraceCut extends AbstractComponent<Void> {
public Rectangle2D getCachingBounds() {
double size = getSize().convertToPixels();
return new Rectangle2D.Double(point.getX() - size, point.getY() - size, size * 2, size * 2);
}
@Override
public int getLayerId() {
return 1;
}
}
@@ -25,6 +25,7 @@ import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
@@ -57,7 +58,7 @@ import org.diylc.utils.Constants;
description = "Cliff-style closed panel mount 1/4\" phono jack",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = CliffJackTransformer.class,
enableCache = true)
public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
public class CliffJack1_4 extends AbstractMultiPartComponent<JackType> {
private static final long serialVersionUID = 1L;
@@ -76,7 +77,9 @@ public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
private JackType type = JackType.MONO;
private Orientation orientation = Orientation.DEFAULT;
transient private Area[] body;
private String value = "";
@SuppressWarnings("unused")
@Deprecated
private transient String value = "";
public CliffJack1_4() {
super();
@@ -287,7 +290,17 @@ public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
g2d.drawLine(pinX1, width * 2 / 8, pinX1, width * 3 / 8);
g2d.drawLine(pinX1, width * 5 / 8, pinX1, width * 6 / 8);
g2d.drawLine(pinX2, width * 2 / 8, pinX2, width * 3 / 8);
g2d.drawLine(pinX2, width * 5 / 8, pinX2, width * 6 / 8);
g2d.drawLine(pinX2, width * 5 / 8, pinX2, width * 6 / 8);
g2d.setColor(LABEL_COLOR);
g2d.setFont(LABEL_FONT.deriveFont(width / 3.5f));
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
g2d.setRenderingHints(rh);
StringUtils.drawCenteredText(g2d, "6.3", width / 2 - 1, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@Override
@@ -316,23 +329,12 @@ public class CliffJack1_4 extends AbstractMultiPartComponent<String> {
return VisibilityPolicy.NEVER;
}
@EditableProperty
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public JackType getType() {
@EditableProperty(name = "Type")
public JackType getValue() {
return type;
}
public void setType(JackType type) {
public void setValue(JackType type) {
this.type = type;
updateControlPoints();
}
@@ -0,0 +1,379 @@
/*
*
* 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.electromechanical;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.awt.StringUtils;
import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation;
import org.diylc.common.VerticalAlignment;
import org.diylc.components.AbstractMultiPartComponent;
import org.diylc.components.transform.CliffJackTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Cliff 1/8\" Jack", category = "Electro-Mechanical",
author = "Branislav Stojkovic", description = "Cliff-style closed 1/8\" phono jack",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false,
transformer = CliffJackTransformer.class, enableCache = true)
public class CliffJack1_8 extends AbstractMultiPartComponent<JackType> {
private static final long serialVersionUID = 1L;
private static Size ROW_SPACING = new Size(9.4d, SizeUnit.mm);
private static Size PIN_SPACING = new Size(3.8d, SizeUnit.mm);
private static Size PIN_WIDTH = new Size(1d, SizeUnit.mm);
private static Size PIN_THICKNESS = new Size(0.02d, SizeUnit.in);
private static Color BODY_COLOR = Color.decode("#666666");
private static Color BORDER_COLOR = Color.black;
private static Color LABEL_COLOR = Color.white;
private static Size BODY_WIDTH = new Size(10.8d, SizeUnit.mm);
private static Size BODY_LENGTH_MONO = new Size(8.6d, SizeUnit.mm);
private static Size BODY_LENGTH_STEREO = new Size(12.4d, SizeUnit.mm);
private static Size SHAFT_LENGTH_W_NUT = new Size(5d, SizeUnit.mm);
private static Size SHAFT_LENGTH_NO_NUT = new Size(2d, SizeUnit.mm);
private static Size SHAFT_DIA_W_NUT = new Size(8d, SizeUnit.mm);
private static Size SHAFT_DIA_NO_NUT = new Size(7d, SizeUnit.mm);
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
private JackType type = JackType.MONO;
private Orientation orientation = Orientation.DEFAULT;
transient private Shape[] body;
private boolean nut = false;
public CliffJack1_8() {
super();
updateControlPoints();
}
private void updateControlPoints() {
// invalidate body shape
body = null;
double x = controlPoints[0].getX();
double y = controlPoints[0].getY();
int rowSpacing = (int) ROW_SPACING.convertToPixels();
int pinSpacing = (int) PIN_SPACING.convertToPixels();
controlPoints = new Point2D[type == JackType.STEREO ? 6 : 4];
controlPoints[0] = new Point2D.Double(x, y);
controlPoints[1] = new Point2D.Double(x, y + rowSpacing);
controlPoints[2] = new Point2D.Double(x + pinSpacing, y);
controlPoints[3] = new Point2D.Double(x + pinSpacing, y + rowSpacing);
if (type == JackType.STEREO) {
controlPoints[4] = new Point2D.Double(x + 2 * pinSpacing, y);
controlPoints[5] = new Point2D.Double(x + 2 * pinSpacing, y + rowSpacing);
}
// Apply rotation if necessary
double angle = getAngle();
if (angle != 0) {
AffineTransform rotation = AffineTransform.getRotateInstance(angle, x, y);
for (int i = 1; i < controlPoints.length; i++) {
rotation.transform(controlPoints[i], controlPoints[i]);
}
}
}
private double getAngle() {
// Apply rotation if necessary
double angle;
switch (orientation) {
case _90:
angle = Math.PI / 2;
break;
case _180:
angle = Math.PI;
break;
case _270:
angle = Math.PI * 3 / 2;
break;
default:
angle = 0;
}
return angle;
}
public Shape[] getBody() {
if (body == null) {
body = new Shape[4];
// Create body.
double bodyLength =
(type == JackType.MONO ? BODY_LENGTH_MONO : BODY_LENGTH_STEREO).convertToPixels();
double bodyWidth = BODY_WIDTH.convertToPixels();
int shaftLength = (int) (nut ? SHAFT_LENGTH_W_NUT : SHAFT_LENGTH_NO_NUT).convertToPixels();
int shaftWidth = (int) (nut ? SHAFT_DIA_W_NUT : SHAFT_DIA_NO_NUT).convertToPixels();
double centerX =
(controlPoints[0].getX() + controlPoints[controlPoints.length - 1].getX()) / 2;
double centerY =
(controlPoints[0].getY() + controlPoints[controlPoints.length - 1].getY()) / 2;
body[0] = new Area(new Rectangle2D.Double(centerX - bodyLength / 2, centerY - bodyWidth / 2,
bodyLength, bodyWidth));
body[1] = new Area(new Rectangle2D.Double(centerX + bodyLength / 2, centerY - shaftWidth / 2,
shaftLength, shaftWidth));
// Apply rotation if necessary
AffineTransform rotation = null;
double angle = getAngle();
if (angle != 0) {
rotation = AffineTransform.getRotateInstance(angle, centerX, centerY);
for (int i = 0; i < body.length; i++) {
if (body[i] != null) {
Area area = new Area(body[i]);
area.transform(rotation);
body[i] = area;
}
}
}
GeneralPath path = new GeneralPath();
int step = 4;
for (double i = centerX + bodyLength / 2 + step; i <= centerX + bodyLength / 2
+ shaftLength; i += step) {
Point2D p = new Point2D.Double(i, centerY - shaftWidth / 2 + 1);
if (rotation != null) {
rotation.transform(p, p);
}
path.moveTo(p.getX(), p.getY());
p = new Point2D.Double(i - step, centerY + shaftWidth / 2 - 1);
if (rotation != null) {
rotation.transform(p, p);
}
path.lineTo(p.getX(), p.getY());
}
body[2] = path;
// Create pins.
Area pins = new Area();
int pinWidth = (int) PIN_WIDTH.convertToPixels();
int pinThickness = (int) PIN_THICKNESS.convertToPixels();
for (int i = 0; i < getControlPointCount(); i++) {
Point2D point = getControlPoint(i);
Rectangle2D pin;
if (orientation == Orientation.DEFAULT || orientation == Orientation._180) {
pin = new Rectangle2D.Double(point.getX() - pinWidth / 2, point.getY() - pinThickness / 2,
pinWidth, pinThickness);
} else {
pin = new Rectangle2D.Double(point.getX() - pinThickness / 2, point.getY() - pinWidth / 2,
pinThickness, pinWidth);
}
pins.add(new Area(pin));
}
body[3] = pins;
}
return body;
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
Shape[] body = getBody();
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
// if (componentState != ComponentState.DRAGGING) {
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : BODY_COLOR);
for (int i = 0; i < 2; i++) {
g2d.fill(body[i]);
}
g2d.setComposite(oldComposite);
// }
if (nut) {
g2d.setColor(BORDER_COLOR);
g2d.draw(body[2]);
}
Color finalBorderColor;
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
if (outlineMode) {
finalBorderColor = theme.getOutlineColor();
} else {
finalBorderColor = BORDER_COLOR;
}
drawingObserver.stopTracking();
g2d.setColor(finalBorderColor);
for (int i = 0; i < 2; i++) {
g2d.draw(body[i]);
}
// Pins are the last piece.
Shape pins = body[body.length - 1];
if (!outlineMode) {
g2d.setColor(METAL_COLOR);
g2d.fill(pins);
}
g2d.setColor(outlineMode ? theme.getOutlineColor() : METAL_COLOR.darker());
g2d.draw(pins);
Color finalLabelColor;
if (outlineMode) {
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED
: theme.getOutlineColor();
} else {
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED
: LABEL_COLOR;
}
g2d.setColor(finalLabelColor);
g2d.setFont(project.getFont());
// Override font size
if (getFontSizeOverride() != null)
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
double centerX = (controlPoints[0].getX() + controlPoints[controlPoints.length - 1].getX()) / 2;
double centerY = (controlPoints[0].getY() + controlPoints[controlPoints.length - 1].getY()) / 2;
StringUtils.drawCenteredText(g2d, name, centerX, centerY, HorizontalAlignment.CENTER,
VerticalAlignment.CENTER);
drawSelectionOutline(g2d, componentState, outlineMode, project, drawingObserver);
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
int bodyWidth = getClosestOdd(width * 3 / 5);
int tailWidth = getClosestOdd(width * 3 / 9);
g2d.setColor(BODY_COLOR);
g2d.fillRect((width - tailWidth) / 2, 2 * 32 / height, tailWidth, height / 2);
g2d.setColor(BORDER_COLOR);
g2d.drawRect((width - tailWidth) / 2, 2 * 32 / height, tailWidth, height / 2);
g2d.setColor(BODY_COLOR);
g2d.fillRect((width - bodyWidth) / 2, height / 7 + 1, bodyWidth, height * 5 / 7);
g2d.setColor(BORDER_COLOR);
g2d.drawRect((width - bodyWidth) / 2, height / 7 + 1, bodyWidth, height * 5 / 7);
g2d.setColor(METAL_COLOR);
int pinX1 = getClosestOdd((width - bodyWidth * 3 / 4) / 2);
int pinX2 = getClosestOdd((width + bodyWidth * 3 / 4) / 2) - 1;
g2d.drawLine(pinX1, width * 4 / 16, pinX1, width * 5 / 16);
g2d.drawLine(pinX1, width * 11 / 16, pinX1, width * 12 / 16);
g2d.drawLine(pinX2, width * 4 / 16, pinX2, width * 5 / 16);
g2d.drawLine(pinX2, width * 11 / 16, pinX2, width * 12 / 16);
g2d.setColor(LABEL_COLOR);
g2d.setFont(LABEL_FONT.deriveFont(width / 3.5f));
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
g2d.setRenderingHints(rh);
StringUtils.drawCenteredText(g2d, "3.5", width / 2 - 1, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public Point2D getControlPoint(int index) {
return controlPoints[index];
}
@Override
public void setControlPoint(Point2D point, int index) {
controlPoints[index].setLocation(point);
body = null;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@EditableProperty(name = "Type")
public JackType getValue() {
return type;
}
public void setValue(JackType type) {
this.type = type;
updateControlPoints();
}
@EditableProperty
public boolean getNut() {
return nut;
}
public void setNut(boolean nut) {
this.nut = nut;
this.body = null;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
}
@Override
public boolean canPointMoveFreely(int pointIndex) {
return false;
}
}
@@ -26,6 +26,7 @@ import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
@@ -57,7 +58,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, enableCache = true)
public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
public class ClosedJack1_4 extends AbstractMultiPartComponent<JackType> {
private static final long serialVersionUID = 1L;
@@ -78,7 +79,9 @@ public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
private JackType type = JackType.MONO;
private Orientation orientation = Orientation.DEFAULT;
transient private Shape[] body;
private String value = "";
@SuppressWarnings("unused")
@Deprecated
private transient String value = "";
public ClosedJack1_4() {
super();
@@ -298,7 +301,17 @@ public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
g2d.setColor(METAL_COLOR);
g2d.fillRect(width * 7 / 16, height * 6 / 7 + 1, width / 8, height / 7 - 1);
g2d.fillRect(width * 7 / 16, height / 7 + 2, width / 8, height / 7 - 1);
g2d.fillRect(width * 7 / 16, height / 7 + 2, width / 8, height / 7 - 1);
g2d.setColor(LABEL_COLOR);
g2d.setFont(LABEL_FONT.deriveFont(width / 3.5f));
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
g2d.setRenderingHints(rh);
StringUtils.drawCenteredText(g2d, "6.3", width / 2 - 1, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@Override
@@ -327,23 +340,12 @@ public class ClosedJack1_4 extends AbstractMultiPartComponent<String> {
return VisibilityPolicy.NEVER;
}
@EditableProperty
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public JackType getType() {
@EditableProperty(name = "Type")
public JackType getValue() {
return type;
}
public void setType(JackType type) {
public void setValue(JackType type) {
this.type = type;
updateControlPoints();
}
File diff suppressed because it is too large Load Diff
@@ -57,7 +57,7 @@ import org.diylc.utils.Constants;
description = "1/4\" mono/stereo phono jack based on Neutrik NMJx series, PCB or Panel-mount",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", autoEdit = false, transformer = NeutrikJack1_4Transformer.class,
enableCache = true)
public class NeutrikJack1_4 extends AbstractMultiPartComponent<String> {
public class NeutrikJack1_4 extends AbstractMultiPartComponent<JackType> {
private static final long serialVersionUID = 1L;
@@ -81,7 +81,10 @@ public class NeutrikJack1_4 extends AbstractMultiPartComponent<String> {
private Mount mount = Mount.Panel;
private Orientation orientation = Orientation.DEFAULT;
transient private Area[] body;
private String value = "";
@SuppressWarnings("unused")
@Deprecated
private transient String value = "";
public NeutrikJack1_4() {
super();
@@ -330,23 +333,12 @@ public class NeutrikJack1_4 extends AbstractMultiPartComponent<String> {
return VisibilityPolicy.NEVER;
}
@EditableProperty
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public JackType getType() {
@EditableProperty(name = "Type")
public JackType getValue() {
return type;
}
public void setType(JackType type) {
public void setValue(JackType type) {
this.type = type;
updateControlPoints();
}
@@ -51,11 +51,12 @@ import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
import org.diylc.components.electromechanical.OpenJack1_4.OpenJackType;
@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", enableCache = true)
public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
public class OpenJack1_4 extends AbstractMultiPartComponent<OpenJackType> {
private static final float FONT_SCALE = 0.8f;
private static final double RING_THETA = Math.PI * 0.795;
@@ -76,7 +77,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
private static Size HOLE_DIAMETER = new Size(0.05d, SizeUnit.in);
private static Size HOLE_TO_EDGE = new Size(0.063d, SizeUnit.in);
private String value = "";
@SuppressWarnings("unused")
@Deprecated
private transient String value = "";
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0), new Point2D.Double(0, 0), new Point2D.Double(0, 0)};
transient Area[] body;
@Deprecated
@@ -163,8 +166,8 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
int holeToEdge = (int) HOLE_TO_EDGE.convertToPixels();
double centerY = controlPoints[0].getY() + springLength - holeToEdge;
Point2D tipLabel = new Point2D.Double(controlPoints[0].getX(), (int) (controlPoints[0].getY() + holeToEdge * 1.25));
AffineTransform ringTransform = AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, controlPoints[0].getX(), centerY);
AffineTransform sleeveTransform = AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, controlPoints[0].getX(), centerY);
AffineTransform ringTransform = AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, controlPoints[0].getX(), centerY);
AffineTransform sleeveTransform = AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, controlPoints[0].getX(), centerY);
Point2D ringOrSwitchLabel = new Point2D.Double(0, 0);
Point2D sleeveLabel = new Point2D.Double(0, 0);
ringTransform.transform(tipLabel, ringOrSwitchLabel);
@@ -178,9 +181,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
}
StringUtils.drawCenteredText(g2d, "T", tipLabel.getX(), tipLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
StringUtils.drawCenteredText(g2d, "S", sleeveLabel.getX(), sleeveLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
if (getType() == OpenJackType.STEREO)
if (getValue() == OpenJackType.STEREO)
StringUtils.drawCenteredText(g2d, "R", ringOrSwitchLabel.getX(), ringOrSwitchLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
if (getType() == OpenJackType.SWITCHED)
if (getValue() == OpenJackType.SWITCHED)
StringUtils.drawCenteredText(g2d, "Sw", ringOrSwitchLabel.getX(), ringOrSwitchLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@@ -225,7 +228,7 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
springWidth, springWidth));
sleeve.subtract(new Area(new Ellipse2D.Double(x - holeDiameter / 2, y - holeDiameter / 2, holeDiameter,
holeDiameter)));
sleeve.transform(AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY));
sleeve.transform(AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY));
sleeve.add(new Area(new Ellipse2D.Double(x - ringDiameter / 2, centerY - ringDiameter / 2, ringDiameter,
ringDiameter)));
sleeve.subtract(new Area(new Ellipse2D.Double(x - innerDiameter / 2, centerY - innerDiameter / 2, innerDiameter,
@@ -233,13 +236,13 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
body[2] = sleeve;
if (getType() != OpenJackType.MONO) {
if (getValue() != OpenJackType.MONO) {
Area ringOrSwitch =
new Area(new RoundRectangle2D.Double(x - springWidth / 2, y - holeToEdge, springWidth, springLength,
springWidth, springWidth));
ringOrSwitch.subtract(new Area(new Ellipse2D.Double(x - holeDiameter / 2, y - holeDiameter / 2, holeDiameter,
holeDiameter)));
ringOrSwitch.transform(AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY));
ringOrSwitch.transform(AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY));
ringOrSwitch.subtract(new Area(new Ellipse2D.Double(x - outerDiameter / 2, centerY - outerDiameter / 2, outerDiameter,
outerDiameter)));
@@ -272,8 +275,8 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
double centerY = y + springLength - holeToEdge;
AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY).transform(controlPoints[0], controlPoints[1]);
AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY).transform(controlPoints[0], controlPoints[2]);
AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY).transform(controlPoints[0], controlPoints[1]);
AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY).transform(controlPoints[0], controlPoints[2]);
// Rotate if needed
if (getTheta() != 0) {
@@ -322,7 +325,7 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
g2d.setRenderingHints(rh);
StringUtils.drawCenteredText(g2d, "1/4\"", width / 2, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
StringUtils.drawCenteredText(g2d, "6.3", width / 2 - 1, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@Override
@@ -337,7 +340,7 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
@Override
public boolean isControlPointSticky(int index) {
return index < 2 || (getType() == OpenJackType.STEREO || getType() == OpenJackType.SWITCHED);
return index < 2 || (getValue() == OpenJackType.STEREO || getValue() == OpenJackType.SWITCHED);
}
@Override
@@ -351,16 +354,6 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
// Invalidate the body
body = null;
}
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Integer getAngle() {
@@ -384,12 +377,12 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
return Math.toRadians(getAngle());
}
@EditableProperty
public OpenJackType getType() {
@EditableProperty(name = "Type")
public OpenJackType getValue() {
return type;
}
public void setType(OpenJackType type) {
public void setValue(OpenJackType type) {
this.type = type;
updateControlPoints();
// Invalidate the body
@@ -411,9 +404,9 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
return "Tip";
if (index == 1)
return "Sleeve";
if (index == 2 && getType() == OpenJackType.STEREO)
if (index == 2 && getValue() == OpenJackType.STEREO)
return "Ring";
if (index == 2 && getType() == OpenJackType.SWITCHED)
if (index == 2 && getValue() == OpenJackType.SWITCHED)
return "Shunt";
return null;
}
@@ -423,7 +416,7 @@ public class OpenJack1_4 extends AbstractMultiPartComponent<String> {
return false;
}
public enum OpenJackType {
public static enum OpenJackType {
MONO, STEREO, SWITCHED;
@@ -51,11 +51,12 @@ import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
import org.diylc.components.electromechanical.OpenJack1_8.OpenJackType;
@ComponentDescriptor(name = "Open 1/8\" Jack", category = "Electro-Mechanical", author = "Branislav Stojkovic",
description = "Switchcraft-style open panel mount 1/8\" phono jack, stereo and mono",
zOrder = IDIYComponent.COMPONENT, instanceNamePrefix = "J", enableCache = true)
public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
public class OpenJack1_8 extends AbstractMultiPartComponent<OpenJackType> {
private static final float FONT_SCALE = 0.6f;
private static final double RING_THETA = Math.PI * 0.795;
@@ -76,7 +77,9 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
private static Size HOLE_DIAMETER = new Size(0.025d, SizeUnit.in);
private static Size HOLE_TO_EDGE = new Size(0.0315d, SizeUnit.in);
private String value = "";
@SuppressWarnings("unused")
@Deprecated
private transient String value = "";
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0), new Point2D.Double(0, 0), new Point2D.Double(0, 0)};
transient Area[] body;
@Deprecated
@@ -163,8 +166,8 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
int holeToEdge = (int) HOLE_TO_EDGE.convertToPixels();
double centerY = controlPoints[0].getY() + springLength - holeToEdge;
Point2D tipLabel = new Point2D.Double(controlPoints[0].getX(), (int) (controlPoints[0].getY() + holeToEdge * 1.25));
AffineTransform ringTransform = AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, controlPoints[0].getX(), centerY);
AffineTransform sleeveTransform = AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, controlPoints[0].getX(), centerY);
AffineTransform ringTransform = AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, controlPoints[0].getX(), centerY);
AffineTransform sleeveTransform = AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, controlPoints[0].getX(), centerY);
Point2D ringOrSwitchLabel = new Point2D.Double(0, 0);
Point2D sleeveLabel = new Point2D.Double(0, 0);
ringTransform.transform(tipLabel, ringOrSwitchLabel);
@@ -178,9 +181,9 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
}
StringUtils.drawCenteredText(g2d, "T", tipLabel.getX(), tipLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
StringUtils.drawCenteredText(g2d, "S", sleeveLabel.getX(), sleeveLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
if (getType() == OpenJackType.STEREO)
if (getValue() == OpenJackType.STEREO)
StringUtils.drawCenteredText(g2d, "R", ringOrSwitchLabel.getX(), ringOrSwitchLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
if (getType() == OpenJackType.SWITCHED)
if (getValue() == OpenJackType.SWITCHED)
StringUtils.drawCenteredText(g2d, "Sw", ringOrSwitchLabel.getX(), ringOrSwitchLabel.getY(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@@ -225,7 +228,7 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
springWidth, springWidth));
sleeve.subtract(new Area(new Ellipse2D.Double(x - holeDiameter / 2, y - holeDiameter / 2, holeDiameter,
holeDiameter)));
sleeve.transform(AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY));
sleeve.transform(AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY));
sleeve.add(new Area(new Ellipse2D.Double(x - ringDiameter / 2, centerY - ringDiameter / 2, ringDiameter,
ringDiameter)));
sleeve.subtract(new Area(new Ellipse2D.Double(x - innerDiameter / 2, centerY - innerDiameter / 2, innerDiameter,
@@ -233,13 +236,13 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
body[2] = sleeve;
if (getType() != OpenJackType.MONO) {
if (getValue() != OpenJackType.MONO) {
Area ringOrSwitch =
new Area(new RoundRectangle2D.Double(x - springWidth / 2, y - holeToEdge, springWidth, springLength,
springWidth, springWidth));
ringOrSwitch.subtract(new Area(new Ellipse2D.Double(x - holeDiameter / 2, y - holeDiameter / 2, holeDiameter,
holeDiameter)));
ringOrSwitch.transform(AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY));
ringOrSwitch.transform(AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY));
ringOrSwitch.subtract(new Area(new Ellipse2D.Double(x - outerDiameter / 2, centerY - outerDiameter / 2, outerDiameter,
outerDiameter)));
@@ -272,8 +275,8 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
double centerY = y + springLength - holeToEdge;
AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY).transform(controlPoints[0], controlPoints[1]);
AffineTransform.getRotateInstance(getType() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY).transform(controlPoints[0], controlPoints[2]);
AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SLEEVE_SWITCHED_THETA : SLEEVE_THETA, x, centerY).transform(controlPoints[0], controlPoints[1]);
AffineTransform.getRotateInstance(getValue() == OpenJackType.SWITCHED ? SWITCH_THETA : RING_THETA, x, centerY).transform(controlPoints[0], controlPoints[2]);
// Rotate if needed
if (getTheta() != 0) {
@@ -322,7 +325,7 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
g2d.setRenderingHints(rh);
StringUtils.drawCenteredText(g2d, "1/8\"", width / 2 - 1, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
StringUtils.drawCenteredText(g2d, "3.5", width / 2 - 1, height / 2, HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
}
@Override
@@ -337,7 +340,7 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
@Override
public boolean isControlPointSticky(int index) {
return index < 2 || (getType() == OpenJackType.STEREO || getType() == OpenJackType.SWITCHED);
return index < 2 || (getValue() == OpenJackType.STEREO || getValue() == OpenJackType.SWITCHED);
}
@Override
@@ -352,16 +355,6 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
body = null;
}
@Override
public String getValue() {
return value;
}
@Override
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Integer getAngle() {
if (angle == null || (orientation != null && orientation != Orientation.DEFAULT)) {
@@ -384,12 +377,12 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
return Math.toRadians(getAngle());
}
@EditableProperty
public OpenJackType getType() {
@EditableProperty(name = "Type")
public OpenJackType getValue() {
return type;
}
public void setType(OpenJackType type) {
public void setValue(OpenJackType type) {
this.type = type;
updateControlPoints();
// Invalidate the body
@@ -411,9 +404,9 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
return "Tip";
if (index == 1)
return "Sleeve";
if (index == 2 && getType() == OpenJackType.STEREO)
if (index == 2 && getValue() == OpenJackType.STEREO)
return "Ring";
if (index == 2 && getType() == OpenJackType.SWITCHED)
if (index == 2 && getValue() == OpenJackType.SWITCHED)
return "Shunt";
return null;
}
@@ -423,7 +416,7 @@ public class OpenJack1_8 extends AbstractMultiPartComponent<String> {
return false;
}
public enum OpenJackType {
static enum OpenJackType {
MONO, STEREO, SWITCHED;
@@ -1,26 +1,23 @@
/*
*
* 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.electromechanical;
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.electromechanical;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
@@ -50,343 +47,350 @@ import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Tactile Micro-Switch", author = "Branislav Stojkovic", category = "Electro-Mechanical",
instanceNamePrefix = "SW", description = "4-pin tactile momentary switch",
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class,
enableCache = true)
public class TactileMicroSwitch extends AbstractLabeledComponent<String> {
private static final long serialVersionUID = 1L;
public static Color BODY_COLOR = Color.lightGray;
public static Color BORDER_COLOR = Color.gray.darker();
public static Color PIN_COLOR = METAL_COLOR;
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
public static Color INDENT_COLOR = Color.gray.darker();
public static Color LABEL_COLOR = Color.white;
@ComponentDescriptor(name = "Tactile Micro-Switch", author = "Branislav Stojkovic",
category = "Electro-Mechanical", instanceNamePrefix = "SW",
description = "4-pin tactile momentary switch", zOrder = IDIYComponent.COMPONENT,
keywordPolicy = KeywordPolicy.SHOW_VALUE, enableCache = true)
public class TactileMicroSwitch extends AbstractLabeledComponent<String> {
private static final long serialVersionUID = 1L;
public static Color BODY_COLOR = Color.lightGray;
public static Color BORDER_COLOR = Color.gray.darker();
public static Color PIN_COLOR = METAL_COLOR;
public static Color PIN_BORDER_COLOR = PIN_COLOR.darker();
public static Color INDENT_COLOR = Color.gray.darker();
public static Color LABEL_COLOR = Color.white;
public static Size PIN_SIZE = new Size(0.04d, SizeUnit.in);
public static int PIN_COUNT = 4;
public static Size CASE_SIZE = new Size(6d, SizeUnit.mm);
public static Size INDENT_SIZE = new Size(3d, SizeUnit.mm);
private static Size PIN_SPACING = new Size(4.5d, SizeUnit.mm);
private static Size ROW_SPACING = new Size(6.5d, SizeUnit.mm);
private String value = "";
private Orientation orientation = Orientation.DEFAULT;
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
protected Display display = Display.BOTH;
private Color bodyColor = BODY_COLOR;
private Color borderColor = BORDER_COLOR;
private Color labelColor = LABEL_COLOR;
transient private Area[] body;
public TactileMicroSwitch() {
super();
updateControlPoints();
}
@EditableProperty
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Reset body shape.
body = null;
}
@EditableProperty
public Display getDisplay() {
if (display == null) {
display = Display.VALUE;
}
return display;
}
public void setDisplay(Display display) {
this.display = display;
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public Point2D getControlPoint(int index) {
return controlPoints[index];
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public void setControlPoint(Point2D point, int index) {
controlPoints[index].setLocation(point);
body = null;
}
private void updateControlPoints() {
Point2D firstPoint = controlPoints[0];
controlPoints = new Point2D[PIN_COUNT];
controlPoints[0] = firstPoint;
double pinSpacing = PIN_SPACING.convertToPixels();
double rowSpacing = ROW_SPACING.convertToPixels();
// Update control points.
double dx1;
double dy1;
double dx2;
double dy2;
for (int i = 0; i < PIN_COUNT / 2; i++) {
switch (orientation) {
case DEFAULT:
dx1 = 0;
dy1 = i * pinSpacing;
dx2 = rowSpacing;
dy2 = i * pinSpacing;
break;
case _90:
dx1 = -i * pinSpacing;
dy1 = 0;
dx2 = -i * pinSpacing;
dy2 = rowSpacing;
break;
case _180:
dx1 = 0;
dy1 = -i * pinSpacing;
dx2 = -rowSpacing;
dy2 = -i * pinSpacing;
break;
case _270:
dx1 = i * pinSpacing;
dy1 = 0;
dx2 = i * pinSpacing;
dy2 = -rowSpacing;
break;
default:
throw new RuntimeException("Unexpected orientation: " + orientation);
}
controlPoints[i] = new Point2D.Double((int) (firstPoint.getX() + dx1), (int) (firstPoint.getY() + dy1));
controlPoints[i + PIN_COUNT / 2] = new Point2D.Double((int) (firstPoint.getX() + dx2), (int) (firstPoint.getY() + dy2));
}
}
public Area[] getBody() {
if (body == null) {
body = new Area[2];
double x = controlPoints[0].getX();
double y = controlPoints[0].getY();
double width;
double height;
private static Size ROW_SPACING = new Size(6.5d, SizeUnit.mm);
private String value = "";
private Orientation orientation = Orientation.DEFAULT;
private Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
protected Display display = Display.BOTH;
private Color bodyColor = BODY_COLOR;
private Color borderColor = BORDER_COLOR;
private Color labelColor = LABEL_COLOR;
transient private Area[] body;
public TactileMicroSwitch() {
super();
updateControlPoints();
}
@EditableProperty
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@EditableProperty
public Orientation getOrientation() {
return orientation;
}
public void setOrientation(Orientation orientation) {
this.orientation = orientation;
updateControlPoints();
// Reset body shape.
body = null;
}
@EditableProperty
public Display getDisplay() {
if (display == null) {
display = Display.VALUE;
}
return display;
}
public void setDisplay(Display display) {
this.display = display;
}
@Override
public int getControlPointCount() {
return controlPoints.length;
}
@Override
public Point2D getControlPoint(int index) {
return controlPoints[index];
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public void setControlPoint(Point2D point, int index) {
controlPoints[index].setLocation(point);
body = null;
}
private void updateControlPoints() {
Point2D firstPoint = controlPoints[0];
controlPoints = new Point2D[PIN_COUNT];
controlPoints[0] = firstPoint;
double pinSpacing = PIN_SPACING.convertToPixels();
double rowSpacing = ROW_SPACING.convertToPixels();
// Update control points.
double dx1;
double dy1;
double dx2;
double dy2;
for (int i = 0; i < PIN_COUNT / 2; i++) {
switch (orientation) {
case DEFAULT:
dx1 = 0;
dy1 = i * pinSpacing;
dx2 = rowSpacing;
dy2 = i * pinSpacing;
break;
case _90:
dx1 = -i * pinSpacing;
dy1 = 0;
dx2 = -i * pinSpacing;
dy2 = rowSpacing;
break;
case _180:
dx1 = 0;
dy1 = -i * pinSpacing;
dx2 = -rowSpacing;
dy2 = -i * pinSpacing;
break;
case _270:
dx1 = i * pinSpacing;
dy1 = 0;
dx2 = i * pinSpacing;
dy2 = -rowSpacing;
break;
default:
throw new RuntimeException("Unexpected orientation: " + orientation);
}
controlPoints[i] =
new Point2D.Double((int) (firstPoint.getX() + dx1), (int) (firstPoint.getY() + dy1));
controlPoints[i + PIN_COUNT / 2] =
new Point2D.Double((int) (firstPoint.getX() + dx2), (int) (firstPoint.getY() + dy2));
}
}
public Area[] getBody() {
if (body == null) {
body = new Area[2];
double x = controlPoints[0].getX();
double y = controlPoints[0].getY();
double width;
double height;
double caseSize = CASE_SIZE.convertToPixels();
double indentSize = INDENT_SIZE.convertToPixels();
width = height = caseSize;
x = (controlPoints[0].getX() + controlPoints[3].getX() - width) / 2;
y = (controlPoints[0].getY() + controlPoints[3].getY() - height) / 2;
body[0] = new Area(new Rectangle2D.Double(x, y, width, height));
width = height = indentSize;
double indentSize = INDENT_SIZE.convertToPixels();
width = height = caseSize;
x = (controlPoints[0].getX() + controlPoints[3].getX() - width) / 2;
y = (controlPoints[0].getY() + controlPoints[3].getY() - height) / 2;
body[1] = new Area(new Ellipse2D.Double(x, y, width, height));
}
return body;
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
IDrawingObserver drawingObserver) {
if (checkPointsClipped(g2d.getClip())) {
return;
body[0] = new Area(new Rectangle2D.Double(x, y, width, height));
width = height = indentSize;
x = (controlPoints[0].getX() + controlPoints[3].getX() - width) / 2;
y = (controlPoints[0].getY() + controlPoints[3].getY() - height) / 2;
body[1] = new Area(new Ellipse2D.Double(x, y, width, height));
}
Area[] body = getBody();
return body;
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
if (checkPointsClipped(g2d.getClip())) {
return;
}
Area[] body = getBody();
Area mainArea = body[0];
Area indentArea = body[1];
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
if (!outlineMode) {
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
if (!outlineMode) {
int pinSize = (int) PIN_SIZE.convertToPixels() / 2 * 2;
for (Point2D point : controlPoints) {
Rectangle2D rect = new Rectangle2D.Double(point.getX() - pinSize / 2, point.getY() - pinSize / 2, pinSize, pinSize);
g2d.setColor(PIN_COLOR);
g2d.fill(rect);
g2d.setColor(PIN_BORDER_COLOR);
g2d.draw(rect);
}
}
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
Rectangle2D rect = new Rectangle2D.Double(point.getX() - pinSize / 2,
point.getY() - pinSize / 2, pinSize, pinSize);
g2d.setColor(PIN_COLOR);
g2d.fill(rect);
g2d.setColor(PIN_BORDER_COLOR);
g2d.draw(rect);
}
}
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(outlineMode ? Constants.TRANSPARENT_COLOR : getBodyColor());
g2d.fill(mainArea);
g2d.setColor(INDENT_COLOR);
g2d.fill(indentArea);
g2d.setColor(INDENT_COLOR.darker());
g2d.draw(indentArea);
g2d.setComposite(oldComposite);
Color finalBorderColor;
if (outlineMode) {
Theme theme =
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: theme.getOutlineColor();
} else {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
: getBorderColor();
}
g2d.setColor(finalBorderColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.draw(mainArea);
drawingObserver.stopTracking();
// Draw label.
g2d.setComposite(oldComposite);
Color finalBorderColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: theme.getOutlineColor();
} else {
finalBorderColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: getBorderColor();
}
g2d.setColor(finalBorderColor);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.draw(mainArea);
drawingObserver.stopTracking();
// Draw label.
g2d.setFont(project.getFont());
// Override font size
if (getFontSizeOverride() != null)
g2d.setFont(g2d.getFont().deriveFont(1f * getFontSizeOverride()));
Color finalLabelColor;
if (outlineMode) {
Theme theme =
(Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY, Constants.DEFAULT_THEME);
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
: theme.getOutlineColor();
} else {
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? LABEL_COLOR_SELECTED
: getLabelColor();
}
g2d.setColor(finalLabelColor);
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
String[] label = null;
if (getDisplay() == Display.NAME) {
label = new String[] {getName()};
} else if (getDisplay() == Display.VALUE) {
label = new String[] {getValue().toString()};
} else if (getDisplay() == Display.BOTH) {
String value = getValue().toString();
label = value.isEmpty() ? new String[] {getName()} : new String[] {getName(), value};
}
if (label != null) {
for (int i = 0; i < label.length; i++) {
String l = label[i];
Rectangle2D rect = fontMetrics.getStringBounds(l, g2d);
int textHeight = (int) (rect.getHeight());
int textWidth = (int) (rect.getWidth());
// Center text horizontally and vertically
Rectangle bounds = mainArea.getBounds();
double x = bounds.getX() + (bounds.width - textWidth) / 2;
double y = bounds.getY() + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
if (label.length == 2) {
if (i == 0)
g2d.translate(0, -textHeight / 2);
else if (i == 1)
g2d.translate(0, textHeight / 2);
}
g2d.drawString(l, (int)x, (int)y);
}
}
}
@Override
Color finalLabelColor;
if (outlineMode) {
Theme theme = (Theme) ConfigurationManager.getInstance().readObject(IPlugInPort.THEME_KEY,
Constants.DEFAULT_THEME);
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED
: theme.getOutlineColor();
} else {
finalLabelColor =
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? LABEL_COLOR_SELECTED
: getLabelColor();
}
g2d.setColor(finalLabelColor);
FontMetrics fontMetrics = g2d.getFontMetrics(g2d.getFont());
String[] label = null;
if (getDisplay() == Display.NAME) {
label = new String[] {getName()};
} else if (getDisplay() == Display.VALUE) {
label = new String[] {getValue().toString()};
} else if (getDisplay() == Display.BOTH) {
String value = getValue().toString();
label = value.isEmpty() ? new String[] {getName()} : new String[] {getName(), value};
}
if (label != null) {
for (int i = 0; i < label.length; i++) {
String l = label[i];
Rectangle2D rect = fontMetrics.getStringBounds(l, g2d);
int textHeight = (int) (rect.getHeight());
int textWidth = (int) (rect.getWidth());
// Center text horizontally and vertically
Rectangle bounds = mainArea.getBounds();
double x = bounds.getX() + (bounds.width - textWidth) / 2;
double y = bounds.getY() + (bounds.height - textHeight) / 2 + fontMetrics.getAscent();
if (label.length == 2) {
if (i == 0)
g2d.translate(0, -textHeight / 2);
else if (i == 1)
g2d.translate(0, textHeight / 2);
}
g2d.drawString(l, (int) x, (int) y);
}
}
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
int pinSize = 4 * width / 32;
g2d.setColor(PIN_COLOR);
g2d.fillRect(width / 6 - pinSize + 1, height / 6 + 1, pinSize, pinSize);
g2d.fillRect(5 * width / 6, height / 6 + 1, pinSize, pinSize);
g2d.fillRect(width / 6 - pinSize + 1, 5 * height / 6 - pinSize - 1, pinSize, pinSize);
g2d.fillRect(5 * width / 6, 5 * height / 6 - pinSize - 1, pinSize, pinSize);
g2d.setColor(BODY_COLOR);
g2d.fillRect(width / 6, width / 6, 4 * width / 6, 4 * width / 6);
g2d.setColor(BORDER_COLOR);
g2d.drawRect(width / 6, width / 6, 4 * width / 6, 4 * width / 6);
g2d.setColor(BODY_COLOR);
g2d.fillRect(width / 6, width / 6, 4 * width / 6, 4 * width / 6);
g2d.setColor(BORDER_COLOR);
g2d.drawRect(width / 6, width / 6, 4 * width / 6, 4 * width / 6);
g2d.setColor(INDENT_COLOR);
int indentSize = 9 * width / 32;
g2d.fillOval(width / 2 - indentSize / 2, height / 2 - indentSize / 2, indentSize, indentSize);
}
@EditableProperty(name = "Body")
public Color getBodyColor() {
if (bodyColor == null) {
bodyColor = BODY_COLOR;
}
return bodyColor;
}
public void setBodyColor(Color bodyColor) {
this.bodyColor = bodyColor;
}
@EditableProperty(name = "Border")
public Color getBorderColor() {
if (borderColor == null) {
borderColor = BORDER_COLOR;
}
return borderColor;
}
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
@EditableProperty(name = "Label")
public Color getLabelColor() {
if (labelColor == null) {
labelColor = LABEL_COLOR;
}
return labelColor;
}
public void setLabelColor(Color labelColor) {
this.labelColor = labelColor;
g2d.fillOval(width / 2 - indentSize / 2, height / 2 - indentSize / 2, indentSize, indentSize);
}
@EditableProperty(name = "Body")
public Color getBodyColor() {
if (bodyColor == null) {
bodyColor = BODY_COLOR;
}
return bodyColor;
}
public void setBodyColor(Color bodyColor) {
this.bodyColor = bodyColor;
}
@EditableProperty(name = "Border")
public Color getBorderColor() {
if (borderColor == null) {
borderColor = BORDER_COLOR;
}
return borderColor;
}
public void setBorderColor(Color borderColor) {
this.borderColor = borderColor;
}
@EditableProperty(name = "Label")
public Color getLabelColor() {
if (labelColor == null) {
labelColor = LABEL_COLOR;
}
return labelColor;
}
public void setLabelColor(Color labelColor) {
this.labelColor = labelColor;
}
@Override
public boolean canPointMoveFreely(int pointIndex) {
return false;
}
@Override
public Rectangle2D getCachingBounds() {
double minX = Integer.MAX_VALUE;
@@ -405,7 +409,8 @@ public class TactileMicroSwitch extends AbstractLabeledComponent<String> {
if (p.getY() > maxY)
maxY = p.getY();
}
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin);
}
}
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin,
maxY - minY + 2 * margin);
}
}
@@ -250,6 +250,11 @@ public class Label extends AbstractComponent<String> {
public String getValue() {
return text;
}
@Override
public String getValueForDisplay() {
return "";
}
@Override
public void setValue(String value) {
@@ -56,9 +56,9 @@ import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Audio Transformer", author = "Branislav Stojkovic", category = "Passive",
instanceNamePrefix = "TR", description = "Small signal audio transformer with EI core",
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE, transformer = DIL_ICTransformer.class)
@ComponentDescriptor(name = "Mini Signal Transformer", author = "Branislav Stojkovic", category = "Passive",
instanceNamePrefix = "TR", description = "Miniature PCB-mount signal transformer with EI core",
zOrder = IDIYComponent.COMPONENT, keywordPolicy = KeywordPolicy.SHOW_VALUE)
public class AudioTransformer extends AbstractMultiPartComponent<String> {
private static final long serialVersionUID = 1L;
@@ -60,7 +60,7 @@ public class FuseSymbol extends AbstractSchematicLeadedSymbol<Current> {
@Override
public String getValueForDisplay() {
return getValue().toString();// + (getPowerNew() == null ? "" : " " + getPowerNew().toString());
return getValue() == null ? null : getValue().toString();// + (getPowerNew() == null ? "" : " " + getPowerNew().toString());
}
public void drawIcon(Graphics2D g2d, int width, int height) {
@@ -76,7 +76,7 @@ public class RadialInductor extends AbstractRadialComponent<Inductance> {
@Override
public String getValueForDisplay() {
return getValue().toString();
return getValue() == null ? null : getValue().toString();
}
@Override
@@ -36,7 +36,7 @@ public abstract class AbstractDiodeSymbol extends AbstractSchematicLeadedSymbol<
public static Size DEFAULT_SIZE = new Size(0.1, SizeUnit.in);
private String value = null;
private String value = "";
public AbstractDiodeSymbol() {
super();
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,109 @@
/*
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.transform;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.Orientation;
import org.diylc.components.connectivity.PCBTerminalBlock;
import org.diylc.core.IDIYComponent;
public class PCBTerminalBlockTransformer implements IComponentTransformer {
@Override
public boolean canRotate(IDIYComponent<?> component) {
return component.getClass().equals(PCBTerminalBlock.class);
}
@Override
public boolean canMirror(IDIYComponent<?> component) {
return component.getClass().equals(PCBTerminalBlock.class);
}
@Override
public boolean mirroringChangesCircuit() {
return false;
}
@Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY());
for (int index = 0; index < component.getControlPointCount(); index++) {
Point2D p = new Point2D.Double();
rotate.transform(component.getControlPoint(index), p);
component.setControlPoint(p, index);
}
PCBTerminalBlock block = (PCBTerminalBlock) component;
Orientation o = block.getOrientation();
int oValue = o.ordinal();
oValue += direction;
if (oValue < 0)
oValue = Orientation.values().length - 1;
if (oValue >= Orientation.values().length)
oValue = 0;
o = Orientation.values()[oValue];
block.setOrientation(o);
}
@SuppressWarnings("incomplete-switch")
@Override
public void mirror(IDIYComponent<?> component, Point2D center, int direction) {
PCBTerminalBlock block = (PCBTerminalBlock) component;
double dx = center.getX() - block.getControlPoint(0).getX();
double dy = center.getY() - block.getControlPoint(0).getY();
if (direction == IComponentTransformer.HORIZONTAL) {
Orientation o = block.getOrientation();
switch (o) {
case _90:
o = Orientation._270;
break;
case _270:
o = Orientation._90;
}
for (int i = 0; i < block.getControlPointCount(); i++) {
Point2D p = block.getControlPoint(i);
block.setControlPoint(new Point2D.Double(p.getX() + 2 * dx, p.getY()), i);
}
block.setOrientation(o);
} else {
Orientation o = block.getOrientation();
switch (o) {
case DEFAULT:
o = Orientation._180;
break;
case _180:
o = Orientation.DEFAULT;
}
for (int i = 0; i < block.getControlPointCount(); i++) {
Point2D p = block.getControlPoint(i);
block.setControlPoint(new Point2D.Double(p.getX(), p.getY() + 2 * dy), i);
}
block.setOrientation(o);
}
}
}
@@ -80,7 +80,7 @@ public class FlexibleLeadsEditor implements IProjectEditor {
// create leads
HookupWire w1 = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w1, null);
w1.setGauge(AWG._26);
w1.setValue(AWG._26);
w1.setLeadColor(leaded.getLeadColor());
// w1.setPointCount(PointCount.THREE);
w1.setControlPoint(p1, 0);
@@ -93,7 +93,7 @@ public class FlexibleLeadsEditor implements IProjectEditor {
HookupWire w2 = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w2, null);
w2.setGauge(AWG._26);
w2.setValue(AWG._26);
w2.setLeadColor(leaded.getLeadColor());
// w2.setPointCount(PointCount.THREE);
w2.setControlPoint(p2, 0);
@@ -134,9 +134,9 @@ public class FlexibleLeadsEditor implements IProjectEditor {
getInstantiationManager().fillWithDefaultProperties(w, null);
// make the leads thicker for TO220 and TO126
if (c instanceof TransistorTO220 || c instanceof TransistorTO126)
w.setGauge(AWG._24);
w.setValue(AWG._24);
else
w.setGauge(AWG._26);
w.setValue(AWG._26);
w.setLeadColor(AbstractTransistorPackage.METAL_COLOR);
w.setPointCount(PointCount.THREE);
w.setControlPoint(p0, 0);
@@ -244,7 +244,7 @@ public class FlexibleLeadsEditor implements IProjectEditor {
tx = AffineTransform.getRotateInstance(c.getOrientation().toRadians(), p0.getX(), p0.getY());
HookupWire w = new HookupWire();
w.setGauge(AWG._24);
w.setValue(AWG._24);
getInstantiationManager().fillWithDefaultProperties(w, null);
for (int j = 0; j < w.getControlPointCount(); j++) {
Point2D p = new Point2D.Double((int)(p0.getX() + dx * j), (int)(p0.getY() + dy * j));
@@ -439,29 +439,29 @@ public class V2FileParser implements IOldFileParser {
}
num = num * 2 + 8;
if (num == 8)
hw.setGauge(AWG._8);
hw.setValue(AWG._8);
else if (num == 10)
hw.setGauge(AWG._10);
hw.setValue(AWG._10);
else if (num == 12)
hw.setGauge(AWG._12);
hw.setValue(AWG._12);
else if (num == 14)
hw.setGauge(AWG._14);
hw.setValue(AWG._14);
else if (num == 16)
hw.setGauge(AWG._16);
hw.setValue(AWG._16);
else if (num == 18)
hw.setGauge(AWG._18);
hw.setValue(AWG._18);
else if (num == 20)
hw.setGauge(AWG._20);
hw.setValue(AWG._20);
else if (num == 22)
hw.setGauge(AWG._22);
hw.setValue(AWG._22);
else if (num == 24)
hw.setGauge(AWG._24);
hw.setValue(AWG._24);
else if (num == 26)
hw.setGauge(AWG._26);
hw.setValue(AWG._26);
else if (num == 28)
hw.setGauge(AWG._28);
hw.setValue(AWG._28);
else if (num == 30)
hw.setGauge(AWG._30);
hw.setValue(AWG._30);
hw.setLeadColor(cl);
hw.setControlPoint(tacke.get(0), 0);
hw.setControlPoint(tacke.get(1), 1);
+1 -1
View File
@@ -14,5 +14,5 @@
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.diylc.DIYLCStarter"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="diylc-swing"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="diylc-swing"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m -Xmx2048m -javaagent:lib/jar-loader.jar -Dorg.diylc.storeDict=true -Dorg.diylc.enableTests=true -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugContinuityAreas=true -Ddorg.diylc.debugComponentAreas=true -Ddorg.diylc.WriteStaticVariants=true -Dorg.diylc.WriteStaticBlocks=true &#13;&#10;--add-opens java.base/java.util=ALL-UNNAMED&#13;&#10;--add-opens java.base/java.lang=ALL-UNNAMED&#13;&#10;--add-opens java.base/java.text=ALL-UNNAMED&#13;&#10;--add-opens java.desktop/java.awt=ALL-UNNAMED&#13;&#10;--add-opens java.desktop/java.awt.font=ALL-UNNAMED&#13;&#10;--add-opens java.desktop/java.awt.geom=ALL-UNNAMED"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m -Xmx2048m -javaagent:lib/jar-loader.jar -Dorg.diylc.storeDict=true -Dorg.diylc.enableTests=true -Dorg.diylc.scriptRun=true -Ddorg.diylc.debugContinuityAreas=true -Ddorg.diylc.debugComponentAreas=true -Ddorg.diylc.WriteStaticVariants=true -Ddorg.diylc.WriteStaticBlocks=true &#13;&#10;--add-opens java.base/java.util=ALL-UNNAMED&#13;&#10;--add-opens java.base/java.lang=ALL-UNNAMED&#13;&#10;--add-opens java.base/java.text=ALL-UNNAMED&#13;&#10;--add-opens java.desktop/java.awt=ALL-UNNAMED&#13;&#10;--add-opens java.desktop/java.awt.font=ALL-UNNAMED&#13;&#10;--add-opens java.desktop/java.awt.geom=ALL-UNNAMED"/>
</launchConfiguration>
+606
View File
@@ -0,0 +1,606 @@
<map>
<entry>
<string>Title Block</string>
<list>
<org.diylc.components.shapes.Rectangle>
<name>RECT1</name>
<alpha>127</alpha>
<value></value>
<controlPoints>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.7007874015748</x>
<y>149.60629921259843</y>
</java.awt.geom.Point2D_-Double>
</controlPoints>
<firstPoint>
<x>0.0</x>
<y>0.0</y>
</firstPoint>
<secondPoint>
<x>393.7007874015748</x>
<y>149.60629921259843</y>
</secondPoint>
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</color>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<borderThickness>
<value>0.5</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</borderThickness>
<edgeRadius>
<value>0.0</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</edgeRadius>
</org.diylc.components.shapes.Rectangle>
<org.diylc.components.connectivity.Line>
<name>LN1</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>188.9763779527559</x>
<y>149.60629921259843</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>188.9763779527559</x>
<y>118.11023622047246</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.connectivity.Line>
<name>LN2</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>118.11023622047246</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.70078740157487</x>
<y>118.11023622047246</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.connectivity.Line>
<name>LN3</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>55.118110236220474</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.7007874015748</x>
<y>55.118110236220474</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.connectivity.Line>
<name>LN4</name>
<alpha>127</alpha>
<points>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>86.61417322834646</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>393.70078740157476</x>
<y>86.61417322834646</y>
</java.awt.geom.Point2D_-Double>
<java.awt.geom.Point2D_-Double>
<x>0.0</x>
<y>0.0</y>
</java.awt.geom.Point2D_-Double>
</points>
<bodyColor>
<red>255</red>
<green>255</green>
<blue>255</blue>
<alpha>255</alpha>
</bodyColor>
<borderColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</borderColor>
<labelColor>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</labelColor>
<leadColor>
<red>204</red>
<green>204</green>
<blue>204</blue>
<alpha>255</alpha>
</leadColor>
<display>NAME</display>
<flipStanding>false</flipStanding>
<labelOriantation>Directional</labelOriantation>
<moveLabel>false</moveLabel>
<hideShortLeads>false</hideShortLeads>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<style>SOLID</style>
<thickness>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">mm</unit>
</thickness>
<arrowSize>
<value>5.0</value>
<unit class="org.diylc.core.measures.SizeUnit">px</unit>
</arrowSize>
<arrowTx serialization="custom">
<java.awt.geom.AffineTransform>
<default>
<m00>1.0</m00>
<m01>0.0</m01>
<m02>0.0</m02>
<m10>0.0</m10>
<m11>1.0</m11>
<m12>0.0</m12>
</default>
</java.awt.geom.AffineTransform>
</arrowTx>
<arrowStart>false</arrowStart>
<arrowEnd>false</arrowEnd>
</org.diylc.components.connectivity.Line>
<org.diylc.components.misc.Label>
<name>LAB1</name>
<point>
<x>204.7244094488189</x>
<y>133.85826771653544</y>
</point>
<text>revision</text>
<font>
<size class="float">14.0</size>
<weight class="null"/>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Roman</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB2</name>
<point>
<x>291.3385826771654</x>
<y>133.85826771653544</y>
</point>
<text>1.0.0</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB3</name>
<point>
<x>15.748031496062993</x>
<y>133.85826771653544</y>
</point>
<text>updated</text>
<font>
<size class="float">14.0</size>
<weight class="null"/>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Roman</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB4</name>
<point>
<x>86.61417322834646</x>
<y>133.85826771653544</y>
</point>
<text>1/1/2020</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB5</name>
<point>
<x>47.24409448818898</x>
<y>70.86614173228347</y>
</point>
<text>drawn by</text>
<font reference="../../org.diylc.components.misc.Label/font"/>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB6</name>
<point>
<x>31.496062992125985</x>
<y>15.748031496062993</y>
</point>
<text>title</text>
<font reference="../../org.diylc.components.misc.Label/font"/>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB7</name>
<point>
<x>188.9763779527559</x>
<y>70.86614173228347</y>
</point>
<text>Author Name</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB8</name>
<point>
<x>188.9763779527559</x>
<y>31.496062992125985</y>
</point>
<text>My Cool Project</text>
<font>
<size class="float">20.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>255</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB9</name>
<point>
<x>15.748031496062993</x>
<y>102.36220472440945</y>
</point>
<text>website</text>
<font>
<size class="float">14.0</size>
<weight class="null"/>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Roman</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>LEFT</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
<org.diylc.components.misc.Label>
<name>LAB10</name>
<point>
<x>188.9763779527559</x>
<y>102.36220472440945</y>
</point>
<text>www.mysite.com/myproject</text>
<font>
<size class="float">14.0</size>
<weight class="float">2.0</weight>
<width class="null"/>
<superscript class="null"/>
<posture class="null"/>
<transform class="null"/>
<family class="string">Square721 BT Bold</family>
<tracking class="null"/>
</font>
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<alpha>255</alpha>
</color>
<horizontalAlignment>CENTER</horizontalAlignment>
<verticalAlignment>CENTER</verticalAlignment>
<orientation>DEFAULT</orientation>
</org.diylc.components.misc.Label>
</list>
</entry>
</map>
+3 -3
View File
@@ -10,7 +10,7 @@
<property name="jar.dir" value="${build.dir}/jar" />
<property name="report.dir" value="${build.dir}/junitreport" />
<property name="main.class" value="org.diylc.DIYLCStarter" />
<property name="diylc.version" value="4.34.0" />
<property name="diylc.version" value="4.37.0" />
<property name="osx.jre8.path" value="tools\jre\osx\jre8u321\Contents\Home\" />
<property name="osx.jre8m1.path" value="tools\jre\osx\zulu-8.jre\Contents\Home\" />
@@ -99,7 +99,7 @@
<typedeclaration
identifier="org.diylc.diy"
description="DIYLC file type"
icon="icons/diylc.icns"
icon="icons/diylc_file.icns"
conformsTo="public.xml,public.text"
extensions="diy" />
<runtime dir="${osx.jre8.path}" />
@@ -146,7 +146,7 @@
<typedeclaration
identifier="org.diylc.diy"
description="DIYLC file type"
icon="icons/diylc.icns"
icon="icons/diylc_file.icns"
conformsTo="public.xml,public.text"
extensions="diy" />
<runtime dir="${osx.jre8m1.path}" />
+23 -16
View File
@@ -1,18 +1,18 @@
#10 (2.59mm / 0.10190in)
#12 (2.05mm / 0.08081in)
#14 (1.63mm / 0.06409in)
#16 (1.29mm / 0.05082in)
#18 (1.02mm / 0.04030in)
#20 (0.81mm / 0.03196in)
#22 (0.64mm / 0.02535in)
#24 (0.51mm / 0.02010in)
#26 (0.40mm / 0.01594in)
#28 (0.32mm / 0.01264in)
#30 (0.25mm / 0.01003in)
#32 (0.20mm / 0.00795in)
#34 (0.16mm / 0.00631in)
#36 (0.13mm / 0.00500in)
#8 (3.26mm / 0.12849in)
#10 / 2.59mm
#12 / 2.05mm
#14 / 1.63mm
#16 / 1.29mm
#18 / 1.02mm
#20 / 0.81mm
#22 / 0.64mm
#24 / 0.51mm
#26 / 0.40mm
#28 / 0.32mm
#30 / 0.25mm
#32 / 0.20mm
#34 / 0.16mm
#36 / 0.13mm
#8 / 3.26mm
1 throws / 2 positions
10 throws / 10 positions
11 throws / 11 positions
@@ -49,13 +49,14 @@ AWG
Alternate
And
Angle Offset
Apply Model
B-C-E BJT
Background
Box
C-B-E BJT
Circle
Coil(s)
Component reordering is possible only when Project Explorer is sorted by z-index
Component reordering is possible only when Project Explorer is sorted by z-index.
Configuration
Could not apply changes. Check the log for details.
D-G-S JFET
@@ -85,6 +86,7 @@ Double Rods
Drop
E+
E-B-C BJT
Eight
English
Español
Filament Voltage
@@ -102,11 +104,13 @@ I-G-O REGULATOR
Italiano
Lin
Log
MPJA
Markers
Maximum number of switching combinations exceeded. Allowed: %s, actual: %s
NPN
Nand
Nederlands
Nine
Non-shorting
Nor
Not
@@ -124,6 +128,8 @@ PCB
PNP
Poles
Português
RS
RY1
Rectangle
Rev log
S-G-D JFET
@@ -145,6 +151,7 @@ Source Style
Source Type
Srpski
Stroke
Ten
Terminal
Timing
Tubular Beveled
@@ -37,6 +37,54 @@
<update_contact>nbenitezl_AT_gmail.com</update_contact>
<content_rating type="oars-1.1"/>
<releases>
<release version="4.37.0" date="2023-04-27">
<description>
<ul>
<li>[New Feature] 'Proto Board 780 Holes' added with two variations (sponsored by Pete Olivier)</li>
<li>[Improvement] Ability to rotate (almost) all components using keyboard shortcuts and 'Transform Selection' menu</li>
</ul>
</description>
<url>https://github.com/bancika/diy-layout-creator/releases/tag/v4.37.0</url>
</release>
<release version="4.36.0" date="2023-03-30">
<description>
<ul>
<li>[New Feature] Title Block added as one of factory building blocks (was missing in 4.35 by mistake)</li>
<li>[New Feature] Configurable max switch combination count for circuit analysis (using org.diylc.maxSwitchCombinations argument)</li>
<li>[Improvement] Added resilience to the code that saves the configuration file to avoid it getting corrupted</li>
<li>[Improvement] When backing up the configuration file, append the current timestamp at the end instead of a '~'</li>
<li>[Improvement] Improve the format of timestamp in file backups</li>
<li>[Bug Fix] General application slowness when Inductor component is added to the drawing</li>
<li>[Bug Fix] Lever switch orientation not loaded correctly from files created prior to version 4.35</li>
</ul>
</description>
<url>https://github.com/bancika/diy-layout-creator/releases/tag/v4.36.0</url>
</release>
<release version="4.35.0" date="2022-12-23">
<description>
<ul>
<li>[New Feature] Added '1/8" Cliff Jack' component - stereo and mono</li>
<li>[New Feature] Added 'Solder Lug' component</li>
<li>[New Feature] Added 'PCB Terminal Block' component</li>
<li>[New Feature] Show component values in the project explorer</li>
<li>[New Feature] Double click in the project explorer to edit selected component</li>
<li>[New Feature] Title Block added as one of factory building blocks</li>
<li>[New Feature] 'Renumber On Paste' feature now applies to variants as well. When set to OFF, the app honors the name saved in the variant</li>
<li>[New Feature] New file icons for Mac OS</li>
<li>[Improvement] Ability to use up/down arrow keys in the project explorer to select components</li>
<li>[Improvement] Use scroll buttons in 'Tabbed Toolbar' instead of arranging tabs into multiple lines when the screen is not large enough to show them all</li>
<li>[Improvement] Escape comma in BOM CSV files to avoid component names being split into separate columns</li>
<li>[Improvement] Show jack type in the BOM and project explorer</li>
<li>[Improvement] Show wire gauge in the BOM and project explorer</li>
<li>[Improvement] Improved find tool usability, make the screen pan to the selected components</li>
<li>[Bug Fix] Trace cut doesn't affect continuity of vero board traces</li>
<li>[Bug Fix] DIL IC pin labels incorrect in the netlist</li>
<li>[Bug Fix] Diode symbol doesn't appear in the BOM</li>
<li>[Bug Fix] Upon starting or opening a project, the ruler is slightly miss-aligned with the project boundaries</li>
</ul>
</description>
<url>https://github.com/bancika/diy-layout-creator/releases/tag/v4.35.0</url>
</release>
<release version="4.34.0" date="2022-12-09">
<description>
<ul>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -230,9 +230,7 @@ public class DIYLCStarter {
if (ConfigurationManager.getInstance().isFileWithErrors())
mainFrame.showMessage("<html>"
+ "There was an error reading the configuration file and it was replaced by a default configuration.<br>"
+ "The backup file is created and placed in user directory under '.diylc' sub-directory with '~' at the end.<br>"
+ "This can happen when running two versions of DIYLC on the same machine at the same time.<br>"
+ "Replace the main 'config.xml' file with the backup when running the latest version of DIYLC."
+ "The backup file is created and placed in user directory under 'diylc' sub-directory with the current timestamp at the end.<br>"
+ "</html>", "Warning", IView.WARNING_MESSAGE);
}
@@ -23,11 +23,10 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.EnumSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -129,15 +128,11 @@ public class AutoSavePlugin implements IPlugIn {
name = name.substring(0, name.length() - 4);
// append date and time
Date date = new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss");
file = new File(AUTO_SAVE_PATH + File.separator + name + "." + dateFormat.format(date) + ".diy");
// make sure that it doesn't already exist
int i = 2;
while (file.exists()) {
file = new File(AUTO_SAVE_PATH + File.separator + name + "." + dateFormat.format(date) + "-" + i + ".diy");
i++;
}
String timestamp = LocalDateTime.now()
.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.substring(0, 19)
.replace(':', '-');
file = new File(AUTO_SAVE_PATH + File.separator + name + "." + timestamp + ".diy");
return file.getAbsolutePath();
}
@@ -93,6 +93,7 @@ public class CanvasPlugin implements IPlugIn{
scroll.getHorizontalScrollBar().setValue((totalSize.width - visibleSize.width) / 2);
scroll.getVerticalScrollBar().setValue((totalSize.height - visibleSize.height) / 2);
getScrollPane().getViewport().setVisible(true);
updateZeroLocation();
}
@Override
@@ -473,6 +474,8 @@ public class CanvasPlugin implements IPlugIn{
canvasPanel.scrollRectToVisible(visibleRect);
canvasPanel.revalidate();
updateZeroLocation();
}
});
}
@@ -46,7 +46,7 @@ import org.diylc.swing.gui.SearchTextField;
public class ExplorerPane extends JPanel {
private static final long serialVersionUID = 1L;
private static final String REORDERING_NOT_POSSIBLE = LangUtil.translate(
"Component reordering is possible only when Project Explorer is sorted by z-index.");
@@ -74,13 +74,13 @@ public class ExplorerPane extends JPanel {
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weighty = 0;
gbc.gridwidth = 1;
// add(getTitleLabel(), gbc);
//
// gbc.gridy++;
// add(getTitleLabel(), gbc);
//
// gbc.gridy++;
add(getSearchField(), gbc);
@@ -100,14 +100,14 @@ public class ExplorerPane extends JPanel {
add(getSortBox(), gbc);
setPreferredSize(new Dimension(180, 200));
setPreferredSize(new Dimension(240, 200));
}
public JLabel getTitleLabel() {
if (titleLabel == null) {
titleLabel = new JLabel(getName());
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
// titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
// titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
}
return titleLabel;
}
@@ -179,10 +179,17 @@ public class ExplorerPane extends JPanel {
componentList.addMouseListener(new MouseAdapter() {
private MouseEvent pressedEvent;
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
plugInPort.editSelection();
}
}
@Override
public void mousePressed(MouseEvent e) {
ExplorerPane.this.requestFocus();
componentList.requestFocus();
pressedEvent = e;
}
@@ -342,36 +349,52 @@ public class ExplorerPane extends JPanel {
return this.components.get(index);
}
}
private static class ComponentListCellRenderer implements ListCellRenderer<IDIYComponent<?>> {
// private static Color[] layerColors = new Color[] { Color.gray, Color.decode("#ff6363"), Color.decode("#293462"), Color.decode("#138588"),
// Color.decode("#c0ca03"), Color.decode("#990000") };
// private static Color[] layerColors = new Color[] { Color.gray, Color.decode("#ff6363"),
// Color.decode("#293462"), Color.decode("#138588"),
// Color.decode("#c0ca03"), Color.decode("#990000") };
protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();
private Map<String, ComponentType> componentTypes;
public ComponentListCellRenderer(Map<String, List<ComponentType>> componentTypeMap) {
this.componentTypes = componentTypeMap.values().stream()
.flatMap(x -> x.stream())
this.componentTypes = componentTypeMap.values().stream().flatMap(x -> x.stream())
.collect(Collectors.toMap(x -> x.getInstanceClass().getCanonicalName(), x -> x));
}
@Override
public Component getListCellRendererComponent(JList<? extends IDIYComponent<?>> list,
IDIYComponent<?> value, int index, boolean isSelected, boolean cellHasFocus) {
ComponentType componentType = componentTypes.get(value.getClass().getCanonicalName());
JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
isSelected, cellHasFocus);
int layerId = (int)Math.round(componentType.getZOrder());
renderer.setText(String.format("<html><font color='#c0c0c0'>[L%s]</font> %s</html>", layerId, value.getName()));
int layerId = (int) Math.round(componentType.getZOrder());
String valueForDisplay = value.getValueForDisplay();
if (isSelected) {
if (valueForDisplay == null || valueForDisplay.trim().isEmpty()) {
renderer.setText(String.format("[L%s] %s", layerId, value.getName()));
} else {
renderer
.setText(String.format("[L%s] %s (%s)", layerId, value.getName(), valueForDisplay));
}
} else {
if (valueForDisplay == null || valueForDisplay.trim().isEmpty()) {
renderer.setText(String.format("<html><font color='#c0c0c0'>[L%s]</font> %s</html>",
layerId, value.getName()));
} else {
renderer.setText(String.format(
"<html><font color='#c0c0c0'>[L%s]</font> %s (<font color='#666666'>%s</font>)</html>",
layerId, value.getName(), valueForDisplay));
}
}
return renderer;
}
}
@@ -125,7 +125,7 @@ class ComponentTabbedPane extends JTabbedPane {
}
});
setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
@SuppressWarnings("unchecked")