ImageMap


Source link: https://github.com/Pernifloss/ImageMap

ImageMap

Simple Android library to display bitmaps on top of an Image.

For now, you can get it on this repo

repositories {

maven {

  url "https://jitpack.io"

 
}

 
}

And add it as a dependency with

 compile 'com.github.Pernifloss:ImageMap:0.4.1'
  

You can test demo app here : https://appetize.io/app/e30ek8kmb8pmrg14r3xcr6qr5c

This library deliver two views, first the simple ImageMapView, it allow you to place items on an image and define where they are positioned and wich bitmap is drawn at this position. (a little bit like a map with marker but way simpler to use)

Here is a little demo of the simple ImageMapView, in this demo the user have to tap on the item which is asked on top :

How does it work? really simply

First define view on xml use src attribute to define the main image:

<com.zechassault.zonemap.view.ImageMapView

android:layout_width="match_parent"

android:layout_height="match_parent"

android:src="@drawable/my_image" /> 

You just have to define your adapter that extends MapAdapter !

An then you define specidied method :

  /** 
  * Define this function to target where the item is positioned on the image 
  * 
  * @param item Item to get position 
  * @return PointF(x, y) x and y are float 0 to 1 
  * x is ratio of image width (e. x = 0.5f  item is centered horizontally) 
  * y is ratio of image height (e. y =  1f  item will be at bottom) 
  */

public abstract PointF getItemCoordinates(T item);

/** 
  * Define this function to indicate which item the given position correspond to 
  * 
  * @param position int, index of item 
  * @return the item corresponding to the position index 
  */
  public abstract T getItemAtPosition(int position);

/** 
  * define this function to specifie the number of item you want to display 
  * 
  * @return int, the number of item to display 
  */

public abstract int getCount();

/** 
  * Override this method to a custom bitmap to draw for each element 
  * 
  * @param item the item of which the bitmap will correspond 
  * @return the Bitmap to draw for given item 
  */
  public abstract Bitmap getItemBitmap(T item);
 

You can then interact with items by setting the itemClickListener of your addapter.

If you want an exemple feel free to clone the project, it has a demo app that display an ImageViewMap.

The other view is called NoteImageView, it's like ImgeView map, but you also have labels diplayed on both side on the image, they are liken to the items. Like the following :

Label click are also considered as click on specified item !

You can customize labels, you can tell where the label is linked to the item image. By default it's linked to the center.


private PointF centerAnchor = new PointF(0.5f, 0.5f);

/** 
  * Override this method to change the anchor calculation based on the bitmap 
  * PointF(0.0f,0.5f) will anchor the line to the center left of the bitmap 
  * @param item the item to define the anchor 
  * @return anchor as PointF 
  */
  public PointF getAnchor(T item) {

return centerAnchor;
  
}

By overiting the right method can also define the Paint used for writing text, so you can change color, style and font of labels. the same apply for line.

 /** 
  * Override this function to define your own Paint for label drawing 
  * 
  * @param item the item to which the legend is linked 
  * @return the labelPaint of to draw the label 
  */
  public Paint getLabelPaint(T item) {

return labelPaint;
  
}

/** 
  * Override this function to define your own Paint for lines 
  * 
  * @param item the item to which the legend is linked 
  * @return the labelPaint of to draw the label 
  */
  public Paint getLinePaint(T item) {

return linePaint;
  
}

  

There is a way of telling on wich side you want a label to appear.

Please note that this library is still in development, and i will be glad to correct bugs and add new features!

We made the choice to manipulate bitmap and paint for maximum flexibility and customisation, but don't worry the library come with a helper that convert drawable to bitmap.

Resources

Smart Fonts is an Android Studio Library which makes it easy to use Custom Fonts (TTF or OTF) in your apps. It handles the Android text widgets (TextView, EditText, CheckBox, RadioButton...). You can add any other widgets easily, including your own classes!

You can use Styles, and see the result directly in the Layout Editor!

A manager handles the caching of the fonts so that they are loaded only once. If a font is not used it is not loaded.

It is easy to integrate with gradle.

A pretty label layout.

Android project to experiment with various number of testing tools. It uses Java and Kotlin languages. Priority is given to fluency and ease of use. The idea is to provide a toolbox to write elegant and intelligible tests, with modern techniques like behavior-driven testing frameworks or fluent assertions.

Materially inspired widgets and views.

Just a simple library for Android that provides setting custom font on TextView from xml layout or Java class.

Observe Android's CONNECTIVITY_CHANGE broadcasts using RxJava.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes