Revision 10450 branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerLineSymbol.java

View differences:

MultiLayerLineSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.2  2007-02-21 07:34:09  jaume
46
* Revision 1.1.2.3  2007-02-21 16:09:02  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1.2.2  2007/02/21 07:34:09  jaume
47 50
* labeling starts working
48 51
*
49 52
* Revision 1.1.2.1  2007/02/16 10:54:12  jaume
......
270 273
		return contains;
271 274
	}
272 275

  
276
	public int getAlpha() {
277
		// will compute the acumulated opacity
278
		double myAlpha = 0;
279
		for (int i = 0; i < layers.length; i++) {
280
			double layerAlpha = layers[i].getAlpha()/255D;
281
			myAlpha += (1-myAlpha)*layerAlpha;
282
		}
283
		int result = (int) Math.round(myAlpha * 255); 
284
		return (result>255) ? 255 : result;
285
	}
273 286
	
287
	public void setAlpha(int outlineAlpha) {
288
		// first, get the biggest alpha in the layers and the index if such layer
289
		int maxAlpha = Integer.MIN_VALUE;
290
		int maxAlphaLayerIndex = 0;
291
		for (int i = 0; i < layers.length; i++) {
292
			if (layers[i].getAlpha() > maxAlpha) {
293
				maxAlpha = layers[i].getAlpha();
294
				maxAlphaLayerIndex = i;
295
			}
296
		}
297
		
298
		// now, max alpha takes the value of the desired alpha and the rest
299
		// will take a scaled (to biggest alpha) alpha value
300
		for (int i = 0; i < layers.length; i++) {
301
			if (i!=maxAlphaLayerIndex) {
302
				double scaledAlpha = (double) layers[i].getAlpha()/maxAlpha;
303
				layers[i].setAlpha((int) (outlineAlpha*scaledAlpha));
304
			} else {
305
				layers[i].setAlpha(outlineAlpha);
306
			}
307
		}
308
		
309
	}
310
	
311
	
274 312
}

Also available in: Unified diff