Statistics curve on android app - android

I'm trying to make an app where I can show some statistics.
I have some data that I collect from an STM microcontroller each 5 minutes, and with those data, i want to be able to draw a curve with this data, something like this :
https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQ56Bh-zxV5SZ0OYfaO0sLlxYCuZG0PbDtRR95opMtU80SPDx2r
So, what element in android can allow me to do so and how should i process the data i have ? I thought about using canvas, and making point then drawing the curve using those points, is that a valid method ?
And thanks

You can implement your own CustomView, which allows you to draw, like in a canvas. You can draw lines, curves and charts, but you must implement it manually, by extending and overriding View class method. But it isn't hard. The abilities of the CustomView is wide, you can even use it for simple games. So check this tutorial, if you want to know more.
But if you haven't time for it, you can use libraries, that do all work for you, just like this.

find some components to try in the Graphics section https://android-arsenal.com/free
william chart looks really cool!

Related

Display Watch Face in android activity

I'd like to display a watch face I've developed in my app and have it appear live as though it was on a watch. The class and engine already exist so i feel like it shouldn't be too hard to get it to appear within an activity. Does anyone have experience with this or have a suggestions as to which path to take in attempting this?
It should be fairly easy to achieve. What you need to do is this:
extract all the drawing logic; which is whatever code is interacting with Canvas.
create a custom View and in View.onDraw(Canvas) use the extracted code to draw the watch face.
In the end everything draws on a Canvas, so you can (more or less) transfer functionality from View objects to WallpapersService. View system is an abstraction on top of Canvas.

Motion to draw numbers on android

im new to this android things. And i have to develop an application that can help an autism to learn numbers. I have a few ideas and I've been trying to learn and implement the code. But it's failed. The question is how can i apply the motion code or sprite to draw a numbers or letter? For example like this, i wanna make the penguin move through the line and draw a number nine.
There is example from mybringback.com which is the image move to draw a rectangle. How can i implement it to draw a number? Im sorry if i asking too much, i just trying to get some ideas.
I think that you should first build an utility program, in order to create the "path vector".
What I mean by path vector is simply a vector of Points (where a point has x value, and y value). And your utility should let you draw whatever you want, with a simple pen. You should draw on surface and store points when mouse is down, and ignore points when mouse is up.
Then, in the main program, you will just have to read at the path of your number/letter.
I've tried to implement something like this for the Sugar OLPC platform, without serializing path into files : I was able to draw, and to view the animation. And I used the process I've just described you.
Hope it can help you.
P.S : I used the word mouse, but you guessed that I talk about finger ...
There are various ways to achieve animation effects. One approach that is quite versatile involves creating a custom View or SurfaceView in which you Override the onDraw method. Various tutorials can be found on this; the official Android discussion of it is here:
http://developer.android.com/guide/topics/graphics/2d-graphics.html#on-view
Your implementation will look something like this:
// Find elapsed time since previous draw
// Compute new position of drawable/bitmap along figure
// Draw bitmap in appropriate location
// Add line to buffer containing segments of curve drawn so far
// Render all segments in curve buffer
// Take some action to call for the rendering of the next frame (this may be done in another thread)
Obviously a simplification. For a very simplistic tutorial, see here:
http://www.techrepublic.com/blog/software-engineer/bouncing-a-ball-on-androids-canvas/1733/
Note that different implementations of this technique will require different levels of involvement by you; for example, if you use a SurfaceView, you are in charge of calling the onDraw method, whereas subclassing the normal View lets you leave Android in charge of redrawing (at the expense of limiting your ability to draw on a different thread). In this respect, Google remains your friend =]

Using View objects to make simple Android-game

I'm making a board for Android. I use .png images for the board (background) and checker pieces. Basically, it's a game where the graphics are updated upon touch events. It's a school-assignment so I have to use View implementations. For the graphics I've considered two options:
Making a whole "BoardView" class (that extends View) and draw all the graphic components directly on the canvas using onDraw(canvas).
Using ImageView objects to represent each checker piece and the board and putting them on a Layout.
My intuition tells me to use the first method. But my thoughts are that I want to use the pre-implemented TranslateAnimation when a checker is moved. From my understandings; this forces me to use the second method, since I can't animate a Drawable.
Now, to the question: what method is best for me? And if the second; which Layout is preferred to use? I want to be able to overlap the checkers over the board image and compare the ImageView objects' positions to each other to determine where to put the checkers on the board.
Regarding to your simple requirement, I think you can adopt method 2.
Trust me, I have done this kind of stuff years ago, on a legacy linux platform. For these kind of simple game applications, you really do not need to bother with all the frame drawing stuff. Just stick with the existing UI widgets.
This is because the visible elements are all very simple, like cards, static images, blocks etc. You don't need to perform pixel drawing. I have tried to make tetris, mine sweep, and card match games. I even create simple visual effects for it using existing animation facility. That is very easy to do so.
And, of cause, as a software programmer, to write a game using the typical frame by frame approach is much more professional. But it depends on the requirements. Why not using less code to create more value?

Best way to draw tournament bracket in Android

I need to draw a tournament bracket in Android. I already calculated the positions for all games (i.e. an (x,y) tuple that defines where to place teams in a spreadsheet-like structure). However, I don't know the preferred way of drawing the bracket. I found an example that shows what I need:Example
My first idea was to programmatically create and fill a TableLayout. However, borders are not really supported and a lot of TextViews are needed to fill the space between games. So I am not sure if this is the best way to do it.
Does anyone have better suggestions or maybe even an example of something similar?
I'd suggest custom drawing using Canvas. That way you can draw wherever it makes sense and probably even support zooming without too much work.

android drawing on photos

I am looking to be pointed in the right direction for help. What I want to do is take a picture, and then be able to highlight certain aspects of it (i.e circle a door, comment on a color) right onto the picture. Basically what a Samsung note can do. What android package would I be looking at? What it looks like to me, is that I would use the picture as a canvas and then draw on top of the canvas(which is the picture), is that it basically summed up? Or am I missing something?
Another thing that I would like to do with the picture is add data for future identification. I know android has their Exif Interface for this, but what I cant seem to find any information on is, it possible to create my own tags for this class? For example adding a "who took it" tag.
You're going to need a custom view and override the onDraw method of the view. In the onDraw method you get a reference to a Canvas object. From there, you can do most of whatever drawing you need. If you want to take user input and draw with it, you're going to have to override the touch events, and keep track of what you want to draw and then draw in the onDraw method.
As for Exif data. If you want to develop for before Android 2.0, then you need a 3rd party library, I use sanselanandroid personally. If you don't care about pre 2.0, I head ExifInterface works well too. It looks like you can save any arbitrary tag using ExifInterface because it just uses a string tag, and then string value, but know that only your app will know to read that tag.

Categories

Resources