国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

基于Java的MathML轉(zhuǎn)圖片的方法(示例代碼)

瀏覽:7日期:2022-08-10 08:55:10

Maven依賴:

<dependency><groupId>de.rototor.jeuclid</groupId><artifactId>jeuclid-core</artifactId><version>3.1.14</version></dependency>

示例:

@Testpublic void testMathMlToImg() throws IOException {//MathML字符串String mathStr = '<math xmlns='http://www.w3.org/1998/Math/MathML'>n' +'<mi>f</mi>n' +' <mo>(</mo>n' +' <mi>x</mi>n' +' <mo>)</mo>n' +' <mo>&gt;</mo>n' +' <mfrac>n' +'<msqrt>n' +' <mn>2</mn>n' +'</msqrt>n' +'<mn>8</mn>n' +' </mfrac>n' +' <mo>+</mo>n' +' <mn>1</mn>n' +'</math>';//創(chuàng)建轉(zhuǎn)換器Converter converter = Converter.getInstance();//創(chuàng)建layoutContext并設(shè)置相關(guān)參數(shù)//參數(shù)設(shè)置可以參考net.sourceforge.jeuclid.context.Parameter類//參數(shù)默認(rèn)值可以參考LayoutContextImpl類構(gòu)造方法LayoutContextImpl layoutContext = (LayoutContextImpl) LayoutContextImpl.getDefaultLayoutContext();//設(shè)置公式字體大小,默認(rèn)12.0ptlayoutContext.setParameter(Parameter.MATHSIZE, 30);//設(shè)置公式顏色,默認(rèn)黑色layoutContext.setParameter(Parameter.MATHCOLOR, Color.RED);//轉(zhuǎn)換Dimension dimension = converter.convert(mathStr, new FileOutputStream('f:/1.png'), 'image/png', layoutContext);if(dimension != null){System.out.println('圖片轉(zhuǎn)換成功!高:' + dimension.getHeight() + ' 寬:' + dimension.getWidth());}}

輸出結(jié)果:

圖片轉(zhuǎn)換成功!高:70.0 寬:149.0

轉(zhuǎn)換結(jié)果如下:

基于Java的MathML轉(zhuǎn)圖片的方法(示例代碼)

關(guān)于outFileType參數(shù)的取值,支持以下幾種:

image/pngimage/vnd.wap.wbmpimage/x-pngimage/jpegimage/tiffimage/bmpimage/gif

以上就是基于Java的MathML轉(zhuǎn)圖片的方法(示例代碼)的詳細(xì)內(nèi)容,更多關(guān)于Java MathML轉(zhuǎn)圖片的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Java
相關(guān)文章:
主站蜘蛛池模板: 漾濞| 定日县| 山东省| 双牌县| 西城区| 乌拉特中旗| 巴彦县| 金寨县| 九龙城区| 外汇| 中西区| 常宁市| 丰城市| 托克托县| 平凉市| 始兴县| 成都市| 常山县| 会同县| 五莲县| 昭平县| 博罗县| 乐平市| 丹江口市| 金川县| 那曲县| 北流市| 和田县| 思茅市| 龙门县| 宁波市| 永嘉县| 灵宝市| 富裕县| 聂荣县| 牡丹江市| 仁怀市| 丰宁| 阿坝县| 阳春市| 莱芜市|