public bool IsCompleteTree(TreeNode root) { List <AnnotationNode> nodes = new List <AnnotationNode>(); AnnotationNode tempNode = null; int count = 0; nodes.Add(new AnnotationNode(root, 1)); while (nodes.Count > count) { tempNode = nodes[count++]; if (tempNode.Node.left != null) { nodes.Add(new AnnotationNode(tempNode.Node.left, tempNode.Position * 2)); } if (tempNode.Node.right != null) { nodes.Add(new AnnotationNode(tempNode.Node.right, tempNode.Position * 2 + 1)); } } return(nodes[nodes.Count - 1].Position == nodes.Count); }
protected virtual bool TryCreateHandler(AnnotationNode annotation, WebFileNode webfileNode, IPortalContext portal, out IHttpHandler handler) { if (annotation != null) { // convert to Entity object and populate the documentbody attribute value var portalOrgService = HttpContext.Current.GetOrganizationService(); var entity = annotation.ToEntity(); var body = portalOrgService.RetrieveSingle("annotation", new[] { "documentbody" }, new Condition("annotationid", ConditionOperator.Equal, annotation.Id)); entity.SetAttributeValue("documentbody", body); var webfile = webfileNode != null ? portalOrgService.RetrieveSingle("adx_webfile", FetchAttribute.All, new Condition("adx_webfileid", ConditionOperator.Equal, webfileNode.Id)) : null; handler = CreateAnnotationHandler(entity, webfile); return(true); } handler = CreateAnnotationHandler(null); return(true); }
public bool IsCousins(TreeNode root, int x, int y) { Queue <AnnotationNode> queue = new Queue <AnnotationNode>(); AnnotationNode tempNode = null; TreeNode parentX = null, parentY = null; int count = 1; bool foundX = false, foundY = false; if (root == null) { return(false); } queue.Enqueue(new AnnotationNode(root, null)); while (queue.Count > 0) { count = queue.Count; while (count-- > 0) { tempNode = queue.Dequeue(); if (tempNode.Node.val == x) { parentX = tempNode.ParentNode; foundX = true; } else if (tempNode.Node.val == y) { parentY = tempNode.ParentNode; foundY = true; } if (tempNode.Node.left != null) { queue.Enqueue(new AnnotationNode(tempNode.Node.left, tempNode.Node)); } if (tempNode.Node.right != null) { queue.Enqueue(new AnnotationNode(tempNode.Node.right, tempNode.Node)); } if (parentX != parentY && foundX && foundY) { return(true); } } parentX = null; parentY = null; foundX = false; foundY = false; } return(false); }
/// <summary> /// Visits the Annotation node. /// </summary> /// <param name="node">The node to visit.</param> public override bool VisitAnnotation(AnnotationNode node) { if (node.AnnotatedNode == null) return false; if (node.Key == null) return false; if (node.Value == null) return false; return true; }
public IList <IList <int> > VerticalTraversal(TreeNode root) { if (root == null) { return(new List <IList <int> >()); } SortedList <int, List <int> > result = new SortedList <int, List <int> >(); Queue <AnnotationNode> queue = new Queue <AnnotationNode>(); int count = 0; queue.Enqueue(new AnnotationNode(root, 0, 0)); while (queue.Count != 0) { count = queue.Count; Dictionary <int, SortedSet <int> > dictionary = new Dictionary <int, SortedSet <int> >(); while (count-- > 0) { AnnotationNode annotationNode = queue.Dequeue(); if (!dictionary.Keys.Contains(annotationNode.X)) { dictionary.Add(annotationNode.X, new SortedSet <int>()); } dictionary[annotationNode.X].Add(annotationNode.Node.val); if (annotationNode.Node.left != null) { queue.Enqueue(new AnnotationNode(annotationNode.Node.left, annotationNode.X - 1, annotationNode.Y - 1)); } if (annotationNode.Node.right != null) { queue.Enqueue(new AnnotationNode(annotationNode.Node.right, annotationNode.X + 1, annotationNode.Y - 1)); } } foreach (var item in dictionary) { if (!result.Keys.Contains(item.Key)) { result.Add(item.Key, new List <int>()); } result[item.Key].AddRange(item.Value.ToList <int>()); } } return(result.Values.ToList <IList <int> >()); }
public RuntimeVisibleAnnotationsAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope) { var attribute = new RuntimeVisibleAnnotationsAttribute(); var annotationsCount = Binary.BigEndian.ReadUInt16(attributeDataStream); attribute.Annotations.Capacity = annotationsCount; for (var i = 0; i < annotationsCount; i++) { attribute.Annotations.Add(AnnotationNode.Parse(attributeDataStream, readerState)); } return(attribute); }
/// <summary> /// 创建注记实体 /// </summary> /// <param name="pITable">数据表对象</param> /// <param name="entinyNode">VCT空间实体节点</param> public override void CreateFeature(ITable pITable, EntityNode entinyNode) { try { AnnotationNode pAnnotationNode = entinyNode as AnnotationNode; if (pAnnotationNode != null) { IFeatureClass pFeatureCls = pITable as IFeatureClass; this.Feature = pFeatureCls.CreateFeature(); ///标识码赋值 int dBSMIndex = -1; dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled); if (dBSMIndex != -1) this.Feature.set_Value(dBSMIndex, pAnnotationNode.EntityID); ///要素代码赋值 int dSYDMIndex = -1; dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField); if (dSYDMIndex != -1) this.Feature.set_Value(dSYDMIndex, pAnnotationNode.FeatureCode); IAnnotationFeature pAnnotationFeature = Feature as IAnnotationFeature; if (pAnnotationFeature != null) { /////注记内容赋值 ITextElement pTextElement = new TextElementClass(); ITextSymbol pTextSymbol = new TextSymbolClass(); pTextSymbol.Angle = pAnnotationNode.Angle; pTextElement.Text = pAnnotationNode.Text; pTextElement.Symbol = pTextSymbol; pAnnotationFeature.Annotation = pTextElement as IElement; } IPoint pPoint = new PointClass(); pPoint.PutCoords(pAnnotationNode.PointLocation.X, pAnnotationNode.PointLocation.Y); (this.Feature as IFeature).Shape = pPoint; this.Feature.Store(); } } catch (Exception ex) { Logger.WriteErrorLog(ex); } }
protected virtual AnnotationNode ParseAnnotation(InterchangeElementNode nodeForAnnotation) { // TODO : Move constants out of code into a the InterchangeFormatConstants class // TODO : Move error messages out of code into a the InterchangeFormatErrors class // PARSE: <annotation> ::= ’Annotation’ ’key:’ quotedString ’value:’ quotedString <elementSeparator> AnnotationNode result = this.CreateAnnotationNode(nodeForAnnotation); Token token = this.GetNextTokenxx(); StringToken str = token as StringToken; if (str == null) { this.ReportParserError(result, "Missing annotation key.", token); } result.Key = str; token = this.GetNextTokenxx(); KeywordToken cmd = token as KeywordToken; if ((cmd == null) || (cmd.Value != "value:")) { this.ReportParserError("Missing annotation #value: keyword.", token); } token = this.GetNextTokenxx(); str = token as StringToken; if (str == null) { this.ReportParserError(result, "Missing annotation value.", token); } result.Value = str; token = this.GetNextTokenxx(); if (!(token is EofToken)) { this.ReportParserError(result, "Unexpected code found after annotation value.", token); result.Key = null; // This is to avoid something like: Annotation key: 'x' value: 'y' crash: 'yes'. result.Value = null; // This is to avoid something like: Annotation key: 'x' value: 'y' crash: 'yes'. return(result); } return(result); }
/// <summary> /// 获取VCT注记实体节点 /// </summary> public override EntityNode GetEntityNode() { try { AnnotationNode pAnnotationNode = new AnnotationNode(); //特征类型统一设置为单点注记 pAnnotationNode.AnnotationType = Convert.ToInt32(Metadata.MetaDataFile.GraphConfig.GetGraphSymbol("ANNOTATIONFEATURETYPE", "SingPointAnnotation")); IFeature pFeature = this.Feature as IFeature; if (pFeature != null) { ///标识码赋值 int dBSMIndex = -1; dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled); if (dBSMIndex != -1) pAnnotationNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex)); ///要素代码赋值 pAnnotationNode.FeatureCode = this.FeatureCode; ///图形表现赋值 //pAnnotationNode.Representation = pFeature.Class.AliasName; ///注记坐标赋值 IGeometry5 pArea = pFeature.Shape as IGeometry5; if (pArea != null) { PointInfoNode pPTInfoNode = new PointInfoNode(pArea.CentroidEx.X, pArea.CentroidEx.Y); pAnnotationNode.PointLocation = pPTInfoNode; } m_AnnotationNode = pAnnotationNode; return pAnnotationNode; } return null; } catch (Exception ex) { Logger.WriteErrorLog(ex); return null; } }
public RuntimeVisibleParameterAnnotationsAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope) { var attribute = new RuntimeVisibleParameterAnnotationsAttribute(); var parametersCount = attributeDataStream.ReadByteFully(); attribute.Parameters.Capacity = parametersCount; for (var i = 0; i < parametersCount; i++) { var parameter = new ParameterAnnotations(); var annotationsCount = Binary.BigEndian.ReadUInt16(attributeDataStream); parameter.Annotations.Capacity = annotationsCount; for (var j = 0; j < annotationsCount; j++) { parameter.Annotations.Add(AnnotationNode.Parse(attributeDataStream, readerState)); } attribute.Parameters.Add(parameter); } return(attribute); }
public static string GetAnnotation(XmlSchemaAnnotated a, AnnotationNode node, string language) { XmlSchemaAnnotation ann = a.Annotation; if (ann == null) { return(null); } string filter = node.ToString().ToLowerInvariant(); if (filter == "default") { filter = ""; } string result = GetMarkup(ann, filter, language); if (!string.IsNullOrEmpty(result)) { return(result); } return(GetMarkup(ann, null, language)); }
public static string GetAnnotation(XmlSchemaAnnotated a, AnnotationNode node, string language) { XmlSchemaAnnotation ann = a.Annotation; if (ann == null) return null; string filter = node.ToString().ToLowerInvariant(); if (filter == "default") filter = ""; string result = GetMarkup(ann, filter, language); if (!string.IsNullOrEmpty(result)) return result; return GetMarkup(ann, null, language); }
public BtStatus Execute() { AnnotationNode.Execute(); return(Child.Execute()); }
/// <summary> /// Visits the Annotation node. /// </summary> /// <param name="node">The node to visit.</param> public virtual TResult VisitAnnotation(AnnotationNode node) { return(default(TResult)); // The default naive implementation }