protected void onDraw(Canvas cs) { super.onDraw(cs); // 描画方法の設定 Paint p = new Paint(); p.setColor(Color.BLACK); p.setStyle(Paint.Style.FILL); p.setStrokeWidth(8); // 円の描画 cs.drawCircle(x, y, 50, p); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (paint == null) { paint = new Paint(); luar = new LinearGradient( 0.f, 0.f, 0.f, this.getMeasuredHeight(), 0xffffffff, 0xff000000, TileMode.CLAMP); } int rgb = Color.HSVToColor(color); Shader dalam = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, 0xffffffff, rgb, TileMode.CLAMP); ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY); paint.setShader(shader); canvas.drawRect(0.f, 0.f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint); }
@Override protected void onDraw(final Canvas canvas) { final Context context = getContext(); if (context instanceof FBReader) { ((FBReader) context).createWakeLock(); } else { System.err.println("A surprise: view's context is not an FBReader"); } super.onDraw(canvas); // final int w = getWidth(); // final int h = getMainAreaHeight(); if (getAnimationProvider().inProgress()) { onDrawInScrolling(canvas); } else { onDrawStatic(canvas); ZLApplication.Instance().onRepaintFinished(); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (Build.VERSION.SDK_INT < 11) { mTransform.set(canvas.getMatrix()); mTransform.preRotate(mRotation, mPivot.x, mPivot.y); canvas.setMatrix(mTransform); } for (Item it : mData) { mPiePaint.setShader(it.mItemShader); cSlicePaint.setShader(it.cSliceShader); // Log.d(TAG, "mBounds: " +mBounds); canvas.drawArc(mBounds, 360 - it.mEndAngle, it.mEndAngle - it.mStartAngle, true, mPiePaint); Log.d(TAG, "Item Being Built: " + it.mLabel); Log.d(TAG, "RectF: " + it.cSliceBounds); Log.d(TAG, "StartAngle> " + it.mStartAngle + " EndAngle> " + it.mEndAngle); canvas.drawArc( it.cSliceBounds, 360 - it.mEndAngle, it.mEndAngle - it.mStartAngle, true, cSlicePaint); // Log.d(TAG, "StartAngle> "+it.mStartAngle+" EndAngle> "+it.mEndAngle); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // draw border mPlotPaint.setStyle(Paint.Style.STROKE); mPlotPaint.setColor(Color.BLACK); canvas.drawRect(mPlotBounds, mPlotPaint); // draw grid mPlotPaint.setColor(gridColor); // x grid if (xTicks != null) { for (float tick : xTicks) { int x = calcX(tick); canvas.drawLine(x, mPlotBounds.bottom, x, mPlotBounds.top, mPlotPaint); } } if (yTicks != null) { for (float tick : yTicks) { int y = calcY(tick); canvas.drawLine(mPlotBounds.left, y, mPlotBounds.right, y, mPlotPaint); } } /* ************************* * draw the data ***************************/ for (Seria s : mData) { stroke(s, canvas); } // draw rectangles that hide out of bounds lines mPlotPaint.setStyle(Style.FILL); mPlotPaint.setColor(Color.WHITE); // left canvas.drawRect(0, 0, mPlotBounds.left, this.getBottom(), mPlotPaint); // bottom canvas.drawRect(0, mPlotBounds.bottom + 1, this.getRight(), this.getBottom(), mPlotPaint); // right canvas.drawRect(mPlotBounds.right + 1, 0, this.getRight(), this.getBottom(), mPlotPaint); // top canvas.drawRect(0, 0, this.getRight(), mPlotBounds.top, mPlotPaint); // x ticks mPlotPaint.setStyle(Paint.Style.STROKE); mPlotPaint.setTextAlign(Align.CENTER); mPlotPaint.setTextSize(xTickTextHeight); mPlotPaint.setColor(xTickColor); if (xTicks != null) { for (float tick : xTicks) { textFigure( xTickFormat.format(tick).toString(), calcX(tick), mPlotBounds.bottom + xTickTextHeight, canvas); } } mPlotPaint.setTextSize(labelTextHeight); mPlotPaint.setTextAlign(Align.RIGHT); if (labelX != null) { textFigure(labelX, mPlotBounds.right, mPlotBounds.bottom + axisXSpacing, canvas); } // y ticks mPlotPaint.setTextAlign(Align.CENTER); mPlotPaint.setTextSize(yTickTextHeight); mPlotPaint.setColor(yTickColor); if (yTicks != null) { for (float tick : yTicks) { textFigure( yTickFormat.format(tick).toString(), mPlotBounds.left - yTickTextHeight, calcY(tick), 90, canvas); } } mPlotPaint.setTextSize(labelTextHeight); mPlotPaint.setTextAlign(Align.RIGHT); if (labelX != null) { textFigure(labelX, mPlotBounds.right, mPlotBounds.bottom + axisXSpacing, canvas); } mPlotPaint.setTextAlign(Align.LEFT); if (labelY != null) { textFigure(labelY, mPlotBounds.left - axisYSpacing, mPlotBounds.top, 90, canvas); } }