本文整理匯總了Java中com.badlogic.gdx.utils.reflect.ClassReflection.getFields方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassReflection.getFields方法的具體用法?Java ClassReflection.getFields怎麽用?Java ClassReflection.getFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.reflect.ClassReflection
的用法示例。
在下文中一共展示了ClassReflection.getFields方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findMetadata
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
private Metadata findMetadata (Class<?> clazz) {
Metadata metadata = metadataCache.get(clazz);
if (metadata == null) {
Annotation tca = ClassReflection.getAnnotation(clazz, TaskConstraint.class);
if (tca != null) {
TaskConstraint taskConstraint = tca.getAnnotation(TaskConstraint.class);
ObjectMap<String, AttrInfo> taskAttributes = new ObjectMap<String, AttrInfo>();
Field[] fields = ClassReflection.getFields(clazz);
for (Field f : fields) {
Annotation a = f.getDeclaredAnnotation(TaskAttribute.class);
if (a != null) {
AttrInfo ai = new AttrInfo(f.getName(), a.getAnnotation(TaskAttribute.class));
taskAttributes.put(ai.name, ai);
}
}
metadata = new Metadata(taskConstraint.minChildren(), taskConstraint.maxChildren(), taskAttributes);
metadataCache.put(clazz, metadata);
}
}
return metadata;
}
示例2: runValidation
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
/**
* Check if exist a MapWayPointItemStyle for all CacheTypes and WayPointTypes
*/
@Override
public void runValidation() {
checkCacheTypes();
//Check changes of MapWayPointItemStyle.class
Field[] fields = ClassReflection.getFields(MapWayPointItemStyle.class);
String classChanged = "";
if (fields.length > 3) {
classChanged = "MapWayPointItemStyle is changed, maybe you must add new Validation " +
"on de.longri.cachebox3.develop.tools.skin_editor.validation.Validate_MapWayPointItemStyle.java";
}
//set result
if (missingBitmaps.length > 0 || missingSyles.length > 0) {
errorMsg = "Missing Styles:\n\n" + missingSyles.toString() + "\n\nMissing Bitmaps:\n\n" + missingBitmaps.toString();
}
if (!classChanged.isEmpty()) {
warnMsg = classChanged + "\n\n Wrong Sizes:\n\n" + wrongBitmapsSize.toString();
} else if (wrongBitmapsSize.length > 0) {
warnMsg = "Wrong Sizes:\n\n" + wrongBitmapsSize.toString();
}
}
示例3: isFontInUse
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
/**
* Is font is already in use somewhere else?
*/
public boolean isFontInUse(BitmapFont font) {
try {
// Check if it is already in use somewhere!
for (String widget : SkinEditorGame.widgets) {
String widgetStyle = "com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style";
Class<?> style = Class.forName(widgetStyle);
ObjectMap<String, ?> styles = game.skinProject.getAll(style);
Iterator<String> it = styles.keys().iterator();
while (it.hasNext()) {
Object item = styles.get((String) it.next());
Field[] fields = ClassReflection.getFields(item.getClass());
for (Field field : fields) {
if (field.getType() == BitmapFont.class) {
BitmapFont f = (BitmapFont) field.get(item);
if (font.equals(f)) {
return true;
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例4: newStyleProperties
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
private void newStyleProperties(Class clazz) {
for (Field field : ClassReflection.getFields(clazz)) {
StyleProperty styleProperty = new StyleProperty(field.getType(), field.getName(), true);
properties.put(field.getName(), styleProperty);
}
}
示例5: updateTableFields
import com.badlogic.gdx.utils.reflect.ClassReflection; //導入方法依賴的package包/類
/**
*
*/
private void updateTableFields(final String style) {
ImageButton button = (ImageButton) game.screenMain.barWidgets.group.getChecked();
String widget = button.getUserObject().toString();
Gdx.app.log("OptionsPane", "Update fields table for widget: " + widget + ", style: " + style);
tableFields.clear();
tableFields.add(new Label("name", game.skin, "title")).left().width(170);
tableFields.add(new Label("Value", game.skin, "title")).left().width(60).padRight(50);
tableFields.row();
Field[] fields = ClassReflection.getFields(currentStyle.getClass());
for (final Field field : fields) {
try {
Actor actor = null;
// field type
String name = field.getType().getSimpleName();
Object obj = field.get(currentStyle);
if (name.equals("Array")) {
actor = getArrayActor(field, obj);
} else if (name.equals("Drawable")) {
actor = getDrawableActor(field, -1, null);
} else if (name.equals("Bitmap")) {
actor = getBitmapActor(field);
} else if (name.equals("Color")) {
actor = getColorActor(field);
} else if (name.equals("BitmapFont")) {
actor = getBitmapFontActor(field);
} else if (name.equals("float")) {
actor = getFloatActor(field);
} else if (name.equals("ListStyle")) {
actor = getListStyleActor(field);
} else if (name.equals("ScrollPaneStyle")) {
actor = getScrollPaneStyleActor(field);
} else if (name.equals("boolean")) {
actor = getBooleanActor(field);
} else if (field.getType().isEnum()) {
actor = getEnumActor(field, obj);
} else {
Gdx.app.log("OptionsPane", "Unknown type: " + name);
if (!(currentStyle instanceof AbstractIconStyle)) {
actor = new Label("Unknown Type", game.skin);
}
}
if (actor != null) {
// field name
// White required
// Grey optional
if (game.opt.isFieldOptional(currentStyle.getClass(), field.getName())) {
tableFields.add(new Label(field.getName(), game.skin, "optional")).left();
} else {
tableFields.add(new Label(field.getName(), game.skin, "default")).left();
}
// tableFields.add(actor).left().height(64).padRight(24).expandX().fillX();
tableFields.add(actor).left().padBottom(12).padRight(24).expandX().fillX();
tableFields.row();
}
} catch (Exception e) {
e.printStackTrace();
}
//send changes to PreviewPane
previewPane.selectedStyleChanged();
}
}