Example usage for org.jfree.chart.plot.dial DialPlot addPointer

List of usage examples for org.jfree.chart.plot.dial DialPlot addPointer

Introduction

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

Prototype

public void addPointer(DialPointer pointer) 

Source Link

Document

Adds a pointer to the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:meter_rpm.Stackoverflow.java

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

    DialPlot plot = new DialPlot();
    plot.setView(0.0D, 0.0D, 1.0D, 1.0D);
    plot.setDataset(0, dataset0);//ww  w  .  j  ava2s . 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:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Speedometer.java

/**
 * Creates a chart of type Speedometer./*from www .j av  a  2s . 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:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SBISpeedometer.java

/**
 * Creates a chart of type speedometer.//w  w w . j  av  a2s.  c o  m
 * 
 * @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.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  . ja  v  a2  s.c om
    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.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);/*from  ww w.  ja v  a  2  s  .  co 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:org.pentaho.chart.plugin.jfreechart.chart.dial.JFreeDialChartGenerator.java

protected void setDialPointer(ChartDocument chartDocument, DialPlot dialPlot) {
    // ~ params begin
    double pointerRadius = 0.9; // length of pointer
    double pointerWidthRadius = 0.05; // width of base of pointer
    Color pointerFillPaint = Color.gray;
    Color pointerOutlinePaint = Color.black;
    Stroke pointerOutlineStroke = new BasicStroke(2.0f);
    // ~ params end

    VariableStrokePointer pointer = new VariableStrokePointer();

    ChartElement pointerElement = getUniqueElement(chartDocument, DIALPOINTER);

    final Color pointerColorTmp = ColorFactory.getInstance().getColor(pointerElement);
    if (pointerColorTmp != null) {
        pointerFillPaint = pointerColorTmp;
    }/*w w w.  j  a  v a 2  s  . c  om*/

    final Color pointerBorderColorTmp = ColorFactory.getInstance().getColor(pointerElement,
            BorderStyleKeys.BORDER_TOP_COLOR);
    if (pointerBorderColorTmp != null) {
        pointerOutlinePaint = pointerBorderColorTmp;
    }

    double pointerWidthRadiusTmp = parseDouble(pointerElement.getLayoutStyle().getValue(BoxStyleKeys.WIDTH))
            / 100;
    if (pointerWidthRadiusTmp != 0) {
        pointerWidthRadius = pointerWidthRadiusTmp;
    }

    double pointerRadiusTmp = parseDouble(pointerElement.getLayoutStyle().getValue(BoxStyleKeys.HEIGHT)) / 100;
    if (pointerRadiusTmp != 0) {
        pointerRadius = pointerRadiusTmp;
    }

    final BasicStroke borderStyleStroke = StrokeFactory.getInstance().getBorderStroke(pointerElement);
    if (borderStyleStroke != null) {
        pointerOutlineStroke = borderStyleStroke;
    }

    pointer.setRadius(pointerRadius);
    pointer.setOutlineStroke(pointerOutlineStroke);
    pointer.setWidthRadius(pointerWidthRadius);
    pointer.setFillPaint(pointerFillPaint);
    pointer.setOutlinePaint(pointerOutlinePaint);
    // DialPointer pointer = new DialPointer.Pin();
    dialPlot.addPointer(pointer);
}

From source file:DashboardInterface.CableOutSpeedDial.java

