svg for wordcloud
authorPierre <ratinaud@univ-tlse2.fr>
Sat, 9 Feb 2013 14:06:15 +0000 (15:06 +0100)
committerPierre <ratinaud@univ-tlse2.fr>
Sat, 9 Feb 2013 14:06:15 +0000 (15:06 +0100)
KeyFrame.py
PrintRScript.py
configuration/global.cfg
configuration/iramuteq.cfg
dialog.py
layout.py
textwordcloud.py

index ddaecf2..2c47759 100755 (executable)
@@ -135,8 +135,9 @@ class AlcOptFrame(wx.Dialog):
         for i in range(0,len(self.listlabel)):
             self.keys[self.listcle[i]] = self.listspin[i].GetValue()
         DoConf().makeoptions(['KEY'], [self.keys], outfile = self.parent.parent.ira.ConfigPath['key'])
-        self.Disable()
-        return
+        #self.Disable()
+        self.Destroy()
+        #return
 
 
 class ListView(wx.Dialog):
index 686322e..fd86a2c 100644 (file)
@@ -1092,7 +1092,14 @@ class WordCloudRScript(PrintRScript) :
         self.packages(['wordcloud'])
         bg_col = Rcolor(self.parametres['col_bg'])
         txt_col = Rcolor(self.parametres['col_text'])
