Ejemplo n.º 1
0
 public void CopyWithoutIdFrom(AxisStyle from)
 {
     this.AxisLineStyle   = from._axisLineStyle == null ? null : (AxisLineStyle)from._axisLineStyle.Clone();
     this.MajorLabelStyle = from._majorLabelStyle == null ? null : (AxisLabelStyleBase)from._majorLabelStyle.Clone();
     this.MinorLabelStyle = from._minorLabelStyle == null ? null : (AxisLabelStyleBase)from._minorLabelStyle.Clone();
     this.Title           = from._axisTitle == null ? null : (TextGraphic)from._axisTitle.Clone();
 }
Ejemplo n.º 2
0
        public object Clone()
        {
            AxisStyle res = new AxisStyle(_styleID);

            res.CopyFrom(this);
            return(res);
        }
Ejemplo n.º 3
0
        public object Clone()
        {
            var res = new AxisStyle();

            res.CopyFrom(this);
            return(res);
        }
 public bool InitializeDocument(params object[] args)
 {
   if (args.Length == 0 || !(args[0] is AxisStyle))
     return false;
   _doc = (AxisStyle)args[0];
   this.SetElements(true);
   return true;
 }
Ejemplo n.º 5
0
 public void CopyWithoutIdFrom(AxisStyle from)
 {
     TickSpacing     = from._customTickSpacing == null ? null : (TickSpacing)from._customTickSpacing.Clone();
     AxisLineStyle   = from._axisLineStyle == null ? null : (AxisLineStyle)from._axisLineStyle.Clone();
     MajorLabelStyle = from._majorLabelStyle == null ? null : (AxisLabelStyle)from._majorLabelStyle.Clone();
     MinorLabelStyle = from._minorLabelStyle == null ? null : (AxisLabelStyle)from._minorLabelStyle.Clone();
     Title           = from._axisTitle == null ? null : (TextGraphic)from._axisTitle.Clone();
 }
Ejemplo n.º 6
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                AxisStyle s = (AxisStyle)obj;

                info.AddValue("StyleID", s._styleID);
                info.AddValue("AxisStyle", s._axisLineStyle);
                info.AddValue("MajorLabelStyle", s._majorLabelStyle);
                info.AddValue("MinorLabelStyle", s._minorLabelStyle);
                info.AddValue("AxisTitle", s._axisTitle);
            }
Ejemplo n.º 7
0
            protected virtual AxisStyle SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                AxisStyle s = null != o ? (AxisStyle)o : new AxisStyle();

                // Styles
                s._styleID        = (CSLineID)info.GetValue("StyleID", s);
                s.AxisLineStyle   = (AxisLineStyle)info.GetValue("AxisStyle", s);
                s.MajorLabelStyle = (AxisLabelStyle)info.GetValue("MajorLabelStyle", s);
                s.MinorLabelStyle = (AxisLabelStyle)info.GetValue("MinorLabelStyle", s);
                s.Title           = (TextGraphic)info.GetValue("AxisTitle", s);

                return(s);
            }
Ejemplo n.º 8
0
 void CopyFrom(AxisStyle from)
 {
   this._styleID = from._styleID.Clone();
   CopyWithoutIdFrom(from);
   this._cachedAxisInfo = from._cachedAxisInfo;
 }
		private IMVCANController CreateAxisStyleController(AxisStyle doc, UseDocument useDocumentCopy)
		{
			var result = (AxisStyleController)Current.Gui.GetControllerAndControl(new object[] { doc }, typeof(AxisStyleController), useDocumentCopy);
			result.MadeDirty += EhAxisStyleControllerDirty;
			return result;
		}
		private void OnAxisStyleCreation(AxisStyle result)
		{
			MajorLabelCondController.AnnounceEnabledChanged(result.AreMajorLabelsEnabled);
			MinorLabelCondController.AnnounceEnabledChanged(result.AreMinorLabelsEnabled);
		}
    public bool Apply()
    {
        // read axis title
        _doc.TitleText = m_View.AxisTitle;

        if (null != _axisLineStyleController)
        {
          if (!_axisLineStyleController.Apply())
            return false;
          else
            _doc.AxisLineStyle = (AxisLineStyle)_axisLineStyleController.ModelObject;
        }

        _doc.ShowMajorLabels = m_View.ShowMajorLabels;
        _doc.ShowMinorLabels = m_View.ShowMinorLabels;

        // if we have offset applying, create a brand new AxisStyle instance
        double offset = m_View.PositionOffset/100;
        if (0 != offset)
        {
          AxisStyle newDoc = new AxisStyle(CSLineID.FromIDandFirstLogicalOffset(_doc.StyleID, offset));
          newDoc.CopyWithoutIdFrom(_doc);
          _doc = newDoc;
        }


      return true; // all ok
    }
