Revision 10679 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleFillSymbol.java

View differences:

SimpleFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.4  2007-03-06 17:08:54  caballero
47
* Exceptions
46
* Revision 1.5  2007-03-09 11:20:57  jaume
47
* Advanced symbology (start committing)
48 48
*
49
* Revision 1.3.2.5  2007/02/21 07:34:09  jaume
50
* labeling starts working
51
*
52
* Revision 1.3.2.4  2007/02/16 10:54:12  jaume
53
* multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
54
*
55
* Revision 1.3.2.3  2007/02/15 16:23:44  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.3.2.2  2007/02/12 15:15:20  jaume
59
* refactored interval legend and added graduated symbol legend
60
*
61
* Revision 1.3.2.1  2007/02/09 07:47:05  jaume
62
* Isymbol moved
63
*
49 64
* Revision 1.3  2007/01/24 17:58:22  jaume
50 65
* new features and architecture error fixes
51 66
*
......
80 95
*/
81 96
package com.iver.cit.gvsig.fmap.core.symbols;
82 97

  
83
import java.awt.BasicStroke;
84 98
import java.awt.Graphics2D;
85 99
import java.awt.Rectangle;
86 100
import java.awt.Shape;
87 101
import java.awt.geom.AffineTransform;
88 102

  
89 103
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
104
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
90 105
import com.iver.cit.gvsig.fmap.core.FShape;
91
import com.iver.cit.gvsig.fmap.core.SymbolFactory;
106
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
107
import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
92 108
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
93 109
import com.iver.utiles.StringUtilities;
94 110
import com.iver.utiles.XMLEntity;
95 111

  
96 112
/**
97
 * Basic fill symbol. It will allow to paint a shape with its filling color (and transparency)
98
 * and the outline.
99
 * @author jaume dominguez faus - jaume.dominguez@iver.es
100
 *
113
 * Basic fill symbol. It will allow to paint a shape with its filling color (and transparency) and the outline.
114
 * @author   jaume dominguez faus - jaume.dominguez@iver.es
101 115
 */
102 116
public class SimpleFillSymbol extends AbstractFillSymbol {
103 117
	private SimpleFillSymbol symbolForSelection;
104 118

  
119

  
105 120
	public ISymbol getSymbolForSelection() {
106 121
		if (symbolForSelection == null) {
107 122
			XMLEntity xml = getXMLEntity();
108
			xml.putProperty("color", FSymbol.getSelectionColor());
109
			symbolForSelection = (SimpleFillSymbol) SymbolFactory.
110
					createFromXML(xml, getDescription()+" version for selection");
123
			xml.putProperty("color", StringUtilities.color2String(FSymbol.getSelectionColor()));
124
			symbolForSelection = (SimpleFillSymbol) SymbologyFactory.
125
					createSymbolFromXML(xml, getDescription()+" version for selection");
111 126
		}
112 127
		return symbolForSelection;
113 128
	}
114 129

  
115 130
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
116
		g.setColor(color);
131
		g.setColor(getFillColor());
117 132
		g.fill(shp);
118
		g.setColor(outline);
119
		g.setStroke(new BasicStroke(1));
120
		g.draw(shp);
133
		if (getOutline() != null)
134
			getOutline().draw(g, affineTransform, shp);
121 135
	}
122 136

  
123 137
	public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform,
......
133 147
		xml.putProperty("className", getClassName());
134 148

  
135 149
		// color
136
		xml.putProperty("color", StringUtilities.color2String(color));
150
		xml.putProperty("color", StringUtilities.color2String(getFillColor()));
137 151

  
138
		// outline
139
		xml.putProperty("outline", StringUtilities.color2String(outline));
140

  
141 152
		// description
142 153
		xml.putProperty("desc", getDescription());
143 154

  
144 155
		// is shape visible
145 156
		xml.putProperty("isShapeVisible", isShapeVisible());
146 157

  
158
		// outline
159
		if (getOutline() != null)
160
			xml.addChild(getOutline().getXMLEntity());
147 161
		return xml;
148 162
	}
149 163

  
......
153 167

  
154 168
	public void drawInsideRectangle(Graphics2D g,
155 169
			AffineTransform scaleInstance, Rectangle r) {
156
		int height = (int) r.getHeight();
157
		int width = (int) r.getWidth();
158
		g.setColor(color);
159
		for (int i = 0; i < height; i++) {
160
			g.drawLine(0, i, width, i);
161
		}
162
		g.setColor(outline);
163
		// TODO canviar esto per draw de AbstractLineSymbol
164
		g.drawRect(0, 0, width, height);
170
		g.setColor(getFillColor());
171
		r.setFrame(((int) r.getMinX())+1, ((int) r.getMinY())+1, ((int) r.getMaxX())-2, ((int) r.getMaxY())-2);
172
		g.fillRect(r.x, r.y, r.width, r.height);
173
		FShape shp = new FPolygon2D(new GeneralPathX(r));
174
		if (getOutline() != null)
175
			getOutline().draw(g, scaleInstance, shp);
165 176

  
166 177

  
167
		r.setFrame(((int) r.getMinX())+1, ((int) r.getMinY())+1, ((int) r.getMaxX())-1, ((int) r.getMaxY())-1);
168 178
	}
169 179

  
170 180
	public String getClassName() {
......
173 183

  
174 184
	public void setXMLEntity(XMLEntity xml) {
175 185
		// color
176
		color = StringUtilities.string2Color(xml.getStringProperty("color"));
186
		setFillColor(StringUtilities.string2Color(xml.getStringProperty("color")));
177 187

  
178
		// outline
179
		outline = StringUtilities.string2Color(xml.getStringProperty("outline"));
180 188

  
181 189
		// description
182 190
		setDescription(xml.getStringProperty("desc"));
183 191

  
184 192
		// is shape visible
185 193
		setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
194

  
195
		// outline
196
		if (xml.getChildrenCount() > 0)
197
			setOutline((ILineSymbol) SymbologyFactory.createSymbolFromXML(xml.getChild(0), null));
198

  
186 199
	}
187 200

  
188 201
	public void print(Graphics2D g, AffineTransform at, FShape shape) throws ReadDriverException {

Also available in: Unified diff