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

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

Introduction

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

Prototype

public void setTickLabelFont(Font font) 

Source Link

Document

Sets the font used to display the tick labels 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  ww w. j  a v a 2 s  . c  o  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:it.marcoberri.mbmeteo.action.chart.GetLastRDial.java

/**
 * Processes requests for both HTTP/*from   w  w w  .  j av a  2  s  .com*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getDayRainfall());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);

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

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(0);
    scale.setUpperBound(50);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Daily Rain mm");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastTDial.java

/**
 * Processes requests for both HTTP//from   w w  w .  jav  a  2  s .  c o  m
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getOutdoorTemperature());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);

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

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(-20);
    scale.setUpperBound(40);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Temperature C");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastUDial.java

/**
 * Processes requests for both HTTP/*from   w ww. j  a  v a 2  s.  c  om*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    DefaultValueDataset dataset = new DefaultValueDataset(meteolog.getOutdoorHumidity());

    // get data for diagrams
    DialPlot plot = new DialPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    //plot.setView(0.1, 0.1, 0.9, 0.9);
    // plot.set
    plot.setDataset(0, dataset);

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

    StandardDialScale scale = new StandardDialScale();
    scale.setLowerBound(0);
    scale.setUpperBound(100);
    scale.setTickLabelOffset(0.14);
    scale.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.addScale(0, scale);
    plot.setInsets(RectangleInsets.ZERO_INSETS);

    DialPointer needle = new DialPointer.Pointer(0);

    plot.addLayer(needle);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setTitle("Humidity %");

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart1, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();
}

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

private ChartViewer createChartElements() {
    humidityPlot.addLayer(/*from  www.  j ava  2s .  co  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: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 w  w.  j  a  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, 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: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.  jav a  2s .c o m*/
    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:DashboardInterface.CableOutSpeedDial.java

public CableOutSpeedDial(JPanel parentIn) {
    super(new BorderLayout());
    parent = parentIn;/*w  ww .  j  av  a  2 s . com*/
    dataset1 = new DefaultValueDataset(0D);
    dataset2 = new DefaultValueDataset(0D);
    pipe = MessagePipeline.getInstance();
    pipe.attach(this);
    DialPlot dialplot = new DialPlot();
    dialplot.setView(0.0D, 0.0D, 1.0D, 1.0D);
    dialplot.setDataset(0, dataset1);
    dialplot.setDataset(1, dataset2);
    setBackground(Color.WHITE);
    StandardDialFrame standarddialframe = new StandardDialFrame();
    standarddialframe.setBackgroundPaint(Color.lightGray);
    standarddialframe.setForegroundPaint(Color.darkGray);

    dialplot.setDialFrame(standarddialframe);

    DialBackground dialbackground = new DialBackground(Color.LIGHT_GRAY);

    dialbackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialplot.setBackground(dialbackground);

    DialTextAnnotation dialtextannotation = new DialTextAnnotation("Cable Out (ft)");
    dialtextannotation.setFont(new Font("Dialog", 1, 12));
    dialtextannotation.setPaint(new Color(36, 130, 9));
    dialtextannotation.setRadius(0.47999999999999996D);
    dialplot.addLayer(dialtextannotation);

    DialTextAnnotation dialtextannotation2 = new DialTextAnnotation("Speed (kts)");
    dialtextannotation2.setFont(new Font("Dialog", 1, 12));
    dialtextannotation2.setPaint(Color.BLUE);
    dialtextannotation2.setRadius(0.78999999999999996D);
    dialplot.addLayer(dialtextannotation2);

    /*DialValueIndicator dialvalueindicator = new DialValueIndicator(0);
    dialvalueindicator.setFont(new Font("Dialog", 0, 10));
    dialvalueindicator.setOutlinePaint(Color.BLACK);
    dialvalueindicator.setRadius(0.84999999999999998D);
    dialvalueindicator.setAngle(-90D);
    dialplot.addLayer(dialvalueindicator);
            
    DialValueIndicator dialvalueindicator1 = new DialValueIndicator(1);
    dialvalueindicator1.setFont(new Font("Dialog", 0, 10));
    dialvalueindicator1.setOutlinePaint(Color.BLACK);
    dialvalueindicator1.setRadius(0.60999999999999998D);
    dialvalueindicator1.setAngle(-90D);
    dialplot.addLayer(dialvalueindicator1);*/

    StandardDialScale standarddialscale = new StandardDialScale(0D, 90D, -110D, -320D, 10D, 4);
    standarddialscale.setTickRadius(0.88D);
    standarddialscale.setTickLabelOffset(0.14999999999999999D);
    standarddialscale.setTickLabelFont(new Font("Dialog", 0, 14));
    standarddialscale.setMajorTickPaint(Color.BLUE);
    standarddialscale.setMinorTickPaint(Color.BLUE);
    dialplot.addScale(0, standarddialscale);

    StandardDialScale standarddialscale1 = new StandardDialScale(0.0D, 6000D, -110D, -320D, 750D, 4);
    standarddialscale1.setTickRadius(0.5D);
    standarddialscale1.setTickLabelOffset(0.14999999999999999D);
    standarddialscale1.setTickLabelFont(new Font("Dialog", 0, 10));
    standarddialscale1.setTickLabelPaint(new Color(36, 130, 9));
    standarddialscale1.setMajorTickPaint(new Color(36, 130, 9));
    standarddialscale1.setMinorTickPaint(new Color(36, 130, 9));
    dialplot.addScale(1, standarddialscale1);

    dialplot.mapDatasetToScale(1, 1);

    org.jfree.chart.plot.dial.DialPointer.Pointer pointer = new org.jfree.chart.plot.dial.DialPointer.Pointer(
            0);
    pointer.setFillPaint(Color.BLUE);
    dialplot.addPointer(pointer);

    org.jfree.chart.plot.dial.DialPointer.Pointer pin = new org.jfree.chart.plot.dial.DialPointer.Pointer(1);
    pin.setRadius(0.55000000000000004D);
    pin.setFillPaint(new Color(36, 130, 9));
    dialplot.addPointer(pin);

    DialCap dialcap = new DialCap();
    dialcap.setRadius(0.10000000000000001D);
    dialplot.setCap(dialcap);

    Dimension size = parent.getBounds().getSize();
    int width = parent.getWidth();
    int height = parent.getHeight();

    width = 200;

    JFreeChart jfreechart = new JFreeChart(dialplot);
    jfreechart.setBackgroundPaint(Color.WHITE);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(width, width));

    add(chartpanel);
}

From source file:DashboardInterface.TensionSpeedDial.java

public TensionSpeedDial(JPanel parentIn) {
    super(new BorderLayout());
    parent = parentIn;/*  w  w w .  j  a v a 2 s .c  o  m*/
    dataset1 = new DefaultValueDataset(0D);
    dataset2 = new DefaultValueDataset(0D);
    pipe = MessagePipeline.getInstance();
    pipe.attach(this);
    DialPlot dialplot = new DialPlot();
    dialplot.setView(0.0D, 0.0D, 1.0D, 1.0D);
    dialplot.setDataset(0, dataset1);
    dialplot.setDataset(1, dataset2);
    setBackground(Color.WHITE);
    StandardDialFrame standarddialframe = new StandardDialFrame();
    standarddialframe.setBackgroundPaint(Color.lightGray);
    standarddialframe.setForegroundPaint(Color.darkGray);

    dialplot.setDialFrame(standarddialframe);

    DialBackground dialbackground = new DialBackground(Color.LIGHT_GRAY);

    dialbackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialplot.setBackground(dialbackground);

    DialTextAnnotation dialtextannotation = new DialTextAnnotation("Tension (lbf)");
    dialtextannotation.setFont(new Font("Dialog", 1, 12));
    dialtextannotation.setPaint(Color.RED);
    dialtextannotation.setRadius(0.47999999999999996D);
    dialplot.addLayer(dialtextannotation);

    DialTextAnnotation dialtextannotation2 = new DialTextAnnotation("Speed (kts)");
    dialtextannotation2.setFont(new Font("Dialog", 1, 12));
    dialtextannotation2.setPaint(Color.BLUE);
    dialtextannotation2.setRadius(0.78999999999999996D);
    dialplot.addLayer(dialtextannotation2);

    /*DialValueIndicator dialvalueindicator = new DialValueIndicator(0);
    dialvalueindicator.setFont(new Font("Dialog", 0, 10));
    dialvalueindicator.setOutlinePaint(Color.BLACK);
    dialvalueindicator.setRadius(0.84999999999999998D);
    dialvalueindicator.setAngle(-90D);
    dialplot.addLayer(dialvalueindicator);
            
    DialValueIndicator dialvalueindicator1 = new DialValueIndicator(1);
    dialvalueindicator1.setFont(new Font("Dialog", 0, 10));
    dialvalueindicator1.setOutlinePaint(Color.BLACK);
    dialvalueindicator1.setRadius(0.60999999999999998D);
    dialvalueindicator1.setAngle(-90D);
    dialplot.addLayer(dialvalueindicator1);*/

    StandardDialScale standarddialscale = new StandardDialScale(0D, 90D, -120D, -300D, 10D, 4);
    standarddialscale.setTickRadius(0.88D);
    standarddialscale.setTickLabelOffset(0.14999999999999999D);
    standarddialscale.setTickLabelFont(new Font("Dialog", 0, 14));
    standarddialscale.setTickLabelPaint(Color.BLUE);
    standarddialscale.setMajorTickPaint(Color.BLUE);
    standarddialscale.setMinorTickPaint(Color.BLUE);
    dialplot.addScale(0, standarddialscale);

    StandardDialScale standarddialscale1 = new StandardDialScale(0.0D, 2500D, -120D, -300D, 500D, 4);
    standarddialscale1.setTickRadius(0.5D);
    standarddialscale1.setTickLabelOffset(0.14999999999999999D);
    standarddialscale1.setTickLabelFont(new Font("Dialog", 0, 10));
    standarddialscale1.setTickLabelPaint(Color.RED);
    standarddialscale1.setMajorTickPaint(Color.RED);
    standarddialscale1.setMinorTickPaint(Color.RED);
    dialplot.addScale(1, standarddialscale1);

    dialplot.mapDatasetToScale(1, 1);

    org.jfree.chart.plot.dial.DialPointer.Pointer pointer = new org.jfree.chart.plot.dial.DialPointer.Pointer(
            0);
    pointer.setFillPaint(Color.BLUE);
    dialplot.addPointer(pointer);

    org.jfree.chart.plot.dial.DialPointer.Pointer pin = new org.jfree.chart.plot.dial.DialPointer.Pointer(1);
    pin.setRadius(0.55000000000000004D);
    pin.setFillPaint(Color.RED);
    dialplot.addPointer(pin);

    DialCap dialcap = new DialCap();
    dialcap.setRadius(0.10000000000000001D);
    dialplot.setCap(dialcap);

    Dimension size = parent.getBounds().getSize();
    int width = parent.getWidth();
    int height = parent.getHeight();

    width = 200;

    JFreeChart jfreechart = new JFreeChart(dialplot);
    jfreechart.setBackgroundPaint(Color.WHITE);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(width, width));

    add(chartpanel);
}

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);/*from  w  w w .  j  a  v  a  2 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;
}