当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.getHeight方法代码示例

本文整理汇总了Java中android.graphics.Canvas.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.getHeight方法的具体用法?Java Canvas.getHeight怎么用?Java Canvas.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Draws the overlay with its associated graphic objects.
 */
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    synchronized (mLock) {
        if ((mPreviewWidth != 0) && (mPreviewHeight != 0)) {
            mWidthScaleFactor = (float) canvas.getWidth() / (float) mPreviewWidth;
            mHeightScaleFactor = (float) canvas.getHeight() / (float) mPreviewHeight;
        }

        for (Graphic graphic : mGraphics) {
            graphic.draw(canvas);
        }
    }
}
 
开发者ID:Jugendhackt,项目名称:SocialPaka,代码行数:19,代码来源:GraphicOverlay.java

示例2: doDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
    public void doDraw(Canvas canvas) {
        int canvasWidth = canvas.getWidth();
        int canvasHeight = canvas.getHeight();

        if (canvasWidth != this.mContainerWidth || canvasHeight != this.mContainerHeight) {//phone rotated !
            this.mContainerWidth = canvasWidth;
            this.mContainerHeight = canvasHeight;
        }
        canvas.save();
        canvas.translate(mCurrX,mCurrY);
//        for (int i = 0; i < 4; i++) { //加深阴影,产生描边效果. stroke/outline effect
//            staticLayout.draw(canvas);
//        }
        borderStaticLayout.draw(canvas);
        staticLayout.draw(canvas);
        canvas.restore();
        mCurrX = (int) (mCurrX - sBaseSpeed * mFactor);//only support moving along X axis
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DanmakuItem.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
    protected void onDraw(Canvas canvas) {
        int canvasWidth = canvas.getWidth();
        int canvasHeight = canvas.getHeight();
        int layerId = canvas.saveLayer(0, 0, canvasWidth, canvasHeight, null, Canvas.ALL_SAVE_FLAG);
        {
            bgPaint.setColor(bgColor);
            // draw the background of progress
            canvas.drawRoundRect(bgRect, rectRadius, rectRadius, bgPaint);
            // draw progress
            canvas.drawRect(progressRect, progressPaint);
            bgPaint.setXfermode(null);
            if (bitmap != null) {
                //draw icon
                canvas.drawBitmap(bitmap, srcRect, dstRect, bgPaint);
            }
        }
        canvas.restoreToCount(layerId);
        // TODO: 弄明白为什么在xml预览中,canvas.restoreToCount
        // TODO: 会导致后续的canvas对象为空 但canvas.restore方法则不会导致这个问题
//        canvas.restore();
//        canvas.save();

    }
 
开发者ID:CuiZhaoHui,项目名称:IOS11RectProgress,代码行数:25,代码来源:RectProgress.java

示例4: initDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
private void initDraw(Canvas canvas) {
    width = canvas.getWidth();
    height = canvas.getHeight();
    centerHeight = height >> 1;
    //振幅为宽度的1/8
    //如果未设置振幅高度,则使用默认高度
    if (amplitude == 0) {
        amplitude = width >> 3;
    }

    //初始化采样点及映射

    //这里因为包括起点和终点,所以需要+1
    samplingX = new float[SAMPLING_SIZE + 1];
    mapX = new float[SAMPLING_SIZE + 1];
    //确定采样点之间的间距
    float gap = width / (float)SAMPLING_SIZE;
    //采样点的位置
    float x;
    for (int i = 0; i <= SAMPLING_SIZE; i++){
        x = i * gap;
        samplingX[i] = x;
        //将采样点映射到[-2,2]
        mapX[i] = (x / (float)width) * 4 - 2;
    }
}
 
开发者ID:Jay-Goo,项目名称:RecordWaveView,代码行数:27,代码来源:RecordWaveView.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
    if (isInEditMode()) {
        return;
    }
    Rect frame = mFrameRect;
    if (frame == null) {
        return;
    }
    int width = canvas.getWidth();
    int height = canvas.getHeight();

    // 绘制焦点框外边的暗色背景
    mPaint.setColor(mMaskColor);
    canvas.drawRect(0, 0, width, frame.top, mPaint);
    canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, mPaint);
    canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, mPaint);
    canvas.drawRect(0, frame.bottom + 1, width, height, mPaint);

    drawFocusRect(canvas, frame);
    drawAngle(canvas, frame);
    drawText(canvas, frame);
    drawLaser(canvas, frame);
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:25,代码来源:ScannerFinderView.java

