当前位置: 首页>>代码示例>>Java>>正文


Java JSONArray类代码示例

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


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

示例1: collectResourceGroup

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
private static ResourceGroup<TextureData> collectResourceGroup( @Nonnull final JSONArray jsonTilesets )
{
	final ResourceGroup<TextureData> textureResources = new ResourceGroup<>( jsonTilesets.length() );

	for( JSON json : jsonTilesets )
	{
		final JSONObject jsonTileset = checkNotNull( json.asObject() );

		final String image = checkNotNull( jsonTileset.getString( "image" ) );

		textureResources.add( TextureDataResource.from( image ) );
	}

	return textureResources;
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:17,代码来源:MapResources.java

示例2: decodeObjects

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
private static List<MapObject> decodeObjects( @Nonnull final JSONArray jsonArray )
{
	final ArrayList<MapObject> mapObjects = Lists.newArrayList( jsonArray.length() );

	for( final JSON json : jsonArray )
	{
		final MapObject mapObject = decodeObject( checkNotNull( json.asObject() ) );

		if( null != mapObject )
		{
			mapObjects.add( mapObject );
		}
	}

	return mapObjects;
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:18,代码来源:MapResources.java

示例3: decodeTileSets

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
private static TileSet[] decodeTileSets( @Nonnull final JSONArray jsonArray, @Nonnull final List<TextureData> textures )
{
	final TileSet[] tileSets = new TileSet[ jsonArray.length() ];

	int index = 0;

	for( final JSON json : jsonArray )
	{
		final JSONObject jsonObject = json.asObject();

		if( null == jsonObject )
			throw new RuntimeException( "Broken Json" );

		tileSets[ index ] = decodeTileSet( jsonObject, textures.get( index ) );

		index++;
	}

	return tileSets;
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:22,代码来源:MapResources.java

示例4: inflateDescriptors

import defrac.json.JSONArray; //导入依赖的package包/类
/**
 * Inflates an array of descriptors into a parent
 *
 * <p>This method should only be called from {@link #inflateRepetition(DisplayObjectContainer, JSONObject, int)}
 * and not manually.
 *
 * @param parent The parent
 * @param descriptors The array of descriptors
 *
 * @return The Future representing the completion of inflating the descriptors
 */
@Nonnull
private Future<Void> inflateDescriptors(@Nonnull final DisplayObjectContainer parent,
                                        @Nonnull final JSONArray descriptors) {
  final int descriptorCount = descriptors.length();

  final Future<Void> future;

  if(0 == descriptorCount) {
    future = success();
  } else if(1 == descriptorCount) {
    final JSON firstChild = descriptors.get(0);

    if(firstChild == null || !firstChild.isObject()) {
      future = success();
    } else {
      future = inflate(parent, (JSONObject)firstChild);
    }
  } else {
    future = inflateDescriptorsTrampoline(parent, descriptors, 0, descriptorCount);
  }

  return future;
}
 
开发者ID:defrac,项目名称:defrac-gaming,代码行数:35,代码来源:LayoutInflater.java

示例5: inflateDescriptorsTrampoline

import defrac.json.JSONArray; //导入依赖的package包/类
/**
 * Trampoline for asynchronous inflation of an array of descriptors into a parent
 *
 * @param parent The parent
 * @param descriptors The descriptor
 * @param descriptorIndex The current index in the descriptors array
 * @param descriptorCount The length of the descriptors array
 *
 * @return The Future representing the completion of inflating the descriptor {@code repeatCount - repeatIndex} times
 */
@Nonnull
private Future<Void> inflateDescriptorsTrampoline(@Nonnull final DisplayObjectContainer parent,
                                                  @Nonnull final JSONArray descriptors,
                                                  final int descriptorIndex,
                                                  final int descriptorCount) {
  final JSON descriptor = descriptors.get(descriptorIndex);
  final Future<Void> future = inflate(parent, descriptor == null ? null : descriptor.asObject());

  return future.flatMap(theVoid -> {
    final int nextDescriptorIndex = descriptorIndex + 1;

    if(nextDescriptorIndex == descriptorCount) {
      return success();
    } else {
      return inflateDescriptorsTrampoline(parent, descriptors, nextDescriptorIndex, descriptorCount);
    }
  }, context.dispatcher());
}
 
开发者ID:defrac,项目名称:defrac-gaming,代码行数:29,代码来源:LayoutInflater.java

示例6: readCurve

import defrac.json.JSONArray; //导入依赖的package包/类
private static void readCurve(@Nonnull final CurveTimeline timeline,
                              final int frameIndex,
                              @Nonnull final JSONObject valueMap) {
  final JSON curve = valueMap.opt("curve");

  if(curve.isString() && "stepped".equals(curve.stringValue())) {
    timeline.setSteppedAt(frameIndex);
  } else if (curve.isArray()) {
    final JSONArray curveArray = (JSONArray)curve;

    timeline.setCurve(
        frameIndex,
        curveArray.getFloat(0), curveArray.getFloat(1),
        curveArray.getFloat(2), curveArray.getFloat(3));
  }
}
 
开发者ID:defrac,项目名称:defrac-gaming,代码行数:17,代码来源:SkeletonJson.java

示例7: readTranslateTimeline

import defrac.json.JSONArray; //导入依赖的package包/类
private static float readTranslateTimeline(@Nonnull final  Array<Timeline> timelines,
                                           final int boneIndex,
                                           final float duration,
                                           @Nonnull final JSONArray timelineData,
                                           @Nonnull final TranslateTimeline timeline,
                                           final float timelineScale) {
  timeline.boneIndex = boneIndex;

  for(int frameIndex = 0, frameCount = timelineData.size(); frameIndex < frameCount; ++frameIndex) {
    final JSONObject valueMap = timelineData.optObject(frameIndex);
    final float x = valueMap.optFloat("x", 0.0f) * timelineScale;
    final float y = valueMap.optFloat("y", 0.0f) * timelineScale;
    timeline.setFrame(frameIndex, valueMap.getFloat("time"), x, y);
    readCurve(timeline, frameIndex, valueMap);
  }

  timelines.push(timeline);
  return Math.max(duration, timeline.frames()[timeline.frameCount() * 3 - 3]);
}
 
开发者ID:defrac,项目名称:defrac-gaming,代码行数:20,代码来源:SkeletonJson.java

示例8: readFlipTimeline

import defrac.json.JSONArray; //导入依赖的package包/类
private static float readFlipTimeline(@Nonnull final Array<Timeline> timelines,
                                      final int boneIndex,
                                      final float duration,
                                      @Nonnull final JSONArray timelineData,
                                      @Nonnull final String field,
                                      @Nonnull final FlipXTimeline timeline) {
  timeline.boneIndex = boneIndex;

  for(int frameIndex = 0, frameCount = timelineData.size(); frameIndex < frameCount; ++frameIndex) {
    final JSONObject value = timelineData.optObject(frameIndex);
    timeline.setFrame(frameIndex, value.getFloat("time"), value.optBoolean(field, false));
  }

  timelines.push(timeline);
  return Math.max(duration, timeline.frames()[timeline.frameCount() * 3 - 3]);
}
 
开发者ID:defrac,项目名称:defrac-gaming,代码行数:17,代码来源:SkeletonJson.java

示例9: setTargets

import defrac.json.JSONArray; //导入依赖的package包/类
@NotNull
public DefracConfigBase setTargets(@NotNull final DefracPlatform[] value) {
  final JSONArray array = new JSONArray();

  for(final DefracPlatform target : value) {
    if(target == null || target.isGeneric()) {
      continue;
    }

    array.push(target.name);
  }

  json.put("targets", array);

  return this;
}
 
开发者ID:defrac,项目名称:defrac-plugin-intellij,代码行数:17,代码来源:DefracConfigBase.java

示例10: decodeLayers

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
private static MapLayer[] decodeLayers( @Nonnull final JSONArray jsonArray )
{
	final MapLayer[] mapLayers = new MapLayer[ jsonArray.length() ];

	int index = 0;

	for( final JSON json : jsonArray )
		mapLayers[ index++ ] = decodeLayer( checkNotNull( json.asObject() ) );

	return mapLayers;
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:13,代码来源:MapResources.java

示例11: decodePolyLine

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
private static MapObject decodePolyLine(
		@Nonnull final String name,
		@Nonnull final JSONArray jsonArray,
		final int x, final int y,
		final int width, final int height,
		final boolean visible,
		final boolean closed )
{
	final int n = jsonArray.length();

	final Point[] points = new Point[ n + ( closed ? 1 : 0 ) ];

	for( int i = 0 ; i < n ; ++i )
	{
		final JSON json = jsonArray.get( i );
		assert json != null;

		final JSONObject jsonPoint = json.asObject();
		assert jsonPoint != null;

		points[ i ] = new Point( jsonPoint.getInt( "x" ), jsonPoint.getInt( "y" ) );
	}

	if( closed )
	{
		points[ n ] = points[ 0 ];
	}

	return new ObjectPolyLine( x, y, width, height, visible, name, points );
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:32,代码来源:MapResources.java

示例12: decodeAnimation

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
@SuppressWarnings( "SpellCheckingInspection" )
private static TileAnimation decodeAnimation( @Nonnull final JSONArray jsonArray )
{
	int relativeTime = 0;

	final TileAnimation.Builder builder = new TileAnimation.Builder( jsonArray.length() );

	for( final JSON json : jsonArray )
	{
		final JSONObject jsonObject = json.asObject();
		assert null != jsonObject;

		final int duration = jsonObject.getInt( "duration" );
		final int tileId = jsonObject.getInt( "tileid" );

		if( 0 == duration )
		{
			builder.add( Integer.MAX_VALUE, tileId );

			return builder.build();
		}
		else
		{
			builder.add( relativeTime += duration, tileId );
		}
	}

	return builder.build();
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:31,代码来源:MapResources.java

示例13: decodeDataIntegerArray

import defrac.json.JSONArray; //导入依赖的package包/类
@Nonnull
private static int[] decodeDataIntegerArray( @Nonnull final JSONArray dataJSON )
{
	final int numData = dataJSON.length();

	final int[] data = new int[ numData ];

	for( int i = 0 ; i < numData ; ++i )
		data[ i ] = ( int ) ( dataJSON.getLong( i ) & 0xFFFFFFFFL ); // Avoid int overflow

	return data;
}
 
开发者ID:andremichelle,项目名称:platforms,代码行数:13,代码来源:MapResources.java

示例14: rootChildren

import defrac.json.JSONArray; //导入依赖的package包/类
/**
 * Resolves and returns the controls array in the layout root
 *
 * @param layoutRoot The layout root
 * @return An array of controls in the layout root
 */
@Nonnull
private JSONArray rootChildren(@Nonnull final JSONObject layoutRoot) {
  return context.
      resolveProperty(layoutRoot, KEY_CHILDREN, JSONArray.EMPTY).
      asArray(JSONArray.EMPTY);
}
 
开发者ID:defrac,项目名称:defrac-gaming,代码行数:13,代码来源:LayoutInflater.java


注:本文中的defrac.json.JSONArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。