List of usage examples for org.apache.commons.lang ArrayUtils toPrimitive
public static boolean[] toPrimitive(Boolean[] array)
Converts an array of object Booleans to primitives.
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.FilteringController.java
/** * Get the mean displacement for a condition. * * @param plateCondition// w ww . j av a 2s.c om * @return */ public Double getMedianDisplAcrossReplicates(PlateCondition plateCondition) { SingleCellConditionDataHolder conditionDataHolder = singleCellPreProcessingController .getConditionDataHolder(plateCondition); Double[] instantaneousDisplacementsVector = conditionDataHolder.getInstantaneousDisplacementsVector(); return AnalysisUtils.computeMedian( ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(instantaneousDisplacementsVector))); }
From source file:com.flexive.core.security.UserTicketImpl.java
/** * (Re)load all assignments for the guest user ticket * * @param flagDirty flag the UserTicketStores guest ticket as dirty? */// w w w .j a va 2 s.c o m public static synchronized void reloadGuestTicketAssignments(boolean flagDirty) { try { if (CacheAdmin.isEnvironmentLoaded()) { STRUCTURE_TIMESTAMP = CacheAdmin.getEnvironment().getTimeStamp(); } AccountEngine accountInterface = EJBLookup.getAccountEngine(); final List<ACLAssignment> assignmentList = accountInterface.loadAccountAssignments(Account.USER_GUEST); guestACLAssignments = assignmentList.toArray(new ACLAssignment[assignmentList.size()]); final List<Role> roles = accountInterface.getRoles(Account.USER_GUEST, RoleLoadMode.ALL); guestRoles = roles.toArray(new Role[roles.size()]); final List<Long> groupList = FxSharedUtils .getSelectableObjectIdList(accountInterface.getGroups(Account.USER_GUEST)); guestGroups = ArrayUtils.toPrimitive(groupList.toArray(new Long[groupList.size()])); guestContactData = accountInterface.load(Account.USER_GUEST).getContactData(); if (flagDirty) UserTicketStore.flagDirtyHavingUserId(Account.USER_GUEST); } catch (FxApplicationException e) { guestACLAssignments = null; LOG.error(e); } }
From source file:de.alpharogroup.file.checksum.ChecksumExtensions.java
/** * Gets the checksum from the given byte array with an instance of. * * @param bytes/* w ww . ja va 2 s. c o m*/ * the Byte object array. * @param algorithm * the algorithm to get the checksum. This could be for instance "MD4", "MD5", * "SHA-1", "SHA-256", "SHA-384" or "SHA-512". * @return The checksum from the file as a String object. * @throws NoSuchAlgorithmException * Is thrown if the algorithm is not supported or does not exists. * {@link java.security.MessageDigest} object. */ public static String getChecksum(final Byte[] bytes, final String algorithm) throws NoSuchAlgorithmException { return getChecksum(ArrayUtils.toPrimitive(bytes), algorithm); }
From source file:be.ugent.maf.cellmissy.analysis.singlecell.processing.impl.SingleCellConditionOperatorImpl.java
/** * * @param singleCellConditionDataHolder/* w w w . j ava 2s. c o m*/ */ @Override public void computeMedianSpeed(SingleCellConditionDataHolder singleCellConditionDataHolder) { for (SingleCellWellDataHolder singleCellWellDataHolder : singleCellConditionDataHolder .getSingleCellWellDataHolders()) { double medianSpeed = AnalysisUtils.computeMedian(ArrayUtils .toPrimitive(AnalysisUtils.excludeNullValues(singleCellWellDataHolder.getTrackSpeedsVector()))); singleCellConditionDataHolder.setMedianSpeed(medianSpeed); } }
From source file:ch.algotrader.esper.aggregation.GenericTALibFunction.java
@Override public Object getValue() { try {//w ww . j a va2s.co m // get the total number of parameters int numberOfArgs = 2 + this.inputParams.size() + this.optInputParams.size() + 2 + this.outputParams.size(); Object[] args = new Object[numberOfArgs]; // get the size of the first input buffer int elements = this.inputParams.iterator().next().size(); args[0] = elements - 1; // startIdx args[1] = elements - 1; // endIdx // inputParams int argCount = 2; for (CircularFifoBuffer<Number> buffer : this.inputParams) { // look at the first element of the buffer to determine the type Object firstElement = buffer.iterator().next(); if (firstElement instanceof Double) { args[argCount] = ArrayUtils.toPrimitive(buffer.toArray(new Double[0])); } else if (firstElement instanceof Integer) { args[argCount] = ArrayUtils.toPrimitive(buffer.toArray(new Integer[0])); } else { throw new IllegalArgumentException("unsupported type " + firstElement.getClass()); } argCount++; } // optInputParams for (Object object : this.optInputParams) { args[argCount] = object; argCount++; } // begin MInteger begin = new MInteger(); args[argCount] = begin; argCount++; // length MInteger length = new MInteger(); args[argCount] = length; argCount++; // OutputParams for (Map.Entry<String, Object> entry : this.outputParams.entrySet()) { args[argCount++] = entry.getValue(); } // invoke the function RetCode retCode = (RetCode) this.function.invoke(this.core, args); if (retCode == RetCode.Success) { if (length.value == 0) { return null; } // if we only have one outPutParam return that value // otherwise return a Map if (this.outputParams.size() == 1) { Object value = this.outputParams.values().iterator().next(); return getNumberFromNumberArray(value); } else { Object returnObject = this.outputClass.newInstance(); for (Map.Entry<String, Object> entry : this.outputParams.entrySet()) { Number value = getNumberFromNumberArray(entry.getValue()); String name = entry.getKey().toLowerCase().substring(3); Field field = this.outputClass.getField(name); field.set(returnObject, value); } return returnObject; } } else { throw new RuntimeException(retCode.toString()); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.filtering.FilteringController.java
public void setPercentileDispl(PlateCondition plateCondition) { SingleCellConditionDataHolder conditionDataHolder = singleCellPreProcessingController .getConditionDataHolder(plateCondition); multipleCutOffFilteringController.getMultipleCutOffPanel().getPercentileDisplTextField() .setText("" + AnalysisUtils.roundThreeDecimals(AnalysisUtils.computeQuantile( ArrayUtils.toPrimitive( AnalysisUtils.excludeNullValues(conditionDataHolder.getTrackDisplacementsVector())), 5)));// w w w . jav a2 s .c o m }
From source file:com.kylinolap.job.engine.JobEngine.java
private double[] getJobStepDuration() { Collection<Double> values = JOB_DURATION.values(); Double[] all = (Double[]) values.toArray(new Double[values.size()]); return ArrayUtils.toPrimitive(all); }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java
/** * * @param track/*w w w . j a v a 2s . co m*/ */ private void plotDisplInTime(Track track) { Double[] stepDisplacements = track.getStepDisplacements(); double[] timeIndexes = track.getTimeIndexes(); XYSeries xYSeries = JFreeChartUtils.generateXYSeries(timeIndexes, ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(stepDisplacements))); XYSeriesCollection ySeriesCollection = new XYSeriesCollection(xYSeries); JFreeChart displInTimeChart = ChartFactory.createXYLineChart("displacements in time", "time index", "displ.", ySeriesCollection, PlotOrientation.VERTICAL, false, true, false); ChartPanel chartPanel = new ChartPanel(displInTimeChart); computationDataPanel.getDisplParentPanel().removeAll(); computationDataPanel.getDisplParentPanel().add(chartPanel, gridBagConstraints); computationDataPanel.getDisplParentPanel().revalidate(); computationDataPanel.getDisplParentPanel().repaint(); }
From source file:eu.crydee.alignment.aligner.ae.MetricsSummaryAE.java
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { try {/* w w w . j a v a 2 s . co m*/ String template = IOUtils.toString(getClass() .getResourceAsStream("/eu/crydee/alignment/aligner/ae/" + "metrics-summarizer-template.html")); String titledTemplate = template.replace("@@TITLE@@", "Metrics summarizer" + LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME)); StringBuilder sb = new StringBuilder(); sb.append("<table class=\"table table-striped ").append("table-condensed\">\n") .append(" <thead>\n").append(" <tr>\n") .append(" <th>City\\Metric</th>\n"); for (String key : keys) { sb.append(" <th>").append(methodsMetadata.get(key).getRight()).append("</th>\n"); } sb.append(" <tr>\n").append(" </thead>\n").append(" <tbody>\n"); for (String ele : results.rowKeySet()) { sb.append(" <tr>\n").append(" <td>").append(ele) .append("</td>\n"); Map<String, Samples> metricResults = results.row(ele); for (String key : keys) { Samples samples = metricResults.get(key); SummaryStatistics ss = new SummaryStatistics(); samples.samples.forEach(d -> ss.addValue(d)); double mean = ss.getMean(); boolean significant = TestUtils.tTest(samples.mu, ArrayUtils.toPrimitive(samples.samples.toArray(new Double[0])), 0.05), above = samples.mu > mean; String summary = String.format("%.3f", samples.mu) + " <small class=\"text-muted\">" + String.format("%.3f", ss.getMean()) + "" + String.format("%.3f", ss.getStandardDeviation()) + "</small>"; logger.info(ele + "\t" + key + "\t" + summary + "\t" + significant); sb.append(" <td class=\"") .append(significant ? (above ? "success" : "danger") : "warning").append("\">") .append(summary).append("</td>\n"); } sb.append(" </tr>\n"); } sb.append(" </tbody>\n").append(" </table>"); FileUtils.write(new File(htmlFilepath), titledTemplate.replace("@@TABLE@@", sb.toString()), StandardCharsets.UTF_8); } catch (IOException ex) { logger.error("IO problem with the HTML output."); throw new AnalysisEngineProcessException(ex); } }
From source file:morphy.timeseal.TimesealCoder.java
public static byte[][] splitBytes(byte[] bytes, byte splitByte) { byte[] bytesToProcess = bytes; ArrayList<Byte[]> bytesList = new ArrayList<Byte[]>(); int idx;//from ww w .j a v a2 s .c o m while ((idx = ArrayUtils.indexOf(bytesToProcess, splitByte)) != -1) { bytesList.add(ArrayUtils.toObject(Arrays.copyOfRange(bytesToProcess, 0, idx))); if (idx + 1 < bytesToProcess.length) { bytesToProcess = Arrays.copyOfRange(bytesToProcess, idx + 1, bytesToProcess.length); } } bytesList.add(ArrayUtils.toObject(bytesToProcess)); byte[][] newBytes = new byte[bytesList.size()][]; Byte[][] objBytesArray = bytesList.toArray(new Byte[bytesList.size()][0]); for (int i = 0; i < objBytesArray.length; i++) { newBytes[i] = ArrayUtils.toPrimitive(objBytesArray[i]); } return newBytes; }