📄 visiblevector.java
字号:
package edu.odu.cs.zeil.AlgAE.Demos.Utils;import edu.odu.cs.zeil.AlgAE.Server.Rendering;import edu.odu.cs.zeil.AlgAE.Server.Visible;import edu.odu.cs.zeil.AlgAE.Server.VisibleRendering;import edu.odu.cs.zeil.AlgAE.Demos.Utils.Indexable;import java.awt.Color;import java.util.Vector;/** * A Visible replacement for java.util.Vector * * @author Steven Zeil */public class VisibleVector extends Vector implements Indexable, Visible { private VisibleRendering vr; /** * Constructs an empty vector with the specified initial capacity and * capacity increment. * * @param initialCapacity the initial capacity of the vector. * @param capacityIncrement the amount by which the capacity is * increased when the vector overflows. */ public VisibleVector(int initialCapacity, int capacityIncrement, Color color, boolean vertical) { super(initialCapacity, capacityIncrement); vr = new VisibleRendering (this, color, vertical); } /** * Constructs an empty vector with the specified initial capacity. * * @param initialCapacity the initial capacity of the vector. */ public VisibleVector(int initialCapacity, Color color, boolean vertical) { super(initialCapacity); vr = new VisibleRendering (this, color, vertical); } /** * Constructs an empty vector. * */ public VisibleVector(Color color, boolean vertical) { super(); vr = new VisibleRendering (this, color, vertical); } /** * Returns a clone of this vector. * * @return a clone of this vector. */ public synchronized Object clone() { VisibleVector v = new VisibleVector (size(), vr.color(), vr.getVertical()); for (int i = 0; i < size(); ++i) v.addElement (elementAt(i)); return v; } /** * For convenience, stacklike operations **/ public void push (Visible v) { addElement (v); } /** * For convenience, stacklike operations **/ public void pop () { removeElementAt (size()-1); } /** * This function returns the VisibleRendering data member * * @return the rendering information for this object. **/ public Rendering getRendering() { return vr; } /** * Produce the text string to be displayed in the picture of the object. * * @return the text string to be displayed **/ public String getAlgAEText() { return ""; } /** * If an object <CODE>s</CODE> is to be portrayed as having * pointers/references/arrows to other Visible objects, then when * <CODE>s.touchAllPointers()</CODE> is called, * the body of <CODE>touchAllPointers</CODE> should call, for each arrow * from <CODE>s</CODE> to another Visible object <CODE>p</CODE>, * <CODE>s.getRendering().touch(p, dir)</CODE> or * <CODE>s.getRendering().touch(p, dir, label)</CODE>. * <P> * <CODE>dir</CODE> is the "exit" direction from which the AlgAE system * will draw the arrow from <CODE>s</CODE> to <CODE>p</CODE>. **/ public void touchAllPointers() { } /** * If an object <CODE>s</CODE> is to be portrayed as a compound structure * containing other Visible objects, then when * <CODE>s.touchAllComponents()</CODE> is called, * the body of <CODE>touchAllComponents</CODE> should call, for each * contained Visible component <CODE>p</CODE>, * <CODE>s.getRendering().touch(p)</CODE>. * <P> * Note that the the distinction between a "Pointer" and a "Component" * is a logical distinction, as they are both typically implemented as * simple data members of the Visible class. It is up to the designer * of the algorithm animation to decide what to portray as references and * what to portray as contained components. **/ public void touchAllComponents() { int sz = size(); for (int i = 0; i < sz; ++i) { Visible v = (Visible)elementAt(i); vr.touch (v); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -