List of usage examples for java.util Formatter Formatter
public Formatter(OutputStream os)
From source file:adapters.AxisAdapter.java
/** * Formats and returns a string containing a <SPAN CLASS="logo,LaTeX">L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X</SPAN>-compatible * source code which represents this axis and its parameters. * * @return LaTeX source code in a String. * @param scale current axis wished scale. * * *//*from w w w. j a va 2s .c o m*/ public String toLatex(double scale) { Formatter formatter = new Formatter(Locale.US); double maxAxis = Math.max(axis.getRange().getUpperBound(), twinAxisPosition); //valeur du label le plus grand double minAxis = Math.min(axis.getRange().getLowerBound(), twinAxisPosition); //valeur du label le plus petit String precisionAffichageLabel; //determine combien de decimales seront affichees pour les labels double pas = axis.getTickUnit().getSize(); //step d'affichage des labels pas = fixStep(minAxis, maxAxis, pas); int puissDix; //echelle des valeurs sur l'axe if (Math.log10(pas) < 0) puissDix = (int) Math.log10(pas) - 1; else puissDix = (int) Math.log10(pas); //Placement des fleches, on pourrait facilement les rendre personnalisables... String arrowLeftType = "latex"; String arrowRightType = "latex"; String arrowLeftMargin = "3mm"; String arrowRightMargin = "3mm"; if (twinAxisPosition == minAxis) { arrowLeftType = ""; arrowLeftMargin = "0mm"; } else if (twinAxisPosition == maxAxis) { arrowRightType = ""; arrowRightMargin = "0mm"; } // Label pour l'axe, avec eventuellement l'echelle String label = axis.getLabel(); if (label == null) label = " "; if (puissDix < -2 || puissDix > 2) label = label + " $(10^{" + puissDix + "})$"; else puissDix = 0; if (orientation) { //on est sur l'axe des abscisses //affichage de l'axe formatter.format("\\draw [%s-%s] ([xshift=-%s] %s,0) -- ([xshift=%s] %s,0) node[right] {%s};%n", arrowLeftType, arrowRightType, arrowLeftMargin, (minAxis - twinAxisPosition) * scale, arrowRightMargin, (maxAxis - twinAxisPosition) * scale, label); if (labelsFlag) { //labels manuels String name; double value; double labelTemp; for (int i = 0; i < labelsValue.length; i++) { value = labelsValue[i]; if (labelsName == null) { labelTemp = (value * 100.0 / Math.pow(10, puissDix)); // if(labelTemp == (int)(labelTemp)) name = Integer.toString((int) (labelTemp / 100.0)); // else // name = Double.toString(Math.round(labelTemp)/100.0); } else name = labelsName[i]; if (value == twinAxisPosition && tick0Flag) formatter.format("\\draw (%s,00) -- +(0mm,1mm) -- +(0mm,-1mm) node[below right] {%s};%n", (value - twinAxisPosition) * scale, name); else formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%s};%n", (value - twinAxisPosition) * scale, name); } } else { //labels automatiques double labelTemp; double k = twinAxisPosition; labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; if (tick0Flag) formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below right] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); else formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; while (k <= maxAxis) { //cote positif labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; } k = twinAxisPosition - pas; while (k >= minAxis) { //cote negatif labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (%s,0) -- +(0mm,1mm) -- +(0mm,-1mm) node[below] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k -= pas; } } } else { //On est sur l'axe des ordonnees //affichage de l'axe formatter.format("\\draw [%s-%s] ([yshift=-%s] 0,%s) -- ([yshift=%s] 0, %s) node[above] {%s};%n", arrowLeftType, arrowRightType, arrowLeftMargin, (minAxis - twinAxisPosition) * scale, arrowRightMargin, (maxAxis - twinAxisPosition) * scale, label); if (labelsFlag) { //labels manuels String name; double value; double labelTemp; for (int i = 0; i < labelsValue.length; i++) { value = labelsValue[i]; if (labelsName == null) { labelTemp = (value * scale * 100 / Math.pow(10, puissDix)); if (labelTemp == (int) (labelTemp)) name = Integer.toString((int) (labelTemp / 100.0)); else name = Double.toString(Math.round(labelTemp) / 100.0); } else name = labelsName[i]; if (value == twinAxisPosition && tick0Flag) formatter.format("\\draw (%s,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[above left] {%s};%n", 0, (value - twinAxisPosition) * scale, name); else formatter.format("\\draw (%s,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%s};%n", 0, (value - twinAxisPosition) * scale, name); } } else { //Les labels automatiques double k = twinAxisPosition; double labelTemp; labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; if (tick0Flag) formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[above left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); else formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; while (k <= maxAxis) { //cote positif de l'axe labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k += pas; } k = twinAxisPosition - pas; while (k >= minAxis) { //cote negatif de l'axe labelTemp = (Math.round(k * 100 / Math.pow(10, puissDix))) / 100.0; if (labelTemp == (int) (labelTemp)) precisionAffichageLabel = "0"; else if (labelTemp * 10 == (int) (labelTemp * 10)) precisionAffichageLabel = "1"; else precisionAffichageLabel = "2"; formatter.format("\\draw (0,%s) -- +(1mm,0mm) -- +(-1mm,0mm) node[left] {%." + precisionAffichageLabel + "f};%n", (k - twinAxisPosition) * scale, labelTemp); k -= pas; } } } return formatter.toString(); }
From source file:com.itemanalysis.jmetrik.stats.transformation.LinearTransformationAnalysis.java
public String transformScore() throws SQLException { Statement stmt = null;/*from ww w. j a va 2 s . c o m*/ ResultSet rs = null; Double constrainedScore = null; try { //add variable to db dao.addColumnToDb(conn, tableName, addedVariableInfo); conn.setAutoCommit(false);//begin transaction Table sqlTable = new Table(tableName.getNameForDatabase()); SelectQuery select = new SelectQuery(); select.addColumn(sqlTable, selectedVariable.getName().nameForDatabase()); select.addColumn(sqlTable, addedVariableInfo.getName().nameForDatabase()); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery(select.toString()); this.firePropertyChange("message", "", "Transforming scores..."); double origValue = 0.0; double transValue = 0.0; double z = 0.0; StandardDeviation sd = new StandardDeviation(); Mean mean = new Mean(); Min min = new Min(); Max max = new Max(); while (rs.next()) { origValue = rs.getDouble(selectedVariable.getName().nameForDatabase()); if (!rs.wasNull()) { sd.increment(origValue); mean.increment(origValue); min.increment(origValue); max.increment(origValue); } updateProgress(); } double meanValue = mean.getResult(); double sdValue = sd.getResult(); double minValue = min.getResult(); double maxValue = max.getResult(); double A = 1.0; double B = 0.0; rs.beforeFirst(); while (rs.next()) { origValue = rs.getDouble(selectedVariable.getName().nameForDatabase()); if (!rs.wasNull()) { if (type1) { z = (origValue - meanValue) / sdValue; transValue = scaleSd * z + scaleMean; transValue = checkConstraints(transValue); } else { A = (maxPossibleScore - minPossibleScore) / (maxValue - minValue); B = minPossibleScore - minValue * A; transValue = origValue * A + B; transValue = checkConstraints(transValue); } descriptiveStatistics.increment(transValue); rs.updateDouble(addedVariableInfo.getName().nameForDatabase(), transValue); rs.updateRow(); } updateProgress(); } conn.commit(); conn.setAutoCommit(true); //create output DefaultLinearTransformation linearTransformation = new DefaultLinearTransformation(); linearTransformation.setScale(A); linearTransformation.setIntercept(B); StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format(publishHeader()); f.format(descriptiveStatistics.toString()); f.format(linearTransformation.toString()); f.format("%n"); f.format("%n"); return f.toString(); } catch (SQLException ex) { conn.rollback(); conn.setAutoCommit(true); throw ex; } finally { if (rs != null) rs.close(); if (stmt != null) stmt.close(); } }
From source file:com.itemanalysis.jmetrik.stats.frequency.FrequencyAnalysis.java
public void publishHeader() throws IllegalArgumentException { StringBuilder header = new StringBuilder(); Formatter f = new Formatter(header); String s1 = String.format("%1$tB %1$te, %1$tY %tT", Calendar.getInstance()); int len = 21 + Double.valueOf(Math.floor(Double.valueOf(s1.length()).doubleValue() / 2.0)).intValue(); String dString = ""; try {// w w w . j a v a 2 s . co m dString = command.getDataString(); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException(ex); } int len2 = 21 + Double.valueOf(Math.floor(Double.valueOf(dString.length()).doubleValue() / 2.0)).intValue(); f.format("%31s", "FREQUENCY ANALYSIS"); f.format("%n"); f.format("%" + len2 + "s", dString); f.format("%n"); f.format("%" + len + "s", s1); f.format("%n"); f.format("%n"); publish(f.toString()); }
From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java
private static void appendDir(final Appendable report, final File file, final int indent) throws IOException { for (int i = 0; i < indent; i++) report.append(" - "); final Formatter formatter = new Formatter(report); final Calendar calendar = new GregorianCalendar(UTC); calendar.setTimeInMillis(file.lastModified()); formatter.format(Locale.US, "%tF %tT %8d %s\n", calendar, calendar, file.length(), file.getName()); formatter.close();/*from ww w.j a va2s.c o m*/ final File[] files = file.listFiles(); if (files != null) for (final File f : files) appendDir(report, f, indent + 1); }
From source file:com.itemanalysis.psychometrics.measurement.TestSummary.java
public String print() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); String f2 = "%.4f"; f.format("%n"); f.format("%n"); f.format("%-21s", " TEST LEVEL STATISTICS "); f.format("%n"); f.format("%-42s", "=========================================="); f.format("%n"); f.format("%-18s", "Number of Items = "); f.format("%-10d", this.numberOfItems()); f.format("%n"); f.format("%-22s", "Number of Examinees = "); f.format("%10d", stats.getN()); f.format("%n"); f.format("%-6s", "Min = "); f.format(f2, stats.getMin());/*from w w w . j av a 2s .c o m*/ f.format("%n"); f.format("%-6s", "Max = "); f.format(f2, stats.getMax()); f.format("%n"); f.format("%-7s", "Mean = "); f.format(f2, stats.getMean()); f.format("%n"); f.format("%-9s", "Median = "); f.format(f2, stats.getPercentile(50)); f.format("%n"); f.format("%-21s", "Standard Deviation = "); f.format(f2, stdDev.getResult()); f.format("%n"); f.format("%-22s", "Interquartile Range = "); f.format(f2, stats.getPercentile(75) - stats.getPercentile(25)); f.format("%n"); f.format("%-11s", "Skewness = "); f.format(f2, stats.getSkewness()); f.format("%n"); f.format("%-11s", "Kurtosis = "); f.format(f2, stats.getKurtosis()); f.format("%n"); f.format("%-7s", "KR21 = "); f.format(f2, this.kr21()); f.format("%n"); f.format("%-42s", "------------------------------------------"); f.format("%n"); f.format("%n"); f.format("%n"); if (reliabilitySampleSize > 0) { reliability = new ReliabilitySummary(relMatrix, variableAttributes, unbiased, deletedReliability); sb.append(reliability.toString()); if (deletedReliability) { f.format("%n"); f.format("%n"); f.format(reliability.itemDeletedString()); } } if (cutScores != null) { f.format("%n"); f.format("%n"); sb.append(this.computeDecisionConsistency().toString()); } if (showCsem) { f.format("%n"); f.format("%n"); sb.append(this.computeCSEM(reliability.value(), unbiased).print()); } //reliability of subscale defined part tests if (numberOfSubscales > 1) { reliability = new ReliabilitySummary(partRelMatrix, variableAttributes, unbiased, false); f.format("%n"); f.format("%n"); f.format("%n"); f.format("%59s", " ITEM GROUP DEFINED PART-TEST RELIABILITY"); f.format("%n"); sb.append(reliability.toString()); f.format("%-6s", "Number of part-tests = " + partRelMatrix.getNumberOfVariables()); f.format("%n"); } f.format("%n"); f.format("%n"); f.format("%n"); return f.toString(); }
From source file:org.apache.hadoop.hive.metastore.tools.BenchmarkTool.java
@Override public void run() { LOG.info("Using warmup " + warmup + " spin " + spinCount + " nparams " + nParameters + " threads " + nThreads);/*from w w w . ja v a2 s .co m*/ StringBuilder sb = new StringBuilder(); BenchData bData = new BenchData(dbName, tableName); MicroBenchmark bench = new MicroBenchmark(warmup, spinCount); BenchmarkSuite suite = new BenchmarkSuite(); suite.setScale(scale).doSanitize(doSanitize).add("getNid", () -> benchmarkGetNotificationId(bench, bData)) .add("listDatabases", () -> benchmarkListDatabases(bench, bData)) .add("listTables", () -> benchmarkListAllTables(bench, bData)) .add("getTable", () -> benchmarkGetTable(bench, bData)) .add("createTable", () -> benchmarkTableCreate(bench, bData)) .add("dropTable", () -> benchmarkDeleteCreate(bench, bData)) .add("dropTableWithPartitions", () -> benchmarkDeleteWithPartitions(bench, bData, 1, nParameters)) .add("addPartition", () -> benchmarkCreatePartition(bench, bData)) .add("dropPartition", () -> benchmarkDropPartition(bench, bData)) .add("listPartition", () -> benchmarkListPartition(bench, bData)) .add("getPartition", () -> benchmarkGetPartitions(bench, bData, 1)) .add("getPartitionNames", () -> benchmarkGetPartitionNames(bench, bData, 1)) .add("getPartitionsByNames", () -> benchmarkGetPartitionsByName(bench, bData, 1)) .add("renameTable", () -> benchmarkRenameTable(bench, bData, 1)) .add("dropDatabase", () -> benchmarkDropDatabase(bench, bData, 1)); for (int howMany : instances) { suite.add("listTables" + '.' + howMany, () -> benchmarkListTables(bench, bData, howMany)) .add("dropTableWithPartitions" + '.' + howMany, () -> benchmarkDeleteWithPartitions(bench, bData, howMany, nParameters)) .add("listPartitions" + '.' + howMany, () -> benchmarkListManyPartitions(bench, bData, howMany)) .add("getPartitions" + '.' + howMany, () -> benchmarkGetPartitions(bench, bData, howMany)) .add("getPartitionNames" + '.' + howMany, () -> benchmarkGetPartitionNames(bench, bData, howMany)) .add("getPartitionsByNames" + '.' + howMany, () -> benchmarkGetPartitionsByName(bench, bData, howMany)) .add("addPartitions" + '.' + howMany, () -> benchmarkCreatePartitions(bench, bData, howMany)) .add("dropPartitions" + '.' + howMany, () -> benchmarkDropPartitions(bench, bData, howMany)) .add("renameTable" + '.' + howMany, () -> benchmarkRenameTable(bench, bData, howMany)) .add("dropDatabase" + '.' + howMany, () -> benchmarkDropDatabase(bench, bData, howMany)); } if (doList) { suite.listMatching(matches, exclude).forEach(System.out::println); return; } LOG.info("Using table '{}.{}", dbName, tableName); try (HMSClient client = new HMSClient(getServerUri(host, String.valueOf(port)), confDir)) { bData.setClient(client); if (!client.dbExists(dbName)) { client.createDatabase(dbName); } if (client.tableExists(dbName, tableName)) { client.dropTable(dbName, tableName); } // Arrange various benchmarks in a suite BenchmarkSuite result = suite.runMatching(matches, exclude); Formatter fmt = new Formatter(sb); if (doCSV) { result.displayCSV(fmt, csvSeparator); } else { result.display(fmt); } PrintStream output = System.out; if (outputFile != null) { output = new PrintStream(outputFile); } if (outputFile != null) { // Print results to stdout as well StringBuilder s = new StringBuilder(); Formatter f = new Formatter(s); result.display(f); System.out.print(s); f.close(); } output.print(sb.toString()); fmt.close(); if (dataSaveDir != null) { saveData(result.getResult(), dataSaveDir, scale); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.itemanalysis.jmetrik.stats.transformation.LinearTransformationAnalysis.java
private String publishHeader() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); String dString = ""; String title = "LINEAR TRANSFORMATION"; try {/*w ww. j av a 2 s . c om*/ dString = command.getDataString(); } catch (IllegalArgumentException ex) { dString = ""; throw new IllegalArgumentException(ex); } //create header int len1 = 25 + Double.valueOf(Math.floor(Double.valueOf(title.length()).doubleValue() / 2.0)).intValue(); int len2 = 25 + Double.valueOf(Math.floor(Double.valueOf(dString.length()).doubleValue() / 2.0)).intValue(); String date = String.format("%1$tB %1$te, %1$tY %tT", Calendar.getInstance()); int len3 = 25 + Double.valueOf(Math.floor(Double.valueOf(date.length()).doubleValue() / 2.0)).intValue(); f.format("%" + len1 + "s", title); f.format("%n"); f.format("%" + len2 + "s", dString); f.format("%n"); f.format("%" + len3 + "s", date); f.format("%n"); f.format("%n"); f.format("%n"); f.format("%n"); return f.toString(); }
From source file:com.itemanalysis.psychometrics.irt.equating.IrtScaleLinking.java
public String toString() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); String gapFormat1 = "%-" + Math.max(13, precision + 4 + 5) + "s"; String gapFormat2 = "%-" + Math.max(9, precision + 4 + 5) + "s"; String intFormat = "%" + Math.max(13, (precision + 4)) + "." + precision + "f"; String sclFormat = "%" + Math.max(9, (precision + 4)) + "." + precision + "f"; f.format("%n"); f.format("%60s", " TRANSFORMATION COEFFICIENTS "); f.format("%n"); f.format("%60s", " Form X (New Form) to Form Y (Old Form) "); f.format("%n"); f.format("%63s", "==============================================================="); f.format("%n"); f.format("%-18s", " Method"); f.format(gapFormat2, "Slope (A)"); f.format("%5s", " "); f.format(gapFormat1, "Intercept (B)"); f.format("%5s", " "); f.format(gapFormat1, "fmin"); f.format("%n"); f.format("%63s", "---------------------------------------------------------------"); f.format("%n"); f.format("%-17s", " Mean/Mean"); f.format(sclFormat, mm.getScale());// www .j av a 2s. co m f.format("%5s", " "); f.format(intFormat, mm.getIntercept()); f.format("%5s", " "); f.format("%n"); f.format("%-17s", " Mean/Sigma"); f.format(sclFormat, ms.getScale()); f.format("%5s", " "); f.format(intFormat, ms.getIntercept()); f.format("%5s", " "); f.format("%n"); f.format("%-17s", " Haebara"); f.format(sclFormat, hb.getScale()); f.format("%5s", " "); f.format(intFormat, hb.getIntercept()); f.format("%5s", " "); f.format("%13.6f", fHB); f.format("%5s", " "); f.format("%n"); f.format("%-17s", " Stocking-Lord"); f.format(sclFormat, sl.getScale()); f.format("%5s", " "); f.format(intFormat, sl.getIntercept()); f.format("%5s", " "); f.format("%13.6f", fSL); f.format("%5s", " "); f.format("%n"); f.format("%63s", "==============================================================="); f.format("%n"); return f.toString(); }
From source file:com.hyperaware.conference.android.fragment.SpeakerDetailFragment.java
private void updateSpeaker() { tvName.setText(speakerItem.getName()); host.setTitle(speakerItem.getName()); final String company = speakerItem.getCompanyName(); tvCompany.setVisibility(Strings.isNullOrEmpty(company) ? View.GONE : View.VISIBLE); tvCompany.setText(company);//w w w . j a va2 s . c o m final String title = speakerItem.getTitle(); tvTitle.setVisibility(Strings.isNullOrEmpty(title) ? View.GONE : View.VISIBLE); tvTitle.setText(title); Glide.with(SpeakerDetailFragment.this).load(speakerItem.getImage100()).fitCenter() .placeholder(R.drawable.nopic).into(ivPic); boolean links_visible = false; final String website = speakerItem.getWebsite(); if (!Strings.isNullOrEmpty(website)) { links_visible = true; tvWebsite.setVisibility(View.VISIBLE); tvWebsite.setText(website); } final String twitter = speakerItem.getTwitter(); if (!Strings.isNullOrEmpty(twitter)) { links_visible = true; tvTwitter.setVisibility(View.VISIBLE); tvTwitter.setText(twitter); } final String facebook = speakerItem.getFacebook(); if (!Strings.isNullOrEmpty(facebook)) { links_visible = true; tvFacebook.setVisibility(View.VISIBLE); tvFacebook.setText(facebook); } final String linkedin = speakerItem.getLinkedin(); if (!Strings.isNullOrEmpty(linkedin)) { links_visible = true; tvLinkedin.setVisibility(View.VISIBLE); tvLinkedin.setText(linkedin); } vgDetailLinks.setVisibility(links_visible ? View.VISIBLE : View.GONE); tvAbout.setText(speakerItem.getAbout()); if (agendaItems.size() > 0) { vgSessions.setVisibility(View.VISIBLE); vgSessions.removeAllViews(); final StringBuilder sb = new StringBuilder(); final Formatter formatter = new Formatter(sb); final LayoutInflater inflater = getActivity().getLayoutInflater(); for (final AgendaItem item : agendaItems) { final View view = inflater.inflate(R.layout.item_speaker_session, vgSessions, false); ((TextView) view.findViewById(R.id.tv_topic)).setText(item.getTopic()); sb.setLength(0); DateUtils.formatDateRange(getActivity(), formatter, item.getEpochStartTime() * 1000, item.getEpochEndTime() * 1000, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY, tz.getID()); ((TextView) view.findViewById(R.id.tv_date)).setText(formatter.toString()); sb.setLength(0); DateUtils.formatDateRange(getActivity(), formatter, item.getEpochStartTime() * 1000, item.getEpochEndTime() * 1000, DateUtils.FORMAT_SHOW_TIME, tz.getID()); ((TextView) view.findViewById(R.id.tv_time)).setText(formatter.toString()); final String session_id = item.getId(); final ImageButton ib_favorite = (ImageButton) view.findViewById(R.id.button_favorite_session); favSessionButtonManager.attach(ib_favorite, session_id); if (host != null) { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Fragment next = SessionDetailFragment.instantiate(item.getId()); host.pushFragment(next, "session_detail"); } }); } vgSessions.addView(view); } } }
From source file:contrail.stages.CompressAndCorrect.java
/** * Remove low coverage nodes./*from w ww . j a v a2 s . c o m*/ * @param inputPath * @param outputPath * @return True if any tips were removed. */ private JobInfo removeLowCoverageNodes(String inputPath, String outputPath) throws Exception { RemoveLowCoverageAvro stage = new RemoveLowCoverageAvro(); stage.setConf(getConf()); // Make a shallow copy of the stage options required by the compress // stage. Map<String, Object> stageOptions = ContrailParameters.extractParameters(this.stage_options, stage.getParameterDefinitions().values()); stageOptions.put("inputpath", inputPath); stageOptions.put("outputpath", outputPath); stage.setParameters(stageOptions); RunningJob job = stage.runJob(); JobInfo result = new JobInfo(); if (job == null) { result.logMessage = "RemoveLowCoverage stage was skipped because graph would not " + "change."; sLogger.info(result.logMessage); result.graphPath = inputPath; result.graphChanged = false; return result; } // Check if any tips were found. long nodesRemoved = job.getCounters() .findCounter(RemoveLowCoverageAvro.NUM_REMOVED.group, RemoveLowCoverageAvro.NUM_REMOVED.tag) .getValue(); result.graphPath = outputPath; if (nodesRemoved > 0) { result.graphChanged = true; } Formatter formatter = new Formatter(new StringBuilder()); result.logMessage = formatter.format("RemoveLowCoverage removed %d nodes.", nodesRemoved).toString(); return result; }