private static void patchHiDPI(UIDefaults defaults) {
    if (!JBUI.isHiDPI()) return;

    List<String> myIntKeys = Arrays.asList("Tree.leftChildIndent", "Tree.rightChildIndent");
    List<String> patched = new ArrayList<String>();
    for (Map.Entry<Object, Object> entry : defaults.entrySet()) {
      Object value = entry.getValue();
      String key = entry.getKey().toString();
      if (value instanceof DimensionUIResource) {
        entry.setValue(JBUI.size((DimensionUIResource) value).asUIResource());
      } else if (value instanceof InsetsUIResource) {
        entry.setValue(JBUI.insets(((InsetsUIResource) value)).asUIResource());
      } else if (value instanceof Integer) {
        if (key.endsWith(".maxGutterIconWidth") || myIntKeys.contains(key)) {
          if (!"true".equals(defaults.get(key + ".hidpi.patched"))) {
            entry.setValue(Integer.valueOf(JBUI.scale((Integer) value)));
            patched.add(key);
          }
        }
      }
    }
    for (String key : patched) {
      defaults.put(key + ".hidpi.patched", "true");
    }
  }
示例#2
0
  @Override
  public void registerIcons(IIconRegister iconRegister) {
    // register icons as usually
    super.registerIcons(iconRegister);

    // now we flip all the different part icons, so we only need 1 graphic for 4 different
    // orientations \o/
    // handle first: flip x
    Iterator<Map.Entry<Integer, IIcon>> iter = handleIcons.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry<Integer, IIcon> entry = iter.next();
      entry.setValue(new IconFlipped(entry.getValue(), true, false));
      // the entry object should reference the direct object in the map, no further updating needed
    }

    // accessory: flip y
    iter = accessoryIcons.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry<Integer, IIcon> entry = iter.next();
      entry.setValue(new IconFlipped(entry.getValue(), false, true));
    }

    // extra: flip x and y
    iter = extraIcons.entrySet().iterator();
    while (iter.hasNext()) {
      Map.Entry<Integer, IIcon> entry = iter.next();
      entry.setValue(new IconFlipped(entry.getValue(), true, true));
    }
  }
示例#3
0
 @Override
 public Map.Entry<String, Object> next() {
   Map.Entry<String, Object> entry = mapIter.next();
   if (entry.getValue() instanceof Map) {
     entry.setValue(new JsonObject((Map) entry.getValue()));
   } else if (entry.getValue() instanceof List) {
     entry.setValue(new JsonArray((List) entry.getValue()));
   }
   return entry;
 }
示例#4
0
 /**
  * Utility method that replaces the values of a {@link Map}, which must be instances of {@link
  * List}, with unmodifiable equivalents.
  *
  * @param map The map whose values are to be made unmodifiable.
  */
 protected static void makeMappedListsUnmodifiable(Map map) {
   for (Iterator it = map.entrySet().iterator(); it.hasNext(); ) {
     Map.Entry entry = (Map.Entry) it.next();
     List value = (List) entry.getValue();
     if (value.size() == 0) {
       entry.setValue(Collections.EMPTY_LIST);
     } else {
       entry.setValue(Collections.unmodifiableList(value));
     }
   }
 }
  @Test
  public void entry_setValue() {
    MutableMap<Integer, String> map = this.newMapWithKeyValue(1, "One");
    Map.Entry<Integer, String> entry = Iterate.getFirst(map.entrySet());
    String value = "Ninety-Nine";
    Assert.assertEquals("One", entry.setValue(value));
    Assert.assertEquals(value, entry.getValue());
    Verify.assertContainsKeyValue(1, value, map);

    map.remove(1);
    Verify.assertEmpty(map);
    Assert.assertNull(entry.setValue("Ignored"));
  }
  /**
   * Method used to recursively scan our package map for classes whose names start with a given
   * prefix, ignoring case.
   *
   * @param prefix The prefix that the unqualified class names must match (ignoring case).
   * @param currentPkg The package that <code>map</code> belongs to (i.e. all levels of packages
   *     scanned before this one), separated by '<code>/</code>'.
   * @param addTo The list to add any matching <code>ClassFile</code>s to.
   */
  void getClassesWithNamesStartingWith(
      LibraryInfo info, String prefix, String currentPkg, List<ClassFile> addTo) {

    final int prefixLen = prefix.length();

    for (Map.Entry<String, PackageMapNode> children : subpackages.entrySet()) {
      String key = children.getKey();
      PackageMapNode child = children.getValue();
      child.getClassesWithNamesStartingWith(info, prefix, currentPkg + key + "/", addTo);
    }

    for (Map.Entry<String, ClassFile> cfEntry : classFiles.entrySet()) {
      // If value is null, we only lazily create the ClassFile if
      // necessary (i.e. if the class name does match what they've
      // typed).
      String className = cfEntry.getKey();
      if (className.regionMatches(true, 0, prefix, 0, prefixLen)) {
        ClassFile cf = cfEntry.getValue();
        if (cf == null) {
          String fqClassName = currentPkg + className + ".class";
          try {
            cf = info.createClassFile(fqClassName);
            cfEntry.setValue(cf); // Update the map
          } catch (IOException ioe) {
            ioe.printStackTrace();
          }
        }
        if (cf != null) { // possibly null if IOException above
          addTo.add(cf);
        }
      }
    }
  }
 @Lazy
 @Bean(name = "sql-stored-component")
 @ConditionalOnClass(CamelContext.class)
 @ConditionalOnMissingBean(SqlStoredComponent.class)
 public SqlStoredComponent configureSqlStoredComponent(
     CamelContext camelContext, SqlStoredComponentConfiguration configuration) throws Exception {
   SqlStoredComponent component = new SqlStoredComponent();
   component.setCamelContext(camelContext);
   Map<String, Object> parameters = new HashMap<>();
   IntrospectionSupport.getProperties(configuration, parameters, null, false);
   for (Map.Entry<String, Object> entry : parameters.entrySet()) {
     Object value = entry.getValue();
     Class<?> paramClass = value.getClass();
     if (paramClass.getName().endsWith("NestedConfiguration")) {
       Class nestedClass = null;
       try {
         nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
         HashMap<String, Object> nestedParameters = new HashMap<>();
         IntrospectionSupport.getProperties(value, nestedParameters, null, false);
         Object nestedProperty = nestedClass.newInstance();
         IntrospectionSupport.setProperties(
             camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
         entry.setValue(nestedProperty);
       } catch (NoSuchFieldException e) {
       }
     }
   }
   IntrospectionSupport.setProperties(
       camelContext, camelContext.getTypeConverter(), component, parameters);
   return component;
 }
示例#8
0
 private void toExValue(Map labels) {
   if (!labels.isEmpty())
     for (Iterator it = labels.entrySet().iterator(); it.hasNext(); ) {
       final Map.Entry me = (Map.Entry) it.next();
       me.setValue(new ExValue((String) me.getValue()));
     }
 }
示例#9
0
 @Override
 public void multiply(double n) {
   for (Map.Entry<Integer, Integer> e : entrySet()) {
     e.setValue((int) (e.getValue() * n));
   }
   defaultValue *= n;
 }
示例#10
0
  public static HashMap<Character, Integer> Count(
      ArrayList<String> inputList, ArrayList<Character> inputCharList) {
    ArrayList<String> tempList = inputList;
    ArrayList<Character> tempCharList = inputCharList;
    HashMap<Character, Integer> result = new HashMap<Character, Integer>();

    for (int i = 0; i < 33; i++) {
      result.put(tempCharList.get(i), 0);
    }

    for (int i = 0; i < 10; i++) {
      char[] listItemToCharArray = tempList.get(i).toCharArray();
      for (Map.Entry<Character, Integer> pair : result.entrySet()) {

        for (int j = 0; j < listItemToCharArray.length; j++) {
          if (listItemToCharArray[j] == pair.getKey()) {
            int charCount = pair.getValue();
            charCount++;
            pair.setValue(charCount);
          }
        }
      }
    }
    return result;
  }
示例#11
0
  public void testSimple() throws Exception {
    File tmp = new File("tmp");
    PersistentMap<String> pm = new PersistentMap<String>(new File(tmp, "simple"), String.class);
    try {

      assertNull(pm.put("abc", "def"));
      assertEquals("def", pm.get("abc"));

      pm.close();

      PersistentMap<String> pm2 = new PersistentMap<String>(new File(tmp, "simple"), String.class);
      assertEquals("def", pm2.get("abc"));

      assertEquals(Arrays.asList("abc"), new ArrayList<String>(pm2.keySet()));

      for (Map.Entry<String, String> e : pm2.entrySet()) {
        e.setValue("XXX");
      }
      assertEquals("XXX", pm2.get("abc"));
      pm2.close();
    } finally {
      pm.close();
      IO.delete(tmp);
    }
  }
示例#12
0
  /** {@inheritDoc} */
  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (roundEnv.processingOver()) return false;

    // We have: A sorted set of all priority levels: 'priorityLevels'

    // Step 1: Take all CUs which aren't already in the map. Give them the first priority level.

    for (Element element : roundEnv.getRootElements()) {
      JCCompilationUnit unit = toUnit(element);
      if (unit == null) continue;
      if (roots.containsKey(unit)) continue;
      roots.put(unit, priorityLevels[0]);
    }

    while (true) {
      // Step 2: For all CUs (in the map, not the roundEnv!), run them across all handlers at their
      // current prio level.

      for (long prio : priorityLevels) {
        List<JCCompilationUnit> cusForThisRound = new ArrayList<JCCompilationUnit>();
        for (Map.Entry<JCCompilationUnit, Long> entry : roots.entrySet()) {
          Long prioOfCu = entry.getValue();
          if (prioOfCu == null || prioOfCu != prio) continue;
          cusForThisRound.add(entry.getKey());
        }
        transformer.transform(prio, processingEnv.getContext(), cusForThisRound);
      }

      // Step 3: Push up all CUs to the next level. Set level to null if there is no next level.

      Set<Long> newLevels = new HashSet<Long>();
      for (int i = priorityLevels.length - 1; i >= 0; i--) {
        Long curLevel = priorityLevels[i];
        Long nextLevel = (i == priorityLevels.length - 1) ? null : priorityLevels[i + 1];
        for (Map.Entry<JCCompilationUnit, Long> entry : roots.entrySet()) {
          if (curLevel.equals(entry.getValue())) {
            entry.setValue(nextLevel);
            newLevels.add(nextLevel);
          }
        }
      }
      newLevels.remove(null);

      // Step 4: If ALL values are null, quit. Else, either do another loop right now or force a
      // resolution reset by forcing a new round in the annotation processor.

      if (newLevels.isEmpty()) return false;
      newLevels.retainAll(priorityLevelsRequiringResolutionReset);
      if (newLevels.isEmpty()) {
        // None of the new levels need resolution, so just keep going.
        continue;
      } else {
        // Force a new round to reset resolution. The next round will cause this method (process) to
        // be called again.
        forceNewRound((JavacFiler) processingEnv.getFiler());
        return false;
      }
    }
  }
示例#13
0
 /*
  * (non-Javadoc)
  *
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Module)
  */
 public Object visit(Namespace a) {
   /* set current namespace */
   ns = a;
   /*
    * visit definitions We set an infinite loop to cope with modifications
    * introduced by visiting sub expressions. When something is modified -
    * through lift - we restart the whole process. TODO : change this to defer
    * registering new bindings at end
    */
   while (true) {
     try {
       Iterator it = a.getAllBindings().entrySet().iterator();
       while (it.hasNext()) {
         Map.Entry entry = (Map.Entry) it.next();
         String functionName = (String) entry.getKey();
         Expression def = (Expression) entry.getValue();
         if (def instanceof Abstraction)
           ((Abstraction) def).setClassName(ns.getName() + "." + functionName);
         log.finest("Analyzing lifting for " + functionName);
         lift = false;
         entry.setValue((Expression) def.visit(this));
       }
       break;
     } catch (ConcurrentModificationException cmex) {
       /* restart the process */
     }
   }
   return a;
 }
示例#14
0
文件: LaplaceNode.java 项目: hfgl/cg
  public void laplace() {
    double alpha = 0.5;

    //
    HashMap<Vertex, Vector3> centerList = new HashMap();
    for (Vertex v : vertexList) {
      ArrayList<Vertex> neighboursVertexes;
      Vector3 sum = new Vector3(0, 0, 0);

      neighboursVertexes = GetNeighboursVertexes(v);
      for (Vertex neighbour : neighboursVertexes) {
        sum = sum.add(neighbour.getPosition());
      }
      sum = sum.devideValueByVector(1);
      centerList.put(v, sum);
    }
    for (Map.Entry<Vertex, Vector3> entry : centerList.entrySet()) {
      Vector3 ap = entry.getKey().getPosition().multiply(alpha);
      Vector3 ac = entry.getValue().multiply(1 - alpha);
      Vector3 newPosition = new Vector3(ap).add(ac);
      entry.setValue(newPosition);
    }
    vertexList = new ArrayList<>();
    for (Map.Entry<Vertex, Vector3> entry : centerList.entrySet()) {
      Vertex vertex = new Vertex(entry.getValue());
      vertex.setHalfEgde(entry.getKey().getHalfEdge());
      vertex.setColor(entry.getKey().getColor());
      vertexList.add(vertex);
    }
    triangulatedMesh.computeTriangleNormals();
    triangulatedMesh.computeVertexNormals();
  }
示例#15
0
  @Override
  public void pollSubNodes() {

    //		System.out.println("Before SubNodesPolled: Load=" + networkLoad + "hops, subNodeStatusMap: "
    // + subNodesStatusMap.entrySet().toString());

    Datacentre dc = World.getInstance().getDatacentre(location.dc());

    // poll each sub-node for latest status
    for (Map.Entry<Integer, Boolean> entry : subNodesStatusMap.entrySet()) {

      //			Server s = dc.getServer(entry.getKey());
      //			System.out.println(s.getStatus());
      entry.setValue(dc.getServer(entry.getKey()).isAlive()); // poll current server status

      PartialIP node_ip = new PartialIP(dc.getServer(entry.getKey()).getIP());
      int hops =
          2
              * PartialIP.navigatePointToPoint(
                  location, node_ip); // x2 for round trip (request/response)
      networkLoad += hops;
    }

    //		System.out.println("After SubNodesPolled: Load=" + networkLoad + "hops, subNodeStatusMap: "
    // + subNodesStatusMap.entrySet().toString());
  }
示例#16
0
  /** Checks if a player has any activity within a predefined period of time */
  public void checkPlayerActivity() {

    for (Map.Entry<Integer, Instant> entry : timeTagMap.entrySet()) {
      int key = entry.getKey();
      Instant value = entry.getValue();
      // check which player has a time tag older than TIME_DELAY ago
      // kick the player off from the idMap and addressMap
      System.out.println("Key = " + key + ", Value = " + value);
      // each player has its own time tag

      if (value == null) entry.setValue(Instant.now());

      Instant newLogTime = Instant.now();
      long elapsed = java.time.Duration.between(oldLogTime, newLogTime).toMillis() / 1000;

      if (elapsed > TIME_DELAY) {
        // unregister player,
        // clear idMap, addressMap
        centralRegistry.getIdMap().remove(key);
        centralRegistry.getAddressMap().remove(key);
        // Do NOT clear timeTagMap. leave it as it is.
        // send msg to panel
        // sendDisconnect();
        // TODO: where in this class to update new value e.g. entry.setValue(newLogTime);
      }
    }
  }
