List of usage examples for java.util List indexOf
int indexOf(Object o);
From source file:gov.nih.nci.caarray.plugins.illumina.CsvDataHandler.java
private void validateData(final DelimitedFileReader reader, final FileValidationResult result, final ArrayDesign arrayDesign) throws IOException { final List<String> headers = getHeaders(reader); final int targetIdColumnIndex = headers.indexOf(TARGET_ID); positionAtData(reader);// ww w . java2 s .c om final ProbeNamesValidator probeNamesValidator = new ProbeNamesValidator(this.arrayDao, arrayDesign); final List<String> probeNamesBatch = new ArrayList<String>(BATCH_SIZE); int probeCounter = 0; while (reader.hasNextLine()) { final List<String> nextLineValues = reader.nextLine(); if (nextLineValues.size() != headers.size()) { final ValidationMessage message = result.addMessage(Type.ERROR, "Invalid number of values in row"); message.setLine(reader.getCurrentLineNumber()); } probeNamesBatch.add(nextLineValues.get(targetIdColumnIndex)); probeCounter++; if (0 == probeCounter % BATCH_SIZE) { probeNamesValidator.validateProbeNames(result, probeNamesBatch); probeNamesBatch.clear(); } } if (!probeNamesBatch.isEmpty()) { probeNamesValidator.validateProbeNames(result, probeNamesBatch); } }
From source file:dr.app.bss.Utils.java
public static int arrayIndex(String[] array, String element) { List<String> vector = new ArrayList<String>(); for (int i = 0; i < array.length; i++) { vector.add(array[i]);/*ww w . ja va 2 s .c o m*/ } return vector.indexOf(element); }
From source file:gov.nih.nci.caarray.plugins.illumina.CsvDataHandler.java
private void loadDesignElementList(DataSet dataSet, DelimitedFileReader reader, List<String> headers, ArrayDesign design) throws IOException { final int indexOfTargetId = headers.indexOf(TARGET_ID); final DesignElementBuilder builder = new DesignElementBuilder(dataSet, design, this.arrayDao, this.searchDao); positionAtData(reader);//w ww. jav a 2 s .c om while (reader.hasNextLine()) { final List<String> values = reader.nextLine(); final String probeName = values.get(indexOfTargetId); builder.addProbe(probeName); } builder.finish(); }
From source file:com.haulmont.cuba.gui.components.filter.edit.FilterEditor.java
public void moveConditionUp() { AbstractCondition condition = conditionsDs.getItem(); Node<AbstractCondition> node = conditions.getNode(condition); List<Node<AbstractCondition>> siblings = node.getParent() == null ? conditions.getRootNodes() : node.getParent().getChildren(); int idx = siblings.indexOf(node); if (idx > 0) { Node<AbstractCondition> prev = siblings.get(idx - 1); siblings.set(idx - 1, node);/* www . jav a 2 s. co m*/ siblings.set(idx, prev); refreshConditionsDs(); conditionsTree.setSelected(condition); } }
From source file:com.haulmont.cuba.gui.components.filter.edit.FilterEditor.java
public void moveConditionDown() { AbstractCondition condition = conditionsDs.getItem(); Node<AbstractCondition> node = conditions.getNode(condition); List<Node<AbstractCondition>> siblings = node.getParent() == null ? conditions.getRootNodes() : node.getParent().getChildren(); int idx = siblings.indexOf(node); if (idx < siblings.size() - 1) { Node<AbstractCondition> next = siblings.get(idx + 1); siblings.set(idx + 1, node);/*from ww w . j a va2 s.com*/ siblings.set(idx, next); refreshConditionsDs(); conditionsTree.setSelected(condition); } }
From source file:com.mb.kids_mind.Adapter.SimilarListAdapter.java
public void doRemoveItem(int size, List<Integer> list, int position) { if (size != 0) { //list0=new LinkedList<Integer>(); for (int i = 0; i < size; i++) { if (list.contains(position)) { int index = list.indexOf(position); list.remove(index);// w ww . j av a2 s .c om } } Collections.sort(list); for (int i = 0; i < list.size(); i++) Log.v(TAG, "? " + list.get(i).intValue() + ""); } }
From source file:gr.iti.mklab.reveal.forensics.maps.dq.DQExtractor.java
public void detectDQDiscontinuities() { int imWidth = dcts.length; int imHeight = dcts[0].length; int[] p_h_avg = new int[maxCoeffs]; int[] p_h_fft = new int[maxCoeffs]; int[] p_final = new int[maxCoeffs]; double[][] pTampered = new double[maxCoeffs][]; double[][] pUntampered = new double[maxCoeffs][]; for (int coeffIndex = 0; coeffIndex < maxCoeffs; coeffIndex++) { int coe = coeff[coeffIndex]; int startY = coe % 8 - 1; if (startY == -1) { startY = 8;/*from w ww . j a v a2 s . co m*/ } int startX = (int) Math.floor((coe - 1) / 8); List<Integer> selectedCoeffs = new ArrayList<Integer>(); for (int ii = startX; ii < imWidth; ii += 8) { for (int jj = startY; jj < imHeight; jj += 8) { selectedCoeffs.add(dcts[ii][jj]); } } int minCoeffValue = Collections.min(selectedCoeffs); int maxCoeffValue = Collections.max(selectedCoeffs); int s_0; Double[] coeffHist = new Double[0]; if (maxCoeffValue - minCoeffValue > 0) { //will be a power of 2 to allow for fft (zero padded) int trueHistRange = maxCoeffValue - minCoeffValue + 1; //int histLength = trueHistRange; int histLength = (int) Math.pow(2, Math.ceil(Math.log(trueHistRange) / Math.log(2))); coeffHist = new Double[histLength]; for (int ii = 0; ii < coeffHist.length; ii++) { coeffHist[ii] = 0.0; } for (Integer selectedCoeff : selectedCoeffs) { coeffHist[selectedCoeff - minCoeffValue] += 1; } List<Double> coeffHistList = Arrays.asList(coeffHist); s_0 = coeffHistList.indexOf(Collections.max(coeffHistList)); List<Double> h = new ArrayList<>(); DescriptiveStatistics vals; for (int coeffInd = 1; coeffInd < coeffHistList.size(); coeffInd++) { vals = new DescriptiveStatistics(); for (int leapInd = s_0; leapInd < coeffHistList.size(); leapInd += coeffInd) { vals.addValue(coeffHistList.get(leapInd)); } for (int leapInd = s_0 - coeffInd; leapInd >= 0; leapInd -= coeffInd) { vals.addValue(coeffHistList.get(leapInd)); } h.add(vals.getMean()); } p_h_avg[coeffIndex] = (h.indexOf(Collections.max(h))); FastFourierTransformer fastFourierTransformer = new FastFourierTransformer( DftNormalization.STANDARD); Complex[] fft = fastFourierTransformer.transform(ArrayUtils.toPrimitive(coeffHist), TransformType.FORWARD); double[] power = new double[fft.length]; for (int ii = 0; ii < power.length; ii++) { power[ii] = fft[ii].abs(); } //Find first local minimum, to bypass DC peak double DC = power[0]; int FreqValley = 1; while (FreqValley < power.length - 1 & power[FreqValley] >= power[FreqValley + 1]) { FreqValley++; } int maxFFTInd = 0; double maxFFTVal = 0; double minFFTVal = Double.MAX_VALUE; for (int ii = FreqValley; ii < power.length / 2; ii++) { if (power[ii] > maxFFTVal) { maxFFTInd = ii; maxFFTVal = power[ii]; } if (power[ii] < minFFTVal) { minFFTVal = power[ii]; } } if (maxFFTInd == 0 | maxFFTVal < (DC / 5) | minFFTVal / maxFFTVal > 0.9) { p_h_fft[coeffIndex] = 1; } else { p_h_fft[coeffIndex] = Math.round(coeffHist.length / maxFFTInd); } } else { p_h_avg[coeffIndex] = 1; p_h_fft[coeffIndex] = 1; s_0 = 0; } if (p_h_avg[coeffIndex] < p_h_fft[coeffIndex]) { p_final[coeffIndex] = p_h_avg[coeffIndex]; } else { p_final[coeffIndex] = p_h_fft[coeffIndex]; } pTampered[coeffIndex] = new double[selectedCoeffs.size()]; pUntampered[coeffIndex] = new double[selectedCoeffs.size()]; int[] adjustedCoeffs = new int[selectedCoeffs.size()]; int[] period_start = new int[selectedCoeffs.size()]; int[] period; int[] num = new int[selectedCoeffs.size()]; int[] denom = new int[selectedCoeffs.size()]; double[] P_u = new double[selectedCoeffs.size()]; double[] P_t = new double[selectedCoeffs.size()]; if (p_final[coeffIndex] != 1) { for (int ii = 0; ii < adjustedCoeffs.length; ii++) { adjustedCoeffs[ii] = selectedCoeffs.get(ii) - minCoeffValue; period_start[ii] = adjustedCoeffs[ii] - rem(adjustedCoeffs[ii] - s_0, p_final[coeffIndex]); } for (int kk = 0; kk < selectedCoeffs.size(); kk++) { if (period_start[kk] > s_0) { period = new int[p_final[coeffIndex]]; for (int ii = 0; ii < p_final[coeffIndex]; ii++) { period[ii] = period_start[kk] + ii; if (period[ii] >= coeffHist.length) { period[ii] = period[ii] - p_final[coeffIndex]; } } num[kk] = (int) coeffHist[adjustedCoeffs[kk]].doubleValue(); denom[kk] = 0; for (int ll = 0; ll < period.length; ll++) { denom[kk] = denom[kk] + (int) coeffHist[period[ll]].doubleValue(); } } else { period = new int[p_final[coeffIndex]]; for (int ii = 0; ii < p_final[coeffIndex]; ii++) { period[ii] = period_start[kk] - ii; if (period_start[kk] - p_final[coeffIndex] + 1 <= 0) { if (period[ii] <= 0) { period[ii] = period[ii] + p_final[coeffIndex]; } } } num[kk] = (int) coeffHist[adjustedCoeffs[kk]].doubleValue(); denom[kk] = 0; for (int ll = 0; ll < period.length; ll++) { denom[kk] = denom[kk] + (int) coeffHist[period[ll]].doubleValue(); } } P_u[kk] = ((double) num[kk] / denom[kk]); P_t[kk] = (1.0 / p_final[coeffIndex]); if (P_u[kk] + P_t[kk] != 0) { pTampered[coeffIndex][kk] = P_t[kk] / (P_u[kk] + P_t[kk]); pUntampered[coeffIndex][kk] = P_u[kk] / (P_u[kk] + P_t[kk]); } else { pTampered[coeffIndex][kk] = 0.5; pUntampered[coeffIndex][kk] = 0.5; } } } else { for (int kk = 0; kk < selectedCoeffs.size(); kk++) { pTampered[coeffIndex][kk] = 0.5; pUntampered[coeffIndex][kk] = 0.5; } } } double[] pTamperedOverall = new double[pTampered[0].length]; double pTamperedProd; double pUntamperedProd; for (int locationIndex = 0; locationIndex < pTampered[0].length; locationIndex++) { pTamperedProd = 1; pUntamperedProd = 1; for (int coeffIndex = 0; coeffIndex < pTampered.length; coeffIndex++) { pTamperedProd = pTamperedProd * pTampered[coeffIndex][locationIndex]; pUntamperedProd = pUntamperedProd * pUntampered[coeffIndex][locationIndex]; } if (pTamperedProd + pUntamperedProd != 0) { pTamperedOverall[locationIndex] = pTamperedProd / (pTamperedProd + pUntamperedProd); } else { pTamperedOverall[locationIndex] = 0; } } int blocksH = imWidth / 8; int blocksV = imHeight / 8; double[][] outputMap = new double[blocksV][blocksH]; for (int kk = 0; kk < pTamperedOverall.length; kk++) { outputMap[kk % blocksV][(int) Math.floor(kk / blocksV)] = pTamperedOverall[kk]; if (pTamperedOverall[kk] > maxProbValue) { maxProbValue = pTamperedOverall[kk]; } if (pTamperedOverall[kk] < minProbValue) { minProbValue = pTamperedOverall[kk]; } } probabilityMap = outputMap; BufferedImage outputIm = visualizeWithJet(outputMap); // output displaySurface = outputIm; }
From source file:com.boxedfolder.carrot.service.impl.AnalyticsServiceImpl.java
@Override public List<AnalyticsTransfer> beaconsTriggered(DateTime from, DateTime to) { List<AnalyticsTransfer> output = new ArrayList<>(); List<AnalyticsLog> logs = findAll(from, to); for (AnalyticsLog log : logs) { AnalyticsTransfer transfer = new AnalyticsTransfer(); transfer.setId(log.getBeacon().getId()); transfer.setName(log.getBeacon().getName()); if (!output.contains(transfer)) { output.add(transfer);//w ww .j a va 2s . co m } else { transfer = output.get(output.indexOf(transfer)); } Integer value = transfer.getCount(); value++; transfer.setCount(value); } return output; }
From source file:com.haulmont.cuba.web.gui.components.WebCalendar.java
@Override public Map<Month, String> getMonthNames() { List<String> months = Arrays.asList(component.getMonthNamesShort()); return months.stream().collect(Collectors.toMap((String m) -> Month.of(months.indexOf(m) + 1), m -> m)); }
From source file:gobblin.source.extractor.extract.QueryBasedExtractor.java
/** * @param given list of primary key columns * @param column name to search for/*from ww w. j av a 2 s . c om*/ * @return index of the column if it exist in given list of primary key columns. otherwise, return 0 */ protected int getPrimarykeyIndex(String primarykeyColumn, String columnName) { if (columnName != null) { columnName = columnName.toLowerCase(); } if (StringUtils.isNotBlank(primarykeyColumn)) { List<String> primarykeyColumnList = Arrays.asList(primarykeyColumn.toLowerCase().split(",")); return primarykeyColumnList.indexOf(columnName) + 1; } return 0; }