Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.Json.readValue()


      }

      public NinePatch read (Json json, Object jsonData, Class type) {
        if (jsonData instanceof String) return getResource((String)jsonData, NinePatch.class);
        if (jsonData instanceof Array) {
          TextureRegion[] regions = json.readValue(TextureRegion[].class, jsonData);
          if (regions.length == 1) return new NinePatch(regions[0]);
          return new NinePatch(regions);
        } else {
          ObjectMap map = (ObjectMap)jsonData;
          NinePatch ninePatch;
View Full Code Here


          return new NinePatch(regions);
        } else {
          ObjectMap map = (ObjectMap)jsonData;
          NinePatch ninePatch;
          if (map.containsKey("regions"))
            ninePatch = new NinePatch(json.readValue("regions", TextureRegion[].class, jsonData));
          else if (map.containsKey("region"))
            ninePatch = new NinePatch(json.readValue("region", TextureRegion.class, jsonData));
          else
            ninePatch = new NinePatch(json.readValue(TextureRegion.class, jsonData));
          // throw new SerializationException("Missing ninepatch regions: " + map);
View Full Code Here

          ObjectMap map = (ObjectMap)jsonData;
          NinePatch ninePatch;
          if (map.containsKey("regions"))
            ninePatch = new NinePatch(json.readValue("regions", TextureRegion[].class, jsonData));
          else if (map.containsKey("region"))
            ninePatch = new NinePatch(json.readValue("region", TextureRegion.class, jsonData));
          else
            ninePatch = new NinePatch(json.readValue(TextureRegion.class, jsonData));
          // throw new SerializationException("Missing ninepatch regions: " + map);
          if (map.containsKey("color")) ninePatch.setColor(json.readValue("color", Color.class, jsonData));
          return ninePatch;
View Full Code Here

          if (map.containsKey("regions"))
            ninePatch = new NinePatch(json.readValue("regions", TextureRegion[].class, jsonData));
          else if (map.containsKey("region"))
            ninePatch = new NinePatch(json.readValue("region", TextureRegion.class, jsonData));
          else
            ninePatch = new NinePatch(json.readValue(TextureRegion.class, jsonData));
          // throw new SerializationException("Missing ninepatch regions: " + map);
          if (map.containsKey("color")) ninePatch.setColor(json.readValue("color", Color.class, jsonData));
          return ninePatch;
        }
      }
View Full Code Here

          else if (map.containsKey("region"))
            ninePatch = new NinePatch(json.readValue("region", TextureRegion.class, jsonData));
          else
            ninePatch = new NinePatch(json.readValue(TextureRegion.class, jsonData));
          // throw new SerializationException("Missing ninepatch regions: " + map);
          if (map.containsKey("color")) ninePatch.setColor(json.readValue("color", Color.class, jsonData));
          return ninePatch;
        }
      }
    });
View Full Code Here

      }

      public Color read (Json json, Object jsonData, Class type) {
        if (jsonData instanceof String) return getResource((String)jsonData, Color.class);
        ObjectMap map = (ObjectMap)jsonData;
        float r = json.readValue("r", float.class, 0f, jsonData);
        float g = json.readValue("g", float.class, 0f, jsonData);
        float b = json.readValue("b", float.class, 0f, jsonData);
        float a = json.readValue("a", float.class, 1f, jsonData);
        return new Color(r, g, b, a);
      }
View Full Code Here

      public Color read (Json json, Object jsonData, Class type) {
        if (jsonData instanceof String) return getResource((String)jsonData, Color.class);
        ObjectMap map = (ObjectMap)jsonData;
        float r = json.readValue("r", float.class, 0f, jsonData);
        float g = json.readValue("g", float.class, 0f, jsonData);
        float b = json.readValue("b", float.class, 0f, jsonData);
        float a = json.readValue("a", float.class, 1f, jsonData);
        return new Color(r, g, b, a);
      }
    });
View Full Code Here

      public Color read (Json json, Object jsonData, Class type) {
        if (jsonData instanceof String) return getResource((String)jsonData, Color.class);
        ObjectMap map = (ObjectMap)jsonData;
        float r = json.readValue("r", float.class, 0f, jsonData);
        float g = json.readValue("g", float.class, 0f, jsonData);
        float b = json.readValue("b", float.class, 0f, jsonData);
        float a = json.readValue("a", float.class, 1f, jsonData);
        return new Color(r, g, b, a);
      }
    });
View Full Code Here

        if (jsonData instanceof String) return getResource((String)jsonData, Color.class);
        ObjectMap map = (ObjectMap)jsonData;
        float r = json.readValue("r", float.class, 0f, jsonData);
        float g = json.readValue("g", float.class, 0f, jsonData);
        float b = json.readValue("b", float.class, 0f, jsonData);
        float a = json.readValue("a", float.class, 1f, jsonData);
        return new Color(r, g, b, a);
      }
    });

    json.setSerializer(TintedNinePatch.class, new Serializer() {
View Full Code Here

        json.writeField(tintedPatch, "color");
        json.writeObjectEnd();
      }

      public Object read (Json json, Object jsonData, Class type) {
        String name = json.readValue("name", String.class, jsonData);
        Color color = json.readValue("color", Color.class, jsonData);
        return new NinePatch(getResource(name, NinePatch.class), color);
      }
    });
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.