List of usage examples for java.util Vector size
public synchronized int size()
From source file:net.sf.ginp.commands.SelectCollection.java
/** * Called when a Start tag is processed. * *@param model Description of the Parameter *@param params Description of the Parameter *//*from www. j a v a 2 s. c om*/ public final void action(final GinpModel model, final Vector params) { String id = ""; for (int i = 0; i < params.size(); i++) { CommandParameter param = (CommandParameter) params.get(i); if (param.getName().equals("id")) { id = param.getValue(); } } int idNum = 0; try { idNum = (new Integer(id)).intValue(); } catch (Exception ex) { log.error(ex); idNum = 0; } if (model.setCurrectCollection(idNum)) { model.setCurrentPage(Configuration.getCollectionPageName()); model.getCollection().setPath("/"); model.setPageOffset(0); model.setPagePosition(0); } }
From source file:Ventanas.VentanaVerGrafico.java
private CategoryDataset createCategoryDataset(Vector items) { int size = items.size(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); {//from w w w . ja v a 2s .com botonVolverVerGrafica = new JButton(); this.getContentPane().add(botonVolverVerGrafica); botonVolverVerGrafica.setText("Volver"); botonVolverVerGrafica.setBounds(300, 512, 97, 30); botonVolverVerGrafica.addActionListener(this); } for (int i = 0; i < size; i++) { Vector item = (Vector) items.get(i); String series1 = "N entradas+salidas"; String series2 = "N articulos E+S"; String series3 = "Tiempo Trabajado(Minutos)"; int rowcount = item.size(); for (int cuenta = 0; cuenta < rowcount; cuenta++) { dataset.addValue(Integer.parseInt("" + item.get(1)), series1, "" + item.get(0)); dataset.addValue(Integer.parseInt("" + item.get(2)), series2, "" + item.get(0)); dataset.addValue(Integer.parseInt("" + item.get(3)), series3, "" + item.get(0)); } } return dataset; }
From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport_UK1.java
/** * * @param a_SAR_File//from www .ja v a 2 s .co m * @param a_CAS_File * @return Object[] result where; * result[0] is a String[] of variable names * result[1] is a double[number of variables][no of data items] * of a_SAR_data * result[2] is a double[number of variables][no of data items] * of a_CAS_data * @throws IOException */ protected static Object[] loadDataISARHP_ISARCEP(File a_SAR_File, File a_CAS_File) throws IOException { Object[] result = new Object[3]; TreeMap<String, double[]> a_SAROptimistaionConstraints_TreeMap = loadCASOptimistaionConstraints(a_SAR_File); TreeMap<String, double[]> a_CASOptimistaionConstraints_TreeMap = loadCASOptimistaionConstraints(a_CAS_File); Vector<String> variables = GeneticAlgorithm_ISARHP_ISARCEP.getVariableList(); variables.add(0, "Zone_Code"); String[] variableNames = new String[0]; variableNames = variables.toArray(variableNames); result[0] = variableNames; // Format (Flip) data double[][] a_SAR_Data = new double[variables.size() - 1][a_SAROptimistaionConstraints_TreeMap.size()]; double[][] a_CAS_Data = new double[variables.size() - 1][a_SAROptimistaionConstraints_TreeMap.size()]; String oa; double[] a_SARExpectedRow; double[] a_CASObservedRow; int j = 0; Iterator<String> iterator_String = a_SAROptimistaionConstraints_TreeMap.keySet().iterator(); while (iterator_String.hasNext()) { oa = iterator_String.next(); a_SARExpectedRow = a_SAROptimistaionConstraints_TreeMap.get(oa); a_CASObservedRow = a_CASOptimistaionConstraints_TreeMap.get(oa); if (a_SARExpectedRow == null) { System.out.println( "Warning a_SARExpectedRow == null in loadDataISARHP_ISARCEP(File,File) for OA " + oa); } else { if (a_CASObservedRow == null) { System.out.println( "Warning a_CASObservedRow == null in loadDataISARHP_ISARCEP(File,File) for OA " + oa); } else { for (int i = 0; i < variables.size() - 1; i++) { a_SAR_Data[i][j] = a_SARExpectedRow[i]; a_CAS_Data[i][j] = a_CASObservedRow[i]; } } } j++; } result[1] = a_SAR_Data; result[2] = a_CAS_Data; return result; }
From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport_UK1.java
protected static Object[] loadDataHSARHP_ISARCEP(File a_SARFile, File a_CASFile) throws IOException { Object[] result = new Object[3]; TreeMap<String, double[]> a_SAROptimistaionConstraints = loadCASOptimistaionConstraints(a_SARFile); TreeMap<String, double[]> a_CASOptimistaionConstraints = loadCASOptimistaionConstraints(a_CASFile); Vector<String> variables = GeneticAlgorithm_HSARHP_ISARCEP.getVariableList(); variables.add(0, "Zone_Code"); String[] variableNames = new String[0]; variableNames = variables.toArray(variableNames); result[0] = variableNames;/*from w w w.j a v a 2s .co m*/ // Format (Flip) data double[][] a_SARExpectedData = new double[variables.size() - 1][a_SAROptimistaionConstraints.size()]; double[][] a_CASObservedData = new double[variables.size() - 1][a_SAROptimistaionConstraints.size()]; String oa; double[] a_SARExpectedRow; double[] a_CASObservedRow; int j = 0; Iterator<String> iterator_String = a_SAROptimistaionConstraints.keySet().iterator(); while (iterator_String.hasNext()) { oa = iterator_String.next(); a_SARExpectedRow = a_SAROptimistaionConstraints.get(oa); a_CASObservedRow = a_CASOptimistaionConstraints.get(oa); // if (oa.equalsIgnoreCase("00AAFQ0013")){ // System.out.println(oa); // } if (a_SARExpectedRow == null) { System.out.println( "Warning a_SARExpectedRow == null in loadDataHSARHP_ISARCEP(File,File) for OA " + oa); } else { if (a_CASObservedRow == null) { System.out.println( "Warning a_SARExpectedRow == null in loadDataHSARHP_ISARCEP(File,File) for OA " + oa); } else { for (int i = 0; i < variables.size() - 1; i++) { a_SARExpectedData[i][j] = a_SARExpectedRow[i]; a_CASObservedData[i][j] = a_CASObservedRow[i]; } } } j++; } result[1] = a_SARExpectedData; result[2] = a_CASObservedData; return result; }
From source file:eionet.gdem.web.struts.hosts.ListHostsAction.java
@Override public ActionForward execute(ActionMapping map, ActionForm actionForm, HttpServletRequest request, HttpServletResponse httpServletResponse) { ActionErrors errors = new ActionErrors(); List result = new ArrayList(); try {//from w w w. j ava 2 s.co m if (checkPermission(request, Names.ACL_HOST_PATH, "v")) { Vector list = hostDao.getHosts(null); for (int i = 0; i < list.size(); i++) { Hashtable host = (Hashtable) list.get(i); HostDto h = new HostDto(); h.setId((String) host.get("host_id")); h.setHostname((String) host.get("host_name")); h.setUsername((String) host.get("user_name")); result.add(h); } } else { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.vnoperm", translate(map, request, "label.hosts"))); } } catch (Exception e) { LOGGER.error("", e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("label.exception.unknown")); } if (errors.size() > 0) { request.getSession().setAttribute("dcm.errors", errors); } request.setAttribute("hosts.list", result); return map.findForward("success"); }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.RemoveRawFileListener.java
@Override public void handleEvent(Event event) { Vector<File> files = this.selectRawFilesUI.getSelectedRemovedFile(); if (files.size() < 1) { this.selectRawFilesUI.displayMessage("No file selected"); return;/*from w ww .j a v a2 s .c o m*/ } File mapping = ((GeneExpressionData) this.dataType).getStsmf(); boolean confirm = this.selectRawFilesUI.confirm( "The column mapping file and the word mapping file will be removed consequently.\nAre you sure to remove these files?"); for (File file : files) { if (file == null) { return; } if (((GeneExpressionData) this.dataType).getRawFiles().size() == files.size()) { if (mapping != null) { if (confirm) { ((GeneExpressionData) this.dataType).setSTSMF(null); try { FileUtils.forceDelete(mapping); } catch (IOException e) { // TODO Auto-generated catch block this.selectRawFilesUI.displayMessage("File error: " + e.getLocalizedMessage()); e.printStackTrace(); } ((GeneExpressionData) this.dataType).getRawFiles().remove(file); FileUtils.deleteQuietly(file); UsedFilesPart.sendFilesChanged(dataType); } } else { if (confirm) { ((GeneExpressionData) this.dataType).getRawFiles().remove(file); FileUtils.deleteQuietly(file); UsedFilesPart.sendFilesChanged(dataType); } } } } this.selectRawFilesUI.updateViewer(); WorkPart.updateSteps(); WorkPart.updateFiles(); }
From source file:net.sf.ginp.commands.ShowPicture.java
/** * PicCollection id (colid) and path (path) should be sent in the * parameters so that the model is not out of sync with browser. * This can happen due to use of the Back Button. * * @param model Description of the Parameter * @param params Description of the Parameter *///w ww . j a v a 2 s . com public final void action(final GinpModel model, final Vector params) { String name = ""; String path = null; for (int i = 0; i < params.size(); i++) { CommandParameter param = (CommandParameter) params.get(i); if (param.getName().equals("name")) { name = param.getValue(); } else if (param.getName().equals("colid")) { try { int id = (new Integer(param.getValue())).intValue(); model.setCurrectCollection(id); } catch (Exception ex) { log.error(ex); } } else if (param.getName().equals("path")) { path = param.getValue(); } } if (path != null) { model.getCollection().setPath(path); } model.setCurrentPage(Configuration.getPicturePageName() + "?name=" + name); }
From source file:com.ss.language.model.gibblda.Document.java
public Document(Vector<Integer> doc) { this.length = doc.size(); storeDoc(doc); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.ChartAxisFactory.java
public static ValueAxis createRangeAxis(RangeAxisConfig rangeAxisConfig, PlotInstance plotInstance) throws ChartPlottimeException { if (rangeAxisConfig.getValueType() == ValueType.UNKNOWN || rangeAxisConfig.getValueType() == ValueType.INVALID) { return null; } else {/* www .j a v a 2 s. c om*/ RangeAxisData rangeAxisData = plotInstance.getPlotData().getRangeAxisData(rangeAxisConfig); double initialUpperBound = rangeAxisData.getUpperViewBound(); double initialLowerBound = rangeAxisData.getLowerViewBound(); double upperBound = initialUpperBound; double lowerBound = initialLowerBound; // fetch old zooming LinkAndBrushMaster linkAndBrushMaster = plotInstance.getMasterPlotConfiguration() .getLinkAndBrushMaster(); Range axisZoom = linkAndBrushMaster.getRangeAxisZoom(rangeAxisConfig, plotInstance.getCurrentPlotConfigurationClone()); List<ValueSource> valueSources = rangeAxisConfig.getValueSources(); if (rangeAxisConfig.hasAbsolutStackedPlot()) { for (ValueSource valueSource : valueSources) { VisualizationType seriesType = valueSource.getSeriesFormat().getSeriesType(); if (seriesType == VisualizationType.BARS || seriesType == VisualizationType.AREA) { if (valueSource.getSeriesFormat().getStackingMode() == StackingMode.ABSOLUTE) { Pair<Double, Double> minMax = calculateUpperAndLowerBounds(valueSource, plotInstance); if (upperBound < minMax.getSecond()) { upperBound = minMax.getSecond(); } if (lowerBound > minMax.getFirst()) { lowerBound = minMax.getFirst(); } } } } } double margin = upperBound - lowerBound; if (lowerBound == upperBound) { margin = lowerBound; } if (margin == 0) { margin = 0.1; } double normalPad = RangeAxisConfig.padFactor * margin; if (rangeAxisConfig.isLogarithmicAxis()) { if (!rangeAxisConfig.isUsingUserDefinedLowerViewBound()) { lowerBound -= RangeAxisConfig.logPadFactor * lowerBound; } if (!rangeAxisConfig.isUsingUserDefinedUpperViewBound()) { upperBound += RangeAxisConfig.logPadFactor * upperBound; } } else { // add margin if (!rangeAxisConfig.isUsingUserDefinedLowerViewBound()) { lowerBound -= normalPad; } if (!rangeAxisConfig.isUsingUserDefinedUpperViewBound()) { upperBound += normalPad; } } boolean includeZero = false; if (isIncludingZero(rangeAxisConfig, initialLowerBound) && !rangeAxisConfig.isUsingUserDefinedLowerViewBound()) { // if so set lower bound to zero lowerBound = 0.0; includeZero = true; } boolean upToOne = false; // if there are only relative plots set upper Bound to 1.0 if (rangeAxisConfig.mustHaveUpperBoundOne(initialUpperBound) && !rangeAxisConfig.isUsingUserDefinedUpperViewBound()) { upperBound = 1.0; upToOne = true; } if (includeZero && !upToOne) { upperBound *= 1.05; } String label = rangeAxisConfig.getLabel(); if (label == null) { label = I18N.getGUILabel("plotter.unnamed_value_label"); } ValueAxis rangeAxis; if (rangeAxisConfig.getValueType() == ValueType.NOMINAL && !valueSources.isEmpty()) { // get union of distinct values of all plotValueConfigs on range axis int maxValue = Integer.MIN_VALUE; for (ValueSource valueSource : rangeAxisData.getRangeAxisConfig().getValueSources()) { ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource); double maxValueInSource = valueSourceData.getMaxValue(); if (maxValueInSource > maxValue) { maxValue = (int) maxValueInSource; } } Vector<String> yValueStrings = new Vector<String>(maxValue); yValueStrings.setSize(maxValue + 1); ValueSourceData valueSourceData = plotInstance.getPlotData() .getValueSourceData(valueSources.get(0)); for (int i = 0; i <= maxValue; ++i) { yValueStrings.set(i, valueSourceData.getStringForValue(SeriesUsageType.MAIN_SERIES, i)); } String[] yValueStringArray = new String[yValueStrings.size()]; int i = 0; for (String s : yValueStrings) { yValueStringArray[i] = s; ++i; } CustomSymbolAxis symbolRangeAxis = new CustomSymbolAxis(null, yValueStringArray); symbolRangeAxis.setVisible(true); symbolRangeAxis.setAutoRangeIncludesZero(false); symbolRangeAxis.saveUpperBound(upperBound, initialUpperBound); symbolRangeAxis.saveLowerBound(lowerBound, initialLowerBound); symbolRangeAxis.setLabel(label); Font axesFont = plotInstance.getCurrentPlotConfigurationClone().getAxesFont(); if (axesFont != null) { symbolRangeAxis.setLabelFont(axesFont); symbolRangeAxis.setTickLabelFont(axesFont); } // set range if axis has been zoomed before if (axisZoom != null) { symbolRangeAxis.setRange(axisZoom); } rangeAxis = symbolRangeAxis; } else if (rangeAxisConfig.getValueType() == ValueType.NUMERICAL) { NumberAxis numberRangeAxis; if (rangeAxisConfig.isLogarithmicAxis()) { if (rangeAxisData.getMinYValue() <= 0) { throw new ChartPlottimeException("log_axis_contains_zero", label); } numberRangeAxis = new CustomLogarithmicAxis(null); ((CustomLogarithmicAxis) numberRangeAxis).saveUpperBound(upperBound, initialUpperBound); ((CustomLogarithmicAxis) numberRangeAxis).saveLowerBound(lowerBound, initialLowerBound); } else { numberRangeAxis = new CustomNumberAxis(); ((CustomNumberAxis) numberRangeAxis).saveUpperBound(upperBound, initialUpperBound); ((CustomNumberAxis) numberRangeAxis).saveLowerBound(lowerBound, initialLowerBound); } numberRangeAxis.setAutoRangeIncludesZero(false); numberRangeAxis.setVisible(true); numberRangeAxis.setLabel(label); Font axesFont = plotInstance.getCurrentPlotConfigurationClone().getAxesFont(); if (axesFont != null) { numberRangeAxis.setLabelFont(axesFont); numberRangeAxis.setTickLabelFont(axesFont); } // set range if axis has been zoomed before if (axisZoom != null) { numberRangeAxis.setRange(axisZoom); } rangeAxis = numberRangeAxis; } else if (rangeAxisConfig.getValueType() == ValueType.DATE_TIME) { CustomDateAxis dateRangeAxis; if (rangeAxisConfig.isLogarithmicAxis()) { throw new ChartPlottimeException("logarithmic_not_supported_for_value_type", label, ValueType.DATE_TIME); } else { dateRangeAxis = new CustomDateAxis(); } dateRangeAxis.saveUpperBound(upperBound, initialUpperBound); dateRangeAxis.saveLowerBound(lowerBound, initialLowerBound); dateRangeAxis.setVisible(true); dateRangeAxis.setLabel(label); Font axesFont = plotInstance.getCurrentPlotConfigurationClone().getAxesFont(); if (axesFont != null) { dateRangeAxis.setLabelFont(axesFont); } // set range if axis has been zoomed before if (axisZoom != null) { dateRangeAxis.setRange(axisZoom); } rangeAxis = dateRangeAxis; } else { throw new RuntimeException("Unknown value type. This should not happen"); } // configure format formatAxis(plotInstance.getCurrentPlotConfigurationClone(), rangeAxis); return rangeAxis; } }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java
/** Parses the securities Vector into the price chart */ public void setSecurities(Vector securities) { for (int i = 0; i < securities.size(); i++) { Vector secVect = (Vector) securities.get(i); String name = (String) secVect.get(0); addSecurity(name);/*from w w w.j a va2 s . co m*/ for (int j = 1; j < secVect.size(); j++) { float[] point = (float[]) secVect.get(j); addPoint(name, point[0], point[1]); } } }