JFreeChart uses and it is transplanted to Linux

xiaoxiao2021-03-06  62

JFreechart

JFreeChart is a Java tool for creating a picture for free (document fee 40 $). You can create a graphic (Pie Charts). XY Plots and Scatter Plots; Time Series, High / Low / Open / Close Charts and Candle Stick Charts; Combination Charts; Bubble Charts; Wind Plots, Meter Charts And Symbol Charts;

A few stickers must be seen:

Http://www-900.ibm.com/developerWorks/cn/wsdd/library/techarticles/yangyaping0307/waslinux.shtml

http://www.lslnet.com/linux/docs/linux-2940.htm

Http://blog.blogchina.com/Article_81038.344426.html

There is no Chinese when transplanting to Linux, and a block appears.

Workaround: COPY or reference / usr / share / fonts / zh_cn / trueType directory in Chinese font, modify /HOME/jdk/jre/lib/fonts.properties

The configuration file is as follows:

Sansserif.0 = -Misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

Sansserif.italic.0 = -Misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

Sansserif.Bold.0 = -Misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

Sansserif.Bolditalic.0 = -Misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

# Component Font Character EncoDings # fontcharset.serif.0 = sun.io.Chartobyteiso8859_1Fontcharset.serif.1 = sun.awt.motif.Chartobytex11GBK

Fontcharset.sansserif.0 = sun.io.Chartobyteiso8859_1Fontcharset.sansserif.1 = sun.awt.motif.Chartobytex11GBK

Fontcharset.monospaced.0 = sun.io.Chartobyteiso8859_1Fontcharset.Monospaced.1 = sun.awt.motif.Chartobytex11GBK

Fontcharset.dialog.0 = sun.io.Chartobyteiso8859_1Fontcharset.dialog.1 = sun.awt.motif.Chartobytex11GBK

Fontcharset.dialoginput.0 = sun.io.Chartobyteiso8859_1Fontcharset.dialoginput.1 = sun.awt.motif.Chartobytex11GBK

FontSet.sansserif.plain = / - misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

FontSet.sansserif.italic = / - misc-zysong18030-medium-r-normal - * -% d - * - * - c - * - ISO10646-1FontSet.sansserif.bold = / - misc-zysong18030-medium-r- NORMAL - * -% D - * - * - C - * - ISO10646-1

FontSet.sansserif.bolditalic = / - misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

FontSet.default = / - misc-zysong18030-medium-r-normal - * -% D - * - * - C - * - ISO10646-1

AppendedFontPath = / usr / share / fonts / zh_cn / trueType

Then recompile the procedures written by JFreechart:

Javac -Encoding GBK BARCHARTDEMO.JAVA / / Code java -djava.awt.Headless = true barchartdeMo // does not call X11 graphics environments when using AWT

When using JFreeChart in Tomcat,

Tomcat is 5.0, on redhat 8, the X, the method is as follows: 1) Terminate your Tomcat. That is: Tomcat directory /bin/shutdown.sh2) Set environment variable: Catalina_opts = "- djava.awt.Headless = true" export catalina_opts (if you want to automatically take effect every time you turn it, you can write this two sentences to your system or you The account launch SH.profile) 3) Start your Tomcat. That is: Tomcat directory /bin/startup.sh

When using the web server RESIN,

Modify a row of rows in resin / bin / below Wrapper.pl = "- djava.awt.headless = true";

============================================================================================================================================================================================================= ============

JFreechart used in the recent project, the version used is: JFreeChart-0.9.8. If the relevant Font setting is not performed, the Chinese generated chart display is very blurred. Other examples can solve this problem.

[This method is to replace the general font to "black body" makes Chinese more clearly.

Therefore, you must ensure that your OS has this font, and JDK can recognize it]

The core code is as follows:

JFreechart Chart = ChartFactory.createVerticalBarchart3d (Title, Domain, Range, Dataset, True, True, False)

Chart.SetBackground (New GradientPaint (0.0F, 0.0F, Color.White, 1000F, 0.0F, Color.red); Chart.SetTitle (New TextTitle (Title, New Font ("Lishu", Font.italic, 15) ))); Font font = new font ("black body", font.tribype_font, 12);

StandardLegend Legend = (StandardLegend) Chart.getlegend (); Legend.SetItemFont (font);

CategoryPlot Plot = (categoryPlot) Chart.getPlot (); plot.setforeghroundalpha (0.9f);

Categoryaxis domain_axis = plot.getdomainaxis (); domain_axis.settickLabelfont (font);

Valueaxis value_axis = plot.getRangeaxis (); value_axis.settickLabelfont (font);

转载请注明原文地址:https://www.9cbs.com/read-83587.html

New Post(0)