Search in sources :

Example 21 with RectangleInsets

use of org.jfree.ui.RectangleInsets in project series-rest-api by 52North.

the class ChartIoHandler method addNotice.

private void addNotice(JFreeChart chart) {
    TextTitle notice = new TextTitle();
    String msg = i18n.get("msg.io.chart.notice");
    if (msg != null && !msg.isEmpty()) {
        notice.setText(msg);
        notice.setPaint(Color.BLACK);
        notice.setFont(LabelConstants.FONT_LABEL_SMALL);
        notice.setPosition(RectangleEdge.BOTTOM);
        notice.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        notice.setVerticalAlignment(VerticalAlignment.BOTTOM);
        notice.setPadding(new RectangleInsets(0, 0, 20, 20));
        chart.addSubtitle(notice);
    }
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 22 with RectangleInsets

use of org.jfree.ui.RectangleInsets in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createBarChart.

/**
	 * Create a bar chart instance.
	 * 
	 * @return a bar chart instance
	 */
private JFreeChart createBarChart() {
    bardataset = new DefaultCategoryDataset();
    if (valueMap != null) {
        for (String key : valueMap.keySet()) {
            bardataset.addValue(0D, key, "");
        }
    }
    bardataset.addValue(barMax, "100", "");
    JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", bardataset, PlotOrientation.VERTICAL, false, false, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    chart.setBackgroundPaint(Color.BLACK);
    //plot
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setOutlineVisible(false);
    RectangleInsets rectangleInsets = new RectangleInsets();
    categoryplot.setAxisOffset(rectangleInsets);
    categoryplot.setBackgroundPaint(Color.BLACK);
    categoryplot.setDomainGridlinesVisible(false);
    categoryplot.setRangeGridlinesVisible(false);
    //renderer
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer(0);
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setMaximumBarWidth(0.6);
    stackedbarrenderer.setItemMargin(0);
    //painter
    StandardBarPainter painter = new StandardBarPainter() {

        private static final long serialVersionUID = -3124115075260902181L;

        public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) {
            Paint itemPaint = renderer.getItemPaint(row, column);
            GradientPaintTransformer t = renderer.getGradientPaintTransformer();
            if (t != null && itemPaint instanceof GradientPaint) {
                itemPaint = t.transform((GradientPaint) itemPaint, bar);
            }
            g2.setPaint(itemPaint);
            double height = bar.getHeight();
            double width = bar.getWidth();
            double x = bar.getBounds2D().getX();
            double y = bar.getBounds2D().getY();
            int barNumber = (int) (height / 2 + 0.5);
            if (height < 1 && height > 0.5) {
                barNumber = 1;
            }
            for (int i = 0; i < barNumber; i++) {
                RectangularShape subBarLeft = new Rectangle2D.Double(x, y, width / 2, 0.8);
                g2.fill(subBarLeft);
                RectangularShape subBarRight = new Rectangle2D.Double(x + width / 2 + 1, y, width / 2, 0.8);
                g2.fill(subBarRight);
                y += 2;
            }
            if (renderer.isDrawBarOutline()) {
                Stroke stroke = renderer.getItemOutlineStroke(row, column);
                Paint paint = renderer.getItemOutlinePaint(row, column);
                if (stroke != null && paint != null) {
                    g2.setStroke(stroke);
                    g2.setPaint(paint);
                    g2.draw(bar);
                }
            }
        }
    };
    stackedbarrenderer.setBarPainter(painter);
    stackedbarrenderer.setSeriesPaint(0, Color.GREEN);
    stackedbarrenderer.setSeriesPaint(1, Color.RED);
    int backPaintOrder = 1;
    if (valueMap != null) {
        backPaintOrder = valueMap.size();
    }
    stackedbarrenderer.setSeriesPaint(backPaintOrder, new Color(136, 200, 135));
    stackedbarrenderer.setShadowVisible(false);
    stackedbarrenderer.setDrawBarOutline(false);
    //categoryAxis
    categoryAxis = categoryplot.getDomainAxis();
    categoryAxis.setAxisLineVisible(false);
    //	categoryAxis.setCategoryMargin(0);
    categoryAxis.setMinorTickMarksVisible(false);
    categoryAxis.setTickLabelsVisible(false);
    categoryAxis.setTickMarksVisible(false);
    categoryAxis.setLabelPaint(Color.GREEN);
    categoryAxis.setLabelFont(new Font("", 0, 10));
    //valueAxis
    ValueAxis valueAxis = categoryplot.getRangeAxis();
    valueAxis.setVisible(false);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) GradientPaintTransformer(org.jfree.ui.GradientPaintTransformer) Color(java.awt.Color) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Font(java.awt.Font) Graphics2D(java.awt.Graphics2D) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) ValueAxis(org.jfree.chart.axis.ValueAxis) RectangularShape(java.awt.geom.RectangularShape) RectangleInsets(org.jfree.ui.RectangleInsets) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 23 with RectangleInsets

use of org.jfree.ui.RectangleInsets in project cubrid-manager by CUBRID.

the class ChartCompositePart method createChart.

/**
	 * Create the chart
	 *
	 * @return the instance of JFreeChart
	 */
private JFreeChart createChart() {
    timeseriescollection = new TimeSeriesCollection();
    seriesMap = new TreeMap<String, TimeSeries>();
    xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    int number = 0;
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        TimeSeries series = new TimeSeries(key);
        seriesMap.put(key, series);
        if (settingMap.get(key).isChecked()) {
            timeseriescollection.addSeries(series);
            RGB seriesRgb = settingMap.get(key).getSeriesRgb();
            float width = settingMap.get(key).getWidth();
            Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
            xylineandshaperenderer.setSeriesPaint(number, color);
            xylineandshaperenderer.setSeriesStroke(number, new BasicStroke(width, 0, 2));
            number++;
        }
    }
    DateAxis dateaxis = new DateAxis("");
    NumberAxis numberaxis = new NumberAxis("");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    RectangleInsets rectangleInsets = new RectangleInsets();
    xyplot.setAxisOffset(rectangleInsets);
    xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
    xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
    xyplot.setOutlineVisible(false);
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
    xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLowerMargin(0.01D);
    numberaxis.setUpperMargin(0.01D);
    JFreeChart chart = new JFreeChart(chartTitle, new Font("SansSerif", 1, 15), xyplot, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor) RGB(org.eclipse.swt.graphics.RGB) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) RectangleInsets(org.jfree.ui.RectangleInsets) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 24 with RectangleInsets

use of org.jfree.ui.RectangleInsets in project cubrid-manager by CUBRID.

the class ReplicationMonitorViewPart method createChart.

/**
	 * Create chart unit
	 * 
	 * @return chart
	 */
private JFreeChart createChart() {
    //create data set
    replTimeSeries = new TimeSeries(Messages.msgDelayValue + "    ");
    replTimeSeries.setMaximumItemAge(2592000);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(replTimeSeries);
    //create X axis
    DateAxis dateaxis = new DateAxis(Messages.msgSlaveTimes);
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    //create Y axis
    NumberAxis numberaxis = new NumberAxis(Messages.msgDelayValue);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //create display model
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, true);
    xylineandshaperenderer.setSeriesPaint(0, new Color(146, 208, 80));
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    //set backcolor of grid
    xyplot.setBackgroundPaint(Color.BLACK);
    //set vertical line color of grid
    xyplot.setDomainGridlinePaint(new Color(130, 130, 130));
    //set horizontal line color of grid
    xyplot.setRangeGridlinePaint(new Color(130, 130, 130));
    xyplot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 10D));
    JFreeChart chart = new JFreeChart(Messages.titlePerformancePart, new Font("SansSerif", 1, 15), xyplot, true);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) RectangleInsets(org.jfree.ui.RectangleInsets) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart)

Example 25 with RectangleInsets

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

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