• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GdxArrays类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.github.czyzby.kiwi.util.gdx.collection.GdxArrays的典型用法代码示例。如果您正苦于以下问题:Java GdxArrays类的具体用法?Java GdxArrays怎么用?Java GdxArrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GdxArrays类属于com.github.czyzby.kiwi.util.gdx.collection包,在下文中一共展示了GdxArrays类的35个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initiateRegularComponents

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param context will contain instances of scanned components. This method will clear scanners, as they are no
 *            longer expected to be needed.
 * @param contextDestroyer used to register destruction callbacks. */
private void initiateRegularComponents(final Context context, final ContextDestroyer contextDestroyer) {
    final Array<Class<?>> componentTypes = GdxArrays.newArray();
    for (final Entry<Class<?>, ClassScanner> scannerData : scanners) {
        componentTypes.addAll(scannerData.value.findClassesAnnotatedWith(scannerData.key, scannedAnnotations));
    }
    final Array<Object> components = createComponents(componentTypes, context);
    // Manually added components are already mapped. Now they will be initiated:
    components.addAll(manuallyAddedComponents);
    manuallyAddedComponents.clear();
    initiateComponents(components, context, contextDestroyer);
    // Scanners no longer needed, all components found:
    if (clearProcessors) {
        scanners.clear();
    }
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:19,
代码来源:ContextInitializer.java

示例2: createComponents

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param types classes of components to initiate.
 * @param context will contain components mapped by their classes tree.
 * @return an array containing all created components. */
private Array<Object> createComponents(final Array<Class<?>> types, final Context context) {
    final Array<Object> components = GdxArrays.newArray();
    for (final Class<?> type : types) {
        final Constructor[] constructors = ClassReflection.getConstructors(type);
        if (constructors == null || constructors.length == 0) {
            throw new ContextInitiationException(
                    type + " has no available public constructors. Unable to create component.");
        } else if (constructors.length == 1) {
            // Single constructor - trying to invoke it:
            addIfNotNull(components, processConstructor(constructors[0], context));
        } else {
            // Multiple constructors - trying to find a suitable one:
            addIfNotNull(components, processConstructor(findSuitableConstructor(constructors), context));
        }
    }
    int initiationIterations = 0;
    while (GdxArrays.isNotEmpty(delayedConstructions)) {
        validateIterationsAmount(initiationIterations);
        processDelayedConstructions(context, components);
        initiationIterations++;
    }
    return components;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:27,
代码来源:ContextInitializer.java

示例3: extractFromBinaries

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
private static Array<Class<?>> extractFromBinaries(final Iterable<Class<? extends Annotation>> annotations,
        final String mainPackageName, final Queue<Pair<File, Integer>> filesWithDepthsToProcess)
                throws ReflectionException {
    final Array<Class<?>> result = GdxArrays.newArray();
    while (!filesWithDepthsToProcess.isEmpty()) {
        final Pair<File, Integer> classPathFileWithDepth = filesWithDepthsToProcess.poll();
        final File classPathFile = classPathFileWithDepth.getFirst();
        final int depth = classPathFileWithDepth.getSecond();
        if (classPathFile.isDirectory()) {
            addAllChildren(filesWithDepthsToProcess, classPathFile, depth);
        } else {
            final String className = getBinaryClassName(mainPackageName, classPathFile, depth);
            if (!isFromPackage(mainPackageName, className)) {
                continue;
            }
            final Class<?> classToProcess = ClassReflection.forName(className);
            processClass(annotations, result, classToProcess);
        }
    }
    return result;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:22,
代码来源:FallbackDesktopClassScanner.java

示例4: getDefaultViewShowingActionProvider

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
private ActionProvider getDefaultViewShowingActionProvider() {
    return new ActionProvider() {
        @Override
        public Action provideAction(final ViewController forController, final ViewController previousController) {
            if (musicService.getCurrentTheme() == null && GdxArrays.isNotEmpty(forController.getThemes())) {
                final Music currentTheme = forController.getThemes().random();
                return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                        Actions.run(CommonActionRunnables.getMusicThemeSetterRunnable(musicService, currentTheme)),
                        Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())),
                        MusicFadingAction.fadeIn(currentTheme, MusicService.DEFAULT_THEME_FADING_TIME,
                                musicService.getMusicVolume()));
            }
            return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                    Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())));
        }
    };
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn-mvc,
代码行数:18,
代码来源:InterfaceService.java

