Changeset 567
- Timestamp:
- 09/14/08 16:16:20 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.CEDMA.Charting
- Files:
-
- 3 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.CEDMA.Charting/BubbleChart.cs
r566 r567 160 160 UpdateViewSize(x, y, size); 161 161 int alpha = CalculateAlpha(size); 162 Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor));162 Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor)); 163 163 Brush brush = pen.Brush; 164 164 FixedSizeCircle c = new FixedSizeCircle(this, x, y, size, pen, brush); 165 c.ToolTipText = CreateToolTipText(r);165 c.ToolTipText = r.GetToolTipText(); 166 166 points.Add(c); 167 167 primitiveToRecordDictionary[c] = r; … … 172 172 UpdateEnabled = true; 173 173 } 174 }175 176 private string CreateToolTipText(Record r) {177 StringBuilder b = new StringBuilder();178 foreach(KeyValuePair<string, double> v in r.Values) {179 b.Append(v.Key).Append(" = ").Append(v.Value).AppendLine();180 }181 return b.ToString();182 174 } 183 175 … … 220 212 } 221 213 222 public override void MouseClick(Point point, MouseButtons button) { 223 if(button == MouseButtons.Left) { 224 Record r; 225 IPrimitive p = points.GetPrimitive(TransformPixelToWorld(point)); 226 if(p != null) { 227 primitiveToRecordDictionary.TryGetValue(p, out r); 228 if(r != null) r.ToggleSelected(); 229 results.FireChanged(); 230 } 231 } else base.MouseClick(point, button); 232 } 233 234 public override void MouseDoubleClick(Point point, MouseButtons button) { 235 if(button == MouseButtons.Left) { 236 Record r; 237 IPrimitive p = points.GetPrimitive(TransformPixelToWorld(point)); 238 if(p != null) { 239 primitiveToRecordDictionary.TryGetValue(p, out r); 240 if(r != null) results.OpenModel(r); 241 } 242 } else base.MouseDoubleClick(point, button); 243 } 214 internal Record GetRecord(Point point) { 215 Record r = null; 216 IPrimitive p = points.GetPrimitive(TransformPixelToWorld(point)); 217 if(p != null) { 218 primitiveToRecordDictionary.TryGetValue(p, out r); 219 } 220 return r; 221 } 222 244 223 245 224 public override void MouseDrag(Point start, Point end, MouseButtons button) { … … 261 240 } 262 241 } 263 results.FireChanged();264 242 } else { 265 243 base.MouseDrag(start, end, button); -
trunk/sources/HeuristicLab.CEDMA.Charting/BubbleChartControl.Designer.cs
r566 r567 48 48 this.pictureBox = new System.Windows.Forms.PictureBox(); 49 49 this.pictureBoxContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 50 this.moveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 50 51 this.zoomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 52 this.selectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 52 this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();53 53 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 54 54 ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); … … 80 80 // 81 81 this.pictureBoxContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 82 this.moveToolStripMenuItem, 82 83 this.zoomToolStripMenuItem, 83 this.selectToolStripMenuItem, 84 this.toolStripMenuItem2}); 84 this.selectToolStripMenuItem}); 85 85 this.pictureBoxContextMenuStrip.Name = "pictureBoxContextMenuStrip"; 86 this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(104, 54); 86 this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(153, 92); 87 // 88 // moveToolStripMenuItem 89 // 90 this.moveToolStripMenuItem.Name = "moveToolStripMenuItem"; 91 this.moveToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 92 this.moveToolStripMenuItem.Text = "Move"; 93 this.moveToolStripMenuItem.Click += new System.EventHandler(this.moveToolStripMenuItem_Click); 87 94 // 88 95 // zoomToolStripMenuItem 89 96 // 90 97 this.zoomToolStripMenuItem.Name = "zoomToolStripMenuItem"; 91 this.zoomToolStripMenuItem.Size = new System.Drawing.Size(1 03, 22);98 this.zoomToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 92 99 this.zoomToolStripMenuItem.Text = "&Zoom"; 93 100 this.zoomToolStripMenuItem.Click += new System.EventHandler(this.zoomToolStripMenuItem_Click); … … 96 103 // 97 104 this.selectToolStripMenuItem.Name = "selectToolStripMenuItem"; 98 this.selectToolStripMenuItem.Size = new System.Drawing.Size(1 03, 22);105 this.selectToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 99 106 this.selectToolStripMenuItem.Text = "&Select"; 100 107 this.selectToolStripMenuItem.Click += new System.EventHandler(this.selectToolStripMenuItem_Click); 101 //102 // toolStripMenuItem2103 //104 this.toolStripMenuItem2.Name = "toolStripMenuItem2";105 this.toolStripMenuItem2.Size = new System.Drawing.Size(100, 6);106 108 // 107 109 // BubbleChartControl … … 126 128 protected System.Windows.Forms.ToolStripMenuItem zoomToolStripMenuItem; 127 129 protected System.Windows.Forms.ToolStripMenuItem selectToolStripMenuItem; 128 pr otected System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;130 private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem; 129 131 130 132 } -
trunk/sources/HeuristicLab.CEDMA.Charting/BubbleChartControl.cs
r566 r567 34 34 private Bitmap bitmap; 35 35 private bool renderingRequired; 36 private Point mousePosition; 37 private Record clickedRecord; 36 38 private Point buttonDownPoint; 37 private Point mousePosition; 38 private int mouseClickCount; 39 private DateTime lastRendered = DateTime.Now; 39 40 40 private BubbleChart myChart; 41 41 public BubbleChart Chart { … … 82 82 83 83 private void pictureBox_MouseDown(object sender, MouseEventArgs e) { 84 clickedRecord = null; 84 85 buttonDownPoint = e.Location; 85 mouseClickCount = e.Clicks; 86 if(e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) { 87 clickedRecord = Chart.GetRecord(buttonDownPoint); 88 } 86 89 } 87 90 private void pictureBox_MouseUp(object sender, MouseEventArgs e) { … … 100 103 Chart.MouseDrag(lowerLeft, upperRight, e.Button); 101 104 } 105 } else if(Chart.Mode == ChartMode.Move) { 102 106 } 103 107 } else if(e.Button == MouseButtons.Middle) { 104 108 if(Chart.Mode == ChartMode.Zoom) { 105 if(mouseClickCount == 1) Chart.ZoomOut(); 106 else if(mouseClickCount == 2) Chart.Unzoom(); 109 Chart.ZoomOut(); 107 110 } 108 111 } … … 138 141 SetMode(ChartMode.Select); 139 142 } 143 private void moveToolStripMenuItem_Click(object sender, EventArgs e) { 144 SetMode(ChartMode.Move); 145 } 140 146 141 147 private void GenerateImage() { … … 162 168 zoomToolStripMenuItem.Checked = false; 163 169 selectToolStripMenuItem.Checked = false; 170 moveToolStripMenuItem.Checked = false; 164 171 if(mode == ChartMode.Zoom) zoomToolStripMenuItem.Checked = true; 165 172 else if(mode == ChartMode.Select) selectToolStripMenuItem.Checked = true; 173 else if(mode == ChartMode.Move) moveToolStripMenuItem.Checked = true; 166 174 Chart.Mode = mode; 167 175 } 168 176 169 177 private void pictureBox_MouseClick(object sender, MouseEventArgs e) { 170 Chart.MouseClick(e.Location, e.Button);178 if(clickedRecord != null) clickedRecord.ToggleSelected(); 171 179 } 172 180 173 181 private void pictureBox_MouseDoubleClick(object sender, MouseEventArgs e) { 174 Chart.MouseDoubleClick(e.Location, e.Button);182 if(clickedRecord != null) clickedRecord.OpenModel(); 175 183 } 176 184 } -
trunk/sources/HeuristicLab.CEDMA.Charting/HeuristicLab.CEDMA.Charting.csproj
r566 r567 73 73 <DependentUpon>BubbleChartControl.cs</DependentUpon> 74 74 </Compile> 75 <Compile Include="ModelView.cs"> 76 <SubType>UserControl</SubType> 77 </Compile> 78 <Compile Include="ModelView.Designer.cs"> 79 <DependentUpon>ModelView.cs</DependentUpon> 80 </Compile> 75 81 <Compile Include="Record.cs" /> 76 82 <Compile Include="HeuristicLabCedmaChartingPlugin.cs" /> … … 90 96 <Name>HeuristicLab.CEDMA.DB.Interfaces</Name> 91 97 </ProjectReference> 98 <ProjectReference Include="..\HeuristicLab.Charting.Data\HeuristicLab.Charting.Data.csproj"> 99 <Project>{E0740131-AA3E-4A3F-BA03-C9FF8327F4EE}</Project> 100 <Name>HeuristicLab.Charting.Data</Name> 101 </ProjectReference> 92 102 <ProjectReference Include="..\HeuristicLab.Charting\HeuristicLab.Charting.csproj"> 93 103 <Project>{B462D3CC-8866-42F0-9832-AD0967613B72}</Project> … … 97 107 <Project>{F43B59AB-2B8C-4570-BC1E-15592086517C}</Project> 98 108 <Name>HeuristicLab.Core</Name> 109 </ProjectReference> 110 <ProjectReference Include="..\HeuristicLab.DataAnalysis\HeuristicLab.DataAnalysis.csproj"> 111 <Project>{7DD3A97A-56E9-462F-90E2-A351FE7AF5C2}</Project> 112 <Name>HeuristicLab.DataAnalysis</Name> 113 </ProjectReference> 114 <ProjectReference Include="..\HeuristicLab.Data\HeuristicLab.Data.csproj"> 115 <Project>{F473D9AF-3F09-4296-9F28-3C65118DAFFA}</Project> 116 <Name>HeuristicLab.Data</Name> 117 </ProjectReference> 118 <ProjectReference Include="..\HeuristicLab.Functions\HeuristicLab.Functions.csproj"> 119 <Project>{B95CA6E2-34BC-4430-994D-BD6E99375319}</Project> 120 <Name>HeuristicLab.Functions</Name> 121 </ProjectReference> 122 <ProjectReference Include="..\HeuristicLab.Logging\HeuristicLab.Logging.csproj"> 123 <Project>{4095C92C-5A4C-44BC-9963-5F384CF5CC3F}</Project> 124 <Name>HeuristicLab.Logging</Name> 99 125 </ProjectReference> 100 126 <ProjectReference Include="..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj"> … … 110 136 <EmbeddedResource Include="BubbleChartControl.resx"> 111 137 <DependentUpon>BubbleChartControl.cs</DependentUpon> 138 <SubType>Designer</SubType> 139 </EmbeddedResource> 140 <EmbeddedResource Include="ModelView.resx"> 141 <DependentUpon>ModelView.cs</DependentUpon> 112 142 <SubType>Designer</SubType> 113 143 </EmbeddedResource> -
trunk/sources/HeuristicLab.CEDMA.Charting/Record.cs
r566 r567 68 68 public const string Y_JITTER = "__Y_JITTER"; 69 69 70 public event EventHandler OnSelectionChanged; 71 70 72 private Dictionary<string, double> values = new Dictionary<string, double>(); 71 public Dictionary<string, double> Values { 72 get { 73 return values; 74 } 75 } 73 private ResultList resultList; 76 74 77 75 private bool selected = false; … … 80 78 private string uri; 81 79 public string Uri { get { return uri; } } 82 public Record( string uri) {80 public Record(ResultList resultList, string uri) { 83 81 this.uri = uri; 82 this.resultList = resultList; 84 83 } 85 84 86 85 public void Set(string name, double value) { 87 Values.Add(name, value);86 values.Add(name, value); 88 87 } 89 88 90 89 public double Get(string name) { 91 if(name == null || ! Values.ContainsKey(name)) return double.NaN;92 return Values[name];90 if(name == null || !values.ContainsKey(name)) return double.NaN; 91 return values[name]; 93 92 } 94 93 … … 96 95 selected = !selected; 97 96 if(OnSelectionChanged != null) OnSelectionChanged(this, new EventArgs()); 97 resultList.FireChanged(); 98 98 } 99 99 100 public event EventHandler OnSelectionChanged; 100 internal string GetToolTipText() { 101 StringBuilder b = new StringBuilder(); 102 foreach(KeyValuePair<string, double> v in values) { 103 if(v.Key != X_JITTER && v.Key != Y_JITTER) { 104 b.Append(v.Key).Append(" = ").Append(v.Value).AppendLine(); 105 } 106 } 107 return b.ToString(); 108 } 109 110 internal void OpenModel() { 111 resultList.OpenModel(this); 112 } 101 113 } 102 114 } -
trunk/sources/HeuristicLab.CEDMA.Charting/ResultList.cs
r566 r567 31 31 using System.IO; 32 32 using HeuristicLab.PluginInfrastructure; 33 using HeuristicLab.Logging; 34 using HeuristicLab.Data; 35 using HeuristicLab.DataAnalysis; 36 using HeuristicLab.Functions; 37 using HeuristicLab.Charting.Data; 38 using System.Drawing; 33 39 34 40 namespace HeuristicLab.CEDMA.Charting { … … 55 61 private readonly Entity treeHeightPredicate = new Entity(cedmaNS + "TreeHeight"); 56 62 private readonly Entity rawDataPredicate = new Entity(cedmaNS + "rawData"); 63 private readonly Entity hasModelPredicate = new Entity(cedmaNS + "hasModel"); 57 64 private readonly Entity anyEntity = new Entity(null); 65 private Dictionary<Record, Dataset> datasets; 58 66 59 67 private IStore store; … … 102 110 foreach(Statement[] ss in results) { 103 111 if(ss.Length > 0) { 104 Record r = new Record( ss[0].Subject.Uri);112 Record r = new Record(this, ss[0].Subject.Uri); 105 113 r.Set(Record.X_JITTER, random.NextDouble() * 2.0 - 1.0); 106 114 r.Set(Record.Y_JITTER, random.NextDouble() * 2.0 - 1.0); … … 132 140 : base() { 133 141 records = new List<Record>(); 142 datasets = new Dictionary<Record, Dataset>(); 134 143 predicateToVariableName = new Dictionary<Entity, string>(); 135 144 predicateToVariableName[targetVariablePredicate] = Record.TARGET_VARIABLE; … … 148 157 } 149 158 150 internal void OpenModel(Record r ) {151 IList<Statement> s = store.Select(new Statement(new Entity(r.Uri), rawDataPredicate, anyEntity));152 if( s.Count == 1) {153 string rawData = ((SerializedLiteral) s[0].Property).RawData;159 internal void OpenModel(Record record) { 160 IList<Statement> modelResults = store.Select(new Statement(new Entity(record.Uri), rawDataPredicate, anyEntity)); 161 if(modelResults.Count == 1) { 162 string rawData = ((SerializedLiteral)modelResults[0].Property).RawData; 154 163 XmlDocument doc = new XmlDocument(); 155 164 doc.LoadXml(rawData); 156 IItem item = (IItem)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>()); 157 PluginManager.ControlManager.ShowControl(item.CreateView()); 165 IFunctionTree tree = (IFunctionTree)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>()); 166 int targetVariable = (int)record.Get(Record.TARGET_VARIABLE); 167 Dataset dataset = GetDataset(record); 168 169 ModelView modelView = new ModelView(dataset, tree, targetVariable); 170 PluginManager.ControlManager.ShowControl(modelView); 158 171 } 172 } 173 174 private Dataset GetDataset(Record record) { 175 if(!datasets.ContainsKey(record)) { 176 IList<Statement> result = store.Select(new Statement(anyEntity, hasModelPredicate, new Entity(record.Uri))); 177 if(result.Count == 1) { 178 IList<Statement> datasetResult = store.Select(new Statement(result[0].Subject, rawDataPredicate, anyEntity)); 179 if(datasetResult.Count == 1) { 180 string rawData = ((SerializedLiteral)datasetResult[0].Property).RawData; 181 XmlDocument doc = new XmlDocument(); 182 doc.LoadXml(rawData); 183 Dataset dataset = (Dataset)PersistenceManager.Restore(doc.ChildNodes[1], new Dictionary<Guid, IStorable>()); 184 datasets.Add(record, dataset); 185 } 186 } 187 } 188 return datasets[record]; 159 189 } 160 190 } -
trunk/sources/HeuristicLab.CEDMA.Charting/ResultListView.cs
r566 r567 15 15 private const string FREQUENCY = "<Frequency>"; 16 16 private const string CONSTANT_SIZE = "<constant>"; 17 private double xJitterFactor = 0.0;18 private double yJitterFactor = 0.0;19 private double maxXJitterPercent = .1;20 private double maxYJitterPercent = .1;21 17 22 18 public ResultListView(ResultList results) { … … 37 33 38 34 private void yAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) { 39 yJitterFactor = 0.0;40 yTrackBar.Value = 0;41 35 UpdateChart(); 42 36 } 43 37 44 38 private void xAxisComboBox_SelectedIndexChanged(object sender, EventArgs e) { 45 xJitterFactor = 0.0;46 xTrackBar.Value = 0;47 39 UpdateChart(); 48 40 }
Note: See TracChangeset
for help on using the changeset viewer.