Search in sources :

Example 1 with XYTitleAnnotation

use of org.jfree.chart.annotations.XYTitleAnnotation in project CS3243-Project by Kangqing-Qiu.

the class MatlabChart method legend.

public void legend(String position) {
    CheckExists();
    legend.setItemFont(font);
    legend.setBackgroundPaint(Color.WHITE);
    legend.setFrame(new BlockBorder(Color.BLACK));
    if (position.toLowerCase().equals("northoutside")) {
        legend.setPosition(RectangleEdge.TOP);
        chart.addLegend(legend);
    } else if (position.toLowerCase().equals("eastoutside")) {
        legend.setPosition(RectangleEdge.RIGHT);
        chart.addLegend(legend);
    } else if (position.toLowerCase().equals("southoutside")) {
        legend.setPosition(RectangleEdge.BOTTOM);
        chart.addLegend(legend);
    } else if (position.toLowerCase().equals("westoutside")) {
        legend.setPosition(RectangleEdge.LEFT);
        chart.addLegend(legend);
    } else if (position.toLowerCase().equals("north")) {
        legend.setPosition(RectangleEdge.TOP);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.50, 0.98, legend, RectangleAnchor.TOP);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("northeast")) {
        legend.setPosition(RectangleEdge.TOP);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.98, legend, RectangleAnchor.TOP_RIGHT);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("east")) {
        legend.setPosition(RectangleEdge.RIGHT);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.50, legend, RectangleAnchor.RIGHT);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("southeast")) {
        legend.setPosition(RectangleEdge.BOTTOM);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, legend, RectangleAnchor.BOTTOM_RIGHT);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("south")) {
        legend.setPosition(RectangleEdge.BOTTOM);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.50, 0.02, legend, RectangleAnchor.BOTTOM);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("southwest")) {
        legend.setPosition(RectangleEdge.BOTTOM);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.02, 0.02, legend, RectangleAnchor.BOTTOM_LEFT);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("west")) {
        legend.setPosition(RectangleEdge.LEFT);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.02, 0.50, legend, RectangleAnchor.LEFT);
        chart.getXYPlot().addAnnotation(ta);
    } else if (position.toLowerCase().equals("northwest")) {
        legend.setPosition(RectangleEdge.TOP);
        XYTitleAnnotation ta = new XYTitleAnnotation(0.02, 0.98, legend, RectangleAnchor.TOP_LEFT);
        chart.getXYPlot().addAnnotation(ta);
    }
}
Also used : BlockBorder(org.jfree.chart.block.BlockBorder) XYTitleAnnotation(org.jfree.chart.annotations.XYTitleAnnotation)

Aggregations

XYTitleAnnotation (org.jfree.chart.annotations.XYTitleAnnotation)1 BlockBorder (org.jfree.chart.block.BlockBorder)1