Merge branch 'next' into lang

Conflicts:
	diylc/diylc-library/lib/diylc-core.jar
	diylc/diylc-swing/lib/diylc-core.jar
	diylc/diylc-swing/library/main.jar
This commit is contained in:
bancika
2020-04-24 13:23:26 +02:00
20 changed files with 199 additions and 28 deletions
+1
View File
@@ -8,6 +8,7 @@
<classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/> <classpathentry kind="lib" path="lib/jettison-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/> <classpathentry kind="lib" path="lib/xstream-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/java-http-proxy.jar"/> <classpathentry kind="lib" path="lib/java-http-proxy.jar"/>
<classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>
Binary file not shown.
@@ -3033,5 +3033,33 @@
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>4</major>
<minor>6</minor>
<build>0</build>
</versionNumber>
<releaseDate>2020-04-20 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Include themes and fonts in OSX app package</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Some boards (e.g. Breadboard) stop working at certain orientations</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Component leads on resistors, capacitors, etc disappear when they are very short</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Prevent "Radial Film Capacitor" from switching to standing mode when end points are too close</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
</a> </a>
</java.util.Arrays_-ArrayList> </java.util.Arrays_-ArrayList>
@@ -0,0 +1,51 @@
/*
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
*
* This file is part of DIYLC.
*
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
package org.diylc.utils;
import java.io.File;
import org.apache.log4j.Logger;
public class ResourceLoader {
private static final Logger LOG = Logger.getLogger(ResourceLoader.class);
public static File[] getFiles(String relativePath) {
String bundlePath;
try {
bundlePath = com.apple.eio.FileManager.getPathToApplicationBundle();
LOG.debug("Detected OSX bundle path: " + bundlePath);
} catch (Exception e) {
bundlePath = null; // on non-OSX platforms
}
try {
String absolutePath;
if (bundlePath == null)
absolutePath = relativePath;
else
absolutePath = bundlePath + File.separator + "Contents" + File.separator + "Resources" + File.separator + relativePath;
LOG.debug("Looking for files in: " + absolutePath);
File absoluteFile = new File(absolutePath);
return absoluteFile.listFiles();
} catch (Exception e) {
LOG.error("Error while looking for files in: " + relativePath, e);
return null;
}
}
}
@@ -0,0 +1,34 @@
package org.diylc.utils;
import java.io.BufferedInputStream;
import java.net.URL;
import java.util.List;
import org.diylc.appframework.update.Change;
import org.diylc.appframework.update.Version;
import org.diylc.presenter.Presenter;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class VersionReader {
public static void main(String[] args) {
try {
URL resource = Presenter.class.getResource("update.xml");
if (resource != null) {
BufferedInputStream in = new BufferedInputStream(resource.openStream());
XStream xStream = new XStream(new DomDriver());
@SuppressWarnings("unchecked")
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
Version latest = allVersions.get(allVersions.size() - 1);
StringBuilder sb = new StringBuilder();
for (Change c : latest.getChanges())
sb.append("**[" + c.getChangeType() + "]** " + c.getDescription()).append("\n");
System.out.println(sb.toString());
in.close();
}
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
}
Binary file not shown.
@@ -88,6 +88,8 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
protected transient Double gamma = null; protected transient Double gamma = null;
protected transient Double r = null; protected transient Double r = null;
private Boolean hideShortLeads = false;
protected AbstractLeadedComponent() { protected AbstractLeadedComponent() {
super(); super();
try { try {
@@ -205,7 +207,7 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
double leadLength = (distance - calculatePinSpacing(shapeRect)) / 2; double leadLength = (distance - calculatePinSpacing(shapeRect)) / 2;
// only draw leads longer than threshold // only draw leads longer than threshold
if (leadLength > LEAD_RENDER_THRESHOLD) { if (leadLength > LEAD_RENDER_THRESHOLD || !getHideShortLeads()) {
if (shouldShadeLeads()) { if (shouldShadeLeads()) {
Stroke leadStroke = ObjectCache.getInstance().fetchBasicStroke(leadThickness - 1); Stroke leadStroke = ObjectCache.getInstance().fetchBasicStroke(leadThickness - 1);
Color leadColor = getLeadColorForPainting(componentState); Color leadColor = getLeadColorForPainting(componentState);
@@ -717,6 +719,17 @@ public abstract class AbstractLeadedComponent<T> extends AbstractTransparentComp
return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin); return new Rectangle2D.Double(minX - margin, minY - margin, maxX - minX + 2 * margin, maxY - minY + 2 * margin);
} }
// for internal use. Set this flag to true when replacing standard leads with flexible ones
public Boolean getHideShortLeads() {
if (hideShortLeads == null)
hideShortLeads = false;
return hideShortLeads;
}
public void setHideShortLeads(Boolean hideShortLeads) {
this.hideShortLeads = hideShortLeads;
}
public enum LabelOriantation { public enum LabelOriantation {
Directional, Horizontal Directional, Horizontal
} }
@@ -337,7 +337,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
@Override @Override
public Rectangle2D getCachingBounds() { public Rectangle2D getCachingBounds() {
Point finalSecondPoint = getFinalSecondPoint(); Point finalSecondPoint = getFinalSecondPoint();
return new Rectangle2D.Double(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x + 1, finalSecondPoint.y - firstPoint.y + 1); return new Rectangle2D.Double(Math.min(firstPoint.x, finalSecondPoint.x), Math.min(firstPoint.y, finalSecondPoint.y),
Math.abs(finalSecondPoint.x - firstPoint.x) + 2, Math.abs(finalSecondPoint.y - firstPoint.y) + 2);
} }
public static enum CoordinateType { public static enum CoordinateType {
@@ -382,7 +382,8 @@ public class Breadboard extends AbstractComponent<Void> {
@Override @Override
public Rectangle2D getCachingBounds() { public Rectangle2D getCachingBounds() {
Point finalSecondPoint = getControlPoint(1); Point finalSecondPoint = getControlPoint(1);
return new Rectangle2D.Double(point.x, point.y, finalSecondPoint.x - point.x + 1, finalSecondPoint.y - point.y + 1); return new Rectangle2D.Double(Math.min(point.x, finalSecondPoint.x), Math.min(point.y, finalSecondPoint.y),
Math.abs(finalSecondPoint.x - point.x) + 2, Math.abs(finalSecondPoint.y - point.y) + 2);
} }
public enum BreadboardSize { public enum BreadboardSize {
@@ -700,6 +700,7 @@ public class ProtoBoard extends AbstractComponent<Void> {
@Override @Override
public Rectangle2D getCachingBounds() { public Rectangle2D getCachingBounds() {
Point finalSecondPoint = getControlPoint(1); Point finalSecondPoint = getControlPoint(1);
return new Rectangle2D.Double(point.x, point.y, finalSecondPoint.x - point.x + 1, finalSecondPoint.y - point.y + 1); return new Rectangle2D.Double(Math.min(point.x, finalSecondPoint.x), Math.min(point.y, finalSecondPoint.y),
Math.abs(finalSecondPoint.x - point.x) + 2, Math.abs(finalSecondPoint.y - point.y) + 2);
} }
} }
@@ -48,11 +48,6 @@ public abstract class AbstractFilmCapacitor extends AbstractLeadedComponent<Capa
protected Boolean showOuterFoil = false; protected Boolean showOuterFoil = false;
protected Color outerFoilColor = OUTER_FOIL_COLOR; protected Color outerFoilColor = OUTER_FOIL_COLOR;
@Override
protected boolean supportsStandingMode() {
return true;
}
@EditableProperty(validatorClass = PositiveMeasureValidator.class) @EditableProperty(validatorClass = PositiveMeasureValidator.class)
public Capacitance getValue() { public Capacitance getValue() {
return value; return value;
@@ -61,4 +61,9 @@ public class AxialFilmCapacitor extends AbstractFilmCapacitor {
return new Rectangle2D.Double(0f, 0f, getLength().convertToPixels(), return new Rectangle2D.Double(0f, 0f, getLength().convertToPixels(),
getClosestOdd(getWidth().convertToPixels())); getClosestOdd(getWidth().convertToPixels()));
} }
@Override
protected boolean supportsStandingMode() {
return true;
}
} }
@@ -75,6 +75,9 @@ public class FlexibleLeadsEditor implements IProjectEditor {
leaded.setControlPoint(newP1, 0); leaded.setControlPoint(newP1, 0);
leaded.setControlPoint(newP2, 1); leaded.setControlPoint(newP2, 1);
// make the standard leads go away
leaded.setHideShortLeads(true);
// create leads // create leads
HookupWire w1 = new HookupWire(); HookupWire w1 = new HookupWire();
getInstantiationManager().fillWithDefaultProperties(w1, null); getInstantiationManager().fillWithDefaultProperties(w1, null);
Binary file not shown.
+3 -1
View File
@@ -125,6 +125,8 @@
</bundleapp> </bundleapp>
<zip destfile="${build.dir}/diylc-${diylc.version}-osx.zip"> <zip destfile="${build.dir}/diylc-${diylc.version}-osx.zip">
<zipfileset filemode="755" dir="${build.dir}/DIYLC.app" prefix="DIYLC.app" /> <zipfileset filemode="755" dir="${build.dir}/DIYLC.app" prefix="DIYLC.app" />
<zipfileset filemode="755" dir="${basedir}/themes" prefix="DIYLC.app/Contents/Resources/themes" />
<zipfileset filemode="755" dir="${basedir}/fonts" prefix="DIYLC.app/Contents/Resources/fonts" />
</zip> </zip>
</target> </target>
@@ -166,7 +168,7 @@
</zip> </zip>
</target> </target>
<target name="full" depends="win,mac,universal" /> <target name="full" depends="win,universal,mac" />
<target name="javadoc"> <target name="javadoc">
<javadoc access="public" author="true" classpathref="class.path" destdir="doc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.6" splitindex="true" use="true" version="true"> <javadoc access="public" author="true" classpathref="class.path" destdir="doc" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.6" splitindex="true" use="true" version="true">
Binary file not shown.
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
<project name="diylc-swing-ftp" basedir="."
default="printVersion">
<property environment="env" />
<property name="FTP_USER" value="diylc_deploy@diy-fever.com" />
<property name="URL" value="ftp.diy-fever.com" />
<target name="upload">
<echo
message="Logging to ${FTP_USER}:${env.DIYLC_DEPLOY_PWD}@${URL}" />
<ftp server="${URL}" userid="${FTP_USER}"
password="${env.DIYLC_DEPLOY_PWD}">
<fileset dir="./../diylc-core/src/org/diylc/presenter">
<include name="update.xml" />
</fileset>
</ftp>
</target>
<path id="class.path">
<fileset dir="${basedir}">
<include name="lib/**/*.jar" />
<include name="library/**/*.jar" />
</fileset>
</path>
<target name="printVersion">
<java classname="org.diylc.utils.VersionReader">
<sysproperty key="DEBUG" value="true" />
<arg value="${basedir}/" />
<classpath>
<path refid="class.path" />
</classpath>
</java>
</target>
</project>
@@ -39,6 +39,7 @@ import org.diylc.presenter.Presenter;
import org.diylc.swing.gui.MainFrame; import org.diylc.swing.gui.MainFrame;
import org.diylc.swing.gui.TemplateDialog; import org.diylc.swing.gui.TemplateDialog;
import org.diylc.swingframework.FontChooserComboBox; import org.diylc.swingframework.FontChooserComboBox;
import org.diylc.utils.ResourceLoader;
/** /**
* Main class that runs DIYLC. * Main class that runs DIYLC.
@@ -101,22 +102,22 @@ public class DIYLCStarter {
public void run() { public void run() {
LOG.debug("Starting font pre-loading"); LOG.debug("Starting font pre-loading");
File dir = new File("fonts"); File[] fonts = ResourceLoader.getFiles("fonts");
File[] fonts = dir.listFiles();
for (int i = 0; i < fonts.length; i++) { if (fonts != null)
try { for (int i = 0; i < fonts.length; i++) {
LOG.info("Dynamically loading font: " + fonts[i].getName()); try {
Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f); LOG.info("Dynamically loading font: " + fonts[i].getName());
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f);
// register the font GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(customFont); // register the font
} catch (IOException e) { ge.registerFont(customFont);
LOG.error("Could not load font", e); } catch (IOException e) {
} catch (FontFormatException e) { LOG.error("Could not load font", e);
LOG.error("Font format error", e); } catch (FontFormatException e) {
LOG.error("Font format error", e);
}
} }
}
FontChooserComboBox box = new FontChooserComboBox(); FontChooserComboBox box = new FontChooserComboBox();
box.getPreferredSize(); box.getPreferredSize();
@@ -38,6 +38,7 @@ import org.diylc.images.IconLoader;
import org.diylc.lang.TranslateUtil; import org.diylc.lang.TranslateUtil;
import org.diylc.swing.ActionFactory; import org.diylc.swing.ActionFactory;
import org.diylc.swing.ISwingUI; import org.diylc.swing.ISwingUI;
import org.diylc.utils.ResourceLoader;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.io.xml.DomDriver;
@@ -163,11 +164,11 @@ public class ConfigPlugin implements IPlugIn {
ActionFactory.getInstance() ActionFactory.getInstance()
.createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU); .createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU);
File themeDir = new File("themes"); File[] themeFiles = ResourceLoader.getFiles("themes");
if (themeDir.exists()) { if (themeFiles != null && themeFiles.length > 0) {
XStream xStream = new XStream(new DomDriver()); XStream xStream = new XStream(new DomDriver());
swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU); swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU);
for (File file : themeDir.listFiles()) { for (File file : themeFiles) {
if (file.getName().toLowerCase().endsWith(".xml")) { if (file.getName().toLowerCase().endsWith(".xml")) {
try { try {
InputStream in = new FileInputStream(file); InputStream in = new FileInputStream(file);