Example usage for org.jfree.chart.plot.dial StandardDialScale setTickLabelFormatter

List of usage examples for org.jfree.chart.plot.dial StandardDialScale setTickLabelFormatter

Introduction

In this page you can find the example usage for org.jfree.chart.plot.dial StandardDialScale setTickLabelFormatter.

Prototype

public void setTickLabelFormatter(NumberFormat formatter) 

Source Link

Document

Sets the number formatter used to convert the tick label values to strings, and sends a DialLayerChangeEvent to all registered listeners.

Usage

From source file:meter_rpm.Stackoverflow.java

private ChartPanel buildDialPlot(int minimumValue, int maximumValue, int majorTickGap) {

    DialPlot plot = new DialPlot();
    plot.setView(0.0D, 0.0D, 1.0D, 1.0D);
    plot.setDataset(0, dataset0);/*from  w  w w . j  a v  a  2s.com*/
    plot.setDataset(1, dataset1);

    plot.setDialFrame(new StandardDialFrame());

    DialTextAnnotation dialtextannotation = new DialTextAnnotation("RPM");
    dialtextannotation.setFont(new Font("Dialog", 1, 12));
    dialtextannotation.setRadius(0.69999999999999996D);
    plot.addLayer(dialtextannotation);

    // value indicator uses the real data set
    //plot.addLayer(new DialValueIndicator(0));

    DialValueIndicator dialvalueindicator = new DialValueIndicator(0);
    dialvalueindicator.setFont(new Font("Dialog", Font.BOLD, 12));
    dialvalueindicator.setOutlinePaint(Color.YELLOW);
    dialvalueindicator.setRadius(0.6D);
    dialvalueindicator.setAngle(-90D);
    dialvalueindicator.setTemplateValue(1000);
    plot.addLayer(dialvalueindicator);

    org.jfree.chart.plot.dial.DialPointer.Pin pin1 = new org.jfree.chart.plot.dial.DialPointer.Pin(1);
    pin1.setRadius(0.55000000000000004D);
    plot.addPointer(pin1);

    // needle uses constrained data set
    plot.addLayer(new DialPointer.Pointer(0));

    StandardDialScale scale = new StandardDialScale(0d, 6000, -110, -320, majorTickGap, 4);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.20);
    scale.setTickLabelFormatter(new DecimalFormat("####"));

    plot.addScale(0, scale);

    StandardDialScale standarddialscale1 = new StandardDialScale(0D, 30D, -120D, -300D, 5D, 4);
    standarddialscale1.setTickRadius(0.5D);
    standarddialscale1.setTickLabelOffset(0.14999999999999999D);
    standarddialscale1.setTickLabelFont(new Font("Dialog", 0, 10));
    standarddialscale1.setMajorTickPaint(Color.RED);
    standarddialscale1.setMinorTickPaint(Color.RED);
    plot.addScale(1, standarddialscale1);

    plot.mapDatasetToScale(1, 1);

    JFreeChart jfreechart = new JFreeChart(plot);
    jfreechart.setTitle("ENGINE RPM & MANIFOLD PRESSURE");
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(400, 400));

    return chartpanel;
}

From source file:com.romraider.logger.ecu.ui.handler.dash.SmallDialGaugeStyle.java

protected JFreeChart buildChart() {
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);/*from w ww .ja  v  a  2  s .c om*/
    plot.setDataset(0, current);
    plot.setDataset(1, max);
    plot.setDataset(2, min);
    DialFrame dialFrame = new StandardDialFrame();
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));
    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(VERTICAL));
    plot.setBackground(db);

    unitsLabel.setFont(new Font(Font.DIALOG, BOLD, 14));
    unitsLabel.setRadius(0.7);
    unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits());
    plot.addLayer(unitsLabel);

    DecimalFormat format = new DecimalFormat(loggerData.getSelectedConvertor().getFormat());

    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setNumberFormat(format);
    plot.addLayer(dvi);

    EcuDataConvertor convertor = loggerData.getSelectedConvertor();
    GaugeMinMax minMax = convertor.getGaugeMinMax();
    StandardDialScale scale = new StandardDialScale(minMax.min, minMax.max, 225.0, -270.0, minMax.step, 5);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    scale.setTickLabelFont(new Font(Font.DIALOG, PLAIN, 12));
    scale.setTickLabelFormatter(format);
    plot.addScale(0, scale);
    plot.addScale(1, scale);
    plot.addScale(2, scale);

    StandardDialRange range = new StandardDialRange(rangeLimit(minMax, 0.75), minMax.max, RED);
    range.setInnerRadius(0.52);
    range.setOuterRadius(0.55);
    plot.addLayer(range);

    StandardDialRange range2 = new StandardDialRange(rangeLimit(minMax, 0.5), rangeLimit(minMax, 0.75), ORANGE);
    range2.setInnerRadius(0.52);
    range2.setOuterRadius(0.55);
    plot.addLayer(range2);

    StandardDialRange range3 = new StandardDialRange(minMax.min, rangeLimit(minMax, 0.5), GREEN);
    range3.setInnerRadius(0.52);
    range3.setOuterRadius(0.55);
    plot.addLayer(range3);

    DialPointer needleCurrent = new DialPointer.Pointer(0);
    plot.addLayer(needleCurrent);

    DialPointer needleMax = new DialPointer.Pin(1);
    needleMax.setRadius(0.84);
    ((DialPointer.Pin) needleMax).setPaint(RED);
    ((DialPointer.Pin) needleMax).setStroke(new BasicStroke(1.5F));
    plot.addLayer(needleMax);

    DialPointer needleMin = new DialPointer.Pin(2);
    needleMin.setRadius(0.84);
    ((DialPointer.Pin) needleMin).setPaint(BLUE);
    ((DialPointer.Pin) needleMin).setStroke(new BasicStroke(1.5F));
    plot.addLayer(needleMin);

    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    plot.setCap(cap);

    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(loggerData.getName());

    return chart;
}

From source file:it.alus.GPSreceiver.instruments.Accelerometer.java

public Accelerometer() {
    super(null);/* w  w w .ja  va  2s .co m*/
    dataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    DialTextAnnotation titleLabel = new DialTextAnnotation("Acceleration");
    titleLabel.setFont(new Font("Arial", 1, 18));
    titleLabel.setRadius(0.45D);
    titleLabel.setAngle(90);
    titleLabel.setPaint(Color.lightGray);
    plot.addLayer(titleLabel);
    DialValueIndicator valueindicator = new DialValueIndicator(0);
    plot.addLayer(valueindicator);
    DialTextAnnotation annotation = new DialTextAnnotation("g");
    annotation.setFont(new Font("Arial", 1, 20));
    annotation.setRadius(0.4D);
    annotation.setPaint(Color.lightGray);
    plot.addLayer(annotation);
    plot.setDialFrame(dialFrame);
    StandardDialScale scale = new StandardDialScale(-1, 3, -95, -340, 1, 20);
    scale.setMajorTickPaint(Color.white);
    scale.setMinorTickPaint(Color.lightGray);
    scale.setFirstTickLabelVisible(true);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    NumberFormat formatter = new DecimalFormat("#");
    scale.setTickLabelFormatter(formatter);
    scale.setTickLabelFont(new Font("Arial", Font.BOLD, 24));
    scale.setTickLabelPaint(Color.white);
    plot.addScale(0, scale);
    plot.setBackground(new DialBackground(Color.black));
    Pointer needle = new Pointer(0);
    needle.setFillPaint(Color.white);
    plot.addLayer(needle);
    plot.mapDatasetToScale(1, 1);
    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    cap.setFillPaint(Color.gray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:it.alus.GPSreceiver.instruments.Altimeter.java

public Altimeter(float groundAltitudeFt) {
    super(null);//from  w w  w . j  ava2s .  c o m
    altitude = 0;
    if (groundAltitudeFt < 0)
        groundAltitude = 0;
    else
        groundAltitude = groundAltitudeFt;
    hoursDataset = new DefaultValueDataset(0.0);
    minutesDataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    Image background = Toolkit.getDefaultToolkit().getImage(getClass().getResource("altimeter.png"));
    plot.setDataset(0, hoursDataset);
    plot.setDataset(1, minutesDataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    DialTextAnnotation annotation = new DialTextAnnotation("Feet");
    annotation.setFont(new Font("Arial", 1, 14));
    annotation.setRadius(0.4D);
    annotation.setPaint(Color.lightGray);
    plot.addLayer(annotation);
    DialValueIndicator valueindicator = new DialValueIndicator(0);
    NumberFormat formatter = new DecimalFormat("#");
    plot.addLayer(valueindicator);
    plot.setDialFrame(dialFrame);
    StandardDialScale scale = new StandardDialScale(0, 10, 90, -360, 1, 10);
    scale.setMajorTickPaint(Color.white);
    scale.setMinorTickPaint(Color.lightGray);
    scale.setFirstTickLabelVisible(false);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    scale.setTickLabelFormatter(formatter);
    scale.setTickLabelFont(new Font("Arial", Font.BOLD, 24));
    scale.setTickLabelPaint(Color.white);
    plot.addScale(3, scale);
    plot.setBackground(new DialBackground(Color.black));
    StandardDialScale hourScale = new StandardDialScale(0, 10000, 90, -360, 1000, 10);
    hourScale.setVisible(false);
    hourScale.setTickRadius(0.88);
    hourScale.setTickLabelOffset(0.15);
    plot.addScale(0, hourScale);
    StandardDialScale minScale = new StandardDialScale(0, 1000, 90, -360, 0, 0);
    minScale.setVisible(false);
    minScale.setMajorTickIncrement(5.0);
    minScale.setTickRadius(0.68);
    plot.addScale(1, minScale);
    Pointer hourNeedle = new Pointer(0);
    hourNeedle.setRadius(0.55);
    hourNeedle.setFillPaint(Color.lightGray);
    plot.addLayer(hourNeedle);
    plot.mapDatasetToScale(1, 1);
    Pointer minNeedle = new Pointer(1);
    minNeedle.setFillPaint(Color.white);
    plot.addLayer(minNeedle);
    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    cap.setFillPaint(Color.lightGray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    jChart.setBackgroundImage(background);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:com.bdb.weather.display.current.Hygrometer.java

private ChartViewer createChartElements() {
    humidityPlot.addLayer(/*from   w  w  w .  ja v a2 s.c o m*/
            new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue)));
    StandardDialScale scale = new StandardDialScale(Humidity.MIN_HUMIDITY.get(), Humidity.MAX_HUMIDITY.get(),
            240.0, -300.0, 10.0, 9);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.9);
    scale.setTickLabelFormatter(new DecimalFormat("#"));
    scale.setTickLabelOffset(.2);
    scale.setTickLabelPaint(Color.BLACK);
    humidityPlot.addScale(0, scale);
    humidityPlot.setDialFrame(new StandardDialFrame());

    DialValueIndicator valueInd = new DialValueIndicator(0);
    valueInd.setNumberFormat(new DecimalFormat("# '%rH'"));
    Color c = new Color(255, 255, 255, 0);
    valueInd.setBackgroundPaint(c);
    valueInd.setOutlinePaint(c);
    valueInd.setPaint(Color.cyan);
    humidityPlot.addLayer(valueInd);

    double angle = valueInd.getAngle();
    double radius = valueInd.getRadius();

    trendAnnotation.setPaint(Color.cyan);
    trendAnnotation.setAngle(angle);
    trendAnnotation.setRadius(radius + .1);
    humidityPlot.addLayer(trendAnnotation);

    DialPointer.Pointer pointer = new DialPointer.Pointer(0);
    humidityPlot.addPointer(pointer);

    DialCap cap = new DialCap();
    cap.setRadius(cap.getRadius() * 1.5);
    humidityPlot.setCap(cap);

    range = new StandardDialRange(Humidity.MIN_HUMIDITY.get(), Humidity.MAX_HUMIDITY.get(), Color.BLACK);
    range.setInnerRadius(.40);
    range.setOuterRadius(.45);
    range.setScaleIndex(0);
    humidityPlot.addLayer(range);

    JFreeChart chart = new JFreeChart(humidityPlot);
    chart.setBackgroundPaint(Color.GRAY);

    ChartViewer chartViewer = new ChartViewer(chart);
    //chartViewer.setMinHeight(100);
    //chartViewer.setMinWidth(100);
    //chartViewer.setMaxHeight(400);
    //chartViewer.setMaxWidth(400);
    //chartViewer.setBackground(Color.GRAY);
    return chartViewer;
}

From source file:it.alus.GPSreceiver.instruments.Turnometer.java

public Turnometer() {
    super(null);// w  ww.j  a  v  a2 s  .co m
    dataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    //DialTextAnnotation titleLabel = new DialTextAnnotation("Vertical speed");
    //titleLabel.setFont(new Font("Arial",1,18));
    //titleLabel.setRadius(0.45D);
    //titleLabel.setAngle(90);
    //titleLabel.setPaint(Color.lightGray);
    //plot.addLayer(titleLabel);
    DialTextAnnotation L = new DialTextAnnotation("L");
    L.setFont(new Font("Arial", Font.BOLD, 30));
    L.setRadius(0.4);
    L.setPaint(Color.white);
    L.setAngle(200);
    plot.addLayer(L);
    DialTextAnnotation R = new DialTextAnnotation("R");
    R.setFont(new Font("Arial", Font.BOLD, 30));
    R.setRadius(0.4);
    R.setPaint(Color.white);
    R.setAngle(-20);
    plot.addLayer(R);

    DialValueIndicator valueindicator = new DialValueIndicator(0);
    plot.addLayer(valueindicator);
    DialTextAnnotation annotation = new DialTextAnnotation("deg/min");
    annotation.setFont(new Font("Arial", 1, 14));
    annotation.setRadius(0.4D);
    annotation.setPaint(Color.lightGray);
    plot.addLayer(annotation);
    plot.setDialFrame(dialFrame);
    StandardDialScale scale = new StandardDialScale(-540, 540, -135, -270, 90, 9);
    scale.setMajorTickPaint(Color.white);
    scale.setMinorTickPaint(Color.lightGray);
    scale.setFirstTickLabelVisible(true);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    NumberFormat formatter = new DecimalFormat("#");
    scale.setTickLabelFormatter(formatter);
    scale.setTickLabelFont(new Font("Arial", Font.BOLD, 24));
    scale.setTickLabelPaint(Color.white);
    plot.addScale(0, scale);
    plot.setBackground(new DialBackground(Color.black));
    Pointer needle = new Pointer(0);
    needle.setFillPaint(Color.white);
    plot.addLayer(needle);
    plot.mapDatasetToScale(1, 1);
    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    cap.setFillPaint(Color.gray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:it.alus.GPSreceiver.instruments.Variometer.java

public Variometer() {
    super(null);/*w w  w .  j  a v a  2  s . co  m*/
    dataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    DialTextAnnotation titleLabel = new DialTextAnnotation("Vertical speed");
    titleLabel.setFont(new Font("Arial", 1, 18));
    titleLabel.setRadius(0.45D);
    titleLabel.setAngle(90);
    titleLabel.setPaint(Color.lightGray);
    plot.addLayer(titleLabel);
    DialTextAnnotation unitLabel = new DialTextAnnotation("100 Ft/min");
    unitLabel.setFont(new Font("Arial", 1, 18));
    unitLabel.setRadius(0.3D);
    unitLabel.setAngle(90);
    unitLabel.setPaint(Color.white);
    plot.addLayer(unitLabel);
    DialValueIndicator valueindicator = new DialValueIndicator(0);
    plot.addLayer(valueindicator);
    DialTextAnnotation annotation = new DialTextAnnotation("Ft/min");
    annotation.setFont(new Font("Arial", 1, 14));
    annotation.setRadius(0.4D);
    annotation.setPaint(Color.lightGray);
    plot.addLayer(annotation);
    plot.setDialFrame(dialFrame);
    StandardDialScale realScale = new StandardDialScale(-3000, 3000, -10, -340, 100, 10);
    realScale.setVisible(false);
    plot.addScale(0, realScale);
    StandardDialScale dispScale = new StandardDialScale(-30, 30, -10, -340, 5, 10);
    dispScale.setMajorTickPaint(Color.white);
    dispScale.setMinorTickPaint(Color.lightGray);
    dispScale.setFirstTickLabelVisible(true);
    dispScale.setTickRadius(0.88);
    dispScale.setTickLabelOffset(0.15);
    NumberFormat formatter = new DecimalFormat("#");
    dispScale.setTickLabelFormatter(formatter);
    dispScale.setTickLabelFont(new Font("Arial", Font.BOLD, 24));
    dispScale.setTickLabelPaint(Color.white);
    plot.addScale(1, dispScale);
    plot.setBackground(new DialBackground(Color.black));
    Pointer needle = new Pointer(0);
    needle.setFillPaint(Color.white);
    plot.addLayer(needle);
    plot.mapDatasetToScale(1, 1);
    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    cap.setFillPaint(Color.gray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:com.romraider.logger.ecu.ui.handler.dash.DialGaugeStyle.java

protected JFreeChart buildChart() {
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);/* w ww .  ja v  a2  s. com*/
    plot.setDataset(0, current);
    plot.setDataset(1, max);
    plot.setDataset(2, min);
    DialFrame dialFrame = new StandardDialFrame();
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));
    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(VERTICAL));
    plot.setBackground(db);

    unitsLabel.setFont(new Font(Font.DIALOG, BOLD, 15));
    unitsLabel.setRadius(0.7);
    unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits());
    plot.addLayer(unitsLabel);

    DecimalFormat format = new DecimalFormat(loggerData.getSelectedConvertor().getFormat());

    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setNumberFormat(format);
    plot.addLayer(dvi);

    EcuDataConvertor convertor = loggerData.getSelectedConvertor();
    GaugeMinMax minMax = convertor.getGaugeMinMax();
    StandardDialScale scale = new StandardDialScale(minMax.min, minMax.max, 225.0, -270.0, minMax.step, 5);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    scale.setTickLabelFont(new Font(Font.DIALOG, PLAIN, 12));
    scale.setTickLabelFormatter(format);
    plot.addScale(0, scale);
    plot.addScale(1, scale);
    plot.addScale(2, scale);

    StandardDialRange range = new StandardDialRange(rangeLimit(minMax, 0.75), minMax.max, RED);
    range.setInnerRadius(0.52);
    range.setOuterRadius(0.55);
    plot.addLayer(range);

    StandardDialRange range2 = new StandardDialRange(rangeLimit(minMax, 0.5), rangeLimit(minMax, 0.75), ORANGE);
    range2.setInnerRadius(0.52);
    range2.setOuterRadius(0.55);
    plot.addLayer(range2);

    StandardDialRange range3 = new StandardDialRange(minMax.min, rangeLimit(minMax, 0.5), GREEN);
    range3.setInnerRadius(0.52);
    range3.setOuterRadius(0.55);
    plot.addLayer(range3);

    DialPointer needleCurrent = new DialPointer.Pointer(0);
    plot.addLayer(needleCurrent);

    DialPointer needleMax = new DialPointer.Pin(1);
    needleMax.setRadius(0.84);
    ((DialPointer.Pin) needleMax).setPaint(RED);
    ((DialPointer.Pin) needleMax).setStroke(new BasicStroke(1.5F));
    plot.addLayer(needleMax);

    DialPointer needleMin = new DialPointer.Pin(2);
    needleMin.setRadius(0.84);
    ((DialPointer.Pin) needleMin).setPaint(BLUE);
    ((DialPointer.Pin) needleMin).setStroke(new BasicStroke(1.5F));
    plot.addLayer(needleMin);

    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    plot.setCap(cap);

    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(loggerData.getName());

    return chart;
}

From source file:it.alus.GPSreceiver.instruments.Speedometer.java

public Speedometer(int Vs0, int Vfe, int Vs, int Vno, int Vne, int endScaleKmh) {
    super(null);/*from   w ww  .j  a v  a  2  s . c o m*/
    currentGroundSpeedKmh = 0;
    if (!setArcs(Vs0, Vfe, Vs, Vno, Vne, endScaleKmh)) {
        this.Vx = 90;
        this.Vy = 100;
        this.Vs0 = 45;
        this.Vs = 55;
        this.Vfe = 86;
        this.Va = 135;
        this.Vno = 160;
        this.Vne = 180;
        this.endScale = 185;
    }
    groundSpeedDataset = new DefaultValueDataset(0);
    totalSpeedDataset = new DefaultValueDataset(0);
    DialPlot dialplot = new DialPlot();
    dialplot.setDataset(0, groundSpeedDataset);
    dialplot.setDataset(1, totalSpeedDataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    DialBackground db = new DialBackground(Color.black);
    dialplot.setBackground(db);
    dialplot.setDialFrame(dialFrame);

    DialTextAnnotation dialtextannotation = new DialTextAnnotation("Km/h");
    dialtextannotation.setFont(new Font("Arial", 1, 14));
    dialtextannotation.setRadius(0.4D);
    dialtextannotation.setPaint(Color.lightGray);
    dialplot.addLayer(dialtextannotation);

    //DialValueIndicator dialvalueindicator = new DialValueIndicator(0);
    //dialplot.addLayer(dialvalueindicator);
    DialValueIndicator groundIndicator = new DialValueIndicator(0);
    groundIndicator.setFont(new Font("Dialog", 0, 10));
    groundIndicator.setOutlinePaint(Color.green);
    groundIndicator.setRadius(0.3);
    groundIndicator.setAngle(-110D);
    dialplot.addLayer(groundIndicator);
    DialValueIndicator realIndicator = new DialValueIndicator(1);
    realIndicator.setFont(new Font("Dialog", 0, 10));
    realIndicator.setOutlinePaint(Color.cyan);
    realIndicator.setRadius(0.3);
    realIndicator.setAngle(-70);
    dialplot.addLayer(realIndicator);
    StandardDialScale scale = new StandardDialScale(0, endScale, 90, -350, 10, 5);
    scale.setFirstTickLabelVisible(true);
    scale.setTickRadius(0.9D);
    scale.setTickLabelOffset(0.14999999999999999D);
    NumberFormat formatter = new DecimalFormat("#");
    scale.setTickLabelFormatter(formatter);
    scale.setTickLabelFont(new Font("Arial", Font.BOLD, 16));
    scale.setMajorTickPaint(Color.white);
    scale.setMinorTickPaint(Color.lightGray);
    scale.setTickLabelPaint(Color.white);
    dialplot.addScale(0, scale);
    dialplot.addPointer(new org.jfree.chart.plot.dial.DialPointer.Pin());
    DialCap dialcap = new DialCap();
    dialcap.setRadius(0.10);
    dialcap.setFillPaint(Color.lightGray);
    dialplot.setCap(dialcap);
    jChart = new JFreeChart(dialplot);
    StandardDialRange standarddialrange = new StandardDialRange(this.Vne, endScale, Color.red);
    standarddialrange.setInnerRadius(0.54D);
    standarddialrange.setOuterRadius(0.56D);
    dialplot.addLayer(standarddialrange);
    StandardDialRange standarddialrange1 = new StandardDialRange(this.Vno, this.Vne, Color.yellow);
    standarddialrange1.setInnerRadius(0.54D);
    standarddialrange1.setOuterRadius(0.56D);
    dialplot.addLayer(standarddialrange1);
    StandardDialRange standarddialrange2 = new StandardDialRange(this.Vs, this.Vno, Color.green);
    standarddialrange2.setInnerRadius(0.54D);
    standarddialrange2.setOuterRadius(0.56D);
    dialplot.addLayer(standarddialrange2);
    StandardDialRange standarddialrange3 = new StandardDialRange(this.Vs0, this.Vfe, Color.white);
    standarddialrange3.setInnerRadius(0.50D);
    standarddialrange3.setOuterRadius(0.52D);
    dialplot.addLayer(standarddialrange3);
    //dialplot.removePointer(0);
    Pointer realPointer = new Pointer(1);
    realPointer.setFillPaint(Color.cyan);
    dialplot.addPointer(realPointer);
    Pointer groundPointer = new Pointer(0);
    groundPointer.setFillPaint(Color.green);
    dialplot.addPointer(groundPointer);

    /* PER NASCONDERE GLI INDICATORI
    groundIndicator.setVisible(false);
    realIndicator.setVisible(false);
    groundPointer.setVisible(false);
    realPointer.setVisible(false);
    */

    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:com.bdb.weather.display.current.WindGauge.java

/**
 * Constructor./*from  w  ww.j  a v  a 2  s. c  o m*/
 */
public WindGauge() {
    this.setPrefSize(200.0, 200.0);
    lastHeading = 0.0;
    lastSpeed = 0.0;
    plot = new DialPlot();
    for (int i = 0; i < WIND_DIR_ITEMS; i++) {
        datasets[i] = new DefaultValueDataset();
        plot.setDataset(WIND_DIR_DATASET_INDEX_BASE + i, datasets[i]);
    }

    plot.setDataset(WIND_SPEED_DATASET_INDEX, speedDataset);
    plot.setDataset(WIND_GUST_DATASET_INDEX, gustDataset);
    plot.setDataset(MAX_WIND_SPEED_DATASET_INDEX, maxSpeedDataset);
    plot.setDataset(MAX_WIND_GUST_DATASET_INDEX, maxGustDataset);

    plot.addLayer(
            new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue)));

    StandardDialScale scale = new StandardDialScale(0.0, 360.0, 90.0, -360.0, 45.0, 1);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.9);
    scale.setTickLabelFormatter(new CompassHeadingFormat());
    scale.setTickLabelOffset(0.06);
    scale.setMajorTickPaint(new Color(0, 0, 0, 0));
    scale.setTickLabelPaint(Color.BLACK);
    scale.setMinorTickLength(scale.getMajorTickLength());
    scale.setMinorTickStroke(scale.getMajorTickStroke());
    plot.addScale(WIND_DIR_SCALE, scale);

    scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 10.0, 9);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.4);
    scale.setTickLabelFormatter(new DecimalFormat("##"));
    scale.setTickLabelOffset(.15);
    scale.setTickLabelPaint(Color.BLACK);
    plot.addScale(WIND_SPEED_SCALE, scale);

    DialPointer.Pointer pointer;
    for (int i = 1; i < WIND_DIR_ITEMS; i++) {
        pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE + i, false);
        pointer.setOutlinePaint(Color.RED);
        plot.addPointer(pointer);
    }

    plot.setDialFrame(new StandardDialFrame());
    pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE, true);
    Color fill = Color.CYAN;
    pointer.setFillPaint(fill);
    pointer.setOutlinePaint(Color.BLACK);
    plot.addPointer(pointer);

    DialCap cap = new DialCap();
    plot.setCap(cap);

    DialPointer.Pin speedPin = new DialPointer.Pin(WIND_SPEED_DATASET_INDEX);
    speedPin.setPaint(WIND_SPEED_PIN_COLOR);
    speedPin.setRadius(WIND_SPEED_PIN_RADIUS);
    speedPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(speedPin);

    DialPointer.Pin gustPin = new DialPointer.Pin(WIND_GUST_DATASET_INDEX);
    gustPin.setPaint(WIND_GUST_PIN_COLOR);
    gustPin.setRadius(WIND_GUST_PIN_RADIUS);
    gustPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(gustPin);

    DialPointer.Pin maxSpeedPin = new DialPointer.Pin(MAX_WIND_SPEED_DATASET_INDEX);
    maxSpeedPin.setPaint(WIND_SPEED_PIN_COLOR);
    maxSpeedPin.setRadius(MAX_WIND_SPEED_PIN_RADIUS);
    maxSpeedPin
            .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(maxSpeedPin);

    DialPointer.Pin maxGustPin = new DialPointer.Pin(MAX_WIND_GUST_DATASET_INDEX);
    maxGustPin.setPaint(WIND_GUST_PIN_COLOR);
    maxGustPin.setRadius(MAX_WIND_GUST_PIN_RADIUS);
    maxGustPin
            .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(maxGustPin);

    speedAnnotation.setAngle(270.0);
    speedAnnotation.setRadius(.35);
    speedAnnotation.setPaint(Color.cyan);
    plot.addLayer(speedAnnotation);

    double angle = speedAnnotation.getAngle();
    double radius = speedAnnotation.getRadius();

    avgAnnotation.setPaint(Color.cyan);
    avgAnnotation.setAngle(angle);
    avgAnnotation.setRadius(radius + .1);
    plot.addLayer(avgAnnotation);

    for (int i = 0; i < WIND_DIR_ITEMS; i++)
        plot.mapDatasetToScale(WIND_DIR_DATASET_INDEX_BASE + i, WIND_DIR_SCALE);

    plot.mapDatasetToScale(WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(MAX_WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(MAX_WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE);

    StandardDialRange range = new StandardDialRange(0.0, 360.0, Color.BLACK);
    range.setInnerRadius(.70);
    range.setOuterRadius(.72);
    range.setScaleIndex(WIND_DIR_SCALE);
    plot.addLayer(range);

    JFreeChart chart = new JFreeChart(plot);
    chart.setBackgroundPaint(Color.GRAY);

    chartViewer = new ChartViewer(chart);
    //chartViewer.setMinHeight(100);
    //chartViewer.setMinWidth(100);
    //chartViewer.setMaxHeight(400);
    //chartViewer.setMaxWidth(400);
    //chartViewer.setBackground(Color.GRAY);
    //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED));

    this.setCenter(chartViewer);
    this.setTop(title);
    BorderPane.setAlignment(title, Pos.CENTER);
    title.textProperty().bind(titleProperty);
    setTitle("Wind");

    timeline.setCycleCount(9);
    timeline.setOnFinished((event) -> {
        datasets[0].setValue(currentHeading);
        speedDataset.setValue(currentSpeed);
        lastHeading = currentHeading;
        lastSpeed = currentSpeed;
    });
}