/*
 * $Id: CartesianRenderer.java,v 1.13 2003/08/22 23:02:31 dwd Exp $
 *
 * This software is provided by NOAA for full, free and open release.  It is
 * understood by the recipient/user that NOAA assumes no liability for any
 * errors contained in the code.  Although this software is released without
 * conditions or restrictions in its use, it is expected that appropriate
 * credit be given to its author and to the National Oceanic and Atmospheric
 * Administration should the software be included by the recipient as an
 * element in other product development.
 */

package sgtplot;



import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Point;
import java.beans.PropertyChangeListener;

import org.freehep.graphics2d.VectorGraphics;

import sgtplot.dm.Annotation;
import sgtplot.dm.Collection;
import sgtplot.dm.SGTData;
import sgtplot.dm.SGTGrid;
import sgtplot.dm.SGTImage;
import sgtplot.dm.SGTLine;
import sgtplot.dm.SGTPoint;
import sgtplot.dm.SGTVector;
import sgtplot.util.Debug;

/**
 * CartesianRenderer defines an interface to enable data to
 * be rendered on a CartesianGraph.
 *
 * @see CartesianGraph
 *
 * @author Donald Denbo
 * @version $Revision: 1.13 $, $Date: 2003/08/22 23:02:31 $
 * @since 1.0
 */
public abstract class CartesianRenderer implements PropertyChangeListener {
  /**
   * Factory method to create a new Renderer instance given
   * the SGTData object and Attribute.
   * For example, a LineCartesianRenderer
   * is created if SGTData object is a SGTLine.
   * 

* A renderer is constucted based on the two arguements. *

*

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*

SGTData *

*

Attribute *

*

CartesianRenderer *

SGTPointPointAttributePointCartesianRenderer
SGTLineLineAttributeLineCartesianRenderer
SGTGridGridAttributeGridCartesianRenderer
SGTVectorVectorAttributeVectorCartesianRenderer
CollectionPointAttributePointCartesianRenderer
CollectionLineAttributeLineCartesianRenderer
CollectionVectorAttributeVectorCartesianRenderer
Annotationn/aAnnotationCartesianRenderer
*

* * @param dmo DataModel object */ public static CartesianRenderer getRenderer(CartesianGraph cg, SGTData dmo, Attribute attr) { if(dmo instanceof SGTPoint) { return new PointCartesianRenderer(cg, (SGTPoint)dmo, (PointAttribute)attr); } else if(dmo instanceof SGTLine) { return new LineCartesianRenderer(cg, (SGTLine)dmo, (LineAttribute)attr); } else if(dmo instanceof SGTGrid) { return new GridCartesianRenderer(cg, (SGTGrid)dmo, (GridAttribute)attr); } else if(dmo instanceof SGTVector) { return new VectorCartesianRenderer(cg, (SGTVector)dmo, (VectorAttribute)attr); } else if(dmo instanceof Collection) { Object fe = ((Collection)dmo).firstElement(); if(fe instanceof SGTPoint) { return new PointCartesianRenderer(cg, (Collection)dmo, (PointAttribute)attr); } else if(fe instanceof SGTLine) { return new LineCartesianRenderer(cg, (Collection)dmo, (LineAttribute)attr); } else if(fe instanceof SGTVector) { return new VectorCartesianRenderer(cg, (Collection)dmo, (VectorAttribute)attr); } } else if(dmo instanceof Annotation) { return new AnnotationCartesianRenderer(cg, (Annotation)dmo, null); } return null; } /** * Render the SGTData object. This method should * never be called directly. * * @see Pane#draw */ public abstract void draw(VectorGraphics g); /** * Get the Attribute associated with the * renderer. * * @return the Attribute */ public abstract Attribute getAttribute(); /** * Get the CartesianGraph associated with the * renderer. * @since 2.0 * * @return the CartesianGraph */ public abstract CartesianGraph getCartesianGraph(); /** @directed * @label cg*/ protected CartesianGraph cg_; /** * Get parent pane. * @since 2.0 */ public AbstractPane getPane() { return cg_.getPane(); } /** * For internal sgtplot use. * @since 2.0 */ public void modified(String mess) { if(cg_ != null) cg_.modified(mess); } /** * Find data object. * @since 3.0 */ public SGTData getDataAt(int x, int y) { return getDataAt(new Point(x, y)); } /** * Find data object. * @since 3.0 */ public abstract SGTData getDataAt(Point pt); }

Ads help maintain this website.