Java 类com.badlogic.gdx.utils.OrderedMap 实例源码

项目:skin-composer    文件:JsonData.java   
@Override
public void read(Json json, JsonValue jsonData) {
    try {
        colors = json.readValue("colors", Array.class, jsonData);
        fonts = json.readValue("fonts", Array.class, jsonData);
        classStyleMap = new OrderedMap<>();
        for (JsonValue data : jsonData.get("classStyleMap").iterator()) {
            classStyleMap.put(ClassReflection.forName(data.name), json.readValue(Array.class, data));
        }
        for (Array<StyleData> styleDatas : classStyleMap.values()) {
            for (StyleData styleData : styleDatas) {
                styleData.jsonData = this;
            }
        }
        customClasses = json.readValue("customClasses", Array.class, CustomClass.class, new Array<>(), jsonData);
        for (CustomClass customClass : customClasses) {
            customClass.setMain(main);
        }
    } catch (ReflectionException e) {
        Gdx.app.log(getClass().getName(), "Error parsing json data during file read", e);
        main.getDialogFactory().showDialogError("Error while reading file...", "Error while attempting to read save file.\nPlease ensure that file is not corrupted.\n\nOpen error log?");
    }
}
项目:fabulae    文件:UsableItem.java   
@Override
public InventoryItem createNewInstance() {
    UsableItem returnValue = (UsableItem) super.createNewInstance();
    returnValue.usesLeft = s_maxUses;
    returnValue.useCondition = useCondition;
    returnValue.targetType = targetType;
    returnValue.targetScript = targetScript;
    returnValue.effects = new OrderedMap<Effect, Array<EffectParameter>>();
    for (Effect key : effects.keys()) {
        Array<EffectParameter> originalParams = effects.get(key);
        Array<EffectParameter> newCopyParam = new Array<EffectParameter>();
        for (EffectParameter param : originalParams) {
            newCopyParam.add(param);
        }
        returnValue.effects.put(key, newCopyParam);
    }
return returnValue;
}
项目:RuinsOfRevenge    文件:JsonDOM.java   
@SuppressWarnings("unchecked")
public void readJsonObject(JsonObject element, OrderedMap<String, Object> jsonData) {
    Entries<String, Object> entries = jsonData.entries();
    for (Entry<String, Object> entry : entries) {
        if (entry.value instanceof OrderedMap) {
            JsonObject obj = new JsonObject();
            element.elements.put(entry.key, obj);

            // unchecked, but safe:
            readJsonObject(obj, (OrderedMap<String, Object>) entry.value);
        } else if (entry.value instanceof Array) {
            JsonArray arr = new JsonArray();
            element.elements.put(entry.key, arr);

            // unchecked, but safe:
            readJsonArray(arr, (Array<OrderedMap<String, Object>>) entry.value);
        } else {
            element.values.put(entry.key, entry.value.toString());
        }
    }
}
项目:Gensokyo_LibGdx    文件:Profile.java   
/***
 *      Implement Json Serializable
 */
@SuppressWarnings("unchecked")
@Override
public void read(Json json, OrderedMap<String, Object> jsonData)
{
    // read basic properties
    currentLevelId = json.readValue("currentLevelId", Integer.class, jsonData);
    credits = json.readValue("credits", Integer.class, jsonData);

    // change Json Hashmap default formatted strings to integers (levelId)
    Map<String, Integer> highScores = json.readValue("highScores", HashMap.class, Integer.class, jsonData);
    for (String levelIdAsString : highScores.keySet())
    {
        int levelId = Integer.valueOf(levelIdAsString);
        Integer highScore = highScores.get(levelIdAsString);
        this.highScores.put(levelId, highScore);
    }

    // read the playerCharacter
    playerCharacter = json.readValue("playerCharacter", PlayerCharacter.class, jsonData);

}
项目:Mindustry    文件:MapFilter.java   
private static OrderedMap<String, GenPref> map(GenPref...objects){
    OrderedMap<String, GenPref> prefs = new OrderedMap<>();

    for(int i = 0; i < objects.length; i ++){
        GenPref pref = (GenPref)objects[i];
        prefs.put(pref.name, pref);
    }
    return prefs;
}
项目:Undertailor    文件:TilemapFactory.java   
Tilemap() {
    this.objects = new ObjectMap<>();
    this.entrypoints = new ObjectMap<>();
    this.tileLayers = new Array<>(true, 16);
    this.imageLayers = new Array<>(true, 16);
    this.tilesets = new OrderedMap<>();
}
项目:Undertailor    文件:UIController.java   
public UIController(Environment parent, MultiRenderer renderer) {
    this.destroyed = false;
    this.renderer = renderer;
    this.environment = parent;
    this.removed = new ObjectSet<>();
    this.events = new EventHelper(this);
    this.camera = new OrthographicCamera(OverworldController.RENDER_WIDTH,
        OverworldController.RENDER_HEIGHT);
    this.camera.position.x += OverworldController.RENDER_WIDTH / 2F;
    this.camera.position.y += OverworldController.RENDER_HEIGHT / 2F;
    this.camera.update();

    this.aObj = new OrderedMap<>();
    this.bObj = new OrderedMap<>();
}
项目:Undertailor    文件:Text.java   
private Text() {
    this.components = new OrderedMap<>();

    this.instantiationTime = TimeUtils.millis();
    this.stringBounds = new Pair<>(0, 0);
    this.spaceTaken = new Pair<>(-1F, -1F);
    this.transform = new Transform();

    this.m_valuePair = new Pair<>();
    this.m_drawnTransform = new Transform();
}
项目:skin-composer    文件:StyleData.java   
public StyleData(StyleData styleData, String styleName, Main main) {
    name = styleName;
    this.main = main;

    clazz = styleData.clazz;
    properties = new OrderedMap<>();
    for (Entry<String, StyleProperty> entry : styleData.properties.entries()) {
        properties.put(entry.key, new StyleProperty(entry.value));
    }
    deletable = true;
}
项目:skin-composer    文件:StyleData.java   
public StyleData (Class clazz, String styleName, Main main) {
    name = styleName;
    this.main = main;

    this.clazz = clazz;
    properties = new OrderedMap<>();
    deletable = true;

    resetProperties();
}
项目:skin-composer    文件:StyleData.java   
@Override
public void read(Json json, JsonValue jsonData) {
    name = jsonData.getString("name");
    properties = json.readValue("properties", OrderedMap.class, jsonData);
    deletable = jsonData.getBoolean("deletable");
    try {
        clazz = ClassReflection.forName(jsonData.getString("clazz"));
    } catch (ReflectionException ex) {
        Gdx.app.error(getClass().toString(), "Error reading from serialized object" , ex);
        main.getDialogFactory().showDialogError("Read Error...","Error reading from serialized object.\n\nOpen log?");
    }
}
项目:fabulae    文件:OrderedAssetManager.java   
@Override
protected <T> void addAsset(String fileName, Class<T> type, T asset) {
    super.addAsset(fileName, type, asset);

    // this is VERY ugly, but a bit more future proof in case of changes in the parent
    // than just copying the parent method
    ObjectMap<String, RefCountedContainer> typeToAssets = assets.get(type);

    if (!(typeToAssets instanceof OrderedMap)) {
        RefCountedContainer value = typeToAssets.get(fileName);
        typeToAssets = new OrderedMap<String, RefCountedContainer>();
        typeToAssets.put(fileName, value);
        assets.put(type, typeToAssets);
    }
}
项目:fabulae    文件:TrapType.java   
public TrapType(FileHandle file) throws IOException {
    s_id = file.nameWithoutExtension().toLowerCase(Locale.ENGLISH);
    s_effects =  new OrderedMap<Effect, Array<EffectParameter>>();
    s_projectile = null;
    s_automaticOnHitAnimation = true;
    loadFromXML(file);
}
项目:fabulae    文件:Weapon.java   
@Override
public void loadFromXML(FileHandle file) throws IOException {
    effects =  new OrderedMap<Effect, Array<EffectParameter>>();
    super.loadFromXML(file);
    if (s_weaponDamageMax < s_weaponDamageMin) {
        throw new GdxRuntimeException("Max damage cannot be less than min damage for "+getId());
    }
}
项目:fabulae    文件:Weapon.java   
@Override
public InventoryItem createNewInstance() {
    Weapon newInstance = (Weapon) super.createNewInstance();
    newInstance.effects = new OrderedMap<Effect, Array<EffectParameter>>();
    for (Entry<Effect, Array<EffectParameter>> entry : this.effects.entries()) {
        newInstance.effects.put(entry.key, entry.value);
    }
    return newInstance;     
}
项目:fabulae    文件:Perk.java   
public Perk(FileHandle file) throws IOException {
    s_id = file.nameWithoutExtension().toLowerCase(Locale.ENGLISH);
    s_modifiers = new Array<Modifier>();
    s_effects =  new OrderedMap<Effect, Array<EffectParameter>>();
    s_isAttack = false;
    s_isActivated = false;
    s_automaticOnHitAnimation = true;
    projectile = null;
    loadFromXML(file);
}
项目:gdx-twitter    文件:TwitterSignature.java   
private void percentEncodeAndOrderParameters() {
    percentEncodedParameters = new OrderedMap<String, String>();

    ObjectMap.Entries<String, String> entries = parameters.iterator();

    while (entries.hasNext()) {
        ObjectMap.Entry<String, String> pair = entries.next();
        percentEncodedParameters.put(PercentEncoder.encode(pair.key), PercentEncoder.encode(pair.value));
    }

}
项目:gdx-kiwi    文件:GdxMaps.java   
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key.
 * @return a new ordered map with the given values. Not fail-fast - be careful when passing arguments, or it might
 *         result in unexpected map values. */
@SuppressWarnings("unchecked")
public static <Key, Value> OrderedMap<Key, Value> newOrderedMap(final Object... keyAndValues) {
    if (keyAndValues.length % 2 != 0) {
        throw new IllegalArgumentException("Total number of keys and values has to be even.");
    }
    final OrderedMap<Key, Value> map = new OrderedMap<Key, Value>();
    for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) {
        map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]);
    }
    return map;
}
项目:gdx-lml    文件:GdxMaps.java   
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key.
 * @return a new ordered map with the given values. Not fail-fast - be careful when passing arguments, or it might
 *         result in unexpected map values.
 * @param <Key> type of map keys.
 * @param <Value> type of map values. */
@SuppressWarnings("unchecked")
public static <Key, Value> OrderedMap<Key, Value> newOrderedMap(final Object... keyAndValues) {
    if (keyAndValues.length % 2 != 0) {
        throw new IllegalArgumentException("Total number of keys and values has to be even.");
    }
    final OrderedMap<Key, Value> map = new OrderedMap<Key, Value>();
    for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) {
        map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]);
    }
    return map;
}
项目:gdx-lml    文件:GdxMaps.java   
/** @param map will be copied.
 * @return a new ordered map with the passed values.
 * @param <Key> type of map keys.
 * @param <Value> type of map values. */
public static <Key, Value> OrderedMap<Key, Value> toOrdered(final ObjectMap<? extends Key, ? extends Value> map) {
    final OrderedMap<Key, Value> orderedMap = new OrderedMap<Key, Value>();
    for (final ObjectMap.Entry<? extends Key, ? extends Value> entry : map) {
        orderedMap.put(entry.key, entry.value);
    }
    return orderedMap;
}
项目:dictson    文件:Dictson.java   
/**
 * Returns a Dictson instance with the text values obtained from dictionary.json file
 * 
 * @param aLocale
 * @return a Dictson instance with the requested Locale or English if not supported
 */
@SuppressWarnings("unchecked")
public static Dictson getInstance(Locale aLocale) {
    INSTANCE.wordsMap = new Json().fromJson(OrderedMap.class, Gdx.files.internal("data/dictionary.json"));
    INSTANCE.setLocale(getSupportedLocale(aLocale));
    return INSTANCE;
}
项目:libgdxcn    文件:PixmapPacker.java   
private void newPage () {
    Page page = new Page();
    page.image = new Pixmap(pageWidth, pageHeight, pageFormat);
    page.root = new Node(0, 0, pageWidth, pageHeight, null, null, null);
    page.rects = new OrderedMap<String, Rectangle>();
    pages.add(page);
    currPage = page;
}
项目:RuinsOfRevenge    文件:JsonDOM.java   
public void readJsonArray(JsonArray array, Array<OrderedMap<String, Object>> jsonArray) {
    for (OrderedMap<String, Object> jsonObject : jsonArray) {
        JsonObject obj = new JsonObject();
        array.elements.add(obj);
        readJsonObject(obj, jsonObject);
    }
}
项目:Gensokyo_LibGdx    文件:PlayerCharacter.java   
/***
 *      Implement Json Serializable utility
 */
@Override
public void read(Json json, OrderedMap<String, Object> jsonData)
{
    playerModel = PlayerModel.valueOf (json.readValue("playerModel", String.class, jsonData));
    spellType = SpellType.valueOf (json.readValue("spellType", String.class, jsonData));
    shield = Shield.valueOf (json.readValue("shield", String.class, jsonData));
}
项目:ingress-indonesia-dev    文件:PixmapPacker.java   
private void newPage()
{
  PixmapPacker.Page localPage = new PixmapPacker.Page(this);
  localPage.image = new Pixmap(this.pageWidth, this.pageHeight, this.pageFormat);
  localPage.root = new PixmapPacker.Node(0, 0, this.pageWidth, this.pageHeight, null, null, null);
  localPage.rects = new OrderedMap();
  this.pages.add(localPage);
  this.currPage = localPage;
}
项目:gdx-cclibs    文件:OrderedMapSerializer.java   
@Override
public OrderedMap create (int length){
    return new OrderedMap(length);
}
项目:Undertailor    文件:Scheduler.java   
public Scheduler(Environment env) {
    this.env = env;
    this.destroyed = false;
    this.tasks = new LongMap<>();
    this.activeTasks = new OrderedMap<>();
}
项目:Undertailor    文件:Text.java   
/**
 * Internal method.
 * 
 * <p>Responsible for DRYing the process of iterating
 * through each character within the string bounds.</p>
 * 
 * <p>The consumer takes a pair of integers and a
 * TextComponent. The first integer is the index of the
 * component's first character in the entire text. The
 * second integer is the index of the current character,
 * local to the scope of the current TextComponent.</p>
 * 
 * <p>Assume a component with the text content <code>
 * "Hello, world!"</code>. To point to the character
 * <code>o</code> at index 4, the consumer is provided
 * with 4 and the component holding the text
 * <code>(component.getText().charAt(4) =
 * 'o')</code></p>
 * 
 * @param consumer the consumer that processes each
 *        character
 */
