List of usage examples for org.apache.commons.lang.math NumberUtils max
public static float max(float a, float b, float c)
Gets the maximum of three float values.
If any value is NaN, NaN is returned.
From source file:com.livinglogic.ul4.Color.java
public Vector<Double> hls() { int maxc = NumberUtils.max((int) r, (int) g, (int) b); int minc = NumberUtils.min((int) r, (int) g, (int) b); double dmaxc = maxc / 255.; double dminc = minc / 255.; double l = (dminc + dmaxc) / 2.0; if (minc == maxc) { Vector retVal = new Vector(3); retVal.add(new Double(0.0)); retVal.add(new Double(l)); retVal.add(new Double(0.0)); return retVal; }// ww w .j av a2 s . c o m double s = l <= 0.5 ? (dmaxc - dminc) / (dmaxc + dminc) : (dmaxc - dminc) / (2.0 - dmaxc - dminc); double rc = (dmaxc - r / 255.) / (dmaxc - dminc); double gc = (dmaxc - g / 255.) / (dmaxc - dminc); double bc = (dmaxc - b / 255.) / (dmaxc - dminc); double h; if (r == maxc) h = bc - gc; else if (g == maxc) h = 2.0 + rc - bc; else h = 4.0 + gc - rc; h = (h / 6.0) % 1.0; Vector retVal = new Vector(3); retVal.add(new Double(h)); retVal.add(new Double(l)); retVal.add(new Double(s)); return retVal; }
From source file:com.livinglogic.ul4.Color.java
public Vector<Double> hsv() { int maxc = NumberUtils.max((int) r, (int) g, (int) b); int minc = NumberUtils.min((int) r, (int) g, (int) b); double dmaxc = maxc / 255.; double dminc = minc / 255.; double v = dmaxc; if (minc == maxc) { Vector retVal = new Vector(3); retVal.add(0.0d);//from ww w .j av a 2 s . c om retVal.add(0.0d); retVal.add(v); return retVal; } double s = (dmaxc - dminc) / dmaxc; double rc = (dmaxc - r / 255.) / (dmaxc - dminc); double gc = (dmaxc - g / 255.) / (dmaxc - dminc); double bc = (dmaxc - b / 255.) / (dmaxc - dminc); double h; if (r == maxc) h = bc - gc; else if (g == maxc) h = 2.0 + rc - bc; else h = 4.0 + gc - rc; h = (h / 6.0) % 1.0; Vector retVal = new Vector(3); retVal.add(h); retVal.add(s); retVal.add(v); return retVal; }
From source file:com.livinglogic.ul4.Color.java
public double lum() { int maxc = NumberUtils.max((int) r, (int) g, (int) b); int minc = NumberUtils.min((int) r, (int) g, (int) b); double dmaxc = maxc / 255.; double dminc = minc / 255.; return (dminc + dmaxc) / 2.0; }
From source file:com.livinglogic.ul4.Color.java
public Color withlum(double lum) { int maxc = NumberUtils.max((int) r, (int) g, (int) b); int minc = NumberUtils.min((int) r, (int) g, (int) b); double dmaxc = maxc / 255.; double dminc = minc / 255.; double l = (dminc + dmaxc) / 2.0; if (minc == maxc) return fromhls(0., lum, 0., a); double s = l <= 0.5 ? (dmaxc - dminc) / (dmaxc + dminc) : (dmaxc - dminc) / (2.0 - dmaxc - dminc); double rc = (dmaxc - r / 255.) / (dmaxc - dminc); double gc = (dmaxc - g / 255.) / (dmaxc - dminc); double bc = (dmaxc - b / 255.) / (dmaxc - dminc); double h;//from ww w .java 2 s .co m if (r == maxc) h = bc - gc; else if (g == maxc) h = 2.0 + rc - bc; else h = 4.0 + gc - rc; h = (h / 6.0) % 1.0; return fromhls(h, lum, s, a); }
From source file:org.hydracache.data.partitioning.ConsistentHashNodePartitionTest.java
private void assertUniformedDistribution(final int sampleSize, final ServerNode A, final ServerNode B, final ServerNode C, final HashMap<ServerNode, Integer> counterMap) { final int maxCounter = NumberUtils.max(counterMap.get(A), counterMap.get(B), counterMap.get(C)); final int minCounter = NumberUtils.min(counterMap.get(A), counterMap.get(B), counterMap.get(C)); final int counterDifference = maxCounter - minCounter; assertTrue("Distribution difference is greater than 20%", counterDifference < (sampleSize * 0.20)); }
From source file:org.jlibrary.client.ui.editor.relations.figure.RelationFigure.java
/** * @param document//from w w w . j a v a 2 s . c o m */ private void computeWidth(Repository repository, Document document) { int length1 = repository.getName().length(); int length2 = document.getMetaData().getTitle().length(); int length3 = sdf.format(document.getDate()).length(); int max = NumberUtils.max(length1, length2, length3); hintWidth = max * 10 + 10; }
From source file:sernet.verinice.rcp.RiskAnalysisDecorator.java
private int getRiskLevelForAsset(CnATreeElement element) throws NumberFormatException { Entity treeElementEntity = element.getEntity(); try {/*from w ww. j ava 2 s . co m*/ int riskValueConfidentiality = Integer.parseInt(treeElementEntity.getSimpleValue("asset_riskvalue_c")); int riskValueIntegrity = Integer.parseInt(treeElementEntity.getSimpleValue("asset_riskvalue_i")); int riskValueAvailability = Integer.parseInt(treeElementEntity.getSimpleValue("asset_riskvalue_a")); // Possible range is 0..8 int riskValueMax = NumberUtils.max(riskValueConfidentiality, riskValueIntegrity, riskValueAvailability); return getRiskLevelForAssetOrIncidentScenario(riskValueMax); } catch (NumberFormatException e) { throw e; } }