<commit_before>//-----------------------------------------------------------------------//
//                                                                       //
//                        V e r t i c a l A r e a                        //
//                                                                       //
//  Copyright (C) <NAME> 2000-2005. All rights reserved.          //
//  This software is released under the terms of the GNU General Public  //
//  License. Please contact the author at <EMAIL>      //
//  to report bugs & suggestions.                                        //
//-----------------------------------------------------------------------//

package omr.sheet;

import omr.constant.Constant;
import omr.constant.ConstantSet;
import omr.glyph.GlyphLag;
import omr.stick.Stick;
import omr.stick.StickArea;
import omr.util.Logger;

import java.util.Collections;
import java.util.Comparator;

/**
 * Class <code>VerticalArea</code> processes a vertical lag to extract
 * vertical stick as potential candidates for bars, stems, ...
 * <p/>
 * <p/>
 * Input is a vertical lag. </p>
 * <p/>
 * <p/>
 * Output is a list of vertical sticks that represent good candidates. </p>
 *
 * @author <NAME>
 * @version $Id$
 */
public class VerticalArea
    extends StickArea
{
    //~ Static variables/initializers -------------------------------------

    // Class usual stuff
    private static final Constants constants = new Constants();
    private static final Logger logger = Logger.getLogger(VerticalArea.class);

    //~ Constructors ------------------------------------------------------

    //--------------//
    // VerticalArea //
    //--------------//

    /**
     * Build a family of vertical sticks, that will later be checked for
     * finer recognition
     *
     * @param sheet the sheet to process
     * @param vLag  the vertical lag from which bar sticks are built
     *
     * @throws omr.ProcessingException raised when step processing must
     *                                 stop, due to encountered error
     */
    public VerticalArea (Sheet sheet,
                         GlyphLag vLag,
                         int maxThickness)
            throws omr.ProcessingException
    {
        if (logger.isDebugEnabled()) {
            logger.debug("maxThickness=" + maxThickness);
        }

        // Retrieve the stick(s)
        Scale scale = sheet.getScale();
        initialize(vLag,
                   null,
                   new Source(vLag.getVertices()), // source for adequate sections
                   scale.fracToPixels(constants.coreSectionLength), // minCoreLength
                   constants.maxAdjacency.getValue(), // maxAdjacency
                   maxThickness, // maxThickness
                   constants.maxSlope.getValue(), // maxSlope
                   false); // longAlignment

        // Merge aligned verticals
        merge(scale.fracToPixels(constants.maxDeltaCoord),
              scale.fracToPixels(constants.maxDeltaPos),
              constants.maxDeltaSlope.getValue());

        // Sort sticks found
        Collections.sort(sticks,
                         new Comparator<Stick>()
                         {
                             public int compare (Stick s1,
                                                 Stick s2)
                             {
                                 return s1.getId() - s2.getId();
                             }
                         });

        if (logger.isDebugEnabled()) {
            logger.debug("End of scanning Vertical Area, found "
                         + sticks.size() + " stick(s)");
        }
    }

    //~ Classes -----------------------------------------------------------
<commit_msg>Use of a provided section predicate, in building the stick area<commit_after>//-----------------------------------------------------------------------//
//                                                                       //
//                        V e r t i c a l A r e a                        //
//                                                                       //
//  Copyright (C) <NAME> 2000-2005. All rights reserved.          //
//  This software is released under the terms of the GNU General Public  //
//  License. Please contact the author at <EMAIL>      //
//  to report bugs & suggestions.                                        //
//-----------------------------------------------------------------------//

package omr.sheet;

import omr.constant.Constant;
import omr.constant.ConstantSet;
import omr.glyph.GlyphLag;
import omr.stick.Stick;
import omr.stick.StickArea;
import omr.stick.StickSection;
import omr.util.Logger;
import omr.util.Predicate;

import java.util.Collections;
import java.util.Comparator;

/**
 * Class <code>VerticalArea</code> processes a vertical lag to extract
 * vertical stick as potential candidates for bars, stems, ...
 *
 * <p>Input is a vertical lag.</p>
 *
 * <p>Output is a list of vertical sticks that represent good
 * candidates.</p>
 *
 * @author <NAME>
 * @version $Id$
 */
public class VerticalArea
    extends StickArea
{
    //~ Static variables/initializers -------------------------------------

    // Class usual stuff
    private static final Constants constants = new Constants();
    private static final Logger logger = Logger.getLogger(VerticalArea.class);

    //~ Constructors ------------------------------------------------------

    //--------------//
    // VerticalArea //
    //--------------//
    /**
     * Build a family of vertical sticks, that will later be checked for
     * finer recognition, with default section predicate
     *
     * @param sheet the sheet to process
     * @param vLag  the vertical lag from which bar sticks are built
     * @param maxThickness max value for vertical stick thickness
     * @exception omr.ProcessingException raised when step processing must
     *                                 stop, due to encountered error
     */
    public VerticalArea (Sheet                   sheet,
                         GlyphLag                vLag,
                         int                     maxThickness)
            throws omr.ProcessingException
    {
        this (sheet, vLag, new SectionPredicate(), maxThickness);
    }

    //--------------//
    // VerticalArea //
    //--------------//
    /**
     * Build a family of vertical sticks, that will later be checked for
     * finer recognition
     *
     * @param sheet the sheet to process
     * @param vLag  the vertical lag from which bar sticks are built
     * @param predicate a specific predicate for sections to consider
     * @param maxThickness max value for vertical stick thickness
     * @exception omr.ProcessingException raised when step processing must
     *                                 stop, due to encountered error
     */
    public VerticalArea (Sheet            sheet,
                         GlyphLag         vLag,
                         SectionPredicate predicate,
                         int              maxThickness)
            throws omr.ProcessingException
    {
        if (logger.isDebugEnabled()) {
            logger.debug("maxThickness=" + maxThickness);
        }

        // Retrieve the stick(s)
        Scale scale = sheet.getScale();
        initialize(vLag,
                   null,
                   new Source(vLag.getVertices(),
                              predicate), // source for adequate sections
                   scale.fracToPixels(constants.coreSectionLength), // minCoreLength
                   constants.maxAdjacency.getValue(), // maxAdjacency
                   maxThickness, // maxThickness
                   constants.maxSlope.getValue(), // maxSlope
                   false); // longAlignment

        // Merge aligned verticals
        merge(scale.fracToPixels(constants.maxDeltaCoord),
              scale.fracToPixels(constants.maxDeltaPos),
              constants.maxDeltaSlope.getValue());

        // Sort sticks found
        Collections.sort(sticks,
                         new Comparator<Stick>()
                         {
                             public int compare (Stick s1,
                                                 Stick s2)
                             {
                                 return s1.getId() - s2.getId();
                             }
                         });

        if (logger.isDebugEnabled()) {
            logger.debug("End of scanning Vertical Area, found "
                         + sticks.size() + " stick(s)");
        }
    }

    //~ Classes -----------------------------------------------------------

{'fraction_non_alphanumeric': 0.1569599815476877, 'fraction_numerical': 0.002767846845807865, 'mean_word_length': 1.1364868194136486, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5199856', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1869, 'n_words': 584}