better measure

This commit is contained in:
bancika
2011-01-10 22:51:26 +00:00
parent d141b9c477
commit c4cedd8946
4 changed files with 17 additions and 10 deletions
@@ -64,5 +64,10 @@ public enum EventType {
* <code>Map<IDIYComponent<?>, Set<Integer>></code> containing all the
* components and indices of their control points that are under the cursor.
*/
AVAILABLE_CTRL_POINTS_CHANGED;
AVAILABLE_CTRL_POINTS_CHANGED,
/**
* Called when mouse cursor is moved. Point object is passed, containing the
* current cursor location (not taking zoom into account).
*/
MOUSE_MOVED;
}
@@ -107,7 +107,8 @@ public class StatusBar extends JPanel implements IPlugIn {
public JLabel getSizeLabel() {
if (sizeLabel == null) {
sizeLabel = new JLabel();
sizeLabel = new JLabel("N/A");
sizeLabel.setToolTipText("Selection Size");
sizeLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(
0, 1, 0, 1, UIManager.getColor("Separator.shadow")), BorderFactory
.createEmptyBorder(0, 4, 0, 4)));
@@ -186,11 +187,11 @@ public class StatusBar extends JPanel implements IPlugIn {
boolean isMetric = (Boolean) ConfigurationManager.getInstance().getConfigurationItem(
Presenter.METRIC_KEY);
if (size == null) {
getSizeLabel().setText("Size: N/A");
getSizeLabel().setText("N/A");
} else {
getSizeLabel().setText(
"Size: " + sizeFormat.format(size.getX()) + " x "
+ sizeFormat.format(size.getY()) + (isMetric ? " cm" : " in"));
sizeFormat.format(size.getX()) + " x " + sizeFormat.format(size.getY())
+ (isMetric ? " cm" : " in"));
}
break;
case SLOT_CHANGED:
@@ -437,6 +437,8 @@ public class Presenter implements IPlugInPort {
}
}
messageDispatcher.dispatchMessage(EventType.MOUSE_MOVED, scaledPoint);
if (!components.equals(controlPointMap)) {
controlPointMap = components;
messageDispatcher.dispatchMessage(EventType.AVAILABLE_CTRL_POINTS_CHANGED,
@@ -604,7 +606,7 @@ public class Presenter implements IPlugInPort {
.deepClone(currentProject), "Add");
messageDispatcher.dispatchMessage(EventType.REPAINT);
}
@Override
public void deleteSelectedComponents() {
LOG.debug("deleteSelectedComponents()");
@@ -679,8 +681,8 @@ public class Presenter implements IPlugInPort {
}
double width = area.getBounds2D().getWidth();
double height = area.getBounds2D().getHeight();
width /= Constants.PIXELS_PER_INCH;
height /= Constants.PIXELS_PER_INCH;
width /= Constants.GRID * Constants.GRIDS_PER_INCH;
height /= Constants.GRID * Constants.GRIDS_PER_INCH;
if (isMetric) {
width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
height *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
@@ -4,14 +4,13 @@ import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Stroke;
import java.awt.Toolkit;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
public class Constants {
public static final int PIXELS_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
// public static final int PIXELS_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
public static int GRIDS_PER_INCH = 10;
public static Size GRID_SIZE = new Size(1d / GRIDS_PER_INCH, SizeUnit.in);
public static final int GRID = 10;