p2=
WPlot.component
(
list
(xData= mtcars[,
6
]*
1000
, yData= mtcars[,
1
],
xname=
"Weight (lbs)"
, yname=
"Miles per gallon"
))
GShell.setVariable
(
'rownames'
,
row.names
(mtcars))
GShell.setVariable
(
'p2'
, p2)
GShell.evalEDT
('
import kcl.waterloo.gui.images.Images
def thisfont=new
java.awt.Font
(
"sans serif"
,java.awt.Font.PLAIN,
8
);
p2.getPlot
()
.setComponents
(new
kcl.waterloo.widget.GJButton
());
p2.createFrame
()
for
(def k=
0
; k<rownames.length;k++){
p2.getPlot
().componentArray[k]
.setPreferredSize
(new
java.awt.Dimension
(
30
,
30
))
p2.getPlot
().componentArray[k]
.setFileName
(k+
1
+
".png"
)
p2.getPlot
().componentArray[k]
.setToolTipText
(
String.format
("<HTML><STRONG>%d: %s</STRONG><BR><EM>
Click
for
link</EM></HTML>",
k+
1
, rownames[k]))
// This adds a URL descripton string as the actionCommand
p2.getPlot
().componentArray[k]
.setActionCommand
(
rownames[k]
.replace
(
" "
,
"%20"
)))
// This adds a listener that responds to mouse clicks. It searches
for
the car on Wikipedia
// using the string supplied
in
the actionCommand
p2.getPlot
().componentArray[k]
.addActionListener
(
kcl.waterloo.actions.ComponentActionListener.getInstance
())
};
p2.getPlot
()
.getParentGraph
()
.getGraphContainer
()
.setTitleText
(
"Relationship between vehicle weight and fuel consumption"
)
p2.getPlot
()
.getParentGraph
()
.getGraphContainer
()
.setSubTitleText
(
"Hover over a data point with the mouse to see its origin and click for its Wikipdiedia entry"
)
p2.getPlot
()
.getParentGraph
()
.setMajorGridPainted
(false)
p2.getPlot
()
.getParentGraph
()
.setMinorGridPainted
(false)
')