+        if self.parametres['svg'] :
+            svg = 'TRUE'
+        else :
+            svg = 'FALSE'
         txt = """
+        svg <- %s
+        """ % svg
+        txt += """
         act <- read.csv2("%s", header = FALSE, row.names=1, sep='\t')
         selected.col <- read.table("%s")
         toprint <- as.matrix(act[selected.col[,1] + 1,])
@@ -1102,7 +1109,7 @@ class WordCloudRScript(PrintRScript) :
             toprint <- as.matrix(toprint[order(toprint[,1], decreasing=TRUE),])
             toprint <- as.matrix(toprint[1:maxword,])
         }
-        open_file_graph("%s", width = %i, height = %i)
+        open_file_graph("%s", width = %i, height = %i , svg = svg)
         par(bg=rgb%s)
         wordcloud(row.names(toprint), toprint[,1], scale=c(%f,%f), random.order=FALSE, colors=rgb%s)
         dev.off()
index 864a3d3..a9ca819 100644 (file)
@@ -6,6 +6,6 @@ copyright = (c) 2008-2013 Pierre Ratinaud
 author = Pierre Ratinaud
 gpl-fr = gpl-2.0-fr.txt
 dev = Pierre Ratinaud (ratinaud@univ-tlse2.fr);Sebastien Dejean
-version = 0.6 alpha 1
+version = 0.6 alpha 2
 licence = GNU GPL (v2)
-version_nb = 0.6.a1
+version_nb = 0.6.a2
index 91089d1..3136743 100644 (file)
@@ -5,7 +5,7 @@ language=french
 guilanguage=french
 R_mem = false
 R_max_mem = 1535
-version_nb = 0.6.a1
+version_nb = 0.6.a2
 rlibs = false
 libsvdc = false
 libsvdc_path = /usr/bin/svd
index e21c0f6..0711708 100755 (executable)
--- a/dialog.py
+++ b/dialog.py
@@ -1152,8 +1152,7 @@ class StatDialog(wx.Dialog):
         dial = AlcOptFrame(self, self.parent.parent)
         dial.CenterOnParent()
         dial.ShowModal()
-       dial.Destroy()
-        print 'zerazer'
+        #dial.Destroy()
 
 class LexDialog( wx.Dialog ):
     
@@ -1954,6 +1953,21 @@ class PrefWordCloud ( wx.Dialog ):
         self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
         fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
         
+        self.m_staticText11 = wx.StaticText( self, wx.ID_ANY, u"Format de l'image", wx.DefaultPosition, wx.DefaultSize, 0 )
+        self.m_staticText11.Wrap( -1 )
+        fgSizer1.Add( self.m_staticText11, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        formatChoices = [ u"png", u"svg" ]
+        self.format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, formatChoices, 0 )
+        self.format.SetSelection( 0 )
+        fgSizer1.Add( self.format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+        
+        self.m_staticline13 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+        fgSizer1.Add( self.m_staticline13, 0, wx.EXPAND |wx.ALL, 5 )
+        
+        self.m_staticline14 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+        fgSizer1.Add( self.m_staticline14, 0, wx.EXPAND |wx.ALL, 5 )
+
         self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, u"Nombre maximum de formes", wx.DefaultPosition, wx.DefaultSize, 0 )
         self.m_staticText5.Wrap( -1 )
         fgSizer1.Add( self.m_staticText5, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_LEFT|wx.ALL, 5 )
index 69381d4..5628059 100644 (file)
--- a/layout.py
+++ b/layout.py
@@ -262,7 +262,11 @@ class GraphPanel(wx.ScrolledWindow):
         self.deb = wx.StaticText(self, -1, txt)
         for i in range(0,len(list_graph)):
             if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
-                self.listimg.append(wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
+                filename, ext = os.path.splitext(list_graph[i][0])
+                if ext == '.svg' :
+                    self.listimg.append(hl.HyperLinkCtrl(self, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0])))
+                else :
+                    self.listimg.append(wx.StaticBitmap(self, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
                 self.labels.append(wx.StaticText(self, -1, list_graph[i][1]))
                 
         self.__set_properties()
@@ -834,19 +838,13 @@ class DefaultTextLayout :
 
 class WordCloudLayout(DefaultTextLayout):
     def dolayout(self):
-        #self.dictpathout = parent.corpus.dictpathout
-        #self.pathout = os.path.dirname(filename)
-        #self.corpus = parent.corpus
-    #    self.read_result()
         self.pathout.basefiles(simipath)
         self.Tab = aui.AuiNotebook(self.ira.nb, -1, wx.DefaultPosition)
-#        if os.path.exists(self.pathout['liste_graph']) :
-#            list_graph = read_list_file(self.pathout['liste_graph'])
-#        else : 
-#            list_graph = [['','']]
-        list_graph = [['nuage_1.png', 'Nuage']]
+        if self.parametres['svg'] :
+            list_graph = [['nuage_1.svg', 'Nuage']]
+        else :
+            list_graph = [['nuage_1.png', 'Nuage']]
         self.TabStatTot = GraphPanel(self.ira.nb, self.pathout, list_graph)
-        #self.TabStatTot.write(self.result['glob'])
         self.Tab.AddPage(self.TabStatTot, 'Nuage')
         self.Tab.corpus = self.corpus
         self.Tab.parametres = self.parametres
index c7ca3f1..ed4c1cf 100644 (file)
@@ -48,6 +48,10 @@ class WordCloud(AnalyseText):
         dial.CenterOnParent()
         res = dial.ShowModal()
         if res == wx.ID_OK :
+            if dial.format.GetSelection() == 0 :
+                svg = 0
+            else :
+                svg = 1
             self.parametres['width'] = dial.spin_L.GetValue()
             self.parametres['height'] = dial.spin_H.GetValue()
             self.parametres['maxword'] = dial.spin_maxword.GetValue()
@@ -56,15 +60,19 @@ class WordCloud(AnalyseText):
             self.parametres['col_text'] = dial.color_text.GetColour()
             self.parametres['col_bg'] = dial.color_bg.GetColour()
             self.parametres['mode'] = dial.typeformeschoice.GetSelection()
+            self.parametres['svg'] = svg
             outgraph = os.path.join(os.path.dirname(self.pathout['zipf.png']), 'nuage_')
             nb = 1
-            while os.path.exists(outgraph + str(nb) + '.png') :
+            if svg :
+                end = '.svg'
+            else :
+                end = '.png'
+            while os.path.exists(outgraph + str(nb) + end) :
                 nb += 1
-            self.parametres['graphout'] = outgraph + str(nb) + '.png'
+            self.parametres['graphout'] = outgraph + str(nb) + end
         dial.Destroy()
         return res
 
-
     def make_wordcloud(self) :
         act = ['\t'.join([act, `self.corpus.getlemeff(act)`]) for act in self.actives]
         with open(self.pathout['actives_eff.csv'], 'w') as f :