ArcGIS runtime for Android development tutorial V2.0 (7) Basics-spatial element visualization 2

Source: Internet
Author: User
1-symbol rendering 1.1
Symbol

Symbol is mainly an interface for style setting of graphic objects. All style-compliant classes have implemented the symbol interface. The symbol interface diagram is as follows:

 

1.2 picturemarkersymbol

Picturemarkersymbol is a class for style setting of graphic objects with vertices or multi-point elements. picturemarkersymbol mainly sets image conformity through URL or drawable of images, for picturemarkersymbol, we can also set the Rotation Angle and position offset that match the image. The usage is as follows:

// Create an image style that complies with picturemarkersymbol PIC = new picturemarkersymbol (getresources (). getdrawable (R. drawable. icon); point Pt = new point (); // create a vertex object graphic Gp = new graphic (PT, PIC); Set graphicslayer to conform to the style. addgraphic (GP); add to Layer

 

1.3 simplefillsymbolds

Simplefillsymbol is a class for style setting of graphic objects of a surface element. Through this class, we can set the fill color and transparency of the surface element, in addition, we can also add border style settings for the surface elements. simplefillsymbol is very easy to use, as shown below:

Polygon poly = new polygon (); // create a polygon object Poly. startpath (new point (0, 0); // Add the initial point Poly. lineto (new point (10, 0); Poly. lineto (new point (10, 10); Poly. lineto (new point (); // The polygon is closed. Therefore, we need to add the initial vertex position simplefillsymbol SFS = new simplefillsymbol (color. red); // surface style object SFs. setalpha (50); // sets the transparency. Graphic Gp = new graphic (poly, SFS); graphicslayer. addgraphic (GP); add to Layer

 

1.4 simplelinesymbol

Simplelinesymbol is a class for style setting of graphic objects of linear elements. With this class, we can set the style of linear elements, for example, you can set the line type, line color, line width, and line transparency. The specific usage is as follows:

Polyline poly = new polyline (); // create a polygon object Poly. startpath (new point (0, 0); // Add the initial point Poly. lineto (new point (10, 0); Poly. lineto (new point (10, 10); simplelinesymbol SLS = new simplelinesymbol (color. red, 25, simplelinesymbol. solid); // line style object SFs. setalpha (50); // sets the transparency. Graphic Gp = new graphic (poly, SLS); graphicslayer. addgraphic (GP); add to Layer

 

1.5 simplemarkersymbolds

Simplemarkersymbol is also a class for style setting of graphic objects of point elements. We have already introduced a related point element style class picturemarkersymbol. simplemarkersymbol is similar to picturemarkersymbol, only one is rendered as a vector point, and the other is replaced by an image. With simplemarkersymbol, we can set the dot style, such as the dot size, the dot color, and the dot type. The usage is as follows:

Point point = new point (); // create a point object point. setx (114); // set the X coordinate point. sety (32); // set Y coordinates // set the color, size, and point type of the vertex style simplemarkersymbol SMS = new simplemarkersymbol (color. red, 25, style. circle) graphic Gp = new graphic (point, SMS); graphicslayer. addgraphic (GP); // Add to layer to display

 

1.6 textsymbol

Textsymbol is also a class for style setting for graphic objects of point elements. It replaces the position of a point with text for painting and display, textsymbol allows you to set the text size, color, content, and arrangement. The layout is to display only the text in horizontal or vertical la S. By default, the text is displayed in horizontal la S. The usage is as follows:

Point point = new point (); // create a point object point. setx (114); // set the X coordinate point. sety (32); // set Y coordinates // set the color, size, and text content of the vertex style textsymbol Ts = new textsymbol (12, "vertex style", color. red); graphic Gp = new graphic (point, TS); graphicslayer. addgraphic (GP); // Add to layer to display
1.7
Renderer

Renderer is an interface type. This interface is mainly used for style rendering of graphic objects. It currently has four implementation classes. The functions and usage of these four classes are described in the following sections, the diagram is as follows:

 

 

1.8 simplerenderer

 

Simplerenderer is the simplest rendering class. With this rendering class, we can render elements of a certain type in the layer at the same time, to render all vertices in a layer into the same style at the same time, the usage is as follows:

Simplerenderer Renderer = new simplerenderer (New simplemarkersymbol (color. Red, 25, style. Circle); graphicslayer. setrenderer (Renderer); // set rendering for layers

 

1.9 classbreaksrenderer

Classbreaksrenderer is the implementation class of the Renderer interface. Using classbreaksrenderer, we can perform multipart rendering of a certain type of graphic object in the graphicslayer layer. Its usage is as follows:

Classbreaksrenderer Renderer = new classbreaksrenderer (); Renderer. setminvalue (0.0); // set the minimum Renderer. setfield ("pop07_sqmi"); // The classbreak CB1 = new classbreak (); // defines the rendering range and style cb1.setclassmaxvalue (25) of the first section ); cb1.setsymbol (New simplefillsymbol (color. argb (128, 56,168, 0); cb1.setlabel ("First Class"); classbreak CB2 = new classbreak (); // define the rendering range and style cb2.setclassmaxvalue (75); cb2.setsymbol (New simplefillsymbol (color. argb (128,139,209, 0); cb2.setlabel ("Second Class"); classbreak CB3 = new classbreak (); // defines the rendering range and style cb5.setclassmaxvalue (double. max_value); cb5.setsymbol (New simplefillsymbol (color. argb (128,255, 0, 0); Renderer. addclassbreak (CB1); Renderer. addclassbreak (CB2); Renderer. addclassbreak (CB3); graphicslayer. setrenderer (Renderer); // sets rendering for the Layer

Through the above code, we can find that multipart rendering is very simple, with the following steps:

1) create a classbreaksrenderer object

2) set the rendering field and minimum value

3) create multiple multipart rendering objects (classbreak) and set the maximum value and Style

4) Add the multipart rendering object to the classbreaksrenderer object.

5) set the Renderer object for the Layer

2.0 uniquevaluerenderer

 

Uniquevaluerenderer is a unique value rendering class. This rendering method is to render the unique value of a field. For example, we have a hierarchical data, and one field is the data classification of this layer, in this case, we can render the unique value of this classification field: the type of the residential building is yellow, the factory is purple, and the commercial area is red, we can also perform joint unique value rendering for multiple fields. A maximum of three fields can be combined for rendering. The usage is as follows:

Uniquevaluerenderer UVR = new uniquevaluerenderer (); UVR. setfield ("type"); uniquevalue uv1 = new uniquevalue (); UV. setvalue (New String [] {"Residential"}); UV. setsymbol (New simplefillsymbol (color. argb (128,255,100, 0); uniquevalue uv2 = new uniquevalue (); UV. setvalue (New String [] {"Industrial"}); UV. setsymbol (New simplefillsymbol (color. argb (128,255,200, 0); uniquevalue UV3 = new uniquevalue (); UV. setvalue (New String [] {"commercial"}); UV. setsymbol (New simplefillsymbol (color. argb (128,255,150, 0); UVR. adduniquevalue (uv1); UVR. adduniquevalue (uv2); UVR. adduniquevalue (UV3); graphicslayer. setrenderer (UVR); // sets rendering for layers

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.