示例#17
0
 private void resolveVariables(Context ctx, Properties initProps) {
   for (Map.Entry<Object, Object> entry : initProps.entrySet()) {
     if (entry.getValue() != null) {
       entry.setValue(ctx.replaceTokens((String) entry.getValue()));
     }
   }
 }
  /**
   * Loads the configuration file for the application, if it exists. This is either the
   * user-specified properties file, or the spark-defaults.conf file under the Spark configuration
   * directory.
   */
  Properties loadPropertiesFile() throws IOException {
    Properties props = new Properties();
    File propsFile;
    if (propertiesFile != null) {
      propsFile = new File(propertiesFile);
      CommandBuilderUtils.checkArgument(
          propsFile.isFile(), "Invalid properties file '%s'.", propertiesFile);
    } else {
      propsFile = new File(getConfDir(), CommandBuilderUtils.DEFAULT_PROPERTIES_FILE);
    }

    if (propsFile.isFile()) {
      FileInputStream fd = null;
      try {
        fd = new FileInputStream(propsFile);
        props.load(new InputStreamReader(fd, "UTF-8"));
        for (Map.Entry<Object, Object> e : props.entrySet()) {
          e.setValue(e.getValue().toString().trim());
        }
      } finally {
        if (fd != null) {
          try {
            fd.close();
          } catch (IOException e) {
            // Ignore.
          }
        }
      }
    }

    return props;
  }
  /**
   * Normalizes our data from what we get from YAML, to a format that's easier to deal with in
   * X-Ray.
   *
   * <p>TODO: Exception error reporting
   */
  public void normalizeData() throws BlockTypeLoadException {
    // First check our super
    super.normalizeData();

    // Now check for some required attributes
    if (this.tex == null || this.tex.length() == 0) {
      throw new BlockTypeLoadException("tex is a required attribute");
    }

    // Now do the actual normalizing...  Modify our textures to use the full path
    this.tex = this.getFullTextureFilename(this.tex);
    checkTextureAvailability(this.tex);

    if (this.tex_data != null && this.tex_data.size() > 0) {
      for (Map.Entry<Integer, String> entry : this.tex_data.entrySet()) {
        entry.setValue(this.getFullTextureFilename(entry.getValue()));
        checkTextureAvailability(entry.getValue());
      }
    }
    if (this.tex_direction != null && this.tex_direction.size() > 0) {
      this.tex_direction_int = new HashMap<DIRECTION_REL, String>();
      for (Map.Entry<String, String> entry : this.tex_direction.entrySet()) {
        DIRECTION_REL dir;
        try {
          dir = DIRECTION_REL.valueOf(entry.getKey());
        } catch (IllegalArgumentException e) {
          throw new BlockTypeLoadException("Invalid relative direction: " + entry.getKey());
        }
        this.tex_direction_int.put(dir, this.getFullTextureFilename(entry.getValue()));
        checkTextureAvailability(this.tex_direction_int.get(dir));
      }
    }
  }
示例#20
0
  /** {@inheritDoc} */
  public void processSpace(Properties properties) {
    SparseDoubleVector empty = new CompactSparseVector();
    for (Map.Entry<RelationTuple, SparseDoubleVector> e : relationVectors.entrySet()) {
      RelationTuple relation = e.getKey();
      SparseDoubleVector relationCounts = e.getValue();
      String headWord = termBasis.getDimensionDescription(relation.head);
      String rel = relation.relation;

      SelectionalPreference headPref = preferenceVectors.get(headWord);

      if (headPref == null) LOG.fine("what the f**k");

      for (int index : relationCounts.getNonZeroIndices()) {
        double frequency = relationCounts.get(index);
        String depWord = termBasis.getDimensionDescription(index);
        SelectionalPreference depPref = preferenceVectors.get(depWord);

        // It's possible that the dependent word is not being
        // represented in this space, so skip missing terms.
        if (depPref == null) continue;

        headPref.addPreference(rel, depPref.lemmaVector, frequency);
        depPref.addInversePreference(rel, headPref.lemmaVector, frequency);
      }
      e.setValue(empty);
    }

    // Null out all the relation tuple counts so that memory can be
    // freed up.
    relationVectors = null;
  }
 public ResolvedValueProducer declareTaskProducing(
     final ValueSpecification valueSpecification,
     final ResolveTask task,
     final ResolvedValueProducer producer) {
   do {
     final MapEx<ResolveTask, ResolvedValueProducer> tasks =
         getBuilder().getOrCreateTasks(valueSpecification);
     ResolvedValueProducer result = null;
     if (tasks != null) {
       ResolvedValueProducer discard = null;
       synchronized (tasks) {
         if (!tasks.isEmpty()) {
           if (tasks.containsKey(null)) {
             continue;
           }
           final Map.Entry<ResolveTask, ResolvedValueProducer> resolveTask =
               tasks.getHashEntry(task);
           if (resolveTask != null) {
             if (resolveTask.getKey() == task) {
               // Replace an earlier attempt from this task with the new producer
               discard = resolveTask.getValue();
               producer.addRef(); // The caller already holds an open reference
               resolveTask.setValue(producer);
               result = producer;
             } else {
               // An equivalent task is doing the work
               result = resolveTask.getValue();
             }
             result
                 .addRef(); // Either the caller holds an open reference on the producer, or we've
                            // got the task lock
           }
         }
         if (result == null) {
           final ResolvedValue value = getBuilder().getResolvedValue(valueSpecification);
           if (value != null) {
             result = new SingleResolvedValueProducer(task.getValueRequirement(), value);
           }
         }
         if (result == null) {
           // No matching tasks
           producer.addRef(); // Caller already holds open reference
           tasks.put(task, producer);
           result = producer;
           result.addRef(); // Caller already holds open reference (this is the producer)
         }
       }
       if (discard != null) {
         discard.release(this);
       }
     } else {
       final ResolvedValue value = getBuilder().getResolvedValue(valueSpecification);
       if (value != null) {
         result = new SingleResolvedValueProducer(task.getValueRequirement(), value);
       }
     }
     return result;
   } while (true);
 }
 private void undoPriorInfluence(Map<String, Double> probabilites) {
   if (probabilites != null && probabilites.size() > 0) {
     model.priorDenominator--;
     for (Map.Entry<String, Double> e : model.categoryPriors.entrySet()) {
       e.setValue(e.getValue() - probabilites.get(e.getKey()));
     }
   }
 }
