diff --git a/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java b/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java
index c6ba12de..afff6d31 100644
--- a/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java
+++ b/diylc/diylc-core/src/org/diylc/common/IPlugInPort.java
@@ -255,9 +255,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
void setLayerLocked(int layerZOrder, boolean locked);
/**
- * @return selection size expressed in either inches or centimeters, based on the user preference.
+ * @return selection size expressed in both inches or centimeters, respectively
*/
- Point2D calculateSelectionDimension();
+ Point2D[] calculateSelectionDimension();
// /**
// * @return the smallest rectangle that encloses the selection
diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
index 29d3afc9..98a805da 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
+++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
@@ -1707,30 +1707,26 @@ public class Presenter implements IPlugInPort {
}
@Override
- public Point2D calculateSelectionDimension() {
+ public Point2D[] calculateSelectionDimension() {
if (selectedComponents.isEmpty()) {
return null;
}
- boolean metric = ConfigurationManager.getInstance().readBoolean(METRIC_KEY, true);
- Area area = new Area();
- for (IDIYComponent> component : selectedComponents) {
- Area componentArea = drawingManager.getComponentArea(component);
- if (componentArea != null) {
- area.add(componentArea);
- } else {
- LOG.warn("No area found for: " + component.getName());
- }
- }
- double width = area.getBounds2D().getWidth();
- double height = area.getBounds2D().getHeight();
+ Rectangle2D rect = getSelectionBounds();
+
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
width /= Constants.PIXELS_PER_INCH;
height /= Constants.PIXELS_PER_INCH;
- if (metric) {
- width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
- height *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
- }
- Point2D dimension = new Point2D.Double(width, height);
- return dimension;
+
+ Point2D inSize = new Point2D.Double(width, height);
+
+ width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
+ height *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
+
+ Point2D cmSize = new Point2D.Double(width, height);
+
+ return new Point2D[] {inSize, cmSize};
}
// @Override
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java
index 8966262f..44c09bb8 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/statusbar/StatusBar.java
@@ -30,7 +30,6 @@ import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
import org.diylc.announcements.AnnouncementProvider;
-import org.diylc.appframework.miscutils.ConfigurationManager;
import org.diylc.appframework.miscutils.Utils;
import org.diylc.common.BadPositionException;
import org.diylc.common.ComponentType;
@@ -41,7 +40,6 @@ import org.diylc.common.ITask;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IView;
import org.diylc.images.IconLoader;
-import org.diylc.presenter.Presenter;
import org.diylc.swing.ISwingUI;
import org.diylc.swingframework.MemoryBar;
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
@@ -134,7 +132,7 @@ public class StatusBar extends JPanel implements IPlugIn {
private UpdateLabel getUpdateLabel() {
if (updateLabel == null) {
updateLabel = new UpdateLabel(plugInPort.getCurrentVersionNumber(), UPDATE_URL) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -153,7 +151,7 @@ public class StatusBar extends JPanel implements IPlugIn {
public JLabel getAnnouncementLabel() {
if (announcementLabel == null) {
announcementLabel = new JLabel(IconLoader.Megaphone.getIcon()) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -200,7 +198,7 @@ public class StatusBar extends JPanel implements IPlugIn {
private MemoryBar getMemoryPanel() {
if (memoryPanel == null) {
memoryPanel = new MemoryBar(false) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -223,7 +221,7 @@ public class StatusBar extends JPanel implements IPlugIn {
public JLabel getSizeLabel() {
if (sizeLabel == null) {
sizeLabel = new JLabel(IconLoader.Size.getIcon()) {
-
+
private static final long serialVersionUID = 1L;
@Override
@@ -237,17 +235,16 @@ public class StatusBar extends JPanel implements IPlugIn {
@Override
public void mouseClicked(MouseEvent e) {
- Point2D size = plugInPort.calculateSelectionDimension();
- boolean metric = ConfigurationManager.getInstance().readBoolean(Presenter.METRIC_KEY, true);
+ Point2D[] sizes = plugInPort.calculateSelectionDimension();
String text;
- if (size == null) {
+ if (sizes == null) {
text = "Selection is empty.";
} else {
text =
- "Selection size: " + sizeFormat.format(size.getX()) + " x " + sizeFormat.format(size.getY())
- + (metric ? " cm" : " in");
+ sizeFormat.format(sizes[0].getX()) + " x " + sizeFormat.format(sizes[0].getY()) + " in\n"
+ + sizeFormat.format(sizes[1].getX()) + " x " + sizeFormat.format(sizes[1].getY()) + " cm";
}
- JOptionPane.showMessageDialog(SwingUtilities.getRootPane(StatusBar.this), text, "Information",
+ JOptionPane.showMessageDialog(SwingUtilities.getRootPane(StatusBar.this), text, "Selection Size",
JOptionPane.INFORMATION_MESSAGE);
}
});
diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml
index a5aab7ec..84dd2c79 100644
--- a/diylc/diylc-swing/update.xml
+++ b/diylc/diylc-swing/update.xml
@@ -1709,6 +1709,10 @@
IMPROVEMENT
Solder Pad size shouldn't be rounded up or down to the nearest integer to allow better precision
+
+
+ IMPROVEMENT
+ Show selection size in both inches and centimeters
BUG_FIX