14a15,16 > import CH.ifa.draw.contrib.dnd.DNDHelper; > import CH.ifa.draw.contrib.dnd.DNDInterface; 20a23 > import java.util.List; 32d34 < 36c38 < java.awt.dnd.Autoscroll { --- > DNDInterface, java.awt.dnd.Autoscroll { 41d42 < * @see #setStatus 48c49 < private transient Vector fSelectionListeners; --- > private transient List fSelectionListeners; 63c64 < transient private Vector fSelection; --- > transient private List fSelection; 68c69 < transient private Vector fSelectionHandles; --- > transient private List fSelectionHandles; 82,83c83,84 < * A vector of optional backgrounds. The vector maintains < * a list a view painters that are drawn before the contents, --- > * A List of optional backgrounds. The list contains > * view painters that are drawn before the contents, 86c87 < private Vector fBackgrounds; --- > private List fBackgrounds; 89,90c90,91 < * A vector of optional foregrounds. The vector maintains < * a list a view painters that are drawn after the contents, --- > * A List of optional foregrounds. The list contains > * view painters that are drawn after the contents, 93c94 < private Vector fForegrounds; --- > private List fForegrounds; 116a118,119 > private DNDHelper dndh; > 138c141 < fSelectionListeners = new Vector(); --- > fSelectionListeners = CollectionsFactory.current().createList(); 142c145 < fSelection = new Vector(); --- > fSelection = CollectionsFactory.current().createList(); 236c239 < * Adds a vector of figures to the drawing. --- > * Adds a Collection of figures to the drawing. 238,241c241,244 < public void addAll(Vector figures) { < FigureEnumeration k = new FigureEnumerator(figures); < while (k.hasMoreElements()) { < add(k.nextFigure()); --- > public void addAll(Collection figures) { > FigureEnumeration fe = new FigureEnumerator(figures); > while (fe.hasNextFigure()) { > add(fe.nextFigure()); 248,250c251,253 < public boolean figureExists(Figure inf, FigureEnumeration e) { < while(e.hasMoreElements()) { < Figure figure = e.nextFigure(); --- > public boolean figureExists(Figure inf, FigureEnumeration fe) { > while (fe.hasNextFigure()) { > Figure figure = fe.nextFigure(); 272,273c275,276 < Vector addedFigures = new Vector(); < Vector vCF = new Vector(10); --- > List addedFigures = CollectionsFactory.current().createList(); > List vCF = CollectionsFactory.current().createList(10); 275c278 < while (fe.hasMoreElements()) { --- > while (fe.hasNextFigure()) { 278c281 < vCF.addElement(figure); --- > vCF.add(figure); 285c288 < addedFigures.addElement(figure); --- > addedFigures.add(figure); 291c294 < while (ecf.hasMoreElements()) { --- > while (ecf.hasNextFigure()) { 316c319 < addedFigures.addElement(nf); --- > addedFigures.add(nf); 324c327 < * Returns a vector of connectionfigures attached to this figure --- > * Returns a FigureEnumeration of connectionfigures attached to this figure 326c329 < public Vector getConnectionFigures(Figure inFigure) { --- > public FigureEnumeration getConnectionFigures(Figure inFigure) { 335c338 < Vector result = new Vector(5); --- > List result = CollectionsFactory.current().createList(5); 339c342 < while (figures.hasMoreElements()) { --- > while (figures.hasNextFigure()) { 347c350 < result.addElement(f); --- > result.add(f); 352c355 < return result; --- > return new FigureEnumerator(result); 386,395d388 < * Gets the currently selected figures. < * @return a vector with the selected figures. The vector < * is a copy of the current selection. < */ < public Vector selection() { < // protect the vector with the current selection < return (Vector)fSelection.clone(); < } < < /** 396a390,393 > * The selection is a snapshot of the current selection > * which does not get changed anymore > * > * @return an enumeration with the currently selected figures. 398,399c395,396 < public FigureEnumeration selectionElements() { < return new FigureEnumerator(selectionZOrdered()); --- > public FigureEnumeration selection() { > return selectionZOrdered(); 405,406c402,403 < * @return a vector with the selected figures. The vector < * is a copy of the current selection. --- > * @return a FigureEnumeration with the selected figures. The enumeration > * represents a snapshot of the current selection. 408,409c405,406 < public Vector selectionZOrdered() { < Vector result = new Vector(selectionCount()); --- > public FigureEnumeration selectionZOrdered() { > List result = CollectionsFactory.current().createList(selectionCount()); 412c409 < while (figures.hasMoreElements()) { --- > while (figures.hasNextFigure()) { 415c412 < result.addElement(f); --- > result.add(f); 418c415 < return result; --- > return new ReverseFigureEnumerator(result); 441c438 < fSelection.addElement(figure); --- > fSelection.add(figure); 449c446 < * Adds a vector of figures to the current selection. --- > * Adds a Collection of figures to the current selection. 451c448 < public void addToSelectionAll(Vector figures) { --- > public void addToSelectionAll(Collection figures) { 459c456 < while (fe.hasMoreElements()) { --- > while (fe.hasNextFigure()) { 469c466 < fSelection.removeElement(figure); --- > fSelection.remove(figure); 500,501c497,498 < FigureEnumeration fe = selectionElements(); < while (fe.hasMoreElements()) { --- > FigureEnumeration fe = selection(); > while (fe.hasNextFigure()) { 504c501 < fSelection = new Vector(); --- > fSelection = CollectionsFactory.current().createList(); 512c509 < private Enumeration selectionHandles() { --- > private HandleEnumeration selectionHandles() { 514,520c511,517 < fSelectionHandles = new Vector(); < FigureEnumeration k = selectionElements(); < while (k.hasMoreElements()) { < Figure figure = k.nextFigure(); < Enumeration kk = figure.handles().elements(); < while (kk.hasMoreElements()) { < fSelectionHandles.addElement(kk.nextElement()); --- > fSelectionHandles = CollectionsFactory.current().createList(); > FigureEnumeration fe = selection(); > while (fe.hasNextFigure()) { > Figure figure = fe.nextFigure(); > HandleEnumeration kk = figure.handles(); > while (kk.hasNextHandle()) { > fSelectionHandles.add(kk.nextHandle()); 524c521 < return fSelectionHandles.elements(); --- > return new HandleEnumerator(fSelectionHandles); 532c529 < return new StandardFigureSelection(new FigureEnumerator(selectionZOrdered()), selectionCount()); --- > return new StandardFigureSelection(selectionZOrdered(), selectionCount()); 542,544c539,541 < Enumeration k = selectionHandles(); < while (k.hasMoreElements()) { < handle = (Handle) k.nextElement(); --- > HandleEnumeration he = selectionHandles(); > while (he.hasNextHandle()) { > handle = he.nextHandle(); 560c557 < FigureSelectionListener l = (FigureSelectionListener)fSelectionListeners.elementAt(i); --- > FigureSelectionListener l = (FigureSelectionListener)fSelectionListeners.get(i); 567c564 < return fDamage; --- > return fDamage; // clone? 617,618c614,615 < FigureEnumeration figures = selectionElements(); < while (figures.hasMoreElements()) { --- > FigureEnumeration figures = selection(); > while (figures.hasNextFigure()) { 628,630c625,627 < Enumeration each = drawing().drawingChangeListeners(); < while (each.hasMoreElements()) { < Object l = each.nextElement(); --- > Iterator each = drawing().drawingChangeListeners(); > while (each.hasNext()) { > Object l = each.next(); 716,718c713,715 < Enumeration k = selectionHandles(); < while (k.hasMoreElements()) { < ((Handle) k.nextElement()).draw(g); --- > HandleEnumeration he = selectionHandles(); > while (he.hasNextHandle()) { > (he.nextHandle()).draw(g); 739c736 < protected void drawPainters(Graphics g, Vector v) { --- > protected void drawPainters(Graphics g, List v) { 741c738 < ((Painter)v.elementAt(i)).draw(g, this); --- > ((Painter)v.get(i)).draw(g, this); 750c747 < fBackgrounds = new Vector(3); --- > fBackgrounds = CollectionsFactory.current().createList(3); 752c749 < fBackgrounds.addElement(painter); --- > fBackgrounds.add(painter); 761c758 < fBackgrounds.removeElement(painter); --- > fBackgrounds.remove(painter); 766c763 < protected Vector getBackgrounds() { --- > protected List getBackgrounds() { 775c772 < fForegrounds.removeElement(painter); --- > fForegrounds.remove(painter); 785c782 < fForegrounds = new Vector(3); --- > fForegrounds = CollectionsFactory.current().createList(3); 787c784 < fForegrounds.addElement(painter); --- > fForegrounds.add(painter); 791c788 < protected Vector getForegrounds() { --- > protected List getForegrounds() { 816c813 < fSelection = new Vector(); // could use lazy initialization instead --- > fSelection = CollectionsFactory.current().createList(); // could use lazy initialization instead 820c817 < fSelectionListeners= new Vector(); --- > fSelectionListeners= CollectionsFactory.current().createList(); 838c835 < FigureEnumeration k = drawing().figures(); --- > FigureEnumeration fe = drawing().figures(); 840,841c837,838 < while (k.hasMoreElements()) { < Rectangle r = k.nextFigure().displayBox(); --- > while (fe.hasNextFigure()) { > Rectangle r = fe.nextFigure().displayBox(); 916a914 > t.printStackTrace(); 923d920 < * @return whether the event was handled. 941d937 < * @return whether the event was handled. 959d954 < * @return whether the event was handled. 975d969 < * @return whether the event was handled. 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); > }