Class Canvas

java.lang.Object
com.codename1.charts.compat.Canvas

public class Canvas extends Object

An internal compatibility class for use by the Charts library. Since the library was ported from an Android library, it made use of Canvas and Paint, so rather than rewriting all of this, we added a Canvas and Paint compatibility layer.

DO NOT USE DIRECTLY

  • Field Details

    • g

      public Graphics g
    • bounds

      public Rectangle bounds
    • absoluteX

      public int absoluteX
    • absoluteY

      public int absoluteY
  • Constructor Details

    • Canvas

      public Canvas()
  • Method Details

    • getClipBounds

      public void getClipBounds(Rectangle mRect)
    • drawRect

      public void drawRect(float left, float top, float right, float bottom, Paint paint)
    • drawText

      public void drawText(String string, float x, float y, Paint paint)
    • getHeight

      public int getHeight()
    • getWidth

      public int getWidth()
    • drawPath

      public void drawPath(Shape p, Paint paint)
    • drawLine

      public void drawLine(float x1, float y1, float x2, float y2, Paint paint)
    • rotate

      public void rotate(float angle, float x, float y)
    • getTransform

      public void getTransform(Transform out)

      Copies the transform in effect into out, so that a temporary rotation, scale or translation can be undone by handing the same object to #setTransform(Transform).

      Undo a temporary transform this way and never by applying its inverse. The angle of a rotation is a float, its sine and cosine are not exact, and rotating by a and then by -a leaves a matrix that is identity to fifteen digits and not to the sixteenth. Nothing shows on a platform that only multiplies by it, but the JavaScript port draws text as DOM nodes under an identity transform and on the canvas under any other, with different metrics: one rotated axis title moved every label painted after it, the form's own title included, by a few pixels.

      Parameters
      • out: receives the current transform
    • setTransform

      public void setTransform(Transform t)

      Replaces the transform in effect, typically with one captured by #getTransform(Transform).

      Parameters
      • t: the transform to install
    • scale

      public void scale(float x, float y)
    • translate

      public void translate(float x, float y)
    • drawCircle

      public void drawCircle(float cx, float cy, float r, Paint paint)
    • drawArc

      public void drawArc(Rectangle2D oval, float currentAngle, float sweepAngle, boolean useCenter, Paint paint)
    • drawArcWithGradient

      public void drawArcWithGradient(Rectangle2D oval, float currentAngle, float sweepAngle, boolean useCenter, Paint paint, GradientDrawable gradient)
    • drawPoint

      public void drawPoint(Float get, Float get0, Paint paint)
    • drawRoundRect

      public void drawRoundRect(Rectangle2D rect, float rx, float ry, Paint mPaint)
    • drawBitmap

      public void drawBitmap(Image img, float left, float top, Paint paint)
    • isShapeClipSupported

      public boolean isShapeClipSupported()