Example usage for org.jfree.chart.plot CompassPlot CompassPlot

List of usage examples for org.jfree.chart.plot CompassPlot CompassPlot

Introduction

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

Prototype

public CompassPlot(ValueDataset dataset) 

Source Link

Document

Constructs a new compass plot.

Usage

From source file:org.jfree.chart.demo.CompassDemo1.java

private static JFreeChart createChart(ValueDataset valuedataset) {
    CompassPlot compassplot = new CompassPlot(valuedataset);
    compassplot.setSeriesNeedle(7);//w  ww  .  j  av a 2 s  .com
    compassplot.setSeriesPaint(0, Color.black);
    compassplot.setSeriesOutlinePaint(0, Color.black);
    compassplot.setRosePaint(Color.red);
    compassplot.setRoseHighlightPaint(Color.gray);
    compassplot.setRoseCenterPaint(Color.white);
    compassplot.setDrawBorder(false);
    JFreeChart jfreechart = new JFreeChart(compassplot);
    return jfreechart;
}

From source file:org.usfirst.frc.team2084.smartdashboard.extensions.BetterCompass.java

@Override
public void init() {
    // needleType.add("Arrow", 0);
    // needleType.add("Line", 1);
    // needleType.add("Long", 2);
    // needleType.add("Pin", 3);
    // needleType.add("Plum", 4);
    // needleType.add("Pointer", 5);
    // needleType.add("Ship", 6);
    // needleType.add("Wind", 7);
    // needleType.add("Arrow Line", 8);
    // needleType.add("Middle Pin", 9);
    // needleType.setDefault("Arrow Line");

    SwingUtilities.invokeLater(() -> {
        setLayout(new BorderLayout());

        compass = new CompassPlot(getDataset());
        compass.setSeriesNeedle(8);//from w  w  w .  ja v a 2  s . com
        // propertyChanged(needleType);
        compass.setSeriesPaint(0, Color.RED);
        compass.setSeriesOutlinePaint(0, Color.RED);

        JFreeChart chart = new JFreeChart(getFieldName(), JFreeChart.DEFAULT_TITLE_FONT, compass, false);
        chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(250, 150));

        propertyChanged(circumference);
        propertyChanged(ringColor);

        add(chartPanel, BorderLayout.CENTER);

        revalidate();
        repaint();
    });
}

From source file:org.jfree.chart.demo.CompassDemo2.java

/**
 * Creates a chart./*  ww  w. j a  v  a  2  s .c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final ValueDataset dataset) {

    final CompassPlot plot = new CompassPlot(dataset);
    plot.setSeriesNeedle(7);
    plot.setSeriesPaint(0, Color.red);
    plot.setSeriesOutlinePaint(0, Color.red);
    final JFreeChart chart = new JFreeChart(plot);
    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.CompassDemo1.java

/**
 * Creates a chart./*from w ww  .ja v a 2s  . c o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(ValueDataset dataset) {

    CompassPlot plot = new CompassPlot(dataset);
    plot.setSeriesNeedle(7);
    plot.setSeriesPaint(0, Color.red);
    plot.setSeriesOutlinePaint(0, Color.red);
    plot.setRoseHighlightPaint(Color.CYAN);
    JFreeChart chart = new JFreeChart(plot);
    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.SuperValueChart.java

/**
 * Creates a chart.//from w ww .  j  av a  2s  .  co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(ValueDataset dataset) {
    // create the chart...
    // OPTIONAL CUSTOMISATION COMPLETED.
    CompassPlot plot = new CompassPlot(dataset);
    plot.setSeriesNeedle(7);
    plot.setSeriesPaint(0, Color.red);
    plot.setSeriesOutlinePaint(0, Color.red);
    plot.setRoseHighlightPaint(Color.CYAN);
    JFreeChart chart = new JFreeChart(plot);

    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates a compass chart./* w  w w  .j  a  v a2 s .  c  o  m*/
 *
 * @return a compass chart.
 */
public JFreeChart createCompassChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.compass.title");
    final String subtitleStr = this.resources.getString("meter.compass.subtitle");
    final DefaultValueDataset data = new DefaultValueDataset(new Double(45.0));

    final Plot plot = new CompassPlot(data);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*from   www.jav a 2  s  . c  o m*/
 *
 * @param g _more_
 * @param comp _more_
 */
public void paintDashboardAfter(Graphics g, JComponent comp) {

    Graphics2D g2 = (Graphics2D) g;
    AffineTransform oldTransform = g2.getTransform();
    Rectangle b = dashboardLbl.getBounds();
    int w = dashboardImage.getWidth(null);
    int h = dashboardImage.getHeight(null);
    Point ul = new Point(b.width / 2 - w / 2, b.height - h);
    int ptsIdx = 0;

    try {
        pipPanel.setPreferredSize(new Dimension(dialPts[ptsIdx][2], dialPts[ptsIdx][3]));
        pipFrame.setSize(dialPts[ptsIdx][2], dialPts[ptsIdx][3]);
        pipPanel.doLayout();
        pipPanel.validate();
        pipFrame.pack();
        pipPanel.resetDrawBounds();
        pipPanel.redraw();
    } catch (Exception ignore) {
    }

    JLabel locLbl = null;

    if (lastLocation != null) {
        try {
            locLbl = new JLabel("<html><table width=100%><tr><td align=right>&nbsp;Lat:</td></td>"
                    + getIdv().getDisplayConventions().formatLatLon(getLat(lastLocation)) + "</td></tr>"
                    + "<tr><td align=right>&nbsp;Lon:</td></td>"
                    + getIdv().getDisplayConventions().formatLatLon(getLon(lastLocation)) + "</td></tr>"
                    + "<tr><td align=right>&nbsp;Alt:</td></td>"
                    + getIdv().getDisplayConventions().formatDistance(getAlt(lastLocation)) + "</table>");
        } catch (Exception ignore) {
        }
    }
    if (locLbl == null) {
        locLbl = new JLabel(
                "<html><table width=100%><tr><td align=right>&nbsp;Lat:</td></td>N/A </td></tr><tr><td align=right>&nbsp;Lon:</td></td>N/A </td></tr><tr><td align=right>&nbsp;Alt:</td></td>N/A </table>");
    }
    locLbl.setOpaque(true);
    locLbl.setBackground(Color.white);

    DefaultValueDataset headingDataset = new DefaultValueDataset(new Double(currentHeading));

    CompassPlot plot = new CompassPlot(headingDataset);
    plot.setSeriesNeedle(0);
    plot.setSeriesPaint(0, Color.red);
    plot.setSeriesOutlinePaint(0, Color.red);
    JFreeChart chart = new JFreeChart("", plot);
    ChartPanel compassPanel = new ChartPanel(chart);

    plot.setBackgroundPaint(new Color(255, 255, 255, 0));
    plot.setBackgroundImageAlpha(0.0f);
    chart.setBackgroundPaint(new Color(255, 255, 255, 0));
    compassPanel.setBackground(new Color(255, 255, 255, 0));
    compassPanel.setPreferredSize(dialDimension);
    //        compassPanel.setSize(new Dimension(100,100));

    g2.setTransform(oldTransform);
    pipRect = drawDial(g2, pipPanel, ptsIdx++, ul);

    JFrame dummyFrame = new JFrame("");
    dummyFrame.setContentPane(compassPanel);
    dummyFrame.pack();

    g2.setTransform(oldTransform);
    drawDial(g2, compassPanel, ptsIdx++, ul);

    g2.setTransform(oldTransform);
    dummyFrame.setContentPane(locLbl);
    dummyFrame.pack();
    drawDial(g2, locLbl, ptsIdx++, ul);

    if (showReadout) {
        for (JComponent dial : dials) {
            dummyFrame.setContentPane(dial);
            dummyFrame.pack();

            g2.setTransform(oldTransform);
            drawDial(g2, dial, ptsIdx++, ul);
        }
    }

    g2.setTransform(oldTransform);

}

From source file:se.technipelago.weather.chart.Generator.java

private void createWindCompass(int direction, final String filename) throws IOException {
    final ValueDataset dataset = new DefaultValueDataset(direction);
    final CompassPlot plot2 = new CompassPlot(dataset);
    plot2.setSeriesNeedle(7);/*www.ja  va 2  s .  com*/
    plot2.setSeriesPaint(0, Color.red);
    plot2.setSeriesOutlinePaint(0, Color.red);

    final JFreeChart chart = new JFreeChart(plot2);
    //final TextTitle title = new TextTitle("Vindriktning", new Font("Dialog", Font.BOLD, 12));
    //title.setPaint(Color.DARK_GRAY);
    //chart.setTitle(title);
    chart.setBackgroundPaint(VERY_LIGHT_GRAY);

    OutputStream out = null;
    try {
        out = new FileOutputStream(outputDir != null ? outputDir + "/" + filename : filename);
        ChartUtilities.writeChartAsPNG(out, chart, DIAL_WIDTH, DIAL_HEIGHT);
    } finally {
        if (out != null) {
            out.close();
        }
    }
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createCompassChart(String title, ValueDataset dataset) {
    // create the chart...
    CompassPlot plot = new CompassPlot(dataset);
    plot.setSeriesNeedle(7);//w  ww  .  j  a  v a  2 s  .co  m
    plot.setSeriesPaint(0, Color.red);
    plot.setSeriesOutlinePaint(0, Color.red);
    plot.setRoseHighlightPaint(Color.CYAN);
    JFreeChart chart = new JFreeChart(plot);

    return chart;

}