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


Java Canvas.drawLines方法代码示例

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


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

示例1: drawLines

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawLines(Varargs varargs) {
    final Canvas canvas = getCanvas();
    if (canvas != null) {
        final LuaTable table = LuaUtil.getTable(varargs, 2);
        if (table != null) {
            final LuaValue[] keys = table.keys();
            if (keys.length > 0) {
                final float pts[] = new float[keys.length * 4];
                LuaValue value = null;
                for (int i = 0; i < keys.length; i++) {
                    value = table.get(keys[i]);
                    if (value instanceof LuaTable && value.length() >= 4) {
                        for (int j = 0; j < 4; j++) {
                            pts[i * 4 + j] = DimenUtil.dpiToPx(value.get(j + 1));
                        }
                    }
                }
                final LuaValue config = LuaUtil.isTable(varargs.arg(3)) ? LuaUtil.getTable(varargs, 3) : null;
                canvas.drawLines(pts, getDefaultPaint(config));
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:24,代码来源:UDCanvas.java

示例2: render

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void render(Canvas canvas, byte[] data, int width, int height) {
  super.render(canvas, data, width, height);

  for (int i = 0; i < data.length / divisions; i++) {
    points[i * 4] = i * 4 * divisions;
    points[i * 4 + 2] = i * 4 * divisions;

    byte rfk = data[divisions * i];
    byte ifk = data[divisions * i + 1];

    float magnitude = (rfk * rfk + ifk * ifk);
    int dbValue = (int) ((int) (10 * Math.log10(magnitude)) * ampValue);

    points[i * 4 + 1] = height;
    points[i * 4 + 3] = height - (dbValue * 2 - 10);
  }

  canvas.drawLines(points, paint);
}
 
开发者ID:zhangjing02,项目名称:droid-vizu-master,代码行数:21,代码来源:BarRenderer.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    canvas.drawColor(BACKGROUND_COLOR);

    if (points == null) {
        points = new float[POINTS * 2];
        for(int i = 0; i < POINTS; i++) {
            points[i * 2    ] = (float) Math.random() * getWidth();
            points[i * 2 + 1] = (float) Math.random() * getHeight();
        }
    }

    paint.setColor(0xffa0a0a0);
    paint.setStrokeWidth(4.f);
    paint.setStrokeCap(Paint.Cap.BUTT);
    canvas.drawLines(points, paint);

    paint.setColor(0xffffffff);
    paint.setStrokeWidth(10.f);
    paint.setStrokeCap(Paint.Cap.ROUND);
    canvas.drawPoints(points, paint);
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:23,代码来源:PrimitiveDrawer.java

示例4: onDrawOver

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override public void onDrawOver(@NonNull Canvas canvas, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    int childCount = parent.getChildCount();
    if (childCount < 2) return;
    RecyclerView.LayoutManager lm = parent.getLayoutManager();
    float[] lines = new float[childCount * 4];
    boolean hasDividers = false;
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.ViewHolder viewHolder = parent.getChildViewHolder(child);
        if (!(viewHolder instanceof ProgressBarViewHolder)) {
            boolean canDivide = toDivide == null || viewHolder.getClass() == toDivide;
            if (canDivide) {
                int position = parent.getChildAdapterPosition(child);
                if (child.isActivated() || (i + 1 < childCount && parent.getChildAt(i + 1).isActivated())) {
                    continue;
                }
                if (position != (state.getItemCount() - 1)) {
                    lines[i * 4] = inset == 0 ? inset : inset + lm.getDecoratedLeft(child);
                    lines[(i * 4) + 2] = lm.getDecoratedRight(child);
                    int y = lm.getDecoratedBottom(child) + (int) child.getTranslationY() - height;
                    lines[(i * 4) + 1] = y;
                    lines[(i * 4) + 3] = y;
                    hasDividers = true;
                }
            }
        }
    }
    if (hasDividers) {
        canvas.drawLines(lines, paint);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:32,代码来源:InsetDividerDecoration.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (bytes != null) {
        if (points == null || points.length < bytes.length * 4) {
            points = new float[bytes.length * 4];
        }
        paint.setStrokeWidth(getHeight() * strokeWidth);
        rect.set(0, 0, getWidth(), getHeight());

        for (int i = 0; i < bytes.length - 1; i++) {
            points[i * 4] = rect.width() * i / (bytes.length - 1);
            points[i * 4 + 1] = rect.height() / 2
                    + ((byte) (bytes[i] + 128)) * (rect.height() / 3) / 128;
            points[i * 4 + 2] = rect.width() * (i + 1) / (bytes.length - 1);
            points[i * 4 + 3] = rect.height() / 2
                    + ((byte) (bytes[i + 1] + 128)) * (rect.height() / 3) / 128;
        }
        canvas.drawLines(points, paint);
    }
    super.onDraw(canvas);
}
 
开发者ID:GautamChibde,项目名称:android-audio-visualizer,代码行数:22,代码来源:LineVisualizer.java

示例6: render

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void render(Canvas canvas, byte[] data, int w, int h) {
  super.render(canvas, data, w, h);

  for (int i = 0; i < data.length - 1; i++) {
    points[i * 4] = w * i / (data.length - 1);
    points[i * 4 + 1] = (float) (h / 2 + ((byte) (data[i] + 128) * ampValue) * (h / 2) / 128);
    points[i * 4 + 2] = w * (i + 1) / (data.length - 1);
    points[i * 4 + 3] = (float) (h / 2 + ((byte) (data[i + 1] + 128) * ampValue) * (h / 2) / 128);
  }

  canvas.drawLines(points, paint);
}
 
开发者ID:zhangjing02,项目名称:droid-vizu-master,代码行数:14,代码来源:LineRenderer.java

示例7: drawSelectedBg

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawSelectedBg(Canvas canvas) {
  matrix.mapPoints(destPoints, srcPoints);
  //noinspection Range
  canvas.drawLines(destPoints, 0, 8, borderPaint);
  //noinspection Range
  canvas.drawLines(destPoints, 2, 8, borderPaint);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:MotionEntity.java

示例8: render

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void render(Canvas canvas, byte[] data, int width, int height) {
  super.render(canvas, data, width, height);
  if (colorInterpolatePercentage > 1.0) {
    colorInterpolatePercentage = 0;
    int tempColor = startColor;
    startColor = endColor;
    endColor = tempColor;
  }

  for (int i = 0; i < data.length / divisions; i++) {
    points[i * 4] = i * 4 * divisions;
    points[i * 4 + 2] = i * 4 * divisions;

    byte rfk = data[divisions * i];
    byte ifk = data[divisions * i + 1];

    float magnitude = (rfk * rfk + ifk * ifk);
    int dbValue = (int) ((int) (10 * Math.log10(magnitude)) * ampValue);

    points[i * 4 + 1] = height;
    points[i * 4 + 3] = height - (dbValue * 2 - 10);
  }

  changeColor(interpolateColor(startColor, endColor, colorInterpolatePercentage));
  canvas.drawLines(points, paint);
  colorInterpolatePercentage += 0.05;
}
 
开发者ID:zhangjing02,项目名称:droid-vizu-master,代码行数:29,代码来源:ColorfulBarRenderer.java

示例9: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@SuppressWarnings("checkstyle:magicnumber")
@Override
public int draw(Canvas canvas) {
    if (pts.length == SIZE) {
        canvas.drawLine(pts[0], pts[1], pts[2], pts[3], paint);
    } else {
        canvas.drawLines(pts, offset, count, paint);
    }
    return NO_SAVE;
}
 
开发者ID:52inc,项目名称:CanvasScript,代码行数:11,代码来源:LineParams.java

示例10: drawLines

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 画线  两个坐标就进行连接
 *
 * @param canvas
 */
private void drawLines(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(Color.BLACK);
    float[] points = {20, 20, 120, 20, 70, 20, 70, 120, 20, 120, 120, 120, 150, 20, 250, 20, 150, 20, 150, 120, 250, 20, 250, 120, 150, 120, 250, 120};
    canvas.drawLines(points, paint);
}
 
开发者ID:songjiabin,项目名称:MySelfDemo,代码行数:12,代码来源:MyView2.java

示例11: drawCropGrid

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * This method draws crop bounds (empty rectangle)
 * and crop guidelines (vertical and horizontal lines inside the crop bounds) if needed.
 *
 * @param canvas - valid canvas object
 */
protected void drawCropGrid(@NonNull Canvas canvas) {
    if (mShowCropGrid) {
        if (mGridPoints == null && !mCropViewRect.isEmpty()) {

            mGridPoints = new float[(mCropGridRowCount) * 4 + (mCropGridColumnCount) * 4];

            int index = 0;
            for (int i = 0; i < mCropGridRowCount; i++) {
                mGridPoints[index++] = mCropViewRect.left;
                mGridPoints[index++] = (mCropViewRect.height() * (((float) i + 1.0f) / (float) (mCropGridRowCount + 1))) + mCropViewRect.top;
                mGridPoints[index++] = mCropViewRect.right;
                mGridPoints[index++] = (mCropViewRect.height() * (((float) i + 1.0f) / (float) (mCropGridRowCount + 1))) + mCropViewRect.top;
            }

            for (int i = 0; i < mCropGridColumnCount; i++) {
                mGridPoints[index++] = (mCropViewRect.width() * (((float) i + 1.0f) / (float) (mCropGridColumnCount + 1))) + mCropViewRect.left;
                mGridPoints[index++] = mCropViewRect.top;
                mGridPoints[index++] = (mCropViewRect.width() * (((float) i + 1.0f) / (float) (mCropGridColumnCount + 1))) + mCropViewRect.left;
                mGridPoints[index++] = mCropViewRect.bottom;
            }
        }

        if (mGridPoints != null) {
            canvas.drawLines(mGridPoints, mCropGridPaint);
        }
    }

    if (mShowCropFrame) {
        canvas.drawRect(mCropViewRect, mCropFramePaint);
    }
}
 
开发者ID:BrandonVargas,项目名称:AndroidOCRFforID,代码行数:38,代码来源:OverlayView.java

示例12: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
void draw(Canvas canvas) {
    canvas.save();
    canvas.rotate(-90, canvas.getWidth() / 2, canvas.getHeight() / 2);
    canvas.drawArc(boundingBox, 0, 360, false, paint);
    canvas.drawLines(marker, markerPaint);
    canvas.restore();
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:8,代码来源:ColorWheelView.java

示例13: drawSelf

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void drawSelf(Canvas canvas) {
    // 根据坐标绘制图形
    if(canvas == null){
        return ;
    }
    if(mPaint == null){
        return ;
    }
    LogUtil.d("");
    if(coordinates != null && coordinates.length > MIN_POINTS_NUM){
        canvas.drawLines(coordinates,mPaint);
    }

}
 
开发者ID:zmobs,项目名称:DoChart,代码行数:16,代码来源:LineDrawItem.java

示例14: drawAxisLines

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawAxisLines(Canvas canvas, Axis axis, int position) {
    final Rect contentRectMargins = computator.getContentRectMinusAxesMargins();
    float separationX1, separationY1, separationX2, separationY2;
    separationX1 = separationY1 = separationX2 = separationY2 = 0;
    float lineX1, lineY1, lineX2, lineY2;
    lineX1 = lineY1 = lineX2 = lineY2 = 0;
    boolean isAxisVertical = isAxisVertical(position);
    if (LEFT == position || RIGHT == position) {
        separationX1 = separationX2 = separationLineTab[position];
        separationY1 = contentRectMargins.bottom;
        separationY2 = contentRectMargins.top;
        lineX1 = contentRectMargins.left;
        lineX2 = contentRectMargins.right;
    } else if (TOP == position || BOTTOM == position) {
        separationX1 = contentRectMargins.left;
        separationX2 = contentRectMargins.right;
        separationY1 = separationY2 = separationLineTab[position];
        lineY1 = contentRectMargins.top;
        lineY2 = contentRectMargins.bottom;
    }
    // Draw separation line with the same color as axis labels and name.
    if (axis.hasSeparationLine()) {
        canvas.drawLine(separationX1, separationY1, separationX2, separationY2, labelPaintTab[position]);
    }

    if (axis.hasLines()) {
        int valueToDrawIndex = 0;
        for (; valueToDrawIndex < valuesToDrawNumTab[position]; ++valueToDrawIndex) {
            if (isAxisVertical) {
                lineY1 = lineY2 = rawValuesTab[position][valueToDrawIndex];
            } else {
                lineX1 = lineX2 = rawValuesTab[position][valueToDrawIndex];
            }
            linesDrawBufferTab[position][valueToDrawIndex * 4 + 0] = lineX1;
            linesDrawBufferTab[position][valueToDrawIndex * 4 + 1] = lineY1;
            linesDrawBufferTab[position][valueToDrawIndex * 4 + 2] = lineX2;
            linesDrawBufferTab[position][valueToDrawIndex * 4 + 3] = lineY2;
        }
        canvas.drawLines(linesDrawBufferTab[position], 0, valueToDrawIndex * 4, linePaintTab[position]);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:AxesRenderer.java

示例15: drawCropGrid

import android.graphics.Canvas; //导入方法依赖的package包/类
protected void drawCropGrid(@NonNull Canvas canvas) {
    if (this.mShowCropGrid) {
        if (this.mGridPoints == null && !this.mCropViewRect.isEmpty()) {
            int i;
            int i2;
            this.mGridPoints = new float[((this.mCropGridRowCount * 4) + (this
                    .mCropGridColumnCount * 4))];
            int index = 0;
            for (i = 0; i < this.mCropGridRowCount; i++) {
                i2 = index + 1;
                this.mGridPoints[index] = this.mCropViewRect.left;
                index = i2 + 1;
                this.mGridPoints[i2] = (this.mCropViewRect.height() * ((((float) i) + 1.0f) /
                        ((float) (this.mCropGridRowCount + 1)))) + this.mCropViewRect.top;
                i2 = index + 1;
                this.mGridPoints[index] = this.mCropViewRect.right;
                index = i2 + 1;
                this.mGridPoints[i2] = (this.mCropViewRect.height() * ((((float) i) + 1.0f) /
                        ((float) (this.mCropGridRowCount + 1)))) + this.mCropViewRect.top;
            }
            for (i = 0; i < this.mCropGridColumnCount; i++) {
                i2 = index + 1;
                this.mGridPoints[index] = (this.mCropViewRect.width() * ((((float) i) + 1.0f)
                        / ((float) (this.mCropGridColumnCount + 1)))) + this.mCropViewRect.left;
                index = i2 + 1;
                this.mGridPoints[i2] = this.mCropViewRect.top;
                i2 = index + 1;
                this.mGridPoints[index] = (this.mCropViewRect.width() * ((((float) i) + 1.0f)
                        / ((float) (this.mCropGridColumnCount + 1)))) + this.mCropViewRect.left;
                index = i2 + 1;
                this.mGridPoints[i2] = this.mCropViewRect.bottom;
            }
        }
        if (this.mGridPoints != null) {
            canvas.drawLines(this.mGridPoints, this.mCropGridPaint);
        }
    }
    if (this.mShowCropFrame) {
        canvas.drawRect(this.mCropViewRect, this.mCropFramePaint);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:42,代码来源:OverlayView.java


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