Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1337


Ignore:
Timestamp:
03/12/09 19:26:27 (15 years ago)
Author:
bspisic
Message:

#520 Implemented font changes of x-axis, legend and title

Location:
trunk/sources/HeuristicLab.Visualization
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/HeuristicLab.Visualization.csproj

    r1325 r1337  
    100100      <DependentUpon>OptionsDialog.cs</DependentUpon>
    101101    </Compile>
     102    <Compile Include="Options\ViewPropertiesModel.cs" />
    102103    <Compile Include="PanListener.cs" />
    103104    <Compile Include="LabelProvider\StringLabelProvider.cs" />
  • trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs

    r1240 r1337  
    11using System.Collections.Generic;
    2 using HeuristicLab.Visualization.Legend;
     2using System.Drawing;
    33
    44namespace HeuristicLab.Visualization.Legend {
    55  public class LegendShape : WorldShape {
    66    private readonly IList<LegendItem> legendItems = new List<LegendItem>();
    7    
     7
     8    private Color color = Color.Blue;
     9    private Font font = new Font("Arial", 8);
     10
    811    public LegendShape() {
    912      CreateLegend();
     
    1518      foreach (LegendItem item in legendItems) {
    1619        AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
    17         AddShape(new TextShape(35, y, item.Label));
     20        AddShape(new TextShape(35, y, item.Label, font, color));
    1821        y -= 15;
    1922      }
     
    3134      legendItems.Clear();
    3235    }
     36
     37    public Color Color {
     38      get { return color; }
     39      set {
     40        color = value;
     41        UpdateTextShapes();
     42      }
     43    }
     44
     45    public Font Font {
     46      get { return font; }
     47      set {
     48        font = value;
     49        UpdateTextShapes();
     50      }
     51    }
     52
     53    private void UpdateTextShapes() {
     54      foreach (IShape shape in shapes) {
     55        TextShape textShape = shape as TextShape;
     56
     57        if (textShape != null) {
     58          textShape.Font = font;
     59          textShape.Color = color;
     60        }
     61      }
     62    }
    3363  }
    3464}
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1328 r1337  
    2929    private bool zoomToFullView;
    3030
     31    private readonly ViewPropertiesModel viewPropertiesModel;
     32
    3133    /// <summary>
    3234    /// This constructor shouldn't be called. Only required for the designer.
     
    3436    public LineChart() {
    3537      InitializeComponent();
    36     }
    37 
    38     public TextShape Title {
    39       get { return titleShape; }
    40     }
    41 
    42     public LegendShape Legend {
    43       get { return legendShape; }
    4438    }
    4539
     
    5650
    5751      this.model = model;
     52      viewPropertiesModel = new ViewPropertiesModel(titleShape.Font, titleShape.Color, legendShape.Font, legendShape.Color, xAxis.Font, xAxis.Color);
     53      viewPropertiesModel.OnUpdateProperties += UpdateViewProperties;
    5854
    5955      Item = model;
     
    6359
    6460      ZoomToFullView();
     61    }
     62
     63    private void UpdateViewProperties() {
     64      titleShape.Font = viewPropertiesModel.TitleFont;
     65      titleShape.Color = viewPropertiesModel.TitleColor;
     66
     67      legendShape.Font = viewPropertiesModel.LegendFont;
     68      legendShape.Color = viewPropertiesModel.LegendColor;
     69
     70      xAxis.Font = viewPropertiesModel.XAxisFont;
     71      xAxis.Color = viewPropertiesModel.XAxisColor;
     72
     73      canvasUI.Invalidate();
    6574    }
    6675
     
    136145
    137146    private void optionsToolStripMenuItem_Click(object sender, EventArgs e) {
    138       OptionsDialog optionsdlg = new OptionsDialog(this.model, this);
     147      OptionsDialog optionsdlg = new OptionsDialog(this.model, viewPropertiesModel);
    139148      optionsdlg.ShowDialog(this);
    140149    }
  • trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.Designer.cs

    r1328 r1337  
    3131      this.btnChangeTitleFont = new System.Windows.Forms.Button();
    3232      this.tabPage2 = new System.Windows.Forms.TabPage();
     33      this.btnChangeLegendFont = new System.Windows.Forms.Button();
     34      this.labelposition = new System.Windows.Forms.Label();
    3335      this.cbLabelPosition = new System.Windows.Forms.ComboBox();
    34       this.labelposition = new System.Windows.Forms.Label();
    3536      this.tabPage1 = new System.Windows.Forms.TabPage();
     37      this.OptionsDialogSelectColorBt = new System.Windows.Forms.Button();
     38      this.ColorPreviewTB = new System.Windows.Forms.TextBox();
     39      this.label2 = new System.Windows.Forms.Label();
     40      this.LinestyleCB = new System.Windows.Forms.ComboBox();
     41      this.label1 = new System.Windows.Forms.Label();
     42      this.LineSelectCB = new System.Windows.Forms.ComboBox();
    3643      this.groupBox1 = new System.Windows.Forms.GroupBox();
     44      this.label4 = new System.Windows.Forms.Label();
     45      this.LineThicknessCB = new System.Windows.Forms.ComboBox();
    3746      this.label3 = new System.Windows.Forms.Label();
    38       this.LineThicknessCB = new System.Windows.Forms.ComboBox();
    39       this.label4 = new System.Windows.Forms.Label();
    40       this.LineSelectCB = new System.Windows.Forms.ComboBox();
    41       this.label1 = new System.Windows.Forms.Label();
    42       this.LinestyleCB = new System.Windows.Forms.ComboBox();
    43       this.label2 = new System.Windows.Forms.Label();
    44       this.ColorPreviewTB = new System.Windows.Forms.TextBox();
    45       this.OptionsDialogSelectColorBt = new System.Windows.Forms.Button();
    4647      this.Optionstabs = new System.Windows.Forms.TabControl();
    47       this.btnChangeLegendFont = new System.Windows.Forms.Button();
     48      this.tpXAxis = new System.Windows.Forms.TabPage();
     49      this.btnChangeXAxisFont = new System.Windows.Forms.Button();
    4850      this.tpTitle.SuspendLayout();
    4951      this.tabPage2.SuspendLayout();
     
    5153      this.groupBox1.SuspendLayout();
    5254      this.Optionstabs.SuspendLayout();
     55      this.tpXAxis.SuspendLayout();
    5356      this.SuspendLayout();
    5457      //
     
    119122      this.tabPage2.Text = "Legend";
    120123      this.tabPage2.UseVisualStyleBackColor = true;
     124      //
     125      // btnChangeLegendFont
     126      //
     127      this.btnChangeLegendFont.Location = new System.Drawing.Point(3, 6);
     128      this.btnChangeLegendFont.Name = "btnChangeLegendFont";
     129      this.btnChangeLegendFont.Size = new System.Drawing.Size(94, 23);
     130      this.btnChangeLegendFont.TabIndex = 2;
     131      this.btnChangeLegendFont.Text = "Change Font";
     132      this.btnChangeLegendFont.UseVisualStyleBackColor = true;
     133      this.btnChangeLegendFont.Click += new System.EventHandler(this.btnChangeLegendFont_Click);
     134      //
     135      // labelposition
     136      //
     137      this.labelposition.AutoSize = true;
     138      this.labelposition.Location = new System.Drawing.Point(3, 47);
     139      this.labelposition.Name = "labelposition";
     140      this.labelposition.Size = new System.Drawing.Size(72, 13);
     141      this.labelposition.TabIndex = 1;
     142      this.labelposition.Text = "Labelposition:";
    121143      //
    122144      // cbLabelPosition
     
    133155      this.cbLabelPosition.Size = new System.Drawing.Size(121, 21);
    134156      this.cbLabelPosition.TabIndex = 0;
    135       //
    136       // labelposition
    137       //
    138       this.labelposition.AutoSize = true;
    139       this.labelposition.Location = new System.Drawing.Point(3, 47);
    140       this.labelposition.Name = "labelposition";
    141       this.labelposition.Size = new System.Drawing.Size(72, 13);
    142       this.labelposition.TabIndex = 1;
    143       this.labelposition.Text = "Labelposition:";
    144157      //
    145158      // tabPage1
     
    160173      this.tabPage1.UseVisualStyleBackColor = true;
    161174      //
     175      // OptionsDialogSelectColorBt
     176      //
     177      this.OptionsDialogSelectColorBt.Location = new System.Drawing.Point(217, 126);
     178      this.OptionsDialogSelectColorBt.Name = "OptionsDialogSelectColorBt";
     179      this.OptionsDialogSelectColorBt.Size = new System.Drawing.Size(50, 23);
     180      this.OptionsDialogSelectColorBt.TabIndex = 7;
     181      this.OptionsDialogSelectColorBt.Text = "Select";
     182      this.OptionsDialogSelectColorBt.UseVisualStyleBackColor = true;
     183      this.OptionsDialogSelectColorBt.Click += new System.EventHandler(this.OptionsDialogSelectColorBtn_Click);
     184      //
     185      // ColorPreviewTB
     186      //
     187      this.ColorPreviewTB.Location = new System.Drawing.Point(146, 127);
     188      this.ColorPreviewTB.Name = "ColorPreviewTB";
     189      this.ColorPreviewTB.ReadOnly = true;
     190      this.ColorPreviewTB.Size = new System.Drawing.Size(64, 20);
     191      this.ColorPreviewTB.TabIndex = 6;
     192      //
     193      // label2
     194      //
     195      this.label2.AutoSize = true;
     196      this.label2.Location = new System.Drawing.Point(36, 80);
     197      this.label2.Name = "label2";
     198      this.label2.Size = new System.Drawing.Size(30, 13);
     199      this.label2.TabIndex = 3;
     200      this.label2.Text = "Style";
     201      //
     202      // LinestyleCB
     203      //
     204      this.LinestyleCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     205      this.LinestyleCB.FormattingEnabled = true;
     206      this.LinestyleCB.Location = new System.Drawing.Point(146, 73);
     207      this.LinestyleCB.Name = "LinestyleCB";
     208      this.LinestyleCB.Size = new System.Drawing.Size(121, 21);
     209      this.LinestyleCB.TabIndex = 2;
     210      //
     211      // label1
     212      //
     213      this.label1.AutoSize = true;
     214      this.label1.Location = new System.Drawing.Point(7, 37);
     215      this.label1.Name = "label1";
     216      this.label1.Size = new System.Drawing.Size(72, 13);
     217      this.label1.TabIndex = 1;
     218      this.label1.Text = "Selected Line";
     219      //
     220      // LineSelectCB
     221      //
     222      this.LineSelectCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     223      this.LineSelectCB.FormattingEnabled = true;
     224      this.LineSelectCB.Location = new System.Drawing.Point(146, 30);
     225      this.LineSelectCB.Name = "LineSelectCB";
     226      this.LineSelectCB.Size = new System.Drawing.Size(121, 21);
     227      this.LineSelectCB.TabIndex = 0;
     228      this.LineSelectCB.SelectedIndexChanged += new System.EventHandler(this.LineSelectCB_SelectedIndexChanged);
     229      //
    162230      // groupBox1
    163231      //
     
    172240      this.groupBox1.Text = "Details";
    173241      //
     242      // label4
     243      //
     244      this.label4.AutoSize = true;
     245      this.label4.Location = new System.Drawing.Point(33, 77);
     246      this.label4.Name = "label4";
     247      this.label4.Size = new System.Drawing.Size(31, 13);
     248      this.label4.TabIndex = 8;
     249      this.label4.Text = "Color";
     250      //
     251      // LineThicknessCB
     252      //
     253      this.LineThicknessCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     254      this.LineThicknessCB.FormattingEnabled = true;
     255      this.LineThicknessCB.Location = new System.Drawing.Point(142, 46);
     256      this.LineThicknessCB.Name = "LineThicknessCB";
     257      this.LineThicknessCB.Size = new System.Drawing.Size(121, 21);
     258      this.LineThicknessCB.TabIndex = 4;
     259      //
    174260      // label3
    175261      //
     
    181267      this.label3.Text = "Thickness";
    182268      //
    183       // LineThicknessCB
    184       //
    185       this.LineThicknessCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    186       this.LineThicknessCB.FormattingEnabled = true;
    187       this.LineThicknessCB.Location = new System.Drawing.Point(142, 46);
    188       this.LineThicknessCB.Name = "LineThicknessCB";
    189       this.LineThicknessCB.Size = new System.Drawing.Size(121, 21);
    190       this.LineThicknessCB.TabIndex = 4;
    191       //
    192       // label4
    193       //
    194       this.label4.AutoSize = true;
    195       this.label4.Location = new System.Drawing.Point(33, 77);
    196       this.label4.Name = "label4";
    197       this.label4.Size = new System.Drawing.Size(31, 13);
    198       this.label4.TabIndex = 8;
    199       this.label4.Text = "Color";
    200       //
    201       // LineSelectCB
    202       //
    203       this.LineSelectCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    204       this.LineSelectCB.FormattingEnabled = true;
    205       this.LineSelectCB.Location = new System.Drawing.Point(146, 30);
    206       this.LineSelectCB.Name = "LineSelectCB";
    207       this.LineSelectCB.Size = new System.Drawing.Size(121, 21);
    208       this.LineSelectCB.TabIndex = 0;
    209       this.LineSelectCB.SelectedIndexChanged += new System.EventHandler(this.LineSelectCB_SelectedIndexChanged);
    210       //
    211       // label1
    212       //
    213       this.label1.AutoSize = true;
    214       this.label1.Location = new System.Drawing.Point(7, 37);
    215       this.label1.Name = "label1";
    216       this.label1.Size = new System.Drawing.Size(72, 13);
    217       this.label1.TabIndex = 1;
    218       this.label1.Text = "Selected Line";
    219       //
    220       // LinestyleCB
    221       //
    222       this.LinestyleCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    223       this.LinestyleCB.FormattingEnabled = true;
    224       this.LinestyleCB.Location = new System.Drawing.Point(146, 73);
    225       this.LinestyleCB.Name = "LinestyleCB";
    226       this.LinestyleCB.Size = new System.Drawing.Size(121, 21);
    227       this.LinestyleCB.TabIndex = 2;
    228       //
    229       // label2
    230       //
    231       this.label2.AutoSize = true;
    232       this.label2.Location = new System.Drawing.Point(36, 80);
    233       this.label2.Name = "label2";
    234       this.label2.Size = new System.Drawing.Size(30, 13);
    235       this.label2.TabIndex = 3;
    236       this.label2.Text = "Style";
    237       //
    238       // ColorPreviewTB
    239       //
    240       this.ColorPreviewTB.Location = new System.Drawing.Point(146, 127);
    241       this.ColorPreviewTB.Name = "ColorPreviewTB";
    242       this.ColorPreviewTB.ReadOnly = true;
    243       this.ColorPreviewTB.Size = new System.Drawing.Size(64, 20);
    244       this.ColorPreviewTB.TabIndex = 6;
    245       //
    246       // OptionsDialogSelectColorBt
    247       //
    248       this.OptionsDialogSelectColorBt.Location = new System.Drawing.Point(217, 126);
    249       this.OptionsDialogSelectColorBt.Name = "OptionsDialogSelectColorBt";
    250       this.OptionsDialogSelectColorBt.Size = new System.Drawing.Size(50, 23);
    251       this.OptionsDialogSelectColorBt.TabIndex = 7;
    252       this.OptionsDialogSelectColorBt.Text = "Select";
    253       this.OptionsDialogSelectColorBt.UseVisualStyleBackColor = true;
    254       this.OptionsDialogSelectColorBt.Click += new System.EventHandler(this.OptionsDialogSelectColorBtn_Click);
    255       //
    256269      // Optionstabs
    257270      //
     
    259272      this.Optionstabs.Controls.Add(this.tabPage2);
    260273      this.Optionstabs.Controls.Add(this.tpTitle);
     274      this.Optionstabs.Controls.Add(this.tpXAxis);
    261275      this.Optionstabs.Location = new System.Drawing.Point(0, 1);
    262276      this.Optionstabs.Name = "Optionstabs";
     
    265279      this.Optionstabs.TabIndex = 0;
    266280      //
    267       // btnChangeLegendFont
    268       //
    269       this.btnChangeLegendFont.Location = new System.Drawing.Point(3, 6);
    270       this.btnChangeLegendFont.Name = "btnChangeLegendFont";
    271       this.btnChangeLegendFont.Size = new System.Drawing.Size(94, 23);
    272       this.btnChangeLegendFont.TabIndex = 2;
    273       this.btnChangeLegendFont.Text = "Change Font";
    274       this.btnChangeLegendFont.UseVisualStyleBackColor = true;
    275       this.btnChangeLegendFont.Click += new System.EventHandler(this.btnChangeLegendFont_Click);
     281      // tpXAxis
     282      //
     283      this.tpXAxis.Controls.Add(this.btnChangeXAxisFont);
     284      this.tpXAxis.Location = new System.Drawing.Point(4, 22);
     285      this.tpXAxis.Name = "tpXAxis";
     286      this.tpXAxis.Size = new System.Drawing.Size(284, 199);
     287      this.tpXAxis.TabIndex = 3;
     288      this.tpXAxis.Text = "X-Axis";
     289      this.tpXAxis.UseVisualStyleBackColor = true;
     290      //
     291      // btnChangeXAxisFont
     292      //
     293      this.btnChangeXAxisFont.Location = new System.Drawing.Point(3, 3);
     294      this.btnChangeXAxisFont.Name = "btnChangeXAxisFont";
     295      this.btnChangeXAxisFont.Size = new System.Drawing.Size(94, 23);
     296      this.btnChangeXAxisFont.TabIndex = 2;
     297      this.btnChangeXAxisFont.Text = "Change Font";
     298      this.btnChangeXAxisFont.UseVisualStyleBackColor = true;
     299      this.btnChangeXAxisFont.Click += new System.EventHandler(this.btnChangeXAxisFont_Click);
    276300      //
    277301      // OptionsDialog
     
    297321      this.groupBox1.PerformLayout();
    298322      this.Optionstabs.ResumeLayout(false);
     323      this.tpXAxis.ResumeLayout(false);
    299324      this.ResumeLayout(false);
    300325
     
    325350    private System.Windows.Forms.TabControl Optionstabs;
    326351    private System.Windows.Forms.Button btnChangeLegendFont;
     352    private System.Windows.Forms.TabPage tpXAxis;
     353    private System.Windows.Forms.Button btnChangeXAxisFont;
    327354  }
    328355}
  • trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs

    r1328 r1337  
    66  public partial class OptionsDialog : Form {
    77    private readonly IChartDataRowsModel model;
    8     private readonly LineChart lineChart;
     8    private readonly ViewPropertiesModel propertiesModel;
    99
    10     public OptionsDialog(IChartDataRowsModel model, LineChart lineChart) {
     10    public OptionsDialog(IChartDataRowsModel model, ViewPropertiesModel propertiesModel) {
    1111      InitializeComponent();
     12
    1213      this.model = model;
    13       this.lineChart = lineChart;
     14      this.propertiesModel = propertiesModel;
    1415    }
    1516
     
    7172        ((IDataRow)LineSelectCB.SelectedValue).Style = (DrawingStyle)LinestyleCB.SelectedItem;
    7273      }
    73 
    74       lineChart.Invalidate(true);
    7574    }
    7675
    7776    private void btnChangeTitleFont_Click(object sender, EventArgs e) {
    78       fdFont.Font = lineChart.Title.Font;
    79       fdFont.Color = lineChart.Title.Color;
     77      fdFont.Font = propertiesModel.TitleFont;
     78      fdFont.Color = propertiesModel.TitleColor;
    8079
    8180      DialogResult dr = fdFont.ShowDialog();
    8281
    8382      if(dr == DialogResult.OK) {
    84         lineChart.Title.Font = fdFont.Font;
    85         lineChart.Title.Color = fdFont.Color;
     83        propertiesModel.TitleFont = fdFont.Font;
     84        propertiesModel.TitleColor = fdFont.Color;
     85
     86        propertiesModel.UpdateView();
    8687      }
    8788    }
    8889
    8990    private void btnChangeLegendFont_Click(object sender, EventArgs e) {
    90 //      fdFont.Font = lineChart.Legend.Font;
    91 //      fdFont.Color = lineChart.Legend.Color;
     91      fdFont.Font = propertiesModel.LegendFont;
     92      fdFont.Color = propertiesModel.LegendColor;
    9293
    9394      DialogResult dr = fdFont.ShowDialog();
    9495
    9596      if (dr == DialogResult.OK) {
    96 //        lineChart.Legend.Font = fdFont.Font;
    97 //        lineChart.Legend.Color = fdFont.Color;
     97        propertiesModel.LegendFont = fdFont.Font;
     98        propertiesModel.LegendColor = fdFont.Color;
     99
     100        propertiesModel.UpdateView();
     101      }
     102    }
     103
     104    private void btnChangeXAxisFont_Click(object sender, EventArgs e) {
     105      fdFont.Font = propertiesModel.XAxisFont;
     106      fdFont.Color = propertiesModel.XAxisColor;
     107
     108      DialogResult dr = fdFont.ShowDialog();
     109
     110      if (dr == DialogResult.OK) {
     111        propertiesModel.XAxisFont = fdFont.Font;
     112        propertiesModel.XAxisColor = fdFont.Color;
     113
     114        propertiesModel.UpdateView();
    98115      }
    99116    }
  • trunk/sources/HeuristicLab.Visualization/TextShape.cs

    r1328 r1337  
    3434
    3535      Color = Color.Blue;
     36    }
     37
     38    public TextShape(double x, double y, string text, Font font, Color color) {
     39      this.x = x;
     40      this.y = y;
     41      this.text = text;
     42      Font = font;
     43      Color = color;
    3644    }
    3745
  • trunk/sources/HeuristicLab.Visualization/XAxis.cs

    r1240 r1337  
    77   
    88    private ILabelProvider labelProvider = new ContinuousLabelProvider("0.####");
     9
     10    private Color color = Color.Blue;
     11    private Font font = new Font("Arial", 8);
    912
    1013    public ILabelProvider LabelProvider {
     
    2023                                              ClippingArea.X1)) {
    2124        TextShape label = new TextShape(x, ClippingArea.Height - 3,
    22                                         labelProvider.GetLabel(x));
     25                                        labelProvider.GetLabel(x), Font, Color);
    2326        label.AnchorPositionX = AnchorPositionX.Middle;
    2427        label.AnchorPositionY = AnchorPositionY.Top;
     
    2831      base.Draw(graphics);
    2932    }
     33
     34    public Color Color {
     35      get { return color; }
     36      set { color = value; }
     37    }
     38
     39    public Font Font {
     40      get { return font; }
     41      set { font = value; }
     42    }
    3043  }
    3144}
Note: See TracChangeset for help on using the changeset viewer.