/// <summary> /// Update the color for the legend. /// </summary> /// <param name="colormap">Color for the legend.</param> public void UpdateColor(ColormapBrush.ColormapBrushEnum colormap) { _Colormap.ColormapBrushType = colormap; // Update the legend Update(); }
/// <summary> /// Receive a list of vectors and add /// it to the list. Limit the size of the list /// of vectors. /// </summary> /// <param name="vectors">Vectors to add to the list.</param> /// <param name="colorMap">Color Scheme.</param> public void DrawPlot(List <DataSet.EnsembleVelocityVectors> vectors, ColormapBrush.ColormapBrushEnum colorMap) { _plot.MaxEnsembles = vectors.Count; _plot.ColormapBrushSelection = colorMap; _plot.DrawPlot(vectors); //PropertyChangeVelocityScales(); }
public ContourPlotLegendViewModel(ColormapBrush.ColormapBrushEnum colormap, double min, double max) { _MinVelocity = min; _MaxVelocity = max; _Colormap = new ColormapBrush(); _Colormap.ColormapBrushType = colormap; ScaleLabel = DEFAULT_SCALE_LABEL; // Update the legend Update(); }
private void DrawColorbar(ColormapBrush.ColormapBrushEnum brushType, double offset) { double width = 30.0; double height = 20.0; ColormapBrush cb = new ColormapBrush(); cb.Ydivisions = 10; cb.ColormapBrushType = brushType; SolidColorBrush[] brush = cb.ColormapBrushes(); Rectangle rect; for (int i = 0; i < 10; i++) { rect = new Rectangle(); rect.Width = width; rect.Height = height; Canvas.SetTop(rect, 10 + i * 23); Canvas.SetLeft(rect, 10 + 40 * offset); rect.Fill = brush[i]; chartCanvas.Children.Add(rect); } }
/// <summary> /// Create the a brush based off the enum given and the minimum and maximum value. /// The brush will be created, then frozen and returned. /// Spectrum of the color is 0.0 to 1.0. /// /// I added black to the begining of some some, ranging from 0.0-0.01 to 0.0 - 0.1 /// to display black for bad velocity with a velocity of 0. /// </summary> /// <param name="brushEnum">Brush chosen.</param> /// <param name="alphaValue">The transparency of the display.</param> /// <returns>Brush for the given enum.</returns> public static Brush GetBrush(ColormapBrush.ColormapBrushEnum brushEnum, byte alphaValue = 255) { // Determine which brush is being selected // Then create the brush and return switch (brushEnum) { case ColormapBrush.ColormapBrushEnum.Spring: LinearGradientBrush springBrush = new LinearGradientBrush(); springBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal springBrush.EndPoint = new Point(1, 0.5); springBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) springBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 0, 255), 0.1)); // R = 255 G = 255*0 = 0 B = 255-G = 255 springBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 0), 1.0)); // R = 255 G = 255*1 = 255 B = 255-G = 0 springBrush.Freeze(); return(springBrush); case ColormapBrush.ColormapBrushEnum.Summer: LinearGradientBrush summerBrush = new LinearGradientBrush(); summerBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal summerBrush.EndPoint = new Point(1, 0.5); summerBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) summerBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 128, 102), 0.01)); // R = 255*0 = 0 G = 255 * 0.5 * (1 + 0) = 127.5 B = 255*0.4 = 102 summerBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 102), 1.0)); // R = 255*1 = 255 G = 255 * 0.5 * (1 + 1) = 255 B = 255*0.4 = 102 summerBrush.Freeze(); return(summerBrush); case ColormapBrush.ColormapBrushEnum.Autumn: LinearGradientBrush autumnBrush = new LinearGradientBrush(); autumnBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal autumnBrush.EndPoint = new Point(1, 0.5); autumnBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) autumnBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 0, 0), 0.1)); // R = 255 G = 255*0 = 0 B = 0 autumnBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 0), 1.0)); // R = 255 G = 255*1 = 255 B = 0 autumnBrush.Freeze(); return(autumnBrush); case ColormapBrush.ColormapBrushEnum.Winter: LinearGradientBrush winterBrush = new LinearGradientBrush(); winterBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal winterBrush.EndPoint = new Point(1, 0.5); winterBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) winterBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 0, 255), 0.01)); // R = 0 G = 255*0 = 0 B = 255 * (1.0 - (0.5 * 0)) = 255 winterBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 255, 128), 1.0)); // R = 0 G = 255*1 = 255 B = 255 * (1.0 - (0.5 * 1)) = 128 winterBrush.Freeze(); return(winterBrush); case ColormapBrush.ColormapBrushEnum.Gray: LinearGradientBrush grayBrush = new LinearGradientBrush(); grayBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 0, 0), 0.0)); // R = 255*0 = 0 G = 255*0 = 0 B = 255*0 = 0 grayBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 255, 255), 1.0)); // R = 255*1 = 255 G = 255*1 = 255 B = 255*1 = 255 grayBrush.Freeze(); return(grayBrush); case ColormapBrush.ColormapBrushEnum.Hot: LinearGradientBrush hotBrush = new LinearGradientBrush(); hotBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal hotBrush.EndPoint = new Point(1, 0.5); hotBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); hotBrush.GradientStops.Add(new GradientStop(Colors.Red, 0.25)); hotBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.50)); hotBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.75)); hotBrush.GradientStops.Add(new GradientStop(Colors.White, 1.0)); hotBrush.Freeze(); return(hotBrush); case ColormapBrush.ColormapBrushEnum.Cool: LinearGradientBrush coolBrush = new LinearGradientBrush(); coolBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal coolBrush.EndPoint = new Point(1, 0.5); coolBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) coolBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 0, 255, 255), 0.1)); // R = 255*0 = 0 G = 255 * (1.0 - 0) = 255 B = 255 coolBrush.GradientStops.Add(new GradientStop(Color.FromArgb(alphaValue, 255, 0, 255), 1.0)); // R = 255*1 = 255 G = 255 * (1.0 - 1) = 0 B = 255 coolBrush.Freeze(); return(coolBrush); case ColormapBrush.ColormapBrushEnum.Jet: LinearGradientBrush jetBrush = new LinearGradientBrush(); jetBrush.StartPoint = new Point(0, 0.5); // Creates a horizontal linear gradient instead of it looking diagonal jetBrush.EndPoint = new Point(1, 0.5); jetBrush.GradientStops.Add(new GradientStop(Colors.Black, 0.0)); // Add Black for bad Velocity (0 Velocity) jetBrush.GradientStops.Add(new GradientStop(Colors.DarkBlue, 0.01)); jetBrush.GradientStops.Add(new GradientStop(Colors.Blue, 0.125)); jetBrush.GradientStops.Add(new GradientStop(Colors.Cyan, 0.375)); jetBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.625)); jetBrush.GradientStops.Add(new GradientStop(Colors.Red, 0.875)); jetBrush.GradientStops.Add(new GradientStop(Colors.DarkRed, 1.0)); jetBrush.Freeze(); return(jetBrush); default: SolidColorBrush defaultBrush = new SolidColorBrush(Colors.YellowGreen); defaultBrush.Freeze(); return(defaultBrush); } }