Example: Visualization of Quick Sort Algorithm

 

Following Java Applet used Assisting Visualization Framework to visualize classic quicksort algorithm. Elements sorted by this algorithm is an array of float value. Each one of the element is visualized by a bar, and its value is represented as the height of the bar. Following two Java Applets visualized the same program but with different binding XML definition.

Visualization using first binding XML
Complete Binding XML for First Applet
Visualization using second binding XML
Complete Binding XML for Second Applet
Part of Binding XML for Applet B (changes are marked in red) Part of Binding XML for Applet A (changes are marked in green)
<PropertyMap className="demo.sort.SortElement" toName="x"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="0.7" />
<Field
name="(float)(Math.cos((float)index/(float)maxIndex*Math.PI-Math.PI/2f)*300.0)" />

</PropertyMap>
<PropertyMap className="demo.sort.SortElement" toName="x"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="0.7" />
<Field name="(float)index*20.0" />
</PropertyMap>
<PropertyMap className="demo.sort.SortElement" toName="z"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="0.7" />
<Field
name="(float)(Math.sin((float)index/(float)maxIndex*Math.PI-Math.PI/2f)*300.0)" />

</PropertyMap>

<PropertyMap className="demo.sort.SortElement" toName="z"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="0.1" />
<Code outVar="offset">
float offset=0.0f;
if(currentPivot) offset=50f;
else if(pivot) offset=100f;
else offset=0f;
</Code>

</PropertyMap>

<PropertyMap className="demo.sort.SortElement" toName="colorRed">
<Field name="value" />
</PropertyMap>
<PropertyMap className="demo.sort.SortElement" toName="colorRed"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="1" />
<Code outVar="color">
float color=0.0f;
if(currentPivot) color=1f;
else if(pivot) color=0.5f;
else color=0f;
</Code>

</PropertyMap>

<PropertyMap className="demo.sort.SortElement" toName="rotateW"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="0.7" />
<Field
name="Math.cos(-((float)index/(float)maxIndex*Math.PI-Math.PI/2f)*0.5f)" />
</PropertyMap>

<PropertyMap className="demo.sort.SortElement" toName="rotateY"
type="INTERPOLATE" interpolate="INT_LINEAR">
<InterpolateParam key="adaptFactor" value="0.0" />
<InterpolateParam key="estimateInterval" value="0.7" />
<Field
name="Math.sin(-((float)index/(float)maxIndex*Math.PI-Math.PI/2f)*0.5f)" />
</PropertyMap>

-
Source File