List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:de.tudarmstadt.ukp.lmf.transform.framenet.FNConverter.java
/** * Converts the informations provided by the initialized {@link FrameNet} object to LMF-format. * The result of the conversion can be obtained by calling * {@link FNConverter#getLexicalResource()} *///from w w w. j ava 2 s . c om public void toLMF() { // Setting attributes of LexicalResource lexicalResource.setName("FrameNet"); lexicalResource.setDtdVersion(this.dtd_version); // *** Setting GlobalInformation *** // GlobalInformation globalInformation = new GlobalInformation(); globalInformation.setLabel("LMF representation of FrameNet 1.5"); lexicalResource.setGlobalInformation(globalInformation); //*** Setting Lexicon (only one since FrameNet is monolingual)***// Lexicon lexicon = new Lexicon(); lexicon.setLanguageIdentifier(ELanguageIdentifier.ENGLISH); lexicon.setId("FN_Lexicon_0"); lexicon.setName("FrameNet"); LinkedList<Lexicon> lexicons = new LinkedList<Lexicon>(); lexicons.add(lexicon); lexicalResource.setLexicons(lexicons); // *** Creating SemanticPredicates *** // logger.info("Generating SemanticPredicates..."); SemanticPredicateGenerator semanticPredicateGenerator = new SemanticPredicateGenerator(fn, resourceVersion); List<SemanticPredicate> semanticPredicates = new ArrayList<SemanticPredicate>(); semanticPredicates.addAll(semanticPredicateGenerator.getSemanticPredicates()); lexicon.setSemanticPredicates(semanticPredicates); logger.info("Generating SemanticPredicates done"); // *** Creating LexicalEntries *** // logger.info("Generating LexicalEntries..."); LexicalEntryGenerator lexicalEntryGenerator = new LexicalEntryGenerator(fn, semanticPredicateGenerator, resourceVersion); lexicon.setLexicalEntries(lexicalEntryGenerator.getLexicalEntries()); logger.info("Generating LexicalEntries done"); }
From source file:exploration.rendezvous.MultiPointRendezvousStrategy.java
/** * This method finds a point among connectionsToBase (that is in comm range of Base Station) * that is closest to origPoint. That is, it's an estimate of the shortest distance we need to * travel from origPoint to get into comm range of the Base station * * @param origPoint// w ww.j a v a 2 s .com * @param connectionsToBase * @param ag * @return */ public static int findNearestPointInBaseCommRange(NearRVPoint origPoint, List<CommLink> connectionsToBase, RealAgent ag) { int pathsCalculated = 0; // only calculate nearest base point for connectedPoint if we haven't already. if (origPoint.distanceToParent == Double.MAX_VALUE) { PriorityQueue<NearRVPoint> lineOfSightBasePoints = new PriorityQueue<NearRVPoint>(); PriorityQueue<NearRVPoint> nonLOSBasePoints = new PriorityQueue<NearRVPoint>(); for (CommLink baseLink : connectionsToBase) { NearRVPoint basePoint = new NearRVPoint(baseLink.getRemotePoint().x, baseLink.getRemotePoint().y); double approxPathLen = basePoint.distance(origPoint); basePoint.setDistanceToFrontier(approxPathLen); if (baseLink.numObstacles == 0) { lineOfSightBasePoints.add(basePoint); } else { nonLOSBasePoints.add(basePoint); } } LinkedList<NearRVPoint> pointsConnectedToBase = new LinkedList<NearRVPoint>(); for (int j = 0; (j < 5) && !lineOfSightBasePoints.isEmpty(); j++) { pointsConnectedToBase.add(lineOfSightBasePoints.poll()); } for (int j = 0; (j < 20) && !nonLOSBasePoints.isEmpty(); j++) { pointsConnectedToBase.add(nonLOSBasePoints.poll()); } for (NearRVPoint basePoint : pointsConnectedToBase) { pathsCalculated++; Path pathToBase = ag.calculatePath(origPoint, basePoint, false, false); double pathLen = Double.MAX_VALUE; if (pathToBase.found) { pathLen = pathToBase.getLength(); } if (pathLen < origPoint.distanceToParent) { origPoint.distanceToParent = pathLen; origPoint.parentPoint = basePoint; } } } return pathsCalculated; }
From source file:com.hp.alm.ali.idea.translate.filter.MultipleItemsResolver.java
@Override public String toRESTQuery(String value) { LinkedList<String> list = new LinkedList<String>(); for (String item : Arrays.asList(value.split(";"))) { if (NO_VALUE.equals(item)) { list.add(NO_VALUE); } else {/*ww w . j a v a 2s . c om*/ list.add("\"" + item + "\""); } } return StringUtils.join(list, " OR "); }
From source file:net.semanticmetadata.lire.utils.FileUtils.java
public static void saveImageResultsToPng(String prefix, ImageSearchHits hits, String queryImage, IndexReader reader) throws IOException { LinkedList<BufferedImage> results = new LinkedList<BufferedImage>(); int width = 0; for (int i = 0; i < hits.length(); i++) { // hits.score(i) // hits.doc(i).get("descriptorImageIdentifier") BufferedImage tmp = ImageIO.read(new FileInputStream( reader.document(hits.documentID(i)).getValues(DocumentBuilder.FIELD_NAME_IDENTIFIER)[0])); // if (tmp.getHeight() > 200) { double factor = 200d / ((double) tmp.getHeight()); tmp = ImageUtils.scaleImage(tmp, (int) (tmp.getWidth() * factor), 200); // } width += tmp.getWidth() + 5;/* ww w.j ava2 s . c o m*/ results.add(tmp); } BufferedImage result = new BufferedImage(width, 220, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = (Graphics2D) result.getGraphics(); g2.setColor(Color.white); g2.setBackground(Color.white); g2.clearRect(0, 0, result.getWidth(), result.getHeight()); g2.setColor(Color.black); g2.setFont(Font.decode("\"Arial\", Font.BOLD, 12")); int offset = 0; int count = 0; for (Iterator<BufferedImage> iterator = results.iterator(); iterator.hasNext();) { BufferedImage next = iterator.next(); g2.drawImage(next, offset, 20, null); g2.drawString(hits.score(count) + "", offset + 5, 12); offset += next.getWidth() + 5; count++; } ImageIO.write(result, "PNG", new File(prefix + "_" + (System.currentTimeMillis() / 1000) + ".png")); }
From source file:com.manydesigns.portofino.i18n.ResourceBundleManager.java
public void addSearchPath(String searchPath) { if (searchPaths.contains(searchPath)) { logger.debug("Not adding search path: {}", searchPath); return;//ww w . j a v a 2s . c om } logger.info("Adding search path: {}", searchPath); LinkedList<String> newSearchPaths = new LinkedList<String>(searchPaths); newSearchPaths.add(searchPath); searchPaths = newSearchPaths; resourceBundles.clear(); //Clear cache }
From source file:edu.umd.cfar.lamp.viper.gui.chronology.ViperChronicleSelectionModel.java
public TemporalRange getSelectedTime() { if (nodeWhoseTimeToSelect instanceof TemporalNode) { return ((TemporalNode) nodeWhoseTimeToSelect).getRange(); } else if (nodeWhoseTimeToSelect instanceof Config) { Sourcefile sf = mediator.getCurrFile(); if (sf != null) { Iterator iter = sf.getDescriptorsBy((Config) nodeWhoseTimeToSelect); if (iter.hasNext()) { LinkedList ll = new LinkedList(); while (iter.hasNext()) { ll.add(((Descriptor) iter.next()).getRange()); }//from w w w . ja v a 2s.c o m TemporalRange[] R = new TemporalRange[ll.size()]; ll.toArray(R); return new MultipleRange(R); } } } return null; }
From source file:eu.stratosphere.test.operators.CrossITCase.java
@Parameters public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException { LinkedList<Configuration> tConfigs = new LinkedList<Configuration>(); String[] localStrategies = { PactCompiler.HINT_LOCAL_STRATEGY_NESTEDLOOP_BLOCKED_OUTER_FIRST, PactCompiler.HINT_LOCAL_STRATEGY_NESTEDLOOP_BLOCKED_OUTER_SECOND, PactCompiler.HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_FIRST, PactCompiler.HINT_LOCAL_STRATEGY_NESTEDLOOP_STREAMED_OUTER_SECOND }; String[] shipStrategies = { "BROADCAST_FIRST", "BROADCAST_SECOND" // PactCompiler.HINT_SHIP_STRATEGY_BROADCAST // PactCompiler.HINT_SHIP_STRATEGY_SFR };//from w ww .j av a 2s . co m for (String localStrategy : localStrategies) { for (String shipStrategy : shipStrategies) { Configuration config = new Configuration(); config.setString("CrossTest#LocalStrategy", localStrategy); config.setString("CrossTest#ShipStrategy", shipStrategy); config.setInteger("CrossTest#NoSubtasks", 4); tConfigs.add(config); } } return toParameterList(tConfigs); }
From source file:com.espertech.esper.epl.core.ResultSetProcessorSimple.java
/** * Applies the select-clause to the given events returning the selected events. The number of events stays the * same, i.e. this method does not filter it just transforms the result set. * <p>// w w w.j a v a 2 s.c o m * Also applies a having clause. * @param exprProcessor - processes each input event and returns output event * @param events - input events * @param optionalHavingNode - supplies the having-clause expression * @param isNewData - indicates whether we are dealing with new data (istream) or old data (rstream) * @param isSynthesize - set to true to indicate that synthetic events are required for an iterator result set * @param exprEvaluatorContext context for expression evalauation * @return output events, one for each input event */ protected static EventBean[] getSelectEventsHaving(SelectExprProcessor exprProcessor, Set<MultiKey<EventBean>> events, ExprEvaluator optionalHavingNode, boolean isNewData, boolean isSynthesize, ExprEvaluatorContext exprEvaluatorContext) { LinkedList<EventBean> result = new LinkedList<EventBean>(); for (MultiKey<EventBean> key : events) { EventBean[] eventsPerStream = key.getArray(); Boolean passesHaving = (Boolean) optionalHavingNode.evaluate(eventsPerStream, isNewData, exprEvaluatorContext); if ((passesHaving == null) || (!passesHaving)) { continue; } EventBean resultEvent = exprProcessor.process(eventsPerStream, isNewData, isSynthesize, exprEvaluatorContext); result.add(resultEvent); } if (!result.isEmpty()) { return result.toArray(new EventBean[result.size()]); } else { return null; } }
From source file:com.adobe.acs.commons.mcp.impl.processes.asset.HierarchicalElement.java
@SuppressWarnings("squid:S00112") default void visitAllFolders(CheckedConsumer<HierarchicalElement> visitor, CheckedFunction<HierarchicalElement, Stream<HierarchicalElement>> childFunction) throws Exception { LinkedList<HierarchicalElement> nodes = new LinkedList<>(); nodes.add(this); while (!nodes.isEmpty()) { HierarchicalElement node = nodes.pop(); childFunction.apply(node).forEach(nodes::add); visitor.accept(node);/*from w w w. java 2s. c o m*/ } }
From source file:com.adobe.acs.commons.mcp.impl.processes.asset.HierarchicalElement.java
@SuppressWarnings("squid:S00112") default void visitAllFiles(CheckedConsumer<HierarchicalElement> visitor, CheckedFunction<HierarchicalElement, Stream<HierarchicalElement>> childFolderFunction, CheckedFunction<HierarchicalElement, Stream<HierarchicalElement>> childFileFunction) throws Exception { LinkedList<HierarchicalElement> nodes = new LinkedList<>(); nodes.add(this); while (!nodes.isEmpty()) { HierarchicalElement node = nodes.pop(); childFolderFunction.apply(node).forEach(nodes::add); for (HierarchicalElement child : childFileFunction.apply(node).collect(Collectors.toList())) { visitor.accept(child);//w w w. j av a 2 s. c om } } }