public final void testGetJustificationInfo() { iga = new ImageGraphicAttribute(img, alignment); float advance = iga.getAdvance(); GlyphJustificationInfo gji = new GlyphJustificationInfo( advance, false, GlyphJustificationInfo.PRIORITY_INTERCHAR, advance / 3, advance / 3, false, GlyphJustificationInfo.PRIORITY_WHITESPACE, 0, 0); equalsGlyphJustificationInfo(gji, iga.getJustificationInfo()); }
public static AttributedString textIconReplace(final String text) { final String compacted = text.replaceAll("\\{[^}]+}", "M"); final AttributedString attrString = new AttributedString(compacted); for (int i = 0, j = 0; i < text.length(); i++, j++) { char c = text.charAt(i); if (c == '{') { final int endSymbol = text.indexOf('}', i); // get mana-string, substring returns at -1 value String iconString = text.substring(i, endSymbol + 1); // get related Icon as Image Image iconImage = MagicImages.getIcon(iconString).getImage(); // define replacement icon ImageGraphicAttribute icon = new ImageGraphicAttribute(iconImage, GraphicAttribute.BOTTOM_ALIGNMENT); // replace M with icon attrString.addAttribute( TextAttribute.CHAR_REPLACEMENT, icon, j, j + 1 ); // advance i to the end of symbol i = endSymbol; } } return attrString; }
public final void testEqualsImageGraphicAttribute() { iga = new ImageGraphicAttribute(img, alignment); ImageGraphicAttribute iga1 = new ImageGraphicAttribute(img, alignment); assertEquals(iga, iga1); }
public final void testEqualsObject() { iga = new ImageGraphicAttribute(img, alignment); ImageGraphicAttribute iga1 = new ImageGraphicAttribute(img, alignment); assertEquals(iga, iga1); }
public final void testGetAlignment() { iga = new ImageGraphicAttribute(img, alignment); assertEquals(alignment, iga.getAlignment()); }