本文整理汇总了Java中com.github.czyzby.lml.util.Lml类的典型用法代码示例。如果您正苦于以下问题:Java Lml类的具体用法?Java Lml怎么用?Java Lml使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Lml类属于com.github.czyzby.lml.util包,在下文中一共展示了Lml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructParser
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
/** @return a new fully constructed instance of LML parser. */
private static LmlParser constructParser() {
return Lml.parser().skin(getDefaultSkin()).i18nBundle(getDefaultI18nBundle())
.preferences(getDefaultPreferences()).i18nBundle("custom", getCustomI18nBundle())
.preferences("custom", getCustomPreferences())
// Adding custom actor - text area that handles basic LML syntax highlighting:
.tag(new CodeTextArea.CodeTextAreaLmlTagProvider(), "codeTextArea")
.attribute(new CodeTextArea.AreaMessageLmlAttribute(), "message")
// {examples} argument will allow to iterate over Main#EXAMPLES array in LML templates:
.argument("examples", EXAMPLES)
// templates/examples/arguments.lml:
.argument("someArgument", "Extracted from argument.").argument("someNumber", 50)
.argument("lmlSnippet", "<label>Created with argument.</label>")
// templates/examples/actions.lml:
.action("labelConsumer", getActorConsumer()).actions("custom", CustomActionContainer.class)
// Custom tags, attributes and macros created in Java:
.attribute(getCustomAttribute(), "href", "showLink") // Custom attribute - opens a link.
.macro(getCustomMacroProvider(), "uppercase", "toUppercase") // Custom macro - converts to upper case.
.tag(getCustomTagProvider(), "blink", "blinkingLabel") // Custom tag - creates a blinking label.
.attribute(getCustomBlinkingLabelAttribute(), "blinkingTime") // Additional blinking label's attribute.
// Preparing the parser:
.build();
}
示例2: closeTag
import com.github.czyzby.lml.util.Lml; //导入依赖的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));
}
}
示例3: processTagAttributes
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
private void processTagAttributes(final ObjectSet<String> processedAttributes, final Actor actor,
final Object managedObject) {
if (hasComponentActors() && !Lml.DISABLE_COMPONENT_ACTORS_ATTRIBUTE_PARSING) {
// Processing own attributes first, ignoring unknowns:
LmlUtilities.processAttributes(actor, this, getParser(), processedAttributes, false);
// Processing leftover attributes for component children:
processComponentAttributes(processedAttributes, actor);
// Processing leftover attributes, after the widget is fully constructed; not throwing errors for unknown
// attributes. After we're done with components, we parse original attributes again for meaningful
// exceptions - "attribute for Window not found" is a lot better than "attribute for Label not found", just
// because we were parsing Label component of Window last. Continuing even for non-strict parser to ensure
// the same parsing behavior.
}
boolean hasDistinctManagedObject = managedObject != null && managedObject != actor;
if (hasDistinctManagedObject) {
// Throws errors if actor is null:
LmlUtilities.processAttributes(managedObject, this, getParser(), processedAttributes, actor == null);
}
if (actor != null) {
// Processing own attributes. Throwing errors for the unknown attributes:
LmlUtilities.processAttributes(actor, this, getParser(), processedAttributes, true);
}
}
示例4: extractActionFromContainer
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
/** @param actionContainer action container that might contain the referenced method.
* @param actionId name of the requested action.
* @param forActor will be used as potential action argument.
* @return actor consumer constructed with container's method (or field) or null if action not found. */
protected ActorConsumer<?, ?> extractActionFromContainer(final ActionContainerWrapper actionContainer,
final String actionId, final Object forActor) {
Method method = actionContainer.getNamedMethod(actionId);
if (method == null && Lml.EXTRACT_UNANNOTATED_METHODS) {
method = findUnnamedMethod(actionContainer, actionId, forActor);
}
if (method != null) {
return new MethodActorConsumer(method, actionContainer.getActionContainer());
} else if (Lml.EXTRACT_FIELDS_AS_METHODS) {
Field field = actionContainer.getNamedField(actionId);
if (field == null && Lml.EXTRACT_UNANNOTATED_METHODS) {
field = actionContainer.getField(actionId);
}
if (field != null) {
return new FieldActorConsumer(field, actionContainer.getActionContainer());
}
}
return null;
}
示例5: mapClassFields
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
private void mapClassFields(final Class<?> containerClass) {
if (!Lml.EXTRACT_FIELDS_AS_METHODS) {
return;
}
for (final Field field : ClassReflection.getDeclaredFields(containerClass)) {
final LmlAction actionData = Reflection.getAnnotation(field, LmlAction.class);
if (actionData != null) {
final String[] ids = actionData.value();
if (ids.length > 0) {
for (final String actionId : ids) {
annotatedFields.put(actionId, field);
}
} else {
annotatedFields.put(field.getName(), field);
}
}
}
}
示例6: provide
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
@Override
public Asset provide(final Object target, final Member member) {
if (member == null) {
throwUnknownPathException();
}
final String id = member.getName();
if (Strings.isEmpty(id)) {
throwUnknownPathException();
}
final Asset asset = getOrLoad(id);
if (member instanceof FieldMember) {
if (asset == null) {
assetManager.addInjection( // Delayed asset injection - field will be filled when assets are loaded:
new AssetInjection(idsToPaths.get(id), getType(), ((FieldMember) member).getField(), target));
} else if (target instanceof Loaded) {
((Loaded) target).onLoad(idsToPaths.get(id), getType(), asset);
}
} else if (asset == null) {
Gdx.app.log(Lml.LOGGER_TAG, "Warn: requested instance of unloaded asset: " + id);
}
return asset;
}
示例7: initiateConfiguration
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
/** Thanks to the Initiate annotation, this method will be automatically invoked during context building. All
* method's parameters will be injected with values from the context.
*
* @param skinService contains GUI skin.
* @param interfaceService manages screens. */
@Initiate
public void initiateConfiguration(final SkinService skinService, final InterfaceService interfaceService) {
// Loading default VisUI skin with the selected scale:
VisUI.load("ui/skin.json");
// Registering VisUI skin with "default" name - this skin will be the default one for all LML widgets:
skinService.addSkin("default", VisUI.getSkin());
// Methods not annotated with @LmlAction will not be available in LML views.
Lml.EXTRACT_UNANNOTATED_METHODS = false;
// Changing title on bundles (re)load.
interfaceService.setActionOnBundlesReload(new Runnable() {
@Override
public void run() {
Gdx.graphics.setTitle(interfaceService.getParser().getData().getDefaultI18nBundle().get("title")
+ " - BialJam, M&M 2016");
}
});
// Changing the default resizer - centering actors on resize.
InterfaceService.DEFAULT_VIEW_RESIZER = new ViewResizer() {
@Override
public void resize(final Stage stage, final int width, final int height) {
stage.getViewport().update(width, height, true);
for (final Actor actor : stage.getActors()) {
Actors.centerActor(actor);
}
}
};
}
示例8: onParsingError
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
private void onParsingError(final Exception exception) {
// Printing the message without stack trace - we don't want to completely flood the console and its usually not
// relevant anyway. Change to '(...), "Unable to parse LML template:", exception);' for stacks.
Gdx.app.error(Lml.LOGGER_TAG, "Unable to parse LML template: " + exception);
resultTable.clear();
resultTable.add("Error occurred. Sorry.");
parser.fillStage(getStage(), Gdx.files.internal("templates/dialogs/error.lml"));
}
示例9: setStageViewport
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
/** Called by the {@link #create()} method to set {@link Viewport} instance of the GUI {@link Stage}. */
protected void setStageViewport() {
if (context.isAvailable(Viewport.class)) {
stage.setViewport(context.get(Viewport.class, stage));
} else {
Gdx.app.debug(Lml.LOGGER_TAG, "No provider found for Viewport.class. Using default Stage viewport.");
}
final Viewport viewport = stage.getViewport();
centerCamera = viewport instanceof ScreenViewport || viewport instanceof LetterboxingViewport;
}
示例10: dispose
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
@Override
public void dispose() {
super.dispose();
ApplicationPreferences.saveAllPreferences();
if (context != null) {
try {
context.destroy();
} catch (final Exception exception) {
Gdx.app.error(Lml.LOGGER_TAG, "Unable to destroy the context.", exception);
}
}
}
示例11: handleItemClick
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
@LmlAction("itemListener")
public void handleItemClick(final String selectedItem) {
// Printing selected item into the console:
Gdx.app.log(Lml.LOGGER_TAG, "Selected: " + selectedItem);
}
示例12: isOn
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
@Override
protected boolean isOn() {
return Lml.INFO_LOGS_ON;
}
示例13: isOn
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
@Override
protected boolean isOn() {
return Lml.ERROR_LOGS_ON;
}
示例14: isOn
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
@Override
protected boolean isOn() {
return Lml.DEBUG_LOGS_ON;
}
示例15: log
import com.github.czyzby.lml.util.Lml; //导入依赖的package包/类
/** @param message will be displayed in the console. */
protected void log(final String message) {
if (displayLogs) {
Gdx.app.log(Lml.LOGGER_TAG, message);
}
}