Te u zagrebu fakultet organizacije I informatike



Yüklə 0,49 Mb.
Pdf görüntüsü
səhifə15/15
tarix02.10.2017
ölçüsü0,49 Mb.
#2688
1   ...   7   8   9   10   11   12   13   14   15

38 

 

63    



64   

//graph

 

65 



 

 

 



 

 

 



 

 

 



 

GraphModel 

graphModel 

Lookup.getDefault().lookup(GraphController.



class

).getModel()

;

 

66    



67 

 

 



 

 

 



 

 

 



 

 

DynamicController 



dc 

=  


Lookup.getDefault().lookup(DynamicController.

class

)

;



 

68 


 

 

 



 

 

 



 

 

 



 

PreviewModel 

model 



Lookup.getDefault().lookup(PreviewController.



class

).getModel()

;

 

69    



70           DynamicModel dynamicModel= dc.getModel()

;

 



71 

 

 



 

 

 



 

 

 



 

 

DynamicGraph 



dynGraph 

dynamicModel.createDynamicGraph(graphModel.getGraph())



;

 

72           getDynamicInfo(dynamicModel



dynGraph)

;

 

73    



74           DateTime startDatum = 

new 

DateTime(

2004



5



19



0

0



)

;

 



75           DateTime endDatum = 

new 

DateTime(

2013



4



9



0

0



)

;

 



76           DateTime curDate = startDatum

;

 



77    

78 


 

 

 



 

 

 



 

 

 



 

FilterController 

filterController 

Lookup.getDefault().lookup(FilterController.



class

)

;



 

79 


 

 

 



 

 

 



 

 

 



 

FilterBuilder[] 

builders 

Lookup.getDefault().lookup(DynamicRangeBuilder.



class

).getBuilders()

;

 

80                      DynamicRangeBuilder.DynamicRangeFilter  dynamicRangeFilter  = 



(DynamicRangeBuilder.DynamicRangeFilter) builders[

0

].getFilter()



;

 

81           Query dynamicQuery = filterController.createQuery(dynamicRangeFilter)



;

 

82           filterController.add(dynamicQuery)



;

 

83    



84    

85   


while

(curDate.isBefore(endDatum)) {  

86                              dynamicRangeFilter.setRange(

new 

Range(startDatum.getMillis()

curDate.getMillis()))



;

 

87               GraphView view = filterController.filter(dynamicQuery)



;

 

88               Graph filteredGraph = graphModel.getGraph(view)



;

 

89 



 

 

 



 

 

 



 

 

 



 

 

 



 

 

System.out.println(



"filter 

range: 

startDatum.toString(



"dd.MM.YYYY."

) + 


" - " 

+ curDate.toString(



"dd.MM.YYYY."

))

;



 

90                              System.out.println(



"filteredgraph  info: 

\n

EDGE  COUNT:" 

filteredGraph.getEdgeCount()  



91                       + 

"

\n

NODE COUNT:" 

+ filteredGraph.getNodeCount())

;

 

92               layoutGraph(graphModel



workspace

startDatum



curDate)


;

 

93               curDate = curDate.plusDays(



1

)

;



 

94           }  

95       }  

96    


97   

private void 

getDynamicInfo(DynamicModel dynamicmodel

DynamicGraph dynGraph) {  



98 

 

 



 

 

 



 

 

 



 

 

System.out.println(



"

\t

Da 

li 

je 

dynamic?" 

dynamicmodel.isDynamicGraph())



;

 

99           System.out.println(



"

\t

Dynamic edges?" 

+ dynamicmodel.hasDynamicNodes())

;

 

100                    System.out.println(



"

\t

MIN:  " 

+  dynamicmodel.getMin()  + 



"  MAX:" 

dynamicmodel.getMax())



;

 

101          System.out.println(



"

\t

HIGH:" 

+ dynGraph.getHigh())

;

 

102          System.out.println(



"

\t

LOW:" 

+ dynGraph.getLow())

;

 

103          System.out.println(



"

\t

INTERVAL:" 

+ dynGraph.getInterval())

;

 

104                    System.out.println(



"

\t

NORMAL  graph  info: 

\n\t

EDGE  COUNT:" 

dynGraph.getUnderlyingGraph().getEdgeCount()  



105 

 

 



 

 

 



 

 

 



 

 

 



 

 

 



 

 

 





"

\n\t

NODE 

COUNT:" 

dynGraph.getUnderlyingGraph().getNodeCount())



;

 

106      }  



107   

108   


private  void 

layoutGraph(GraphModel  graphModel

Workspace  workspace



DateTime 

startDatum

DateTime curDatum) {  




39 

 

109  



//vrti force atlas

 

110          System.out.println(



"Running forceAtlas"

)

;



 

111          ForceAtlas2 atlas2 = 



new 

ForceAtlas2Builder().buildLayout()

;

 

112          atlas2.setGraphModel(graphModel)



;

 

113          atlas2.setOutboundAttractionDistribution(



true

)

;



 

114          atlas2.setScalingRatio(

2.0

)

;



 

115          atlas2.setGravity(

1.0

)

;



 

116          atlas2.setThreadsCount(

3

)

;



 

117          atlas2.setJitterTolerance(

1.0

)

;



 

118          atlas2.setBarnesHutOptimize(



false

)

;



 

119          atlas2.setAdjustSizes(



false

)

;



 

120          atlas2.setLinLogMode(



true

)

;



 

121 


 

 

 



 

 

 



 

 

 



AutoLayout.DynamicProperty 

dissuadeHubsProperty 

AutoLayout.createDynamicProperty(



"forceAtlas2.distributedAttraction.name"

Boolean.TRUE



1f

)



;

 

122          atlas2.initAlgo()



;

 

123  



for 

(

int 

i = 

0



i <

50 


&& atlas2.canAlgo()

i++) {  



124              atlas2.goAlgo()

;

 



125              exportGraph(workspace

startDatum



curDatum)

;

 

126          }  



127          atlas2.endAlgo()

;

 



128      }  