示例6: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Draws the overlay with its associated graphic objects.
 */
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    synchronized (mLock) {
        if ((mPreviewWidth != 0) && (mPreviewHeight != 0)) {
            sWidthScaleFactor = (float) canvas.getWidth() / (float) mPreviewWidth;
            sHeightScaleFactor = (float) canvas.getHeight() / (float) mPreviewHeight;
        }

        for (Graphic graphic : mGraphics) {
            graphic.draw(canvas);
        }
    }
}
 
开发者ID:dvdciri,项目名称:DeepImagePreview-Project,代码行数:19,代码来源:GraphicOverlay.java

示例7: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
    if (mOffscreenBitmap == null) {
        mOffscreenBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
        mOffscreenCanvas = new Canvas(mOffscreenBitmap);
        BitmapShader mBitmapShader = new BitmapShader(mOffscreenBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setShader(mBitmapShader);
        mRectF = new RectF(0f, 0f, canvas.getWidth(), canvas.getHeight());
    }
    super.draw(mOffscreenCanvas);

    canvas.drawRoundRect(mRectF, 16, 16, mPaint);
}
 
开发者ID:enricocid,项目名称:ColorBox-library,代码行数:15,代码来源:RoundedCornerLayout.java

示例8: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
  Paint background = new Paint();
  background.setColor(Color.WHITE);
  background.setStyle(Paint.Style.FILL_AND_STROKE);
  canvas.drawPaint(background);

  if (timeSeries == null || timeSeries.isEmpty()) {
    return; // No points, so skip.
  }

  // Calculate bounds for the X axis.
  TimeSeriesSnapshot<Double[]> snapshot = timeSeries.getRecentSnapshot(Double[].class);
  long timeEndMicro = snapshot.timestamps[snapshot.length - 1];
  long timeStartMicro = snapshot.timestamps[0];
  double timeDeltaInv = 1.0 / (double)(timeEndMicro - timeStartMicro);

  for (int i = 0; i < snapshot.length; i++) {
    double x = snapshot.values[i][0]; // Relative Theta
    double y = snapshot.values[i][1]; // Relative Beta
    float fX = (float)(x * canvas.getWidth());
    float fY = (float)((1 - y) * canvas.getHeight());
    float fR = DOT_RADIUS * canvas.getWidth();
    double age = Math.min(1, Math.max(0,
        (timeEndMicro - snapshot.timestamps[i]) * timeDeltaInv));
    canvas.drawCircle(fX, fY, fR, paintForAge(age));
  }
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:29,代码来源:Plot2DView.java

示例9: drawBGRect

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 绘制焦点框外边的暗色背景
 *
 * @param canvas
 * @param rect
 */
private void drawBGRect(Canvas canvas, Rect rect) {
    int width = canvas.getWidth();
    int height = canvas.getHeight();
    // 画笔颜色
    mPaint.setColor(mMaskColor);
    canvas.drawRect(0, 0, width, rect.top, mPaint);
    canvas.drawRect(0, rect.top, rect.left, rect.bottom + 1, mPaint);
    canvas.drawRect(rect.right + 1, rect.top, width, rect.bottom + 1, mPaint);
    canvas.drawRect(0, rect.bottom + 1, width, height, mPaint);
}
 
开发者ID:Jusenr,项目名称:androidgithub,代码行数:17,代码来源:QrCodeFinderView.java

示例10: drawPath

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * The graphical representation of a path.
 * 
 * @param canvas the canvas to paint to
 * @param points the points that are contained in the path to paint
 * @param paint the paint to be used for painting
 * @param circular if the path ends with the start point
 */
protected void drawPath(Canvas canvas, List<Float> points, Paint paint, boolean circular) {
  Path path = new Path();
  int height = canvas.getHeight();
  int width = canvas.getWidth();

  float[] tempDrawPoints;
  if (points.size() < 4) {
    return;
  }
  tempDrawPoints = calculateDrawPoints(points.get(0), points.get(1), points.get(2),
      points.get(3), height, width);
  path.moveTo(tempDrawPoints[0], tempDrawPoints[1]);
  path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);

  int length = points.size();
  for (int i = 4; i < length; i += 2) {
    if ((points.get(i - 1) < 0 && points.get(i + 1) < 0)
        || (points.get(i - 1) > height && points.get(i + 1) > height)) {
      continue;
    }
    tempDrawPoints = calculateDrawPoints(points.get(i - 2), points.get(i - 1), points.get(i),
        points.get(i + 1), height, width);
    if (!circular) {
      path.moveTo(tempDrawPoints[0], tempDrawPoints[1]);
    }
    path.lineTo(tempDrawPoints[2], tempDrawPoints[3]);
  }
  if (circular) {
    path.lineTo(points.get(0), points.get(1));
  }
  canvas.drawPath(path, paint);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:41,代码来源:AbstractChart.java

示例11: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    int w = canvas.getWidth(), h = canvas.getHeight();
    bgPaint.setColor(bgColor);
    fgPaint.setColor(fgColor);
    bgRect.set(0, 0, w, h);
    fgRect.set(0, 0, (int)(percentage * w), h);
    canvas.drawRect(bgRect, bgPaint);
    canvas.drawRect(fgRect, fgPaint);
}
 
开发者ID:AndroidNewbies,项目名称:Sanxing,代码行数:11,代码来源:BarCanvasView.java

示例12: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public final void draw(@NonNull final Canvas canvas) {
    int width = canvas.getWidth();
    int height = canvas.getHeight();
    int intrinsicWidth = background.getIntrinsicWidth();
    int intrinsicHeight = background.getIntrinsicHeight();
    int left = (width / 2) - (intrinsicWidth / 2);
    int top = (height / 2) - (intrinsicHeight / 2);
    background.getIntrinsicWidth();
    background.setBounds(left, top, left + intrinsicWidth, top + intrinsicHeight);
    background.draw(canvas);
    float x = width / 2f;
    float y = (height / 2f) - ((paint.descent() + paint.ascent()) / 2f);
    canvas.drawText(label, x, y, paint);
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:16,代码来源:TabSwitcherDrawable.java

示例13: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (middleLine.getColor() != Color.BLUE) {
        middleLine.setColor(color);
    }
    if (bytes != null) {
        float barWidth = getWidth() / density;
        float div = bytes.length / density;
        canvas.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2, middleLine);
        paint.setStrokeWidth(barWidth - gap);

        for (int i = 0; i < density; i++) {
            int x = (int) Math.ceil(i * div);
            int top = canvas.getHeight() / 2
                    + (128 - Math.abs(bytes[x]))
                    * (canvas.getHeight() / 2) / 128;

            int bottom = canvas.getHeight() / 2
                    - (128 - Math.abs(bytes[x]))
                    * (canvas.getHeight() / 2) / 128;

            canvas.drawLine(i * barWidth, bottom, i * barWidth, getHeight() / 2, paint);
            canvas.drawLine(i * barWidth, top, i * barWidth, getHeight() / 2, paint);
        }
        super.onDraw(canvas);
    }
}
 
开发者ID:GautamChibde,项目名称:android-audio-visualizer,代码行数:28,代码来源:LineBarVisualizer.java

示例14: drawHorizontalPicker

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawHorizontalPicker(Canvas canvas) {
	rect.left = 0;
	rect.top = 0;
	rect.right = 0;
	rect.bottom = canvas.getHeight();

	// 8%
	int margin = Math.round(canvas.getHeight() * 0.08f);

	for (int i = 0; i < colors.length; i++) {

		paint.setColor(colors[i]);

		rect.left = rect.right;
		rect.right += cellSize;

		if (isColorSelected && colors[i] == selectedColor) {
			rect.top = 0;
			rect.bottom = canvas.getHeight();
		} else {
			rect.top = margin;
			rect.bottom = canvas.getHeight() - margin;
		}

		canvas.drawRect(rect, paint);
	}
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:28,代码来源:LineColorPicker.java

示例15: createRoundIconWithText

import android.graphics.Canvas; //导入方法依赖的package包/类
static Bitmap createRoundIconWithText(Context context, String letter) {

        //calculate dimensions
        //-1 to take into account the shadow layer
        int w = (int) context.getResources().getDimension(android.R.dimen.app_icon_size);
        int h = (int) context.getResources().getDimension(android.R.dimen.app_icon_size);
        int r = w / 2 - 1;

        //create bitmap
        Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);

        //draw a circle of the same dimensions
        Canvas canvas = new Canvas(b);
        Paint paint = new Paint();
        int color = ContextCompat.getColor(context, getRandom(SolidWallpaperUtils.material_colors));
        paint.setColor(color);

        final int SHADOW_COLOR = 0x80000000;
        paint.setShadowLayer(0.5f, 1, 1, SHADOW_COLOR);
        paint.setAntiAlias(true);
        canvas.drawCircle(r, r, r, paint);

        Paint textPaint = new Paint();
        textPaint.setColor(Utilities.getComplementaryColor(color));
        textPaint.setTextAlign(Paint.Align.CENTER);
        textPaint.setTextSize(w / 2);

        textPaint.setAntiAlias(true);
        textPaint.setTypeface(Typeface.SANS_SERIF);
        int xPos = (canvas.getWidth() / 2);
        int yPos = (int) ((canvas.getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2));

        canvas.drawText(letter, xPos, yPos, textPaint);

        return b;
    }
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:37,代码来源:RoundedContact.java


注:本文中的android.graphics.Canvas.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。