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

The following examples show how to use java.util.Vector#clear() . 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: AreaOp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void finalizeSubCurves(Vector subcurves, Vector chains) {
    int numchains = chains.size();
    if (numchains == 0) {
        return;
    }
    if ((numchains & 1) != 0) {
        throw new InternalError("Odd number of chains!");
    }
    ChainEnd[] endlist = new ChainEnd[numchains];
    chains.toArray(endlist);
    for (int i = 1; i < numchains; i += 2) {
        ChainEnd open = endlist[i - 1];
        ChainEnd close = endlist[i];
        CurveLink subcurve = open.linkTo(close);
        if (subcurve != null) {
            subcurves.add(subcurve);
        }
    }
    chains.clear();
}
 
Example 2
Source File: AreaOp.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void finalizeSubCurves(Vector subcurves, Vector chains) {
    int numchains = chains.size();
    if (numchains == 0) {
        return;
    }
    if ((numchains & 1) != 0) {
        throw new InternalError("Odd number of chains!");
    }
    ChainEnd[] endlist = new ChainEnd[numchains];
    chains.toArray(endlist);
    for (int i = 1; i < numchains; i += 2) {
        ChainEnd open = endlist[i - 1];
        ChainEnd close = endlist[i];
        CurveLink subcurve = open.linkTo(close);
        if (subcurve != null) {
            subcurves.add(subcurve);
        }
    }
    chains.clear();
}
 
Example 3
Source File: Plot.java    From opt4j with MIT License 6 votes vote down vote up
/**
 * Clear the plot of data points in the specified dataset. This calls
 * repaint() to request an update of the display.
 * 
 * This is not synchronized, so the caller should be. Moreover, this should
 * only be called in the event dispatch thread. It should only be called via
 * deferIfNecessary().
 */
private void _clear(int dataset) {
	// Ensure replot of offscreen buffer.
	_plotImage = null;
	_checkDatasetIndex(dataset);
	_xyInvalid = true;

	Vector<PlotPoint> points = _points.elementAt(dataset);

	// Vector.clear() is new in JDK1.2, so we use just
	// create a new Vector here so that we can compile
	// this with JDK1.1 for use in JDK1.1 browsers
	points.clear();

	// _points.setElementAt(new Vector(), dataset);
	_points.setElementAt(points, dataset);
	repaint();
}
 
Example 4
Source File: TemplateFactory.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public static Vector<Template> getTemplates(Vector<Template> data,
                                            int decompositionType) {
    data.clear();
    data.add(simpleModel);
    data.add(classicModel);
    data.add(ditalizatedModel);
    data = getUserTemplates(data, decompositionType);
    return data;
}
 
Example 5
Source File: RunCalibrationAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void refreshModel(final ProfilerTable table) {
    Object selected = null;
    Set original = new HashSet();
    int selrow = table.getSelectedRow();
    int column = table.convertColumnIndexToView(0);
    for (int row = 0; row < table.getRowCount(); row++) {
        Object value = table.getValueAt(row, column);
        original.add(value);
        if (row == selrow) selected = value;
    }
    
    final DefaultTableModel model = (DefaultTableModel)table.getModel();
    Vector data = model.getDataVector();
    data.clear();
    
    for (JavaPlatform platform : JavaPlatform.getPlatforms()) {
        data.add(new Vector(Arrays.asList(platform, null)));
        if (!original.contains(platform)) selected = platform;
    }
    
    table.clearSelection();
    model.fireTableDataChanged();
    
    if (selected != null) table.selectValue(selected, column, true);
    
    RequestProcessor.getDefault().post(new Runnable() {
        public void run() { refreshTimes(model); }
    });
}
 
Example 6
Source File: JSONMessage.java    From JSONMessage with MIT License 5 votes vote down vote up
/**
 * Ends the centering of the JSONMessage text.
 *
 * @return This {@link JSONMessage} instance
 */
public JSONMessage endCenter() {
    int current = centeringStartIndex;

    while (current < parts.size()) {
        Vector<MessagePart> currentLine = new Vector<>();
        int totalLineLength = 0;

        for (; ; current++) {
            MessagePart part = current < parts.size() ? parts.get(current) : null;
            String raw = part == null ? null : ChatColor.stripColor(part.toLegacy());

            if (current >= parts.size() || totalLineLength + raw.length() >= 53) {
                int padding = Math.max(0, (53 - totalLineLength) / 2);
                currentLine.firstElement().setText(Strings.repeat(" ", padding) + currentLine.firstElement().getText());
                currentLine.lastElement().setText(currentLine.lastElement().getText() + "\n");
                currentLine.clear();
                break;
            }

            totalLineLength += raw.length();
            currentLine.add(part);
        }
    }

    MessagePart last = parts.get(parts.size() - 1);
    last.setText(last.getText().substring(0, last.getText().length() - 1));

    centeringStartIndex = -1;

    return this;
}
 
