java - Displaying data on table into jfreechart -


i building application check similiairity between 2 java codes or more. now, have data store table. code build table this

public final class astparseunit {  string idlexer;  public astparseunit(final iparserselector parserselector) {     this.parserselector = parserselector; }  public string getidlexer() {     return idlexer; }  public void setidlexer(string idlexer) {     idlexer = idlexer; }  public astmanager parse(final jccdfile[] files) {      final astmanager container = new astmanager(             tipenode.project.gettipe(), null);       jccdfile temp;     temp = files[0];     string name = temp.getname();      string idlexerseleksi = "";      stringbuilder nameoffilemainfile = new stringbuilder();      stringbuilder countlevenstheins = new stringbuilder();     stringbuilder countjaccards = new stringbuilder();     stringbuilder countcosines = new stringbuilder();       (final jccdfile file : files) {         container.tandainoderoot();           parsetree(file, container);         if (name.equals(file.getname())) {             idlexerseleksi = getidlexer();         }          levenshteindistance lv = new levenshteindistance();         similarityrunner sr = new similarityrunner(); // class count similiarity          if (idlexerseleksi != getidlexer()) {              nameoffilemainfile.append(file.getname());              system.out.println(temp.getname() + " ==> " + file.getname());                countlevenstheins.append(lv.printdistance(idlexerseleksi, getidlexer()));             countjaccards.append(sr.hitungjaccard(idlexerseleksi, getidlexer()));             countcosines.append(sr.hitungcosine(idlexerseleksi, getidlexer()));          }     }      string enemy = nameofmainfile.tostring();     string resultoflevenstheins = countlevenstheins.tostring();     string resultofjaccards = countjaccards.tostring();     string resultofcosines = countcosines.tostring();      defaulttablemodel model = (defaulttablemodel) main_menu.jtable3.getmodel();     list<report3> thelistdata = new arraylist<report3>();     report3 persentasetabel = new report3();      persentasetabel.setmainfile(name);     persentasetabel.setcomparingfile(enemy);     persentasetabel.setlevenstheins(resultoflevenstheins);     persentasetabel.setjaccard(resultofjaccards);     persentasetabel.setcosine(resultofcosines);      thelistdata.add(persentasetabel);     (report3 report3 : thelistdata) {         model.addrow(new object[]{             report3.getmainfile(),             report3.getcomparingfile(),             report3.getlevenstheins(),             report3.getjaccard(),             report3.getcosine(),});     }      return container; } 

now, how can representation table jfreechart ? jfreechart code...

public class layeredbarchartdemo11 extends applicationframe {  public layeredbarchartdemo11(string s) {     super(s);       categorydataset dataset = createdataset();     jfreechart chart = createchart(dataset);     chartpanel chartpanel = new chartpanel(chart);     chartpanel.setpreferredsize(new java.awt.dimension(500, 270));     setcontentpane(chartpanel);     chartpanel.setmousewheelenabled(true);      //main_menu form     main_menu.presentase.removeall();     main_menu.presentase.setlayout(new java.awt.borderlayout());     main_menu.presentase.add(chartpanel); }  private static categorydataset createdataset() {     string s = "levensthein";     string s1 = "jaccard";     string s2 = "cosine";     string s3 = "a.java";     string s4 = "b.java";     string s5 = "c.java";      defaultcategorydataset defaultcategorydataset = new defaultcategorydataset();     defaultcategorydataset.addvalue(100d, s, s3);     defaultcategorydataset.addvalue(20, s1, s3);      defaultcategorydataset.addvalue(40d, s, s4);     defaultcategorydataset.addvalue(170, s, s5);     defaultcategorydataset.addvalue(69, s1, s4);     defaultcategorydataset.addvalue(51, s1, s5);     defaultcategorydataset.addvalue(32, s2, s3);     defaultcategorydataset.addvalue(87, s2, s4);     defaultcategorydataset.addvalue(68, s2, s5);     defaultcategorydataset.addvalue(89, s2, s4);     defaultcategorydataset.addvalue(8, s2, s5);     return defaultcategorydataset; }  private static jfreechart createchart(categorydataset categorydataset) {     jfreechart jfreechart = chartfactory.createbarchart("persentase kemiripan", "file pembanding", "file utama", categorydataset, plotorientation.horizontal, true, true, false);     categoryplot categoryplot = (categoryplot) jfreechart.getplot();     categoryplot.setdomaingridlinesvisible(true);     categoryplot.setrangepannable(true);     categoryplot.setrangezerobaselinevisible(true);     categoryplot.configurerangeaxes();     numberaxis numberaxis = (numberaxis) categoryplot.getrangeaxis();     numberaxis.setstandardtickunits(numberaxis.createintegertickunits());     layeredbarrenderer layeredbarrenderer = new layeredbarrenderer();     layeredbarrenderer.setdrawbaroutline(false);     categoryplot.setrenderer(layeredbarrenderer);     categoryplot.setrowrenderingorder(sortorder.descending);     gradientpaint gradientpaint = new gradientpaint(0.0f, 0.0f, color.blue, 0.0f, 0.0f, new color(0, 0, 64));     gradientpaint gradientpaint1 = new gradientpaint(0.0f, 0.0f, color.green, 0.0f, 0.0f, new color(0, 64, 0));     gradientpaint gradientpaint2 = new gradientpaint(0.0f, 0.0f, color.red, 0.0f, 0.0f, new color(64, 0, 0));     layeredbarrenderer.setseriespaint(0, gradientpaint);     layeredbarrenderer.setseriespaint(1, gradientpaint1);     layeredbarrenderer.setseriespaint(2, gradientpaint2);     return jfreechart; }  public static jpanel createdemopanel() {     jfreechart jfreechart = createchart(createdataset());     chartpanel chartpanel = new chartpanel(jfreechart);     chartpanel.setmousewheelenabled(true);     return chartpanel; } 

this screenshot of application https://www.dropbox.com/s/opmao5l9sy0df8v/new%20picture%20%2810%29.png

assuming want chart reflect (possibly changing) table entries, add tablemodellistener tablemodel. based on tablemodelevent received, update categorydataset accordingly; listening chart update in response.

if table model not change after query , comparison functions evaluated, use jdbccategorydataset, mentioned here, query database; construct corresponding table model.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -