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:de.thorstenberger.taskmodel.complex.complextaskhandling.subtasklets.impl.SubTasklet_MCBuilder.java
/** * Return all instances of <code>clazz</code> from the given list. * * @param correctOrIncorrect// w w w . ja va2 s .c o m * @param clazz * @return */ static int[] getIndices(List correctOrIncorrect, Class<?> clazz) { List<Integer> selected = new ArrayList<Integer>(); int idx = 0; for (Object o : correctOrIncorrect) { if (clazz.isInstance(o)) { selected.add(idx); } idx++; } return ArrayUtils.toPrimitive(selected.toArray(new Integer[selected.size()])); }
From source file:dk.dma.ais.view.rest.AisStoreResource.java
@GET @Path("/track") @Produces("application/octet-stream") public StreamingOutput pastTrack(@Context UriInfo info, @QueryParam("mmsi") List<Integer> mmsis) { Iterable<AisPacket> query = getPastTrack(info, ArrayUtils.toPrimitive(mmsis.toArray(new Integer[mmsis.size()]))); return StreamingUtil.createStreamingOutput(query, AisPacketOutputSinks.PAST_TRACK_JSON); }
From source file:com.flexive.war.beans.admin.main.UserGroupBean.java
/** * Creates a new user group./*ww w. ja v a2 s . co m*/ * * @return the next page to render */ public String create() { try { final UserTicket ticket = FxContext.getUserTicket(); long mandatorId = getMandator(); if (!ticket.isGlobalSupervisor()) { mandatorId = ticket.getMandatorId(); } this.setId(getUserGroupEngine().create(currentData.name, currentData.color, mandatorId)); this.currentData.createdGroupId = this.currentData.id; new FxFacesMsgInfo("UserGroup.nfo.created", currentData.name).addToContext(); // Assign the given roles to the group try { getUserGroupEngine().setRoles(this.currentData.id, ArrayUtils.toPrimitive(currentData.roles)); } catch (Exception exc) { new FxFacesMsgErr(exc).addToContext(); currentData.color = getUserGroupEngine().load(currentData.id).getColor(); return "userGroupEdit"; } // Deselect the group and return to the overview this.setId(-1); return "userGroupOverview"; } catch (Exception exc) { new FxFacesMsgErr(exc).addToContext(); return "userGroupNew"; } }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java
/** * * @param track/*from ww w .j a va 2 s .c om*/ */ private void plotDeltaX(Track track) { Double[] deltaXValues = ComputationUtils.transpose2DArray(track.getSteps())[0]; double[] values = ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(deltaXValues)); HistogramDataset histogramDataset = new HistogramDataset(); histogramDataset.addSeries("", values, 2); String title = "delta_x_values for track: " + track.getTrackid(); JFreeChart jFreeChart = ChartFactory.createHistogram(title, "delta_x", "count", histogramDataset, PlotOrientation.VERTICAL, true, true, true); ChartPanel chartPanel = new ChartPanel(jFreeChart); computationDataPanel.getDeltaxPlotPanel().removeAll(); computationDataPanel.getDeltaxPlotPanel().add(chartPanel, gridBagConstraints); computationDataPanel.getDeltaxPlotPanel().revalidate(); computationDataPanel.getDeltaxPlotPanel().repaint(); }
From source file:de.tudarmstadt.ukp.dkpro.core.mallet.topicmodel.MalletTopicModelInferencer.java
/** * Assign topics according to the following formula: * <p>// w w w .ja v a 2 s .c o m * Topic proportion must be at least the maximum topic's proportion divided by the maximum * number of topics to be assigned. In addition, the topic proportion must not lie under the * minTopicProb. If more topics comply with these criteria, only retain the n * (maxTopicAssignments) largest values. * * @param topicDistribution * a double array containing the document's topic proportions * @return an array of integers pointing to the topics assigned to the document */ private int[] assignTopics(final double[] topicDistribution) { /* * threshold is the largest value divided by the maximum number of topics or the fixed * number set as minTopicProb parameter. */ double threshold = Math.max( Collections.max(Arrays.asList(ArrayUtils.toObject(topicDistribution))) / maxTopicAssignments, minTopicProb); /* * assign indexes for values that are above threshold */ List<Integer> indexes = new ArrayList<>(topicDistribution.length); for (int i = 0; i < topicDistribution.length; i++) { if (topicDistribution[i] >= threshold) { indexes.add(i); } } /* * Reduce assignments to maximum number of allowed assignments. */ if (indexes.size() > maxTopicAssignments) { /* sort index list by corresponding values */ Collections.sort(indexes, new Comparator<Integer>() { @Override public int compare(Integer aO1, Integer aO2) { return Double.compare(topicDistribution[aO1], topicDistribution[aO2]); } }); while (indexes.size() > maxTopicAssignments) { indexes.remove(0); } } return ArrayUtils.toPrimitive(indexes.toArray(new Integer[indexes.size()])); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.explore.EnclosingBallController.java
public void plotXTBalls(TrackDataHolder trackDataHolder) { int selectedIndexEpsilon = exploreTrackController.getExploreTrackPanel().getEnclosingBallEpsCombobox() .getSelectedIndex();//from w w w .j av a 2 s. com List<List<EnclosingBall>> xtEnclosingBallList = trackDataHolder.getStepCentricDataHolder() .getxTEnclosingBalls(); List<EnclosingBall> xTempBalls = xtEnclosingBallList.get(selectedIndexEpsilon); // get the track coordinates matrix and transpose it Double[][] transpose2DArray = AnalysisUtils .transpose2DArray(trackDataHolder.getStepCentricDataHolder().getCoordinatesMatrix()); // we get the x coordinates and the time information double[] xCoordinates = ArrayUtils.toPrimitive(AnalysisUtils.excludeNullValues(transpose2DArray[0])); double[] timeIndexes = trackDataHolder.getStepCentricDataHolder().getTimeIndexes(); // we create the series and set its key XYSeries xtSeries = JFreeChartUtils.generateXYSeries(timeIndexes, xCoordinates); String seriesKey = "track " + trackDataHolder.getTrack().getTrackNumber() + ", well " + trackDataHolder.getTrack().getWellHasImagingType().getWell(); xtSeries.setKey(seriesKey); // we then create the XYSeriesCollection and use it to make a new line chart XYSeriesCollection xtSeriesCollection = new XYSeriesCollection(xtSeries); JFreeChart chart = ChartFactory.createXYLineChart(seriesKey + " - enclosing balls", "time", "x (m)", xtSeriesCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyPlot = chart.getXYPlot(); xyPlot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis yaxis = (NumberAxis) xyPlot.getRangeAxis(); yaxis.setAutoRangeIncludesZero(false); JFreeChartUtils.setupXYPlot(xyPlot); JFreeChartUtils.setupSingleTrackPlot(chart, exploreTrackController.getExploreTrackPanel().getTracksList().getSelectedIndex(), true); xTBallsChartPanel.setChart(chart); xTempBalls.stream().forEach((ball) -> { xyPlot.addAnnotation(new XYShapeAnnotation(ball.getShape(), JFreeChartUtils.getDashedLine(), GuiUtils.getDefaultColor())); }); }
From source file:ijfx.ui.plugin.panel.OverlayPanel.java
protected XYChart.Series<Double, Double> getOverlayHistogram(Overlay overlay) { Timer timer = timerService.getTimer(this.getClass()); timer.start();/*from w w w .j a v a 2 s. com*/ Double[] valueList = statsService.getValueList(currentDisplay(), overlay); timer.elapsed("Getting the stats"); SummaryStatistics sumup = new SummaryStatistics(); for (Double v : valueList) { sumup.addValue(v); } timer.elapsed("Building the sumup"); double min = sumup.getMin(); double max = sumup.getMax(); double range = max - min; int bins = 100;//new Double(max - min).intValue(); EmpiricalDistribution distribution = new EmpiricalDistribution(bins); double[] values = ArrayUtils.toPrimitive(valueList); Arrays.parallelSort(values); distribution.load(values); timer.elapsed("Sort and distrubution repartition up"); XYChart.Series<Double, Double> serie = new XYChart.Series<>(); ArrayList<Data<Double, Double>> data = new ArrayList<>(bins); double k = min; for (SummaryStatistics st : distribution.getBinStats()) { data.add(new Data<Double, Double>(k, new Double(st.getN()))); k += range / bins; } serie.getData().clear(); serie.getData().addAll(data); timer.elapsed("Creating charts"); return serie; }
From source file:dk.dma.ais.view.rest.AisStoreResource.java
@GET @Path("/track/raw") @Produces("application/octet-stream") public StreamingOutput pastTrackRaw(@Context UriInfo info, @QueryParam("mmsi") List<Integer> mmsis) { Iterable<AisPacket> query = getPastTrack(info, ArrayUtils.toPrimitive(mmsis.toArray(new Integer[mmsis.size()]))); return StreamingUtil.createStreamingOutput(query, AisPacketOutputSinks.OUTPUT_TO_TEXT); }
From source file:dk.dma.ais.view.rest.AisStoreResource.java
@GET @Path("/track/html") @Produces("text/html") public StreamingOutput pastTrackHtml(@Context UriInfo info, @QueryParam("mmsi") List<Integer> mmsis) { Iterable<AisPacket> query = getPastTrack(info, ArrayUtils.toPrimitive(mmsis.toArray(new Integer[mmsis.size()]))); return StreamingUtil.createStreamingOutput(query, AisPacketOutputSinks.OUTPUT_TO_HTML); }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java
/** * * @param track//ww w . j a v a2s. co m */ private void plotDeltaY(Track track) { Double[] deltaYValues = ComputationUtils.transpose2DArray(track.getSteps())[1]; double[] values = ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(deltaYValues)); HistogramDataset histogramDataset = new HistogramDataset(); histogramDataset.addSeries("", values, 2); String title = "delta_y_values for track: " + track.getTrackid(); JFreeChart jFreeChart = ChartFactory.createHistogram(title, "delta_y", "count", histogramDataset, PlotOrientation.VERTICAL, true, true, true); ChartPanel chartPanel = new ChartPanel(jFreeChart); computationDataPanel.getDeltayPlotPanel().removeAll(); computationDataPanel.getDeltayPlotPanel().add(chartPanel, gridBagConstraints); computationDataPanel.getDeltayPlotPanel().revalidate(); computationDataPanel.getDeltayPlotPanel().repaint(); }