<commit_before>// @(#)root/graf:$Name:  $:$Id: TPaveLabel.cxx,v 1.13 2002/10/28 15:38:32 brun Exp $
// Author: <NAME>   17/10/95

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "Riostream.h"
#include "TROOT.h"
#include "TPaveLabel.h"
#include "TLatex.h"
#include "TVirtualPad.h"

ClassImp(TPaveLabel)

//______________________________________________________________________________
//*  A PaveLabel is a Pave (see TPave) with a text centered in the Pave.
//Begin_Html
/*
<img src="gif/pavelabel.gif">
*/
//End_Html
//

//______________________________________________________________________________
TPaveLabel::TPaveLabel(): TPave(), TAttText()
{
//*-*-*-*-*-*-*-*-*-*-*pavelabel default constructor*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  =============================
}

//______________________________________________________________________________
TPaveLabel::TPaveLabel(Double_t x1, Double_t y1,Double_t x2, Double_t  y2, const char *label, Option_t *option)
           :TPave(x1,y1,x2,y2,3,option), TAttText(22,0,1,62,0.99)
{
//*-*-*-*-*-*-*-*-*-*-*pavelabel normal constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  ============================
// a PaveLabel is a Pave with a label centered in the Pave
// The Pave is by default defined bith bordersize=5 and option ="br".
// The text size is automatically computed as a function of the pave size.
//
//  IMPORTANT NOTE:
//  Because TPave objects (and objects deriving from TPave) have their
//  master coordinate system in NDC, one cannot use the TBox functions
//  SetX1,SetY1,SetX2,SetY2 to change the corner coordinates. One should use
//  instead SetX1NDC, SetY1NDC, SetX2NDC, SetY2NDC.

   fLabel  = label;
}

//______________________________________________________________________________
TPaveLabel::~TPaveLabel()
{
//*-*-*-*-*-*-*-*-*-*-*pavelabel default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  ============================
}

//______________________________________________________________________________
TPaveLabel::TPaveLabel(const TPaveLabel &pavelabel) : TPave(pavelabel), TAttText(pavelabel)
{
   ((TPaveLabel&)pavelabel).Copy(*this);
}

//______________________________________________________________________________
void TPaveLabel::Copy(TObject &obj) const
{
//*-*-*-*-*-*-*-*-*-*-*Copy this pavelabel to pavelabel*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  ================================

   TPave::Copy(obj);
   TAttText::Copy(((TPaveLabel&)obj));
   ((TPaveLabel&)obj).fLabel      = fLabel;
}

//______________________________________________________________________________
void TPaveLabel::Draw(Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Draw this pavelabel with its current attributes*-*-*-*-*
//*-*                  ===============================================

   Option_t *opt;
   if (strlen(option)) opt = option;
   else                opt = GetOption();

   AppendPad(opt);

}

//______________________________________________________________________________
void TPaveLabel::DrawPaveLabel(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char *label, Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Draw this pavelabel with new Doubleinates*-*-*-*-*-*-*-*
//*-*                  ========================================
   TPaveLabel *newpavelabel = new TPaveLabel(x1,y1,x2,y2,label,option);
   newpavelabel->SetBit(kCanDelete);
   newpavelabel->AppendPad();
}

//______________________________________________________________________________
void TPaveLabel::Paint(Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Paint this pavelabel with its current attributes*-*-*-*
//*-*                  ================================================

//*-* Convert from NDC to pad coordinates
   TPave::ConvertNDCtoPad();

   PaintPaveLabel(fX1, fY1, fX2, fY2, GetLabel(), option);

}


