Examples of NinePatch


Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  public Button (TextureRegion region) {
    this(new ButtonStyle(new NinePatch(region), null, null, 0f, 0f, 0f, 0f));
  }

  public Button (TextureRegion regionUp, TextureRegion regionDown) {
    this(new ButtonStyle(new NinePatch(regionUp), new NinePatch(regionDown), null, 0f, 0f, 0f, 0f));
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  public Button (TextureRegion regionUp, TextureRegion regionDown) {
    this(new ButtonStyle(new NinePatch(regionUp), new NinePatch(regionDown), null, 0f, 0f, 0f, 0f));
  }

  public Button (TextureRegion regionUp, TextureRegion regionDown, TextureRegion regionChecked) {
    this(new ButtonStyle(new NinePatch(regionUp), new NinePatch(regionDown), new NinePatch(regionChecked), 0f, 0f, 0f, 0f));
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  public NinePatch newTintedPatch (String patchName, String colorName) {
    return newTintedPatch(patchName, getColor(colorName));
  }

  public NinePatch newTintedPatch (String patchName, Color color) {
    return new NinePatch(getPatch(patchName), color);
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  public NinePatch newTintedRegion (String regionName, String colorName) {
    return newTintedRegion(regionName, getColor(colorName));
  }

  public NinePatch newTintedRegion (String regionName, Color color) {
    NinePatch patch = new NinePatch(getRegion(regionName));
    patch.setColor(color);
    return patch;
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

      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;
          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;
        }
      }
    });

    json.setSerializer(Color.class, new Serializer<Color>() {
      public void write (Json json, Color color, Class valueType) {
        json.writeObjectStart();
        json.writeFields(color);
        json.writeObjectEnd();
      }

      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);
      }
    });

    json.setSerializer(TintedNinePatch.class, new Serializer() {
      public void write (Json json, Object tintedPatch, Class valueType) {
        json.writeObjectStart();
        json.writeField(tintedPatch, "name");
        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);
      }
    });

    return json;
  }
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.