Revision 24903 trunk/libraries/lib3DMap/src/org/gvsig/gvsig3d/gui/FeatureFactory.java

View differences:

FeatureFactory.java
1 1
package org.gvsig.gvsig3d.gui;
2 2

  
3 3
import java.awt.Color;
4
import java.util.ArrayList;
4 5
import java.util.HashMap;
5 6
import java.util.Iterator;
6 7
import java.util.List;
7 8

  
8 9
import org.apache.log4j.Logger;
9 10
import org.gvsig.gvsig3d.labels3D.ILabel3D;
11
import org.gvsig.gvsig3d.labels3D.SimpleLabel3D;
10 12
import org.gvsig.gvsig3d.utils.Punto3D;
11 13
import org.gvsig.osgvp.AutoTransform;
12 14
import org.gvsig.osgvp.Geode;
......
27 29
import org.gvsig.osgvp.features.Text;
28 30
import org.gvsig.osgvp.planets.Planet;
29 31

  
32
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
30 33
import com.iver.ai2.gvsig3d.resources.ResourcesFactory;
31 34
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
35
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy;
32 36

  
33 37
public class FeatureFactory extends Group {
34 38

  
......
737 741
		if (color.w() != 1) {
738 742
			p.setEnabledBlending(true);
739 743
		}
744
		List positionTapa = new ArrayList();
740 745
		// Adding points
741 746
		for (int i = 0; i < points.size(); i++) {
742 747
			Vec3 element = (Vec3) points.get(i);
748
			Vec3 elementTapa = new Vec3(element.x(),element.y(),element.z()+heigth);
749
			positionTapa.add(elementTapa);
750
//			System.out.println("posicion : " + element.z());
743 751
			p.addVertex(element, color);
744 752
		}
745 753
		
754
		
755
		
746 756
		PolygonExtruder pe = new PolygonExtruder();
747
		pe.extrude(p,new Vec3 (0.0,0.0,-1.0), heigth);		
757
		pe.extrude(p,new Vec3 (0.0,0.0,1.0), heigth);		
748 758
		
749 759

  
750 760
		// Optimizer generated nodes
751 761
		Optimizer opt = new Optimizer();
762
		Node node = null;
752 763
		try {
753 764
			opt.optimize(p, OptimizationOptions.ALL_OPTIMIZATIONS);
765
			node = FeatureFactory.insertPolygon(positionTapa, color, null);
766
			opt.optimize(node, OptimizationOptions.ALL_OPTIMIZATIONS);
767
			
754 768
		} catch (InvalidValueException e) {
755 769
			logger.error("Command:" + "Error setting optimizer value.",e);
756 770
		} catch (NodeException e) {
757 771
			logger.error("Command:" + "Error adding optimizer.",e);
758 772
		}
759

  
773
		Group group = new Group();
760 774
		Geode geode = new Geode();
761 775
		
776
		geode.getOrCreateStateSet().setTwoSidedLighting(true);
762 777
		try {
763 778
			geode.addDrawable(pe.getGeometry());
779
			group.addChild(geode);
780
			group.addChild(node);
764 781
		} catch (NodeException e) {
765 782
			logger.error("Command:" + "Error adding drawable object.",e);
766 783
		}
784
		
767 785
		// Return node
768
		return geode;
786
//		return geode;
787
		return group;
769 788
	}
770 789
	/**
771 790
	 * Method to create a new 3D line. With a List of 3D points and a color
......
983 1002
	 * @return Node group
984 1003
	 */
985 1004
	public static Node insertLabels(List<ILabel3D> labels,Planet planet) {
1005
		
1006
		int height;
1007
		AttrInTableLabelingStrategy strategy;
1008
		
986 1009
		// Creating a group node
987 1010
		Group p = new Group();
988 1011

  
......
1005 1028
				// Set up parameters
1006 1029

  
1007 1030
				// Getting color
1008
//				 Color original_color = f.getColor();
1009
				Color co = new Color(255, 255, 255, 255);
1031
//				 Color co = f.getColor();
1032
				Color co = new Color(255, 0, 0, 255);
1033
				if (label3D instanceof SimpleLabel3D) {
1034
					strategy = ((SimpleLabel3D) label3D).getStrategy();
1035
					co = strategy.getFixedColor();
1036
					height = strategy.getFont().getSize();
1037
				}
1010 1038
				float r, g, b, a;
1011 1039
				r = ((float) co.getRed()) / 255.0f;
1012 1040
				g = ((float) co.getGreen()) / 255.0f;
......
1031 1059
				}
1032 1060
				
1033 1061
				boolean inPixels = (label3D.getUnits() <= -1);
1034
				int height = (int)f.getHeight()/255;
1062
//				height = (int)f.getHeight()/255;
1063
				height = 100;
1035 1064
				// Adding new child text nodes
1036 1065
				try {
1037 1066
					p.addChild(insertTextoS(label, pos,textColor,height , inPixels));
1067
//					p.addChild(insertTextoS(label, pos,textColor,height , true));
1038 1068
				} catch (NodeException e) {
1039 1069
					logger.error("Command:" + "Error adding new child text.",e);
1040 1070
				}

Also available in: Unified diff