Archiwum kategorii 'Krótkie'

Nov 27 2008

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

Napisał(a) Grzegorz w kategorii English, Informatyka, Krótkie, Porady

Google wasn’t awfully helpful while I was searching for solution to word wrapping a text when drawing 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;
            }
        }
    }

Brak komentarzy

Nov 07 2008

Uwaga karmiące mamy!

Napisał(a) Grzegorz w kategorii Humor, Krótkie

Szczeciński sąd zakazał pokazywania piersi dzieciom w związku z czym należy je teraz karmić butelką lub ostatecznie z zawiązanymi oczami.

Brak komentarzy

Sep 02 2008

[en] NetBeans 6.5 and JiBX problems solved

Napisał(a) Grzegorz w kategorii English, Informatyka, Krótkie, Porady

After upgrading NetBeans to 6.5 the -post-compile task I added so JiBX bindings are compiled stopped working for me throwing an exception about bindings not found at runtime.

The solution to this is to disable “Compile on Save” feature in project properties.

Brak komentarzy

Dec 14 2007

Access database (mdb file), format() function and ODBC/PHP

Napisał(a) Grzegorz w kategorii English, Informatyka, Krótkie, Porady

Can You tell a difference between

SELECT *, format(Data_ur, "yyyy-mm-dd") AS Datur FROM Czlonkowie

and

SELECT *, format(Data_ur, 'yyyy-mm-dd') AS Datur FROM Czlonkowie

?

It turns out that when using ODBC to connect to Microsoft Access database (in an mdb file), one has to use single quotes when writing function parameters. The first statement runs fine from the Access itself, but when called through the ODBC (for instance when using PHP and PDO) it returns empty set (it doesn’t even throw an exception).

The second statement (with single quotes) runs fine through ODBC. Worth remembering.

Brak komentarzy

Dec 03 2007

59%

Napisał(a) Grzegorz w kategorii Humor, Informatyka, Krótkie

O cholera :)

Brak komentarzy

« Poprzednie - Następne »