List of usage examples for android.graphics Canvas drawLine
public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint)
From source file:com.cssweb.android.view.KlineView.java
private void drawMA(Canvas canvas, JSONObject quoteData, int begin, int count, double shapeWidth, double spaceWidth, double highPrice, double lowPrice, double highVolume, int actualDataLen) throws JSONException { if (quoteData == null || quoteData.isNull("MA")) { isNetworkErrorDisplay();/* w ww. j a v a2s. c o m*/ return; } int startX = klineX; int startY = klineY; double ma5Height = 0; double ma5x = 0; double ma5y = 0; double ma5 = 0; paint.setColor(GlobalColor.colorM5); for (int i = begin; i < (begin + count); i++) { //klineX = 0; ma5 = quoteData.getJSONArray("MA").getJSONArray(i).getDouble(1); if ((i - begin) == 0) { ma5x = startX + spaceWidth + shapeWidth / 2; ma5Height = (int) ((ma5 - lowPrice) * scale); ma5y = axisLabelHeight + klineHeight - ma5Height; } else { if (quoteData.getJSONArray("MA").getJSONArray(i - 1).getDouble(1) == 0) { ma5x = ma5x + spaceWidth + shapeWidth; ma5Height = (ma5 - lowPrice) * scale; ma5y = startY + klineHeight - ma5Height; } else { canvas.drawLine((float) ma5x, (float) ma5y, (float) (ma5x + spaceWidth + shapeWidth), (float) (axisLabelHeight + klineHeight - (ma5 - lowPrice) * scale), paint); ma5x = ma5x + spaceWidth + shapeWidth; ma5Height = (ma5 - lowPrice) * scale; ma5y = startY + klineHeight - ma5Height; } } } // end for double ma10x = 0; double ma10y = 0; double ma10Height = 0; double ma10 = 0; paint.setColor(GlobalColor.colorM10); for (int i = begin; i < (begin + count); i++) { //klineX = 0; ma10 = quoteData.getJSONArray("MA").getJSONArray(i).getDouble(2); if ((i - begin) == 0) { ma10x = startX + spaceWidth + shapeWidth / 2; ma10Height = (ma10 - lowPrice) * scale; ma10y = startY + klineHeight - ma10Height; } else { if (quoteData.getJSONArray("MA").getJSONArray(i - 1).getDouble(2) == 0) { ma10x = ma10x + spaceWidth + shapeWidth; ma10Height = (ma10 - lowPrice) * scale; ma10y = startY + klineHeight - ma10Height; } else { canvas.drawLine((float) ma10x, (float) ma10y, (float) (ma10x + spaceWidth + shapeWidth), (float) (axisLabelHeight + klineHeight - (ma10 - lowPrice) * scale), paint); ma10x = ma10x + spaceWidth + shapeWidth; ma10Height = (ma10 - lowPrice) * scale; ma10y = startY + klineHeight - ma10Height; } } } // end for double ma20x = 0; double ma20y = 0; double ma20Height = 0; double ma20 = 0; //paint.setColor(GlobalColor.colorM20); paint.setARGB(255, 255, 0, 255); for (int i = begin; i < (begin + count); i++) { //klineX = 0; ma20 = quoteData.getJSONArray("MA").getJSONArray(i).getDouble(3); if ((i - begin) == 0) { ma20x = startX + spaceWidth + shapeWidth / 2; ma20Height = (ma20 - lowPrice) * scale; ma20y = startY + klineHeight - ma20Height; } else { if (quoteData.getJSONArray("MA").getJSONArray(i - 1).getDouble(3) == 0) { ma20x = ma20x + spaceWidth + shapeWidth; ma20Height = (ma20 - lowPrice) * scale; ma20y = startY + klineHeight - ma20Height; } else { canvas.drawLine((float) ma20x, (float) ma20y, (float) (ma20x + spaceWidth + shapeWidth), (float) (axisLabelHeight + klineHeight - (ma20 - lowPrice) * scale), paint); ma20x = ma20x + spaceWidth + shapeWidth; ma20Height = (ma20 - lowPrice) * scale; ma20y = startY + klineHeight - ma20Height; } } } // end for double ma60x = 0; double ma60y = 0; double ma60Height = 0; double ma60 = 0; paint.setColor(GlobalColor.colorM60); for (int i = begin; i < (begin + count); i++) { //klineX = 0; ma60 = quoteData.getJSONArray("MA").getJSONArray(i).getDouble(4); if ((i - begin) == 0) { ma60x = startX + spaceWidth + shapeWidth / 2; ma60Height = (ma60 - lowPrice) * scale; ma60y = startY + klineHeight - ma60Height; } else { if (quoteData.getJSONArray("MA").getJSONArray(i - 1).getDouble(4) == 0) { ma60x = ma60x + spaceWidth + shapeWidth; ma60Height = (ma60 - lowPrice) * scale; ma60y = startY + klineHeight - ma60Height; } else { canvas.drawLine((float) ma60x, (float) ma60y, (float) (ma60x + spaceWidth + shapeWidth), (float) (axisLabelHeight + klineHeight - (ma60 - lowPrice) * scale), paint); ma60x = ma60x + spaceWidth + shapeWidth; ma60Height = (ma60 - lowPrice) * scale; ma60y = startY + klineHeight - ma60Height; } } } // end for }
From source file:com.google.android.apps.forscience.whistlepunk.RunReviewOverlay.java
/** * Draw a flag above a specific timestamp with a given value, but make sure the flag starts * after the given flagXToDrawAfter or that the flag is raised up to avoid intersecting it. * @param canvas The canvas to use/*from w ww .j a v a 2 s . c o m*/ * @param pointData The point data to use * @param flagMeasurements This set of measurements will be updated in-place to hold the bounds * of the flag. * @param flagXToDrawAfter The x position past which the flag may not draw. If the flag needs * this space, it must draw itself higher. */ private void drawFlagAfter(Canvas canvas, OverlayPointData pointData, FlagMeasurements flagMeasurements, float flagXToDrawAfter, boolean drawStem) { if (pointData.label == null) { pointData.label = ""; } float labelWidth = mTextPaint.measureText(pointData.label); String timeLabel = mTimeFormat.formatToTenths(pointData.timestamp - mExternalAxis.getRecordingStartTime()); float timeWidth = mTimePaint.measureText(timeLabel); // Ascent returns the distance above (negative) the baseline (ascent). Since it is negative, // negate it again to get the text height. float textSize = -1 * mTextPaint.ascent(); flagMeasurements.boxTop = mHeight - mChartHeight - mPaddingBottom - textSize; flagMeasurements.boxBottom = flagMeasurements.boxTop + textSize + mLabelPadding * 2 + 5; float width = mIntraLabelPadding + 2 * mLabelPadding + timeWidth + labelWidth; // Ideal box layout flagMeasurements.boxStart = pointData.screenPoint.x - width / 2; flagMeasurements.boxEnd = pointData.screenPoint.x + width / 2; // Adjust it if the ideal doesn't work boolean isRaised = false; if (flagMeasurements.boxStart < flagXToDrawAfter + mCropFlagBufferX) { // See if we can simply offset the flag, if it doesn't cause the notch to be drawn // off the edge of the flag. if (flagXToDrawAfter + mCropFlagBufferX < pointData.screenPoint.x - mNotchHeight * SQRT_2_OVER_2 - mCornerRadius) { flagMeasurements.boxStart = flagXToDrawAfter + mCropFlagBufferX; flagMeasurements.boxEnd = flagMeasurements.boxStart + width; } else { // We need to move the flag up! moveUpToAvoid(flagMeasurements, textSize); isRaised = true; } } if (flagMeasurements.boxEnd > mWidth) { flagMeasurements.boxEnd = mWidth; flagMeasurements.boxStart = flagMeasurements.boxEnd - width; if (!isRaised && flagXToDrawAfter + mCropFlagBufferX > flagMeasurements.boxStart) { // We need to move the flag up! moveUpToAvoid(flagMeasurements, textSize); isRaised = true; } } flagMeasurements.notchBottom = flagMeasurements.boxBottom + mNotchHeight; pointData.labelRect.set(flagMeasurements.boxStart, flagMeasurements.boxTop, flagMeasurements.boxEnd, flagMeasurements.boxBottom); canvas.drawRoundRect(pointData.labelRect, mCornerRadius, mCornerRadius, mPaint); mPath.reset(); mPath.moveTo((int) (pointData.screenPoint.x - mNotchHeight * SQRT_2_OVER_2), flagMeasurements.boxBottom); mPath.lineTo(pointData.screenPoint.x, flagMeasurements.boxBottom + mNotchHeight); mPath.lineTo((int) (pointData.screenPoint.x + mNotchHeight * SQRT_2_OVER_2), flagMeasurements.boxBottom); canvas.drawPath(mPath, mPaint); float textBase = flagMeasurements.boxTop + mLabelPadding + textSize; canvas.drawText(timeLabel, flagMeasurements.boxStart + mLabelPadding, textBase, mTimePaint); canvas.drawText(pointData.label, flagMeasurements.boxEnd - labelWidth - mLabelPadding, textBase, mTextPaint); float center = flagMeasurements.boxStart + mLabelPadding + timeWidth + mIntraLabelPadding / 2; canvas.drawLine(center, flagMeasurements.boxTop + mLabelPadding, center, flagMeasurements.boxBottom - mLabelPadding, mCenterLinePaint); if (drawStem) { // Draws a vertical line to the flag notch from the base. // If there is a flag to draw after, does not overlap that flag. if (pointData.screenPoint.x < flagXToDrawAfter) { canvas.drawLine(pointData.screenPoint.x, mHeight, pointData.screenPoint.x, mFlagMeasurements.boxBottom - 5 + textSize + 3 * mLabelPadding, mCropVerticalLinePaint); } else { canvas.drawLine(pointData.screenPoint.x, mHeight, pointData.screenPoint.x, mFlagMeasurements.notchBottom - 5, mCropVerticalLinePaint); } } }
From source file:org.telegram.ui.Cells.DialogCell.java
@Override protected void onDraw(Canvas canvas) { if (currentDialogId == 0) { return;/*from w w w.j a v a2 s .co m*/ } if (isSelected) { canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), backPaint); } if (drawNameLock) { setDrawableBounds(lockDrawable, nameLockLeft, nameLockTop); lockDrawable.draw(canvas); } else if (drawNameGroup) { setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop); groupDrawable.draw(canvas); } else if (drawNameBroadcast) { setDrawableBounds(broadcastDrawable, nameLockLeft, nameLockTop); broadcastDrawable.draw(canvas); } else if (drawNameBot) { setDrawableBounds(botDrawable, nameLockLeft, nameLockTop); botDrawable.draw(canvas); } if (nameLayout != null) { canvas.save(); canvas.translate(nameLeft, AndroidUtilities.dp(13)); nameLayout.draw(canvas); canvas.restore(); } canvas.save(); canvas.translate(timeLeft, timeTop); timeLayout.draw(canvas); canvas.restore(); if (messageLayout != null) { canvas.save(); canvas.translate(messageLeft, messageTop); try { messageLayout.draw(canvas); } catch (Exception e) { FileLog.e("tmessages", e); } canvas.restore(); } if (drawClock) { setDrawableBounds(clockDrawable, checkDrawLeft, checkDrawTop); clockDrawable.draw(canvas); } else if (drawCheck2) { if (drawCheck1) { setDrawableBounds(halfCheckDrawable, halfCheckDrawLeft, checkDrawTop); halfCheckDrawable.draw(canvas); setDrawableBounds(checkDrawable, checkDrawLeft, checkDrawTop); checkDrawable.draw(canvas); } else { setDrawableBounds(checkDrawable, checkDrawLeft, checkDrawTop); checkDrawable.draw(canvas); } } if (dialogMuted && !drawVerified) { setDrawableBounds(muteDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f)); muteDrawable.draw(canvas); } else if (drawVerified) { setDrawableBounds(verifiedDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f)); verifiedDrawable.draw(canvas); } if (drawError) { setDrawableBounds(errorDrawable, errorLeft, errorTop); errorDrawable.draw(canvas); } else if (drawCount) { if (dialogMuted) { setDrawableBounds(countDrawableGrey, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); countDrawableGrey.draw(canvas); } else { setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); countDrawable.draw(canvas); } canvas.save(); canvas.translate(countLeft, countTop + AndroidUtilities.dp(4)); if (countLayout != null) { countLayout.draw(canvas); } canvas.restore(); } if (useSeparator) { if (LocaleController.isRTL) { canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, linePaint); } else { canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint); } } avatarImage.draw(canvas); }
From source file:com.cssweb.android.view.KlineView.java
private void drawVolumeMACD(Canvas canvas, JSONObject quoteData, int begin, int count, double shapeWidth, double spaceWidth, double highPrice, double lowPrice, double highVolume) throws JSONException { if (quoteData == null || quoteData.isNull("MA") || highVolume == 0) { //isNetworkErrorDisplay(); return;/*from w ww . j a v a 2 s. c om*/ } double avgPrice, x1 = 0, x2 = 0; int y1 = 0, y2 = 0; paint.setColor(GlobalColor.colorM5); for (int i = begin; i < begin + count; i++) { if (quoteData.getJSONArray("MA").length() < i) break; avgPrice = quoteData.getJSONArray("MA").getJSONArray(i).getDouble(5); y2 = (int) (avgPrice * scale); y2 = klineY + volumeHeight - y2; if (i < 4) { if (x2 == 0) { x2 = klineX + spaceWidth + shapeWidth / 2; x2 += (spaceWidth + shapeWidth) * (4 - i); } continue; } if (i == 4 && begin != 4) { x1 = x2; y1 = y2; continue; } if (i == begin) x2 = klineX + spaceWidth + shapeWidth / 2; else x2 = spaceWidth + shapeWidth + x2; if (i == begin) { x1 = x2; y1 = y2; } else { canvas.drawLine((int) Math.round(x1), y1, (int) Math.round(x2), y2, paint); x1 = x2; y1 = y2; } if (i == (begin + count - 1)) { // Util.drawString(g2, labelMaVol5, "MA5:"+avgPrice, cssMa5); } } paint.setColor(GlobalColor.colorM10); x2 = 0; for (int i = begin; i < begin + count; i++) { if (quoteData.getJSONArray("MA").length() < i) break; avgPrice = quoteData.getJSONArray("MA").getJSONArray(i).getDouble(6); y2 = (int) (avgPrice * scale); y2 = klineY + volumeHeight - y2; if (i < 9) { if (x2 == 0) { x2 = klineX + spaceWidth + shapeWidth / 2; x2 += (spaceWidth + shapeWidth) * (9 - i); } continue; } if (i == 9 && begin != 9) { x1 = x2; y1 = y2; continue; } if (i == begin) x2 = klineX + spaceWidth + shapeWidth / 2; else x2 = spaceWidth + shapeWidth + x2; if (i == begin) { x1 = x2; y1 = y2; } else { canvas.drawLine((int) Math.round(x1), y1, (int) Math.round(x2), y2, paint); x1 = x2; y1 = y2; } if (i == (begin + count - 1)) { // Util.drawString(g2, labelMaVol10, "MA10:"+avgPrice, cssMa10); } } // end for }
From source file:fr.magistry.taigime.CandidateView.java
/** * If the canvas is null, then only touch calculations are performed to pick the target * candidate./*from w ww .java 2 s . com*/ */ @Override protected void onDraw(Canvas canvas) { if (canvas != null) { super.onDraw(canvas); } mTotalWidth = 0; if (mSuggestions == null) return; if (mBgPadding == null) { mBgPadding = new Rect(0, 0, 0, 0); if (getBackground() != null) { getBackground().getPadding(mBgPadding); } } int x = 0; final int count = mSuggestions.size(); final int height = getHeight(); final Rect bgPadding = mBgPadding; final Paint paint = mPaint; final int touchX = mTouchX; final int scrollX = getScrollX(); final boolean scrolled = mScrolled; final int y; //= (int) ( - mPaint.ascent() + mVerticalPadding); final int y2; //= (int) (height - mPaintTRS.descent()); // (y - mVerticalPadding - mPaint.descent() - mPaintTRS.ascent()) ; final float initialTRSsize = mPaintTRS.getTextSize(); if (mOutputTRS) { y2 = (int) (-mPaintTRS.ascent() + mVerticalPadding); y = (int) (height - mPaint.descent()); } else { y = (int) (-mPaint.ascent() + mVerticalPadding); y2 = (int) (height - mPaintTRS.descent()); } for (int i = 0; i < count; i++) { Candidate suggestion = mSuggestions.get(i); String hanji = suggestion.getWord().getHanji(); String trs = ""; switch (ROMANISATION_OUTPUT_MODE) { case 0: trs = suggestion.getWord().getTailuo(); break; case 1: trs = suggestion.getWord().getPOJ(); break; case 2: trs = suggestion.getWord().getPOJ_safe(); break; default: trs = suggestion.getWord().getTailuo(); } float textWidth; if (i == 0) { hanji = ""; trs = "";//hanji;//TODO: conversion? //if(mOutputTRS){ trs = suggestion.getWord().getBopomo(); if (trs != "") textWidth = mPaintBPM.measureText(trs); else textWidth = 3; //} //else { // hanji = suggestion.getWord().getBopomo(); // textWidth = paint.measureText(hanji); //} } else textWidth = paint.measureText(hanji); if (textWidth == 0.0) textWidth = paint.measureText(" "); final int wordWidth = (int) textWidth + X_GAP * 2; mWordX[i] = x; mWordWidth[i] = wordWidth; mPaintTRS.setTextSize(initialTRSsize); mPaintTRS.setTextSize(reduceTextSizeFromWidth(mPaintTRS, trs, textWidth)); paint.setColor(mColorNormal); if (touchX + scrollX >= x && touchX + scrollX < x + wordWidth && !scrolled) { if (canvas != null) { canvas.translate(x, 0); mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height); mSelectionHighlight.draw(canvas); canvas.translate(-x, 0); } mSelectedIndex = i; } if (canvas != null) { Paint activePaint = null; Paint secondPaint = null; if (mOutputTRS) { activePaint = mPaintTRS; secondPaint = paint; } else { activePaint = paint; secondPaint = mPaintTRS; } if (i == 0) { activePaint = mPaintBPM; } secondPaint.setAlpha(150); if ((i == mCursor)) { activePaint.setFakeBoldText(true); activePaint.setColor(mColorRecommended); } else if (i != 0) { activePaint.setColor(mColorOther); } if (i == 0) { canvas.drawText(trs, x + X_GAP, y2, mPaintBPM); } else { canvas.drawText(hanji, x + X_GAP, y, paint); canvas.drawText(trs, x + X_GAP, y2, mPaintTRS); } activePaint.setColor(mColorOther); canvas.drawLine(x + wordWidth + 0.5f, bgPadding.top, x + wordWidth + 0.5f, height + 1, paint); activePaint.setFakeBoldText(false); secondPaint.setAlpha(255); } x += wordWidth; mPaintTRS.setTextSize(initialTRSsize); } mTotalWidth = x; if (mTargetScrollX != getScrollX()) { scrollToTarget(); } }
From source file:com.skytree.epubtest.BookViewActivity.java
@Override public void draw(Canvas canvas) { Rect b = getBounds();/*from w w w . j a v a 2 s. com*/ mPaint.setColor(mColor); mPaint.setStrokeWidth(mStrokeWidth); mPaint.setStyle(Paint.Style.FILL); canvas.drawLine(0, b.height() / 2 + b.height() * 0.1f, b.width(), b.height() / 2 + b.height() * .1f, mPaint); }
From source file:com.cssweb.android.view.KlineView.java
public void drawCCI(Canvas canvas, JSONObject quoteData, int begin, int count, double shapeWidth, double spaceWidth, double highPrice, double lowPrice, double highVolume, int actualDataLen) throws JSONException { if (quoteData.isNull("CCI") || quoteData.getJSONArray("CCI").length() < 1) { isNetworkErrorDisplay();//from www . jav a2 s. co m return; } //this.shapeWidth = shapeWidth; //this.spaceWidth = spaceWidth; double max = 0.001; double min = -0.001; for (int i = begin; i < (begin + count); i++) { double cci = quoteData.getJSONArray("CCI").getJSONArray(i).getDouble(1); max = Math.max(cci, max); min = Math.min(cci, min); } double scale = this.volumeHeight / (Math.max(100, max) + Math.max(Math.abs(min), 100)); int axisY100 = (int) (klineY + volumeHeight - (100 + Math.abs(min)) * scale); paint.setColor(GlobalColor.clrLine); Graphics.drawDashline(canvas, klineX, axisY100, width, axisY100, paint); int axisY0 = (int) (klineY + volumeHeight - (0 + Math.abs(min)) * scale); Graphics.drawDashline(canvas, klineX, axisY0, width, axisY0, paint); int axisYM100 = (int) (klineY + volumeHeight - (Math.abs(min) - 100) * scale); Graphics.drawDashline(canvas, klineX, axisYM100, width, axisYM100, paint); if (isTrackStatus == false) { tPaint.setColor(GlobalColor.colorKlabel); canvas.drawText("100.00", klineX - tips / 4, axisY100 + axisLabelHeight / 2, tPaint); canvas.drawText("0.00", klineX - tips / 4, axisY0 + axisLabelHeight / 2, tPaint); canvas.drawText("-100.00", klineX - tips / 4, axisYM100 + axisLabelHeight / 2, tPaint); } canvas.drawLine(klineX, height - axisLabelHeight, width, height - axisLabelHeight, paint); if (quoteData != null) { double axisX = 0; double difx = 0; //double deax = 0; //double jx = 0; int kHeight = 0; int ky = 0; //int dHeight = 0; //int dy = 0; //int jHeight = 0; //int jy = 0; paint.setColor(GlobalColor.colorM5); for (int i = begin; i < (begin + count); i++) { double cci = quoteData.getJSONArray("CCI").getJSONArray(i).getDouble(1); //klineX = 0; if ((i - begin) == 0) axisX = axisX + klineX + spaceWidth; else axisX = axisX + spaceWidth + shapeWidth; if ((i - begin) == 0) { difx = difx + klineX + spaceWidth + shapeWidth / 2; kHeight = (int) ((cci + Math.abs(min)) * scale); //kHeight = cci * scale; ky = klineY + volumeHeight - kHeight; } else { double x1 = difx; int y1 = ky; difx = difx + spaceWidth + shapeWidth; kHeight = (int) ((cci + Math.abs(min)) * scale); ky = klineY + volumeHeight - kHeight; canvas.drawLine((int) x1, y1, (int) difx, ky, paint); } if (i == (begin + count - 1)) { //labelDif.text = "CCI:" + Utils.StockFormat(exchange+stockCode, cci); } } // end for } // end if }
From source file:com.lt.adamlee.aagame.GameView.java
public void onDraw(Canvas c) { try {// w w w. jav a2 s. c o m if (mainpage == -1) { this.eg.exitdialog(c); } if (mainpage == 1) { if (bak2) { internalcounter2++; if (internalcounter2 % 10 == 0) { counter1234++; } if (counter1234 >= 2) { counter1234 = 0; internalcounter2 = 0; bak2 = false; } } if (bak4) { this.internalcounter4++; if (this.internalcounter4 % 10 == 0) { this.counter12346++; } if (this.counter12346 >= 2) { this.counter12346 = 0; this.internalcounter4 = 0; bak4 = false; } } c.drawBitmap(this.mainpageimage, 0.0f, 0.0f, null); c.drawBitmap(this.play, F.wf(110.0f), F.hf(175.0f), null); c.drawBitmap(this.moreapps, F.wf(45.0f), F.hf(340.0f), null); c.drawBitmap(this.help, F.wf(130.0f), F.hf(340.0f), null); c.drawBitmap(this.leaderboard, F.wf(215.0f), F.hf(340.0f), null); } if (mainpage == 5) { help(c); } if (mainpage == 6) { this.anim.levelanim(c); } if (mainpage == 7) { if (this.bakc) { this.internalcounterc++; if (this.internalcounterc % 10 == 0) { this.counterc++; } if (this.counterc >= 2) { this.counterc = 0; this.internalcounterc = 0; this.bakc = false; } } this.level.Level_Canvas(c); } if (mainpage == 3) { float[] fArr; if (baka) { this.internalcountera++; if (this.internalcountera % 10 == 0) { this.countera++; } if (this.countera >= 2) { this.countera = 0; this.internalcountera = 0; baka = false; } } view.drawRectangle(c); if (levelcounter % 3 == 0) { if (rotation[0] <= 0.0f && rotation[0] <= 0.0f) { changeangle = 2.0d; } if (rotation[0] > 0.0f && rotation[0] >= 360.0f) { changeangle = -2.0d; } } if (levelcounter % 3 == 1) { changeangle = 2.0d; } if (levelcounter % 3 == 2) { changeangle = -2.0d; } x = (int) F.wf(160.0f); y = (int) F.hf(159.0f); r = (int) F.wf(10.0f); int i = 0; while (i < blinedraw.length) { if (blinedraw[i]) { c.save(); c.rotate(rotation[i], (float) (screenW / 2), F.hf(272.0f)); c.drawLine((float) (screenW / 2), F.hf(272.0f), (float) (screenW / 2), F.hf(272.0f) - F.hf(105.0f), paint4); c.drawCircle((float) x, (float) y, (float) r, paint3); c.drawBitmap(this.cartoonbomb, new Rect(0, 0, this.cartoonbomb.getWidth(), this.cartoonbomb.getHeight()), new Rect(x - (this.cartoonbomb.getWidth() / 2), y - (this.cartoonbomb.getHeight() / 2), x + (this.cartoonbomb.getWidth() / 2), y + (this.cartoonbomb.getHeight() / 2)), null); if (i >= saveline) { c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)), this.innercircletext); } savex[i] = x; savey[i] = y; if (changeangle > 0.0d && rotation[i] >= 360.0f) { rotation[i] = 0.0f; } if (changeangle < 0.0d && rotation[i] <= -360.0f) { rotation[i] = 0.0f; } if (!(errorcircle || !GameActivity.isResume || circleblink)) { fArr = rotation; fArr[i] = (float) (((double) fArr[i]) + changeangle); } c.restore(); if (circleblink) { holdcounter++; if (holdcounter > 32000) { holdcounter = 0; } if (holdcounter % 5 == 0) { hcm++; } if (hcm > 32000) { hcm = 0; } if (hcm <= 9) { h = (int) F.wf(160.0f); j = (int) F.hf(159.0f); k = (int) F.wf(11.0f); paint7.setAlpha(a1); paint7.setColor(SupportMenu.CATEGORY_MASK); paint7.setAntiAlias(true); paint7.setFilterBitmap(true); paint7.setStrokeWidth(2.0f); c.drawCircle((float) h, (float) j, (float) k, paint7); c.drawCircle((float) x, (float) y, (float) r, paint3); if (i >= saveline) { c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)), this.innercircletext); } } if (hcm >= 11) { circleblink = false; mainpage = 6; // GameActivity.vimapad.isBottomAdVisible(true); // GameActivity.vimapad.isTopAdVisible(true); holdcounter = 0; hcm = 0; } } } i++; } i = 0; while (i < circledrawboolean.length) { if (circledrawboolean[i]) { c.save(); c.rotate(rotation[i], (float) (screenW / 2), F.hf(272.0f)); c.drawLine((float) (screenW / 2), F.hf(272.0f), (float) (screenW / 2), F.hf(272.0f) - F.hf(105.0f), paint4); c.drawCircle((float) x, (float) y, (float) r, paint3); if (i >= saveline) { c.drawText((Circle.var - (i - saveline) + ""), (float) x, (float) ((int) F.hf(163.0f)), this.innercircletext); } savex[i] = x; savey[i] = y; if (changeangle > 0.0d && rotation[i] >= 360.0f) { rotation[i] = 0.0f; } if (changeangle < 0.0d && rotation[i] <= -360.0f) { rotation[i] = 0.0f; } if (!(errorcircle || !GameActivity.isResume || circleblink)) { fArr = rotation; fArr[i] = (float) (((double) fArr[i]) + changeangle); } c.restore(); if (colcircle) { this.displaycount3++; textdisplayboolean = false; if (this.displaycount3 <= 70 || (this.displaycount3 >= 80 && this.displaycount3 <= 90)) { paint6.setAntiAlias(true); } paint6.setFilterBitmap(true); paint6.setColor(ViewCompat.MEASURED_STATE_MASK); c.drawCircle((float) (screenW / 2), F.hf(272.0f), F.wf(39.0f), paint6); paint6.setColor(SupportMenu.CATEGORY_MASK); paint6.setAntiAlias(true); paint6.setFilterBitmap(true); paint6.setTypeface(tf); paint6.setAlpha(Circle.a); paint6.setTextAlign(Paint.Align.CENTER); c.drawText(String.valueOf(levelcounter), F.wf(160.0f), F.hf(278.0f), paint6); paint6.setColor(getResources().getColor(R.color.common_signin_btn_default_background)); paint6.setAlpha(20); paint6.setAntiAlias(true); paint6.setFilterBitmap(true); c.drawRect(0.0f, 0.0f, (float) screenW, (float) screenH, paint6); if (this.displaycount3 <= 70 || this.displaycount3 >= 80) { } if (this.displaycount3 > 90) { int j; this.displaycount3 = 0; colcircle = false; circleblink = false; bak4 = true; reset(); levelcounter++; errorcircle = false; linecounter = NoOfInitialLines - 1; for (j = 0; j < NoOfInitialLines; j++) { blinedraw[j] = true; } for (j = 0; j < rotation.length; j++) { rotation[j] = 0.0f; } for (j = 0; j < NoOfInitialLines; j++) { rotation[j] = (float) ((j + 1) * (360 / NoOfInitialLines)); if (rotation[j] > 360.0f) { rotation[j] = rotation[j] - 360.0f; } } } } } i++; } this.paint21.setColor(-1); this.paint21.setTypeface(tf); this.paint21.setTextAlign(Paint.Align.CENTER); this.paint21.setAntiAlias(true); this.paint21.setFilterBitmap(true); if (textdisplayboolean) { c.drawText(String.valueOf(levelcounter), F.wf(160.0f), F.hf(278.0f), this.paint21); } } } catch (Exception e) { } }
From source file:net.droidsolutions.droidcharts.core.plot.CategoryPlot.java
/** * Utility method for drawing a line perpendicular to the range axis (used * for crosshairs)./*from w w w . j a v a 2s. c o m*/ * * @param g2 * the graphics device. * @param dataArea * the area defined by the axes. * @param value * the data value. * @param stroke * the line stroke (<code>null</code> not permitted). * @param paint * the line paint (<code>null</code> not permitted). */ protected void drawRangeLine(Canvas g2, Rectangle2D dataArea, double value, float stroke, Paint paint) { double java2D = getRangeAxis().valueToJava2D(value, dataArea, getRangeAxisEdge()); Line2D line = null; if (this.orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, dataArea.getMaxY()); } else if (this.orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), java2D, dataArea.getMaxX(), java2D); } paint.setStrokeWidth(stroke); g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(), (float) line.getY2(), paint); }
From source file:com.cssweb.android.view.KlineView.java
public void drawVOLUME(Canvas canvas, JSONObject quoteData, int begin, int count, double shapeWidth, double spaceWidth, double highPrice, double lowPrice, double highVolume, int actualDataLen) throws JSONException { if (quoteData == null || quoteData.isNull("MA")) { isNetworkErrorDisplay();// w w w .j a va 2 s . com return; } axisX = klineX; for (int i = begin; i < (begin + count); i++) { highVolume = Arith.max(highVolume, quoteData.getJSONArray("MA").getJSONArray(i).getDouble(5), quoteData.getJSONArray("MA").getJSONArray(i).getDouble(6)); } if (highVolume > 0) { scale = volumeHeight / highVolume; } else { scale = 999999; } double ratio = highVolume / rowNum; ratio = Math.round(ratio); String lblvalue = "12345", labelRatio = ""; String lbhighVolume = String.valueOf(Math.round(highVolume)); int ratiolen = lbhighVolume.length() - lblvalue.length(); double scaleVol = 1; switch (ratiolen) { case 1: labelRatio = "x10"; scaleVol = 10; break; case 2: labelRatio = "x100"; scaleVol = 100; break; case 3: labelRatio = "x1000"; scaleVol = 1000; break; case 4: labelRatio = "x1"; scaleVol = 10000; break; case 5: labelRatio = "x1"; scaleVol = 1000000; break; case 6: labelRatio = "x1"; scaleVol = 1000000; break; default: labelRatio = "x1"; scaleVol = 1; break; } double AxisLabelVolume = 0; paint.setColor(GlobalColor.clrLine); tPaint.setTextAlign(Paint.Align.RIGHT); for (int i = 0; i <= rowNum; i++) { if (i == rowNum || i == 0) { canvas.drawLine(klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } else { Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint); } if (i != rowNum && isTrackStatus == false) { AxisLabelVolume = Math.round(highVolume - ratio * i); if (i == 0) { tPaint.setColor(GlobalColor.colorTicklabel); canvas.drawText(Utils.dataFormation(Math.round(AxisLabelVolume / scaleVol), 0), klineX - tips / 4, klineY + rowHeight * i + axisLabelHeight / 2, tPaint); } else { tPaint.setColor(GlobalColor.colorTicklabel); canvas.drawText(Utils.dataFormation(Math.round(AxisLabelVolume / scaleVol), 0), klineX - tips / 4, klineY + rowHeight * i + axisLabelHeight / 2, tPaint); } } } if (isTrackStatus == false) { tPaint.setColor(GlobalColor.colorTicklabel); canvas.drawText(labelRatio, klineX - tips / 4, height - axisLabelHeight, tPaint); } // K if (quoteData != null) { for (int i = begin; i < (begin + count); i++) { if (i == 0) { drawVolumeKLine(canvas, i - begin, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i).getDouble(5)); } else { drawVolumeKLine(canvas, i - begin, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1), quoteData.getJSONArray("K").getJSONArray(i).getDouble(4), quoteData.getJSONArray("K").getJSONArray(i).getDouble(5)); } if (i == (begin + count - 1)) { // Util.drawString(g2, labelVolume, "VOLUME:", css); } } drawVolumeMACD(canvas, quoteData, begin, count, shapeWidth, spaceWidth, highPrice, lowPrice, highVolume); } }