Java Code Examples for java.util.Vector.get()

The following are Jave code examples for showing how to use get() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: QN-ACTR-Release   File: ParametricAnalysisChecker.java   View Source Code Vote up 7 votes
/**
 * This method has a meaning only if used inside a service times parametric analysis.
 * It can be used to get the keys of classes avaible to perform that kind of parametric
 * analysis.
 * @param stationKey the key of the station whose service times will be varied.
 * @return a Vector containing the keys of avaible classes
 */
public Vector<Object> checkForServiceTimesParametricSimulationAvaibleClasses(Object stationKey) {
	Vector<Object> valid = new Vector<Object>(0, 1);
	Vector classes = cd.getClassKeys();
	for (int j = 0; j < classes.size(); j++) {
		Object thisClass = classes.get(j);
		Object temp = sd.getServiceTimeDistribution(stationKey, thisClass);
		if (temp instanceof Distribution) {
			Distribution distr = (Distribution) temp;
			if (distr.hasMean()) {
				valid.add(thisClass);
			}
		}
	}
	return valid;
}
 
Example 2
Project: geomapapp   File: LayerTree.java   View Source Code Vote up 7 votes
void addLayers(Vector layers, LayerEntry parent) {
	String name = (String)ParseLink.getProperty( layers, "name");
	if( name==null ) name = "untitled_"+(++n_null);
	String description = (String)ParseLink.getProperty( layers, "description");
	if( description==null )description="";
	String url = (String)ParseLink.getProperty( layers, "url");
	Vector children = (url==null)
			? new Vector()
			: null;
	LayerEntry entry = new LayerEntry( parent, children, name, description, url);
	parent.getChildren().add( entry );
	Vector props = ParseLink.getProperties( layers, "layer");
	for( int k=0 ; k<props.size() ; k++) {
		Vector prop = (Vector)props.get(k);
		addLayers( prop, entry);
	}
}
 
Example 3
Project: AgentWorkbench   File: TableModelDataVector.java   View Source Code Vote up 7 votes
@Override
public synchronized boolean addAll(int index, Collection<? extends Vector<Number>> collection) {

	boolean fullSuccess = true;
	int newIndexPos = index;
	for (Vector<Number> rowVector : collection) {
		Number key = rowVector.get(this.getKeyColumnIndex());
		if (this.getKeyRowVectorTreeMap().get(key)==null) {
			this.getKeyRowVectorTreeMap().put(key, rowVector);
			super.add(newIndexPos, rowVector);
			newIndexPos++;
			
		}  else {
			System.err.println(this.typeDescription + ": Duplicate key value " + key + " - row data was not added!");
			fullSuccess = false;
		}
	}
	
	this.resetRowNumberAndReminderMaps();
	return fullSuccess;
}
 
Example 4
Project: geomapapp   File: DSDPDataSet.java   View Source Code Vote up 7 votes
public static String[] parseRow( String line, String token ) {
	StringTokenizer st = new StringTokenizer(line,token, true);
	String s;
	Vector fields = new Vector();
	while( st.hasMoreTokens() ) {
		s = st.nextToken();
		if( s.equals(token) ) {
			fields.add("");
			continue;
		}
		s = s.trim();
		if( s.startsWith("\"")&&s.endsWith("\"") ) {
			if( s.length()<=2) s="";
			else s = s.substring(1, s.length()-1);
		} else if( s.startsWith("-99") || s.equals("-") ) {
			s = "";
		}
		fields.add(s);
		if( st.hasMoreTokens() )st.nextToken();
	}
	String[] vals = new String[fields.size()];
	for( int k=0 ; k<vals.length ; k++) vals[k]=(String)fields.get(k);
	return vals;
}
 
Example 5
Project: jmt   File: EngineConvex2D.java   View Source Code Vote up 7 votes
/**
 * This function return a vector that contains the same point of the parameter one but
 * the points are ordered from the point with the biggest X to the point with the smallest X
 * @param v The vector to order
 * @return The vector ordered
 */
private Vector<Point2D> orderByX(Vector<Point2D> v) {
	Vector<Point2D> r = (Vector<Point2D>) v.clone();
	boolean again = true;

	while (again) {
		again = false;
		for (int k = 0; k < r.size() - 1; k++) {
			//Take the points
			Point2D p1 = r.get(k);
			Point2D p2 = r.get(k + 1);

			if (p1.getX() < p2.getX()) {
				//swap
				r.remove(k);
				r.insertElementAt(p2, k);
				r.remove(k + 1);
				r.insertElementAt(p1, k + 1);
				again = true;
			}
		}
	}
	return r;
}
 
Example 6
Project: ramus   File: MovingArea.java   View Source Code Vote up 7 votes
/**
 * Медод ініцалізує масив з панелями для перетягування.
 */

public void setPanels() {
    movingFunctions.clear();
    final Vector fs = dataPlugin.getChilds(activeFunction, true);
    final Vector<MovingText> v = new Vector<MovingText>();
    for (int i = 0; i < fs.size(); i++)
        v.add(addIDEF0Object((Function) fs.get(i)));
    for (int i = 0; i < refactor.getTextCount(); i++)
        v.add(refactor.getText(i));
    for (int i = 0; i < refactor.getSectorsCount(); i++) {
        final PaintSector sector = refactor.getSector(i);
        if (sector.getText() != null)
            v.add(sector.getText());
    }
    panels = new MovingText[v.size()];
    for (int i = 0; i < panels.length; i++)
        panels[i] = v.get(i);
}
 
Example 7
Project: Wilmersdorf_SER316   File: NoteListImpl.java   View Source Code Vote up 7 votes
/**
    * @see net.sf.memoranda.NoteList#getMarkedNotes()
    */
   public Collection getMarkedNotes() {
       Vector v = new Vector();
       Elements yrs = _root.getChildElements("year");
       for (int yi = 0; yi < yrs.size(); yi++) {
           Year y = new Year(yrs.get(yi));
           Vector ms = y.getMonths();
           for (int mi = 0; mi < ms.size(); mi++) {
               Month m = (Month) ms.get(mi);
               Vector ds = m.getDays();
               for (int di = 0; di < ds.size(); di++) {
                   Day d = (Day) ds.get(di);
				Vector ns = d.getNotes();
				for(int ni = 0; ni < ns.size(); ni++) {
					NoteElement ne = (NoteElement) ns.get(ni);
					Note n = new NoteImpl(ne.getElement(), _project);
					if (n.isMarked()) v.add(n);
               }
           }
       }
   }
        return v;
}
 
Example 8
Project: DAA_Converter   File: FastAQ_Reader_Parallel.java   View Source Code Vote up 7 votes
private static byte[] packSequence(String dna) {

		Vector<Byte> packed = new Vector<Byte>();
		byte p = 0;
		for (int i = 0; i < dna.length(); i++) {
			char c = dna.charAt(i);
			byte b = 0;
			b |= nucToIndex.get(c) << (i * 2) % 8;
			p |= b;
			if (i == dna.length() - 1 || (((i + 1) * 2) % 8 == 0 && i != 0)) {
				packed.add(p);
				p = 0;
			}
		}

		byte[] a = new byte[packed.size()];
		for (int i = 0; i < packed.size(); i++)
			a[i] = packed.get(i);

		return a;

	}
 
Example 9
Project: Dahlem_SER316   File: NoteListImpl.java   View Source Code Vote up 6 votes
/**
 * returns combined tags of all notes
 * 
 * @return Set of tags
 */
public TreeSet<String> getAllTags() {
	_tagsSet.clear();
	Vector v = (Vector) getAllNotes();
	for (int i = 0; i < v.size(); i++) {
		Note n = (Note) v.get(i);
		_tagsSet.addAll(n.getTagSet());
	}
	return _tagsSet;
}
 
