/************************************************************************** /* This class is part of the Java Plotlib Toolkit. /* /* Copyright (c) 1999-2004 by Bernhard Bablok (bablokb@gmx.de) /* /* This program is free software; you can redistribute it and/or modify /* it under the terms of the GNU General Public License as published /* by the Free Software Foundation; either version 2 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 Library General Public License for more details. /* /* You should have received a copy of the GNU General Public License /* along with this program; see the file COPYING. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ package de.bablokb.plotlib.core; import java.util.*; import java.awt.*; import java.awt.geom.*; /** Plot a symbol. A Symbol is defined by the location (Point2D) and various attributes (see SymbolProperties). The actual graphical form of the symbol is implemented by a private class, which implements a plot() method. @version $Revision: 1.3 $ @author $Author: bablokb $ */ public class Symbol extends AbstractPlottable { ///////////////////////////////////////////////////////////////////////////// /** Symbol location (instance of Point2D). */ private Point2D iPoint; ///////////////////////////////////////////////////////////////////////////// /** Default constructor: create and initialize a Symbol object. */ public Symbol() { iPoint = Toolkit.getDefaultToolkit().getPoint2D(); } ///////////////////////////////////////////////////////////////////////////// /** Create and initialize a Symbol object with a given point. */ public Symbol(Point2D p) { this(); iPoint.setLocation(p); } ///////////////////////////////////////////////////////////////////////////// /** Create and initialize a Symbol object with given coordinates. */ public Symbol(double x, double y) { this(); iPoint.setLocation(x,y); } ///////////////////////////////////////////////////////////////////////////// /** Sets properties-object. */ public void setProperties(SymbolProperties sp) { iProperties = sp; } ///////////////////////////////////////////////////////////////////////////// /** Set the location from given Point2D. */ public void setPoint(Point2D p) { iPoint.setLocation(p); } ///////////////////////////////////////////////////////////////////////////// /** Set the location from given coordinates. */ public void setPoint(double x, double y) { iPoint.setLocation(x,y); } ///////////////////////////////////////////////////////////////////////////// /** Query the location. */ public Point2D getPoint() { return iPoint; } ///////////////////////////////////////////////////////////////////////////// /** Plot the symbol. */ public void plotObjects(PlottingContext pc) { SymbolProperties sp; if (iProperties == null) sp = new SymbolProperties(); else sp = (SymbolProperties) iProperties; int symbolType = sp.getSymbolType(); if (symbolType == Plotlib.NONE) return; Graphics2D g2 = pc.getG2(); Form form = Plotlib.FORM_TABLE[symbolType]; form.setSize(sp.getSize()); form.setG2(g2); if (iPoint != null) form.plot(pc.transform(iPoint)); } }