Changeset 1233 for trunk/sources
- Timestamp:
- 02/28/09 21:21:59 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 added
- 13 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/LegendForm.cs
r1195 r1233 1 1 using System.Drawing; 2 2 using System.Windows.Forms; 3 using HeuristicLab.Visualization.Legend; 3 4 4 5 namespace HeuristicLab.Visualization.Test { … … 9 10 10 11 CreateLegendShape(); 11 12 12 } 13 13 -
trunk/sources/HeuristicLab.Visualization/DataRow.cs
r1194 r1233 21 21 private DrawingStyle style = DrawingStyle.Solid; 22 22 private DataRowType lineType = DataRowType.Normal; 23 private List<double> dataRow = new List<double>();23 private readonly List<double> dataRow = new List<double>(); 24 24 25 25 private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##"); … … 41 41 } 42 42 43 44 43 public DataRow() { 45 44 } … … 48 47 this.Label = label; 49 48 } 50 51 49 52 50 public DataRow(string label, Color color, int thickness, DrawingStyle style, List<double> dataRow) { … … 58 56 } 59 57 60 /// <summary>61 /// Raised when data row data changed. Should cause redraw in the view.62 /// </summary>63 58 public event DataRowChangedHandler DataRowChanged; 64 59 … … 130 125 OnValueChanged(value, index, Action.Added); 131 126 } else { 132 throw new System.IndexOutOfRangeException();127 throw new IndexOutOfRangeException(); 133 128 } 134 129 } … … 154 149 OnValuesChanged(values, index, Action.Added); 155 150 } else { 156 throw new System.IndexOutOfRangeException();151 throw new IndexOutOfRangeException(); 157 152 } 158 153 } … … 164 159 OnValueChanged(value, index, Action.Modified); 165 160 } else { 166 throw new System.IndexOutOfRangeException();161 throw new IndexOutOfRangeException(); 167 162 } 168 163 } … … 180 175 OnValuesChanged(values, startInd, Action.Modified); 181 176 } else { 182 throw new System.IndexOutOfRangeException();177 throw new IndexOutOfRangeException(); 183 178 } 184 179 } … … 191 186 OnValueChanged(remVal, index, Action.Deleted); 192 187 } else { 193 throw new System.IndexOutOfRangeException();188 throw new IndexOutOfRangeException(); 194 189 } 195 190 } … … 210 205 OnValuesChanged(remValues, index, Action.Deleted); 211 206 } else { 212 throw new System.IndexOutOfRangeException();207 throw new IndexOutOfRangeException(); 213 208 } 214 209 } else { 215 throw new System.Exception("parameter count must be > 0!");210 throw new Exception("parameter count must be > 0!"); 216 211 } 217 212 } -
trunk/sources/HeuristicLab.Visualization/Grid.cs
r1182 r1233 6 6 shapes.Clear(); 7 7 8 foreach (double y in XAxis.GetTicks(YAxis.PixelsPerInterval,9 viewport.Height,10 ClippingArea.Height,11 ClippingArea.Y1)) {8 foreach (double y in AxisTicks.GetTicks(YAxis.PixelsPerInterval, 9 viewport.Height, 10 ClippingArea.Height, 11 ClippingArea.Y1)) { 12 12 LineShape line = new LineShape(ClippingArea.X1, y, 13 13 ClippingArea.X2, y, 14 0, Color.LightBlue, 1, DrawingStyle.Dashed); 14 Color.LightBlue, 1, 15 DrawingStyle.Dashed); 15 16 shapes.Add(line); 16 17 } 17 18 18 foreach (double x in XAxis.GetTicks(XAxis.PixelsPerInterval,19 viewport.Width,20 ClippingArea.Width,21 ClippingArea.X1)) {19 foreach (double x in AxisTicks.GetTicks(XAxis.PixelsPerInterval, 20 viewport.Width, 21 ClippingArea.Width, 22 ClippingArea.X1)) { 22 23 LineShape line = new LineShape(x, ClippingArea.Y1, 23 24 x, ClippingArea.Y2, 24 0, Color.LightBlue, 1, DrawingStyle.Dashed); 25 Color.LightBlue, 1, 26 DrawingStyle.Dashed); 25 27 shapes.Add(line); 26 28 } … … 28 30 LineShape lineZeroX = new LineShape(0, ClippingArea.Y1, 29 31 0, ClippingArea.Y2, 30 0, Color.LightBlue, 3, DrawingStyle.Dashed); 32 Color.LightBlue, 3, 33 DrawingStyle.Dashed); 31 34 32 35 LineShape lineZeroY = new LineShape(ClippingArea.X1, 0, 33 36 ClippingArea.X2, 0, 34 0, Color.LightBlue, 3, DrawingStyle.Dashed); 37 Color.LightBlue, 3, 38 DrawingStyle.Dashed); 35 39 36 40 shapes.Add(lineZeroX); -
trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj
r1195 r1233 68 68 </ItemGroup> 69 69 <ItemGroup> 70 <Compile Include="AxisTicks.cs" /> 70 71 <Compile Include="Canvas.cs" /> 71 72 <Compile Include="CanvasUI.cs"> … … 87 88 <Compile Include="LabelProvider\ILabelProvider.cs" /> 88 89 <Compile Include="IMouseEventListener.cs" /> 90 <Compile Include="Legend\LegendItem.cs" /> 89 91 <Compile Include="Options\OptionsDialog.cs"> 90 92 <SubType>Form</SubType> … … 96 98 <Compile Include="LabelProvider\StringLabelProvider.cs" /> 97 99 <Compile Include="TextShape.cs" /> 98 <Compile Include="Legend Shape.cs" />100 <Compile Include="Legend\LegendShape.cs" /> 99 101 <Compile Include="DataRow.cs" /> 100 102 <Compile Include="DrawingStyle.cs" /> -
trunk/sources/HeuristicLab.Visualization/HeuristicLabVisualizationPlugin.cs
r621 r1233 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Text;25 22 using HeuristicLab.PluginInfrastructure; 26 23 -
trunk/sources/HeuristicLab.Visualization/HorizontalLineShape.cs
r1187 r1233 1 1 using System.Drawing; 2 using System.Drawing.Drawing2D;3 2 4 3 namespace HeuristicLab.Visualization { 5 4 public class MinMaxLineShape : WorldShape { 6 private LineShape minLineShape;7 private LineShape maxLineShape;5 private readonly LineShape minLineShape; 6 private readonly LineShape maxLineShape; 8 7 9 8 /// <summary> 10 9 /// Initializes the HorizontalLineShape. 11 10 /// </summary> 12 /// <param name="z">Z-order</param>13 11 /// <param name="color">color for the LineShape</param> 14 12 /// <param name="yMin">y value for lower line</param> … … 16 14 /// <param name="thickness">line thickness</param> 17 15 /// <param name="style">line style</param> 18 public MinMaxLineShape(double yMin, double yMax, double z,Color color, int thickness, DrawingStyle style) {19 minLineShape = new LineShape(0, yMin, 1, yMin, z,color, thickness, style);20 maxLineShape = new LineShape(0, yMax, 1, yMax, z,color, thickness, style);16 public MinMaxLineShape(double yMin, double yMax, Color color, int thickness, DrawingStyle style) { 17 minLineShape = new LineShape(0, yMin, 1, yMin, color, thickness, style); 18 maxLineShape = new LineShape(0, yMax, 1, yMax, color, thickness, style); 21 19 shapes.Add(minLineShape); 22 20 shapes.Add(maxLineShape); -
trunk/sources/HeuristicLab.Visualization/IDataRow.cs
r1194 r1233 15 15 DataRowType LineType { get; set; } 16 16 ILabelProvider YAxisLabelProvider { get; set; } 17 18 /// <summary> 19 /// Raised when data row data changed. Should cause redraw in the view. 20 /// </summary> 21 event DataRowChangedHandler DataRowChanged; 17 22 18 23 void AddValue(double value); -
trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs
r1232 r1233 1 1 using System.Collections.Generic; 2 using System.Drawing;2 using HeuristicLab.Visualization.Legend; 3 3 4 namespace HeuristicLab.Visualization { 5 public class LegendItem { 6 public LegendItem(string label, Color color, int thickness) { 7 Label = label; 8 Color = color; 9 Thickness = thickness; 10 } 11 12 public string Label { get; set; } 13 public Color Color { get; set; } 14 public int Thickness { get; set; } 15 } 16 17 4 namespace HeuristicLab.Visualization.Legend { 18 5 public class LegendShape : WorldShape { 19 6 private readonly IList<LegendItem> legendItems = new List<LegendItem>(); … … 27 14 double y = ClippingArea.Y2; 28 15 foreach (LegendItem item in legendItems) { 29 AddShape(new LineShape(10, y - 10, 30, y - 10, 0,item.Color, item.Thickness, DrawingStyle.Solid));16 AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid)); 30 17 AddShape(new TextShape(35, y, item.Label)); 31 18 y -= 15; -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1195 r1233 2 2 using System.Collections.Generic; 3 3 using System.Drawing; 4 using System.Drawing.Drawing2D;5 4 using System.Windows.Forms; 6 5 using HeuristicLab.Core; 6 using HeuristicLab.Visualization.Legend; 7 7 using HeuristicLab.Visualization.Options; 8 8 … … 65 65 root.AddShape(titleShape); 66 66 67 minMaxLineShape = new MinMaxLineShape(this.minDataValue, this.maxDataValue, 0,Color.Yellow, 4, DrawingStyle.Solid);67 minMaxLineShape = new MinMaxLineShape(this.minDataValue, this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid); 68 68 root.AddShape(minMaxLineShape); 69 69 … … 207 207 } 208 208 for (int i = 1; i < row.Count; i++) { 209 LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], 0,row.Color, row.Thickness, row.Style);209 LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style); 210 210 lineShapes.Add(lineShape); 211 211 // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently. … … 246 246 maxDataRowCount = row.Count; 247 247 } 248 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], 0,row.Color, row.Thickness,248 LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness, 249 249 row.Style); 250 250 lineShapes.Add(lineShape); … … 412 412 413 413 private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { 414 varoptionsdlg = new OptionsDialog(this);415 optionsdlg.Show ();414 OptionsDialog optionsdlg = new OptionsDialog(this); 415 optionsdlg.ShowDialog(this); 416 416 } 417 417 418 418 public void ApplyChangesToRow(IDataRow row) { 419 foreach ( varls in rowToLineShapes[row]) {419 foreach (LineShape ls in rowToLineShapes[row]) { 420 420 ls.LSColor = row.Color; 421 421 ls.LSThickness = row.Thickness; 422 if (row.Style == DrawingStyle.Dashed) { 423 ls.LSDashStyle = DashStyle.Dash; 424 } 425 else { 426 ls.LSDashStyle = DashStyle.Solid; //default 427 } 422 ls.LSDrawingStyle = row.Style; 428 423 } 429 424 canvas.Invalidate(); -
trunk/sources/HeuristicLab.Visualization/LineShape.cs
r1187 r1233 5 5 public class LineShape : IShape { 6 6 private RectangleD boundingBox; 7 private double z; 7 8 8 private Color color; 9 9 private int thickness; 10 private DashStyle dashStyle; 10 private DrawingStyle drawingStyle; 11 12 private Pen pen; 11 13 12 14 /// <summary> … … 18 20 /// <param name="y2">y coordinate of right lineEndPoind</param> 19 21 /// <param name="color">color for the LineShape</param> 20 public LineShape(double x1, double y1, double x2, double y2, double z, Color color, int thickness, DrawingStyle style) { 22 /// <param name="thickness">tickness of the line in pixels</param> 23 /// <param name="drawingStyle">drawing style of the line (solid, dashed, dotted,...)</param> 24 public LineShape(double x1, double y1, double x2, double y2, Color color, int thickness, DrawingStyle drawingStyle) { 21 25 this.boundingBox = new RectangleD(x1, y1, x2, y2); 22 this.z = z;23 26 this.LSColor = color; 24 27 this.LSThickness = thickness; 25 if (style==DrawingStyle.Dashed) { 26 this.LSDashStyle = DashStyle.Dash; 27 } 28 else { 29 this.LSDashStyle = DashStyle.Solid; //default 30 } 28 this.LSDrawingStyle = drawingStyle; 31 29 } 32 30 … … 62 60 /// <param name="clippingArea">rectangle in screen-coordinates to draw</param> 63 61 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 64 using (Pen pen = new Pen(LSColor, LSThickness)){ 65 pen.DashStyle = this.LSDashStyle; 66 Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea); 67 graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); 68 } 62 Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea); 63 64 graphics.DrawLine(GetPen(), screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top); 69 65 } 70 66 71 public double Z { 72 get { return z; } 73 set { z = value; } 67 private Pen GetPen() { 68 if (pen == null) { 69 pen = new Pen(LSColor, LSThickness); 70 71 switch (LSDrawingStyle) { 72 case DrawingStyle.Dashed: 73 pen.DashStyle = DashStyle.Dash; 74 break; 75 default: 76 pen.DashStyle = DashStyle.Solid; 77 break; 78 } 79 } 80 81 return pen; 82 } 83 84 private void DisposePen() { 85 if (pen != null) { 86 pen.Dispose(); 87 pen = null; 88 } 74 89 } 75 90 76 91 public Color LSColor { 77 92 get { return color; } 78 set { color = value; } 93 set { 94 color = value; 95 DisposePen(); 96 } 79 97 } 80 98 81 99 public int LSThickness { 82 100 get { return thickness; } 83 set { thickness = value; } 101 set { 102 thickness = value; 103 DisposePen(); 104 } 84 105 } 85 106 86 public DashStyle LSDashStyle { 87 get { return dashStyle; } 88 set { dashStyle = value; } 107 public DrawingStyle LSDrawingStyle { 108 get { return drawingStyle; } 109 set { 110 drawingStyle = value; 111 DisposePen(); 112 } 89 113 } 90 114 } -
trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs
r1195 r1233 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.ComponentModel;4 using System.Data;5 using System.Drawing;6 using System.Linq;7 using System.Text;8 3 using System.Windows.Forms; 9 4 10 5 namespace HeuristicLab.Visualization.Options { 11 6 public partial class OptionsDialog : Form { 12 13 7 private LineChart lc; 14 8 … … 18 12 } 19 13 20 21 14 private void button1_Click(object sender, EventArgs e) { 22 vardlg = new ColorDialog();15 ColorDialog dlg = new ColorDialog(); 23 16 dlg.ShowDialog(); 24 17 this.ColorPreviewTB.BackColor = dlg.Color; … … 44 37 45 38 private void LineSelectCB_SelectedIndexChanged(object sender, EventArgs e) { 46 int index = this.LineThicknessCB.FindStringExact(((IDataRow) this.LineSelectCB.SelectedValue).Thickness.ToString()); 39 IDataRow datarow = (IDataRow)this.LineSelectCB.SelectedValue; 40 41 int index = this.LineThicknessCB.FindStringExact(datarow.Thickness.ToString()); 47 42 this.LineThicknessCB.SelectedIndex = index; 48 index = this.LinestyleCB.FindStringExact( ((IDataRow) this.LineSelectCB.SelectedValue).Style.ToString());43 index = this.LinestyleCB.FindStringExact(datarow.Style.ToString()); 49 44 LinestyleCB.SelectedIndex = index; 50 this.ColorPreviewTB.BackColor = ((IDataRow) this.LineSelectCB.SelectedValue).Color;45 this.ColorPreviewTB.BackColor = datarow.Color; 51 46 } 52 47 … … 56 51 57 52 private void OptionsDialogOkButton_Click(object sender, EventArgs e) { 58 ((IDataRow) this.LineSelectCB.SelectedValue).Thickness = (int) this.LineThicknessCB.SelectedItem; 59 ((IDataRow) this.LineSelectCB.SelectedValue).Color = this.ColorPreviewTB.BackColor; 60 ((IDataRow) this.LineSelectCB.SelectedValue).Style = (DrawingStyle) this.LineThicknessCB.SelectedItem; 61 this.lc.ApplyChangesToRow((IDataRow) this.LineSelectCB.SelectedValue); 53 IDataRow datarow = (IDataRow)this.LineSelectCB.SelectedValue; 54 55 datarow.Thickness = (int)this.LineThicknessCB.SelectedItem; 56 datarow.Color = this.ColorPreviewTB.BackColor; 57 datarow.Style = (DrawingStyle)this.LineThicknessCB.SelectedItem; 58 59 this.lc.ApplyChangesToRow(datarow); 62 60 this.Close(); 63 61 } -
trunk/sources/HeuristicLab.Visualization/RectangleShape.cs
r1038 r1233 4 4 public class RectangleShape : IShape { 5 5 private RectangleD rectangle; 6 6 7 private Color color; 7 8 private int opacity = 255; 9 10 private Pen pen; 11 private Brush brush; 8 12 9 13 public RectangleShape(double x1, double y1, double x2, double y2, Color color) { … … 16 20 } 17 21 18 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {19 Color brushColor = Color.FromArgb(opacity, color);20 21 using (Pen pen = new Pen(color, 1))22 using (Brush brush = new SolidBrush(brushColor)) {23 Rectangle screenRect = Transform.ToScreen(rectangle, viewport, clippingArea);24 25 graphics.DrawRectangle(pen, screenRect);26 graphics.FillRectangle(brush, screenRect);27 }28 }29 30 public int Opacity {31 get { return opacity; }32 set { opacity = value; }33 }34 35 22 public RectangleD Rectangle { 36 23 get { return rectangle; } … … 38 25 } 39 26 27 public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 28 Rectangle screenRect = Transform.ToScreen(rectangle, viewport, clippingArea); 29 30 graphics.DrawRectangle(GetPen(), screenRect); 31 graphics.FillRectangle(GetBrush(), screenRect); 32 } 33 34 private Pen GetPen() { 35 if (pen == null) 36 pen = new Pen(color, 1); 37 return pen; 38 } 39 40 private Brush GetBrush() { 41 if (brush == null) 42 brush = new SolidBrush(Color.FromArgb(opacity, color)); 43 return brush; 44 } 45 46 public int Opacity { 47 get { return opacity; } 48 set { 49 opacity = value; 50 DisposeDrawingTools(); 51 } 52 } 53 40 54 public Color Color { 41 55 get { return color; } 42 set { color = value; } 56 set { 57 color = value; 58 DisposeDrawingTools(); 59 } 60 } 61 62 private void DisposeDrawingTools() { 63 if (pen != null) { 64 pen.Dispose(); 65 pen = null; 66 } 67 68 if (brush != null) { 69 brush.Dispose(); 70 brush = null; 71 } 43 72 } 44 73 } -
trunk/sources/HeuristicLab.Visualization/XAxis.cs
r1194 r1233 1 using System;2 using System.Collections.Generic;3 1 using System.Drawing; 4 2 using HeuristicLab.Visualization.LabelProvider; … … 7 5 public class XAxis : WorldShape { 8 6 public const int PixelsPerInterval = 100; 7 9 8 private ILabelProvider labelProvider = new ContinuousLabelProvider("0.####"); 10 9 … … 14 13 } 15 14 16 public static IEnumerable<double> GetTicks(int pixelsPerInterval, int screenSize, double worldSize, double worldStart) {17 int intervals = screenSize/pixelsPerInterval;18 19 if (intervals > 0) {20 double step = worldSize/intervals;21 step = Math.Pow(10, Math.Floor(Math.Log10(step)));22 if (worldSize/(step*5) > intervals)23 step = step*5;24 else if (worldSize/(step*2) > intervals)25 step = step*2;26 27 for (double x = Math.Floor(worldStart/step)*step;28 x <= worldStart + worldSize;29 x += step)30 yield return x;31 }32 }33 34 15 public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 35 16 shapes.Clear(); 36 17 37 foreach (double x in GetTicks(PixelsPerInterval, viewport.Width, ClippingArea.Width, ClippingArea.X1)) { 18 foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, viewport.Width, 19 ClippingArea.Width, 20 ClippingArea.X1)) { 38 21 TextShape label = new TextShape(x, ClippingArea.Height - 3, 39 22 labelProvider.GetLabel(x)); -
trunk/sources/HeuristicLab.Visualization/YAxis.cs
r1194 r1233 16 16 shapes.Clear(); 17 17 18 foreach (double y in XAxis.GetTicks(PixelsPerInterval, 19 viewport.Height, 20 ClippingArea.Height, 21 ClippingArea.Y1)) { 18 foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, viewport.Height, 19 ClippingArea.Height, 20 ClippingArea.Y1)) { 22 21 TextShape label = new TextShape(ClippingArea.X2 - 3, y, 23 22 labelProvider.GetLabel(y));
Note: See TracChangeset
for help on using the changeset viewer.