FontCharacteristicsUtils { static short normalizeFontWeight(short fw) { fw = (short) ((fw/100)*100); if (fw < FontWeights.THIN) return FontWeights.THIN; if (fw > FontWeights.BLACK) return FontWeights.BLACK; return fw; }    }
@Test public void testNormalizingThinFontWeight() { Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) -10000)); Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 0)); Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 50)); Assert.assertEquals(100, FontCharacteristicsUtils.normalizeFontWeight((short) 100)); }
@Test public void testNormalizingHeavyFontWeight() { Assert.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 900)); Assert.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 1600)); Assert.assertEquals(900, FontCharacteristicsUtils.normalizeFontWeight((short) 23000)); }
@Test public void testNormalizingNormalFontWeight() { Assert.assertEquals(200, FontCharacteristicsUtils.normalizeFontWeight((short) 220)); Assert.assertEquals(400, FontCharacteristicsUtils.normalizeFontWeight((short) 456)); Assert.assertEquals(500, FontCharacteristicsUtils.normalizeFontWeight((short) 550)); Assert.assertEquals(600, FontCharacteristicsUtils.normalizeFontWeight((short) 620)); Assert.assertEquals(700, FontCharacteristicsUtils.normalizeFontWeight((short) 780)); }