Example usage for org.jfree.chart.annotations XYTextAnnotation setRotationAnchor

List of usage examples for org.jfree.chart.annotations XYTextAnnotation setRotationAnchor

Introduction

In this page you can find the example usage for org.jfree.chart.annotations XYTextAnnotation setRotationAnchor.

Prototype

public void setRotationAnchor(TextAnchor anchor) 

Source Link

Document

Sets the rotation anchor point and sends an AnnotationChangeEvent to all registered listeners.

Usage

From source file:org.jgrasstools.gears.utils.chart.Scatter.java

public void addAnnotation(String text, double x) {
    XYPlot plot = (XYPlot) getChart().getPlot();
    Color color = new Color(0, 0, 0, 100);
    Marker updateMarker = new ValueMarker(x, color, new BasicStroke(2f));
    plot.addDomainMarker(updateMarker);//from  w  w w .j  a v a2s  .c om
    if (text != null) {
        XYTextAnnotation updateLabel = new XYTextAnnotation(text, x, 0);
        updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
        updateLabel.setRotationAngle(-3.14 / 2);
        updateLabel.setPaint(Color.black);
        plot.addAnnotation(updateLabel);
    }
    setShapeLinesVisibility(plot);
}

From source file:org.zaproxy.zap.extension.ascan.ScanProgressDialog.java

/**
 * Update the current Scan progress and//from w w  w . j ava 2 s . c o  m
 * prepare actions and scan summary
 */

private void showProgress() {
    // Start panel data settings
    HostProcess hp = getSelectedHostProcess();
    if (scan.getHostProcesses() != null && hp != null) {

        // Update the main table entries
        model.updateValues(scan, hp);

        if (scan.isStopped()) {
            this.stopThread = true;
        }

        if (chart != null) {
            ResponseCountSnapshot snapshot = scan.getRequestHistory();
            while (snapshot != null) {
                try {
                    Second second = new Second(snapshot.getDate());
                    this.seriesTotal.add(second, snapshot.getTotal());
                    this.series100.add(second, snapshot.getResp100());
                    this.series200.add(second, snapshot.getResp200());
                    this.series300.add(second, snapshot.getResp300());
                    this.series400.add(second, snapshot.getResp400());
                    this.series500.add(second, snapshot.getResp500());
                    snapshot = scan.getRequestHistory();

                    for (Plugin plugin : scan.getHostProcesses().get(0).getRunning()) {
                        if (!labelsAdded.contains(plugin.getName())) {
                            // Add a vertical line with the plugin name
                            ValueMarker vm = new ValueMarker(plugin.getTimeStarted().getTime());

                            double center = chart.getXYPlot().getRangeAxis().getRange().getCentralValue();
                            if (lastCentre != center) {
                                if (lastCentre != -1) {
                                    // Move the existing labels so they stay in the centre
                                    @SuppressWarnings("rawtypes")
                                    List annotations = chart.getXYPlot().getAnnotations();
                                    for (Object o : annotations) {
                                        if (o instanceof XYTextAnnotation) {
                                            XYTextAnnotation annotation = (XYTextAnnotation) o;
                                            annotation.setY(center);
                                        }
                                    }
                                }
                                lastCentre = center;
                            }

                            XYTextAnnotation updateLabel = new XYTextAnnotation(plugin.getName(),
                                    plugin.getTimeStarted().getTime(), center);
                            updateLabel.setFont(FontUtils.getFont("Sans Serif"));
                            updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);

                            updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
                            updateLabel.setRotationAngle(-3.14 / 2);
                            updateLabel.setPaint(Color.black);
                            chart.getXYPlot().addDomainMarker(vm, Layer.BACKGROUND);
                            chart.getXYPlot().addAnnotation(updateLabel);
                            labelsAdded.add(plugin.getName());
                        }
                    }
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
}