view gwt-client/src/main/java/org/dive4elements/river/client/shared/model/ChartInfo.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/java/org/dive4elements/river/client/shared/model/ChartInfo.java@821a02bbfb4e
children 172338b1407f
line wrap: on
line source
package org.dive4elements.river.client.shared.model;

import java.io.Serializable;

import com.google.gwt.core.client.GWT;

import org.dive4elements.river.client.shared.Transform2D;


/**
 * Give information about chart dimension and transform of chart<->pixel
 * space.
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class ChartInfo implements Serializable {

    protected Axis[] xAxes;
    protected Axis[] yAxes;

    protected Transform2D[] transformer;


    public ChartInfo() {
    }


    public ChartInfo(Axis[] xAxes, Axis[] yAxes, Transform2D[] transformer) {
        this.xAxes       = xAxes;
        this.yAxes       = yAxes;
        this.transformer = transformer;
    }


    public Transform2D getTransformer(int pos) {
        if (pos >= 0 && pos < transformer.length) {
            return transformer[pos];
        }

        return null;
    }


    public int getTransformerCount() {
        return transformer.length;
    }


    public int getXAxisCount() {
        return xAxes.length;
    }


    public int getYAxisCount() {
        return yAxes.length;
    }


    public Axis getXAxis(int pos) {
        if (pos >= 0 && pos < xAxes.length) {
            return xAxes[pos];
        }

        return null;
    }


    public Axis getYAxis(int pos) {
        if (pos >= 0 && pos < yAxes.length) {
            return yAxes[pos];
        }

        return null;
    }


    public void dumpGWT() {
        StringBuilder sb = new StringBuilder();

        Axis x = getXAxis(0);

        GWT.log("X axis:");
        GWT.log("... from " + x.getFrom() + " to " + x.getTo());
        GWT.log("... min " + x.getMin() + " max " + x.getMax());

        for (int i = 0, count = getYAxisCount(); i < count; i++) {
            Axis y = getYAxis(i);

            GWT.log("Y axis " + i + ":");
            GWT.log("... from " + y.getFrom() + " to " + y.getTo());
            GWT.log("... min " + y.getMin() + " max " + y.getMax());
        }

        for (Transform2D t: transformer) {
            t.dumpGWT();
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org