public void ShowAxisLine(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { if (_axisLineStyle == null) { AxisLineStyle = new AxisLineStyle(context); } }
/// <summary> /// Serializes the axis style (version 0). /// </summary> /// <param name="obj">The axis style to serialize.</param> /// <param name="info">The serialization info.</param> /// <param name="context">The streaming context.</param> public void GetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { AxisLineStyle s = (AxisLineStyle)obj; info.AddValue("AxisPen", s._axisPen); info.AddValue("MajorPen", s._majorTickPen); info.AddValue("MinorPen", s._minorTickPen); info.AddValue("MajorLength", s._majorTickLength); info.AddValue("MinorLength", s._minorTickLength); info.AddValue("MajorRight", s._showFirstUpMajorTicks); info.AddValue("MajorLeft", s._showFirstDownMajorTicks); info.AddValue("MinorRight", s._showFirstUpMinorTicks); info.AddValue("MinorLeft", s._showFirstDownMinorTicks); info.AddValue("AxisPosition", s._axisPosition); }
public void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info) { AxisLineStyle s = (AxisLineStyle)obj; info.AddValue("AxisPen", s._axisPen); info.AddValue("MajorPen", s._majorTickPen); info.AddValue("MinorPen", s._minorTickPen); info.AddValue("MajorLength", s._majorTickLength); info.AddValue("MinorLength", s._minorTickLength); info.AddValue("AxisPosition", s._axisPosition); info.AddValue("Major1Up", s._showFirstUpMajorTicks); info.AddValue("Major1Dw", s._showFirstDownMajorTicks); info.AddValue("Minor1Up", s._showFirstUpMinorTicks); info.AddValue("Minor1Dw", s._showFirstDownMinorTicks); }
/// <summary> /// Deserializes the axis style (version 0). /// </summary> /// <param name="obj">The empty axis object to deserialize into.</param> /// <param name="info">The serialization info.</param> /// <param name="context">The streaming context.</param> /// <param name="selector">The deserialization surrogate selector.</param> /// <returns>The deserialized linear axis.</returns> public object SetObjectData(object obj, System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.ISurrogateSelector selector) { AxisLineStyle s = (AxisLineStyle)obj; s._axisPen = (PenX)info.GetValue("AxisPen", typeof(PenX)); s._majorTickPen = (PenX)info.GetValue("MajorPen", typeof(PenX)); s._minorTickPen = (PenX)info.GetValue("MinorPen", typeof(PenX)); s._majorTickLength = (float)info.GetSingle("MajorLength"); s._minorTickLength = (float)info.GetSingle("MinorLength"); s._showFirstUpMajorTicks = (bool)info.GetBoolean("MajorRight"); s._showFirstDownMajorTicks = (bool)info.GetBoolean("MajorLeft"); s._showFirstUpMinorTicks = (bool)info.GetBoolean("MinorRight"); s._showFirstDownMinorTicks = (bool)info.GetBoolean("MinorLeft"); s._axisPosition = (Calc.RelativeOrAbsoluteValue)info.GetValue("AxisPosition", typeof(Calc.RelativeOrAbsoluteValue)); return(s); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { AxisLineStyle s = null != o ? (AxisLineStyle)o : new AxisLineStyle(info); s._axisPen = (PenX)info.GetValue("AxisPen", s); s._majorTickPen = (PenX)info.GetValue("MajorPen", s); s._minorTickPen = (PenX)info.GetValue("MinorPen", s); s._majorTickLength = info.GetDouble("MajorLength"); s._minorTickLength = info.GetDouble("MinorLength"); s._axisPosition = (RADouble)info.GetValue("AxisPosition", s); s._showFirstUpMajorTicks = info.GetBoolean("Major1Up"); s._showFirstDownMajorTicks = info.GetBoolean("Major1Dw"); s._showFirstUpMinorTicks = info.GetBoolean("Minor1Up"); s._showFirstDownMinorTicks = info.GetBoolean("Minor1Dw"); return(s); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { AxisLineStyle s = null != o ? (AxisLineStyle)o : new AxisLineStyle(); s._axisPen = (PenX)info.GetValue("AxisPen", s); s._majorTickPen = (PenX)info.GetValue("MajorPen", s); s._minorTickPen = (PenX)info.GetValue("MinorPen", s); s._majorTickLength = (float)info.GetSingle("MajorLength"); s._minorTickLength = (float)info.GetSingle("MinorLength"); s._axisPosition = (Calc.RelativeOrAbsoluteValue)info.GetValue("AxisPosition", s); s._showFirstUpMajorTicks = (bool)info.GetBoolean("Major1Up"); s._showFirstDownMajorTicks = (bool)info.GetBoolean("Major1Dw"); s._showFirstUpMinorTicks = (bool)info.GetBoolean("Minor1Up"); s._showFirstDownMinorTicks = (bool)info.GetBoolean("Minor1Dw"); s.WireEventChain(true); return(s); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { AxisLineStyle s = null != o ? (AxisLineStyle)o : new AxisLineStyle(); Edge edge = (Edge)info.GetValue("Edge", s); s._axisPen = (PenX)info.GetValue("AxisPen", s); s._majorTickPen = (PenX)info.GetValue("MajorPen", s); s._minorTickPen = (PenX)info.GetValue("MinorPen", s); s._majorTickLength = (float)info.GetSingle("MajorLength"); s._minorTickLength = (float)info.GetSingle("MinorLength"); bool bOuterMajorTicks = (bool)info.GetBoolean("MajorOuter"); bool bInnerMajorTicks = (bool)info.GetBoolean("MajorInner"); bool bOuterMinorTicks = (bool)info.GetBoolean("MinorOuter"); bool bInnerMinorTicks = (bool)info.GetBoolean("MinorInner"); s._axisPosition = (Calc.RelativeOrAbsoluteValue)info.GetValue("AxisPosition", s); if (edge.TypeOfEdge == EdgeType.Top || edge.TypeOfEdge == EdgeType.Right) { s._showFirstUpMajorTicks = bOuterMajorTicks; s._showFirstDownMajorTicks = bInnerMajorTicks; s._showFirstUpMinorTicks = bOuterMinorTicks; s._showFirstDownMinorTicks = bInnerMinorTicks; } else { s._showFirstUpMajorTicks = bInnerMajorTicks; s._showFirstDownMajorTicks = bOuterMajorTicks; s._showFirstUpMinorTicks = bInnerMinorTicks; s._showFirstDownMinorTicks = bOuterMinorTicks; } s.WireEventChain(true); return(s); }
/// <summary> /// Copy operation. /// </summary> /// <param name="from">The AxisStyle to copy from</param> public void CopyFrom(AxisLineStyle from) { if (_axisPen != null) { WireEventChain(false); } this._axisPen = null == from._axisPen ? null : (PenX)from._axisPen.Clone(); this._axisPosition = from._axisPosition; this._showFirstDownMajorTicks = from._showFirstDownMajorTicks; this._showFirstDownMinorTicks = from._showFirstDownMinorTicks; this._showFirstUpMajorTicks = from._showFirstUpMajorTicks; this._showFirstUpMinorTicks = from._showFirstUpMinorTicks; this._majorTickLength = from._majorTickLength; this._majorTickPen = null == from._majorTickPen ? null : (PenX)from._majorTickPen; this._minorTickLength = from._minorTickLength; this._minorTickPen = (null == from._minorTickPen) ? null : (PenX)from._minorTickPen; this._cachedAxisStyleInfo = from._cachedAxisStyleInfo; this._parent = from._parent; // Rewire the event chain WireEventChain(true); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { AxisLineStyle s = null != o ? (AxisLineStyle)o : new AxisLineStyle(info); var edge = (Edge)info.GetValue("Edge", s); s._axisPen = (PenX)info.GetValue("AxisPen", s); s._majorTickPen = (PenX)info.GetValue("MajorPen", s); s._minorTickPen = (PenX)info.GetValue("MinorPen", s); s._majorTickLength = info.GetDouble("MajorLength"); s._minorTickLength = info.GetDouble("MinorLength"); bool bOuterMajorTicks = info.GetBoolean("MajorOuter"); bool bInnerMajorTicks = info.GetBoolean("MajorInner"); bool bOuterMinorTicks = info.GetBoolean("MinorOuter"); bool bInnerMinorTicks = info.GetBoolean("MinorInner"); s._axisPosition = (RADouble)info.GetValue("AxisPosition", s); if (edge.TypeOfEdge == EdgeType.Top || edge.TypeOfEdge == EdgeType.Right) { s._showFirstUpMajorTicks = bOuterMajorTicks; s._showFirstDownMajorTicks = bInnerMajorTicks; s._showFirstUpMinorTicks = bOuterMinorTicks; s._showFirstDownMinorTicks = bInnerMinorTicks; } else { s._showFirstUpMajorTicks = bInnerMajorTicks; s._showFirstDownMajorTicks = bOuterMajorTicks; s._showFirstUpMinorTicks = bInnerMinorTicks; s._showFirstDownMinorTicks = bOuterMinorTicks; } return(s); }
/// <summary> /// Copy constructor. /// </summary> /// <param name="from">The AxisStyle to copy from</param> public AxisLineStyle(AxisLineStyle from) { CopyFrom(from); }
/// <summary> /// Abstract paint function for the AbstractXYAxisLabelStyle. /// </summary> /// <param name="g">The graphics context.</param> /// <param name="layer">The layer the lables belongs to.</param> /// <param name="styleInfo">The information which identifies the axis styles.</param> /// <param name="axisstyle">The axis style the axis is formatted with.</param> /// <param name="useMinorTicks">If true, the minor ticks where used instead of the (default) major ticks.</param> public abstract void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks);
private GraphicsPath _enclosingPath = new GraphicsPath(); // with Winding also overlapping rectangles are selected public override void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks) { _cachedStyleID = styleInfo.Identifier; CSLineID styleID = styleInfo.Identifier; Scale raxis = styleID.ParallelAxisNumber==0 ? layer.XAxis : layer.YAxis; _enclosingPath.Reset(); _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected GraphicsPath helperPath = new GraphicsPath(); Matrix math = new Matrix(); Logical3D r0 = _cachedStyleID.Begin; Logical3D r1 = _cachedStyleID.End; SizeF layerSize = layer.Size; PointF outVector; Logical3D outer; float outerDistance = null==axisstyle? 0 : axisstyle.GetOuterDistance(styleInfo.PreferedLabelSide); float dist_x = outerDistance; // Distance from axis tick point to label float dist_y = outerDistance; // y distance from axis tick point to label // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks // next statement is necessary to have a consistent string length both // on 0 degree rotated text and rotated text // without this statement, the text is fitted to the pixel grid, which // leads to "steps" during scaling g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; double[] relpositions; AltaxoVariant[] ticks; if(useMinorTicks) { relpositions = raxis.GetMinorTicksNormal(); ticks = raxis.GetMinorTicksAsVariant(); } else { relpositions = raxis.GetMajorTicksNormal(); ticks = raxis.GetMajorTicksAsVariant(); } IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g,_font,_stringFormat,ticks); float emSize = _font.SizeInPoints; for(int i=0;i<ticks.Length;i++) { double r = relpositions[i]; outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, styleInfo.PreferedLabelSide); PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector); PointF tickend = tickorg; tickend.X += outVector.X * outerDistance; tickend.Y += outVector.Y * outerDistance; SizeF msize = labels[i].Size; PointF morg = tickend; if (_automaticRotationShift) { double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X); double shift = msize.Height * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.Width + _font.SizeInPoints / 2) * 0.5 * Math.Abs(Math.Cos(alpha)); morg.X += (float)(outVector.X * shift); morg.Y += (float)(outVector.Y * shift); } else { morg.X += (float)(outVector.X * _font.SizeInPoints/3); } RectangleF mrect = new RectangleF(morg,msize); if(_automaticRotationShift) AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center); else AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment); math.Reset(); math.Translate((float)morg.X, (float)morg.Y); if (this._rotation != 0) { math.Rotate((float)-this._rotation); } math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset)); System.Drawing.Drawing2D.GraphicsState gs = g.Save(); g.MultiplyTransform(math); if(this._backgroundStyle!=null) _backgroundStyle.Draw(g,new RectangleF(PointF.Empty,msize)); _brush.Rectangle = new RectangleF(PointF.Empty, msize); labels[i].Draw(g,_brush,new PointF(0,0)); g.Restore(gs); // Restore the graphics state helperPath.Reset(); helperPath.AddRectangle(new RectangleF(PointF.Empty, msize)); helperPath.Transform(math); _enclosingPath.AddPath(helperPath,true); } }
public void ShowAxisLine(Altaxo.Main.Properties.IReadOnlyPropertyBag context) { if (_axisLineStyle == null) AxisLineStyle = new AxisLineStyle(context); }
public AxisLineStyleController(AxisLineStyle doc) { _doc = (AxisLineStyle)doc.Clone(); Initialize(true); }
/// <summary> /// Copy operation. /// </summary> /// <param name="from">The AxisStyle to copy from</param> public void CopyFrom(AxisLineStyle from) { if (_axisPen != null) WireEventChain(false); this._axisPen = null == from._axisPen ? null : (PenX)from._axisPen.Clone(); this._axisPosition = from._axisPosition; this._showFirstDownMajorTicks = from._showFirstDownMajorTicks; this._showFirstDownMinorTicks = from._showFirstDownMinorTicks; this._showFirstUpMajorTicks = from._showFirstUpMajorTicks; this._showFirstUpMinorTicks = from._showFirstUpMinorTicks; this._majorTickLength = from._majorTickLength; this._majorTickPen = null==from._majorTickPen ? null : (PenX)from._majorTickPen; this._minorTickLength = from._minorTickLength; this._minorTickPen = (null==from._minorTickPen) ? null : (PenX)from._minorTickPen; this._cachedAxisStyleInfo = from._cachedAxisStyleInfo; this._parent = from._parent; // Rewire the event chain WireEventChain(true); }
private GraphicsPath _enclosingPath = new GraphicsPath(); // with Winding also overlapping rectangles are selected public override void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks) { _cachedStyleID = styleInfo.Identifier; CSLineID styleID = styleInfo.Identifier; Scale raxis = styleID.ParallelAxisNumber == 0 ? layer.XAxis : layer.YAxis; _enclosingPath.Reset(); _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected GraphicsPath helperPath = new GraphicsPath(); Matrix math = new Matrix(); Logical3D r0 = _cachedStyleID.Begin; Logical3D r1 = _cachedStyleID.End; SizeF layerSize = layer.Size; PointF outVector; Logical3D outer; float outerDistance = null == axisstyle? 0 : axisstyle.GetOuterDistance(styleInfo.PreferedLabelSide); float dist_x = outerDistance; // Distance from axis tick point to label float dist_y = outerDistance; // y distance from axis tick point to label // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks // next statement is necessary to have a consistent string length both // on 0 degree rotated text and rotated text // without this statement, the text is fitted to the pixel grid, which // leads to "steps" during scaling g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; double[] relpositions; AltaxoVariant[] ticks; if (useMinorTicks) { relpositions = raxis.GetMinorTicksNormal(); ticks = raxis.GetMinorTicksAsVariant(); } else { relpositions = raxis.GetMajorTicksNormal(); ticks = raxis.GetMajorTicksAsVariant(); } IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks); float emSize = _font.SizeInPoints; for (int i = 0; i < ticks.Length; i++) { double r = relpositions[i]; outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, styleInfo.PreferedLabelSide); PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector); PointF tickend = tickorg; tickend.X += outVector.X * outerDistance; tickend.Y += outVector.Y * outerDistance; SizeF msize = labels[i].Size; PointF morg = tickend; if (_automaticRotationShift) { double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X); double shift = msize.Height * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.Width + _font.SizeInPoints / 2) * 0.5 * Math.Abs(Math.Cos(alpha)); morg.X += (float)(outVector.X * shift); morg.Y += (float)(outVector.Y * shift); } else { morg.X += (float)(outVector.X * _font.SizeInPoints / 3); } RectangleF mrect = new RectangleF(morg, msize); if (_automaticRotationShift) { AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center); } else { AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment); } math.Reset(); math.Translate((float)morg.X, (float)morg.Y); if (this._rotation != 0) { math.Rotate((float)-this._rotation); } math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset)); System.Drawing.Drawing2D.GraphicsState gs = g.Save(); g.MultiplyTransform(math); if (this._backgroundStyle != null) { _backgroundStyle.Draw(g, new RectangleF(PointF.Empty, msize)); } _brush.Rectangle = new RectangleF(PointF.Empty, msize); labels[i].Draw(g, _brush, new PointF(0, 0)); g.Restore(gs); // Restore the graphics state helperPath.Reset(); helperPath.AddRectangle(new RectangleF(PointF.Empty, msize)); helperPath.Transform(math); _enclosingPath.AddPath(helperPath, true); } }