List of usage examples for java.util HashMap values
public Collection<V> values()
From source file:eu.planets_project.tb.gui.backing.service.ServiceInspector.java
public List<Experiment> getExperiments() { // Single Services: if (this.srb != null) { if (srb.getServiceRecord() != null) { return srb.getServiceRecord().getExperiments(); } else {/*w w w. j a va 2 s . com*/ return new ArrayList<Experiment>(); } } // Lists: HashMap<Long, Experiment> exps = new HashMap<Long, Experiment>(); if (this.srbs != null) { for (ServiceRecordBean srb : srbs) { if (srb.getServiceRecord() != null) { for (Experiment exp : srb.getServiceRecord().getExperiments()) { exps.put(Long.valueOf(exp.getEntityID()), exp); } } } } return new ArrayList<Experiment>(exps.values()); }
From source file:com.wasteofplastic.beaconz.listeners.BeaconCaptureListener.java
/** * Puts a beacon map in the player's main hand * @param player/*from w ww .j av a 2s .co m*/ * @param beacon */ @SuppressWarnings("deprecation") private void giveBeaconMap(Player player, BeaconObj beacon) { // Make a map! player.sendMessage(ChatColor.GREEN + Lang.beaconYouHaveAMap); MapView map = Bukkit.createMap(getBeaconzWorld()); //map.setWorld(getBeaconzWorld()); map.setCenterX(beacon.getX()); map.setCenterZ(beacon.getZ()); map.getRenderers().clear(); map.addRenderer(new TerritoryMapRenderer(getBeaconzPlugin())); map.addRenderer(new BeaconMap(getBeaconzPlugin())); ItemStack newMap = new ItemStack(Material.MAP); newMap.setDurability(map.getId()); ItemMeta meta = newMap.getItemMeta(); meta.setDisplayName("Beacon map for " + beacon.getName()); newMap.setItemMeta(meta); // Each map is unique and the durability defines the map ID, register it getRegister().addBeaconMap(map.getId(), beacon); //getLogger().info("DEBUG: beacon id = " + beacon.getId()); // Put map into hand //ItemStack inHand = player.getInventory().getItemInMainHand(); ItemStack offHand = player.getInventory().getItemInOffHand(); player.getInventory().setItemInOffHand(newMap); //player.getInventory().setItemInOffHand(inHand); if (offHand != null && !offHand.getType().equals(Material.AIR)) { HashMap<Integer, ItemStack> leftOvers = player.getInventory().addItem(offHand); if (!leftOvers.isEmpty()) { player.sendMessage(ChatColor.RED + Lang.errorInventoryFull); for (ItemStack item : leftOvers.values()) { player.getWorld().dropItem(player.getLocation(), item); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1F, 0.5F); } } } }
From source file:magma.agent.worldmodel.localizer.impl.LocalizerTriangulation.java
/** * Calculates absolute position and directions by performing triangulation * for all pairs of flags taking the average of all calculations. * @param flags visible landmarks with known position to be used for * localization/*from w w w .j a v a 2s . c o m*/ * @param neckYawAngle the horizontal neck angle (yaw) of the viewer * @param neckPitchAngle the vertical neck angle (pitch) of the viewer (not * used at the moment) * @return an array of two Vector3Ds, the first containing the absolute x,y,z * position of the viewer on the field, the second containing no real * vector, but the horizontal, latitudal and rotational absolute body * angles of the viewer */ public PositionOrientation localize(HashMap<String, ILocalizationFlag> flags, float neckYawAngle, float neckPitchAngle, Vector3D gyro) { if (flags.size() < 2) { // there are not 2 visible flags logger.log(Level.FINER, "Localization not possible, only have {0} flags", flags.size()); return null; } // sort the flags according to their angle List<ILocalizationFlag> sortedFlags = new ArrayList<ILocalizationFlag>(flags.values()); Collections.sort(sortedFlags); // get the two flags with maximum angle difference int triangulations = sortedFlags.size() * (sortedFlags.size() - 1) / 2; assert triangulations > 0 : "we need at least one triangulation"; PositionOrientation[] results = new PositionOrientation[triangulations]; int count = 0; for (int i = 0; i < sortedFlags.size() - 1; i++) { ILocalizationFlag flag1 = sortedFlags.get(i); for (int j = i + 1; j < sortedFlags.size(); j++) { ILocalizationFlag flag2 = sortedFlags.get(j); results[count] = triangulate(flag1, flag2, neckYawAngle); count++; } } PositionOrientation result = PositionOrientation.average(results); return result; }
From source file:com.android.ddmuilib.log.event.DisplayGraph.java
/** * Updates the chart with the {@link EventContainer} by adding the values/occurrences defined * by the {@link ValueDisplayDescriptor} and {@link OccurrenceDisplayDescriptor} objects from * the two lists.//from w ww. j a v a 2s .c om * <p/>This method is only called when at least one of the descriptor list is non empty. * @param event * @param logParser * @param valueDescriptors * @param occurrenceDescriptors */ private void updateChart(EventContainer event, EventLogParser logParser, ArrayList<ValueDisplayDescriptor> valueDescriptors, ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors) { Map<Integer, String> tagMap = logParser.getTagMap(); Millisecond millisecondTime = null; long msec = -1; // If the event container is a cpu container (tag == 2721), and there is no descriptor // for the total CPU load, then we do accumulate all the values. boolean accumulateValues = false; double accumulatedValue = 0; if (event.mTag == 2721) { accumulateValues = true; for (ValueDisplayDescriptor descriptor : valueDescriptors) { accumulateValues &= (descriptor.valueIndex != 0); } } for (ValueDisplayDescriptor descriptor : valueDescriptors) { try { // get the hashmap for this descriptor HashMap<Integer, TimeSeries> map = mValueDescriptorSeriesMap.get(descriptor); // if it's not there yet, we create it. if (map == null) { map = new HashMap<Integer, TimeSeries>(); mValueDescriptorSeriesMap.put(descriptor, map); } // get the TimeSeries for this pid TimeSeries timeSeries = map.get(event.pid); // if it doesn't exist yet, we create it if (timeSeries == null) { // get the series name String seriesFullName = null; String seriesLabel = getSeriesLabel(event, descriptor); switch (mValueDescriptorCheck) { case EVENT_CHECK_SAME_TAG: seriesFullName = String.format("%1$s / %2$s", seriesLabel, descriptor.valueName); break; case EVENT_CHECK_SAME_VALUE: seriesFullName = String.format("%1$s", seriesLabel); break; default: seriesFullName = String.format("%1$s / %2$s: %3$s", seriesLabel, tagMap.get(descriptor.eventTag), descriptor.valueName); break; } // get the data set for this ValueType TimeSeriesCollection dataset = getValueDataset( logParser.getEventInfoMap().get(event.mTag)[descriptor.valueIndex].getValueType(), accumulateValues); // create the series timeSeries = new TimeSeries(seriesFullName, Millisecond.class); if (mMaximumChartItemAge != -1) { timeSeries.setMaximumItemAge(mMaximumChartItemAge * 1000); } dataset.addSeries(timeSeries); // add it to the map. map.put(event.pid, timeSeries); } // update the timeSeries. // get the value from the event double value = event.getValueAsDouble(descriptor.valueIndex); // accumulate the values if needed. if (accumulateValues) { accumulatedValue += value; value = accumulatedValue; } // get the time if (millisecondTime == null) { msec = (long) event.sec * 1000L + (event.nsec / 1000000L); millisecondTime = new Millisecond(new Date(msec)); } // add the value to the time series timeSeries.addOrUpdate(millisecondTime, value); } catch (InvalidTypeException e) { // just ignore this descriptor if there's a type mismatch } } for (OccurrenceDisplayDescriptor descriptor : occurrenceDescriptors) { try { // get the hashmap for this descriptor HashMap<Integer, TimeSeries> map = mOcurrenceDescriptorSeriesMap.get(descriptor); // if it's not there yet, we create it. if (map == null) { map = new HashMap<Integer, TimeSeries>(); mOcurrenceDescriptorSeriesMap.put(descriptor, map); } // get the TimeSeries for this pid TimeSeries timeSeries = map.get(event.pid); // if it doesn't exist yet, we create it. if (timeSeries == null) { String seriesLabel = getSeriesLabel(event, descriptor); String seriesFullName = String.format("[%1$s:%2$s]", tagMap.get(descriptor.eventTag), seriesLabel); timeSeries = new TimeSeries(seriesFullName, Millisecond.class); if (mMaximumChartItemAge != -1) { timeSeries.setMaximumItemAge(mMaximumChartItemAge); } getOccurrenceDataSet().addSeries(timeSeries); map.put(event.pid, timeSeries); } // update the series // get the time if (millisecondTime == null) { msec = (long) event.sec * 1000L + (event.nsec / 1000000L); millisecondTime = new Millisecond(new Date(msec)); } // add the value to the time series timeSeries.addOrUpdate(millisecondTime, 0); // the value is unused } catch (InvalidTypeException e) { // just ignore this descriptor if there's a type mismatch } } // go through all the series and remove old values. if (msec != -1 && mMaximumChartItemAge != -1) { Collection<HashMap<Integer, TimeSeries>> pidMapValues = mValueDescriptorSeriesMap.values(); for (HashMap<Integer, TimeSeries> pidMapValue : pidMapValues) { Collection<TimeSeries> seriesCollection = pidMapValue.values(); for (TimeSeries timeSeries : seriesCollection) { timeSeries.removeAgedItems(msec, true); } } pidMapValues = mOcurrenceDescriptorSeriesMap.values(); for (HashMap<Integer, TimeSeries> pidMapValue : pidMapValues) { Collection<TimeSeries> seriesCollection = pidMapValue.values(); for (TimeSeries timeSeries : seriesCollection) { timeSeries.removeAgedItems(msec, true); } } } }
From source file:com.opengamma.analytics.math.rootfinding.YieldCurveFittingSetup.java
protected double[] catMap(final HashMap<String, double[]> map) { int nNodes = 0; for (final double[] temp : map.values()) { nNodes += temp.length;/*from w w w .ja v a 2s .co m*/ } final double[] temp = new double[nNodes]; int index = 0; for (final double[] times : map.values()) { for (final double t : times) { temp[index++] = t; } } Arrays.sort(temp); return temp; }
From source file:info.semanticsoftware.lodexporter.tdb.TDBTripleStoreImpl.java
private void prepareTDBRelationModel(final HashMap<String, LinkedList<RelationMapping>> relationMapList) { model = dataset.getDefaultModel();//from w ww . ja v a 2 s . com relationModelHash = new HashMap<>(); for (final LinkedList<RelationMapping> relationMapElement : relationMapList.values()) { for (final RelationMapping rMap : relationMapElement) { relationModelHash.put(rMap.getRule(), model.createProperty(rMap.getType())); } } }
From source file:org.apache.hadoop.hive.ql.parse.TezCompiler.java
@Override protected void setInputFormat(Task<? extends Serializable> task) { if (task instanceof TezTask) { TezWork work = ((TezTask) task).getWork(); List<BaseWork> all = work.getAllWork(); for (BaseWork w : all) { if (w instanceof MapWork) { MapWork mapWork = (MapWork) w; HashMap<String, Operator<? extends OperatorDesc>> opMap = mapWork.getAliasToWork(); if (!opMap.isEmpty()) { for (Operator<? extends OperatorDesc> op : opMap.values()) { setInputFormat(mapWork, op); }/*w w w . j av a 2 s .com*/ } } } } else if (task instanceof ConditionalTask) { List<Task<? extends Serializable>> listTasks = ((ConditionalTask) task).getListTasks(); for (Task<? extends Serializable> tsk : listTasks) { setInputFormat(tsk); } } if (task.getChildTasks() != null) { for (Task<? extends Serializable> childTask : task.getChildTasks()) { setInputFormat(childTask); } } }
From source file:de.tudarmstadt.ukp.dkpro.core.stanfordnlp.StanfordNamedEntityRecognizerTrainer.java
private void convert(JCas aJCas, PrintWriter aOut) { Type neType = JCasUtil.getType(aJCas, NamedEntity.class); Feature neValue = neType.getFeatureByBaseName("value"); // Named Entities IobEncoder neEncoder = new IobEncoder(aJCas.getCas(), neType, neValue, false); Map<Sentence, Collection<NamedEntity>> idx = JCasUtil.indexCovered(aJCas, Sentence.class, NamedEntity.class); Collection<NamedEntity> coveredNEs; for (Sentence sentence : select(aJCas, Sentence.class)) { coveredNEs = idx.get(sentence);/*from ww w.j a va 2 s .c o m*/ /* * don't include sentence in temp file that contains no annotations * * (saves memory for training) */ if (coveredNEs.isEmpty()) { continue; } HashMap<Token, Row> ctokens = new LinkedHashMap<>(); // Tokens List<Token> tokens = selectCovered(Token.class, sentence); for (Token token : tokens) { Row row = new Row(); row.token = token; row.ne = neEncoder.encode(token); ctokens.put(row.token, row); } // Write sentence in column format for (Row row : ctokens.values()) { aOut.printf("%s\t%s%n", row.token.getCoveredText(), row.ne); } aOut.println(); } }
From source file:com.theultimatelabs.scale.ScaleActivity.java
public void findScale() { if (mDevice == null) { UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE); HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList(); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); while (deviceIterator.hasNext()) { mDevice = deviceIterator.next(); Log.v(TAG, String.format( "name=%s deviceId=%d productId=%d vendorId=%d deviceClass=%d subClass=%d protocol=%d interfaceCount=%d", mDevice.getDeviceName(), mDevice.getDeviceId(), mDevice.getProductId(), mDevice.getVendorId(), mDevice.getDeviceClass(), mDevice.getDeviceSubclass(), mDevice.getDeviceProtocol(), mDevice.getInterfaceCount())); break; }/*from ww w .j a v a 2s .co m*/ } if (mDevice != null) { new ScaleListener().execute(); } else { new AlertDialog.Builder(ScaleActivity.this).setTitle("Scale Not Found") .setMessage("Please connect scale with OTG cable and turn the scale on").setCancelable(false) .setPositiveButton("Try Again", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { findScale(); } }).setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }).setNeutralButton("Buy Scale", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://theultimatelabsstore.blogspot.com/p/store.html")); startActivity(browserIntent); } }).show(); } }
From source file:de.tud.kom.p2psim.impl.network.gnp.topology.GnpSpace.java
/** * Calculates good positions for all Hosts in Map * /*from w w w . j ava 2s .c o m*/ * @param monitorResheduling * number of rescheduling the downhill simplex */ private void insertCoordinates(int monitorResheduling) { GnpSpace.calculationStepStatus = 2; coordinateIndex.clear(); HashMap<Integer, Host> peers = this.getMapRef().getHostIndex(); int c = 0; for (Host host : peers.values()) { GnpSpace.calculationProgressStatus = c; if (host.getHostType() == Host.HOST) { GnpPosition coord = this.insertCoordinateDownhillSimplex(host, monitorResheduling); coordinateIndex.put(host.getIpAddress(), coord); c++; if (c % 1000 == 0) log.debug(c + " of " + peers.size() + " are positioned in gnp"); } if (!calculationInProgress) return; } GnpSpace.calculationStepStatus = 0; GnpSpace.calculationInProgress = false; }