<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Kimi's NutShell

    我荒廢的今日,正是昨日殞身之人祈求的明日

    BlogJava 新隨筆 管理
      141 Posts :: 0 Stories :: 75 Comments :: 0 Trackbacks

    package com.primesuccess.portal.chart;

    import com.primesuccess.portal.chartAttTemplate.LineAttTemplate;
    import com.primesuccess.portal.util.JSFUtils;

    import java.awt.Color;
    import java.awt.Font;
    import java.awt.RenderingHints;

    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.PrintWriter;

    import java.io.Writer;

    import java.text.NumberFormat;

    import javax.faces.context.FacesContext;

    import javax.faces.context.ResponseStream;

    import java.io.OutputStream;

    import java.util.Hashtable;

    import javax.servlet.http.HttpServletResponse;

    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartRenderingInfo;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.entity.StandardEntityCollection;
    import org.jfree.chart.imagemap.ImageMapUtilities;
    import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
    import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.DatasetRenderingOrder;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.renderer.category.LineAndShapeRenderer;
    import org.jfree.chart.servlet.ServletUtilities;
    import org.jfree.chart.title.TextTitle;
    import org.jfree.chart.urls.StandardCategoryURLGenerator;
    import org.jfree.data.category.CategoryDataset;


    public class LineBean {


    ??? CategoryDataset data;
    ??? LineAttTemplate att;


    ??? public LineBean(CategoryDataset data, LineAttTemplate att) {
    ??????? this.data = data;
    ??????? this.att = att;
    ??? }


    ??? static class LabelGenerator extends StandardCategoryItemLabelGenerator {

    ??????? public String generateItemLabel(CategoryDataset categorydataset, int i,
    ??????????????????????????????????????? int j) {
    ??????????? return categorydataset.getRowKey(i).toString();
    ??????? }

    ??????? LabelGenerator() {
    ??????????? super();
    ??????? }
    ??? }
    ???
    ??? static class StandardCategoryURLGeneratorEx extends StandardCategoryURLGenerator {
    ??? String prefix="aa.jspx";

    ??????? public String generateURL(CategoryDataset dataset, int series,
    ????????????????????????????? int category) {
    ??????????????????
    ??????????????????????????? return "#\""+" onclick=\"javascript:window.open('"+ super.generateURL(dataset,series,category)+"','newwindow','height=100,width=400')";
    ???????
    ??????? }
    //??????? public String getTargeURL(){
    //??????????? return
    //??????? }

    ??????? StandardCategoryURLGeneratorEx(String targeturl) {
    ??????????? super(targeturl);
    ??????? }
    ??? }

    ??? private JFreeChart createChart(String targetUrl) {
    ??????? JFreeChart jfreechart =
    ??????????? ChartFactory.createLineChart("", att.getDomaindesc(),
    ???????????????????????????????????????? att.getRangedesc(), data,
    ???????????????????????????????????????? PlotOrientation.VERTICAL, true, true,
    ???????????????????????????????????????? false);
    ??????? jfreechart.setBackgroundPaint(Color.white);
    ??????? CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
    ??????? categoryplot.setBackgroundPaint(att.getBackgroudpaint());
    ??????? categoryplot.setDomainAxisLocation(att.getDomainaxisloc());
    ??????? categoryplot.getDomainAxis().setTickLabelFont( new Font("Arial", Font.PLAIN, 8) );
    ??????? categoryplot.mapDatasetToRangeAxis(1, 1);
    ???????
    ??????? LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    ??????? if (targetUrl != null && !targetUrl.trim().equals("")) {
    ???????????
    ??????????? lineandshaperenderer.setItemURLGenerator(new StandardCategoryURLGeneratorEx(targetUrl));
    ?????????
    ??????? }
    ??????? Hashtable hash=att.getSeriesitemlabelfont();
    ??????? for(int i=0;i<att.getSeries_count();i++){
    ??????????? lineandshaperenderer.setSeriesItemLabelFont(i,(Font)hash.get(i),true);
    ??????? }
    ??????? lineandshaperenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    ??????? lineandshaperenderer.setItemLabelGenerator(new LabelGenerator());
    ??????? lineandshaperenderer.setShapesFilled(att.isShapesfilled());
    ??????? lineandshaperenderer.setShapesVisible(att.isShapesvisible());
    ??????? categoryplot.setRenderer(lineandshaperenderer);
    ??????? categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    ??????? jfreechart.setTitle(new TextTitle(att.getTitle(),
    ????????????????????????????????????????? new Font("Arial", Font.BOLD, 15)));
    ??????? jfreechart.setAntiAlias(false);
    ??????? jfreechart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,
    ?????????????????????????????????????????? RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    ??????? return jfreechart;
    ??? }

    ??? public String generateChart(String targetURL, PrintWriter pw, int w,
    ??????????????????????????????? int h) {
    ??????? JFreeChart chart = createChart(targetURL);
    ??????? ChartRenderingInfo info =
    ??????????? new ChartRenderingInfo(new StandardEntityCollection());
    ??????? String filename = new String();
    ??????? try {
    ??????????? filename =
    ??????????????????? ServletUtilities.saveChartAsPNG(chart, w, h, info, JSFUtils.getSession());

    ??????????? ImageMapUtilities.writeImageMap(pw, filename, info);
    ??????????? pw.flush();
    ??????? } catch (Exception e) {
    ??????????? e.printStackTrace();
    ??????????? filename = "public_error_500x300.png";
    ??????? }
    ??????? return filename;
    ??? }

    ??? public String[] getLastURLandFilename() throws IOException {
    ??????? HttpServletResponse resp =
    ??????????? (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
    ??????
    ??????? String filenames =
    ??????????? generateChart(att.getItemurl(), new PrintWriter((OutputStream)resp.getOutputStream()),
    ????????????????????????? att.getWidth(), att.getHeight());
    ??????? return new String[] { "/servlet/DisplayChart?filename=" + filenames,
    ????????????????????????????? filenames };
    ??? }


    }

    ?

    posted on 2006-04-30 16:45 Kimi 閱讀(403) 評論(0)  編輯  收藏 所屬分類: Java
    主站蜘蛛池模板: 亚洲毛片一级带毛片基地| 最近2019中文字幕免费看最新| 一区二区三区免费看| 精品久久久久久亚洲中文字幕 | 久久午夜免费视频| 最近免费最新高清中文字幕韩国 | 一区二区视频在线免费观看| 特黄特色的大片观看免费视频| 一级特黄a大片免费| 久久99久久成人免费播放| a级毛片免费高清视频| 成人一区二区免费视频| www一区二区www免费| 日本免费A级毛一片| 一级毛片在线观看免费| 91香焦国产线观看看免费| 131美女爱做免费毛片| 999在线视频精品免费播放观看| 9久9久女女免费精品视频在线观看| 人妻视频一区二区三区免费| 免费观看的a级毛片的网站| 日本高清免费不卡在线| 亚洲 另类 无码 在线| 在线精品亚洲一区二区小说| 久久亚洲精品成人综合| 亚洲另类春色校园小说| 亚洲最大无码中文字幕| 国产亚洲日韩在线a不卡| 国产区在线免费观看| 久操免费在线观看| 国拍在线精品视频免费观看| 日本免费v片一二三区| 国产av无码专区亚洲av果冻传媒| 亚洲成a人片在线观看中文动漫 | 在线亚洲人成电影网站色www| 亚洲午夜精品一区二区| 亚洲中文精品久久久久久不卡| 日本黄页网址在线看免费不卡| 三年片在线观看免费| 永久免费毛片在线播放| 免费人成网站7777视频|