Revision 12866 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolEditor.java

View differences:

SymbolEditor.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.15  2007-07-30 12:56:04  jaume
46
 * Revision 1.16  2007-08-01 13:01:43  jaume
47
 * refactored to be pluggable
48
 *
49
 * Revision 1.15  2007/07/30 12:56:04  jaume
47 50
 * organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
48 51
 *
49 52
 * Revision 1.14  2007/07/30 06:59:51  jaume
......
142 145
import java.awt.FlowLayout;
143 146
import java.awt.event.ActionEvent;
144 147
import java.awt.event.ActionListener;
148
import java.lang.reflect.Constructor;
149
import java.lang.reflect.InvocationTargetException;
150
import java.util.ArrayList;
145 151
import java.util.Comparator;
146 152
import java.util.TreeSet;
147 153

  
......
154 160
import org.gvsig.gui.beans.AcceptCancelPanel;
155 161

  
156 162
import com.iver.andami.PluginServices;
163
import com.iver.andami.messages.NotificationManager;
157 164
import com.iver.andami.ui.mdiManager.IWindow;
158 165
import com.iver.andami.ui.mdiManager.WindowInfo;
159 166
import com.iver.cit.gvsig.fmap.core.CartographicSupport;
......
168 175
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
169 176
import com.iver.cit.gvsig.gui.JUnitsComboBox;
170 177
import com.iver.utiles.XMLEntity;
178
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
171 179

  
172 180
/**
173 181
 *
......
176 184
 */
177 185
public class SymbolEditor extends JPanel implements IWindow {
178 186

  
187
	private static Hashtable editorsByType;
179 188
	private WindowInfo wi;
180 189
	private JPanel pnlWest = null;
181 190
	private JPanel pnlCenter = null;
......
317 326
				return result;
318 327
			}
319 328
		};
329
		
330
		
320 331
		TreeSet set = new TreeSet(tabComparator);
321

  
322
		// TODO refactor this to make it dynamic and plug'n'play
323
		if (shapeType == FShape.POLYGON) {
324
			// Polygon options
325

  
326
			// add here your options for polygon symbols
327
			set.add(new SimpleFill(SymbolEditor.this));
328
			set.add(new MarkerFill(SymbolEditor.this));
329
			set.add(new LineFill(SymbolEditor.this));
330
			set.add(new PictureFill(SymbolEditor.this));
331
		} else if (shapeType == FShape.POINT) {
332
			// Point options
333

  
334
			// add here your options for point symbol
335
			set.add(new CharacterMarker(SymbolEditor.this));
336
			set.add(new SimpleMarker(SymbolEditor.this));
337
			set.add(new PictureMarker(SymbolEditor.this));
338
		} else if (shapeType == FShape.LINE) {
339
			// Point options
340

  
341
			// add here your options for line symbol
342
			set.add(new SimpleLine(this));
343
			set.add(new PictureLine(this));
344

  
345
//////////	/-------------------------------------
346
		} else if (shapeType == FShape.TEXT) {
347
			// Text options
348

  
349
			// add here your options for text symbol
350
			set.add(new SimpleText(this));
351
//////////	/-------------------------------------
352
		}
332
		ArrayList editors = (ArrayList) editorsByType.get(new Integer(shapeType));
333
		Class[] constrLocator = new Class[] {SymbolEditor.class};
334
		Object[] constrInitargs = new Object[] { this };
335
		for (int i = 0; i < editors.size(); i++) {
336
			Class editorClass = (Class) editors.get(i);
337
			try {
338
				Constructor c = editorClass.getConstructor(constrLocator);
339
				set.add(c.newInstance(constrInitargs));
340
			} catch (Exception e) {
341
				// TODO Auto-generated catch block
342
				NotificationManager.addError(PluginServices.getText(this, "failed_installing_symbol_editor"), e);
343
			} 
344
		};	
353 345
 		tabs = (AbstractTypeSymbolEditorPanel[]) set
354 346
				.toArray(new AbstractTypeSymbolEditorPanel[0]);
355 347

  
......
593 585
		return cmbUnitsReferenceSystem.getSelectedIndex();
594 586
	}
595 587

  
588
	public static void addSymbolEditorPanel(Class abstractTypeSymbolEditorPanelClass, int shapeType) {
589
		if (editorsByType == null) {
590
			editorsByType = new Hashtable();
591
		}
592
		
593
		Integer key = new Integer(shapeType);
594
		ArrayList l = (ArrayList) editorsByType.get(key);
595
		if (l == null) {
596
			l = new ArrayList();
597
		}
598
		l.add(abstractTypeSymbolEditorPanelClass);
599
		
600
		editorsByType.put(key, l);
601
	}
596 602

  
603

  
597 604
}

Also available in: Unified diff