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

📄 jsourcecodewizardprocessorfunction.java

📁 用免疫遗传算法解决TSP问题
💻 JAVA
字号:
/**
 * IgaLib -> wizard
 * Copyright (C) 2001  Tosiki IGA , IgaLib project member
 *   (http://homepage2.nifty.com/igat/igapyon/index.html)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package jp.ne.nifty.iga.tosiki.wizard;

import jp.ne.nifty.iga.tosiki.string.*;
import java.io.*;
import java.util.*;

/**
 * JSourceCodeWizardProcessor 偺僿儖僷乕僋儔僗<BR>
 * Function晹暘偱偡<BR>
 *
 * @author Tosiki IGA
 */
public class JSourceCodeWizardProcessorFunction
{
	/**
	 * Function傪憓擖偟傑偡丅
	 */
	public static final void writeFunction(
		JSourceCodeWizard wizard,JSourceCodeWizardChannel dataChannel,ArrayList vecItem,IndentWriter out)
		throws IOException
	{
		if(dataChannel.getFunction().isUseMain())
		{
			out.println("	/**");
			out.println("	 * "+dataChannel.getName()+"("+dataChannel.getTitle()+") 僋儔僗偺僄儞僩儕億僀儞僩<BR>");
			out.println("	 * ");
			out.println("	 *   @param String[] args 婲摦堷悢僷儔儊乕僞");
			out.println("	 */");
			out.println("	public static void main(String[] args)");
			out.println("	{");

			if(dataChannel.getFunction().isUseSwing())
			{
				out.println("		javax.swing.JFrame frame=new javax.swing.JFrame();");
				out.println("		"+JSourceCodeWizardProcessor.getMyClassName(wizard,dataChannel)+" myself=new "+JSourceCodeWizardProcessor.getMyClassName(wizard,dataChannel)+"();");
				out.println("		frame.getContentPane().add(myself);");
				out.println("		frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);");
				out.println("		frame.pack();");
				out.println("		frame.setVisible(true);");
			}
			out.println("	}");
			out.println("");
		}

		if(dataChannel.getFunction().isUseConstracter())
		{
			out.println("	/**");
			out.println("	 * "+dataChannel.getName()+"("+dataChannel.getTitle()+") 僋儔僗偺僐儞僗僩儔僋僞<BR>");
			out.println("	 */");
			out.println("	public "+JSourceCodeWizardProcessor.getMyClassName(wizard,dataChannel)+"()");
			out.println("	{");
			if(dataChannel.getFunction().isUseInit())
			{
				out.println(2,"wizInit();");
			}
			out.println("	}");
			out.println("");
		}

		if(dataChannel.getFunction().isUseInit())
		{
			out.println("	/**");
			out.println("	 * "+dataChannel.getName()+"("+dataChannel.getTitle()+") 僋儔僗偺僼傿乕儖僪偺弶婜壔<BR>");
			out.println("	 */");
			out.println("	protected void wizInit()");
			out.println("	{");

			int iSwingObjectCounter=0;
			for(int index=0;index<vecItem.size();index++)
			{
				JSourceCodeWizardField wrk_field=(JSourceCodeWizardField)vecItem.get(index);
				if(wrk_field.getDefault()!=null)
				{
					// 偙偙偱if暥偑昁梫偵側偭偰偟傑偄傑偡丅
					// 偲偄偆偺傕 setter帪偵宆偺撉懼傪峴偭偰偄傞偐傜偱偡丅
					if(wrk_field.getType().equals(WizType.getWizAlterType(wrk_field.getType())))
					{
						out.println(2,"set"+JSourceCodeWizardProcessor.getUpper(wrk_field.getName())+"("+wrk_field.getDefault()+");");
					}
					else
					{
						out.println(2,"f_"+wrk_field.getName()+"="+wrk_field.getDefault()+";");
					}
				}

				if(dataChannel.getFunction().isUseSwing())
				{
					if("javax.swing.JCheckBox".equals(wrk_field.getType()))
					{
						iSwingObjectCounter++;
						out.println(2,wrk_field.getTitleFieldName()+".setText(\""+wrk_field.getTitle()+"\");");
						out.println(2,"add("+wrk_field.getTitleFieldName()+");");
					}
					else if("javax.swing.JTextField".equals(wrk_field.getType()))
					{
						iSwingObjectCounter++;
						if(wrk_field.getLength()>0)
						{
							out.println(2,wrk_field.getTitleFieldName()+".setColumns("+wrk_field.getLength()+");");
						}
						out.println(2,wrk_field.getTitleFieldName()+".setBorder(new javax.swing.border.TitledBorder(\""+wrk_field.getTitle()+"\"));");
						out.println(2,"add("+wrk_field.getTitleFieldName()+");");
					}
				}
			}

			if(dataChannel.getFunction().isUseSwing())
			{
				out.println(2,"setLayout(new java.awt.GridLayout("+iSwingObjectCounter+",1));");
			}

			out.println("	}");
			out.println("");
		}

		if(dataChannel.getFunction().isUseServlet())
		{
			new JSourceCodeWizardProcessorServlet().write(wizard,dataChannel,vecItem,out);
		}
	}
}

⌨️ 快捷键说明

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