/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.jfreechart.xyplot;
import java.util.List;
import org.geoforge.jfreechart.handler.IGfrDepthMetersAndFeet;
import org.geoforge.jfreechart.axis.GfrAxsLinDstAbs;
import org.geoforge.jfreechart.data.xy.GfrEmptyDataSet;
import org.jfree.chart.annotations.Annotation;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.xy.XYDataset;
/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*/
abstract public class GfrXYPlotGridDepAbs extends GfrXYPlotGridAbs implements
IGfrDepthMetersAndFeet
{
//--
//--beg public methods
protected GfrXYPlotGridDepAbs(
XYDataset dataset,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYItemRenderer renderer)
{
super(
dataset,
domainAxis,
rangeAxis,
renderer);
}
@Override
public void setUnitDepthMeter(boolean bln)
{
ValueAxis vas = super.getDomainAxis(0);
((GfrAxsLinDstAbs) vas).setUnitMeter(bln);
XYDataset dst = super.getDataset();
if (dst != null)
{
if (dst instanceof IGfrDepthMetersAndFeet)
((IGfrDepthMetersAndFeet) dst).setUnitDepthMeter(bln);
else if (dst instanceof GfrEmptyDataSet)
{
//ignore
}
else
{
System.out.println("Uncaught dataset" + dst.toString());
System.exit(1);
}
}
List<Annotation> lstAnnotations = super.getAnnotations();
if (lstAnnotations != null)
{
for (int i = 0; i < lstAnnotations.size(); i++)
{
Annotation ant = lstAnnotations.get(i);
if (ant instanceof IGfrDepthMetersAndFeet)
((IGfrDepthMetersAndFeet) ant).setUnitDepthMeter(bln);
else
{
System.out.println("Uncaught annotation" + ant.toString());
System.exit(1);
}
}
}
}
//--end public methods
//--
}