From 62cbe4826f66166f966dd9330a8381b269403aee Mon Sep 17 00:00:00 2001 From: bancika Date: Mon, 24 Jan 2011 19:13:09 +0000 Subject: [PATCH] improved stick mechanism when more than one point is stuck --- .../src/org/diylc/presenter/Presenter.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java index 5e0bf008..528d10eb 100644 --- a/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java +++ b/ diy-layout-creator --username bancika@gmail.com/DIYLC/src/org/diylc/presenter/Presenter.java @@ -593,12 +593,14 @@ public class Presenter implements IPlugInPort { .extractComponentTypeFrom( (Class>) 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 - // that matches with one of its control points. - for (int i = 0; i < component.getControlPointCount(); i++) { + // Check if there's a control point in the current selection + // that matches with one of its control points. + 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)) { boolean componentMatches = false; for (Map.Entry, Set> entry : controlPointMap @@ -623,8 +625,8 @@ public class Presenter implements IPlugInPort { LOG.debug("Including component: " + component); Set indices = new HashSet(); // For stretchable components just add the - // matching component. - // Otherwise, add all control points. + // matching component. Otherwise, add all control + // points. if (componentType.isStretchable()) { indices.add(i); } else { @@ -632,7 +634,11 @@ public class Presenter implements IPlugInPort { indices.add(k); } } - controlPointMap.put(component, indices); + if (controlPointMap.containsKey(component)) { + controlPointMap.get(component).addAll(indices); + } else { + controlPointMap.put(component, indices); + } } } }