<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>代码爬虫 --- Coded  Creeper</title>
    <description>creep  code</description>
    <link>http://biby.javaeye.com</link>
    <language>UTF-8</language>
    <copyright>Copyright 2003-2008, JavaEye.com</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>JavaEye - 做最棒的软件开发交流社区</generator>
      <item>
        <title>感人的歌曲-----化为千风（Do not stand at my grave and weep）</title>
        <author>biby</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://biby.javaeye.com">biby</a>&nbsp;
          链接：<a href="http://biby.javaeye.com/blog/160899" style="color:red;">http://biby.javaeye.com/blog/160899</a>&nbsp;
          发表时间: 2008年02月01日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          第一次听到这首歌，是在2006年的NHK红白歌会中美声男歌手秋川雅史演唱的，配合着中文字幕，听得眼睛都湿润了<img src="/images/smiles/icon_cry.gif"/>，很少有歌曲能够这么感动我。<br />   <br />    歌的来源，是一首英文诗。作者名字及写作时间已经不详，但最有根据的是在1932年，在美国马里兰州巴尔的摩市，一位名为Mary Elizabeth Frye (1905-2004) 的主妇，为了同居友人Margaret Schwarzkopf的母亲过世而写的作品。诗本身并无名字，一般人就以其第一句「Do not stand at my grave and weep」来命名。<br /><br />    诗的原意是纪念逝去的近亲，在95年，英国一名青年在爱尔兰共和军袭击下牺牲，临死前把一封信交给父母，请他们在他离世后打开，信内就是这一首诗，经过传媒的报导后，得到广泛的回响。而到了2001年，美国的911恐怖袭击事件后，在一个追悼仪式中，1名11岁的少女在会中读出此诗，以表达她对在911事件中丧生的父亲的追思，使此诗再一次成为话题。<br /><br />    2003 年，日本小说家兼歌手，「芥川赏」得主新井满，把此诗译为日文版本，并取诗中第三行「I am a thousand winds that blow」的意思，把诗命名为「千の风になって」，再谱上歌曲及唱出，在MAXI SINGLE「千の风になって a thousand winds」上发表。<br /><br />    <br />   <br />化为千风<br />词：不详<br />曲：新井 满<br />演唱者：秋川雅史<br />（译：张桂娥）<br /><br />私のお墓の前で 泣かないでください<br />请不要伫立在我坟前哭泣<br />そこに私はいません 眠ってなんかいません<br />我不在那里 我没有沈睡不醒<br />千の风に 千の风になって<br />化为千风 我已化身为千缕微风<br />あの大きな空を 吹きわたっています<br />翱翔在无限宽广的天空里<br />秋には光になって 畑にふりそそぐ<br />秋天 化身为阳光照射在田地间<br />冬はダイヤのように きらめく雪になる<br />冬天 化身为白雪绽放钻石光芒<br />朝は鸟になって あなたを目覚めさせる<br />晨曦升起时 幻化为飞鸟轻声唤醒你<br />夜は星になって あなたを见守る<br />夜幕低垂时 幻化为星辰温柔守护你<br />私のお墓の前で 泣かないでください<br />请不要伫立在我坟前哭泣<br />そこに私はいません 死んでなんかいません<br />我不在那里 我没有离开人间<br />千の风に 千の风になって<br />化为千风 我已化身为千缕微风<br />あの大きな空を 吹きわたっています<br />翱翔在无限宽广的天空里<br />千の风に 千の风になって<br />化为千风 我已化身为千缕微风<br />あの大きな空を 吹きわたっています<br />翱翔在无限宽广的天空里<br />あの大きな空を 吹きわたっています<br />翱翔在无限宽广的天空里<br /><br />这里有它的英文原诗<br />Do not stand at my grave and weep<br />I am not there; I do not sleep.<br />I am a thousand winds that blow,<br />I am the diamond glints on snow,<br />I am the sun on ripened grain,<br />I am the gentle autumn rain.<br />When you awaken in the morning's hush<br />I am the swift uplifting rush<br />Of quiet birds in circling flight.<br />I am the soft starlight at night.<br />Do not stand at my grave and cry,<br />I am not there; I did not die.
          <br/>
          <span style="color:red;">
            <a href="http://biby.javaeye.com/blog/160899#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li><li><a href='/adverts/97' target='_blank'><span style="color:blue;font-weight:bold;">Oracle专区上线，有Oracle最新文章，重要下载及知识库等精彩内容，欢迎访问。</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 01 Feb 2008 09:26:49 +0800</pubDate>
        <link>http://biby.javaeye.com/blog/160899</link>
        <guid>http://biby.javaeye.com/blog/160899</guid>
      </item>
      <item>
        <title>jfreechart 生成折线图，饼图，柱状图，堆栈柱状图</title>
        <author>biby</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://biby.javaeye.com">biby</a>&nbsp;
          链接：<a href="http://biby.javaeye.com/blog/157328" style="color:red;">http://biby.javaeye.com/blog/157328</a>&nbsp;
          发表时间: 2008年01月18日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          最近公司使用jfreechart来生成统计图，使用了折线图，饼图等，因为用的1.0.8a版的jfreechart,与1.0.0版本的地方有很多不同，而且图片生成清晰度比老版的高，如下是我做的demo.<br /><br />1.所需包<br />(1) jfreechart-1.0.8a.jar<br />(2) jcommon-1.0.12.jar<br />2.运行环境<br />JDK 1.5<br /><br />3.源代码<br /><br />import java.awt.Color;<br />import java.awt.Font;<br />import java.io.File;<br />import java.io.FileOutputStream;<br />import java.text.DecimalFormat;<br />import java.text.NumberFormat;<br /><br />import org.jfree.chart.ChartFactory;<br />import org.jfree.chart.ChartUtilities;<br />import org.jfree.chart.JFreeChart;<br />import org.jfree.chart.axis.CategoryAxis;<br />import org.jfree.chart.axis.CategoryLabelPositions;<br />import org.jfree.chart.axis.NumberAxis;<br />import org.jfree.chart.axis.ValueAxis;<br />import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;<br />import org.jfree.chart.labels.StandardPieSectionLabelGenerator;<br />import org.jfree.chart.plot.CategoryPlot;<br />import org.jfree.chart.plot.PiePlot3D;<br />import org.jfree.chart.plot.PlotOrientation;<br />import org.jfree.chart.renderer.category.BarRenderer;<br />import org.jfree.chart.renderer.category.LineAndShapeRenderer;<br />import org.jfree.chart.renderer.category.StackedBarRenderer;<br />import org.jfree.chart.title.TextTitle;<br />import org.jfree.data.category.CategoryDataset;<br />import org.jfree.data.general.DatasetUtilities;<br />import org.jfree.data.general.DefaultPieDataset;<br />import org.jfree.data.general.PieDataset;<br /><br />/**<br /> * 实际取色的时候一定要16位的，这样比较准确<br /> * <br /> * @author new<br /> */<br />public class CreateChartServiceImpl<br />{<br />	private static final String CHART_PATH = "E:/test/";<br /><br />	public static void main(String[] args)<br />	{<br />		// TODO Auto-generated method stub<br />		CreateChartServiceImpl pm = new CreateChartServiceImpl();<br />		// 生成饼状图<br />		pm.makePieChart();<br />		// 生成单组柱状图<br />		pm.makeBarChart();<br />		// 生成多组柱状图<br />		pm.makeBarGroupChart();<br />		// 生成堆积柱状图<br />		pm.makeStackedBarChart();<br />		// 生成折线图<br />		pm.makeLineAndShapeChart();<br />	}<br /><br />	/**<br />	 * 生成折线图<br />	 */<br />	public void makeLineAndShapeChart()<br />	{<br />		double[][] data = new double[][]<br />		{<br />		{ 672, 766, 223, 540, 126 },<br />		{ 325, 521, 210, 340, 106 },<br />		{ 332, 256, 523, 240, 526 } };<br />		String[] rowKeys =<br />		{ "苹果", "梨子", "葡萄" };<br />		String[] columnKeys =<br />		{ "北京", "上海", "广州", "成都", "深圳" };<br />		CategoryDataset dataset = getBarData(data, rowKeys, columnKeys);<br />		createTimeXYChar("折线图", "x轴", "y轴", dataset, "lineAndShap.png");<br />	}<br /><br />	/**<br />	 * 生成分组的柱状图<br />	 */<br />	public void makeBarGroupChart()<br />	{<br />		double[][] data = new double[][]<br />		{<br />		{ 672, 766, 223, 540, 126 },<br />		{ 325, 521, 210, 340, 106 },<br />		{ 332, 256, 523, 240, 526 } };<br />		String[] rowKeys =<br />		{ "苹果", "梨子", "葡萄" };<br />		String[] columnKeys =<br />		{ "北京", "上海", "广州", "成都", "深圳" };<br />		CategoryDataset dataset = getBarData(data, rowKeys, columnKeys);<br />		createBarChart(dataset, "x坐标", "y坐标", "柱状图", "barGroup.png");<br />	}<br /><br />	/**<br />	 * 生成柱状图<br />	 */<br />	public void makeBarChart()<br />	{<br />		double[][] data = new double[][]<br />		{<br />		{ 672, 766, 223, 540, 126 } };<br />		String[] rowKeys =<br />		{ "苹果" };<br />		String[] columnKeys =<br />		{ "北京", "上海", "广州", "成都", "深圳" };<br />		CategoryDataset dataset = getBarData(data, rowKeys, columnKeys);<br />		createBarChart(dataset, "x坐标", "y坐标", "柱状图", "bar.png");<br />	}<br /><br />	/**<br />	 * 生成堆栈柱状图<br />	 */<br />	public void makeStackedBarChart()<br />	{<br />		double[][] data = new double[][]<br />		{<br />		{ 0.21, 0.66, 0.23, 0.40, 0.26 },<br />		{ 0.25, 0.21, 0.10, 0.40, 0.16 } };<br />		String[] rowKeys =<br />		{ "苹果", "梨子" };<br />		String[] columnKeys =<br />		{ "北京", "上海", "广州", "成都", "深圳" };<br />		CategoryDataset dataset = getBarData(data, rowKeys, columnKeys);<br />		createStackedBarChart(dataset, "x坐标", "y坐标", "柱状图", "stsckedBar.png");<br />	}<br /><br />	/**<br />	 * 生成饼状图<br />	 */<br />	public void makePieChart()<br />	{<br />		double[] data =<br />		{ 9, 91 };<br />		String[] keys =<br />		{ "失败率", "成功率" };<br /><br />		createValidityComparePimChar(getDataPieSetByUtil(data, keys), "饼状图",<br />		        "pie2.png", keys);<br />	}<br /><br />	// 柱状图,折线图 数据集<br />	public CategoryDataset getBarData(double[][] data, String[] rowKeys,<br />	        String[] columnKeys)<br />	{<br />		return DatasetUtilities<br />		        .createCategoryDataset(rowKeys, columnKeys, data);<br /><br />	}<br /><br />	// 饼状图 数据集<br />	public PieDataset getDataPieSetByUtil(double[] data,<br />	        String[] datadescription)<br />	{<br /><br />		if (data != null && datadescription != null)<br />		{<br />			if (data.length == datadescription.length)<br />			{<br />				DefaultPieDataset dataset = new DefaultPieDataset();<br />				for (int i = 0; i &lt; data.length; i++)<br />				{<br />					dataset.setValue(datadescription[i], data[i]);<br />				}<br />				return dataset;<br />			}<br /><br />		}<br /><br />		return null;<br />	}<br /><br />	/**<br />	 * 柱状图<br />	 * <br />	 *@param dataset 数据集<br />	 * @param xName x轴的说明（如种类，时间等）<br />	 * @param yName y轴的说明（如速度，时间等）<br />	 * @param chartTitle 图标题<br />	 * @param charName 生成图片的名字<br />	 * @return<br />	 */<br />	public String createBarChart(CategoryDataset dataset, String xName,<br />	        String yName, String chartTitle, String charName)<br />	{<br />		JFreeChart chart = ChartFactory.createBarChart(chartTitle, // 图表标题<br />		        xName, // 目录轴的显示标签<br />		        yName, // 数值轴的显示标签<br />		        dataset, // 数据集<br />		        PlotOrientation.VERTICAL, // 图表方向：水平、垂直<br />		        true, // 是否显示图例(对于简单的柱状图必须是false)<br />		        false, // 是否生成工具<br />		        false // 是否生成URL链接<br />		        );<br />		Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 12);<br />		/*<br />		 * VALUE_TEXT_ANTIALIAS_OFF表示将文字的抗锯齿关闭,<br />		 * 使用的关闭抗锯齿后，字体尽量选择12到14号的宋体字,这样文字最清晰好看<br />		 */<br />		// chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);<br />		chart.setTextAntiAlias(false);<br />		chart.setBackgroundPaint(Color.white);<br />		// create plot<br />		CategoryPlot plot = chart.getCategoryPlot();<br />		// 设置横虚线可见<br />		plot.setRangeGridlinesVisible(true);<br />		// 虚线色彩<br />		plot.setRangeGridlinePaint(Color.gray);<br /><br />		// 数据轴精度<br />		NumberAxis vn = (NumberAxis) plot.getRangeAxis();<br />		// vn.setAutoRangeIncludesZero(true);<br />		DecimalFormat df = new DecimalFormat("#0.00");<br />		vn.setNumberFormatOverride(df); // 数据轴数据标签的显示格式<br />		// x轴设置<br />		CategoryAxis domainAxis = plot.getDomainAxis();<br />		domainAxis.setLabelFont(labelFont);// 轴标题<br />		domainAxis.setTickLabelFont(labelFont);// 轴数值<br /><br />		// Lable（Math.PI/3.0）度倾斜<br />		// domainAxis.setCategoryLabelPositions(CategoryLabelPositions<br />		// .createUpRotationLabelPositions(Math.PI / 3.0));<br /><br />		domainAxis.setMaximumCategoryLabelWidthRatio(0.6f);// 横轴上的 Lable 是否完整显示<br /><br />		// 设置距离图片左端距离<br />		domainAxis.setLowerMargin(0.1);<br />		// 设置距离图片右端距离<br />		domainAxis.setUpperMargin(0.1);<br />		// 设置 columnKey 是否间隔显示<br />		// domainAxis.setSkipCategoryLabelsToFit(true);<br /><br />		plot.setDomainAxis(domainAxis);<br />		// 设置柱图背景色（注意，系统取色的时候要使用16位的模式来查看颜色编码，这样比较准确）<br />		plot.setBackgroundPaint(new Color(255, 255, 204));<br /><br />		// y轴设置<br />		ValueAxis rangeAxis = plot.getRangeAxis();<br />		rangeAxis.setLabelFont(labelFont);<br />		rangeAxis.setTickLabelFont(labelFont);<br />		// 设置最高的一个 Item 与图片顶端的距离<br />		rangeAxis.setUpperMargin(0.15);<br />		// 设置最低的一个 Item 与图片底端的距离<br />		rangeAxis.setLowerMargin(0.15);<br />		plot.setRangeAxis(rangeAxis);<br /><br />		BarRenderer renderer = new BarRenderer();<br />		// 设置柱子宽度<br />		renderer.setMaximumBarWidth(0.05);<br />		// 设置柱子高度<br />		renderer.setMinimumBarLength(0.2);<br />		// 设置柱子边框颜色<br />		renderer.setBaseOutlinePaint(Color.BLACK);<br />		// 设置柱子边框可见<br />		renderer.setDrawBarOutline(true);<br /><br />		// // 设置柱的颜色<br />		renderer.setSeriesPaint(0, new Color(204, 255, 255));<br />		renderer.setSeriesPaint(1, new Color(153, 204, 255));<br />		renderer.setSeriesPaint(2, new Color(51, 204, 204));<br /><br />		// 设置每个地区所包含的平行柱的之间距离<br />		renderer.setItemMargin(0.0);<br /><br />		// 显示每个柱的数值，并修改该数值的字体属性<br />		renderer.setIncludeBaseInRange(true);<br />		renderer<br />		        .setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());<br />		renderer.setBaseItemLabelsVisible(true);<br /><br />		plot.setRenderer(renderer);<br />		// 设置柱的透明度<br />		plot.setForegroundAlpha(1.0f);<br /><br />		FileOutputStream fos_jpg = null;<br />		try<br />		{<br />			isChartPathExist(CHART_PATH);<br />			String chartName = CHART_PATH + charName;<br />			fos_jpg = new FileOutputStream(chartName);<br />			ChartUtilities.writeChartAsPNG(fos_jpg, chart, 500, 500, true, 10);<br />			return chartName;<br />		}<br />		catch (Exception e)<br />		{<br />			e.printStackTrace();<br />			return null;<br />		}<br />		finally<br />		{<br />			try<br />			{<br />				fos_jpg.close();<br />			}<br />			catch (Exception e)<br />			{<br />				e.printStackTrace();<br />			}<br />		}<br />	}<br /><br />	/**<br />	 * 横向图<br />	 * <br />	 * @param dataset 数据集<br />	 * @param xName x轴的说明（如种类，时间等）<br />	 * @param yName y轴的说明（如速度，时间等）<br />	 * @param chartTitle 图标题<br />	 * @param charName 生成图片的名字<br />	 * @return<br />	 */<br />	public String createHorizontalBarChart(CategoryDataset dataset,<br />	        String xName, String yName, String chartTitle, String charName)<br />	{<br />		JFreeChart chart = ChartFactory.createBarChart(chartTitle, // 图表标题<br />		        xName, // 目录轴的显示标签<br />		        yName, // 数值轴的显示标签<br />		        dataset, // 数据集<br />		        PlotOrientation.VERTICAL, // 图表方向：水平、垂直<br />		        true, // 是否显示图例(对于简单的柱状图必须是false)<br />		        false, // 是否生成工具<br />		        false // 是否生成URL链接<br />		        );<br /><br />		CategoryPlot plot = chart.getCategoryPlot();<br />		// 数据轴精度<br />		NumberAxis vn = (NumberAxis) plot.getRangeAxis();<br />		//设置刻度必须从0开始<br />		// vn.setAutoRangeIncludesZero(true);<br />		DecimalFormat df = new DecimalFormat("#0.00");<br />		vn.setNumberFormatOverride(df); // 数据轴数据标签的显示格式<br /><br />		CategoryAxis domainAxis = plot.getDomainAxis();<br /><br />		domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 横轴上的<br />		// Lable<br />		Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 12);<br /><br />		domainAxis.setLabelFont(labelFont);// 轴标题<br />		domainAxis.setTickLabelFont(labelFont);// 轴数值<br /><br />		domainAxis.setMaximumCategoryLabelWidthRatio(0.8f);// 横轴上的 Lable 是否完整显示<br />		// domainAxis.setVerticalCategoryLabels(false);<br />		plot.setDomainAxis(domainAxis);<br /><br />		ValueAxis rangeAxis = plot.getRangeAxis();<br />		// 设置最高的一个 Item 与图片顶端的距离<br />		rangeAxis.setUpperMargin(0.15);<br />		// 设置最低的一个 Item 与图片底端的距离<br />		rangeAxis.setLowerMargin(0.15);<br />		plot.setRangeAxis(rangeAxis);<br />		BarRenderer renderer = new BarRenderer();<br />		// 设置柱子宽度<br />		renderer.setMaximumBarWidth(0.03);<br />		// 设置柱子高度<br />		renderer.setMinimumBarLength(30);<br /><br />		renderer.setBaseOutlinePaint(Color.BLACK);<br /><br />		// 设置柱的颜色<br />		renderer.setSeriesPaint(0, Color.GREEN);<br />		renderer.setSeriesPaint(1, new Color(0, 0, 255));<br />		// 设置每个地区所包含的平行柱的之间距离<br />		renderer.setItemMargin(0.5);<br />		// 显示每个柱的数值，并修改该数值的字体属性<br />		renderer<br />		        .setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());<br />		// 设置柱的数值可见<br />		renderer.setBaseItemLabelsVisible(true);<br /><br />		plot.setRenderer(renderer);<br />		// 设置柱的透明度<br />		plot.setForegroundAlpha(0.6f);<br /><br />		FileOutputStream fos_jpg = null;<br />		try<br />		{<br />			isChartPathExist(CHART_PATH);<br />			String chartName = CHART_PATH + charName;<br />			fos_jpg = new FileOutputStream(chartName);<br />			ChartUtilities.writeChartAsPNG(fos_jpg, chart, 500, 500, true, 10);<br />			return chartName;<br />		}<br />		catch (Exception e)<br />		{<br />			e.printStackTrace();<br />			return null;<br />		}<br />		finally<br />		{<br />			try<br />			{<br />				fos_jpg.close();<br />			}<br />			catch (Exception e)<br />			{<br />				e.printStackTrace();<br />			}<br />		}<br />	}<br /><br />	/**<br />	 * 饼状图<br />	 * <br />	 * @param dataset 数据集<br />	 * @param chartTitle 图标题<br />	 * @param charName 生成图的名字<br />	 * @param pieKeys 分饼的名字集<br />	 * @return<br />	 */<br />	public String createValidityComparePimChar(PieDataset dataset,<br />	        String chartTitle, String charName, String[] pieKeys)<br />	{<br />		JFreeChart chart = ChartFactory.createPieChart3D(chartTitle, // chart<br />		        // title<br />		        dataset,// data<br />		        true,// include legend<br />		        true, false);<br /><br />		// 使下说明标签字体清晰,去锯齿类似于<br />		// chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);的效果<br />		chart.setTextAntiAlias(false);<br />		// 图片背景色<br />		chart.setBackgroundPaint(Color.white);<br />		// 设置图标题的字体重新设置title<br />		Font font = new Font("隶书", Font.BOLD, 25);<br />		TextTitle title = new TextTitle(chartTitle);<br />		title.setFont(font);<br />		chart.setTitle(title);<br /><br />		PiePlot3D plot = (PiePlot3D) chart.getPlot();<br />		// 图片中显示百分比:默认方式<br /><br />		// 指定饼图轮廓线的颜色<br />		// plot.setBaseSectionOutlinePaint(Color.BLACK);<br />		// plot.setBaseSectionPaint(Color.BLACK);<br /><br />		// 设置无数据时的信息<br />		plot.setNoDataMessage("无对应的数据，请重新查询。");<br /><br />		// 设置无数据时的信息显示颜色<br />		plot.setNoDataMessagePaint(Color.red);<br /><br />		// 图片中显示百分比:自定义方式，{0} 表示选项， {1} 表示数值， {2} 表示所占比例 ,小数点后两位<br />		plot.setLabelGenerator(new StandardPieSectionLabelGenerator(<br />		        "{0}={1}({2})", NumberFormat.getNumberInstance(),<br />		        new DecimalFormat("0.00%")));<br />		// 图例显示百分比:自定义方式， {0} 表示选项， {1} 表示数值， {2} 表示所占比例<br />		plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(<br />		        "{0}={1}({2})"));<br /><br />		plot.setLabelFont(new Font("SansSerif", Font.TRUETYPE_FONT, 12));<br /><br />		// 指定图片的透明度(0.0-1.0)<br />		plot.setForegroundAlpha(0.65f);<br />		// 指定显示的饼图上圆形(false)还椭圆形(true)<br />		plot.setCircular(false, true);<br /><br />		// 设置第一个 饼块section 的开始位置，默认是12点钟方向<br />		plot.setStartAngle(90);<br /><br />		// // 设置分饼颜色<br />		plot.setSectionPaint(pieKeys[0], new Color(244, 194, 144));<br />		plot.setSectionPaint(pieKeys[1], new Color(144, 233, 144));<br /><br />		FileOutputStream fos_jpg = null;<br />		try<br />		{<br />			// 文件夹不存在则创建<br />			isChartPathExist(CHART_PATH);<br />			String chartName = CHART_PATH + charName;<br />			fos_jpg = new FileOutputStream(chartName);<br />			// 高宽的设置影响椭圆饼图的形状<br />			ChartUtilities.writeChartAsPNG(fos_jpg, chart, 500, 230);<br /><br />			return chartName;<br />		}<br />		catch (Exception e)<br />		{<br />			e.printStackTrace();<br />			return null;<br />		}<br />		finally<br />		{<br />			try<br />			{<br />				fos_jpg.close();<br />				System.out.println("create pie-chart.");<br />			}<br />			catch (Exception e)<br />			{<br />				e.printStackTrace();<br />			}<br />		}<br /><br />	}<br /><br />	/**<br />	 * 判断文件夹是否存在，如果不存在则新建<br />	 * @param chartPath<br />	 */<br />	private void isChartPathExist(String chartPath)<br />	{<br />		File file = new File(chartPath);<br />		if (!file.exists())<br />		{<br />			file.mkdirs();<br />			// log.info("CHART_PATH="+CHART_PATH+"create.");<br />		}<br />	}<br /><br />	/**<br />	 * 折线图<br />	 * <br />	 * @param chartTitle<br />	 * @param x<br />	 * @param y<br />	 * @param xyDataset<br />	 * @param charName<br />	 * @return<br />	 */<br />	public String createTimeXYChar(String chartTitle, String x, String y,<br />	        CategoryDataset xyDataset, String charName)<br />	{<br /><br />		JFreeChart chart = ChartFactory.createLineChart(chartTitle, x, y,<br />		        xyDataset, PlotOrientation.VERTICAL, true, true, false);<br /><br />		chart.setTextAntiAlias(false);<br />		chart.setBackgroundPaint(Color.WHITE);<br />		// 设置图标题的字体重新设置title<br />		Font font = new Font("隶书", Font.BOLD, 25);<br />		TextTitle title = new TextTitle(chartTitle);<br />		title.setFont(font);<br />		chart.setTitle(title);<br />		// 设置面板字体<br />		Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 12);<br /><br />		chart.setBackgroundPaint(Color.WHITE);<br /><br />		CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();<br />		// x轴 // 分类轴网格是否可见<br />		categoryplot.setDomainGridlinesVisible(true);<br />		// y轴 //数据轴网格是否可见<br />		categoryplot.setRangeGridlinesVisible(true);<br /><br />		categoryplot.setRangeGridlinePaint(Color.WHITE);// 虚线色彩<br /><br />		categoryplot.setDomainGridlinePaint(Color.WHITE);// 虚线色彩<br /><br />		categoryplot.setBackgroundPaint(Color.lightGray);<br /><br />		// 设置轴和面板之间的距离<br />		// categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));<br /><br />		CategoryAxis domainAxis = categoryplot.getDomainAxis();<br /><br />		domainAxis.setLabelFont(labelFont);// 轴标题<br />		domainAxis.setTickLabelFont(labelFont);// 轴数值<br /><br />		domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // 横轴上的<br />		// Lable<br />		// 45度倾斜<br />		// 设置距离图片左端距离<br />		domainAxis.setLowerMargin(0.0);<br />		// 设置距离图片右端距离<br />		domainAxis.setUpperMargin(0.0);<br /><br />		NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();<br />		numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());<br />		numberaxis.setAutoRangeIncludesZero(true);<br /><br />		// 获得renderer 注意这里是下嗍造型到lineandshaperenderer！！<br />		LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot<br />		        .getRenderer();<br /><br />		lineandshaperenderer.setBaseShapesVisible(true); // series 点（即数据点）可见<br />		lineandshaperenderer.setBaseLinesVisible(true); // series 点（即数据点）间有连线可见<br /><br />		// 显示折点数据<br />		// lineandshaperenderer.setBaseItemLabelGenerator(new<br />		// StandardCategoryItemLabelGenerator());<br />		// lineandshaperenderer.setBaseItemLabelsVisible(true);<br /><br />		FileOutputStream fos_jpg = null;<br />		try<br />		{<br />			isChartPathExist(CHART_PATH);<br />			String chartName = CHART_PATH + charName;<br />			fos_jpg = new FileOutputStream(chartName);<br /><br />			// 将报表保存为png文件<br />			ChartUtilities.writeChartAsPNG(fos_jpg, chart, 500, 510);<br /><br />			return chartName;<br />		}<br />		catch (Exception e)<br />		{<br />			e.printStackTrace();<br />			return null;<br />		}<br />		finally<br />		{<br />			try<br />			{<br />				fos_jpg.close();<br />				System.out.println("create time-createTimeXYChar.");<br />			}<br />			catch (Exception e)<br />			{<br />				e.printStackTrace();<br />			}<br />		}<br />	}<br /><br />	/**<br />	 * 堆栈柱状图<br />	 * <br />	 * @param dataset<br />	 * @param xName<br />	 * @param yName<br />	 * @param chartTitle<br />	 * @param charName<br />	 * @return<br />	 */<br />	public String createStackedBarChart(CategoryDataset dataset, String xName,<br />	        String yName, String chartTitle, String charName)<br />	{<br />		// 1:得到 CategoryDataset<br /><br />		// 2:JFreeChart对象<br />		JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, // 图表标题<br />		        xName, // 目录轴的显示标签<br />		        yName, // 数值轴的显示标签<br />		        dataset, // 数据集<br />		        PlotOrientation.VERTICAL, // 图表方向：水平、垂直<br />		        true, // 是否显示图例(对于简单的柱状图必须是false)<br />		        false, // 是否生成工具<br />		        false // 是否生成URL链接<br />		        );<br />		// 图例字体清晰<br />		chart.setTextAntiAlias(false);<br /><br />		chart.setBackgroundPaint(Color.WHITE);<br /><br />		// 2 ．2 主标题对象 主标题对象是 TextTitle 类型<br />		chart<br />		        .setTitle(new TextTitle(chartTitle, new Font("隶书", Font.BOLD,<br />		                25)));<br />		// 2 ．2.1:设置中文<br />		// x,y轴坐标字体<br />		Font labelFont = new Font("SansSerif", Font.TRUETYPE_FONT, 12);<br /><br />		// 2 ．3 Plot 对象 Plot 对象是图形的绘制结构对象<br />		CategoryPlot plot = chart.getCategoryPlot();<br /><br />		// 设置横虚线可见<br />		plot.setRangeGridlinesVisible(true);<br />		// 虚线色彩<br />		plot.setRangeGridlinePaint(Color.gray);<br /><br />		// 数据轴精度<br />		NumberAxis vn = (NumberAxis) plot.getRangeAxis();<br />		// 设置最大值是1<br />		vn.setUpperBound(1);<br />		// 设置数据轴坐标从0开始<br />		// vn.setAutoRangeIncludesZero(true);<br />		// 数据显示格式是百分比<br />		DecimalFormat df = new DecimalFormat("0.00%");<br />		vn.setNumberFormatOverride(df); // 数据轴数据标签的显示格式<br />		// DomainAxis （区域轴，相当于 x 轴）， RangeAxis （范围轴，相当于 y 轴）<br />		CategoryAxis domainAxis = plot.getDomainAxis();<br /><br />		domainAxis.setLabelFont(labelFont);// 轴标题<br />		domainAxis.setTickLabelFont(labelFont);// 轴数值<br /><br />		// x轴坐标太长，建议设置倾斜，如下两种方式选其一，两种效果相同<br />		// 倾斜（1）横轴上的 Lable 45度倾斜<br />		// domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);<br />		// 倾斜（2）Lable（Math.PI 3.0）度倾斜<br />		// domainAxis.setCategoryLabelPositions(CategoryLabelPositions<br />		// .createUpRotationLabelPositions(Math.PI / 3.0));<br /><br />		domainAxis.setMaximumCategoryLabelWidthRatio(0.6f);// 横轴上的 Lable 是否完整显示<br /><br />		plot.setDomainAxis(domainAxis);<br /><br />		// y轴设置<br />		ValueAxis rangeAxis = plot.getRangeAxis();<br />		rangeAxis.setLabelFont(labelFont);<br />		rangeAxis.setTickLabelFont(labelFont);<br />		// 设置最高的一个 Item 与图片顶端的距离<br />		rangeAxis.setUpperMargin(0.15);<br />		// 设置最低的一个 Item 与图片底端的距离<br />		rangeAxis.setLowerMargin(0.15);<br />		plot.setRangeAxis(rangeAxis);<br /><br />		// Renderer 对象是图形的绘制单元<br />		StackedBarRenderer renderer = new StackedBarRenderer();<br />		// 设置柱子宽度<br />		renderer.setMaximumBarWidth(0.05);<br />		// 设置柱子高度<br />		renderer.setMinimumBarLength(0.1);<br />        //设置柱的边框颜色<br />		renderer.setBaseOutlinePaint(Color.BLACK);<br />		//设置柱的边框可见<br />		renderer.setDrawBarOutline(true);<br /><br />		// // 设置柱的颜色(可设定也可默认)<br />		renderer.setSeriesPaint(0, new Color(204, 255, 204));<br />		renderer.setSeriesPaint(1, new Color(255, 204, 153));<br /><br />		// 设置每个地区所包含的平行柱的之间距离<br />		renderer.setItemMargin(0.4);<br /><br />		plot.setRenderer(renderer);<br />		// 设置柱的透明度(如果是3D的必须设置才能达到立体效果，如果是2D的设置则使颜色变淡)<br />		// plot.setForegroundAlpha(0.65f);<br /><br />		FileOutputStream fos_jpg = null;<br />		try<br />		{<br />			isChartPathExist(CHART_PATH);<br />			String chartName = CHART_PATH + charName;<br />			fos_jpg = new FileOutputStream(chartName);<br />			ChartUtilities.writeChartAsPNG(fos_jpg, chart, 500, 500, true, 10);<br />			return chartName;<br />		}<br />		catch (Exception e)<br />		{<br />			e.printStackTrace();<br />			return null;<br />		}<br />		finally<br />		{<br />			try<br />			{<br />				fos_jpg.close();<br />			}<br />			catch (Exception e)<br />			{<br />				e.printStackTrace();<br />			}<br />		}<br />	}<br /><br />}
          <br/>
          <span style="color:red;">
            <a href="http://biby.javaeye.com/blog/157328#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/97' target='_blank'><span style="color:blue;font-weight:bold;">Oracle专区上线，有Oracle最新文章，重要下载及知识库等精彩内容，欢迎访问。</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 18 Jan 2008 15:54:17 +0800</pubDate>
        <link>http://biby.javaeye.com/blog/157328</link>
        <guid>http://biby.javaeye.com/blog/157328</guid>
      </item>
      <item>
        <title>iText生成rtf文件简单例子</title>
        <author>biby</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://biby.javaeye.com">biby</a>&nbsp;
          链接：<a href="http://biby.javaeye.com/blog/156131" style="color:red;">http://biby.javaeye.com/blog/156131</a>&nbsp;
          发表时间: 2008年01月15日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          最近研究用java生成word文档，原来打算用poi的，但是在word2003下乱码，因为rtf格式用word也可以打开，itext对这个的支持不错，下面是它的一个简单例子。<br /><strong><br />1.需要的包</strong><br />(1)itext-2.0.4.jar<br />(2)iTextAsian.jar<br /><br /><strong>2.源码</strong><br /><br />import java.awt.Color;<br />import java.io.FileNotFoundException;<br />import java.io.FileOutputStream;<br />import java.io.IOException;<br /><br />import com.lowagie.text.Cell;<br />import com.lowagie.text.Document;<br />import com.lowagie.text.DocumentException;<br />import com.lowagie.text.Element;<br />import com.lowagie.text.Font;<br />import com.lowagie.text.PageSize;<br />import com.lowagie.text.Paragraph;<br />import com.lowagie.text.Table;<br />import com.lowagie.text.pdf.BaseFont;<br />import com.lowagie.text.rtf.RtfWriter2;<br /><br />/**<br /> * @author new<br /> */<br />public class RtfMain<br />{<br />	private static final String FILE_NAME = "e:/itext_rtf.rtf";<br /><br />	/**<br />	 * @param args<br />	 */<br />	public static void main(String[] args)<br />	{<br />		// TODO Auto-generated method stub<br />		try<br />		{<br />			RtfMain rtfMain = new RtfMain();<br />			rtfMain.createRTFContext(FILE_NAME);<br /><br />		}<br />		catch (FileNotFoundException e)<br />		{<br />			// TODO Auto-generated catch block<br />			e.printStackTrace();<br />		}<br />		catch (DocumentException e)<br />		{<br />			// TODO Auto-generated catch block<br />			e.printStackTrace();<br />		}<br />		catch (IOException e)<br />		{<br />			// TODO Auto-generated catch block<br />			e.printStackTrace();<br />		}<br />	}<br /><br />	<br /><br />	public void createRTFContext(String path)throws DocumentException,<br />    IOException<br />	{<br />		Document document = new Document(PageSize.A4);<br />		RtfWriter2.getInstance(document, new FileOutputStream(path));<br />		document.open();<br />		//设置中文字体<br />		BaseFont bfChinese = BaseFont.createFont("STSongStd-Light",<br />		        "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);<br />        //标题字体风格		<br />		Font titleFont= new Font(bfChinese, 12, Font.BOLD);<br />		<br />		//正文字体风格<br />		Font contextFont= new Font(bfChinese, 10, Font.NORMAL);<br />		<br />		Paragraph title = new Paragraph("标题");<br />		//设置标题格式对齐方式<br />		title.setAlignment(Element.ALIGN_CENTER);<br />		title.setFont(titleFont);<br />		document.add(title);<br />		<br />		String contextString = "iText是一个能够快速产生PDF文件的java类库。iText的java类对于那些要产生包含文本，表格，图形的只读文档是很有用的。它的类库尤其与java Servlet有很好的给合。使用iText与PDF能够使你正确的控制Servlet的输出。";<br />		Paragraph context = new Paragraph(contextString);<br />		//正文格式左对齐<br />		context.setAlignment(Element.ALIGN_LEFT);<br />		context.setFont(contextFont);<br />		//离上一段落（标题）空的行数<br />		context.setSpacingBefore(20);<br />		//设置第一行空的列数<br />		context.setFirstLineIndent(20);<br />		<br />		document.add(context);<br />		<br />		// //在表格末尾添加图片<br />		// Image png=Image.getInstance("d:\\duck.jpg");<br />		// document.add(png);<br />	    document.close();<br />	}<br />	<br />}
          <br/>
          <span style="color:red;">
            <a href="http://biby.javaeye.com/blog/156131#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/106' target='_blank'><span style="color:blue;font-weight:bold;">JavaEye问答大赛开始了！ 从6月23日 至 7月6日，奖品丰厚 ！</span></a></li><li><a href='/adverts/97' target='_blank'><span style="color:blue;font-weight:bold;">Oracle专区上线，有Oracle最新文章，重要下载及知识库等精彩内容，欢迎访问。</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/92' target='_blank'><span style="color:red;font-weight:bold;">快来参加7月17日在成都举行的SOA中国技术论坛</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 15 Jan 2008 16:37:12 +0800</pubDate>
        <link>http://biby.javaeye.com/blog/156131</link>
        <guid>http://biby.javaeye.com/blog/156131</guid>
      </item>
  </channel>
</rss>