Adjusting margins and paddings to fit translucent decor.
778628
private void initDecorMargins() {
        if (DecorUtils.isCanHaveTransparentDecor()) {
            Views.getParams(views.appBar).height += DecorUtils.getStatusBarHeight(this);
        }
        DecorUtils.paddingForStatusBar(views.toolbar, true);
        DecorUtils.paddingForStatusBar(views.pagerToolbar, true);
        DecorUtils.paddingForStatusBar(views.fullImageToolbar, true);
        DecorUtils.paddingForNavBar(views.grid);
        DecorUtils.marginForNavBar(views.pagerTitle);
    }
931219
private void adjustBannerTextVerticalBias(float percentBias) {
    if (!isLandscape()) {
      ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) instructionLayoutText.getLayoutParams();
      params.verticalBias = percentBias;
      instructionLayoutText.setLayoutParams(params);
    }
  }
757259
def adjustMask(self):
        
        if self.currentMode() == XPopupWidget.Mode.Dialog:
            self.clearMask()
            return
        
        path = self.borderPath()
        bitmap = QBitmap(self.width(), self.height())
        bitmap.fill(QColor('white'))
        
        with XPainter(bitmap) as painter:
            painter.setRenderHint(XPainter.Antialiasing)
            pen = QPen(QColor('black'))
            pen.setWidthF(0.75)
            painter.setPen(pen)
            painter.setBrush(QColor('black'))
            painter.drawPath(path)
        
        self.setMask(bitmap)
230412
def layout_padding(plots, renderer):
    
    widths, heights = defaultdict(int), defaultdict(int)
    for r, row in enumerate(plots):
        for c, p in enumerate(row):
            if p is not None:
                width, height = renderer.get_size(p)
                widths[c] = max(widths[c], width)
                heights[r] = max(heights[r], height)

    expanded_plots = []
    for r, row in enumerate(plots):
        expanded_plots.append([])
        for c, p in enumerate(row):
            if p is None:
                p = empty_plot(widths[c], heights[r])
            elif hasattr(p, 'plot_width') and p.plot_width == 0 and p.plot_height == 0:
                p.plot_width = widths[c]
                p.plot_height = heights[r]
            expanded_plots[r].append(p)
    return expanded_plots
691118
function SetMargins() {
    /////////////////////////////////////////////////////////////////
    // When the image is first created - set the margins
    // to be the standard viewport.
    // The standard viewport is the full area of the view surface (or panel),
    // less a margin of 4 character heights all round for labelling.
    // It thus depends on the current character size, set by SetCharacterHeight().
    /////////////////////////////////////////////////////////////////

    $str = preg_split("/\n/",$this->title_txt);
    $nbLines = count($str);

    if ($this->use_ttf == 1) {
      $title_size = $this->TTFBBoxSize($this->title_ttffont_size, $this->title_angle, $this->title_ttffont, 'X'); //An array
      if ($nbLines == 1) {
        $this->y_top_margin = $title_size[1] * 4;
      } else {
        $this->y_top_margin = $title_size[1] * ($nbLines+3);
      }

      //ajo working here
      //$x_label_size = $this->TTFBBoxSize($this->x_label_ttffont_size, 0, $this->axis_ttffont, $this->x_label_txt);

      $this->y_bot_margin = $this->x_label_height ;
      $this->x_left_margin = $this->y_label_width * 2 + $this->tick_length;
      $this->x_right_margin = 33.0; // distance between right and end of x axis in pixels
    } else {
      $title_size = array(ImageFontWidth($this->title_font) * strlen($this->title_txt),ImageFontHeight($this->title_font));
      //$this->y_top_margin = ($title_size[1] * 4);
      if ($nbLines == 1) {
        $this->y_top_margin = $title_size[1] * 4;
      } else {
        $this->y_top_margin = $title_size[1] * ($nbLines+3);
      }
      if ($this->x_datalabel_angle == 90) {
        $this->y_bot_margin = 76.0; // Must be integer
      } else {
        $this->y_bot_margin = 66.0; // Must be integer
      }
      $this->x_left_margin = 77.0; // distance between left and start of x axis in pixels
      $this->x_right_margin = 33.0; // distance between right and end of x axis in pixels
    }

//exit;
    $this->x_tot_margin = $this->x_left_margin + $this->x_right_margin;
    $this->y_tot_margin = $this->y_top_margin + $this->y_bot_margin;

    if ($this->plot_max_x && $this->plot_max_y && $this->plot_area_width ) { //If data has already been analysed then set translation
      $this->SetTranslation();
    }
  }
