001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2002, Centre for Computational Geography
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.styling;
018:
019: import org.geotools.event.AbstractGTComponent;
020: import org.geotools.factory.CommonFactoryFinder;
021: import org.geotools.factory.GeoTools;
022: import org.geotools.resources.Utilities;
023: import org.opengis.filter.FilterFactory;
024: import org.opengis.filter.expression.Expression;
025: import org.opengis.util.Cloneable;
026:
027: // J2SE dependencies
028: import java.util.logging.Logger;
029:
030: /**
031: * DOCUMENT ME!
032: *
033: * @author Ian Turton, CCG
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/LinePlacementImpl.java $
035: * @version $Id: LinePlacementImpl.java 27862 2007-11-12 19:51:19Z desruisseaux $
036: */
037: public class LinePlacementImpl extends AbstractGTComponent implements
038: LinePlacement, Cloneable {
039: /** The logger for the default core module. */
040: private static final Logger LOGGER = org.geotools.util.logging.Logging
041: .getLogger("org.geotools.core");
042: private FilterFactory filterFactory;
043: private Expression perpendicularOffset = null;
044:
045: public LinePlacementImpl() {
046: this (CommonFactoryFinder.getFilterFactory(GeoTools
047: .getDefaultHints()));
048: }
049:
050: public LinePlacementImpl(FilterFactory factory) {
051: filterFactory = factory;
052: init();
053: }
054:
055: public void setFilterFactory(FilterFactory factory) {
056: filterFactory = factory;
057: init();
058: }
059:
060: /**
061: * Creates a new instance of DefaultLinePlacement
062: */
063: private void init() {
064: try {
065: perpendicularOffset = filterFactory.literal(0);
066: } catch (org.geotools.filter.IllegalFilterException ife) {
067: LOGGER.severe("Failed to build defaultLinePlacement: "
068: + ife);
069: }
070: }
071:
072: /**
073: * Getter for property perpendicularOffset.
074: *
075: * @return Value of property perpendicularOffset.
076: */
077: public Expression getPerpendicularOffset() {
078: return perpendicularOffset;
079: }
080:
081: /**
082: * Setter for property perpendicularOffset.
083: *
084: * @param perpendicularOffset New value of property perpendicularOffset.
085: */
086: public void setPerpendicularOffset(Expression perpendicularOffset) {
087: this .perpendicularOffset = perpendicularOffset;
088: fireChanged();
089: }
090:
091: public void accept(StyleVisitor visitor) {
092: visitor.visit(this );
093: }
094:
095: /* (non-Javadoc)
096: * @see Cloneable#clone()
097: */
098: public Object clone() {
099: try {
100: return super .clone();
101: } catch (CloneNotSupportedException e) {
102: throw new RuntimeException("This can not happen");
103: }
104: }
105:
106: /* (non-Javadoc)
107: * @see java.lang.Object#equals(java.lang.Object)
108: */
109: public boolean equals(Object obj) {
110: if (this == obj) {
111: return true;
112: }
113:
114: if (obj instanceof LinePlacementImpl) {
115: LinePlacementImpl other = (LinePlacementImpl) obj;
116:
117: return Utilities.equals(perpendicularOffset,
118: other.perpendicularOffset);
119: }
120:
121: return false;
122: }
123:
124: /* (non-Javadoc)
125: * @see java.lang.Object#hashCode()
126: */
127: public int hashCode() {
128: final int PRIME = 37;
129: int result = 17;
130:
131: if (perpendicularOffset != null) {
132: result = (result * PRIME) + perpendicularOffset.hashCode();
133: }
134:
135: return result;
136: }
137: }
|