mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Show selection size in both inches and centimeters
This commit is contained in:
@@ -255,9 +255,9 @@ public interface IPlugInPort extends ISelectionProcessor, IMouseProcessor, IKeyP
|
|||||||
void setLayerLocked(int layerZOrder, boolean locked);
|
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
|
// * @return the smallest rectangle that encloses the selection
|
||||||
|
|||||||
@@ -1707,30 +1707,26 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Point2D calculateSelectionDimension() {
|
public Point2D[] calculateSelectionDimension() {
|
||||||
if (selectedComponents.isEmpty()) {
|
if (selectedComponents.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
boolean metric = ConfigurationManager.getInstance().readBoolean(METRIC_KEY, true);
|
Rectangle2D rect = getSelectionBounds();
|
||||||
Area area = new Area();
|
|
||||||
for (IDIYComponent<?> component : selectedComponents) {
|
double width = rect.getWidth();
|
||||||
Area componentArea = drawingManager.getComponentArea(component);
|
double height = rect.getHeight();
|
||||||
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();
|
|
||||||
width /= Constants.PIXELS_PER_INCH;
|
width /= Constants.PIXELS_PER_INCH;
|
||||||
height /= Constants.PIXELS_PER_INCH;
|
height /= Constants.PIXELS_PER_INCH;
|
||||||
if (metric) {
|
|
||||||
width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
Point2D inSize = new Point2D.Double(width, height);
|
||||||
height *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
|
||||||
}
|
width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
||||||
Point2D dimension = new Point2D.Double(width, height);
|
height *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
||||||
return dimension;
|
|
||||||
|
Point2D cmSize = new Point2D.Double(width, height);
|
||||||
|
|
||||||
|
return new Point2D[] {inSize, cmSize};
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import javax.swing.SwingUtilities;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.announcements.AnnouncementProvider;
|
import org.diylc.announcements.AnnouncementProvider;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
|
||||||
import org.diylc.appframework.miscutils.Utils;
|
import org.diylc.appframework.miscutils.Utils;
|
||||||
import org.diylc.common.BadPositionException;
|
import org.diylc.common.BadPositionException;
|
||||||
import org.diylc.common.ComponentType;
|
import org.diylc.common.ComponentType;
|
||||||
@@ -41,7 +40,6 @@ import org.diylc.common.ITask;
|
|||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.IView;
|
import org.diylc.core.IView;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
import org.diylc.presenter.Presenter;
|
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swingframework.MemoryBar;
|
import org.diylc.swingframework.MemoryBar;
|
||||||
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
|
import org.diylc.swingframework.miscutils.PercentageListCellRenderer;
|
||||||
@@ -134,7 +132,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
private UpdateLabel getUpdateLabel() {
|
private UpdateLabel getUpdateLabel() {
|
||||||
if (updateLabel == null) {
|
if (updateLabel == null) {
|
||||||
updateLabel = new UpdateLabel(plugInPort.getCurrentVersionNumber(), UPDATE_URL) {
|
updateLabel = new UpdateLabel(plugInPort.getCurrentVersionNumber(), UPDATE_URL) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,7 +151,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
public JLabel getAnnouncementLabel() {
|
public JLabel getAnnouncementLabel() {
|
||||||
if (announcementLabel == null) {
|
if (announcementLabel == null) {
|
||||||
announcementLabel = new JLabel(IconLoader.Megaphone.getIcon()) {
|
announcementLabel = new JLabel(IconLoader.Megaphone.getIcon()) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -200,7 +198,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
private MemoryBar getMemoryPanel() {
|
private MemoryBar getMemoryPanel() {
|
||||||
if (memoryPanel == null) {
|
if (memoryPanel == null) {
|
||||||
memoryPanel = new MemoryBar(false) {
|
memoryPanel = new MemoryBar(false) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -223,7 +221,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
public JLabel getSizeLabel() {
|
public JLabel getSizeLabel() {
|
||||||
if (sizeLabel == null) {
|
if (sizeLabel == null) {
|
||||||
sizeLabel = new JLabel(IconLoader.Size.getIcon()) {
|
sizeLabel = new JLabel(IconLoader.Size.getIcon()) {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -237,17 +235,16 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
Point2D size = plugInPort.calculateSelectionDimension();
|
Point2D[] sizes = plugInPort.calculateSelectionDimension();
|
||||||
boolean metric = ConfigurationManager.getInstance().readBoolean(Presenter.METRIC_KEY, true);
|
|
||||||
String text;
|
String text;
|
||||||
if (size == null) {
|
if (sizes == null) {
|
||||||
text = "Selection is empty.";
|
text = "Selection is empty.";
|
||||||
} else {
|
} else {
|
||||||
text =
|
text =
|
||||||
"Selection size: " + sizeFormat.format(size.getX()) + " x " + sizeFormat.format(size.getY())
|
sizeFormat.format(sizes[0].getX()) + " x " + sizeFormat.format(sizes[0].getY()) + " in\n"
|
||||||
+ (metric ? " cm" : " in");
|
+ 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);
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1709,6 +1709,10 @@
|
|||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Solder Pad size shouldn't be rounded up or down to the nearest integer to allow better precision</description>
|
<description>Solder Pad size shouldn't be rounded up or down to the nearest integer to allow better precision</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Show selection size in both inches and centimeters</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>BUG_FIX</changeType>
|
<changeType>BUG_FIX</changeType>
|
||||||
|
|||||||
Reference in New Issue
Block a user