public void setSwingDataCollection(Collection<ICFSecurityISOCountryObj> value) { final String S_ProcName = "setSwingDataCollection"; swingDataCollection = value; if (swingDataCollection == null) { arrayOfISOCountry = new ICFSecurityISOCountryObj[0]; } else { int len = value.size(); arrayOfISOCountry = new ICFSecurityISOCountryObj[len]; Iterator<ICFSecurityISOCountryObj> iter = swingDataCollection.iterator(); int idx = 0; while (iter.hasNext() && (idx < len)) { arrayOfISOCountry[idx++] = iter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Collection iterator did not fully populate the array copy"); } if (iter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newRuntimeException( getClass(), S_ProcName, "Collection iterator had left over items when done populating array copy"); } Arrays.sort(arrayOfISOCountry, compareISOCountryByQualName); } PickerTableModel tblDataModel = getDataModel(); if (tblDataModel != null) { tblDataModel.fireTableDataChanged(); } }
/** Implementation note: Sorting can not be done for orphaned children. */ public java.util.List<Figure> sort(Collection<Figure> c) { ensureSorted(); ArrayList<Figure> sorted = new ArrayList<Figure>(c.size()); for (Figure f : children) { if (c.contains(f)) { sorted.add(f); } } return sorted; }
public Figure findFigureBehind(Point2D.Double p, Collection<Figure> figures) { int inFrontOf = figures.size(); for (Figure f : getFiguresFrontToBack()) { if (inFrontOf == 0) { if (f.isVisible() && f.contains(p)) { return f; } } else { if (figures.contains(f)) { inFrontOf--; } } } return null; }
private TreeModel buildModel(Object[] resolvers) { TreeModel fullModel = null; DefaultMutableTreeNode top = new DefaultMutableTreeNode(Tr.t("root")); try { cpos = null; for (Object resolver : resolvers) { if (resolver instanceof ColorPository) { cpos = (ColorPository) resolver; GraphCellRenderer graphCellRenderer = new GraphCellRenderer(cpos); colors.setCellRenderer(graphCellRenderer); break; } } Collection<ColorPository.ClassRecord> classes = cpos.getClasses(); String[] classNames = new String[classes.size()]; Iterator<ColorPository.ClassRecord> it = classes.iterator(); int count = 0; while (it.hasNext()) { classNames[count] = it.next().name; count++; } Arrays.sort(classNames); for (String className : classNames) { ColorPository.ColorRecord[] colors = cpos.enumerateColors(className); String[] colorNames = new String[colors.length]; for (int a = 0; a < colorNames.length; a++) { colorNames[a] = colors[a].name; } Arrays.sort(colorNames); DefaultMutableTreeNode tn = new DefaultMutableTreeNode(className); top.add(tn); for (String colorName : colorNames) { tn.add(new DefaultMutableTreeNode(colorName)); } } fullModel = new DefaultTreeModel(top); } catch (Exception e) { fullModel = new DefaultTreeModel(new DefaultMutableTreeNode(Tr.t("root.failed"))); // e.printStackTrace(); } return fullModel; }
public Figure findFigure(Point2D.Double p) { Collection<Figure> c = quadTree.findContains(p); switch (c.size()) { case 0: return null; case 1: { Figure f = c.iterator().next(); return (f.contains(p)) ? f : null; } default: { for (Figure f : getFiguresFrontToBack()) { if (c.contains(f) && f.contains(p)) return f; } return null; } } }
public Figure findFigureExcept(Point2D.Double p, Collection ignore) { Collection<Figure> c = quadTree.findContains(p); switch (c.size()) { case 0: { return null; } case 1: { Figure f = c.iterator().next(); return (!ignore.contains(f) || !f.contains(p)) ? null : f; } default: { for (Figure f : getFiguresFrontToBack()) { if (!ignore.contains(f) && f.contains(p)) return f; } return null; } } }