0001: /**
0002: * <copyright></copyright> $Id: ProjectFactoryImpl.java 24662 2007-03-02 18:26:24Z jeichar $
0003: */package net.refractions.udig.project.internal.impl;
0004:
0005: import java.awt.Color;
0006: import java.awt.Point;
0007: import java.awt.geom.AffineTransform;
0008: import java.net.MalformedURLException;
0009: import java.net.URL;
0010: import java.util.HashMap;
0011: import java.util.Iterator;
0012: import java.util.List;
0013: import java.util.Map.Entry;
0014:
0015: import net.refractions.udig.catalog.IGeoResource;
0016: import net.refractions.udig.core.internal.CorePlugin;
0017: import net.refractions.udig.core.internal.ExtensionPointList;
0018: import net.refractions.udig.project.command.CommandStack;
0019: import net.refractions.udig.project.command.EditCommand;
0020: import net.refractions.udig.project.command.MapCommand;
0021: import net.refractions.udig.project.command.NavCommand;
0022: import net.refractions.udig.project.command.NavCommandStack;
0023: import net.refractions.udig.project.interceptor.MapInterceptor;
0024: import net.refractions.udig.project.internal.Blackboard;
0025: import net.refractions.udig.project.internal.BlackboardEntry;
0026: import net.refractions.udig.project.internal.CatalogRef;
0027: import net.refractions.udig.project.internal.ContextModel;
0028: import net.refractions.udig.project.internal.EditManager;
0029: import net.refractions.udig.project.internal.Layer;
0030: import net.refractions.udig.project.internal.LayerFactory;
0031: import net.refractions.udig.project.internal.Map;
0032: import net.refractions.udig.project.internal.PicoBlackboard;
0033: import net.refractions.udig.project.internal.Project;
0034: import net.refractions.udig.project.internal.ProjectFactory;
0035: import net.refractions.udig.project.internal.ProjectPackage;
0036: import net.refractions.udig.project.internal.ProjectPlugin;
0037: import net.refractions.udig.project.internal.ProjectRegistry;
0038: import net.refractions.udig.project.internal.StyleBlackboard;
0039: import net.refractions.udig.project.internal.StyleEntry;
0040: import net.refractions.udig.project.internal.render.RenderFactory;
0041: import net.refractions.udig.project.internal.render.RenderPackage;
0042: import net.refractions.udig.project.render.displayAdapter.IMapDisplay;
0043: import net.refractions.udig.ui.PlatformGIS;
0044: import net.refractions.udig.ui.palette.ColourScheme;
0045:
0046: import org.eclipse.core.runtime.IConfigurationElement;
0047: import org.eclipse.core.runtime.IProgressMonitor;
0048: import org.eclipse.emf.common.notify.Adapter;
0049: import org.eclipse.emf.common.util.URI;
0050: import org.eclipse.emf.ecore.EClass;
0051: import org.eclipse.emf.ecore.EDataType;
0052: import org.eclipse.emf.ecore.EObject;
0053: import org.eclipse.emf.ecore.impl.EFactoryImpl;
0054: import org.eclipse.jface.resource.ImageDescriptor;
0055: import org.geotools.brewer.color.BrewerPalette;
0056: import org.geotools.data.FeatureEvent;
0057: import org.geotools.data.FeatureResults;
0058: import org.geotools.data.Query;
0059: import org.geotools.feature.Feature;
0060: import org.geotools.filter.Filter;
0061: import org.geotools.geometry.jts.ReferencedEnvelope;
0062: import org.geotools.styling.SLD;
0063: import org.opengis.referencing.crs.CoordinateReferenceSystem;
0064: import org.picocontainer.MutablePicoContainer;
0065:
0066: import com.vividsolutions.jts.geom.Coordinate;
0067: import com.vividsolutions.jts.geom.Envelope;
0068:
0069: /**
0070: * The EMF factory for project model objects
0071: *
0072: * @author Jesse
0073: * @since 1.0.0
0074: * @generated
0075: */
0076: public class ProjectFactoryImpl extends EFactoryImpl implements
0077: ProjectFactory {
0078: /**
0079: * <!-- begin-user-doc --> <!-- end-user-doc -->
0080: * @generated
0081: */
0082: public static final String copyright = "uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; //$NON-NLS-1$
0083:
0084: /**
0085: * Creates an instance of the factory.
0086: * <!-- begin-user-doc --> <!-- end-user-doc -->
0087: * @generated
0088: */
0089: public ProjectFactoryImpl() {
0090: super ();
0091: }
0092:
0093: /**
0094: * <!-- begin-user-doc --> <!-- end-user-doc -->
0095: * @generated
0096: */
0097: public EObject create(EClass eClass) {
0098: switch (eClass.getClassifierID()) {
0099: case ProjectPackage.CONTEXT_MODEL:
0100: return createContextModel();
0101: case ProjectPackage.EDIT_MANAGER:
0102: return createEditManager();
0103: case ProjectPackage.LAYER:
0104: return createLayer();
0105: case ProjectPackage.MAP:
0106: return createMap();
0107: case ProjectPackage.PROJECT:
0108: return createProject();
0109: case ProjectPackage.PROJECT_REGISTRY:
0110: return createProjectRegistry();
0111: case ProjectPackage.STYLE_BLACKBOARD:
0112: return createStyleBlackboard();
0113: case ProjectPackage.STYLE_ENTRY:
0114: return createStyleEntry();
0115: case ProjectPackage.LAYER_FACTORY:
0116: return createLayerFactory();
0117: case ProjectPackage.PICO_BLACKBOARD:
0118: return createPicoBlackboard();
0119: case ProjectPackage.BLACKBOARD:
0120: return createBlackboard();
0121: case ProjectPackage.BLACKBOARD_ENTRY:
0122: return createBlackboardEntry();
0123: default:
0124: throw new IllegalArgumentException(
0125: "The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
0126: }
0127: }
0128:
0129: /**
0130: * <!-- begin-user-doc --> <!-- end-user-doc -->
0131: * @generated
0132: */
0133: public Object createFromString(EDataType eDataType,
0134: String initialValue) {
0135: switch (eDataType.getClassifierID()) {
0136: case ProjectPackage.COORDINATE:
0137: return createCoordinateFromString(eDataType, initialValue);
0138: case ProjectPackage.MAP_DISPLAY:
0139: return createMapDisplayFromString(eDataType, initialValue);
0140: case ProjectPackage.FEATURE_RESULTS:
0141: return createFeatureResultsFromString(eDataType,
0142: initialValue);
0143: case ProjectPackage.LIST:
0144: return createListFromString(eDataType, initialValue);
0145: case ProjectPackage.AFFINE_TRANSFORM:
0146: return createAffineTransformFromString(eDataType,
0147: initialValue);
0148: case ProjectPackage.NAV_COMMAND_STACK:
0149: return createNavCommandStackFromString(eDataType,
0150: initialValue);
0151: case ProjectPackage.IGEO_RESOURCE:
0152: return createIGeoResourceFromString(eDataType, initialValue);
0153: case ProjectPackage.FILTER:
0154: return createFilterFromString(eDataType, initialValue);
0155: case ProjectPackage.COORDINATE_REFERENCE_SYSTEM:
0156: return createCoordinateReferenceSystemFromString(eDataType,
0157: initialValue);
0158: case ProjectPackage.COMMAND_STACK:
0159: return createCommandStackFromString(eDataType, initialValue);
0160: case ProjectPackage.FEATURE:
0161: return createFeatureFromString(eDataType, initialValue);
0162: case ProjectPackage.POINT:
0163: return createPointFromString(eDataType, initialValue);
0164: case ProjectPackage.ADAPTER:
0165: return createAdapterFromString(eDataType, initialValue);
0166: case ProjectPackage.IPROGRESS_MONITOR:
0167: return createIProgressMonitorFromString(eDataType,
0168: initialValue);
0169: case ProjectPackage.QUERY:
0170: return createQueryFromString(eDataType, initialValue);
0171: case ProjectPackage.URL:
0172: return createURLFromString(eDataType, initialValue);
0173: case ProjectPackage.IMAGE_DESCRIPTOR:
0174: return createImageDescriptorFromString(eDataType,
0175: initialValue);
0176: case ProjectPackage.EDIT_COMMAND:
0177: return createEditCommandFromString(eDataType, initialValue);
0178: case ProjectPackage.NAV_COMMAND:
0179: return createNavCommandFromString(eDataType, initialValue);
0180: case ProjectPackage.ENVELOPE:
0181: return createEnvelopeFromString(eDataType, initialValue);
0182: case ProjectPackage.COMMAND:
0183: return createCommandFromString(eDataType, initialValue);
0184: case ProjectPackage.URI:
0185: return createURIFromString(eDataType, initialValue);
0186: case ProjectPackage.CATALOG_REF:
0187: return createCatalogRefFromString(eDataType, initialValue);
0188: case ProjectPackage.COLOUR_PALETTE:
0189: return createColourPaletteFromString(eDataType,
0190: initialValue);
0191: case ProjectPackage.COLOUR_SCHEME:
0192: return createColourSchemeFromString(eDataType, initialValue);
0193: case ProjectPackage.DEFAULT_COLOR:
0194: return createDefaultColorFromString(eDataType, initialValue);
0195: case ProjectPackage.MUTABLE_PICO_CONTAINER:
0196: return createMutablePicoContainerFromString(eDataType,
0197: initialValue);
0198: case ProjectPackage.REFERENCED_ENVELOPE:
0199: return createReferencedEnvelopeFromString(eDataType,
0200: initialValue);
0201: case ProjectPackage.FEATURE_EVENT:
0202: return createFeatureEventFromString(eDataType, initialValue);
0203: default:
0204: throw new IllegalArgumentException(
0205: "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
0206: }
0207: }
0208:
0209: /**
0210: * <!-- begin-user-doc --> <!-- end-user-doc -->
0211: * @generated
0212: */
0213: public String convertToString(EDataType eDataType,
0214: Object instanceValue) {
0215: switch (eDataType.getClassifierID()) {
0216: case ProjectPackage.COORDINATE:
0217: return convertCoordinateToString(eDataType, instanceValue);
0218: case ProjectPackage.MAP_DISPLAY:
0219: return convertMapDisplayToString(eDataType, instanceValue);
0220: case ProjectPackage.FEATURE_RESULTS:
0221: return convertFeatureResultsToString(eDataType,
0222: instanceValue);
0223: case ProjectPackage.LIST:
0224: return convertListToString(eDataType, instanceValue);
0225: case ProjectPackage.AFFINE_TRANSFORM:
0226: return convertAffineTransformToString(eDataType,
0227: instanceValue);
0228: case ProjectPackage.NAV_COMMAND_STACK:
0229: return convertNavCommandStackToString(eDataType,
0230: instanceValue);
0231: case ProjectPackage.IGEO_RESOURCE:
0232: return convertIGeoResourceToString(eDataType, instanceValue);
0233: case ProjectPackage.FILTER:
0234: return convertFilterToString(eDataType, instanceValue);
0235: case ProjectPackage.COORDINATE_REFERENCE_SYSTEM:
0236: return convertCoordinateReferenceSystemToString(eDataType,
0237: instanceValue);
0238: case ProjectPackage.COMMAND_STACK:
0239: return convertCommandStackToString(eDataType, instanceValue);
0240: case ProjectPackage.FEATURE:
0241: return convertFeatureToString(eDataType, instanceValue);
0242: case ProjectPackage.POINT:
0243: return convertPointToString(eDataType, instanceValue);
0244: case ProjectPackage.ADAPTER:
0245: return convertAdapterToString(eDataType, instanceValue);
0246: case ProjectPackage.IPROGRESS_MONITOR:
0247: return convertIProgressMonitorToString(eDataType,
0248: instanceValue);
0249: case ProjectPackage.QUERY:
0250: return convertQueryToString(eDataType, instanceValue);
0251: case ProjectPackage.URL:
0252: return convertURLToString(eDataType, instanceValue);
0253: case ProjectPackage.IMAGE_DESCRIPTOR:
0254: return convertImageDescriptorToString(eDataType,
0255: instanceValue);
0256: case ProjectPackage.EDIT_COMMAND:
0257: return convertEditCommandToString(eDataType, instanceValue);
0258: case ProjectPackage.NAV_COMMAND:
0259: return convertNavCommandToString(eDataType, instanceValue);
0260: case ProjectPackage.ENVELOPE:
0261: return convertEnvelopeToString(eDataType, instanceValue);
0262: case ProjectPackage.EDIT_MANAGER_CONTROL_COMMAND:
0263: return convertEditManagerControlCommandToString(eDataType,
0264: instanceValue);
0265: case ProjectPackage.COMMAND:
0266: return convertCommandToString(eDataType, instanceValue);
0267: case ProjectPackage.URI:
0268: return convertURIToString(eDataType, instanceValue);
0269: case ProjectPackage.CATALOG_REF:
0270: return convertCatalogRefToString(eDataType, instanceValue);
0271: case ProjectPackage.COLOUR_PALETTE:
0272: return convertColourPaletteToString(eDataType,
0273: instanceValue);
0274: case ProjectPackage.COLOUR_SCHEME:
0275: return convertColourSchemeToString(eDataType, instanceValue);
0276: case ProjectPackage.DEFAULT_COLOR:
0277: return convertDefaultColorToString(eDataType, instanceValue);
0278: case ProjectPackage.MUTABLE_PICO_CONTAINER:
0279: return convertMutablePicoContainerToString(eDataType,
0280: instanceValue);
0281: case ProjectPackage.REFERENCED_ENVELOPE:
0282: return convertReferencedEnvelopeToString(eDataType,
0283: instanceValue);
0284: case ProjectPackage.FEATURE_EVENT:
0285: return convertFeatureEventToString(eDataType, instanceValue);
0286: default:
0287: throw new IllegalArgumentException(
0288: "The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
0289: }
0290: }
0291:
0292: /**
0293: * <!-- begin-user-doc --> <!-- end-user-doc -->
0294: * @generated
0295: */
0296: public ContextModel createContextModel() {
0297: ContextModelImpl contextModel = new ContextModelImpl();
0298: return contextModel;
0299: }
0300:
0301: /**
0302: * <!-- begin-user-doc --> <!-- end-user-doc -->
0303: * @generated
0304: */
0305: public Layer createLayer() {
0306: LayerImpl layer = new LayerImpl();
0307: return layer;
0308: }
0309:
0310: /**
0311: * <!-- begin-user-doc --> <!-- end-user-doc -->
0312: * @generated
0313: */
0314: public Project createProject() {
0315: ProjectImpl project = new ProjectImpl();
0316: return project;
0317: }
0318:
0319: /**
0320: * <!-- begin-user-doc --> <!-- end-user-doc -->
0321: * @generated
0322: */
0323: public ProjectRegistry createProjectRegistry() {
0324: ProjectRegistryImpl projectRegistry = new ProjectRegistryImpl();
0325: return projectRegistry;
0326: }
0327:
0328: /**
0329: * <!-- begin-user-doc --> <!-- end-user-doc -->
0330: * @generated
0331: */
0332: public StyleBlackboard createStyleBlackboard() {
0333: StyleBlackboardImpl styleBlackboard = new StyleBlackboardImpl();
0334: return styleBlackboard;
0335: }
0336:
0337: /**
0338: * <!-- begin-user-doc --> <!-- end-user-doc -->
0339: * @generated
0340: */
0341: public StyleEntry createStyleEntry() {
0342: StyleEntryImpl styleEntry = new StyleEntryImpl();
0343: return styleEntry;
0344: }
0345:
0346: /**
0347: * <!-- begin-user-doc --> <!-- end-user-doc -->
0348: * @generated
0349: */
0350: public LayerFactory createLayerFactory() {
0351: LayerFactoryImpl layerFactory = new LayerFactoryImpl();
0352: return layerFactory;
0353: }
0354:
0355: /**
0356: * <!-- begin-user-doc --> <!-- end-user-doc -->
0357: * @generated
0358: */
0359: public PicoBlackboard createPicoBlackboard() {
0360: PicoBlackboardImpl picoBlackboard = new PicoBlackboardImpl();
0361: return picoBlackboard;
0362: }
0363:
0364: /**
0365: * <!-- begin-user-doc --> <!-- end-user-doc -->
0366: * @generated
0367: */
0368: public Blackboard createBlackboard() {
0369: BlackboardImpl blackboard = new BlackboardImpl();
0370: return blackboard;
0371: }
0372:
0373: /**
0374: * <!-- begin-user-doc --> <!-- end-user-doc -->
0375: * @generated
0376: */
0377: public BlackboardEntry createBlackboardEntry() {
0378: BlackboardEntryImpl blackboardEntry = new BlackboardEntryImpl();
0379: return blackboardEntry;
0380: }
0381:
0382: /**
0383: * <!-- begin-user-doc --> <!-- end-user-doc -->
0384: * @generated
0385: */
0386: public EditManager createEditManager() {
0387: EditManagerImpl editManager = new EditManagerImpl();
0388: return editManager;
0389: }
0390:
0391: /**
0392: * <!-- begin-user-doc --> <!-- end-user-doc -->
0393: * @generated
0394: */
0395: public Query createQueryFromString(EDataType eDataType,
0396: String initialValue) {
0397: return (Query) super .createFromString(eDataType, initialValue);
0398: }
0399:
0400: /**
0401: * <!-- begin-user-doc --> <!-- end-user-doc -->
0402: * @generated
0403: */
0404: public String convertQueryToString(EDataType eDataType,
0405: Object instanceValue) {
0406: return super .convertToString(eDataType, instanceValue);
0407: }
0408:
0409: /**
0410: * <!-- begin-user-doc --> <!-- end-user-doc -->
0411: *
0412: * @generated NOT
0413: */
0414: public Envelope createEnvelopeFromString(EDataType eDataType,
0415: String initialValue) {
0416: if (initialValue.equals("")) //$NON-NLS-1$
0417: return new Envelope();
0418: String[] coords = initialValue.substring(1,
0419: initialValue.length() - 2).split(","); //$NON-NLS-1$
0420: return new Envelope(Integer.parseInt(coords[0]), Integer
0421: .parseInt(coords[1]), Integer.parseInt(coords[2]),
0422: Integer.parseInt(coords[3]));
0423: }
0424:
0425: /**
0426: * <!-- begin-user-doc --> <!-- end-user-doc -->
0427: *
0428: * @generated NOT
0429: */
0430: public String convertEnvelopeToString(EDataType eDataType,
0431: Object instanceValue) {
0432: Envelope env = (Envelope) instanceValue;
0433: if (env.isNull())
0434: return ""; //$NON-NLS-1$
0435: return ((Envelope) instanceValue).toString();
0436: }
0437:
0438: /**
0439: * <!-- begin-user-doc --> <!-- end-user-doc -->
0440: * @generated
0441: */
0442: public Coordinate createCoordinateFromString(EDataType eDataType,
0443: String initialValue) {
0444: return (Coordinate) super .createFromString(eDataType,
0445: initialValue);
0446: }
0447:
0448: /**
0449: * <!-- begin-user-doc --> <!-- end-user-doc -->
0450: * @generated
0451: */
0452: public String convertCoordinateToString(EDataType eDataType,
0453: Object instanceValue) {
0454: return super .convertToString(eDataType, instanceValue);
0455: }
0456:
0457: /**
0458: * <!-- begin-user-doc --> <!-- end-user-doc -->
0459: * @generated
0460: */
0461: public NavCommand createNavCommandFromString(EDataType eDataType,
0462: String initialValue) {
0463: return (NavCommand) super .createFromString(eDataType,
0464: initialValue);
0465: }
0466:
0467: /**
0468: * <!-- begin-user-doc --> <!-- end-user-doc -->
0469: * @generated
0470: */
0471: public String convertNavCommandToString(EDataType eDataType,
0472: Object instanceValue) {
0473: return super .convertToString(eDataType, instanceValue);
0474: }
0475:
0476: /**
0477: * <!-- begin-user-doc --> <!-- end-user-doc -->
0478: * @generated
0479: */
0480: public Feature createFeatureFromString(EDataType eDataType,
0481: String initialValue) {
0482: return (Feature) super
0483: .createFromString(eDataType, initialValue);
0484: }
0485:
0486: /**
0487: * <!-- begin-user-doc --> <!-- end-user-doc -->
0488: * @generated
0489: */
0490: public String convertFeatureToString(EDataType eDataType,
0491: Object instanceValue) {
0492: return super .convertToString(eDataType, instanceValue);
0493: }
0494:
0495: /**
0496: * <!-- begin-user-doc --> <!-- end-user-doc -->
0497: * @generated
0498: */
0499: public ImageDescriptor createImageDescriptorFromString(
0500: EDataType eDataType, String initialValue) {
0501: return (ImageDescriptor) super .createFromString(eDataType,
0502: initialValue);
0503: }
0504:
0505: /**
0506: * <!-- begin-user-doc --> <!-- end-user-doc -->
0507: * @generated
0508: */
0509: public String convertImageDescriptorToString(EDataType eDataType,
0510: Object instanceValue) {
0511: return super .convertToString(eDataType, instanceValue);
0512: }
0513:
0514: /**
0515: * <!-- begin-user-doc --> <!-- end-user-doc -->
0516: * @generated
0517: */
0518: public AffineTransform createAffineTransformFromString(
0519: EDataType eDataType, String initialValue) {
0520: return (AffineTransform) super .createFromString(eDataType,
0521: initialValue);
0522: }
0523:
0524: /**
0525: * <!-- begin-user-doc --> <!-- end-user-doc -->
0526: * @generated
0527: */
0528: public String convertAffineTransformToString(EDataType eDataType,
0529: Object instanceValue) {
0530: return super .convertToString(eDataType, instanceValue);
0531: }
0532:
0533: /**
0534: * <!-- begin-user-doc --> <!-- end-user-doc -->
0535: * @generated
0536: */
0537: public NavCommandStack createNavCommandStackFromString(
0538: EDataType eDataType, String initialValue) {
0539: return (NavCommandStack) super .createFromString(eDataType,
0540: initialValue);
0541: }
0542:
0543: /**
0544: * <!-- begin-user-doc --> <!-- end-user-doc -->
0545: * @generated
0546: */
0547: public String convertNavCommandStackToString(EDataType eDataType,
0548: Object instanceValue) {
0549: return super .convertToString(eDataType, instanceValue);
0550: }
0551:
0552: /**
0553: * <!-- begin-user-doc --> <!-- end-user-doc -->
0554: *
0555: * @generated NOT
0556: */
0557: public CoordinateReferenceSystem createCoordinateReferenceSystemFromString(
0558: EDataType eDataType, String initialValue) {
0559: return (CoordinateReferenceSystem) RenderFactory.eINSTANCE
0560: .createFromString(RenderPackage.eINSTANCE
0561: .getCoordinateReferenceSystem(), initialValue);
0562: }
0563:
0564: /**
0565: * <!-- begin-user-doc --> <!-- end-user-doc -->
0566: *
0567: * @generated NOT
0568: */
0569: public String convertCoordinateReferenceSystemToString(
0570: EDataType eDataType, Object instanceValue) {
0571: return RenderFactory.eINSTANCE.convertToString(
0572: RenderPackage.eINSTANCE.getCoordinateReferenceSystem(),
0573: instanceValue);
0574: }
0575:
0576: /**
0577: * <!-- begin-user-doc --> <!-- end-user-doc -->
0578: * @generated
0579: */
0580: public CommandStack createCommandStackFromString(
0581: EDataType eDataType, String initialValue) {
0582: return (CommandStack) super .createFromString(eDataType,
0583: initialValue);
0584: }
0585:
0586: /**
0587: * <!-- begin-user-doc --> <!-- end-user-doc -->
0588: * @generated
0589: */
0590: public String convertCommandStackToString(EDataType eDataType,
0591: Object instanceValue) {
0592: return super .convertToString(eDataType, instanceValue);
0593: }
0594:
0595: /**
0596: * <!-- begin-user-doc --> <!-- end-user-doc -->
0597: * @generated
0598: */
0599: public Point createPointFromString(EDataType eDataType,
0600: String initialValue) {
0601: return (Point) super .createFromString(eDataType, initialValue);
0602: }
0603:
0604: /**
0605: * <!-- begin-user-doc --> <!-- end-user-doc -->
0606: * @generated
0607: */
0608: public String convertPointToString(EDataType eDataType,
0609: Object instanceValue) {
0610: return super .convertToString(eDataType, instanceValue);
0611: }
0612:
0613: /**
0614: * <!-- begin-user-doc --> <!-- end-user-doc -->
0615: * @generated
0616: */
0617: public Adapter createAdapterFromString(EDataType eDataType,
0618: String initialValue) {
0619: return (Adapter) super
0620: .createFromString(eDataType, initialValue);
0621: }
0622:
0623: /**
0624: * <!-- begin-user-doc --> <!-- end-user-doc -->
0625: * @generated
0626: */
0627: public String convertAdapterToString(EDataType eDataType,
0628: Object instanceValue) {
0629: return super .convertToString(eDataType, instanceValue);
0630: }
0631:
0632: /**
0633: * <!-- begin-user-doc --> <!-- end-user-doc -->
0634: * @generated NOT
0635: */
0636: public URL createURLFromString(EDataType eDataType,
0637: String initialValue) {
0638:
0639: try {
0640: return new URL(null, initialValue,
0641: CorePlugin.RELAXED_HANDLER);
0642: } catch (MalformedURLException e) {
0643: throw (RuntimeException) new RuntimeException(e);
0644: }
0645: }
0646:
0647: /**
0648: * <!-- begin-user-doc --> <!-- end-user-doc -->
0649: * @generated
0650: */
0651: public String convertURLToString(EDataType eDataType,
0652: Object instanceValue) {
0653: return instanceValue.toString();
0654: }
0655:
0656: /**
0657: * <!-- begin-user-doc --> <!-- end-user-doc -->
0658: * @generated
0659: */
0660: public EditCommand createEditCommandFromString(EDataType eDataType,
0661: String initialValue) {
0662: return (EditCommand) super .createFromString(eDataType,
0663: initialValue);
0664: }
0665:
0666: /**
0667: * <!-- begin-user-doc --> <!-- end-user-doc -->
0668: * @generated
0669: */
0670: public String convertEditCommandToString(EDataType eDataType,
0671: Object instanceValue) {
0672: return super .convertToString(eDataType, instanceValue);
0673: }
0674:
0675: /**
0676: * <!-- begin-user-doc --> <!-- end-user-doc -->
0677: * @generated
0678: */
0679: public URI createURIFromString(EDataType eDataType,
0680: String initialValue) {
0681: return (URI) super .createFromString(eDataType, initialValue);
0682: }
0683:
0684: /**
0685: * <!-- begin-user-doc --> <!-- end-user-doc -->
0686: * @generated
0687: */
0688: public String convertURIToString(EDataType eDataType,
0689: Object instanceValue) {
0690: return super .convertToString(eDataType, instanceValue);
0691: }
0692:
0693: /**
0694: * <!-- begin-user-doc --> <!-- end-user-doc -->
0695: * @generated
0696: */
0697: public MapCommand createCommandFromString(EDataType eDataType,
0698: String initialValue) {
0699: return (MapCommand) super .createFromString(eDataType,
0700: initialValue);
0701: }
0702:
0703: /**
0704: * <!-- begin-user-doc --> <!-- end-user-doc -->
0705: * @generated
0706: */
0707: public String convertCommandToString(EDataType eDataType,
0708: Object instanceValue) {
0709: return super .convertToString(eDataType, instanceValue);
0710: }
0711:
0712: /**
0713: * <!-- begin-user-doc --> <!-- end-user-doc -->
0714: * @generated
0715: */
0716: public IMapDisplay createMapDisplayFromString(EDataType eDataType,
0717: String initialValue) {
0718: return (IMapDisplay) super .createFromString(eDataType,
0719: initialValue);
0720: }
0721:
0722: /**
0723: * <!-- begin-user-doc --> <!-- end-user-doc -->
0724: * @generated
0725: */
0726: public String convertMapDisplayToString(EDataType eDataType,
0727: Object instanceValue) {
0728: return super .convertToString(eDataType, instanceValue);
0729: }
0730:
0731: /**
0732: * <!-- begin-user-doc --> <!-- end-user-doc -->
0733: * @generated
0734: */
0735: public List createListFromString(EDataType eDataType,
0736: String initialValue) {
0737: return (List) super .createFromString(eDataType, initialValue);
0738: }
0739:
0740: /**
0741: * <!-- begin-user-doc --> <!-- end-user-doc -->
0742: * @generated
0743: */
0744: public String convertListToString(EDataType eDataType,
0745: Object instanceValue) {
0746: return super .convertToString(eDataType, instanceValue);
0747: }
0748:
0749: /**
0750: * <!-- begin-user-doc --> <!-- end-user-doc -->
0751: * @generated
0752: */
0753: public FeatureResults createFeatureResultsFromString(
0754: EDataType eDataType, String initialValue) {
0755: return (FeatureResults) super .createFromString(eDataType,
0756: initialValue);
0757: }
0758:
0759: /**
0760: * <!-- begin-user-doc --> <!-- end-user-doc -->
0761: * @generated
0762: */
0763: public String convertFeatureResultsToString(EDataType eDataType,
0764: Object instanceValue) {
0765: return super .convertToString(eDataType, instanceValue);
0766: }
0767:
0768: /**
0769: * <!-- begin-user-doc --> <!-- end-user-doc -->
0770: * @generated
0771: */
0772: public IGeoResource createIGeoResourceFromString(
0773: EDataType eDataType, String initialValue) {
0774: return (IGeoResource) super .createFromString(eDataType,
0775: initialValue);
0776: }
0777:
0778: /**
0779: * <!-- begin-user-doc --> <!-- end-user-doc -->
0780: * @generated
0781: */
0782: public String convertIGeoResourceToString(EDataType eDataType,
0783: Object instanceValue) {
0784: return super .convertToString(eDataType, instanceValue);
0785: }
0786:
0787: /**
0788: * <!-- begin-user-doc --> <!-- end-user-doc -->
0789: *
0790: * @generated NOT
0791: */
0792: public CatalogRef createCatalogRefFromString(EDataType eDataType,
0793: String initialValue) {
0794: CatalogRef ref = new CatalogRef();
0795: try {
0796: ref.parseResourceParameters(initialValue);
0797: return ref;
0798: } catch (Exception e) {
0799: return ref;
0800: }
0801:
0802: }
0803:
0804: /**
0805: * <!-- begin-user-doc --> <!-- end-user-doc -->
0806: *
0807: * @generated NOT
0808: */
0809: public String convertCatalogRefToString(EDataType eDataType,
0810: Object instanceValue) {
0811: try {
0812: return instanceValue.toString();
0813: } catch (Exception e) {
0814: return ""; //$NON-NLS-1$
0815: }
0816: }
0817:
0818: /**
0819: * <!-- begin-user-doc --> <!-- end-user-doc -->
0820: * @generated NOT
0821: */
0822: public BrewerPalette createColourPaletteFromString(
0823: EDataType eDataType, String initialValue) {
0824: return PlatformGIS.getColorBrewer().getPalette(initialValue);
0825: }
0826:
0827: /**
0828: * <!-- begin-user-doc --> <!-- end-user-doc -->
0829: * @generated NOT
0830: */
0831: public String convertColourPaletteToString(EDataType eDataType,
0832: Object instanceValue) {
0833: return ((BrewerPalette) instanceValue).getName();
0834: }
0835:
0836: /**
0837: * <!-- begin-user-doc --> <!-- end-user-doc -->
0838: *
0839: * @generated NOT
0840: */
0841: public ColourScheme createColourSchemeFromString(
0842: EDataType eDataType, String initialValue) {
0843: String[] parts = initialValue.split(";"); //$NON-NLS-1$
0844: if (parts.length != 4) {
0845: //something is wrong...
0846: BrewerPalette palette = PlatformGIS.getColorBrewer()
0847: .getPalette("Dark2"); //$NON-NLS-1$
0848: return new ColourScheme(palette, 0);
0849: }
0850: String[] strap = parts[2].split(","); //$NON-NLS-1$
0851: BrewerPalette palette = PlatformGIS.getColorBrewer()
0852: .getPalette(parts[0]);
0853: HashMap<Integer, Integer> colourMapping = new HashMap<Integer, Integer>();
0854: for (int i = 0; i < strap.length; i++) {
0855: colourMapping.put(i, Integer.parseInt(strap[i]));
0856: }
0857: String[] strap2 = parts[3].split(","); //$NON-NLS-1$
0858: HashMap<String, Integer> idMapping = new HashMap<String, Integer>();
0859: for (int i = 0; i < strap2.length; i++) {
0860: idMapping.put(strap2[i], Integer.parseInt(strap2[++i]));
0861: }
0862: ColourScheme scheme = new ColourScheme(palette, colourMapping,
0863: idMapping, strap.length, Integer.parseInt(parts[1]));
0864: return scheme;
0865: }
0866:
0867: /**
0868: * <!-- begin-user-doc --> <!-- end-user-doc -->
0869: *
0870: * @generated NOT
0871: */
0872: public String convertColourSchemeToString(EDataType eDataType,
0873: Object instanceValue) {
0874: ColourScheme instance = (ColourScheme) instanceValue;
0875: String value = instance.getColourPalette().getName() + ";"; //$NON-NLS-1$;
0876: int numItems = instance.getSizeScheme();
0877: int numColours = instance.getSizePalette();
0878: value = value + numColours + ";"; //$NON-NLS-1$
0879: HashMap colourMap = instance.getColourMap();
0880: for (int i = 0; i < numItems; i++) {
0881: if (i > 0)
0882: value = value + ","; //$NON-NLS-1$
0883: value = value + colourMap.get(i);
0884: }
0885: value = value + ";"; //$NON-NLS-1$
0886: HashMap<String, Integer> idMap = instance.getIdMap();
0887: Iterator<Entry<String, Integer>> it = idMap.entrySet()
0888: .iterator();
0889: while (it.hasNext()) {
0890: Entry<String, Integer> entry = it.next();
0891: value = value + entry.getKey() + "," + entry.getValue(); //$NON-NLS-1$
0892: if (it.hasNext()) {
0893: value = value + ","; //$NON-NLS-1$
0894: }
0895: }
0896: return value;
0897: }
0898:
0899: /**
0900: * <!-- begin-user-doc --> <!-- end-user-doc -->
0901: *
0902: * @generated NOT
0903: */
0904: public Color createDefaultColorFromString(EDataType eDataType,
0905: String initialValue) {
0906:
0907: return SLD.toColor(initialValue);
0908: }
0909:
0910: /**
0911: * <!-- begin-user-doc --> <!-- end-user-doc -->
0912: *
0913: * @generated NOT
0914: */
0915: public String convertDefaultColorToString(EDataType eDataType,
0916: Object instanceValue) {
0917: Color instance = (Color) instanceValue;
0918: return SLD.toHTMLColor(instance);
0919: }
0920:
0921: /**
0922: * <!-- begin-user-doc --> <!-- end-user-doc -->
0923: * @generated
0924: */
0925: public MutablePicoContainer createMutablePicoContainerFromString(
0926: EDataType eDataType, String initialValue) {
0927: return (MutablePicoContainer) super .createFromString(eDataType,
0928: initialValue);
0929: }
0930:
0931: /**
0932: * <!-- begin-user-doc --> <!-- end-user-doc -->
0933: * @generated
0934: */
0935: public String convertMutablePicoContainerToString(
0936: EDataType eDataType, Object instanceValue) {
0937: return super .convertToString(eDataType, instanceValue);
0938: }
0939:
0940: /**
0941: * <!-- begin-user-doc --> <!-- end-user-doc -->
0942: * @generated
0943: */
0944: public ReferencedEnvelope createReferencedEnvelopeFromString(
0945: EDataType eDataType, String initialValue) {
0946: return (ReferencedEnvelope) super .createFromString(eDataType,
0947: initialValue);
0948: }
0949:
0950: /**
0951: * <!-- begin-user-doc --> <!-- end-user-doc -->
0952: * @generated
0953: */
0954: public String convertReferencedEnvelopeToString(
0955: EDataType eDataType, Object instanceValue) {
0956: return super .convertToString(eDataType, instanceValue);
0957: }
0958:
0959: /**
0960: * <!-- begin-user-doc --> <!-- end-user-doc -->
0961: * @generated
0962: */
0963: public FeatureEvent createFeatureEventFromString(
0964: EDataType eDataType, String initialValue) {
0965: return (FeatureEvent) super .createFromString(eDataType,
0966: initialValue);
0967: }
0968:
0969: /**
0970: * <!-- begin-user-doc --> <!-- end-user-doc -->
0971: * @generated
0972: */
0973: public String convertFeatureEventToString(EDataType eDataType,
0974: Object instanceValue) {
0975: return super .convertToString(eDataType, instanceValue);
0976: }
0977:
0978: /**
0979: * <!-- begin-user-doc --> <!-- end-user-doc -->
0980: * @generated
0981: */
0982: public Filter createFilterFromString(EDataType eDataType,
0983: String initialValue) {
0984: return (Filter) super .createFromString(eDataType, initialValue);
0985: }
0986:
0987: /**
0988: * <!-- begin-user-doc --> <!-- end-user-doc -->
0989: * @generated
0990: */
0991: public String convertFilterToString(EDataType eDataType,
0992: Object instanceValue) {
0993: return super .convertToString(eDataType, instanceValue);
0994: }
0995:
0996: /**
0997: * <!-- begin-user-doc --> <!-- end-user-doc -->
0998: * @generated
0999: */
1000: public IProgressMonitor createIProgressMonitorFromString(
1001: EDataType eDataType, String initialValue) {
1002: return (IProgressMonitor) super .createFromString(eDataType,
1003: initialValue);
1004: }
1005:
1006: /**
1007: * <!-- begin-user-doc --> <!-- end-user-doc -->
1008: * @generated
1009: */
1010: public String convertIProgressMonitorToString(EDataType eDataType,
1011: Object instanceValue) {
1012: return super .convertToString(eDataType, instanceValue);
1013: }
1014:
1015: /**
1016: * <!-- begin-user-doc --> <!-- end-user-doc -->
1017: * @generated
1018: */
1019: public String convertEditManagerControlCommandToString(
1020: EDataType eDataType, Object instanceValue) {
1021: return super .convertToString(eDataType, instanceValue);
1022: }
1023:
1024: /**
1025: * <!-- begin-user-doc --> <!-- end-user-doc -->
1026: * @generated
1027: */
1028: public ProjectPackage getProjectPackage() {
1029: return (ProjectPackage) getEPackage();
1030: }
1031:
1032: /**
1033: * <!-- begin-user-doc --> <!-- end-user-doc -->
1034: * @deprecated
1035: * @generated
1036: */
1037: public static ProjectPackage getPackage() {
1038: return ProjectPackage.eINSTANCE;
1039: }
1040:
1041: /**
1042: * <!-- begin-user-doc --> <!-- end-user-doc -->
1043: *
1044: * @generated NOT
1045: */
1046: public Map createMap() {
1047: MapImpl map = new MapImpl();
1048: map.setLayerFactory(createLayerFactory());
1049: map.setBlackBoardInternal(createBlackboard());
1050: return map;
1051: }
1052:
1053: private void runMapCreationInterceptors(Map map) {
1054: List<IConfigurationElement> interceptors = ExtensionPointList
1055: .getExtensionPointList(MapInterceptor.MAP_INTERCEPTOR_EXTENSIONPOINT); //$NON-NLS-1$
1056: for (IConfigurationElement element : interceptors) {
1057: if (!"mapCreation".equals(element.getName())) //$NON-NLS-1$
1058: continue;
1059: try {
1060: MapInterceptor interceptor = (MapInterceptor) element
1061: .createExecutableExtension("class"); //$NON-NLS-1$
1062: interceptor.run(map);
1063: } catch (Exception e) {
1064: ProjectPlugin.log("", e); //$NON-NLS-1$
1065: }
1066: }
1067: }
1068:
1069: /**
1070: * @see net.refractions.udig.project.ProjectFactory#createMap(net.refractions.udig.project.Project,
1071: * java.lang.String, java.util.List)
1072: */
1073: @SuppressWarnings("unchecked")//$NON-NLS-1$
1074: public Map createMap(Project owner, String name, List layers) {
1075: Map map = createMap();
1076:
1077: map.setName(name);
1078: map.setProjectInternal(owner);
1079: map.setViewportModelInternal(RenderFactory.eINSTANCE
1080: .createViewportModel());
1081: runMapCreationInterceptors(map);
1082: if (!layers.isEmpty())
1083: map.getLayersInternal().addAll(layers);
1084:
1085: return map;
1086: }
1087:
1088: } // ProjectFactoryImpl
|