private void processCharacters(BiConsumer<Pair<Integer>, TextComponent> consumer) {
    int boundL = this.getStringBounds().getA();
    int boundR = this.getStringBounds().getB();

    if (boundL < 0) {
        boundL = this.getText().length() - Math.abs(boundL);
    }

    if (boundR < 0) {
        boundR = this.getText().length() - Math.abs(boundR);
    }

    TextComponent first = boundL == 0 ? null : this.getTextComponentAt(boundL);
    TextComponent last = boundR == 0 ? null : this.getTextComponentAt(boundR);
    for (OrderedMap.Entry<Integer, TextComponent> entry : this.components.entries()) {
        if (first != null) { // if first is null, we've found the first component to iterate through
            if (entry.value != first) {
                continue;
            }

            first = null;
        }

        int localIndex = 0;
        if (boundL != 0 && entry.key < boundL) {
            localIndex += boundL - entry.key;
        }

        this.m_valuePair.setA(entry.key);
        for (int ind = localIndex; ind < entry.value.getText().length(); ind++) {
            this.m_valuePair.setB(ind);
            consumer.accept(this.m_valuePair, entry.value);

            if (boundR != 0 && entry.key + ind >= boundR) {
                return;
            }
        }

        if (entry.value == last) {
            return;
        }
    }
}
项目:skin-composer    文件:JsonData.java   
public OrderedMap<Class, Array<StyleData>> getClassStyleMap() {
    return classStyleMap;
}
项目:skin-composer    文件:RootTable.java   
public StyleData getSelectedStyle() {
    OrderedMap<Class, Array<StyleData>> classStyleMap = main.getProjectData().getJsonData().getClassStyleMap();
    return classStyleMap.get(getSelectedClass()).get(styleSelectBox.getSelectedIndex());
}
项目:fabulae    文件:UsableItem.java   
@Override
public void loadFromXML(FileHandle file) throws IOException {
    effects = new OrderedMap<Effect, Array<EffectParameter>>();
    super.loadFromXML(file);
}
项目:gdx-twitter    文件:TwitterRequest.java   
public TwitterRequest build() {

        if (this.token != null && this.token.length() > 0) {
            put("oauth_token", this.token);
        }

        headerString = "OAuth ";

        String timestamp = Long.toString(TimeUtils.millis() / 1000L);

        put("oauth_consumer_key", this.consumerKey);
        put("oauth_nonce", timestamp + "NOUNCE");
        put("oauth_signature_method", "HMAC-SHA1");
        put("oauth_timestamp", timestamp);
        put("oauth_version", "1.0");

        TwitterSignature twitterSignature = new TwitterSignature(requestType, this.url, this.consumerSecret, this.tokenSecret, parameters);
        String signature = twitterSignature.getSignature();
        put("oauth_signature", signature);

        OrderedMap.Entries<String, String> entries = parameters.iterator();

        while (entries.hasNext()) {
            OrderedMap.Entry<String, String> pair = entries.next();

            if (pair.key.equals("oauth_token") || pair.key.equals("oauth_signature") || pair.key.equals("oauth_version") || pair.key.equals("oauth_consumer_key")
                    || pair.key.equals("oauth_nonce") || pair.key.equals("oauth_signature_method") || pair.key.equals("oauth_timestamp")) {
                headerString += PercentEncoder.encode(pair.key) + "=\"" + PercentEncoder.encode(pair.value) + "\", ";
            } else {
                dataString += PercentEncoder.encode(pair.key) + "=" + PercentEncoder.encode(pair.value) + "&";
            }
        }

        headerString = headerString.substring(0, headerString.length() - 2);

        if (dataString.length() > 0) {
            dataString = dataString.substring(0, dataString.length() - 1);
        }

        return this;
    }
项目:gdx-kiwi    文件:GdxMaps.java   
/** @return an empty, new ordered map. */
public static <Key, Value> OrderedMap<Key, Value> newOrderedMap() {
    return new OrderedMap<Key, Value>();
}
项目:gdx-kiwi    文件:GdxMaps.java   
/** @return a new ordered map with the passed values. */
public static <Key, Value> OrderedMap<Key, Value> newOrderedMap(
        final ObjectMap<? extends Key, ? extends Value> map) {
    return new OrderedMap<Key, Value>(map);
}
项目:gdx-kiwi    文件:GdxMaps.java   
/** @return a new ordered map with the passed values. */
public static <Key, Value> OrderedMap<Key, Value> toOrdered(final ObjectMap<? extends Key, ? extends Value> map) {
    return new OrderedMap<Key, Value>(map);
}
项目:gdx-lml    文件:GdxMaps.java   
/** @return an empty, new ordered map.
 * @param <Key> type of map keys.
 * @param <Value> type of map values. */
public static <Key, Value> OrderedMap<Key, Value> newOrderedMap() {
    return new OrderedMap<Key, Value>();
}
项目:gdx-lml    文件:GdxMaps.java   
/** @param map will be copied.
 * @return a new ordered map with the passed values.
 * @param <Key> type of map keys.
 * @param <Value> type of map values. */
public static <Key, Value> OrderedMap<Key, Value> newOrderedMap(
        final OrderedMap<? extends Key, ? extends Value> map) {
    return new OrderedMap<Key, Value>(map);
}
项目:libgdxcn    文件:PixmapPacker.java   
public OrderedMap<String, Rectangle> getRects () {
    return rects;
}
项目:vis-editor    文件:EnumSelectBox.java   
protected OrderedMap<String, E> getEnumMap () {
    return enumMap;
}
项目:RuinsOfRevenge    文件:JsonDOM.java   
@Override
public void read(Json json, OrderedMap<String, Object> jsonData) {
    readJsonObject(root, jsonData);
}