Revision 423

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/Abrir.java
6 6
import org.cresques.cts.ProjectionPool;
7 7

  
8 8
import com.hardcode.driverManager.DriverLoadException;
9
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
9 10
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
10 11
import com.iver.cit.gvsig.fmap.drivers.dgn.DGNDriver;
11 12
import com.iver.cit.gvsig.fmap.drivers.shp.DemoSHPDriver;
......
51 52
			
52 53
			try {
53 54
				lyr = LayerFactory.createLayer(fopen.getDriverName(), fich, proj);
54

  
55
				lyr.setVisible(true);
56
				lyr.setName(layerName);
55
				
57 56
				if (lyr != null )
58 57
				{
59
					try {
58
					try 
59
					{
60
						if (lyr instanceof FLyrVect)
61
						{
62
							FLyrVect lyrVect = (FLyrVect) lyr;
63
							lyrVect.setLegend(LegendFactory.createSingleSymbolLegend());
64
						}
65
						lyr.setVisible(true);
66
						lyr.setName(layerName);						
60 67
						theView.getMapControl().getMapContext().getLayers().addLayer(lyr);
61 68
					} catch (CancelationException e) {
62 69
						// TODO Auto-generated catch block
......
69 76
				}    		
70 77
				
71 78
			} catch (DriverLoadException e) {
79
				e.printStackTrace();				
80
			} catch (DriverIOException e) {
81
				// TODO Auto-generated catch block
72 82
				e.printStackTrace();
73 83
			}
74 84
		} // for
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/TOCRenderer.java
154 154
		String stringValue = "";
155 155
		this.setBackground(UIManager.getColor("Button.background"));
156 156
		this.label.setFont(tree.getFont());
157
		System.out.println("ancho tree=" + tree.getWidth());
158
        int widthTree = tree.getWidth()-30;
159
        Dimension sizeNode;
160
        
161
		this.setPreferredSize(new Dimension(widthTree,18));
162
		
163
		
157
		// System.out.println("ancho tree=" + tree.getWidth());
164 158

  
165 159
		if (n.getUserObject() instanceof ITocItem)
166 160
		{
161
			
167 162
	       	ITocItem item = (ITocItem) n.getUserObject();	       	
168 163
			stringValue = item.getLabel();
169
			if (widthTree < 100) widthTree = 100;
170 164
			
171
			sizeNode = new Dimension(100,18);			
165
	        Dimension sizeNode = item.getSize(); // Se fija en el resize del TOC
166
	        
167
			this.setPreferredSize(sizeNode);
168
			
172 169
			if (item instanceof TocItemBranch)
173 170
			{
174 171
				TocItemBranch branch = (TocItemBranch) item;
175
				sizeNode = new Dimension(widthTree,25);
176 172
				FLayer lyr = branch.getLayer();
177 173
				check.setVisible(true);
178 174
				check.setSelected(lyr.isVisible());		
......
193 189
				
194 190
			}
195 191
	        label.setText(stringValue);
196
	        label.setIcon(item.getIcon());
192
	        if (item.getIcon() != null)
193
	        {
194
	        	label.setIcon(item.getIcon());
195
	        	// System.out.println("Pongo etiqueta " + stringValue + " con icono " + item.getIcon().toString());
196
	        }
197 197
	        this.setPreferredSize(sizeNode);
198 198
		}		
199 199
		// this.setPreferredSize(new Dimension(tree.getWidth()-60,24)); // sizeNode);
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/TocItemLeaf.java
6 6
 */
7 7
package com.iver.cit.gvsig.gui.toc;
8 8

  
9
import java.awt.Dimension;
9 10
import java.awt.Graphics2D;
10 11
import java.awt.Rectangle;
11 12
import java.awt.datatransfer.DataFlavor;
......
33 34
	private int layerType;
34 35
	private static int w_1symbol = 20;
35 36
	private static int h_1symbol = 15;
37
	
38
	private Dimension sz;
39
	
36 40
	private static SymbolPreviewDrawer pSD = new SymbolPreviewDrawer();
37 41
	
38 42
    final public static DataFlavor INFO_FLAVOR =
......
58 62
	 * @see com.iver.cit.gvsig.gui.toc.ITocItem#getIcon()
59 63
	 */
60 64
	public Icon getIcon() {
65
		// System.out.println("Dentro de getIcon: layerType=" + layerType);
61 66
		BufferedImage img = new BufferedImage(w_1symbol, h_1symbol, BufferedImage.TYPE_INT_ARGB);
62 67
		Graphics2D g2 = img.createGraphics();
63 68
		pSD.setSymbol(symbol);
......
67 72
			case FShape.POINT:
68 73
				r = new Rectangle(w_1symbol, h_1symbol);
69 74
				pSD.drawPoint(g2,r);
75
				// System.out.println("Dibujo icono punto");
70 76
				break;					
71 77
			case FShape.LINE:
72 78
				r = new Rectangle(w_1symbol, h_1symbol);
73 79
				pSD.drawLine(g2,r);
80
				// System.out.println("Dibujo icono linea");
74 81
				break;					
75 82
			case FShape.POLYGON:
76 83
				r = new Rectangle(w_1symbol, h_1symbol);
77 84
				pSD.drawPolygon(g2,r);
85
				// System.out.println("Dibujo icono pol?gono");
78 86
				break;
79 87
		}
80 88
		
......
104 112
	      }