Example 7
Source File: ConfigParser.java    From EasyVPN-Free with GNU General Public License v3.0 5 votes vote down vote up
private void checkinlinefile(Vector<String> args, BufferedReader br) throws IOException, ConfigParseError {
    String arg0 = args.get(0).trim();
    // CHeck for <foo>
    if (arg0.startsWith("<") && arg0.endsWith(">")) {
        String argname = arg0.substring(1, arg0.length() - 1);
        String inlinefile = VpnProfile.INLINE_TAG;

        String endtag = String.format("</%s>", argname);
        do {
            String line = br.readLine();
            if (line == null) {
                throw new ConfigParseError(String.format("No endtag </%s> for starttag <%s> found", argname, argname));
            }
            if (line.trim().equals(endtag))
                break;
            else {
                inlinefile += line;
                inlinefile += "\n";
            }
        } while (true);

        args.clear();
        args.add(argname);
        args.add(inlinefile);
    }

}
 
Example 8
Source File: Resample.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * creates the subsample without replacement
 * 
 * @param random	the random number generator to use
 * @param origSize	the original size of the dataset
 * @param sampleSize	the size to generate
 */
public void createSubsampleWithoutReplacement(Random random, int origSize, 
    int sampleSize) {
  
  if (sampleSize > origSize) {
    sampleSize = origSize;
    System.err.println(
 "Resampling with replacement can only use percentage <=100% - "
 + "Using full dataset!");
  }

  Vector<Integer> indices = new Vector<Integer>(origSize);
  Vector<Integer> indicesNew = new Vector<Integer>(sampleSize);

  // generate list of all indices to draw from
  for (int i = 0; i < origSize; i++)
    indices.add(i);

  // draw X random indices (selected ones get removed before next draw)
  for (int i = 0; i < sampleSize; i++) {
    int index = random.nextInt(indices.size());
    indicesNew.add(indices.get(index));
    indices.remove(index);
  }

  if (getInvertSelection())
    indicesNew = indices;
  else
    Collections.sort(indicesNew);

  for (int i = 0; i < indicesNew.size(); i++)
    push((Instance) getInputFormat().instance(indicesNew.get(i)).copy());

  // clean up
  indices.clear();
  indicesNew.clear();
  indices = null;
  indicesNew = null;
}
 
Example 9
Source File: MatchViewPart.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
private void executeSimpleMatch(TransUnitInfo2TranslationBean tuInfo, TransUnitBean transUnit,
		List<String> needClearToolId, List<AltTransBean> needSaveAltTransList,
		List<AltTransBean> needLoadAltTransList) {
	// 如果忽略锁定的文本,不进行机器翻译
	if (TranslateParameter.getInstance().isIgnoreLock()) {
		if ("no".equals(transUnit.getTuProps().get("translate"))) {
			return;
		}
	}
	// 如果忽略上下文匹配和完全匹配,不翻译
	if (TranslateParameter.getInstance().isIgnoreExactMatch()) {
		if ("100".equals(transUnit.getTgtProps().get("hs:quality"))
				|| "101".equals(transUnit.getTgtProps().get("hs:quality"))) {
			return;
		}
	}
	List<ISimpleMatcher> simpleMatchers = SimpleMatcherFactory.getInstance().getCuurentMatcher();
	for (ISimpleMatcher matcher : simpleMatchers) {
		String toolId = matcher.getMathcerToolId();
		String matcherType = matcher.getMatcherType();
		Vector<AltTransBean> currentMatch = transUnit.getMatchesByToolId(toolId);
		boolean isOverwrite = matcher.isOverwriteMatch();
		if (!matcher.matchChecker()) {
			needLoadAltTransList.addAll(currentMatch);
			continue;
		}
		if (currentMatch.size() > 0 && !isOverwrite) {
			needLoadAltTransList.addAll(currentMatch);
			continue;
		} else {
			String tgtText = matcher.executeMatch(tuInfo);
			if (tgtText.equals("")) {
				continue;
			}

			AltTransBean bean = new AltTransBean(tuInfo.getSrcPureText(), tgtText, tuInfo.getSrcLanguage(),
					tuInfo.getTgtLangugage(), matcher.getMathcerOrigin(), toolId);
			bean.getMatchProps().put("match-quality", "100");
			bean.setSrcContent(tuInfo.getSrcPureText());
			bean.setTgtContent(tgtText);
			bean.getMatchProps().put("hs:matchType", matcherType);

			currentMatch.clear();
			currentMatch.add(bean);
			needLoadAltTransList.addAll(currentMatch);

			if (CommonFunction.checkEdition("U") && matcher.isSuportPreTrans()) {
				needSaveAltTransList.add(bean);
				transUnit.updateMatches(toolId, currentMatch);
				if (currentMatch.size() > 0) {
					needClearToolId.add(toolId);
				}
			}
		}
	}
}
 
