Search in sources :

Example 1 with MeterPlot

use of org.jfree.chart.plot.MeterPlot in project adempiere by adempiere.

the class PerformanceIndicator method createChart.

//	getGoal
private JFreeChart createChart() {
    JFreeChart chart = null;
    //	Set Text
    StringBuffer text = new StringBuffer(m_goal.getName());
    if (m_goal.isTarget())
        text.append(": ").append(m_goal.getPercent()).append("%");
    else
        text.append(": ").append(s_format.format(m_goal.getMeasureActual()));
    m_text = text.toString();
    //	ToolTip
    text = new StringBuffer();
    if (m_goal.getDescription() != null)
        text.append(m_goal.getDescription()).append(": ");
    text.append(s_format.format(m_goal.getMeasureActual()));
    if (m_goal.isTarget())
        text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ").append(s_format.format(m_goal.getMeasureTarget()));
    setToolTipText(text.toString());
    //
    //setBackground(m_goal.getColor());
    setForeground(GraphUtil.getForeground(getBackground()));
    //	Performance Line
    int percent = m_goal.getPercent();
    if (//	draw 100% line
    percent > 100)
        m_line = s_width100;
    else
        //	draw Performance Line
        m_line = s_width100 * m_goal.getGoalPerformanceDouble();
    String title = m_text;
    DefaultValueDataset data = new DefaultValueDataset((float) m_goal.getPercent());
    MeterPlot plot = new MeterPlot(data);
    MColorSchema colorSchema = m_goal.getColorSchema();
    int rangeLo = 0;
    int rangeHi = 0;
    for (int i = 1; i <= 4; i++) {
        switch(i) {
            case 1:
                rangeHi = colorSchema.getMark1Percent();
                break;
            case 2:
                rangeHi = colorSchema.getMark2Percent();
                break;
            case 3:
                rangeHi = colorSchema.getMark3Percent();
                break;
            case 4:
                rangeHi = colorSchema.getMark4Percent();
                break;
        }
        if (rangeHi == 9999)
            rangeHi = (int) Math.floor(rangeLo * 1.5);
        if (rangeLo < rangeHi) {
            plot.addInterval(new //label
            MeterInterval(//label
            "Normal", //range
            new Range(rangeLo, rangeHi), colorSchema.getColor(rangeHi), new BasicStroke(7.0f), //Color.lightGray
            new Color(-13091716)));
            rangeLo = rangeHi;
        }
    }
    plot.setRange(new Range(0, rangeLo));
    //Color.GRAY);
    plot.setDialBackgroundPaint(new Color(-13091716));
    plot.setUnits(m_goal.getName());
    //CIRCLE);        
    plot.setDialShape(DialShape.CHORD);
    //plot.setDialBackgroundPaint(new GradientPaint(0, 0, m_goal.getColor(), 0, 1000, Color.black));
    plot.setNeedlePaint(Color.white);
    plot.setTickSize(2000);
    plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 12));
    plot.setTickLabelPaint(Color.white);
    plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 15), plot, false);
    return chart;
}
Also used : DefaultValueDataset(org.jfree.data.general.DefaultValueDataset) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Range(org.jfree.data.Range) JFreeChart(org.jfree.chart.JFreeChart) MeterPlot(org.jfree.chart.plot.MeterPlot) Font(java.awt.Font) MColorSchema(org.compiere.model.MColorSchema) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 2 with MeterPlot

use of org.jfree.chart.plot.MeterPlot in project adempiere by adempiere.

the class WPerformanceIndicator method createChart.

//	getGoal
private JFreeChart createChart() {
    JFreeChart chart = null;
    //	Set Text
    StringBuffer text = new StringBuffer(m_goal.getName());
    if (m_goal.isTarget())
        text.append(": ").append(m_goal.getPercent()).append("%");
    else
        text.append(": ").append(s_format.format(m_goal.getMeasureActual()));
    m_text = text.toString();
    //	ToolTip
    text = new StringBuffer();
    if (m_goal.getDescription() != null)
        text.append(m_goal.getDescription()).append(": ");
    text.append(s_format.format(m_goal.getMeasureActual()));
    if (m_goal.isTarget())
        text.append(" ").append(Msg.getMsg(Env.getCtx(), "of")).append(" ").append(s_format.format(m_goal.getMeasureTarget()));
    setTooltiptext(text.toString());
    //
    DefaultValueDataset data = new DefaultValueDataset((float) m_goal.getPercent());
    MeterPlot plot = new MeterPlot(data);
    MColorSchema colorSchema = m_goal.getColorSchema();
    int rangeLo = 0;
    int rangeHi = 0;
    for (int i = 1; i <= 4; i++) {
        switch(i) {
            case 1:
                rangeHi = colorSchema.getMark1Percent();
                break;
            case 2:
                rangeHi = colorSchema.getMark2Percent();
                break;
            case 3:
                rangeHi = colorSchema.getMark3Percent();
                break;
            case 4:
                rangeHi = colorSchema.getMark4Percent();
                break;
        }
        if (rangeHi == 9999)
            rangeHi = (int) Math.floor(rangeLo * 1.5);
        if (rangeLo < rangeHi) {
            plot.addInterval(new //label
            MeterInterval(//label
            "Normal", //range
            new Range(rangeLo, rangeHi), colorSchema.getColor(rangeHi), new BasicStroke(7.0f), null));
            rangeLo = rangeHi;
        }
    }
    plot.setRange(new Range(0, rangeLo));
    // new Color(-13091716)
    plot.setDialBackgroundPaint(null);
    plot.setUnits("");
    //CIRCLE);
    plot.setDialShape(DialShape.CHORD);
    plot.setDialOutlinePaint(Color.GRAY);
    plot.setNeedlePaint(Color.BLACK);
    plot.setTickSize(2000);
    plot.setTickPaint(Color.DARK_GRAY);
    plot.setTickLabelFont(new Font("SansSerif", Font.BOLD, 8));
    plot.setTickLabelPaint(Color.DARK_GRAY);
    plot.setValueFont(new Font("SansSerif", Font.BOLD, 8));
    plot.setValuePaint(Color.BLUE);
    plot.setNoDataMessageFont(new Font("SansSerif", Font.BOLD, 8));
    plot.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    chart = new JFreeChart(m_text, new Font("SansSerif", Font.BOLD, 9), plot, false);
    return chart;
}
Also used : DefaultValueDataset(org.jfree.data.general.DefaultValueDataset) BasicStroke(java.awt.BasicStroke) MColorSchema(org.compiere.model.MColorSchema) RectangleInsets(org.jfree.ui.RectangleInsets) Range(org.jfree.data.Range) JFreeChart(org.jfree.chart.JFreeChart) MeterPlot(org.jfree.chart.plot.MeterPlot) Font(java.awt.Font)

Aggregations

BasicStroke (java.awt.BasicStroke)2 Font (java.awt.Font)2 MColorSchema (org.compiere.model.MColorSchema)2 JFreeChart (org.jfree.chart.JFreeChart)2 MeterPlot (org.jfree.chart.plot.MeterPlot)2 Range (org.jfree.data.Range)2 DefaultValueDataset (org.jfree.data.general.DefaultValueDataset)2 RectangleInsets (org.jfree.ui.RectangleInsets)2 Color (java.awt.Color)1