Example usage for org.jfree.chart.plot.dial StandardDialRange setInnerRadius

List of usage examples for org.jfree.chart.plot.dial StandardDialRange setInnerRadius

Introduction

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

Prototype

public void setInnerRadius(double radius) 

Source Link

Document

Sets the inner radius and sends a DialLayerChangeEvent to all registered listeners.

Usage

From source file:org.cyberoam.iview.charts.MeterChart.java

/**
 * This method generates JFreeChart instance for Meter chart with dial port and iView customization.
 * @param reportID//from w  ww  . j  a  va 2  s  . co m
 * @param rsw
 * @param request
 * @return
 */
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
    JFreeChart chart = null;
    ReportColumnBean reportColumnBean = null;
    GraphBean graphBean = null;
    try {
        DefaultValueDataset data = null;
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnDBname = reportColumnBean.getDbColumnName();
        rsw.first();
        double used = Double.parseDouble(rsw.getString(yColumnDBname));
        data = new DefaultValueDataset(100 - used);
        DialPlot plot = new DialPlot(data);
        chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

        chart.setBackgroundPaint(Color.white);
        int imgWidth = graphBean.getWidth();
        int imgHeight = graphBean.getHeight();
        if (request != null && request.getParameter("imgwidth") != null
                && !"".equalsIgnoreCase(request.getParameter("imgwidth"))
                && !"null".equalsIgnoreCase(request.getParameter("imgwidth"))) {
            imgWidth = Integer.parseInt(request.getParameter("imgwidth"));
        }
        if (request != null && request.getParameter("imgheight") != null
                && !"".equalsIgnoreCase(request.getParameter("imgheight"))
                && !"null".equalsIgnoreCase(request.getParameter("imgheight"))) {
            imgHeight = Integer.parseInt(request.getParameter("imgheight"));
        }
        plot.setView((1 - ((double) imgWidth / (double) imgHeight)) / 2, plot.getViewY(),
                ((double) imgWidth / (double) imgHeight), plot.getViewHeight());
        StandardDialFrame dialFrame = new StandardDialFrame();
        dialFrame.setBackgroundPaint(new Color(54, 73, 109));
        dialFrame.setRadius(0.8);
        dialFrame.setStroke(new BasicStroke(0));
        plot.setDialFrame(dialFrame);
        GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
                new Color(196, 210, 219));
        DialBackground db = new DialBackground(gp);
        db.setGradientPaintTransformer(
                new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
        plot.setBackground(db);

        DialValueIndicator dvi = new DialValueIndicator(0);
        dvi.setRadius(0.55);
        dvi.setBackgroundPaint(gp);
        dvi.setNumberFormat(new DecimalFormat("###"));
        dvi.setFont(new Font("Vandara", Font.CENTER_BASELINE, 10));
        dvi.setOutlinePaint(Color.lightGray);
        plot.addLayer(dvi);

        StandardDialScale scale = new StandardDialScale(0, 100, -120, -300, 10, 4);
        scale.setTickRadius(0.75);
        scale.setTickLabelOffset(0.15);
        scale.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 9));
        plot.addScale(0, scale);

        StandardDialRange range = new StandardDialRange(0.0, 50.0, Color.green);
        range.setInnerRadius(0.35);
        range.setOuterRadius(0.38);
        plot.addLayer(range);

        StandardDialRange range2 = new StandardDialRange(50.0, 75.0, Color.yellow);
        range2.setInnerRadius(0.35);
        range2.setOuterRadius(0.38);
        plot.addLayer(range2);

        StandardDialRange range3 = new StandardDialRange(75.0, 100.0, Color.red);
        range3.setInnerRadius(0.35);
        range3.setOuterRadius(0.38);
        plot.addLayer(range3);

        DialPointer needle = new DialPointer.Pointer();
        needle.setRadius(0.55);
        plot.addLayer(needle);

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

    } catch (Exception e) {
        CyberoamLogger.appLog.debug("MeterChart=>Exception : " + e, e);
    }
    return chart;
}

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);//w w w .ja v  a  2s. co m
    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:com.netsteadfast.greenstep.action.CommonMeterChartAction.java

