Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by Ashish ( 14 years ago )
my main activity class is as foloow
public class AshActivity extends Activity {
private static final String FCDFFF = null;
ImageView i;
ImageView h;
Draw j;
TextView t,k;
Button back;
Button next;
OnClickListener l2 = null;
OnClickListener l = null;
String Human_info="Hi,I am human,we are here demonstarate you about where dna is located in ur body ";
String Tissue_info="Tissue is a cellular organizational level intermediate between cells and a complete organism. A tissue is an ensemble of cells, not necessarily identical, but from the same origin, that together carry out a specific function. These are called tissues because of their identical functioning.";
String Hand_info="This is my hand";
String Cell_info="The cell is the basic structural and functional unit of all known living organisms. It is the smallest unit of life that is classified as a living thing, and is often called the building block of life";
String Nucleus_info="The cell nucleus acts like the brain of the cell. It helps control eating, movement, and reproduction. If it happens in a cell, chances are the nucleus knows about it. The nucleus is not always in the center of the cell. It will be a big dark spot somewhere in the middle of all of the cytoplasm (cytosol).";
String Chromosome_info="Hi,I am human";
String Dnahelix_info="Hi,I am human";
int count=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
i = (FirstImage)findViewById(R.id.image);
j=(Draw)findViewById(R.id.info);
t=(TextView)findViewById(R.id.textView);
k=(TextView)findViewById(R.id.textView1);
back=(Button)findViewById(R.id.button1);
next=(Button)findViewById(R.id.button2);
Log.w("DEBUG","which is null: " + i+ " OR " + h );
h=(ImageIn)findViewById(R.id.imagein);
if (count==0){
((FirstImage) i).changeImage(R.drawable.human);
t.setText(Human_info);
}
addListenerOnButton();
}
private void addListenerOnButton()
{
next.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
switch (count)
{
case 0:
((FirstImage) i).changeImage(R.drawable.hand);
((ImageIn) h).changeImage(R.drawable.hand,i);
t.setText(Hand_info);
j.clearInfo();
back.setEnabled(true);
break;
case 1:
((FirstImage) i).changeImage(R.drawable.tissue);
((ImageIn) h).changeImage(R.drawable.tissue,i);
t.setText(Tissue_info);
j.clearInfo();
break;
case 2:
((FirstImage) i).changeImage(R.drawable.cell);
((ImageIn) h).changeImage(R.drawable.coordinatebestcolormatch,i);
t.setText(Cell_info);
j.clearInfo();
break;
case 3:
((FirstImage) i).changeImage(R.drawable.nucleus);
((ImageIn) h).changeImage(R.drawable.nucleus,i);
j.clearInfo();
t.setText(Nucleus_info);
break;
case 4:
((FirstImage) i).changeImage(R.drawable.chromosome);
((ImageIn) h).changeImage(R.drawable.chromosome,i);
j.clearInfo();
t.setText(Chromosome_info);
break;
case 5:
((FirstImage) i).changeImage(R.drawable.dnahelix);
((ImageIn) h).changeImage(R.drawable.dnahelix,i);
j.clearInfo();
t.setText(Dnahelix_info);
next.setEnabled(false);
break;
default:
break;
}
count++;
}
});
back.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
switch (count)
{
case 1:
((FirstImage) i).changeImage(R.drawable.human);
((ImageIn) h).changeImage(R.drawable.human,i);
j.clearInfo();
t.setText(Hand_info);
back.setEnabled(false);
break;
case 2:
((FirstImage) i).changeImage(R.drawable.hand);
((ImageIn) h).changeImage(R.drawable.hand,i);
j.clearInfo();
t.setText(Hand_info);
back.setEnabled(true);
break;
case 3:
((FirstImage) i).changeImage(R.drawable.tissue);
((ImageIn) h).changeImage(R.drawable.tissue,i);
j.clearInfo();
t.setText(Tissue_info);
break;
case 4:
((FirstImage) i).changeImage(R.drawable.cell);
((ImageIn) h).changeImage(R.drawable.coordinatebestcolormatch,i);
j.clearInfo();
t.setText(Cell_info);
break;
case 5:
((FirstImage) i).changeImage(R.drawable.nucleus);
((ImageIn) h).changeImage(R.drawable.nucleus,i);
j.clearInfo();
t.setText(Nucleus_info);
break;
case 6:
((FirstImage) i).changeImage(R.drawable.chromosome);
((ImageIn) h).changeImage(R.drawable.chromosome,i);
j.clearInfo();
t.setText(Chromosome_info);
next.setEnabled(true);
break;
default:
break;
}
count--;
}
});
}
public void updateMsg(String info, float x, float y, int id,int num,double pix) {
// TODO Auto-generated method stub
k.setText(Float.toString(x)+"-"+Float.toString(y)+"-"+Double.toString(pix));
Log.w("DEBUG","which is null: " + k + " OR " + pix );
if(id==R.drawable.human)
t.setText(Human_info);
else if(id==R.drawable.hand)
t.setText(Hand_info);
else if(id==R.drawable.tissue)
t.setText(Tissue_info);
else if(id==R.drawable.cell)
t.setText(Cell_info);
else if(id==R.drawable.nucleus)
t.setText(Nucleus_info);
else if(id==R.drawable.chromosome)
t.setText(Chromosome_info);
else if(id==R.drawable.dnahelix)
{ if (pix==Color.YELLOW)
j.updateInfo(info, x, y, R.drawable.dnahelthyminecopy, num);
else if(pix==Color.GREEN)
j.updateInfo(info, x, y, R.drawable.dnaheladeninecopy, num);
else if(pix==Color.rgb(252, 223, 255))
j.updateInfo(info, x, y, R.drawable.dnahelguaninecopy, num);
else if(pix==Color.rgb(198, 174, 199))
j.updateInfo(info, x, y, R.drawable.dnahelcytosinecopy, num);
}
j.updateInfo(info, x, y, id, num);
}
public double getMaskColor(float x, float y){
return ((ImageIn) h).getmaskPixel(x, y,i,h);
}
}
/// my first image class is as follow
public class FirstImage extends ImageView implements OnTouchListener {
double pixel=0;
MotionEvent event;
TextView k;
int rid;
Bitmap image,bitmap;
String huma ="human";
String info = "human";
float x = 0; //init value
float y = 0; //init value
Animation animationFadeIn;
int t=0;
int i=1;
public FirstImage(Context context) {
super(context);
}
public FirstImage(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void changeImage(int id){
Bitmap imageres = BitmapFactory.decodeResource(getResources(), id);
this.setImageBitmap(imageres);
rid=id;
final Animation animationFadeout=AnimationUtils.loadAnimation(getContext(), R.anim.zoomin);
this.startAnimation(animationFadeout);
this.setOnTouchListener(this);
}
@Override
public boolean onTouch(View v, MotionEvent me) {
switch(me.getAction()){
case MotionEvent.ACTION_DOWN:
x=me.getX();
y= me.getY();
pageinfo(x,y);
break;
case MotionEvent.ACTION_MOVE:
x=me.getX();
y= me.getY();
pageinfo(x,y);
break;
case MotionEvent.ACTION_UP:
x=me.getX();
y= me.getY();
pageinfo(x,y);
break;
case MotionEvent.ACTION_OUTSIDE:
x=me.getX();
y= me.getY();
pageinfo(x,y);
break;
default: return true;
}
return false;
}
public void pageinfo(float x, float y) {
// TODO Auto-generated method stub
if(rid==R.drawable.human){
((AshActivity)getContext()).updateMsg(info, x,y,rid,t,pixel);
}
else if(rid==R.drawable.hand){
((AshActivity)getContext()).updateMsg(info, x,y,rid,t,pixel);
}
else if(rid==R.drawable.tissue){
((AshActivity)getContext()).updateMsg(info, x,y,rid,t,pixel);
}
else if(rid==R.drawable.cell){
double pixel = ((AshActivity)getContext()).getMaskColor(x, y);
((AshActivity)getContext()).updateMsg(info, x,y,rid,t,pixel);
}
else if(rid==R.drawable.nucleus){
}
else if(rid==R.drawable.chromosome){
}
else if(rid==R.drawable.dnahelix){
double pixel = ((AshActivity)getContext()).getMaskColor(x, y);
((AshActivity)getContext()).updateMsg(info, x,y,rid,i,pixel);
}
}
}
///// my image in back image class is as follow
public class ImageIn extends ImageView {
MotionEvent event;
TextView k;
int rid;
int pixel;
Bitmap image,image2;
double bmHeight ;
double bmWidth;
String huma ="human";
String info = "human";
float x = 0; //init value
float y = 0; //init value
// Animation animationFadeIn;
int t=0;
int i=1;
public ImageIn(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public ImageIn(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void changeImage(int id,ImageView i){
this.setMaxWidth(i.getWidth());
this.setMinimumHeight(i.getDrawable().getIntrinsicHeight ());
this.setScaleType(ImageView.ScaleType.CENTER);
Bitmap imageres = BitmapFactory.decodeResource(getResources(), id);
this.setImageBitmap(imageres);
rid=id;
}
public double getmaskPixel(float x, float y,ImageView i,ImageView h) {
/*// TODO Auto-generated method stub
this.setDrawingCacheEnabled(true);
// this is the important code :)
// Without it the view will have a dimension of 0,0 and the bitmap will be null
this.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
this.layout(0, 0, this.getMeasuredWidth(), this.getMeasuredHeight());
this.buildDrawingCache(true);
Bitmap image = Bitmap.createBitmap(this.getDrawingCache());
this.setDrawingCacheEnabled(false);
//image2 = BitmapFactory.decodeResource(getResources(), rid);
Log.w("DEBUG","which is null:image i " + i.getWidth() + " OR " +i.getDrawable().getIntrinsicHeight () );
Log.w("DEBUG","which is null:image h " + h.getWidth() + " OR " +h.getHeight() );
Log.w("DEBUG","which is null:image2 " + image2.getWidth() + " OR " +image2.getHeight() );
/*Context ctx=(AshActivity)getContext();
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight();
int newx=((width-i.getWidth())/2);
int newy=((height-i.getHeight())/2);
*/
//Bitmap image = Bitmap.createScaledBitmap(image2, i.getWidth(), i.getHeight(), false);*/
Matrix matrix = new Matrix();
BitmapFactory.Options bfoOptions = new BitmapFactory.Options();
bfoOptions.inScaled = false;
//Fit to your size
matrix.setScale(i.getWidth(), i.getHeight());
image2 = BitmapFactory.decodeResource(getResources(), rid);
Log.w("DEBUG","which is null:image i " + i.getWidth() + " OR " +i.getDrawable().getIntrinsicHeight () );
Log.w("DEBUG","which is null:image h " + h.getWidth() + " OR " +h.getHeight() );
Log.w("DEBUG","which is null:image2 " + image2.getWidth() + " OR " +image2.getHeight() );
//Set to UnAutoScale
Bitmap image = Bitmap.createBitmap(image2, 0, 0, image2.getWidth(), image2.getHeight(), matrix, true);
Log.w("DEBUG","which is null:image " + image.getWidth() + " OR " +image.getHeight() );
double bmWidth = image.getWidth();
double bmHeight = image.getHeight();
if ( x < 0 || y < 0 || x > getWidth() || y > getHeight()){
return 0; //Invalid, return 0
}else{
//Convert touched x, y on View to on Bitmap
int xBm = (int)(x * (bmWidth / getWidth()));
int yBm = (int)(y * (bmHeight / getHeight()));
return image.getPixel(xBm, yBm);
}
}
public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
// create a matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// recreate the new Bitmap
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
return resizedBitmap;
}
}
/// my draw class on the image is as folow
public class Draw extends View {
String info = "";
float x = 0;
float y = 0;
float z=0;
float t=0;
String info2="ashsish";
int color = Color.GREEN;
Bitmap bitmap;
int count=2;
public Draw(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public Draw(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setColor(color);
//paint.setStrokeWidth(15);
paint.setTextSize(12);
if (count==0){
canvas.drawLine(x-10, y, x+10, y, paint);
canvas.drawLine(x, y-10, x, y+10, paint);
canvas.drawText(info, x+3, y, paint);
}
else if (count==1)
canvas.drawBitmap(bitmap, z, t, paint);
}
public void updateInfo(String t_info, float t_x, float t_y,int id,int num){
x = t_x;
y = t_y;
if (num == 1){
bitmap = BitmapFactory.decodeResource(getResources(), id);
count=1;
}
else if(num==0){
info = t_info;
count=0;
}
final Animation animationFadeout=AnimationUtils.loadAnimation(getContext(), R.anim.fadein);
this.startAnimation(animationFadeout);
invalidate();
}
public void clearInfo(){
info = "";
x = 0;
y = 0;
count=2;
invalidate();
}
}
//my main xml class is as follow
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:name="http://schemas.android.com/apk/res/com.example.nam"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- Screen Design for VIDEOS -->
<TableLayout
android:id="@+id/tablelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dip"
android:text="pic on click which will tell where is the dna located in human body or cell "
android:textSize="18dip" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<com.example.nam.ImageIn
android:id="@+id/imagein"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="invisible"
/>
<com.example.nam.FirstImage
android:id="@+id/image"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
<com.example.nam.Draw
android:id="@+id/info"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
</FrameLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="left"
android:src="@drawable/monotone_arrow_next_left"/>
<Button
android:id="@+id/button2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:gravity="right"
android:src="@drawable/monotone_arrow_next_lrightcopy"/>
</LinearLayout>
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dip"
android:text="please don't mind "
android:textSize="18dip" />
</TableRow>
</TableLayout>
</ScrollView>
Revise this Paste