tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From og0815 <oliver.guent...@gg-net.de>
Subject Re: OpenEJB Embeeded Progress Monitor
Date Fri, 18 Nov 2011 09:09:38 GMT
Hi,

code looks like this.

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.SplashScreen;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;

public class SplashAppender extends AppenderSkeleton {

    private String s1 = "Loading ";

    private String s2 = "";

    private String s3 = "";

    private SplashScreen splash;

    private Graphics2D graphics;

    // On every call adds a point to the graphics instance
    private void renderSplashFrame() {
        int size = 35;
        if ( s1.length() > size && s2.length() > size && s3.length()
> size
); 
        else if ( s1.length() > size && s2.length() > size ) s3 += ".";
        else if ( s1.length() > size ) s2 += ".";
        else s1 += ".";
        graphics.drawString(s1, 5, 15);
        graphics.drawString(s2, 5, 30);
        graphics.drawString(s3, 5, 45);
        splash.update();
    }

    @Override
    protected void append(LoggingEvent event) {
        if ( getThreshold() != null && getThreshold().toInt() >
event.getLevel().toInt() ) return;
        if ( splash == null ) {
            splash = SplashScreen.getSplashScreen();
            if ( splash == null ) return;
        }
        if ( !splash.isVisible() ) return;
        if ( graphics == null ) {
            graphics = splash.createGraphics();
            if ( graphics == null ) return;
            graphics.setComposite(AlphaComposite.Clear);
            graphics.fillRect(0, 0, 100, 100);
            graphics.setPaintMode();
            graphics.setColor(Color.WHITE);
            graphics.setFont(new Font(Font.MONOSPACED, Font.BOLD, 12));
        }
        renderSplashFrame();
    }

    @Override
    public void close() {
        // nothing to do;
    }

    @Override
    public boolean requiresLayout() {
        return false;
    }
}


--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-Embeeded-Progress-Monitor-tp4019519p4082625.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message