private void fillChart(String title, float value, int lowerBound, int upperBound) throws Exception {
    DefaultValueDataset dataset = new DefaultValueDataset();

    dataset.setValue(value);/* www  . j  a  va2  s .  c o  m*/

    DialPlot plot = new DialPlot();
    plot.setView(0.0d, 0.0d, 1.0d, 1.0d);
    plot.setDataset(0, dataset);

    StandardDialFrame frame = new StandardDialFrame();
    plot.setDialFrame(frame);
    DialBackground dialBackground = new DialBackground();
    dialBackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    plot.setBackground(dialBackground);
    DialTextAnnotation textAnnotation = new DialTextAnnotation(title);
    textAnnotation.setRadius(0.555555555555555555D);
    plot.addLayer(textAnnotation);

    DialValueIndicator valueIndicator = new DialValueIndicator(0);
    plot.addLayer(valueIndicator);

    StandardDialScale scale1 = new StandardDialScale();
    scale1.setLowerBound(lowerBound);
    scale1.setUpperBound(upperBound);
    scale1.setStartAngle(-140); // -120
    scale1.setExtent(-260D); // -300D 
    scale1.setTickRadius(0.88D);
    scale1.setTickLabelOffset(0.14999999999999999D);
    scale1.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 14));
    plot.addScale(0, scale1);

    StandardDialRange standarddialrange0 = new StandardDialRange(lowerBound, (upperBound * 0.6), Color.red);
    standarddialrange0.setInnerRadius(0.52000000000000002D);
    standarddialrange0.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange0);

    StandardDialRange standarddialrange1 = new StandardDialRange((upperBound * 0.6), (upperBound * 0.8),
            Color.orange);
    standarddialrange1.setInnerRadius(0.52000000000000002D);
    standarddialrange1.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange1);

    StandardDialRange standarddialrange2 = new StandardDialRange((upperBound * 0.8), upperBound, Color.green);
    standarddialrange2.setInnerRadius(0.52000000000000002D);
    standarddialrange2.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange2);

    Pointer pointer = new Pointer(0);
    pointer.setFillPaint(new Color(144, 196, 246));
    plot.addPointer(pointer);
    plot.mapDatasetToScale(0, 0);
    DialCap dialcap = new DialCap();
    dialcap.setRadius(0.0700000000000001D);
    plot.setCap(dialcap);

    this.chart = new JFreeChart(plot);
    //this.chart.setBackgroundPaint(new Color(234, 244, 253));
    this.chart.setBackgroundPaint(Color.white);
}

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 w  w  . jav a 2s  .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.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 .j a v  a  2s.  c o m*/
    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.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.SimpleDial.java

/**
 * Creates the chart .//from  www .j a  v  a 2  s.com
 * 
 * @return A Simple Dial chart .
 */
public JFreeChart createChart() {
    logger.debug("IN");

    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        return null;
    }

    DialPlot plot = new DialPlot();
    plot.setDataset((ValueDataset) dataset);
    logger.debug("Created the new Dial Plot");

    ArcDialFrame dialFrame = null;
    plot.setView(0.21, 0.0, 0.58, 0.30);
    dialFrame = new ArcDialFrame(60.0, 60.0);
    dialFrame.setInnerRadius(0.65);
    dialFrame.setOuterRadius(0.90);
    dialFrame.setForegroundPaint(Color.darkGray);
    dialFrame.setStroke(new BasicStroke(3.0f));
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(240, 240, 240));
    DialBackground sdb = new DialBackground(gp);

    GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL;

    sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType));
    plot.addLayer(sdb);

    increment = (upper - lower) / 4;
    StandardDialScale scale = null;
    scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount);

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.70);
        range.setOuterRadius(0.75);
        plot.addLayer(range);

    }

    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.07);
    Font f = new Font("Arial", Font.PLAIN, 11);
    scale.setTickLabelFont(f);
    //scale.setMajorTickIncrement(25.0);
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pin();
    needle.setRadius(0.82);
    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    logger.debug("Created the chart");
    chart1.setBackgroundPaint(color);
    logger.debug("Setted background color of the chart");

    TextTitle title = setStyleTitle(name, styleTitle);
    chart1.setTitle(title);
    logger.debug("Setted the title of the chart");
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart1.addSubtitle(subTitle);
        logger.debug("Setted the subtitle of the chart");
    }

    logger.debug("OUT");
    return chart1;
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Speedometer.java

/**
 * Creates a chart of type Speedometer./*from www .ja v a  2 s  .  c  o  m*/
 * 
 * @return A Speedometer Chart
 */
public JFreeChart createChart() {
    logger.debug("IN");

    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        return null;
    }

    DialPlot plot = new DialPlot();
    logger.debug("Created new DialPlot");

    plot.setDataset((ValueDataset) dataset);
    plot.setDialFrame(new StandardDialFrame());
    plot.setBackground(new DialBackground());

    if (dialtextuse) {
        //Usually it shoudn'tbe used. It is a type of title written into the graph
        DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext);
        annotation1.setFont(styleTitle.getFont());
        annotation1.setRadius(0.7);
        plot.addLayer(annotation1);
    }

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

    increment = (upper - lower) / 10;
    StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4);
    //      if (!( increment > 0)){
    //         increment = 0.01;
    //      }
    scale.setMajorTickIncrement(increment);
    logger.debug("Setted the unit after which a new MajorTickline will be drawed");
    scale.setMinorTickCount(minorTickCount);
    logger.debug("Setted the number of MinorTickLines between every MajorTickline");
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    Font f = new Font("Arial", Font.PLAIN, 11);
    scale.setTickLabelFont(f);
    plot.addScale(0, scale);
    plot.addPointer(new DialPointer.Pin());

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

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.52);
        range.setOuterRadius(0.55);
        plot.addLayer(range);
        logger.debug("new range added to the plot");
    }

    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(GradientPaintTransformType.VERTICAL));
    plot.setBackground(db);
    plot.removePointer(0);

    DialPointer.Pointer p = new DialPointer.Pointer();
    //Pointer color
    p.setFillPaint(Color.black);
    plot.addPointer(p);
    logger.debug("Setted all properties of the plot");

    JFreeChart chart = new JFreeChart(name, plot);
    logger.debug("Created the chart");
    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    logger.debug("Setted the title of the chart");
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
        logger.debug("Setted the subtitle of the chart");
    }

    chart.setBackgroundPaint(color);
    logger.debug("Setted background color of the chart");

    logger.debug("OUT");
    return chart;
}

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

/**
 * Constructor.//from   w ww  . j  a  va 2s  .com
 */
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;
    });
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SBISpeedometer.java

/**
 * Creates a chart of type speedometer.//from  w  w  w  .j a va2  s .  c om
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart speedometer.
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    DialPlot plot = new DialPlot();
    plot.setDataset((ValueDataset) dataset);
    plot.setDialFrame(new StandardDialFrame());

    plot.setBackground(new DialBackground());
    if (dialtextuse) {
        DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext);
        annotation1.setFont(styleTitle.getFont());
        annotation1.setRadius(0.7);

        plot.addLayer(annotation1);
    }

    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));
    dvi.setPaint(labelsValueStyle.getColor());
    plot.addLayer(dvi);

    StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4);

    if (!(increment > 0)) {
        logger.warn("increment cannot be less than 0, put default to 0.1");
        increment = 0.01;
    }

    scale.setMajorTickIncrement(increment);

    //      if (!( minorTickCount > 0)){
    //         logger.warn("minor tick count cannot be less than 0, put default to 1");
    //         minorTickCount = 1;
    //      }

    scale.setMinorTickCount(minorTickCount);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    //set tick label style
    Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
    scale.setTickLabelFont(tickLabelsFont);
    scale.setTickLabelPaint(labelsTickStyle.getColor());
    plot.addScale(0, scale);

    plot.addPointer(new DialPointer.Pin());

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

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.52);
        range.setOuterRadius(0.55);
        plot.addLayer(range);

    }

    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(GradientPaintTransformType.VERTICAL));
    plot.setBackground(db);

    plot.removePointer(0);
    DialPointer.Pointer p = new DialPointer.Pointer();
    p.setFillPaint(Color.yellow);
    plot.addPointer(p);

    logger.debug("OUT");
    JFreeChart chart = new JFreeChart(name, plot);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    chart.setBackgroundPaint(color);
    return chart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SimpleDial.java

/**
 * Creates the chart ./*from ww  w. j ava 2 s.com*/
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart .
 */

public JFreeChart createChart(DatasetMap datasets) {
    // get data for diagrams
    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    DialPlot plot = new DialPlot();
    plot.setDataset((ValueDataset) dataset);

    ArcDialFrame dialFrame = null;
    if (!horizontalView) {
        plot.setView(0.78, 0.37, 0.22, 0.26);
        dialFrame = new ArcDialFrame(-10.0, 20.0);
    } else {
        plot.setView(0.21, 0.0, 0.58, 0.30);
        dialFrame = new ArcDialFrame(60.0, 60.0);
    }

    dialFrame.setInnerRadius(0.65);
    dialFrame.setOuterRadius(0.90);
    dialFrame.setForegroundPaint(Color.darkGray);
    dialFrame.setStroke(new BasicStroke(3.0f));
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(240, 240, 240));
    DialBackground sdb = new DialBackground(gp);

    GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.VERTICAL;
    if (horizontalView) {
        gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL;
    }

    sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType));
    plot.addLayer(sdb);

    if (!(increment > 0)) {
        logger.warn("increment cannot be less than 0, put default to 0.1 ");
        increment = 0.1;
    }

    StandardDialScale scale = null;
    if (!horizontalView) {
        scale = new StandardDialScale(lower, upper, -8, 16.0, increment, minorTickCount);
    } else {
        scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount);
    }

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.70);
        range.setOuterRadius(0.75);
        plot.addLayer(range);

    }

    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.07);
    //set tick label style
    Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
    scale.setTickLabelFont(tickLabelsFont);
    scale.setTickLabelPaint(labelsTickStyle.getColor());
    //scale.setMajorTickIncrement(25.0);
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pin();
    needle.setRadius(0.82);
    plot.addLayer(needle);
    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));
    dvi.setPaint(labelsValueStyle.getColor());
    plot.addLayer(dvi);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart1.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart1.addSubtitle(subTitle);
    }

    logger.debug("OUT");
    return chart1;
}