Example 10
Project: AgentWorkbench   File: TableModel.java   View Source Code Vote up 6 votes
/**
 * Gets the value with the specified key / x value from the series with the specified index
 * @param seriesIndex The index of the series to get the value from
 * @param key The key / x value of the desired value
 * @return The value for the given key / x value
 * @throws NoSuchSeriesException Will be thrown if there is no series with the specified index
 */
public Float getValueByKey(int seriesIndex, Number key) throws NoSuchSeriesException{
	if(seriesIndex < this.getColumnCount()-this.tableModelDataVector.getNoOfPrefixColumns()){
		Vector<Number> rowVector = this.tableModelDataVector.getKeyRowVectorTreeMap().get(key);
		return (Float) rowVector.get(seriesIndex + this.tableModelDataVector.getNoOfPrefixColumns());
	}else{
		throw new NoSuchSeriesException();
	}
}
 
Example 11
Project: MARF-for-Android   File: AudioSystem.java   View Source Code Vote up 6 votes
/**
 * Obtains information about all target lines of a particular type that are supported
 * by the installed mixers.
 *
 * @param info a <code>Line.Info</code> object that specifies the kind of
 *             lines about which information is requested
 * @return an array of <code>Line.Info</code> objects describing target lines matching
 * the type requested.  If no matching target lines are supported, an array of length 0
 * is returned.
 * @see Mixer#getTargetLineInfo(Line.Info)
 */
public static Line.Info[] getTargetLineInfo(Line.Info info) {

    Vector vector = new Vector();
    Line.Info[] currentInfoArray;

    Mixer mixer;
    Line.Info fullInfo = null;
    Mixer.Info[] infoArray = getMixerInfo();

    for (int i = 0; i < infoArray.length; i++) {

        mixer = getMixer(infoArray[i]);

        currentInfoArray = mixer.getTargetLineInfo(info);
        for (int j = 0; j < currentInfoArray.length; j++) {
            vector.addElement(currentInfoArray[j]);
        }
    }

    Line.Info[] returnedArray = new Line.Info[vector.size()];

    for (int i = 0; i < returnedArray.length; i++) {
        returnedArray[i] = (Line.Info) vector.get(i);
    }

    return returnedArray;
}
 
Example 12
Project: spellchecker_ta   File: Analyser.java   View Source Code Vote up 6 votes
public static String getRoot(Vector v)
{
	for(int i=0; i<v.size(); i++)
	{
		Element elmt = (Element) v.get(i);
		Vector partV = elmt.getPart();
		String tag = null;

		if(partV.size() > 0)
		{
			return (String)partV.get(0);
		}
	}
	return null;
}
 
Example 13
Project: SER316-Munich   File: NoteListImpl.java   View Source Code Vote up 6 votes
public Collection getNotesForPeriod(CalendarDate startDate, CalendarDate endDate) {
    Vector v = new Vector();
    Elements yrs = _root.getChildElements("year");
    for (int yi = 0; yi < yrs.size(); yi++) {
        Year y = new Year(yrs.get(yi));
        if ((y.getValue() >= startDate.getYear()) && (y.getValue() <= endDate.getYear())) {
            Vector months = y.getMonths();
            for (int mi = 0; mi < months.size(); mi++) {
                Month m = (Month) months.get(mi);
                if (!((y.getValue() == startDate.getYear()) && (m.getValue() < startDate.getMonth()))
                    || !((y.getValue() == endDate.getYear()) && (m.getValue() > endDate.getMonth()))) {
                    Vector days = m.getDays();
                    for (int di = 0; di < days.size(); di++) {
                        Day d = (Day) days.get(di);
                        if (!((m.getValue() == startDate.getMonth()) && (d.getValue() < startDate.getDay()))
			|| !((m.getValue() == endDate.getMonth()) && (d.getValue() > endDate.getDay()))) {
				Vector ns = d.getNotes();
				for(int ni = 0; ni < ns.size(); ni++) {
					NoteElement n = (NoteElement) ns.get(ni);
					v.add(new NoteImpl(n.getElement(), _project));
				}
			}
                    }
                }
            }
        }
    }
    return v;
}
 
Example 14
Project: geomapapp   File: TableDB.java   View Source Code Vote up 6 votes
protected void resolveLonLat() {
	String s;
	lonCol=-1;
	latCol=-1;
	for( int k=0 ; k<headings.size() ; k++) {
		String tag="";
		try {
			tag = (String)headings.get(k);
		} catch(Exception e) {
			continue;
		}
		if( latCol==-1 && tag.toLowerCase().startsWith("lat") )latCol=k;
		if( lonCol==-1 && tag.toLowerCase().startsWith("lon") )lonCol=k;
	}
//	System.out.println( "lat,lon\t"+ latCol +"\t"+ lonCol);
	for( int k=0 ; k<rows.size() ; k++) {
		Vector row = (Vector)rows.get(k);
		for( int i=0 ; i<row.size() ; i++) {
			if( i==latCol || i==lonCol ) {
				s = (String)row.get(i);
				if( s!=null ) {
					double lat = ParseLatLon.parse( s );
					row.setElementAt( new Double(lat), i);
				}
			}
		}
	}
}
 
Example 15
Project: QN-ACTR-Release   File: ParameterOptionPanel.java   View Source Code Vote up 6 votes
public Object getStationKey(String name) {
	Object key = null;
	Vector stations = sd.getStationKeys();
	for (int i = 0; i < stations.size(); i++) {
		if (sd.getStationName(stations.get(i)).equals(name)) {
			key = stations.get(i);
		}
	}
	return key;
}
 
Example 16
Project: jmt   File: ClassSwitchSectionPanel.java   View Source Code Vote up 6 votes
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
	Vector<Object> classes = classData.getClassKeys();
	Object rowClassKey = classes.get(rowIndex);
	Object columnClassKey = classes.get(columnIndex);
	int rowClassType = classData.getClassType(rowClassKey);
	int columnClassType = classData.getClassType(columnClassKey);
	return rowClassType == columnClassType;
}
 
Example 17
Project: geomapapp   File: GTable.java   View Source Code Vote up 6 votes
public Point2D getPoint(int rowIndex) {
	Vector row = (Vector)allRows.get(rowIndex);
	if( row.get(latCol)==null || row.get(lonCol)==null)return null;
	Point2D.Double p = new Point2D.Double( 
		((Double)row.get(lonCol)).doubleValue(),
		((Double)row.get(latCol)).doubleValue() );
	return p;
}
 
Example 18
Project: Reinickendorf_SER316   File: NoteListImpl.java   View Source Code Vote up 6 votes
public Collection getNotesForPeriod(CalendarDate startDate, CalendarDate endDate) {
    Vector v = new Vector();
    Elements yrs = _root.getChildElements("year");
    for (int yi = 0; yi < yrs.size(); yi++) {
        Year y = new Year(yrs.get(yi));
        if ((y.getValue() >= startDate.getYear()) && (y.getValue() <= endDate.getYear())) {
            Vector months = y.getMonths();
            for (int mi = 0; mi < months.size(); mi++) {
                Month m = (Month) months.get(mi);
                if (!((y.getValue() == startDate.getYear()) && (m.getValue() < startDate.getMonth()))
                    || !((y.getValue() == endDate.getYear()) && (m.getValue() > endDate.getMonth()))) {
                    Vector days = m.getDays();
                    for (int di = 0; di < days.size(); di++) {
                        Day d = (Day) days.get(di);
                        if (!((m.getValue() == startDate.getMonth()) && (d.getValue() < startDate.getDay()))
			|| !((m.getValue() == endDate.getMonth()) && (d.getValue() > endDate.getDay()))) {
				Vector ns = d.getNotes();
				for(int ni = 0; ni < ns.size(); ni++) {
					NoteElement n = (NoteElement) ns.get(ni);
					v.add(new NoteImpl(n.getElement(), _project));
				}
			}
                    }
                }
            }
        }
    }
    return v;
}
 
Example 19
Project: ChronoBike   File: CEntityResourceField.java   View Source Code Vote up 6 votes
public CDataEntity GetArrayReference(Vector v, CBaseEntityFactory factory) 
{
	CEntityArrayReference e = factory.NewEntityArrayReference(getLine()) ;
	e.SetReference(this) ;
	for (int i=0; i<v.size(); i++)
	{
		CExpression expr = (CExpression)v.get(i);
		CBaseEntityExpression exp = expr.AnalyseExpression(factory);
		e.AddIndex(exp);
	}
	return e ;
}
 
Example 20
Project: AgentWorkbench   File: TimeSeriesTableModel.java   View Source Code Vote up 5 votes
@Override
public void addEmptyRow(JTable jTable){
	
	// --- Get current position in the table model ----
	Vector<Number> rowSelected = null;
	Vector<Number> newRow = null;
	long currKey = 0L;
	long newKey = 0L;
	float newValue = 0f;
	
	// --- Get the current or the last row ------------
	int modelLineSelected = 0;
	int modelLineSelectedNew = 0;
	int tableRowSelected = 0;
	int tableRowSelectedNew = 0;
		
	tableRowSelected = jTable.getSelectedRow();
	if (tableRowSelected==-1 || tableRowSelected>=jTable.getRowCount()) {
		tableRowSelected = jTable.getRowCount()-1;
	}
	
	if (tableModelDataVector.size()==0) {
		// --- Create new data series -------
		DataSeries newSeries = parentDataModel.createNewDataSeries(parentDataModel.getDefaultSeriesLabel());
		
		ValuePair initialValuePair = parentDataModel.createNewValuePair(0L, newValue);
		parentDataModel.getValuePairsFromSeries(newSeries).add(initialValuePair);
		parentDataModel.addSeries(newSeries);
		
	} else {
		// --- Get current selection --------
		modelLineSelected = jTable.convertRowIndexToModel(tableRowSelected);
		rowSelected = tableModelDataVector.get(modelLineSelected);
		currKey = (Long) rowSelected.get(tableModelDataVector.getKeyColumnIndex());
		
		// --- Find a new key value ---------
		newKey = currKey + 1L;
		while (tableModelDataVector.getKeyRowVectorTreeMap().get(newKey)!=null) {
			newKey = newKey + 1L;
		}
		
		// --- Find new index position ------
		modelLineSelectedNew = tableModelDataVector.size();
		for (int i=0; i < tableModelDataVector.size(); i++) {
			Vector<Number> row = tableModelDataVector.get(i);
			long key = (Long) row.get(0);
			if (key>newKey) {
				modelLineSelectedNew = i;
				break;
			}
		}
		
		// --- Add new row data -------------
		newRow = new Vector<Number>();
		newRow.add(newKey);
		for(int i=1; i<getColumnCount(); i++){
			newRow.add(newValue);
			try {
				this.getChartModel().addOrUpdateValuePair(i-1, newKey, newValue);
				this.getOntologyModel().addOrUpdateValuePair(i-1, newKey, newValue);
				
			} catch (NoSuchSeriesException e) {
				e.printStackTrace();
			}
		}
		// --- Add new row to table model ---
		tableModelDataVector.add(modelLineSelectedNew, newRow);
		
	}
	fireTableRowsInserted(0, getRowCount()-1);
	
	// --- Set new selection ----------------
	tableRowSelectedNew = jTable.convertRowIndexToView(modelLineSelectedNew);
	if(tableRowSelectedNew >= 0){
		jTable.setRowSelectionInterval(tableRowSelectedNew, tableRowSelectedNew);
		jTable.changeSelection(tableRowSelectedNew, 0, false, false);
	}
}