All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.openhtmltopdf.layout.CounterLanguage Maven / Gradle / Ivy

Go to download

Open HTML to PDF is a CSS 2.1 renderer written in Java. This artifact contains the core rendering and layout code.

The newest version!
package com.openhtmltopdf.layout;

public class CounterLanguage {
    static String toRoman(int val) {
        int[] ints = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String[] nums = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < ints.length; i++) {
            int count = val / ints[i];
            for (int j = 0; j < count; j++) {
                sb.append(nums[i]);
            }
            val -= ints[i] * count;
        }
        return sb.toString();
    }

    static String toLatin(int val) {
        String result = "";
        val -= 1;
        while (val >= 0) {
            int letter = val % 26;
            val = val / 26 - 1;
            result = ((char) (letter + 65)) + result;
        }
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy