Android Open Source - lunatick Luna Tick






From Project

Back to project page lunatick.

License

The source code is released under:

Copyright (c) 2014, a. bellenir All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1....

If you think the Android project lunatick 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 com.bellenir.lunatick;
//from   w w w. j  a v a2 s. c  om
import android.graphics.*;
import java.text.SimpleDateFormat;
import java.sql.*;

public class LunaTick
{
  private static final int SIZE = 500;
  
  public static Bitmap getLunaTickBmp(boolean drawSeconds){
    return getLunaTickBmp(SIZE, SIZE, drawSeconds);
  }
  
  private static Bitmap getLunaTickBmp(int w, int h, boolean drawSeconds){
    int r = ((h<w)?h:w)/2;
    Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(bmp);
    drawMun(c, ((int)(r*0.7)));
    Tick.drawNao(c, ((int)(r*0.9)), drawSeconds);
    
    drawDate(c, SIZE/10, 0.7);
    return bmp;
  }
  private static void drawMun(Canvas c, int r){
    double ph = Luna.getCurrentPhase();
    Luna.drawMunPhase(c, ph, r);
    Luna.drawPhasePercent(c, ph, r/2);
  }
  private static void drawDate(Canvas c, int txtSize, double r){
  
    Path p = new Path();
    int hcw = c.getWidth()/2;
    int hch = c.getHeight()/2;
    //assumes square canvas
    int adj = (int)(hch * r);
    RectF rep = new RectF(hcw-adj, hch-adj, hcw+adj, hch+adj);
    p.addArc(rep, 180, -180);
    
    Paint shadowPaint = new Paint();
    shadowPaint.setColor(Color.BLACK);
    shadowPaint.setTextSize(txtSize);
    shadowPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    shadowPaint.setStrokeWidth(5);
    shadowPaint.setTextAlign(Paint.Align.CENTER);
    Paint paint = new Paint();
    paint.setColor(Color.WHITE);
    paint.setTextSize(txtSize);
    paint.setTextAlign(Paint.Align.CENTER);
    
    SimpleDateFormat df = new SimpleDateFormat("EEE, yyyy.MM.dd");
    String nao = df.format(new java.util.Date());
    c.drawTextOnPath(nao, p, 0, 0, shadowPaint);
    c.drawTextOnPath(nao, p, 0, 0, paint);
    
  }
}




Java Source Code List

com.bellenir.lunatick.Info.java
com.bellenir.lunatick.LunaTick.java
com.bellenir.lunatick.Luna.java
com.bellenir.lunatick.Tick.java
com.bellenir.lunatick.Widget.java