JFreeChart 보고서 구현 계기판
6714 단어 데이터 구조UI프레임jfreechartF#
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Point;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.dial.DialBackground;
import org.jfree.chart.plot.dial.DialCap;
import org.jfree.chart.plot.dial.DialPlot;
import org.jfree.chart.plot.dial.DialTextAnnotation;
import org.jfree.chart.plot.dial.DialValueIndicator;
import org.jfree.chart.plot.dial.StandardDialFrame;
import org.jfree.chart.plot.dial.StandardDialScale;
import org.jfree.chart.plot.dial.DialPointer.Pin;
import org.jfree.chart.plot.dial.DialPointer.Pointer;
import org.jfree.data.general.DefaultValueDataset;
import org.jfree.ui.GradientPaintTransformType;
import org.jfree.ui.RefineryUtilities;
import org.jfree.ui.StandardGradientPaintTransformer;
/**
*
*
* @author Administrator
*
*/
public class DialDemo3 {
public static void main(String[] args) {
// 1, DefaultValueDataset
DefaultValueDataset dataset = new DefaultValueDataset();
// , :
dataset.setValue(10D);
DefaultValueDataset dataset2 = new DefaultValueDataset();
dataset2.setValue(20D);
/**
*
*
* A. setDataSet(int index, DataSet dataSet);
* , , 。 。
*/
DialPlot dialplot = new DialPlot();
dialplot.setView(0.0D, 0.0D, 1.0D, 1.0D);
dialplot.setDataset(0, dataset);
dialplot.setDataset(1, dataset2);
// System.out.println("dataset count:"+dialplot.getDatasetCount());
/**
* B. setDailFrame(DailFrame dailFrame);
* , 。
*/
StandardDialFrame dialFrame = new StandardDialFrame();
dialFrame.setBackgroundPaint(Color.lightGray);
dialFrame.setForegroundPaint(Color.darkGray);
dialplot.setDialFrame(dialFrame);
/**
* C. setBackground(Color color);
* , Java 。
*/
GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(
255, 255, 255), new Point(), new Color(170, 170, 220));
DialBackground dialbackground = new DialBackground(gradientpaint);
dialbackground
.setGradientPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.VERTICAL));
dialplot.setBackground(dialbackground);
//
DialTextAnnotation dialtextannotation = new DialTextAnnotation("km/h");
dialtextannotation.setFont(new Font("Dialog", 1, 14));
dialtextannotation.setRadius(0.69999999999999996D);
dialplot.addLayer(dialtextannotation);
/**
* , ,
* DialValueIndicator dialvalueindicator = new DialValueIndicator(0);
* dialplot.addLayer(dialvalueindicator);
*/
DialValueIndicator dvi = new DialValueIndicator(0);
dvi.setFont(new Font("Dialog", Font.PLAIN, 10));
dvi.setOutlinePaint(Color.darkGray);
dvi.setRadius(0.60);
dvi.setAngle(-103.0);
dialplot.addLayer(dvi);
DialValueIndicator dvi2 = new DialValueIndicator(1);
dvi2.setFont(new Font("Dialog", Font.PLAIN, 10));
dvi2.setOutlinePaint(Color.red);
dvi2.setRadius(0.60);
dvi2.setAngle(-77.0);
dialplot.addLayer(dvi2);
// (0.75),
/**
* F. addScale(int index, DailScale dailScale);
* ,index , DailScale , 。
*
* StandardDialScale(double lowerBound, double upperBound, double
* startAngle, double extent, double majorTickIncrement, int
* minorTickCount) new StandardDialScale(-40D, 60D, -120D, -300D,30D);
*/
// pointer
StandardDialScale dialScale1 = new StandardDialScale();
dialScale1.setLowerBound(-40D); //
dialScale1.setUpperBound(60D); //
dialScale1.setStartAngle(-120D); // 120,
dialScale1.setExtent(-300D); // 300,
dialScale1.setTickRadius(0.88D); // ,
dialScale1.setTickLabelOffset(0.14999999999999999D); // , 0
// .14999999999999999D
dialScale1.setTickLabelFont(new Font("Dialog", 0, 14)); //
dialplot.addScale(0, dialScale1);
// pin
StandardDialScale dialScale2 = new StandardDialScale();
dialScale2.setLowerBound(0D);
dialScale2.setUpperBound(100D);
dialScale2.setStartAngle(-120D);
dialScale2.setExtent(-300D);
dialScale2.setTickRadius(0.52D);
dialScale2.setTickLabelOffset(0.1D);
dialScale2.setTickLabelFont(new Font("Dialog", 0, 10)); //
//dialScale2.setTickLabelPaint(new Color(255,0,0)); //
dialScale2.setMinorTickPaint(new Color(255,0,0)); // red
dialScale2.setMajorTickPaint(new Color(255,0,0)); // red
dialplot.addScale(1, dialScale2);
/**
* G. addPointer(DailPointer dailPointer);
* ,JFreeChart ,
* , DailPoint
*/
//
Pointer pointer = new Pointer(0); //
dialplot.addPointer(pointer); // addLayer(pointer);
dialplot.mapDatasetToScale(0, 0); //Scale Dataset
//
Pin pin = new Pin(1);
pin.setPaint(new GradientPaint(new Point(), new Color(255, 0, 0),
new Point(), new Color(170, 170, 220))); //
pin.setRadius(0.50); // ,
dialplot.addPointer(pin);
dialplot.mapDatasetToScale(1, 1); //Scale Dataset
/**
* DialCap H. setCap(DailCap dailCap); 1, 。 2,
*/
DialCap dialcap = new DialCap();
dialcap.setRadius(0.0700000000000001D);// 0.10000000000000001D
dialplot.setCap(dialcap);
// chart
JFreeChart jfreechart = new JFreeChart(dialplot);
//
jfreechart.setTitle(" ");
ChartFrame frame = new ChartFrame(" ", jfreechart,
true);
frame.pack();
//
RefineryUtilities.centerFrameOnScreen(frame);
frame.setVisible(true);
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
정수 반전Udemy 에서 공부 한 것을 중얼거린다 Chapter3【Integer Reversal】 (예) 문자열로 숫자를 반전 (toString, split, reverse, join) 인수의 수치 (n)가 0보다 위 또는 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.