krysalis-jplugin/src/java/org/krysalis/swingx/resources DefaultResourceFactory.java,NONE,1.1 ResourceFactory.java,NONE,1.1

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-jplugin/src/java/org/krysalis/swingx/resources
In directory sc8-pr-cvs1:/tmp/cvs-serv24886/src/java/org/krysalis/swingx/resources

Added Files:
	DefaultResourceFactory.java ResourceFactory.java 
Log Message:
refactoring swingx.swing.* packages to swingx.*

--- NEW FILE: DefaultResourceFactory.java ---

/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package   org.krysalis.swingx.resources;

import java.io.File;
import java.net.MalformedURLException;
import java.util.HashMap;

import javax.swing.ImageIcon;

import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;

/**
 *@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
 *@created    June 20, 2001
 *@version    1.0
 */
public class DefaultResourceFactory
implements ResourceFactory, Component, Configurable {

  private HashMap icons = new HashMap();

  private String resourcesPathString;
  private String filesPathString;
  private String htmlPathString;
  private String iconsPathString;

  public DefaultResourceFactory () {
  }

  public void configure(Configuration conf) throws ConfigurationException
  {
    resourcesPathString = conf.getChild("resources").getAttribute("path","./resources/");
    filesPathString = conf.getChild("files").getAttribute("path","./resources/files/");
    htmlPathString = conf.getChild("html").getAttribute("path","./resources/files/");
    iconsPathString = conf.getChild("icons").getAttribute("path","./resources/icons/");
  }


  public java.net.URL getPlainResource (String resourceString) {
    try{
      return new File(resourceString).toURL();
    }catch(MalformedURLException mue){return null;}
  }

  public java.net.URL getResource (String resourceString) {
    try{
      return new File(resourcesPathString + resourceString).toURL();
    }catch(MalformedURLException mue){return null;}
  }

  public java.net.URL getFileResource (String resourceString) {
    try{
      return new File(filesPathString + resourceString).toURL();
    }catch(MalformedURLException mue){return null;}
  }

  public java.net.URL getHtmlResource (String resourceString) {
    try{
      return new File(htmlPathString + resourceString).toURL();
    }catch(MalformedURLException mue){return null;}
  }

  public ImageIcon getImageIcon (String imageName) {
    try{
      ImageIcon returnIcon = (ImageIcon)icons.get(imageName);
      if (returnIcon == null) {
        returnIcon = new ImageIcon(new File(iconsPathString + imageName).toURL());
        icons.put(imageName, returnIcon);
      }
      return  returnIcon;
    }catch(MalformedURLException mue){return null;}
  }
}

--- NEW FILE: ResourceFactory.java ---

/*****************************************************************************
 * Copyright (C) The Krysalis project. All rights reserved.                  *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Krysalis Software       *
 * License version 1.1_01, a copy of which has been included  with this      *
 * distribution in the LICENSE file.                                         *
 *****************************************************************************/
package   org.krysalis.swingx.resources;

import javax.swing.ImageIcon;

import org.apache.avalon.framework.component.Component;

/**
 *@author <a href="mailto:[email protected]">Nicola Ken Barozzi</a>
 *@created    June 20, 2001
 *@version    1.0
 */
public interface ResourceFactory extends Component {
  public java.net.URL getPlainResource (String resourceString);
  public java.net.URL getResource (String resourceString);
  public java.net.URL getFileResource (String resourceString);
  public ImageIcon getImageIcon (String imageName);
}




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.