250 likes | 379 Views
Chapter 11 Navigating Object Model Diagrams. Week 6, 2008 Spring. Getting Layers/Assigning Colors. Which layer/dataframe change will be made? Start from MxDocument class (currently opened .mxd file) Map class (refers to a data frame) FeatureLayer class
E N D
Chapter 11 Navigating Object Model Diagrams Week 6, 2008 Spring
Getting Layers/Assigning Colors • Which layer/dataframe change will be made? • Start from MxDocument class (currently opened .mxd file) • Map class (refers to a data frame) • FeatureLayer class • Renderer class (layer’s legend) • Symbol class • Color class MxDocument is associated with the Map class, but not with Color class. Associated – means that MxDocument’s object has objects in the connected class. Each map document have data frames. Symbols class is connected to Color class, -> symbols have colors.
Association (Class to Class) • * Asterisk means multiplicity – many maps in one map documents (*asterisk not in Mxd to Application) • Properties of Classes • In ILayer, Name returns string and Visible returns boolean values • Some return interfaces, such as FocusMap in IMxDocument returns IMap. FocusMap tells you which dataframe is active. If you want to hop from the MxDocument class to the Map class, you get the FocusMap property. • ThisDocument (predefined object of MxDocument) is an object from IDocument (not IMxDocument), but FocusMap property is with IMxDocument, so that we have to use QI to get to IMxDocument • See next slide for code
From Map to Layer Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument ‘ QI Dim pMap As IMap Set pMap = pMxDoc.FocusMap ‘hop from MxDocument class to Map class ‘To access Layer ‘Layer class is associated with Map Dim pLayer As ILayer Set pLayer = pMap.Layer(1)
Instantiation (class to class) • Also called “Creates” relationship • Where method in class creates object from another class. • Dashed line with an arrow that points to the created object.
Inheritance (class to class) • When a particular class uses an interface (“Implement”) from a more general class. • Abstract class (Such as Layer) – no objects, once interface is implemented, then objects can be created, (page 176) • Solid lines with triangle:e.g. Layer with ILayer and other connected classes inherit all of layer’s interfaces • To create a new FeatureLayer and set its Name property: • Dim pLayer As ILayer • Set pLayer = New FeatureLayer • pLayer.Name = “USA”
Three different Class Types • Abstract Classes: 2-D gray boxes, no object, parking spots for common interfaces, you need to implement them. • Classes (regular classes): 3-D white boxes. You can’t create from the New keyword, need to use methods/property of other class to get this. • Coclasses: 3-D gray boxes. You can create object with New keyword or from other class’s property or methods.
This only updates TOC, not map. Dim pActiveView As IActiveView Set pActiveView = pMxDoc.ActiveView pActiveView.Refresh
Color Objects • Each color is an object, following diagram show Color abstract and five coclasses: ICmykColor, IRgbColor, IHIsColor, IGrayColor, IHsvColor • Monitor use RGB and printer use CMYK IRgbColor To make a sandy yellow: pRgbColor.Red = 255 pRgbColor.Green= 255 pRgbColor.Blue = 190 RgbColor Blue: Long Green: Long Red: Long
Access Color (p. 189) • Application -- • MxDocument -- • PageLayout -- • Page ---- • Color on the Display diagram