List of usage examples for java.util Vector size
public synchronized int size()
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a pie graph representing test counts for each product area. * * @param suites List of test suites * @param areas List of product areas * /* www . j a v a 2s. c o m*/ * @return Pie graph representing build execution times across all builds */ public static final JFreeChart getAverageAreaTestTimeChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the average of all test types Hashtable timeAvg = new Hashtable(); DefaultPieDataset dataset = new DefaultPieDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect test data for each of the suites in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the data for the current suite CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Long elapsedTime = new Long(suite.getElapsedTime() / (1000 * 60)); CMnDbFeatureOwnerData area = null; // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData currentArea = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { Long avgValue = null; String areaName = currentArea.getDisplayName(); if (timeAvg.containsKey(areaName)) { Long oldAvg = (Long) timeAvg.get(areaName); avgValue = oldAvg + elapsedTime; } else { avgValue = elapsedTime; } timeAvg.put(areaName, avgValue); } } } // while list has elements // Populate the data set with the average values for each metric Enumeration keys = timeAvg.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Long total = (Long) timeAvg.get(key); Long avg = new Long(total.longValue() / builds.size()); dataset.setValue(key, avg); } } // if list has elements // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls) chart = ChartFactory.createPieChart("Avg Test Time by Area", dataset, true, true, false); // get a reference to the plot for further customization... PiePlot plot = (PiePlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, "min"); return chart; }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a pie graph representing test counts for each product area. * * @param suites List of test suites * @param areas List of product areas * //from w ww . j a va 2 s. c o m * @return Pie graph representing build execution times across all builds */ public static final JFreeChart getAverageAreaTestCountChart(Vector<CMnDbBuildData> builds, Vector<CMnDbTestSuite> suites, Vector<CMnDbFeatureOwnerData> areas) { JFreeChart chart = null; // Collect the average of all test types Hashtable countAvg = new Hashtable(); DefaultPieDataset dataset = new DefaultPieDataset(); if ((suites != null) && (suites.size() > 0)) { // Collect test data for each of the suites in the list Enumeration suiteList = suites.elements(); while (suiteList.hasMoreElements()) { // Process the data for the current suite CMnDbTestSuite suite = (CMnDbTestSuite) suiteList.nextElement(); Integer testCount = new Integer(suite.getTestCount()); CMnDbFeatureOwnerData area = null; // Iterate through each product area to determine who owns this suite CMnDbFeatureOwnerData currentArea = null; Iterator iter = areas.iterator(); while (iter.hasNext()) { currentArea = (CMnDbFeatureOwnerData) iter.next(); if (currentArea.hasFeature(suite.getGroupName())) { Integer avgValue = null; String areaName = currentArea.getDisplayName(); if (countAvg.containsKey(areaName)) { Integer oldAvg = (Integer) countAvg.get(areaName); avgValue = oldAvg + testCount; } else { avgValue = testCount; } countAvg.put(areaName, avgValue); } } } // while list has elements // Populate the data set with the average values for each metric Enumeration keys = countAvg.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Integer total = (Integer) countAvg.get(key); Integer avg = new Integer(total.intValue() / builds.size()); dataset.setValue(key, avg); } } // if list has elements // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls) chart = ChartFactory.createPieChart("Avg Test Count by Area", dataset, true, true, false); // get a reference to the plot for further customization... PiePlot plot = (PiePlot) chart.getPlot(); chartFormatter.formatAreaChart(plot, "tests"); return chart; }
From source file:de.mpg.mpdl.inge.transformation.Util.java
/** * Merges a Vector of Format[] into Format[]. * /*from w w w. j av a 2s. c o m*/ * @param allFormatsV as Format[] Vector * @return Format[] */ public static Format[] mergeFormats(Vector<Format[]> allFormatsV) { Vector<Format> tmpV = new Vector<Format>(); Format[] tmpA; for (int i = 0; i < allFormatsV.size(); i++) { tmpA = allFormatsV.get(i); if (tmpA != null) { for (int x = 0; x < tmpA.length; x++) { tmpV.add(tmpA[x]); // System.out.println(tmpA[x].getName()); } } } tmpV = getRidOfDuplicatesInVector(tmpV); return formatVectorToFormatArray(tmpV); }
From source file:marytts.util.io.FileUtils.java
public static void writeTextFile(Vector<String> textInRows, String textFile) { PrintWriter out = null;//from w ww .j av a 2s . c o m try { out = new PrintWriter(new FileWriter(textFile)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (out != null) { for (int i = 0; i < textInRows.size(); i++) out.println(textInRows.get(i)); out.close(); } else System.out.println("Error! Cannot create file: " + textFile); }
From source file:Main.java
public SortedComboBoxModel(Vector items) { Collections.sort(items);/*from www . jav a 2s.c o m*/ int size = items.size(); for (int i = 0; i < size; i++) { super.addElement(items.elementAt(i)); } setSelectedItem(items.elementAt(0)); }
From source file:edu.umn.cs.spatialHadoop.nasa.SpatioAggregateQueries.java
/** * Performs a spatio-temporal aggregate query on an indexed directory * @param inFile//from w w w. ja v a 2s . c o m * @param params * @throws ParseException * @throws IOException * @throws InterruptedException */ public static AggregateQuadTree.Node aggregateQuery(Path inFile, OperationsParams params) throws ParseException, IOException, InterruptedException { // 1- Find matching temporal partitions final FileSystem fs = inFile.getFileSystem(params); Vector<Path> matchingPartitions = selectTemporalPartitions(inFile, params); // 2- Find all matching files (AggregateQuadTrees) in matching partitions final Rectangle spatialRange = params.getShape("rect", new Rectangle()).getMBR(); // Convert spatialRange from lat/lng space to Sinusoidal space double cosPhiRad = Math.cos(spatialRange.y1 * Math.PI / 180); double southWest = spatialRange.x1 * cosPhiRad; double southEast = spatialRange.x2 * cosPhiRad; cosPhiRad = Math.cos(spatialRange.y2 * Math.PI / 180); double northWest = spatialRange.x1 * cosPhiRad; double northEast = spatialRange.x2 * cosPhiRad; spatialRange.x1 = Math.min(northWest, southWest); spatialRange.x2 = Math.max(northEast, southEast); // Convert to the h v space used by MODIS spatialRange.x1 = (spatialRange.x1 + 180.0) / 10.0; spatialRange.x2 = (spatialRange.x2 + 180.0) / 10.0; spatialRange.y2 = (90.0 - spatialRange.y2) / 10.0; spatialRange.y1 = (90.0 - spatialRange.y1) / 10.0; // Vertically flip because the Sinusoidal space increases to the south double tmp = spatialRange.y2; spatialRange.y2 = spatialRange.y1; spatialRange.y1 = tmp; // Find the range of cells in MODIS Sinusoidal grid overlapping the range final int h1 = (int) Math.floor(spatialRange.x1); final int h2 = (int) Math.ceil(spatialRange.x2); final int v1 = (int) Math.floor(spatialRange.y1); final int v2 = (int) Math.ceil(spatialRange.y2); PathFilter rangeFilter = new PathFilter() { @Override public boolean accept(Path p) { Matcher matcher = MODISTileID.matcher(p.getName()); if (!matcher.matches()) return false; int h = Integer.parseInt(matcher.group(1)); int v = Integer.parseInt(matcher.group(2)); return h >= h1 && h < h2 && v >= v1 && v < v2; } }; final Vector<Path> allMatchingFiles = new Vector<Path>(); for (Path matchingPartition : matchingPartitions) { // Select all matching files FileStatus[] matchingFiles = fs.listStatus(matchingPartition, rangeFilter); for (FileStatus matchingFile : matchingFiles) { allMatchingFiles.add(matchingFile.getPath()); } } //noinspection SizeReplaceableByIsEmpty if (allMatchingFiles.isEmpty()) return null; final int resolution = AggregateQuadTree.getResolution(fs, allMatchingFiles.get(0)); // 3- Query all matching files in parallel List<Node> threadsResults = Parallel.forEach(allMatchingFiles.size(), new RunnableRange<AggregateQuadTree.Node>() { @Override public Node run(int i1, int i2) { Node threadResult = new AggregateQuadTree.Node(); for (int i_file = i1; i_file < i2; i_file++) { Path matchingFile = allMatchingFiles.get(i_file); try { Matcher matcher = MODISTileID.matcher(matchingFile.getName()); matcher.matches(); // It has to match int h = Integer.parseInt(matcher.group(1)); int v = Integer.parseInt(matcher.group(2)); // Clip the query region and normalize in this tile Rectangle translated = spatialRange.translate(-h, -v); int x1 = (int) (Math.max(translated.x1, 0) * resolution); int y1 = (int) (Math.max(translated.y1, 0) * resolution); int x2 = (int) (Math.min(translated.x2, 1.0) * resolution); int y2 = (int) (Math.min(translated.y2, 1.0) * resolution); AggregateQuadTree.Node fileResult = AggregateQuadTree.aggregateQuery(fs, matchingFile, new java.awt.Rectangle(x1, y1, (x2 - x1), (y2 - y1))); threadResult.accumulate(fileResult); } catch (Exception e) { throw new RuntimeException("Error reading file " + matchingFile, e); } } return threadResult; } }); AggregateQuadTree.Node finalResult = new AggregateQuadTree.Node(); for (Node threadResult : threadsResults) { finalResult.accumulate(threadResult); } numOfTreesTouchesInLastRequest = allMatchingFiles.size(); return finalResult; }
From source file:com.almarsoft.GroundhogReader.lib.DBUtils.java
public static void updateHeaderRecordAttachments(int headerId, Vector<HashMap<String, String>> attachsVector, Context context) {// w w w . j a v a 2 s.c o m if (attachsVector == null || attachsVector.size() == 0) return; StringBuffer strbu = new StringBuffer(); HashMap<String, String> attachData = null; int len = attachsVector.size(); for (int i = 0; i < len; i++) { attachData = attachsVector.get(i); strbu.append(attachData.get("md5")); if (i != len - 1) strbu.append(";"); } DBHelper db = new DBHelper(context); SQLiteDatabase dbwriter = db.getWritableDatabase(); String q = "UPDATE headers SET has_attachments=1, attachments_fnames=" + esc(strbu.toString()) + " WHERE _id=" + headerId; dbwriter.execSQL(q); dbwriter.close(); db.close(); }
From source file:com.modeln.build.ctrl.charts.CMnBuildListChart.java
/** * Generate a pie graph representing average build execution times across * all builds in the list. /* www . j av a 2 s . c o m*/ * * @param builds List of builds * * @return Pie graph representing build execution times across all builds */ public static final JFreeChart getAverageMetricChart(Vector<CMnDbBuildData> builds) { JFreeChart chart = null; // Get a list of all possible build metrics int[] metricTypes = CMnDbMetricData.getAllTypes(); Hashtable metricAvg = new Hashtable(metricTypes.length); DefaultPieDataset dataset = new DefaultPieDataset(); if ((builds != null) && (builds.size() > 0)) { // Collect build metrics for each of the builds in the list Enumeration buildList = builds.elements(); while (buildList.hasMoreElements()) { // Process the build metrics for the current build CMnDbBuildData build = (CMnDbBuildData) buildList.nextElement(); Vector metrics = build.getMetrics(); if ((metrics != null) && (metrics.size() > 0)) { // Collect data for each of the build metrics in the current build Enumeration metricList = metrics.elements(); while (metricList.hasMoreElements()) { CMnDbMetricData currentMetric = (CMnDbMetricData) metricList.nextElement(); // Get elapsed time in "minutes" Long elapsedTime = new Long(currentMetric.getElapsedTime() / (1000 * 60)); String metricName = CMnDbMetricData.getMetricType(currentMetric.getType()); Long avgValue = null; if (metricAvg.containsKey(metricName)) { Long oldAvg = (Long) metricAvg.get(metricName); avgValue = oldAvg + elapsedTime; } else { avgValue = elapsedTime; } metricAvg.put(metricName, avgValue); } // while build has metrics } // if has metrics } // while list has elements // Populate the data set with the average values for each metric Enumeration keys = metricAvg.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Long total = (Long) metricAvg.get(key); Long avg = new Long(total.longValue() / (long) builds.size()); //dataset.setValue(key, (Long) metricAvg.get(key)); dataset.setValue(key, avg); } } // if list has elements // API: ChartFactory.createPieChart(title, data, legend, tooltips, urls) chart = ChartFactory.createPieChart("Average Build Metrics", dataset, true, true, false); // get a reference to the plot for further customization... PiePlot plot = (PiePlot) chart.getPlot(); chartFormatter.formatMetricChart(plot, "min"); return chart; }
From source file:com.celements.web.plugin.cmd.FormObjStorageCommand.java
public BaseObject newObject(XWikiDocument storageDoc, String className, XWikiContext context) { Vector<BaseObject> objects = storageDoc.getObjects(className); if ((objects != null) && (objects.size() > _MAX_OBJ_ON_DOC)) { mLogger.warn("PERFORMANCE WARNING! There are more than " + _MAX_OBJ_ON_DOC + " objects of the class [" + className + "] on storageDoc [" + storageDoc.getFullName() + "]."); }//w ww . j a va2s. c o m try { return storageDoc.newObject(className, context); } catch (XWikiException exp) { mLogger.error("Failed to create new object [" + className + "] on document [" + storageDoc.getFullName() + "].", exp); } return null; }
From source file:info.novatec.testit.livingdoc.util.CollectionUtilTest.java
@Test @SuppressWarnings("unchecked") public void testCanConvertArraysToVectors() { Vector<? extends Object> vec = CollectionUtil.toVector("1", null, new Date()); assertEquals(3, vec.size()); assertTrue(vec.get(0) instanceof String); assertTrue(vec.get(1) == null);/*w ww .ja va 2s . c o m*/ assertTrue(vec.get(2) instanceof Date); }