.setTextSize(28f) // default size is 24 .setTextSize(32f) // default size is 24 .setTextColor(new Color(0f, 1f, 1f, 0.70f)) // cyan, with 7% opacity
@Test public void testSetTextSize() throws Exception { TextAttributes attributes = new TextAttributes(); float size = 2.5f; attributes.setTextSize(size); assertEquals(size, attributes.textSize, 0.0f); }
/** * Test identical cache keys are equal and generate identical hash codes. The {@Typeface} class setting is ignored * as the Android environment is required for non-null values. This has the effect of testing properties set to null * during equivalency testing. */ @Test public void testIdenticalWithAttributes() { // Common Text Attributes TextAttributes attrs = new TextAttributes(); attrs.setEnableOutline(true); attrs.setOutlineColor(new Color(0.5f, 0.2f, 0.3f, 1)); attrs.setOutlineWidth(15); attrs.setTextColor(new Color(1, 1, 0.2f, 1)); attrs.setTextSize(90); // Common Text String text = "Testing"; // Cache Key 1 RenderContext.TextCacheKey textCacheKeyOne = new RenderContext.TextCacheKey().set(text, attrs); // Cache Key 2 RenderContext.TextCacheKey textCacheKeyTwo = new RenderContext.TextCacheKey().set(text, attrs); assertTrue("TextCacheKey with attributes equals", textCacheKeyOne.equals(textCacheKeyTwo)); assertTrue("TextCacheKey with attributes hashcode", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); }
@Test public void testModifiedAttrs() { // Common Text Attributes TextAttributes attrs = new TextAttributes(); attrs.setEnableOutline(true); attrs.setOutlineColor(new Color(0.5f, 0.2f, 0.3f, 1)); attrs.setOutlineWidth(15); attrs.setTextColor(new Color(1, 1, 0.2f, 1)); attrs.setTextSize(90); // Common Text String text = "Testing"; // Cache Key 1 RenderContext.TextCacheKey textCacheKeyOne = new RenderContext.TextCacheKey().set(text, attrs); // Modify color property Color outlineColor = attrs.getOutlineColor().set(1, 1, 0.3f, 1); attrs.setOutlineColor(outlineColor); // Cache Key 2 RenderContext.TextCacheKey textCacheKeyTwo = new RenderContext.TextCacheKey().set(text, attrs); assertFalse("TextCacheKey modified attributes equals", textCacheKeyOne.equals(textCacheKeyTwo)); assertFalse("TextCacheKey modified attributes hashcode", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); } }
attrs.setTextSize(48); // 48 screen pixels label = new Label(new Position(38.907192, -77.036871, 0), "Washington", attrs); layer.addRenderable(label);