kumo icon indicating copy to clipboard operation
kumo copied to clipboard

How to use your library for android?

Open nicks258 opened this issue 8 years ago • 14 comments

@zapodot @JNKHunter @kennycason @rj93 @rzo1

nicks258 avatar Jun 16 '17 13:06 nicks258

My guess is that you just important and follow the examples on the README. I'm honestly not sure if there is anything "special" about android that would require special use. Can you paste specific issues/errors you find here?

kennycason avatar Jun 19 '17 05:06 kennycason

but how to download this library for android as there is no dependency for this i found ->// ``` https://mvnrepository.com/artifact/com.kennycason/kumo compile group: 'com.kennycason', name: 'kumo', version: '1.0' but in this FrequencyAnalyzer is not defined how to solve this issue. thanks in advance.

nicks258 avatar Jun 26 '17 08:06 nicks258

You should use: https://mvnrepository.com/artifact/com.kennycason/kumo-core/1.11

rzo1 avatar Jun 26 '17 08:06 rzo1

@kennycason This isn't as simple as it should be because java.awt is not supported on Android, thus the Dimension class is not supported when creating a WordCloud object. There is no problem importing this project and compiling it, but implementing it is another issue.

Unless I'm misreading your code and Dimension doesn't use java.awt?

jamespfluger avatar Aug 04 '17 20:08 jamespfluger

core contains a lot of java.awt classes...

rzo1 avatar Aug 04 '17 21:08 rzo1

Right, but Dimension is something that requires an import of java.awt. I don't know how well the other classes work (the ones within core), but I do know that Dimension can't be imported because Android doesn't support it. And if Dimension can't be imported, then the library can't be used. Some aspects should work fine, but the drawing features likely won't.

If core uses a lot of java.awt, which doesn't surprise me, then I doubt the rest of the library would work anyways.

If you have gotten it to work, let me know how because I don't see a way.

jamespfluger avatar Aug 04 '17 22:08 jamespfluger

Well I spent the past couple days working on rewriting Kumo in Android, but there are just too many functions that I don't know what the proper Android equivalent would be.

I think it might be easier to write a whole new library than try and figure out what lines are portable.

Either that or create a REST API and host Kumo on an external server.

jamespfluger avatar Aug 08 '17 00:08 jamespfluger

@jamespfluger I'm admittedly not super up-to-date on all the intricacies/limitations of Android development. If you could highlight the core problems. I'd be happy to look into solving them if possible.

@rzo1 I read up more on java.awt missing from Android, of which I was completely unaware of. This seems like it would indeed be a massive refactoring. Thoughts?

kennycason avatar Aug 08 '17 20:08 kennycason

core module heavily rely on awt-classes including classes like BufferedImage, Dimension. If I remember it right, the WordCloud class is based upon BufferedImage.

In order to use it in Android, we would need to introduce some sort of abstract layer for WordCloud (+ some sort of implementation specific factory) and separate Drawing-Algorithmns (atm on BufferedImage) in WordCloud (and related classes) to an own module.

Based on this abstract layer, one could implement the Drawing-Algorithmn stuff android compatible in an separate module.

Dependency would change in kumo-core + kumo-awt (normal usecase) or kumo-core + kumo-android

rzo1 avatar Aug 09 '17 07:08 rzo1

Seems in line with what I was thinking. Will definitely not be trivial. I'll investigate next time I jump into Kumo

kennycason avatar Aug 10 '17 00:08 kennycason

Has there been any development on this? Would have loved to use this in a hackathon but I can't seem to get it to work at all. Missing libraries and incompatible types with Android.

Leniox avatar Jan 28 '18 05:01 Leniox

@Leniox Unfortunately I am pretty disconnected with Android development and outside of what's in this thread and am not super up-to-date. I would be happy if someone wanted to make it support Android. I promise that the next time I dig into Kumo I will investigate Android support. :)

kennycason avatar Jan 30 '18 10:01 kennycason

I have a need for a kumo implementation on Android, too :D There are further problems, because Android also doesn't allow some of Javas default file writing interfaces, but I've ignored that for now. Just to get a better idea of what we're looking at, I've made a list of all java.awt classes used in kumo, and which methods of those were used. Next to them are the Android equivalents, if I found some.

Point new ...(x, y) => new ...(x, y) [access x, y] => [access x, y] -> Point

Dimension new (width, height) ->None, but a custom implementation would be trivial

Color new(red, green, blue) => Color.argb(alpha, red, green, blue) getRed() => Color.red(c) getGreen() => Color.green(c) getBlue() => Color.blue(c) ->Color (in Android, colors are usually represented by an int))

Graphics [gotten from BufferedImage] => new ...(bitmap) drawImage(bufferedImage, x, y, [null observer]) => drawBitmap(bitmap, x, y, paint) setColor(color) [backgroundcolor] =>drawColor(c) [fills the entire Canvas with that color] fillRect(0, 0, dimension.width, dimension.height) => drawRect(x, y, width, height, paint) getFontMetrics(font) => X

Graphics2D translate(x, y) => translate(dx, dy) rotate(theta, x, y) =>rotate(degrees, xPivot, yPivot) drawRenderedImage(buff, xForm:null) => X dispose() => X setRenderingHint(TEXT_ANTIALIASING, TEXT_ANTIALIAS_LCD_HRGB) => paint.setAntiAlias(aa) setFont(font) => paint.setTypeface(typeface) [for paint see directly below] drawString(word, x, y) =>drawText(x, y, paint) -> Canvas

BufferedImage new(width, height, type) => Bitmap.createBitmap(width, height, config) getWidth() => getWidth() getHeight() => getHeight() createGraphics()/getGraphics() => [See above, Canvas is created from Bitmap] getRGB(x, y) => getPixel(x, y) -> BitMap

Font PLAIN/BOLD/ITALIC => NORMAL/BOLD/ITALIC/BOLD_ITALIC new(string type, weight, DEFAULT_WEIGHT) => Typeface.create(String familyName, style) Font.createFont(TRUETYPE, file/inputstream) => Typeface.createFromFile(file/path) -> Typeface

GraphicsEnvironment getLocalGraphicsEnvironment() => X registerFont(font) => X

FontFormatException getMessage() -> ...

FontMetrics getMaxDescent() => fontMetrics.bottom stringWidth(word) => paint.measureText(text) getHeight() => fontMetrics.top getFont() => paint.getTypeface() -> Paint.FontMetrics/Paint (there's paint.getFontMetrics())

RenderingHints [constants]

One way or the other, Android compatibility will mean to create a seperate version, or introduce lots of breaking changes.

Namnodorel avatar Jan 05 '19 19:01 Namnodorel

Wordcloud for android, here you go mates https://github.com/sirmordred/WordCloud 👍

sirmordred avatar Jan 18 '19 20:01 sirmordred