Exemple #1
0
        /// <summary>
        /// このユニットを指定した位置に描画します。
        /// </summary>
        /// <param name="graphics">描画に使用するグラフィクス</param>
        /// <param name="x">描画する位置のx座標</param>
        /// <param name="y">描画する位置のy座標</param>
        /// <returns>描画された装置図に外接する四角形のサイズ</returns>
        public virtual void paintTo(Graphics2D graphics, int x, int y, int width, int height)
        {
            // 現在の描画時のストローク、色を保存しておく
            Stroke old_stroke = graphics.getStroke();
            Color  old_color  = graphics.getColor();

            // 描画用のストロークが初期化してなかったら初期化
            if (mStroke == null)
            {
                mStroke = new BasicStroke();
            }

            if (mFont == null)
            {
                mFont = new Font("Arial", Font.PLAIN, 10);
            }

            // 枠と背景を描画
            paintBackground(graphics, mStroke, x, y, width, height, Color.black, PortUtil.Pink);

            // デバイス名を書く
            string typename = this.GetType().Name;

            PortUtil.drawStringEx(
                (Graphics)graphics, typename, mFont,
                new Rectangle(x, y, width, height),
                PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER);

            // 描画時のストローク、色を元に戻す
            graphics.setStroke(old_stroke);
            graphics.setColor(old_color);
        }
Exemple #2
0
        public override void paintTo(Graphics2D graphics, int x, int y, int width, int height)
        {
            // 現在の描画時のストローク、色を保存しておく
            Stroke old_stroke = graphics.getStroke();
            Color  old_color  = graphics.getColor();

            // 描画用のストロークが初期化してなかったら初期化
            if (mStroke == null)
            {
                mStroke = new BasicStroke();
            }

            // 枠と背景を描画
            paintBackground(graphics, mStroke, x, y, width, height, Color.black, PortUtil.Pink);

            // デバイス名を書く
            PortUtil.drawStringEx(
                (Graphics)graphics, "Amplifier", AppManager.baseFont10,
                new Rectangle(x, y, width, height),
                PortUtil.STRING_ALIGN_CENTER, PortUtil.STRING_ALIGN_CENTER);

            // 描画時のストローク、色を元に戻す
            graphics.setStroke(old_stroke);
            graphics.setColor(old_color);
        }
Exemple #3
0
 /// <summary>
 /// デフォルトのストロークを取得します
 /// </summary>
 /// <returns></returns>
 private BasicStroke getStrokeDefault()
 {
     if (mStrokeDefault == null)
     {
         mStrokeDefault = new BasicStroke();
     }
     return(mStrokeDefault);
 }
Exemple #4
0
 /// <summary>
 /// 幅が2ピクセルのストロークを取得します
 /// </summary>
 /// <returns></returns>
 private BasicStroke getStroke2px()
 {
     if (mStroke2px == null)
     {
         mStroke2px = new BasicStroke(2.0f);
     }
     return(mStroke2px);
 }
