List of usage examples for org.apache.commons.collections.primitives ArrayIntList ArrayIntList
public ArrayIntList(int[] array)
From source file:net.sf.sprockets.util.SparseArrays.java
/** * Get the keys of the SparseBooleanArray which have the value. *//*w ww . j av a 2 s.com*/ private static int[] keys(SparseBooleanArray array, boolean value) { int size = array.size(); ArrayIntList keys = new ArrayIntList(size); for (int i = 0; i < size; i++) { if (array.valueAt(i) == value) { keys.add(array.keyAt(i)); } } return keys.toArray(); }
From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java
private void removeRows(int[] r) { ByteList stat = new ArrayByteList(r.length); IntList von = new ArrayIntList(r.length); DoubleList wert = new ArrayDoubleList(r.length); for (int i = 0; i < r.length; i++) { stat.add(statusList.get(r[i]));/*from w w w. j a v a2 s . c om*/ von.add(vonList.get(r[i])); wert.add(wertList.get(r[i])); } statusList.removeAll(stat); vonList.removeAll(von); wertList.removeAll(wert); }
From source file:net.sf.sprockets.app.ui.SprocketsPreferenceFragment.java
/** * Set the preference's value(s) as its summary. *///from w ww. ja v a 2s . c om protected void setSummary(Preference pref) { SharedPreferences prefs = getPreferenceManager().getSharedPreferences(); if (pref instanceof RingtonePreference) { String val = prefs.getString(pref.getKey(), null); if (!TextUtils.isEmpty(val)) { Ringtone tone = RingtoneManager.getRingtone(a, Uri.parse(val)); if (tone != null) { pref.setSummary(tone.getTitle(a)); } } else { pref.setSummary(R.string.none); } } else if (pref instanceof MultiSelectListPreference) { Set<String> vals = prefs.getStringSet(pref.getKey(), null); if (vals != null) { if (!vals.isEmpty()) { MultiSelectListPreference multi = (MultiSelectListPreference) pref; IntList indexList = new ArrayIntList(vals.size()); for (String val : vals) { // find selected entry indexes int i = multi.findIndexOfValue(val); if (i >= 0) { indexList.add(i); } } int[] indexes = indexList.toArray(); Arrays.sort(indexes); // to display in same order as dialog pref.setSummary(TextUtils.join(getString(R.string.delimiter), Elements.slice(multi.getEntries(), indexes))); } else { pref.setSummary(R.string.none); } } } else if (pref instanceof EditTextPreference) { pref.setSummary(prefs.getString(pref.getKey(), null)); } else if (pref.getClass() == Preference.class) { String val = prefs.getString(pref.getKey(), null); if (!TextUtils.isEmpty(val)) { // don't clear existing summary pref.setSummary(val); } } }
From source file:de.unibayreuth.bayeos.goat.table.MassenTableModel.java
public boolean load(ObjektNode objekt, TimeFilter tFilter, StatusFilter sFilter) { try {/*w w w .ja v a2s . c o m*/ Vector params = new Vector(); params.add(objekt.getId()); params.add(tFilter.getVector()); params.add(sFilter.getVector()); Vector vReturn = (Vector) xmlClient.execute("MassenTableHandler.getRows", params); // Rows als byte[] byte[] ba = (byte[]) vReturn.elementAt(1); statusList = new ArrayByteList(ba.length / rowLength); vonList = new ArrayIntList(ba.length / rowLength); wertList = new ArrayDoubleList(ba.length / rowLength); ByteBuffer b = ByteBuffer.wrap(ba); while (b.hasRemaining()) { vonList.add(b.getInt()); wertList.add((double) b.getFloat()); statusList.add(b.get()); } vReturn = null; logger.debug("MassenTableModel filled with " + getRowCount() + " records."); return true; } catch (XmlRpcException e) { MsgBox.error(e.getMessage()); return false; } }
From source file:org.apache.niolex.common.primitive.IntListMain.java
/** * @param args//from w w w. ja va 2 s . c om */ public static void main(String[] args) { StopWatch w = new StopWatch(1); w.begin(true); // This is slower! for (int i = 0; i < 1000; ++i) { IntList inList = new ArrayIntList(10000); Stop s = w.start(); for (int j = 0; j < 10000; ++j) { inList.add(j); } s.stop(); } w.done(); w.print(); // ------------ w = new StopWatch(1); w.begin(true); for (int i = 0; i < 1000; ++i) { ArrayList<Integer> oList = new ArrayList<Integer>(10000); Stop s = w.start(); for (int j = 0; j < 10000; ++j) { oList.add(j); } s.stop(); } w.done(); w.print(); }
From source file:pipeline.plugins.cell_manipulation.BallSegmentation.java
@Override public void run(ProgressReporter r, MultiListParameter inChannels, TableParameter outChannels, PreviewType previewType, boolean inputHasChanged, AbstractParameter parameterWhoseValueChanged, boolean stayInCoreLoop) throws InterruptedException { final PluginIOCells inputCells = (PluginIOCells) pluginInputs.get("Seeds"); final PluginIOCells outputCells = (PluginIOCells) pluginOutputs.get("Cells"); inputCells.copyInto(outputCells);/*from w w w . j a v a 2s . c om*/ outputCells.clear(); float rad = 0; if (!usedEmbeddedDiameter) { if (inMicrons) { if (inputCells.getCalibration() == null || inputCells.getCalibration().pixelDepth == 0) { throw new IllegalArgumentException("Calibration information not present"); } rad = (float) ((diameter / inputCells.getCalibration().pixelWidth) / 2); } else rad = diameter / 2; } final int xyradius = (int) rad; final float zradius = (float) (rad * (inputCells.getCalibration().pixelWidth / inputCells.getCalibration().pixelDepth)); final int width = inputCells.getWidth(); final int height = inputCells.getHeight(); final int depth = inputCells.getDepth(); ParFor parFor = new ParFor(0, inputCells.getPoints().size() - 1, r, threadPool, true); for (int i = 0; i < parFor.getNThreads(); i++) parFor.addLoopWorker(new ILoopWorker() { int localRadius = xyradius; int localRadiusSq = xyradius * xyradius; List<ClickedPoint> pointList = inputCells.getPoints(); @Override public final Object run(int loopIndex, int threadIndex) { ClickedPoint p = pointList.get(loopIndex); ClickedPoint pCloned = (ClickedPoint) p.clone(); pCloned.listNamesOfQuantifiedProperties = outputCells.getQuantifiedPropertyNames(); pCloned.userCellDescriptions = outputCells.getUserCellDescriptions(); if (usedEmbeddedDiameter) { localRadius = (int) p.getQuantifiedProperty("localRadius"); localRadiusSq = localRadius * localRadius; } int x = (int) p.x; int y = (int) p.y; int z = (int) p.z; int z0 = (int) (diskOnly ? 0 : Math.min(z, zradius)); int z1 = (int) (diskOnly ? 0 : Math.min(depth - 1 - z, zradius)); int y0 = Math.min(y, localRadius); int y1 = Math.min(height - 1 - y, localRadius); int x0 = Math.min(x, localRadius); int x1 = Math.min(width - 1 - x, localRadius); ArrayIntList xCoord = new ArrayIntList(500); ArrayIntList yCoord = new ArrayIntList(500); ArrayIntList zCoord = new ArrayIntList(500); for (int k = -z0; k <= z1; k++) { int kSq = k * k; for (int j = -y0; j <= y1; j++) { int jSq = j * j; for (int i = -x0; i <= x1; i++) { int iSq = i * i; if (kSq + jSq + iSq > localRadiusSq) continue; xCoord.add(x + i); yCoord.add(y + j); zCoord.add(z + k); } } } pCloned.imageFullSegCoordsX = xCoord.getIntArrayFast(); pCloned.imageFullSegCoordsY = yCoord.getIntArrayFast(); pCloned.imageFullSegCoordsZ = zCoord.getIntArrayFast(); return pCloned; } }); for (Object p : parFor.run(true)) { outputCells.addDontFireValueChanged((ClickedPoint) p); } outputCells.fireValueChanged(false, false); }
From source file:pipeline.plugins.cell_manipulation.ExpandPerimeter.java
@Override protected ClickedPoint transform(ClickedPoint point, IPluginIOList<ClickedPoint> allInputPoints, IPluginIOHyperstack inputImage, int pointIndex) { ClickedPoint pCloned = (ClickedPoint) point.clone(); if (point.imageFullSegCoordsX == null || point.imageFullSegCoordsX.length == 0) { missingSegmentation.getAndIncrement(); return pCloned; }// ww w . jav a 2 s. c om Set<Point> innerPoints = new HashSet<>(); int nInnerPoints = point.imageFullSegCoordsX.length; if (onlyExpandOutwards) for (int i = 0; i < nInnerPoints; i++) { float x = point.imageFullSegCoordsX[i]; float y = point.imageFullSegCoordsY[i]; float z = point.imageFullSegCoordsZ[i]; innerPoints.add(new Point((int) x, (int) y, (int) z)); } int nPoints = point.imagePerimsegCoordsX.length; int xyRad = (int) (boxRadius / point.xyCalibration); int zRad = (int) (boxRadius / point.zCalibration); int width = ((PluginIOCells) allInputPoints).getWidth(); int height = ((PluginIOCells) allInputPoints).getHeight(); int depth = ((PluginIOCells) allInputPoints).getDepth(); ArrayIntList xCoord = new ArrayIntList(500); ArrayIntList yCoord = new ArrayIntList(500); ArrayIntList zCoord = new ArrayIntList(500); for (int ii = 0; ii < nPoints; ii++) { int x = point.imagePerimsegCoordsX[ii]; int y = point.imagePerimsegCoordsY[ii]; int z = point.imagePerimsegCoordsZ[ii]; innerPoints.add(new Point(x, y, z)); xCoord.add(x); yCoord.add(y); zCoord.add(z); int z0 = Math.min(z, zRad); int z1 = Math.min(depth - 1 - z, zRad); int y0 = Math.min(y, xyRad); int y1 = Math.min(height - 1 - y, xyRad); int x0 = Math.min(x, xyRad); int x1 = Math.min(width - 1 - x, xyRad); for (int k = -z0; k <= z1; k++) { for (int j = -y0; j <= y1; j++) { for (int i = -x0; i <= x1; i++) { Point candidate = new Point(x + i, y + j, z + k); if (innerPoints.contains(candidate)) continue; xCoord.add(x + i); yCoord.add(y + j); zCoord.add(z + k); // add point to innerPoints so it doesn't get added more than once to the new perimeter innerPoints.add(candidate); } } } } pCloned.imagePerimsegCoordsX = xCoord.getIntArrayFast(); pCloned.imagePerimsegCoordsY = yCoord.getIntArrayFast(); pCloned.imagePerimsegCoordsZ = zCoord.getIntArrayFast(); return pCloned; }