Ejemplo n.º 12
0
		public AxisStyleControllerGlue(AxisStyle axisStyle)
		{
			_doc = axisStyle;
			InternalInitialize();
		}
Ejemplo n.º 13
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                AxisStyle s = SDeserialize(o, info, parent);

                return(s);
            }
Ejemplo n.º 14
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			var layer = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing<XYPlotLayer>(this);

			if (null == layer)
			{
				PaintErrorInvalidLayerType(g, paintContext);
				return;
			}

			Logical3D rBegin;
			layer.CoordinateSystem.LayerToLogicalCoordinates(X, Y, out rBegin);

			Logical3D rEnd = rBegin;
			switch (_scaleSpanType)
			{
				case FloatingScaleSpanType.IsLogicalValue:
					rEnd[_scaleNumber] = rBegin[_scaleNumber] + _scaleSpanValue;
					break;

				case FloatingScaleSpanType.IsPhysicalEndOrgDifference:
					{
						var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[this._scaleNumber]);
						physValue += _scaleSpanValue; // to be replaced by the scale span
						var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue);
						rEnd[_scaleNumber] = logValue;
					}
					break;

				case FloatingScaleSpanType.IsPhysicalEndOrgRatio:
					{
						var physValue = layer.Scales[_scaleNumber].NormalToPhysicalVariant(rBegin[this._scaleNumber]);
						physValue *= _scaleSpanValue; // to be replaced by the scale span
						var logValue = layer.Scales[_scaleNumber].PhysicalVariantToNormal(physValue);
						rEnd[_scaleNumber] = logValue;
					}
					break;
			}

			// axis style
			var csLineId = new CSLineID(_scaleNumber, rBegin);
			if (_axisStyle.StyleID != csLineId)
			{
				var propertyContext = this.GetPropertyContext();
				var axStyle = new AxisStyle(new CSLineID(_scaleNumber, rBegin), false, false, false, null, propertyContext);
				axStyle.CopyWithoutIdFrom(_axisStyle);
				_axisStyle = axStyle;
			}

			var privScale = new ScaleSegment(layer.Scales[_scaleNumber], rBegin[_scaleNumber], rEnd[_scaleNumber], _scaleSegmentType);
			_tickSpacing.FinalProcessScaleBoundaries(privScale.OrgAsVariant, privScale.EndAsVariant, privScale);
			privScale.TickSpacing = _tickSpacing;
			var privLayer = new LayerSegment(layer, privScale, rBegin, rEnd, _scaleNumber);

			if (_background == null)
			{
				_axisStyle.Paint(g, paintContext, privLayer, privLayer.GetAxisStyleInformation);
			}
			else
			{
				// if we have a background, we paint in a dummy bitmap in order to measure all items
				// the real painting is done later on after painting the background.
				using (var bmp = new Bitmap(4, 4))
				{
					using (Graphics gg = Graphics.FromImage(bmp))
					{
						_axisStyle.Paint(gg, paintContext, privLayer, privLayer.GetAxisStyleInformation);
					}
				}
			}

			_cachedPath = _axisStyle.AxisLineStyle.GetObjectPath(privLayer, true);

			// calculate size information
			RectangleD2D bounds1 = _cachedPath.GetBounds();

			if (_axisStyle.AreMinorLabelsEnabled)
			{
				var path = _axisStyle.MinorLabelStyle.GetSelectionPath();
				if (path.PointCount > 0)
				{
					_cachedPath.AddPath(path, false);
					RectangleD2D bounds2 = path.GetBounds();
					bounds1.ExpandToInclude(bounds2);
				}
			}
			if (_axisStyle.AreMajorLabelsEnabled)
			{
				var path = _axisStyle.MajorLabelStyle.GetSelectionPath();
				if (path.PointCount > 0)
				{
					_cachedPath.AddPath(path, false);
					RectangleD2D bounds2 = path.GetBounds();
					bounds1.ExpandToInclude(bounds2);
				}
			}

			((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds1.Size);
			//this._leftTop = bounds1.Location - this.GetPosition();
			//throw new NotImplementedException("debug the previous statement");
			if (_background != null)
			{
				bounds1.Expand(_backgroundPadding);
				_background.Draw(g, bounds1);
				_axisStyle.Paint(g, paintContext, privLayer, privLayer.GetAxisStyleInformation);
			}
		}
