mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 09:12:09 +10:00
better measure
This commit is contained in:
+6
-1
@@ -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;
|
||||
}
|
||||
|
||||
+5
-4
@@ -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:
|
||||
|
||||
+4
-2
@@ -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,
|
||||
@@ -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();
|
||||
|
||||
+1
-2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user