Compare commits

..

2 Commits

Author SHA1 Message Date
Branislav Stojkovic 8e20f61946 spring 2025-03-14 10:33:01 +01:00
Bane Stojkovic ad9a575dc6 Update install.iss (#888)
* Update install.iss

* Update update.xml
2025-03-10 10:44:12 +01:00
56 changed files with 2443 additions and 549 deletions
+20 -20
View File
@@ -1,20 +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>
<?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>
+100
View File
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>5.1.0</version>
</parent>
<artifactId>diylc-core</artifactId>
<!-- No need to specify version - it inherits from parent -->
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<!-- Common dependencies from Maven Central -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.4.0-jre</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Local dependencies from lib folder -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>gerber-writer-api-1.0.0</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>java-http-proxy</artifactId>
<version>1.0</version>
</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>
@@ -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
);
}
}
@@ -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);
}
@@ -35,9 +35,19 @@ public enum Orientation {
}
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() {
@@ -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());
}
}
@@ -23,8 +23,6 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.diylc.core.IDIYComponent;
public class Netlist implements Comparable<Netlist> {
@@ -60,6 +58,10 @@ public class Netlist implements Comparable<Netlist> {
return switchSetup;
}
public void done() {
Collections.sort(switchSetup);
}
@Override
public int hashCode() {
final int prime = 31;
@@ -84,16 +86,11 @@ public class Netlist implements Comparable<Netlist> {
return false;
return true;
}
public String getSwitchSetupString() {
return getSwitchSetup().isEmpty() ? "[ ALL ]" : "[ " +
getSwitchSetup().stream().map(x -> x.toString()).collect(Collectors.joining(",")) + " ]";
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Switch setup: ").append(getSwitchSetupString()).append("\n\n");
sb.append("Switch setup: ").append(getSwitchSetup()).append("\n\n");
List<Group> list = getSortedGroups();
for (Group g : list) {
sb.append("\t").append(g).append("\n");
@@ -22,7 +22,6 @@ import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -30,7 +29,6 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import org.apache.log4j.Logger;
import org.diylc.common.ComponentType;
import org.diylc.core.ICommonNode;
@@ -44,7 +42,6 @@ import org.diylc.presenter.ComponentProcessor;
import org.diylc.presenter.Connection;
import org.diylc.presenter.ContinuityArea;
import org.diylc.utils.RTree;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.ImmutableGraph;
import com.google.common.graph.ImmutableGraph.Builder;
@@ -191,29 +188,10 @@ public class NetlistBuilder {
// sort everything alphabetically
List<Netlist> netlists = new ArrayList<Netlist>(result.keySet());
Collections.sort(netlists);
netlists.forEach(netlist -> cleanupRedundantSwitches(netlist.getSwitchSetup()));
return netlists;
}
public static void cleanupRedundantSwitches(List<SwitchSetup> switchSetups) {
Map<ISwitch, Set<Integer>> positionCountMap = new HashMap<>();
switchSetups.forEach(s -> s.getPositions().forEach(pos -> {
positionCountMap.computeIfAbsent(pos.getSwitch(), k -> new HashSet<Integer>()).add(pos.getPosition());
}));
// find switches that are here in all the positions, meaning that they don't affect the circuit
Set<ISwitch> switchesToPrune = positionCountMap.entrySet().stream()
.filter(e -> e.getKey().getPositionCount() == e.getValue().size())
.map(x -> x.getKey())
.collect(Collectors.toSet());
switchSetups.forEach(s -> s.getPositions().removeIf(x -> switchesToPrune.contains(x.getSwitch())));
switchSetups.removeIf(x -> x.getPositions().isEmpty());
HashSet<SwitchSetup> uniqueSetups = new HashSet<>(switchSetups);
switchSetups.clear();
switchSetups.addAll(uniqueSetups);
switchSetups.sort(Comparator.comparing(x -> x.toString()));
}
public static Netlist buildNetlist(List<IDIYComponent<?>> components, Collection<Node> nodes,
Collection<ContinuityArea> continuityAreas, Collection<Connection> connections) {
ImmutableGraph<ProjectGraphNode> graph = buildGraph(nodes, continuityAreas, connections);
@@ -161,10 +161,10 @@ public class Tree {
}
public String toAsciiString() {
return String.join("<br>", toAsciiLines());
return String.join("<br>", toAscii());
}
private List<String> toAsciiLines() {
private List<String> toAscii() {
if (leaf != null) {
return Arrays.asList(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1) + " " + leaf.toHTML() + " " + TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1));
}
@@ -172,7 +172,7 @@ public class Tree {
List<Tree> children = getOrderedChildren();
List<List<String>> childrenAscii =
children.stream().map(c -> c.toAsciiLines()).collect(Collectors.toList());
children.stream().map(c -> c.toAscii()).collect(Collectors.toList());
if (TreeConnectionType.Series.equals(connectionType)) {
return TreeAsciiUtil.concatenateMultiLineSerial(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1), childrenAscii);
@@ -42,7 +42,18 @@ import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.security.AnyTypePermission;
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/presenter/BuildingBlockManager.java
public class BuildingBlockManager {
=======
import org.diylc.common.BuildingBlockPackage;
import org.diylc.common.IBlockProcessor;
import org.diylc.common.IPlugInPort;
import org.diylc.common.IBlockProcessor.InvalidBlockException;
import org.diylc.core.IDIYComponent;
import org.diylc.serialization.ProjectFileManager;
public class BuildingBlockManager implements BuildingBlockService {
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/presenter/BuildingBlockManager.java
private static final String BLOCKS_FILE_NAME = "blocks.xml";
@@ -50,10 +61,10 @@ public class BuildingBlockManager {
private IConfigurationManager<?> configManager;
private XStream xStream;
private InstantiationManager instantiationManager;
private InstantiationService instantiationManager;
public BuildingBlockManager(IConfigurationManager<?> configManager, XStream xStream,
InstantiationManager instantiationManager) {
InstantiationService instantiationManager) {
super();
this.configManager = configManager;
this.xStream = xStream;
@@ -0,0 +1,21 @@
package org.diylc.presenter;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import org.diylc.common.IBlockProcessor;
import org.diylc.core.IDIYComponent;
public interface BuildingBlockService {
// Core block operations
void saveSelectionAsBlock(String blockName, Collection<IDIYComponent<?>> selectedComponents,
List<IDIYComponent<?>> allComponents);
List<IDIYComponent<?>> loadBlock(String blockName, List<IDIYComponent<?>> existingComponents)
throws IBlockProcessor.InvalidBlockException;
void deleteBlock(String blockName);
// Import/Export
void importDefaultBlocks();
int importBlocks(String fileName) throws IOException;
}
@@ -74,7 +74,7 @@ import org.diylc.utils.Constants;
*
* @author Branislav Stojkovic
*/
public class DrawingManager {
public class DrawingManager implements DrawingService {
private static final Logger LOG = Logger.getLogger(DrawingManager.class);
@@ -0,0 +1,52 @@
package org.diylc.presenter;
import java.awt.*;
import java.awt.geom.Area;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.diylc.common.DrawOption;
import org.diylc.common.IComponentFilter;
import org.diylc.common.PropertyWrapper;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.Theme;
public interface DrawingService {
// Core drawing methods
List<IDIYComponent<?>> drawProject(Graphics2D g2d, Project project,
Set<DrawOption> drawOptions, IComponentFilter filter, Rectangle selectionRect,
Collection<IDIYComponent<?>> selectedComponents, Set<IDIYComponent<?>> lockedComponents,
Set<IDIYComponent<?>> groupedComponents, List<Point2D> controlPointSlot,
List<IDIYComponent<?>> componentSlot, boolean dragInProgress, Double externalZoom,
Double scaleFactor, Rectangle2D visibleRect);
// Component area handling
ComponentArea getComponentArea(IDIYComponent<?> component);
void clearComponentAreaMap();
List<IDIYComponent<?>> findComponentsAt(Point2D point, Project project);
void invalidateComponent(IDIYComponent<?> component);
// Continuity area handling
void clearContinuityArea();
List<ContinuityArea> getContinuityAreas();
List<Area> getContinuityAreaProximity(float threshold);
void findContinuityAreaAtPoint(Point2D point);
// Theme handling
Theme getTheme();
void setTheme(Theme theme);
// Zoom control
double getZoomLevel();
void setZoomLevel(double zoomLevel);
void fireZoomChanged();
// Canvas dimensions
Dimension getCanvasDimensions(Project project, Double zoomLevel,
boolean includeExtraSpace);
double getExtraSpace(Project project);
}
@@ -38,7 +38,6 @@ import org.diylc.clipboard.ComponentTransferable;
import org.diylc.common.ComponentType;
import org.diylc.common.IPlugInPort;
import org.diylc.common.Orientation;
import org.diylc.common.Orientation45;
import org.diylc.common.OrientationHV;
import org.diylc.common.PropertyWrapper;
import org.diylc.core.Angle;
@@ -54,7 +53,7 @@ import org.diylc.core.measures.Size;
*
* @author Branislav Stojkovic
*/
public class InstantiationManager {
public class InstantiationManager implements InstantiationService{
private static final Logger LOG = Logger.getLogger(InstantiationManager.class);
@@ -437,7 +436,6 @@ public class InstantiationManager {
for (PropertyWrapper propertyWrapper : properties) {
if (propertyWrapper.getType().getName().equals(Orientation.class.getName())
|| propertyWrapper.getType().getName().equals(OrientationHV.class.getName())
|| propertyWrapper.getType().getName().equals(Orientation45.class.getName())
|| propertyWrapper.getName().equalsIgnoreCase("angle")) {
angleProperty = propertyWrapper;
break;
@@ -457,9 +455,6 @@ public class InstantiationManager {
} else if (value instanceof OrientationHV) {
angleProperty.setValue(OrientationHV.values()[(((OrientationHV) value).ordinal() + 1)
% OrientationHV.values().length]);
} else if (value instanceof Orientation45) {
angleProperty.setValue(Orientation45.values()[(((Orientation45) value).ordinal() + 1)
% Orientation45.values().length]);
} else if (value instanceof Angle) {
Angle angle = (Angle) angleProperty.getValue();
Angle newAngle = angle.rotate(1);
@@ -0,0 +1,37 @@
package org.diylc.presenter;
import java.awt.geom.Point2D;
import java.util.List;
import org.diylc.clipboard.ComponentTransferable;
import org.diylc.common.ComponentType;
import org.diylc.core.IDIYComponent;
import org.diylc.core.Project;
import org.diylc.core.Template;
import org.diylc.core.measures.Size;
public interface InstantiationService {
// Component type slot management
ComponentType getComponentTypeSlot();
Template getTemplate();
String[] getModel();
List<IDIYComponent<?>> getComponentSlot();
void setComponentTypeSlot(ComponentType componentTypeSlot, Template template, String[] model,
Project currentProject, boolean forceInstantiate) throws Exception;
// Point-by-point creation
Point2D getFirstControlPoint();
Point2D getPotentialControlPoint();
void setPotentialControlPoint(Point2D potentialControlPoint);
void instatiatePointByPoint(Point2D scaledPoint, Project currentProject) throws Exception;
boolean updatePointByPoint(Point2D scaledPoint);
boolean updateSingleClick(Point2D point, boolean snapToGrid, Size gridSpacing);
// Component operations
void pasteComponents(ComponentTransferable componentTransferable, Point2D scaledPoint,
boolean snapToGrid, Size gridSpacing, boolean autoGroup, Project currentProject,
boolean assignNewNames);
String createUniqueName(ComponentType componentType, List<IDIYComponent<?>> components);
void fillWithDefaultProperties(Object object, Template template);
void loadComponentShapeFromTemplate(IDIYComponent<?> component, Template template);
void tryToRotateComponentSlot();
}
@@ -48,6 +48,7 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.swing.JOptionPane;
import org.apache.log4j.Logger;
import org.checkerframework.checker.units.qual.A;
import org.diylc.appframework.miscutils.IConfigListener;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.appframework.miscutils.JarScanner;
@@ -90,15 +91,27 @@ import org.diylc.test.DIYTest;
import org.diylc.test.Snapshot;
import org.diylc.utils.Constants;
import org.diylc.utils.ReflectionUtils;
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/presenter/Presenter.java
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.security.AnyTypePermission;
=======
import org.reflections.Reflections;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import static org.reflections.scanners.Scanners.TypesAnnotated;
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java
/**
* The main presenter class, contains core app logic and drawing routines.
*
* @author Branislav Stojkovic
*/
@Component
public class Presenter implements IPlugInPort, IConfigListener {
private static final String REACHED_BOTTOM =
@@ -165,7 +178,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
private Map<String, List<ComponentType>> componentTypes;
// Maps component class names to ComponentType objects.
private List<IPlugIn> plugIns;
private List<IPlugIn> plugIns = new ArrayList<>();
private Set<IDIYComponent<?>> selectedComponents;
// Maps components that have at least one dragged point to set of indices
@@ -175,11 +188,11 @@ public class Presenter implements IPlugInPort, IConfigListener {
// Utilities
// private Cloner cloner;
private DrawingManager drawingManager;
private ProjectFileManager projectFileManager;
private InstantiationManager instantiationManager;
private VariantManager variantManager;
private BuildingBlockManager buildingBlockManager;
private DrawingService drawingManager;
private ProjectFileService projectFileManager;
private InstantiationService instantiationManager;
private VariantService variantManager;
private BuildingBlockService buildingBlockManager;
private Rectangle selectionRect;
@@ -202,6 +215,7 @@ public class Presenter implements IPlugInPort, IConfigListener {
private DIYTest test = null;
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/presenter/Presenter.java
public Presenter(IView view, IConfigurationManager<?> configManager) {
this(view, configManager, false);
}
@@ -221,6 +235,28 @@ public class Presenter implements IPlugInPort, IConfigListener {
instantiationManager = new InstantiationManager();
variantManager = new VariantManager(configManager, projectFileManager.getXStream());
buildingBlockManager = new BuildingBlockManager(configManager, projectFileManager.getXStream(), instantiationManager);
=======
@Autowired
public Presenter(
@Lazy
IView view,
IConfigurationManager configManager,
MessageDispatcher<EventType> messageDispatcher,
DrawingService drawingService,
ProjectFileService projectFileService,
InstantiationService instantiationService,
VariantService variantService,
BuildingBlockService buildingBlockService,
boolean importVariantsAndBlocks) {
this.view = view;
this.configManager = configManager;
this.messageDispatcher = messageDispatcher;
this.drawingManager = drawingService;
this.projectFileManager = projectFileService;
this.instantiationManager = instantiationService;
this.variantManager = variantService;
this.buildingBlockManager = buildingBlockService;
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java
// lockedLayers = EnumSet.noneOf(ComponentLayer.class);
// visibleLayers = EnumSet.allOf(ComponentLayer.class);
@@ -0,0 +1,31 @@
package org.diylc.presenter;
import java.io.IOException;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import com.thoughtworks.xstream.XStream;
import org.diylc.core.Project;
import org.diylc.test.DIYTest;
public interface ProjectFileService {
// Project operations
void serializeProjectToFile(Project project, String fileName, boolean isBackup) throws IOException;
Project deserializeProjectFromFile(String fileName, List<String> warnings)
throws SAXException, IOException, ParserConfigurationException;
// Test operations
void serializeTestToFile(DIYTest test, String fileName) throws IOException;
DIYTest deserializeTestFromFile(String fileName)
throws SAXException, IOException, ParserConfigurationException;
// File status
void startNewFile();
void notifyFileChange();
String getCurrentFileName();
boolean isModified();
void fireFileStatusChanged();
// Serialization
XStream getXStream();
}
@@ -41,7 +41,7 @@ import org.diylc.core.Template;
import org.diylc.serialization.ProjectFileManager;
import com.thoughtworks.xstream.XStream;
public class VariantManager {
public class VariantManager implements VariantService {
private static final String VARIANTS_FILE_NAME = "variants.xml";
@@ -0,0 +1,16 @@
package org.diylc.presenter;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.diylc.common.ComponentType;
import org.diylc.core.Template;
public interface VariantService {
void importDefaultVariants();
void upgradeVariants(Map<String, List<ComponentType>> componentTypes);
List<Template> getVariantsFor(ComponentType type);
int importVariants(String fileName) throws IOException;
String getDefaultVariant(ComponentType type);
void deleteVariant(ComponentType type, String templateName);
}
@@ -223,7 +223,7 @@
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Switched to AppImage distribution for Linux system, abandoning Flatpak as a means of distribution. DIYLC AppImage will be available alongside with other executables on the official DIYLC GitHub page</description>
<description>Switched to AppImage distribution for Linux system, abandoning Flatpak as a means of distribution. DIYLC AppImage will be available alongside with other executables on the official DIYLC GitHub page.</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
@@ -248,14 +248,10 @@
</versionNumber>
<releaseDate>2025-03-09 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>'Multimeter Probe' component added and 'Virtual Multimeter' functionality that uses it</description>
</org.diylc.appframework.update.Change>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Cleaner text representation of switch configuration in analyzer windows - removed switches and positions that have no effect on the effective circuit</description>
<description>Updated the windows installer to avoid false positive virus detection</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
@@ -43,10 +43,14 @@ import org.apache.log4j.Logger;
import org.diylc.appframework.miscutils.Utils;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.appframework.update.VersionNumber;
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/serialization/ProjectFileManager.java
import org.diylc.common.EventType;
import org.diylc.core.Project;
import org.diylc.presenter.Presenter;
import org.diylc.test.DIYTest;
=======
import org.diylc.presenter.ProjectFileService;
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -56,6 +60,7 @@ import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.mapper.MapperWrapper;
import com.thoughtworks.xstream.security.AnyTypePermission;
<<<<<<< Updated upstream:diylc/diylc-core/src/org/diylc/serialization/ProjectFileManager.java
public class ProjectFileManager {
@@ -64,6 +69,21 @@ public class ProjectFileManager {
private XStream xStream;
// Legacy deserializer for 3.0.1 through 3.0.7, loads Points referenced in
// pixels.
=======
import org.diylc.common.EventType;
import org.diylc.core.Project;
import org.diylc.presenter.Presenter;
import org.diylc.test.DIYTest;
public class ProjectFileManager implements ProjectFileService {
private static final Logger LOG = Logger.getLogger(ProjectFileManager.class);
private XStream xStream;
// Legacy deserializer for 3.0.1 through 3.0.7, loads Points referenced in
// pixels.
>>>>>>> Stashed changes:diylc/diylc-core/src/main/java/org/diylc/serialization/ProjectFileManager.java
private XStream xStreamOld;
public static final XStream xStreamSerializer = new XStream(new DomDriver("UTF-8"));
@@ -20,17 +20,6 @@ public class TreeAsciiUtilTest {
assertEquals("yy-yyy", result.get(1));
assertEquals("&nbsp;&nbsp;&nbsp;aaa", result.get(2));
}
@Test
public void testSimpleParallel() {
List<String> result = TreeAsciiUtil.concatenateMultiLineParallel(
Arrays.asList(Arrays.asList("xx"), Arrays.asList("yy")));
assertNotNull(result);
assertEquals(3, result.size());
assertEquals("&nbsp;&#x250C;xx&#x2510;&nbsp;", result.get(0));
assertEquals("&#x2500;&#x2524;&nbsp;&nbsp;&#x251C;&#x2500;", result.get(1));
assertEquals("&nbsp;&#x2514;yy&#x2518;&nbsp;", result.get(2));
}
@Test
public void testConcatenateMultiLineSerial_singleInput() {
Binary file not shown.
@@ -1,243 +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.components.connectivity;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Path2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import org.diylc.common.ObjectCache;
import org.diylc.common.Orientation45;
import org.diylc.components.AbstractTransparentComponent;
import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.ComponentState;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDrawingObserver;
import org.diylc.core.Project;
import org.diylc.core.VisibilityPolicy;
import org.diylc.core.annotations.BomPolicy;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
@ComponentDescriptor(name = "Multimeter Probe", category = "Connectivity",
author = "Branislav Stojkovic", description = "Multimeter Probe", instanceNamePrefix = "Probe",
zOrder = IDIYComponent.TEXT, bomPolicy = BomPolicy.NEVER_SHOW, autoEdit = false,
keywordPolicy = KeywordPolicy.SHOW_TYPE_NAME, transformer = SimpleComponentTransformer.class,
enableCache = true)
public class MultimeterProbe extends AbstractTransparentComponent<Color> {
private static final long serialVersionUID = 1L;
public static Size PROBE_DIAMETER = new Size(0.05d, SizeUnit.in);
public static Size PROBE_LENGTH = new Size(0.4d, SizeUnit.in);
public static Color PROBE_COLOR = METAL_COLOR;
public static Size HANDLE_DIAMETER = new Size(0.2d, SizeUnit.in);
public static Size HANDLE_LENGTH = new Size(0.4d, SizeUnit.in);
public static Color HANDLE_COLOR = Color.red;
private Point2D.Double point = new Point2D.Double(0, 0);
private Color handleColor = HANDLE_COLOR;
private Orientation45 orientation = Orientation45._315;
private transient Shape[] body = null;
public MultimeterProbe() {
this.alpha = (byte) (MAX_ALPHA / 2);
}
@Override
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode,
Project project, IDrawingObserver drawingObserver) {
Shape[] shapes = getBody();
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1f));
if (!outlineMode) {
Composite oldComposite = g2d.getComposite();
if (alpha < MAX_ALPHA) {
g2d.setComposite(
AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
}
g2d.setColor(PROBE_COLOR);
g2d.fill(shapes[0]);
g2d.setColor(handleColor);
g2d.fill(shapes[1]);
g2d.setComposite(oldComposite);
}
g2d.setColor(
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: handleColor.darker());
g2d.draw(shapes[1]);
g2d.setColor(
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: PROBE_COLOR.darker());
g2d.draw(shapes[0]);
}
@Override
public void drawIcon(Graphics2D g2d, int width, int height) {
double probeDiameter = 2;
double probeLength = height / 2 + 2;
double handleDiameter = width / 4;
double handleLength = height / 2 + 2;
double x = 2;
double y = height - 2;
Shape probe = buildProbeShape(probeDiameter, probeLength, x, y);
Shape handle = buildHandleShape(probeDiameter, probeLength, handleDiameter, handleLength, x, y);
double theta = Math.PI / 4;
AffineTransform tx = AffineTransform.getRotateInstance(theta, x, y);
probe = tx.createTransformedShape(probe);
handle = tx.createTransformedShape(handle);
g2d.setColor(PROBE_COLOR);
g2d.fill(probe);
g2d.setColor(HANDLE_COLOR);
g2d.fill(handle);
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
g2d.setColor(PROBE_COLOR.darker());
g2d.draw(probe);
g2d.setColor(HANDLE_COLOR.darker());
g2d.draw(handle);
}
public Shape[] getBody() {
if (body == null) {
double probeDiameter = PROBE_DIAMETER.convertToPixels();
double probeLength = PROBE_LENGTH.convertToPixels();
double handleDiameter = HANDLE_DIAMETER.convertToPixels();
double handleLength = HANDLE_LENGTH.convertToPixels();
double x = point.getX();
double y = point.getY();
body = new Shape[2];
Path2D probe = buildProbeShape(probeDiameter, probeLength, x, y);
body[0] = probe;
Path2D handle =
buildHandleShape(probeDiameter, probeLength, handleDiameter, handleLength, x, y);
body[1] = handle;
double theta = orientation.toRadians();
if (theta != 0) {
AffineTransform tx = AffineTransform.getRotateInstance(theta, x, y);
body[0] = tx.createTransformedShape(body[0]);
body[1] = tx.createTransformedShape(body[1]);
}
}
return body;
}
private Path2D buildHandleShape(double probeDiameter, double probeLength, double handleDiameter,
double handleLength, double x, double y) {
Path2D handle = new Path2D.Double();
handle.moveTo(x + probeDiameter, y - probeLength);
handle.lineTo(x + handleDiameter / 2, y - handleLength - probeLength);
handle.lineTo(x - handleDiameter / 2, y - handleLength - probeLength);
handle.lineTo(x - probeDiameter, y - probeLength);
handle.moveTo(x + probeDiameter, y - probeLength);
handle.closePath();
return handle;
}
private Path2D buildProbeShape(double probeDiameter, double probeLength, double x, double y) {
Path2D probe = new Path2D.Double();
probe.moveTo(x, y);
probe.lineTo(x - probeDiameter / 2, y - probeDiameter);
probe.lineTo(x - probeDiameter / 2, y - probeLength);
probe.lineTo(x + probeDiameter / 2, y - probeLength);
probe.lineTo(x + probeDiameter / 2, y - probeDiameter);
probe.lineTo(x, y);
probe.closePath();
return probe;
}
@Override
public int getControlPointCount() {
return 1;
}
@Override
public boolean isControlPointSticky(int index) {
return true;
}
@Override
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
return VisibilityPolicy.NEVER;
}
@Override
public Point2D getControlPoint(int index) {
return point;
}
@Override
public void setControlPoint(Point2D point, int index) {
this.point.setLocation(point);
this.body = null;
}
@Override
@EditableProperty(name = "Color")
public Color getValue() {
return handleColor;
}
public void setValue(Color color) {
this.handleColor = color;
}
@EditableProperty(name = "Angle")
public Orientation45 getOrientation() {
return orientation;
}
public void setOrientation(Orientation45 orientation) {
this.orientation = orientation;
this.body = null;
}
@Override
public String getControlPointNodeName(int index) {
return "Tip";
}
@Override
public Rectangle2D getCachingBounds() {
Shape[] shapes = getBody();
Rectangle2D bounds1 = shapes[0].getBounds2D();
Rectangle2D bounds2 = shapes[1].getBounds2D();
double minX = Math.min(bounds1.getMinX(), bounds2.getMinX());
double minY = Math.min(bounds1.getMinY(), bounds2.getMinY());
double maxX = Math.max(bounds1.getMaxX(), bounds2.getMaxX());
double maxY = Math.max(bounds1.getMaxY(), bounds2.getMaxY());
return new Rectangle2D.Double(minX - 1, minY - 1, maxX - minX + 2, maxY - minY + 2);
}
}
@@ -1,91 +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.List;
import java.util.Set;
import javax.swing.JLabel;
import org.diylc.common.INetlistAnalyzer;
import org.diylc.components.connectivity.MultimeterProbe;
public class MultimeterAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
@Override
public String getName() {
return "Virtual Multimeter";
}
@Override
public String getShortName() {
return "multimeter";
}
@Override
public String getIconName() {
return "Multimeter";
}
@Override
public String getFontName() {
return new JLabel().getFont().getName();
}
protected Summary summarize(Netlist netlist, Node preferredOutput) throws TreeException {
Tree tree = constructTree(netlist);
if (tree == null) {
return new Summary(netlist, "No components found connecting the two multimeter probes.");
}
List<String> notes = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
String asciiTree = tree.toAsciiString();
sb.append("<br><br>")
.append("<font face='Courier New'>")
.append(asciiTree)
.append("</font>");
if (!notes.isEmpty()) {
Collections.sort(notes);
sb.append("<br><br>");
for (String v : notes) {
sb.append(v).append("<br>");
}
}
return new Summary(netlist, sb.toString());
}
public Tree constructTree(Netlist netlist) throws TreeException {
List<Node> probeNodes = find(Set.of(MultimeterProbe.class.getCanonicalName()), null, netlist);
if (probeNodes.size() == 0) {
throw new TreeException("No multimeter probes are placed on the circuit.");
} else if (probeNodes.size() != 2) {
throw new TreeException(
"Place exactly two multimeter probes on the circuit in order to run the analysis.");
} else {
return constructTreeBetween(netlist, probeNodes.get(0), probeNodes.get(1));
}
}
}
BIN
View File
Binary file not shown.
@@ -1,5 +1,2 @@
eclipse.preferences.version=1
encoding//appimage/setup_wsl_appimage.bat=UTF-8
encoding//lang/Deutsch.txt=UTF-8
encoding//src/org/diylc/swing/gui/CollapsiblePanel.java=UTF-8
encoding/lang=UTF-8
encoding/<project>=ISO-8859-1
+436 -14
View File
@@ -13,26 +13,27 @@
#34 / 0.16mm
#36 / 0.13mm
#8 / 3.26mm
(Building Blocks)
(Favorites)
(Recently Used)
1 throws / 2 positions
10 throws / 10 positions
11 throws / 11 positions
12 throws / 12 positions
135 degrees clockwise
180 degrees clockwise
1P12T
2 throws / 2 positions
2 throws / 3 positions / OFF even positions
225 degrees clockwise
270 degrees clockwise
2P5T
2P6T
3 throws / 3 positions
3 throws / 5 positions / SHORT even positions
315 degrees clockwise
3P4T
3PDT
3PDT (On/Off/On)
4 band
4 throws / 4 positions
45 degrees clockwise
4P3T
4P5T
4P5T (Super/Mega)
@@ -49,22 +50,115 @@
7 throws / 7 positions
8 throws / 8 positions
9 throws / 9 positions
90 degrees clockwise
A variant with that name already exists. Overwrite?
A-O-I REGULATOR
AC
ANSI
AWG
About
Above
Access User Files
Add Flexible Leads
Add Validation Step
All Connected
Alpha
Alternate
Analyze
Analyze Guitar Diagrams
And
Angle
Angle Offset
Anti-Aliasing
Arrow Size
Author
Auto-Create Pads
Auto-Edit Mode
B-C-E BJT
Background
Base
Below
Board
Board Color
Board Width
Boards
Bobbin 1
Bobbin 2
Body
Border
Border Thickness
Both
Both Sides
Bottom
Bottom Left
Bottom Right
Box
Bracket
Bring Forward
Bring Selection to Front
Buffer
C-B-E BJT
Center
Center Negative
Center Positive
Center Terminal
Central
Change Password
Channel
Chassis
Check Trace Proximity
Circle
Circular
Click on a component to highlight area directly or indirectly connected to the area below the cursor. To continue editing, this mode needs to be switched OFF
Click on the canvas to create a new %s or press %s to cancel
Click on the canvas to set the %s control point of a new %s or press %s to cancel
Click the lightbulb icon in the bottom-right corner of the window for more info.
Click to fetch the most recent public announcement
Click to show recent changes and updates
Click to toggle to the next option
Coil
Coil Border
Coil Length
Coil Width
Coil(s)
Color
Color 1
Color 2
Color code
Column Spacing
Columns
Component
Component API
Component reordering is possible only when Project Explorer is sorted by z-index.
Components
Config
Configuration
Connectivity
Connector
Connector (Mirrored)
Contacts
Continuous Creation
Coordinate Color
Coordinate Origin
Coordinates
Copy
Core
Core Border
Core Thickness
Core Width
Could not apply changes. Check the log for details.
Could not create a new file. Check the log for details.
Could not create component. Check log for details.
Could not fetch public announcements.
Could not save the project to file. Check the log for details.
Could not set component type slot. Check log for details.
Cover
Create B.O.M.
Create New Account
Current
Cut
Cut Between Holes
Cut Orientation
D-G-S JFET
D-G-S MOSFET
D-S-G JFET
@@ -73,8 +167,12 @@ DC
DFM A
DFM B
DIP
DIP (Mirrored)
DP3T
DP3T (Import 5-Position Strat)
DP3T (Standard 3-Position Strat)
DP3T (Standard 5-Position Strat)
DP4T (4-Position Tele)
DP4T (6-Position Oak Grigsby)
DP5T
DPDT
@@ -82,24 +180,78 @@ DPDT (On/Off/On)
DPDT (On/On)
DPDT (On/On/On Type 1)
DPDT (On/On/On Type 2)
Dashed
Decimals
Default
Default Font
Default Font Size
Delete Selection
Description
Designation
Deutsch
Diameter
Dimension Mode
Directional
Directly heated
Display
Display Pin #s
Dog Ear
Donate
Dot Spacing
Dots (Gradual)
Dots (Uniform)
Dotted
Double Rails
Double Rods
Drag control point(s) of
Drag the mouse over the canvas to place a new
Draw Standard
Drop
Duodecar B12C
Duplicate
E+
E-B-C BJT
Edges
Edit
Edit Project Settings
Edit Selection
Eight
English
Español
Electro-Mechanical
Electrode Labels
Enable Cache Boost
End Arrow
Enjoying DIYLC? Click here to buy me a coffee :)
Error
Error occurred while editing selection. Check the log for details.
Exit
Expand Selection
Explicit Dimensions
Explicit Length
Explicit Width
Export
Export Building Blocks
Export Grid
Export Variants
Export to Gerber
Export to PDF
Export to PNG
Extra Working Area
Eyelet color
FAQ
Filament Voltage
Français
File
Filtertron
Find
Five
Flip
Folded
Font
Font Bold
Font Italic
Font Size
Font Size Override
Four
Full
Fuse
G-D-S JFET
G-D-S MOSFET
G-I-O REGULATOR
@@ -108,50 +260,198 @@ G-S-D JFET
G-S-D MOSFET
Generate DIYLC Netlist (excl. Switches)
Generate DIYLC Netlist (incl. Switches)
Gray
Generate Spice Netlist
Grid
Grid Spacing
Group Selection
Guitar
Half
Heaters
Height
Help
Hi-Quality Rendering
Highlight Connected Areas
Hole
Hole Size
Hole Spacing
Hole Type
Holes Per Strip
Horizontal
Horizontal Alignment
Horizontal Large
Horizontal Medium
Horizontal Small 1
Horizontal Small 2
Horizontal X-Small
Humbucking - 4 leads
I-G-O REGULATOR
IEC
Image
Immediate Only
Import
Import Building Blocks
Import Netlist
Import Variants
In-Line D-44
In-line
Indent
Information
Inline
Inner 1
Inner 2
Inner 3
Inner 4
Inner 5
Inner 6
Italiano
Inside Color
Integration
Invert Polarity
Label
Label Color
Label Orientation
Label Position
Labels
Language
Language selection will be applied after the application is restarted.
Layer
Layers
Lead Color
Lead Count
Lead Length
Lead Spacing
Left
Left click to instantiate this component, right click for more options
Left-to-Right
Legs
Length
Letters
Lin
Loadline Editor
Lock
Log
Log In
Log Out
Lug Size
Lugs
MPJA
Make a Donation
Manage Account
Manage My Uploads
Mark Common Lugs
Marker
Marker Size
Markers
Maximum number of switching combinations exceeded. Allowed: %s, actual: %s
Mini
Miniature
Mirror Horizontally
Mirror Selection
Mirror Vertically
Mirroring operation will change the circuit. Do you want to continue?
Misc
Model
Mono
Mount
Mounting Lugs
Mouse Wheel Zoom
Moveable Label
NPN
Name
Nand
Nederlands
Negative
New
New version available
Nine
No
No new public announcements available.
Non-Plated Through Hole
Non-shorting
None
Nor
Not
Noval B9A
Nudge
Numbers
Numeric (0-10)
Numeric (1-10)
Numeric (1-11)
Numeric (1-12)
Numeric (Even, No Ticks)
Numeric (Even, With Ticks)
Nut
O-G-I REGULATOR
Octal
Offset
One
One Side
Open
Opposing Points
Or
Orientation
Outer Foil
Outer Foil Mark
Outline Mode
Outside
Oval horizontal
Oval vertical
PAF
PCB
PNP
Pad Color
Pad color
Panel
Passive
Paste
Pin Arrangement
Pin Color
Pin Spacing
Pin spacing
Pinout
Pins
Pitch
Plated Through Hole
Play Test
Plugin API
Point Count
Polarity
Polarized
Pole Color
Pole Pieces
Pole Pieces 1
Pole Pieces 2
Poles
Português
Positions
Positive
Power Rating
Power Strip
Primary CT
Print...
Project Cloud
Public Announcement
RS
Radius
Rail
Recent Files
Recent Updates
Rectangle
Redo
Renumber On Paste
Renumber Selection
Resistance
Rev log
Reverse (standing)
Right
Rim
Rods
Rotate Clockwise
Rotate Counterclockwise
Rotate Selection
Round
Round WOG A
Round WOG B
Row Spacing
Rows
Ruler Inch Subdivision...
S-G-D JFET
S-G-D MOSFET
SMD
@@ -159,28 +459,150 @@ SPDT
SPDT (On/Off/On)
SPDT (On/On)
SPST
Same Type Only
Save
Save As
Save as Variant
Scale
Schematic Symbols
Screw Position
Screws
Search The Cloud
Searchable Tree
Secondary CT
Select All
Selected component(s) have reached the bottom of their layer. Do you want to force the selection to the back?
Selected component(s) have reached the top of their layer. Do you want to force the selection to the top?
Selection
Selection Size
Selection contains components that cannot be mirrored. Do you want to exclude them?
Selection contains components that cannot be rotated. Do you want to exclude them?
Selection is empty.
Semiconductors
Send Backward
Send Selection to Back
Seven
Shaft Down
Shaft Up
Shape
Shapes
Shorting
Show Bracket
Show Grid
Show Project Explorer
Show Rulers
Shroud
Shrouded
Single - North
Single - South
Single Rail
Single Rods
Six
Size
Sizing Mode
Small-button B7G
Smooth
Snap To
Soap Bar
Solid
Sort by Name
Sort by Type
Sort by Z-index
Source Style
Source Type
Srpski
Spacing
Square
Square BR-3
Standard
Start Arrow
Start Recording
Stereo
Sticky Points
Stop Recording
Stratocaster
Strip Color
Stripe
Stripe 1
Stripe 2
Stripe Color
Stripe Color 1
Stripe Color 2
Stroke
Style
Submit a Bug
Suppressor grid
Switched
Switches
Tab
Tab Border
Tabbed Toolbar
Taper
Telecaster
Ten
Terminal
Terminal Spacing
Terminals
Test
Text
Text Color
There are unsaved changes. Would you like to save them?
Thickness
Three
Through Hole
Tick
Tick Width
Ticks
Timing
Title
Toolbox
Top
Top Lead
Top Left
Top Right
Top-to-Bottom
Trace
Trace Color
Trace Mask
Transform Selection
Triangle
Tubes
Tubular
Tubular Beveled
Virtual Multimeter
Two
Type
Ultra-miniature
Underside Pad Color
Underside Trace Color
Undo
Ungroup Selection
Unit
Upload A Project
User Manual
Value
Version history is not available.
Vertical
Vertical Alignment
Vertical Inline
Vertical Offset 1
Vertical Offset 2
View
Visible
Voltage
Wafer
Warning
Width
Winding Spacing
Wiring
X-axis
Xnor
Xor
Y-axis
Zoom
base of 10
base of 2
cm
ft
hold %s and drag to unstick from
in
mm
px
Binary file not shown.
Binary file not shown.
+559
View File
@@ -0,0 +1,559 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.diylc</groupId>
<artifactId>diylc-parent</artifactId>
<version>5.1.0</version>
</parent>
<artifactId>diylc-swing</artifactId>
<!-- No need to specify version - it inherits from parent -->
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<!-- Internal module dependencies -->
<dependency>
<groupId>org.diylc</groupId>
<artifactId>diylc-core</artifactId>
</dependency>
<dependency>
<groupId>org.diylc</groupId>
<artifactId>diylc-library</artifactId>
</dependency>
<!-- Common dependencies from Maven Central -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.5-FINAL</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.4.0-jre</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.27</version>
</dependency>
<dependency>
<groupId>com.orsonpdf</groupId>
<artifactId>orsonpdf</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>commons-compiler</artifactId>
<version>3.1.12</version>
</dependency>
<dependency>
<groupId>net.java.balloontip</groupId>
<artifactId>balloontip</artifactId>
<version>1.2.4.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>com.guigarage</groupId>
<artifactId>gestures-wrapper</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
</dependency>
<!-- Local dependencies from lib folder -->
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>app-framework</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>gerber-writer-api-1.0.0</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>java-http-proxy</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>jep-2.4.1</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>svgSalamander-1.1.2.4</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.diylc.local</groupId>
<artifactId>swing-framework</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>3.2.3</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>diylc</finalName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.diylc.DIYLCStarter</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>universal-zip</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<descriptors>
<descriptor>deploy/universal-zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<configuration>
<finalName>diylc-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>linux-appimage</id>
<properties>
<appdir.dir>${project.build.directory}/AppDir</appdir.dir>
<jdk.version>17.0.14+7</jdk.version>
<jdk.version.file>17.0.14_7</jdk.version.file>
<jdk.archive.linux>OpenJDK17U-jre_x64_linux_hotspot_${jdk.version.file}.tar.gz</jdk.archive.linux>
<jdk.url.linux>https://github.com/adoptium/temurin17-binaries/releases/download/jdk-${jdk.version}/${jdk.archive.linux}</jdk.url.linux>
<jre.dest.linux>${project.build.directory}/jre-temp</jre.dest.linux>
<appdir.jre>${appdir.dir}/usr/bin/jre</appdir.jre>
<wsl.command>wsl bash -c</wsl.command>
<appimage.output.file>DIYLayoutCreator-${project.version}-x86_64.AppImage</appimage.output.file>
</properties>
<build>
<plugins>
<!-- Create AppDir structure and copy files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>create-appdir</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Create directory structure -->
<mkdir dir="${appdir.dir}/usr/bin" />
<mkdir dir="${appdir.dir}/usr/lib" />
<mkdir dir="${appdir.dir}/usr/share/icons/hicolor/512x512/apps" />
<mkdir dir="${appdir.dir}/usr/share/metainfo" />
<!-- Copy app files -->
<copy file="${project.build.directory}/diylc.jar" todir="${appdir.dir}/usr/lib" />
<!-- Copy AppImage specific files -->
<copy file="${project.basedir}/deploy/linux/appimage/diylc.sh" tofile="${appdir.dir}/usr/bin/diylc.sh" />
<copy file="${project.basedir}/deploy/linux/appimage/AppRun" tofile="${appdir.dir}/AppRun" />
<chmod file="${appdir.dir}/AppRun" perm="755" />
<chmod file="${appdir.dir}/usr/bin/diylc.sh" perm="755" />
<!-- Copy icons and desktop files -->
<copy file="${project.basedir}/src/main/resources/icons/icon_512x512.png"
tofile="${appdir.dir}/usr/share/icons/hicolor/512x512/apps/com.diy_fever.DIYLayoutCreator.png" />
<copy file="${project.basedir}/src/main/resources/icons/icon_512x512.png"
tofile="${appdir.dir}/com.diy_fever.DIYLayoutCreator.png" />
<copy file="${project.basedir}/deploy/linux/appimage/com.diy_fever.DIYLayoutCreator.desktop"
todir="${appdir.dir}" />
<copy file="${project.basedir}/deploy/linux/appimage/com.diy_fever.DIYLayoutCreator.metainfo.xml"
todir="${appdir.dir}/usr/share/metainfo" />
<!-- Download and extract JRE for Linux -->
<!-- Ensure clean jre folders -->
<delete dir="${jre.dest.linux}" />
<mkdir dir="${jre.dest.linux}" />
<mkdir dir="${project.build.directory}/downloads" />
<!-- Download JRE 17 if not already present -->
<get src="${jdk.url.linux}"
dest="${project.build.directory}/downloads/${jdk.archive.linux}"
usetimestamp="true" />
<!-- Extract JRE -->
<untar src="${project.build.directory}/downloads/${jdk.archive.linux}"
dest="${jre.dest.linux}"
compression="gzip" />
<!-- Move extracted folder into AppImage location -->
<mkdir dir="${appdir.jre}" />
<move todir="${appdir.jre}">
<fileset dir="${jre.dest.linux}/jdk-${jdk.version}-jre" />
</move>
<!-- Clean up temporary directory -->
<delete dir="${jre.dest.linux}" />
<echo message="JRE 17 bundled into ${appdir.jre}" />
<!-- Convert line endings to Unix format -->
<fixcrlf file="${appdir.dir}/com.diy_fever.DIYLayoutCreator.desktop" eol="unix" />
<fixcrlf file="${appdir.dir}/AppRun" eol="unix" />
<fixcrlf file="${appdir.dir}/usr/bin/diylc.sh" eol="unix" />
<echo message="AppDir structure created successfully at: ${appdir.dir}" />
</target>
</configuration>
</execution>
<!-- Build AppImage -->
<execution>
<id>build-appimage</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="Starting AppImage build process..." />
<!-- Detect operating system -->
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isMac">
<os family="mac" />
</condition>
<condition property="isLinux">
<and>
<os family="unix" />
<not>
<os family="mac" />
</not>
</and>
</condition>
<echo message="Detected OS: ${os.name}" />
<!-- Windows-specific build -->
<echo message="Windows build will execute: ${isWindows}" />
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c echo Building AppImage using Windows with WSL..." />
</exec>
<!-- Check if WSL is available -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c where wsl" />
</exec>
<!-- Set WSL command -->
<property name="wsl.command" value="wsl bash -c" />
<!-- Check if WSL has a Linux distribution installed -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c wsl -l" />
</exec>
<!-- Copy AppDir to WSL /tmp directory -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c wsl cp -r &quot;$(wslpath -u '${appdir.dir}')&quot; /tmp/AppDir" />
</exec>
<!-- Convert line endings to Unix format in WSL -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c ${wsl.command} &quot;sed -i 's/\r$//' /tmp/AppDir/com.diy_fever.DIYLayoutCreator.desktop&quot;" />
</exec>
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c ${wsl.command} &quot;sed -i 's/\r$//' /tmp/AppDir/AppRun&quot;" />
</exec>
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c ${wsl.command} &quot;sed -i 's/\r$//' /tmp/AppDir/usr/bin/diylc.sh&quot;" />
</exec>
<!-- Setup WSL with required dependencies -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c echo Setting up WSL with required dependencies..." />
</exec>
<!-- Install necessary Linux dependencies inside WSL -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c ${wsl.command} &quot;sudo apt update &amp;&amp; sudo apt install -y wget libfuse2 fuse&quot;" />
</exec>
<!-- Download AppImageTool into WSL if not already present -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c ${wsl.command} &quot;if [ ! -f ~/appimagetool ]; then wget -O ~/appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage &amp;&amp; chmod +x ~/appimagetool; fi&quot;" />
</exec>
<!-- Build AppImage using appimagetool in WSL -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c ${wsl.command} &quot;cd /tmp &amp;&amp; ~/appimagetool /tmp/AppDir /tmp/${appimage.output.file}&quot;" />
</exec>
<!-- Copy the AppImage back to the build directory -->
<exec executable="cmd.exe" failonerror="true" osfamily="windows">
<arg line="/c wsl bash -c &quot;cp /tmp/${appimage.output.file} $(wslpath -u '${project.build.directory}/${appimage.output.file}')&quot;" />
</exec>
<!-- macOS-specific build -->
<echo message="Mac build will execute: ${isMac}" />
<exec executable="bash" failonerror="true" osfamily="mac">
<arg line="-c 'echo Building AppImage using macOS with Docker...'" />
</exec>
<!-- Check if Docker is available -->
<exec executable="docker" resultproperty="docker.result" failifexecutionfails="false" osfamily="mac">
<arg line="--version" />
</exec>
<!-- Create a temporary directory for Docker volume mapping -->
<mkdir dir="${project.build.directory}/docker-tmp" />
<!-- Copy AppDir to the Docker volume directory -->
<copy todir="${project.build.directory}/docker-tmp/AppDir">
<fileset dir="${appdir.dir}" />
</copy>
<!-- Run AppImageTool in Docker -->
<exec executable="docker" failonerror="true" osfamily="mac">
<arg line="run --rm -v &quot;${project.build.directory}/docker-tmp:/workspace&quot; -w /workspace appimagecrafters/appimage-builder:latest /bin/bash -c &quot;ARCH=x86_64 appimagetool AppDir ${appimage.output.file}&quot;" />
</exec>
<!-- Copy the AppImage to the build directory -->
<copy file="${project.build.directory}/docker-tmp/${appimage.output.file}" todir="${project.build.directory}" />
<!-- Clean up temporary directory -->
<delete dir="${project.build.directory}/docker-tmp" />
<!-- &lt;!&ndash; Linux-specific build &ndash;&gt;-->
<!-- <echo message="Linux build will execute: ${isLinux}" />-->
<!-- <exec executable="bash" failonerror="true" osfamily="unix">-->
<!-- <arg line="-c 'echo Building AppImage natively on Linux...'" />-->
<!-- </exec>-->
<!-- -->
<!-- &lt;!&ndash; Install dependencies if needed &ndash;&gt;-->
<!-- <exec executable="bash" failonerror="true" osfamily="unix">-->
<!-- <arg line="-c 'which appimagetool || (echo &quot;Installing appimagetool...&quot; &amp;&amp; sudo apt-get update &amp;&amp; sudo apt-get install -y libfuse2 fuse &amp;&amp; wget -O /tmp/appimagetool https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage &amp;&amp; chmod +x /tmp/appimagetool &amp;&amp; sudo mv /tmp/appimagetool /usr/local/bin/)'" />-->
<!-- </exec>-->
<!-- -->
<!-- &lt;!&ndash; Build AppImage &ndash;&gt;-->
<!-- <exec executable="bash" failonerror="true" osfamily="unix">-->
<!-- <arg line="-c 'appimagetool ${appdir.dir} ${project.build.directory}/${appimage.output.file}'" />-->
<!-- </exec>-->
<!-- Create zip package -->
<zip destfile="${project.build.directory}/diylc-${project.version}-linux.zip">
<zipfileset file="${project.build.directory}/${appimage.output.file}"
filemode="755" />
</zip>
<echo message="AppImage build completed successfully! Output: ${project.build.directory}/${appimage.output.file}" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Windows InnoSetup build profile using Docker -->
<profile>
<id>win64-installer</id>
<properties>
<jdk.version>17.0.14+7</jdk.version>
<jdk.version.file>17.0.14_7</jdk.version.file>
<jdk.archive.win64>OpenJDK17U-jre_x64_windows_hotspot_${jdk.version.file}.zip</jdk.archive.win64>
<jdk.url.win64>https://github.com/adoptium/temurin17-binaries/releases/download/jdk-${jdk.version}/${jdk.archive.win64}</jdk.url.win64>
</properties>
<build>
<plugins>
<!-- Download and extract JRE -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>download-extract-jre</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- Clean old jre_win folder -->
<delete dir="${project.build.directory}/jre_win" />
<!-- Create folder to hold extracted JRE -->
<mkdir dir="${project.build.directory}/jre_win" />
<!-- Download JRE 64-bit for Windows -->
<mkdir dir="${project.build.directory}/downloads" />
<get src="${jdk.url.win64}"
dest="${project.build.directory}/downloads/${jdk.archive.win64}"
usetimestamp="true" />
<!-- Extract JRE into jre_win -->
<unzip src="${project.build.directory}/downloads/${jdk.archive.win64}"
dest="${project.build.directory}/jre_win" />
<!-- Move files up one level -->
<move todir="${project.build.directory}/jre_win">
<fileset dir="${project.build.directory}/jre_win/jdk-${jdk.version}-jre" />
</move>
<!-- Remove empty top-level folder -->
<delete dir="${project.build.directory}/jre_win/jdk-${jdk.version}-jre" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- Run InnoSetup -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>build-windows-installer</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>docker</executable>
<arguments>
<argument>run</argument>
<argument>--rm</argument>
<argument>-v</argument>
<argument>${project.basedir}:/workspace</argument>
<argument>amake/innosetup</argument>
<argument>/Ddiylcver=${project.version}</argument>
<argument>/Darch=x64</argument>
<argument>/workspace/deploy/win/install.iss</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -31,6 +31,13 @@ import org.apache.log4j.PropertyConfigurator;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.PropertyInjector;
import org.diylc.appframework.miscutils.Utils;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
=======
import org.diylc.config.DIYLCConfig;
import org.diylc.swingframework.export.DrawingExporter;
import org.diylc.swingframework.fonts.FontOptimizer;
import com.thoughtworks.xstream.XStream;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java
import org.diylc.common.IPlugInPort;
import org.diylc.core.IView;
import org.diylc.lang.LangUtil;
@@ -39,10 +46,16 @@ import org.diylc.serialization.ProjectFileManager;
import org.diylc.swing.gui.MainFrame;
import org.diylc.swing.gui.TemplateDialog;
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
import org.diylc.swingframework.export.DrawingExporter;
import org.diylc.swingframework.fonts.FontOptimizer;
import com.thoughtworks.xstream.XStream;
import ca.cgjennings.jvm.JarLoader;
=======
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/DIYLCStarter.java
/**
* Main class that runs DIYLC.
@@ -177,8 +190,15 @@ public class DIYLCStarter {
LOG.info("Creating the main frame...");
MainFrame mainFrame = new MainFrame();
Presenter presenter = mainFrame.getPresenter();
// Disable web server since this is a Swing app
ConfigurableApplicationContext context = new SpringApplicationBuilder(DIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run(args);
// Get MainFrame from Spring context and show it
MainFrame mainFrame = context.getBean(MainFrame.class);
Presenter presenter = context.getBean(Presenter.class);
LOG.info("Main frame created.");
// mainFrame.setLocationRelativeTo(null);
@@ -0,0 +1,46 @@
package org.diylc;
import org.diylc.appframework.simplemq.MessageDispatcher;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.presenter.*;
import org.diylc.swing.actions.file.ImportFileView;
import org.diylc.swing.gui.DummyView;
import org.diylc.swing.loadline.LoadlineEditorFrame;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.*;
import org.diylc.config.DIYLCConfig;
import org.diylc.swing.gui.MainFrame;
import org.diylc.core.IView;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.swing.plugins.PluginConfig;
import java.util.List;
@Configuration
//@Import({DIYLCConfig.class})
public class DIYLCSwingConfig {
@Primary
@Bean
public IView mainFrame(@Lazy
Presenter presenter, IConfigurationManager configurationManager, List<IPlugIn> plugins) {
return new MainFrame(presenter, configurationManager, plugins);
}
@Bean
public IView importFileView() {
return new ImportFileView();
}
@Bean
public IView dummyView() {
return new DummyView();
}
@Bean
public IView loadlineView(Presenter presenter) {
return new LoadlineEditorFrame(presenter);
}
}
@@ -9,11 +9,15 @@ import java.util.Set;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.clipboard.ComponentTransferableFactory;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ITask;
import org.diylc.common.PropertyWrapper;
import org.diylc.config.DIYLCConfig;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.core.IView;
import org.diylc.presenter.Presenter;
import org.diylc.swing.ActionFactory;
@@ -21,6 +25,9 @@ import org.diylc.swing.ISwingUI;
import org.diylc.swing.gui.DialogFactory;
import org.diylc.swing.images.IconLoader;
import org.diylc.swing.plugins.file.FileFilterEnum;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
public class ImportAction extends AbstractAction {
@@ -34,35 +41,14 @@ public class ImportAction extends AbstractAction {
super();
this.plugInPort = plugInPort;
this.swingUI = swingUI;
this.presenter = new Presenter(new IView() {
@Override
public int showConfirmDialog(String message, String title, int optionType,
int messageType) {
return JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
}
ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportFileDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
@Override
public void showMessage(String message, String title, int messageType) {
JOptionPane.showMessageDialog(null, message, title, messageType);
}
this.presenter = context.getBean(Presenter.class);
@Override
public String showInputDialog(String message, String title) {
return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE);
}
@Override
public File promptFileSave() {
return null;
}
@Override
public boolean editProperties(List<PropertyWrapper> properties,
Set<PropertyWrapper> defaultedProperties, String title) {
return false;
}
}, InMemoryConfigurationManager.getInstance());
putValue(AbstractAction.NAME, "Import");
putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_I,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
@@ -0,0 +1,41 @@
package org.diylc.swing.actions.file;
import org.diylc.common.PropertyWrapper;
import org.diylc.core.IView;
import org.springframework.stereotype.Component;
import javax.swing.*;
import java.io.File;
import java.util.List;
import java.util.Set;
@Component
public class ImportFileView implements IView {
@Override
public int showConfirmDialog(String message, String title, int optionType,
int messageType) {
return JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
}
@Override
public void showMessage(String message, String title, int messageType) {
JOptionPane.showMessageDialog(null, message, title, messageType);
}
@Override
public String showInputDialog(String message, String title) {
return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE);
}
@Override
public File promptFileSave() {
return null;
}
@Override
public boolean editProperties(List< PropertyWrapper > properties,
Set<PropertyWrapper> defaultedProperties, String title) {
return false;
}
}
@@ -88,6 +88,41 @@ import org.diylc.swing.plugins.toolbox.ToolBox;
import org.diylc.swing.plugins.tree.ComponentTree;
import org.diylc.swingframework.ButtonDialog;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
=======
import org.diylc.common.BadPositionException;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ITask;
import org.diylc.common.PropertyWrapper;
import org.diylc.core.IView;
import org.diylc.core.images.IconLoader;
import org.diylc.lang.LangUtil;
import org.diylc.presenter.Presenter;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.gui.actionbar.ActionBarPlugin;
import org.diylc.swing.gui.editor.PropertyEditorDialog;
import org.diylc.swing.plugins.autosave.AutoSavePlugin;
import org.diylc.swing.plugins.canvas.CanvasPlugin;
import org.diylc.swing.plugins.cloud.CloudPlugIn;
import org.diylc.swing.plugins.config.ConfigPlugin;
import org.diylc.swing.plugins.edit.EditMenuPlugin;
import org.diylc.swing.plugins.explorer.ExplorerPlugin;
import org.diylc.swing.plugins.file.FileFilterEnum;
import org.diylc.swing.plugins.file.FileMenuPlugin;
import org.diylc.swing.plugins.help.HelpMenuPlugin;
import org.diylc.swing.plugins.layers.LayersMenuPlugin;
import org.diylc.swing.plugins.statusbar.StatusBar;
import org.diylc.swing.plugins.test.TestMenuPlugin;
import org.diylc.swing.plugins.toolbox.ToolBox;
import org.diylc.swing.plugins.tree.ComponentTree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.diylc.swing.plugins.PluginFactory;
@Component
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
public class MainFrame extends JFrame implements ISwingUI {
private static final Logger LOG = Logger.getLogger(MainFrame.class);
@@ -100,7 +135,8 @@ public class MainFrame extends JFrame implements ISwingUI {
private JPanel topPanel;
private JPanel bottomPanel;
private Presenter presenter;
private final Presenter presenter;
private final IConfigurationManager configManager;
private JMenuBar mainMenuBar;
private Map<String, JMenu> menuMap;
@@ -108,26 +144,47 @@ public class MainFrame extends JFrame implements ISwingUI {
private CanvasPlugin canvasPlugin;
public MainFrame() {
@Autowired
public MainFrame(
Presenter presenter,
IConfigurationManager configManager,
List<IPlugIn> plugins) { // Spring will inject all IPlugIn implementations
super("DIYLC 4");
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
=======
this.presenter = presenter;
this.configManager = configManager;
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
setPreferredSize(new Dimension(1024, 700));
createBasePanels();
menuMap = new HashMap<String, JMenu>();
buttonGroupMap = new HashMap<String, ButtonGroup>();
setIconImages(Arrays.asList(IconLoader.IconSmall.getImage(), IconLoader.IconMedium.getImage(),
IconLoader.IconLarge.getImage()));
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
DialogFactory.getInstance().initialize(this);
IConfigurationManager<?> configManager = ConfigurationManager.getInstance();
=======
DialogFactory.getInstance().initialize(this);
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
this.presenter = new Presenter(this, configManager, true);
for (IPlugIn plugIn : plugins) {
presenter.installPlugin(() -> plugIn);
}
presenter.installPlugin(() -> new ToolBox(this));
// this.canvasPlugin = (CanvasPlugin) plugins.stream()
// .filter(x -> CanvasPlugin.class.isInstance(x))
// .findFirst().orElseThrow();
presenter.installPlugin(() -> new ToolBox(this));
presenter.installPlugin(() -> new FileMenuPlugin(this));
presenter.installPlugin(() -> new EditMenuPlugin(this));
presenter.installPlugin(() -> new ConfigPlugin(this));
presenter.installPlugin(() -> new LayersMenuPlugin(this));
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/MainFrame.java
presenter.installPlugin(() -> new CloudPlugIn(this));
if ("true".equalsIgnoreCase(System.getProperty("org.diylc.enableTests")))
presenter.installPlugin(() -> new TestMenuPlugin(this));
@@ -144,6 +201,20 @@ public class MainFrame extends JFrame implements ISwingUI {
presenter.installPlugin(() -> new FramePlugin());
presenter.installPlugin(() -> new AutoSavePlugin(this));
=======
presenter.installPlugin(() -> new CloudPlugIn(this));
if ("true".equalsIgnoreCase(System.getProperty("org.diylc.enableTests")))
presenter.installPlugin(() -> new TestMenuPlugin(this));
presenter.installPlugin(() -> new HelpMenuPlugin(this));
presenter.installPlugin(() -> new ActionBarPlugin(this));
presenter.installPlugin(() -> new StatusBar(this));
canvasPlugin = new CanvasPlugin(this, configManager);
presenter.installPlugin(() -> canvasPlugin);
presenter.installPlugin(() -> new ComponentTree(this, canvasPlugin.getCanvasPanel()));
presenter.installPlugin(() -> new ExplorerPlugin(this, canvasPlugin.getCanvasPanel()));
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/MainFrame.java
presenter.createNewProject();
@@ -21,6 +21,7 @@
*/
package org.diylc.swing.gui;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/TemplateDialog.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -58,7 +59,52 @@ import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper;
import org.diylc.core.IView;
=======
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.apache.log4j.Logger;
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.core.IView;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/TemplateDialog.java
import org.diylc.presenter.Presenter;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
public class TemplateDialog extends JDialog {
@@ -85,13 +131,13 @@ public class TemplateDialog extends JDialog {
setModal(true);
setResizable(false);
this.plugInPort = plugInPort;
this.presenter = new Presenter(new IView() {
@Override
public int showConfirmDialog(String message, String title, int optionType, int messageType) {
return JOptionPane.showConfirmDialog(TemplateDialog.this, message, title, optionType, messageType);
}
ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportFileDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/gui/TemplateDialog.java
@Override
public void showMessage(String message, String title, int messageType) {
JOptionPane.showMessageDialog(TemplateDialog.this, message, title, messageType);
@@ -101,17 +147,10 @@ public class TemplateDialog extends JDialog {
public String showInputDialog(String message, String title) {
return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE);
}
=======
this.presenter = context.getBean(Presenter.class);
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/gui/TemplateDialog.java
@Override
public File promptFileSave() {
return null;
}
@Override
public boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties, String title) {
return false;
}
}, InMemoryConfigurationManager.getInstance());
// this.presenter.installPlugin(new IPlugIn() {
//
// @Override
@@ -47,12 +47,14 @@ import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.images.IconLoader;
import org.diylc.swing.plugins.help.HelpMenuPlugin;
import org.springframework.stereotype.Component;
/**
* Mini toolbar with common actions
*
* @author Branislav Stojkovic
*/
@Component
public class ActionBarPlugin implements IPlugIn {
private static final Logger LOG = Logger.getLogger(ActionBarPlugin.class);
@@ -69,7 +69,7 @@ public enum IconLoader {
SnapToComponents("snap_to_components.png"), SnapToNone("snap_to_none.png"), TraceProximity("trace_proximity.png"),
ComponentLarge("component_large.png"), ImportNetlist("import_netlist.png"), SplashIC("splash_ic.png"),
ComponentPreferences("component_preferences.png"), ComponentReplace("component_replace.png"), Barcode("barcode.png"),
Multimeter("multimeter.png"), DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png");
DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png");
protected String name;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 864 B

@@ -32,9 +32,27 @@ import javax.swing.JTextField;
import javax.swing.UIManager;
import org.apache.log4j.Logger;
import org.apache.poi.util.IOUtils;
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.appframework.miscutils.Utils;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java
=======
import org.diylc.components.connectivity.Dot;
import org.diylc.components.connectivity.Line;
import org.diylc.components.misc.Image;
import org.diylc.components.misc.Image.ImageSizingMode;
import org.diylc.components.misc.Label;
import org.diylc.components.misc.LoadlineCurve;
import org.diylc.components.misc.LoadlineEntity;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.config.LoadlineDIYLCConfig;
import org.diylc.swingframework.ButtonDialog;
import org.diylc.swingframework.DoubleTextField;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/loadline/LoadlineEditorFrame.java
import org.diylc.common.EventType;
import org.diylc.common.HorizontalAlignment;
import org.diylc.common.IPlugIn;
@@ -63,11 +81,19 @@ import org.diylc.swing.gui.editor.PropertyEditorDialog;
import org.diylc.swing.images.IconLoader;
import org.diylc.swing.plugins.canvas.CanvasPanel;
import org.diylc.swing.plugins.file.FileFilterEnum;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/loadline/LoadlineEditorFrame.java
import org.diylc.swingframework.ButtonDialog;
import org.diylc.swingframework.DoubleTextField;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
=======
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/loadline/LoadlineEditorFrame.java
@Component
public class LoadlineEditorFrame extends JFrame implements IView {
private static final long serialVersionUID = 1L;
@@ -94,7 +120,7 @@ public class LoadlineEditorFrame extends JFrame implements IView {
private int xIncrement;
private int yIncrement;
public LoadlineEditorFrame() {
public LoadlineEditorFrame(Presenter plugInPort) {
super("Loadline Editor");
setIconImage(IconLoader.Loadline.getImage());
setResizable(false);
@@ -116,8 +142,9 @@ public class LoadlineEditorFrame extends JFrame implements IView {
}
});
this.plugInPort = plugInPort;
this.plugInPort = new Presenter(this, configManager);
this.plugInPort.installPlugin(() -> new IPlugIn() {
@SuppressWarnings("incomplete-switch")
@@ -711,7 +738,13 @@ public class LoadlineEditorFrame extends JFrame implements IView {
@Override
public void actionPerformed(ActionEvent e) {
new LoadlineEditorFrame().setVisible(true);
ConfigurableApplicationContext context = new SpringApplicationBuilder(LoadlineDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
IView view = context.getBean(IView.class);
((LoadlineEditorFrame)view).setVisible(true);
}
}
}
@@ -0,0 +1,10 @@
package org.diylc.swing.plugins;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ComponentScan;
@Configuration
@ComponentScan("org.diylc.swing.plugins")
public class PluginConfig {
// Plugin-specific beans can be defined here if needed
}
@@ -0,0 +1,85 @@
package org.diylc.swing.plugins;
import org.diylc.swing.ISwingUI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.swing.gui.*;
import org.diylc.swing.plugins.canvas.CanvasPlugin;
import org.diylc.swing.plugins.file.FileMenuPlugin;
import org.diylc.swing.plugins.edit.EditMenuPlugin;
import org.diylc.swing.plugins.config.ConfigPlugin;
import org.diylc.swing.plugins.layers.LayersMenuPlugin;
import org.diylc.swing.plugins.cloud.CloudPlugIn;
import org.diylc.swing.plugins.help.HelpMenuPlugin;
import org.diylc.swing.plugins.test.TestMenuPlugin;
import org.diylc.swing.plugins.statusbar.StatusBar;
import org.diylc.swing.plugins.tree.ComponentTree;
import org.diylc.swing.plugins.explorer.ExplorerPlugin;
import org.diylc.swing.plugins.toolbox.ToolBox;
import org.diylc.swing.gui.actionbar.ActionBarPlugin;
import javax.swing.*;
@Component
public class PluginFactory {
private final IConfigurationManager configManager;
@Autowired
public PluginFactory(IConfigurationManager configManager) {
this.configManager = configManager;
}
public CanvasPlugin createCanvasPlugin(ISwingUI ui) {
return new CanvasPlugin(ui, configManager);
}
public FileMenuPlugin createFileMenuPlugin(ISwingUI ui) {
return new FileMenuPlugin(ui);
}
public EditMenuPlugin createEditMenuPlugin(ISwingUI ui) {
return new EditMenuPlugin(ui);
}
public ConfigPlugin createConfigPlugin(ISwingUI ui) {
return new ConfigPlugin(ui);
}
public LayersMenuPlugin createLayersMenuPlugin(ISwingUI ui) {
return new LayersMenuPlugin(ui);
}
public CloudPlugIn createCloudPlugIn(ISwingUI ui) {
return new CloudPlugIn(ui);
}
public TestMenuPlugin createTestMenuPlugin(ISwingUI ui) {
return new TestMenuPlugin(ui);
}
public HelpMenuPlugin createHelpMenuPlugin(ISwingUI ui) {
return new HelpMenuPlugin(ui);
}
public ActionBarPlugin createActionBarPlugin(ISwingUI ui) {
return new ActionBarPlugin(ui);
}
public StatusBar createStatusBar(ISwingUI ui) {
return new StatusBar(ui);
}
public ToolBox createToolBox(ISwingUI ui) {
return new ToolBox(ui);
}
public ComponentTree createComponentTree(ISwingUI ui, JComponent canvasPanel) {
return new ComponentTree(ui, canvasPanel);
}
public ExplorerPlugin createExplorerPlugin(ISwingUI ui, JComponent canvasPanel) {
return new ExplorerPlugin(ui, canvasPanel);
}
}
@@ -36,7 +36,9 @@ import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.core.IView;
import org.springframework.stereotype.Component;
@Component
public class AutoSavePlugin implements IPlugIn {
private static final String AUTO_SAVE_PATH = Utils.getUserDataDirectory("diylc") + "backup";
@@ -52,6 +52,7 @@ import org.diylc.presenter.Presenter;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.gui.ComponentPopupMenu;
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
import org.diylc.swingframework.ruler.IRulerListener;
import org.diylc.swingframework.ruler.Ruler.InchSubdivision;
import org.diylc.swingframework.ruler.RulerScrollPane;
@@ -59,7 +60,11 @@ import com.guigarage.gestures.GestureMagnificationEvent;
import com.guigarage.gestures.GestureMagnificationListener;
import com.guigarage.gestures.GestureUtilities;
import com.guigarage.gestures.GesturesNotSupportedException;
=======
import org.springframework.stereotype.Component;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/canvas/CanvasPlugin.java
@Component
public class CanvasPlugin implements IPlugIn{
private static final Logger LOG = Logger.getLogger(CanvasPlugin.class);
@@ -21,6 +21,7 @@
*/
package org.diylc.swing.plugins.cloud;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
@@ -52,6 +53,48 @@ import org.diylc.swing.plugins.cloud.view.browser.UploadManagerFrame;
import org.diylc.swing.plugins.file.FileFilterEnum;
import org.diylc.swingframework.ButtonDialog;
=======
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.ListIterator;
import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import org.apache.log4j.Logger;
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.config.DummyViewDIYLCConfig;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.swingframework.ButtonDialog;
import org.diylc.common.EventType;
import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ITask;
import org.diylc.core.IView;
import org.diylc.plugins.cloud.presenter.CloudException;
import org.diylc.plugins.cloud.presenter.CloudPresenter;
import org.diylc.presenter.Presenter;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.gui.DialogFactory;
import org.diylc.swing.gui.DummyView;
import org.diylc.utils.IconLoader;
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
import org.diylc.swing.plugins.cloud.view.LoginDialog;
import org.diylc.swing.plugins.cloud.view.UploadDialog;
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
import org.diylc.swing.plugins.cloud.view.browser.CloudBrowserFrame;
import org.diylc.swing.plugins.cloud.view.browser.UploadManagerFrame;
import org.diylc.swing.plugins.file.FileFilterEnum;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
@Component
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/cloud/CloudPlugIn.java
public class CloudPlugIn implements IPlugIn {
private static final String ONLINE_TITLE = "Project Cloud";
@@ -80,7 +123,18 @@ public class CloudPlugIn implements IPlugIn {
super();
this.swingUI = swingUI;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/CloudPlugIn.java
this.thumbnailPresenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
=======
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
this.thumbnailPresenter = context.getBean(Presenter.class);
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/cloud/CloudPlugIn.java
this.thumbnailGenerator = new ThumbnailGenerator(thumbnailPresenter);
swingUI.injectMenuAction(getLibraryAction(), ONLINE_TITLE);
@@ -50,7 +50,14 @@ import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.text.DefaultCaret;
import org.apache.log4j.Logger;
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
=======
import org.diylc.config.DummyViewDIYLCConfig;
import org.diylc.swingframework.ButtonDialog;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/cloud/view/browser/ResultsScrollPanel.java
import org.diylc.common.IPlugInPort;
import org.diylc.common.ITask;
import org.diylc.common.PropertyWrapper;
@@ -72,6 +79,9 @@ import org.diylc.swing.plugins.cloud.view.CommentDialog;
import org.diylc.swing.plugins.file.FileFilterEnum;
import org.diylc.swingframework.ButtonDialog;
import org.diylc.utils.Pair;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
/**
* Component that is capable of showing a list of {@link ProjectEntity} objects. Can work in paging
@@ -398,9 +408,15 @@ public class ResultsScrollPanel extends JScrollPane {
+ project.getName()
+ "\" with a new file?\nThis opperation is irreversible. Once replaced, the old version of the project cannot be restored.",
"Replace Project", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) == IView.YES_OPTION) {
final Presenter thumbnailPresenter =
new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
Presenter thumbnailPresenter = context.getBean(Presenter.class);
final ThumbnailGenerator thumbnailGenerator = new ThumbnailGenerator(thumbnailPresenter);
final File file =
@@ -34,13 +34,18 @@ import org.diylc.swing.IDynamicSubmenuHandler;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.images.IconLoader;
import org.diylc.swing.loadline.LoadlineEditorFrame;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.diylc.appframework.miscutils.IConfigurationManager;
import org.diylc.common.AbstractPlugin;
/**
* Entry point class for File management utilities.
*
* @author Branislav Stojkovic
*/
public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
@Component
public class FileMenuPlugin extends AbstractPlugin implements IDynamicSubmenuHandler {
private static final Logger LOG = Logger.getLogger(FileMenuPlugin.class);
@@ -56,6 +61,7 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
private ISwingUI swingUI;
private IPlugInPort plugInPort;
@Autowired
public FileMenuPlugin(ISwingUI swingUI) {
super();
this.swingUI = swingUI;
@@ -130,7 +136,7 @@ public class FileMenuPlugin implements IPlugIn, IDynamicSubmenuHandler {
@Override
public EnumSet<EventType> getSubscribedEventTypes() {
return null;
return EnumSet.of(EventType.FILE_STATUS_CHANGED);
}
@Override
@@ -21,6 +21,7 @@
*/
package org.diylc.swing.plugins.file;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/swing/plugins/file/ProjectPreview.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -44,6 +45,39 @@ import org.diylc.serialization.ProjectFileManager;
import org.diylc.swing.gui.DummyView;
import org.diylc.swingframework.IFileChooserAccessory;
=======
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.FileInputStream;
import java.util.EnumSet;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.config.DummyViewDIYLCConfig;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.swingframework.IFileChooserAccessory;
import org.diylc.common.DrawOption;
import org.diylc.common.IPlugInPort;
import org.diylc.core.Project;
import org.diylc.presenter.Presenter;
import org.diylc.serialization.ProjectFileManager;
import org.diylc.swing.gui.DummyView;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/file/ProjectPreview.java
/**
* {@link JComponent} that shows preview of the selected project in {@link JFileChooser}. It's
* hooked onto {@link JFileChooser} as {@link PropertyChangeListener} and refreshes when file is
@@ -64,7 +98,13 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
super();
setPreferredSize(new Dimension(140, 128));
presenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
this.presenter = context.getBean(Presenter.class);
emptyProject = new Project();
emptyProject.setTitle("");
@@ -27,6 +27,7 @@ import java.net.URL;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
<<<<<<< Updated upstream:diylc/diylc-swing/src/org/diylc/utils/BatchConverter.java
import org.diylc.DIYLCStarter;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.presenter.Presenter;
@@ -61,3 +62,50 @@ public class BatchConverter {
}
}
=======
import org.diylc.DIYLCSwingConfig;
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
import org.diylc.DIYLCStarter;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.DummyView;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
public class BatchConverter {
private static final Logger LOG = Logger.getLogger(BatchConverter.class);
public static void main(String[] args) {
URL url = DIYLCStarter.class.getResource("/log4j.properties");
Properties properties = new Properties();
try (InputStream inputStream = url.openStream()) {
properties.load(inputStream);
PropertyConfigurator.configure(properties);
} catch (Exception e) {
LOG.error("Could not initialize log4j configuration", e);
}
File dir = new File("C:\\Users\\Branislav Stojkovic\\Documents\\layouts_v1");
File[] matchingFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return true;
}
});
ConfigurableApplicationContext context = new SpringApplicationBuilder(ImportFileDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
Presenter presenter = context.getBean(Presenter.class);
for (File file : matchingFiles) {
if (file.getName() != "" && file.getName() != "." && file.getName() != ".." && !file.isDirectory())
presenter.loadProjectFromFile(file.getAbsolutePath());
presenter.saveProjectToFile(file.getParentFile().getAbsolutePath() + "\\converted\\" + file.getName(), false);
}
}
}
>>>>>>> Stashed changes:diylc/diylc-swing/src/main/java/org/diylc/utils/BatchConverter.java
@@ -20,19 +20,40 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.appframework.update.VersionNumber;
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/RegressionTestRunner.java
=======
import org.diylc.common.EventType;
import org.diylc.config.DummyViewDIYLCConfig;
import org.diylc.config.ImportFileDIYLCConfig;
import org.diylc.presenter.*;
import org.diylc.swingframework.export.DrawingExporter;
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/RegressionTestRunner.java
import org.diylc.common.IPlugInPort;
import org.diylc.core.IView;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.NetlistException;
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/RegressionTestRunner.java
import org.diylc.presenter.Presenter;
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
import org.diylc.swingframework.export.DrawingExporter;
=======
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/RegressionTestRunner.java
import com.github.romankh3.image.comparison.ImageComparison;
import com.github.romankh3.image.comparison.ImageComparisonUtil;
import com.github.romankh3.image.comparison.model.ImageComparisonResult;
import com.github.romankh3.image.comparison.model.ImageComparisonState;
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/RegressionTestRunner.java
=======
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/RegressionTestRunner.java
public class RegressionTestRunner {
@@ -79,7 +100,8 @@ public class RegressionTestRunner {
private static void createReport(List<RegressionTestResult> results, String basePath)
throws IOException {
IView view = new MockView();
Presenter presenter = new Presenter(view, InMemoryConfigurationManager.getInstance());
Presenter presenter = TestBase.getPresenter(view);
VersionNumber currentVersionNumber = presenter.getCurrentVersionNumber();
String fileName = basePath + File.separator + "reports" + File.separator
@@ -161,7 +183,7 @@ public class RegressionTestRunner {
String prefix = "File: " + file.getName() + " status: ";
try {
MockView view = new MockView();
Presenter presenter = new Presenter(view, InMemoryConfigurationManager.getInstance());
Presenter presenter = TestBase.getPresenter(view);
ProjectDrawingProvider drawingProvider =
new ProjectDrawingProvider(presenter, false, true, false);
presenter.loadProjectFromFile(file.getAbsolutePath());
@@ -1,3 +1,4 @@
<<<<<<< Updated upstream:diylc/diylc-swing/test/org/diylc/TestBase.java
package org.diylc;
import java.awt.Point;
@@ -49,3 +50,82 @@ public class TestBase {
presenter.mouseClicked(point2, MouseEvent.BUTTON1, false, false, false, 1);
}
}
=======
package org.diylc;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.apache.log4j.PropertyConfigurator;
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.ComponentType;
import org.diylc.config.DummyViewDIYLCConfig;
import org.diylc.core.IView;
import org.diylc.presenter.*;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
public class TestBase {
protected Presenter presenter;
protected IView view;
public TestBase() {
URL url = DIYLCStarter.class.getResource("/log4j.properties");
Properties properties = new Properties();
try (InputStream inputStream = url.openStream()) {
properties.load(inputStream);
PropertyConfigurator.configure(properties);
} catch (Exception e) {
System.err.println("Could not initialize log4j configuration: " + e.getMessage());
}
ConfigurationManager.getInstance().initialize("diylc-test");
view = new MockView();
presenter = getPresenter(view);
}
protected void instantiateOneClick(String category, String name, Point point1) {
Map<String, List<ComponentType>> componentTypes = presenter.getComponentTypes();
ComponentType resistorType = componentTypes.get(category).stream().filter(x -> x.getName().equals(name)).findFirst().get();
presenter.setNewComponentTypeSlot(resistorType, null, null, false);
presenter.mouseClicked(point1, MouseEvent.BUTTON1, false, false, false, 1);
}
protected void instantiateTwoClick(String category, String name, Point point1, Point point2) {
Map<String, List<ComponentType>> componentTypes = presenter.getComponentTypes();
ComponentType resistorType = componentTypes.get(category).stream().filter(x -> x.getName().equals(name)).findFirst().get();
presenter.setNewComponentTypeSlot(resistorType, null, null, false);
presenter.mouseClicked(point1, MouseEvent.BUTTON1, false, false, false, 1);
presenter.mouseMoved(point2, false, false, false);
presenter.mouseClicked(point2, MouseEvent.BUTTON1, false, false, false, 1);
}
static Presenter getPresenter(IView view) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(DummyViewDIYLCConfig.class, DIYLCSwingConfig.class)
.web(WebApplicationType.NONE)
.headless(false)
.run();
Presenter presenter = new Presenter(view,
context.getBean(IConfigurationManager.class),
context.getBean(MessageDispatcher.class),
context.getBean(DrawingService.class),
context.getBean(ProjectFileService.class),
context.getBean(InstantiationService.class),
context.getBean(VariantService.class),
context.getBean(BuildingBlockService.class),
false);
return presenter;
}
}
>>>>>>> Stashed changes:diylc/diylc-swing/src/test/java/org/diylc/TestBase.java
+1 -1
View File
@@ -4,7 +4,7 @@ AppVersion={#diylcver}
DefaultDirName={pf}\DIYLC
DefaultGroupName=DIY Layout Creator
UninstallDisplayIcon={app}\diylc.exe
Compression=lzma2
Compression=zip
SolidCompression=yes
OutputDir=../build
OutputBaseFilename=diylc