Changeset 1559


Ignore:
Timestamp:
04/14/09 21:59:13 (12 years ago)
Author:
dwagner
Message:

Added functionality: Markers on every datapoint. (#581)

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/CompositeShape.cs

    r1530 r1559  
    66  public class CompositeShape : IShape {
    77    private IShape parent;
     8    private bool showChildShapes = true;
    89
    910    protected readonly List<IShape> shapes = new List<IShape>();
    1011    protected RectangleD boundingBox = RectangleD.Empty;
    1112
     13
     14
    1215    public virtual void Draw(Graphics graphics) {
     16      if(!showChildShapes)
     17        return;
    1318      foreach (IShape shape in shapes) {
    1419        shape.Draw(graphics);
     
    3944    }
    4045
     46    public bool ShowChildShapes {
     47      get { return showChildShapes; }
     48      set { showChildShapes = value; }
     49    }
     50
    4151    public void ClearShapes() {
    4252      shapes.Clear();
    4353      boundingBox = RectangleD.Empty;
     54    }
     55
     56    public IShape GetShape(int index) {
     57      return shapes[index];
    4458    }
    4559
  • trunk/sources/HeuristicLab.Visualization/3.2/HeuristicLab.Visualization-3.2.csproj

    r1534 r1559  
    110110    <Compile Include="IMouseEventListener.cs" />
    111111    <Compile Include="Legend\LegendItem.cs" />
     112    <Compile Include="MarkerShape.cs" />
    112113    <Compile Include="MaxAggregator.cs" />
    113114    <Compile Include="MinAggregator.cs" />
  • trunk/sources/HeuristicLab.Visualization/3.2/LineChart.cs

    r1530 r1559  
    22using System.Collections.Generic;
    33using System.Drawing;
     4using System.Drawing.Drawing2D;
    45using System.Windows.Forms;
    56using HeuristicLab.Core;
     
    391392          LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style);
    392393          rowEntry.LinesShape.AddShape(lineShape);
    393         }
     394          rowEntry.LinesShape.AddMarkerShape(new MarkerShape(i-1,row[i-1],8,row.Color));
     395        }
     396        if(row.Count>0)
     397          rowEntry.LinesShape.AddMarkerShape(new MarkerShape((row.Count - 1), row[(row.Count - 1)], 8, row.Color));
    394398      }
    395399
     
    405409                                                        row.Style);
    406410          rowEntry.LinesShape.AddShape(lineShape);
     411         
    407412        } else {
    408413          LineShape lineShape = rowEntry.LinesShape.GetShape(0);
     
    411416        }
    412417      } else {
    413         if (index > rowEntry.LinesShape.Count + 1) {
     418        if (index > rowEntry.LinesShape.Count + 1) {    //MarkersShape is on position zero
    414419          throw new NotImplementedException();
    415420        }
     
    419424          LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness, row.Style);
    420425          rowEntry.LinesShape.AddShape(lineShape);
     426          rowEntry.LinesShape.AddMarkerShape(new MarkerShape(index, row[index ], 8, row.Color));
    421427        }
    422428
     
    424430        if (index > 0) {
    425431          rowEntry.LinesShape.GetShape(index - 1).Y2 = value;
     432          ((MarkerShape)rowEntry.LinesShape.markersShape.GetShape(index - 1)).Y = value;
    426433        }
    427434
     
    429436        if (index > 0 && index < row.Count - 1) {
    430437          rowEntry.LinesShape.GetShape(index).Y1 = value;
     438          ((MarkerShape)rowEntry.LinesShape.markersShape.GetShape(index)).Y = value;
    431439        }
    432440      }
     
    583591
    584592    private class LinesShape : WorldShape {
     593      public readonly CompositeShape markersShape = new CompositeShape();
     594
    585595      public void UpdateStyle(IDataRow row) {
    586596        foreach (IShape shape in shapes) {
     
    594604      }
    595605
     606      public override void Draw(Graphics graphics) {
     607        GraphicsState gstate = graphics.Save();
     608
     609        graphics.SetClip(Viewport);
     610        foreach (IShape shape in shapes) {
     611          // draw child shapes using our own clipping area
     612          shape.Draw(graphics);
     613        }
     614        markersShape.Draw(graphics);
     615        graphics.Restore(gstate);
     616      }
     617
     618      public void AddMarkerShape(IShape shape) {
     619        shape.Parent = this;
     620        markersShape.AddShape(shape);
     621      }
     622
    596623      public int Count {
    597624        get { return shapes.Count; }
     
    599626
    600627      public LineShape GetShape(int index) {
    601         return (LineShape)shapes[index];
     628        return (LineShape)shapes[index];     //shapes[0] is markersShape!!
    602629      }
    603630    }
     
    610637      public RowEntry(IDataRow dataRow) {
    611638        this.dataRow = dataRow;
     639        linesShape.markersShape.Parent = linesShape;
    612640      }
    613641
     
    619647        get { return linesShape; }
    620648      }
    621     }
    622 
    623     private class YAxisInfo {
     649
     650      public void hideMarkers() {
     651        linesShape.markersShape.ShowChildShapes = false;
     652      }
     653
     654      public void showMarkers() {
     655        linesShape.markersShape.ShowChildShapes = true;
     656      }
     657    }
     658
     659    private class YAxisInfo {
    624660      private readonly Grid grid = new Grid();
    625661      private readonly YAxis yAxis = new YAxis();
Note: See TracChangeset for help on using the changeset viewer.