dostaje automatycznie „display: none” w Firefoksie?

Stra­ci­łem nad tym wię­cej cza­su niż chcę się przy­znać; mia­łem dodać mały ele­ment gra­ficz­ny o nazwie pli­ku zspon.png do stro­ny jed­ne­go z Klien­tów i jakimś cudem nie poja­wiał się on nigdy na stro­nie, a Fire­bug poka­zy­wał że ma on „display: none”, choć żad­ne­go CSSa nie przypisywałem.

Oka­za­ło się, że Adblock z fil­tra­mi Filterset.g wyci­na mi obraz­ki któ­re mają w nazwie „spon” :> Wyłą­cze­nie Adbloc­ka na czas deve­lop­men­tu to dobry pomysł, choć ja zosta­wiam włą­czo­ny — jak ktoś będzie go uży­wał to wolę zawcza­su wie­dzieć co mu znik­nie i zmie­nić nazwę pli­ku 🙂 zs-pon.png się wyświetla 😀

[en] How to word wrap text in Graphics2D.drawString in Java

Google wasn’t awful­ly help­ful whi­le I was sear­ching for solu­tion to word wrap­ping a text when dra­wing in Java, so let’s teach Google this: 😉

    private void drawStringRect(Graphics2D graphics, int x1, int y1, int x2, int y2, 
        float interline, String txt) {
        AttributedString as = new AttributedString(txt);
        as.addAttribute(TextAttribute.FOREGROUND, graphics.getPaint());
        as.addAttribute(TextAttribute.FONT, graphics.getFont());
        AttributedCharacterIterator aci = as.getIterator();
        FontRenderContext frc = new FontRenderContext(null, true, false);
        LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
        float width = x2 - x1;

        while (lbm.getPosition()  txt.length()) {
            TextLayout tl = lbm.nextLayout(width);
            y1 += tl.getAscent();
            tl.draw(graphics, x1, y1);
            y1 += tl.getDescent() + tl.getLeading() + (interline - 1.0f) * tl.getAscent();
            if (y1 > y2) {
                break;
            }
        }
    }