105 113
	      else throw new UnsupportedFlavorException(dF);
106 114
	}
115
	/* (non-Javadoc)
116
	 * @see com.iver.cit.gvsig.gui.toc.ITocItem#getSize()
117
	 */
118
	public Dimension getSize() {
119
		return sz;
120
	}
121
	/* (non-Javadoc)
122
	 * @see com.iver.cit.gvsig.gui.toc.ITocItem#setSize(java.awt.Dimension)
123
	 */
124
	public void setSize(Dimension sz) {
125
		this.sz = sz;
126
		
127
	}
107 128
	
108 129

  
109 130
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/ITocItem.java
6 6
 */
7 7
package com.iver.cit.gvsig.gui.toc;
8 8

  
9
import java.awt.Dimension;
9 10
import java.awt.datatransfer.Transferable;
10 11

  
11 12
import javax.swing.Icon;
......
21 22
public interface ITocItem extends Transferable {
22 23
	String getLabel();
23 24
	Icon getIcon();
25
	Dimension getSize();
26
	void setSize(Dimension sz);
24 27
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/TocItemBranch.java
6 6
 */
7 7
package com.iver.cit.gvsig.gui.toc;
8 8

  
9
import java.awt.Dimension;
10
import java.awt.Image;
9 11
import java.awt.datatransfer.DataFlavor;
10 12
import java.awt.datatransfer.UnsupportedFlavorException;
11 13
import java.io.IOException;
12 14

  
13 15
import javax.swing.Icon;
16
import javax.swing.ImageIcon;
17
import javax.swing.UIManager;
14 18

  
15 19
import com.iver.cit.gvsig.fmap.layers.FLayer;
16 20

  
......
22 26
 */
23 27
public class TocItemBranch implements ITocItem {
24 28

  
29
	private final Icon icolayer = new ImageIcon("images/icolayer.png");
30
	
25 31
	private FLayer lyr;
26 32
	
33
	private Dimension sz;
34
	
27 35
    final public static DataFlavor INFO_FLAVOR =
28 36
	    new DataFlavor(TocItemBranch.class, "ItemBranch");
29 37
    static DataFlavor flavors[] = {INFO_FLAVOR };
......
45 53
	public Icon getIcon() {
46 54
		// TODO Pedirle el icono a la capa. Por defecto habr? un icono
47 55
		// para vectoriales y otro para raster, pero se podr?n cambiar.
48
		return null;
56
		return icolayer;
49 57
	}
50 58

  
51 59
	public FLayer getLayer() {
......
75 83
	      }
76 84
	      else throw new UnsupportedFlavorException(dF);
77 85
	}
86
	/* (non-Javadoc)
87
	 * @see com.iver.cit.gvsig.gui.toc.ITocItem#getSize()
88
	 */
89
	public Dimension getSize() {
90
		return sz;
91
	}
92
	/* (non-Javadoc)
93
	 * @see com.iver.cit.gvsig.gui.toc.ITocItem#setSize(java.awt.Dimension)
94
	 */
95
	public void setSize(Dimension sz) {
96
		this.sz = sz;
97
	}
78 98
	
79 99
}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/TOC.java
19 19
import java.awt.event.MouseAdapter;
20 20
import java.awt.event.MouseEvent;
21 21
import java.util.ArrayList;
22
import java.util.Enumeration;
22 23

  
23 24
import javax.swing.BorderFactory;
24 25
import javax.swing.JColorChooser;
......
44 45
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
45 46
import com.iver.cit.gvsig.gui.toc.DnDJTree;
46 47
import com.iver.cit.gvsig.gui.toc.FPopupMenu;
48
import com.iver.cit.gvsig.gui.toc.ITocItem;
47 49
import com.iver.cit.gvsig.gui.toc.ITocOrderListener;
48 50
import com.iver.cit.gvsig.gui.toc.TOCRenderer;
49 51
import com.iver.cit.gvsig.gui.toc.TocItemBranch;
......
238 240
	}