Ejemplo n.º 15
0
 public void CopyWithoutIdFrom(AxisStyle from)
 {
   this.AxisLineStyle = from._axisLineStyle == null ? null : (AxisLineStyle)from._axisLineStyle.Clone();
   this.MajorLabelStyle = from._majorLabelStyle == null ? null : (AxisLabelStyleBase)from._majorLabelStyle.Clone();
   this.MinorLabelStyle = from._minorLabelStyle == null ? null : (AxisLabelStyleBase)from._minorLabelStyle.Clone();
   this.Title = from._axisTitle == null ? null : (TextGraphic)from._axisTitle.Clone();
 }
Ejemplo n.º 16
0
 void CopyFrom(AxisStyle from)
 {
     this._styleID = from._styleID.Clone();
     CopyWithoutIdFrom(from);
     this._cachedAxisInfo = from._cachedAxisInfo;
 }
Ejemplo n.º 17
0
            protected virtual AxisStyle SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                AxisStyle s = null != o ? (AxisStyle)o : new AxisStyle();

                // Styles
                bool     showAxis = info.GetBoolean("ShowAxis");
                EdgeType edge     = (EdgeType)info.GetEnum("Edge", typeof(EdgeType));

                s.AxisLineStyle = (AxisLineStyle)info.GetValue("AxisStyle", s);
                bool showMajorLabels = info.GetBoolean("ShowMajorLabels");

                if (showMajorLabels)
                {
                    s.MajorLabelStyle = (AxisLabelStyleBase)info.GetValue("MajorLabelStyle", s);
                }
                else
                {
                    s.MajorLabelStyle = null;
                }

                bool showMinorLabels = info.GetBoolean("ShowMinorLabels");

                if (showMinorLabels)
                {
                    s.MinorLabelStyle = (AxisLabelStyleBase)info.GetValue("MinorLabelStyle", s);
                }
                else
                {
                    s.MinorLabelStyle = null;
                }

                s.Title = (TextGraphic)info.GetValue("AxisTitle", s);

                if (!showAxis)
                {
                    s.MajorLabelStyle = null;
                    s.MinorLabelStyle = null;
                    s.AxisLineStyle   = null;
                    s.Title           = null;
                }


                double offset = 0;

                if (s.AxisLineStyle != null && s.AxisLineStyle.Position.IsRelative)
                {
                    offset = s.AxisLineStyle.Position.Value;
                    // Note here: Absolute values are no longer supported
                    // and so this problem can not be fixed here.
                }

                switch (edge)
                {
                case EdgeType.Bottom:
                    s._styleID = new CSLineID(0, -offset);
                    break;

                case EdgeType.Top:
                    s._styleID = new CSLineID(0, 1 + offset);
                    break;

                case EdgeType.Left:
                    s._styleID = new CSLineID(1, -offset);
                    break;

                case EdgeType.Right:
                    s._styleID = new CSLineID(1, 1 + offset);
                    break;
                }


                return(s);
            }
