双轨制二叉树节点对象

来源:互联网 发布:淘宝直播不能开通 编辑:程序博客网 时间:2024/05/20 18:16
// 双轨制二叉树节点对象unit unitOBJPosNodeClass;interfaceuses  Windows, Graphics, ExtCtrls, SysUtils;type  TPosNode = class (TObject)  private    FPosition: TPoint;             //位置    FLayer: Integer;               //层号,本节点所在的层,设计用于绘图    FBH: String;                   //会员编号    FXM: String;                   //姓名    FZW: String;                   //职务    FHYJB: String;                 //会员级别    FJHRQ: TDateTime;              //激活日期    FColor : TColor;               //会员颜色    FInTopArea: String;            //相对于顶点,本节点所在的区,设计用于绘图    FAPoint: Integer;              //A区点    FBPoint: Integer;              //B区点    FATotal: Integer;              //A总    FBTotal: Integer;              //B总    FARemainder: Integer;          //A余    FBRemainder: Integer;          //B余    FYHYJB: String;                //会员原级别    FSJSM: String;                 //会员升级说明    FSJRQ: TDateTime;              //升级日期    FYColor : TColor;    FTopArea: String;              //原会员颜色    FHeight: Integer;              //节点图高度    FWidth: Integer;               //节点图宽度    procedure SetFLayer(Value: Integer);    procedure SetFPosition(Value: TPoint);    procedure SetFBH(Value: String);    procedure SetFXM(Value: String);    procedure SetFZW(Value: String);    procedure SetFHYJB(Value: String);    procedure SetFJHRQ(Value: TDateTime);    procedure SetFInTopArea(Value: String);    procedure SetFAPoint(Value: Integer);    procedure SetFBPoint(Value: Integer);    procedure SetFATotal(Value: Integer);    procedure SetFBTotal(Value: Integer);    procedure SetFARemainder(Value: Integer);    procedure SetFBRemainder(Value: Integer);    procedure SetFYHYJB(Value: String);    procedure SetFSJSM(Value: String);    procedure SetFSJRQ(Value: TDateTime);  public    Name: string;    Father: TObject;    constructor create; overload;    function DrawSelf(img: TImage):Boolean;    function DrawLinkLine(img: TImage):Boolean;    property Layer: Integer read FLayer write SetFLayer default 0;    property Position: TPoint read FPosition write SetFPosition;    property BH: String read FBH write SetFBH;    property XM: String read FXM write SetFXM;    property ZW: String read FZW write SetFZW;    property HYJB: String read FHYJB write SetFHYJB;    property JHRQ: TDateTime read FJHRQ write SetFJHRQ;    property InTopArea: String read FTopArea write SetFInTopArea;    property APoint: Integer read FAPoint write SetFAPoint default 0;    property BPoint: Integer read FBPoint write SetFBPoint default 0;    property ATotal: Integer read FATotal write SetFATotal default 0;    property BTotal: Integer read FBTotal write SetFBTotal default 0;    property ARemainder: Integer read FARemainder write SetFARemainder default 0;    property BRemainder: Integer read FBRemainder write SetFBRemainder default 0;    property YHYJB: String read FYHYJB write SetFYHYJB;    property SJSM: String read FSJSM write SetFSJSM;    property SJRQ: TDateTime read FSJRQ write SetFSJRQ;    property Width: Integer read FWidth;    property Height: Integer read FHeight;  end;const  clMColor = TColor($00ECFFFF);    //主色  clAColor = TColor($0071C8F2);    //钻卡颜色  clBColor = TColor($009E77FB);    //金卡颜色  clCColor = TColor($00FFC6C6);    //银卡颜色  wgHeight = 16;                   //网格高度  wgWidth  = 36;                   //网格宽度implementation{********************************** TPosNode **********************************}constructor TPosNode.create;begin  DateSeparator := '-';  ShortDateFormat := 'yyyy-MM-dd';  LongDateFormat := 'yyyy-MM-dd hh:mm:ss';  Name:='PosNode1';  FHeight := 112;  FWidth  := 108;  FBH := 'CN88888888';  FXM := '总公司';  FZW := '';  FHYJB := '';  FSJSM := '';  FJHRQ := DATE();  FColor := clAColor;  FYHYJB := '';  FYColor := clCColor;  FSJRQ := strtodate('2016-05-16');end;function TPosNode.DrawSelf(img: TImage): Boolean;var  c:TCanvas;  p1,p2:TPoint;  uHeight,uWidth,uI,uX,uY: integer;  uStr:String;  dtf:TFormatSettings;begin//  c := TCanvas.Create;//  c.Handle := GetDC(pnl.Handle);  dtf.ShortDateFormat :='yyyy-MM-dd';  c := img.Canvas;  c.FillRect(c.ClipRect);  c.Font.Name :='宋体';  c.Font.Size :=9;  uHeight:=c.TextHeight('W');  //第1,2行  p1.X := FPosition.X + 0;  p1.Y := FPosition.Y + 0;  p2.X := FPosition.X + 3*wgWidth;  p2.Y := FPosition.Y + 2*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := FColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  //输出FBH  uWidth := c.TextWidth(FBH);  uX := FPosition.X + round((3*wgWidth-uWidth)/2);  uY := FPosition.Y + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,FBH);  //输出FZW+' '+FXM  uWidth:=c.TextWidth(FZW+' '+FXM);  uX := FPosition.X + round((3*wgWidth-uWidth)/2);  uY := FPosition.Y + 1*wgHeight + 2;  c.Brush.Style :=bsClear;     //文本不带背景输出  c.Font.Color :=clBlack;  c.TextOut(uX,uY,FZW+' '+FXM);  //第3行  p1.X := FPosition.X + 0;  p1.Y := FPosition.Y + 2*wgHeight;  p2.X := FPosition.X + 3*wgWidth;  p2.Y := FPosition.Y + 3*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  //输出FHYJB  uWidth:=c.TextWidth(FHYJB+FSJSM);  uX := FPosition.X + round((3*wgWidth-uWidth)/2);  uY := FPosition.Y + 2*wgHeight + 2;  c.Brush.Style :=bsClear;     //文本不带背景输出  c.Font.Color :=clBlack;  c.TextOut(uX,uY,FHYJB+FSJSM);  //左边三行  p1.X := FPosition.X + 0;  p1.Y := FPosition.Y + 3*wgHeight;  p2.X := FPosition.X + 1*wgWidth;  p2.Y := FPosition.Y + 4*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  p1.X := FPosition.X + 0;  p1.Y := FPosition.Y + 4*wgHeight;  p2.X := FPosition.X + 1*wgWidth;  p2.Y := FPosition.Y + 5*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  p1.X := FPosition.X + 0;  p1.Y := FPosition.Y + 5*wgHeight;  p2.X := FPosition.X + 1*wgWidth;  p2.Y := FPosition.Y + 6*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  //输出FAPoint  uStr:=inttostr(FAPoint);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 3*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //输出FATotal  uStr:=inttostr(FATotal);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 4*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //输出FARemainder  uStr:=inttostr(FARemainder);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 5*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //中间三行  p1.X := FPosition.X + 1*wgWidth;  p1.Y := FPosition.Y + 3*wgHeight;  p2.X := FPosition.X + 2*wgWidth;  p2.Y := FPosition.Y + 4*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  p1.X := FPosition.X + 1*wgWidth;  p1.Y := FPosition.Y + 4*wgHeight;  p2.X := FPosition.X + 2*wgWidth;  p2.Y := FPosition.Y + 5*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  p1.X := FPosition.X + 1*wgWidth;  p1.Y := FPosition.Y + 5*wgHeight;  p2.X := FPosition.X + 2*wgWidth;  p2.Y := FPosition.Y + 6*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  //输出'点'  uStr:='点';  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + 1*wgWidth + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 3*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //输出'总'  uStr:='总';  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + 1*wgWidth + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 4*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //输出'余'  uStr:='余';  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + 1*wgWidth + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 5*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //右边三行  p1.X := FPosition.X + 2*wgWidth;  p1.Y := FPosition.Y + 3*wgHeight;  p2.X := FPosition.X + 3*wgWidth;  p2.Y := FPosition.Y + 4*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  p1.X := FPosition.X + 2*wgWidth;  p1.Y := FPosition.Y + 4*wgHeight;  p2.X := FPosition.X + 3*wgWidth;  p2.Y := FPosition.Y + 5*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  p1.X := FPosition.X + 2*wgWidth;  p1.Y := FPosition.Y + 5*wgHeight;  p2.X := FPosition.X + 3*wgWidth;  p2.Y := FPosition.Y + 6*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := clMColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  //输出FBPoint  uStr:=inttostr(FBPoint);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + 2*wgWidth + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 3*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //输出FBTotal  uStr:=inttostr(FBTotal);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + 2*wgWidth + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 4*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //输出FBRemainder  uStr:=inttostr(FBRemainder);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + 2*wgWidth + round((1*wgWidth-uWidth)/2);  uY := FPosition.Y + 5*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);  //第7行  p1.X := FPosition.X + 0;  p1.Y := FPosition.Y + 6*wgHeight;  p2.X := FPosition.X + 3*wgWidth;  p2.Y := FPosition.Y + 7*wgHeight;  c.Pen.Color := FColor;  c.Brush.Color := FYColor;  c.Rectangle(p1.X,p1.Y,p2.X,p2.Y);  //输出FJHRQ  uStr:=DateToStr(FJHRQ,dtf);  uWidth:=c.TextWidth(uStr);  uX := FPosition.X + round((3*wgWidth-uWidth)/2);  uY := FPosition.Y + 6*wgHeight + 2;  c.Brush.Style := bsClear;     //文本不带背景输出  c.Font.Color := clBlack;  c.TextOut(uX,uY,uStr);//  DrawLinkLine(img);  Result := true;end;function TPosNode.DrawLinkLine(img: TImage):Boolean;var  c:TCanvas;begin  if Assigned(Father) then  begin    c := img.Canvas;    c.Pen.Color := clBlack;    c.MoveTo(FPosition.X+54,FPosition.Y);    c.LineTo(TPosNode(Father).FPosition.X+54,TPosNode(Father).FPosition.Y+112);  end;  Result := true;end;procedure TPosNode.SetFLayer(Value: Integer);begin  FLayer := Value;end;procedure TPosNode.SetFPosition(Value: TPoint);begin  FPosition := Value;end;procedure TPosNode.SetFBH(Value: String);begin  FBH := Value;end;procedure TPosNode.SetFXM(Value: String);begin  FXM := Value;end;procedure TPosNode.SetFZW(Value: String);begin  FZW := Value;end;procedure TPosNode.SetFHYJB(Value: String);begin  FHYJB := Value;  if (FHYJB='钻卡') then    FColor := clAColor  else if (FHYJB='金卡') then    FColor := clBColor  else    FColor := clCColor;end;procedure TPosNode.SetFJHRQ(Value: TDateTime);begin  FJHRQ := Value;end;procedure TPosNode.SetFInTopArea(Value: String);begin  FInTopArea := Value;end;procedure TPosNode.SetFAPoint(Value: Integer);begin  FAPoint := Value;end;procedure TPosNode.SetFBPoint(Value: Integer);begin  FBPoint := Value;end;procedure TPosNode.SetFATotal(Value: Integer);begin  FATotal := Value;end;procedure TPosNode.SetFBTotal(Value: Integer);begin  FBTotal := Value;end;procedure TPosNode.SetFARemainder(Value: Integer);begin  FARemainder := Value;end;procedure TPosNode.SetFBRemainder(Value: Integer);begin  FBRemainder := Value;end;procedure TPosNode.SetFSJSM(Value: String);begin  FSJSM := Value;end;procedure TPosNode.SetFSJRQ(Value: TDateTime);begin  FSJRQ := Value;end;procedure TPosNode.SetFYHYJB(Value: String);begin  FYHYJB := Value;  if (FYHYJB='钻卡') then    FYColor := clAColor  else if (FYHYJB='金卡') then    FYColor := clBColor  else if (FYHYJB='银卡') then    FYColor := clCColor  else    FYColor := FColor;end;end.

0 0
原创粉丝点击