Example 10
Source File: DBMng.java    From JVoiceXML with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void insertBackupTbl(Vector vt) 
{
    VNXLog.fatal("Insert backup table here, don't support yet : vt:"+vt);
    vt.clear();
}
 
Example 11
Source File: Conv2dLayer.java    From CupDnn with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void backward() {
	// TODO Auto-generated method stub
	Blob input = mNetwork.getDatas().get(id-1);
	Blob inputDiff = mNetwork.getDiffs().get(id);
	Blob outputDiff = mNetwork.getDiffs().get(id-1);
	float[] inputDiffData = inputDiff.getData();
	float[] zData = z.getData();
	float[] kernelGradientData = kernelGradient.getData();
	float[] inputData = input.getData();
	float[] biasGradientData = biasGradient.getData();
	
	//�ȳ˼�����ĵ���,�õ��ò�����
	Vector<Task<Object>> workers = new Vector<Task<Object>>();
	if(activationFunc!=null){
		for(int n=0;n<inputDiff.getNumbers();n++){
			workers.add(new Task<Object>(n) {
				@Override
			    public Object call() throws Exception {
					for(int c=0;c<inputDiff.getChannels();c++){
						for(int h=0;h<inputDiff.getHeight();h++){
							for(int w=0;w<inputDiff.getWidth();w++){
								inputDiffData[inputDiff.getIndexByParams(n, c, h, w)] *= activationFunc.diffActive(zData[z.getIndexByParams(n, c, h, w)]);
							}
						}
					}
					return null;
				}
			});
		}
		ThreadPoolManager.getInstance(mNetwork).dispatchTask(workers);
	}
	
	//Ȼ����²���
	//����kernelGradient,���ﲢ������kernel,kernel���Ż����и���
	kernelGradient.fillValue(0);
	workers.clear();
	for(int n=0;n<inputDiff.getNumbers();n++){
		workers.add(new Task<Object>(n) {
			@Override
		    public Object call() throws Exception {
				for(int ci=0;ci<inputDiff.getChannels();ci++){
					for(int co=0;co<outputDiff.getChannels();co++) {
						for(int h=0;h<inputDiff.getHeight();h++){
							for(int w=0;w<inputDiff.getWidth();w++){
								//�ȶ�λ�������λ��
								//Ȼ�����kernel,ͨ��kernel��λ�����λ��
								//Ȼ���������diff
								int inStartX = w - kernelGradient.getWidth()/2;
								int inStartY = h - kernelGradient.getHeight()/2;
								//�;���˳˼�
					
								for(int kh=0;kh<kernelGradient.getHeight();kh++){
									for(int kw=0;kw<kernelGradient.getWidth();kw++){
										int inY = inStartY + kh;
										int inX = inStartX + kw;
										if (inY >= 0 && inY < input.getHeight() && inX >= 0 && inX < input.getWidth()){
											kernelGradientData[kernelGradient.getIndexByParams(0,  ci*outputDiff.getChannels()+co, kh, kw)] += inputData[input.getIndexByParams(n,co , inY, inX)]
													*inputDiffData[inputDiff.getIndexByParams(n, ci, h, w)];
										}
									}
								}
							}
						}
					}
				}
				return null;
			}
		});
	}
	ThreadPoolManager.getInstance(mNetwork).dispatchTask(workers);
	//ƽ��
	MathFunctions.dataDivConstant(kernelGradientData, inputDiff.getNumbers());
	
	//����bias
	biasGradient.fillValue(0);
	for(int n=0;n<inputDiff.getNumbers();n++){
		for(int c=0;c<inputDiff.getChannels();c++){
			for(int h=0;h<inputDiff.getHeight();h++){
				for(int w=0;w<inputDiff.getWidth();w++){
					biasGradientData[bias.getIndexByParams(0, 0, 0, c)] += inputDiffData[inputDiff.getIndexByParams(n, c, h, w)];
				}
			}
		}
	}
	//ƽ��
	MathFunctions.dataDivConstant(biasGradientData, inputDiff.getNumbers());
	
	if(id<=1)return;
	//�Ȱ�kernel��ת180��
	//Blob kernelRoate180 = MathFunctions.rotate180Blob(kernel);
	//Ȼ���������
	outputDiff.fillValue(0);
	MathFunctions.conv2dBlobSame(mNetwork,inputDiff, kernel, outputDiff);	
	
	mNetwork.updateW(kernel, kernelGradient);
	mNetwork.updateW(bias, biasGradient);
}
 
Example 12
Source File: RMIGenerator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 13
Source File: UpdateTransactionCache_taddr.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
  synchronized (requestExistsMutex) {
    if (requestExist) {
      callback.onResponse("Another UpdateTransacionCache_taddr request exists.", null);
      return;
    } else {
      requestExist = true;
    }
  }

  Vector<ZCashTransactionDetails_taddr> transactions = cache;
  if (transactions == null) {
    synchronized (requestExistsMutex) {
      requestExist = false;
    }

    callback.onResponse("Wallet is not imported.", null);
    return;
  }


  SortedSet<ZCashTransactionDetails_taddr> uniqueTransactions = new TreeSet<>();
  long lastBlock = 0;

  if (transactions.isEmpty()) {
    rescan = true;
  } else {
    lastBlock = transactions.lastElement().blockHeight;
  }

  if (rescan) {
    synchronized (transactions) {
      transactions.clear();
    }
  }

  try {
    getAllRecv(20, 0, rescan, lastBlock, uniqueTransactions);
    getAllSent(20, 0, rescan, lastBlock, uniqueTransactions);
  } catch (ZCashException e) {
    synchronized (requestExistsMutex) {
      requestExist = false;
    }

    callback.onResponse(e.getMessage(), null);
    return;
  }

  boolean initialized = ZCashTransactionDetails_taddr.prepareAfterParsing(uniqueTransactions);
  if (initialized) {
    transactions.addAll(uniqueTransactions);
  } else {
    synchronized (requestExistsMutex) {
      requestExist = false;
    }

    return;
  }

  synchronized (requestExistsMutex) {
    requestExist = false;
  }


  callback.onResponse("ok", null);
}
 
Example 14
Source File: RMIGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 15
Source File: RMIGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Compute the exceptions which need to be caught and rethrown in a
 * stub method before wrapping Exceptions in UnexpectedExceptions,
 * given the exceptions declared in the throws clause of the method.
 * Returns a Vector containing ClassDefinition objects for each
 * exception to catch.  Each exception is guaranteed to be unique,
 * i.e. not a subclass of any of the other exceptions in the Vector,
 * so the catch blocks for these exceptions may be generated in any
 * order relative to each other.
 *
 * RemoteException and RuntimeException are each automatically placed
 * in the returned Vector (if none of their superclasses are already
 * present), since those exceptions should always be directly rethrown
 * by a stub method.
 *
 * The returned Vector will be empty if java.lang.Exception or one
 * of its superclasses is in the throws clause of the method, indicating
 * that no exceptions need to be caught.
 */
private Vector<ClassDefinition> computeUniqueCatchList(ClassDeclaration[] exceptions) {
    Vector<ClassDefinition> uniqueList = new Vector<>();       // unique exceptions to catch

    uniqueList.addElement(defRuntimeException);
    uniqueList.addElement(defRemoteException);

    /* For each exception declared by the stub method's throws clause: */
nextException:
    for (int i = 0; i < exceptions.length; i++) {
        ClassDeclaration decl = exceptions[i];
        try {
            if (defException.subClassOf(env, decl)) {
                /*
                 * (If java.lang.Exception (or a superclass) was declared
                 * in the throws clause of this stub method, then we don't
                 * have to bother catching anything; clear the list and
                 * return.)
                 */
                uniqueList.clear();
                break;
            } else if (!defException.superClassOf(env, decl)) {
                /*
                 * Ignore other Throwables that do not extend Exception,
                 * since they do not need to be caught anyway.
                 */
                continue;
            }
            /*
             * Compare this exception against the current list of
             * exceptions that need to be caught:
             */
            for (int j = 0; j < uniqueList.size();) {
                ClassDefinition def = uniqueList.elementAt(j);
                if (def.superClassOf(env, decl)) {
                    /*
                     * If a superclass of this exception is already on
                     * the list to catch, then ignore and continue;
                     */
                    continue nextException;
                } else if (def.subClassOf(env, decl)) {
                    /*
                     * If a subclass of this exception is on the list
                     * to catch, then remove it.
                     */
                    uniqueList.removeElementAt(j);
                } else {
                    j++;    // else continue comparing
                }
            }
            /* This exception is unique: add it to the list to catch. */
            uniqueList.addElement(decl.getClassDefinition(env));
        } catch (ClassNotFound e) {
            env.error(0, "class.not.found", e.name, decl.getName());
            /*
             * REMIND: We do not exit from this exceptional condition,
             * generating questionable code and likely letting the
             * compiler report a resulting error later.
             */
        }
    }
    return uniqueList;
}
 
Example 16
Source File: WaveletMassDetector.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function searches for maximums from wavelet data points
 */
private DataPoint[] getMzPeaks(double noiseLevel, DataPoint[] originalDataPoints,
    DataPoint[] waveletDataPoints) {

  TreeSet<DataPoint> mzPeaks =
      new TreeSet<DataPoint>(new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));

  Vector<DataPoint> rawDataPoints = new Vector<DataPoint>();
  int peakMaxInd = 0;
  int stopInd = waveletDataPoints.length - 1;

  for (int ind = 0; ind <= stopInd; ind++) {

    while ((ind <= stopInd) && (waveletDataPoints[ind].getIntensity() == 0)) {
      ind++;
    }
    peakMaxInd = ind;
    if (ind >= stopInd) {
      break;
    }

    // While peak is on
    while ((ind <= stopInd) && (waveletDataPoints[ind].getIntensity() > 0)) {
      // Check if this is the maximum point of the peak
      if (waveletDataPoints[ind].getIntensity() > waveletDataPoints[peakMaxInd].getIntensity()) {
        peakMaxInd = ind;
      }
      rawDataPoints.add(originalDataPoints[ind]);
      ind++;
    }

    if (ind >= stopInd) {
      break;
    }

    rawDataPoints.add(originalDataPoints[ind]);

    if (originalDataPoints[peakMaxInd].getIntensity() > noiseLevel) {
      SimpleDataPoint peakDataPoint = new SimpleDataPoint(originalDataPoints[peakMaxInd].getMZ(),
          calcAproxIntensity(rawDataPoints));

      mzPeaks.add(peakDataPoint);

    }
    rawDataPoints.clear();
  }

  return mzPeaks.toArray(new DataPoint[0]);

}
 
Example 17
Source File: missing.java    From KEEL with GNU General Public License v3.0 4 votes vote down vote up
static Interval[][] values_missing(Interval X[][],int nejemplos,int dimx, int m)
{
			
	
	Vector<Float> frequent_min= new Vector<Float>();
	Vector<Float> frequent_max= new Vector<Float>();
	for(int i=0;i<dimx;i++)
	{
		float mean_min=0;
		float mean_max=0;
		int contador=0;
		frequent_min.clear();
		frequent_max.clear();
		for(int j=0;j<nejemplos;j++)
		{
			if(X[j][i].getmin()!=Main.MISSING && X[j][i].getmax()!=Main.MISSING)
			{
				mean_min=mean_min+X[j][i].getmin();
				mean_max=mean_max+X[j][i].getmax();
				contador++;
				
				frequent_min.add(X[j][i].getmin());
				frequent_max.add(X[j][i].getmax());
			
			}
		}
	
		int max_ant_min=0;
		float variable_min=0;
		int max_ant_max=0;
		float variable_max=0;
		for(int f=0;f<frequent_min.size();f++)
		{
			
			int max_min=1;
			int max_max=1;
			for(int t=0;t<frequent_min.size();t++)
			{
			  
			    if(t!=f)
			     {
			    
			    	if(frequent_min.get(t).compareTo(frequent_min.get(f))==0)
			    	{
			    		max_min++;
			    	
			    	}
			    	if(frequent_max.get(t).compareTo(frequent_max.get(f))==0)
			    	{
			    		max_max++;
			    	
			    	}
			    	
			    }
			   		
			}
			if(max_min>max_ant_min)
			{
				
				max_ant_min=max_min;
				variable_min=frequent_min.get(f);
			}
			if(max_max>max_ant_max)
			{
			
				max_ant_max=max_max;
				variable_max=frequent_max.get(f);
			}
			
		}
		
		
		
		
		
		
		
		mean_min=mean_min/contador;
		mean_max=mean_max/contador;
	   for(int j=0;j<nejemplos;j++)
		{
			if(X[j][i].getmin()==Main.MISSING && X[j][i].getmax()==Main.MISSING)
			{
				if(m==1)
				{
					X[j][i].setmin(mean_min);
					X[j][i].setmax(mean_max);
				}
				else
				{
					X[j][i].setmin(variable_min);
					X[j][i].setmax(variable_max);
				}
			}
		}
	}
	
	
	
	return X;
}
 
Example 18
Source File: OpenSimDB.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Set the current model to the new one and fire an event for the change.
 */
public void setCurrentModel(final Model aCurrentModel, boolean allowUndo) {
    final Model saveCurrentModel = currentModel;
    currentModel = aCurrentModel;
    Vector<OpenSimObject> objs = new Vector<OpenSimObject>(1);
    objs.add(aCurrentModel);
    ObjectSetCurrentEvent evnt = new ObjectSetCurrentEvent(this, aCurrentModel, objs);
    setChanged();
    //ModelEvent evnt = new ModelEvent(aCurrentModel, ModelEvent.Operation.SetCurrent);
    notifyObservers(evnt);
    objs.clear();
    
    if (allowUndo){
        ExplorerTopComponent.addUndoableEdit(new AbstractUndoableEdit() {
            public void undo() throws CannotUndoException {
                super.undo();
                setCurrentModel(saveCurrentModel, false);
            }

            public void redo() throws CannotRedoException {
                super.redo();
                setCurrentModel(aCurrentModel, true);
            }

            public boolean canUndo() {
                return true;
            }

            public boolean canRedo() {
                return true;
            }

            @Override
            public String getRedoPresentationName() {
                return "Redo Change Current Model";
            }

            @Override
            public String getUndoPresentationName() {
                return "Undo Change Current Model";
            }
       });
}
}
 
Example 19
Source File: GenBroadcastObject.java    From JVoiceXML with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void insertBackupTbl(Vector vt) {
    VNXLog.fatal("Insert backup table here, don't support yet : vt:" + vt);
    vt.clear();
}
 
Example 20
Source File: WaveletMassDetector.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function searches for maximums from wavelet data points
 */
private DataPoint[] getMzPeaks(double noiseLevel, DataPoint[] originalDataPoints,
    DataPoint[] waveletDataPoints) {

  TreeSet<DataPoint> mzPeaks =
      new TreeSet<DataPoint>(new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));

  Vector<DataPoint> rawDataPoints = new Vector<DataPoint>();
  int peakMaxInd = 0;
  int stopInd = waveletDataPoints.length - 1;

  for (int ind = 0; ind <= stopInd; ind++) {

    while ((ind <= stopInd) && (waveletDataPoints[ind].getIntensity() == 0)) {
      ind++;
    }
    peakMaxInd = ind;
    if (ind >= stopInd) {
      break;
    }

    // While peak is on
    while ((ind <= stopInd) && (waveletDataPoints[ind].getIntensity() > 0)) {
      // Check if this is the maximum point of the peak
      if (waveletDataPoints[ind].getIntensity() > waveletDataPoints[peakMaxInd].getIntensity()) {
        peakMaxInd = ind;
      }
      rawDataPoints.add(originalDataPoints[ind]);
      ind++;
    }

    if (ind >= stopInd) {
      break;
    }

    rawDataPoints.add(originalDataPoints[ind]);

    if (originalDataPoints[peakMaxInd].getIntensity() > noiseLevel) {
      SimpleDataPoint peakDataPoint = new SimpleDataPoint(originalDataPoints[peakMaxInd].getMZ(),
          calcAproxIntensity(rawDataPoints));

      mzPeaks.add(peakDataPoint);

    }
    rawDataPoints.clear();
  }

  return mzPeaks.toArray(new DataPoint[0]);

}