Android Customized Barchart - java

I need to create a chart like this picture bellow in Android.
and I am already aware of MPAndroidChart and AndroidHelloCharts libraries. but none of them are capable of drawing such thing.
do you know any way to create a chart like this?
please explain and at least suggest me some tutorials or articles that are related to what I am about to do.
thank you

Its actually pretty simple to create your own bar chart.
First you need to use drawRect to draw a rectangle.
And then drawText to draw text below the rectangle.
You may have noticed that both methods take a paint object as the parameter , you can think of the paint object like a brush. So you set the color to the brush and draw different elements.
I have written about it
here

Related

Convert Shape from awt to Shape in javafx

I want to display Shape on Pane in JavaFx. I am using oracle JGeometry object selected from spatial database, it has a method createShape() but it returns java.awt.Shape.
Is it possible to create JavaFx object also so easily? Maybe I am just blind but I haven't found anything and don't want to program too much stuff on top. Thank you
Java only supports a handful of shapes, so it is not very difficult to write a little converter but if all you want to do is to draw the AWT shapes on a JavaFX canvas, then maybe this library can be helpful: http://www.jfree.org/fxgraphics2d/

Libgdx display text/score as actor on stage

I would like to display multiple texts/scores on my stage. This tutorial suggested SpriteBatch, however, the issue is that these texts won’t fade out (not actor). Certain posts suggested use table, but the issue is that I can’t set texts' position on stage. Is there any other way to display texts as an actor on stage without using table?
Thanks in advance.
Zi
You can create a subclass of actor and draw text as you like in it's overridden draw method.
Just don't forget to set alpha before drawing using setColor method. The value of alpha will be available as a parameter for draw.
You then can fade it the way you want.
Good luck.

How to paint the portion of the image inside its border line via using libgdx?

I am creating an image painting app in libgdx where user would touch the portion of the image. e.g If the user touch the wheels of a car that should turn into the selected color.
I don't really know how to specify the custom area around the touch. That can be a wheel, a door which are not always rectangle and circle. I just need an idea to do it. Whether libgdx pixelmap can achive this. I have to paint the image inside the border line of the touch region. I hope my problem is clearly stated.
I woule really appreciate for your time for giving the answers. Thanks in advance
I think you want to look at flood fill algorithms. I don't think there is any built-in support for this in libGDX, but you should be able to implement your own flood fill on a libGDX pixmap.

Drawing a simple game board in Android

I have some C# experience, but im completly new to java. So i have some questions for someone with more experience.
I would like to draw a simple game board of for example 10x10 grey boxes. So i figured a 2d array might be useful:
int gameBoard[][] = new int[10][10];
For each board i would like to draw a grey rectangle, and place it it some control to be rendered on the device.
I suppose this can be done with an instance of Paint and Canvas
And this is where im stuck at the moment. What controls are best suited for this? Any help is much appreciated.
Take a look at this link, it explains very clearly the differences between canvas, paint and bitmap and finishes with an example of an app that draws a colored rectangle and displays it in an ImageView. Hope it can be useful.
Better use GridView or TableView for the box structure. Further , if you will wand something to crawl over boxes, it will be another activity on the deskboard one. There you'll maybe use bitmaps. THis way you will save heaps of time.
I would probably go with the TableLayout, which I guess is what Gangnus meant with TableView
There is a tutorial for TableLayout here:
http://developer.android.com/resources/tutorials/views/hello-tablelayout.html
In your case you would put 10 views in each of 10 rows. You can chose to create them in the xml file or from the java file.

JXMapViewer change orientation to Heading Up

I am trying to use JXMapViewer (from swingx-ws) with Open Street Maps. I was wondering if it would be possible to display the map tiles in the JXMapViewer based on heading up, rather than on North up. For example, the normal car GPS navigation systems let you do that.
I've looked through the documentation and there doesn't seem to be a straightforward way to do this. Is there something else that accomplish this, besides JXMapViewer?
Nevermind, I found a solution. Here is how I did it(if anybody is interested) :
I subclassed JXMapViewer, and overrode the paint method.
In the paint method contents of the JPanel are converted to a BufferedImage which is then rotated according to an angle and then painted on top of the panel.
so super.paint()-> BufferedImage-> apply an affineTransformation to it-> draw the new Image.
Of course, you would also need to override the convertGeoPositionToPoint and convertPointToGeoPosition methods taking into account the fact that the image is rotated.

Categories

Resources