Example usage for org.apache.commons.lang3.math NumberUtils max

List of usage examples for org.apache.commons.lang3.math NumberUtils max

Introduction

In this page you can find the example usage for org.apache.commons.lang3.math NumberUtils max.

Prototype

public static float max(final float a, final float b, final float c) 

Source Link

Document

Gets the maximum of three float values.

If any value is NaN, NaN is returned.

Usage

From source file:io.wcm.dam.assetservice.impl.AssetRequestParser.java

private static List<AssetRequest> getAssetRequestsFromUrlParams(String assetPath,
        SlingHttpServletRequest request) {
    String[] mediaFormats = ObjectUtils.defaultIfNull(RequestParam.getMultiple(request, RP_MEDIAFORMAT),
            new String[0]);
    String[] widthStrings = ObjectUtils.defaultIfNull(RequestParam.getMultiple(request, RP_WIDTH),
            new String[0]);
    String[] heightStrings = ObjectUtils.defaultIfNull(RequestParam.getMultiple(request, RP_HEIGHT),
            new String[0]);
    int maxParamIndex = NumberUtils.max(mediaFormats.length, widthStrings.length, heightStrings.length);

    List<AssetRequest> requests = new ArrayList<>();
    for (int i = 0; i < maxParamIndex; i++) {
        String mediaFormat = mediaFormats.length > i ? mediaFormats[i] : null;
        long width = widthStrings.length > i ? NumberUtils.toLong(widthStrings[i]) : 0;
        long height = heightStrings.length > i ? NumberUtils.toLong(heightStrings[i]) : 0;
        requests.add(new AssetRequest(assetPath, mediaFormat, width, height));
    }/*  w  w w.  j  av a  2  s  . c o  m*/
    return requests;
}

From source file:io.wcm.dam.assetservice.impl.AssetRequestServlet.java

private List<AssetRequest> getAssetRequests(String assetPath, SlingHttpServletRequest request) {
    String[] mediaFormats = ObjectUtils.defaultIfNull(RequestParam.getMultiple(request, RP_MEDIAFORMAT),
            new String[0]);
    String[] widthStrings = ObjectUtils.defaultIfNull(RequestParam.getMultiple(request, RP_WIDTH),
            new String[0]);
    String[] heightStrings = ObjectUtils.defaultIfNull(RequestParam.getMultiple(request, RP_HEIGHT),
            new String[0]);
    int maxParamIndex = NumberUtils.max(mediaFormats.length, widthStrings.length, heightStrings.length);

    List<AssetRequest> requests = new ArrayList<>();
    if (maxParamIndex == 0) {
        requests.add(new AssetRequest(assetPath, null, 0, 0));
    } else {/*from w w w. j  ava  2 s  .  c  o m*/
        for (int i = 0; i < maxParamIndex; i++) {
            String mediaFormat = mediaFormats.length > i ? mediaFormats[i] : null;
            long width = widthStrings.length > i ? NumberUtils.toLong(widthStrings[i]) : 0;
            long height = heightStrings.length > i ? NumberUtils.toLong(heightStrings[i]) : 0;
            requests.add(new AssetRequest(assetPath, mediaFormat, width, height));
        }
    }

    return requests;
}

From source file:com.pentaho.ctools.issues.cde.CDE394.java

/**
 * ############################### Test Case 1 ###############################
 *
 * Test Case Name:// w  w w.j  a v a  2  s .com
 *    Asserting all dots of line chart stay inside container
 *
 * Description:
 *    The test pretends validate the CDE-394 issue, so with specific conditions that used to trigger
 *    an error, the dots of the line chart are all shown inside the container.
 *
 * Steps:
 *    1. Get width of Chart
 *    2. Get "cx" for rightmost dots
 *    3. Assert "cx" are smaller than chart's width
 */
@Test
public void tc1_NewCdeDashboard_LineChartContained() {
    this.log.info("tc1_NewCdeDashboard_LineChartContained");

    /*
     * ## Step 1
     */
    //Go to Issue Sample
    driver.get(baseUrl
            + "api/repos/%3Apublic%3AIssues%3ACDE%3ACDE-394%3ACDE-394%25282%2529.wcdf/generatedContent");
    this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"));

    //Wait for menus: filemenu, viewmenu, toolsmenu AND helpmenu
    this.elemHelper.WaitForElementVisibility(driver, By.id("column1protovis"));
    WebElement element = this.elemHelper.FindElement(driver, By.xpath(
            "//div[contains(@id,'column1protovis')]/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][2]/*[local-name()='rect']"));
    assertNotNull(element);
    String widthText = element.getAttribute("width");
    double width = Double.parseDouble(widthText);

    /*
     * ## Step 2
     */
    element = this.elemHelper.FindElement(driver, By.xpath(
            "//div[contains(@id,'column1protovis')]/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g']/*[local-name()='g'][3]/*[local-name()='circle'][14]"));
    assertNotNull(element);
    String cx1Text = element.getAttribute("cx");
    double cx1 = Double.parseDouble(cx1Text);
    element = this.elemHelper.FindElement(driver, By.xpath(
            "//div[contains(@id,'column1protovis')]/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g']/*[local-name()='g'][6]/*[local-name()='circle'][14]"));
    assertNotNull(element);
    String cx2Text = element.getAttribute("cx");
    double cx2 = Double.parseDouble(cx2Text);
    element = this.elemHelper.FindElement(driver, By.xpath(
            "//div[contains(@id,'column1protovis')]/*[local-name()='svg' and namespace-uri()='http://www.w3.org/2000/svg']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g']/*[local-name()='g'][5]/*[local-name()='g']/*[local-name()='g'][9]/*[local-name()='circle'][14]"));
    assertNotNull(element);
    String cx3Text = element.getAttribute("cx");
    double cx3 = Double.parseDouble(cx3Text);

    /*
     * ## Step 3
     */
    assertEquals(width, NumberUtils.max(width, cx1, cx3), NumberUtils.max(width, cx2, cx3));
}

From source file:at.knowcenter.wag.egov.egiz.pdf.PDFPage.java

/**
 * Returns the calculated page length./*from  w w  w . j av  a2  s .com*/
 * 
 * @return the max page length value
 */
public float getMaxPageLength() {
    if (logger.isDebugEnabled()) {
        logger.debug("Determining page content length: text=" + max_character_ypos + ", image=" + max_image_ypos
                + ", path=" + maxPathRelatedYPositionFromTop);
    }
    return NumberUtils.max(max_character_ypos, max_image_ypos, maxPathRelatedYPositionFromTop);
}