From 2c00a7a97328a5009126bd084e4733a7f57d7d8b Mon Sep 17 00:00:00 2001 From: bancika Date: Fri, 21 Jan 2011 21:17:30 +0000 Subject: [PATCH] improved piece of code --- .../src/org/diylc/presenter/Presenter.java | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 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 5d0719a6..2a0c6c8a 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 @@ -585,49 +585,48 @@ public class Presenter implements IPlugInPort { int oldSize = controlPointMap.size(); LOG.debug("Expanding selected component map"); for (IDIYComponent component : currentProject.getComponents()) { - // Do not process a component if it's already in the map. ComponentType componentType = componentTypeMap.get(component.getClass().getName()); - // 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++) { - if (controlPointMap.containsKey(component)) { - break; - } - if (!controlPointMap.containsKey(component) && component.isControlPointSticky(i)) { - boolean componentMatches = false; - for (Map.Entry, Set> entry : controlPointMap - .entrySet()) { - if (componentMatches) { - break; - } - for (Integer j : entry.getValue()) { - Point firstPoint = component.getControlPoint(i); - if (entry.getKey().isControlPointSticky(j)) { - Point secondPoint = entry.getKey().getControlPoint(j); - // If they are close enough we can consider them - // matched. - if (firstPoint.distance(secondPoint) < DrawingManager.CONTROL_POINT_SIZE) { - componentMatches = true; - break; + // Do not process a component if it's already in the map. + if (!controlPointMap.containsKey(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++) { + if (component.isControlPointSticky(i)) { + boolean componentMatches = false; + for (Map.Entry, Set> entry : controlPointMap + .entrySet()) { + if (componentMatches) { + break; + } + for (Integer j : entry.getValue()) { + Point firstPoint = component.getControlPoint(i); + if (entry.getKey().isControlPointSticky(j)) { + Point secondPoint = entry.getKey().getControlPoint(j); + // If they are close enough we can consider + // them matched. + if (firstPoint.distance(secondPoint) < DrawingManager.CONTROL_POINT_SIZE) { + componentMatches = true; + break; + } } } } - } - if (componentMatches) { - LOG.debug("Including component: " + component); - Set indices = new HashSet(); - // For stretchable components just add the - // matching component. - // Otherwise, add all control points. - if (componentType.isStretchable()) { - indices.add(i); - } else { - for (int k = 0; k < component.getControlPointCount(); k++) { - indices.add(k); + if (componentMatches) { + LOG.debug("Including component: " + component); + Set indices = new HashSet(); + // For stretchable components just add the + // matching component. + // Otherwise, add all control points. + if (componentType.isStretchable()) { + indices.add(i); + } else { + for (int k = 0; k < component.getControlPointCount(); k++) { + indices.add(k); + } } + controlPointMap.put(component, indices); } - controlPointMap.put(component, indices); } } }