示例5: injectAssets

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void injectAssets(final AssetService assetService) {
    try {
        Array array = (Array) Reflection.getFieldValue(field, component);
        if (array == null) {
            array = GdxArrays.newArray();
        }
        for (final String assetPath : assetPaths) {
            array.add(assetService.get(assetPath, assetType));
        }
        Reflection.setFieldValue(field, component, array);
    } catch (final ReflectionException exception) {
        throw new GdxRuntimeException("Unable to inject array of assets into component: " + component + ".",
                exception);
    }
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn-mvc,
代码行数:17,
代码来源:ArrayAssetInjection.java

示例6: provide

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public Array<Object> provide() {
    final Array<Object> assets = GdxArrays.newArray();
    for (final String assetPath : assetPaths) {
        if (loadOnDemand) {
            assets.add(assetService.finishLoading(assetPath, assetClass));
            continue;
        }
        if (!assetService.isLoaded(assetPath)) {
            // LibGDX method that should load a specific asset immediately does pretty much the same.
            assetService.finishLoading();
        }
        assets.add(assetService.get(assetPath, assetClass));
    }
    return assets;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn-mvc,
代码行数:17,
代码来源:ArrayAssetProvider.java

示例7: toString

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public String toString() {
    final StringBuilder builder = new StringBuilder();
    builder.append("Currently parsing: ");
    appendDebugMessage(builder, originalSequence);
    // Slow, but this is for debug only.
    final Array<CharSequenceEntry> sequences = GdxArrays.newArray(sequencesQueue);
    for (int index = sequencesQueue.size() - 2; index >= 0; index--) {
        builder.append("\nWhich spawned:");
        appendDebugMessage(builder, sequences.get(index));
    }
    if (currentSequence != originalSequence) {
        builder.append("\nWhich spawned:");
        appendDebugMessage(builder, currentSequence);
    }
    return builder.toString();
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:18,
代码来源:DefaultLmlTemplateReader.java

示例8: parseNames

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** Parses names proceeding styles block. */
protected void parseNames() {
    while (reader.hasNextCharacter()) {
        final char character = next();
        if (Strings.isWhitespace(character)) {
            addName();
            continue;
        } else if (character == blockOpening) {
            addName();
            break;
        } else {
            builder.append(character);
        }
    }
    if (GdxArrays.isEmpty(tags)) {
        throwException("No tag names chosen.");
    }
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:19,
代码来源:LssParser.java

示例9: getAttributeNamesAndDefaultValues

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @return parsed additional macro attributes. */
protected Pair<Array<String>, Array<String>> getAttributeNamesAndDefaultValues() {
    final Array<String> attributes = getAttributes();
    final Array<String> attributeNames = GdxArrays.newArray();
    final Array<String> defaultValues = GdxArrays.newArray();
    if (GdxArrays.sizeOf(attributes) > 2) {
        final LmlSyntax syntax = getParser().getSyntax();
        for (int index = 2, length = attributes.size; index < length; index++) {
            final String rawAttribute = attributes.get(index);
            if (Strings.contains(rawAttribute, syntax.getAttributeSeparator())) {
                final int separatorIndex = rawAttribute.indexOf(syntax.getAttributeSeparator());
                attributeNames.add(rawAttribute.substring(0, separatorIndex).trim());
                defaultValues.add(LmlUtilities
                        .stripQuotation(rawAttribute.substring(separatorIndex + 1, rawAttribute.length())));
            } else {
                attributeNames.add(rawAttribute.trim());
                defaultValues.add(Nullables.DEFAULT_NULL_STRING);
            }
        }
    }
    return Pair.of(attributeNames, defaultValues);
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:23,
代码来源:MetaLmlMacroTag.java

示例10: closeTag

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void closeTag() {
    if (!isOn()) {
        return;
    }
    final Array<String> attributes = getAttributes();
    if (GdxArrays.isEmpty(attributes)) {
        if (Strings.isNotEmpty(content)) {
            // Only content between tags is given:
            log(Lml.LOGGER_TAG, content);
        }
    } else if (hasAttribute(LOG_ATTRIBUTE)) {
        log(Lml.LOGGER_TAG, Strings.isBlank(content) ? getAttribute(LOG_ATTRIBUTE)
                : Strings.join(" ", getAttribute(LOG_ATTRIBUTE), content));
    } else {
        if (Strings.isNotBlank(content)) {
            attributes.add(content);
        }
        log(Lml.LOGGER_TAG, Strings.join(" ", attributes));
    }
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:22,
代码来源:AbstractLoggerLmlMacroTag.java

示例11: closeTag

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void closeTag() {
    boolean always;
    if (GdxArrays.isEmpty(getAttributes())) {
        always = true;
    } else {
        if (hasAttribute(STRICT_ATTRIBUTE)) {
            always = getParser().parseBoolean(getAttribute(STRICT_ATTRIBUTE), getActor());
        } else {
            always = getParser().parseBoolean(getAttributes().first(), getActor());
        }
    }
    content = hasAttribute(MESSAGE_ATTRIBUTE) ? getAttribute(MESSAGE_ATTRIBUTE) : content;
    if (always) {
        getParser().throwError(content);
    } else {
        getParser().throwErrorIfStrict(content);
    }
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:20,
代码来源:ExceptionLmlMacroTag.java

示例12: closeTag

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void closeTag() {
    final Array<String> attributes = getAttributes();
    if (GdxArrays.sizeOf(attributes) < 2) {
        getParser().throwError(
                "Cannot register a new tag without two attributes: tag names array and method ID (consuming LmlActorBuilder, providing Actor).");
    }
    // Possible tag names:
    final String[] tagNames = getTagNames();
    // Creates actual actor:
    final ActorConsumer<Actor, LmlActorBuilder> creator = getActorCreator();
    final ActorConsumer<LmlActorBuilder, ?> builderCreator;
    if (attributes.size > 2) { // Provides builders:
        builderCreator = getBuilderCreator();
    } else { // Using default builders:
        builderCreator = null;
    }
    if (creator == null) { // No actor creation method - new tag cannot be created.
        getParser().throwError(
                "Cannot register a method consuming LmlActorBuilder, providing Actor. Method consuming LmlActorBuilder and returning actor not found for attribute: "
                        + attributes.get(1));

    }
    // Registering provider that will create custom tags for the selected tag names:
    getParser().getSyntax().addTagProvider(getNewTagProvider(creator, builderCreator), tagNames);
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:27,
代码来源:NewTagLmlMacroTag.java

示例13: closeTag

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void closeTag() {
    final Array<String> attributes = getAttributes();
    if (GdxArrays.sizeOf(attributes) < 2) {
        getParser().throwError(
                "Unable to create a new atrribute with less than two macro attributes: attribute aliases array and setter method consuming AttributeParsingData.");
    }
    // Possible tag names:
    final String[] tagNames = getAttributeNames();
    // Processes attribute parsing:
    final ActorConsumer<?, AttributeParsingData> parser = getAttributeParser();
    if (parser == null) {
        getParser().throwError(
                "Unable to add new attribute. Action consuming AttributeParsingData not found for name: "
                        + attributes.get(1));
    }
    getParser().getSyntax().addAttributeProcessor(new CustomLmlAttribute(parser), tagNames);
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:19,
代码来源:NewAttributeLmlMacroTag.java

示例14: closeTag

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void closeTag() {
    if (GdxArrays.sizeOf(getAttributes()) < 2) {
        getParser().throwErrorIfStrict("Style macro needs at least 2 attributes: tag and attribute names.");
        return;
    }
    final String[] tagNames = getTagNames();
    final String[] attributeNames = getAttributeNames();
    final String defaultValue = getDefaultValueArgument();
    if (tagNames == null || tagNames.length == 0 || attributeNames == null || attributeNames.length == 0
            || defaultValue == null) {
        getParser().throwErrorIfStrict(
                "Style macro needs at least 2 arguments: tag and attribute names. Default attribute value can be set with third argument or data between macro tags. All 3 values are required.");
        return;
    }
    final LmlStyleSheet styleSheet = getParser().getStyleSheet();
    for (final String tag : tagNames) {
        for (final String attribute : attributeNames) {
            styleSheet.addStyle(tag, attribute, defaultValue);
        }
    }
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:23,
代码来源:StyleLmlMacroTag.java

示例15: getArgumentValueFromAttributes

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @return attribute assigned to argument value. */
protected String getArgumentValueFromAttributes() {
    if (hasAttribute(VALUE_ATTRIBUTE)) {
        return getAttribute(VALUE_ATTRIBUTE);
    }
    final Array<String> attributes = getAttributes();
    if (GdxArrays.sizeOf(attributes) == 2) {
        return attributes.get(1);
    }
    final StringBuilder builder = new StringBuilder();
    final char separator = getAttributeSeparator();
    for (int index = 1, length = GdxArrays.sizeOf(attributes); index < length; index++) {
        if (builder.length() > 0) {
            builder.append(separator);
        }
        builder.append(attributes.get(index));
    }
    return builder.toString();
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:20,
代码来源:AssignLmlMacroTag.java

示例16: closeTag

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void closeTag() {
    if (GdxArrays.isEmpty(getAttributes())) {
        getParser().throwErrorIfStrict("Import macros need at least one argument: template name to import.");
        return;
    }
    final FileHandle template = getFileHandle(getTemplateFileName());
    final CharSequence textToAppend;
    if (isReplacingArguments()) {
        if (content == null) {
            getParser().throwErrorIfStrict(
                    "Import macros with content name attribute (second attribute) have to be parental and contain some content that can be replaced in the imported template. Remove second import attribute or add data between macro tags.");
        }
        textToAppend = replaceArguments(template.readString(), getArguments());
    } else {
        textToAppend = template.readString();
    }
    appendTextToParse(textToAppend);
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:20,
代码来源:AbstractImportLmlMacroTag.java

示例17: destroy

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public void destroy() {
    final Array<Destructible> sortedDestructibles = GdxArrays.newArray(destructibles);
    sortedDestructibles.sort(new Comparator<Destructible>() {
        @Override
        public int compare(final Destructible o1, final Destructible o2) {
            return o1.getDestructionOrder() - o2.getDestructionOrder();
        }
    });
    destructibles.clear();
    try {
        for (final Destructible destructible : sortedDestructibles) {
            destructible.destroy();
        }
    } catch (final Exception exception) {
        throw new RuntimeException("Unable to destroy context.", exception);
    }
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:19,
代码来源:DefaultContext.java

示例18: findClassesAnnotatedWith

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public Array<Class<?>> findClassesAnnotatedWith(final Class<?> root,
        final Iterable<Class<? extends Annotation>> annotations) {
    final Array<Class<?>> result = GdxArrays.newArray();
    final String packageName = extractPackageName(root);
    for (final String className : JTranscReflection.getAllClasses()) {
        if (Strings.isNotEmpty(className) && className.startsWith(packageName)) {
            try {
                final Class<?> processed = ClassReflection.forName(className);
                if (isAnnotatedWithAny(processed, annotations)) {
                    result.add(processed);
                }
            } catch (final Exception exception) {
                Gdx.app.debug("JTransc", "Error thrown during processing of class: " + className, exception);
            }
        }
    }
    return result;
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:20,
代码来源:JTranscClassScanner.java

示例19: findClassesAnnotatedWith

点赞 3

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public Array<Class<?>> findClassesAnnotatedWith(final Class<?> root,
        final Iterable<Class<? extends Annotation>> annotations) {
    final ObjectSet<Class<?>> result = GdxSets.newSet(); // Using set to remove duplicates.
    final FastClasspathScanner scanner = new FastClasspathScanner(root.getPackage().getName(),
            AutumnRoot.class.getPackage().getName());
    for (final Class<? extends Annotation> annotation : annotations) {
        scanner.matchClassesWithAnnotation(annotation, new ClassAnnotationMatchProcessor() {
            @Override
            public void processMatch(final Class<?> matchingClass) {
                result.add(matchingClass);
            }
        });
    }
    scanner.scan();
    return GdxArrays.newArray(result);
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:18,
代码来源:DesktopClassScanner.java

示例20: getControlTypes

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@LmlAction("controls")
public Iterable<ControlType> getControlTypes() {
    if (GdxUtilities.isRunningOnAndroid()) {
        // Keyboard controls on Android do not work well...
        return GdxArrays.newArray(ControlType.TOUCH, ControlType.PAD, ControlType.INACTIVE, ControlType.BOT);
    } else if (GdxUtilities.isRunningOnIOS()) {
        // Controllers (pads) do not exactly work on iOS.
        return GdxArrays.newArray(ControlType.TOUCH, ControlType.INACTIVE, ControlType.BOT);
    } // Desktop supports all controllers:
    return GdxArrays.newArray(ControlType.values());
}
 

开发者ID:BialJam,
项目名称:M-M,
代码行数:12,
代码来源:ControlsSwitchController.java

示例21: setGamePadControls

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@LmlAction("PAD")
public void setGamePadControls() {
    final Array<Controller> controllers = Controllers.getControllers();
    if (GdxArrays.isEmpty(controllers)) {
        changeControls(new InactiveControl());
    } else {
        changeControls(new GamePadControl(controllers.first()));
    }
}
 

开发者ID:BialJam,
项目名称:M-M,
代码行数:10,
代码来源:ControlsSwitchController.java

示例22: getDisplayModes

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @return array of serialized display modes' names. */
@LmlAction("displayModes")
public Array<String> getDisplayModes() {
    final ObjectSet<String> alreadyAdded = GdxSets.newSet(); // Removes duplicates.
    final Array<String> displayModes = GdxArrays.newArray(); // Keeps display modes sorted.
    for (final DisplayMode mode : fullscreenService.getDisplayModes()) {
        final String modeName = fullscreenService.serialize(mode);
        if (alreadyAdded.contains(modeName)) {
            continue; // Same size already added.
        }
        displayModes.add(modeName);
        alreadyAdded.add(modeName);
    }
    return displayModes;
}
 

开发者ID:BialJam,
项目名称:M-M,
代码行数:16,
代码来源:SettingsController.java

示例23: saveControlsInPreferences

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Destroy(priority = AutumnActionPriority.TOP_PRIORITY)
public void saveControlsInPreferences() {
    final Array<ControlsData> controlsData = GdxArrays.newArray(Configuration.PLAYERS_AMOUNT);
    for (final Control control : controls) {
        controlsData.add(control.toData());
    }
    controlsData.size = Configuration.PLAYERS_AMOUNT;
    preference.set(controlsData);
}
 

开发者ID:BialJam,
项目名称:M-M,
代码行数:10,
代码来源:ControlsService.java

示例24: getDefault

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public Array<ControlsData> getDefault() {
    final Array<ControlsData> controls = GdxArrays.newArray();
    // First player defaults to touch (on mobile) or keyboard (on desktop) controls.
    controls.add(GdxUtilities.isMobile() ? new TouchControl().toData() : new KeyboardControl().toData());
    // Second player is an AI:
    controls.add(new ComputerControl().toData());
    for (int index = 2; index < Configuration.PLAYERS_AMOUNT; index++) {
        // Other players are simply inactive:
        controls.add(new ControlsData(ControlType.INACTIVE));
    }
    return controls;
}
 

开发者ID:BialJam,
项目名称:M-M,
代码行数:14,
代码来源:ControlsPreference.java

示例25: initiateMetaComponents

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param context will contain instances of scanned annotation procesors.
 * @param contextDestroyer used to register destruction callbacks. */
private void initiateMetaComponents(final Context context, final ContextDestroyer contextDestroyer) {
    final Array<Class<?>> metaComponentTypes = GdxArrays.newArray();
    for (final Entry<Class<?>, ClassScanner> scannerData : scanners) {
        metaComponentTypes
                .addAll(scannerData.value.findClassesAnnotatedWith(scannerData.key, scannedMetaAnnotations));
    }
    final Array<Object> metaComponents = createComponents(metaComponentTypes, context);
    metaComponents.addAll(manuallyAddedProcessors);
    manuallyAddedProcessors.clear();
    initiateComponents(metaComponents, context, contextDestroyer);
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:14,
代码来源:ContextInitializer.java

示例26: validateIterationsAmount

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param initiationIterations if greater than {@link #maxInitiationIterations}, throws an an exception. */
private void validateIterationsAmount(final int initiationIterations) {
    if (initiationIterations >= maxInitiationIterations) {
        throw new ContextInitiationException("Context could not have been built after " + initiationIterations
                + " iterations. Some constructor dependencies are missing (not annotated, not available in the context) or some components have circular dependencies. Unable to invoke constructors: "
                + GdxArrays.newArray(delayedConstructions));
    }
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:9,
代码来源:ContextInitializer.java

示例27: invokeConstructor

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param constructor will be invoked.
 * @param parameters will be used to invoke the constructor.
 * @return a new instance of the class.
 * @throws ContextInitiationException if unable to invoke the constructor. */
private static Object invokeConstructor(final Constructor constructor, final Object[] parameters) {
    try {
        return constructor.newInstance(parameters);
    } catch (final ReflectionException exception) {
        throw new ContextInitiationException("Unable to create a new instance of class: "
                + constructor.getDeclaringClass() + " with constructor: " + constructor + " with parameters: "
                + GdxArrays.newArray(parameters), exception);
    }
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:14,
代码来源:ContextInitializer.java

示例28: processDelayedConstructions

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param context used to get constructor parameters.
 * @param components will contain created components. */
private void processDelayedConstructions(final Context context, final Array<Object> components) {
    final Array<Constructor> stillMissingConstructions = GdxArrays.newArray();
    for (final Constructor constructor : delayedConstructions) {
        final Object component = processConstructor(constructor, context);
        if (component != null) {
            components.add(component);
        } else {
            stillMissingConstructions.add(constructor);
        }
    }
    delayedConstructions = stillMissingConstructions;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:15,
代码来源:ContextInitializer.java

示例29: getComponent

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param componentClass class of the component.
 * @return a single component mapped to the class.
 * @throws GdxRuntimeException if no components or multiple components mapped to the selected class.
 * @see #isPresent(Class) */
public Object getComponent(final Class<?> componentClass) {
    final Array<Object> componentsForClass = components.get(componentClass);
    if (GdxArrays.isEmpty(componentsForClass)) {
        throw new GdxRuntimeException("Component for class: " + componentClass + " not available in context.");
    } else if (GdxArrays.sizeOf(componentsForClass) > 1) {
        throw new GdxRuntimeException("Multiple components mapped to: " + componentClass + ". Be more specific.");
    }
    return componentsForClass.first();
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:14,
代码来源:Context.java

示例30: getProvider

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param dependencyClass requested class.
 * @return provider that provides instances of the requested class.
 * @param <Type> type of requested class objects provided by the returned provider.
 * @see #isPresent(Class)
 * @throws GdxRuntimeException if unable to select 1 provider for class. */
@SuppressWarnings("unchecked")
public <Type> DependencyProvider<Type> getProvider(final Class<Type> dependencyClass) {
    final Array<DependencyProvider<?>> providersForClass = providers.get(dependencyClass);
    if (GdxArrays.isEmpty(providersForClass)) {
        throw new GdxRuntimeException(
                "Unable to return provider of: " + dependencyClass + ". No providers available for this class.");
    } else if (GdxArrays.sizeOf(providersForClass) != 1) {
        throw new GdxRuntimeException("Unable to return a provider of: " + dependencyClass
                + ". Multiple providers mapped to the same type. Pass more specific class.");
    }
    return (DependencyProvider<Type>) providersForClass.first();
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:18,
代码来源:Context.java

示例31: addChild

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** @param child will be set as collapsible's child. */
protected void addChild(final Table child) {
    final CollapsibleWidget container = getCollapsibleWidget();
    if (GdxArrays.isNotEmpty(container.getChildren())) {
        getParser().throwErrorIfStrict("Collapsible widget can manage only one child.");
    }
    container.setTable(child);
}
 

开发者ID:czyzby,
项目名称:gdx-lml,
代码行数:9,
代码来源:CollapsibleWidgetLmlTag.java

示例32: invoke

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
/** Invokes the stored method with the chosen arguments.
 *
 * @return result of the invoked method. */
public Object invoke() {
    try {
        return Reflection.invokeMethod(method, methodOwner, parameters);
    } catch (final Exception exception) {
        throw new GdxRuntimeException("Unable to invoke method: " + method.getName() + " of type: " + methodOwner
                + " with parameters: " + GdxArrays.newArray(parameters), exception);
    }
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:12,
代码来源:MethodInvocation.java

示例33: findClassesAnnotatedWith

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
@Override
public Array<Class<?>> findClassesAnnotatedWith(final Class<?> root,
        final Iterable<Class<? extends Annotation>> annotations) {
    final String packageName = extractPackageName(root);
    final Array<Class<?>> result = GdxArrays.newArray();
    for (final Class<?> possibleMatch : pool) {
        if (isInPackage(possibleMatch, packageName) && isAnnotatedWithAny(possibleMatch, annotations)) {
            result.add(possibleMatch);
        }
    }
    return result;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:13,
代码来源:FixedClassScanner.java

示例34: extractFromJar

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
private static Array<Class<?>> extractFromJar(final Iterable<Class<? extends Annotation>> annotations,
        final String classPathRoot, final ClassLoader classLoader)
                throws URISyntaxException, IOException, ReflectionException {
    final Array<JarFile> filesToProcess = getJarFilesToProcess();
    final Array<Class<?>> result = GdxArrays.newArray();
    for (final JarFile jarFile : filesToProcess) {
        final Enumeration<JarEntry> entries = jarFile.entries();
        while (entries.hasMoreElements()) {
            final JarEntry entry = entries.nextElement();
            processEntry(annotations, classPathRoot, result, entry);
        }
    }
    return result;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:15,
代码来源:FallbackDesktopClassScanner.java

示例35: getJarFilesToProcess

点赞 2

import com.github.czyzby.kiwi.util.gdx.collection.GdxArrays; //导入依赖的package包/类
private static Array<JarFile> getJarFilesToProcess() throws URISyntaxException, IOException {
    final Array<JarFile> filesToProcess = GdxArrays.newArray();
    final File jarDirectory = new File(ClassLoader.getSystemClassLoader().getResource(".").toURI());
    for (final File file : jarDirectory.listFiles()) {
        if (file.getName().endsWith(JAR_FILE_EXTENSION)) {
            filesToProcess.add(new JarFile(file));
        }
    }
    return filesToProcess;
}
 

开发者ID:gdx-libs,
项目名称:gdx-autumn,
代码行数:11,
代码来源:FallbackDesktopClassScanner.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)