mavenization

This commit is contained in:
Branislav Stojkovic
2025-03-10 15:21:43 +01:00
parent f820c23093
commit 6e347fd7d0
1366 changed files with 14486 additions and 18790 deletions
+67 -20
View File
@@ -1,20 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="test"/> <classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/> <classpathentry kind="lib" path="lib/junit-4.7.jar"/>
<classpathentry kind="lib" path="lib/junit-4.7.jar"/> <classpathentry kind="lib" path="lib/app-framework.jar"/>
<classpathentry kind="lib" path="lib/app-framework.jar"/> <classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/> <classpathentry kind="lib" path="lib/java-http-proxy.jar"/>
<classpathentry kind="lib" path="lib/java-http-proxy.jar"/> <classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/>
<classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/> <classpathentry kind="lib" path="lib/xstream-1.4.19.jar"/>
<classpathentry kind="lib" path="lib/xstream-1.4.19.jar"/> <classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/>
<classpathentry kind="lib" path="lib/guava-31.1-jre.jar"/> <classpathentry kind="lib" path="lib/gerber-writer-api-1.0.0.jar"/>
<classpathentry kind="lib" path="lib/gerber-writer-api-1.0.0.jar"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <attributes>
<attributes> <attribute name="maven.pomderived" value="true"/>
<attribute name="module" value="true"/> </attributes>
</attributes> </classpathentry>
</classpathentry> <classpathentry kind="src" output="target/classes" path="src/main/java">
<classpathentry kind="output" path="bin"/> <attributes>
</classpath> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
+6
View File
@@ -10,8 +10,14 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
</natures> </natures>
<filteredResources> <filteredResources>
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.announcements; package org.diylc.announcements;
import java.io.Serializable; import java.io.Serializable;
@@ -1,41 +1,43 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.announcements; package org.diylc.announcements;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.plugins.cloud.model.IServiceAPI;
import com.diyfever.httpproxy.PhpFlatProxy; import com.diyfever.httpproxy.PhpFlatProxy;
import com.diyfever.httpproxy.ProxyFactory; import com.diyfever.httpproxy.ProxyFactory;
import org.diylc.plugins.cloud.model.IServiceAPI;
public class AnnouncementProvider { public class AnnouncementProvider {
private String serviceUrl = "http://www.diy-fever.com/diylc/api/v1/announcements.html"; private String serviceUrl = "http://www.diy-fever.com/diylc/api/v1/announcements.html";
private String LAST_READ_KEY = "announcement.lastReadDate"; private String LAST_READ_KEY = "announcement.lastReadDate";
private String USER_ID_KEY = "userId"; private String USER_ID_KEY = "userId";
private IAnnouncementService service; private IAnnouncementService service;
@@ -55,20 +57,20 @@ public class AnnouncementProvider {
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1"); ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1");
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy()); ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
service = factory.createProxy(IAnnouncementService.class, serviceUrl); service = factory.createProxy(IAnnouncementService.class, serviceUrl);
} }
private String getUserId() { private String getUserId() {
String userId = ConfigurationManager.getInstance().readString(USER_ID_KEY, null); String userId = ConfigurationManager.getInstance().readString(USER_ID_KEY, null);
if (userId == null) { if (userId == null) {
userId = UUID.randomUUID().toString(); userId = UUID.randomUUID().toString();
ConfigurationManager.getInstance().writeValue(USER_ID_KEY, userId); ConfigurationManager.getInstance().writeValue(USER_ID_KEY, userId);
} }
return userId; return userId;
} }
public String getCurrentAnnouncements(boolean forceLast) throws ParseException { public String getCurrentAnnouncements(boolean forceLast) throws ParseException {
announcements = service.getAnnouncements(getUserId()); announcements = service.getAnnouncements(getUserId());
if (announcements == null) if (announcements == null)
return null; return null;
boolean hasUnread = false; boolean hasUnread = false;
StringBuilder sb = new StringBuilder("<html>"); StringBuilder sb = new StringBuilder("<html>");
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.announcements; package org.diylc.announcements;
import java.util.List; import java.util.List;
import com.diyfever.httpproxy.ParamName; import com.diyfever.httpproxy.ParamName;
public interface IAnnouncementService { public interface IAnnouncementService {
public List<Announcement> getAnnouncements(@ParamName("userId")String userId); public List<Announcement> getAnnouncements(@ParamName("userId")String userId);
} }
@@ -19,8 +19,8 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.clipboard; package org.diylc.clipboard;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
@@ -28,55 +28,56 @@ import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDIYComponent;
/**
* Represents component selection as a {@link List} of {@link IDIYComponent} objects. Implements /**
* {@link Transferable}, so it is suitable for clipboard usage. * Represents component selection as a {@link List} of {@link IDIYComponent} objects. Implements
* * {@link Transferable}, so it is suitable for clipboard usage.
* @author Branislav Stojkovic *
*/ * @author Branislav Stojkovic
public class ComponentTransferable implements Transferable, Serializable { */
public class ComponentTransferable implements Transferable, Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public static final DataFlavor listFlavor = new DataFlavor(ComponentTransferable.class, "application/diylc"); public static final DataFlavor listFlavor = new DataFlavor(ComponentTransferable.class, "application/diylc");
private List<IDIYComponent<?>> components; private List<IDIYComponent<?>> components;
private Set<Set<IDIYComponent<?>>> groups; private Set<Set<IDIYComponent<?>>> groups;
public ComponentTransferable() { public ComponentTransferable() {
super(); super();
} }
public ComponentTransferable(List<IDIYComponent<?>> components) { public ComponentTransferable(List<IDIYComponent<?>> components) {
super(); super();
this.components = components; this.components = components;
this.groups = null; this.groups = null;
} }
public ComponentTransferable(List<IDIYComponent<?>> components, Set<Set<IDIYComponent<?>>> groups) { public ComponentTransferable(List<IDIYComponent<?>> components, Set<Set<IDIYComponent<?>>> groups) {
super(); super();
this.components = components; this.components = components;
this.groups = groups; this.groups = groups;
} }
@Override @Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(listFlavor)) { if (flavor.equals(listFlavor)) {
return this; return this;
} }
throw new UnsupportedFlavorException(flavor); throw new UnsupportedFlavorException(flavor);
} }
@Override @Override
public DataFlavor[] getTransferDataFlavors() { public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] {listFlavor}; return new DataFlavor[] {listFlavor};
} }
@Override @Override
public boolean isDataFlavorSupported(DataFlavor flavor) { public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(listFlavor); return flavor.equals(listFlavor);
} }
public List<IDIYComponent<?>> getComponents() { public List<IDIYComponent<?>> getComponents() {
@@ -85,5 +86,5 @@ public class ComponentTransferable implements Transferable, Serializable {
public Set<Set<IDIYComponent<?>>> getGroups() { public Set<Set<IDIYComponent<?>>> getGroups() {
return groups; return groups;
} }
} }
@@ -25,6 +25,7 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class ComponentTransferableFactory { public class ComponentTransferableFactory {
@@ -19,10 +19,10 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public class BadPositionException extends Exception { public class BadPositionException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
@@ -1,27 +1,28 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.util.Collection; import java.util.Collection;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class BuildingBlock { public class BuildingBlock {
@@ -23,6 +23,7 @@ package org.diylc.common;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class BuildingBlockPackage { public class BuildingBlockPackage {
@@ -20,6 +20,7 @@ package org.diylc.common;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import javax.swing.Icon; import javax.swing.Icon;
import org.diylc.core.CreationMethod; import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.BomPolicy; import org.diylc.core.annotations.BomPolicy;
@@ -5,6 +5,7 @@ import java.awt.geom.Point2D;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.core.Angle; import org.diylc.core.Angle;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.presenter.ComponentProcessor; import org.diylc.presenter.ComponentProcessor;
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum Display { public enum Display {
NAME, VALUE, NONE, BOTH; NAME, VALUE, NONE, BOTH;
@Override @Override
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.awt.Graphics; import java.awt.Graphics;
@@ -56,17 +56,17 @@ public enum DrawOption {
/** /**
* Draw components in outline mode. * Draw components in outline mode.
*/ */
OUTLINE_MODE, OUTLINE_MODE,
/** /**
* Include extra space around the layout. * Include extra space around the layout.
*/ */
EXTRA_SPACE, EXTRA_SPACE,
/** /**
* Whether components should be cached or not. * Whether components should be cached or not.
*/ */
ENABLE_CACHING, ENABLE_CACHING,
/** /**
* Whether locked components should be rendered as transparent or not. * Whether locked components should be rendered as transparent or not.
*/ */
LOCKED_ALPHA; LOCKED_ALPHA;
} }
@@ -1,28 +1,29 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.diylc.core.Project; import org.diylc.core.Project;
/** /**
@@ -84,7 +85,7 @@ public enum EventType {
AVAILABLE_CTRL_POINTS_CHANGED, AVAILABLE_CTRL_POINTS_CHANGED,
/** /**
* Called when mouse cursor is moved. Point object is passed, containing the current cursor * Called when mouse cursor is moved. Point object is passed, containing the current cursor
* location (not taking zoom into account) in pixels and two {@link Point2D} objects with coordinates in * location (not taking zoom into account) in pixels and two {@link Point2D} objects with coordinates in
* inches and mm * inches and mm
*/ */
MOUSE_MOVED, MOUSE_MOVED,
@@ -101,9 +102,9 @@ public enum EventType {
/** /**
* Called to update the status message. New status message is passed as a first parameter. * Called to update the status message. New status message is passed as a first parameter.
*/ */
STATUS_MESSAGE_CHANGED, STATUS_MESSAGE_CHANGED,
/** /**
* Signals the listeners to scroll to selection. * Signals the listeners to scroll to selection.
*/ */
SCROLL_TO; SCROLL_TO;
} }
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum GridType { public enum GridType {
LINES, CROSSHAIR, DOT, NONE; LINES, CROSSHAIR, DOT, NONE;
} }
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum HorizontalAlignment { public enum HorizontalAlignment {
LEFT, CENTER, RIGHT; LEFT, CENTER, RIGHT;
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
@@ -19,32 +19,32 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.io.IOException; import java.io.IOException;
public interface IBlockProcessor { public interface IBlockProcessor {
public static final String BLOCKS_KEY = "buildingBlocks"; public static final String BLOCKS_KEY = "buildingBlocks";
public static final String DEFAULT_BLOCKS_IMPORTED_KEY = "defaultBlocksImported"; public static final String DEFAULT_BLOCKS_IMPORTED_KEY = "defaultBlocksImported";
void saveSelectionAsBlock(String blockName); void saveSelectionAsBlock(String blockName);
void loadBlock(String blockName) throws InvalidBlockException; void loadBlock(String blockName) throws InvalidBlockException;
void deleteBlock(String blockName); void deleteBlock(String blockName);
int importBlocks(String fileName) throws IOException; int importBlocks(String fileName) throws IOException;
public class BlockAlreadyExistsException extends Exception { public class BlockAlreadyExistsException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
public class InvalidBlockException extends Exception { public class InvalidBlockException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
} }
@@ -19,11 +19,11 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public interface IComponentFilter { public interface IComponentFilter {
boolean testComponent(IDIYComponent<?> component); boolean testComponent(IDIYComponent<?> component);
} }
@@ -19,26 +19,27 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDIYComponent;
public interface IComponentTransformer {
public interface IComponentTransformer {
public static final int CLOCKWISE = 1;
public static final int COUNTER_CLOCKWISE = 1; public static final int CLOCKWISE = 1;
public static final int COUNTER_CLOCKWISE = 1;
public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1; public static final int HORIZONTAL = 0;
public static final int VERTICAL = 1;
boolean canRotate(IDIYComponent<?> component);
boolean canRotate(IDIYComponent<?> component);
boolean canMirror(IDIYComponent<?> component);
boolean canMirror(IDIYComponent<?> component);
boolean mirroringChangesCircuit();
boolean mirroringChangesCircuit();
void rotate(IDIYComponent<?> component, Point2D center, int direction);
void rotate(IDIYComponent<?> component, Point2D center, int direction);
void mirror(IDIYComponent<?> component, Point2D center, int direction);
} void mirror(IDIYComponent<?> component, Point2D center, int direction);
}
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public interface IKeyProcessor { public interface IKeyProcessor {
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.awt.Point; import java.awt.Point;
@@ -22,6 +22,7 @@
package org.diylc.common; package org.diylc.common;
import java.util.List; import java.util.List;
import org.diylc.netlist.Netlist; import org.diylc.netlist.Netlist;
import org.diylc.netlist.Node; import org.diylc.netlist.Node;
import org.diylc.netlist.Summary; import org.diylc.netlist.Summary;
@@ -22,6 +22,7 @@
package org.diylc.common; package org.diylc.common;
import java.util.List; import java.util.List;
import org.diylc.netlist.INetlistParser; import org.diylc.netlist.INetlistParser;
import org.diylc.netlist.Netlist; import org.diylc.netlist.Netlist;
import org.diylc.netlist.NetlistException; import org.diylc.netlist.NetlistException;
@@ -19,22 +19,22 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import org.diylc.appframework.simplemq.IMessageListener; import org.diylc.appframework.simplemq.IMessageListener;
/** /**
* Interface for plug-ins. * Interface for plug-ins.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public interface IPlugIn extends IMessageListener<EventType> { public interface IPlugIn extends IMessageListener<EventType> {
/** /**
* Method that connects the plug-in with {@link IPlugInPort}. Called by the application when * Method that connects the plug-in with {@link IPlugInPort}. Called by the application when
* plug-in is installed. * plug-in is installed.
* *
* @param plugInPort * @param plugInPort
*/ */
void connect(IPlugInPort plugInPort); void connect(IPlugInPort plugInPort);
} }
@@ -1,47 +1,48 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.diylc.appframework.simplemq.IMessageListener; import org.diylc.appframework.simplemq.IMessageListener;
import org.diylc.appframework.simplemq.MessageDispatcher; import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.appframework.update.Version; import org.diylc.appframework.update.Version;
import org.diylc.appframework.update.VersionNumber; import org.diylc.appframework.update.VersionNumber;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.IDIYComponent; import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.Project; import org.diylc.core.IDIYComponent;
import org.diylc.core.Template; import org.diylc.core.Project;
import org.diylc.core.Theme; import org.diylc.core.Template;
import org.diylc.core.measures.Size; import org.diylc.core.Theme;
import org.diylc.test.ITestProcessor; import org.diylc.core.measures.Size;
import org.diylc.test.ITestProcessor;
/** /**
* Interface for communication between plug-ins and the application. Plug-ins may acquire * Interface for communication between plug-ins and the application. Plug-ins may acquire
@@ -63,7 +64,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
public static final String EXPORT_GRID_KEY = "exportGrid"; public static final String EXPORT_GRID_KEY = "exportGrid";
public static final String STICKY_POINTS_KEY = "stickyPoints"; public static final String STICKY_POINTS_KEY = "stickyPoints";
public static final String METRIC_KEY = "metric"; public static final String METRIC_KEY = "metric";
public static final String SNAP_TO_KEY = "snapTo"; public static final String SNAP_TO_KEY = "snapTo";
public static final String CONTINUOUS_CREATION_KEY = "continuousCreation"; public static final String CONTINUOUS_CREATION_KEY = "continuousCreation";
public static final String AUTO_EDIT_KEY = "autoEdit"; public static final String AUTO_EDIT_KEY = "autoEdit";
@@ -75,27 +76,27 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
public static final String RECENT_COMPONENTS_KEY = "recentComponents"; public static final String RECENT_COMPONENTS_KEY = "recentComponents";
public static final String RECENT_FILES_KEY = "recentFiles"; public static final String RECENT_FILES_KEY = "recentFiles";
public static final String SHOW_RULERS_KEY = "showRulers"; public static final String SHOW_RULERS_KEY = "showRulers";
public static final String SHOW_GRID_KEY = "showGrid"; public static final String SHOW_GRID_KEY = "showGrid";
public static final String HIGHLIGHT_CONTINUITY_AREA = "highlightContinuityArea"; public static final String HIGHLIGHT_CONTINUITY_AREA = "highlightContinuityArea";
public static final String HARDWARE_ACCELERATION = "hardwareAcceleration"; public static final String HARDWARE_ACCELERATION = "hardwareAcceleration";
public static final String EXTRA_SPACE_KEY = "extraSpace"; public static final String EXTRA_SPACE_KEY = "extraSpace";
public static final String FAVORITES_KEY = "favorites"; public static final String FAVORITES_KEY = "favorites";
public static final String RENUMBER_ON_PASTE_KEY = "renumberOnPaste"; public static final String RENUMBER_ON_PASTE_KEY = "renumberOnPaste";
public static final String RULER_IN_SUBDIVISION_KEY = "rulerInSubdivision"; public static final String RULER_IN_SUBDIVISION_KEY = "rulerInSubdivision";
public static final String CACHING_ENABLED_KEY = "cachingEnabled"; public static final String CACHING_ENABLED_KEY = "cachingEnabled";
public static final String RULER_IN_SUBDIVISION_2 = "base of 2"; public static final String RULER_IN_SUBDIVISION_2 = "base of 2";
public static final String RULER_IN_SUBDIVISION_10 = "base of 10"; public static final String RULER_IN_SUBDIVISION_10 = "base of 10";
public static final String RULER_IN_SUBDIVISION_DEFAULT = RULER_IN_SUBDIVISION_10; public static final String RULER_IN_SUBDIVISION_DEFAULT = RULER_IN_SUBDIVISION_10;
public static final String SNAP_TO_NONE = "None"; public static final String SNAP_TO_NONE = "None";
public static final String SNAP_TO_GRID = "Grid"; public static final String SNAP_TO_GRID = "Grid";
public static final String SNAP_TO_COMPONENTS = "Components"; public static final String SNAP_TO_COMPONENTS = "Components";
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID; public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
public static final String LOCKED_ALPHA = "lockedAlpha"; public static final String LOCKED_ALPHA = "lockedAlpha";
public static final String LANGUAGE = "language"; public static final String LANGUAGE = "language";
public static final String LANGUAGE_DEFAULT = "English"; public static final String LANGUAGE_DEFAULT = "English";
public static final int DND_TOGGLE_STICKY = 0x1; public static final int DND_TOGGLE_STICKY = 0x1;
@@ -114,7 +115,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* Each dimension is calculated as the product of the actual size and the number of pixels per * Each dimension is calculated as the product of the actual size and the number of pixels per
* unit. If <code>useZoom</code> is set to true, the result is scaled by zoom factor. * unit. If <code>useZoom</code> is set to true, the result is scaled by zoom factor.
* *
* @param useZoom * @param useZoom
* @param includeExtraSpace * @param includeExtraSpace
* *
* @return canvas dimensions * @return canvas dimensions
@@ -126,9 +127,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* *
* Note: point coordinates are scaled for zoom factor. * Note: point coordinates are scaled for zoom factor.
* *
* @param point * @param point
* @param ctrlDown * @param ctrlDown
* @param shiftDown * @param shiftDown
* @param altDown * @param altDown
* @return cursor * @return cursor
*/ */
@@ -145,7 +146,7 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* Loads specified {@link Project}. * Loads specified {@link Project}.
* *
* @param project * @param project
* @param freshStart * @param freshStart
* @param optional file name when loading from a file * @param optional file name when loading from a file
*/ */
void loadProject(Project project, boolean freshStart, String filename); void loadProject(Project project, boolean freshStart, String filename);
@@ -168,14 +169,14 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* @param fileName * @param fileName
* @param isBackup * @param isBackup
*/ */
void saveProjectToFile(String fileName, boolean isBackup); void saveProjectToFile(String fileName, boolean isBackup);
/** /**
* Exports the current project into one or more files - one per layer and potentially drill layer. * Exports the current project into one or more files - one per layer and potentially drill layer.
* *
* @param fileNameBase * @param fileNameBase
* @param g2d * @param g2d
*/ */
void exportToGerber(String fileNameBase, Graphics2D g2d); void exportToGerber(String fileNameBase, Graphics2D g2d);
/** /**
@@ -210,9 +211,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* *
* @param g2d * @param g2d
* @param drawOptions specific drawing options * @param drawOptions specific drawing options
* @param filter * @param filter
* @param externalZoom * @param externalZoom
* @param scaleFactor * @param scaleFactor
* @param visibleRect * @param visibleRect
*/ */
void draw(Graphics2D g2d, Set<DrawOption> drawOptions, IComponentFilter filter, Double externalZoom, Double scaleFactor, Rectangle2D visibleRect); void draw(Graphics2D g2d, Set<DrawOption> drawOptions, IComponentFilter filter, Double externalZoom, Double scaleFactor, Rectangle2D visibleRect);
@@ -238,20 +239,20 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* *
* @return * @return
*/ */
VersionNumber getCurrentVersionNumber(); VersionNumber getCurrentVersionNumber();
/** /**
* Returns few most recent versions. * Returns few most recent versions.
* *
* @return * @return
*/ */
List<Version> getRecentUpdates(); List<Version> getRecentUpdates();
/** /**
* Adds a list of components to the project. * Adds a list of components to the project.
* *
* @param componentTransferable * @param componentTransferable
* @param autoGroup * @param autoGroup
* @param assignNewNames * @param assignNewNames
*/ */
void pasteComponents(ComponentTransferable componentTransferable, boolean autoGroup, boolean assignNewNames); void pasteComponents(ComponentTransferable componentTransferable, boolean autoGroup, boolean assignNewNames);
@@ -317,8 +318,8 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* component. * component.
* *
* @param componentType * @param componentType
* @param template optional * @param template optional
* @param model optional datasheet model * @param model optional datasheet model
* @param forceInstatiate * @param forceInstatiate
*/ */
void setNewComponentTypeSlot(ComponentType componentType, Template template, String[] model, boolean forceInstatiate); void setNewComponentTypeSlot(ComponentType componentType, Template template, String[] model, boolean forceInstatiate);
@@ -373,29 +374,29 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* *
* @param xAxisFirst * @param xAxisFirst
*/ */
void renumberSelectedComponents(boolean xAxisFirst); void renumberSelectedComponents(boolean xAxisFirst);
/** /**
* @return size of extra space around the canvas * @return size of extra space around the canvas
*/ */
double getExtraSpace(); double getExtraSpace();
/** /**
* Applies changes to the current project as specified by the provided {@link IProjectEditor}. * Applies changes to the current project as specified by the provided {@link IProjectEditor}.
* *
* @param editor * @param editor
*/ */
void applyEditor(IProjectEditor editor); void applyEditor(IProjectEditor editor);
/** /**
* Locks or unlocks a single component. * Locks or unlocks a single component.
*/ */
void lockComponent(IDIYComponent<?> c, boolean locked); void lockComponent(IDIYComponent<?> c, boolean locked);
/** /**
* Checks for proximity between continuity areas and creates additional components around any problematic areas to visually identify them. * Checks for proximity between continuity areas and creates additional components around any problematic areas to visually identify them.
* *
* @param threshold * @param threshold
*/ */
List<Area> checkContinuityAreaProximity(Size threshold); List<Area> checkContinuityAreaProximity(Size threshold);
} }
@@ -22,6 +22,7 @@
package org.diylc.common; package org.diylc.common;
import java.util.Set; import java.util.Set;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
@@ -1,33 +1,34 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.ExpansionMode; import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.IDIYComponent; import org.diylc.core.ExpansionMode;
import org.diylc.core.IDIYComponent;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
public interface ISelectionProcessor { public interface ISelectionProcessor {
@@ -37,20 +38,20 @@ public interface ISelectionProcessor {
* *
* @return * @return
*/ */
Collection<IDIYComponent<?>> getSelectedComponents(); Collection<IDIYComponent<?>> getSelectedComponents();
/** /**
* Returns selected component types * Returns selected component types
* *
* @return * @return
*/ */
Collection<ComponentType> getSelectedComponentTypes(); Collection<ComponentType> getSelectedComponentTypes();
/** /**
* Updates the selection with the specified list of component. Also, updates control point map * Updates the selection with the specified list of component. Also, updates control point map
* with all components that are stuck to the newly selected components. * with all components that are stuck to the newly selected components.
* *
* @param newSelection * @param newSelection
* @param panToSelection * @param panToSelection
*/ */
void setSelection(Collection<IDIYComponent<?>> newSelection, boolean panToSelection); void setSelection(Collection<IDIYComponent<?>> newSelection, boolean panToSelection);
@@ -59,7 +60,7 @@ public interface ISelectionProcessor {
* Finds all components at the specified location, sorted by z-index from top to bottom. Location * Finds all components at the specified location, sorted by z-index from top to bottom. Location
* depends on the current zoom level. * depends on the current zoom level.
* *
* @param point * @param point
* @param includeLocked * @param includeLocked
* @return * @return
*/ */
@@ -108,8 +109,8 @@ public interface ISelectionProcessor {
/** /**
* Returns the minimum rectangle containing all selected components, or null if none exists. * Returns the minimum rectangle containing all selected components, or null if none exists.
* Rectangle is scaled by the current zoom level. * Rectangle is scaled by the current zoom level.
* *
* @param applyZoom * @param applyZoom
* *
* @return * @return
*/ */
@@ -122,36 +123,36 @@ public interface ISelectionProcessor {
* @param yOffset * @param yOffset
* @param includeStuckComponents * @param includeStuckComponents
*/ */
void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents); void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents);
/** /**
* Selects components that match the criteria. * Selects components that match the criteria.
* *
* @param criteria * @param criteria
*/ */
void selectMatching(String criteria); void selectMatching(String criteria);
/** /**
* Attempts to apply the specified model to all selected components. * Attempts to apply the specified model to all selected components.
* *
* @param model * @param model
*/ */
void applyModelToSelection(String[] model); void applyModelToSelection(String[] model);
/** /**
* Sends each of the selected components one step back. * Sends each of the selected components one step back.
*/ */
void sendSelectionToBack(); void sendSelectionToBack();
/** /**
* Brings each of the selected components one step to front. * Brings each of the selected components one step to front.
*/ */
void bringSelectionToFront(); void bringSelectionToFront();
/** /**
* Move selected components to z index starting from the provided value * Move selected components to z index starting from the provided value
* @param zIndex * @param zIndex
*/ */
void moveSelectionToZIndex(int zIndex); void moveSelectionToZIndex(int zIndex);
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
/** /**
@@ -19,37 +19,38 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import org.diylc.core.Template; import org.diylc.core.Template;
public interface IVariantProcessor { public interface IVariantProcessor {
public static final String TEMPLATES_KEY = "templates"; public static final String TEMPLATES_KEY = "templates";
public static final String DEFAULT_TEMPLATES_KEY = "defaultTemplates"; public static final String DEFAULT_TEMPLATES_KEY = "defaultTemplates";
public static final String DEFAULT_TEMPLATES_IMPORT_DATE_KEY = "defaultTemplatesImportDate"; public static final String DEFAULT_TEMPLATES_IMPORT_DATE_KEY = "defaultTemplatesImportDate";
void saveSelectedComponentAsVariant(String variantName); void saveSelectedComponentAsVariant(String variantName);
List<Template> getVariantsFor(ComponentType type); List<Template> getVariantsFor(ComponentType type);
List<Template> getVariantsForSelection(); List<Template> getVariantsForSelection();
void applyVariantToSelection(Template variant); void applyVariantToSelection(Template variant);
void deleteVariant(ComponentType type, String variantName); void deleteVariant(ComponentType type, String variantName);
void setDefaultVariant(ComponentType type, String variantName); void setDefaultVariant(ComponentType type, String variantName);
int importVariants(String fileName) throws IOException; int importVariants(String fileName) throws IOException;
String getDefaultVariant(ComponentType type); String getDefaultVariant(ComponentType type);
public class VariantAlreadyExistsException extends Exception { public class VariantAlreadyExistsException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
} }
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum LabelPosition { public enum LabelPosition {
ABOVE, BELOW; ABOVE, BELOW;
@Override @Override
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum LineStyle { public enum LineStyle {
SOLID, DASHED, DOTTED; SOLID, DASHED, DOTTED;
@Override @Override
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
@@ -19,19 +19,19 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum Orientation { public enum Orientation {
DEFAULT, _90, _180, _270; DEFAULT, _90, _180, _270;
@Override @Override
public String toString() { public String toString() {
if (this == DEFAULT) { if (this == DEFAULT) {
return "Default"; return "Default";
} else { } else {
return name().replace("_", "") + " degrees clockwise"; return name().replace("_", "") + " degrees clockwise";
} }
} }
public double toDegrees() { public double toDegrees() {
@@ -52,5 +52,5 @@ public enum Orientation {
public double toRadians() { public double toRadians() {
return Math.toRadians(toDegrees()); return Math.toRadians(toDegrees());
} }
} }
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum OrientationHV { public enum OrientationHV {
VERTICAL, HORIZONTAL; VERTICAL, HORIZONTAL;
@Override @Override
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
@@ -23,18 +23,18 @@ package org.diylc.common;
import org.diylc.core.gerber.GerberLayer; import org.diylc.core.gerber.GerberLayer;
public enum PCBLayer { public enum PCBLayer {
_1("Bottom"), _2("Top"), _3("Inner 1"), _4("Inner 2"), _5("Inner 3"), _6("Inner 4"), _7("Inner 5"), _8("Inner 6"); _1("Bottom"), _2("Top"), _3("Inner 1"), _4("Inner 2"), _5("Inner 3"), _6("Inner 4"), _7("Inner 5"), _8("Inner 6");
private String label; private String label;
private PCBLayer(String label) { private PCBLayer(String label) {
this.label = label; this.label = label;
} }
public String toString() { public String toString() {
return label; return label;
}; };
public int getId() { public int getId() {
@@ -48,5 +48,5 @@ public enum PCBLayer {
default: default:
throw new RuntimeException("Unsupported PCB layer: " + this); throw new RuntimeException("Unsupported PCB layer: " + this);
} }
} }
} }
@@ -1,28 +1,29 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.diylc.core.IPropertyValidator; import org.diylc.core.IPropertyValidator;
/** /**
@@ -74,19 +75,19 @@ public class PropertyWrapper implements Cloneable {
// } // }
public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException, public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException, SecurityException, NoSuchMethodException { InvocationTargetException, SecurityException, NoSuchMethodException {
// nothing to do if no setter // nothing to do if no setter
if (setter == null) if (setter == null)
return; return;
object.getClass().getMethod(setter, type).invoke(object, this.value); object.getClass().getMethod(setter, type).invoke(object, this.value);
} }
public Method getGetter() throws SecurityException, NoSuchMethodException { public Method getGetter() throws SecurityException, NoSuchMethodException {
return getOwnerObject().getClass().getMethod(getter); return getOwnerObject().getClass().getMethod(getter);
} }
public boolean isReadOnly() { public boolean isReadOnly() {
return setter == null; return setter == null;
} }
public String getName() { public String getName() {
@@ -19,17 +19,17 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum ResistorColorCode { public enum ResistorColorCode {
NONE, _4_BAND, _5_BAND; NONE, _4_BAND, _5_BAND;
@Override @Override
public String toString() { public String toString() {
if (name().startsWith("_")) { if (name().startsWith("_")) {
return name().substring(1).replace("_", " ").toLowerCase(); return name().substring(1).replace("_", " ").toLowerCase();
} }
return name().substring(0, 1).toUpperCase() + name().substring(1).toLowerCase(); return name().substring(0, 1).toUpperCase() + name().substring(1).toLowerCase();
} }
} }
@@ -23,6 +23,7 @@ package org.diylc.common;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.diylc.core.Template; import org.diylc.core.Template;
public class VariantPackage { public class VariantPackage {
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.common; package org.diylc.common;
public enum VerticalAlignment { public enum VerticalAlignment {
TOP, CENTER, BOTTOM; TOP, CENTER, BOTTOM;
public String toString() { public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); return name().substring(0, 1) + name().substring(1).toLowerCase();
} }
} }
@@ -22,6 +22,7 @@
package org.diylc.components; package org.diylc.components;
import java.awt.Shape; import java.awt.Shape;
import org.diylc.common.Orientation; import org.diylc.common.Orientation;
import org.diylc.core.Angle; import org.diylc.core.Angle;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
@@ -1,40 +1,41 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components; package org.diylc.components;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Shape; import java.awt.Shape;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.Project;
import org.diylc.core.measures.Size; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
/** /**
* Abstract implementation of {@link IDIYComponent} that contains component name and toString. * Abstract implementation of {@link IDIYComponent} that contains component name and toString.
@@ -57,14 +58,14 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
public static Color LABEL_COLOR = Color.black; public static Color LABEL_COLOR = Color.black;
public static Color LABEL_COLOR_SELECTED = Color.red; public static Color LABEL_COLOR_SELECTED = Color.red;
public static Font LABEL_FONT = new Font("Square721 BT", Font.PLAIN, 14); public static Font LABEL_FONT = new Font("Square721 BT", Font.PLAIN, 14);
public static Color METAL_COLOR = Color.decode("#759DAF"); public static Color METAL_COLOR = Color.decode("#759DAF");
public static Color LIGHT_METAL_COLOR = Color.decode("#EEEEEE"); public static Color LIGHT_METAL_COLOR = Color.decode("#EEEEEE");
public static Color COPPER_COLOR = Color.decode("#DA8A67"); public static Color COPPER_COLOR = Color.decode("#DA8A67");
public static Color GOLD_COLOR = Color.decode("#F4B301"); public static Color GOLD_COLOR = Color.decode("#F4B301");
public static Color FR4_COLOR = Color.decode("#6B9B6B"); public static Color FR4_COLOR = Color.decode("#6B9B6B");
public static Color FR4_LIGHT_COLOR = Color.decode("#BABE71"); public static Color FR4_LIGHT_COLOR = Color.decode("#BABE71");
public static Color PHENOLIC_COLOR = Color.decode("#F8EBB3"); public static Color PHENOLIC_COLOR = Color.decode("#F8EBB3");
public static Color PHENOLIC_DARK_COLOR = Color.decode("#CD8500"); public static Color PHENOLIC_DARK_COLOR = Color.decode("#CD8500");
@EditableProperty(defaultable = false) @EditableProperty(defaultable = false)
@Override @Override
@@ -88,13 +89,13 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
} }
@Override @Override
public String getValueForDisplay() { public String getValueForDisplay() {
if (getValue() == null) if (getValue() == null)
return ""; return "";
Object val = getValue(); Object val = getValue();
if (val.getClass().isArray()) { if (val.getClass().isArray()) {
return String.join(" / ", Arrays.stream((Object[])val).map(x -> x == null ? "" : x.toString()).collect(Collectors.toList())); return String.join(" / ", Arrays.stream((Object[])val).map(x -> x == null ? "" : x.toString()).collect(Collectors.toList()));
} }
return val.toString(); return val.toString();
} }
@@ -107,17 +108,17 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
*/ */
protected int getClosestOdd(double x) { protected int getClosestOdd(double x) {
return ((int) x / 2) * 2 + 1; return ((int) x / 2) * 2 + 1;
} }
/** /**
* Returns the closest odd number, i.e. x when x is odd, or x + 1 when x is even. * Returns the closest odd number, i.e. x when x is odd, or x + 1 when x is even.
* *
* @param x * @param x
* @return * @return
*/ */
protected int getClosestOdd(Size s) { protected int getClosestOdd(Size s) {
double x = s.convertToPixels(); double x = s.convertToPixels();
return ((int) x / 2) * 2 + 1; return ((int) x / 2) * 2 + 1;
} }
/** /**
@@ -136,9 +137,9 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
* @param clip * @param clip
* @return true if none of the control points lie in the clip rectangle. * @return true if none of the control points lie in the clip rectangle.
*/ */
protected boolean checkPointsClipped(Shape clip) { protected boolean checkPointsClipped(Shape clip) {
if (clip == null) { if (clip == null) {
return false; return false;
} }
for (int i = 0; i < getControlPointCount(); i++) { for (int i = 0; i < getControlPointCount(); i++) {
if (clip.contains(getControlPoint(i))) { if (clip.contains(getControlPoint(i))) {
@@ -171,7 +172,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public IDIYComponent<T> clone() throws CloneNotSupportedException { public IDIYComponent<T> clone() throws CloneNotSupportedException {
try { try {
// Instantiate object of the same type // Instantiate object of the same type
Class<?> clazz = this.getClass(); Class<?> clazz = this.getClass();
AbstractComponent<T> newInstance = (AbstractComponent<T>) clazz.getDeclaredConstructor().newInstance(); AbstractComponent<T> newInstance = (AbstractComponent<T>) clazz.getDeclaredConstructor().newInstance();
while (AbstractComponent.class.isAssignableFrom(clazz)) { while (AbstractComponent.class.isAssignableFrom(clazz)) {
@@ -191,7 +192,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
&& value.getClass().getComponentType().isAssignableFrom(Point2D.class)) { && value.getClass().getComponentType().isAssignableFrom(Point2D.class)) {
Object newArray = Array.newInstance(value.getClass().getComponentType(), Array.getLength(value)); Object newArray = Array.newInstance(value.getClass().getComponentType(), Array.getLength(value));
for (int i = 0; i < Array.getLength(value); i++) { for (int i = 0; i < Array.getLength(value); i++) {
Point2D p = (Point2D) Array.get(value, i); Point2D p = (Point2D) Array.get(value, i);
if (p != null) if (p != null)
Array.set(newArray, i, new Point2D.Double(p.getX(), p.getY())); Array.set(newArray, i, new Point2D.Double(p.getX(), p.getY()));
} }
@@ -199,7 +200,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
} }
// Deep copy points. // Deep copy points.
// TODO: something nicer // TODO: something nicer
if (value != null && value instanceof Point2D) { if (value != null && value instanceof Point2D) {
Point2D p = (Point2D) value; Point2D p = (Point2D) value;
value = new Point2D.Double(p.getX(), p.getY()); value = new Point2D.Double(p.getX(), p.getY());
} }
@@ -212,7 +213,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
} catch (Exception e) { } catch (Exception e) {
throw new CloneNotSupportedException("Could not clone the component. Reason: " + e.getMessage()); throw new CloneNotSupportedException("Could not clone the component. Reason: " + e.getMessage());
} }
} }
@Override @Override
public boolean equalsTo(IDIYComponent<?> other) { public boolean equalsTo(IDIYComponent<?> other) {
@@ -229,7 +230,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
// in // in
// AbstractComponent or one of it's child classes // AbstractComponent or one of it's child classes
for (Field field : fields) { for (Field field : fields) {
if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isFinal(field.getModifiers()) && if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isFinal(field.getModifiers()) &&
!Modifier.isTransient(field.getModifiers())) { !Modifier.isTransient(field.getModifiers())) {
field.setAccessible(true); field.setAccessible(true);
try { try {
@@ -251,45 +252,45 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
return true; return true;
if (o1 == null || o2 == null) if (o1 == null || o2 == null)
return false; return false;
if (o1.getClass().isArray()) { if (o1.getClass().isArray()) {
if (o1.getClass().getComponentType() == byte.class) if (o1.getClass().getComponentType() == byte.class)
return Arrays.equals((byte[]) o1, (byte[]) o2); return Arrays.equals((byte[]) o1, (byte[]) o2);
if (o1.getClass().getComponentType() == double.class) if (o1.getClass().getComponentType() == double.class)
return Arrays.equals((double[]) o1, (double[]) o2); return Arrays.equals((double[]) o1, (double[]) o2);
if (o1.getClass().getComponentType() == int.class) if (o1.getClass().getComponentType() == int.class)
return Arrays.equals((int[]) o1, (int[]) o2); return Arrays.equals((int[]) o1, (int[]) o2);
return Arrays.equals((Object[]) o1, (Object[]) o2); return Arrays.equals((Object[]) o1, (Object[]) o2);
} }
return o1.equals(o2); return o1.equals(o2);
} }
@Override @Override
public String getControlPointNodeName(int index) { public String getControlPointNodeName(int index) {
return Integer.toString(index + 1); return Integer.toString(index + 1);
} }
@Override @Override
public String getInternalLinkName(int index1, int index2) { public String getInternalLinkName(int index1, int index2) {
return null; return null;
} }
@Override @Override
public String[] getSectionNames(int pointIndex) { public String[] getSectionNames(int pointIndex) {
return null; return null;
} }
@Override @Override
public boolean canPointMoveFreely(int pointIndex) { public boolean canPointMoveFreely(int pointIndex) {
return true; return true;
} }
@Override @Override
public Rectangle2D getCachingBounds() { public Rectangle2D getCachingBounds() {
return null; return null;
} }
@Override @Override
public void createdIn(Project project) { public void createdIn(Project project) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }
@@ -30,6 +30,10 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import com.google.common.collect.Streams;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.LineStyle; import org.diylc.common.LineStyle;
import org.diylc.common.ObjectCache; import org.diylc.common.ObjectCache;
@@ -41,8 +45,6 @@ import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants; import org.diylc.utils.Constants;
import com.google.common.collect.Streams;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComponent<T> { public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComponent<T> {
@@ -19,13 +19,13 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components; package org.diylc.components;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractLabeledComponent<T> extends AbstractTransparentComponent<T> { public abstract class AbstractLabeledComponent<T> extends AbstractTransparentComponent<T> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected Integer fontSizeOverride; protected Integer fontSizeOverride;
@@ -36,5 +36,5 @@ public abstract class AbstractLabeledComponent<T> extends AbstractTransparentCom
public void setFontSizeOverride(Integer fontSizeOverride) { public void setFontSizeOverride(Integer fontSizeOverride) {
this.fontSizeOverride = fontSizeOverride; this.fontSizeOverride = fontSizeOverride;
} }
} }
@@ -19,24 +19,24 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components; package org.diylc.components;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> { public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static byte MAX_ALPHA = 127; public static byte MAX_ALPHA = 127;
protected byte alpha = MAX_ALPHA; protected byte alpha = MAX_ALPHA;
@EditableProperty @EditableProperty
public Byte getAlpha() { public Byte getAlpha() {
return alpha; return alpha;
} }
public void setAlpha(Byte alpha) { public void setAlpha(Byte alpha) {
this.alpha = alpha; this.alpha = alpha;
} }
} }
@@ -1,28 +1,29 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.transform; package org.diylc.components.transform;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class DefaultTransformer implements IComponentTransformer { public class DefaultTransformer implements IComponentTransformer {
@@ -1,29 +1,30 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.transform; package org.diylc.components.transform;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class LeadedComponentTransformer implements IComponentTransformer { public class LeadedComponentTransformer implements IComponentTransformer {
@@ -46,7 +47,7 @@ public class LeadedComponentTransformer implements IComponentTransformer {
@Override @Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) { public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY()); AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY());
for (int index = 0; index < component.getControlPointCount(); index++) { for (int index = 0; index < component.getControlPointCount(); index++) {
Point2D p = new Point2D.Double(); Point2D p = new Point2D.Double();
rotate.transform(component.getControlPoint(index), p); rotate.transform(component.getControlPoint(index), p);
component.setControlPoint(p, index); component.setControlPoint(p, index);
@@ -1,30 +1,31 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.components.transform; package org.diylc.components.transform;
import java.awt.Point; import java.awt.Point;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
public class SimpleComponentTransformer implements IComponentTransformer { public class SimpleComponentTransformer implements IComponentTransformer {
@@ -19,15 +19,15 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
/** /**
* Validator that allows all values. * Validator that allows all values.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public class AllowAllValidator implements IPropertyValidator { public class AllowAllValidator implements IPropertyValidator {
@Override @Override
public void validate(Object owner, Object value) throws ValidationException {} public void validate(Object owner, Object value) throws ValidationException {}
} }
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
/** /**
* Enumerates all possible states that a component can be in. * Enumerates all possible states that a component can be in.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public enum ComponentState { public enum ComponentState {
NORMAL, SELECTED, LOCKED, DRAGGING NORMAL, SELECTED, LOCKED, DRAGGING
} }
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
public enum CreationMethod { public enum CreationMethod {
SINGLE_CLICK, POINT_BY_POINT; SINGLE_CLICK, POINT_BY_POINT;
} }
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
public enum ExpansionMode { public enum ExpansionMode {
ALL, SAME_TYPE, IMMEDIATE, ALL, SAME_TYPE, IMMEDIATE,
} }
@@ -1,31 +1,32 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.io.Serializable; import java.io.Serializable;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
/** /**
@@ -50,7 +51,7 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
public static final int CHASSIS = 1; public static final int CHASSIS = 1;
public static final int BOARD = 2; public static final int BOARD = 2;
public static final int TRACE = 3; public static final int TRACE = 3;
public static final int COMPONENT = 4; public static final int COMPONENT = 4;
public static final int WIRING = 5; public static final int WIRING = 5;
public static final int TEXT = 6; public static final int TEXT = 6;
@@ -111,37 +112,37 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
* same component</b>. The other control point must be able to overlap too. * same component</b>. The other control point must be able to overlap too.
*/ */
boolean canControlPointOverlap(int index); boolean canControlPointOverlap(int index);
/** /**
* @param index * @param index
* @return {@link VisibilityPolicy} of the control point. * @return {@link VisibilityPolicy} of the control point.
*/
VisibilityPolicy getControlPointVisibilityPolicy(int index);
/**
* @param index
* @return name of the control point node, if the control point represents a graph node, null otherwise.
*/
String getControlPointNodeName(int index);
/**
* @param index1
* @param index2
* @return name of the internal linked formed by the two control points, null if they do not form an internal link
*/
String getInternalLinkName(int index1, int index2);
/**
* @param pointIndex
* @return name of the internal section containing the specified point, or null if the component does not have internal sections.
* One point can be shared between multiple sections, in which case, the result may contain more than one element.
*/
String[] getSectionNames(int pointIndex);
/**
* @param pointIndex
* @return true if the control point can move without affecting other points' position, false otherwise
*/ */
VisibilityPolicy getControlPointVisibilityPolicy(int index);
/**
* @param index
* @return name of the control point node, if the control point represents a graph node, null otherwise.
*/
String getControlPointNodeName(int index);
/**
* @param index1
* @param index2
* @return name of the internal linked formed by the two control points, null if they do not form an internal link
*/
String getInternalLinkName(int index1, int index2);
/**
* @param pointIndex
* @return name of the internal section containing the specified point, or null if the component does not have internal sections.
* One point can be shared between multiple sections, in which case, the result may contain more than one element.
*/
String[] getSectionNames(int pointIndex);
/**
* @param pointIndex
* @return true if the control point can move without affecting other points' position, false otherwise
*/
boolean canPointMoveFreely(int pointIndex); boolean canPointMoveFreely(int pointIndex);
/** /**
@@ -184,18 +185,18 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
* @param other * @param other
* @return * @return
*/ */
boolean equalsTo(IDIYComponent<?> other); boolean equalsTo(IDIYComponent<?> other);
/** /**
* Used only if {@link ComponentDescriptor#enableCache()} is set to true. * Used only if {@link ComponentDescriptor#enableCache()} is set to true.
* @return * @return
*/ */
Rectangle2D getCachingBounds(); Rectangle2D getCachingBounds();
/** /**
* Notifies the component that it's being created in the context of the specified project * Notifies the component that it's being created in the context of the specified project
* *
* @param project * @param project
*/ */
void createdIn(Project project); void createdIn(Project project);
} }
@@ -21,22 +21,22 @@
*/ */
package org.diylc.core; package org.diylc.core;
/** /**
* Interface for tracking component drawing process. Components may use it to stop or restart * Interface for tracking component drawing process. Components may use it to stop or restart
* tracking. Anything drawn while tracking is stopped will not be added to the mouse hot-spot area. * tracking. Anything drawn while tracking is stopped will not be added to the mouse hot-spot area.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public interface IDrawingObserver { public interface IDrawingObserver {
/** /**
* Notifies the observer that it should start tracking the drawing process. * Notifies the observer that it should start tracking the drawing process.
*/ */
void stopTracking(); void stopTracking();
/** /**
* Notifies the observer that it should stop tracking the drawing process. * Notifies the observer that it should stop tracking the drawing process.
*/ */
void startTracking(); void startTracking();
/** /**
@@ -64,5 +64,5 @@ public interface IDrawingObserver {
* *
* @param marker * @param marker
*/ */
void setContinuityMarker(String marker); void setContinuityMarker(String marker);
} }
@@ -19,19 +19,19 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
/** /**
* Interface for validating property value changes. * Interface for validating property value changes.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public interface IPropertyValidator { public interface IPropertyValidator {
/** /**
* @param owner * @param owner
* @param value * @param value
* @throws ValidationException if validation fails. Message will contain the reason. * @throws ValidationException if validation fails. Message will contain the reason.
*/ */
void validate(Object owner, Object value) throws ValidationException; void validate(Object owner, Object value) throws ValidationException;
} }
@@ -1,29 +1,30 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.diylc.common.PropertyWrapper; import org.diylc.common.PropertyWrapper;
@@ -55,8 +56,8 @@ public interface IView {
int showConfirmDialog(String message, String title, int optionType, int messageType); int showConfirmDialog(String message, String title, int optionType, int messageType);
boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties, String title); boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties, String title);
String showInputDialog(String message, String title); String showInputDialog(String message, String title);
File promptFileSave(); File promptFileSave();
@@ -1,41 +1,42 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
import java.awt.Font; import java.awt.Font;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.diylc.appframework.update.VersionNumber; import org.diylc.appframework.update.VersionNumber;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.MultiLineText; import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.PositiveMeasureValidator; import org.diylc.core.annotations.MultiLineText;
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator; import org.diylc.core.annotations.PositiveMeasureValidator;
import org.diylc.core.measures.Size; import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
/** /**
@@ -62,11 +63,11 @@ public class Project implements Serializable, Cloneable {
private String description; private String description;
private Size width; private Size width;
private Size height; private Size height;
private Size gridSpacing; private Size gridSpacing;
private Integer dotSpacing; private Integer dotSpacing;
private List<IDIYComponent<?>> components; private List<IDIYComponent<?>> components;
private Set<Set<IDIYComponent<?>>> groups; private Set<Set<IDIYComponent<?>>> groups;
private Set<Integer> lockedLayers; private Set<Integer> lockedLayers;
private Set<IDIYComponent<?>> lockedComponents; private Set<IDIYComponent<?>> lockedComponents;
private Set<Integer> hiddenLayers; private Set<Integer> hiddenLayers;
private Font font = DEFAULT_FONT; private Font font = DEFAULT_FONT;
@@ -75,7 +76,7 @@ public class Project implements Serializable, Cloneable {
components = new ArrayList<IDIYComponent<?>>(); components = new ArrayList<IDIYComponent<?>>();
groups = new HashSet<Set<IDIYComponent<?>>>(); groups = new HashSet<Set<IDIYComponent<?>>>();
lockedLayers = new HashSet<Integer>(); lockedLayers = new HashSet<Integer>();
hiddenLayers = new HashSet<Integer>(); hiddenLayers = new HashSet<Integer>();
lockedComponents = new HashSet<IDIYComponent<?>>(); lockedComponents = new HashSet<IDIYComponent<?>>();
title = DEFAULT_TITLE; title = DEFAULT_TITLE;
author = System.getProperty("user.name"); author = System.getProperty("user.name");
@@ -137,17 +138,17 @@ public class Project implements Serializable, Cloneable {
public void setGridSpacing(Size gridSpacing) { public void setGridSpacing(Size gridSpacing) {
this.gridSpacing = gridSpacing; this.gridSpacing = gridSpacing;
} }
@EditableProperty(name = "Dot Spacing", validatorClass = PositiveNonZeroMeasureValidator.class) @EditableProperty(name = "Dot Spacing", validatorClass = PositiveNonZeroMeasureValidator.class)
public Integer getDotSpacing() { public Integer getDotSpacing() {
if (dotSpacing == null) if (dotSpacing == null)
dotSpacing = 1; dotSpacing = 1;
return dotSpacing; return dotSpacing;
} }
public void setDotSpacing(Integer dotSpacing) { public void setDotSpacing(Integer dotSpacing) {
this.dotSpacing = dotSpacing; this.dotSpacing = dotSpacing;
} }
/** /**
@@ -166,12 +167,12 @@ public class Project implements Serializable, Cloneable {
*/ */
public Set<Set<IDIYComponent<?>>> getGroups() { public Set<Set<IDIYComponent<?>>> getGroups() {
return groups; return groups;
} }
public Set<IDIYComponent<?>> getLockedComponents() { public Set<IDIYComponent<?>> getLockedComponents() {
if (lockedComponents == null) if (lockedComponents == null)
lockedComponents = new HashSet<IDIYComponent<?>>(); lockedComponents = new HashSet<IDIYComponent<?>>();
return lockedComponents; return lockedComponents;
} }
public Set<Integer> getLockedLayers() { public Set<Integer> getLockedLayers() {
@@ -275,36 +276,36 @@ public class Project implements Serializable, Cloneable {
if (other.width != null) if (other.width != null)
return false; return false;
} else if (!width.equals(other.width)) } else if (!width.equals(other.width))
return false; return false;
if (gridSpacing == null) { if (gridSpacing == null) {
if (other.gridSpacing != null) if (other.gridSpacing != null)
return false; return false;
} else if (!gridSpacing.equals(other.gridSpacing)) } else if (!gridSpacing.equals(other.gridSpacing))
return false; return false;
if (font == null) { if (font == null) {
if (other.font != null) if (other.font != null)
return false; return false;
} else if (!font.getFamily().equals(other.font.getFamily()) || font.getSize() != other.font.getSize() || font.getStyle() != other.font.getStyle()) } else if (!font.getFamily().equals(other.font.getFamily()) || font.getSize() != other.font.getSize() || font.getStyle() != other.font.getStyle())
return false; return false;
if (groups == null) { if (groups == null) {
if (other.groups != null) if (other.groups != null)
return false; return false;
} else if (!groups.equals(other.groups)) } else if (!groups.equals(other.groups))
return false; return false;
if (lockedLayers == null) { if (lockedLayers == null) {
if (other.lockedLayers != null) if (other.lockedLayers != null)
return false; return false;
} else if (!lockedLayers.equals(other.lockedLayers)) } else if (!lockedLayers.equals(other.lockedLayers))
return false; return false;
if (getLockedComponents() == null) { if (getLockedComponents() == null) {
if (other.lockedComponents != null) if (other.lockedComponents != null)
return false; return false;
} else if (!getLockedComponents().equals(other.lockedComponents)) } else if (!getLockedComponents().equals(other.lockedComponents))
return false; return false;
if (hiddenLayers == null) { if (hiddenLayers == null) {
if (other.hiddenLayers != null) if (other.hiddenLayers != null)
return false; return false;
} else if (!hiddenLayers.equals(other.hiddenLayers)) } else if (!hiddenLayers.equals(other.hiddenLayers))
return false; return false;
return true; return true;
} }
@@ -340,7 +341,7 @@ public class Project implements Serializable, Cloneable {
project.setHeight(this.getHeight()); project.setHeight(this.getHeight());
project.setWidth(this.getWidth()); project.setWidth(this.getWidth());
project.getLockedLayers().addAll(this.getLockedLayers()); project.getLockedLayers().addAll(this.getLockedLayers());
project.getHiddenLayers().addAll(this.getHiddenLayers()); project.getHiddenLayers().addAll(this.getHiddenLayers());
project.setFont(this.getFont()); project.setFont(this.getFont());
Map<IDIYComponent<?>, IDIYComponent<?>> cloneMap = new HashMap<IDIYComponent<?>, IDIYComponent<?>>(); Map<IDIYComponent<?>, IDIYComponent<?>> cloneMap = new HashMap<IDIYComponent<?>, IDIYComponent<?>>();
@@ -361,10 +362,10 @@ public class Project implements Serializable, Cloneable {
cloneGroup.add(cloneMap.get(component)); cloneGroup.add(cloneMap.get(component));
} }
project.groups.add(cloneGroup); project.groups.add(cloneGroup);
} }
for (IDIYComponent<?> component : this.getLockedComponents()) { for (IDIYComponent<?> component : this.getLockedComponents()) {
project.lockedComponents.add(cloneMap.get(component)); project.lockedComponents.add(cloneMap.get(component));
} }
return project; return project;
} }
@@ -19,17 +19,17 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
import java.awt.geom.Point2D; import java.awt.geom.Point2D;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class Template { public class Template {
private String name; private String name;
private Map<String, Object> values; private Map<String, Object> values;
private List<Point2D> points; private List<Point2D> points;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Deprecated @Deprecated
@@ -41,37 +41,37 @@ public class Template {
public Template(String name, Map<String, Object> values, List<Point2D> points) { public Template(String name, Map<String, Object> values, List<Point2D> points) {
this(name, values, points, LocalDateTime.now()); this(name, values, points, LocalDateTime.now());
} }
public Template(String name, Map<String, Object> values, List<Point2D> points, LocalDateTime createdOn) { public Template(String name, Map<String, Object> values, List<Point2D> points, LocalDateTime createdOn) {
this.name = name; this.name = name;
this.values = values; this.values = values;
this.points = points;
this.createdOn = createdOn;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getValues() {
return values;
}
public void setValues(Map<String, Object> values) {
this.values = values;
}
public List<Point2D> getPoints() {
return points;
}
public void setPoints(List<Point2D> points) {
this.points = points; this.points = points;
this.createdOn = createdOn;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Map<String, Object> getValues() {
return values;
}
public void setValues(Map<String, Object> values) {
this.values = values;
}
public List<Point2D> getPoints() {
return points;
}
public void setPoints(List<Point2D> points) {
this.points = points;
} }
public LocalDateTime getCreatedOn() { public LocalDateTime getCreatedOn() {
@@ -80,8 +80,8 @@ public class Template {
public void setCreatedOn(LocalDateTime createdOn) { public void setCreatedOn(LocalDateTime createdOn) {
this.createdOn = createdOn; this.createdOn = createdOn;
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@@ -125,8 +125,8 @@ public class Template {
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return name; return name;
} }
} }
@@ -1,27 +1,27 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
import java.awt.Color; import java.awt.Color;
import java.io.Serializable; import java.io.Serializable;
public class Theme implements Serializable { public class Theme implements Serializable {
@@ -31,14 +31,14 @@ public class Theme implements Serializable {
private String name; private String name;
private Color bgColor; private Color bgColor;
private Color gridColor; private Color gridColor;
private Color outlineColor; private Color outlineColor;
private Color dotColor; private Color dotColor;
public Theme(String name, Color bgColor, Color gridColor, Color dotColor, Color outlineColor) { public Theme(String name, Color bgColor, Color gridColor, Color dotColor, Color outlineColor) {
super(); super();
this.name = name; this.name = name;
this.bgColor = bgColor; this.bgColor = bgColor;
this.gridColor = gridColor; this.gridColor = gridColor;
this.dotColor = dotColor; this.dotColor = dotColor;
this.outlineColor = outlineColor; this.outlineColor = outlineColor;
} }
@@ -53,12 +53,12 @@ public class Theme implements Serializable {
public Color getGridColor() { public Color getGridColor() {
return gridColor; return gridColor;
} }
public Color getDotColor() { public Color getDotColor() {
if (dotColor == null) if (dotColor == null)
dotColor = gridColor; dotColor = gridColor;
return dotColor; return dotColor;
} }
public Color getOutlineColor() { public Color getOutlineColor() {
@@ -19,13 +19,13 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
public class ValidationException extends Exception { public class ValidationException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public ValidationException(String message) { public ValidationException(String message) {
super(message); super(message);
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core; package org.diylc.core;
/** /**
@@ -19,15 +19,15 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
/** /**
* Tells the system how to represent components in the B.O.M. * Tells the system how to represent components in the B.O.M.
* *
* @see ComponentDescriptor * @see ComponentDescriptor
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public enum BomPolicy { public enum BomPolicy {
SHOW_ALL_NAMES, SHOW_ONLY_TYPE_NAME, NEVER_SHOW, SHOW_ALL_NAMES, SHOW_ONLY_TYPE_NAME, NEVER_SHOW,
} }
@@ -1,31 +1,32 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import org.diylc.common.DefaultComponentTransformer;
import org.diylc.common.IComponentTransformer; import org.diylc.common.DefaultComponentTransformer;
import org.diylc.core.CreationMethod; import org.diylc.common.IComponentTransformer;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
/** /**
@@ -109,22 +110,22 @@ public @interface ComponentDescriptor {
* *
* @return * @return
*/ */
String keywordTag() default ""; String keywordTag() default "";
/** /**
* @return true if the component drawing should be cached * @return true if the component drawing should be cached
*/ */
boolean enableCache() default false; boolean enableCache() default false;
/** /**
* @return true if component datasheet should be loaded from the corresponding file * @return true if component datasheet should be loaded from the corresponding file
*/ */
boolean enableDatasheet() default false; boolean enableDatasheet() default false;
/** /**
* If datasheet is enabled, this property determines how many columns define a component, e.g. in how many steps we can instantiate a component * If datasheet is enabled, this property determines how many columns define a component, e.g. in how many steps we can instantiate a component
* *
* @return * @return
*/ */
int datasheetCreationStepCount() default 0; int datasheetCreationStepCount() default 0;
} }
@@ -19,13 +19,13 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface DynamicList { public @interface DynamicList {
public String availableValueFunction(); public String availableValueFunction();
} }
@@ -1,29 +1,30 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import org.diylc.core.AllowAllValidator;
import org.diylc.core.AllowAllValidator;
import org.diylc.core.IPropertyValidator; import org.diylc.core.IPropertyValidator;
/** /**
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
public @interface ElementLabel { public @interface ElementLabel {
public String functionName(); public String functionName();
} }
@@ -19,23 +19,24 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import java.util.List; import java.util.List;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDIYComponent;
/**
* Interface for creating components automatically each time a component is created by the user. /**
* * Interface for creating components automatically each time a component is created by the user.
* @author Branislav Stojkovic *
*/ * @author Branislav Stojkovic
public interface IAutoCreator { */
public interface IAutoCreator {
/**
* @param lastAdded the component created by the user /**
* @return {@link List} of {@link IDIYComponent}s that will be automatically created as a result. * @param lastAdded the component created by the user
* Empty {@link List} or {@code null} are valid responses for cases when no components * @return {@link List} of {@link IDIYComponent}s that will be automatically created as a result.
* should be auto-created. * Empty {@link List} or {@code null} are valid responses for cases when no components
*/ * should be auto-created.
public List<IDIYComponent<?>> createIfNeeded(IDIYComponent<?> lastAdded); */
} public List<IDIYComponent<?>> createIfNeeded(IDIYComponent<?> lastAdded);
}
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
/** /**
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface MultiLineText { public @interface MultiLineText {
} }
@@ -19,13 +19,13 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface PercentEditor { public @interface PercentEditor {
public byte _100PercentValue(); public byte _100PercentValue();
} }
@@ -19,35 +19,35 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import org.diylc.core.IPropertyValidator; import org.diylc.core.IPropertyValidator;
import org.diylc.core.ValidationException; import org.diylc.core.ValidationException;
import org.diylc.core.measures.AbstractMeasure; import org.diylc.core.measures.AbstractMeasure;
/** /**
* Validates any generic {@link AbstractMeasure} descendants and makes sure that the value is * Validates any generic {@link AbstractMeasure} descendants and makes sure that the value is
* positive. * positive.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public class PositiveMeasureValidator implements IPropertyValidator { public class PositiveMeasureValidator implements IPropertyValidator {
@Override @Override
public void validate(Object owner, Object value) throws ValidationException { public void validate(Object owner, Object value) throws ValidationException {
if (value == null) if (value == null)
return; return;
if (value instanceof AbstractMeasure) { if (value instanceof AbstractMeasure) {
AbstractMeasure<?> measure = (AbstractMeasure<?>) value; AbstractMeasure<?> measure = (AbstractMeasure<?>) value;
if (measure.getValue() < 0) { if (measure.getValue() < 0) {
throw new ValidationException("must be greater or equal to zero."); throw new ValidationException("must be greater or equal to zero.");
} }
} else if (value instanceof Integer) { } else if (value instanceof Integer) {
Integer i = (Integer) value; Integer i = (Integer) value;
if (i < 0) if (i < 0)
throw new ValidationException("must be greater or equal to zero."); throw new ValidationException("must be greater or equal to zero.");
} else { } else {
throw new ValidationException("wrong data type."); throw new ValidationException("wrong data type.");
} }
} }
} }
@@ -19,35 +19,35 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.annotations; package org.diylc.core.annotations;
import org.diylc.core.IPropertyValidator; import org.diylc.core.IPropertyValidator;
import org.diylc.core.ValidationException; import org.diylc.core.ValidationException;
import org.diylc.core.measures.AbstractMeasure; import org.diylc.core.measures.AbstractMeasure;
/** /**
* Validates any generic {@link AbstractMeasure} descendants and makes sure that the value is * Validates any generic {@link AbstractMeasure} descendants and makes sure that the value is
* positive. * positive.
* *
* @author Branislav Stojkovic * @author Branislav Stojkovic
*/ */
public class PositiveNonZeroMeasureValidator implements IPropertyValidator { public class PositiveNonZeroMeasureValidator implements IPropertyValidator {
@Override @Override
public void validate(Object owner, Object value) throws ValidationException { public void validate(Object owner, Object value) throws ValidationException {
if (value == null) if (value == null)
return; return;
if (value instanceof AbstractMeasure) { if (value instanceof AbstractMeasure) {
AbstractMeasure<?> measure = (AbstractMeasure<?>) value; AbstractMeasure<?> measure = (AbstractMeasure<?>) value;
if (measure.getValue() <= 0) { if (measure.getValue() <= 0) {
throw new ValidationException("must be greater than zero."); throw new ValidationException("must be greater than zero.");
} }
} else if (value instanceof Integer) { } else if (value instanceof Integer) {
Integer i = (Integer) value; Integer i = (Integer) value;
if (i < 0) if (i < 0)
throw new ValidationException("must be greater or equal to zero."); throw new ValidationException("must be greater or equal to zero.");
} else { } else {
throw new ValidationException("wrong data type."); throw new ValidationException("wrong data type.");
} }
} }
} }
@@ -13,6 +13,9 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.bancika.gerberwriter.DataLayer;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.IView; import org.diylc.core.IView;
@@ -20,7 +23,6 @@ import org.diylc.core.Project;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
import org.diylc.lang.LangUtil; import org.diylc.lang.LangUtil;
import com.bancika.gerberwriter.DataLayer;
public class GerberExporter { public class GerberExporter {
@@ -30,13 +30,15 @@ import java.awt.image.renderable.RenderableImage;
import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
import com.bancika.gerberwriter.DataLayer; import com.bancika.gerberwriter.DataLayer;
import com.bancika.gerberwriter.Point; import com.bancika.gerberwriter.Point;
import com.bancika.gerberwriter.padmasters.Circle; import com.bancika.gerberwriter.padmasters.Circle;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
public class GerberG2DWrapper extends Graphics2D public class GerberG2DWrapper extends Graphics2D
implements IDrawingObserver, IGerberDrawingObserver { implements IDrawingObserver, IGerberDrawingObserver {
@@ -19,15 +19,17 @@ import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.measures.SizeUnit;
import com.bancika.gerberwriter.DataLayer; import com.bancika.gerberwriter.DataLayer;
import com.bancika.gerberwriter.Point; import com.bancika.gerberwriter.Point;
import com.bancika.gerberwriter.path.MoveTo; import com.bancika.gerberwriter.path.MoveTo;
import com.bancika.gerberwriter.path.Path; import com.bancika.gerberwriter.path.Path;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.measures.SizeUnit;
public class GerberPathRenderer { public class GerberPathRenderer {
public static void drawComponent(Project currentProject, GerberG2DWrapper g2d, IDIYComponent<?> c, public static void drawComponent(Project currentProject, GerberG2DWrapper g2d, IDIYComponent<?> c,
@@ -3,6 +3,7 @@ package org.diylc.core.gerber;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Set; import java.util.Set;
import org.diylc.core.ComponentState; import org.diylc.core.ComponentState;
import org.diylc.core.IDrawingObserver; import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project; import org.diylc.core.Project;
@@ -1,31 +1,31 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.images; package org.diylc.core.images;
import java.awt.Image; import java.awt.Image;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
/** /**
@@ -1,28 +1,28 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
import java.io.Serializable; import java.io.Serializable;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.Format; import java.text.Format;
/*** /***
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public class Capacitance extends AbstractMeasure<CapacitanceUnit> { public class Capacitance extends AbstractMeasure<CapacitanceUnit> {
@@ -49,11 +49,11 @@ public class Capacitance extends AbstractMeasure<CapacitanceUnit> {
} }
} }
throw new IllegalArgumentException("Could not parse capacitance: " + value); throw new IllegalArgumentException("Could not parse capacitance: " + value);
} }
public Double getNormalizedValue() { public Double getNormalizedValue() {
if (value == null || unit == null) if (value == null || unit == null)
return null; return null;
return value * unit.getFactor(); return value * unit.getFactor();
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum CapacitanceUnit implements Unit { public enum CapacitanceUnit implements Unit {
@@ -19,19 +19,19 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public class Current extends AbstractMeasure<CurrentUnit> { public class Current extends AbstractMeasure<CurrentUnit> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Current(Double value, CurrentUnit unit) { public Current(Double value, CurrentUnit unit) {
super(value, unit); super(value, unit);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@Override @Override
public Current clone() throws CloneNotSupportedException { public Current clone() throws CloneNotSupportedException {
return new Current(value, unit); return new Current(value, unit);
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum CurrentUnit implements Unit { public enum CurrentUnit implements Unit {
@@ -19,19 +19,19 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public class Frequency extends AbstractMeasure<FrequencyUnit> { public class Frequency extends AbstractMeasure<FrequencyUnit> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Frequency(Double value, FrequencyUnit unit) { public Frequency(Double value, FrequencyUnit unit) {
super(value, unit); super(value, unit);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
@Override @Override
public Frequency clone() throws CloneNotSupportedException { public Frequency clone() throws CloneNotSupportedException {
return new Frequency(value, unit); return new Frequency(value, unit);
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum FrequencyUnit implements Unit { public enum FrequencyUnit implements Unit {
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public class Inductance extends AbstractMeasure<InductanceUnit> { public class Inductance extends AbstractMeasure<InductanceUnit> {
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum InductanceUnit implements Unit { public enum InductanceUnit implements Unit {
@@ -19,21 +19,21 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
import java.util.ArrayList; import java.util.ArrayList;
public class MeasureList<T extends Enum<? extends Unit>> extends ArrayList<AbstractMeasure<T>> { public class MeasureList<T extends Enum<? extends Unit>> extends ArrayList<AbstractMeasure<T>> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String name; private String name;
public MeasureList(String name) { public MeasureList(String name) {
this.name = name; this.name = name;
} }
public String getName() { public String getName() {
return name; return name;
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
import org.diylc.core.annotations.EditableProperty; import org.diylc.core.annotations.EditableProperty;
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public class Power extends AbstractMeasure<PowerUnit> { public class Power extends AbstractMeasure<PowerUnit> {
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum PowerUnit implements Unit { public enum PowerUnit implements Unit {
@@ -1,27 +1,28 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
import java.awt.Color; import java.awt.Color;
import org.diylc.common.ResistorColorCode; import org.diylc.common.ResistorColorCode;
public class Resistance extends AbstractMeasure<ResistanceUnit> { public class Resistance extends AbstractMeasure<ResistanceUnit> {
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum ResistanceUnit implements Unit { public enum ResistanceUnit implements Unit {
@@ -35,7 +35,7 @@ public enum ResistanceUnit implements Unit {
@Override @Override
public double getFactor() { public double getFactor() {
return factor; return factor;
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
import org.diylc.utils.Constants; import org.diylc.utils.Constants;
@@ -44,13 +44,13 @@ public class Size extends AbstractMeasure<SizeUnit> implements Comparable<Size>
// return (int) Math.round(Constants.PIXELS_PER_INCH / Constants.GRIDS_PER_INCH // return (int) Math.round(Constants.PIXELS_PER_INCH / Constants.GRIDS_PER_INCH
// * (grids + remainder)); // * (grids + remainder));
return getValue() * getUnit().getFactor() / SizeUnit.in.getFactor() * Constants.PIXELS_PER_INCH; return getValue() * getUnit().getFactor() / SizeUnit.in.getFactor() * Constants.PIXELS_PER_INCH;
} }
public double convertToUnits(SizeUnit unit) { public double convertToUnits(SizeUnit unit) {
if (unit == getUnit()) { if (unit == getUnit()) {
return this.getValue(); return this.getValue();
} }
return convertToPixels() * SizeUnit.px.getFactor(); return convertToPixels() * SizeUnit.px.getFactor();
} }
@Override @Override
@@ -67,14 +67,14 @@ public class Size extends AbstractMeasure<SizeUnit> implements Comparable<Size>
} }
} }
throw new IllegalArgumentException("Could not parse size: " + value); throw new IllegalArgumentException("Could not parse size: " + value);
} }
public static Size fromPixels(double pixels, SizeUnit unit) { public static Size fromPixels(double pixels, SizeUnit unit) {
return new Size(pixels / unit.getFactor() * SizeUnit.in.getFactor() / Constants.PIXELS_PER_INCH, unit); return new Size(pixels / unit.getFactor() * SizeUnit.in.getFactor() / Constants.PIXELS_PER_INCH, unit);
} }
public Size scale(double factor) { public Size scale(double factor) {
return new Size(value * factor, unit); return new Size(value * factor, unit);
} }
@Override @Override
@@ -19,22 +19,22 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
import org.diylc.utils.Constants; import org.diylc.utils.Constants;
public enum SizeUnit implements Unit { public enum SizeUnit implements Unit {
px(25.4d / Constants.PIXELS_PER_INCH), mm(1d), cm(10d), m(1e3d), in(25.4d), ft(25.4d * 12), yd(9144d); px(25.4d / Constants.PIXELS_PER_INCH), mm(1d), cm(10d), m(1e3d), in(25.4d), ft(25.4d * 12), yd(9144d);
double factor; double factor;
private SizeUnit(double factor) { private SizeUnit(double factor) {
this.factor = factor; this.factor = factor;
} }
@Override @Override
public double getFactor() { public double getFactor() {
return factor; return factor;
} }
} }
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public interface Unit { public interface Unit {
double getFactor(); double getFactor();
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public class Voltage extends AbstractMeasure<VoltageUnit> { public class Voltage extends AbstractMeasure<VoltageUnit> {
@@ -49,11 +49,11 @@ public class Voltage extends AbstractMeasure<VoltageUnit> {
} }
} }
throw new IllegalArgumentException("Could not parse voltage: " + value); throw new IllegalArgumentException("Could not parse voltage: " + value);
} }
public Double getNormalizedValue() { public Double getNormalizedValue() {
if (value == null || unit == null) if (value == null || unit == null)
return null; return null;
return value * unit.getFactor(); return value * unit.getFactor();
} }
} }
@@ -1,24 +1,24 @@
/* /*
DIY Layout Creator (DIYLC). DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors. Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC. This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DIYLC is distributed in the hope that it will be useful, DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>. along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.diylc.core.measures; package org.diylc.core.measures;
public enum VoltageUnit implements Unit { public enum VoltageUnit implements Unit {
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.ConfigurationManager; import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.utils.ResourceLoader; import org.diylc.utils.ResourceLoader;
@@ -33,6 +33,7 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.measures.Size; import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@@ -24,6 +24,7 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.diylc.presenter.ContinuityArea; import org.diylc.presenter.ContinuityArea;
import org.diylc.utils.RTree; import org.diylc.utils.RTree;
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
/** /**

Some files were not shown because too many files have changed in this diff Show More