Te u zagrebu fakultet organizacije I informatike



Yüklə 0,49 Mb.
Pdf görüntüsü
səhifə14/15
tarix02.10.2017
ölçüsü0,49 Mb.
#2688
1   ...   7   8   9   10   11   12   13   14   15
    Bu səhifədəki naviqasiya:
  • "UTF-8"

36 

 

110                      edgeCount++



;

 

111                  }  



112   

113              } 



else 

{  


114                  System.out.println(

"Url is malformed, skipping " 

+ fromNode)

;

 

115              }  



116          }  

117   


118          Base.close()

;

 



119   

120          StaxGraphWriter graphWriter = 



new 

StaxGraphWriter()

;

 

121          File f = 



new 

File(fileName)

;

 

122          Writer out



;

 

123  



try 

{  


124              out = 

new 

FileWriter(f



false

)

;



 

125              graphWriter.writeToStream(gexf

out




"UTF-8"

)

;



 

126              System.out.println(f.getAbsolutePath())

;

 

127          } 



catch 

(IOException e) {  

128              e.printStackTrace()

;

 



129          }  

130      }  

131   

132  


private 

Node createNode(Graph graph

String label



Date date){  

133          Node newNode = graph.createNode(

"" 

+ nodeCount)

;

 

134          newNode.setLabel(label)



;

 

135          newNode.setStartValue(date)



;

 

136          nodeCount++



;

 

137  



return 

newNode


;

 

138      }  



139   

140  


private 

Node findNode(Graph graph

String nodeName){  



141  

for

(Node node: graph.getNodes()){  

142  

if

(node.getLabel().equals(nodeName)){  

143  

return 

node


;

 

144              }  



145          }  

146  


return null

;

 



147      }  

148   


149  

private 

Edge findEdge(Graph graph

Node fromNode



Node toNode){  

150  

for

(Edge edge : graph.getAllEdges()){  

151  

if

(edge.getSource().equals(fromNode) && edge.getTarget().equals(toNode)){  

152  

return 

edge


;

 

153              }  



154          }  

155  


return null

;

 



156      }  

157  }  


158   

 

 



 

DynamicGephi.java

 

 

1    



package 

info.asy.pictury

;

 

2     



3    

import 

org.gephi.dynamic.api.DynamicController

;

 

4    



import 

org.gephi.dynamic.api.DynamicGraph

;

 



37 

 

5    



import 

org.gephi.dynamic.api.DynamicModel

;

 

6    



import 

org.gephi.filters.api.FilterController

;

 

7    



import 

org.gephi.filters.api.Query

;

 

8    



import 

org.gephi.filters.api.Range

;

 

9    



import 

org.gephi.filters.plugin.dynamic.DynamicRangeBuilder

;

 

10   



import 

org.gephi.filters.spi.FilterBuilder

;

 

11   



import 

org.gephi.graph.api.Graph

;

 

12   



import 

org.gephi.graph.api.GraphController

;

 

13   



import 

org.gephi.graph.api.GraphModel

;

 

14   



import 

org.gephi.graph.api.GraphView

;

 

15   



import 

org.gephi.io.exporter.api.ExportController

;

 

16   



import 

org.gephi.io.exporter.preview.PNGExporter

;

 

17   



import 

org.gephi.io.importer.api.ImportController

;

 

18   



import 

org.gephi.layout.plugin.AutoLayout

;

 

19   



import 

org.gephi.layout.plugin.forceAtlas2.ForceAtlas2

;

 

20   



import 

org.gephi.layout.plugin.forceAtlas2.ForceAtlas2Builder

;

 

21   



import 

org.gephi.preview.api.PreviewController

;

 

22   



import 

org.gephi.preview.api.PreviewModel

;

 

23   



import 

org.gephi.project.api.ProjectController

;

 

24   



import 

org.gephi.project.api.Workspace

;

 

25   



import 

org.joda.time.DateTime

;

 

26   



import 

org.openide.util.Lookup

;

 

27    



28   

import 

javax.imageio.ImageIO

;

 

29   



import 

java.awt.*

;

 

30   



import 

java.awt.image.BufferedImage

;

 

31   



import 

java.io.File

;

 

32   



import 

java.io.IOException

;

 

33   



import 

java.net.URISyntaxException

;

 

34   



import 

java.nio.file.Files

;

 

35    



36   

public class 

DynamicGephi {  

37    

38   


final 

Font consolasFont = 



new 

Font(


"Consolas"

Font.PLAIN



12

)



;

 

39   



int 

fileCount = 

0

;

 



40    

41    


42   

public void 

run(){  


43   

//pokreni projekt - workspace

 

44   



//dijelovi ovog koda su adaptirani sa gephi toolkit wikija

 

45    



46 

 

 



 

 

 



 

 

 



 

 

ProjectController 



pc 

Lookup.getDefault().lookup(ProjectController.



class

)

;



 

47           pc.newProject()

;

 

48    



49   

if 

(pc.getCurrentProject() != 



null

) {  


50               pc.closeCurrentProject()

;

 



51           }  

52   


try 

{  


53 

 

 



 

 

 



 

 

 



 

 

 



 

 

 



File 

file 




new 

File(getClass().getResource(



"/resource/limitGephi1.gephi"

).toURI())

;

 

54               pc.openProject(file).run()



;

 

55           } 



catch 

(URISyntaxException e) {  

56               e.printStackTrace()

;

 



57           }  

58    


59           Workspace workspace = pc.getCurrentWorkspace()

;

 



60    

61   


//kontoleri i model

 

62 



 

 

 



 

 

 



 

 

 



 

ImportController 

importController 

Lookup.getDefault().lookup(ImportController.



class

)

;



 


Yüklə 0,49 Mb.

Dostları ilə paylaş:
1   ...   7   8   9   10   11   12   13   14   15




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə