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
|
* <code>Map<IDIYComponent<?>, Set<Integer>></code> containing all the
|
||||||
* components and indices of their control points that are under the cursor.
|
* 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() {
|
public JLabel getSizeLabel() {
|
||||||
if (sizeLabel == null) {
|
if (sizeLabel == null) {
|
||||||
sizeLabel = new JLabel();
|
sizeLabel = new JLabel("N/A");
|
||||||
|
sizeLabel.setToolTipText("Selection Size");
|
||||||
sizeLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(
|
sizeLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(
|
||||||
0, 1, 0, 1, UIManager.getColor("Separator.shadow")), BorderFactory
|
0, 1, 0, 1, UIManager.getColor("Separator.shadow")), BorderFactory
|
||||||
.createEmptyBorder(0, 4, 0, 4)));
|
.createEmptyBorder(0, 4, 0, 4)));
|
||||||
@@ -186,11 +187,11 @@ public class StatusBar extends JPanel implements IPlugIn {
|
|||||||
boolean isMetric = (Boolean) ConfigurationManager.getInstance().getConfigurationItem(
|
boolean isMetric = (Boolean) ConfigurationManager.getInstance().getConfigurationItem(
|
||||||
Presenter.METRIC_KEY);
|
Presenter.METRIC_KEY);
|
||||||
if (size == null) {
|
if (size == null) {
|
||||||
getSizeLabel().setText("Size: N/A");
|
getSizeLabel().setText("N/A");
|
||||||
} else {
|
} else {
|
||||||
getSizeLabel().setText(
|
getSizeLabel().setText(
|
||||||
"Size: " + sizeFormat.format(size.getX()) + " x "
|
sizeFormat.format(size.getX()) + " x " + sizeFormat.format(size.getY())
|
||||||
+ sizeFormat.format(size.getY()) + (isMetric ? " cm" : " in"));
|
+ (isMetric ? " cm" : " in"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SLOT_CHANGED:
|
case SLOT_CHANGED:
|
||||||
|
|||||||
+5
-3
@@ -437,6 +437,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
messageDispatcher.dispatchMessage(EventType.MOUSE_MOVED, scaledPoint);
|
||||||
|
|
||||||
if (!components.equals(controlPointMap)) {
|
if (!components.equals(controlPointMap)) {
|
||||||
controlPointMap = components;
|
controlPointMap = components;
|
||||||
messageDispatcher.dispatchMessage(EventType.AVAILABLE_CTRL_POINTS_CHANGED,
|
messageDispatcher.dispatchMessage(EventType.AVAILABLE_CTRL_POINTS_CHANGED,
|
||||||
@@ -604,7 +606,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
.deepClone(currentProject), "Add");
|
.deepClone(currentProject), "Add");
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteSelectedComponents() {
|
public void deleteSelectedComponents() {
|
||||||
LOG.debug("deleteSelectedComponents()");
|
LOG.debug("deleteSelectedComponents()");
|
||||||
@@ -679,8 +681,8 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
double width = area.getBounds2D().getWidth();
|
double width = area.getBounds2D().getWidth();
|
||||||
double height = area.getBounds2D().getHeight();
|
double height = area.getBounds2D().getHeight();
|
||||||
width /= Constants.PIXELS_PER_INCH;
|
width /= Constants.GRID * Constants.GRIDS_PER_INCH;
|
||||||
height /= Constants.PIXELS_PER_INCH;
|
height /= Constants.GRID * Constants.GRIDS_PER_INCH;
|
||||||
if (isMetric) {
|
if (isMetric) {
|
||||||
width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
width *= SizeUnit.in.getFactor() / SizeUnit.cm.getFactor();
|
||||||
height *= 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.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Stroke;
|
import java.awt.Stroke;
|
||||||
import java.awt.Toolkit;
|
|
||||||
|
|
||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
|
|
||||||
public class Constants {
|
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 int GRIDS_PER_INCH = 10;
|
||||||
public static Size GRID_SIZE = new Size(1d / GRIDS_PER_INCH, SizeUnit.in);
|
public static Size GRID_SIZE = new Size(1d / GRIDS_PER_INCH, SizeUnit.in);
|
||||||
public static final int GRID = 10;
|
public static final int GRID = 10;
|
||||||
|
|||||||
Reference in New Issue
Block a user