14a15,16 > import CH.ifa.draw.contrib.dnd.DNDHelper; > import CH.ifa.draw.contrib.dnd.DNDInterface; 20a23,23 > import java.util.List; 32,32d34 < 36,36c38,38 < java.awt.dnd.Autoscroll { --- > DNDInterface, java.awt.dnd.Autoscroll { 41,41d42 < * @see #setStatus 48,48c49,49 < private transient Vector fSelectionListeners; --- > private transient List fSelectionListeners; 63,63c64,64 < transient private Vector fSelection; --- > transient private List fSelection; 68,68c69,69 < transient private Vector fSelectionHandles; --- > transient private List fSelectionHandles; 81a83,83 > * A List of optional backgrounds. The list contains 82,82d82 < * A vector of optional backgrounds. The vector maintains 83,83c84,84 < * a list a view painters that are drawn before the contents, --- > * view painters that are drawn before the contents, 86,86c87,87 < private Vector fBackgrounds; --- > private List fBackgrounds; 88a90,90 > * A List of optional foregrounds. The list contains 89,89d89 < * A vector of optional foregrounds. The vector maintains 90,90c91,91 < * a list a view painters that are drawn after the contents, --- > * view painters that are drawn after the contents, 93,93c94,94 < private Vector fForegrounds; --- > private List fForegrounds; 116a118,119 > private DNDHelper dndh; > 137a141,141 > fSelectionListeners = CollectionsFactory.current().createList(); 138,138d140 < fSelectionListeners = new Vector(); 141a145,145 > fSelection = CollectionsFactory.current().createList(); 142,142d144 < fSelection = new Vector(); 236,236c239,239 < * Adds a vector of figures to the drawing. --- > * Adds a Collection of figures to the drawing. 237a241,241 > public void addAll(Collection figures) { 238,238d240 < public void addAll(Vector figures) { 239a243,243 > while (fe.hasNextFigure()) { 239,239c242,242 < FigureEnumeration k = new FigureEnumerator(figures); --- > FigureEnumeration fe = new FigureEnumerator(figures); 240,240d242 < while (k.hasMoreElements()) { 241,241c244,244 < add(k.nextFigure()); --- > add(fe.nextFigure()); 248a252,252 > while (fe.hasNextFigure()) { 248,248c251,251 < public boolean figureExists(Figure inf, FigureEnumeration e) { --- > public boolean figureExists(Figure inf, FigureEnumeration fe) { 249,249d251 < while(e.hasMoreElements()) { 250,250c253,253 < Figure figure = e.nextFigure(); --- > Figure figure = fe.nextFigure(); 271a275,276 > List addedFigures = CollectionsFactory.current().createList(); > List vCF = CollectionsFactory.current().createList(10); 272,273d274 < Vector addedFigures = new Vector(); < Vector vCF = new Vector(10); 275,275c278,278 < while (fe.hasMoreElements()) { --- > while (fe.hasNextFigure()) { 278,278c281,281 < vCF.addElement(figure); --- > vCF.add(figure); 285,285c288,288 < addedFigures.addElement(figure); --- > addedFigures.add(figure); 291,291c294,294 < while (ecf.hasMoreElements()) { --- > while (ecf.hasNextFigure()) { 316,316c319,319 < addedFigures.addElement(nf); --- > addedFigures.add(nf); 324,324c327,327 < * Returns a vector of connectionfigures attached to this figure --- > * Returns a FigureEnumeration of connectionfigures attached to this figure 326,326c329,329 < public Vector getConnectionFigures(Figure inFigure) { --- > public FigureEnumeration getConnectionFigures(Figure inFigure) { 334a338,338 > List result = CollectionsFactory.current().createList(5); 335,335d337 < Vector result = new Vector(5); 339,339c342,342 < while (figures.hasMoreElements()) { --- > while (figures.hasNextFigure()) { 347,347c350,350 < result.addElement(f); --- > result.add(f); 352,352c355,355 < return result; --- > return new FigureEnumerator(result); 385a390,391 > * The selection is a snapshot of the current selection > * which does not get changed anymore 386,388d389 < * Gets the currently selected figures. < * @return a vector with the selected figures. The vector < * is a copy of the current selection. 389,389c392,392 < */ --- > * 390,390d392 < public Vector selection() { 391,391c393,393 < // protect the vector with the current selection --- > * @return an enumeration with the currently selected figures. 392,395d393 < return (Vector)fSelection.clone(); < } < < /** 398,398c395,395 < public FigureEnumeration selectionElements() { --- > public FigureEnumeration selection() { 399,399c396,396 < return new FigureEnumerator(selectionZOrdered()); --- > return selectionZOrdered(); 405,405c402,402 < * @return a vector with the selected figures. The vector --- > * @return a FigureEnumeration with the selected figures. The enumeration 406,406c403,403 < * is a copy of the current selection. --- > * represents a snapshot of the current selection. 407a405,406 > public FigureEnumeration selectionZOrdered() { > List result = CollectionsFactory.current().createList(selectionCount()); 408,409d404 < public Vector selectionZOrdered() { < Vector result = new Vector(selectionCount()); 412,412c409,409 < while (figures.hasMoreElements()) { --- > while (figures.hasNextFigure()) { 415,415c412,412 < result.addElement(f); --- > result.add(f); 417a415,415 > return new ReverseFigureEnumerator(result); 418,418d414 < return result; 441,441c438,438 < fSelection.addElement(figure); --- > fSelection.add(figure); 449,449c446,446 < * Adds a vector of figures to the current selection. --- > * Adds a Collection of figures to the current selection. 451,451c448,448 < public void addToSelectionAll(Vector figures) { --- > public void addToSelectionAll(Collection figures) { 459,459c456,456 < while (fe.hasMoreElements()) { --- > while (fe.hasNextFigure()) { 469,469c466,466 < fSelection.removeElement(figure); --- > fSelection.remove(figure); 500,500c497,497 < FigureEnumeration fe = selectionElements(); --- > FigureEnumeration fe = selection(); 501,501c498,498 < while (fe.hasMoreElements()) { --- > while (fe.hasNextFigure()) { 503a501,501 > fSelection = CollectionsFactory.current().createList(); 504,504d500 < fSelection = new Vector(); 512,512c509,509 < private Enumeration selectionHandles() { --- > private HandleEnumeration selectionHandles() { 513a511,513 > fSelectionHandles = CollectionsFactory.current().createList(); > FigureEnumeration fe = selection(); > while (fe.hasNextFigure()) { 514,516d510 < fSelectionHandles = new Vector(); < FigureEnumeration k = selectionElements(); < while (k.hasMoreElements()) { 517,517c514,514 < Figure figure = k.nextFigure(); --- > Figure figure = fe.nextFigure(); 517a515,516 > HandleEnumeration kk = figure.handles(); > while (kk.hasNextHandle()) { 518,519d514 < Enumeration kk = figure.handles().elements(); < while (kk.hasMoreElements()) { 520,520c517,517 < fSelectionHandles.addElement(kk.nextElement()); --- > fSelectionHandles.add(kk.nextHandle()); 523a521,521 > return new HandleEnumerator(fSelectionHandles); 524,524d520 < return fSelectionHandles.elements(); 532,532c529,529 < return new StandardFigureSelection(new FigureEnumerator(selectionZOrdered()), selectionCount()); --- > return new StandardFigureSelection(selectionZOrdered(), selectionCount()); 541a539,541 > HandleEnumeration he = selectionHandles(); > while (he.hasNextHandle()) { > handle = he.nextHandle(); 542,544d538 < Enumeration k = selectionHandles(); < while (k.hasMoreElements()) { < handle = (Handle) k.nextElement(); 560,560c557,557 < FigureSelectionListener l = (FigureSelectionListener)fSelectionListeners.elementAt(i); --- > FigureSelectionListener l = (FigureSelectionListener)fSelectionListeners.get(i); 567,567c564,564 < return fDamage; --- > return fDamage; // clone? 617,617c614,614 < FigureEnumeration figures = selectionElements(); --- > FigureEnumeration figures = selection(); 618,618c615,615 < while (figures.hasMoreElements()) { --- > while (figures.hasNextFigure()) { 628a626,626 > while (each.hasNext()) { 628,628c625,625 < Enumeration each = drawing().drawingChangeListeners(); --- > Iterator each = drawing().drawingChangeListeners(); 629,629d625 < while (each.hasMoreElements()) { 630,630c627,627 < Object l = each.nextElement(); --- > Object l = each.next(); 715a713,715 > HandleEnumeration he = selectionHandles(); > while (he.hasNextHandle()) { > (he.nextHandle()).draw(g); 716,718d712 < Enumeration k = selectionHandles(); < while (k.hasMoreElements()) { < ((Handle) k.nextElement()).draw(g); 739,739c736,736 < protected void drawPainters(Graphics g, Vector v) { --- > protected void drawPainters(Graphics g, List v) { 741,741c738,738 < ((Painter)v.elementAt(i)).draw(g, this); --- > ((Painter)v.get(i)).draw(g, this); 749a747,747 > fBackgrounds = CollectionsFactory.current().createList(3); 750,750d746 < fBackgrounds = new Vector(3); 752,752c749,749 < fBackgrounds.addElement(painter); --- > fBackgrounds.add(painter); 761,761c758,758 < fBackgrounds.removeElement(painter); --- > fBackgrounds.remove(painter); 766,766c763,763 < protected Vector getBackgrounds() { --- > protected List getBackgrounds() { 775,775c772,772 < fForegrounds.removeElement(painter); --- > fForegrounds.remove(painter); 784a782,782 > fForegrounds = CollectionsFactory.current().createList(3); 785,785d781 < fForegrounds = new Vector(3); 787,787c784,784 < fForegrounds.addElement(painter); --- > fForegrounds.add(painter); 791,791c788,788 < protected Vector getForegrounds() { --- > protected List getForegrounds() { 816,816c813,813 < fSelection = new Vector(); // could use lazy initialization instead --- > fSelection = CollectionsFactory.current().createList(); // could use lazy initialization instead 819a817,817 > fSelectionListeners= CollectionsFactory.current().createList(); 820,820d816 < fSelectionListeners= new Vector(); 838,838c835,835 < FigureEnumeration k = drawing().figures(); --- > FigureEnumeration fe = drawing().figures(); 839a837,837 > while (fe.hasNextFigure()) { 840,840d836 < while (k.hasMoreElements()) { 841,841c838,838 < Rectangle r = k.nextFigure().displayBox(); --- > Rectangle r = fe.nextFigure().displayBox(); 916a914,914 > t.printStackTrace(); 923,923d920 < * @return whether the event was handled. 941,941d937 < * @return whether the event was handled. 959,959d954 < * @return whether the event was handled. 975,975d969 < * @return whether the event was handled. 992,992d985 < * @return whether the event was handled. 1050a1044,1066 > > protected DNDHelper createDNDHelper() { > return new DNDHelper () { > protected DrawingView view() { > return StandardDrawingView.this; > } > }; > } > > protected DNDHelper getDNDHelper() { > if (dndh == null) { > dndh = createDNDHelper(); > } > return dndh; > } > > public boolean setDragSourceActive(boolean state) { > return getDNDHelper().setDragSourceActive(state); > } > > public boolean setDropTargetActive(boolean state) { > return getDNDHelper().setDropTargetActive(state); > }