<commit_before>package org.basex.gui.view.map;

import java.util.ArrayList;

/**
 * StripLayout Algorithm.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-09, ISC License
 * @author <NAME>
 */
public class StripAlgo extends MapAlgo{
  @Override
  public ArrayList<MapRect> calcMap(final MapRect r, final MapList ml, 
      final int ns, final int ne, final int l) {
    // stores all calculated rectangles
    final ArrayList<MapRect> rects = new ArrayList<MapRect>();
    
    // node iterator
    int ni = ns;
    // first node of current row
    int start = ns;

    // setting initial proportions
    final double xx = r.x;
    double yy = r.y;
    final double ww = r.w;
    double hh = r.h;

    ArrayList<MapRect> row = new ArrayList<MapRect>();
    int height = 0;
    double weight = 0;
    double sumweight = 1;
    
    while(ni <= ne) {
      weight += ml.weight[ni];
      height = (int) (weight / sumweight * hh);
      height = height > 0 || yy + height > hh ? height : 1;
      
      final ArrayList<MapRect> tmp = new ArrayList<MapRect>();

      double x = xx;
      for(int i = start; i <= ni; i++) {
        int w = i == ni ? (int) (xx + ww - x) :
          (int) (ml.weight[i] / weight * ww);
        w = w > 0 || x + w > ww ? w : 1;
        if(x + w <= xx + ww) tmp.add(new MapRect((int) x, (int) yy, w, height,
            ml.list[i], l));
        x += w;
      }

      // if ar has increased discard tmp and add row
      if(lineRatio(tmp) > lineRatio(row)) {
        // add rects of row to solution
        rects.addAll(row);
        // preparing next line
        hh -= row.get(0).h;
        yy += row.get(0).h;
        tmp.clear();
        row.clear();
        start = ni;
        sumweight -= weight - ml.weight[ni];<commit_msg>bugfix<commit_after>package org.basex.gui.view.map;

import java.util.ArrayList;

/**
 * StripLayout Algorithm.
 *
 * @author Workgroup DBIS, University of Konstanz 2005-09, ISC License
 * @author <NAME>
 */
public class StripAlgo extends MapAlgo{
  @Override
  public ArrayList<MapRect> calcMap(final MapRect r, final MapList ml, 
      final int ns, final int ne, final int l) {
    // stores all calculated rectangles
    final ArrayList<MapRect> rects = new ArrayList<MapRect>();
    
    // node iterator
    int ni = ns;
    // first node of current row
    int start = ns;

    // setting initial proportions
    final double xx = r.x;
    double yy = r.y;
    final double ww = r.w;
    double hh = r.h;

    ArrayList<MapRect> row = new ArrayList<MapRect>();
    int height = 0;
    double weight = 0;
    double sumweight = 1;
    
    while(ni <= ne) {
      weight += ml.weight[ni];
      height = (int) (weight / sumweight * hh);
      height = height > 0 ? height : 1;
      
      final ArrayList<MapRect> tmp = new ArrayList<MapRect>();

      double x = xx;
      for(int i = start; i <= ni; i++) {
        int w = i == ni ? (int) (xx + ww - x) :
          (int) (ml.weight[i] / weight * ww);
        w = w > 0 ? w : 1;
        if(x + w <= xx + ww) tmp.add(new MapRect((int) x, (int) yy, w, height,
            ml.list[i], l));
        x += w;
      }

      // if ar has increased discard tmp and add row
      if(lineRatio(tmp) > lineRatio(row)) {
        // add rects of row to solution
        rects.addAll(row);
        // preparing next line
        hh -= row.get(0).h;
        yy += row.get(0).h;
        tmp.clear();
        row.clear();
        start = ni;
        sumweight -= weight - ml.weight[ni];
{'fraction_non_alphanumeric': 0.13505007153075824, 'fraction_numerical': 0.008583690987124463, 'mean_word_length': 2.0008583690987125, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7577340', 'n_tokens_mistral': 1190, 'n_tokens_neox': 1142, 'n_words': 373}