8545
function fillBlanks(text, pad) {
    "use strict";
    pad = pad || 80;
    if (text.length < pad) {
        text += new Array(pad - text.length + 1).join(' ');
    }
    return text;
}
1238085
function getSideMargins (style) {
  const margins = compact(style.split(';')).map((decl) => {
    const split = decl.split(':')

    return {
      prop: first(split).trim().toLowerCase(),
      value: last(split).trim().toLowerCase()
    }
  }).filter(({ prop, value }) => prop.indexOf('margin') === 0)

  let left = 0
  let right = 0
  margins.forEach(({ prop, value }) => {
    if (prop === 'margin-left') {
      left = value
      return
    }

    if (prop === 'margin-right') {
      right = value
      return
    }

    if (prop === 'margin') {
      const values = value.split(' ').map((i) => i.trim())

      switch (values.length) {
        case 1:
          right = first(values)
          left = first(values)
          break

        case 2:
          right = last(values)
          left = last(values)
          break

        case 3:
          right = nth(values, 1)
          left = nth(values, 1)
          break

        default:
          right = nth(values, 1)
          left = nth(values, 3)
          break
      }
    }
  })

  return { left, right }
}
76447
def _visual_center(line, width):
    """"""

    spaces = max(width - _visual_width(line), 0)
    left_padding = int(spaces / 2)
    right_padding = spaces - left_padding

    return (left_padding * " ") + line + (right_padding * " ")
772929
function setLayout(d, layout, lastDisplay) {
        if (layout === 'vertical' || layout === 'multimode_vertical' ||
            layout === 'all_vertical') {

            d.displayDiv.style.float = 'none';
            d.titleDiv.style.float = 'none';
            d.titleDiv.style['margin-right'] = '0px';
            d.contentDiv.style.float = 'none';
            return true;
        }
        if (layout === 'horizontal') {
            d.displayDiv.style.float = 'none';
            d.titleDiv.style.float = 'left';
            d.titleDiv.style['margin-right'] = '6px';
            d.contentDiv.style.float = 'right';
            return true;
        }
        if (layout === 'multimode_horizontal') {
            d.displayDiv.style.float = 'left';
            d.titleDiv.style.float = 'none';
            d.titleDiv.style['margin-right'] = '0px';
            d.contentDiv.style.float = 'none';
            if (!lastDisplay) {
                d.displayDiv.style['margin-right'] = '10px';
            }
            return true;
        }
        if (layout === 'all_horizontal') {
            d.displayDiv.style.float = 'left';
            d.titleDiv.style.float = 'left';
            d.titleDiv.style['margin-right'] = '6px';
            d.contentDiv.style.float = 'right';
            if (!lastDisplay) {
                d.displayDiv.style['margin-right'] = '10px';
            }
            return true;
        }
        return false;
    }
1163818
def adjustStyleSheet( self ):
        
        radius  = self.cornerRadius()
        icon    = self.icon()
        
        if not self.objectName():
            self.setStyleSheet('')
        elif not (radius or icon):
            self.setStyleSheet('')
        else:
            palette = self.palette()
            
            options = {}
            options['corner_radius']    = radius
            options['padding']          = 5
            options['objectName']       = self.objectName()
            
            if icon and not icon.isNull():
                options['padding'] += self.iconSize().width() + 2
            
            self.setStyleSheet(LINEEDIT_STYLE % options)
970867
function (x1, y1, w, h, color, c)
    {
        _c = c || _c
        if (color)
        {
            _c.fillStyle = color
        }
        box(x1 * _scale, y1 * _scale, w * _scale, h * _scale)
    }
