shift for horizontal scroll

fixed issue with size calculation when zoomed
This commit is contained in:
Branislav Stojkovic
2018-12-15 18:23:56 +01:00
parent ed6792800b
commit 2ee81093a0
8 changed files with 260 additions and 232 deletions
@@ -100,9 +100,11 @@ 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.
@@ -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();
Binary file not shown.
@@ -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;
Binary file not shown.
@@ -1,24 +1,20 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
*
* This file is part of DIYLC.
*
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
* <http://www.gnu.org/licenses/>.
*/
package org.diylc;
import java.awt.AlphaComposite;
@@ -43,6 +39,7 @@ 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;
/**
* Main class that runs DIYLC.
@@ -117,6 +114,17 @@ public class DIYLCStarter {
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 =
@@ -163,7 +171,7 @@ public class DIYLCStarter {
public static ImageIcon getResistor() {
if (resistor == null) {
resistor = (ImageIcon)IconLoader.SplashResistor.getIcon();
resistor = (ImageIcon) IconLoader.SplashResistor.getIcon();
}
return resistor;
}
@@ -172,7 +180,7 @@ public class DIYLCStarter {
public static ImageIcon getFilm() {
if (film == null) {
film = (ImageIcon)IconLoader.SplashFilm.getIcon();
film = (ImageIcon) IconLoader.SplashFilm.getIcon();
}
return film;
}
@@ -181,7 +189,7 @@ public class DIYLCStarter {
public static ImageIcon getCeramic() {
if (ceramic == null) {
ceramic = (ImageIcon)IconLoader.SplashCeramic.getIcon();
ceramic = (ImageIcon) IconLoader.SplashCeramic.getIcon();
}
return ceramic;
}
@@ -190,7 +198,7 @@ public class DIYLCStarter {
public static ImageIcon getElectrolytic() {
if (electrolytic == null) {
electrolytic = (ImageIcon)IconLoader.SplashElectrolytic.getIcon();
electrolytic = (ImageIcon) IconLoader.SplashElectrolytic.getIcon();
}
return electrolytic;
}
@@ -199,7 +207,7 @@ public class DIYLCStarter {
public static ImageIcon getSplash() {
if (splash == null) {
splash = (ImageIcon)IconLoader.Splash.getIcon();
splash = (ImageIcon) IconLoader.Splash.getIcon();
}
return splash;
}
@@ -240,16 +240,20 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner {
plugInPort.setMetric(isMetric);
}
});
// disable scrolling
scrollPane.setWheelScrollingEnabled(false);
scrollPane.addMouseWheelListener(new MouseWheelListener() {
@Override
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);
} if (e.isShiftDown()) {
int iScrollAmount = e.getScrollAmount();
int iNewValue = horizontalScrollBar.getValue() + horizontalScrollBar.getBlockIncrement() * iScrollAmount * e.getWheelRotation();
if (iNewValue <= horizontalScrollBar.getMaximum())
horizontalScrollBar.setValue(iNewValue);
} else {
// enable scrolling
scrollPane.setWheelScrollingEnabled(true);
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;
+10 -2
View File
@@ -1868,16 +1868,24 @@
<org.diylc.appframework.update.Version>
<versionNumber>
<major>3</major>
<minor>41</minor>
<build>2</build>
<minor>42</minor>
<build>0</build>
</versionNumber>
<releaseDate>2018-12-11 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Holding "shift" key switches mouse wheel scrolling from vertical to horizontal</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>"Cut Line" component sometimes disappears</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Measurement tool shows incorrect readings when zoomed in or out</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>