logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/icons ChainsawIcons.java
Date Wed, 21 May 2003 23:23:22 GMT
psmith      2003/05/21 16:23:22

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
               src/java/org/apache/log4j/chainsaw/icons ChainsawIcons.java
  Added:       src/java/org/apache/log4j/chainsaw ChainsawSplash.java
  Log:
  added a _very_ basic splash screen.
  
  Revision  Changes    Path
  1.69      +36 -17    jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- LogUI.java	21 May 2003 03:33:16 -0000	1.68
  +++ LogUI.java	21 May 2003 23:23:22 -0000	1.69
  @@ -49,19 +49,6 @@
   
   package org.apache.log4j.chainsaw;
   
  -import org.apache.log4j.Level;
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Priority;
  -import org.apache.log4j.UtilLoggingLevel;
  -import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  -import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.ProfileManager;
  -import org.apache.log4j.chainsaw.prefs.Profileable;
  -import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  -import org.apache.log4j.chainsaw.prefs.SettingsListener;
  -import org.apache.log4j.chainsaw.prefs.SettingsManager;
  -import org.apache.log4j.helpers.LogLog;
  -
   import java.awt.BorderLayout;
   import java.awt.Component;
   import java.awt.Dimension;
  @@ -69,6 +56,7 @@
   import java.awt.FlowLayout;
   import java.awt.Font;
   import java.awt.Point;
  +import java.awt.Toolkit;
   import java.awt.event.ActionEvent;
   import java.awt.event.ActionListener;
   import java.awt.event.InputEvent;
  @@ -79,16 +67,13 @@
   import java.awt.event.MouseMotionAdapter;
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
  -
   import java.beans.PropertyChangeEvent;
   import java.beans.PropertyChangeListener;
  -
   import java.io.BufferedInputStream;
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.ObjectInputStream;
  -
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.HashSet;
  @@ -126,7 +111,6 @@
   import javax.swing.ListSelectionModel;
   import javax.swing.SwingUtilities;
   import javax.swing.UIManager;
  -import javax.swing.UnsupportedLookAndFeelException;
   import javax.swing.event.DocumentEvent;
   import javax.swing.event.DocumentListener;
   import javax.swing.event.ListSelectionEvent;
  @@ -135,6 +119,19 @@
   import javax.swing.table.TableColumnModel;
   import javax.swing.table.TableModel;
   
  +import org.apache.log4j.Level;
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Priority;
  +import org.apache.log4j.UtilLoggingLevel;
  +import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  +import org.apache.log4j.chainsaw.prefs.LoadSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.ProfileManager;
  +import org.apache.log4j.chainsaw.prefs.Profileable;
  +import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
  +import org.apache.log4j.chainsaw.prefs.SettingsListener;
  +import org.apache.log4j.chainsaw.prefs.SettingsManager;
  +import org.apache.log4j.helpers.LogLog;
  +
   
   /**
    * The main entry point for Chainsaw, this class represents the first frame
  @@ -155,6 +152,7 @@
     private static final String TABLE_COLUMN_WIDTHS = "table.columns.widths";
     private static final String LOOK_AND_FEEL = "LookAndFeel";
     private static final String STATUS_BAR = "StatusBar";
  +  private static ChainsawSplash splash = null;
     ChainsawTabbledPane tabbedPane;
     JToolBar toolbar;
     private final ChainsawStatusBar statusBar = new ChainsawStatusBar();
  @@ -194,12 +192,31 @@
       }
     }
   
  +  private static final void showSplash() {
  +    splash = new ChainsawSplash();
  +
  +    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  +    splash.setLocation(
  +      (screenSize.width / 2) - (splash.getWidth() / 2),
  +      (screenSize.height / 2) - (splash.getHeight() / 2));
  +
  +    splash.setVisible(true);
  +  }
  +
  +  private static final void removeSplash() {
  +    splash.setVisible(false);
  +
  +    splash.dispose();
  +  }
  +
     /**
      * Starts Chainsaw by attaching a new instance to the Log4J
      * main root Logger via a ChainsawAppender, and activates itself
      * @param args
      */
     public static void main(String[] args) {
  +    showSplash();
  +
       try {
         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
       } catch (Exception e) {
  @@ -433,6 +450,8 @@
       sm.loadSettings();
   
       setVisible(true);
  +
  +    removeSplash();
   
       synchronized (initializationLock) {
         isGUIFullyInitialized = true;
  
  
  
  1.1                  jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawSplash.java
  
  Index: ChainsawSplash.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *    this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *    this list of conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *    include  the following  acknowledgment:  "This product includes  software
   *    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *    Alternately, this  acknowledgment may  appear in the software itself,  if
   *    and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *    endorse  or promote  products derived  from this  software without  prior
   *    written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *    "Apache" appear  in their name,  without prior written permission  of the
   *    Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see <http://www.apache.org/>.
   *
   */
  
  /*
   * @author Paul Smith <psmith@apache.org>
   *
  */
  package org.apache.log4j.chainsaw;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Container;
  import java.awt.Font;
  import java.awt.GraphicsEnvironment;
  import java.util.HashSet;
  import java.util.Set;
  
  import javax.swing.BorderFactory;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JWindow;
  
  import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  
  
  /**
   * A simple splash screen to be used at startup, while everything get's initialized.
   * @author Paul Smith <psmith@apache.org>
   *
   */
  class ChainsawSplash extends JWindow {
    ChainsawSplash() {
      super();
  
      Container container = getContentPane();
      JPanel panel = new JPanel(new BorderLayout());
      JLabel logo = new JLabel(ChainsawIcons.ICON_LOG4J);
  
      JLabel text = new JLabel("Chainsaw v2", JLabel.CENTER);
      Font textFont = null;
      String[] preferredFontNames =
        new String[] { "Arial", "Helvetica", "SansSerif" };
  
      Set availableFontNames = new HashSet();
      Font[] allFonts =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
  
      for (int i = 0; i < allFonts.length; i++) {
        availableFontNames.add(allFonts[i].getName());
      }
  
      for (int i = 0; i < preferredFontNames.length; i++) {
        if (availableFontNames.contains(preferredFontNames[i])) {
          textFont = new Font(preferredFontNames[i], Font.PLAIN, 12);
  
          System.out.println("Using font=" + textFont.getName());
  
          break;
        }
      }
  
      if (textFont == null) {
        System.out.println("Using basic font");
        textFont = text.getFont();
      }
  
      text.setFont(textFont.deriveFont(16f).deriveFont(Font.BOLD));
      text.setBackground(Color.white);
      text.setForeground(Color.black);
      text.setBorder(BorderFactory.createLoweredBevelBorder());
      panel.add(logo, BorderLayout.CENTER);
      panel.add(text, BorderLayout.SOUTH);
      panel.setBorder(BorderFactory.createLineBorder(Color.black, 1));
  
      container.add(panel);
      pack();
    }
  }
  
  
  
  1.13      +4 -0      jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/icons/ChainsawIcons.java
  
  Index: ChainsawIcons.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/icons/ChainsawIcons.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ChainsawIcons.java	21 May 2003 03:30:01 -0000	1.12
  +++ ChainsawIcons.java	21 May 2003 23:23:22 -0000	1.13
  @@ -111,6 +111,10 @@
     public static final URL UNDOCKED_ICON =
       ChainsawIcons.class.getClassLoader().getResource(
         BASE_ICON_PATH + "ZoomIn16.gif");
  +  public static final ImageIcon ICON_LOG4J =
  +    new ImageIcon(
  +      ChainsawIcons.class.getClassLoader().getResource(
  +        "org/apache/log4j/chainsaw/logo.jpg"));
   
     //	TODO give appropriate Credit, http://members.aol.com/gx0vzs/radiotower.html
     //  public static final URL ANIM_RADIO_TOWER = ChainsawIcons.class.getClassLoader().getResource(BASE_ICON_PATH
+ "anim_radiotower.gif");
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message