Package org.geoforge.jfreechart.xyplot

Source Code of org.geoforge.jfreechart.xyplot.GfrXYPlotColDepAbs

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.jfreechart.xyplot;

import java.util.List;
import java.util.Observer;
import java.util.logging.Logger;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.jfreechart.axis.GfrAxsLinRngCol;
import org.geoforge.jfreechart.handler.IGfrDepthMetersAndFeet;
import org.geoforge.jfreechart.handler.IHandlerContainerVariableLayer;
import org.geoforge.jfreechart.handler.IHandlerContainerVariableMarkersTlo;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.chart.annotations.Annotation;

/**
*
* @author robert
*/
abstract public class GfrXYPlotColDepAbs extends GfrXYPlot implements
        Observer,
        IGfrDepthMetersAndFeet,
        IHandlerContainerVariableMarkersTlo,
        IHandlerContainerVariableLayer
{
   // ----
   // begin: instantiate logger for this class

   final private static Logger _LOGGER_ = Logger.getLogger(GfrXYPlotColDepAbs.class.getName());

   static
   {
      GfrXYPlotColDepAbs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
   }
   // end: instantiate logger for this class
   // ----
  
  
   protected boolean _blnUnitDepthMeter = false; // ATTN: SHOULD BE UPDATED
   protected String _strIdTlo = null;
  
   abstract protected void _updateRenderer() throws Exception;
   abstract protected void _updateLayers_() throws Exception;
  
   protected GfrXYPlotColDepAbs(
           XYDataset dataset,
           String strLabelAxisRange,
           XYItemRenderer renderer,
           boolean blnUnitDepthMeter,
           String strIdTlo) throws Exception
   {
      super(dataset,
              (ValueAxis) null, // domainAxis,
              new GfrAxsLinRngCol(strLabelAxisRange),
              renderer);
     
      this._blnUnitDepthMeter = blnUnitDepthMeter;
      this._strIdTlo  = strIdTlo;
     
      super.setRangeGridlinesVisible(false);
     
      _update_();
   }
  
   @Override
   public void setUnitDepthMeter(boolean bln)
   {
      XYDataset dst = super.getDataset();

      if (dst != null)
      { 
         if (dst instanceof IGfrDepthMetersAndFeet)
            ((IGfrDepthMetersAndFeet) dst).setUnitDepthMeter(bln);
      }
     
      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);
         }
      }
     
     lstAnnotations = super.getRenderer().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);
         }
      }
   }
  
   protected void _update_() throws Exception
   {
      _updateRenderer();
      _updateLayers_();
   }
  
   @Override
   public boolean removeVariableLayer(String strId) throws Exception
   {
      _updateLayers_();
      return true;
   }

   @Override
   public boolean addVariableLayer(String strId) throws Exception
   {
      _updateLayers_();
      return true;
   }

   @Override
   public boolean removeAllLayers() throws Exception
   {
      // seems to be handled elsewhere !!!
      //GfrXYPlotColMecDpt._LOGGER_.warning("TODO");
     
      /*--memo amadeus : never used coz iterating somewhere on objects,
       * but should be better to removeAll with this method(i.e. for db performance).
       * (e.g.) iterating in GfrNodCtrFixFolderSetFixPrjAbs
      */
      return true;
   }
  
   @Override
   public boolean removeAllMarkersTlo() throws Exception
    {  
       if (((IHandlerContainerVariableMarkersTlo) super.getDataset()).removeAllMarkersTlo())
       {
         _update_();
         return true;
       }
      
       return false;
    }

   @Override
    public boolean addVariableMarkerTlo(String strId) throws Exception
    {
        if (((IHandlerContainerVariableMarkersTlo) super.getDataset()).addVariableMarkerTlo(strId))
        {
            _update_();
            return true;
        }
       
        return false;
    }
   
    @Override
    public boolean removeVariableMarkerTlo(String strId) throws Exception
    {
        if (((IHandlerContainerVariableMarkersTlo) super.getDataset()).removeVariableMarkerTlo(strId))
        {
            _update_();
            return true;
        }
       
        return false;
    }
}
TOP

Related Classes of org.geoforge.jfreechart.xyplot.GfrXYPlotColDepAbs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.