1 #ifndef __JROOT__JLEGEND__
2 #define __JROOT__JLEGEND__
16 namespace JPP {
using namespace JROOT; }
31 const std::string option,
32 const Double_t factor = 1.0)
38 const Double_t X1 = 0.0 + gPad->GetLeftMargin();
39 const Double_t X2 = 1.0 - gPad->GetRightMargin();
40 const Double_t Y1 = 0.0 + gPad->GetBottomMargin();
41 const Double_t Y2 = 1.0 - gPad->GetTopMargin();
43 const Double_t
w = gPad->XtoPixel(gPad->GetX2());
44 const Double_t h = gPad->YtoPixel(gPad->GetY1());
46 const Double_t w1 = fabs(gPad->XtoPixel(gPad->GetX2()) - gPad->XtoPixel(gPad->GetX1()));
47 const Double_t h1 = fabs(gPad->YtoPixel(gPad->GetY2()) - gPad->YtoPixel(gPad->GetY1()));
49 const Double_t mw = 2.0;
50 const Double_t mh = 0.5;
51 const Double_t eps = 0.005;
52 const Double_t ts = gStyle->GetStatFontSize() * factor;
53 const Double_t ch = ts * (
w < h ?
w : h);
55 Double_t W = (width + mw) * (ch/w1) * factor;
56 Double_t
H = (height + mh) * (ch/h1) * factor;
60 if (fc * W > X2 - X1 - 2*eps) { fc *= (X2 - X1 - 2*eps) / W; }
61 if (fc *
H > Y2 - Y1 - 2*eps) { fc *= (Y2 - Y1 - 2*eps) /
H; }
68 Double_t x1 = X2 - W - eps;
69 Double_t y1 = Y2 -
H - eps;
70 Double_t x2 = X2 - eps;
71 Double_t y2 = Y2 - eps;
73 if (option.find(
'T') != string::npos && option.find(
'B') == string::npos) {
78 if (option.find(
'B') != string::npos && option.find(
'T') == string::npos) {
83 if (option.find(
'R') != string::npos && option.find(
'L') == string::npos) {
88 if (option.find(
'L') != string::npos && option.find(
'R') == string::npos) {
93 TLegend* lg =
new TLegend(x1, y1, x2, y2);
96 lg->SetFillColor(kWhite);
99 lg->SetTextFont(gStyle->GetStatFont());
static const double H
Planck constant [eV s].
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
TLegend * getLegend(const Int_t width, const Int_t height, const std::string option, const Double_t factor=1.0)
Get legend.