List of usage examples for java.util ArrayList get
public E get(int index)
From source file:Main.java
@SuppressWarnings("unchecked") private static Bundle[] toBundleArray(ArrayList<HashMap> arrayList) { Bundle[] ret = new Bundle[arrayList.size()]; for (int i = 0; i < ret.length; i++) { ret[i] = addMapToBundle(arrayList.get(i), new Bundle()); }//from w ww. j a v a 2 s . co m return ret; }
From source file:Main.java
/** * returns the index of the serached string from the array. If not found returns -1. * /*w w w .ja va 2 s. c o m*/ * @param strValues * @param strSearchedValue * @return */ public static int getIndex(ArrayList<String> alValues, String strSearchedValue) { // cycles on the vcalues of the array for (int j = 0; j < alValues.size(); j++) { // gets the j-th element String strVal = alValues.get(j); // if is the searched one, returns its index if (strVal.equals(strSearchedValue)) return j; } // if arrives here, the searched value hasn't been found return -1; }
From source file:com.github.akinaru.bleanalyzer.bluetooth.events.BluetoothObject.java
public static BluetoothObject parseArrayList(Intent intent) { ArrayList<String> actionsStr = intent.getStringArrayListExtra(""); if (actionsStr.size() > 0) { try {//from w ww .jav a 2 s.com JSONObject mainObject = new JSONObject(actionsStr.get(0)); if (mainObject.has(JsonConstants.BT_ADDRESS) && mainObject.has(JsonConstants.BT_DEVICE_NAME)) { int scanInterval = -1; if (mainObject.has(JsonConstants.BT_ADVERTISING_INTERVAL)) scanInterval = mainObject.getInt(JsonConstants.BT_ADVERTISING_INTERVAL); return new BluetoothObject(mainObject.get(JsonConstants.BT_ADDRESS).toString(), mainObject.get(JsonConstants.BT_DEVICE_NAME).toString(), scanInterval); } } catch (JSONException e) { e.printStackTrace(); } } return null; }
From source file:Main.java
/** * Render a path by actually drawing line segments instead. When using a real {@link Path}, then it is first painted * into a temporary bitmap by the CPU, before being rendered by the GPU. That simply fails for large paths, * therefore we use a synthesis from line segments, since lines are drawn entirely by the GPU. *//*from w ww . j a va2s. co m*/ public static void drawPath(final ArrayList<Point> pixelPoints, final Canvas canvas, final Paint paint) { final float[] pointData = new float[(pixelPoints.size() - 1) * 4]; for (int i = 1; i < pixelPoints.size(); i++) { final Point last = pixelPoints.get(i - 1); final Point current = pixelPoints.get(i); final int index = (i - 1) * 4; // start point pointData[index] = last.x; pointData[index + 1] = last.y; // end point pointData[index + 2] = current.x; pointData[index + 3] = current.y; } canvas.drawLines(pointData, paint); }
From source file:com.flexdesktop.connections.restfulConnection.java
public static void soutMatrix(ArrayList<ArrayList<String>> outJson) { for (ArrayList<String> outJson1 : outJson) { for (int j = 0; j < outJson1.size(); j++) { System.out.println(outJson1.get(j)); }//from w w w. ja v a 2 s. c o m } }
From source file:Main.java
public static List<ByteBuffer> mergeAdjacentBuffers(List<ByteBuffer> samples) { ArrayList<ByteBuffer> nuSamples = new ArrayList<ByteBuffer>(samples.size()); for (ByteBuffer buffer : samples) { int lastIndex = nuSamples.size() - 1; if (lastIndex >= 0 && buffer.hasArray() && nuSamples.get(lastIndex).hasArray() && buffer.array() == nuSamples.get(lastIndex).array() && nuSamples.get(lastIndex).arrayOffset() + nuSamples.get(lastIndex).limit() == buffer.arrayOffset()) { ByteBuffer oldBuffer = nuSamples.remove(lastIndex); ByteBuffer nu = ByteBuffer .wrap(buffer.array(), oldBuffer.arrayOffset(), oldBuffer.limit() + buffer.limit()).slice(); // We need to slice here since wrap([], offset, length) just sets position and not the arrayOffset. nuSamples.add(nu);//w w w. j a v a 2 s. c o m } else if (lastIndex >= 0 && buffer instanceof MappedByteBuffer && nuSamples.get(lastIndex) instanceof MappedByteBuffer && nuSamples.get(lastIndex) .limit() == nuSamples.get(lastIndex).capacity() - buffer.capacity()) { // This can go wrong - but will it? ByteBuffer oldBuffer = nuSamples.get(lastIndex); oldBuffer.limit(buffer.limit() + oldBuffer.limit()); } else { buffer.reset(); nuSamples.add(buffer); } } return nuSamples; }
From source file:Main.java
/** * Find the first descendant element of the given parent Node * whose tag name.equals the given tag. * * @param parent The root of the xml dom tree to search. * @param tag The tag name to match./*w ww. j ava2s . co m*/ * @return The element foudn or null */ public static Element findDescendant(Node parent, String tag) { ArrayList found = new ArrayList(); findDescendants(parent, tag, found); if (found.size() == 0) { return null; } return (Element) found.get(0); }
From source file:helpers.Plots.java
public static void plotSimpleLineXY(ArrayList<double[][]> data, ArrayList<String> seriesName, String title, String xname, String yname) { DefaultXYDataset ds = new DefaultXYDataset(); for (int i = 0; i < data.size(); i++) { System.out.println(data.get(i)[0][0]); ds.addSeries(seriesName.get(i), data.get(i)); }//from w w w . ja v a 2 s .c om JFreeChart chart = ChartFactory.createXYLineChart(title, xname, yname, ds, PlotOrientation.VERTICAL, true, true, false); ChartFrame frame = new ChartFrame(title, chart); frame.pack(); frame.setVisible(true); }
From source file:FaceRatios.java
private static double[] listToArray(ArrayList<Double> list) { double[] data = new double[list.size()]; for (int i = 0; i < list.size(); i++) data[i] = list.get(i); return data;//from w ww . j a v a2s. c o m }
From source file:Main.java
public static String listToString(ArrayList<String> list, String flag) { String strMsg = ""; int listSize = list.size(); if (listSize > 0) { for (int i = 0; i < listSize; i++) { if (i == listSize - 1) { strMsg = strMsg + list.get(i).toString(); } else { strMsg = strMsg + list.get(i).toString() + flag; }//from w w w . ja v a 2s.c om } } else { strMsg = ""; } return strMsg; }