本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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));
}
}
示例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]);
}
示例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]);
}
示例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;
}
示例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;
}
示例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 );
}
示例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();
}
示例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;
}
示例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);
}