Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13874


Ignore:
Timestamp:
06/06/16 14:48:09 (8 years ago)
Author:
bburlacu
Message:

#2288: Small refactoring.

Location:
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChart.Designer.cs

    r13789 r13874  
    3232      // pictureBox
    3333      //
    34       //this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
     34      this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
    3535      //
    3636      // toolTip
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChart.cs

    r13821 r13874  
    2626using System.Linq;
    2727using System.Windows.Forms;
     28using HeuristicLab.Common;
    2829using HeuristicLab.Core;
    2930using HeuristicLab.Random;
     
    3637namespace HeuristicLab.VariableInteractionNetworks.Views {
    3738  public partial class DirectedGraphChart : ChartControl {
     39    public new Bitmap Picture { get { return base.Picture; } }
     40
    3841    private ConstrainedForceDirectedLayout layout;
    3942    // provide direct and reverse mapping between graph objects and layout shapes
     
    147150        shape.Move(new Offset(pos.X, pos.Y));
    148151      }
    149 
     152      var colors = ColorGradient.GrayscaledColors;
    150153      foreach (var pair in arcRoutes) {
    151154        var arc = pair.Key;
     
    155158        var len = points.Length; // len = 2 when no edge routingMode is performed
    156159        Pen pen;
    157         var penWidth = weight / max * 2;
     160        var penWidth = weight / max * 3;
     161        //var penColor = colors[(int)Math.Min(255, weight / max * 255)];
     162        var penColor = Color.Black;
    158163        if (len == 2) {
    159164          if (double.IsInfinity(penWidth) || double.IsNaN(penWidth)) penWidth = 1;
    160           pen = new Pen(Color.Black, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) };
     165          pen = new Pen(penColor, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) };
    161166          var start = points[0];
    162167          var end = points[1];
     
    198203            if (intersectionPoints.Any()) {
    199204              endPoint = intersectionPoints.First();
    200               pen = new Pen(Color.Black, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) };
     205              pen = new Pen(penColor, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) };
    201206            } else {
    202207              endPoint = end;
    203               pen = new Pen(Color.Black, (float)penWidth);
     208              pen = new Pen(penColor, (float)penWidth);
    204209            }
    205210            line = new Line(Chart, new PointD(start.X, start.Y), endPoint, pen) { ToolTipText = arc.Label };
     
    226231    }
    227232
    228     private Dictionary<Type, LabeledPrimitive> shapes;
     233    private readonly Dictionary<Type, LabeledPrimitive> shapes;
    229234    public void AddShape(Type t, LabeledPrimitive shape) {
    230235      shapes[t] = shape;
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.Designer.cs

    r13821 r13874  
    1 using System.Globalization;
    2 
    3 namespace HeuristicLab.VariableInteractionNetworks.Views {
     1namespace HeuristicLab.VariableInteractionNetworks.Views {
    42  partial class RunCollectionVariableInteractionNetworkView {
    53    /// <summary>
     
    5250      // settingsGroupBox
    5351      //
    54       this.settingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     52      this.settingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    5553            | System.Windows.Forms.AnchorStyles.Left)));
    5654      this.settingsGroupBox.Controls.Add(this.onlineImpactCalculationButton);
     
    116114      this.impactThresholdTextBox.Size = new System.Drawing.Size(201, 20);
    117115      this.impactThresholdTextBox.TabIndex = 2;
    118       this.impactThresholdTextBox.Text = 0.2.ToString(CultureInfo.CurrentCulture);
     116      this.impactThresholdTextBox.Text = "0.2";
    119117      this.impactThresholdTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.TextBoxValidating);
    120118      this.impactThresholdTextBox.Validated += new System.EventHandler(this.ImpactThresholdTextBoxValidated);
     
    171169      // layoutOptionsGroupBox
    172170      //
    173       this.layoutOptionsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     171      this.layoutOptionsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    174172            | System.Windows.Forms.AnchorStyles.Left)));
    175173      this.layoutOptionsGroupBox.Controls.Add(this.idealEdgeLengthTextBox);
     
    232230      // graphChart
    233231      //
    234       this.graphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    235             | System.Windows.Forms.AnchorStyles.Left)
     232      this.graphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     233            | System.Windows.Forms.AnchorStyles.Left) 
    236234            | System.Windows.Forms.AnchorStyles.Right)));
    237235      this.graphChart.BackColor = System.Drawing.SystemColors.Control;
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.cs

    r13821 r13874  
    233233          var junctionLabel = Concatenate(variableList);
    234234          IVertex junctionNode;
     235          var sb = new StringBuilder();
    235236          if (!nodes.TryGetValue(junctionLabel, out junctionNode)) {
    236237            var solutionsEnsemble = CreateEnsembleSolution(targetRuns);
    237             junctionNode = new JunctionNetworkNode { Label = string.Empty, Data = solutionsEnsemble };
     238            junctionNode = new JunctionNetworkNode { Label = solutionsEnsemble.TrainingRSquared.ToString("N3", CultureInfo.CurrentCulture), Data = solutionsEnsemble };
    238239            vn.AddVertex(junctionNode);
    239240            nodes[junctionLabel] = junctionNode;
    240             junctionNode.Label = solutionsEnsemble.TrainingRSquared.ToString("N3", CultureInfo.CurrentCulture);
     241            sb.AppendLine(junctionNode.Label);
    241242          }
    242243          IArc arc;
     
    249250            }
    250251            arc = new Arc(variableNode, junctionNode) { Weight = impact, Label = impact.ToString("N3", CultureInfo.CurrentCulture) };
     252            sb.AppendLine(v + ": " + arc.Label);
    251253            vn.AddArc(arc);
    252254          }
    253           var trainingR2 = ((IRegressionSolution)((JunctionNetworkNode)junctionNode).Data).TrainingRSquared;
     255          var jcnNode = (JunctionNetworkNode)junctionNode;
     256          var trainingR2 = ((IRegressionSolution)jcnNode.Data).TrainingRSquared;
    254257          arc = new Arc(junctionNode, targetNode) { Weight = junctionNode.InArcs.Sum(x => x.Weight), Label = trainingR2.ToString("N3", CultureInfo.CurrentCulture) };
    255258          vn.AddArc(arc);
     
    394397      errorProvider.SetError(tb, string.Empty);
    395398      double impact;
    396       if (!double.TryParse(tb.Text, out impact))
     399      if (!double.TryParse(tb.Text, out impact)) {
    397400        impact = 0.2;
     401      }
    398402      var network = ApplyThreshold(variableInteractionNetwork, impact);
    399403      graphChart.Graph = network;
     
    443447    }
    444448
     449    private void ControlsEnable(bool enabled) {
     450      qualityResultNameComboBox.Enabled
     451        = impactResultNameComboBox.Enabled
     452        = impactAggregationComboBox.Enabled
     453        = impactThresholdTextBox.Enabled
     454        = onlineImpactCalculationButton.Enabled
     455        = edgeRoutingComboBox.Enabled
     456        = idealEdgeLengthTextBox.Enabled = enabled;
     457    }
     458
    445459    private void onlineImpactCalculationButton_Click(object sender, EventArgs args) {
    446       var button = (Button)sender;
    447460      var worker = new BackgroundWorker();
    448461      worker.DoWork += (o, e) => {
    449         button.Enabled = false;
     462        ControlsEnable(false);
    450463        var impacts = CalculateVariableImpactsOnline(Content, false);
    451464        variableInteractionNetwork = CreateNetwork(impacts);
     
    453466        graphChart.Graph = ApplyThreshold(variableInteractionNetwork, threshold);
    454467      };
    455       worker.RunWorkerCompleted += (o, e) => button.Enabled = true;
     468      worker.RunWorkerCompleted += (o, e) => ControlsEnable(true);
    456469      worker.RunWorkerAsync();
    457470    }
Note: See TracChangeset for help on using the changeset viewer.