#region Disclaimer / License
// Copyright (C) 2010, Jackie Ng
// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie@gmail.com
//
// 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; either
// version 2.1 of the License, or (at your option) any later version.
//
// 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.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using OSGeo.MapGuide.ObjectModels.LayerDefinition;
using OSGeo.MapGuide.MaestroAPI.Resource;
using OSGeo.MapGuide.ObjectModels.Common;
using OSGeo.MapGuide.MaestroAPI;
namespace OSGeo.MapGuide.ObjectModels.SymbolDefinition
{
///
/// Defines the type of symbol instances
///
public enum SymbolInstanceType
{
///
/// A library reference to an existing symbol definition
///
Reference,
///
/// An inline symbol definition
///
Inline
}
///
/// Represents a symbol instance used for advanced cartographic stylization
///
public interface ISymbolInstance
{
///
/// Gets or sets the symbol reference
///
ISymbolInstanceReference Reference { get; set; }
///
/// Gets the parameter overrides for this symbol
///
IParameterOverrideCollection ParameterOverrides { get; }
///
/// Gets or sets the X scale
///
string ScaleX { get; set; }
///
/// Gets or sets the Y scale
///
string ScaleY { get; set; }
///
/// Gets or sets the X insertion offset
///
string InsertionOffsetX { get; set; }
///
/// Gets or sets the Y insertion offset
///
string InsertionOffsetY { get; set; }
///
/// Gets or sets the size context
///
SizeContextType SizeContext { get; set; }
///
/// Gets or sets whether to draw this instance last
///
string DrawLast { get; set; }
///
/// Gets or sets whether to check the exclusion region
///
string CheckExclusionRegion { get; set; }
///
/// Gets or sets whether to add this instance to the exclusion region
///
string AddToExclusionRegion { get; set; }
///
/// Gets or sets the position algorithm
///
string PositioningAlgorithm { get; set; }
}
///
/// Represents a symbol instance reference
///
public interface ISymbolInstanceReference
{
///
/// Gets the type
///
SymbolInstanceType Type { get; }
}
///
/// Represents a symbol instance reference by a resource id
///
public interface ISymbolInstanceReferenceLibrary : ISymbolInstanceReference, IResourceIdReference
{
}
///
/// Represents a symbol instance reference by a inline definition
///
public interface ISymbolInstanceReferenceInline : ISymbolInstanceReference
{
///
/// Gets or sets the inline definition
///
ISymbolDefinitionBase SymbolDefinition { get; set; }
}
///
/// Extension methods for symbol definitions
///
public static class SymbolDefExtensions
{
///
/// Gets the parameters.
///
/// The sym.
///
public static IEnumerable GetParameters(this ISymbolDefinitionBase sym)
{
Check.NotNull(sym, "sym");
if (sym.Type == SymbolDefinitionType.Simple)
return ((ISimpleSymbolDefinition)sym).GetParameters();
else
return ((ICompoundSymbolDefinition)sym).GetParameters();
}
///
/// Gets the parameters.
///
/// The ssym.
///
public static IEnumerable GetParameters(this ISimpleSymbolDefinition ssym)
{
Check.NotNull(ssym, "ssym");
return ssym.ParameterDefinition.Parameter;
}
///
/// Gets the parameters.
///
/// The csym.
///
public static IEnumerable GetParameters(this ICompoundSymbolDefinition csym)
{
Check.NotNull(csym, "csym");
Check.NotNull(csym.CurrentConnection, "csym.CurrentConnection");
List p = new List();
foreach (var sym in csym.SimpleSymbol)
{
if (sym.Type == SimpleSymbolReferenceType.Inline)
{
ISimpleSymbolInlineReference ssir = (ISimpleSymbolInlineReference)sym;
p.AddRange(ssir.SimpleSymbolDefinition.GetParameters());
}
else if (sym.Type == SimpleSymbolReferenceType.Library)
{
ISimpleSymbolLibraryReference sslr = (ISimpleSymbolLibraryReference)sym;
var symDef = (ISymbolDefinitionBase)csym.CurrentConnection.ResourceService.GetResource(sslr.ResourceId);
if (symDef.Type == SymbolDefinitionType.Simple)
{
p.AddRange(((ISimpleSymbolDefinition)symDef).GetParameters());
}
else
{
p.AddRange(((ICompoundSymbolDefinition)symDef).GetParameters());
}
}
}
return p;
}
}
#region Symbol Definition 1.0.0 interfaces
///
/// Indicates the type of symbol definition
///
public enum SymbolDefinitionType
{
///
/// A simple symbol definition
///
Simple,
///
/// A compound symbol definition
///
Compound
}
///
/// Base interface of all symbol definitions
///
public interface ISymbolDefinitionBase : IResource
{
///
/// Gets or sets the name.
///
/// The name.
string Name { get; set; }
///
/// Gets or sets the description.
///
/// The description.
string Description { get; set; }
///
/// Gets the type of symbol definition
///
SymbolDefinitionType Type { get; }
///
/// Purges the schema and version attributes when serializing back to XML
///
void RemoveSchemaAttributes();
}
///
/// Represents a simple symbol definition
///
public interface ISimpleSymbolDefinition : ISymbolDefinitionBase
{
///
/// Gets the graphics.
///
/// The graphics.
IEnumerable Graphics { get; }
///
/// Adds the graphics.
///
/// The graphics.
void AddGraphics(IGraphicBase graphics);
///
/// Removes the graphics.
///
/// The graphics.
void RemoveGraphics(IGraphicBase graphics);
///
/// Gets or sets the resize box.
///
/// The resize box.
IResizeBox ResizeBox { get; set; }
///
/// Gets or sets the point usage.
///
/// The point usage.
IPointUsage PointUsage { get; set; }
///
/// Gets or sets the line usage.
///
/// The line usage.
ILineUsage LineUsage { get; set; }
///
/// Gets or sets the area usage.
///
/// The area usage.
IAreaUsage AreaUsage { get; set; }
///
/// Gets the parameter definition.
///
/// The parameter definition.
IParameterDefinition ParameterDefinition { get; }
///
/// Creates an image reference
///
///
///
///
IImageReference CreateImageReference(string resourceId, string dataName);
///
/// Creates an inline image
///
///
///
IInlineImage CreateInlineImage(byte[] content);
///
/// Creates a point usage context
///
///
IPointUsage CreatePointUsage();
///
/// Creates a line usage context
///
///
ILineUsage CreateLineUsage();
///
/// Creates an area usage context
///
///
IAreaUsage CreateAreaUsage();
///
/// Creates a resize box
///
///
IResizeBox CreateResizeBox();
///
/// Creates the frame.
///
///
ITextFrame CreateFrame();
///
/// Creates the text graphics.
///
///
ITextGraphic CreateTextGraphics();
///
/// Creates the path graphics.
///
///
IPathGraphic CreatePathGraphics();
///
/// Creates the image graphics.
///
///
IImageGraphic CreateImageGraphics();
///
/// Creates the parameter.
///
///
IParameter CreateParameter();
///
/// Removes all graphic elements
///
void ClearGraphics();
}
///
/// Represents a compound symbol definition
///
public interface ICompoundSymbolDefinition : ISymbolDefinitionBase
{
///
/// Gets the simple symbols.
///
/// The simple symbols.
IEnumerable SimpleSymbol { get; }
///
/// Adds the simple symbol.
///
/// The sym.
void AddSimpleSymbol(ISimpleSymbolReferenceBase sym);
///
/// Removes the simple symbol.
///
/// The sym.
void RemoveSimpleSymbol(ISimpleSymbolReferenceBase sym);
///
/// Creates an inline symbol definition reference
///
///
///
ISimpleSymbolReferenceBase CreateSimpleSymbol(ISimpleSymbolDefinition sym);
///
/// Creates a resource id based symbol reference
///
/// The resource id.
///
ISimpleSymbolReferenceBase CreateSymbolReference(string resourceId);
///
/// Purges root element attributes from all inline Simple Symbol Definitions. This should be called
/// before serialization
///
void PurgeSimpleSymbolAttributes();
}
///
/// A collection of graphic elements
///
public interface IGraphics
{
///
/// Gets the elements.
///
/// The elements.
IEnumerable Elements { get; }
///
/// Adds the graphic element.
///
/// The graphics.
void AddGraphicElement(IGraphicBase graphics);
///
/// Removes the graphic element.
///
/// The graphics.
void RemoveGraphicElement(IGraphicBase graphics);
}
///
/// Defines a resize box used with SimpleSymbolDefinitions
///
public interface IResizeBox
{
///
/// Gets or sets initial width of the resize box, in mm. This must be greater than or equal to zero
///
string SizeX { get; set; }
///
/// Gets or sets initial height of the resize box, in mm. This must be greater than or equal to zero
///
string SizeY { get; set; }
///
/// Gets or sets initial x-coordinate of the resize box center, in mm
///
string PositionX { get; set; }
///
/// Gets or sets initial y-coordinate of the resize box center, in mm
///
string PositionY { get; set; }
///
/// Gets or sets how the resize box grows in size. This must evaluate to one of: GrowInX, GrowInY, GrowInXY, or GrowInXYMaintainAspect (default).
///
string GrowControl { get; set; }
}
///
/// Base usage interface
///
public interface IUsageBase
{
///
/// Specifies how the symbol angle is defined. This must evaluate to one of: FromAngle (default) or FromGeometry
///
string AngleControl { get; set; }
///
/// Specifies the symbol angle, in degrees. Only applies if AngleControl evaluates to FromAngle. Defaults to 0
///
string Angle { get; set; }
}
///
/// Specifies how a symbol is used in the context of point features
///
public interface IPointUsage : IUsageBase
{
///
/// Specifies the horizontal offset to apply to the symbol origin, in mm. This offset is applied before the symbol is scaled and rotated. Defaults to 0
///
string OriginOffsetX { get; set; }
///
/// Specifies the vertical offset to apply to the symbol origin, in mm. This offset is applied before the symbol is scaled and rotated. Defaults to 0
///
string OriginOffsetY { get; set; }
}
///
/// Represents line usage
///
public interface ILineUsage : IUsageBase
{
///
/// Gets or sets the units control.
///
/// The units control.
string UnitsControl { get; set; }
///
/// Gets or sets the vertex control.
///
/// The vertex control.
string VertexControl { get; set; }
///
/// Gets or sets the start offset.
///
/// The start offset.
string StartOffset { get; set; }
///
/// Gets or sets the end offset.
///
/// The end offset.
string EndOffset { get; set; }
///
/// Gets or sets the repeat value
///
/// The repeat value.
string Repeat { get; set; }
///
/// Gets or sets the vertex angle limit.
///
/// The vertex angle limit.
string VertexAngleLimit { get; set; }
///
/// Gets or sets the vertex join.
///
/// The vertex join.
string VertexJoin { get; set; }
///
/// Gets or sets the vertex miter limit.
///
/// The vertex miter limit.
string VertexMiterLimit { get; set; }
///
/// Gets or sets the default path.
///
/// The default path.
IPathGraphic DefaultPath { get; set; }
}
///
/// Defines area usage
///
public interface IAreaUsage : IUsageBase
{
///
/// Gets or sets the origin control.
///
/// The origin control.
string OriginControl { get; set; }
///
/// Gets or sets the clipping control.
///
/// The clipping control.
string ClippingControl { get; set; }
///
/// Gets or sets the X origin.
///
/// The X origin.
string OriginX { get; set; }
///
/// Gets or sets the Y origin.
///
/// The Y origin.
string OriginY { get; set; }
///
/// Gets or sets the X repeat value.
///
/// The X repeat value.
string RepeatX { get; set; }
///
/// Gets or sets the Y repeat value
///
/// The Y repeat value.
string RepeatY { get; set; }
///
/// Gets or sets the width of the buffer.
///
/// The width of the buffer.
string BufferWidth { get; set; }
}
///
/// Enumerates the allowed DataType values
///
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
[System.SerializableAttribute()]
public enum DataType
{
///
String,
///
Boolean,
///
Integer,
///
Real,
///
Color,
}
///
/// Defines a parameter
///
public interface IParameter : IExpressionPropertySource
{
///
/// Gets or sets the identifier.
///
/// The identifier.
string Identifier { get; set; }
///
/// Gets or sets the default value.
///
/// The default value.
string DefaultValue { get; set; }
///
/// Gets or sets the display name.
///
/// The display name.
string DisplayName { get; set; }
///
/// Gets or sets the description.
///
///
/// The description.
///
string Description { get; set; }
///
/// Gets or sets the type of the data.
///
/// The type of the data.
string DataType { get; set; }
}
///
/// A parameter definition
///
public interface IParameterDefinition
{
///
/// Gets the parameters.
///
/// The parameters.
IEnumerable Parameter { get; }
///
/// Adds the parameter.
///
/// The param.
void AddParameter(IParameter param);
///
/// Removes the parameter.
///
/// The param.
void RemoveParameter(IParameter param);
}
///
/// Represents a simple symbol reference
///
public interface ISimpleSymbolReferenceBase
{
///
/// Gets the type.
///
/// The type.
SimpleSymbolReferenceType Type { get; }
///
/// Gets or sets the rendering pass.
///
/// The rendering pass.
string RenderingPass { get; set; }
}
///
/// Represents a simple symbol reference by resource id
///
public interface ISimpleSymbolLibraryReference : ISimpleSymbolReferenceBase, IResourceIdReference
{
}
///
/// Represents a simple symbol reference by inline definition
///
public interface ISimpleSymbolInlineReference : ISimpleSymbolReferenceBase
{
///
/// Gets or sets the simple symbol definition.
///
/// The simple symbol definition.
ISimpleSymbolDefinition SimpleSymbolDefinition { get; set; }
}
///
/// The type of simple symbol reference
///
public enum SimpleSymbolReferenceType
{
///
/// External resource id reference
///
Library,
///
/// Inlined definition
///
Inline,
///
/// Undefined
///
Undefined
}
///
/// Defines the valid types of graphic elements
///
public enum GraphicElementType
{
///
/// Text
///
Text,
///
/// Images
///
Image,
///
/// A linear path containing one or more segments
///
Path
}
///
/// Represents the base interface of all graphics
///
public interface IGraphicBase
{
///
/// Gets or sets the resize control.
///
/// The resize control.
string ResizeControl { get; set; }
///
/// Gets the type of graphic element
///
GraphicElementType Type { get; }
}
///
/// A path
///
public interface IPathGraphic : IGraphicBase
{
///
/// Gets or sets the geometry.
///
/// The geometry.
string Geometry { get; set; }
///
/// Gets or sets the color of the fill.
///
/// The color of the fill.
string FillColor { get; set; }
///
/// Gets or sets the color of the line.
///
/// The color of the line.
string LineColor { get; set; }
///
/// Gets or sets the line weight.
///
/// The line weight.
string LineWeight { get; set; }
///
/// Gets or sets the line weight scalable.
///
/// The line weight scalable.
string LineWeightScalable { get; set; }
///
/// Gets or sets the line cap.
///
/// The line cap.
string LineCap { get; set; }
///
/// Gets or sets the line join.
///
/// The line join.
string LineJoin { get; set; }
///
/// Gets or sets the line miter limit.
///
/// The line miter limit.
string LineMiterLimit { get; set; }
}
///
/// An image reference
///
public interface IImageReference : IImageBase
{
///
/// Gets or sets the resource id.
///
/// The resource id.
string ResourceId { get; set; }
///
/// Gets or sets the name of the library item.
///
/// The name of the library item.
string LibraryItemName { get; set; }
}
///
/// The type of image
///
public enum ImageType
{
///
/// A reference to an image
///
Reference,
///
/// Inline content
///
Inline
}
///
/// Defines an image graphic
///
public interface IImageGraphic : IGraphicBase
{
///
/// Gets or sets the image content
///
///
/// If the object being returned is an inline image, the object is a fresh instance whose
/// byte array refers to the same instance. That is to say:
///
/// IInlineImage img1 = (IInlineImage)imageGraphic.Item;
/// IInlineImage img2 = (IInlineImage)imageGraphic.Item;
///
/// Object.ReferenceEquals(img1, img2); //false
/// Object.ReferenceEquals(img1.Content, img2.Content); //true
///
///
IImageBase Item { get; set; }
///
/// Gets or sets the size X.
///
/// The size X.
string SizeX { get; set; }
///
/// Gets or sets the size Y.
///
/// The size Y.
string SizeY { get; set; }
///
/// Gets or sets the size scalable.
///
/// The size scalable.
string SizeScalable { get; set; }
///
/// Gets or sets the angle.
///
/// The angle.
string Angle { get; set; }
///
/// Gets or sets the position X.
///
/// The position X.
string PositionX { get; set; }
///
/// Gets or sets the position Y.
///
/// The position Y.
string PositionY { get; set; }
}
///
/// An image graphic
///
public interface IImageBase
{
///
/// Gets the type.
///
/// The type.
ImageType Type { get; }
}
///
/// Represents an inline image
///
public interface IInlineImage : IImageBase
{
///
/// Gets or sets the content.
///
/// The content.
byte[] Content { get; set; }
}
///
/// Represents an image refrence
///
public interface IImageReferenceImage : IImageBase
{
///
/// Gets or sets the reference.
///
/// The reference.
IImageReference Reference { get; set; }
}
///
/// A text frame
///
public interface ITextFrame
{
///
/// Gets or sets the color of the line.
///
/// The color of the line.
string LineColor { get; set; }
///
/// Gets or sets the color of the fill.
///
/// The color of the fill.
string FillColor { get; set; }
///
/// Gets or sets the offset X.
///
/// The offset X.
double? OffsetX { get; set; }
///
/// Gets or sets the offset Y.
///
/// The offset Y.
double? OffsetY { get; set; }
}
///
/// Text graphics
///
public interface ITextGraphic : IGraphicBase
{
///
/// Gets or sets the content.
///
/// The content.
string Content { get; set; }
///
/// Gets or sets the name of the font.
///
/// The name of the font.
string FontName { get; set; }
///
/// Gets or sets the bold.
///
/// The bold.
string Bold { get; set; }
///
/// Gets or sets the italic.
///
/// The italic.
string Italic { get; set; }
///
/// Gets or sets the underlined.
///
/// The underlined.
string Underlined { get; set; }
///
/// Gets or sets the height.
///
/// The height.
string Height { get; set; }
///
/// Gets or sets the height scalable.
///
/// The height scalable.
string HeightScalable { get; set; }
///
/// Gets or sets the angle.
///
/// The angle.
string Angle { get; set; }
///
/// Gets or sets the position X.
///
/// The position X.
string PositionX { get; set; }
///
/// Gets or sets the position Y.
///
/// The position Y.
string PositionY { get; set; }
///
/// Gets or sets the horizontal alignment.
///
/// The horizontal alignment.
string HorizontalAlignment { get; set; }
///
/// Gets or sets the vertical alignment.
///
/// The vertical alignment.
string VerticalAlignment { get; set; }
///
/// Gets or sets the justification.
///
/// The justification.
string Justification { get; set; }
///
/// Gets or sets the line spacing.
///
/// The line spacing.
string LineSpacing { get; set; }
///
/// Gets or sets the color of the text.
///
/// The color of the text.
string TextColor { get; set; }
///
/// Gets or sets the color of the ghost.
///
/// The color of the ghost.
string GhostColor { get; set; }
///
/// Gets or sets the frame.
///
/// The frame.
ITextFrame Frame { get; set; }
}
///
/// The possible values for grow control
///
public enum GrowControl
{
///
///
///
GrowInX,
///
///
///
GrowInY,
///
///
///
GrowInXY,
///
///
///
GrowInXYMaintainAspect,
}
///
/// The types of angle control
///
public enum AngleControl
{
///
///
///
FromAngle,
///
///
///
FromGeometry,
}
///
/// The types of units control
///
public enum UnitsControl
{
///
///
///
Absolute,
///
///
///
Parametric,
}
///
/// The types of vertex control
///
public enum VertexControl
{
///
///
///
OverlapNone,
///
///
///
OverlapDirect,
///
/// Introduced with Symbol Definition 1.1.0 schema
///
OverlapNoWrap,
///
///
///
OverlapWrap,
}
///
/// The types of vertex join
///
public enum VertexJoin
{
///
///
///
None,
///
///
///
Bevel,
///
///
///
Round,
///
///
///
Miter,
}
///
/// The types of origin control
///
public enum OriginControl
{
///
///
///
Global,
///
///
///
Local,
///
///
///
Centroid,
}
///
/// The types of clipping control
///
public enum ClippingControl
{
///
///
///
Clip,
///
///
///
Inside,
///
///
///
Overlap
}
///
/// The types of resize control
///
public enum ResizeControl
{
///
///
///
ResizeNone,
///
///
///
AddToResizeBox,
///
///
///
AdjustToResizeBox,
}
///
/// The types of line cap
///
public enum LineCap
{
///
///
///
None,
///
///
///
Round,
///
///
///
Triangle,
///
///
///
Square,
}
///
/// The types of line join
///
public enum LineJoin
{
///
///
///
None,
///
///
///
Bevel,
///
///
///
Round,
///
///
///
Miter,
}
///
/// The types of horizontal alignment
///
public enum HorizontalAlignment
{
///
///
///
Left,
///
///
///
Center,
///
///
///
Right,
}
///
/// The types of vertical alignment
///
public enum VerticalAlignment
{
///
///
///
Bottom,
///
///
///
Baseline,
///
///
///
Halfline,
///
///
///
Capline,
///
///
///
Top,
}
///
/// The types of justification
///
public enum Justification
{
///
///
///
Left,
///
///
///
Center,
///
///
///
Right,
///
///
///
Justified,
///
///
///
FromAlignment,
}
#endregion
#region Symbol Definition 1.1.0 interfaces
///
/// An extension of the text element to support rich text. Introduced with the Symbol Definition 1.1.0 schema
///
public interface ITextGraphic2 : ITextGraphic
{
///
/// Gets or sets the type of rich text markup used to render the contents
///
string Markup { get; set; }
///
/// Gets or sets the text style attribute to create a line that runs on top of the text
///
string Overlined { get; set; }
///
/// Gets or sets the skew of shear angle to be applied to the text
///
string ObliqueAngle { get; set; }
///
/// Gets or sets the width scale applied to inter character spacing independent of the font character spacing
///
string TrackSpacing { get; set; }
}
///
/// Enumerates the allowed DataType values. Introduced with Symbol Definition 1.1.0 schema
///
[System.SerializableAttribute()]
public enum DataType2
{
///
String,
///
Boolean,
///
Integer,
///
Real,
///
Color,
///
Angle,
///
FillColor,
///
LineColor,
///
LineWeight,
///
Content,
///
Markup,
///
FontName,
///
Bold,
///
Italic,
///
Underlined,
///
Overlined,
///
ObliqueAngle,
///
TrackSpacing,
///
FontHeight,
///
HorizontalAlignment,
///
VerticalAlignment,
///
Justification,
///
LineSpacing,
///
TextColor,
///
GhostColor,
///
FrameLineColor,
///
FrameFillColor,
///
StartOffset,
///
EndOffset,
///
RepeatX,
///
RepeatY,
}
#endregion
#region Symbol Definition 2.4.0 interfaces
///
/// Path with support for scaling. Only applicable for Symbol Definition schema
/// 2.4.0 and higher
///
public interface IPathGraphic2 : IPathGraphic
{
///
/// >The amount to scale the path geometry in the horizontal direction. This is only applied to the Geometry element. Defaults to 1 if not specified.
///
string ScaleX { get; set; }
///
/// The amount to scale the path geometry in the vertical direction. This is only applied to the Geometry element. Defaults to 1 if not specified
///
string ScaleY { get; set; }
}
#endregion
}