//______________________________________________________________________________
void TPaveLabel::PaintPaveLabel(Double_t x1, Double_t y1,Double_t x2, Double_t  y2,
                      const char *label ,Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Draw this pavelabel with new coordinates*-*-*-*-*-*-*-*
//*-*                  ========================================

   Int_t nch = strlen(label);

//*-*- Draw the pave
   TPave::PaintPave(x1,y1,x2,y2,GetBorderSize(),option);

   Float_t nspecials = 0;
   for (Int_t i=0;i<nch;i++) {
      if (label[i] == '!') nspecials += 1;
      if (label[i] == '?') nspecials += 1.5;
      if (label[i] == '#') nspecials += 1;
      if (label[i] == '`') nspecials += 1;
      if (label[i] == '^') nspecials += 1.5;
      if (label[i] == '~') nspecials += 1;
      if (label[i] == '&') nspecials += 2;
      if (label[i] == '\\') nspecials += 3;  // octal characters very likely
   }<commit_msg>In TPaveLabel::Paint, use the internal option GetOption in case the argument option is null.<commit_after>// @(#)root/graf:$Name:  $:$Id: TPaveLabel.cxx,v 1.14 2002/10/31 07:27:35 brun Exp $
// Author: <NAME>   17/10/95

/*************************************************************************
 * Copyright (C) 1995-2000, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "Riostream.h"
#include "TROOT.h"
#include "TPaveLabel.h"
#include "TLatex.h"
#include "TVirtualPad.h"

ClassImp(TPaveLabel)

//______________________________________________________________________________
//*  A PaveLabel is a Pave (see TPave) with a text centered in the Pave.
//Begin_Html
/*
<img src="gif/pavelabel.gif">
*/
//End_Html
//

//______________________________________________________________________________
TPaveLabel::TPaveLabel(): TPave(), TAttText()
{
//*-*-*-*-*-*-*-*-*-*-*pavelabel default constructor*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  =============================
}

//______________________________________________________________________________
TPaveLabel::TPaveLabel(Double_t x1, Double_t y1,Double_t x2, Double_t  y2, const char *label, Option_t *option)
           :TPave(x1,y1,x2,y2,3,option), TAttText(22,0,1,62,0.99)
{
//*-*-*-*-*-*-*-*-*-*-*pavelabel normal constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  ============================
// a PaveLabel is a Pave with a label centered in the Pave
// The Pave is by default defined bith bordersize=5 and option ="br".
// The text size is automatically computed as a function of the pave size.
//
//  IMPORTANT NOTE:
//  Because TPave objects (and objects deriving from TPave) have their
//  master coordinate system in NDC, one cannot use the TBox functions
//  SetX1,SetY1,SetX2,SetY2 to change the corner coordinates. One should use
//  instead SetX1NDC, SetY1NDC, SetX2NDC, SetY2NDC.

   fLabel  = label;
}

//______________________________________________________________________________
TPaveLabel::~TPaveLabel()
{
//*-*-*-*-*-*-*-*-*-*-*pavelabel default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  ============================
}

//______________________________________________________________________________
TPaveLabel::TPaveLabel(const TPaveLabel &pavelabel) : TPave(pavelabel), TAttText(pavelabel)
{
   ((TPaveLabel&)pavelabel).Copy(*this);
}

//______________________________________________________________________________
void TPaveLabel::Copy(TObject &obj) const
{
//*-*-*-*-*-*-*-*-*-*-*Copy this pavelabel to pavelabel*-*-*-*-*-*-*-*-*-*-*-*
//*-*                  ================================

   TPave::Copy(obj);
   TAttText::Copy(((TPaveLabel&)obj));
   ((TPaveLabel&)obj).fLabel      = fLabel;
}

//______________________________________________________________________________
void TPaveLabel::Draw(Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Draw this pavelabel with its current attributes*-*-*-*-*
//*-*                  ===============================================

   Option_t *opt;
   if (strlen(option)) opt = option;
   else                opt = GetOption();

   AppendPad(opt);

}

//______________________________________________________________________________
void TPaveLabel::DrawPaveLabel(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char *label, Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Draw this pavelabel with new Doubleinates*-*-*-*-*-*-*-*
//*-*                  ========================================
   TPaveLabel *newpavelabel = new TPaveLabel(x1,y1,x2,y2,label,option);
   newpavelabel->SetBit(kCanDelete);
   newpavelabel->AppendPad();
}

//______________________________________________________________________________
void TPaveLabel::Paint(Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Paint this pavelabel with its current attributes*-*-*-*
//*-*                  ================================================

//*-* Convert from NDC to pad coordinates
   TPave::ConvertNDCtoPad();

   PaintPaveLabel(fX1, fY1, fX2, fY2, GetLabel(), strlen(option)?option:GetOption());

}


//______________________________________________________________________________
void TPaveLabel::PaintPaveLabel(Double_t x1, Double_t y1,Double_t x2, Double_t  y2,
                      const char *label ,Option_t *option)
{
//*-*-*-*-*-*-*-*-*-*-*Draw this pavelabel with new coordinates*-*-*-*-*-*-*-*
//*-*                  ========================================

   Int_t nch = strlen(label);

//*-*- Draw the pave
   TPave::PaintPave(x1,y1,x2,y2,GetBorderSize(),option);

   Float_t nspecials = 0;
   for (Int_t i=0;i<nch;i++) {
      if (label[i] == '!') nspecials += 1;
      if (label[i] == '?') nspecials += 1.5;
      if (label[i] == '#') nspecials += 1;
      if (label[i] == '`') nspecials += 1;
      if (label[i] == '^') nspecials += 1.5;
      if (label[i] == '~') nspecials += 1;
      if (label[i] == '&') nspecials += 2;
      if (label[i] == '\\') nspecials += 3;  // octal characters very likely
   }
{'fraction_non_alphanumeric': 0.24749480052940065, 'fraction_numerical': 0.017016449234259785, 'mean_word_length': 3.298659081674116, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '735549', 'n_tokens_mistral': 3236, 'n_tokens_neox': 2975, 'n_words': 657}