Example usage for org.jfree.chart.entity TitleEntity getTitle

List of usage examples for org.jfree.chart.entity TitleEntity getTitle

Introduction

In this page you can find the example usage for org.jfree.chart.entity TitleEntity getTitle.

Prototype

public Title getTitle() 

Source Link

Document

Returns the title that occupies the entity area.

Usage

From source file:net.sf.mzmine.chartbasics.gestures.ChartGestureHandler.java

/**
 * Create preset handlers/*  w  w w . ja  v a 2s.  co  m*/
 * 
 * @param handler
 * @param g
 * @param param Parameters for specific handlers <br>
 * @return
 */
public static ChartGestureHandler createHandler(Handler handler, final ChartGesture g, Object[] param) {
    Consumer<ChartGestureEvent> newHandler = null;
    switch (handler) {
    case DEBUG:
        newHandler = e -> System.out.println(e.toString());
        break;
    case PREVIOUS_ZOOM_HISTORY:
        newHandler = e -> {
            ZoomHistory h = e.getChartWrapper().getZoomHistory();
            if (h != null) {
                Range[] range = h.setPreviousPoint();
                if (range != null && range.length > 0 && range[0] != null) {
                    ValueAxis dom = e.getChart().getXYPlot().getDomainAxis();
                    ValueAxis ran = e.getChart().getXYPlot().getRangeAxis();
                    ChartLogics.setZoomAxis(dom, range[0]);
                    ChartLogics.setZoomAxis(ran, range[1]);
                }
            }
        };
        break;
    case NEXT_ZOOM_HISTORY:
        newHandler = e -> {
            ZoomHistory h = e.getChartWrapper().getZoomHistory();
            if (h != null) {
                Range[] range = h.setNextPoint();
                if (range != null && range.length > 0 && range[0] != null) {
                    ValueAxis dom = e.getChart().getXYPlot().getDomainAxis();
                    ValueAxis ran = e.getChart().getXYPlot().getRangeAxis();
                    ChartLogics.setZoomAxis(dom, range[0]);
                    ChartLogics.setZoomAxis(ran, range[1]);
                }
            }
        };
        break;
    case TITLE_REMOVER:
        newHandler = e -> {
            if (e.getEntity() instanceof TitleEntity) {
                TitleEntity te = (TitleEntity) e.getEntity();
                te.getTitle().setVisible(false);
            }
        };
        break;
    case AUTO_ZOOM_AXIS:
        newHandler = e -> {
            ValueAxis a = e.getAxis();
            if (a != null)
                ChartLogics.autoAxis(a);
        };
        break;
    case AUTO_ZOOM_OPPOSITE_AXIS:
        newHandler = e -> {
            if (e.getGesture().getEntity().equals(Entity.AXIS)) {
                e.getChartWrapper().autoRangeAxis();
                e.getChartWrapper().autoDomainAxis();
            } else if (e.getGesture().getEntity().equals(Entity.DOMAIN_AXIS))
                e.getChartWrapper().autoRangeAxis();
            else
                e.getChartWrapper().autoDomainAxis();
        };
        break;
    case SCROLL_AXIS:
        newHandler = e -> {
            ValueAxis axis = e.getAxis();
            if (axis != null) {
                double diff = 0.03;
                if (e.getMouseEvent().isMouseWheelEvent()) {
                    diff = -0.10 * e.getMouseEvent().getWheelRotation();
                }
                ChartLogics.offsetAxis(axis, diff);
            }
        };
        break;
    case SCROLL_AXIS_AND_AUTO_ZOOM:
        newHandler = e -> {
            ValueAxis axis = e.getAxis();
            if (axis != null) {
                double diff = 0.03;
                if (e.getMouseEvent().isMouseWheelEvent()) {
                    diff = -0.10 * e.getMouseEvent().getWheelRotation();
                }
                ChartLogics.offsetAxis(axis, diff);

                if (e.getGesture().getEntity().equals(Entity.DOMAIN_AXIS))
                    e.getChartWrapper().autoRangeAxis();
                else
                    e.getChartWrapper().autoDomainAxis();
            }
        };
        break;
    case ZOOM_AXIS_INCLUDE_ZERO:
        newHandler = e -> {
            ValueAxis axis = e.getAxis();
            if (axis != null) {
                double diff = 0.05;
                if (e.getMouseEvent().isMouseWheelEvent()) {
                    diff = -0.10 * e.getMouseEvent().getWheelRotation();
                }
                ChartLogics.zoomAxis(axis, diff, true);
            }
        };
        break;
    case ZOOM_AXIS_CENTER:
        newHandler = e -> {
            ValueAxis axis = e.getAxis();
            if (axis != null) {
                MouseEventWrapper p = e.getMouseEvent();
                double diff = 0.05;
                if (e.getMouseEvent().isMouseWheelEvent()) {
                    diff = -0.10 * p.getWheelRotation();
                }

                // get data space coordinates
                Point2D point = e.getCoordinates(p.getX(), p.getY());
                if (point != null) {
                    // vertical ?
                    Boolean orient = e.isVerticalAxis(axis);
                    if (orient == null)
                        return;
                    else if (orient)
                        ChartLogics.zoomAxis(axis, diff, point.getY());
                    else
                        ChartLogics.zoomAxis(axis, diff, point.getX());
                }
            }
        };
        break;
    default:
        break;
    }
    if (newHandler == null)
        return null;
    else
        return new ChartGestureHandler(g, newHandler);
}