コード例 #1
0
ファイル: AxisTitleRenderer.cs プロジェクト: Sl0vi/PDFsharp
        /// <summary>
        /// Calculates the space used for the axis title.
        /// </summary>
        internal override void Format()
        {
            XGraphics gfx = _rendererParms.Graphics;

            AxisTitleRendererInfo atri = ((AxisRendererInfo)_rendererParms.RendererInfo)._axisTitleRendererInfo;
            if (atri.AxisTitleText != "")
            {
                XSize size = gfx.MeasureString(atri.AxisTitleText, atri.AxisTitleFont);
                if (atri.AxisTitleOrientation != 0)
                {
                    XPoint[] points = new XPoint[2];
                    points[0].X = 0;
                    points[0].Y = 0;
                    points[1].X = size.Width;
                    points[1].Y = size.Height;

                    XMatrix matrix = new XMatrix();
                    matrix.RotatePrepend(-atri.AxisTitleOrientation);
                    matrix.TransformPoints(points);

                    size.Width = Math.Abs(points[1].X - points[0].X);
                    size.Height = Math.Abs(points[1].Y - points[0].Y);
                }

                atri.X = 0;
                atri.Y = 0;
                atri.Height = size.Height;
                atri.Width = size.Width;
            }
        }
コード例 #2
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Applies the specified rotation operation to the transformation matrix of this object
 /// in the specified order. The angle unit of measure is degree.
 /// </summary>
 public void RotateTransform(double angle, XMatrixOrder order)
 {
   //XMatrix matrix = this.transform;
   //matrix.Rotate(angle, order);
   //Transform = matrix;
   XMatrix matrix = new XMatrix();  //XMatrix.Identity;
   matrix.RotatePrepend(angle);
   AddTransform(matrix, order);
 }
コード例 #3
0
ファイル: XGraphics.cs プロジェクト: Davincier/openpetra
 /// <summary>
 /// Applies the specified rotation operation to the transformation matrix of this object by 
 /// prepending it to the object's transformation matrix.
 /// </summary>
 public void RotateTransform(double angle)
 {
   //RotateTransform(angle, XMatrixOrder.Prepend);
   XMatrix matrix = new XMatrix();  //XMatrix.Identity;
   matrix.RotatePrepend(angle);
   AddTransform(matrix, XMatrixOrder.Prepend);
 }
コード例 #4
0
ファイル: VectorObject.cs プロジェクト: Matt--/travellermap
        public void DrawName(XGraphics graphics, RectangleF rect, MapOptions options, XFont font, XBrush textBrush, LabelStyle labelStyle)
        {
            if (graphics == null)
                throw new ArgumentNullException("graphics");

            RectangleF bounds = TransformedBounds;

            if (bounds.IntersectsWith(rect))
            {
                if (Name != null)
                {
                    string str = Name;
                    if (labelStyle.Uppercase)
                        str = str.ToUpperInvariant();

                    PointF pos = NamePosition;// PointF( bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2 );

                    using (RenderUtil.SaveState(graphics))
                    {
                        XMatrix matrix = new XMatrix();
                        matrix.TranslatePrepend(pos.X, pos.Y);
                        matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);
                        matrix.RotatePrepend(-labelStyle.Rotation); // Rotate it
                        graphics.MultiplyTransform(matrix, XMatrixOrder.Prepend);

                        XSize size = graphics.MeasureString(str, font);
                        graphics.TranslateTransform(-size.Width / 2, -size.Height / 2); // Center the text
                        RectangleF textBounds = new RectangleF(0, 0, (float)size.Width, (float)size.Height * 2); // *2 or it gets cut off at high sizes

                        XTextFormatter tf = new XTextFormatter(graphics);
                        tf.Alignment = XParagraphAlignment.Center;
                        tf.DrawString(str, font, textBrush, textBounds);
                    }
                }
            }
        }
コード例 #5
0
        public static void DrawLabel(XGraphics g, string text, PointF labelPos, XFont font, XBrush brush, LabelStyle labelStyle)
        {
            using (RenderUtil.SaveState(g))
            {
                XTextFormatter tf = new XTextFormatter(g);
                tf.Alignment = XParagraphAlignment.Center;

                XMatrix matrix = new XMatrix();
                matrix.TranslatePrepend(labelPos.X, labelPos.Y);
                matrix.ScalePrepend(1.0f / Astrometrics.ParsecScaleX, 1.0f / Astrometrics.ParsecScaleY);

                if (labelStyle.Uppercase)
                    text = text.ToUpper();
                if (labelStyle.Wrap)
                    text = text.Replace(' ', '\n');

                matrix.TranslatePrepend(labelStyle.Translation.X, labelStyle.Translation.Y);
                matrix.RotatePrepend(labelStyle.Rotation);
                matrix.ScalePrepend(labelStyle.Scale.Width, labelStyle.Scale.Height);
                g.MultiplyTransform(matrix, XMatrixOrder.Prepend);

                XSize size = g.MeasureString(text, font);
                size.Width *= 2; // prevent cut-off e.g. when rotated
                XRect bounds = new XRect(-size.Width / 2, -size.Height / 2, size.Width, size.Height);
                tf.DrawString(text, font, brush, bounds);
            }
        }