/************************************************************************** /* 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.awt.*; import java.awt.geom.*; /** Text label. Used for free floating text, axis labels and so on. The class is called PLabel to prevent a name clash with java.awt.Label.

Labels are positioned relative to a reference point. The direction defines the way the text is plotted (e.g. left to right or top down), while the rotation defines if and how much each character is rotated.

Most functionality not implemented yet! @version $Revision: 1.3 $ @author $Author: bablokb $ */ public class PLabel extends AbstractPlottable { ///////////////////////////////////////////////////////////////////////////// /** Text of label. */ private String iText = null; ///////////////////////////////////////////////////////////////////////////// /** Reference point. */ private Point2D iPoint = null; ///////////////////////////////////////////////////////////////////////////// /** Default constructor. */ public PLabel() { } ///////////////////////////////////////////////////////////////////////////// /** Construct a PLabel with the specified string and position. */ public PLabel(String s, Point2D p) { iText = s; iPoint = p; } ///////////////////////////////////////////////////////////////////////////// /** Construct a PLabel with the specified string and position. */ public PLabel(String s, double x, double y) { iText = s; iPoint = Toolkit.getDefaultToolkit().getPoint2D(); iPoint.setLocation(x,y); } ///////////////////////////////////////////////////////////////////////////// /** Sets properties-object. */ public void setProperties(PLabelProperties plp) { iProperties = plp; } ///////////////////////////////////////////////////////////////////////////// /** Set text of label. */ public void setText(String text) { iText = text; } ///////////////////////////////////////////////////////////////////////////// /** Set point of label. */ public void setReferencePoint(Point2D point) { iPoint = point; } ///////////////////////////////////////////////////////////////////////////// /** Plot the text. */ public void plotObjects(PlottingContext pc) { Graphics2D g2 = pc.getG2(); if (iText != null && iPoint != null) { Point2D p = pc.transform(iPoint); g2.drawString(iText,(float) p.getX(),(float) p.getY()); } } }