@Override public void applyToAttributedString(AttributedString str, Font normal, Font italic) { Image symbolImage = ManaSymbols.getSizedManaSymbol(symbol.replace("/", ""), normal.getSize()); if (symbolImage != null) { ImageGraphicAttribute imgAttr = new ImageGraphicAttribute(symbolImage, GraphicAttribute.BOTTOM_ALIGNMENT); str.addAttribute(TextAttribute.CHAR_REPLACEMENT, imgAttr, location, location + 1); } } }
private void write(ImageGraphicAttribute iga) { // ImageGraphicAttribute has no getImage() so // it can't be fully supported imports.add("java.awt.font.ImageGraphicAttribute"); out.print("new ImageGraphicAttribute("); write(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)); out.print("/* ImageGraphicAttribute.getImage() not supported */"); out.print(", "); out.print(iga.getAlignment()); out.print(", "); out.print(- iga.getBounds().getX()); out.print(", "); out.print(- iga.getBounds().getY()); out.print(")"); }
private Map<Attribute, Object> computeImageStyle( final StyleSheet layoutContext, final RenderableReplacedContentBox content ) { final Image image = imageProducer.createImagePlaceholder( content ); ImageGraphicAttribute iga = new ImageGraphicAttribute( image, GraphicAttribute.BOTTOM_ALIGNMENT ); Map<Attribute, Object> attrs = computeStyle( layoutContext ); attrs.put( TextAttribute.CHAR_REPLACEMENT, iga ); return attrs; }