forked from patrickchugh/terravision
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shiftLabel.gvpr
41 lines (38 loc) · 1.29 KB
/
shiftLabel.gvpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
BEGIN{
double bbMinX, bbMinY, bbMaxX, bbMaxY, lpX, lpY, lpMinX, lpMaxY, newX, newY;
double fudgeX, fudgeY;
string fld[int];
// recursive routine, processing from the top (root) down
graph_t labelShift (graph_t Gr) {
graph_t thisG;
for (thisG = fstsubg(Gr); thisG; thisG=nxtsubg(thisG)) {
thisG = labelShift(thisG);
}
if (match(Gr.name,"cluster")==0 ){
if (hasAttr(Gr, "_shift") && Gr._shift!="" && Gr._shift!="0"){
fudgeX=2.; // aim for just inside periphery - increase to shift left
fudgeY=1.; // aim for just inside periphery - increase to shift up
if (index(Gr._shift,",")>0){
split(Gr._shift,fld,",");
fudgeX=(double)fld[0];
fudgeY=(double)fld[1];
}
sscanf (Gr.bb, "%lf,%lf,%lf,%lf", &bbMinX, &bbMinY, &bbMaxX, &bbMaxY);
lpX=xOf(Gr.lp);
lpY=yOf(Gr.lp);
lpMinX=lpX-((Gr.lwidth*72.)/2.);
lpMaxY=lpY+((Gr.lheight*72.)/2.);
//print(" // bb: ", Gr.bb, " lpMinX: ", lpMinX, " lpMaxY: ", lpMaxY);
Gr._oldlp=Gr.lp;
newX=lpX-(lpMinX-bbMinX)-fudgeX;
newY=lpY+(bbMaxY-lpMaxY)+fudgeY;
Gr.lp=sprintf("%.1f,%.1f", newX, newY);
}
}
return Gr;
} // end of labelShift
}
BEG_G{
labelShift($G);
}
N[_footernode=="1"]{pos=sprintf("%.0f,%.0f!", 0, -200)}