Show selection size in both inches and centimeters

This commit is contained in:
bancika
2017-04-20 16:19:22 +02:00
parent f1611bbf0f
commit 5dc090828c
4 changed files with 30 additions and 33 deletions
@@ -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
@@ -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