Exemple #5
0
        /// <summary>
        /// Returns true if this BasicStroke represents the same
        /// stroking operation as the given argument.
        /// </summary>
        /// <summary>
        /// Tests if a specified object is equal to this <code>BasicStroke</code>
        /// by first testing if it is a <code>BasicStroke</code> and then comparing
        /// its width, join, cap, miter limit, dash, and dash phase attributes with
        /// those of this <code>BasicStroke</code>. </summary>
        /// <param name="obj"> the specified object to compare to this
        ///              <code>BasicStroke</code> </param>
        /// <returns> <code>true</code> if the width, join, cap, miter limit, dash, and
        ///            dash phase are the same for both objects;
        ///            <code>false</code> otherwise. </returns>
        public override bool Equals(Object obj)
        {
            if (!(obj is BasicStroke))
            {
                return(false);
            }

            BasicStroke bs = (BasicStroke)obj;

            if (Width != bs.Width)
            {
                return(false);
            }

            if (Join != bs.Join)
            {
                return(false);
            }

            if (Cap != bs.Cap)
            {
                return(false);
            }

            if (Miterlimit != bs.Miterlimit)
            {
                return(false);
            }

            if (Dash != null)
            {
                if (Dash_phase != bs.Dash_phase)
                {
                    return(false);
                }

                if (!System.Array.Equals(Dash, bs.Dash))
                {
                    return(false);
                }
            }
            else if (bs.Dash != null)
            {
                return(false);
            }

            return(true);
        }
 static DefaultDrawingSupplier()
 {
   Paint[] paintArray1 = new Paint[1];
   int index1 = 0;
   // ISSUE: variable of the null type
   __Null local1 = Color.lightGray;
   paintArray1[index1] = (Paint) local1;
   DefaultDrawingSupplier.__\u003C\u003EDEFAULT_OUTLINE_PAINT_SEQUENCE = paintArray1;
   Paint[] paintArray2 = new Paint[1];
   int index2 = 0;
   // ISSUE: variable of the null type
   __Null local2 = Color.white;
   paintArray2[index2] = (Paint) local2;
   DefaultDrawingSupplier.__\u003C\u003EDEFAULT_FILL_PAINT_SEQUENCE = paintArray2;
   Stroke[] strokeArray1 = new Stroke[1];
   int index3 = 0;
   BasicStroke basicStroke1 = new BasicStroke(1f, 2, 2);
   strokeArray1[index3] = (Stroke) basicStroke1;
   DefaultDrawingSupplier.__\u003C\u003EDEFAULT_STROKE_SEQUENCE = strokeArray1;
   Stroke[] strokeArray2 = new Stroke[1];
   int index4 = 0;
   BasicStroke basicStroke2 = new BasicStroke(1f, 2, 2);
   strokeArray2[index4] = (Stroke) basicStroke2;
   DefaultDrawingSupplier.__\u003C\u003EDEFAULT_OUTLINE_STROKE_SEQUENCE = strokeArray2;
   DefaultDrawingSupplier.__\u003C\u003EDEFAULT_SHAPE_SEQUENCE = DefaultDrawingSupplier.createStandardSeriesShapes();
 }
Exemple #7
0
    public static void paint(SimpleShape shape, Graphics2D graphics){
        Rectangle2D anchor = shape.GetLogicalAnchor2D();
        java.awt.Shape outline = shape.GetOutline();

        //flip vertical
        if(shape.GetFlipVertical()){
            graphics.translate(anchor.GetX(), anchor.GetY() + anchor.Height);
            graphics.scale(1, -1);
            graphics.translate(-anchor.GetX(), -anchor.GetY());
        }
        //flip horizontal
        if(shape.GetFlipHorizontal()){
            graphics.translate(anchor.GetX() + anchor.Width, anchor.GetY());
            graphics.scale(-1, 1);
            graphics.translate(-anchor.GetX() , -anchor.GetY());
        }

        //rotate transform
        double angle = shape.GetRotation();

        if(angle != 0){
            double centerX = anchor.GetX() + anchor.Width/2;
            double centerY = anchor.GetY() + anchor.Height/2;

            graphics.translate(centerX, centerY);
            graphics.rotate(Math.ToRadians(angle));
            graphics.translate(-centerX, -centerY);
        }

        //fill
        Color FillColor = shape.GetFill().GetForegroundColor();
        if (FillColor != null) {
            //TODO: implement gradient and texture fill patterns
            graphics.SetPaint(FillColor);
            graphics.Fill(outline);
        }

        //border
        Color lineColor = shape.GetLineColor();
        if (lineColor != null){
            graphics.SetPaint(lineColor);
            float width = (float)shape.GetLineWidth();

            int dashing = shape.GetLineDashing();
            //TODO: implement more dashing styles
            float[] dashptrn = null;
            switch(dashing){
                case Line.PEN_SOLID:
                    dashptrn = null;
                    break;
                case Line.PEN_PS_DASH:
                    dashptrn = new float[]{width, width};
                    break;
                case Line.PEN_DOTGEL:
                    dashptrn = new float[]{width*4, width*3};
                    break;
               default:
                    logger.log(POILogger.WARN, "unsupported dashing: " + dashing);
                    dashptrn = new float[]{width, width};
                    break;
            }

            Stroke stroke = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashptrn, 0.0f);
            graphics.SetStroke(stroke);
            graphics.Draw(outline);
        }
    }