Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DrawingArea.cs
1using System;
2using System.Collections.Generic;
3using SkiaSharp;
5
7{
11 public class DrawingArea
12 {
13 private Dictionary<string, double> xLabelPositions = null;
14 private Dictionary<string, double> yLabelPositions = null;
15 private readonly IElement minX;
16 private readonly IElement maxX;
17 private readonly IElement minY;
18 private readonly IElement maxY;
19 private readonly int offsetX;
20 private readonly int offsetY;
21 private readonly int width;
22 private readonly int height;
23 private readonly float origoX;
24 private readonly float origoY;
25 private readonly bool elementwise;
26
42 float OrigoX, float OrigoY, bool Elementwise)
43 {
44 this.minX = MinX;
45 this.maxX = MaxX;
46 this.minY = MinY;
47 this.maxY = MaxY;
48 this.offsetX = OffsetX;
49 this.offsetY = OffsetY;
50 this.width = Width;
51 this.height = Height;
52 this.origoX = OrigoX;
53 this.origoY = OrigoY;
54 this.elementwise = Elementwise;
55 }
56
60 public IElement MinX => this.minX;
61
65 public IElement MaxX => this.maxX;
66
70 public IElement MinY => this.minY;
71
75 public IElement MaxY => this.maxY;
76
80 public int OffsetX => this.offsetX;
81
85 public int OffsetY => this.offsetY;
86
90 public int Width => this.width;
91
95 public int Height => this.height;
96
100 public float OrigoX => this.origoX;
101
105 public float OrigoY => this.origoY;
106
110 public bool Elementwise => this.elementwise;
111
115 public Dictionary<string, double> XLabelPositions
116 {
117 get => this.xLabelPositions;
118 set => this.xLabelPositions = value;
119 }
120
124 public Dictionary<string, double> YLabelPositions
125 {
126 get => this.yLabelPositions;
127 set => this.yLabelPositions = value;
128 }
129
135 public SKPoint[] Scale(IVector VectorX, IVector VectorY)
136 {
137 return Graph.Scale(VectorX, VectorY, this.minX, this.maxX, this.minY, this.maxY,
138 this.offsetX, this.offsetY, this.width, this.height, this.xLabelPositions,
139 this.yLabelPositions);
140 }
141
146 public double[] ScaleX(IVector Vector)
147 {
148 return Graph.Scale(Vector, this.minX, this.maxX, this.offsetX, this.width, this.xLabelPositions);
149 }
150
155 public double[] ScaleY(IVector Vector)
156 {
157 return Graph.Scale(Vector, this.minY, this.maxY, this.offsetY, this.height, this.yLabelPositions);
158 }
159
160
165 public IElement DescaleX(double Value)
166 {
167 return Graph.Descale(Value, this.minX, this.maxX, this.offsetX, this.width);
168 }
169
174 public IElement DescaleY(double Value)
175 {
176 return Graph.Descale(Value, this.minY, this.maxY, this.offsetY, this.height);
177 }
178
179 }
180}
Contains information about the current drawing area.
Definition: DrawingArea.cs:12
IElement DescaleY(double Value)
Descales a scaled value along the Y-axis.
Definition: DrawingArea.cs:174
bool Elementwise
If graph was generated using element-wise addition operations.
Definition: DrawingArea.cs:110
Dictionary< string, double > YLabelPositions
Optional fixed Y-Label positions.
Definition: DrawingArea.cs:125
int Height
Height of drawing area.
Definition: DrawingArea.cs:95
float OrigoY
Y-coordinate for the origo.
Definition: DrawingArea.cs:105
int OffsetY
Y-offset of drawing area, relative to the canvas origin.
Definition: DrawingArea.cs:85
SKPoint[] Scale(IVector VectorX, IVector VectorY)
Scales two vectors of equal size to points in a rectangular area.
Definition: DrawingArea.cs:135
IElement DescaleX(double Value)
Descales a scaled value along the X-axis.
Definition: DrawingArea.cs:165
IElement MinX
Smallest value of X.
Definition: DrawingArea.cs:60
float OrigoX
X-coordinate for the origo.
Definition: DrawingArea.cs:100
IElement MaxY
Largest value of Y.
Definition: DrawingArea.cs:75
Dictionary< string, double > XLabelPositions
Optional fixed X-Label positions.
Definition: DrawingArea.cs:116
int Width
Width of drawing area.
Definition: DrawingArea.cs:90
IElement MaxX
Largest value of X.
Definition: DrawingArea.cs:65
double[] ScaleX(IVector Vector)
Scales a vector to fit a given area.
Definition: DrawingArea.cs:146
int OffsetX
X-offset of drawing area, relative to the canvas origin.
Definition: DrawingArea.cs:80
IElement MinY
Smallest value of Y.
Definition: DrawingArea.cs:70
DrawingArea(IElement MinX, IElement MaxX, IElement MinY, IElement MaxY, int OffsetX, int OffsetY, int Width, int Height, float OrigoX, float OrigoY, bool Elementwise)
Contains information about the current drawing area.
Definition: DrawingArea.cs:41
double[] ScaleY(IVector Vector)
Scales a vector to fit a given area.
Definition: DrawingArea.cs:155
Base class for graphs.
Definition: Graph.cs:79
static IElement Descale(double Value, IElement Min, IElement Max, double Offset, double Size)
Descales a scaled value.
Definition: Graph.cs:747
static SKPoint[] Scale(IVector VectorX, IVector VectorY, IElement MinX, IElement MaxX, IElement MinY, IElement MaxY, double OffsetX, double OffsetY, double Width, double Height, Dictionary< string, double > XLabelPositions, Dictionary< string, double > YLabelPositions)
Scales two vectors of equal size to points in a rectangular area.
Definition: Graph.cs:496
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for vectors.
Definition: IVector.cs:9