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

The following examples show how to use java.util.Vector#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TBXMakerDialog.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 设置列属性 ;
 */
private void setColumnType() {
	if (cols < 2) {
		MessageDialog.openInformation(getShell(), Messages.getString("dialog.TBXMakerDialog.msgTitle"),
				Messages.getString("dialog.TBXMakerDialog.msg2"));
		return;
	}
	Vector<ColProperties> colTypes = new Vector<ColProperties>(cols);
	for (int i = 0; i < cols; i++) {
		colTypes.add((ColProperties) table.getColumn(i).getData());
	}

	ColumnTypeDialog selector = new ColumnTypeDialog(getShell(), colTypes, template, imagePath);
	if (selector.open() == IDialogConstants.OK_ID) {
		for (int i = 0; i < cols; i++) {
			TableColumn col = table.getColumn(i);
			ColProperties type = colTypes.get(i);
			if (!type.getColName().equals("") && !type.getLanguage().equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
				col.setText(type.getColName());
			}
		}
	}
}
 
Example 2
Source File: MTCNN.java    From Android-MobileFaceNet-MTCNN-FaceAntiSpoofing with MIT License 6 votes vote down vote up
/**
 * Refine Net
 * @param bitmap
 * @param boxes
 * @return
 */
private Vector<Box> rNet(Bitmap bitmap, Vector<Box> boxes) {
    // RNet Input Init
    int num = boxes.size();
    float[][][][] rNetIn = new float[num][24][24][3];
    for (int i = 0; i < num; i++) {
        float[][][] curCrop = MyUtil.cropAndResize(bitmap, boxes.get(i), 24);
        curCrop = MyUtil.transposeImage(curCrop);
        rNetIn[i] = curCrop;
    }

    // Run RNet
    rNetForward(rNetIn, boxes);

    // RNetThreshold
    for (int i = 0; i < num; i++) {
        if (boxes.get(i).score < rNetThreshold) {
            boxes.get(i).deleted = true;
        }
    }

    // Nms
    nms(boxes, 0.7f, "Union");
    BoundingBoxReggression(boxes);
    return updateBoxes(boxes);
}
 
Example 3
Source File: SecurityPolicyModelHelper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Vector targetExists(Vector<Vector> rows, TargetElement e) {
    for (Vector row : rows) {
        TargetElement te = (TargetElement) row.get(TargetElement.DATA);
        if (te.equals(e)) {
            return row;
        }
    }
    return null;
}
 
Example 4
Source File: MoodleRestGroup.java    From MoodleRest with GNU General Public License v2.0 5 votes vote down vote up
public MoodleGroup[] __getGroupsById(String url, String token, Long[] groupids) throws MoodleRestGroupException, UnsupportedEncodingException, MoodleRestException {
    Vector v=new Vector();
    MoodleGroup group;
    StringBuilder data=new StringBuilder();
    String functionCall=MoodleCallRestWebService.isLegacy()?MoodleServices.MOODLE_GROUP_GET_GROUPS.toString():MoodleServices.CORE_GROUP_GET_GROUPS.toString();
    data.append(URLEncoder.encode("wstoken", MoodleServices.ENCODING.toString())).append("=").append(URLEncoder.encode(token, MoodleServices.ENCODING.toString()));
    data.append("&").append(URLEncoder.encode("wsfunction", MoodleServices.ENCODING.toString())).append("=").append(URLEncoder.encode(functionCall, MoodleServices.ENCODING.toString()));
    for (int i=0;i<groupids.length;i++) {
        if (groupids[i]<1) throw new MoodleRestGroupException(); data.append("&").append(URLEncoder.encode("groupids["+i+"]", MoodleServices.ENCODING.toString())).append("=").append(groupids[i]);
    }
    data.trimToSize();
    NodeList elements=(new MoodleCallRestWebService()).__call(url,data.toString());
    group=null;
    for (int j=0;j<elements.getLength();j++) {
        String content=elements.item(j).getTextContent();
        String nodeName=elements.item(j).getParentNode().getAttributes().getNamedItem("name").getNodeValue();
        if (nodeName.equals("id")) {
            if (group==null)
                group=new MoodleGroup(Long.parseLong(content));
            else {
                v.add(group);
                group=new MoodleGroup(Long.parseLong(content));
            }
        }
        if (group==null)
          throw new MoodleRestGroupException();
        group.setMoodleGroupField(nodeName, content);
    }
    if (group!=null)
        v.add(group);
    MoodleGroup[] groups=new MoodleGroup[v.size()];
    for (int i=0;i<v.size();i++) {
        groups[i]=(MoodleGroup)v.get(i);
    }
    v.removeAllElements();
    return groups;
}
 
Example 5
Source File: Rtf2Xliff.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Split tagged.
 * @param text
 *            the text
 * @return the string[]
 */
private String[] splitTagged(String text) {
	Vector<String> strings = new Vector<String>();

	int index = find(text, "\uE008" + "0&gt;", 1); //$NON-NLS-1$ //$NON-NLS-2$
	while (index != -1) {
		String candidate = text.substring(0, index);
		int ends = find(candidate, "&lt;0" + "\uE007", 0); //$NON-NLS-1$ //$NON-NLS-2$
		while (ends != -1) {
			if (!candidate.substring(0, ends + 6).endsWith("0" + "\uE007")) { //$NON-NLS-1$ //$NON-NLS-2$
				ends += candidate.substring(ends).indexOf("0" + "\uE007") + 2; //$NON-NLS-1$ //$NON-NLS-2$
				strings.add(candidate.substring(0, ends));
				candidate = candidate.substring(ends);
			} else {
				strings.add(candidate.substring(0, ends + 6));
				candidate = candidate.substring(ends + 6);
			}
			ends = find(candidate, "&lt;0" + "\uE007", 1); //$NON-NLS-1$ //$NON-NLS-2$
		}
		strings.add(candidate);
		text = text.substring(index);
		index = find(text, "\uE008" + "0&gt;", 1); //$NON-NLS-1$ //$NON-NLS-2$
	}
	if (!text.endsWith("0" + "\uE007")) { //$NON-NLS-1$ //$NON-NLS-2$
		index = text.lastIndexOf("0" + "\uE007"); //$NON-NLS-1$ //$NON-NLS-2$
		if (index != -1) {
			strings.add(text.substring(0, index + 2));
			text = text.substring(index + 2);
		}
	}
	strings.add(text);

	String[] result = new String[strings.size()];
	for (int i = 0; i < strings.size(); i++) {
		result[i] = strings.get(i);
	}
	return result;
}
 
Example 6
Source File: ViewTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void queryView(boolean gfxdclient) {
  Vector<String> queryVec = ViewPrms.getQueryViewsStatements();
  String viewQuery = queryVec.get(random.nextInt(queryVec.size()));
  Connection dConn = getDiscConnection();
  Connection gConn = getGFEConnection(); 
  //provided for thin client driver as long as isEdge is set
  //use this especially after product default has been changed to read committed
  queryResultSets(dConn, gConn, viewQuery, false);
  closeDiscConnection(dConn); 
  closeGFEConnection(gConn);
}
 
Example 7
Source File: OpenntfNABNamePickerData.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the address books for the current Session
 * 
 * @param session
 *            Session
 * @return NABDb[] Array of address books
 * @throws NotesException
 */
private static NABDb[] getSessionAddressBooks(final Session session) throws NotesException {
	if (session != null) {// Unit tests
		ArrayList<NABDb> nabs = new ArrayList<NABDb>();
		Vector<?> vc = session.getAddressBooks();
		if (vc != null) {
			for (int i = 0; i < vc.size(); i++) {
				Database db = (Database) vc.get(i);
				try {
					db.open();
					try {
						NABDb nab = new NABDb(db);
						nabs.add(nab);
					} finally {
						db.recycle();
					}
				} catch (NotesException ex) {
					// Opening the database can fail if the user doesn't sufficient
					// rights. In this vase, we simply ignore this NAB and continue
					// with the next one.
				}
			}
		}
		return nabs.toArray(new NABDb[nabs.size()]);
	}
	return null;
}
 
Example 8
Source File: VarcharForBitDataPartitionTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private String vectorToString(Vector<byte[]> v) {
  StringBuffer aStr = new StringBuffer();
  aStr.append("The size of list is " + v.size() + "\n");
  for (int i = 0; i < v.size(); i++) {
    byte[] aStruct = v.get(i);
    for (int j = 0; j < aStruct.length; j++) {
      aStr.append(aStruct[j]);
    }
    aStr.append("\n");
  }
  return aStr.toString();
}
 
