📄 editormanager.java
字号:
/* Ogre4J
Copyright (C) 2002 macross
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 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 org.ogre4j.beans;
import java.util.HashMap;
import org.ogre4j.ColourValue;
import org.ogre4j.beans.editor.AbstractEditor;
import org.ogre4j.beans.editor.ColourValueEditor;
import org.ogre4j.beans.editor.FloatEditor;
import org.ogre4j.beans.editor.IntEditor;
import org.ogre4j.beans.editor.StringEditor;
import org.ogre4j.beans.editor.Vector3Editor;
import org.ogre4j.math.Vector3;
/**
* EditorManager
*
* @author Ivica Aracic <ivica.aracic@bytelords.de>
*/
public class EditorManager {
/*
* singleton
*/
private static EditorManager singleton = new EditorManager();
public static EditorManager instance() {
return singleton;
}
// map
HashMap editorMap = new HashMap();
private EditorManager() {
// register known editors
editorMap.put(int.class.getName(), IntEditor.class.getName());
editorMap.put(Integer.class.getName(), IntEditor.class.getName());
editorMap.put(float.class.getName(), FloatEditor.class.getName());
editorMap.put(Float.class.getName(), FloatEditor.class.getName());
editorMap.put(Vector3.class.getName(), Vector3Editor.class.getName());
editorMap.put(ColourValue.class.getName(), ColourValueEditor.class.getName());
editorMap.put(String.class.getName(), StringEditor.class.getName());
}
public void registerEditor(String className, String editorClassName) {
editorMap.put(className, editorClassName);
}
public void unregisterEditor(String className) {
editorMap.remove(className);
}
public AbstractEditor getEditor(Class clazz) {
if(clazz==null)
return null;
AbstractEditor res;
String className = clazz.getName();
String editorClassName = (String)editorMap.get(className);
try {
res = (AbstractEditor)Class.forName(editorClassName).newInstance();
}
catch(Exception e) {
//res = new NullEditor();
res = null;
}
return res;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -