Example usage for org.jfree.chart.plot.dial DialBackground DialBackground

List of usage examples for org.jfree.chart.plot.dial DialBackground DialBackground

Introduction

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

Prototype

public DialBackground(Paint paint) 

Source Link

Document

Creates a new instance of DialBackground.

Usage

From source file:DashboardInterface.TensionSpeedDial.java

public TensionSpeedDial(JPanel parentIn) {
    super(new BorderLayout());
    parent = parentIn;//from   ww w .  j a va 2s. 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("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:DashboardInterface.CableOutSpeedDial.java

public CableOutSpeedDial(JPanel parentIn) {
    super(new BorderLayout());
    parent = parentIn;//from w w  w.ja  va  2 s .  c  om
    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:netplot.DialPlotPanel.java

public void init() {
    finalize();/*from   ww  w.  ja  v  a  2 s . com*/
    this.dataset1 = new DefaultValueDataset(10.0);
    this.dataset2 = new DefaultValueDataset(50.0);

    // get data for diagrams
    plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, this.dataset1);
    plot.setDataset(1, this.dataset2);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.darkGray);
    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(GradientPaintTransformType.VERTICAL));
    plot.setBackground(db);

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

    chart = new JFreeChart(plot);
    ChartPanel cp1 = new ChartPanel(chart);
    cp1.setPreferredSize(new Dimension(400, 400));

    add(cp1);
}

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  .  j  a v a 2  s .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:it.marcoberri.mbmeteo.action.chart.GetLastRDial.java

/**
 * Processes requests for both HTTP/*  ww w.  j a  v 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.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:com.bdb.weather.display.current.Hygrometer.java

private ChartViewer createChartElements() {
    humidityPlot.addLayer(//from  w ww  . jav  a2s  . c  om
            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.marcoberri.mbmeteo.action.chart.GetLastTDial.java

/**
 * Processes requests for both HTTP// w  w  w . j a v  a  2s  . 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.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.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.SimpleDial.java

/**
 * Creates the chart .//from www . j a va 2s . c  o m
 * 
 * @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.marcoberri.mbmeteo.action.chart.GetLastUDial.java

/**
 * Processes requests for both HTTP/*  w  w w. java  2s .co 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.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:it.alus.GPSreceiver.instruments.Accelerometer.java

public Accelerometer() {
    super(null);//from   www .  j  av a  2s  .c o  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));
}