當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。