use of java.util.Formatter in project weiui by kuaifan.
the class PDF417ScanningDecoder method toString.
public static String toString(BarcodeValue[][] barcodeMatrix) {
try (Formatter formatter = new Formatter()) {
for (int row = 0; row < barcodeMatrix.length; row++) {
formatter.format("Row %2d: ", row);
for (int column = 0; column < barcodeMatrix[row].length; column++) {
BarcodeValue barcodeValue = barcodeMatrix[row][column];
if (barcodeValue.getValue().length == 0) {
formatter.format(" ", (Object[]) null);
} else {
formatter.format("%4d(%2d)", barcodeValue.getValue()[0], barcodeValue.getConfidence(barcodeValue.getValue()[0]));
}
}
formatter.format("%n");
}
return formatter.toString();
}
}
use of java.util.Formatter in project mkgmap by openstreetmap.
the class StylePrinter method dumpToFile.
/**
* Writes out this file to the given writer in the single file format. This
* produces a valid style file, although it is mostly used for testing.
*/
public void dumpToFile(Writer out) {
Formatter fmt = new Formatter(out);
fmt.format("<<<version>>>\n0\n");
dumpInfo(fmt);
dumpOptions(fmt);
if (relations != null)
dumpRuleSet(fmt, "relations", relations);
if (nodes != null)
dumpRuleSet(fmt, "points", nodes);
if (lines != null)
dumpRuleSet(fmt, "lines", lines);
if (polygons != null)
dumpRuleSet(fmt, "polygons", polygons);
fmt.flush();
}
use of java.util.Formatter in project mkgmap by openstreetmap.
the class StyleTester method roadToString.
/**
* This is so we can run against versions of mkgmap that do not have
* toString methods on MapLine and MapRoad.
*/
private static String roadToString(MapRoad el) {
StringBuffer sb = new StringBuffer(lineToString(el));
sb.delete(0, 4);
sb.insert(0, "Road");
Formatter fmt = new Formatter(sb);
fmt.format(" road class=%d speed=%d", el.getRoadDef().getRoadClass(), getRoadSpeed(el.getRoadDef()));
return fmt.toString();
}
use of java.util.Formatter in project mkgmap by openstreetmap.
the class StyleTester method lineToString.
/**
* This is so we can run against versions of mkgmap that do not have
* toString methods on MapLine and MapRoad.
*/
private static String lineToString(MapLine el) {
Formatter fmt = new Formatter();
fmt.format("Line 0x%x, labels=%s, res=%d-%d", el.getType(), Arrays.toString(el.getLabels()), el.getMinResolution(), el.getMaxResolution());
if (el.isDirection())
fmt.format(" oneway");
fmt.format(" ");
for (Coord co : el.getPoints()) fmt.format("(%s),", co);
return fmt.toString();
}
use of java.util.Formatter in project mkgmap by openstreetmap.
the class CollationRules method printExpansions.
private void printExpansions() {
for (CharPosition cp : positionMap) {
if (!cp.isExpansion())
continue;
Formatter fmt = new Formatter();
// noinspection MalformedFormatString
fmt.format("expand %c to", cp.getUnicode());
boolean ok = true;
for (CharPosition cp2 = cp; cp2 != null; cp2 = cp2.nextChar) {
cp2.second = 0x50000;
int top = (cp2.third >> 16) & 0xff;
cp2.third = (top == 0x9e || top == 0xa2 || top == 0x2b) ? 0x9b0000 : 0;
CharPosition floor = basePositionMap.ceiling(cp2);
if (floor == null || floor.getUnicode() == 0xfffd) {
fmt.format(" NF");
ok = false;
} else {
fmt.format(" %s", fmtChar(floor.getUnicode()));
}
}
System.out.println((ok ? "" : "# ") + fmt.toString());
// Print comments to help find problems.
for (CharPosition cp2 = cp; cp2 != null; cp2 = cp2.nextChar) {
CharPosition floor = basePositionMap.ceiling(cp2);
if (floor == null) {
System.out.println("#FIX: NF ref=" + cp2);
} else {
System.out.println("#floor is " + fmtChar(toUnicode(floor.val)) + ", " + floor + ", ref is " + cp2);
}
}
}
}
Aggregations