示例#23
0
 public JaxbMap(Map<String, Object> entries) {
   this.entries = entries;
   if (entries != null && !entries.isEmpty()) {
     for (Map.Entry<String, Object> entry : entries.entrySet()) {
       entry.setValue(ModelWrapper.wrapSkipPrimitives(entry.getValue()));
     }
   }
 }
示例#24
0
  public static void mapValue2SimpleObj(Map<?, Object> m) {
    Iterator var1 = m.entrySet().iterator();

    while (var1.hasNext()) {
      Map.Entry e = (Map.Entry) var1.next();
      e.setValue(getSimpleObj(e.getValue()));
    }
  }
 private void makePriorInfluence(Map<String, Double> probabilites) {
   if (probabilites != null) {
     model.priorDenominator++;
     for (Map.Entry<String, Double> e : model.categoryPriors.entrySet()) {
       e.setValue(e.getValue() + probabilites.get(e.getKey()));
     }
   }
 }
示例#26
0
 // Called with lock held
 protected void flushAccumulatedCredits() {
   if (accumulated_credits > 0) {
     for (Map.Entry<Address, Long> entry : this.credits.entrySet()) {
       entry.setValue(Math.max(0, entry.getValue().longValue() - accumulated_credits));
     }
     accumulated_credits = 0;
   }
 }
 public final void setHexIdInUse(final byte[] hexId) {
   for (Map.Entry<byte[], Boolean> entry : _registeredGameServers.entrySet()) {
     if (Arrays.equals(entry.getKey(), hexId)) {
       entry.setValue(false);
       return;
     }
   }
 }
示例#28
0
 public <K, V> Map.Entry<K, V> removeProxy(Map.Entry<K, V> entry) {
   V value = entry.getValue();
   if (isProxy(value)) {
     value = getRealObject(value);
     entry.setValue(value);
   }
   return entry;
 }
示例#29
0
 /*
  * (non-Javadoc)
  *
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Alternative)
  */
 public Object visit(Alternative a) {
   Iterator it = a.getChoices();
   while (it.hasNext()) {
     Map.Entry entry = (Map.Entry) it.next();
     Expression body = (Expression) entry.getValue();
     entry.setValue(body.visit(this));
   }
   return a;
 }
示例#30
0
 @Override
 public void deobfuscate(SystemSettings systemSettings) {
   for (Map.Entry<SystemSetting, String> entry : systemSettings.entrySet()) {
     String value = entry.getValue();
     if (value != null && entry.getKey().getType() == PropertySimpleType.PASSWORD) {
       entry.setValue(PicketBoxObfuscator.decode(value));
     }
   }
 }