239 241
	private void doRefresh(FLayers theLayers, DefaultMutableTreeNode parentNode)
240 242
	{
243
		Dimension sizeLeaf = new Dimension(m_Tree.getWidth(), 15);
244
		Dimension sizeBranch = new Dimension(m_Tree.getWidth(), 20);
241 245
		for (int i=theLayers.getLayersCount()-1;i>=0; i--)
242 246
		{
243 247
			FLayer lyr = theLayers.getLayer(i);
244 248
			TocItemBranch elTema = new TocItemBranch(lyr);
249
			elTema.setSize(sizeBranch);
245 250
			DefaultMutableTreeNode nodeLayer = new DefaultMutableTreeNode(elTema);
246 251
			
247 252
			m_TreeModel.insertNodeInto(nodeLayer, parentNode, parentNode.getChildCount());
......
266 271
						{					
267 272
							TocItemLeaf itemLeaf;
268 273
							itemLeaf = new TocItemLeaf(symbols[j],descriptions[j], aux.getShapeType());
274
							itemLeaf.setSize(sizeLeaf);
269 275
							DefaultMutableTreeNode nodeValue = new DefaultMutableTreeNode(itemLeaf);
270 276
							m_TreeModel.insertNodeInto(nodeValue, nodeLayer, nodeLayer.getChildCount());
271 277
							TreePath pathSymbol = new TreePath(m_TreeModel.getPathToRoot(nodeValue));
......
274 280
					}
275 281
					TocItemLeaf itemLeaf;
276 282
					itemLeaf = new TocItemLeaf(legendInfo.getDefaultSymbol(),"Default", aux.getShapeType());
283
					itemLeaf.setSize(sizeLeaf);
277 284
					DefaultMutableTreeNode nodeValue = new DefaultMutableTreeNode(itemLeaf);
278 285
					m_TreeModel.insertNodeInto(nodeValue, nodeLayer, nodeLayer.getChildCount());
279 286
					TreePath pathSymbol = new TreePath(m_TreeModel.getPathToRoot(nodeValue));
......
334 341
	 */
335 342
	public void componentResized(ComponentEvent e) {
336 343
		System.out.println("Cambiando tama?o.");
344
		
345
		int i = 0;
346
		DefaultMutableTreeNode n;
347
		Enumeration enum = m_Root.children();
348
		while (enum.hasMoreElements())
349
		{
350
			n =  (DefaultMutableTreeNode) enum.nextElement();
351
			if (n.getUserObject() instanceof TocItemBranch)
352
			{
353
				
354
		       	ITocItem item = (ITocItem) n.getUserObject();
355
		       	Dimension szAnt = item.getSize();
356
		       	item.setSize(new Dimension(this.getWidth()-30,szAnt.height));
357
			}						
358
			System.out.println("i=" + i++);
359
		} 
337 360
		m_Tree.setSize(this.getSize());
338
		System.out.println("Ancho del tree=" + m_Tree.getWidth());
361
		
362
		System.out.println("Ancho del tree=" + m_Tree.getWidth() + " " + m_Tree.getComponentCount());
339 363
		System.out.println("Ancho del TOC=" + this.getWidth());
340
		/* while (m_Root.children().hasMoreElements())
341
		{
342
			DefaultMutableTreeNode n =  (DefaultMutableTreeNode) m_Root.children().nextElement();
343
		} */
344
		// refresh();
345
		// m_Tree.repaint(m_Tree.getBounds());
364
		// m_Tree.repaint();
346 365
		
347 366
		
348 367
	}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/DEMO/ComandosListener.java
163 163
    				
164 164
    			} catch (DriverLoadException ex) {
165 165
    				ex.printStackTrace();
166
    			}
166
    			} catch (DriverIOException ex) {
167
					// TODO Auto-generated catch block
168
					ex.printStackTrace();
169
				}
167 170
    		} // for
168 171
            return;
169 172

  

Also available in: Unified diff