diff --git a/diylc/diylc-core/.classpath b/diylc/diylc-core/.classpath index 764f3461..d10fce33 100644 --- a/diylc/diylc-core/.classpath +++ b/diylc/diylc-core/.classpath @@ -8,6 +8,7 @@ + diff --git a/diylc/diylc-core/lib/AppleJavaExtensions.jar b/diylc/diylc-core/lib/AppleJavaExtensions.jar new file mode 100644 index 00000000..6659a81c Binary files /dev/null and b/diylc/diylc-core/lib/AppleJavaExtensions.jar differ diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml index 43cad1db..3409fad4 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/update.xml +++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml @@ -3032,6 +3032,34 @@ https://github.com/bancika/diy-layout-creator/releases + + + + 4 + 6 + 0 + + 2020-04-20 00:00:00.000 CET + + + + IMPROVEMENT + Include themes and fonts in OSX app package + + + BUG_FIX + Some boards (e.g. Breadboard) stop working at certain orientations + + + BUG_FIX + Component leads on resistors, capacitors, etc disappear when they are very short + + + BUG_FIX + Prevent "Radial Film Capacitor" from switching to standing mode when end points are too close + + + https://github.com/bancika/diy-layout-creator/releases diff --git a/diylc/diylc-core/src/org/diylc/utils/ResourceLoader.java b/diylc/diylc-core/src/org/diylc/utils/ResourceLoader.java new file mode 100644 index 00000000..16e72e48 --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/utils/ResourceLoader.java @@ -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 + * . + * + */ +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; + } + } +} diff --git a/diylc/diylc-core/src/org/diylc/utils/VersionReader.java b/diylc/diylc-core/src/org/diylc/utils/VersionReader.java new file mode 100644 index 00000000..218fa9fc --- /dev/null +++ b/diylc/diylc-core/src/org/diylc/utils/VersionReader.java @@ -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 allVersions = (List) 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()); + } + } +} diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index 60d56a92..e69de29b 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java b/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java index e21888a8..a7115119 100644 --- a/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java +++ b/diylc/diylc-library/src/org/diylc/components/AbstractLeadedComponent.java @@ -87,6 +87,8 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp // parameters for adjusting the label control point protected transient Double gamma = null; protected transient Double r = null; + + private Boolean hideShortLeads = false; protected AbstractLeadedComponent() { super(); @@ -205,7 +207,7 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp double leadLength = (distance - calculatePinSpacing(shapeRect)) / 2; // only draw leads longer than threshold - if (leadLength > LEAD_RENDER_THRESHOLD) { + if (leadLength > LEAD_RENDER_THRESHOLD || !getHideShortLeads()) { if (shouldShadeLeads()) { Stroke leadStroke = ObjectCache.getInstance().fetchBasicStroke(leadThickness - 1); Color leadColor = getLeadColorForPainting(componentState); @@ -716,6 +718,17 @@ public abstract class AbstractLeadedComponent extends AbstractTransparentComp 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 { Directional, Horizontal diff --git a/diylc/diylc-library/src/org/diylc/components/boards/AbstractBoard.java b/diylc/diylc-library/src/org/diylc/components/boards/AbstractBoard.java index 7844cab1..de9724c7 100644 --- a/diylc/diylc-library/src/org/diylc/components/boards/AbstractBoard.java +++ b/diylc/diylc-library/src/org/diylc/components/boards/AbstractBoard.java @@ -337,7 +337,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent @Override public Rectangle2D getCachingBounds() { 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 { diff --git a/diylc/diylc-library/src/org/diylc/components/boards/Breadboard.java b/diylc/diylc-library/src/org/diylc/components/boards/Breadboard.java index c9ee19ab..292247c4 100644 --- a/diylc/diylc-library/src/org/diylc/components/boards/Breadboard.java +++ b/diylc/diylc-library/src/org/diylc/components/boards/Breadboard.java @@ -382,7 +382,8 @@ public class Breadboard extends AbstractComponent { @Override public Rectangle2D getCachingBounds() { 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 { diff --git a/diylc/diylc-library/src/org/diylc/components/boards/ProtoBoard.java b/diylc/diylc-library/src/org/diylc/components/boards/ProtoBoard.java index fe747dec..c6d176d9 100644 --- a/diylc/diylc-library/src/org/diylc/components/boards/ProtoBoard.java +++ b/diylc/diylc-library/src/org/diylc/components/boards/ProtoBoard.java @@ -700,6 +700,7 @@ public class ProtoBoard extends AbstractComponent { @Override public Rectangle2D getCachingBounds() { 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); } } diff --git a/diylc/diylc-library/src/org/diylc/components/passive/AbstractFilmCapacitor.java b/diylc/diylc-library/src/org/diylc/components/passive/AbstractFilmCapacitor.java index ac2047a2..e888498a 100644 --- a/diylc/diylc-library/src/org/diylc/components/passive/AbstractFilmCapacitor.java +++ b/diylc/diylc-library/src/org/diylc/components/passive/AbstractFilmCapacitor.java @@ -48,11 +48,6 @@ public abstract class AbstractFilmCapacitor extends AbstractLeadedComponent + + @@ -166,7 +168,7 @@ - + diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index 60d56a92..e69de29b 100644 Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index d36ebed4..e69de29b 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ diff --git a/diylc/diylc-swing/releaseUtils.xml b/diylc/diylc-swing/releaseUtils.xml new file mode 100644 index 00000000..48c65f7a --- /dev/null +++ b/diylc/diylc-swing/releaseUtils.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java b/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java index ec619d6c..17a75383 100644 --- a/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java +++ b/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java @@ -39,6 +39,7 @@ import org.diylc.presenter.Presenter; import org.diylc.swing.gui.MainFrame; import org.diylc.swing.gui.TemplateDialog; import org.diylc.swingframework.FontChooserComboBox; +import org.diylc.utils.ResourceLoader; /** * Main class that runs DIYLC. @@ -100,23 +101,23 @@ public class DIYLCStarter { @Override public void run() { LOG.debug("Starting font pre-loading"); - - File dir = new File("fonts"); - File[] fonts = dir.listFiles(); + + File[] fonts = ResourceLoader.getFiles("fonts"); - for (int i = 0; i < fonts.length; i++) { - try { - LOG.info("Dynamically loading font: " + fonts[i].getName()); - Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f); - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - // register the font - ge.registerFont(customFont); - } catch (IOException e) { - LOG.error("Could not load font", e); - } catch (FontFormatException e) { - LOG.error("Font format error", e); + if (fonts != null) + for (int i = 0; i < fonts.length; i++) { + try { + LOG.info("Dynamically loading font: " + fonts[i].getName()); + Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonts[i].getAbsolutePath())).deriveFont(12f); + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + // register the font + ge.registerFont(customFont); + } catch (IOException e) { + LOG.error("Could not load font", e); + } catch (FontFormatException e) { + LOG.error("Font format error", e); + } } - } FontChooserComboBox box = new FontChooserComboBox(); box.getPreferredSize(); diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java index 607fd668..15b51075 100644 --- a/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java +++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/config/ConfigPlugin.java @@ -38,6 +38,7 @@ import org.diylc.images.IconLoader; import org.diylc.lang.TranslateUtil; import org.diylc.swing.ActionFactory; import org.diylc.swing.ISwingUI; +import org.diylc.utils.ResourceLoader; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; @@ -163,11 +164,11 @@ public class ConfigPlugin implements IPlugIn { ActionFactory.getInstance() .createConfigAction(plugInPort, "Sticky Points", IPlugInPort.STICKY_POINTS_KEY, true), CONFIG_MENU); - File themeDir = new File("themes"); - if (themeDir.exists()) { + File[] themeFiles = ResourceLoader.getFiles("themes"); + if (themeFiles != null && themeFiles.length > 0) { XStream xStream = new XStream(new DomDriver()); swingUI.injectSubmenu(THEME_MENU, IconLoader.Pens.getIcon(), CONFIG_MENU); - for (File file : themeDir.listFiles()) { + for (File file : themeFiles) { if (file.getName().toLowerCase().endsWith(".xml")) { try { InputStream in = new FileInputStream(file);