--- a/GnuplotGraphView.st Mon Apr 30 22:12:02 2018 +0200
+++ b/GnuplotGraphView.st Mon Apr 30 23:26:28 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:libwidg2' }"
"{ NameSpace: Smalltalk }"
@@ -171,11 +173,13 @@
data:(RandomGenerator new next:50);
open
"
- |command tmpDir outStream errorStream statusCode ok
+ |scriptUsed command tmpDir outStream errorStream statusCode ok
dataFilename scriptFilename outFilename argsDict expandedScript
stdout stderr|
- script isNil ifTrue:[^ self].
+ (scriptUsed := script) isNil ifTrue:[
+ scriptUsed := self class defaultScript.
+ ].
command := 'gnuplot "%1"'.
argsDict := Dictionary new.
@@ -196,7 +200,7 @@
argsDict at:'outputFormat' put:'png'.
argsDict at:'title' put:(title ? '').
- expandedScript := script bindWithArguments:argsDict.
+ expandedScript := scriptUsed bindWithArguments:argsDict.
scriptFilename := (Filename newTemporaryIn:tmpDir).
scriptFilename := scriptFilename asFilename withSuffix:'gnuplot'.
scriptFilename contents:expandedScript.
@@ -237,6 +241,28 @@
self generateImage
].
super generateMagnifiedImage.
+!
+
+redrawX:x y:y width:w height:h
+ (OperatingSystem canExecuteCommand:'gnuplot') ifFalse:[
+ self clearRectangleX:x y:y width:w height:h.
+ self showWarning.
+ ^ self.
+ ].
+ super redrawX:x y:y width:w height:h.
+!
+
+showWarning
+ |infoMsg wString|
+
+ infoMsg := resources string:'No gnuplot command found'.
+ wString := gc font widthOf:infoMsg.
+ gc displayString:infoMsg x:(self width - wString) // 2 y:(self height // 2).
+!
+
+sizeChanged:how
+ super sizeChanged:how.
+ self invalidate.
! !
!GnuplotGraphView class methodsFor:'documentation'!