always show control point when creating new component

changed board alignment
fixed sticking to non-stickable points
This commit is contained in:
bancika
2011-01-17 20:24:29 +00:00
parent dcb5b668db
commit e866762b05
3 changed files with 11 additions and 25 deletions
@@ -39,7 +39,6 @@ import org.diylc.common.IComponentFiler;
import org.diylc.common.IPlugIn; import org.diylc.common.IPlugIn;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
import org.diylc.common.PropertyWrapper; import org.diylc.common.PropertyWrapper;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent; import org.diylc.core.IDIYComponent;
import org.diylc.core.Project; import org.diylc.core.Project;
import org.diylc.core.measures.SizeUnit; import org.diylc.core.measures.SizeUnit;
@@ -425,9 +424,7 @@ public class Presenter implements IPlugInPort {
public void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) { public void mouseMoved(Point point, boolean ctrlDown, boolean shiftDown, boolean altDown) {
Map<IDIYComponent<?>, Set<Integer>> components = new HashMap<IDIYComponent<?>, Set<Integer>>(); Map<IDIYComponent<?>, Set<Integer>> components = new HashMap<IDIYComponent<?>, Set<Integer>>();
Point scaledPoint = scalePoint(point); Point scaledPoint = scalePoint(point);
if (componentSlot != null if (componentSlot != null) {
&& (componentSlot.getCreationMethod() == CreationMethod.POINT_BY_POINT || !componentSlot
.isStretchable())) {
potentialControlPoint = scaledPoint; potentialControlPoint = scaledPoint;
snapPointToGrid(potentialControlPoint); snapPointToGrid(potentialControlPoint);
messageDispatcher.dispatchMessage(EventType.REPAINT); messageDispatcher.dispatchMessage(EventType.REPAINT);
@@ -586,6 +583,7 @@ public class Presenter implements IPlugInPort {
} }
for (Integer j : entry.getValue()) { for (Integer j : entry.getValue()) {
Point firstPoint = component.getControlPoint(i); Point firstPoint = component.getControlPoint(i);
if (entry.getKey().isControlPointSticky(j)) {
Point secondPoint = entry.getKey().getControlPoint(j); Point secondPoint = entry.getKey().getControlPoint(j);
// If they are close enough we can consider them // If they are close enough we can consider them
// matched. // matched.
@@ -595,6 +593,7 @@ public class Presenter implements IPlugInPort {
} }
} }
} }
}
if (componentMatches) { if (componentMatches) {
LOG.debug("Including component: " + component); LOG.debug("Including component: " + component);
Set<Integer> indices = new HashSet<Integer>(); Set<Integer> indices = new HashSet<Integer>();
@@ -1149,16 +1148,4 @@ public class Presenter implements IPlugInPort {
return point == null ? null : new Point((int) (point.x / zoomLevel), return point == null ? null : new Point((int) (point.x / zoomLevel),
(int) (point.y / zoomLevel)); (int) (point.y / zoomLevel));
} }
/**
* @param component
* @return true if control points should be rendered for the specified
* component.
*/
private boolean shouldShowControlPointsFor(IDIYComponent<?> component) {
if (findAllGroupedComponents(component).size() > 1) {
return false;
}
return true;
}
} }
@@ -26,9 +26,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
public static Size DEFAULT_HEIGHT = new Size(1d, SizeUnit.in); public static Size DEFAULT_HEIGHT = new Size(1d, SizeUnit.in);
protected String value; protected String value;
protected Point[] controlPoints = new Point[] { protected Point[] controlPoints = new Point[] { new Point(0, 0),
new Point(-DEFAULT_WIDTH.convertToPixels() / 2, -DEFAULT_HEIGHT.convertToPixels() / 2), new Point(DEFAULT_WIDTH.convertToPixels(), DEFAULT_HEIGHT.convertToPixels()) };
new Point(DEFAULT_WIDTH.convertToPixels() / 2, DEFAULT_HEIGHT.convertToPixels() / 2) };
protected Color boardColor = BOARD_COLOR; protected Color boardColor = BOARD_COLOR;
protected Color borderColor = BORDER_COLOR; protected Color borderColor = BORDER_COLOR;