Android Open Source - Sketcher-Tab Preview View






From Project

Back to project page Sketcher-Tab.

License

The source code is released under:

Apache License

If you think the Android project Sketcher-Tab 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 org.sketchertab.colorpicker;
//from www . j a  v  a  2s.  c  o  m
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;

public class PreviewView extends View {
  private Paint mPaint = new Paint();
  private Paint mOldPaint = new Paint();
  private final Paint mBorderPaint = new Paint();

  public PreviewView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mBorderPaint.setColor(Color.GRAY);
    mBorderPaint.setStrokeWidth(1);
    mBorderPaint.setStyle(Style.STROKE);
  }

  public void setPaint(Paint paint) {
    mPaint = paint;
    mOldPaint = new Paint(paint);
    invalidate();
  }

  public void setColor(int color) {
    mPaint.setColor(color);
    invalidate();
  }

  @Override
  protected void onDraw(Canvas canvas) {
    int width = getWidth();
    int height = getHeight();

    canvas.drawRect(0, 0, width / 2, height, mOldPaint);
    canvas.drawRect(width / 2, 0, width, height, mPaint);
    canvas.drawRect(0, 0, width - 1, height - 1, mBorderPaint);
  }
}




Java Source Code List

org.sketchertab.AboutDialog.java
org.sketchertab.BrushProperties.java
org.sketchertab.DocumentHistory.java
org.sketchertab.DrawController.java
org.sketchertab.FileHelper.java
org.sketchertab.HistoryItem.java
org.sketchertab.Sketcher.java
org.sketchertab.Style.java
org.sketchertab.SurfaceDiff.java
org.sketchertab.Surface.java
org.sketchertab.colorpicker.HuePicker.java
org.sketchertab.colorpicker.PickerDialog.java
org.sketchertab.colorpicker.Picker.java
org.sketchertab.colorpicker.PreviewView.java
org.sketchertab.colorpicker.SatValPicker.java
org.sketchertab.colorpicker.Utils.java
org.sketchertab.style.CirclesStyle.java
org.sketchertab.style.FurStyle.java
org.sketchertab.style.RibbonStyle.java
org.sketchertab.style.ShadedStyle.java
org.sketchertab.style.SimpleStyle.java
org.sketchertab.style.SketchyStyle.java
org.sketchertab.style.StyleBrush.java
org.sketchertab.style.StylesFactory.java
org.sketchertab.style.WebStyle.java