Android Open Source - slider Number Piece Drawer From Project Back to project page slider .
License The source code is released under:
Apache License
If you think the Android project slider listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package de.devisnik.android.sliding.tile;
/ * f r o m w w w . j a v a 2 s . c o m * /
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.Paint.Align;
import android.graphics.Shader.TileMode;
import de.devisnik.sliding.IPiece;
import de.devisnik.sliding.Point;
public class NumberPieceDrawer implements IPieceDrawer {
private static final int TEXT_COLOR = 0xff444444;
private final Paint itsPaint;
private final Paint itsBackPaint;
private final Rect itsBackRect;
private final float itsTextPosX;
private final float itsTextPosY;
private final Point itsTileSize;
private final Paint itsBorderPaint;
public NumberPieceDrawer(final Point tileSize) {
itsTileSize = tileSize;
itsPaint = new Paint();
itsPaint.setColor(TEXT_COLOR);
itsPaint.setAntiAlias(true);
itsPaint.setStrokeWidth(2);
itsPaint.setStrokeCap(Paint.Cap.ROUND);
itsPaint.setStyle(Paint.Style.FILL);
itsPaint.setTextSize(tileSize.x / 3);
itsPaint.setTextAlign(Align.CENTER);
itsBackPaint = new Paint();
itsBackPaint.setShader(new RadialGradient(tileSize.x / 2, tileSize.y / 2, tileSize.x / 2 - 8, 0xff000000,
TEXT_COLOR, TileMode.CLAMP));
itsBackRect = new Rect(0, 0, tileSize.x, tileSize.y);
itsTextPosX = tileSize.x / 2f;
itsTextPosY = (tileSize.y - itsPaint.ascent() - itsPaint.descent()) / 2;
itsBorderPaint = new Paint();
itsBorderPaint.setStyle(Style.STROKE);
itsBorderPaint.setStrokeWidth(1);
itsBorderPaint.setColor(0x33000000);
}
@Override
public Point getTileSize() {
return itsTileSize;
}
@Override
public void drawTile(final IPiece piece, final Canvas canvas, final Paint paint) {
canvas.drawRect(itsBackRect, itsBackPaint);
canvas.drawRect(itsBackRect, itsBorderPaint);
canvas.drawText(piece.getLabel(), itsTextPosX, itsTextPosY, itsPaint);
}
}
Java Source Code List de.devisnik.android.sliding.ARandom.java de.devisnik.android.sliding.FPSCounter.java de.devisnik.android.sliding.FrameDrawer.java de.devisnik.android.sliding.ISpeed.java de.devisnik.android.sliding.ImageCache.java de.devisnik.android.sliding.ImageFactory.java de.devisnik.android.sliding.Logger.java de.devisnik.android.sliding.OpenActivity.java de.devisnik.android.sliding.OpenPreviewActivity.java de.devisnik.android.sliding.PropertiesBuilder.java de.devisnik.android.sliding.RenderHandler.java de.devisnik.android.sliding.Replayer.java de.devisnik.android.sliding.Settings.java de.devisnik.android.sliding.SlidingPreferences.java de.devisnik.android.sliding.SlidingWallpaper.java de.devisnik.android.sliding.SpeedFactory.java de.devisnik.android.sliding.SummaryUpdater.java de.devisnik.android.sliding.tile.BitmapCachingPieceDrawer.java de.devisnik.android.sliding.tile.CachingPieceDrawer.java de.devisnik.android.sliding.tile.IPieceDrawer.java de.devisnik.android.sliding.tile.ImagePieceDrawer.java de.devisnik.android.sliding.tile.NumberPieceDrawer.java de.devisnik.android.sliding.tile.PieceDrawerFactory.java de.devisnik.android.sliding.tile.TileShifter.java de.devisnik.android.sliding.tile.TileStore.java de.devisnik.android.sliding.tile.Tile.java de.devisnik.sliding.FrameFactory.java de.devisnik.sliding.FrameScrambler.java de.devisnik.sliding.FromHomeShiftingEvent.java de.devisnik.sliding.IFrameListener.java de.devisnik.sliding.IFrame.java de.devisnik.sliding.IHole.java de.devisnik.sliding.IMove.java de.devisnik.sliding.IPiece.java de.devisnik.sliding.IRandom.java de.devisnik.sliding.IRobotFrame.java de.devisnik.sliding.IShifterListener.java de.devisnik.sliding.MoveFactory.java de.devisnik.sliding.Point.java de.devisnik.sliding.ShiftingEvent.java de.devisnik.sliding.ToHomeShiftingEvent.java de.devisnik.sliding.animation.AccelerateDecelerateInterpolator.java de.devisnik.sliding.animation.AnimationRunner.java de.devisnik.sliding.animation.Animation.java de.devisnik.sliding.animation.IInterpolator.java de.devisnik.sliding.animation.IMovement.java de.devisnik.sliding.animation.IShiftable.java de.devisnik.sliding.animation.LinearInterpolator.java de.devisnik.sliding.animation.MetaShiftable.java de.devisnik.sliding.animation.ShiftAnimation.java de.devisnik.sliding.animation.Translation.java de.devisnik.sliding.impl.Frame.java de.devisnik.sliding.impl.Hole.java de.devisnik.sliding.impl.Move.java de.devisnik.sliding.impl.PieceIterator.java de.devisnik.sliding.impl.Piece.java de.devisnik.sliding.impl.RobotFrame.java de.devisnik.sliding.impl.Scrambler.java