As said previousely, an abstract graphics system is defined to let Guidebee Map API support multiple platforms with the same binary library. Here’s an example on Java ME platform, you can use MIDP’s LCDUI or Sun’s LWUIT as the UI framework to write applications.
The demo code includes two sample concrete implementation for the com.mapdigit.gis.drawing package. One for standard MIDP library, one for Sun’s LWUIT library.
As a matter of fact, the same Java ME library also works on Blackberry platform, developer for Blackberry can either write Java ME Midlet or write Blackberry application using blackberry Java APIs. Guidebee also provides the Graphics system implementation for blackberry, so you can also use Guidebee Map API for blackberry applications.
The Gis.Drawing defines the minimum classes and methods necessary used by the API library. And if you don’t want to use vector map, you can just provide empty implementation for some methods. And normally you don't need to implement these interfaces for your desired platform. Guidebee Map API package provide the default implementation for you already.
Here list the detailed classes and interfaces defined in Gis.Drawing package, it’s quite a small function set so it’s quite easy to support new graphics system if you want.
In 2.4 defines the following
AbstractGraphcsFactory | Factor class, used to create other graphics objects like font, graphics ,images etc. |
IGraphics | Interface for Graphics object used to draw font, images etc, |
IFont | Font interface. |
IImage | Image interface. |
Class AbstractGraphcsFactory Definition
Java Definition
Method | Description |
abstract public IImage createImage (int[] rgb, int width, int height); | Create an image instance from rgb array. Rgb is the integer array, width, height are the size of the image. And the pixel format is ARGB array. |
abstract public IImage createImage (byte[] bytes, int offset, int len); | Create an image instance for byte array. The byte array is the PNG image content. |
abstract public IImage createImage(int width, int height); | Create an empty image instance with given width and height. |
C# Definition
Method | Description |
public abstract IImage CreateImage(int[] rgb, int width, int height); | Create an image instance from rgb array. Rgb is the integer array, width, height are the size of the image. And the pixel format is ARGB array. |
public abstract IImage CreateImage(byte[] bytes, int offset, int len); | Create an image instance for byte array. The byte array is the PNG image content. |
public abstract IImage CreateImage(int width, int height); | Create an empty image instance with given width and height. |
Interface IGraphics Definition
Java Definition
Method | Description |
public void setClip(int x, int y,int width,int height) | Set the clip region for this graphics. Can use empty implementation. |
public void drawImage(IImage img, int x, int y); | Draw an image at given location. |
public void drawLine(int x1, int y1, int x2, int y2) | Draw a line. |
public void setColor(int RGB); | set the draw or fill color |
public void fillRect(int x, int y, int width, int height); | Fill a rectangle. |
public void drawRect(int x,int y,int width, int height); | Draw a rectangle. |
public void drawString(String str,int x,int y); | Draw a string. Only needed for vector map. |
public void setFont(IFont font); | Set font. Only needed for vector map. |
public void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3); | Fill a triangle. Only needed for vector map. |
C# Definition
Method | Description |
void SetClip(int x, int y, int width, int height); | Set the clip region for this graphics. Can use empty implementation. |
void DrawImage(IImage img, int x, int y); | Draw an image at given location. |
void DrawImage(IImage img, int x, int y,int transparentColor); | Draw an image at given location.Only need for windows mobile. That’s because windows mobile 6 doesn’t support PNG transparency. |
void DrawLine(int x1, int y1, int x2, int y2); | Draw a line. |
void SetColor(int rgb); | set the draw or fill color |
void FillRect(int x, int y, int width, int height); | Fill a rectangle. |
void DrawRect(int x, int y, int width, int height); | Draw a rectangle. |
void DrawString(string str, int x, int y); | Draw a string. Only needed for vector map. |
void SetFont(IFont font); | Set font. Only needed for vector map. |
Class IFont definition,IFont is only needed for vector map. For other circumstances it can have empty implementation.
Java Definition
Method | Description |
public Object getNativeFont(); | Get the native font object. |
public int charsWidth(char[] ch, int offset, int length); | Calculate the chars width with this font. |
C# Definition
Method | Description |
object GetNativeFont(); | Get the native font object. |
int CharsWidth(char[] ch, int offset, int length); | Calculate the chars width with this font. |
Class IImage Definition
Java Definition
Method | Description |
public IGraphics getGraphics(); | Get the graphics object associated with this image. |
public int[] getRGB(); | Get the RGB array of this image. Only needed for vector map. |
public int getHeight() | Get the height of the image. |
public int getWidth(); | Get the width of the image. |
public Object getNativeImage(); | Get the native image assocated with this Image object. |
C# Definition
Method | Description |
IGraphics GetGraphics(); | Get the graphcis object associated with this image. |
int[] GetRGB(); | Get the RGB array of this image. Only needed for vector map. |
int GetHeight(); | Get the height of the image. |
int GetWidth(); | Get the width of the image. |
object GetNativeImage(); | Get the native image assocated with this Image object. |
No comments:
Post a Comment