#region License Information /* HeuristicLab * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Drawing; namespace HeuristicLab.Visualization { public abstract class AxisPrimitiveBase : PrimitiveBase { private AxisType myAxisType; public AxisType AxisType { get { return myAxisType; } } private PointD myPoint; public virtual PointD Point { get { return myPoint; } } private bool myShowGrid; public bool ShowGrid { get { return myShowGrid; } set { if (value != myShowGrid) { myShowGrid = value; OnRedrawRequired(); } } } private string myHorizontalLabel; public string HorizontalLabel { get { return myHorizontalLabel; } set { if (value != myHorizontalLabel) { myHorizontalLabel = value; OnRedrawRequired(); } } } private string myVerticalLabel; public string VerticalLabel { get { return myVerticalLabel; } set { if (value != myVerticalLabel) { myVerticalLabel = value; OnRedrawRequired(); } } } protected AxisPrimitiveBase(IChart chart, PointD point, AxisType axisType) : this(chart, point, axisType, Pens.Black, Brushes.Black) { } protected AxisPrimitiveBase(IChart chart, PointD point, AxisType axisType, Pen pen, Brush brush) : base(chart, pen, brush) { myPoint = point; myAxisType = axisType; myShowGrid = true; } public virtual void SetPosition(PointD point) { myPoint = point; OnRedrawRequired(); } public override void Move(Offset delta) { SetPosition(Point + delta); } public override void Move(PointD point, Offset delta) { Move(delta); } public override void SnapToGrid(IGrid grid) { Move(grid.GetBottomLeftGridPoint(myPoint) - myPoint); } public override void SnapToGrid(PointD point, IGrid grid) { SnapToGrid(grid); } public override bool ContainsPoint(PointD point) { var size = Chart.TransformPixelToWorld(new Size(5, 5)); bool result = false; if ((AxisType & AxisType.Horizontal) == AxisType.Horizontal) result = result || (point.Y >= Point.Y - (size.Height / 2)) && (point.Y <= Point.Y + (size.Height / 2)); if ((AxisType & AxisType.Vertical) == AxisType.Vertical) result = result || (point.X >= Point.X - (size.Height / 2)) && (point.X <= Point.X + (size.Height / 2)); return result; } } }