Package java.util

Examples of java.util.Formatter$Transformer


    public static String getTimeString(DateTime date) {
        return getTimeString(date.getTime());
    }

    public static String getTimeString(long time) {
        return new Formatter().format("%020d", time).toString();
    }
View Full Code Here


        }
        return true;
    }

    private String wordProbToString(double[] prob) {
        Formatter formatter = new Formatter();
        for(int j=0;j<prob.length;++j) {
            double p = prob[j];
            if (p>=0.00001) {
                formatter.format(" %s:%.5f", langlist.get(j), p);
            }
        }
        String string = formatter.toString();
        formatter.close();
        return string;
    }
View Full Code Here

        int readLen;
        while ((readLen = str.read(buffer, 0, buffer.length)) != -1) {
            dgest.update(buffer, 0, readLen);
        }
        str.close();
        Formatter fmt = new Formatter();
        for (byte b : dgest.digest()) {
            fmt.format("%02X", b);
        }
        String result = fmt.toString();
        fmt.close();
        return result;
    }
View Full Code Here

    }
    int bucketWidth = (int)Math.ceil((float)(max - min) / height);
    int[] counts = count(bucketWidth, values);
    int maxCount = max(counts);
    StringBuilder out = new StringBuilder();
    Formatter formatter = new Formatter(out);
    formatter.format("%8d %" + width + "d", 0, maxCount);
    rows[0] = out.toString();
    for (int i = 0; i < counts.length; i++) {
      out.setLength(0);
      int bucketId = (int) (min + bucketWidth * i + bucketWidth / 2f);
      PieGraph pieGraph = new PieGraph(width, new CharMarker(marker.get(i, bucketId), ' '));
      String bar = pieGraph.render(counts[i], maxCount - counts[i]);
      formatter.format("%6d |%s:%6d", bucketId, bar, counts[i]);
      rows[i + 1] = out.toString();
    }
    return rows;
  }
View Full Code Here

      if (out == null) {
        System.out.println("Another balancer is running. Exiting...");
        return ALREADY_RUNNING;
      }

      Formatter formatter = new Formatter(System.out);
      System.out.println("Time Stamp               Iteration#  Bytes Already Moved  Bytes Left To Move  Bytes Being Moved");
      int iterations = 0;
      while (true ) {
        /* get all live datanodes of a cluster and their disk usage
         * decide the number of bytes need to be moved
         */
        long bytesLeftToMove = initNodes();
        if (bytesLeftToMove == 0) {
          System.out.println("The cluster is balanced. Exiting...");
          return SUCCESS;
        } else {
          LOG.info( "Need to move "+ StringUtils.byteDesc(bytesLeftToMove)
              +" bytes to make the cluster balanced." );
        }
       
        /* Decide all the nodes that will participate in the block move and
         * the number of bytes that need to be moved from one node to another
         * in this iteration. Maximum bytes to be moved per node is
         * Min(1 Band worth of bytes,  MAX_SIZE_TO_MOVE).
         */
        long bytesToMove = chooseNodes();
        if (bytesToMove == 0) {
          System.out.println("No block can be moved. Exiting...");
          return NO_MOVE_BLOCK;
        } else {
          LOG.info( "Will move " + StringUtils.byteDesc(bytesToMove) +
              "bytes in this iteration");
        }
  
        formatter.format("%-24s %10d  %19s  %18s  %17s\n",
            DateFormat.getDateTimeInstance().format(new Date()),
            iterations,
            StringUtils.byteDesc(bytesMoved.get()),
            StringUtils.byteDesc(bytesLeftToMove),
            StringUtils.byteDesc(bytesToMove)
View Full Code Here

  }
  public static int unlimited() {
    return -1;
  }
  public static String inKb(long bytes) {   
    return new Formatter().format("%(,.1fKb", (double)bytes/1024).toString();
  }
View Full Code Here

  }
  public static String inKb(long bytes) {   
    return new Formatter().format("%(,.1fKb", (double)bytes/1024).toString();
  }
  public static String inMb(long bytes) {   
    return new Formatter().format("%(,.1fMb", (double)bytes/1024/1024).toString();
  }
View Full Code Here

            }

            vv.setBackground(Color.WHITE);


            Transformer labelTransformer = new ChainedTransformer<String, String>(new Transformer[]{
                        new ToStringLabeller<Node>() {

                            public String transform(Node v) {
                                return v.getLabel();
                                //return ((primitives.graph.Node)(v.getVertex())).getLabel();
View Full Code Here

    DirectedSparseGraph result = new DirectedSparseGraph();

     if ( model instanceof ChainedTransformer)
     {
       Transformer[] transformers = ((ChainedTransformer) model).getTransformers();
       Transformer lastTransformer = null;
       int counter = 0;
       for ( Transformer transformer: transformers)
       {
         result.addVertex(transformer);
         if ( lastTransformer != null)
View Full Code Here

            edgesWeigth.put(edgeName, Util.stringToInteger(columns[4]));

            graphMulti.addEdge(edgeName, commiter1, commiter2, type);
        }

        Transformer trans = createWeigthTransformer(graphMulti, edgesWeigth);

        BetweennessCentrality<String, String> btwGen = new BetweennessCentrality<>(graphMulti, trans);
        ClosenessCentrality<String, String> clsGen = new ClosenessCentrality<>(graphMulti, trans);
        DegreeScorer<String> dgrGen = new DegreeScorer<>(graphMulti);
View Full Code Here

TOP

Related Classes of java.util.Formatter$Transformer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.