List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:android.databinding.tool.reflection.ModelClass.java
/** * Finds public methods that matches the given name exactly. These may be resolved into * listener methods during Expr.resolveListeners. *//*from w ww .j av a 2 s . c o m*/ public List<ModelMethod> findMethods(String name, boolean staticOnly) { ModelMethod[] methods = getDeclaredMethods(); ArrayList<ModelMethod> matching = new ArrayList<ModelMethod>(); for (ModelMethod method : methods) { if (method.getName().equals(name) && (!staticOnly || method.isStatic()) && method.isPublic()) { matching.add(method); } } if (matching.isEmpty()) { return null; } return matching; }
From source file:gov.nih.nci.integration.catissue.client.CaTissueParticipantClient.java
/** * This method is used to populate the CP-title inside Participant object for given CP-shortTitle. Also it will call * method to populate the default ConsentTierResponse * //from ww w . j a v a 2 s . c o m * @param participant * @return Participant with Title populated * @throws ApplicationException - ApplicationException */ private Participant populateCP(Participant participant) throws ApplicationException { final ArrayList<CollectionProtocolRegistration> cprColl = new ArrayList<CollectionProtocolRegistration>( participant.getCollectionProtocolRegistrationCollection()); if (!cprColl.isEmpty()) { // We are expecting only ONE CPR here final CollectionProtocolRegistration incomingCPR = cprColl.get(0); final CollectionProtocol incomingCP = incomingCPR.getCollectionProtocol(); // get the existing CollectionProtocol for given shortTitle final CollectionProtocol fetchedCP = getExistingCollectionProtocol(incomingCP.getShortTitle()); if (fetchedCP != null) { // set the fetched CP_Title into the Participant-CPR-CP-title incomingCP.setTitle(fetchedCP.getTitle()); populateConsentTierResponse(incomingCPR, fetchedCP); } } return participant; }
From source file:com.samsung.multiwindow.MultiWindow.java
/** * Get the MultiWindow enabled applications and activity names * // w w w .j a v a2 s .c om * @param windowType * The window type freestyle or splitstyle. * @param callbackContext * The callback id used when calling back into JavaScript. * */ private void getMultiWindowApps(final String windowType, final CallbackContext callbackContext) throws JSONException { if (Log.isLoggable(MULTIWINDOW, Log.DEBUG)) { Log.d(TAG, "Inside getMultiWindowApps"); } cordova.getThreadPool().execute(new Runnable() { public void run() { JSONArray multiWindowApps = new JSONArray(); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> resolveInfos = cordova.getActivity().getPackageManager().queryIntentActivities( intent, PackageManager.GET_RESOLVED_FILTER | PackageManager.GET_META_DATA); try { // Get the multiwindow enabled applications int index = 0; for (ResolveInfo r : resolveInfos) { if (r.activityInfo != null && r.activityInfo.applicationInfo.metaData != null) { if (r.activityInfo.applicationInfo.metaData .getBoolean("com.sec.android.support.multiwindow") || r.activityInfo.applicationInfo.metaData .getBoolean("com.samsung.android.sdk.multiwindow.enable")) { JSONObject appInfo = new JSONObject(); boolean bUnSupportedMultiWinodw = false; if (windowType.equalsIgnoreCase("splitstyle")) { if (r.activityInfo.metaData != null) { String activityWindowStyle = r.activityInfo.metaData .getString("com.sec.android.multiwindow.activity.STYLE"); if (activityWindowStyle != null) { ArrayList<String> activityWindowStyles = new ArrayList<String>( Arrays.asList(activityWindowStyle.split("\\|"))); if (!activityWindowStyles.isEmpty()) { if (activityWindowStyles.contains("fullscreenOnly")) { bUnSupportedMultiWinodw = true; } } } } } if (!bUnSupportedMultiWinodw || !windowType.equalsIgnoreCase("splitstyle")) { appInfo.put("packageName", r.activityInfo.applicationInfo.packageName); appInfo.put("activity", r.activityInfo.name); multiWindowApps.put(index++, appInfo); } } } } callbackContext.success(multiWindowApps); } catch (Exception e) { callbackContext.error(e.getMessage()); } } }); }
From source file:com.ga.forms.DailyLogUI.java
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed System.out.print(/* w w w .j a va 2s . c o m*/ "REGEX: " + monthCombo.getSelectedItem().toString() + "-" + yearCombo.getSelectedItem().toString()); JFrame fileChooserFrame = new JFrame(); JFileChooser saveFileDialog = new JFileChooser(); FileNameExtensionFilter fileExtentionFilter = new FileNameExtensionFilter("Comma Seperated Values (*.csv)", "csv"); saveFileDialog.setFileFilter(fileExtentionFilter); int saveFileDialogStatus = saveFileDialog.showSaveDialog(fileChooserFrame); if (saveFileDialogStatus == JFileChooser.APPROVE_OPTION) { String fileSaveDetails = saveFileDialog.getSelectedFile().toString(); args = new HashMap(); HashMap regex = new HashMap(); regex.put("$regex", monthCombo.getSelectedItem().toString() + "-" + yearCombo.getSelectedItem().toString()); args.put("date", regex); DailyLogRecord record = new DailyLogRecord(); ArrayList logs = record.retrieveRecord(args); String[] columnNames = new String[] { "Date", "Day", "In", "Out", "Break", "Duration", "Under-Time", "Over-Time" }; ArrayList data = null; if (!logs.isEmpty()) { data = new ArrayList(); data.add(String.join(",", columnNames)); for (int logIndex = 0; logIndex < logs.size(); logIndex++) { JSONObject logJSONOBject = new JSONObject((Map) logs.get(logIndex)); String csvRecord = logJSONOBject.get("date").toString() + "," + logJSONOBject.get("day").toString() + "," + logJSONOBject.get("check-in").toString() + "," + logJSONOBject.get("check-out").toString() + "," + logJSONOBject.get("break").toString() + "," + logJSONOBject.get("duration").toString() + "," + logJSONOBject.get("under-time").toString() + "," + logJSONOBject.get("over-time").toString(); data.add(csvRecord); } } DailyLogCSVExport csvExporter = new DailyLogCSVExport(); csvExporter.save(data, fileSaveDetails); } }
From source file:info.icefilms.icestream.browse.Location.java
public ArrayList<Item> GetListItems(Callback callback) { // Download the page String page = DownloadPage(mURL, callback); if (page == null) { return null; } else if (page.length() == 0) { if (callback.GetErrorBoolean() == false) { callback.SetErrorBoolean(true); callback.SetErrorStringID(R.string.browse_page_download_error); }//w ww. j ava2 s . c om return null; } // Get the list of items ArrayList<Item> listItems = OnGetListItems(page, callback); // Check for any errors if (listItems == null) { return null; } else if (listItems.isEmpty()) { if (callback.GetErrorBoolean() == false) { callback.SetErrorBoolean(true); callback.SetErrorStringID(R.string.browse_parse_error); } return null; } return listItems; }
From source file:blusunrize.immersiveengineering.client.render.TileRenderAutoWorkbench.java
public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) { if (stack.isEmpty()) return null; EntityPlayer player = ClientUtils.mc().player; ArrayList<BufferedImage> images = new ArrayList<>(); try {// w w w . java 2 s . c o m IBakedModel ibakedmodel = ClientUtils.mc().getRenderItem().getItemModelWithOverrides(stack, world, player); HashSet<String> textures = new HashSet(); Collection<BakedQuad> quads = ibakedmodel.getQuads(null, null, 0); for (BakedQuad quad : quads) if (quad != null && quad.getSprite() != null) textures.add(quad.getSprite().getIconName()); for (String s : textures) { ResourceLocation rl = new ResourceLocation(s); rl = new ResourceLocation(rl.getNamespace(), String.format("%s/%s%s", "textures", rl.getPath(), ".png")); IResource resource = ClientUtils.mc().getResourceManager().getResource(rl); BufferedImage bufferedImage = TextureUtil.readBufferedImage(resource.getInputStream()); if (bufferedImage != null) images.add(bufferedImage); } } catch (Exception e) { } if (images.isEmpty()) return null; ArrayList<Pair<TexturePoint, TexturePoint>> lines = new ArrayList(); HashSet testSet = new HashSet(); HashMultimap<Integer, TexturePoint> area = HashMultimap.create(); int wMax = 0; for (BufferedImage bufferedImage : images) { Set<Pair<TexturePoint, TexturePoint>> temp_lines = new HashSet<>(); int w = bufferedImage.getWidth(); int h = bufferedImage.getHeight(); if (h > w) h = w; if (w > wMax) wMax = w; for (int hh = 0; hh < h; hh++) for (int ww = 0; ww < w; ww++) { int argb = bufferedImage.getRGB(ww, hh); float r = (argb >> 16 & 255) / 255f; float g = (argb >> 8 & 255) / 255f; float b = (argb & 255) / 255f; float intesity = (r + b + g) / 3f; int alpha = (argb >> 24) & 255; if (alpha > 0) { boolean added = false; //Check colour sets for similar colour to shade it later TexturePoint tp = new TexturePoint(ww, hh, w); if (!testSet.contains(tp)) { for (Integer key : area.keySet()) { for (TexturePoint p : area.get(key)) { float mod = w / (float) p.scale; int pColour = bufferedImage.getRGB((int) (p.x * mod), (int) (p.y * mod)); float dR = (r - (pColour >> 16 & 255) / 255f); float dG = (g - (pColour >> 8 & 255) / 255f); float dB = (b - (pColour & 255) / 255f); double delta = Math.sqrt(dR * dR + dG * dG + dB * dB); if (delta < .25) { area.put(key, tp); added = true; break; } } if (added) break; } if (!added) area.put(argb, tp); testSet.add(tp); } //Compare to direct neighbour for (int i = 0; i < 4; i++) { int xx = (i == 0 ? -1 : i == 1 ? 1 : 0); int yy = (i == 2 ? -1 : i == 3 ? 1 : 0); int u = ww + xx; int v = hh + yy; int neighbour = 0; float delta = 1; boolean notTransparent = false; if (u >= 0 && u < w && v >= 0 && v < h) { neighbour = bufferedImage.getRGB(u, v); notTransparent = ((neighbour >> 24) & 255) > 0; if (notTransparent) { float neighbourIntesity = ((neighbour >> 16 & 255) + (neighbour >> 8 & 255) + (neighbour & 255)) / 765f; float intesityDelta = Math.max(0, Math.min(1, Math.abs(intesity - neighbourIntesity))); float rDelta = Math.max(0, Math.min(1, Math.abs(r - (neighbour >> 16 & 255) / 255f))); float gDelta = Math.max(0, Math.min(1, Math.abs(g - (neighbour >> 8 & 255) / 255f))); float bDelta = Math.max(0, Math.min(1, Math.abs(b - (neighbour & 255) / 255f))); delta = Math.max(intesityDelta, Math.max(rDelta, Math.max(gDelta, bDelta))); delta = delta < .25 ? 0 : delta > .4 ? 1 : delta; } } if (delta > 0) { Pair<TexturePoint, TexturePoint> l = Pair.of( new TexturePoint(ww + (i == 0 ? 0 : i == 1 ? 1 : 0), hh + (i == 2 ? 0 : i == 3 ? 1 : 0), w), new TexturePoint(ww + (i == 0 ? 0 : i == 1 ? 1 : 1), hh + (i == 2 ? 0 : i == 3 ? 1 : 1), w)); temp_lines.add(l); } } } } lines.addAll(temp_lines); } ArrayList<Integer> lumiSort = new ArrayList<>(area.keySet()); Collections.sort(lumiSort, (rgb1, rgb2) -> Double.compare(getLuminance(rgb1), getLuminance(rgb2))); HashMultimap<ShadeStyle, Point> complete_areaMap = HashMultimap.create(); int lineNumber = 2; int lineStyle = 0; for (Integer i : lumiSort) { complete_areaMap.putAll(new ShadeStyle(lineNumber, lineStyle), area.get(i)); ++lineStyle; lineStyle %= 3; if (lineStyle == 0) lineNumber += 1; } Set<Pair<Point, Point>> complete_lines = new HashSet<>(); for (Pair<TexturePoint, TexturePoint> line : lines) { TexturePoint p1 = line.getKey(); TexturePoint p2 = line.getValue(); complete_lines.add(Pair.of( new Point((int) (p1.x / (float) p1.scale * wMax), (int) (p1.y / (float) p1.scale * wMax)), new Point((int) (p2.x / (float) p2.scale * wMax), (int) (p2.y / (float) p2.scale * wMax)))); } return new BlueprintLines(wMax, complete_lines, complete_areaMap); }
From source file:com.lewisd.maven.lint.plugin.CheckMojo.java
protected String generateErrorMessage(List<String> outputReportList) throws MojoExecutionException { final StringBuffer message = new StringBuffer("[LINT] Violations found. "); if (outputReportList.isEmpty()) { message.append(// ww w . j a v a 2s . co m "No output reports have been configured. Please see documentation regarding the outputReports configuration parameter."); } else { final boolean wroteSummaryToConsole; final ArrayList<String> remainingReports = new ArrayList<String>(outputReportList); if (outputReportList.contains("summary") && SummaryReportWriter.isConsole(summaryOutputFile)) { wroteSummaryToConsole = true; message.append("For more details, see error messages above"); remainingReports.remove("summary"); } else { wroteSummaryToConsole = false; message.append("For more details"); } if (remainingReports.isEmpty()) { message.append("."); } else { if (wroteSummaryToConsole) { message.append(", or "); } else { message.append(" see "); } message.append("results in "); if (remainingReports.size() == 1) { final File outputFile = getOutputFileForReport(remainingReports.get(0)); message.append(outputFile.getAbsolutePath()); } else { message.append("one of the following files: "); boolean first = true; for (final String report : remainingReports) { if (!first) { message.append(", "); } final File outputFile = getOutputFileForReport(report); message.append(outputFile.getAbsolutePath()); first = false; } } } } return message.toString(); }
From source file:blusunrize.immersiveengineering.common.items.ItemRevolver.java
@Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { if (stack.isEmpty() || player == null) return;/*from w ww . j av a 2s .c om*/ if (stack.getItemDamage() == 1) return; String uuid = player.getUniqueID().toString(); if (specialRevolvers.containsKey(uuid)) { ArrayList<SpecialRevolver> list = new ArrayList(specialRevolvers.get(uuid)); if (!list.isEmpty()) { list.add(null); String existingTag = ItemNBTHelper.getString(stack, "elite"); if (existingTag.isEmpty()) applySpecialCrafting(stack, list.get(0)); else { int i = 0; for (; i < list.size(); i++) if (list.get(i) != null && existingTag.equals(list.get(i).tag)) break; int next = (i + 1) % list.size(); applySpecialCrafting(stack, list.get(next)); } } } this.recalculateUpgrades(stack); }
From source file:com.l2jfrozen.gameserver.geo.pathfinding.PathFinding.java
public final Node[] searchByClosest2(final Node start, final Node end) { // Always continues checking from the closest to target non-blocked // node from to_visit list. There's extra length in path if needed // to go backwards/sideways but when moving generally forwards, this is extra fast // and accurate. And can reach insane distances (try it with 800 nodes..). // Minimum required node count would be around 300-400. // Generally returns a bit (only a bit) more intelligent looking routes than // the basic version. Not a true distance image (which would increase CPU // load) level of intelligence though. // List of Visited Nodes final L2FastSet<Node> visited = L2Collections.newL2FastSet(); // List of Nodes to Visit final ArrayList<Node> to_visit = L2Collections.newArrayList(); to_visit.add(start);//from w ww . j a v a2 s .c om try { final int targetx = end.getNodeX(); final int targety = end.getNodeY(); int dx, dy; boolean added; int i = 0; while (i < 550) { if (to_visit.isEmpty()) { // No Path found return null; } final Node node = to_visit.remove(0); if (node.equals(end)) // path found! { return constructPath2(node); } i++; visited.add(node); node.attachNeighbors(); final Node[] neighbors = node.getNeighbors(); if (neighbors == null) continue; for (final Node n : neighbors) { if (!visited.contains(n) && !to_visit.contains(n)) { added = false; n.setParent(node); dx = targetx - n.getNodeX(); dy = targety - n.getNodeY(); n.setCost(dx * dx + dy * dy); for (int index = 0; index < to_visit.size(); index++) { // supposed to find it quite early.. if (to_visit.get(index).getCost() > n.getCost()) { to_visit.add(index, n); added = true; break; } } if (!added) to_visit.add(n); } } } // No Path found return null; } finally { L2Collections.recycle(visited); L2Collections.recycle(to_visit); } }
From source file:com.ga.forms.DailyLogUI.java
private ArrayList updateDailyLogTable(ArrayList logs, String currMonth, String currTear) { String[] columnNames = new String[] { "Date", "Day", "In", "Out", "Break", "Duration", "Under-Time", "Over-Time" }; Object[][] data = null;/*from ww w . j ava 2 s .c om*/ ArrayList duration = null; if (!logs.isEmpty()) { duration = new ArrayList(); data = new Object[logs.size()][columnNames.length]; for (int logIndex = 0; logIndex < logs.size(); logIndex++) { JSONObject logJSONOBject = new JSONObject((Map) logs.get(logIndex)); data[logIndex][0] = logJSONOBject.get("date"); data[logIndex][1] = logJSONOBject.get("day"); data[logIndex][2] = logJSONOBject.get("check-in"); data[logIndex][3] = logJSONOBject.get("check-out"); data[logIndex][4] = logJSONOBject.get("break"); data[logIndex][5] = logJSONOBject.get("duration"); data[logIndex][6] = logJSONOBject.get("under-time"); data[logIndex][7] = logJSONOBject.get("over-time"); duration.add(logJSONOBject.get("duration")); } } DefaultTableModel dailyLogTableModel = new DefaultTableModel(data, columnNames); dailyLogTable.setModel(dailyLogTableModel); return duration; }