parent
f7315defe4
commit
b084bca418
@ -1,54 +0,0 @@ |
||||
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||
|
||||
import android.content.Context |
||||
import android.graphics.Bitmap |
||||
import android.graphics.Canvas |
||||
import android.graphics.Paint |
||||
import android.graphics.RectF |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.handhistory.Street |
||||
import net.pokeranalytics.android.model.realm.handhistory.HandHistory |
||||
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
||||
|
||||
class TableCanvas(bitmap: Bitmap) : Canvas(bitmap) { |
||||
|
||||
companion object { |
||||
|
||||
const val strokeWidth = 20f |
||||
const val tablePadding = 200f |
||||
const val tableCornerRadius = 100f |
||||
|
||||
private val paint = Paint() |
||||
|
||||
fun configurePaints(context: Context) { |
||||
paint.isAntiAlias = true |
||||
paint.style = Paint.Style.STROKE |
||||
paint.strokeWidth = strokeWidth |
||||
paint.color = context.getColor(R.color.green) |
||||
} |
||||
|
||||
/*** |
||||
* WARNING: Avoid instancing objects here, as it's called from onDraw method |
||||
*/ |
||||
fun initializeTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||
|
||||
canvas.drawRoundRect(config.rect, this.tableCornerRadius, this.tableCornerRadius, this.paint) |
||||
|
||||
} |
||||
|
||||
fun drawStreet(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||
|
||||
} |
||||
|
||||
fun drawAction(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||
|
||||
} |
||||
|
||||
//////// |
||||
fun setPot(pot: Double, totalPot: Double) { |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,99 @@ |
||||
package net.pokeranalytics.android.ui.modules.handhistory.replayer |
||||
|
||||
import android.content.Context |
||||
import android.graphics.Bitmap |
||||
import android.graphics.Canvas |
||||
import android.graphics.Paint |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.handhistory.Position |
||||
import net.pokeranalytics.android.model.handhistory.Street |
||||
import net.pokeranalytics.android.ui.modules.handhistory.model.ComputedAction |
||||
import net.pokeranalytics.android.util.extensions.formatted |
||||
|
||||
class TableDrawer(bitmap: Bitmap) : Canvas(bitmap) { |
||||
|
||||
companion object { |
||||
|
||||
const val tableStrokeWidth = 30f |
||||
const val playerStrokeWidth = 8f |
||||
const val tableCornerRadius = 100f |
||||
// const val stackRectRadius = 25f |
||||
|
||||
private val tablePaint = Paint() |
||||
private val playerPaint = Paint() |
||||
private val fillPaint = Paint() |
||||
private val textPaint = Paint() |
||||
|
||||
fun configurePaints(context: Context) { |
||||
tablePaint.isAntiAlias = true |
||||
tablePaint.style = Paint.Style.STROKE |
||||
tablePaint.strokeWidth = tableStrokeWidth |
||||
tablePaint.color = context.getColor(R.color.green) |
||||
|
||||
playerPaint.isAntiAlias = true |
||||
playerPaint.style = Paint.Style.STROKE |
||||
playerPaint.strokeWidth = playerStrokeWidth |
||||
playerPaint.color = context.getColor(R.color.green) |
||||
|
||||
fillPaint.color = context.getColor(R.color.green_darker) |
||||
fillPaint.isAntiAlias = true |
||||
|
||||
textPaint.color = context.getColor(R.color.white) |
||||
textPaint.textAlign = Paint.Align.CENTER |
||||
textPaint.isAntiAlias = true |
||||
} |
||||
|
||||
/*** |
||||
* WARNING: Avoid instancing objects here, as it's called from onDraw method |
||||
*/ |
||||
fun initializeTable(config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||
|
||||
canvas.drawRoundRect(config.tableRect, this.tableCornerRadius, this.tableCornerRadius, this.tablePaint) |
||||
|
||||
val hh = config.handHistory |
||||
val positions = Position.positionsPerPlayers(hh.numberOfPlayers) |
||||
for (i in 0 until hh.numberOfPlayers) { |
||||
val playerSetup = hh.playerSetupForPosition(i) |
||||
|
||||
// Stack zone |
||||
val rect = config.stackRectForPlayer(i) |
||||
val radius = (rect.bottom - rect.top) / 4 |
||||
canvas.drawRoundRect(config.stackRectForPlayer(i), radius, radius, this.fillPaint) |
||||
canvas.drawRoundRect(config.stackRectForPlayer(i), radius, radius, this.playerPaint) |
||||
|
||||
// Player portrait zone |
||||
val circle = config.circleForPlayer(i) |
||||
canvas.drawCircle(circle.x, circle.y, circle.radius, this.fillPaint) |
||||
canvas.drawCircle(circle.x, circle.y, circle.radius, this.playerPaint) |
||||
|
||||
val name = playerSetup?.player?.name ?: positions.elementAt(i).value |
||||
val pnPoint = config.pointForPlayerName(i) |
||||
this.textPaint.textSize = pnPoint.fontSize |
||||
canvas.drawText(name, pnPoint.x, pnPoint.y, this.textPaint) |
||||
|
||||
playerSetup?.stack?.formatted?.let { stack -> |
||||
val psPoint = config.pointForPlayerStack(i) |
||||
this.textPaint.textSize = psPoint.fontSize |
||||
canvas.drawText(stack, psPoint.x, psPoint.y, this.textPaint) |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
fun drawStreet(street: Street, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||
|
||||
} |
||||
|
||||
fun drawAction(action: ComputedAction, config: ReplayerConfiguration, canvas: Canvas, context: Context) { |
||||
|
||||
} |
||||
|
||||
//////// |
||||
fun setPot(pot: Double, totalPot: Double) { |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue