List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:charva.awt.Component.java
/** * Return true if this component is totally obscured by one or more * windows that are stacked above it.//w ww .j av a2 s . c o m */ public boolean isTotallyObscured() { Rectangle bounds = getBounds(); Window ancestor = getAncestorWindow(); Vector windowList = Toolkit.getDefaultToolkit().getWindowList(); boolean obscured = false; synchronized (windowList) { /* Ignore windows that are stacked below this component's * ancestor. */ int i; for (i = 0; i < windowList.size(); i++) { Window w = (Window) windowList.elementAt(i); if (w == ancestor) break; } i++; /* Return true if any of the overlying windows totally obscures * this component. */ for (; i < windowList.size(); i++) { Window w = (Window) windowList.elementAt(i); Rectangle windowRect = w.getBounds(); if (bounds.equals(windowRect.intersection(bounds))) { obscured = true; break; } } } return obscured; }
From source file:org.openxdata.server.sms.FormSmsParser.java
/** * Get the skip logic error messages in a filled form. (eg pregnant males) * /* w w w.ja v a2 s .c o m*/ * @param formData the form data to validate. * @param ruleRequiredQtns a list of questions which become required after rule firing. * @return a comma separated list of validation error messages if any, else null. */ @SuppressWarnings("unchecked") private String getSkipErrorMsg(org.openxdata.model.FormData formData, Vector<QuestionData> ruleRequiredQtns) { String sErrors = null; //Check if form has any questions. Vector<PageData> pages = formData.getPages(); if (pages == null || pages.size() == 0) { sErrors = MSG_FORM_HAS_NO_QUESTIONS; return sErrors; } //Check if form has any skip rules. Vector<SkipRule> rules = formData.getDef().getSkipRules(); if (rules == null) return sErrors; //Deal with the user supplied validation rules for (int index = 0; index < rules.size(); index++) { SkipRule rule = (SkipRule) rules.elementAt(index); Vector<QuestionData> answeredQtns = getAnsweredQuestions(formData, rule.getActionTargets()); rule.fire(formData); //Get the question text of the first condition. This could be improved with a user supplied skip logic error message, in future. String qtnText = formData.getQuestion(((Condition) rule.getConditions().elementAt(0)).getQuestionId()) .getText(); boolean mandatoryRule = (rule.getAction() & OpenXdataConstants.ACTION_MAKE_MANDATORY) != 0; Vector<Byte> ids = rule.getActionTargets(); for (byte i = 0; i < ids.size(); i++) { QuestionData questionData = formData.getQuestion(Byte.parseByte(ids.elementAt(i).toString())); //Check if the user answered a question they were supposed to skip. if (!questionData.isAnswered() && answeredQtns.contains(questionData)) sErrors = addErrorMsg(sErrors, MSG_DUE_TO_ANSWER_FOR + " " + qtnText + ", " + MSG_NO_ANSWER_EXPECTED_FOR + " " + questionData.getDef().getText()); //Check is the user has not answered a question which has become required after an answer to some other question. if (mandatoryRule && questionData.getDef().isMandatory() && !questionData.isAnswered()) sErrors = addErrorMsg(sErrors, MSG_DUE_TO_ANSWER_FOR + " " + qtnText + ", " + MSG_NO_ANSWER_EXPECTED_FOR + " " + questionData.getDef().getText()); if (mandatoryRule) ruleRequiredQtns.add(questionData); } } return sErrors; }
From source file:alice.tuprolog.lib.OOLibrary.java
private static Method mostSpecificMethod(Vector<Method> methods) throws NoSuchMethodException { for (int i = 0; i != methods.size(); i++) { for (int j = 0; j != methods.size(); j++) { if ((i != j) && (moreSpecific(methods.elementAt(i), methods.elementAt(j)))) { methods.removeElementAt(j); if (i > j) i--;// ww w .j a v a 2 s.c o m j--; } } } if (methods.size() == 1) return methods.elementAt(0); else throw new NoSuchMethodException(">1 most specific method"); }
From source file:ca.uqac.info.trace.generation.PQTraceGenerator.java
@Override public EventTrace generate() { EventTrace trace = new EventTrace(); // We choose the number of messages to produce int n_messages = super.nextInt(m_maxMessages - m_minMessages) + m_minMessages; for (int i = 0; i < n_messages; i++) { Node n = trace.getNode(); Vector<String> available_params = new Vector<String>(); // We produce the list of available parameters for this message available_params.add("p"); available_params.add("q"); // We choose the number of param-value pairs to generate int arity = super.nextInt(m_maxArity - m_minArity) + m_minArity; for (int j = 0; j < arity; j++) { // We generate as many param-value pairs as required int index = super.nextInt(available_params.size()); int value = super.nextInt(m_domainSize); if (m_minArity == 1 && m_maxArity == 1 && m_flatten) { // For traces of messages with fixed arity = 1, we // simply put the value as the text child of the "Event" // element n.appendChild(trace.createTextNode(new Integer(value).toString())); } else { Node el = trace.createElement(available_params.elementAt(index)); el.appendChild(trace.createTextNode(new Integer(value).toString())); n.appendChild(el);/*from w ww .j a va 2 s . co m*/ } } Event e = new Event(n); trace.add(e); } return trace; }
From source file:keel.GraphInterKeel.datacf.visualizeData.VisualizePanelCharts2D.java
private void ViewChartjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ViewChartjButtonActionPerformed // Show comparing chart if ((this.attribute1jComboBox.getSelectedIndex() == -1) || (this.attribute2jComboBox.getSelectedIndex() == -1)) { JOptionPane.showMessageDialog(this, "There are no attributes selected", "Error", 2); } else if (((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute1jComboBox.getSelectedIndex()).equals("nominal") && ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute2jComboBox.getSelectedIndex()).equals("nominal")) { // Error message JOptionPane.showMessageDialog(this, "Only one attribute can be nominal", "Error", 2); } else if (((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute1jComboBox.getSelectedIndex()).equals("nominal")) { // Nominal in x axis --> vertical DefaultCategoryDataset dataset = new DefaultCategoryDataset(); boolean legend = false; for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { String column = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); String row = ""; if (((VisualizePanel) (this.getParent()).getParent()).getOutAttribute() != -1 && this.attribute1jComboBox .getSelectedIndex() != ((VisualizePanel) (this.getParent()).getParent()) .getOutAttribute()) { row = "Class " + ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, ((VisualizePanel) (this.getParent()).getParent()).getOutAttribute()); legend = true;/*from w w w. j a v a 2 s . c o m*/ } String valor = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); if (valor != null && column != null) { if (dataset.getColumnIndex(column) == -1 || dataset.getRowIndex(row) == -1) { dataset.addValue(Double.valueOf(valor).doubleValue(), row, column); } else { dataset.incrementValue(Double.valueOf(valor).doubleValue(), row, column); } } } this.chart2 = ChartFactory.createBarChart3D("", ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute1jComboBox.getSelectedIndex()), ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute2jComboBox.getSelectedIndex()), dataset, PlotOrientation.VERTICAL, legend, false, false); this.chart2.setTitle(this.attribute1jComboBox.getSelectedItem().toString() + " vs " + this.attribute2jComboBox.getSelectedItem().toString()); this.chart2.setBackgroundPaint(new Color(0xFFFFFF)); BufferedImage image = this.chart2.createBufferedImage(600, 450); this.imagejLabel.setIcon(new ImageIcon(image)); this.topdfjButton.setEnabled(true); this.topngjButton.setEnabled(true); } else if (((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeTypeIndex(this.attribute2jComboBox.getSelectedIndex()).equals("nominal")) { // Nominal in y axis --> horizontal DefaultCategoryDataset dataset = new DefaultCategoryDataset(); boolean legend = false; try { for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { String column = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); String row = ""; if (((VisualizePanel) (this.getParent()).getParent()).getOutAttribute() != -1 && this.attribute2jComboBox .getSelectedIndex() != ((VisualizePanel) (this.getParent()).getParent()) .getOutAttribute()) { row = "Class " + ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, ((VisualizePanel) (this.getParent()).getParent()).getOutAttribute()); legend = true; } String valor = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); if (valor != null) { if (dataset.getColumnIndex(column) == -1 || dataset.getRowIndex(row) == -1) { dataset.addValue(Double.valueOf(valor).doubleValue(), row, column); } else { dataset.incrementValue(Double.valueOf(valor).doubleValue(), row, column); } } } } catch (ArrayIndexOutOfBoundsException exp) { JOptionPane.showMessageDialog(this, "The data set contains some errors. This attribute can not be visualized", "Error", 2); } this.chart2 = ChartFactory.createBarChart3D("", ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute2jComboBox.getSelectedIndex()), ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute1jComboBox.getSelectedIndex()), dataset, PlotOrientation.HORIZONTAL, legend, false, false); this.chart2.setTitle(this.attribute1jComboBox.getSelectedItem().toString() + " vs " + this.attribute2jComboBox.getSelectedItem().toString()); this.chart2.setBackgroundPaint(new Color(0xFFFFFF)); BufferedImage image = this.chart2.createBufferedImage(579, 330); this.imagejLabel.setIcon(new ImageIcon(image)); this.topdfjButton.setEnabled(true); this.topngjButton.setEnabled(true); } else { XYSeriesCollection juegoDatos = new XYSeriesCollection(); boolean legend = false; if (((VisualizePanel) (this.getParent()).getParent()).getOutAttribute() != -1) { legend = true; Vector outputRang = ((VisualizePanel) (this.getParent()).getParent()).getData() .getRange(((VisualizePanel) (this.getParent()).getParent()).getOutAttribute()); XYSeries series[] = new XYSeries[outputRang.size()]; for (int i = 0; i < outputRang.size(); i++) { series[i] = new XYSeries("Class " + outputRang.elementAt(i)); juegoDatos.addSeries(series[i]); } for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { int clase = outputRang.indexOf(((VisualizePanel) (this.getParent()).getParent()).getData() .getDataIndex(i, ((VisualizePanel) (this.getParent()).getParent()).getOutAttribute())); String valor1 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); String valor2 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); if (valor1 != null) { series[clase].add(Double.valueOf(valor1).doubleValue(), Double.valueOf(valor2).doubleValue()); } } } else { XYSeries series = new XYSeries("Regresin"); juegoDatos.addSeries(series); for (int i = 0; i < ((VisualizePanel) (this.getParent()).getParent()).getData().getNData(); i++) { String valor1 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute1jComboBox.getSelectedIndex()); String valor2 = ((VisualizePanel) (this.getParent()).getParent()).getData().getDataIndex(i, this.attribute2jComboBox.getSelectedIndex()); if (valor1 != null) { series.add(Double.valueOf(valor1).doubleValue(), Double.valueOf(valor2).doubleValue()); } } } // Numeric values this.chart2 = ChartFactory.createScatterPlot("", ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute1jComboBox.getSelectedIndex()), ((VisualizePanel) (this.getParent()).getParent()).getData() .getAttributeIndex(this.attribute2jComboBox.getSelectedIndex()), juegoDatos, PlotOrientation.VERTICAL, legend, false, false); this.chart2.setTitle(this.attribute1jComboBox.getSelectedItem().toString() + " vs " + this.attribute2jComboBox.getSelectedItem().toString()); this.chart2.setBackgroundPaint(new Color(0xFFFFFF)); BufferedImage image = this.chart2.createBufferedImage(579, 330); this.imagejLabel.setIcon(new ImageIcon(image)); this.topdfjButton.setEnabled(true); this.topngjButton.setEnabled(true); } }
From source file:com.good.example.contributor.jhawkins.appkinetics.core.Request.java
/** Execute a service discovery query. * Call this method to execute a service discovery query. The results of the * query are stored internally in the service request object. * /* w w w . j ava 2s .c o m*/ * The query parameters are read from the service identifier and version * properties of the request object. The query is restricted to * application-based service providers. * * If there is exactly one provider, then it is selected. Otherwise, no * provider is selected. * * @return Reference to the service request object. */ public Request queryProviders() { // Execute an AppKinetics service discovery query. Vector<GDServiceProvider> provider_details = GDAndroid.getInstance().getServiceProvidersFor(getServiceID(), getServiceVersion(), GDServiceProviderType.GDSERVICEPROVIDERAPPLICATION); // Store the results in an array in the PathStore for (int i = 0; i < provider_details.size(); i++) { GDServiceProvider provideri = provider_details.elementAt(i); store.pathSet(new PathStore(new JSONObject()).pathSet(provideri.getIdentifier(), "identifier") .pathSet(provideri.getName(), "name").pathSet(provideri.getAddress(), "address") .pathSet(provideri.getVersion(), "version"), "Request", "Provider", "Query", i); } if (provider_details.size() == 1) { selectProvider(0); } return this; }
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
public SomClustTreeSelectionResult updateSideTreeSelection(int x, int y, double w, double h) { sideTreeBImg = sideTree.getImage();/*ww w .ja v a 2 s .co m*/ SomClustTreeSelectionResult result = new SomClustTreeSelectionResult(); Node n = this.getNodeAt(x, y, rowNode); if (n != null) { sideTree.painttree(n, sideTreeBImg.getGraphics(), Color.red); Stack st = new Stack(); Vector v = new Vector(); n.fillMembers(v, st); int[] sel = new int[v.size()]; for (int i = 0; i < v.size(); i++) { sel[i] = ((Integer) v.elementAt(i)); } result.setSelectedIndices(sel); } // try { // byte[] imageData = ChartUtilities.encodeAsPNG(sideTreeBImg); // String base64 = Base64.encodeBase64String(imageData); // base64 = "data:image/png;base64," + base64; SplitedImg si = this.splitImage(sideTreeBImg); result.setTreeImg1Url(si.getImg1Url()); result.setTreeImg(si); System.gc(); return result; // } catch (IOException e) { // System.err.println(e.getLocalizedMessage()); // } // return null; }
From source file:edu.ucsb.nceas.MCTestCase.java
protected String getAccessBlock(Vector<String> accessRules, String permOrder) { String accessBlock = "<access " + "authSystem=\"ldap://ldap.ecoinformatics.org:389/dc=ecoinformatics,dc=org\"" + " order=\"" + permOrder + "\"" + " scope=\"document\"" + ">"; // adding rules if (accessRules != null && !accessRules.isEmpty()) { for (int i = 0; i < accessRules.size(); i++) { String rule = (String) accessRules.elementAt(i); accessBlock += rule;//from w w w . j a va 2 s . c o m } } accessBlock += "</access>"; return accessBlock; }
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
public SomClustTreeSelectionResult updateUpperTreeSelection(int x, int y, double w, double h) { upperTreeBImg = upperTree.getImage(); Node n = this.getNodeAt(y, x, colNode); SomClustTreeSelectionResult result = new SomClustTreeSelectionResult(); if (n != null) { upperTree.painttree(n, upperTreeBImg.getGraphics(), Color.red); Stack st = new Stack(); Vector v = new Vector(); n.fillMembers(v, st);/*from w ww . j a va2 s .co m*/ int[] sel = new int[v.size()]; for (int i = 0; i < v.size(); i++) { sel[i] = ((Integer) v.elementAt(i)); } result.setSelectedIndices(sel); } try { byte[] imageData = ChartUtilities.encodeAsPNG(upperTreeBImg); String base64 = Base64.encodeBase64String(imageData); base64 = "data:image/png;base64," + base64; result.setTreeImg1Url(base64); System.gc(); // result.setTreeImgUrl(navgStringImg); return result; } catch (IOException e) { System.err.println(e.getLocalizedMessage()); } return null; }
From source file:dao.ColMessageDaoDb.java
private int getNodeLevel(String rid, Vector msgs, ColMessage colMsg) { if (RegexStrUtil.isNull(rid) || (msgs == null) || (colMsg == null)) { throw new BaseDaoException("params are null"); }/*from w w w. ja va 2 s. c om*/ //logger.info("msgs.size() = " + msgs.size()); int j = 0; Iterator iterator = msgs.iterator(); if (rid != null) { while (iterator.hasNext()) { Vector replies = (Vector) iterator.next(); if (replies == null) { //logger.info("replies is null "); continue; } for (int i = 0; i < replies.size(); i++) { if (rid.equalsIgnoreCase(((ColMessage) replies.elementAt(i)).getValue(DbConstants.RID))) { String levelStr = ((ColMessage) replies.elementAt(i)).getValue(DbConstants.LEVEL); //logger.info("level = " + levelStr + "msgs rid " + ((ColMessage)replies.elementAt(i)).getValue(DbConstants.MESSAGE_ID) ); if (levelStr != null) { Integer level = new Integer(levelStr); //logger.info("level Integer = " + level); level++; //logger.info("level Integer = " + level.toString() + " j = " + j); colMsg.setValue("level", level.toString()); } return (j + 1); } } j++; } } return -1; }