Logo
Distributed Genetic Programming Framework
print print

File org.sfc.gui.Design.java

Here you can find all the information about the file org.sfc.gui.Design.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2005 Thomas Weise
 *
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2005-08-30 15:49:10
 * Original Filename: org.sfc.gui.Design.java
 * Version          : 3.0.1
 * Last modification: 2006-07-24
 *                by: Thomas Weise
 *
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */


package org.sfc.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.sfc.collections.ArrayCollection;
import org.sfc.collections.IVisitor;
import org.sfc.gui.windows.IWindow;
import org.sfc.gui.windows.Windows;
import org.sfc.utils.Typesafe;

/**
 * This static class helps you to layout your components.
 *
 * @author Thomas Weise
 */

public final  class Design
  {
/**
 * The color gold, as used in the german flag.
 */

  public  static  final Color       GOLD = new Color(255, 214, 8);

/**
 * The metal look and feel.
 */

  public  static  final LookAndFeel METAL =
  new LookAndFeel("Metal""javax.swing.plaf.metal.MetalLookAndFeel");
/**
 * The motif look and feel.
 */

  public  static  final LookAndFeel MOTIF =
  new LookAndFeel("Motif""com.sun.java.swing.plaf.motif.MotifLookAndFeel");
/**
 * The windows look and feel.
 */

  public  static  final LookAndFeel WINDOWS =
  new LookAndFeel("Windows""com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

/**
 * The system's default look&feel.
 */

  public  static  final LookAndFeel DEFAULT ;

/**
 * The list with the available look and feels.
 */

  public  static  final ArrayCollection<LookAndFeel> LOOK_AND_FEELS  ;

/**
 * The current look & feel.
 */

  private static        LookAndFeel s_current ;

  static
    {
    javax.swing.LookAndFeel l_f;
    String                  l_s;

    l_f = UIManager.getLookAndFeel();

    l_s = l_f.getClass().getCanonicalName();
    if(METAL.m_class.equals(l_s))
      {
      DEFAULT = METAL;
      }
    else
      {
      if(MOTIF.m_class.equals(l_s))
        {
        DEFAULT = MOTIF;
        }
      else
        {
        if(WINDOWS.m_class.equals(l_s))
          {
          DEFAULT = WINDOWS;
          }
        else
          {
          DEFAULT = new LookAndFeel(l_f.getName(), l_s);
          l_f     = null;
          }
        }
      }

    if(l_f != null)
      {
      LOOK_AND_FEELS = new ArrayCollection<LookAndFeel>(
                        new LookAndFeel[] {METAL, MOTIF, WINDOWS});
      }
    else
      {
      LOOK_AND_FEELS = new ArrayCollection<LookAndFeel>(
                        new LookAndFeel[] {DEFAULT, METAL, MOTIF, WINDOWS});
      }

    s_current = DEFAULT;
    }

/**
 * The default insets.
 */

  private static  final Insets  DEFAULT_INSETS = new Insets(4, 4, 4, 4);

/**
 * The top-level visitor called on look&feel change.
 */

  private static  final IVisitor<IWindow> LAFV = new IVisitor<IWindow>()
    {
    public  final boolean   visit (final IWindow p_item)
      {
      SwingUtilities.updateComponentTreeUI((Component)p_item);
      return true;
      }
    };

/**
 * The invisible constructor.
 */

  private Design  ()
    {
    Typesafe.do_not_call();
    }

/**
 * Set the gridbag-constraints of a component and add it to the specified
 * container.
 * @param p_container   The container to add the component to.
 * @param p_component   The component to be formatted.
 * @param p_x           The starting column of the component.
 * @param p_y           The starting row of the component.
 * @param p_width       The column-count of the component.
 * @param p_height      The row-count of the component.
 * @param p_factor_x    The x-grow-factor of the component.
 * @param p_factor_y    The y-grow_factor of the component.
 * @param p_anchor      The anchor of the component.
 * @param p_resize      The resize method of the component.
 * @param p_insets      The insets of the component.
 * @param p_padd_x      The x-padding of the component.
 * @param p_padd_y      The y-padding of the component.
 */

  public  static  final void  set_constraints (final  Container p_container,
                                               final  Component p_component,
                                               final  int       p_x,
                                               final  int       p_y,
                                               final  int       p_width,
                                               final  int       p_height,
                                               final  double    p_factor_x,
                                               final  double    p_factor_y,
                                               final  int       p_anchor,
                                               final  int       p_resize,
                                               final  Insets    p_insets,
                                               final  int       p_padd_x,
                                               final  int       p_padd_y)

    {
    GridBagLayout l_gbl;


    l_gbl = ((GridBagLayout)(p_container.getLayout()));
    l_gbl.setConstraints(p_component,
            new GridBagConstraints(p_x, p_y, p_width, p_height,
                                   p_factor_x, p_factor_y,
                                   p_anchor, p_resize, p_insets,
                                   p_padd_x, p_padd_y));
    p_container.add(p_component);
    }

/**
 * Set the gridbag-constraints of a component and add it to the specified
 * container.
 * @param p_container   The container to add the component to.
 * @param p_component   The component to be formatted.
 * @param p_x           The starting column of the component.
 * @param p_y           The starting row of the component.
 * @param p_width       The column-count of the component.
 * @param p_height      The row-count of the component.
 * @param p_factor_x    The x-grow-factor of the component.
 * @param p_factor_y    The y-grow_factor of the component.
 * @param p_anchor      The anchor of the component.
 * @param p_resize      The resize method of the component.
 */

  public  static  final void  set_constraints (final  Container p_container,
                                               final  Component p_component,
                                               final  int       p_x,
                                               final  int       p_y,
                                               final  int       p_width,
                                               final  int       p_height,
                                               final  double    p_factor_x,
                                               final  double    p_factor_y,
                                               final  int       p_anchor,
                                               final  int       p_resize)

    {
    set_constraints(p_container, p_component,
                    p_x, p_y, p_width, p_height,
                    p_factor_x, p_factor_y,
                    p_anchor, p_resize, DEFAULT_INSETS,
                    0, 0);
    }

/**
 * Calculate a <code>Dimension</code>-instance with maximized values.
 *
 * @param p_d The original dimension record.
 * @param p_x The minimum width.
 * @param p_y The minimum height.
 *
 * @return  The same object as <code>p_d</code> but with maximized values.
 */

  public  static  final Dimension max_dimension (final Dimension p_d,
                                                 final int       p_x,
                                                 final int       p_y)
    {
    if(p_x > p_d.width)   p_d.width  = p_x;
    if(p_y > p_d.height)  p_d.height = p_y;
    return p_d;
    }

/**
 * Set the current look&feel.
 * @param p_lf  The look&feel to set. <code>null</code> for reset to
 *              default.
 */

  public static synchronized final void set_look_and_feel (LookAndFeel p_lf)
    {
    if(p_lf == null) p_lf = DEFAULT;
    if(p_lf != s_current)
      {
      s_current = p_lf;
      try
        {
        UIManager.setLookAndFeel(p_lf.m_class);
        }
      catch(Throwable l_t)
        {
        //
        }
      
      synchronized(Windows.INSTANCE)
        {
        Windows.INSTANCE.visit(LAFV);
        }
      }
    }
  }

File Information:

file name:Design.java
package:org.sfc.gui
qualified name:org.sfc.gui.Design.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/sfc/gui/Design.java
size:9.108 KB (9327 B)
uploaded: 2018-01-07 12:03:36 GMT+0000
last update: 2006-07-24 08:45:07 GMT+0000
last access: 2018-04-26 01:52:23 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2018-01-07 12:03:34 GMT+0000 served at 2018-04-26 01:52:23 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo