Exemplo n.º 1
0
  public String getUserSerial(String operID) {

    ConnectionManager cm = ConnectionManager.getInstance();

    String userSerial = Util.getUserSerial(cm.getConnection(), operID);

    StringBuffer StrBuf = new StringBuffer();

    StrBuf.append("<root>");
    StrBuf.append("<action type=\"1\" result=\"true\">");

    StrBuf.append("<record> ");

    StrBuf.append("<field ");
    StrBuf.append(" name =\"userserial\"");
    StrBuf.append(" type =\"text\"");
    StrBuf.append("  value =\"" + userSerial + "\"");
    StrBuf.append(" />");
    StrBuf.append("</record>");
    StrBuf.append("</action>");

    StrBuf.append("</root>");

    cm.release();
    return StrBuf.toString();
  }
Exemplo n.º 2
0
  /**
   * Perform string substitution using pattern matching.
   *
   * @param str the source string
   * @param p pattern to look for
   * @param s the string to replace <i>pattern</i> with. Perl5 references to matches are allowed.
   *     See <a
   *     href="http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/Perl5Substitution.html">http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/Perl5Substitution.html</a>
   * @param numSubs number of substitutions to perform, Util.SUBSTITUTE_ALL will cause all
   *     occurences to be replaced
   * @return the string with the substitution made for numSubs occurences of the pattern
   */
  public static String regsub(String str, String p, String s, int numSubs) {
    try {
      Pattern pattern = compiler.compile(p);
      Perl5Substitution subst = new Perl5Substitution(s);

      String result = Util.substitute(sMatcher, pattern, subst, str, numSubs);
      return result;
    } catch (MalformedPatternException e) {
      throw new CompilationError(e);
    }
  }
Exemplo n.º 3
0
  /** @param args */
  public static void main(String[] args) {
    final int[] dims = {50, 30};
    final int n = 1500;
    final short[] short_pixels = Util.rampShort(n, 0);

    // final int[] int_pixels=Util.rampInt(n,0);
    final float[] float_pixels = Util.rampFloat(n, 0);

    final short[] labels = {0, 1, 2};
    final int[] borders = {0, 10, 200, 1000};

    final float[] flabels = {0, 1, 2};
    final float[] fborders = {0.0f, 10, 200, 1000};

    PixelCube<Short, BaseIndex> pci = new PixelCube<Short, BaseIndex>(dims, short_pixels);
    pci.setIterationPattern(IP_FWD + IP_SINGLE);
    pci.setIndexing(BASE_INDEXING);

    PixelCube<Short, BaseIndex> outc = (PixelCube<Short, BaseIndex>) pci.clone();

    RasterForwardIterator<Short> in = (RasterForwardIterator<Short>) pci.iterator();
    RasterForwardIterator<Short> out = (RasterForwardIterator<Short>) outc.iterator();

    Labeling<Short> labeling = new Labeling<Short>(labels, borders);
    labeling.setIO(in, out);

    labeling.run();
    new ImageJ();
    PixLib plib = new PixLib();

    ImagePlus imp1 = null;
    try {
      imp1 = plib.imageFrom("test", pci);
    } catch (UnsupportedTypeException e2) {
      // TODO Auto-generated catch block
      e2.printStackTrace();
    }
    imp1.show();

    ImagePlus imp2 = null;
    try {
      imp2 = plib.imageFrom("thresholded", outc);
    } catch (UnsupportedTypeException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    imp2.show();

    PixelCube<Float, BaseIndex> pcif = new PixelCube<Float, BaseIndex>(dims, float_pixels);
    pcif.setIterationPattern(IP_FWD + IP_SINGLE);
    pcif.setIndexing(BASE_INDEXING);

    PixelCube<Float, BaseIndex> outcf = (PixelCube<Float, BaseIndex>) pcif.clone();

    RasterForwardIterator<Float> inf = (RasterForwardIterator<Float>) pcif.iterator();
    RasterForwardIterator<Float> outf = (RasterForwardIterator<Float>) outcf.iterator();

    Labeling<Float> labelingf = new Labeling<Float>(flabels, fborders);
    labelingf.setIO(inf, outf);

    Float elem = Float.valueOf(3.0f);
    System.out.println(labelingf.mapFloat(elem).getClass());

    labelingf.run();

    // PixLib plibf=new PixLib();
    ImagePlus imp3 = null;
    try {
      imp3 = plib.imageFrom("test", pcif);
    } catch (UnsupportedTypeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    imp3.show();

    ImagePlus imp4 = null;
    try {
      imp4 = plib.imageFrom("thresholded", outcf);
    } catch (UnsupportedTypeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    imp4.show();
  }