diff --git a/diylc/diylc-core/src/org/diylc/common/ISelectionProcessor.java b/diylc/diylc-core/src/org/diylc/common/ISelectionProcessor.java
index d6caf877..56075d10 100644
--- a/diylc/diylc-core/src/org/diylc/common/ISelectionProcessor.java
+++ b/diylc/diylc-core/src/org/diylc/common/ISelectionProcessor.java
@@ -99,10 +99,12 @@ public interface ISelectionProcessor {
/**
* Returns the minimum rectangle containing all selected components, or null if none exists.
* Rectangle is scaled by the current zoom level.
+ *
+ * @param applyZoom
*
* @return
*/
- Rectangle2D getSelectionBounds();
+ Rectangle2D getSelectionBounds(boolean applyZoom);
/**
* Moves selection for the specified offset.
diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
index c5c7697d..ad3370f7 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
+++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
@@ -859,7 +859,7 @@ public class Presenter implements IPlugInPort {
}
@Override
- public Rectangle2D getSelectionBounds() {
+ public Rectangle2D getSelectionBounds(boolean applyZoom) {
if (selectedComponents == null || selectedComponents.isEmpty())
return null;
@@ -871,7 +871,7 @@ public class Presenter implements IPlugInPort {
else
LOG.info("Area is null");
}
- if (drawingManager.getZoomLevel() != 1) {
+ if (drawingManager.getZoomLevel() != 1 && applyZoom) {
totalArea
.transform(AffineTransform.getScaleInstance(drawingManager.getZoomLevel(), drawingManager.getZoomLevel()));
}
@@ -1881,7 +1881,7 @@ public class Presenter implements IPlugInPort {
if (selectedComponents.isEmpty()) {
return null;
}
- Rectangle2D rect = getSelectionBounds();
+ Rectangle2D rect = getSelectionBounds(false);
double width = rect.getWidth();
double height = rect.getHeight();
diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar
index cc3fc649..efad334d 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/connectivity/CutLine.java b/diylc/diylc-library/src/org/diylc/components/connectivity/CutLine.java
index 6f863ede..28582053 100644
--- a/diylc/diylc-library/src/org/diylc/components/connectivity/CutLine.java
+++ b/diylc/diylc-library/src/org/diylc/components/connectivity/CutLine.java
@@ -22,7 +22,6 @@ import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics2D;
import java.awt.Point;
-import java.awt.geom.Rectangle2D;
import org.diylc.common.ObjectCache;
import org.diylc.common.OrientationHV;
diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar
index cc3fc649..efad334d 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/src/org/diylc/DIYLCStarter.java b/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
index 43c97187..cdc34297 100644
--- a/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
+++ b/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java
@@ -1,223 +1,231 @@
/*
+ *
+ * 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;
- DIY Layout Creator (DIYLC).
- Copyright (c) 2009-2018 held jointly by the individual authors.
+import java.awt.AlphaComposite;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.SplashScreen;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.URL;
+import java.util.Properties;
- This file is part of DIYLC.
+import javax.swing.ImageIcon;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
- 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.
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+import org.diylc.appframework.miscutils.ConfigurationManager;
+import org.diylc.appframework.miscutils.PropertyInjector;
+import org.diylc.images.IconLoader;
+import org.diylc.presenter.Presenter;
+import org.diylc.swing.gui.MainFrame;
+import org.diylc.swing.gui.TemplateDialog;
+import org.diylc.swingframework.FontChooserComboBox;
- 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.
+/**
+ * Main class that runs DIYLC.
+ *
+ * @author Branislav Stojkovic
+ *
+ * @see Presenter
+ * @see MainFrame
+ */
+public class DIYLCStarter {
- You should have received a copy of the GNU General Public License
- along with DIYLC. If not, see .
+ private static final Logger LOG = Logger.getLogger(DIYLCStarter.class);
-*/
-package org.diylc;
-
-import java.awt.AlphaComposite;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.SplashScreen;
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.URL;
-import java.util.Properties;
-
-import javax.swing.ImageIcon;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-import org.diylc.appframework.miscutils.ConfigurationManager;
-import org.diylc.appframework.miscutils.PropertyInjector;
-import org.diylc.images.IconLoader;
-import org.diylc.presenter.Presenter;
-import org.diylc.swing.gui.MainFrame;
-import org.diylc.swing.gui.TemplateDialog;
-
-/**
- * Main class that runs DIYLC.
- *
- * @author Branislav Stojkovic
- *
- * @see Presenter
- * @see MainFrame
- */
-public class DIYLCStarter {
-
- private static final Logger LOG = Logger.getLogger(DIYLCStarter.class);
-
- private static final String SCRIPT_RUN = "org.diylc.scriptRun";
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- // Initialize splash screen
- final SplashScreen splash = SplashScreen.getSplashScreen();
- if (splash != null) {
- final Graphics2D g = splash.createGraphics();
- if (g != null) {
- Thread t = new Thread(new Runnable() {
-
- @Override
- public void run() {
- for (int i = 90; i >= 0; i--) {
- if (!splash.isVisible())
- return;
- final int frame = i;
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- renderSplashFrame(splash, g, frame);
- splash.update();
- }
- });
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
- }
- }
- });
- t.start();
- }
- }
-
- URL url = DIYLCStarter.class.getResource("log4j.properties");
- Properties properties = new Properties();
- try {
- properties.load(url.openStream());
- PropertyConfigurator.configure(properties);
- } catch (Exception e) {
- LOG.error("Could not initialize log4j configuration", e);
- }
-
- ConfigurationManager.initialize("diylc");
-
- LOG.debug("Java version: " + System.getProperty("java.runtime.version") + " by "
- + System.getProperty("java.vm.vendor"));
- LOG.debug("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
-
- LOG.info("Starting DIYLC with working directory " + System.getProperty("user.dir"));
-
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- LOG.error("Could not set Look&Feel", e);
- }
-
- String val = System.getProperty(SCRIPT_RUN);
- if (!"true".equals(val)) {
- int response =
- JOptionPane.showConfirmDialog(null, "It is not recommended to run DIYLC by clicking on the diylc.jar file.\n"
- + "Please use diylc.exe on Windows or run.sh on OSX/Linux to ensure the best\n"
- + "performance and reliability. Do you want to continue?", "DIYLC", JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE);
- if (response != JOptionPane.YES_OPTION) {
- System.exit(0);
- }
- }
-
- MainFrame mainFrame = new MainFrame();
- mainFrame.setLocationRelativeTo(null);
- mainFrame.setVisible(true);
- if (args.length > 0) {
- mainFrame.getPresenter().loadProjectFromFile(args[0]);
- } else {
- boolean showTemplates = ConfigurationManager.getInstance().readBoolean(TemplateDialog.SHOW_TEMPLATES_KEY, false);
- if (showTemplates) {
- TemplateDialog templateDialog = new TemplateDialog(mainFrame, mainFrame.getPresenter());
- if (!templateDialog.getFiles().isEmpty()) {
- templateDialog.setVisible(true);
- }
- }
- }
-
- properties = new Properties();
- try {
- LOG.info("Injecting default properties.");
- File f = new File("config.properties");
- if (f.exists()) {
- properties.load(new FileInputStream(f));
- PropertyInjector.injectProperties(properties);
- }
- } catch (Exception e) {
- LOG.error("Could not read config.properties file", e);
- }
- }
-
- // Splash screen stuff below
-
- private static ImageIcon resistor = null;
-
- public static ImageIcon getResistor() {
- if (resistor == null) {
- resistor = (ImageIcon)IconLoader.SplashResistor.getIcon();
- }
- return resistor;
- }
-
- private static ImageIcon film = null;
-
- public static ImageIcon getFilm() {
- if (film == null) {
- film = (ImageIcon)IconLoader.SplashFilm.getIcon();
- }
- return film;
- }
-
- private static ImageIcon ceramic = null;
-
- public static ImageIcon getCeramic() {
- if (ceramic == null) {
- ceramic = (ImageIcon)IconLoader.SplashCeramic.getIcon();
- }
- return ceramic;
- }
-
- private static ImageIcon electrolytic = null;
-
- public static ImageIcon getElectrolytic() {
- if (electrolytic == null) {
- electrolytic = (ImageIcon)IconLoader.SplashElectrolytic.getIcon();
- }
- return electrolytic;
- }
-
- private static ImageIcon splash = null;
-
- public static ImageIcon getSplash() {
- if (splash == null) {
- splash = (ImageIcon)IconLoader.Splash.getIcon();
- }
- return splash;
- }
-
- private static Point resistorTarget = new Point(112, 114);
- private static Point filmTarget = new Point(233, 113);
- private static Point electrolyticTarget = new Point(261, 23);
- private static Point ceramicTarget = new Point(352, 22);
-
- private static int pxPerFrame = 3;
-
- static void renderSplashFrame(SplashScreen splash, Graphics2D g, int frame) {
- g.setComposite(AlphaComposite.Clear);
- getSplash().paintIcon(null, g, 0, 0);
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f - frame * 0.007f));
- getResistor().paintIcon(null, g, resistorTarget.x - pxPerFrame * frame, resistorTarget.y);
- getFilm().paintIcon(null, g, filmTarget.x, filmTarget.y + pxPerFrame * frame);
- getElectrolytic().paintIcon(null, g, electrolyticTarget.x, electrolyticTarget.y - pxPerFrame * frame);
- getCeramic().paintIcon(null, g, ceramicTarget.x + pxPerFrame * frame, ceramicTarget.y);
- }
-}
+ private static final String SCRIPT_RUN = "org.diylc.scriptRun";
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // Initialize splash screen
+ final SplashScreen splash = SplashScreen.getSplashScreen();
+ if (splash != null) {
+ final Graphics2D g = splash.createGraphics();
+ if (g != null) {
+ Thread t = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ for (int i = 90; i >= 0; i--) {
+ if (!splash.isVisible())
+ return;
+ final int frame = i;
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ renderSplashFrame(splash, g, frame);
+ splash.update();
+ }
+ });
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ });
+ t.start();
+ }
+ }
+
+ URL url = DIYLCStarter.class.getResource("log4j.properties");
+ Properties properties = new Properties();
+ try {
+ properties.load(url.openStream());
+ PropertyConfigurator.configure(properties);
+ } catch (Exception e) {
+ LOG.error("Could not initialize log4j configuration", e);
+ }
+
+ ConfigurationManager.initialize("diylc");
+
+ LOG.debug("Java version: " + System.getProperty("java.runtime.version") + " by "
+ + System.getProperty("java.vm.vendor"));
+ LOG.debug("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
+
+ LOG.info("Starting DIYLC with working directory " + System.getProperty("user.dir"));
+
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception e) {
+ LOG.error("Could not set Look&Feel", e);
+ }
+
+// Thread fontThread = new Thread(new Runnable() {
+//
+// @Override
+// public void run() {
+// LOG.debug("Starting font pre-loading");
+// FontChooserComboBox box = new FontChooserComboBox();
+// LOG.debug("Finished font pre-loading");
+// }
+// });
+// fontThread.start();
+
+ String val = System.getProperty(SCRIPT_RUN);
+ if (!"true".equals(val)) {
+ int response =
+ JOptionPane.showConfirmDialog(null, "It is not recommended to run DIYLC by clicking on the diylc.jar file.\n"
+ + "Please use diylc.exe on Windows or run.sh on OSX/Linux to ensure the best\n"
+ + "performance and reliability. Do you want to continue?", "DIYLC", JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+ if (response != JOptionPane.YES_OPTION) {
+ System.exit(0);
+ }
+ }
+
+ MainFrame mainFrame = new MainFrame();
+ mainFrame.setLocationRelativeTo(null);
+ mainFrame.setVisible(true);
+ if (args.length > 0) {
+ mainFrame.getPresenter().loadProjectFromFile(args[0]);
+ } else {
+ boolean showTemplates = ConfigurationManager.getInstance().readBoolean(TemplateDialog.SHOW_TEMPLATES_KEY, false);
+ if (showTemplates) {
+ TemplateDialog templateDialog = new TemplateDialog(mainFrame, mainFrame.getPresenter());
+ if (!templateDialog.getFiles().isEmpty()) {
+ templateDialog.setVisible(true);
+ }
+ }
+ }
+
+ properties = new Properties();
+ try {
+ LOG.info("Injecting default properties.");
+ File f = new File("config.properties");
+ if (f.exists()) {
+ properties.load(new FileInputStream(f));
+ PropertyInjector.injectProperties(properties);
+ }
+ } catch (Exception e) {
+ LOG.error("Could not read config.properties file", e);
+ }
+ }
+
+ // Splash screen stuff below
+
+ private static ImageIcon resistor = null;
+
+ public static ImageIcon getResistor() {
+ if (resistor == null) {
+ resistor = (ImageIcon) IconLoader.SplashResistor.getIcon();
+ }
+ return resistor;
+ }
+
+ private static ImageIcon film = null;
+
+ public static ImageIcon getFilm() {
+ if (film == null) {
+ film = (ImageIcon) IconLoader.SplashFilm.getIcon();
+ }
+ return film;
+ }
+
+ private static ImageIcon ceramic = null;
+
+ public static ImageIcon getCeramic() {
+ if (ceramic == null) {
+ ceramic = (ImageIcon) IconLoader.SplashCeramic.getIcon();
+ }
+ return ceramic;
+ }
+
+ private static ImageIcon electrolytic = null;
+
+ public static ImageIcon getElectrolytic() {
+ if (electrolytic == null) {
+ electrolytic = (ImageIcon) IconLoader.SplashElectrolytic.getIcon();
+ }
+ return electrolytic;
+ }
+
+ private static ImageIcon splash = null;
+
+ public static ImageIcon getSplash() {
+ if (splash == null) {
+ splash = (ImageIcon) IconLoader.Splash.getIcon();
+ }
+ return splash;
+ }
+
+ private static Point resistorTarget = new Point(112, 114);
+ private static Point filmTarget = new Point(233, 113);
+ private static Point electrolyticTarget = new Point(261, 23);
+ private static Point ceramicTarget = new Point(352, 22);
+
+ private static int pxPerFrame = 3;
+
+ static void renderSplashFrame(SplashScreen splash, Graphics2D g, int frame) {
+ g.setComposite(AlphaComposite.Clear);
+ getSplash().paintIcon(null, g, 0, 0);
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f - frame * 0.007f));
+ getResistor().paintIcon(null, g, resistorTarget.x - pxPerFrame * frame, resistorTarget.y);
+ getFilm().paintIcon(null, g, filmTarget.x, filmTarget.y + pxPerFrame * frame);
+ getElectrolytic().paintIcon(null, g, electrolyticTarget.x, electrolyticTarget.y - pxPerFrame * frame);
+ getCeramic().paintIcon(null, g, ceramicTarget.x + pxPerFrame * frame, ceramicTarget.y);
+ }
+}
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
index 6dd5f126..7f6a25b8 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java
@@ -239,17 +239,21 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
public void unitsChanged(boolean isMetric) {
plugInPort.setMetric(isMetric);
}
- });
+ });
+
+ // disable scrolling
+ scrollPane.setWheelScrollingEnabled(false);
+
scrollPane.addMouseWheelListener(new MouseWheelListener() {
@Override
- public void mouseWheelMoved(MouseWheelEvent e) {
+ public void mouseWheelMoved(MouseWheelEvent e) {
+ final JScrollBar horizontalScrollBar = scrollPane.getHorizontalScrollBar();
+ final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar();
+
boolean wheelZoom = ConfigurationManager.getInstance().readBoolean(IPlugInPort.WHEEL_ZOOM_KEY, false);
if (wheelZoom || (Utils.isMac() ? e.isMetaDown() : e.isControlDown())) {
- // disable scrolling
- scrollPane.setWheelScrollingEnabled(false);
-
Point mousePos = getCanvasPanel().getMousePosition(true);
@@ -280,9 +284,16 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
horizontal.setValue(horizontal.getValue() + dx);
JScrollBar vertical = scrollPane.getVerticalScrollBar();
vertical.setValue(vertical.getValue() + dy);
- } else {
- // enable scrolling
- scrollPane.setWheelScrollingEnabled(true);
+ } if (e.isShiftDown()) {
+ int iScrollAmount = e.getScrollAmount();
+ int iNewValue = horizontalScrollBar.getValue() + horizontalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
+ if (iNewValue <= horizontalScrollBar.getMaximum())
+ horizontalScrollBar.setValue(iNewValue);
+ } else {
+ int iScrollAmount = e.getScrollAmount();
+ int iNewValue = verticalScrollBar.getValue() + verticalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
+ if (iNewValue <= verticalScrollBar.getMaximum())
+ verticalScrollBar.setValue(iNewValue);
}
}
});
@@ -602,7 +613,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
@Override
public void run() {
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.SHOW_RULERS_KEY, true))
- scrollPane.setSelectionRectangle(plugInPort.getSelectionBounds());
+ scrollPane.setSelectionRectangle(plugInPort.getSelectionBounds(true));
}
});
break;
diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml
index 898f3bbc..bc41eab9 100644
--- a/diylc/diylc-swing/update.xml
+++ b/diylc/diylc-swing/update.xml
@@ -1868,16 +1868,24 @@
3
- 41
- 2
+ 42
+ 0
2018-12-11 00:00:00.000 CET
+
+ NEW_FEATURE
+ Holding "shift" key switches mouse wheel scrolling from vertical to horizontal
+
BUG_FIX
"Cut Line" component sometimes disappears
+
+ BUG_FIX
+ Measurement tool shows incorrect readings when zoomed in or out
+
https://github.com/bancika/diy-layout-creator/releases