001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/graphics/sld/LabelPlacement.java $
002 /*----------------------------------------------------------------------------
003 This file is part of deegree, http://deegree.org/
004 Copyright (C) 2001-2009 by:
005 Department of Geography, University of Bonn
006 and
007 lat/lon GmbH
008
009 This library is free software; you can redistribute it and/or modify it under
010 the terms of the GNU Lesser General Public License as published by the Free
011 Software Foundation; either version 2.1 of the License, or (at your option)
012 any later version.
013 This library is distributed in the hope that it will be useful, but WITHOUT
014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016 details.
017 You should have received a copy of the GNU Lesser General Public License
018 along with this library; if not, write to the Free Software Foundation, Inc.,
019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020
021 Contact information:
022
023 lat/lon GmbH
024 Aennchenstr. 19, 53177 Bonn
025 Germany
026 http://lat-lon.de/
027
028 Department of Geography, University of Bonn
029 Prof. Dr. Klaus Greve
030 Postfach 1147, 53001 Bonn
031 Germany
032 http://www.geographie.uni-bonn.de/deegree/
033
034 e-mail: info@deegree.org
035 ----------------------------------------------------------------------------*/
036 package org.deegree.graphics.sld;
037
038 import org.deegree.framework.xml.Marshallable;
039
040 /**
041 * Used to position a label relative to a point or a line string. For a point, you can specify the
042 * anchor point of the label and a linear displacement from the point (so that you can also plot a
043 * graphic symbol at the point). For a line-string placement, you can specify a perpendicular offset
044 * (so you can draw a stroke on the line). MORE PARAMETERS ARE PROBABLY NEEDED HERE.
045 * <p>
046 *
047 * @author <a href="mailto:k.lupp@web.de">Katharina Lupp</a>
048 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider</a>
049 * @version $Revision: 18195 $ $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
050 */
051
052 public class LabelPlacement implements Marshallable {
053
054 private LinePlacement linePlacement = null;
055
056 private PointPlacement pointPlacement = null;
057
058 /**
059 * constructor initializing the class with the <LabelPlacement>
060 * @param pointPlacement
061 */
062 public LabelPlacement( PointPlacement pointPlacement ) {
063 setPointPlacement( pointPlacement );
064 }
065
066 /**
067 * constructor initializing the class with the <LabelPlacement>
068 * @param linePlacement
069 */
070 public LabelPlacement( LinePlacement linePlacement ) {
071 setLinePlacement( linePlacement );
072 }
073
074 /**
075 * For a PointPlacement, the anchor point of the label and a linear displacement from the point
076 * can be specified, to allow a graphic symbol to be plotted directly at the point. This might
077 * be useful to label a city, for example.
078 *
079 * @return the pointplacement for the label
080 *
081 */
082 public PointPlacement getPointPlacement() {
083 return pointPlacement;
084 }
085
086 /**
087 * sets <PointPlacement>
088 *
089 * @param pointPlacement
090 * the pointplacement for the label
091 *
092 */
093 public void setPointPlacement( PointPlacement pointPlacement ) {
094 this.pointPlacement = pointPlacement;
095 linePlacement = null;
096 }
097
098 /**
099 * For a LinePlacement, a perpendicular offset can be specified, to allow the line itself to be
100 * plotted also. This might be useful for labelling a road or a river, for example.
101 *
102 * @return the lineplacement for the label
103 *
104 */
105 public LinePlacement getLinePlacement() {
106 return linePlacement;
107 }
108
109 /**
110 * sets <LinePlacement>
111 *
112 * @param linePlacement
113 * the lineplacement for the label
114 *
115 */
116 public void setLinePlacement( LinePlacement linePlacement ) {
117 this.linePlacement = linePlacement;
118 pointPlacement = null;
119 }
120
121 /**
122 * exports the content of the Font as XML formated String
123 *
124 * @return xml representation of the Font
125 */
126 public String exportAsXML() {
127
128 StringBuffer sb = new StringBuffer( 1000 );
129 sb.append( "<LabelPlacement>" );
130 if ( pointPlacement != null ) {
131 sb.append( ( (Marshallable) pointPlacement ).exportAsXML() );
132 } else if ( linePlacement != null ) {
133 sb.append( ( (Marshallable) linePlacement ).exportAsXML() );
134 }
135 sb.append( "</LabelPlacement>" );
136
137 return sb.toString();
138 }
139
140 }