My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
How_it_works  
Simple explanation of how JavaDiagram works.
Updated Oct 20, 2009 by jd.comm...@gmail.com

Math Sets

Let's say you have a universe (U) set:

  • U = {a,b,c,d,e,f,g,h,k,l,m,n,o,p,q,r,s,t,u,v,x,y,w,z}

And the content of each element of U set are:

  • a = {b,c}
  • b = {d,e}
  • c = {p}
  • d = {}
  • e = {f,g,h}
  • f = {k,l,m,n,o}
  • g = {q,r}
  • h = {i,j}
  • i = {}
  • j = {t,u,v}
  • k = {w,z}
  • l = {s}
  • m = {}
  • n = {}
  • o = {}
  • p = {}
  • q = {x,y}
  • r = {}
  • s = {}
  • t = {}
  • u = {}
  • v = {}
  • x = {}
  • y = {}
  • w = {}
  • z = {}

The JavaDiagram API, converts the U set into an array and then creates a hierarchical block-diagram that represents the universe set. This diagram will be a .png file and will looks like:

To create this result the code is really simple:

/* First, declare your universe set as a common String.*/
private String universeSet =	"a = {b,c}	" +
	                        "b = {d,e}	" +
	                        "c = {p}	" +
	                        "d = {}		" +
	                        "e = {f,g,h}	" +
	                        "f = {k,l,m,n,o}" +
	                        "g = {q,r}      " +
	                        "h = {i,j}      " +
	                        "i = {}         " +
	                        "j = {t,u,v}    " +
	                        "k = {w,z}      " +
	                        "l = {s}        " +
	                        "m = {}         " +
	                        "n = {}         " +
	                        "o = {}         " +
	                        "p = {}  	" +
	                        "q = {x,y}      " +
	                        "r = {}         " +
	                        "s = {}         " +
	                        "t = {}         " +
	                        "u = {}         " +
	                        "v = {}         " +
	                        "x = {}         " +
	                        "y = {}         " +
	                        "w = {}         " +
	                        "z = {}         ";
	
	public void testConvert(){

                /* Second, instantiate the StructureCreator */
		StructureCreator sc = new StructureCreator();

                /* Third, convert your U set into an array of Retagules */
		ArrayList<RetanguleBox> retArray = sc.convert(universeSet);
		
                /* Forth, instantiate the DiagramCreator passing a png file name/path */
		DiagramCreator dc = new DiagramCreator("/tmp/test2.png");

                /* Fiftieth and finally, call the design method, passing the converted array */ 
		dc.design(retArray);
	}

Sign in to add a comment
Powered by Google Project Hosting