TAChart: Support monochrome mode in svg drawing back-end

git-svn-id: trunk@40091 -
This commit is contained in:
ask 2013-01-31 09:25:00 +00:00
parent 9bf682d41a
commit 6cd1638f18
2 changed files with 17 additions and 6 deletions

View File

@ -277,7 +277,7 @@ end;
procedure TSVGDrawer.PrepareSimplePen(AColor: TChartColor); procedure TSVGDrawer.PrepareSimplePen(AColor: TChartColor);
begin begin
FPen.FPColor := FChartColorToFPColorFunc(AColor); FPen.FPColor := FChartColorToFPColorFunc(ColorOrMono(AColor));
FPen.Style := psSolid; FPen.Style := psSolid;
FPen.Width := 1; FPen.Width := 1;
end; end;
@ -323,36 +323,38 @@ end;
procedure TSVGDrawer.SetBrush(ABrush: TFPCustomBrush); procedure TSVGDrawer.SetBrush(ABrush: TFPCustomBrush);
begin begin
FBrushColor := ABrush.FPColor; FBrushColor := FPColorOrMono(ABrush.FPColor);
end; end;
procedure TSVGDrawer.SetBrushColor(AColor: TChartColor); procedure TSVGDrawer.SetBrushColor(AColor: TChartColor);
begin begin
FBrushColor := FChartColorToFPColorFunc(AColor); FBrushColor := FChartColorToFPColorFunc(ColorOrMono(AColor));
end; end;
procedure TSVGDrawer.SetBrushParams( procedure TSVGDrawer.SetBrushParams(
AStyle: TFPBrushStyle; AColor: TChartColor); AStyle: TFPBrushStyle; AColor: TChartColor);
begin begin
FBrushColor := FChartColorToFPColorFunc(AColor); FBrushColor := FChartColorToFPColorFunc(ColorOrMono(AColor));
Unused(AStyle); Unused(AStyle);
end; end;
procedure TSVGDrawer.SetFont(AFont: TFPCustomFont); procedure TSVGDrawer.SetFont(AFont: TFPCustomFont);
begin begin
FFont := AFont; FFont := AFont;
if FMonochromeColor <> clTAColor then
FFont.FPColor := FChartColorToFPColorFunc(FMonochromeColor);
end; end;
procedure TSVGDrawer.SetPen(APen: TFPCustomPen); procedure TSVGDrawer.SetPen(APen: TFPCustomPen);
begin begin
FPen.FPColor := APen.FPColor; FPen.FPColor := FPColorOrMono(APen.FPColor);
FPen.Style := APen.Style; FPen.Style := APen.Style;
FPen.Width := APen.Width; FPen.Width := APen.Width;
end; end;
procedure TSVGDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor); procedure TSVGDrawer.SetPenParams(AStyle: TFPPenStyle; AColor: TChartColor);
begin begin
FPen.FPColor := FChartColorToFPColorFunc(AColor); FPen.FPColor := FChartColorToFPColorFunc(ColorOrMono(AColor));
FPen.Style := AStyle; FPen.Style := AStyle;
end; end;

View File

@ -131,6 +131,7 @@ type
FTransparency: TChartTransparency; FTransparency: TChartTransparency;
FXor: Boolean; FXor: Boolean;
function ColorOrMono(AColor: TChartColor): TChartColor; inline; function ColorOrMono(AColor: TChartColor): TChartColor; inline;
function FPColorOrMono(const AColor: TFPColor): TFPColor; inline;
function GetFontAngle: Double; virtual; abstract; function GetFontAngle: Double; virtual; abstract;
function SimpleTextExtent(const AText: String): TPoint; virtual; abstract; function SimpleTextExtent(const AText: String): TPoint; virtual; abstract;
procedure SimpleTextOut(AX, AY: Integer; const AText: String); virtual; abstract; procedure SimpleTextOut(AX, AY: Integer; const AText: String); virtual; abstract;
@ -327,6 +328,14 @@ begin
Polygon([AP1, AP1 + d, AP2 + d, AP2], 0, 4); Polygon([AP1, AP1 + d, AP2 + d, AP2], 0, 4);
end; end;
function TBasicDrawer.FPColorOrMono(const AColor: TFPColor): TFPColor;
begin
if FMonochromeColor = clTAColor then
Result := AColor
else
Result := FChartColorToFPColorFunc(FMonochromeColor);
end;
procedure TBasicDrawer.LineTo(const AP: TPoint); procedure TBasicDrawer.LineTo(const AP: TPoint);
begin begin
LineTo(AP.X, AP.Y) LineTo(AP.X, AP.Y)