List of usage examples for java.util Map values
Collection<V> values();
From source file:com.github.gdfm.shobaidogu.StatsUtils.java
/** * Compute the magnitude of a vector.//from w w w. j a v a 2s .c o m * * @param vector * @return */ public static <K, V extends Number> double magnitude(Map<K, V> vector) { double result = 0.0; for (V weight : vector.values()) result += Math.pow(weight.doubleValue(), 2); result = Math.sqrt(result); return result; }
From source file:com.darkstar.beanCartography.utils.NameUtils.java
/** * @param o object instanct to check// w w w . j a va 2s . c om * @return <code>true</code> if any fields have names associated with them */ public static boolean hasFieldBusinessNames(Object o) { Preconditions.checkNotNull(o, "Object cannot be null"); // look for business field annotation... Map<String, List<Field>> classFieldMap = getFields(o, true); final MutableBoolean hasBusinessName = new MutableBoolean(false); classFieldMap.values().stream().forEach(fieldList -> { Optional<Field> fieldOpt = fieldList.stream().filter(NameUtils::hasBusinessName).findFirst(); fieldOpt.ifPresent(field -> hasBusinessName.setValue(field != null)); }); return hasBusinessName.booleanValue(); }
From source file:es.ehu.si.ixa.pipe.nerc.train.InputOutputUtils.java
public static List<List<Integer>> getBestIterations(Map<List<Integer>, Double> results, List<List<Integer>> allParams) throws IOException { StringBuffer sb = new StringBuffer(); Double bestResult = (Collections.max(results.values())); for (Map.Entry<List<Integer>, Double> result1 : results.entrySet()) { if (result1.getValue().compareTo(bestResult) == 0) { allParams.add(result1.getKey()); sb.append("Best results: ").append(result1.getKey()).append(" ").append(result1.getValue()) .append("\n"); System.out.println("Results: " + result1.getKey() + " " + result1.getValue()); }//from w w w .j a v a2 s.c om } FileUtils.writeStringToFile(new File("best-results.txt"), sb.toString(), "UTF-8"); System.out.println("Best F via cross evaluation: " + bestResult); System.out.println("All Params " + allParams.size()); return allParams; }
From source file:userinterface.CyberSecurity.ChartFactory.java
public static ChartPanel createChart(UserAccount account) { Map<String, LoginDetails> loginDetails = account.getLoginDetails(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); Collection<LoginDetails> values = loginDetails.values(); for (LoginDetails details : values) { dataset1.addValue(TimeUnit.MILLISECONDS.toHours(details.getLogoutTime() - details.getLoginTime()), HOURS_WORKED_BY_USER, details.getLoginDate()); dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, details.getLoginDate()); }//w w w. j a v a 2s . co m dataset1.addValue(2, HOURS_WORKED_BY_USER, "4-19-2016"); dataset1.addValue(3, HOURS_WORKED_BY_USER, "4-20-2016"); dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, "4-19-2016"); dataset2.addValue(2.5, MINIMUM_WORKING_HOURS, "4-20-2016"); final CategoryItemRenderer renderer = new BarRenderer(); final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset1); plot.setRenderer(renderer); plot.setDomainAxis(new CategoryAxis("Date")); plot.setRangeAxis(new NumberAxis("Hours")); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // now create the second dataset and renderer... final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); final JFreeChart chart = new JFreeChart(plot); chart.setTitle("Employee work hours"); chart.setBackgroundPaint(Color.WHITE); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); return chartPanel; }
From source file:com.jhr.jarvis.table.TableRenderer.java
/** * Renders the Table header border, based on the map of provided headers. * /* w w w . ja v a 2s .c o m*/ * @param headers * Map of headers containing meta information e.g. name+width of * header * @return Returns the rendered header border as String */ public static String getHeaderBorder(Map<Integer, TableHeader> headers) { final StringBuilder headerBorder = new StringBuilder(); for (TableHeader header : headers.values()) { headerBorder.append(StringUtils.padRight(" ", header.getWidth() + 2, '-')); } headerBorder.append("\n"); return headerBorder.toString(); }
From source file:com.excelsiorsoft.transformer.SpringIntegrationUtils.java
/** * Helper Method to dynamically determine and display input and output * directories as defined in the Spring Integration context. * * @param context Spring Application Context *///ww w.ja v a 2 s . c om public static void displayDirectories(final ApplicationContext context) { final File inDir = (File) new DirectFieldAccessor(context.getBean(FileReadingMessageSource.class)) .getPropertyValue("directory"); final Map<String, FileWritingMessageHandler> fileWritingMessageHandlers = context .getBeansOfType(FileWritingMessageHandler.class); final List<String> outputDirectories = new ArrayList<String>(); for (final FileWritingMessageHandler messageHandler : fileWritingMessageHandlers.values()) { final File outDir = (File) new DirectFieldAccessor(messageHandler) .getPropertyValue("destinationDirectory"); outputDirectories.add(outDir.getAbsolutePath()); } final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("\n========================================================="); stringBuilder.append("\n"); stringBuilder.append("\n Input directory is : '" + inDir.getAbsolutePath() + "'"); for (final String outputDirectory : outputDirectories) { stringBuilder.append("\n Output directory is: '" + outputDirectory + "'"); } stringBuilder.append("\n\n========================================================="); LOGGER.info(stringBuilder.toString()); }
From source file:au.edu.uws.eresearch.cr8it.SpringIntegrationUtils.java
/** * Helper Method to dynamically determine and display input and output * directories as defined in the Spring Integration context. * * @param context Spring Application Context *///from w w w .j av a 2 s .com public static void displayDirectories(final ApplicationContext context) { final File inDir = (File) new DirectFieldAccessor(context.getBean(FileReadingMessageSource.class)) .getPropertyValue("directory"); final Map<String, FileWritingMessageHandler> fileWritingMessageHandlers = context .getBeansOfType(FileWritingMessageHandler.class); final List<String> outputDirectories = new ArrayList<String>(); for (final FileWritingMessageHandler messageHandler : fileWritingMessageHandlers.values()) { final Expression outDir = (Expression) new DirectFieldAccessor(messageHandler) .getPropertyValue("destinationDirectoryExpression"); outputDirectories.add(outDir.getExpressionString()); } final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("\n========================================================="); stringBuilder.append("\n"); stringBuilder.append("\n Input directory is : '" + inDir.getAbsolutePath() + "'"); for (final String outputDirectory : outputDirectories) { stringBuilder.append("\n Output directory is: '" + outputDirectory + "'"); } stringBuilder.append("\n\n========================================================="); logger.info(stringBuilder.toString()); }
From source file:com.rapidminer.operator.learner.tree.SelectionCreator.java
/** * Returns a value of the map./*from w w w. j a v a2s. c om*/ * * @param map * a non-empty map * @return */ public static int[] getArbitraryValue(Map<Integer, int[]> map) { return map.values().iterator().next(); }
From source file:alluxio.cli.fsadmin.report.CapacityCommand.java
/** * Gets the formatted tier values of a worker. * * @param map the map to get worker tier values from * @param workerName name of the worker/*from w w w . j a v a 2 s .co m*/ * @return the formatted tier values of the input worker name */ private static String getWorkerFormattedTierValues(Map<String, Map<String, String>> map, String workerName) { return map.values().stream() .map((tierMap) -> (String.format("%-14s", tierMap.getOrDefault(workerName, "-")))) .collect(Collectors.joining("")); }
From source file:com.stratio.crossdata.sh.utils.ConsoleUtils.java
/** * In order to create a separator line in tables, this method calculates the total width of a * table./*www . j a v a2 s. c o m*/ * * @param colWidths columns widths of a table. * @return total width of a table. */ private static int getTotalWidth(Map<String, Integer> colWidths) { int totalWidth = 0; for (int width : colWidths.values()) { totalWidth += width; } return totalWidth; }