improved stick mechanism when more than one point is stuck

This commit is contained in:
bancika
2011-01-24 19:13:09 +00:00
parent 2aa8aed874
commit 62cbe4826f
@@ -593,12 +593,14 @@ public class Presenter implements IPlugInPort {
.extractComponentTypeFrom( .extractComponentTypeFrom(
(Class<? extends IDIYComponent<?>>) component.getClass()); (Class<? extends IDIYComponent<?>>) component.getClass());
// Do not process a component if it's already in the map and if it's
// locked.
if (!controlPointMap.containsKey(component) && !isComponentLocked(component)) {
// Check if there's a control point in the current selection // Check if there's a control point in the current selection
// that matches with one of its control points. // that matches with one of its control points.
for (int i = 0; i < component.getControlPointCount(); i++) { for (int i = 0; i < component.getControlPointCount(); i++) {
// Do not process a control point if it's already in the map and
// if it's locked.
if ((!controlPointMap.containsKey(component) || !controlPointMap.get(component)
.contains(i))
&& !isComponentLocked(component)) {
if (component.isControlPointSticky(i)) { if (component.isControlPointSticky(i)) {
boolean componentMatches = false; boolean componentMatches = false;
for (Map.Entry<IDIYComponent<?>, Set<Integer>> entry : controlPointMap for (Map.Entry<IDIYComponent<?>, Set<Integer>> entry : controlPointMap
@@ -623,8 +625,8 @@ public class Presenter implements IPlugInPort {
LOG.debug("Including component: " + component); LOG.debug("Including component: " + component);
Set<Integer> indices = new HashSet<Integer>(); Set<Integer> indices = new HashSet<Integer>();
// For stretchable components just add the // For stretchable components just add the
// matching component. // matching component. Otherwise, add all control
// Otherwise, add all control points. // points.
if (componentType.isStretchable()) { if (componentType.isStretchable()) {
indices.add(i); indices.add(i);
} else { } else {
@@ -632,12 +634,16 @@ public class Presenter implements IPlugInPort {
indices.add(k); indices.add(k);
} }
} }
if (controlPointMap.containsKey(component)) {
controlPointMap.get(component).addAll(indices);
} else {
controlPointMap.put(component, indices); controlPointMap.put(component, indices);
} }
} }
} }
} }
} }
}
int newSize = controlPointMap.size(); int newSize = controlPointMap.size();
// As long as we're adding new components, do another iteration. // As long as we're adding new components, do another iteration.
if (newSize > oldSize) { if (newSize > oldSize) {