⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 templatemanager.java

📁 JAVA平台下优秀的CHART开源代码,可以实现类似EXCEL中的二维或三维的饼图/椎图功能.
💻 JAVA
字号:
/**
 * Copyright (C) 2003  Manfred Andres
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package freecs.layout;

import freecs.Server;

import java.io.*;
import java.util.*;

public class TemplateManager {
   private HashMap tSets;

   public TemplateManager() throws IOException {
      tSets = new HashMap();
      loadTemplates();
   }

   public TemplateSet getTemplateSet (String name) {
      if (name == null || !tSets.containsKey (name))
         return (TemplateSet) tSets.get("default");
      return (TemplateSet) tSets.get(name);
   }

   private void loadTemplates() throws IOException {
      StringBuffer tsb = new StringBuffer (Server.BASE_PATH).append ("/templatesets");
      File tFile = new File(tsb.toString ());
      if (!tFile.exists()) {
         if (!tFile.mkdir()) { throw new IOException("Unable to create directory 'templateset'"); }
         tsb = new StringBuffer (Server.BASE_PATH).append ("/templatesets/default");
         tFile = new File(tsb.toString ());
         if (!tFile.exists()) {
            if (!tFile.mkdir()) { throw new IOException("Unable to create directory 'default'"); }
         }
         throw new IOException("No templates available. (Directories created)");
      }
      if (!tFile.isDirectory()) {
      	throw new IOException("'templatesets' isn't a directory"); 
      }
	  File defaultTs = new File (tFile.getCanonicalPath(), "default");
	  if (!defaultTs.exists()) {
	  	 throw new IOException ("The default-layout was not present!");
	  }
	  constructTemplateSet(defaultTs);
      File fList[] = tFile.listFiles ();
      for (int i = 0; i < fList.length; i++) {
         if (!fList[i].isDirectory () || fList[i].getName().equals("default")) 
         	continue;
         constructTemplateSet(fList[i]);
      }
      if (!tSets.containsKey("default")) throw new IOException ("Unable to read default-template-set");
   }
   
	private void constructTemplateSet (File f) throws IOException {
		TemplateSet tSet = new TemplateSet (f, this);
		if (!tSet.isValide ()) 
			return;
		StringBuffer tsb = new StringBuffer ("parsed valide templateset ");
		tsb.append (tSet.getName ());
		Server.log(tsb.toString (), Server.MSG_STATE, Server.LVL_MINOR);
		tSets.put (f.getName (), tSet);
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -