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

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

Introduction

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

Prototype

public void setMinorTickLength(double length) 

Source Link

Document

Sets the length factor for the minor tick marks and sends a DialLayerChangeEvent to all registered listeners.

Usage

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

/**
 * Constructor.//from   ww w  . j  av a2 s .  co m
 */
public WindGauge() {
    this.setPrefSize(200.0, 200.0);
    lastHeading = 0.0;
    lastSpeed = 0.0;
    plot = new DialPlot();
    for (int i = 0; i < WIND_DIR_ITEMS; i++) {
        datasets[i] = new DefaultValueDataset();
        plot.setDataset(WIND_DIR_DATASET_INDEX_BASE + i, datasets[i]);
    }

    plot.setDataset(WIND_SPEED_DATASET_INDEX, speedDataset);
    plot.setDataset(WIND_GUST_DATASET_INDEX, gustDataset);
    plot.setDataset(MAX_WIND_SPEED_DATASET_INDEX, maxSpeedDataset);
    plot.setDataset(MAX_WIND_GUST_DATASET_INDEX, maxGustDataset);

    plot.addLayer(
            new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue)));

    StandardDialScale scale = new StandardDialScale(0.0, 360.0, 90.0, -360.0, 45.0, 1);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.9);
    scale.setTickLabelFormatter(new CompassHeadingFormat());
    scale.setTickLabelOffset(0.06);
    scale.setMajorTickPaint(new Color(0, 0, 0, 0));
    scale.setTickLabelPaint(Color.BLACK);
    scale.setMinorTickLength(scale.getMajorTickLength());
    scale.setMinorTickStroke(scale.getMajorTickStroke());
    plot.addScale(WIND_DIR_SCALE, scale);

    scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 10.0, 9);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.4);
    scale.setTickLabelFormatter(new DecimalFormat("##"));
    scale.setTickLabelOffset(.15);
    scale.setTickLabelPaint(Color.BLACK);
    plot.addScale(WIND_SPEED_SCALE, scale);

    DialPointer.Pointer pointer;
    for (int i = 1; i < WIND_DIR_ITEMS; i++) {
        pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE + i, false);
        pointer.setOutlinePaint(Color.RED);
        plot.addPointer(pointer);
    }

    plot.setDialFrame(new StandardDialFrame());
    pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE, true);
    Color fill = Color.CYAN;
    pointer.setFillPaint(fill);
    pointer.setOutlinePaint(Color.BLACK);
    plot.addPointer(pointer);

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

    DialPointer.Pin speedPin = new DialPointer.Pin(WIND_SPEED_DATASET_INDEX);
    speedPin.setPaint(WIND_SPEED_PIN_COLOR);
    speedPin.setRadius(WIND_SPEED_PIN_RADIUS);
    speedPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(speedPin);

    DialPointer.Pin gustPin = new DialPointer.Pin(WIND_GUST_DATASET_INDEX);
    gustPin.setPaint(WIND_GUST_PIN_COLOR);
    gustPin.setRadius(WIND_GUST_PIN_RADIUS);
    gustPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(gustPin);

    DialPointer.Pin maxSpeedPin = new DialPointer.Pin(MAX_WIND_SPEED_DATASET_INDEX);
    maxSpeedPin.setPaint(WIND_SPEED_PIN_COLOR);
    maxSpeedPin.setRadius(MAX_WIND_SPEED_PIN_RADIUS);
    maxSpeedPin
            .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(maxSpeedPin);

    DialPointer.Pin maxGustPin = new DialPointer.Pin(MAX_WIND_GUST_DATASET_INDEX);
    maxGustPin.setPaint(WIND_GUST_PIN_COLOR);
    maxGustPin.setRadius(MAX_WIND_GUST_PIN_RADIUS);
    maxGustPin
            .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(maxGustPin);

    speedAnnotation.setAngle(270.0);
    speedAnnotation.setRadius(.35);
    speedAnnotation.setPaint(Color.cyan);
    plot.addLayer(speedAnnotation);

    double angle = speedAnnotation.getAngle();
    double radius = speedAnnotation.getRadius();

    avgAnnotation.setPaint(Color.cyan);
    avgAnnotation.setAngle(angle);
    avgAnnotation.setRadius(radius + .1);
    plot.addLayer(avgAnnotation);

    for (int i = 0; i < WIND_DIR_ITEMS; i++)
        plot.mapDatasetToScale(WIND_DIR_DATASET_INDEX_BASE + i, WIND_DIR_SCALE);

    plot.mapDatasetToScale(WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(MAX_WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(MAX_WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE);

    StandardDialRange range = new StandardDialRange(0.0, 360.0, Color.BLACK);
    range.setInnerRadius(.70);
    range.setOuterRadius(.72);
    range.setScaleIndex(WIND_DIR_SCALE);
    plot.addLayer(range);

    JFreeChart chart = new JFreeChart(plot);
    chart.setBackgroundPaint(Color.GRAY);

    chartViewer = new ChartViewer(chart);
    //chartViewer.setMinHeight(100);
    //chartViewer.setMinWidth(100);
    //chartViewer.setMaxHeight(400);
    //chartViewer.setMaxWidth(400);
    //chartViewer.setBackground(Color.GRAY);
    //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED));

    this.setCenter(chartViewer);
    this.setTop(title);
    BorderPane.setAlignment(title, Pos.CENTER);
    title.textProperty().bind(titleProperty);
    setTitle("Wind");

    timeline.setCycleCount(9);
    timeline.setOnFinished((event) -> {
        datasets[0].setValue(currentHeading);
        speedDataset.setValue(currentSpeed);
        lastHeading = currentHeading;
        lastSpeed = currentSpeed;
    });
}