Ejemplo n.º 18
0
		public DensityImageLegend(DensityImagePlotItem plotItem, Main.IDocumentNode futureParentObject, PointD2D initialLocation, PointD2D graphicSize, Main.Properties.IReadOnlyPropertyBag context)
			: base(new ItemLocationDirect())
		{
			if (null == plotItem)
				throw new ArgumentNullException("plotItem");
			if (null == futureParentObject)
				throw new ArgumentNullException("futureParentObject");

			this.ParentObject = futureParentObject;
			this.PlotItem = plotItem;
			if (null == this._plotItemProxy.DocumentPath)
				throw new ArgumentException("No path could be found between plotItem and futureParentObject. This is an indication that one of the objects is not rooted.");

			this.SetSize(graphicSize.X, graphicSize.Y, Main.EventFiring.Suppressed);
			this.SetPosition(initialLocation, Main.EventFiring.Suppressed);

			// _orientationIsVertical = true;
			// _scaleIsReversed = false;

			var cachedScale = (NumericalScale)PlotItem.Style.Scale.Clone();
			var scaleTickSpacing = Altaxo.Graph.Scales.Scale.CreateDefaultTicks(cachedScale.GetType());
			_cachedArea = new DensityLegendArea(Size, true, false, cachedScale, scaleTickSpacing);
			//_cachedArea.ParentObject = this; // --> moved to the end of this function

			_axisStyles = new AxisStyleCollection();
			_axisStyles.UpdateCoordinateSystem(_cachedArea.CoordinateSystem);
			// _axisStyles.ParentObject = this; --> see below

			var sx0 = new AxisStyle(CSLineID.X0, true, true, false, "Z values", context);
			sx0.AxisLineStyle.FirstDownMajorTicks = true;
			sx0.AxisLineStyle.FirstUpMajorTicks = false;
			sx0.AxisLineStyle.FirstDownMinorTicks = true;
			sx0.AxisLineStyle.FirstUpMinorTicks = false;

			var sx1 = new AxisStyle(CSLineID.X1, true, false, false, null, context);
			sx1.AxisLineStyle.FirstDownMajorTicks = false;
			sx1.AxisLineStyle.FirstUpMajorTicks = false;
			sx1.AxisLineStyle.FirstDownMinorTicks = false;
			sx1.AxisLineStyle.FirstUpMinorTicks = false;

			var sy0 = new AxisStyle(CSLineID.Y0, true, false, false, "Color map", context);
			var sy1 = new AxisStyle(CSLineID.Y1, true, false, false, null, context);
			_axisStyles.Add(sx0);
			_axisStyles.Add(sx1);
			_axisStyles.Add(sy0);
			_axisStyles.Add(sy1);

			sx0.Title.Rotation = 90;
			sx0.Title.Location.ParentAnchorX = RADouble.NewRel(0); // Left
			sx0.Title.Location.ParentAnchorY = RADouble.NewRel(0.5); // Center
			sx0.Title.Location.LocalAnchorX = RADouble.NewRel(0.5); // Center
			sx0.Title.Location.LocalAnchorY = RADouble.NewRel(1); // Bottom
			sx0.Title.X = -Width / 3;
			sx0.Title.Y = 0;

			sy0.Title.Location.ParentAnchorX = RADouble.NewRel(0.5); // Center
			sy0.Title.Location.ParentAnchorY = RADouble.NewRel(0); // Top
			sy0.Title.Location.LocalAnchorX = RADouble.NewRel(0.5); // Center
			sy0.Title.Location.LocalAnchorY = RADouble.NewRel(1); // Bottom
			sy0.Title.X = 0;
			sy0.Title.Y = sy0.Title.Height / 2;

			// set the parent objects
			_axisStyles.ParentObject = this;
			_cachedArea.ParentObject = this;
			this.UpdateTransformationMatrix();
		}
Ejemplo n.º 19
0
 public object Clone()
 {
   AxisStyle res = new AxisStyle(_styleID);
   res.CopyFrom(this);
   return res;
 }
Ejemplo n.º 20
0
		public FloatingScale(Main.Properties.IReadOnlyPropertyBag context)
			: base(new ItemLocationDirectAutoSize())
		{
			_scaleSpanValue = 0.25;
			_tickSpacing = new SpanTickSpacing();
			_axisStyle = new AxisStyle(new CSLineID(0, 0), true, false, true, null, context);
		}