예제 #1
0
	    public override IList<IElement> End(IWorkerContext ctx, Tag tag,
				    IList<IElement> currentContent) {
    		
		    IList<IElement> elems = new List<IElement>();
    		
		    IDictionary<String, String> attributes = tag.Attributes;
    		
		    if(attributes != null && attributes.ContainsKey("d")) {
			    String fullPath = attributes["d"];
    			
			    PathItem.Builder itemBuilder = null;
			    PathBean.Builder pathBuilder = new PathBean.Builder();
    			
			    IList<String> list = SplitPath(fullPath);
                if (list != null) {
                    foreach (String str in list) {
                        if (str.Length == 1 && Char.IsLetter(str[0])) {
                            if (itemBuilder != null) {
                                pathBuilder.SetPathItem(itemBuilder.Build());
                            }
                            itemBuilder = new PathItem.Builder();
                            itemBuilder.SetType(str[0]);
                        } else if (itemBuilder != null) {
                            itemBuilder.AddCoordinate(str);
                        }
                    }
                }
		        if(itemBuilder != null){
				    pathBuilder.SetPathItem(itemBuilder.Build());
			    }
    			
			    elems.Add(new Path(pathBuilder.Build(), tag.CSS));
	    	    return elems;
		    } else {
			    return new List<IElement>(0);
		    }        
	    }
예제 #2
0
        public override IList<IElement> End(IWorkerContext ctx, Tag tag,
                    IList<IElement> currentContent)
        {

            IList<IElement> elems = new List<IElement>();

            IDictionary<String, String> attributes = tag.Attributes;

            if (attributes != null && attributes.ContainsKey(POINTS))
            {
                String str = attributes[POINTS];

                StringTokenizer tokenizer = new StringTokenizer(CleanPath(str), ", \t\n\r\f");
                IList<String> values = new List<String>();
                while (tokenizer.HasMoreTokens())
                {
                    String value = tokenizer.NextToken().Trim();
                    //System.out.Println(value);
                    values.Add(value);
                }
                PathBean.Builder pathBuilder = new PathBean.Builder();
                if (values.Count % 2 == 1)
                {
                    values.RemoveAt(values.Count - 1);
                }

                if (values.Count % 2 == 0)
                {
                    for (int i = 0; i < (values.Count / 2); i++)
                    {
                        PathItem.Builder itemBuilder = new PathItem.Builder();
                        if (i == 0)
                        {
                            itemBuilder.SetType('M');
                        }
                        else
                        {
                            itemBuilder.SetType('L');
                        }
                        itemBuilder.AddCoordinate(values[i * 2]);
                        itemBuilder.AddCoordinate(values[(i * 2) + 1]);
                        pathBuilder.SetPathItem(itemBuilder.Build());
                    }
                }
                if (tag.Name.Equals(SvgTagNames.POLYGON))
                {
                    PathItem.Builder itemBuilder = new PathItem.Builder();
                    itemBuilder.SetType('z');
                    pathBuilder.SetPathItem(itemBuilder.Build());
                }

                elems.Add(new Path(pathBuilder.Build(), tag.CSS));
                return elems;
            } else {
                return new List<IElement>(0);
            }
        }