129   


130   

private  void 

exportGraph(Workspace  workspace

DateTime  startDatum



DateTime 

curDatum) {  

131          ExportController ec = Lookup.getDefault().lookup(ExportController.



class

)

;



 

132          PNGExporter pngExporter = (PNGExporter)ec.getExporter(



"png"

)

;



 

133          pngExporter.setWorkspace(workspace)

;

 

134          pngExporter.setWidth(



1920

)

;



 

135          pngExporter.setHeight(

1080

)

;



 

136          System.out.print(



"."

)

;



 

137          File file = 



new 

File(


"imgs/test" 

+ fileCount++ + 



".png"

)

;



 

138  


try 

{  


139              ec.exportFile(file

pngExporter)



;

 

140          } 



catch 

(IOException e) {  

141              e.printStackTrace()

;

 



142          }  

143   


144  

//cekanje jer ponekad ne stigne pristupit upravo eksportiranom png-u

 

145  



while

(!Files.isReadable(file.toPath())) {  

146              System.out.println(

"File could not be read, will wait 100ms and try 

again..."

)

;



 

147  


try 

{  


148                  Thread.sleep(

100


)

;

 



149              } 

catch 

(InterruptedException e) {  

150                  e.printStackTrace()

;

 



151              }  

152          }  

153  

try 

{  


154              BufferedImage image = ImageIO.read(file.toURI().toURL())

;

 



155              Graphics g = image.getGraphics()

;

 



156              g.setFont(consolasFont)

;

 



157              g.drawString(

"Vizualizacija 1 - Asja Stermsek"

10



10

)



;

 

158                            g.drawString(startDatum.toString(



"dd.MM.YYYY."

)  + 


"  -  " 

curDatum.toString(



"dd.MM.YYYY."

)



10

24



)

;

 



159              g.dispose()

;

 



160              ImageIO.write(image



"png"

file)


;

 

161          } 



catch 

(IOException e) {  

162              e.printStackTrace()

;

 



163          }  

164      }  




40 

 

165  }  



166   

 

 



Document Outline

  • l1
  • l2
  • l3
  • l4
  • l5
  • l6
  • l7
  • l8
  • l9
  • l10
  • l11
  • l12
  • l13
  • l14
  • l15
  • l16
  • l17
  • l18
  • l19
  • l20
  • l21
  • l22
  • l23
  • l24
  • l25
  • l26
  • l27
  • l28
  • l29
  • l30
  • l31
  • l32
  • l33
  • l34
  • l35
  • l36
  • l37
  • l38
  • l39
  • l40
  • l41
  • l42
  • l43
  • l44
  • l45
  • l46
  • l47
  • l48
  • l49
  • l50
  • l51
  • l52
  • l53
  • l54
  • l55
  • l56
  • l57
  • l58
  • l59
  • l60
  • l61
  • l62
  • l63
  • l64
  • l65
  • l66
  • l67
  • l68
  • l69
  • l70
  • l71
  • l72
  • l73
  • l74
  • l75
  • l76
  • l77
  • l78
  • l79
  • l80
  • l81
  • l82
  • l83
  • l84
  • l85
  • l86
  • l87
  • l88
  • l89
  • l90
  • l91
  • l92
  • l93
  • l94
  • l95
  • l96
  • l97
  • l98
  • l99
  • l100
  • l101
  • l102
  • l103
  • l104
  • l105
  • l106
  • l107
  • l108
  • l109
  • l110
  • l111
  • l112
  • l113
  • l114
  • l115
  • l116
  • l117
  • l118
  • l119
  • l120
  • l121
  • l122
  • l123
  • l124
  • l125
  • l126
  • l127
  • l128
  • l129
  • l130
  • l131
  • l132
  • l133
  • l134
  • l135
  • l136
  • l137
  • l138
  • l139
  • l140
  • l141
  • l142
  • l143
  • l144
  • l145
  • l146
  • l147
  • l148
  • l149
  • l150
  • l151
  • l152
  • l153
  • l154
  • l155
  • l156
  • l157
  • l158
  • l159
  • l160
  • l161
  • l162
  • l163
  • l164
  • l165
  • l166
  • l167
  • l168
  • l169
  • l170
  • l171
  • l172
  • l173
  • l174
  • l175
  • l176
  • l177
  • l178
  • l179
  • l180
  • l181
  • l182
  • l183
  • l184
  • l185
  • l186
  • l187
  • l188
  • l189
  • l190
  • l191
  • l192
  • l193
  • l194
  • l195
  • l196
  • l197
  • l198
  • l199
  • l200
  • l201
  • l202
  • l203
  • l204
  • l205
  • l206
  • l207
  • l208
  • l209
  • l210
  • l211
  • l212
  • l213
  • l214
  • l215
  • l216
  • l217
  • l218
  • l219
  • l220
  • l221
  • l222
  • l223
  • l224

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ə