From e8f935a01d75c89ac591a80b9318eac2480e2dcd Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 27 六月 2024 17:40:01 +0800 Subject: [PATCH] 1. 新增走航轨迹融合功能 --- src/main/kotlin/com/flightfeather/uav/common/chart/ChartUtil.kt | 39 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/common/chart/ChartUtil.kt b/src/main/kotlin/com/flightfeather/uav/common/chart/ChartUtil.kt index 4c30e1d..4ce6f08 100644 --- a/src/main/kotlin/com/flightfeather/uav/common/chart/ChartUtil.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/chart/ChartUtil.kt @@ -3,9 +3,16 @@ import org.jfree.chart.ChartFactory import org.jfree.chart.ChartUtils import org.jfree.chart.JFreeChart +import org.jfree.chart.labels.StandardCategoryItemLabelGenerator +import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator +import org.jfree.chart.plot.CategoryPlot +import org.jfree.chart.renderer.category.LineAndShapeRenderer import org.jfree.chart.title.TextTitle import org.jfree.data.category.DefaultCategoryDataset +import java.awt.BasicStroke +import java.awt.Color import java.awt.Font +import java.awt.Paint import java.io.ByteArrayOutputStream /** @@ -19,8 +26,9 @@ fun line(title: String, dataset: DefaultCategoryDataset): JFreeChart { val line = ChartFactory.createLineChart(title, "鏃堕棿", "娴撳害", dataset) - line.categoryPlot.domainAxis.labelFont = Font("瀹嬩綋", Font.PLAIN, 12) - line.categoryPlot.rangeAxis.labelFont = Font("瀹嬩綋", Font.PLAIN, 12) +// line.categoryPlot.domainAxis.labelFont = Font("瀹嬩綋", Font.PLAIN, 12) +// line.categoryPlot.rangeAxis.labelFont = Font("瀹嬩綋", Font.PLAIN, 12) + setLine(line) return line } @@ -41,4 +49,31 @@ } return dataset } + + /** + * 璁剧疆鎶樼嚎鍥炬牱寮� + */ + private fun setLine(chart: JFreeChart) { + chart.legend.itemFont = Font("SimHei", Font.PLAIN, 16) + chart.title.font = Font("SimHei", Font.BOLD, 20) + chart.categoryPlot.apply { + backgroundPaint = Color(255, 255, 255) + rangeGridlinePaint = Color(200, 200, 200) + rangeGridlineStroke = BasicStroke(1f) + isRangeGridlinesVisible = true + } + } + + private fun setRenderer(plot:CategoryPlot, datasetList:List<DefaultCategoryDataset>) { + val renderer = newBasicRenderer(paint = Color(191, 0, 0)) + } + + private fun newBasicRenderer(series:Int = 0, paint:Paint): LineAndShapeRenderer { + return LineAndShapeRenderer().apply { + legendItemLabelGenerator = StandardCategorySeriesLabelGenerator() + setSeriesStroke(series, BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2000f)) + setSeriesShapesVisible(series, false) + setSeriesPaint(series, paint) + } + } } \ No newline at end of file -- Gitblit v1.9.3