當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassReflection.getFields方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Mignet,項目名稱:Inspiration,代碼行數:22,代碼來源:BehaviorTreeParser.java

示例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();
    }


}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:32,代碼來源:Validate_MapWayPointItemStyle.java

示例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;
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:39,代碼來源:FontPickerDialog.java

示例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);
    }
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:7,代碼來源:StyleData.java

示例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();
        }

    }
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:82,代碼來源:OptionsPane.java


注:本文中的com.badlogic.gdx.utils.reflect.ClassReflection.getFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。