Compare commits

..

1 Commits

Author SHA1 Message Date
Branislav Stojkovic 8e20f61946 spring 2025-03-14 10:33:01 +01:00
1298 changed files with 17469 additions and 31275 deletions
-27
View File
@@ -1,27 +0,0 @@
name: Test Build
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: |
cd diylc
mvn -B test
-3
View File
@@ -1,3 +0,0 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
+1 -1
View File
@@ -29,7 +29,7 @@ DIY Layout Creator (DIYLC) is a specialized software tool designed for hobbyists
<li>group components together and treat them as one, e.g. move, edit or delete </li>
<li>export the output to image, PDF or printer </li>
<li>export PCB trace mask suitable for toner transfer </li>
<li>export PCB designs to Gerber for fabrication </li>
<li>export the circuit to a SPICE compatible netlist (beta) </li>
<li>create a Bill of Materials as a part of the project or export it to few different file formats </li>
<li>analyze guitar wirings and show detailed pickup configuration in each switch configuration</li>
<li>zoom in/out feature </li>
BIN
View File
Binary file not shown.
-149
View File
@@ -1,149 +0,0 @@
# Reference: https://github.com/github/gitignore
# From: https://gist.github.com/edesdan/6bb43343740bcd54ef0f56a384a2f66f
######################
###### Mac OS X ######
######################
# Folder view configuration files
.DS_Store
Desktop.ini
# Thumbnail cache files
._*
Thumbs.db
# Files that might appear on external disks
.Spotlight-V100
.Trashes
######################
###### Java ######
######################
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
######################
###### Gradle ######
######################
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
######################
###### Intellij ######
######################
# Created by https://www.gitignore.io/api/intellij
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
# End of https://www.gitignore.io/api/intellij
######################
###### Maven ######
######################
**/target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
-16
View File
@@ -1,16 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="DIYLCStarter" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="org.diylc.DIYLCStarter" />
<module name="diylc-swing" />
<option name="VM_PARAMETERS" value="-Xms1024m -Xmx4096m -Dsun.java2d.uiScale=1.5 -Dorg.diylc.scriptRun=true -Dfile.encoding=UTF-8 --add-exports java.desktop/com.apple.eawt.event=ALL-UNNAMED --add-exports java.desktop/com.apple.eio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens java.desktop/java.awt.geom=ALL-UNNAMED" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.diylc.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
-4
View File
@@ -1,4 +0,0 @@
{
"java.compile.nullAnalysis.mode": "automatic",
"java.configuration.updateBuildConfiguration": "interactive"
}
-1
View File
@@ -1 +0,0 @@
[![Java CI Tests](https://github.com/{owner}/{repo}/actions/workflows/tests.yml/badge.svg)](https://github.com/{owner}/{repo}/actions/workflows/tests.yml)
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
<classpathentry kind="lib" path="lib/app-framework.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/AppleJavaExtensions.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/gerber-writer-api-1.0.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
-6
View File
@@ -10,14 +10,8 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/org/diylc/core/measures/Resistance.java=UTF-8
encoding//src/org/diylc/core/measures/ResistanceUnit.java=UTF-8
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,5 +1,5 @@
<project name="diylc-core" basedir="." default="jar">
<property name="src.dir" value="${basedir}/src/main/java" />
<property name="src.dir" value="src" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="build.dir" value="${basedir}/build" />
+2
View File
@@ -0,0 +1,2 @@
#org.diylc.utils.Constants.CANVAS_COLOR=#005D96
#org.diylc.utils.Constants.GRID_COLOR=#FFFFFF
+89
View File
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/lib/log4j-1.2.15.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/junit-4.7.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/app-framework.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/jettison-1.0.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/xstream-1.3.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/java-http-proxy.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/AppleJavaExtensions.jar!/" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/test" expected_position="1" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="log4j-1.2.15.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/log4j-1.2.15.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="junit-4.7.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/junit-4.7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="app-framework.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/app-framework.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="jettison-1.0.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jettison-1.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="xstream-1.3.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/xstream-1.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="java-http-proxy.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/java-http-proxy.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="AppleJavaExtensions.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/AppleJavaExtensions.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="inheritedJdk" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+18 -14
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>5.2.0</version>
<version>5.1.0</version>
</parent>
<artifactId>diylc-core</artifactId>
@@ -62,35 +62,39 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Add Mockito for testing -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
<!-- Local dependencies from lib folder -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../lib/app-framework-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>gerber-writer-api-1.0.0</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../lib/gerber-writer-api-1.0.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>java-http-proxy</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/../lib/java-http-proxy.jar</systemPath>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>6.1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -1,5 +0,0 @@
package org.diylc.common;
public enum NetlistSwitchPreference {
WITH, WITHOUT;
}
@@ -1,5 +0,0 @@
package org.diylc.common;
public enum OperationMode {
EDIT, HIGHLIGHT_CONNECTED_AREAS
}
@@ -1,46 +0,0 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum Orientation45 {
DEFAULT, _45, _90, _135, _180, _225, _270, _315;
@Override
public String toString() {
if (this == DEFAULT) {
return "Default";
} else {
return name().replace("_", "") + " degrees clockwise";
}
}
public double toDegrees() {
if (this == DEFAULT)
return 0;
return Integer.parseInt(name().replace("_", ""));
}
public double toRadians() {
return Math.toRadians(toDegrees());
}
}
@@ -0,0 +1,91 @@
package org.diylc.config;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.core.IView;
import org.diylc.presenter.*;
import org.diylc.serialization.ProjectFileManager;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.common.EventType;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
@Configuration
public class DIYLCConfig {
@Primary
@Bean
public IConfigurationManager configurationManager() {
return ConfigurationManager.getInstance();
}
@Primary
@Bean
public MessageDispatcher<EventType> messageDispatcher() {
return new MessageDispatcher<>(true);
}
@Primary
@Bean
public DrawingService drawingService(
MessageDispatcher<EventType> messageDispatcher,
IConfigurationManager configManager) {
return new DrawingManager(messageDispatcher, configManager);
}
@Primary
@Bean
public ProjectFileService projectFileService(MessageDispatcher<EventType> messageDispatcher) {
return new ProjectFileManager(messageDispatcher);
}
@Primary
@Bean
public InstantiationService instantiationService() {
return new InstantiationManager();
}
@Primary
@Bean
public VariantService variantService(
IConfigurationManager configManager,
ProjectFileService projectFileService) {
return new VariantManager(configManager, projectFileService.getXStream());
}
@Bean
public BuildingBlockService buildingBlockService(
IConfigurationManager configManager,
ProjectFileService projectFileService,
InstantiationService instantiationService) {
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
}
@Primary
@Bean
public Presenter presenter(
@Lazy
IView view,
IConfigurationManager configManager,
MessageDispatcher<EventType> messageDispatcher,
DrawingService drawingService,
ProjectFileService projectFileService,
InstantiationService instantiationService,
VariantService variantService,
BuildingBlockService buildingBlockService) {
return new Presenter(
view,
configManager,
messageDispatcher,
drawingService,
projectFileService,
instantiationService,
variantService,
buildingBlockService,
true
);
}
}
@@ -0,0 +1,96 @@
package org.diylc.config;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.common.EventType;
import org.diylc.core.IView;
import org.diylc.presenter.*;
import org.diylc.serialization.ProjectFileManager;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class DummyViewDIYLCConfig {
@Bean
public IConfigurationManager dummyViewConfigManager() {
return InMemoryConfigurationManager.getInstance();
}
@Bean
public MessageDispatcher<EventType> dummyViewMessageDispatcher() {
return new MessageDispatcher<>(true);
}
@Bean
public DrawingService dummyViewDrawingService(
@Qualifier("dummyViewMessageDispatcher")
MessageDispatcher<EventType> messageDispatcher,
@Qualifier("dummyViewConfigManager")
IConfigurationManager configManager) {
return new DrawingManager(messageDispatcher, configManager);
}
@Bean
public ProjectFileService dummyViewProjectFileService(MessageDispatcher<EventType> messageDispatcher) {
return new ProjectFileManager(messageDispatcher);
}
@Bean
public InstantiationService dummyViewInstantiationService() {
return new InstantiationManager();
}
@Bean
public VariantService dummyViewVariantService(
@Qualifier("dummyViewConfigManager")
IConfigurationManager configManager,
@Qualifier("dummyViewProjectFileService")
ProjectFileService projectFileService) {
return new VariantManager(configManager, projectFileService.getXStream());
}
@Bean
public BuildingBlockService dummyViewBuildingBlockService(
@Qualifier("dummyViewConfigManager")
IConfigurationManager configManager,
@Qualifier("dummyViewProjectFileService")
ProjectFileService projectFileService,
@Qualifier("dummyViewInstantiationService")
InstantiationService instantiationService) {
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
}
@Bean
public Presenter dummyViewPresenter(
@Qualifier("dummyView")
IView view,
@Qualifier("dummyViewConfigManager")
IConfigurationManager configManager,
@Qualifier("dummyViewMessageDispatcher")
MessageDispatcher<EventType> messageDispatcher,
@Qualifier("dummyViewDrawingService")
DrawingService drawingService,
@Qualifier("dummyViewProjectFileService")
ProjectFileService projectFileService,
@Qualifier("dummyViewInstantiationService")
InstantiationService instantiationService,
@Qualifier("dummyViewVariantService")
VariantService variantService,
@Qualifier("dummyViewBuildingBlockService")
BuildingBlockService buildingBlockService) {
return new Presenter(
view,
configManager,
messageDispatcher,
drawingService,
projectFileService,
instantiationService,
variantService,
buildingBlockService,
false
);
}
}
@@ -0,0 +1,98 @@
package org.diylc.config;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.common.EventType;
import org.diylc.core.IView;
import org.diylc.presenter.*;
import org.diylc.serialization.ProjectFileManager;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
@Configuration
public class ImportFileDIYLCConfig {
@Bean
public IConfigurationManager importFileConfigManager() {
return InMemoryConfigurationManager.getInstance();
}
@Bean
public MessageDispatcher<EventType> importFileMessageDispatcher() {
return new MessageDispatcher<>(true);
}
@Bean
public DrawingService importFileDrawingService(
@Qualifier("importFileMessageDispatcher")
MessageDispatcher<EventType> messageDispatcher,
@Qualifier("importFileConfigManager")
IConfigurationManager configManager) {
return new DrawingManager(messageDispatcher, configManager);
}
@Bean
public ProjectFileService importFileProjectFileService(MessageDispatcher<EventType> messageDispatcher) {
return new ProjectFileManager(messageDispatcher);
}
@Bean
public InstantiationService importFileInstantiationService() {
return new InstantiationManager();
}
@Bean
public VariantService importFileVariantService(
@Qualifier("importFileConfigManager")
IConfigurationManager configManager,
@Qualifier("importFileProjectFileService")
ProjectFileService projectFileService) {
return new VariantManager(configManager, projectFileService.getXStream());
}
@Bean
public BuildingBlockService importFileBuildingBlockService(
@Qualifier("importFileConfigManager")
IConfigurationManager configManager,
@Qualifier("importFileProjectFileService")
ProjectFileService projectFileService,
@Qualifier("importFileInstantiationService")
InstantiationService instantiationService) {
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
}
@Bean
public Presenter importFilePresenter(
@Qualifier("importFileView")
IView view,
@Qualifier("importFileConfigManager")
IConfigurationManager configManager,
@Qualifier("importFileMessageDispatcher")
MessageDispatcher<EventType> messageDispatcher,
@Qualifier("importFileDrawingService")
DrawingService drawingService,
@Qualifier("importFileProjectFileService")
ProjectFileService projectFileService,
@Qualifier("importFileInstantiationService")
InstantiationService instantiationService,
@Qualifier("importFileVariantService")
VariantService variantService,
@Qualifier("importFileBuildingBlockService")
BuildingBlockService buildingBlockService) {
return new Presenter(
view,
configManager,
messageDispatcher,
drawingService,
projectFileService,
instantiationService,
variantService,
buildingBlockService,
false
);
}
}
@@ -0,0 +1,96 @@
package org.diylc.config;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.common.EventType;
import org.diylc.core.IView;
import org.diylc.presenter.*;
import org.diylc.serialization.ProjectFileManager;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class LoadlineDIYLCConfig {
@Bean
public IConfigurationManager loadlineConfigManager() {
return InMemoryConfigurationManager.getInstance();
}
@Bean
public MessageDispatcher<EventType> loadlineMessageDispatcher() {
return new MessageDispatcher<>(true);
}
@Bean
public DrawingService loadlineDrawingService(
@Qualifier("loadlineMessageDispatcher")
MessageDispatcher<EventType> messageDispatcher,
@Qualifier("loadlineConfigManager")
IConfigurationManager configManager) {
return new DrawingManager(messageDispatcher, configManager);
}
@Bean
public ProjectFileService loadlineProjectFileService(MessageDispatcher<EventType> messageDispatcher) {
return new ProjectFileManager(messageDispatcher);
}
@Bean
public InstantiationService loadlineInstantiationService() {
return new InstantiationManager();
}
@Bean
public VariantService loadlineVariantService(
@Qualifier("loadlineConfigManager")
IConfigurationManager configManager,
@Qualifier("loadlineProjectFileService")
ProjectFileService projectFileService) {
return new VariantManager(configManager, projectFileService.getXStream());
}
@Bean
public BuildingBlockService loadlineBuildingBlockService(
@Qualifier("loadlineConfigManager")
IConfigurationManager configManager,
@Qualifier("loadlineProjectFileService")
ProjectFileService projectFileService,
@Qualifier("loadlineInstantiationService")
InstantiationService instantiationService) {
return new BuildingBlockManager(configManager, projectFileService.getXStream(), instantiationService);
}
@Bean
public Presenter loadlinePresenter(
@Qualifier("loadlineView")
IView view,
@Qualifier("loadlineConfigManager")
IConfigurationManager configManager,
@Qualifier("loadlineMessageDispatcher")
MessageDispatcher<EventType> messageDispatcher,
@Qualifier("loadlineDrawingService")
DrawingService drawingService,
@Qualifier("loadlineProjectFileService")
ProjectFileService projectFileService,
@Qualifier("loadlineInstantiationService")
InstantiationService instantiationService,
@Qualifier("loadlineVariantService")
VariantService variantService,
@Qualifier("loadlineBuildingBlockService")
BuildingBlockService buildingBlockService) {
return new Presenter(
view,
configManager,
messageDispatcher,
drawingService,
projectFileService,
instantiationService,
variantService,
buildingBlockService,
false
);
}
}
@@ -1,34 +0,0 @@
package org.diylc.core;
import org.diylc.common.PropertyWrapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public abstract class AbstractDynamicPropertyValueSource implements IDynamicPropertySource {
protected List<PropertyWrapper> properties;
protected IDIYComponent<?> component;
@Override
public void setProperties(List<PropertyWrapper> properties) {
this.properties = properties;
}
@Override
public void setComponent(IDIYComponent<?> component) {
this.component = component;
}
@Override
public String getDisplayValue(Object value) {
if (value == null) {
return "None";
}
if (component instanceof ISwitch sw) {
return sw.getPositionName((Integer)value);
}
return "#" + (((Integer)value) + 1);
}
}
@@ -1,10 +0,0 @@
package org.diylc.core;
public enum BoardUndersideDisplay {
NONE, ABOVE, BELOW, LEFT, RIGHT;
@Override
public String toString() {
return super.toString().charAt(0) + super.toString().substring(1).toLowerCase();
}
}
@@ -1,18 +0,0 @@
package org.diylc.core;
import org.diylc.core.measures.Size;
import java.awt.geom.Rectangle2D;
public interface IBoard {
Rectangle2D getBoardRectangle();
BoardUndersideDisplay getUndersideDisplay();
Size getUndersideOffset();
Boolean getUndersideTransparency();
boolean shouldExportToGerber();
}
@@ -1,38 +0,0 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core;
import org.diylc.common.PropertyWrapper;
import java.util.List;
import java.util.Map;
public interface IDynamicPropertySource {
void setProperties(List<PropertyWrapper> properties);
void setComponent(IDIYComponent<?> ownerObject);
List<Object> getAvailableValues();
String getDisplayValue(Object value);
}
@@ -1,42 +0,0 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core.annotations;
import org.diylc.core.IDynamicPropertySource;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/***
* Used for properties having dynamic set of possible values. Only to be used in addition to
* EditableProperty annotation.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface DynamicEditableProperty {
/**
* Optional parameter for dynamic values
*
* @return
*/
Class<? extends IDynamicPropertySource> source() ;
}
@@ -1,281 +0,0 @@
/*
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
*
* This file is part of DIYLC.
*
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
* <http://www.gnu.org/licenses/>.
*/
package org.diylc.netlist;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.diylc.core.IDIYComponent;
public abstract class NetlistAnalyzer {
public NetlistAnalyzer() {
}
public List<Summary> summarize(List<Netlist> netlists, Node preferredOutput)
throws TreeException {
Map<String, Summary> summaries = new HashMap<String, Summary>();
for (Netlist n : netlists) {
Summary s = summarize(n, preferredOutput);
if (summaries.containsKey(s.getSummary()))
summaries.get(s.getSummary()).append(n);
else
summaries.put(s.getSummary(), s);
}
List<Summary> res = new ArrayList<Summary>(summaries.values());
Collections.sort(res);
return res;
}
protected abstract Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException;
public Tree constructTreeBetween(Netlist netlist, Node nodeA, Node nodeB) {
Tree tree = new Tree(TreeConnectionType.Parallel);
connectNodes(netlist, nodeA, nodeB, tree.getChildren(), new Tree(TreeConnectionType.Series),
new HashSet<Node>());
return tree;
}
protected void connectNodes(Netlist netlist, Node nodeA, Node nodeB, List<Tree> concurrentPaths,
Tree currentPath, Set<Node> visited) {
if (nodeA == nodeB) {
concurrentPaths.add(currentPath);
return;
}
Group groupA = findGroup(netlist, nodeA);
if (groupA == null)
return;
if (groupA.getNodes().contains(nodeB)) {
concurrentPaths.add(currentPath);
return;
}
Set<Node> pathVisited = new HashSet<>(visited);
pathVisited.add(nodeA);
// First collect all immediate next nodes and their paths
Map<Node, List<Tree>> nextNodes = new HashMap<>();
for (Node n : groupA.getNodes()) {
if (pathVisited.contains(n))
continue;
IDIYComponent<?> c = n.getComponent();
for (int i = 0; i < c.getControlPointCount(); i++) {
int targetPoint = i;
int sourcePoint = n.getPointIndex();
if (targetPoint == sourcePoint)
continue;
if (c.getInternalLinkName(targetPoint, sourcePoint) != null) {
Node newNodeA = new Node(c, targetPoint, n.getZIndex());
if (pathVisited.contains(newNodeA))
continue;
try {
Tree newPath = (Tree) currentPath.clone();
TreeLeaf leaf = new TreeLeaf(c, targetPoint, sourcePoint);
Tree newItem = new Tree(leaf);
if (!newPath.getChildren().contains(newItem)) {
newPath.getChildren().add(newItem);
nextNodes.computeIfAbsent(newNodeA, k -> new ArrayList<>()).add(newPath);
}
} catch (CloneNotSupportedException e) {
// Skip this path if clone fails
}
}
}
}
// Now explore each next node
List<Tree> allPaths = new ArrayList<>();
for (Map.Entry<Node, List<Tree>> entry : nextNodes.entrySet()) {
for (Tree path : entry.getValue()) {
List<Tree> branchPaths = new ArrayList<>();
connectNodes(netlist, entry.getKey(), nodeB, branchPaths, path, pathVisited);
allPaths.addAll(branchPaths);
}
}
if (allPaths.isEmpty())
return;
if (allPaths.size() > 1) {
// Find common prefix among all paths
List<Tree> commonPrefix = findCommonElements(allPaths, true, false);
// Create a new tree for the merged result
Tree mergedTree = new Tree(TreeConnectionType.Series);
// Add common prefix elements
for (Tree prefixElement : commonPrefix) {
mergedTree.getChildren().add(prefixElement);
}
// Extract unique parts
List<Tree> uniqueParts = new ArrayList<>();
for (Tree path : allPaths) {
Tree uniquePart = extractUniquePart(path, commonPrefix.size(), 0);
if (uniquePart != null) {
if (uniquePart.getChildren().size() == 1) {
uniqueParts.add(uniquePart.getChildren().get(0));
} else {
uniqueParts.add(uniquePart);
}
}
}
// Create parallel section for unique parts
if (!uniqueParts.isEmpty()) {
Tree parallelSection = new Tree(TreeConnectionType.Parallel);
parallelSection.getChildren().addAll(uniqueParts);
// Add parallel section to series container
Tree parallelContainer = new Tree(TreeConnectionType.Series);
parallelContainer.getChildren().add(parallelSection);
mergedTree.getChildren().add(parallelContainer);
}
concurrentPaths.add(mergedTree);
} else {
concurrentPaths.add(allPaths.get(0));
}
}
private List<Tree> findCommonElements(List<Tree> paths, boolean fromStart, boolean backward) {
if (paths.isEmpty())
return new ArrayList<>();
List<Tree> common = new ArrayList<>();
Tree template = paths.get(0);
int maxLength = template.getChildren().size();
for (int i = 0; i < maxLength; i++) {
int index = fromStart ?
(backward ? template.getChildren().size() - i - 1 : i) :
(backward ? i : template.getChildren().size() - i - 1);
if (index < 0 || index >= template.getChildren().size())
break;
Tree element = template.getChildren().get(index);
boolean isCommon = true;
for (int j = 1; j < paths.size(); j++) {
Tree current = paths.get(j);
if (current.getChildren().size() <= i || index >= current.getChildren()
.size() || !current.getChildren().get(index).equals(element)) {
isCommon = false;
break;
}
}
if (isCommon) {
common.add(element);
} else {
break;
}
}
return common;
}
private Tree extractUniquePart(Tree path, int prefixSize, int suffixSize) {
if (path.getChildren().size() <= prefixSize + suffixSize)
return null;
Tree uniquePart = new Tree(TreeConnectionType.Series);
for (int i = prefixSize; i < path.getChildren().size() - suffixSize; i++) {
uniquePart.getChildren().add(path.getChildren().get(i));
}
return uniquePart.getChildren().isEmpty() ? null : uniquePart;
}
protected Group findGroup(Netlist netlist, Node node) {
for (Group g : netlist.getGroups())
if (g.getNodes().contains(node))
return g;
return null;
}
protected List<Node> find(Set<String> typeNames, String nodeName, Netlist netlist) {
List<Node> res = new ArrayList<Node>();
for (Group g : netlist.getGroups()) {
for (Node n : g.getNodes()) {
if (typeNames.contains(n.getComponent().getClass()
.getCanonicalName()) && (nodeName == null || n.getDisplayName()
.equalsIgnoreCase(nodeName))) {
res.add(n);
}
}
}
return res;
}
public static List<Set<IDIYComponent<?>>> extractComponentGroups(List<Netlist> netlists) {
List<Set<IDIYComponent<?>>> res = new ArrayList<Set<IDIYComponent<?>>>();
for (Netlist n : netlists) {
res.addAll(extractComponentGroups(n));
}
return res;
}
public static List<Set<IDIYComponent<?>>> extractComponentGroups(Netlist netlist) {
List<Set<IDIYComponent<?>>> res = new ArrayList<Set<IDIYComponent<?>>>();
for (Group g : netlist.getGroups()) {
Set<IDIYComponent<?>> components = new HashSet<IDIYComponent<?>>();
for (Node n : g.getNodes())
components.add(n.getComponent());
res.add(components);
}
return res;
}
protected int find(Node node, List<Group> groups) {
for (int i = 0; i < groups.size(); i++)
if (groups.get(i).getNodes().contains(node))
return i;
return -1;
}
protected boolean intersect(List<Group> groups, Node node) {
for (Group g : groups)
if (g.getNodes().contains(node))
return true;
return false;
}
protected Node intersect(List<Group> groups, Group group) {
for (Group g : groups)
for (Node node : group.getNodes())
if (g.getNodes().contains(node))
return node;
return null;
}
}
@@ -1,287 +0,0 @@
package org.diylc.netlist;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class TreeAsciiUtil {
public static final String BOXVR = "&#x251C;";
public static final String BOXUL = "&#x2518;";
public static final String BOXDL = "&#x2510;";
public static final String BOXH = "&#x2500;";
public static final String NBSP = "&nbsp;";
public static final String BOXDR = "&#x250C;";
public static final String BOXUR = "&#x2514;";
public static final String BOXVH = "&#x253C;";
public static final String BOXVL = "&#x2524;";
public static final String BOXV = "&#x2502;";
public static List<String> concatenateMultiLineParallel(List<List<String>> elementLines) {
if (elementLines == null || elementLines.isEmpty()) {
return new ArrayList<>();
}
if (elementLines.size() == 1) {
return new ArrayList<>(elementLines.get(0));
}
// Calculate maximum line length for each element
List<Integer> lineLengths = elementLines.stream()
.map(element -> element.stream()
.map(TreeAsciiUtil::htmlLength)
.max(Integer::compare)
.orElse(0))
.collect(Collectors.toList());
int maxLineLength = Collections.max(lineLengths);
// Calculate total height and center positions
List<Integer> elementHeights = elementLines.stream()
.map(List::size)
.collect(Collectors.toList());
// Calculate total height including spacing lines
int totalHeight = elementHeights.stream().mapToInt(Integer::intValue).sum() + (elementLines.size() - 1);
int centerLine = totalHeight / 2;
List<String> results = new ArrayList<>();
int lineCounter = 0;
// Process each element
for (int i = 0; i < elementLines.size(); i++) {
List<String> element = elementLines.get(i);
int elementHeight = element.size();
int elementCenter = elementHeight / 2;
// Calculate the first and last line numbers for the entire parallel group
int firstLineOfGroup = 0;
int lastLineOfGroup = totalHeight - 1;
// Process each line of the element
for (int j = 0; j < elementHeight; j++) {
StringBuilder sb = new StringBuilder();
String line = element.get(j);
int lineLength = htmlLength(line);
// Calculate padding to center this element's content
int leftPadding = (maxLineLength - lineLength) / 2;
int rightPadding = maxLineLength - lineLength - leftPadding;
// Start character
if (lineCounter == centerLine) {
sb.append(BOXH);
} else {
sb.append(NBSP);
}
// Left connection
if (j == elementCenter) {
if (i == 0) {
// First element in parallel group
sb.append(BOXDR); // Top-left corner (┌)
} else if (i == elementLines.size() - 1) {
// Last element in parallel group
sb.append(BOXUR); // Bottom-left corner (└)
} else {
sb.append(BOXVR); // T-connection (├) for middle elements
}
} else {
if (j < elementCenter && i == 0) {
sb.append(NBSP); // No connection above first element
} else if (j > elementCenter && i == elementLines.size() - 1) {
sb.append(NBSP); // No connection below last element
} else if (lineCounter == centerLine) {
sb.append(BOXVL); // Horizontal connection
} else {
sb.append(BOXV); // Vertical line
}
}
// Left padding
if (j == elementCenter) {
sb.append(generateString(BOXH, leftPadding));
} else {
sb.append(generateString(NBSP, leftPadding));
}
// Element content
sb.append(line);
// Right padding
if (j == elementCenter) {
sb.append(generateString(BOXH, rightPadding));
} else {
sb.append(generateString(NBSP, rightPadding));
}
// Right connection
if (j == elementCenter) {
if (i == 0) {
// First element in parallel group
sb.append(BOXDL); // Top-right corner (┐)
} else if (i == elementLines.size() - 1) {
// Last element in parallel group
sb.append(BOXUL); // Bottom-right corner (┘)
} else {
sb.append(BOXVL); // T-connection (┤) for middle elements
}
} else {
if (j < elementCenter && i == 0) {
sb.append(NBSP); // No connection above first element
} else if (j > elementCenter && i == elementLines.size() - 1) {
sb.append(NBSP); // No connection below last element
} else if (lineCounter == centerLine) {
sb.append(BOXVR); // Horizontal connection
} else {
sb.append(BOXV); // Vertical line
}
}
// End character
if (lineCounter == centerLine) {
sb.append(BOXH);
} else {
sb.append(NBSP);
}
results.add(sb.toString());
lineCounter++;
}
// Add a separator line between elements (except after the last one)
if (i < elementLines.size() - 1) {
StringBuilder separatorLine = new StringBuilder();
// Start character
if (lineCounter == centerLine) {
separatorLine.append(BOXH);
} else {
separatorLine.append(NBSP);
}
// Left connection
if (lineCounter == centerLine) {
separatorLine.append(BOXVL);
separatorLine.append(generateString(NBSP, maxLineLength));
separatorLine.append(BOXVR);
} else {
separatorLine.append(BOXV);
separatorLine.append(generateString(NBSP, maxLineLength));
separatorLine.append(BOXV);
}
// End character
if (lineCounter == centerLine) {
separatorLine.append(BOXH);
} else {
separatorLine.append(NBSP);
}
results.add(separatorLine.toString());
lineCounter++;
}
}
return results;
}
public static List<String> concatenateMultiLineSerial(String separator, List<List<String>> elementLines) {
if (elementLines == null || elementLines.isEmpty()) {
return new ArrayList<>();
}
if (elementLines.size() == 1) {
return new ArrayList<>(elementLines.get(0));
}
List<Integer> lineCounts = elementLines.stream()
.map(List::size)
.collect(Collectors.toList());
// Detect if all elements have the same height
boolean uniformHeight = lineCounts.stream().distinct().count() == 1;
String blankSeparator = generateString(NBSP, htmlLength(separator));
int maxLineCount = Collections.max(lineCounts);
int centerLine = maxLineCount / 2;
List<Integer> lineLengths = elementLines.stream()
.map(element -> element.stream()
.map(TreeAsciiUtil::htmlLength)
.max(Integer::compare)
.orElse(0))
.collect(Collectors.toList());
List<String> results = new ArrayList<>();
for (int line = 0; line < maxLineCount; line++) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < elementLines.size(); i++) {
List<String> element = elementLines.get(i);
int elementHeight = lineCounts.get(i);
int elementCenter = elementHeight / 2;
int elementWidth = lineLengths.get(i);
// Determine if this line aligns with the element
boolean lineAligned = !(line < centerLine - elementCenter ||
line > centerLine - elementCenter + elementHeight - 1);
if (!lineAligned) {
// Line doesn't align - fill with spaces
sb.append(generateString(NBSP, elementWidth));
} else {
// Line aligns - show content
int elementLine = line - (centerLine - elementCenter);
if (elementLine < element.size()) {
String content = element.get(elementLine);
sb.append(content);
// Pad if needed
int contentLength = htmlLength(content);
if (contentLength < elementWidth) {
sb.append(generateString(NBSP, elementWidth - contentLength));
}
} else {
sb.append(generateString(NBSP, elementWidth));
}
}
// Add separator after each element except the last
if (i < elementLines.size() - 1) {
// Only add separator on the center line
if (line == centerLine) {
// Check if the current element ends with a box character
String currentLine = sb.toString();
if (currentLine.endsWith(BOXDL) || currentLine.endsWith(BOXUL)) {
// If it ends with a box character, just add a single dash
sb.append(BOXH);
} else {
// Otherwise add normal separator
sb.append(separator);
}
} else {
// Don't add any separator on non-center lines
sb.append(NBSP);
}
}
}
results.add(sb.toString());
}
return results;
}
public static String generateString(String seed, int n) {
if (n <= 0) return "";
return String.join("", Collections.nCopies(n, seed));
}
public static int htmlLength(String s) {
if (s == null) return 0;
return s.replaceAll("\\&.*?\\;", "x").length();
}
}
@@ -1,101 +0,0 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import org.apache.log4j.Logger;
import org.diylc.lang.LangUtil;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class ResourceUtils {
private static final Logger LOG = Logger.getLogger(ResourceUtils.class);
public static Map<String, String> getResourceContents(String dir) {
Map<String, String> contents = new HashMap<>();
try {
// Get all resources in the directory
URL dirUrl = ResourceUtils.class.getClassLoader().getResource(dir);
if (dirUrl != null) {
if (dirUrl.getProtocol().equals("jar")) {
// Running from JAR
String jarPath = dirUrl.getPath();
// Remove the "file:" prefix and decode the URL
jarPath = URLDecoder.decode(jarPath.substring(5, jarPath.indexOf("!")), StandardCharsets.UTF_8);
JarFile jarFile = new JarFile(jarPath);
try {
jarFile.stream()
.filter(entry -> entry.getName().startsWith(dir + "/") && !entry.isDirectory())
.forEach(entry -> {
try {
String relativePath = entry.getName().substring(dir.length() + 1);
// Read the entire file content as string
String content = new String(jarFile.getInputStream(entry).readAllBytes(), StandardCharsets.UTF_8);
contents.put(relativePath, content);
} catch (IOException e) {
LOG.warn("Could not read resource: " + entry.getName(), e);
}
});
} finally {
try {
jarFile.close();
} catch (IOException e) {
LOG.warn("Could not close JAR file", e);
}
}
} else {
// Running from filesystem
java.io.File dirFile = new java.io.File(dirUrl.toURI());
if (dirFile.exists() && dirFile.isDirectory()) {
java.io.File[] files = dirFile.listFiles();
if (files != null) {
for (java.io.File file : files) {
if (file.isFile()) {
try {
String relativePath = file.getName();
String content = new String(java.nio.file.Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
contents.put(relativePath, content);
} catch (IOException e) {
LOG.warn("Could not read file: " + file, e);
}
}
}
}
}
}
}
} catch (Exception e) {
LOG.error("Error loading resources from directory: " + dir, e);
}
return contents;
}
}
@@ -1,42 +0,0 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
public class ScaledBufferedImage extends BufferedImage {
private final double scaleFactor;
public ScaledBufferedImage(int width, int height, int imageType, double scaleFactor) {
super((int) Math.round(width * scaleFactor), (int) Math.round(height * scaleFactor), imageType);
this.scaleFactor = scaleFactor;
}
@Override
public Graphics2D createGraphics() {
Graphics2D returnValue = super.createGraphics();
returnValue.scale(scaleFactor, scaleFactor);
return returnValue;
}
}
@@ -1,76 +0,0 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.utils;
import org.diylc.core.ISwitch;
import java.util.*;
public class SwitchUtils {
public static String[] getSwitchingMarkers(ISwitch switchComponent, int numPoints, boolean verbose) {
String[] markers = new String[numPoints];
List<List<Set<Integer>>> switchingMatrix = new ArrayList<>();
for (int p = 0; p < switchComponent.getPositionCount(); p++) {
List<Set<Integer>> connectedPoints = new ArrayList<>();
switchingMatrix.add(connectedPoints);
for (int i = 0; i < numPoints - 1; i++) {
for (int j = i + 1; j < numPoints; j++) {
if (switchComponent.arePointsConnected(i, j, p)) {
connectedPoints.add(Set.of(i, j));
}
}
}
}
List<Integer> commonPoints = new ArrayList<>();
for (int i = 0; i < numPoints; i++) {
final int finalI = i;
if (!switchingMatrix.stream().allMatch(
l -> l.isEmpty()) &&
switchingMatrix.stream().allMatch(
l -> l.isEmpty() ||
l.stream().anyMatch(
s -> s.contains(finalI)))) {
markers[i] = String.valueOf((char)((int)'A' + commonPoints.size()));
commonPoints.add(i);
}
}
for (int p = 0; p < switchComponent.getPositionCount(); p++) {
for (int c : commonPoints) {
for (int i = 0; i < numPoints; i++) {
if (commonPoints.contains(i)) {
continue;
}
if (switchComponent.arePointsConnected(Math.min(c, i), Math.max(c, i), p)) {
String marker = verbose ? markers[c] + (p + 1) : Integer.toString(p + 1);
if (markers[i] == null) {
markers[i] = marker;
} else {
markers[i] += "," + marker;
}
}
}
}
}
return markers;
}
}
@@ -1,24 +1,24 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.announcements;
import java.io.Serializable;
@@ -1,43 +1,41 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.announcements;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.diylc.appframework.miscutils.ConfigurationManager;
import com.diyfever.httpproxy.PhpFlatProxy;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.plugins.cloud.model.IServiceAPI;
import com.diyfever.httpproxy.PhpFlatProxy;
import com.diyfever.httpproxy.ProxyFactory;
import org.diylc.plugins.cloud.model.IServiceAPI;
public class AnnouncementProvider {
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 IAnnouncementService service;
@@ -57,20 +55,20 @@ public class AnnouncementProvider {
ConfigurationManager.getInstance().readString(IServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api/v1");
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
service = factory.createProxy(IAnnouncementService.class, serviceUrl);
}
private String getUserId() {
String userId = ConfigurationManager.getInstance().readString(USER_ID_KEY, null);
if (userId == null) {
userId = UUID.randomUUID().toString();
ConfigurationManager.getInstance().writeValue(USER_ID_KEY, userId);
}
return userId;
}
private String getUserId() {
String userId = ConfigurationManager.getInstance().readString(USER_ID_KEY, null);
if (userId == null) {
userId = UUID.randomUUID().toString();
ConfigurationManager.getInstance().writeValue(USER_ID_KEY, userId);
}
return userId;
}
public String getCurrentAnnouncements(boolean forceLast) throws ParseException {
announcements = service.getAnnouncements(getUserId());
if (announcements == null)
announcements = service.getAnnouncements(getUserId());
if (announcements == null)
return null;
boolean hasUnread = false;
StringBuilder sb = new StringBuilder("<html>");
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.announcements;
package org.diylc.announcements;
import java.util.List;
import com.diyfever.httpproxy.ParamName;
public interface IAnnouncementService {
public List<Announcement> getAnnouncements(@ParamName("userId")String userId);
}
import com.diyfever.httpproxy.ParamName;
public interface IAnnouncementService {
public List<Announcement> getAnnouncements(@ParamName("userId")String userId);
}
@@ -19,8 +19,8 @@
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.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
@@ -28,56 +28,55 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
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.
*
* @author Branislav Stojkovic
*/
public class ComponentTransferable implements Transferable, Serializable {
private static final long serialVersionUID = 1L;
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.
*
* @author Branislav Stojkovic
*/
public class ComponentTransferable implements Transferable, Serializable {
private static final long serialVersionUID = 1L;
public static final DataFlavor listFlavor = new DataFlavor(ComponentTransferable.class, "application/diylc");
private List<IDIYComponent<?>> components;
private Set<Set<IDIYComponent<?>>> groups;
public ComponentTransferable() {
super();
private Set<Set<IDIYComponent<?>>> groups;
public ComponentTransferable() {
super();
}
public ComponentTransferable(List<IDIYComponent<?>> components) {
super();
this.components = components;
this.groups = null;
}
public ComponentTransferable(List<IDIYComponent<?>> components, Set<Set<IDIYComponent<?>>> groups) {
}
public ComponentTransferable(List<IDIYComponent<?>> components, Set<Set<IDIYComponent<?>>> groups) {
super();
this.components = components;
this.groups = groups;
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(listFlavor)) {
return this;
}
throw new UnsupportedFlavorException(flavor);
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] {listFlavor};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(listFlavor);
this.groups = groups;
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(listFlavor)) {
return this;
}
throw new UnsupportedFlavorException(flavor);
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] {listFlavor};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(listFlavor);
}
public List<IDIYComponent<?>> getComponents() {
@@ -86,5 +85,5 @@ public class ComponentTransferable implements Transferable, Serializable {
public Set<Set<IDIYComponent<?>>> getGroups() {
return groups;
}
}
}
}
@@ -25,7 +25,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
import org.diylc.core.IDIYComponent;
public class ComponentTransferableFactory {
@@ -0,0 +1,20 @@
package org.diylc.common;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.EnumSet;
public abstract class AbstractPlugin implements IPlugIn {
protected IPlugInPort plugInPort;
@Override
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
}
@Override
public abstract EnumSet<EventType> getSubscribedEventTypes();
@Override
public abstract void processMessage(EventType eventType, Object... params);
}
@@ -19,10 +19,10 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public class BadPositionException extends Exception {
private static final long serialVersionUID = 1L;
}
package org.diylc.common;
public class BadPositionException extends Exception {
private static final long serialVersionUID = 1L;
}
@@ -1,28 +1,27 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.util.Collection;
import java.util.Collection;
import org.diylc.core.IDIYComponent;
public class BuildingBlock {
@@ -23,7 +23,6 @@ package org.diylc.common;
import java.util.List;
import java.util.Map;
import org.diylc.core.IDIYComponent;
public class BuildingBlockPackage {
@@ -20,7 +20,6 @@ package org.diylc.common;
import java.io.Serializable;
import java.util.List;
import javax.swing.Icon;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
import org.diylc.core.annotations.BomPolicy;
@@ -5,7 +5,6 @@ import java.awt.geom.Point2D;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.apache.log4j.Logger;
import org.diylc.core.Angle;
import org.diylc.core.IDIYComponent;
import org.diylc.presenter.ComponentProcessor;
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum Display {
NAME, VALUE, NONE, BOTH;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum Display {
NAME, VALUE, NONE, BOTH;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -1,24 +1,24 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.awt.Graphics;
@@ -56,17 +56,17 @@ public enum DrawOption {
/**
* Draw components in outline mode.
*/
OUTLINE_MODE,
/**
* Include extra space around the layout.
*/
EXTRA_SPACE,
/**
* Whether components should be cached or not.
*/
ENABLE_CACHING,
/**
* Whether locked components should be rendered as transparent or not.
*/
OUTLINE_MODE,
/**
* Include extra space around the layout.
*/
EXTRA_SPACE,
/**
* Whether components should be cached or not.
*/
ENABLE_CACHING,
/**
* Whether locked components should be rendered as transparent or not.
*/
LOCKED_ALPHA;
}
@@ -1,29 +1,28 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import org.diylc.core.Project;
/**
@@ -85,7 +84,7 @@ public enum EventType {
AVAILABLE_CTRL_POINTS_CHANGED,
/**
* 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
*/
MOUSE_MOVED,
@@ -102,9 +101,9 @@ public enum EventType {
/**
* Called to update the status message. New status message is passed as a first parameter.
*/
STATUS_MESSAGE_CHANGED,
/**
* Signals the listeners to scroll to selection.
*/
STATUS_MESSAGE_CHANGED,
/**
* Signals the listeners to scroll to selection.
*/
SCROLL_TO;
}
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum GridType {
LINES, CROSSHAIR, DOT, NONE;
}
package org.diylc.common;
public enum GridType {
LINES, CROSSHAIR, DOT, NONE;
}
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum HorizontalAlignment {
LEFT, CENTER, RIGHT;
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum HorizontalAlignment {
LEFT, CENTER, RIGHT;
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -19,32 +19,32 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
package org.diylc.common;
import java.io.IOException;
public interface IBlockProcessor {
public interface IBlockProcessor {
public static final String BLOCKS_KEY = "buildingBlocks";
public static final String DEFAULT_BLOCKS_IMPORTED_KEY = "defaultBlocksImported";
void saveSelectionAsBlock(String blockName);
void loadBlock(String blockName) throws InvalidBlockException;
public static final String DEFAULT_BLOCKS_IMPORTED_KEY = "defaultBlocksImported";
void saveSelectionAsBlock(String blockName);
void loadBlock(String blockName) throws InvalidBlockException;
void deleteBlock(String blockName);
int importBlocks(String fileName) throws IOException;
public class BlockAlreadyExistsException extends Exception {
private static final long serialVersionUID = 1L;
}
public class InvalidBlockException extends Exception {
private static final long serialVersionUID = 1L;
}
}
int importBlocks(String fileName) throws IOException;
public class BlockAlreadyExistsException extends Exception {
private static final long serialVersionUID = 1L;
}
public class InvalidBlockException extends Exception {
private static final long serialVersionUID = 1L;
}
}
@@ -19,11 +19,11 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import org.diylc.core.IDIYComponent;
public interface IComponentFilter {
boolean testComponent(IDIYComponent<?> component);
}
package org.diylc.common;
import org.diylc.core.IDIYComponent;
public interface IComponentFilter {
boolean testComponent(IDIYComponent<?> component);
}
@@ -19,27 +19,26 @@
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 org.diylc.core.IDIYComponent;
public interface IComponentTransformer {
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;
boolean canRotate(IDIYComponent<?> component);
boolean canMirror(IDIYComponent<?> component);
boolean mirroringChangesCircuit();
void rotate(IDIYComponent<?> component, Point2D center, int direction);
void mirror(IDIYComponent<?> component, Point2D center, int direction);
}
import org.diylc.core.IDIYComponent;
public interface IComponentTransformer {
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;
boolean canRotate(IDIYComponent<?> component);
boolean canMirror(IDIYComponent<?> component);
boolean mirroringChangesCircuit();
void rotate(IDIYComponent<?> component, Point2D center, int direction);
void mirror(IDIYComponent<?> component, Point2D center, int direction);
}
@@ -1,24 +1,24 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public interface IKeyProcessor {
@@ -1,24 +1,24 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.awt.Point;
@@ -22,8 +22,6 @@
package org.diylc.common;
import java.util.List;
import java.util.Set;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.Node;
import org.diylc.netlist.Summary;
@@ -60,9 +58,4 @@ public interface INetlistAnalyzer {
* @return name of the font to be used for display.
*/
String getFontName();
/**
* @return ability to process netlists with or without switches included.
*/
Set<NetlistSwitchPreference> getSwitchPreference();
}
@@ -22,7 +22,6 @@
package org.diylc.common;
import java.util.List;
import org.diylc.netlist.INetlistParser;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.NetlistException;
@@ -19,22 +19,22 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import org.diylc.appframework.simplemq.IMessageListener;
/**
* Interface for plug-ins.
*
* @author Branislav Stojkovic
*/
public interface IPlugIn extends IMessageListener<EventType> {
/**
* Method that connects the plug-in with {@link IPlugInPort}. Called by the application when
* plug-in is installed.
*
* @param plugInPort
*/
void connect(IPlugInPort plugInPort);
}
package org.diylc.common;
import org.diylc.appframework.simplemq.IMessageListener;
/**
* Interface for plug-ins.
*
* @author Branislav Stojkovic
*/
public interface IPlugIn extends IMessageListener<EventType> {
/**
* Method that connects the plug-in with {@link IPlugInPort}. Called by the application when
* plug-in is installed.
*
* @param plugInPort
*/
void connect(IPlugInPort plugInPort);
}
@@ -1,48 +1,47 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.diylc.appframework.simplemq.IMessageListener;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.appframework.update.Version;
import org.diylc.appframework.update.VersionNumber;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.Template;
import org.diylc.core.Theme;
import org.diylc.core.measures.Size;
import org.diylc.test.ITestProcessor;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.diylc.appframework.simplemq.IMessageListener;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.appframework.update.Version;
import org.diylc.appframework.update.VersionNumber;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.Template;
import org.diylc.core.Theme;
import org.diylc.core.measures.Size;
import org.diylc.test.ITestProcessor;
/**
* Interface for communication between plug-ins and the application. Plug-ins may acquire
@@ -61,11 +60,10 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
public static final String ANTI_ALIASING_KEY = "antiAliasing";
public static final String HI_QUALITY_RENDER_KEY = "hiQualityRender";
public static final String HIGH_DPI_RENDERING = "hiDpiRendering";
public static final String EXPORT_GRID_KEY = "exportGrid";
public static final String STICKY_POINTS_KEY = "stickyPoints";
public static final String METRIC_KEY = "metric";
public static final String SNAP_TO_KEY = "snapTo";
public static final String CONTINUOUS_CREATION_KEY = "continuousCreation";
public static final String AUTO_EDIT_KEY = "autoEdit";
@@ -77,26 +75,27 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
public static final String RECENT_COMPONENTS_KEY = "recentComponents";
public static final String RECENT_FILES_KEY = "recentFiles";
public static final String SHOW_RULERS_KEY = "showRulers";
public static final String SHOW_GRID_KEY = "showGrid";
public static final String HARDWARE_ACCELERATION = "hardwareAcceleration";
public static final String EXTRA_SPACE_KEY = "extraSpace";
public static final String FAVORITES_KEY = "favorites";
public static final String RENUMBER_ON_PASTE_KEY = "renumberOnPaste";
public static final String RULER_IN_SUBDIVISION_KEY = "rulerInSubdivision";
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_10 = "base of 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_GRID = "Grid";
public static final String SNAP_TO_COMPONENTS = "Components";
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
public static final String LOCKED_ALPHA = "lockedAlpha";
public static final String LANGUAGE = "language";
public static final String SHOW_GRID_KEY = "showGrid";
public static final String HIGHLIGHT_CONTINUITY_AREA = "highlightContinuityArea";
public static final String HARDWARE_ACCELERATION = "hardwareAcceleration";
public static final String EXTRA_SPACE_KEY = "extraSpace";
public static final String FAVORITES_KEY = "favorites";
public static final String RENUMBER_ON_PASTE_KEY = "renumberOnPaste";
public static final String RULER_IN_SUBDIVISION_KEY = "rulerInSubdivision";
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_10 = "base of 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_GRID = "Grid";
public static final String SNAP_TO_COMPONENTS = "Components";
public static final String SNAP_TO_DEFAULT = SNAP_TO_GRID;
public static final String LOCKED_ALPHA = "lockedAlpha";
public static final String LANGUAGE = "language";
public static final String LANGUAGE_DEFAULT = "English";
public static final int DND_TOGGLE_STICKY = 0x1;
@@ -115,7 +114,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
* unit. If <code>useZoom</code> is set to true, the result is scaled by zoom factor.
*
* @param useZoom
* @param useZoom
* @param includeExtraSpace
*
* @return canvas dimensions
@@ -127,9 +126,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
*
* Note: point coordinates are scaled for zoom factor.
*
* @param point
* @param ctrlDown
* @param shiftDown
* @param point
* @param ctrlDown
* @param shiftDown
* @param altDown
* @return cursor
*/
@@ -146,8 +145,8 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* Loads specified {@link Project}.
*
* @param project
* @param freshStart
* @param filename file name when loading from a file
* @param freshStart
* @param optional file name when loading from a file
*/
void loadProject(Project project, boolean freshStart, String filename);
@@ -169,14 +168,14 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* @param fileName
* @param isBackup
*/
void saveProjectToFile(String fileName, boolean isBackup);
/**
* Exports the current project into one or more files - one per layer and potentially drill layer.
*
* @param fileNameBase
* @param g2d
*/
void saveProjectToFile(String fileName, boolean isBackup);
/**
* Exports the current project into one or more files - one per layer and potentially drill layer.
*
* @param fileNameBase
* @param g2d
*/
void exportToGerber(String fileNameBase, Graphics2D g2d);
/**
@@ -211,9 +210,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
*
* @param g2d
* @param drawOptions specific drawing options
* @param filter
* @param externalZoom
* @param scaleFactor
* @param filter
* @param externalZoom
* @param scaleFactor
* @param visibleRect
*/
void draw(Graphics2D g2d, Set<DrawOption> drawOptions, IComponentFilter filter, Double externalZoom, Double scaleFactor, Rectangle2D visibleRect);
@@ -239,20 +238,20 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
*
* @return
*/
VersionNumber getCurrentVersionNumber();
/**
* Returns few most recent versions.
*
* @return
*/
VersionNumber getCurrentVersionNumber();
/**
* Returns few most recent versions.
*
* @return
*/
List<Version> getRecentUpdates();
/**
* Adds a list of components to the project.
*
* @param componentTransferable
* @param autoGroup
* @param componentTransferable
* @param autoGroup
* @param assignNewNames
*/
void pasteComponents(ComponentTransferable componentTransferable, boolean autoGroup, boolean assignNewNames);
@@ -318,8 +317,8 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
* component.
*
* @param componentType
* @param template optional
* @param model optional datasheet model
* @param template optional
* @param model optional datasheet model
* @param forceInstatiate
*/
void setNewComponentTypeSlot(ComponentType componentType, Template template, String[] model, boolean forceInstatiate);
@@ -374,41 +373,29 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
*
* @param xAxisFirst
*/
void renumberSelectedComponents(boolean xAxisFirst);
/**
* @return size of extra space around the canvas
*/
double getExtraSpace();
/**
* Applies changes to the current project as specified by the provided {@link IProjectEditor}.
*
* @param editor
*/
void applyEditor(IProjectEditor editor);
/**
* Locks or unlocks a single component.
*/
void lockComponent(IDIYComponent<?> c, boolean locked);
/**
* Checks for proximity between continuity areas and creates additional components around any problematic areas to visually identify them.
*
* @param threshold
*/
void renumberSelectedComponents(boolean xAxisFirst);
/**
* @return size of extra space around the canvas
*/
double getExtraSpace();
/**
* Applies changes to the current project as specified by the provided {@link IProjectEditor}.
*
* @param editor
*/
void applyEditor(IProjectEditor editor);
/**
* Locks or unlocks a single component.
*/
void lockComponent(IDIYComponent<?> c, boolean locked);
/**
* Checks for proximity between continuity areas and creates additional components around any problematic areas to visually identify them.
*
* @param threshold
*/
List<Area> checkContinuityAreaProximity(Size threshold);
/**
* @return the current operation mode of the application
*/
OperationMode getOperationMode();
/**
* Updates the current operation mode of the application
*
* @param operationMode
*/
void setOperationMode(OperationMode operationMode);
}
@@ -22,7 +22,6 @@
package org.diylc.common;
import java.util.Set;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
@@ -1,34 +1,33 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Collection;
import java.util.List;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.ExpansionMode;
import org.diylc.core.IDIYComponent;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Collection;
import java.util.List;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.core.ExpansionMode;
import org.diylc.core.IDIYComponent;
import org.diylc.core.measures.Size;
public interface ISelectionProcessor {
@@ -38,20 +37,20 @@ public interface ISelectionProcessor {
*
* @return
*/
Collection<IDIYComponent<?>> getSelectedComponents();
/**
* Returns selected component types
*
* @return
*/
Collection<IDIYComponent<?>> getSelectedComponents();
/**
* Returns selected component types
*
* @return
*/
Collection<ComponentType> getSelectedComponentTypes();
/**
* 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.
*
* @param newSelection
* @param newSelection
* @param panToSelection
*/
void setSelection(Collection<IDIYComponent<?>> newSelection, boolean panToSelection);
@@ -60,7 +59,7 @@ public interface ISelectionProcessor {
* Finds all components at the specified location, sorted by z-index from top to bottom. Location
* depends on the current zoom level.
*
* @param point
* @param point
* @param includeLocked
* @return
*/
@@ -109,8 +108,8 @@ public interface ISelectionProcessor {
/**
* Returns the minimum rectangle containing all selected components, or null if none exists.
* Rectangle is scaled by the current zoom level.
*
* @param applyZoom
*
* @param applyZoom
*
* @return
*/
@@ -123,36 +122,36 @@ public interface ISelectionProcessor {
* @param yOffset
* @param includeStuckComponents
*/
void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents);
/**
* Selects components that match the criteria.
*
* @param criteria
*/
void selectMatching(String criteria);
/**
* Attempts to apply the specified model to all selected components.
*
* @param model
*/
void applyModelToSelection(String[] model);
/**
* Sends each of the selected components one step back.
*/
void sendSelectionToBack();
/**
* Brings each of the selected components one step to front.
*/
void bringSelectionToFront();
/**
* Move selected components to z index starting from the provided value
* @param zIndex
*/
void nudgeSelection(Size xOffset, Size yOffset, boolean includeStuckComponents);
/**
* Selects components that match the criteria.
*
* @param criteria
*/
void selectMatching(String criteria);
/**
* Attempts to apply the specified model to all selected components.
*
* @param model
*/
void applyModelToSelection(String[] model);
/**
* Sends each of the selected components one step back.
*/
void sendSelectionToBack();
/**
* Brings each of the selected components one step to front.
*/
void bringSelectionToFront();
/**
* Move selected components to z index starting from the provided value
* @param zIndex
*/
void moveSelectionToZIndex(int zIndex);
}
@@ -1,24 +1,24 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
/**
@@ -19,38 +19,37 @@
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.util.List;
import org.diylc.core.Template;
public interface IVariantProcessor {
public interface IVariantProcessor {
public static final String TEMPLATES_KEY = "templates";
public static final String DEFAULT_TEMPLATES_KEY = "defaultTemplates";
public static final String DEFAULT_TEMPLATES_IMPORT_DATE_KEY = "defaultTemplatesImportDate";
void saveSelectedComponentAsVariant(String variantName);
List<Template> getVariantsFor(ComponentType type);
List<Template> getVariantsForSelection();
void applyVariantToSelection(Template variant);
void deleteVariant(ComponentType type, String variantName);
public static final String DEFAULT_TEMPLATES_IMPORT_DATE_KEY = "defaultTemplatesImportDate";
void saveSelectedComponentAsVariant(String variantName);
List<Template> getVariantsFor(ComponentType type);
List<Template> getVariantsForSelection();
void applyVariantToSelection(Template variant);
void deleteVariant(ComponentType type, String variantName);
void setDefaultVariant(ComponentType type, String variantName);
int importVariants(String fileName) throws IOException;
String getDefaultVariant(ComponentType type);
public class VariantAlreadyExistsException extends Exception {
private static final long serialVersionUID = 1L;
}
}
String getDefaultVariant(ComponentType type);
public class VariantAlreadyExistsException extends Exception {
private static final long serialVersionUID = 1L;
}
}
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum LabelPosition {
ABOVE, BELOW;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum LabelPosition {
ABOVE, BELOW;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum LineStyle {
SOLID, DASHED, DOTTED;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum LineStyle {
SOLID, DASHED, DOTTED;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -19,28 +19,38 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum Orientation {
DEFAULT, _90, _180, _270;
@Override
public String toString() {
if (this == DEFAULT) {
return "Default";
} else {
return name().replace("_", "") + " degrees clockwise";
}
package org.diylc.common;
public enum Orientation {
DEFAULT, _90, _180, _270;
@Override
public String toString() {
if (this == DEFAULT) {
return "Default";
} else {
return name().replace("_", "") + " degrees clockwise";
}
}
public double toDegrees() {
if (this == DEFAULT)
return 0;
return Integer.parseInt(name().replace("_", ""));
switch (this) {
case DEFAULT:
return 0;
case _180:
return 180;
case _270:
return 270;
case _90:
return 90;
default:
break;
}
return 0;
}
public double toRadians() {
return Math.toRadians(toDegrees());
}
}
}
}
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum OrientationHV {
VERTICAL, HORIZONTAL;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum OrientationHV {
VERTICAL, HORIZONTAL;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -23,18 +23,18 @@ package org.diylc.common;
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");
private String label;
private PCBLayer(String label) {
this.label = label;
}
public String toString() {
return label;
}
public String toString() {
return label;
};
public int getId() {
@@ -48,5 +48,5 @@ public enum PCBLayer {
default:
throw new RuntimeException("Unsupported PCB layer: " + this);
}
}
}
}
}
@@ -1,30 +1,28 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.diylc.core.IDynamicPropertySource;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.diylc.core.IPropertyValidator;
/**
@@ -46,10 +44,9 @@ public class PropertyWrapper implements Cloneable {
private boolean changed = false;
private int sortOrder;
private Object ownerObject;
private IDynamicPropertySource dynamicPropertySource;
public PropertyWrapper(String name, Class<?> type, String getter, String setter, boolean defaultable,
IPropertyValidator validator, int sortOrder, IDynamicPropertySource dynamicPropertySource) {
IPropertyValidator validator, int sortOrder) {
super();
this.name = name;
this.type = type;
@@ -58,7 +55,6 @@ public class PropertyWrapper implements Cloneable {
this.defaultable = defaultable;
this.validator = validator;
this.sortOrder = sortOrder;
this.dynamicPropertySource = dynamicPropertySource;
this.ownerObject = null;
}
@@ -78,19 +74,19 @@ public class PropertyWrapper implements Cloneable {
// }
public void writeTo(Object object) throws IllegalArgumentException, IllegalAccessException,
InvocationTargetException, SecurityException, NoSuchMethodException {
// nothing to do if no setter
if (setter == null)
InvocationTargetException, SecurityException, NoSuchMethodException {
// nothing to do if no setter
if (setter == null)
return;
object.getClass().getMethod(setter, type).invoke(object, this.value);
}
public Method getGetter() throws SecurityException, NoSuchMethodException {
return getOwnerObject().getClass().getMethod(getter);
}
public boolean isReadOnly() {
return setter == null;
}
public boolean isReadOnly() {
return setter == null;
}
public String getName() {
@@ -141,10 +137,6 @@ public class PropertyWrapper implements Cloneable {
return sortOrder;
}
public IDynamicPropertySource getDynamicPropertySource() {
return dynamicPropertySource;
}
// @Override
// public Object clone() throws CloneNotSupportedException {
// // Try to invoke clone method on value if possible.
@@ -159,7 +151,7 @@ public class PropertyWrapper implements Cloneable {
public Object clone() throws CloneNotSupportedException {
PropertyWrapper clone =
new PropertyWrapper(this.name, this.type, this.getter, this.setter, this.defaultable, this.validator,
this.sortOrder, this.dynamicPropertySource);
this.sortOrder);
clone.value = this.value;
clone.changed = this.changed;
clone.unique = this.unique;
@@ -19,17 +19,17 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum ResistorColorCode {
NONE, _4_BAND, _5_BAND;
@Override
public String toString() {
if (name().startsWith("_")) {
return name().substring(1).replace("_", " ").toLowerCase();
}
return name().substring(0, 1).toUpperCase() + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum ResistorColorCode {
NONE, _4_BAND, _5_BAND;
@Override
public String toString() {
if (name().startsWith("_")) {
return name().substring(1).replace("_", " ").toLowerCase();
}
return name().substring(0, 1).toUpperCase() + name().substring(1).toLowerCase();
}
}
@@ -23,7 +23,6 @@ package org.diylc.common;
import java.util.List;
import java.util.Map;
import org.diylc.core.Template;
public class VariantPackage {
@@ -19,12 +19,12 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.common;
public enum VerticalAlignment {
TOP, CENTER, BOTTOM;
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
package org.diylc.common;
public enum VerticalAlignment {
TOP, CENTER, BOTTOM;
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase();
}
}
@@ -22,7 +22,6 @@
package org.diylc.components;
import java.awt.Shape;
import org.diylc.common.Orientation;
import org.diylc.core.Angle;
import org.diylc.core.annotations.EditableProperty;
@@ -1,41 +1,40 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components;
import java.awt.Color;
import java.awt.Font;
import java.awt.Shape;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import java.awt.Color;
import java.awt.Font;
import java.awt.Shape;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
/**
* Abstract implementation of {@link IDIYComponent} that contains component name and toString.
@@ -58,14 +57,14 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
public static Color LABEL_COLOR = Color.black;
public static Color LABEL_COLOR_SELECTED = Color.red;
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 COPPER_COLOR = Color.decode("#DA8A67");
public static Color GOLD_COLOR = Color.decode("#F4B301");
public static Color FR4_COLOR = Color.decode("#6B9B6B");
public static Color FR4_LIGHT_COLOR = Color.decode("#BABE71");
public static Color PHENOLIC_COLOR = Color.decode("#F8EBB3");
public static Color PHENOLIC_DARK_COLOR = Color.decode("#CD8500");
public static Color COPPER_COLOR = Color.decode("#DA8A67");
public static Color GOLD_COLOR = Color.decode("#F4B301");
public static Color FR4_COLOR = Color.decode("#6B9B6B");
public static Color FR4_LIGHT_COLOR = Color.decode("#BABE71");
public static Color PHENOLIC_COLOR = Color.decode("#F8EBB3");
public static Color PHENOLIC_DARK_COLOR = Color.decode("#CD8500");
@EditableProperty(defaultable = false)
@Override
@@ -89,13 +88,13 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
}
@Override
public String getValueForDisplay() {
if (getValue() == null)
return "";
Object val = getValue();
if (val.getClass().isArray()) {
return String.join(" / ", Arrays.stream((Object[])val).map(x -> x == null ? "" : x.toString()).collect(Collectors.toList()));
public String getValueForDisplay() {
if (getValue() == null)
return "";
Object val = getValue();
if (val.getClass().isArray()) {
return String.join(" / ", Arrays.stream((Object[])val).map(x -> x == null ? "" : x.toString()).collect(Collectors.toList()));
}
return val.toString();
}
@@ -108,17 +107,17 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
*/
protected int getClosestOdd(double x) {
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.
*
* @param x
* @return
*/
protected int getClosestOdd(Size s) {
double x = s.convertToPixels();
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.
*
* @param x
* @return
*/
protected int getClosestOdd(Size s) {
double x = s.convertToPixels();
return ((int) x / 2) * 2 + 1;
}
/**
@@ -137,9 +136,9 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
* @param clip
* @return true if none of the control points lie in the clip rectangle.
*/
protected boolean checkPointsClipped(Shape clip) {
if (clip == null) {
return false;
protected boolean checkPointsClipped(Shape clip) {
if (clip == null) {
return false;
}
for (int i = 0; i < getControlPointCount(); i++) {
if (clip.contains(getControlPoint(i))) {
@@ -172,7 +171,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
@SuppressWarnings("unchecked")
public IDIYComponent<T> clone() throws CloneNotSupportedException {
try {
// Instantiate object of the same type
// Instantiate object of the same type
Class<?> clazz = this.getClass();
AbstractComponent<T> newInstance = (AbstractComponent<T>) clazz.getDeclaredConstructor().newInstance();
while (AbstractComponent.class.isAssignableFrom(clazz)) {
@@ -192,7 +191,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
&& value.getClass().getComponentType().isAssignableFrom(Point2D.class)) {
Object newArray = Array.newInstance(value.getClass().getComponentType(), Array.getLength(value));
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)
Array.set(newArray, i, new Point2D.Double(p.getX(), p.getY()));
}
@@ -200,7 +199,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
}
// Deep copy points.
// TODO: something nicer
if (value != null && value instanceof Point2D) {
if (value != null && value instanceof Point2D) {
Point2D p = (Point2D) value;
value = new Point2D.Double(p.getX(), p.getY());
}
@@ -213,7 +212,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
} catch (Exception e) {
throw new CloneNotSupportedException("Could not clone the component. Reason: " + e.getMessage());
}
}
}
@Override
public boolean equalsTo(IDIYComponent<?> other) {
@@ -230,7 +229,7 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
// in
// AbstractComponent or one of it's child classes
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())) {
field.setAccessible(true);
try {
@@ -252,45 +251,45 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
return true;
if (o1 == null || o2 == null)
return false;
if (o1.getClass().isArray()) {
if (o1.getClass().getComponentType() == byte.class)
return Arrays.equals((byte[]) o1, (byte[]) o2);
if (o1.getClass().getComponentType() == double.class)
return Arrays.equals((double[]) o1, (double[]) o2);
if (o1.getClass().getComponentType() == int.class)
if (o1.getClass().isArray()) {
if (o1.getClass().getComponentType() == byte.class)
return Arrays.equals((byte[]) o1, (byte[]) o2);
if (o1.getClass().getComponentType() == double.class)
return Arrays.equals((double[]) o1, (double[]) o2);
if (o1.getClass().getComponentType() == int.class)
return Arrays.equals((int[]) o1, (int[]) o2);
return Arrays.equals((Object[]) o1, (Object[]) o2);
}
return o1.equals(o2);
}
@Override
public String getControlPointNodeName(int index) {
return Integer.toString(index + 1);
}
@Override
public String getInternalLinkName(int index1, int index2) {
return null;
}
@Override
public String[] getSectionNames(int pointIndex) {
return null;
}
@Override
public boolean canPointMoveFreely(int pointIndex) {
return true;
}
@Override
public Rectangle2D getCachingBounds() {
return null;
}
@Override
public void createdIn(Project project) {
// TODO Auto-generated method stub
}
@Override
public String getControlPointNodeName(int index) {
return Integer.toString(index + 1);
}
@Override
public String getInternalLinkName(int index1, int index2) {
return null;
}
@Override
public String[] getSectionNames(int pointIndex) {
return null;
}
@Override
public boolean canPointMoveFreely(int pointIndex) {
return true;
}
@Override
public Rectangle2D getCachingBounds() {
return null;
}
@Override
public void createdIn(Project project) {
// TODO Auto-generated method stub
}
}
@@ -30,10 +30,6 @@ import java.util.List;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
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.LineStyle;
import org.diylc.common.ObjectCache;
@@ -45,6 +41,8 @@ import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
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> {
@@ -76,7 +74,7 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
* @param curve
* @param g2d
* @param componentState
* @param drawingObserver
* @param theme
*/
protected abstract void drawCurve(Path2D curve, Graphics2D g2d, ComponentState componentState,
IDrawingObserver drawingObserver);
@@ -201,9 +199,6 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
}
public void setPointCount(PointCount pointCount) {
if (this.pointCount == pointCount)
return;
Point2D[] p = getControlPoints();
Point2D[] newPoints = new Point2D[pointCount.count];
newPoints[0] = p[0];
@@ -19,13 +19,13 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components;
import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractLabeledComponent<T> extends AbstractTransparentComponent<T> {
private static final long serialVersionUID = 1L;
package org.diylc.components;
import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractLabeledComponent<T> extends AbstractTransparentComponent<T> {
private static final long serialVersionUID = 1L;
protected Integer fontSizeOverride;
@@ -36,5 +36,5 @@ public abstract class AbstractLabeledComponent<T> extends AbstractTransparentCom
public void setFontSizeOverride(Integer fontSizeOverride) {
this.fontSizeOverride = fontSizeOverride;
}
}
}
}
@@ -19,27 +19,24 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components;
import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> {
private static final long serialVersionUID = 1L;
public static byte MAX_ALPHA = 127;
protected Byte alpha = MAX_ALPHA;
@EditableProperty
public Byte getAlpha() {
if (alpha == null) {
alpha = MAX_ALPHA;
}
return alpha;
}
public void setAlpha(Byte alpha) {
this.alpha = alpha;
}
}
package org.diylc.components;
import org.diylc.core.annotations.EditableProperty;
public abstract class AbstractTransparentComponent<T> extends AbstractComponent<T> {
private static final long serialVersionUID = 1L;
public static byte MAX_ALPHA = 127;
protected byte alpha = MAX_ALPHA;
@EditableProperty
public Byte getAlpha() {
return alpha;
}
public void setAlpha(Byte alpha) {
this.alpha = alpha;
}
}
@@ -1,29 +1,28 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components.transform;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.IDIYComponent;
public class DefaultTransformer implements IComponentTransformer {
@@ -1,30 +1,29 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components.transform;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.IDIYComponent;
public class LeadedComponentTransformer implements IComponentTransformer {
@@ -47,7 +46,7 @@ public class LeadedComponentTransformer implements IComponentTransformer {
@Override
public void rotate(IDIYComponent<?> component, Point2D center, int direction) {
AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2 * direction, center.getX(), center.getY());
for (int index = 0; index < component.getControlPointCount(); index++) {
for (int index = 0; index < component.getControlPointCount(); index++) {
Point2D p = new Point2D.Double();
rotate.transform(component.getControlPoint(index), p);
component.setControlPoint(p, index);
@@ -1,31 +1,30 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.components.transform;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import org.diylc.common.IComponentTransformer;
import org.diylc.core.IDIYComponent;
public class SimpleComponentTransformer implements IComponentTransformer {
@@ -19,15 +19,15 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core;
/**
* Validator that allows all values.
*
* @author Branislav Stojkovic
*/
public class AllowAllValidator implements IPropertyValidator {
@Override
public void validate(Object owner, Object value) throws ValidationException {}
}
package org.diylc.core;
/**
* Validator that allows all values.
*
* @author Branislav Stojkovic
*/
public class AllowAllValidator implements IPropertyValidator {
@Override
public void validate(Object owner, Object value) throws ValidationException {}
}
@@ -1,10 +1,9 @@
package org.diylc.core;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
public class Angle implements Serializable {
public class Angle {
private int value;
@@ -19,14 +19,14 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core;
/**
* Enumerates all possible states that a component can be in.
*
* @author Branislav Stojkovic
*/
public enum ComponentState {
NORMAL, SELECTED, LOCKED, DRAGGING
}
package org.diylc.core;
/**
* Enumerates all possible states that a component can be in.
*
* @author Branislav Stojkovic
*/
public enum ComponentState {
NORMAL, SELECTED, LOCKED, DRAGGING
}
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core;
public enum CreationMethod {
SINGLE_CLICK, POINT_BY_POINT;
}
package org.diylc.core;
public enum CreationMethod {
SINGLE_CLICK, POINT_BY_POINT;
}
@@ -19,9 +19,9 @@
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core;
public enum ExpansionMode {
ALL, SAME_TYPE, IMMEDIATE,
}
package org.diylc.core;
public enum ExpansionMode {
ALL, SAME_TYPE, IMMEDIATE,
}
@@ -1,32 +1,31 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.core;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import org.diylc.core.annotations.ComponentDescriptor;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.Serializable;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
/**
@@ -51,7 +50,7 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
public static final int CHASSIS = 1;
public static final int BOARD = 2;
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 TEXT = 6;
@@ -112,37 +111,37 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
* same component</b>. The other control point must be able to overlap too.
*/
boolean canControlPointOverlap(int index);
/**
* @param index
* @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
/**
* @param index
* @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
*/
boolean canPointMoveFreely(int pointIndex);
/**
@@ -185,18 +184,18 @@ public interface IDIYComponent<T> extends Serializable, Cloneable {
* @param other
* @return
*/
boolean equalsTo(IDIYComponent<?> other);
/**
* Used only if {@link ComponentDescriptor#enableCache()} is set to true.
* @return
*/
Rectangle2D getCachingBounds();
/**
* Notifies the component that it's being created in the context of the specified project
*
* @param project
*/
boolean equalsTo(IDIYComponent<?> other);
/**
* Used only if {@link ComponentDescriptor#enableCache()} is set to true.
* @return
*/
Rectangle2D getCachingBounds();
/**
* Notifies the component that it's being created in the context of the specified project
*
* @param project
*/
void createdIn(Project project);
}

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