221607
function fillRemainingHolesAndMinimizeStyles(messages, i) {
  var html = messages[i].html;
  var frameHoles = messages[i].frameHoles;
  for (var index in frameHoles) {
    if (frameHoles.hasOwnProperty(index)) {
      var frameIndex = frameHoles[index];
      for (var j = 0; j < messages.length; j++) {
        if (messages[j].frameIndex == frameIndex) {
          fillRemainingHolesAndMinimizeStyles(messages, j);
          html[index] = messages[j].html.join('');
        }
      }
    }
  }
  minimizeStyles(messages[i]);
}
1368109
def setContentsMargins(self, left, top, right, bottom):
        
        self._margins   = (left, top, right, bottom)
        self.adjustTitleFont()
723198
private void adjustVisibleColumns() {

        if (m_table.isColumnCollapsingAllowed()) {
            if ((m_model.hasDefaultValues()) || m_model.getBundleType().equals(BundleType.DESCRIPTOR)) {
                m_table.setColumnCollapsed(TableProperty.DEFAULT, false);
            } else {
                m_table.setColumnCollapsed(TableProperty.DEFAULT, true);
            }

            if (((m_model.getEditMode().equals(EditMode.MASTER) || m_model.hasDescriptionValues()))
                || m_model.getBundleType().equals(BundleType.DESCRIPTOR)) {
                m_table.setColumnCollapsed(TableProperty.DESCRIPTION, false);
            } else {
                m_table.setColumnCollapsed(TableProperty.DESCRIPTION, true);
            }
        }
    }
786826
function expandMarginSetting(value) {
			if (typeof value === "number") {
				value = [value];
			}

			if (!Array.isArray(value)) {
				console.log("Margin only takes an integer or an array of integers");
				value = [0];
			}

			switch(value.length) {
			case 1:
				return [value[0], value[0], value[0], value[0]];
			case 2:
				return [value[0], value[1], value[0], value[1]];
			case 3:
				return [value[0], value[1], value[2], value[1]];
			case 4:
				return value;
			default:
				return value.slice(0, 4);
			}
		}
261308
protected function setMargins()
    {
        // prepare the margins
        $this->_margeLeft   = $this->_defaultLeft   + (isset($this->_background['left'])   ? $this->_background['left']   : 0);
        $this->_margeRight  = $this->_defaultRight  + (isset($this->_background['right'])  ? $this->_background['right']  : 0);
        $this->_margeTop    = $this->_defaultTop    + (isset($this->_background['top'])    ? $this->_background['top']    : 0);
        $this->_margeBottom = $this->_defaultBottom + (isset($this->_background['bottom']) ? $this->_background['bottom'] : 0);

        // set the PDF margins
        $this->pdf->SetMargins($this->_margeLeft, $this->_margeTop, $this->_margeRight);
        $this->pdf->SetAutoPageBreak(false, $this->_margeBottom);

        // set the float Margins
        $this->_pageMarges = array();
        if ($this->_isInParagraph !== false) {
            $this->_pageMarges[floor($this->_margeTop*100)] = array($this->_isInParagraph[0], $this->pdf->getW()-$this->_isInParagraph[1]);
        } else {
            $this->_pageMarges[floor($this->_margeTop*100)] = array($this->_margeLeft, $this->pdf->getW()-$this->_margeRight);
        }
    }
1100406
def normalize_layout(layout, min_percentile=1, max_percentile=99, relative_margin=0.1):
    """"""

    # compute percentiles
    mins = np.percentile(layout, min_percentile, axis=(0))
    maxs = np.percentile(layout, max_percentile, axis=(0))

    # add margins
    mins -= relative_margin * (maxs - mins)
    maxs += relative_margin * (maxs - mins)

    # `clip` broadcasts, `[None]`s added only for readability
    clipped = np.clip(layout, mins, maxs)

    # embed within [0,1] along both axes
    clipped -= clipped.min(axis=0)
    clipped /= clipped.max(axis=0)

    return clipped