📄 ezthematics.pas
字号:
unit EzThematics;
{$I EZ_FLAG.PAS}
interface
Uses
Windows, SysUtils, Classes, Messages, Graphics, Controls, StdCtrls, ExtCtrls,
EzBaseGis, ezbase, ezlib, grids, EzMiscelEntities ;
type
{-------------------------------------------------------------------------------}
{ Define TEzThematicBuilder }
{-------------------------------------------------------------------------------}
TEzThematicBuilder = Class;
// TEzThematicItem class
TEzThematicItem = Class( TCollectionItem )
Private
FExpression: String;
FLegend: String;
FFrequency: Integer;
FPenStyle: TEzPenTool;
FBrushStyle: TEzBrushTool;
FSymbolStyle: TEzSymbolTool;
FFontStyle: TEzFontTool;
procedure SetBrushstyle(Value:TEzBrushtool);
procedure SetPenstyle(Value:TEzPentool);
procedure SetSymbolStyle(Value:TEzSymboltool);
procedure SetFontStyle(Value:TEzFonttool);
Protected
Function GetDisplayName: String; Override;
Public
Constructor Create( Collection: TCollection ); Override;
destructor Destroy; Override;
Procedure Assign( Source: TPersistent ); Override;
Published
Property Legend: String Read FLegend Write FLegend;
Property Expression: String Read FExpression Write FExpression;
Property PenStyle: TEzPenTool read FPenStyle write SetPenStyle;
Property BrushStyle: TEzBrushTool read FBrushStyle write SetBrushStyle;
Property SymbolStyle: TEzSymbolTool read FSymbolStyle write SetSymbolStyle;
Property FontStyle: TEzFontTool read FFontStyle Write SetFontStyle;
Property Frequency: Integer read FFrequency write FFrequency;
End;
TEzThematicRanges = Class( TOwnedCollection )
Private
FThematicBuilder: TEzThematicBuilder;
Function GetItem( Index: Integer ): TEzThematicItem;
Procedure SetItem( Index: Integer; Value: TEzThematicItem );
Public
Constructor Create( AOwner: TPersistent );
Destructor destroy; Override;
Function Add: TEzThematicItem;
function Up( Index: Integer ): Boolean;
function Down( Index: Integer ): Boolean;
{$IFDEF DELPHI4}
Procedure Delete(Index: Integer );
{$ENDIF}
Property Items[Index: Integer]: TEzThematicItem Read GetItem Write SetItem; Default;
End;
TEzThematicBuilder = Class( TComponent )
Private
FLayerName: string;
FThematicRanges: TEzThematicRanges;
FTitle: String;
FShowThematic: Boolean;
//FSaveBeforePaintEntity: TEzBeforePaintEntityEvent;
FExprList: TList;
FPenStyle: TEzPenTool;
FBrushStyle: TEzBrushTool;
FSymbolStyle: TEzSymbolTool;
FFontStyle: TEzFontTool;
FApplyPen: Boolean;
FApplyBrush: Boolean;
FApplySymbol: Boolean;
FApplyFont: Boolean;
FApplyColor: Boolean;
FThematicOpened: Boolean;
//FIsBeforePaintEntity: Boolean;
Procedure SetThematicRanges( Value: TEzThematicRanges );
procedure BeforePaintEntity( Sender: TObject; Layer: TEzBaseLayer;
Recno: Integer; Entity: TEzEntity; Grapher: TEzGrapher; Canvas: TCanvas;
Const Clip: TEzRect; DrawMode: TEzDrawMode;
Var CanShow: Boolean; Var EntList: TEzEntityList; Var AutoFree: Boolean );
Function StartThematic( Layer: TEzBaseLayer ): Boolean;
Function CalcThematicInfo( Layer: TEzBaseLayer; Recno: Integer ): Boolean;
Procedure EndThematic;
function GetAbout: TEzAbout;
procedure SetAbout(const Value: TEzAbout);
Public
Constructor Create( AOwner: TComponent ); Override;
Destructor Destroy; Override;
procedure Assign( Source: TPersistent ); Override;
procedure SaveToStream(Stream: TStream);
procedure LoadFromStream(Stream: TStream);
procedure LoadFromFile( const FileName: string );
procedure SaveToFile( const FileName: string );
procedure Prepare(Layer: TEzBaseLayer );
procedure UnPrepare( Layer: TEzBaseLayer );
Procedure CreateAutomaticThematicRange( Gis: TEzBaseGis;
NumRanges: Integer; const ThematicLayer, FieldName: String;
BrushStartColor, BrushStopColor: TColor;
BrushPattern: Integer; LineStartColor, LineStopColor: TColor;
LineStyle: Integer; AutoLineWidth, CalcbyRange, IgnoreZero, ManualRange: boolean;
ManualRangevalue: Double; DecimalPos: Integer );
Procedure CreateAutomaticThematicRangeStrField( Gis: TEzBaseGis;
const ThematicLayer, FieldName: String;
BrushStartColor, BrushStopColor: TColor; BrushPattern: Integer;
LineStartColor, LineStopColor: TColor; LineStyle: Integer; AutoLineWidth: Boolean );
Procedure Recalculate( Gis: TEzBaseGis );
Property About: TEzAbout read GetAbout write SetAbout;
Published
Property LayerName: string read FLayerName write FLayerName;
Property ThematicRanges: TEzThematicRanges Read FThematicRanges Write SetThematicRanges;
Property Title: String Read FTitle Write FTitle;
Property ShowThematic: Boolean read FShowThematic write FShowThematic default True;
Property ApplyPen: Boolean read FApplyPen write FApplyPen default true;
Property ApplyBrush: Boolean read FApplyBrush write FApplyBrush default true;
Property ApplyColor: Boolean read FApplyColor write FApplyColor default true;
Property ApplySymbol: Boolean read FApplySymbol write FApplySymbol default true;
Property ApplyFont: Boolean read FApplyFont write FApplyFont default true;
End;
{ TEzLegend component }
TEzLegendItem = Class( TCollectionItem )
Private
FLegend: String;
FSubLegend: string;
FFrequency: Integer;
FPenStyle: TEzPenTool;
FBrushStyle: TEzBrushTool;
FSymbolStyle: TEzSymbolTool;
FFontStyle: TEzFonttool;
FColor: TColor;
FImageIndex: Integer;
procedure SetBrushstyle(Value:TEzBrushtool);
procedure SetPenstyle(Value:TEzPentool);
procedure SetSymbolStyle(Value:TEzSymboltool);
procedure SetColor(const Value: TColor);
Procedure InvalidateLegend;
procedure SetImageIndex(const Value: Integer);
procedure SetFontStyle(const Value: TEzFonttool);
Protected
Function GetDisplayName: String; Override;
Public
Constructor Create( Collection: TCollection ); Override;
destructor Destroy; Override;
Procedure Assign( Source: TPersistent ); Override;
Published
Property Legend: String Read FLegend Write FLegend;
Property SubLegend: String Read FSubLegend Write FSubLegend;
Property Frequency: Integer read FFrequency write FFrequency;
Property PenStyle: TEzPenTool read FPenStyle write SetPenStyle;
Property BrushStyle: TEzBrushTool read FBrushStyle write SetBrushStyle;
Property SymbolStyle: TEzSymbolTool read FSymbolStyle write SetSymbolStyle;
Property FontStyle: TEzFonttool read FFontStyle write SetFontStyle;
Property Color: TColor read FColor write SetColor;
Property ImageIndex: Integer read FImageIndex write SetImageIndex;
End;
TEzLegendRanges = Class( TOwnedCollection )
Private
Function GetItem( Index: Integer ): TEzLegendItem;
Procedure SetItem( Index: Integer; Value: TEzLegendItem );
Public
Constructor Create( AOwner: TPersistent );
Function Add: TEzLegendItem;
function Up( Index: Integer ): Boolean;
function Down( Index: Integer ): Boolean;
function Owner: TPersistent;
Property Items[Index: Integer]: TEzLegendItem Read GetItem Write SetItem; Default;
End;
TEzLegend = class(TCustomGrid)
Private
FLegendStyle: TEzColumnType;
FLegendRanges: TEzLegendRanges;
FShowTitle: Boolean;
FTitle0: string;
FTitle1: string;
FTitle2: string;
FImageList: TImageList;
FStretch: Boolean;
FPenTool: TEzPenTool;
FBrushTool: TEzBrushTool;
FBorderWidth: Integer;
FLoweredColor: TColor;
FTransparent: Boolean;
FInColChange: Boolean;
FTitleFont: TFont;
FTitleColor: TColor;
FTitleTransparent: Boolean;
FTitleAlignment: TAlignment;
procedure SetLegendStyle(const Value: TEzColumnType);
procedure SetLegendRanges(const Value: TEzLegendRanges);
procedure SetShowTitle(const Value: Boolean);
procedure SetTitle0(const Value: string);
procedure SetTitle1(const Value: string);
procedure SetTitle2(const Value: string);
procedure SetImageList(const Value: TImageList);
procedure InitializeRows;
procedure SetStretch(const Value: Boolean);
procedure SetBrushTool(const Value: TEzBrushTool);
procedure SetPenTool(const Value: TEzPenTool);
procedure SetTitleFont(const Value: TFont);
Protected
procedure DrawCell(ACol, ARow: Longint; ARect: TRect;
AState: TGridDrawState); override;
Procedure Notification( AComponent: TComponent; Operation: TOperation ); Override;
procedure ColWidthsChanged; override;
Public
constructor Create(AOwner: TComponent); Override;
destructor Destroy; override;
Procedure PopulateFrom( Source: TEzThematicBuilder );
procedure AdjustColWidths;
{ inherited properties }
property ColWidths;
property Row;
property RowCount;
property Col;
property ColCount;
property RowHeights;
Published
Property PenTool: TEzPenTool read FPenTool write SetPenTool;
Property BrushTool: TEzBrushTool read FBrushTool write SetBrushTool;
Property BorderWidth: Integer read FBorderWidth write FBorderWidth;
Property LoweredColor: TColor read FLoweredColor write FLoweredColor;
Property TitleFont: TFont read FTitleFont write SetTitleFont;
Property TitleColor: TColor read FTitleColor write FTitleColor;
Property TitleTransparent: Boolean read FTitleTransparent write FTitleTransparent;
Property TitleAlignment: TAlignment read FTitleAlignment write FTitleAlignment;
Property Transparent: Boolean read FTransparent write FTransparent;
Property LegendStyle: TEzColumnType read FLegendStyle write SetLegendStyle;
Property LegendRanges: TEzLegendRanges Read FLegendRanges Write SetLegendRanges;
Property ShowTitle: Boolean read FShowTitle write SetShowTitle;
Property Title0: string read FTitle0 write SetTitle0;
Property Title1: string read FTitle1 write SetTitle1;
Property Title2: string read FTitle2 write SetTitle2;
Property ImageList: TImageList read FImageList write SetImageList;
Property Stretch: Boolean read FStretch write SetStretch;
{ inherited properties and events }
property Options;
property Align;
property Anchors;
property BiDiMode;
property BorderStyle;
property Color;
property Constraints;
property Ctl3D;
property DefaultColWidth;
property DefaultRowHeight;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property FixedColor;
property Font;
property GridLineWidth;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ScrollBars;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property VisibleColCount;
property VisibleRowCount;
property OnClick;
{$IFDEF LEVEL5}
property OnContextPopup;
{$ENDIF}
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnStartDock;
property OnStartDrag;
End;
implementation
uses
Forms, EzMiscelCtrls, ezgraphics, ezlinedraw, ezsystem, ezbaseexpr, ezconsts,
ezentities, EzExpressions;
{-------------------------------------------------------------------------------}
{ Implements TEzThematicItem }
{-------------------------------------------------------------------------------}
Constructor TEzThematicItem.Create( Collection: TCollection );
Begin
Inherited Create( Collection );
FPenStyle:= TEzPentool.Create;
FPenStyle.Style:= 1;
FBrushStyle:= TEzBrushtool.Create;
FBrushStyle.Pattern:= 1;
FFontStyle:= TEzFonttool.Create;
FSymbolStyle:= TEzSymboltool.Create;
End;
destructor TEzThematicItem.Destroy;
begin
FPenStyle.free;
FBrushStyle.Free;
FFontStyle.Free;
FSymbolStyle.Free;
inherited Destroy;
end;
Procedure TEzThematicItem.Assign( Source: TPersistent );
Begin
If Source Is TEzThematicItem Then
Begin
FExpression := TEzThematicItem( Source ).Expression;
FLegend := TEzThematicItem( Source ).Legend;
FFrequency:= TEzThematicItem( Source ).FFrequency;
FPenStyle.Assign( TEzThematicItem( Source ).PenStyle );
FBrushStyle.Assign( TEzThematicItem( Source ).BrushStyle );
FFontStyle.Assign( TEzThematicItem( Source ).FontStyle );
FSymbolStyle.Assign( TEzThematicItem( Source ).SymbolStyle );
End
Else
Inherited Assign( Source );
End;
Function TEzThematicItem.GetDisplayName: String;
Begin
If FLegend = '' Then
Result := Inherited GetDisplayName
else
result := FLegend;
End;
procedure TEzThematicItem.SetBrushstyle(Value:TEzBrushtool);
begin
FBrushstyle.Assign(Value);
end;
procedure TEzThematicItem.SetPenstyle(Value:TEzPentool);
begin
FPenstyle.Assign(Value);
end;
procedure TEzThematicItem.SetSymbolStyle(Value:TEzSymboltool);
begin
FSymbolstyle.Assign(Value);
end;
procedure TEzThematicItem.SetFontStyle(Value:TEzFonttool);
begin
FFontStyle.Assign(Value);
end;
{-------------------------------------------------------------------------------}
{ Implements TEzThematicRanges }
{-------------------------------------------------------------------------------}
Constructor TEzThematicRanges.Create( AOwner: TPersistent );
Begin
Inherited Create( AOwner, TEzThematicItem );
FThematicBuilder := AOwner As TEzThematicBuilder;
End;
Destructor TEzThematicRanges.destroy;
Begin
FThematicBuilder := Nil;
Inherited Destroy;
End;
Function TEzThematicRanges.GetItem( Index: Integer ): TEzThematicItem;
Begin
Result := TEzThematicItem( Inherited GetItem( Index ) );
End;
Procedure TEzThematicRanges.SetItem( Index: Integer; Value: TEzThematicItem );
Begin
Inherited SetItem( Index, Value );
End;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -