Example #1
0
        public Legend(SourceMap sourceMap, MashupParseContext context, DirtyEvent parentEvent, DirtyEvent parentBoundsChangedEvent)
        {
            this._sourceMap          = sourceMap;
            this.dirtyEvent          = new DirtyEvent(parentEvent);
            this._latentRegionHolder = new LatentRegionHolder(this.dirtyEvent, parentBoundsChangedEvent);
            this._displayName        = context.GetRequiredAttribute("DisplayName");
            string attribute = context.reader.GetAttribute("RenderedSize");

            if (attribute != null)
            {
                Legend.renderedSizeRange.Parse(context, "RenderedSize", attribute);
            }
            XMLTagReader xMLTagReader = context.NewTagReader(Legend.GetXMLTag());

            context.ExpectIdentity(this);
            while (xMLTagReader.FindNextStartTag())
            {
                if (xMLTagReader.TagIs(RenderRegion.GetXMLTag()))
                {
                    context.AssertUnique(this._latentRegionHolder.renderRegion);
                    this._latentRegionHolder.renderRegion = new RenderRegion(context, this.dirtyEvent, ContinuousCoordinateSystem.theInstance);
                }
                else
                {
                    if (xMLTagReader.TagIs(LegendView.GetXMLTag()))
                    {
                        this._lastView = new LegendView(this, context);
                    }
                }
            }
        }
Example #2
0
        internal Size GetOutputSizeSynchronously(IFuture synchronousUserBoundsFuture)
        {
            RenderRegion renderRegionSynchronously =
                latentRegionHolder.GetRenderRegionSynchronously(synchronousUserBoundsFuture);

            return(OutputSizeFromRenderRegion(renderRegionSynchronously));
        }
Example #3
0
 private void StoreRenderRegion(Present present)
 {
     if (this.renderRegion == null && present is BoundsPresent)
     {
         BoundsPresent boundsPresent = (BoundsPresent)present;
         this.renderRegion = boundsPresent.GetRenderRegion().Copy(this.dirtyEvent);
         this.boundsChangedEvent.SetDirty();
     }
 }
		private void StoreRenderRegion(Present present)
		{
			if (this.renderRegion == null && present is BoundsPresent)
			{
				BoundsPresent boundsPresent = (BoundsPresent)present;
				this.renderRegion = boundsPresent.GetRenderRegion().Copy(this.dirtyEvent);
				this.boundsChangedEvent.SetDirty();
			}
		}
Example #5
0
        public IFuture GetRenderedLegendFuture(IDisplayableSource displayableSource, FutureFeatures features)
        {
            RenderRegion renderRegion = latentRegionHolder.renderRegion;

            if (renderRegion == null)
            {
                throw new RenderFailedException("Region unavailable");
            }

            renderRegion = renderRegion.Copy(new DirtyEvent());
            MapRectangleParameter mapRectangleParameter = new MapRectangleParameter(renderRegion.GetBoundingBox());
            Size             outputSize     = OutputSizeFromRenderRegion(renderRegion);
            IFuturePrototype imagePrototype =
                displayableSource.GetImagePrototype(new ImageParameterFromRawBounds(outputSize), features);

            return(imagePrototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, mapRectangleParameter })));
        }
Example #6
0
        private Size OutputSizeFromRenderRegion(RenderRegion renderRegion)
        {
            MapRectangleParameter mapRectangleParameter = new MapRectangleParameter(renderRegion.GetBoundingBox());

            return(mapRectangleParameter.value.SizeWithAspectRatio(this.renderedSize));
        }
Example #7
0
        public SourceMap(MashupParseContext context, GetFilenameContext filenameContextDelegate, DirtyEvent parentDirty,
                         DirtyEvent parentReadyToLockEvent)
        {
            dirtyEvent = new DirtyEvent(parentDirty);
            readyToLockChangedEvent      = new DirtyEvent(parentReadyToLockEvent);
            this.filenameContextDelegate = filenameContextDelegate;
            latentRegionHolder           = new LatentRegionHolder(dirtyEvent, readyToLockChangedEvent);
            var xMLTagReader = context.NewTagReader("SourceMap");

            context.ExpectIdentity(this);
            string attribute = context.reader.GetAttribute("SourceMapFilename");

            if (attribute != null)
            {
                string path       = Path.Combine(filenameContextDelegate(), attribute);
                int    pageNumber = 0;
                context.GetAttributeInt("PageNumber", ref pageNumber);
                documentFuture = new GeneralDocumentFuture(new FutureDocumentFromFilesystem(path, pageNumber));
            }

            context.GetAttributeBoolean("Expanded", ref _expanded);
            string      attribute2   = context.reader.GetAttribute("DisplayName");
            MapPosition mapPosition  = null;
            MapPosition mapPosition2 = null;

            while (xMLTagReader.FindNextStartTag())
            {
                if (xMLTagReader.TagIs(RegistrationDefinition.GetXMLTag()))
                {
                    context.AssertUnique(registration);
                    registration = new RegistrationDefinition(context, dirtyEvent);
                }
                else
                {
                    if (xMLTagReader.TagIs(GeneralDocumentFuture.GetXMLTag()))
                    {
                        context.AssertUnique(documentFuture);
                        documentFuture = new GeneralDocumentFuture(context, filenameContextDelegate());
                    }
                    else
                    {
                        if (xMLTagReader.TagIs(LocalDocumentDescriptor.GetXMLTag()))
                        {
                            context.AssertUnique(documentFuture);
                            var localDocumentDescriptor =
                                new LocalDocumentDescriptor(context, filenameContextDelegate());
                            documentFuture = new GeneralDocumentFuture(
                                new FutureDocumentFromFilesystem(localDocumentDescriptor.GetFilesystemAbsolutePath(),
                                                                 localDocumentDescriptor.GetPageNumber()));
                        }
                        else
                        {
                            if (xMLTagReader.TagIs("LastSourceMapPosition"))
                            {
                                var xMLTagReader2 = context.NewTagReader("LastSourceMapPosition");
                                while (xMLTagReader2.FindNextStartTag())
                                {
                                    if (xMLTagReader2.TagIs(MapPosition.GetXMLTag(context.version)))
                                    {
                                        mapPosition = new MapPosition(context,
                                                                      null,
                                                                      ContinuousCoordinateSystem.theInstance);
                                    }
                                }
                            }
                            else
                            {
                                if (xMLTagReader.TagIs("LastVEPosition"))
                                {
                                    var xMLTagReader3 = context.NewTagReader("LastVEPosition");
                                    while (xMLTagReader3.FindNextStartTag())
                                    {
                                        if (xMLTagReader3.TagIs(MapPosition.GetXMLTag(context.version)))
                                        {
                                            mapPosition2 = new MapPosition(context,
                                                                           null,
                                                                           MercatorCoordinateSystem.theInstance);
                                        }
                                    }
                                }
                                else
                                {
                                    if (xMLTagReader.TagIs(RenderRegion.GetXMLTag()))
                                    {
                                        context.AssertUnique(renderRegion);
                                        renderRegion = new RenderRegion(context,
                                                                        dirtyEvent,
                                                                        ContinuousCoordinateSystem.theInstance);
                                    }
                                    else
                                    {
                                        if (xMLTagReader.TagIs(SourceMapInfo.GetXMLTag()))
                                        {
                                            context.AssertUnique(sourceMapInfo);
                                            sourceMapInfo = new SourceMapInfo(context, dirtyEvent);
                                        }
                                        else
                                        {
                                            if (xMLTagReader.TagIs(SourceMapRenderOptions.GetXMLTag()))
                                            {
                                                context.AssertUnique(sourceMapRenderOptions);
                                                sourceMapRenderOptions =
                                                    new SourceMapRenderOptions(context, dirtyEvent);
                                            }
                                            else
                                            {
                                                if (xMLTagReader.TagIs(TransparencyOptions.GetXMLTag()))
                                                {
                                                    transparencyOptions =
                                                        new TransparencyOptions(context, dirtyEvent);
                                                }
                                                else
                                                {
                                                    if (xMLTagReader.TagIs(SourceMapRegistrationView.GetXMLTag()))
                                                    {
                                                        context.AssertUnique(_lastView);
                                                        _lastView = new SourceMapRegistrationView(this, context);
                                                    }
                                                    else
                                                    {
                                                        if (xMLTagReader.TagIs(LegendList.GetXMLTag()))
                                                        {
                                                            context.AssertUnique(legendList);
                                                            legendList = new LegendList(this,
                                                                                        context,
                                                                                        dirtyEvent);
                                                        }
                                                        else
                                                        {
                                                            if (xMLTagReader.TagIs("SnapView"))
                                                            {
                                                                var xMLTagReader4 =
                                                                    context.NewTagReader("SnapView");
                                                                string requiredAttribute =
                                                                    context.GetRequiredAttribute("Context");
                                                                var  latLonZoom = default(LatLonZoom);
                                                                bool flag       = false;
                                                                bool flag2      = true;
                                                                CoordinateSystemIfc coordSys;
                                                                if (requiredAttribute == "Source")
                                                                {
                                                                    coordSys = ContinuousCoordinateSystem.theInstance;
                                                                }
                                                                else
                                                                {
                                                                    if (!(requiredAttribute == "Reference"))
                                                                    {
                                                                        throw new InvalidMashupFile(context,
                                                                                                    string.Format("Invalid {0} value {1}",
                                                                                                                  "Context",
                                                                                                                  requiredAttribute));
                                                                    }

                                                                    coordSys = MercatorCoordinateSystem.theInstance;
                                                                }

                                                                while (xMLTagReader4.FindNextStartTag())
                                                                {
                                                                    if (xMLTagReader4.TagIs(LatLonZoom.GetXMLTag()))
                                                                    {
                                                                        if (flag)
                                                                        {
                                                                            context.ThrowUnique();
                                                                        }

                                                                        try
                                                                        {
                                                                            latLonZoom = new LatLonZoom(context,
                                                                                                        coordSys);
                                                                        }
                                                                        catch (InvalidLLZ)
                                                                        {
                                                                            flag2 = false;
                                                                        }

                                                                        flag = true;
                                                                    }
                                                                }

                                                                if (flag2)
                                                                {
                                                                    if (!flag)
                                                                    {
                                                                        context.AssertPresent(null,
                                                                                              LatLonZoom.GetXMLTag());
                                                                    }

                                                                    if (requiredAttribute == "Source")
                                                                    {
                                                                        sourceSnap = latLonZoom;
                                                                    }
                                                                    else
                                                                    {
                                                                        if (requiredAttribute == "Reference")
                                                                        {
                                                                            referenceSnap = latLonZoom;
                                                                        }
                                                                        else
                                                                        {
                                                                            D.Assert(false, "handled above.");
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (xMLTagReader.TagIs("SnapZoom"))
                                                                {
                                                                    context.NewTagReader("SnapZoom");
                                                                    string requiredAttribute2 =
                                                                        context.GetRequiredAttribute("Context");
                                                                    bool flag3 = false;
                                                                    CoordinateSystemIfc theInstance;
                                                                    if (requiredAttribute2 == "Source")
                                                                    {
                                                                        theInstance = ContinuousCoordinateSystem
                                                                                      .theInstance;
                                                                    }
                                                                    else
                                                                    {
                                                                        if (!(requiredAttribute2 == "Reference"))
                                                                        {
                                                                            throw new InvalidMashupFile(context,
                                                                                                        string.Format("Invalid {0} value {1}",
                                                                                                                      "Context",
                                                                                                                      requiredAttribute2));
                                                                        }

                                                                        theInstance = MercatorCoordinateSystem
                                                                                      .theInstance;
                                                                    }

                                                                    int num = 0;
                                                                    try
                                                                    {
                                                                        theInstance.GetZoomRange()
                                                                        .Parse(context, "Zoom");
                                                                        flag3 = true;
                                                                    }
                                                                    catch (InvalidMashupFile)
                                                                    {
                                                                    }

                                                                    if (flag3)
                                                                    {
                                                                        if (requiredAttribute2 == "Source")
                                                                        {
                                                                            sourceSnapZoom = num;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (requiredAttribute2 == "Reference")
                                                                            {
                                                                                referenceSnapZoom = num;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (context.version == InlineSourceMapInfoSchema.schema)
                {
                    if (xMLTagReader.TagIs("MapFileURL"))
                    {
                        sourceMapInfo.mapFileURL = XMLUtils.ReadStringXml(context, "MapFileURL");
                    }
                    else
                    {
                        if (xMLTagReader.TagIs("MapHomePage"))
                        {
                            sourceMapInfo.mapHomePage = XMLUtils.ReadStringXml(context, "MapHomePage");
                        }
                        else
                        {
                            if (xMLTagReader.TagIs("MapDescription"))
                            {
                                sourceMapInfo.mapDescription = XMLUtils.ReadStringXml(context, "MapDescription");
                            }
                        }
                    }
                }
            }

            if (attribute2 != null)
            {
                _displayName = attribute2;
            }
            else
            {
                _displayName = documentFuture.documentFuture.GetDefaultDisplayName();
            }

            if (_lastView == null && mapPosition != null && mapPosition2 != null)
            {
                _lastView = new SourceMapRegistrationView(this, mapPosition.llz, mapPosition2);
            }

            if (documentFuture == null)
            {
                throw new Exception("Source Map element missing document descriptor tag");
            }

            if (registration == null)
            {
                registration = new RegistrationDefinition(dirtyEvent);
            }

            registration.dirtyEvent.Add(readyToLockChangedEvent);
            if (legendList == null)
            {
                legendList = new LegendList(this, dirtyEvent, readyToLockChangedEvent);
            }

            if (sourceMapInfo == null)
            {
                sourceMapInfo = new SourceMapInfo(dirtyEvent);
            }

            if (sourceMapRenderOptions == null)
            {
                sourceMapRenderOptions = new SourceMapRenderOptions(dirtyEvent);
            }

            if (transparencyOptions == null)
            {
                transparencyOptions = new TransparencyOptions(dirtyEvent);
            }
        }
Example #8
0
		private Size OutputSizeFromRenderRegion(RenderRegion renderRegion)
		{
			MapRectangleParameter mapRectangleParameter = new MapRectangleParameter(renderRegion.GetBoundingBox());
			return mapRectangleParameter.value.SizeWithAspectRatio(this.renderedSize);
		}