Search in sources :

Example 26 with RectangleInsets

use of org.jfree.ui.RectangleInsets 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)

Example 27 with RectangleInsets

use of org.jfree.ui.RectangleInsets in project jgnash by ccavanaugh.

the class SecuritiesHistoryDialog method createChart.

private static JFreeChart createChart(final SecurityNode node) {
    Objects.requireNonNull(node);
    final List<SecurityHistoryNode> hNodes = node.getHistoryNodes();
    final Date max = DateUtils.asDate(hNodes.get(hNodes.size() - 1).getLocalDate());
    final Date min = DateUtils.asDate(hNodes.get(0).getLocalDate());
    final DateAxis timeAxis = new DateAxis(null);
    timeAxis.setVisible(false);
    timeAxis.setAutoRange(false);
    timeAxis.setRange(min, max);
    final NumberAxis valueAxis = new NumberAxis(null);
    valueAxis.setAutoRangeIncludesZero(false);
    valueAxis.setVisible(false);
    final XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setBaseToolTipGenerator(new SecurityItemLabelGenerator(node));
    renderer.setOutline(true);
    renderer.setSeriesPaint(0, new Color(225, 247, 223));
    final XYPlot plot = new XYPlot(null, timeAxis, valueAxis, renderer);
    final List<List<SecurityHistoryNode>> groups = node.getHistoryNodeGroupsBySplits();
    for (int i = 0; i < groups.size(); i++) {
        int size = groups.get(i).size();
        Date[] date = new Date[size];
        double[] high = new double[size];
        double[] low = new double[size];
        double[] open = new double[size];
        double[] close = new double[size];
        double[] volume = new double[size];
        for (int j = 0; j < size; j++) {
            final SecurityHistoryNode hNode = groups.get(i).get(j);
            date[j] = DateUtils.asDate(hNode.getLocalDate());
            high[j] = hNode.getAdjustedHigh().doubleValue();
            low[j] = hNode.getAdjustedLow().doubleValue();
            open[j] = hNode.getAdjustedPrice().doubleValue();
            close[j] = hNode.getAdjustedPrice().doubleValue();
            volume[j] = hNode.getVolume();
        }
        final AbstractXYDataset data = new DefaultHighLowDataset(node.getDescription() + i, date, high, low, open, close, volume);
        plot.setDataset(i, data);
    }
    plot.setInsets(new RectangleInsets(1, 1, 1, 1));
    final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) AbstractXYDataset(org.jfree.data.xy.AbstractXYDataset) DefaultHighLowDataset(org.jfree.data.xy.DefaultHighLowDataset) Color(java.awt.Color) Date(java.util.Date) LocalDate(java.time.LocalDate) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) XYPlot(org.jfree.chart.plot.XYPlot) RectangleInsets(org.jfree.ui.RectangleInsets) SecurityHistoryNode(jgnash.engine.SecurityHistoryNode) List(java.util.List)

Example 28 with RectangleInsets

use of org.jfree.ui.RectangleInsets in project dhis2-core by dhis2.

the class DefaultChartService method getMarker.

/**
     * Returns a horizontal line marker for the given x value and label.
     */
private Marker getMarker(Double value, String label) {
    Marker marker = new ValueMarker(value);
    marker.setPaint(Color.BLACK);
    marker.setStroke(new BasicStroke(1.1f));
    marker.setLabel(label);
    marker.setLabelOffset(new RectangleInsets(-10, 50, 0, 0));
    marker.setLabelFont(SUB_TITLE_FONT);
    return marker;
}
Also used : RectangleInsets(org.jfree.ui.RectangleInsets)

Aggregations

RectangleInsets (org.jfree.ui.RectangleInsets)28 JFreeChart (org.jfree.chart.JFreeChart)17 Color (java.awt.Color)10 NumberAxis (org.jfree.chart.axis.NumberAxis)10 CategoryPlot (org.jfree.chart.plot.CategoryPlot)9 XYPlot (org.jfree.chart.plot.XYPlot)9 BasicStroke (java.awt.BasicStroke)8 CategoryAxis (org.jfree.chart.axis.CategoryAxis)8 Font (java.awt.Font)5 Paint (java.awt.Paint)4 File (java.io.File)4 SimpleDateFormat (java.text.SimpleDateFormat)4 DateAxis (org.jfree.chart.axis.DateAxis)4 XYDataset (org.jfree.data.xy.XYDataset)4 ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)3 ColorScheme (org.baderlab.csplugins.enrichmentmap.style.ColorScheme)3 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)3 StandardBarPainter (org.jfree.chart.renderer.category.StandardBarPainter)3 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)3 CategoryDataset (org.jfree.data.category.CategoryDataset)3