mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
improved point-by-point creation
This commit is contained in:
+2
-2
@@ -14,6 +14,7 @@ import org.diylc.core.Project;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.Size;
|
||||
import org.diylc.core.measures.SizeUnit;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComponent<T> {
|
||||
|
||||
@@ -63,8 +64,7 @@ public abstract class AbstractCurvedComponent<T> extends AbstractTransparentComp
|
||||
if (componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING) {
|
||||
// Do not track guidelines.
|
||||
drawingObserver.stopTracking();
|
||||
g2d.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 10f,
|
||||
new float[] { 2f, 3f }, 5f));
|
||||
g2d.setStroke(Constants.DASHED_STROKE);
|
||||
g2d.setColor(GUIDELINE_COLOR);
|
||||
g2d.drawLine(controlPoints[0].x, controlPoints[0].y, controlPoints[1].x,
|
||||
controlPoints[1].y);
|
||||
|
||||
+21
-3
@@ -3,6 +3,7 @@ package org.diylc.plugins.statusbar;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.geom.Point2D;
|
||||
@@ -56,6 +57,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
|
||||
// State variables
|
||||
private ComponentType componentSlot;
|
||||
private Point controlPointSlot;
|
||||
private List<IDIYComponent<?>> componentsUnderCursor;
|
||||
private List<String> selectedComponentNames;
|
||||
private List<String> stuckComponentNames;
|
||||
@@ -220,6 +222,7 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
break;
|
||||
case SLOT_CHANGED:
|
||||
componentSlot = (ComponentType) params[0];
|
||||
controlPointSlot = (Point) params[1];
|
||||
refreshStatusText();
|
||||
break;
|
||||
case AVAILABLE_CTRL_POINTS_CHANGED:
|
||||
@@ -250,9 +253,24 @@ public class StatusBar extends JPanel implements IPlugIn {
|
||||
getStatusLabel().setText("");
|
||||
}
|
||||
} else {
|
||||
getStatusLabel().setText(
|
||||
"Click on the canvas to create a new " + componentSlot.getName()
|
||||
+ " or press Esc to cancel");
|
||||
switch (componentSlot.getCreationMethod()) {
|
||||
case POINT_BY_POINT:
|
||||
String count;
|
||||
if (controlPointSlot == null) {
|
||||
count = "first";
|
||||
} else {
|
||||
count = "second";
|
||||
}
|
||||
getStatusLabel().setText(
|
||||
"Click on the canvas to set the " + count + " control point of a new "
|
||||
+ componentSlot.getName() + " or press Esc to cancel");
|
||||
break;
|
||||
case SINGLE_CLICK:
|
||||
getStatusLabel().setText(
|
||||
"Click on the canvas to create a new " + componentSlot.getName()
|
||||
+ " or press Esc to cancel");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -375,6 +375,8 @@ public class Presenter implements IPlugInPort {
|
||||
} else {
|
||||
controlPointSlot = scaledPoint;
|
||||
snapPointToGrid(controlPointSlot);
|
||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, componentSlot,
|
||||
controlPointSlot);
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
}
|
||||
break;
|
||||
@@ -1118,11 +1120,12 @@ public class Presenter implements IPlugInPort {
|
||||
this.potentialControlPoint = null;
|
||||
selectedComponents.clear();
|
||||
fireSelectionChanged();
|
||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED,
|
||||
// selectedComponents);
|
||||
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
|
||||
// calculateSelectionDimension());
|
||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, componentSlot);
|
||||
messageDispatcher.dispatchMessage(EventType.SLOT_CHANGED, componentSlot, controlPointSlot);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ public class ProjectPainter {
|
||||
g2d.setColor(Color.white);
|
||||
g2d.draw(selectionRect);
|
||||
g2d.setColor(Color.black);
|
||||
g2d.setStroke(Constants.dashedStroke);
|
||||
g2d.setStroke(Constants.DASHED_STROKE);
|
||||
g2d.draw(selectionRect);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ public class Constants {
|
||||
public static Color SELECTED_CONTROL_POINT_COLOR = Color.blue;
|
||||
public static Color CREATION_POINT_COLOR = Color.decode("#32CD32");
|
||||
|
||||
public static Font LABEL_FONT = new Font("Tahoma", Font.BOLD, 11);
|
||||
public static Font LABEL_FONT = new Font("Tahoma", Font.PLAIN, 11);
|
||||
|
||||
public static final Stroke dashedStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
||||
public static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
|
||||
BasicStroke.JOIN_MITER, 2.0f, new float[] { 2.0f }, 0.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user