List of usage examples for java.util Vector Vector
public Vector()
From source file:techtonic.PlotLogGraphListener.java
@Override public void actionPerformed(ActionEvent e) { List<WitsmlLogCurve> curves = log.getCurves(); Vector<String> curveDescription = new Vector<>(); for (WitsmlLogCurve c : curves) { // System.out.println(c.getDescription()); curveDescription.add(c.getDescription()); }/*w w w. j a v a 2 s . c o m*/ Techtonic.setjcbX_Axis(curveDescription); Techtonic.setEnablejcbX_Axis(true); Techtonic.setEnablejcbY_Axis(false); Techtonic.setEnableRenderBtn(true); Techtonic.setPropertyBtn(true); //Techtonic.setjcbX_Axis(); Vector<String> v = new Vector<String>(Arrays.asList(new String[] { "Depth" })); Techtonic.setjcbY_Axis(v); //plot the graph using values of the second entry WitsmlLogCurve ydata = curves.get(0); WitsmlLogCurve xdata = curves.get(1); List<Object> yvalues = ydata.getValues(); List<Object> xvalues = xdata.getValues(); String title = "Depth against " + xdata.getDescription(); XYSeries series = new XYSeries(title); for (int i = 0; i < yvalues.size(); i++) { Object vx = xvalues.get(i); Object vy = yvalues.get(i); double dx = Double.parseDouble(vx.toString()); double dy = Double.parseDouble(vy.toString()); series.add(dx, dy); } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(series); // create a chart using the createYLineChart method... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xdata.getDescription(), "Depth", // x and y axis labels data); // data ChartPanel cp = new ChartPanel(chart); // JFrame fr = new JFrame(); // fr.add(cp); // fr.pack(); // fr.setVisible(true); //cp.setMouseZoomable(true, true); Techtonic.setFreeChart(chart); Techtonic.setCurrentCurves(curves); Techtonic.setDisplayArea(cp); // chartPanel.setLayout(new java.awt.BorderLayout()); // chartPanel.add(cp,BorderLayout.CENTER); // chartPanel.validate(); // chartPanel.repaint(); }
From source file:com.cladonia.xngreditor.ErrorList.java
public Vector getCurrentErrors() { Vector result = new Vector(); for (int i = 0; i < errors.size(); i++) { String systemId = ((XMLError) errors.elementAt(i)).getSystemId(); if (systemId != null) { String name = document.getName(); if (systemId.endsWith(name)) { result.add(errors.elementAt(i)); }//from w w w . j a va 2s. c o m } else { result.add(errors.elementAt(i)); } } return result; }
From source file:org.openmrs.module.patientaccesscontrol.web.controller.RoleProgramListController.java
@RequestMapping(method = RequestMethod.GET) public String programList(ModelMap model) { List<Program> programList = new Vector<Program>(); // only fill the Object if the user has authenticated properly if (Context.isAuthenticated()) { Program defaultProgram = new Program(); defaultProgram.setName("Default"); defaultProgram.setDescription("Default access control for patients not in any program"); programList.add(defaultProgram); programList.addAll(Context.getProgramWorkflowService().getAllPrograms()); }/* w w w. java 2s .c o m*/ model.addAttribute("programList", programList); return "module/" + Constants.MODULE_ID + "/roleProgramList"; }
From source file:de.betterform.connector.http.ssl.BetterFORMTrustManager.java
private void initBetterFORMKeyStoreManager() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { this.customX509TrustManagers = new Vector<TrustManager[]>(); this.javaDefaultTrustManagers = getJavaDefaultTrustManagers(); }
From source file:mzmatch.ipeak.align.CowCoda.java
@SuppressWarnings("unchecked") public static void main(String args[]) { final String lbl_mcq = "mcq"; try {/*w ww .j a v a 2s . c o m*/ Tool.init(); // parse the commandline options final Options options = new Options(); CmdLineParser cmdline = new CmdLineParser(options); // check whether we need to show the help cmdline.parse(args); if (options.help) { Tool.printHeader(System.out, application, version); cmdline.printUsage(System.out, ""); return; } if (options.verbose) { Tool.printHeader(System.out, application, version); cmdline.printOptions(); } // check the command-line parameters int filetype = JFreeChartTools.PDF; { if (options.ppm == -1) { System.err.println("[ERROR]: the ppm-value needs to be set."); System.exit(0); } if (options.order == -1) { System.err.println("[ERROR]: the order for the polynomial fit needs to be set."); System.exit(0); } if (options.maxrt == -1) { System.err.println("[ERROR]: the maximum retention time shift is not set."); System.exit(0); } if (options.image != null) { String extension = options.image.substring(options.image.lastIndexOf('.') + 1); if (extension.toLowerCase().equals("png")) filetype = JFreeChartTools.PNG; else if (extension.toLowerCase().equals("pdf")) filetype = JFreeChartTools.PDF; else { System.err.println( "[ERROR]: file extension of the image file needs to be either PDF or PNG."); System.exit(0); } } // if the output directories do not exist, create them if (options.output != null) Tool.createFilePath(options.output, true); if (options.image != null) Tool.createFilePath(options.image, true); if (options.selection != null) Tool.createFilePath(options.selection, true); } // load the data if (options.verbose) System.out.println("Loading the data"); double maxrt = 0; Vector<ParseResult> data = new Vector<ParseResult>(); Vector<IPeakSet<IPeak>> matchdata = new Vector<IPeakSet<IPeak>>(); for (String file : options.input) { System.out.println("- " + new File(file).getName()); // load the mass chromatogram data ParseResult result = PeakMLParser.parse(new FileInputStream(file), true); data.add(result); // select the best mass chromatograms Vector<IPeak> selection = new Vector<IPeak>(); for (IPeak peak : (IPeakSet<IPeak>) result.measurement) { maxrt = Math.max(maxrt, maxRT(peak)); double mcq = codaDW(peak); peak.addAnnotation(lbl_mcq, Double.toString(mcq), Annotation.ValueType.DOUBLE); if (mcq >= options.codadw) selection.add(peak); } // keep track of the selected mass chromatograms int id = options.input.indexOf(file); IPeakSet<IPeak> peakset = new IPeakSet<IPeak>(selection); peakset.setMeasurementID(id); for (IPeak mc : peakset) mc.setMeasurementID(id); matchdata.add(peakset); } // match the selection together if (options.verbose) System.out.println("Matching the data"); Vector<IPeakSet<IPeak>> matches = IPeak.match((Vector) matchdata, options.ppm, new IPeak.MatchCompare<IPeak>() { public double distance(IPeak peak1, IPeak peak2) { double diff = Math.abs(peak1.getRetentionTime() - peak2.getRetentionTime()); if (diff > options.maxrt) return -1; Signal signal1 = new Signal(peak1.getSignal()); signal1.normalize(); Signal signal2 = new Signal(peak2.getSignal()); signal2.normalize(); double offset = bestOffSet(peak1, peak2, options.maxrt); for (int i = 0; i < signal2.getSize(); ++i) signal2.getX()[i] += offset; double correlation = signal2 .pearsonsCorrelation(signal1)[Statistical.PEARSON_CORRELATION]; if (correlation < 0.5) return -1; // the match-function optimizes toward 0 (it's a distance) return 1 - correlation; } }); // filter out all incomplete sets Vector<IPeakSet<IPeak>> valids = new Vector<IPeakSet<IPeak>>(); for (IPeakSet<IPeak> set : matches) { if (set.size() < options.input.size()) continue; valids.add((IPeakSet) set); } // calculate the alignment factors if (options.verbose) System.out.println("Calculating the alignment factors"); double medians[] = new double[valids.size() + 2]; DataFrame.Double dataframe = new DataFrame.Double(valids.size() + 2, options.input.size()); medians[0] = 0; medians[medians.length - 1] = maxrt; for (int i = 0; i < options.input.size(); ++i) { dataframe.set(0, i, 0.1); dataframe.set(dataframe.getNrRows() - 1, i, 0); } for (int matchid = 0; matchid < valids.size(); ++matchid) { IPeakSet<IPeak> match = valids.get(matchid); // find the most central double offsets[][] = new double[match.size()][match.size()]; for (int i = 0; i < match.size(); ++i) for (int j = i + 1; j < match.size(); ++j) { offsets[i][j] = bestOffSet(match.get(i), match.get(j), options.maxrt); offsets[j][i] = -offsets[i][j]; } int besti = 0; double bestabssum = Double.MAX_VALUE; for (int i = 0; i < match.size(); ++i) { double abssum = 0; for (int j = 0; j < match.size(); ++j) abssum += Math.abs(offsets[i][j]); if (abssum < bestabssum) { besti = i; bestabssum = abssum; } } for (int i = 0; i < match.size(); ++i) dataframe.set(matchid + 1, match.get(i).getMeasurementID(), (i == besti ? 0 : offsets[i][besti])); medians[matchid + 1] = match.get(besti).getRetentionTime(); dataframe.setRowName(matchid, Double.toString(match.get(besti).getRetentionTime())); } double minmedian = Statistical.min(medians); double maxmedian = Statistical.max(medians); // calculate for each profile the correction function PolynomialFunction functions[] = new PolynomialFunction[valids.size()]; for (int i = 0; i < options.input.size(); ++i) functions[i] = PolynomialFunction.fit(options.order, medians, dataframe.getCol(i)); // make a nice plot out of the whole thing if (options.verbose) System.out.println("Writing results"); if (options.image != null) { org.jfree.data.xy.XYSeriesCollection dataset = new org.jfree.data.xy.XYSeriesCollection(); JFreeChart linechart = ChartFactory.createXYLineChart(null, "Retention Time (seconds)", "offset", dataset, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); // setup the colorkey Colormap colormap = new Colormap(Colormap.EXCEL); // get the structure behind the graph XYPlot plot = (XYPlot) linechart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // setup the plot area linechart.setBackgroundPaint(java.awt.Color.WHITE); linechart.setBorderVisible(false); linechart.setAntiAlias(true); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); // create the datasets for (int i = 0; i < options.input.size(); ++i) { org.jfree.data.xy.XYSeries series = new org.jfree.data.xy.XYSeries(dataframe.getColName(i)); org.jfree.data.xy.XYSeries function = new org.jfree.data.xy.XYSeries( dataframe.getColName(i) + "-function"); dataset.addSeries(series); dataset.addSeries(function); renderer.setSeriesPaint(dataset.getSeriesCount() - 1, new java.awt.Color(colormap.getColor(i))); renderer.setSeriesPaint(dataset.getSeriesCount() - 2, new java.awt.Color(colormap.getColor(i))); renderer.setSeriesLinesVisible(dataset.getSeriesCount() - 2, false); renderer.setSeriesShapesVisible(dataset.getSeriesCount() - 2, true); // add the data-points for (int j = 0; j < valids.size(); ++j) series.add(medians[j], dataframe.get(j, i)); for (double x = minmedian; x < maxmedian; ++x) function.add(x, functions[i].getY(x)); } dataset.removeAllSeries(); for (int i = 0; i < options.input.size(); ++i) { Function function = functions[i]; org.jfree.data.xy.XYSeries series = new org.jfree.data.xy.XYSeries(dataframe.getColName(i)); dataset.addSeries(series); renderer.setSeriesPaint(i, new java.awt.Color(colormap.getColor(i))); renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); // add the data-points for (int j = 0; j < valids.size(); ++j) series.add(medians[j], dataframe.get(j, i) - function.getY(medians[j])); } JFreeChartTools.writeAs(filetype, new FileOutputStream(options.image), linechart, 800, 500); } // save the selected if (options.selection != null) { Header header = new Header(); // set the number of peaks to be stored header.setNrPeaks(valids.size()); // create a set for the measurements SetInfo set = new SetInfo("", SetInfo.SET); header.addSetInfo(set); // create the measurement infos for (int i = 0; i < options.input.size(); ++i) { String file = options.input.get(i); // create the measurement info MeasurementInfo measurement = new MeasurementInfo(i, data.get(i).header.getMeasurementInfo(0)); measurement.addFileInfo(new FileInfo(file, file)); header.addMeasurementInfo(measurement); // add the file to the set set.addChild(new SetInfo(file, SetInfo.SET, i)); } // write the data PeakMLWriter.write(header, (Vector) valids, null, new GZIPOutputStream(new FileOutputStream(options.selection)), null); } // correct the values with the found function and save them for (int i = 0; i < options.input.size(); ++i) { Function function = functions[i]; ParseResult result = data.get(i); IPeakSet<MassChromatogram<Peak>> peakset = (IPeakSet<MassChromatogram<Peak>>) result.measurement; for (IPeak peak : peakset) align(peak, function); File filename = new File(options.input.get(i)); String name = filename.getName(); PeakMLWriter.write(result.header, (Vector) peakset.getPeaks(), null, new GZIPOutputStream(new FileOutputStream(options.output + "/" + name)), null); } } catch (Exception e) { Tool.unexpectedError(e, application); } }
From source file:com.ripariandata.timberwolf.conf4j.ConfigFileParserTest.java
License:asdf
private Configuration mockConfiguration(final Object... settings) { if ((settings.length % 2) != 0) { return null; }/*from w w w .j a v a 2s . c om*/ Configuration config = mock(Configuration.class); Vector<String> keys = new Vector<String>(); for (int i = 0; i < settings.length; i += 2) { String key = settings[i].toString(); keys.add(key); when(config.getProperty(key)).thenReturn(settings[i + 1]); } when(config.getKeys()).thenReturn(keys.iterator()); return config; }
From source file:controller.PackageManagerController.java
private void initData(ModelMap mm) { Vector data = new Vector(); Vector column = new Vector(); List<Packages> list = packageModel.getAll(); column.add("ID"); column.add("Name"); column.add("Content"); column.add("Price"); column.add("Status"); column.add("Type"); for (Packages pack : list) { Vector tmp = new Vector(); tmp.add(pack.getPackageId());/*from w w w . j av a2 s . c o m*/ tmp.add(pack.getPackageName()); tmp.add(pack.getPackageContent()); tmp.add(MyUtils.getCurrencyFormat().format(pack.getPackagePrice())); tmp.add(pack.getStatus() == 1 ? "Active" : "Non-Active"); tmp.add(pack.getType()); tmp.add("id://" + pack.getPackageId()); data.add(tmp); } mm.put("column", column); mm.put("data", data); }
From source file:controller.OrderManagerController.java
private void initData(ModelMap mm) { Vector data = new Vector(); Vector column = new Vector(); List<Order> list = orderModel.getAll(); column.add("Order ID"); column.add("Payment Date"); column.add("Expired Date"); column.add("Status"); for (Order od : list) { Vector tmp = new Vector(); tmp.add(od.getOderId());/*from ww w . j a v a 2 s .c o m*/ tmp.add(od.getOrderPaymentDate()); tmp.add(od.getOrderExpiredDate()); tmp.add(od.getStatus() == 1 ? "Processed" : "Pending"); tmp.add("id://" + od.getOderId()); data.add(tmp); } mm.put("column", column); mm.put("data", data); }
From source file:net.i2cat.netconf.messageQueue.MessageQueue.java
public MessageQueue() { listeners = new Vector<MessageQueueListener>(); queue = new LinkedHashMap<String, RPCElement>(); }
From source file:XMLReader.java
/** Creates a new instance of JavaXmlReader */ public XMLReader(String name, JFrame parent) { this.parent = parent; // parse XML file -> XML document will be build Document doc = parseFile(name); headers = new Vector<ArrayList<ArrayList<String>>>(); fromMappings = new Vector<Vector<String>>(); toMappings = new Vector<Vector<String>>(); worksheetNames = new Vector<String>(); if (doc != null) { // get root node of xml tree structure Node root = doc.getDocumentElement(); // write node and its child nodes into System.out System.out.println("Statement of XML document..."); writeDocumentToOutput(root, 0);/*from w w w . j av a 2 s . c o m*/ System.out.println("... end of statement"); parseHeader(root); parseWorksheetName(root); parseMappings(root); } }