001    /*
002     * AwtInfo
003     * 
004     * Copyright (c) 2001, 2002, 2003 Marco Schmidt.
005     * All rights reserved.
006     */
007    
008    package net.sourceforge.jiu.gui.awt;
009    
010    import java.awt.Dimension;
011    import java.awt.Toolkit;
012    import java.awt.image.ColorModel;
013    import net.sourceforge.jiu.apps.StringIndexConstants;
014    import net.sourceforge.jiu.apps.Strings;
015    
016    /**
017     * Retrieve some information on the current graphical environment.
018     * @author Marco Schmidt
019     * @since 0.8.0
020     */
021    public class AwtInfo
022    {
023            private AwtInfo()
024            {
025            }
026    
027            /**
028             * Returns information on the current AWT settings, regarding the current
029             * language by using a {@link Strings} resource.
030             * Right now, only returns the screen resolution.
031             * All textual information is taken from the strings argument.
032             * @param strings String resources
033             * @return AWT information
034             */
035            public static String getAwtInfo(Strings strings)
036            {
037                    Toolkit toolkit = Toolkit.getDefaultToolkit();
038                    Dimension screen = toolkit.getScreenSize();
039                    StringBuffer result = new StringBuffer();
040                    result.append(strings.get(StringIndexConstants.SCREEN_RESOLUTION) + "=" + screen.width + " x " + screen.height + "\n");
041                    ColorModel model = toolkit.getColorModel();
042                    if (model != null)
043                    {
044                            /* only in Java 1.2+
045                               result.append("# components=" + model.getNumComponents() + "\n"); */
046                            result.append("# bits per pixel=" + model.getPixelSize() + "\n");
047                    }
048                    return result.toString();
049            }
050    }