l2fprod-common-directorychooser-7.3

16:38:40.593 INFO  jd.cli.Main - Decompiling l2fprod-common-directorychooser-7.3.jar
package com.l2fprod.common;

import java.util.Date;

public class Version
{
  private static Date buildDate = new Date(1174140814898L);
  
  public static final Date getBuildDate()
  {
    return buildDate;
  }
  
  private static String buildTimestamp = new String("03/17/2007 03:13 PM");
  
  public static final String getBuildTimestamp()
  {
    return buildTimestamp;
  }
  
  private static String year = new String("2005-2007");
  
  public static final String getYear()
  {
    return year;
  }
  
  private static String version = new String("7.3");
  
  public static final String getVersion()
  {
    return version;
  }
  
  private static String project = new String("l2fprod-common");
  
  public static final String getProject()
  {
    return project;
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.Version
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

class ChooseDirectory$1
  implements ActionListener
{
  private final JButton val$button;
  private final ChooseDirectory this$0;
  
  ChooseDirectory$1(ChooseDirectory this$0, JButton val$button)
  {
    this.this$0 = this$0;this.val$button = val$button;
  }
  
  public void actionPerformed(ActionEvent e)
  {
    ChooseDirectory.selectDirectory(val$button, null);
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.ChooseDirectory.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import com.l2fprod.common.swing.JDirectoryChooser;
import java.io.File;
import javax.swing.filechooser.FileSystemView;

class ChooseDirectory$2
  extends JDirectoryChooser
{
  ChooseDirectory$2(FileSystemView x0)
  {
    super(x0);
  }
  
  public void rescanCurrentDirectory() {}
  
  public void setCurrentDirectory(File dir) {}
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.ChooseDirectory.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import com.l2fprod.common.swing.JDirectoryChooser;
import com.l2fprod.common.swing.LookAndFeelTweaks;
import com.l2fprod.common.swing.PercentLayout;
import com.l2fprod.common.util.ResourceManager;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.filechooser.FileSystemView;

public class ChooseDirectory
  extends JPanel
{
  public static final ResourceManager RESOURCE = ResourceManager.get(ChooseDirectory.class);
  
  public ChooseDirectory()
  {
    setLayout(new PercentLayout(1, 3));
    if (System.getProperty("javawebstart.version") != null)
    {
      JTextArea area = new JTextArea(RESOURCE.getString("message.webstart"));
      LookAndFeelTweaks.makeMultilineLabel(area);
      area.setFocusable(false);
      add(area);
    }
    JButton button = new JButton(RESOURCE.getString("selectDirectory"));
    add(button);
    button.addActionListener(new ActionListener()
    {
      private final JButton val$button;
      
      public void actionPerformed(ActionEvent e)
      {
        ChooseDirectory.selectDirectory(val$button, null);
      }
    });
  }
  
  static void selectDirectory(Component parent, String selectedFile)
  {
    JDirectoryChooser chooser;
    if (System.getProperty("javawebstart.version") != null)
    {
      JDirectoryChooser chooser = new JDirectoryChooser(new FakeFileSystemView())
      {
        public void rescanCurrentDirectory() {}
        
        public void setCurrentDirectory(File dir) {}
      };
      chooser.setShowingCreateDirectory(false);
    }
    else
    {
      chooser = new JDirectoryChooser();
      if (selectedFile != null) {
        chooser.setSelectedFile(new File(selectedFile));
      }
    }
    JTextArea accessory = new JTextArea(RESOURCE.getString("selectDirectory.message"));
    
    accessory.setLineWrap(true);
    accessory.setWrapStyleWord(true);
    accessory.setEditable(false);
    accessory.setOpaque(false);
    accessory.setFont(UIManager.getFont("Tree.font"));
    accessory.setFocusable(false);
    chooser.setAccessory(accessory);
    
    chooser.setMultiSelectionEnabled(true);
    
    int choice = chooser.showOpenDialog(parent);
    if (choice == 0)
    {
      String filenames = "";
      File[] selectedFiles = chooser.getSelectedFiles();
      int i = 0;
      for (int c = selectedFiles.length; i < c; i++) {
        filenames = filenames + "\n" + selectedFiles[i];
      }
      JOptionPane.showMessageDialog(parent, RESOURCE.getString("selectDirectory.confirm", new Object[] { filenames }));
    }
    else
    {
      JOptionPane.showMessageDialog(parent, RESOURCE.getString("selectDirectory.cancel"));
    }
  }
  
  public static void main(String[] args)
    throws Exception
  {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    if (args.length > 0) {
      selectDirectory(null, args[0]);
    } else {
      selectDirectory(null, null);
    }
    System.exit(0);
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.ChooseDirectory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import java.io.File;

class FakeFileSystemView$FakeFile
  extends File
{
  public FakeFileSystemView$FakeFile(String s)
  {
    super(s);
  }
  
  public boolean isDirectory()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.FakeFileSystemView.FakeFile
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;

public class FakeFileSystemView
  extends FileSystemView
{
  private Map files = new HashMap();
  
  public FakeFileSystemView()
  {
    files.put("desktop", new FakeFile("Desktop"));
    files.put("computer", new FakeFile("My Computer"));
    files.put("A", new FakeFile("A"));
    files.put("C", new FakeFile("C"));
    files.put("D", new FakeFile("D"));
    files.put("getFiles(My Computer)", new File[] { (File)files.get("A"), (File)files.get("C"), (File)files.get("D") });
    
    files.put("network", new FakeFile("My Network Places"));
    files.put("getRoots", new File[] { (File)files.get("desktop") });
    files.put("getFiles(Desktop)", new File[] { (File)files.get("computer"), (File)files.get("network") });
    
    FakeFile[] folders = { new FakeFile("Folder 1"), new FakeFile("Folder 2"), new FakeFile("Folder 3") };
    
    files.put("getFiles(C)", folders);
    files.put("getFiles(D)", folders);
  }
  
  public File createNewFolder(File containingDir)
  {
    return null;
  }
  
  public File createFileObject(File dir, String filename)
  {
    return super.createFileObject(dir, filename);
  }
  
  public File createFileObject(String path)
  {
    return super.createFileObject(path);
  }
  
  protected File createFileSystemRoot(File f)
  {
    return super.createFileSystemRoot(f);
  }
  
  public File getChild(File parent, String fileName)
  {
    return super.getChild(parent, fileName);
  }
  
  public File getDefaultDirectory()
  {
    return new FakeFile("Default");
  }
  
  public File[] getFiles(File dir, boolean useFileHiding)
  {
    if (dir.getName().startsWith("Folder")) {
      return new FakeFile[] { new FakeFile(dir.getName() + ".1"), new FakeFile(dir.getName() + ".2"), new FakeFile(dir.getName() + ".3") };
    }
    File[] children = (File[])files.get("getFiles(" + dir.getName() + ")");
    if (children == null) {
      return new File[0];
    }
    return children;
  }
  
  public File getHomeDirectory()
  {
    return new FakeFile("Home");
  }
  
  public File getParentDirectory(File dir)
  {
    return null;
  }
  
  public File[] getRoots()
  {
    return (File[])files.get("getRoots");
  }
  
  public String getSystemDisplayName(File f)
  {
    return f.getName();
  }
  
  public Icon getSystemIcon(File f)
  {
    return null;
  }
  
  public String getSystemTypeDescription(File f)
  {
    return "Description";
  }
  
  public boolean isComputerNode(File dir)
  {
    return files.get("computer") == dir;
  }
  
  public boolean isDrive(File dir)
  {
    return ("C".equals(dir.getName())) || ("D".equals(dir.getName()));
  }
  
  public boolean isFileSystem(File f)
  {
    return false;
  }
  
  public boolean isFileSystemRoot(File dir)
  {
    return false;
  }
  
  public boolean isFloppyDrive(File dir)
  {
    return "A".equals(dir.getName());
  }
  
  public boolean isHiddenFile(File f)
  {
    return false;
  }
  
  public boolean isParent(File folder, File file)
  {
    return false;
  }
  
  public boolean isRoot(File f)
  {
    return files.get("desktop") == f;
  }
  
  public Boolean isTraversable(File f)
  {
    return Boolean.TRUE;
  }
  
  static class FakeFile
    extends File
  {
    public FakeFile(String s)
    {
      super();
    }
    
    public boolean isDirectory()
    {
      return true;
    }
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.FakeFileSystemView
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JEditorPane;

class Main$1
  extends JEditorPane
{
  private final Main this$0;
  
  Main$1(Main this$0, String x0, String x1)
  {
    super(x0, x1);this.this$0 = this$0;
  }
  
  protected void paintComponent(Graphics g)
  {
    Graphics2D g2d = (Graphics2D)g;
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    
    super.paintComponent(g);
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.Main.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.demo;

import com.l2fprod.common.Version;
import com.l2fprod.common.swing.plaf.LookAndFeelAddons;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;

public class Main
  extends JPanel
{
  public Main()
  {
    setLayout(new BorderLayout());
    
    JTabbedPane tabs = new JTabbedPane();
    add("Center", tabs);
    
    addDemo(tabs, "JButtonBar", "ButtonBarMain");
    addDemo(tabs, "JDirectoryChooser", "ChooseDirectory");
    addDemo(tabs, "JFontChooser", "ChooseFont");
    addDemo(tabs, "JOutlookBar", "OutlookBarMain");
    addDemo(tabs, "JTaskPane", "TaskPaneMain");
    addDemo(tabs, "PropertySheet", "PropertySheetMain");
    addDemo(tabs, "JTipOfTheDay", "TOTDTest");
    try
    {
      JEditorPane pane = new JEditorPane("text/html", "<html>")
      {
        protected void paintComponent(Graphics g)
        {
          Graphics2D g2d = (Graphics2D)g;
          g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
          
          super.paintComponent(g);
        }
      };
      pane.setPage(Main.class.getResource("demo.html"));
      pane.setBackground(Color.white);
      pane.setEditable(false);
      pane.setOpaque(true);
      add("South", pane);
    }
    catch (Exception e) {}
  }
  
  void addDemo(JTabbedPane tabs, String title, String demoClass)
  {
    String prefix = "com.l2fprod.common.demo.";
    LookAndFeelAddons addon = LookAndFeelAddons.getAddon();
    try
    {
      JComponent component = (JComponent)Class.forName(prefix + demoClass).newInstance();
      
      component.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
      tabs.addTab(title, component);
    }
    catch (Exception e) {}finally
    {
      try
      {
        LookAndFeelAddons.setAddon(addon.getClass());
      }
      catch (InstantiationException e1)
      {
        e1.printStackTrace();
      }
      catch (IllegalAccessException e1)
      {
        e1.printStackTrace();
      }
    }
  }
  
  public static void main(String[] args)
    throws Exception
  {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    
    JFrame frame = new JFrame("L2FProd.com Common Components " + Version.getVersion() + " (build " + Version.getBuildTimestamp() + ")");
    
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add("Center", new Main());
    frame.setDefaultCloseOperation(3);
    frame.setSize(450, 550);
    frame.setLocation(100, 100);
    frame.setVisible(true);
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.demo.Main
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;

public final class ButtonAreaLayout
  implements LayoutManager
{
  private int gap;
  
  public ButtonAreaLayout(int gap)
  {
    this.gap = gap;
  }
  
  public void addLayoutComponent(String string, Component comp) {}
  
  public void layoutContainer(Container container)
  {
    Insets insets = container.getInsets();
    Component[] children = container.getComponents();
    
    int maxWidth = 0;
    int maxHeight = 0;
    int visibleCount = 0;
    
    int i = 0;
    for (int c = children.length; i < c; i++) {
      if (children[i].isVisible())
      {
        Dimension componentPreferredSize = children[i].getPreferredSize();
        maxWidth = Math.max(maxWidth, width);
        maxHeight = Math.max(maxHeight, height);
        visibleCount++;
      }
    }
    int usedWidth = maxWidth * visibleCount + gap * (visibleCount - 1);
    
    visibleCount = 0;
    int i = 0;
    for (int c = children.length; i < c; i++) {
      if (children[i].isVisible())
      {
        children[i].setBounds(container.getWidth() - right - usedWidth + (maxWidth + gap) * visibleCount, top, maxWidth, maxHeight);
        
        visibleCount++;
      }
    }
  }
  
  public Dimension minimumLayoutSize(Container c)
  {
    return preferredLayoutSize(c);
  }
  
  public Dimension preferredLayoutSize(Container container)
  {
    Insets insets = container.getInsets();
    Component[] children = container.getComponents();
    
    int maxWidth = 0;
    int maxHeight = 0;
    int visibleCount = 0;
    
    int i = 0;
    for (int c = children.length; i < c; i++) {
      if (children[i].isVisible())
      {
        Dimension componentPreferredSize = children[i].getPreferredSize();
        maxWidth = Math.max(maxWidth, width);
        maxHeight = Math.max(maxHeight, height);
        visibleCount++;
      }
    }
    int usedWidth = maxWidth * visibleCount + gap * (visibleCount - 1);
    
    return new Dimension(left + usedWidth + right, top + maxHeight + bottom);
  }
  
  public void removeLayoutComponent(Component c) {}
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.ButtonAreaLayout
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import com.l2fprod.common.swing.plaf.DirectoryChooserUI;
import com.l2fprod.common.swing.plaf.JDirectoryChooserAddon;
import com.l2fprod.common.swing.plaf.LookAndFeelAddons;
import java.awt.Component;
import java.awt.HeadlessException;
import java.io.File;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileSystemView;
import javax.swing.plaf.ComponentUI;

public class JDirectoryChooser
  extends JFileChooser
{
  public static final String UI_CLASS_ID = "l2fprod/DirectoryChooserUI";
  private boolean showingCreateDirectory;
  public static final String SHOWING_CREATE_DIRECTORY_CHANGED_KEY = "showingCreateDirectory";
  
  static
  {
    LookAndFeelAddons.contribute(new JDirectoryChooserAddon());
  }
  
  public JDirectoryChooser()
  {
    setShowingCreateDirectory(true);
  }
  
  public JDirectoryChooser(File currentDirectory)
  {
    super(currentDirectory);
    setShowingCreateDirectory(true);
  }
  
  public JDirectoryChooser(File currentDirectory, FileSystemView fsv)
  {
    super(currentDirectory, fsv);
    setShowingCreateDirectory(true);
  }
  
  public JDirectoryChooser(FileSystemView fsv)
  {
    super(fsv);
    setShowingCreateDirectory(true);
  }
  
  public JDirectoryChooser(String currentDirectoryPath)
  {
    super(currentDirectoryPath);
    setShowingCreateDirectory(true);
  }
  
  public JDirectoryChooser(String currentDirectoryPath, FileSystemView fsv)
  {
    super(currentDirectoryPath, fsv);
    setShowingCreateDirectory(true);
  }
  
  public void updateUI()
  {
    setUI((DirectoryChooserUI)LookAndFeelAddons.getUI(this, DirectoryChooserUI.class));
  }
  
  public void setUI(DirectoryChooserUI ui)
  {
    super.setUI((ComponentUI)ui);
  }
  
  public String getUIClassID()
  {
    return "l2fprod/DirectoryChooserUI";
  }
  
  public boolean isShowingCreateDirectory()
  {
    return showingCreateDirectory;
  }
  
  public void setShowingCreateDirectory(boolean showingCreateDirectory)
  {
    this.showingCreateDirectory = showingCreateDirectory;
    firePropertyChange("showingCreateDirectory", !showingCreateDirectory, showingCreateDirectory);
  }
  
  protected JDialog createDialog(Component parent)
    throws HeadlessException
  {
    JDialog dialog = super.createDialog(parent);
    ((JComponent)dialog.getContentPane()).setBorder(LookAndFeelTweaks.WINDOW_BORDER);
    
    return dialog;
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.JDirectoryChooser
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import java.awt.Image;
import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.MethodDescriptor;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;
import java.util.Vector;
import javax.swing.JFileChooser;

public class JDirectoryChooserBeanInfo
  extends SimpleBeanInfo
{
  protected BeanDescriptor bd = new BeanDescriptor(JDirectoryChooser.class);
  protected Image iconMono16 = loadImage("JDirectoryChooser16-mono.gif");
  protected Image iconColor16 = loadImage("JDirectoryChooser16.gif");
  protected Image iconMono32 = loadImage("JDirectoryChooser32-mono.gif");
  protected Image iconColor32 = loadImage("JDirectoryChooser32.gif");
  
  public JDirectoryChooserBeanInfo()
    throws IntrospectionException
  {
    bd.setName("JDirectoryChooser");
    
    bd.setShortDescription("JDirectoryChooser allows to select one or more directories.");
    
    BeanInfo info = Introspector.getBeanInfo(getBeanDescriptor().getBeanClass().getSuperclass());
    
    String order = info.getBeanDescriptor().getValue("propertyorder") == null ? "" : (String)info.getBeanDescriptor().getValue("propertyorder");
    
    PropertyDescriptor[] pd = getPropertyDescriptors();
    for (int i = 0; i != pd.length; i++) {
      if (order.indexOf(pd[i].getName()) == -1) {
        order = order + (order.length() == 0 ? "" : ":") + pd[i].getName();
      }
    }
    getBeanDescriptor().setValue("propertyorder", order);
  }
  
  public BeanInfo[] getAdditionalBeanInfo()
  {
    Vector bi = new Vector();
    BeanInfo[] biarr = null;
    try
    {
      for (Class cl = JDirectoryChooser.class.getSuperclass(); !cl.equals(JFileChooser.class.getSuperclass()); cl = cl.getSuperclass()) {
        bi.addElement(Introspector.getBeanInfo(cl));
      }
      biarr = new BeanInfo[bi.size()];
      bi.copyInto(biarr);
    }
    catch (Exception e) {}
    return biarr;
  }
  
  public BeanDescriptor getBeanDescriptor()
  {
    return bd;
  }
  
  public int getDefaultPropertyIndex()
  {
    String defName = "";
    if (defName.equals("")) {
      return -1;
    }
    PropertyDescriptor[] pd = getPropertyDescriptors();
    for (int i = 0; i < pd.length; i++) {
      if (pd[i].getName().equals(defName)) {
        return i;
      }
    }
    return -1;
  }
  
  public Image getIcon(int type)
  {
    if (type == 1) {
      return iconColor16;
    }
    if (type == 3) {
      return iconMono16;
    }
    if (type == 2) {
      return iconColor32;
    }
    if (type == 4) {
      return iconMono32;
    }
    return null;
  }
  
  public PropertyDescriptor[] getPropertyDescriptors()
  {
    try
    {
      Vector descriptors = new Vector();
      PropertyDescriptor descriptor = null;
      try
      {
        descriptor = new PropertyDescriptor("showingCreateDirectory", JDirectoryChooser.class);
      }
      catch (IntrospectionException e)
      {
        descriptor = new PropertyDescriptor("showingCreateDirectory", JDirectoryChooser.class, "isShowingCreateDirectory", null);
      }
      descriptor.setPreferred(true);
      descriptor.setBound(true);
      descriptors.add(descriptor);
      
      return (PropertyDescriptor[])descriptors.toArray(new PropertyDescriptor[descriptors.size()]);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }
  
  public MethodDescriptor[] getMethodDescriptors()
  {
    return new MethodDescriptor[0];
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.JDirectoryChooserBeanInfo
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.io.StringReader;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.text.JTextComponent;
import javax.swing.text.View;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;

public class LookAndFeelTweaks
{
  public static final Border PANEL_BORDER = BorderFactory.createEmptyBorder(3, 3, 3, 3);
  public static final Border WINDOW_BORDER = BorderFactory.createEmptyBorder(4, 10, 10, 10);
  public static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder();
  
  public static void tweak()
  {
    Object listFont = UIManager.get("List.font");
    UIManager.put("Table.font", listFont);
    UIManager.put("ToolTip.font", listFont);
    UIManager.put("TextField.font", listFont);
    UIManager.put("FormattedTextField.font", listFont);
    UIManager.put("Viewport.background", "Table.background");
  }
  
  public static PercentLayout createVerticalPercentLayout()
  {
    return new PercentLayout(1, 8);
  }
  
  public static PercentLayout createHorizontalPercentLayout()
  {
    return new PercentLayout(0, 8);
  }
  
  public static ButtonAreaLayout createButtonAreaLayout()
  {
    return new ButtonAreaLayout(6);
  }
  
  public static BorderLayout createBorderLayout()
  {
    return new BorderLayout(8, 8);
  }
  
  public static void setBorder(JComponent component)
  {
    if ((component instanceof JPanel)) {
      component.setBorder(PANEL_BORDER);
    }
  }
  
  public static void setBorderLayout(Container container)
  {
    container.setLayout(new BorderLayout(3, 3));
  }
  
  public static void makeBold(JComponent component)
  {
    component.setFont(component.getFont().deriveFont(1));
  }
  
  public static void makeMultilineLabel(JTextComponent area)
  {
    area.setFont(UIManager.getFont("Label.font"));
    area.setEditable(false);
    area.setOpaque(false);
    if ((area instanceof JTextArea))
    {
      ((JTextArea)area).setWrapStyleWord(true);
      ((JTextArea)area).setLineWrap(true);
    }
  }
  
  public static void htmlize(JComponent component)
  {
    htmlize(component, UIManager.getFont("Button.font"));
  }
  
  public static void htmlize(JComponent component, Font font)
  {
    String stylesheet = "body { margin-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; font-family: " + font.getName() + "; font-size: " + font.getSize() + "pt;\t}" + "a, p, li { margin-top: 0; margin-bottom: 0; margin-left: 0; margin-right: 0; font-family: " + font.getName() + "; font-size: " + font.getSize() + "pt;\t}";
    try
    {
      HTMLDocument doc = null;
      if ((component instanceof JEditorPane))
      {
        if ((((JEditorPane)component).getDocument() instanceof HTMLDocument)) {
          doc = (HTMLDocument)((JEditorPane)component).getDocument();
        }
      }
      else
      {
        View v = (View)component.getClientProperty("html");
        if ((v != null) && ((v.getDocument() instanceof HTMLDocument))) {
          doc = (HTMLDocument)v.getDocument();
        }
      }
      if (doc != null) {
        doc.getStyleSheet().loadRules(new StringReader(stylesheet), null);
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
  
  public static Border addMargin(Border border)
  {
    return new CompoundBorder(border, PANEL_BORDER);
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.LookAndFeelTweaks
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

class PercentLayout$1 {}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayout.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

class PercentLayout$Constraint
{
  protected Object value;
  
  PercentLayout$Constraint(Object x0, PercentLayout.1 x1)
  {
    this(x0);
  }
  
  private PercentLayout$Constraint(Object value)
  {
    this.value = value;
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayout.Constraint
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

class PercentLayout$NumberConstraint
  extends PercentLayout.Constraint
{
  public PercentLayout$NumberConstraint(int d)
  {
    this(new Integer(d));
  }
  
  public PercentLayout$NumberConstraint(Integer d)
  {
    super(d, null);
  }
  
  public int intValue()
  {
    return ((Integer)value).intValue();
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayout.NumberConstraint
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

class PercentLayout$PercentConstraint
  extends PercentLayout.Constraint
{
  public PercentLayout$PercentConstraint(float d)
  {
    super(new Float(d), null);
  }
  
  public float floatValue()
  {
    return ((Float)value).floatValue();
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayout.PercentConstraint
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager2;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;

public class PercentLayout
  implements LayoutManager2
{
  public static final int HORIZONTAL = 0;
  public static final int VERTICAL = 1;
  
  static class Constraint
  {
    protected Object value;
    
    Constraint(Object x0, PercentLayout.1 x1)
    {
      this(x0);
    }
    
    private Constraint(Object value)
    {
      this.value = value;
    }
  }
  
  static class NumberConstraint
    extends PercentLayout.Constraint
  {
    public NumberConstraint(int d)
    {
      this(new Integer(d));
    }
    
    public NumberConstraint(Integer d)
    {
      super(null);
    }
    
    public int intValue()
    {
      return ((Integer)value).intValue();
    }
  }
  
  static class PercentConstraint
    extends PercentLayout.Constraint
  {
    public PercentConstraint(float d)
    {
      super(null);
    }
    
    public float floatValue()
    {
      return ((Float)value).floatValue();
    }
  }
  
  private static final Constraint REMAINING_SPACE = new Constraint("*", null);
  private static final Constraint PREFERRED_SIZE = new Constraint("", null);
  private int orientation;
  private int gap;
  private Hashtable m_ComponentToConstraint;
  
  public PercentLayout()
  {
    this(0, 0);
  }
  
  public PercentLayout(int orientation, int gap)
  {
    setOrientation(orientation);
    this.gap = gap;
    
    m_ComponentToConstraint = new Hashtable();
  }
  
  public void setGap(int gap)
  {
    this.gap = gap;
  }
  
  public int getGap()
  {
    return gap;
  }
  
  public void setOrientation(int orientation)
  {
    if ((orientation != 0) && (orientation != 1)) {
      throw new IllegalArgumentException("Orientation must be one of HORIZONTAL or VERTICAL");
    }
    this.orientation = orientation;
  }
  
  public int getOrientation()
  {
    return orientation;
  }
  
  public Constraint getConstraint(Component component)
  {
    return (Constraint)m_ComponentToConstraint.get(component);
  }
  
  public void setConstraint(Component component, Object constraints)
  {
    if ((constraints instanceof Constraint))
    {
      m_ComponentToConstraint.put(component, constraints);
    }
    else if ((constraints instanceof Number))
    {
      setConstraint(component, new NumberConstraint(((Number)constraints).intValue()));
    }
    else if ("*".equals(constraints))
    {
      setConstraint(component, REMAINING_SPACE);
    }
    else if ("".equals(constraints))
    {
      setConstraint(component, PREFERRED_SIZE);
    }
    else if ((constraints instanceof String))
    {
      String s = (String)constraints;
      if (s.endsWith("%"))
      {
        float value = Float.valueOf(s.substring(0, s.length() - 1)).floatValue() / 100.0F;
        if ((value > 1.0F) || (value < 0.0F)) {
          throw new IllegalArgumentException("percent value must be >= 0 and <= 100");
        }
        setConstraint(component, new PercentConstraint(value));
      }
      else
      {
        setConstraint(component, new NumberConstraint(Integer.valueOf(s)));
      }
    }
    else if (constraints == null)
    {
      setConstraint(component, PREFERRED_SIZE);
    }
    else
    {
      throw new IllegalArgumentException("Invalid Constraint");
    }
  }
  
  public void addLayoutComponent(Component component, Object constraints)
  {
    setConstraint(component, constraints);
  }
  
  public float getLayoutAlignmentX(Container target)
  {
    return 0.5F;
  }
  
  public float getLayoutAlignmentY(Container target)
  {
    return 0.5F;
  }
  
  public void invalidateLayout(Container target) {}
  
  public void addLayoutComponent(String name, Component comp) {}
  
  public void removeLayoutComponent(Component comp)
  {
    m_ComponentToConstraint.remove(comp);
  }
  
  public Dimension minimumLayoutSize(Container parent)
  {
    return preferredLayoutSize(parent);
  }
  
  public Dimension maximumLayoutSize(Container parent)
  {
    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  }
  
  public Dimension preferredLayoutSize(Container parent)
  {
    Component[] components = parent.getComponents();
    Insets insets = parent.getInsets();
    int width = 0;
    int height = 0;
    
    boolean firstVisibleComponent = true;
    int i = 0;
    for (int c = components.length; i < c; i++) {
      if (components[i].isVisible())
      {
        Dimension componentPreferredSize = components[i].getPreferredSize();
        if (orientation == 0)
        {
          height = Math.max(height, height);
          width += width;
          if (firstVisibleComponent) {
            firstVisibleComponent = false;
          } else {
            width += gap;
          }
        }
        else
        {
          height += height;
          width = Math.max(width, width);
          if (firstVisibleComponent) {
            firstVisibleComponent = false;
          } else {
            height += gap;
          }
        }
      }
    }
    return new Dimension(width + right + left, height + top + bottom);
  }
  
  public void layoutContainer(Container parent)
  {
    Insets insets = parent.getInsets();
    Dimension d = parent.getSize();
    
    width = (width - left - right);
    height = (height - top - bottom);
    
    Component[] components = parent.getComponents();
    int[] sizes = new int[components.length];
    
    int totalSize = (0 == orientation ? width : height) - (components.length - 1) * gap;
    
    int availableSize = totalSize;
    
    int i = 0;
    for (int c = components.length; i < c; i++) {
      if (components[i].isVisible())
      {
        Constraint constraint = (Constraint)m_ComponentToConstraint.get(components[i]);
        if ((constraint == null) || (constraint == PREFERRED_SIZE))
        {
          sizes[i] = (0 == orientation ? getPreferredSizewidth : getPreferredSizeheight);
          
          availableSize -= sizes[i];
        }
        else if ((constraint instanceof NumberConstraint))
        {
          sizes[i] = ((NumberConstraint)constraint).intValue();
          availableSize -= sizes[i];
        }
      }
    }
    int remainingSize = availableSize;
    int i = 0;
    for (int c = components.length; i < c; i++) {
      if (components[i].isVisible())
      {
        Constraint constraint = (Constraint)m_ComponentToConstraint.get(components[i]);
        if ((constraint instanceof PercentConstraint))
        {
          sizes[i] = ((int)(remainingSize * ((PercentConstraint)constraint).floatValue()));
          
          availableSize -= sizes[i];
        }
      }
    }
    ArrayList remaining = new ArrayList();
    int i = 0;
    for (int c = components.length; i < c; i++) {
      if (components[i].isVisible())
      {
        Constraint constraint = (Constraint)m_ComponentToConstraint.get(components[i]);
        if (constraint == REMAINING_SPACE)
        {
          remaining.add(new Integer(i));
          sizes[i] = 0;
        }
      }
    }
    int rest;
    Iterator iter;
    if (remaining.size() > 0)
    {
      rest = availableSize / remaining.size();
      for (iter = remaining.iterator(); iter.hasNext();) {
        sizes[((Integer)iter.next()).intValue()] = rest;
      }
    }
    int currentOffset = 0 == orientation ? left : top;
    
    int i = 0;
    for (int c = components.length; i < c; i++) {
      if (components[i].isVisible())
      {
        if (0 == orientation) {
          components[i].setBounds(currentOffset, top, sizes[i], height);
        } else {
          components[i].setBounds(left, currentOffset, width, sizes[i]);
        }
        currentOffset += gap + sizes[i];
      }
    }
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayout
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import java.awt.Component;

class PercentLayoutAnimator$PercentTask
{
  Component component;
  float targetPercent;
  float currentPercent;
  boolean completed;
  boolean incrementing;
  float delta;
  private final PercentLayoutAnimator this$0;
  
  public PercentLayoutAnimator$PercentTask(PercentLayoutAnimator this$0, Component component, float currentPercent, float targetPercent)
  {
    this.this$0 = this$0;
    this.component = component;
    this.currentPercent = currentPercent;
    this.targetPercent = targetPercent;
    
    float diff = targetPercent - currentPercent;
    incrementing = (diff > 0.0F);
    delta = (diff / 10.0F);
  }
  
  public void execute()
  {
    currentPercent += delta;
    if (incrementing)
    {
      if (currentPercent > targetPercent)
      {
        currentPercent = targetPercent;
        completed = true;
      }
    }
    else if (currentPercent < targetPercent)
    {
      currentPercent = targetPercent;
      completed = true;
    }
    PercentLayoutAnimator.access$000(this$0).setConstraint(component, new PercentLayout.PercentConstraint(currentPercent));
  }
  
  public boolean isCompleted()
  {
    return completed;
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayoutAnimator.PercentTask
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.Timer;

public class PercentLayoutAnimator
  implements ActionListener
{
  private Timer animatorTimer;
  private List tasks = new ArrayList();
  private PercentLayout layout;
  private Container container;
  
  public PercentLayoutAnimator(Container container, PercentLayout layout)
  {
    this.container = container;
    this.layout = layout;
  }
  
  public void setTargetPercent(Component component, float percent)
  {
    PercentLayout.Constraint oldConstraint = layout.getConstraint(component);
    if ((oldConstraint instanceof PercentLayout.PercentConstraint)) {
      setTargetPercent(component, ((PercentLayout.PercentConstraint)oldConstraint).floatValue(), percent);
    }
  }
  
  public void setTargetPercent(Component component, float startPercent, float endPercent)
  {
    tasks.add(new PercentTask(component, startPercent, endPercent));
  }
  
  public void start()
  {
    animatorTimer = new Timer(15, this);
    animatorTimer.start();
  }
  
  public void stop()
  {
    animatorTimer.stop();
  }
  
  protected void complete()
  {
    animatorTimer.stop();
  }
  
  public void actionPerformed(ActionEvent e)
  {
    boolean allCompleted = true;
    for (Iterator iter = tasks.iterator(); iter.hasNext();)
    {
      PercentTask element = (PercentTask)iter.next();
      if (!element.isCompleted())
      {
        allCompleted = false;
        element.execute();
      }
    }
    container.invalidate();
    container.doLayout();
    container.repaint();
    if (allCompleted) {
      complete();
    }
  }
  
  class PercentTask
  {
    Component component;
    float targetPercent;
    float currentPercent;
    boolean completed;
    boolean incrementing;
    float delta;
    
    public PercentTask(Component component, float currentPercent, float targetPercent)
    {
      this.component = component;
      this.currentPercent = currentPercent;
      this.targetPercent = targetPercent;
      
      float diff = targetPercent - currentPercent;
      incrementing = (diff > 0.0F);
      delta = (diff / 10.0F);
    }
    
    public void execute()
    {
      currentPercent += delta;
      if (incrementing)
      {
        if (currentPercent > targetPercent)
        {
          currentPercent = targetPercent;
          completed = true;
        }
      }
      else if (currentPercent < targetPercent)
      {
        currentPercent = targetPercent;
        completed = true;
      }
      layout.setConstraint(component, new PercentLayout.PercentConstraint(currentPercent));
    }
    
    public boolean isCompleted()
    {
      return completed;
    }
  }
}

/* Location:
 * Qualified Name:     com.l2fprod.common.swing.PercentLayoutAnimator
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package com.l2fprod.common.swing.plaf;

import com.l2fprod.common.swing.plaf.aqua.AquaLookAndFeelAddons;
import com.l2fprod.common.swing.plaf.metal.MetalLookAndFeelAddons;
import com.l2fprod.common.swing.plaf.motif.MotifLookAndFeelAddons;
import com.l2fprod.common.swing.plaf.windows.WindowsLookAndFeelAddons;
import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Reso
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd