From c4cedd8946d0792f0ff7e89c8fc47df5f6e7cd84 Mon Sep 17 00:00:00 2001 From: bancika Date: Mon, 10 Jan 2011 22:51:26 +0000 Subject: [PATCH] better measure --- .../DIYLC/src/org/diylc/common/EventType.java | 7 ++++++- .../DIYLC/src/org/diylc/plugins/statusbar/StatusBar.java | 9 +++++---- .../DIYLC/src/org/diylc/presenter/Presenter.java | 8 +++++--- .../DIYLC/src/org/diylc/utils/Constants.java | 3 +-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/common/EventType.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/common/EventType.java index d423716e..66911dd1 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/common/EventType.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/common/EventType.java @@ -64,5 +64,10 @@ public enum EventType { * Map, Set> 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; } diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/plugins/statusbar/StatusBar.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/plugins/statusbar/StatusBar.java index 5b8e3e5b..300badb4 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/plugins/statusbar/StatusBar.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/plugins/statusbar/StatusBar.java @@ -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: diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java index ca8e2c67..10e93e5e 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java @@ -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(); diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/utils/Constants.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/utils/Constants.java index ba44976b..ceb795f9 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/utils/Constants.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/utils/Constants.java @@ -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;