public CableOutSpeedDial(JPanel parentIn) {
    super(new BorderLayout());
    parent = parentIn;/*from w  w w.ja va 2s. 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("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;/*from   www . j ava 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:ecg.ecgshow.ECGShowUI.java

private void createGuardData() {
    GuardDataPanel = new JPanel();
    GuardDataPanel.setBackground(new Color(0, 150, 255));
    //        GuardDataPanel.setBounds();
    //        BoxLayout layout=new BoxLayout(GuardDataPanel,BoxLayout.Y_AXIS);
    //        GuardDataPanel.setLayout(layout);
    GroupLayout layout = new GroupLayout(GuardDataPanel);
    GuardDataPanel.setLayout(layout);/*w w  w . j a va  2  s  .  c  o m*/
    JPanel temperatureData = new JPanel();
    temperatureData.setLayout(new FlowLayout());
    //        temperatureData.setLayout(null);
    //        temperatureData.setBounds(0,0,(int) (WIDTH * 0.14), (int) (HEIGHT * 0.15));
    temperatureData.setSize((int) (WIDTH * 0.16), (int) (HEIGHT * 0.11));
    temperatureData.setBackground(new Color(0, 150, 255));
    temperatureLabel = new JLabel("--.- ");
    temperatureLabel.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070)));
    temperatureLabel.setBackground(new Color(0, 150, 255));
    temperatureLabel.setForeground(Color.RED);
    //        temperatureLabel.setBounds(0,0,200,100);
    temperatureLabel.setOpaque(true);
    JLabel temperatureLabelName = new JLabel(" ");
    temperatureLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020)));
    temperatureLabelName.setBackground(new Color(0, 150, 255));
    temperatureLabelName.setForeground(Color.BLACK);
    temperatureLabelName.setBounds(0, 0, 100, 100);
    temperatureLabelName.setOpaque(true); //??
    temperatureData.add(temperatureLabelName);
    temperatureData.add(temperatureLabel);
    //        JPanel emptyPanel=new JPanel();
    //        emptyPanel.setSize((int)(WIDTH*0.14),(int)(HEIGHT*0.2));
    //        emptyPanel.setBackground(new Color(0,150,255));
    //        GuardDataPanel.add(emptyPanel);

    JPanel lightValueData = new JPanel();
    lightValueData.setLayout(new BorderLayout());
    lightValueData.setBackground(new Color(0, 150, 255));
    //        lightValueData.setBounds(0,(int)(HEIGHT*0.28),(int)(WIDTH*0.14),(int)(HEIGHT*0.30));
    lightValueData.setSize((int) (WIDTH * 0.14), (int) (HEIGHT * 0.22));
    lightValueDataSet = new DefaultValueDataset();
    DialPlot lightValueDialPlot = new DialPlot();
    lightValueDialPlot.setDataset(lightValueDataSet);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setVisible(false);
    lightValueDialPlot.setDialFrame(dialFrame);

    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 170));
    DialBackground dialBackground = new DialBackground(gradientpaint);
    dialBackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    lightValueDialPlot.setBackground(dialBackground);
    // ??
    DialTextAnnotation dialtextannotation = new DialTextAnnotation("");
    dialtextannotation.setFont(new Font("Dialog", 0, (int) (0.016 * HEIGHT)));
    dialtextannotation.setRadius(0.1D);
    lightValueDialPlot.addLayer(dialtextannotation);

    DialValueIndicator dialValueIndicator = new DialValueIndicator(0);
    dialValueIndicator.setFont(new Font("Dialog", Font.PLAIN, (int) (0.011 * HEIGHT)));
    dialValueIndicator.setOutlinePaint(Color.darkGray);
    dialValueIndicator.setRadius(0.4D);
    dialValueIndicator.setAngle(-90.0);
    lightValueDialPlot.addLayer(dialValueIndicator);

    StandardDialScale dialScale = new StandardDialScale();
    dialScale.setLowerBound(0D); // 
    dialScale.setUpperBound(1024); // 
    dialScale.setMajorTickIncrement(100);
    dialScale.setStartAngle(-120D); // 120,?
    dialScale.setExtent(-300D); // 300,?
    dialScale.setTickRadius(0.85D); // ,
    dialScale.setTickLabelOffset(0.1D); // ,0

    bloodDialRange = new StandardDialRange(500D, 750D, Color.red);
    bloodDialRange.setInnerRadius(0.52000000000000002D);
    bloodDialRange.setOuterRadius(0.55000000000000004D);
    lightValueDialPlot.addLayer(bloodDialRange);
    //
    bubbleDialRange = new StandardDialRange(0D, 500D, Color.black);
    bubbleDialRange.setInnerRadius(0.52000000000000002D);
    bubbleDialRange.setOuterRadius(0.55000000000000004D);
    lightValueDialPlot.addLayer(bubbleDialRange);
    //
    normalDialRange = new StandardDialRange(750D, 1024D, Color.green);
    normalDialRange.setInnerRadius(0.52000000000000002D);
    normalDialRange.setOuterRadius(0.55000000000000004D);
    lightValueDialPlot.addLayer(normalDialRange);

    dialScale.setTickLabelFont(new Font("Dialog", 0, (int) (0.011 * HEIGHT))); // 
    lightValueDialPlot.addScale(0, dialScale);

    DialPointer.Pointer pointer = new DialPointer.Pointer();
    lightValueDialPlot.addPointer(pointer);
    lightValueDialPlot.mapDatasetToScale(0, 0);
    DialCap dialCap = new DialCap();
    dialCap.setRadius(0.07D);
    JFreeChart lightValueDialChart = new JFreeChart(lightValueDialPlot);
    lightValueDialChart.setBackgroundPaint(new Color(0, 150, 255));
    lightValueDialChart.setTitle("??");
    lightValueDialChart.getTitle().setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020)));
    ChartPanel lightValueDialChartPanel = new ChartPanel(lightValueDialChart, (int) (WIDTH * 0.15),
            (int) (HEIGHT * 0.27), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false,
            false);
    lightValueData.add(lightValueDialChartPanel, BorderLayout.CENTER);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                            .addComponent(temperatureData, GroupLayout.Alignment.LEADING)
                            .addComponent(lightValueData, GroupLayout.Alignment.LEADING))));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05))
                    .addComponent(temperatureData)
                    .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05))
                    .addComponent(lightValueData)
                    .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05))));

    //        JPanel alarmMessage=new JPanel();
    //        alarmMessage.setBackground(new Color(0,150,255));
    //        alarmMessLabel=new JLabel("");
    //        alarmMessLabel.setFont(new Font("SansSerif", 0, (int)(HEIGHT *0.020)));
    //        alarmMessLabel.setBackground(new Color(0,150,255));
    //        alarmMessage.add(alarmMessLabel);
    //        GuardDataPanel.add(alarmMessage);
}