Example 9
Source File: PreTranslation.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private boolean isDuplicated(Vector<Hashtable<String, String>> vector, Hashtable<String, String> tu) {
	int size = vector.size();
	String src = tu.get("srcText"); //$NON-NLS-1$
	String tgt = tu.get("tgtText"); //$NON-NLS-1$
	for (int i = 0; i < size; i++) {
		Hashtable<String, String> table = vector.get(i);
		if (src.trim().equals(table.get("srcText").trim()) //$NON-NLS-1$
				&& tgt.trim().equals(table.get("tgtText").trim())) { //$NON-NLS-1$
			return true;
		}
	}
	return false;
}
 
Example 10
Source File: MTCNN.java    From Android-MobileFaceNet-MTCNN-FaceAntiSpoofing with MIT License 5 votes vote down vote up
/**
 * ONet跑神经网络,将score和bias写入boxes
 * @param oNetIn
 * @param boxes
 */
private void oNetForward(float[][][][] oNetIn, Vector<Box> boxes) {
    int num = oNetIn.length;
    float[][] prob1 = new float[num][2];
    float[][] conv6_2_conv6_2 = new float[num][4];
    float[][] conv6_3_conv6_3 = new float[num][10];

    Map<Integer, Object> outputs = new HashMap<>();
    outputs.put(oInterpreter.getOutputIndex("onet/prob1"), prob1);
    outputs.put(oInterpreter.getOutputIndex("onet/conv6-2/conv6-2"), conv6_2_conv6_2);
    outputs.put(oInterpreter.getOutputIndex("onet/conv6-3/conv6-3"), conv6_3_conv6_3);
    oInterpreter.runForMultipleInputsOutputs(new Object[]{oNetIn}, outputs);

    // 转换
    for (int i = 0; i < num; i++) {
        // prob
        boxes.get(i).score = prob1[i][1];
        // bias
        for (int j = 0; j < 4; j++) {
            boxes.get(i).bbr[j] = conv6_2_conv6_2[i][j];
        }
        // landmark
        for (int j = 0; j < 5; j++) {
            int x = Math.round(boxes.get(i).left() + (conv6_3_conv6_3[i][j] * boxes.get(i).width()));
            int y = Math.round(boxes.get(i).top() + (conv6_3_conv6_3[i][j + 5] * boxes.get(i).height()));
            boxes.get(i).landmark[j] = new Point(x, y);
        }
    }
}
 
Example 11
Source File: AudioSystem.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains the encodings that the system can obtain from an
 * audio input stream with the specified format using the set
 * of installed format converters.
 * @param sourceFormat the audio format for which conversion
 * is queried
 * @return array of encodings. If <code>sourceFormat</code>is not supported,
 * an array of length 0 is returned. Otherwise, the array will have a length
 * of at least 1, representing the encoding of <code>sourceFormat</code> (no conversion).
 */
public static AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat) {


    List codecs = getFormatConversionProviders();
    Vector encodings = new Vector();

    int size = 0;
    int index = 0;
    AudioFormat.Encoding encs[] = null;

    // gather from all the codecs

    for(int i=0; i<codecs.size(); i++ ) {
        encs = ((FormatConversionProvider) codecs.get(i)).getTargetEncodings(sourceFormat);
        size += encs.length;
        encodings.addElement( encs );
    }

    // now build a new array

    AudioFormat.Encoding encs2[] = new AudioFormat.Encoding[size];
    for(int i=0; i<encodings.size(); i++ ) {
        encs = (AudioFormat.Encoding [])(encodings.get(i));
        for(int j=0; j<encs.length; j++ ) {
            encs2[index++] = encs[j];
        }
    }
    return encs2;
}
 
Example 12
Source File: DominoViewPickerData.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
protected Object readLabel(ViewEntry ve, Vector<Object> columnValues) throws NotesException {
    int idx = getMetaData().labelIndex;
    return idx>=0 ? columnValues.get(idx) : null;
}
 
Example 13
Source File: PEHeader.java    From davmail with GNU General Public License v2.0 4 votes vote down vote up
public void updateVAAndSize(Vector oldsections, Vector newsections) {
  long codebase = findNewVA(this.BaseOfCode, oldsections, newsections);
  long codesize = findNewSize(this.BaseOfCode, oldsections, newsections);
  // System.out.println("New BaseOfCode=" + codebase + " (size=" + codesize + ")");
  this.BaseOfCode = codebase;
  this.SizeOfCode = codesize;

  this.AddressOfEntryPoint = findNewVA(this.AddressOfEntryPoint, oldsections, newsections);

  long database = findNewVA(this.BaseOfData, oldsections, newsections);
  long datasize = findNewSize(this.BaseOfData, oldsections, newsections);
  // System.out.println("New BaseOfData=" + database + " (size=" + datasize + ")");
  this.BaseOfData = database;

  long imagesize = 0;
  for (int i = 0; i < newsections.size(); i++) {
    PESection sect = (PESection)newsections.get(i);
    long curmax = sect.VirtualAddress + sect.VirtualSize;
          if (curmax > imagesize)
              imagesize = curmax;
  }
  this.SizeOfImage = imagesize;

  // this.SizeOfInitializedData = datasize;

  ExportDirectory_Size = findNewSize(ExportDirectory_VA, oldsections, newsections);
  ExportDirectory_VA = findNewVA(ExportDirectory_VA, oldsections, newsections);
  ImportDirectory_Size = findNewSize(ImportDirectory_VA, oldsections, newsections);
  ImportDirectory_VA = findNewVA(ImportDirectory_VA, oldsections, newsections);
  ResourceDirectory_Size = findNewSize(ResourceDirectory_VA, oldsections, newsections);
  ResourceDirectory_VA = findNewVA(ResourceDirectory_VA, oldsections, newsections);
  ExceptionDirectory_Size = findNewSize(ExceptionDirectory_VA, oldsections, newsections);
  ExceptionDirectory_VA = findNewVA(ExceptionDirectory_VA, oldsections, newsections);
  SecurityDirectory_Size = findNewSize(SecurityDirectory_VA, oldsections, newsections);
  SecurityDirectory_VA = findNewVA(SecurityDirectory_VA, oldsections, newsections);
  BaseRelocationTable_Size = findNewSize(BaseRelocationTable_VA, oldsections, newsections);
  BaseRelocationTable_VA = findNewVA(BaseRelocationTable_VA, oldsections, newsections);
  DebugDirectory_Size = findNewSize(DebugDirectory_VA, oldsections, newsections);
  DebugDirectory_VA = findNewVA(DebugDirectory_VA, oldsections, newsections);
  ArchitectureSpecificData_Size = findNewSize(ArchitectureSpecificData_VA, oldsections, newsections);
  ArchitectureSpecificData_VA = findNewVA(ArchitectureSpecificData_VA, oldsections, newsections);
  RVAofGP_Size = findNewSize(RVAofGP_VA, oldsections, newsections);
  RVAofGP_VA = findNewVA(RVAofGP_VA, oldsections, newsections);
  TLSDirectory_Size = findNewSize(TLSDirectory_VA, oldsections, newsections);
  TLSDirectory_VA = findNewVA(TLSDirectory_VA, oldsections, newsections);
  LoadConfigurationDirectory_Size = findNewSize(LoadConfigurationDirectory_VA, oldsections, newsections);
  LoadConfigurationDirectory_VA = findNewVA(LoadConfigurationDirectory_VA, oldsections, newsections);
  BoundImportDirectoryinheaders_Size = findNewSize(BoundImportDirectoryinheaders_VA, oldsections, newsections);
  BoundImportDirectoryinheaders_VA = findNewVA(BoundImportDirectoryinheaders_VA, oldsections, newsections);
  ImportAddressTable_Size = findNewSize(ImportAddressTable_VA, oldsections, newsections);
  ImportAddressTable_VA = findNewVA(ImportAddressTable_VA, oldsections, newsections);
  DelayLoadImportDescriptors_Size = findNewSize(DelayLoadImportDescriptors_VA, oldsections, newsections);
  DelayLoadImportDescriptors_VA = findNewVA(DelayLoadImportDescriptors_VA, oldsections, newsections);
  COMRuntimedescriptor_Size = findNewSize(COMRuntimedescriptor_VA, oldsections, newsections);
  COMRuntimedescriptor_VA = findNewVA(COMRuntimedescriptor_VA, oldsections, newsections);
}
 
Example 14
Source File: FreeRoomsProvider.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
/**
 * Given a list of rooms, find the ones that are free for a given range.
 * 
 * @param session
 * @param candidates
 * @param start
 * @param end
 * @return
 * @throws NotesException
 */
private List<Room> findFreeRooms(Session session, List<Room> candidates, Date start, Date end) throws NotesException {

    List<Room> rooms = new ArrayList<Room>();
    DateRange range = null;
    Vector freetimes = null;
    
    try {
    
        DateTime dtStart = session.createDateTime(start);
        DateTime dtEnd = session.createDateTime(end);
        
        range = session.createDateRange();
        range.setStartDateTime(dtStart);
        range.setEndDateTime(dtEnd);
        
        Iterator<Room> iterator = candidates.iterator();
        while ( iterator.hasNext() ) {
            
            if ( freetimes != null ) {
                BackendUtil.safeRecycle(freetimes);
                freetimes = null;
            }
            
            Room room = iterator.next();
            String item = room.getEmailAddress();
            if ( StringUtil.isEmpty(item) ) {
                item = room.getDistinguishedName();
            }
            Vector<String> names = new Vector<String>(1);
            names.addElement(item);
            
            // Get the free time for this room
            
            Logger.get().getLogger().fine("Searching free time for " + item); // $NON-NLS-1$
            
            try {
                freetimes = session.freeTimeSearch(range, 5, names, false);
            }
            catch (Throwable e) {
                Logger.get().warn(e, "Exception thrown searching free time for {0}", item); // $NLW-FreeRoomsProvider.Exceptionthrownsearchingfreetimef-1$
            }
            
            if ( freetimes == null ) {
                continue;
            }
            
            // Compare the start and end times of the first free block
            
            DateRange freeRange = (DateRange)freetimes.get(0);
            Date freeStart = freeRange.getStartDateTime().toJavaDate();
            Date freeEnd = freeRange.getEndDateTime().toJavaDate();
            
            if ( start.getTime() != freeStart.getTime() || 
                 end.getTime() != freeEnd.getTime() ) {
                continue;
            }
            
            // It's completely free.  Add it to the list.
            
            rooms.add(room);
        }
    }
    finally {
        BackendUtil.safeRecycle(range);
        BackendUtil.safeRecycle(freetimes);
    }
    
    return rooms;
}
 
Example 15
Source File: CBNGramFeature.java    From THULAC-Java with MIT License 4 votes vote down vote up
public int putValues(String sequence, int len) {
	if (len >= this.maxLength) {
		System.err.println("Length larger than maxLength.");
		return 1;
	}

	Vector<Integer> result = this.findBases(this.datSize, SENTENCE_BOUNDARY,
			SENTENCE_BOUNDARY);
	this.uniBases[0] = result.get(0);
	this.biBases[0] = result.get(1);

	result = this.findBases(this.datSize, SENTENCE_BOUNDARY, sequence.charAt(0));
	this.uniBases[0] = result.get(0);
	this.biBases[1] = result.get(1);
	for (int i = 0; i + 1 < len; i++) {
		result = this.findBases(this.datSize, sequence.charAt(i),
				sequence.charAt(i + 1));
		this.uniBases[i + 1] = result.get(0);
		this.biBases[i + 2] = result.get(1);
	}

	result = this.findBases(this.datSize, (int) sequence.charAt(len - 1),
			SENTENCE_BOUNDARY);
	this.uniBases[len] = result.get(0);
	this.biBases[len + 1] = result.get(1);

	result = this.findBases(this.datSize, SENTENCE_BOUNDARY, SENTENCE_BOUNDARY);
	this.uniBases[len + 1] = result.get(0);
	this.biBases[len + 2] = result.get(1);

	int base;
	for (int i = 0; i < len; i++) {
		int valueOffset = i * this.model.l_size;
		if ((base = this.uniBases[i + 1]) != -1) {
			this.addValues(valueOffset, base, 49);
		}
		if ((base = this.uniBases[i]) != -1) {
			this.addValues(valueOffset, base, 50);
		}
		if ((base = this.uniBases[i + 2]) != -1) {
			this.addValues(valueOffset, base, 51);
		}
		if ((base = this.biBases[i + 1]) != -1) {
			this.addValues(valueOffset, base, 49);
		}
		if ((base = this.biBases[i + 2]) != -1) {
			this.addValues(valueOffset, base, 50);
		}
		if ((base = this.biBases[i]) != -1) {
			this.addValues(valueOffset, base, 51);
		}
		if ((base = this.biBases[i + 3]) != -1) {
			this.addValues(valueOffset, base, 52);
		}
	}
	return 0;
}
 
Example 16
Source File: EdgeReorderer.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
private Vector<Edge> reorderEdges(Vector<Edge> origEdges, Class criterion)
{
	int i = 0;
	int n = origEdges.size();
	Edge edge;
	// we're going to reorder the edges in order of traversal
	Vector<Boolean> done = new Vector<Boolean>();
	int nDone = 0;

	for(i = 0; i < n; i++)
	{
		done.add(false);
	}

	Vector<Edge> newEdges = new Vector<Edge>();
	i = 0;
	edge = origEdges.get(i);
	newEdges.add(edge);
	_edgeOrientations.add(LR.LEFT);
	ICoord firstPoint = (criterion == Vertex.class) ? edge._leftVertex : edge.getLeftSite();
	ICoord lastPoint = (criterion == Vertex.class) ? edge._rightVertex : edge.getRightSite();

	if (firstPoint == Vertex.VERTEX_AT_INFINITY || lastPoint == Vertex.VERTEX_AT_INFINITY)
	{
		return new Vector<Edge>();
	}

	done.set(i, true);
	++nDone;

	int loops = 0;
	while (nDone < n)
	{
		loops++;
		for (i = 1; i < n; ++i)
		{
			if (done.get(i))
			{
				continue;
			}
			edge = origEdges.get(i);
			
			ICoord leftPoint = (criterion == Vertex.class) ? edge._leftVertex : edge.getLeftSite();
			ICoord rightPoint = (criterion == Vertex.class) ? edge._rightVertex : edge.getRightSite();
			
			if (leftPoint == Vertex.VERTEX_AT_INFINITY || rightPoint == Vertex.VERTEX_AT_INFINITY)
			{
				return new Vector<Edge>();
			}
			
			if (leftPoint == lastPoint)
			{
				lastPoint = rightPoint;
				_edgeOrientations.add(LR.LEFT);
				newEdges.add(edge);
				done.set(i, true);
			}
			else if (rightPoint == firstPoint)
			{
				firstPoint = leftPoint;
				DelaunayUtil.unshiftArray(_edgeOrientations, LR.LEFT);
				DelaunayUtil.unshiftArray(newEdges, edge);
				done.set(i, true);
			}
			else if (leftPoint == firstPoint)
			{
				firstPoint = rightPoint;
				DelaunayUtil.unshiftArray(_edgeOrientations, LR.RIGHT);
				DelaunayUtil.unshiftArray(newEdges, edge);
				done.set(i, true);
			}
			else if (rightPoint == lastPoint)
			{
				lastPoint = leftPoint;
				_edgeOrientations.add(LR.RIGHT);
				newEdges.add(edge);
				done.set(i, true);
			}
			if (done.get(i))
			{
				++nDone;
			}
		}
		
		if (loops > n)
		{
			break;
		}
	}

	return newEdges;
}
 
Example 17
Source File: BundleRevisionsImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
BundleRevisionsImpl(Vector<BundleGeneration> generations) {
  super(generations.get(0).bundle);
  this.generations = generations;
}
 
Example 18
Source File: DwgFile.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Configure the geometry of the polylines in a DWG file from the vertex list in
 * this DWG file. This geometry is given by an array of Points
 * Besides, manage closed polylines and polylines with bulges in a GIS Data model.
 * It means that the arcs of the polylines will be done through a curvature
 * parameter called bulge associated with the points of the polyline.
 */
public void calculateCadModelDwgPolylines() {
    for( int i = 0; i < dwgObjects.size(); i++ ) {
        DwgObject pol = (DwgObject) dwgObjects.get(i);
        if (pol instanceof DwgPolyline2D) {
            int flags = ((DwgPolyline2D) pol).getFlags();
            int firstHandle = ((DwgPolyline2D) pol).getFirstVertexHandle();
            int lastHandle = ((DwgPolyline2D) pol).getLastVertexHandle();
            Vector pts = new Vector();
            Vector bulges = new Vector();
            double[] pt = new double[3];
            for( int j = 0; j < dwgObjects.size(); j++ ) {
                DwgObject firstVertex = (DwgObject) dwgObjects.get(j);
                if (firstVertex instanceof DwgVertex2D) {
                    int vertexHandle = firstVertex.getHandle();
                    if (vertexHandle == firstHandle) {
                        int k = 0;
                        while( true ) {
                            DwgObject vertex = (DwgObject) dwgObjects.get(j + k);
                            int vHandle = vertex.getHandle();
                            if (vertex instanceof DwgVertex2D) {
                                pt = ((DwgVertex2D) vertex).getPoint();
                                pts.add(new Point2D.Double(pt[0], pt[1]));
                                double bulge = ((DwgVertex2D) vertex).getBulge();
                                bulges.add(new Double(bulge));
                                k++;
                                if (vHandle == lastHandle && vertex instanceof DwgVertex2D) {
                                    break;
                                }
                            } else if (vertex instanceof DwgSeqend) {
                                break;
                            }
                        }
                    }
                }
            }
            if (pts.size() > 0) {
                /*Point2D[] newPts = new Point2D[pts.size()];
                 if ((flags & 0x1)==0x1) {
                 newPts = new Point2D[pts.size()+1];
                 for (int j=0;j<pts.size();j++) {
                 newPts[j] = (Point2D)pts.get(j);
                 }
                 newPts[pts.size()] = (Point2D)pts.get(0);
                 bulges.add(new Double(0));
                 } else {
                 for (int j=0;j<pts.size();j++) {
                 newPts[j] = (Point2D)pts.get(j);
                 }
                 }*/
                double[] bs = new double[bulges.size()];
                for( int j = 0; j < bulges.size(); j++ ) {
                    bs[j] = ((Double) bulges.get(j)).doubleValue();
                }
                ((DwgPolyline2D) pol).setBulges(bs);
                // Point2D[] points = GisModelCurveCalculator.calculateGisModelBulge(newPts,
                // bs);
                Point2D[] points = new Point2D[pts.size()];
                for( int j = 0; j < pts.size(); j++ ) {
                    points[j] = (Point2D) pts.get(j);
                }
                ((DwgPolyline2D) pol).setPts(points);
            } else {
                // System.out.println("Encontrada polil�nea sin puntos ...");
                // TODO: No se debe mandar nunca una polil�nea sin puntos, si esto
                // ocurre es porque existe un error que hay que corregir ...
            }
        } else if (pol instanceof DwgPolyline3D) {
        } else if (pol instanceof DwgLwPolyline && ((DwgLwPolyline) pol).getVertices() != null) {
        }
    }
}
 
Example 19
Source File: LabelToValuePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean dialogItemChanged(GenericDialog gd, AWTEvent evt) 
{
	if (gd.wasCanceled() || gd.wasOKed()) 
	{
		return true;
	}
	
	@SuppressWarnings("rawtypes")
	Vector choices = gd.getChoices();
	if (choices == null) 
	{
		IJ.log("empty choices array...");
		return false;
	}
	
	// Change of the data table
       if (evt.getSource() == choices.get(0)) 
	{
		String tableName = ((Choice) evt.getSource()).getSelectedItem();
		Frame tableFrame = WindowManager.getFrame(tableName);
		this.table = ((TextWindow) tableFrame).getTextPanel().getResultsTable();
		
		// Choose current heading
		String[] headings = this.table.getHeadings();
		String defaultHeading = headings[0];
		if (defaultHeading.equals("Label") && headings.length > 1) 
		{
			defaultHeading = headings[1];
		}
		
		Choice headingChoice = (Choice) choices.get(1);
		headingChoice.removeAll();
		for (String heading : headings) 
		{
			headingChoice.add(heading);
		}
		headingChoice.select(defaultHeading);

		changeColumnHeader(defaultHeading);
	}
	
	// Change of the column heading
	if (evt.getSource() == choices.get(1)) 
	{
		String headerName = ((Choice) evt.getSource()).getSelectedItem();
           changeColumnHeader(headerName);
	}
	
	return true;
}
 
Example 20
Source File: myDataset.java    From KEEL with GNU General Public License v3.0 2 votes vote down vote up
/**
   * Returns a nominal representation of a attribute's real value given as argument.
   * @param atributo Attribute given.
   * @param valorReal Real value of the attribute given.
   * @return Returns a nominal representation of a attribute's real value.
   */
public static String valorNominal(int atributo, double valorReal) {
  Vector nominales = Attributes.getInputAttribute(atributo).
      getNominalValuesList();
  return (String) nominales.get( (int) valorReal);
}